editor.main.js 5.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090
  1. /*!-----------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Version: 0.20.0(6363745c0a33c27b149b89342a7b96d354fb554c)
  4. * Released under the MIT license
  5. * https://github.com/Microsoft/vscode/blob/master/LICENSE.txt
  6. *-----------------------------------------------------------*/
  7. (function() {
  8. var __m = ["require","exports","vs/base/common/lifecycle","vs/editor/common/core/range","vs/base/common/event","vs/base/common/strings","vs/base/browser/dom","vs/nls","vs/nls!vs/editor/editor.main","vs/css!vs/editor/editor.main","vs/base/common/errors","vs/platform/instantiation/common/instantiation","vs/editor/browser/editorExtensions","vs/editor/common/core/position","vs/platform/theme/common/themeService","vs/base/common/async","vs/base/common/platform","vs/editor/common/modes","vs/platform/contextkey/common/contextkey","vs/base/common/arrays","vs/platform/theme/common/colorRegistry","vs/base/common/types","vs/editor/common/core/selection","vs/editor/common/editorContextKeys","vs/base/browser/browser","vs/base/common/uri","vs/base/common/cancellation","vs/base/common/color","vs/base/browser/fastDomNode","vs/platform/commands/common/commands","vs/editor/common/model/textModel","vs/base/common/objects","vs/editor/browser/services/codeEditorService","vs/editor/common/config/editorOptions","vs/platform/keybinding/common/keybinding","vs/platform/notification/common/notification","vs/base/common/keyCodes","vs/editor/browser/view/viewPart","vs/base/common/map","vs/base/common/resources","vs/editor/common/controller/cursorCommon","vs/editor/common/modes/languageConfigurationRegistry","vs/platform/registry/common/platform","vs/platform/configuration/common/configuration","vs/editor/common/view/editorColorRegistry","vs/base/browser/mouseEvent","vs/base/common/network","vs/base/browser/ui/widget","vs/editor/common/model","vs/editor/common/services/modelService","vs/base/browser/ui/aria/aria","vs/platform/opener/common/opener","vs/base/browser/event","vs/base/browser/ui/scrollbar/scrollableElement","vs/base/common/iterator","vs/base/common/actions","vs/base/browser/keyboardEvent","vs/base/browser/touch","vs/editor/common/core/editOperation","vs/editor/common/standaloneStrings","vs/editor/browser/config/configuration","vs/base/common/filters","vs/editor/common/services/editorWorkerService","vs/editor/common/modes/nullMode","vs/platform/accessibility/common/accessibility","vs/platform/actions/common/actions","vs/platform/contextview/browser/contextView","vs/editor/browser/core/editorState","vs/editor/common/editorCommon","vs/editor/common/viewModel/viewModel","vs/base/browser/ui/actionbar/actionbar","vs/editor/common/services/modeService","vs/platform/markers/common/markers","vs/platform/progress/common/progress","vs/platform/storage/common/storage","vs/base/common/htmlContent","vs/base/common/linkedList","vs/base/common/path","vs/base/browser/globalMouseMoveMonitor","vs/editor/common/core/characterClassifier","vs/editor/common/commands/replaceCommand","vs/editor/common/view/viewEvents","vs/editor/browser/view/dynamicViewOverlay","vs/platform/instantiation/common/extensions","vs/editor/common/services/resolverService","vs/platform/configuration/common/configurationRegistry","vs/platform/keybinding/common/keybindingsRegistry","vs/base/common/collections","vs/base/browser/canIUse","vs/editor/common/controller/wordCharacterClassifier","vs/editor/common/modes/languageConfiguration","vs/editor/common/view/renderingContext","vs/editor/common/viewModel/viewEventHandler","vs/editor/common/core/lineTokens","vs/editor/standalone/common/standaloneThemeService","vs/platform/log/common/log","vs/platform/telemetry/common/telemetry","vs/platform/theme/common/styler","vs/base/browser/dnd","vs/base/browser/ui/tree/tree","vs/base/common/codicons","vs/base/common/decorators","vs/base/common/functional","vs/base/common/range","vs/base/browser/ui/sash/sash","vs/editor/common/config/editorZoom","vs/editor/common/core/stringBuilder","vs/editor/common/core/token","vs/editor/browser/editorBrowser","vs/editor/common/model/wordHelper","vs/editor/common/viewLayout/viewLineRenderer","vs/editor/contrib/codeAction/types","vs/base/common/severity","vs/editor/contrib/gotoSymbol/referencesModel","vs/editor/common/services/textResourceConfigurationService","vs/platform/instantiation/common/serviceCollection","vs/platform/label/common/label","vs/editor/contrib/markdown/markdownRenderer","vs/editor/common/modes/modesRegistry","vs/editor/contrib/codeAction/codeAction","vs/editor/contrib/suggest/suggest","vs/editor/browser/widget/codeEditorWidget","vs/editor/contrib/message/messageController","vs/editor/contrib/peekView/peekView","vs/base/common/assert","vs/base/common/hash","vs/base/common/diff/diff","vs/base/common/idGenerator","vs/base/common/lazy","vs/base/browser/ui/tree/indexTreeModel","vs/base/browser/ui/tree/objectTreeModel","vs/base/common/numbers","vs/base/common/stopwatch","vs/base/browser/ui/highlightedlabel/highlightedLabel","vs/base/browser/formattedTextRenderer","vs/base/browser/ui/scrollbar/scrollbarArrow","vs/base/common/labels","vs/base/parts/tree/browser/treeDefaults","vs/base/browser/ui/checkbox/checkbox","vs/base/browser/ui/iconLabel/iconLabel","vs/base/browser/ui/list/listView","vs/editor/browser/editorDom","vs/editor/common/config/fontInfo","vs/editor/browser/view/viewLayer","vs/editor/common/model/textModelSearch","vs/editor/common/modes/supports","vs/editor/common/modes/supports/richEditBrackets","vs/editor/common/standalone/standaloneEnums","vs/editor/common/viewLayout/lineDecorations","vs/editor/browser/viewParts/glyphMargin/glyphMargin","vs/editor/contrib/folding/foldingRanges","vs/editor/contrib/snippet/snippetParser","vs/base/browser/ui/inputbox/inputBox","vs/base/browser/ui/list/listWidget","vs/base/browser/ui/tree/abstractTree","vs/base/parts/quickopen/browser/quickOpenModel","vs/editor/browser/services/bulkEditService","vs/editor/common/model/tokensStore","vs/editor/common/controller/cursorMoveOperations","vs/editor/common/controller/cursorTypeOperations","vs/editor/common/controller/cursorWordOperations","vs/editor/common/viewModel/splitLinesCollection","vs/platform/clipboard/common/clipboardService","vs/editor/common/config/commonEditorConfig","vs/editor/browser/controller/coreCommands","vs/editor/contrib/parameterHints/provideSignatureHelp","vs/editor/browser/controller/mouseTarget","vs/editor/browser/widget/embeddedCodeEditorWidget","vs/editor/contrib/find/findModel","vs/editor/standalone/browser/quickOpen/editorQuickOpen","vs/platform/list/browser/listService","vs/platform/workspace/common/workspace","vs/editor/standalone/browser/simpleServices","vs/editor/contrib/snippet/snippetController2","vs/base/browser/iframe","vs/base/browser/ui/scrollbar/scrollbarState","vs/base/common/scrollable","vs/base/common/extpath","vs/base/common/glob","vs/base/common/uint","vs/base/common/marshalling","vs/base/browser/ui/scrollbar/abstractScrollbar","vs/base/common/worker/simpleWorker","vs/base/browser/ui/codiconLabel/codiconLabel","vs/css!vs/base/browser/ui/findinput/findInput","vs/editor/browser/config/elementSizeObserver","vs/editor/browser/viewParts/minimap/minimapCharSheet","vs/editor/browser/controller/textAreaState","vs/editor/browser/widget/diffNavigator","vs/editor/browser/controller/textAreaInput","vs/editor/common/editorAction","vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase","vs/editor/common/standalone/standaloneBase","vs/editor/common/view/overviewZoneManager","vs/editor/common/viewModel/prefixSumComputer","vs/editor/browser/viewParts/margin/margin","vs/editor/contrib/comment/blockCommentCommand","vs/editor/contrib/folding/syntaxRangeProvider","vs/editor/contrib/format/formattingEdit","vs/editor/contrib/gotoSymbol/link/clickLinkGesture","vs/editor/contrib/hover/hoverOperation","vs/editor/contrib/hover/hoverWidgets","vs/editor/contrib/smartSelect/bracketSelections","vs/editor/standalone/common/monarch/monarchCommon","vs/base/browser/ui/findinput/findInputCheckboxes","vs/base/browser/ui/menu/menu","vs/base/browser/ui/tree/objectTree","vs/base/common/keybindingLabels","vs/platform/files/common/files","vs/platform/instantiation/common/descriptors","vs/editor/common/services/markersDecorationService","vs/editor/common/commands/shiftCommand","vs/editor/common/controller/cursorDeleteOperations","vs/editor/common/controller/cursorMoveCommands","vs/editor/common/modes/textToHtmlTokenizer","vs/editor/common/viewModel/minimapTokensColorTracker","vs/editor/standalone/common/monarch/monarchLexer","vs/platform/keybinding/common/keybindingResolver","vs/platform/layout/browser/layoutService","vs/editor/common/services/editorWorkerServiceImpl","vs/platform/jsonschemas/common/jsonContributionRegistry","vs/editor/contrib/codelens/codelens","vs/editor/contrib/colorPicker/color","vs/editor/contrib/colorPicker/colorDetector","vs/editor/contrib/gotoSymbol/goToSymbol","vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode","vs/editor/contrib/wordOperations/wordOperations","vs/editor/browser/viewParts/lines/viewLine","vs/editor/browser/view/viewOutgoingEvents","vs/editor/browser/viewParts/lineNumbers/lineNumbers","vs/editor/browser/widget/diffEditorWidget","vs/editor/contrib/documentSymbols/outlineTree","vs/editor/contrib/find/findController","vs/editor/contrib/codeAction/codeActionCommands","vs/editor/contrib/gotoSymbol/peek/referencesController","vs/editor/contrib/gotoSymbol/goToCommands","vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition","vs/editor/contrib/gotoError/gotoError","vs/editor/standalone/browser/standaloneServices","vs/base/browser/ui/list/list","vs/base/browser/ui/list/splice","vs/base/common/diff/diffChange","vs/base/common/history","vs/base/browser/ui/tree/compressedObjectTreeModel","vs/base/browser/ui/scrollbar/scrollbarVisibilityController","vs/base/common/process","vs/base/browser/ui/list/rangeMap","vs/base/common/search","vs/base/browser/markdownRenderer","vs/base/browser/ui/list/rowCache","vs/base/browser/ui/scrollbar/horizontalScrollbar","vs/base/browser/ui/scrollbar/verticalScrollbar","vs/base/common/mime","vs/base/parts/quickopen/browser/quickOpenViewer","vs/base/parts/tree/browser/tree","vs/base/parts/tree/browser/treeDnd","vs/base/parts/tree/browser/treeModel","vs/base/parts/tree/browser/treeViewModel","vs/base/worker/defaultWorkerFactory","vs/css!vs/base/browser/ui/actionbar/actionbar","vs/css!vs/base/browser/ui/aria/aria","vs/css!vs/base/browser/ui/checkbox/checkbox","vs/css!vs/base/browser/ui/codiconLabel/codicon/codicon","vs/css!vs/base/browser/ui/codiconLabel/codicon/codicon-animations","vs/css!vs/base/browser/ui/contextview/contextview","vs/base/browser/ui/contextview/contextview","vs/css!vs/base/browser/ui/countBadge/countBadge","vs/base/browser/ui/countBadge/countBadge","vs/css!vs/base/browser/ui/iconLabel/iconlabel","vs/css!vs/base/browser/ui/inputbox/inputBox","vs/css!vs/base/browser/ui/keybindingLabel/keybindingLabel","vs/css!vs/base/browser/ui/list/list","vs/css!vs/base/browser/ui/menu/menu","vs/css!vs/base/browser/ui/progressbar/progressbar","vs/base/browser/ui/progressbar/progressbar","vs/css!vs/base/browser/ui/sash/sash","vs/css!vs/base/browser/ui/scrollbar/media/scrollbars","vs/base/parts/tree/browser/treeView","vs/css!vs/base/browser/ui/splitview/splitview","vs/base/browser/ui/splitview/splitview","vs/css!vs/base/browser/ui/tree/media/tree","vs/css!vs/base/parts/quickopen/browser/quickopen","vs/css!vs/base/parts/tree/browser/tree","vs/base/parts/tree/browser/treeImpl","vs/css!vs/editor/browser/controller/textAreaHandler","vs/css!vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight","vs/css!vs/editor/browser/viewParts/decorations/decorations","vs/css!vs/editor/browser/viewParts/glyphMargin/glyphMargin","vs/css!vs/editor/browser/viewParts/indentGuides/indentGuides","vs/css!vs/editor/browser/viewParts/lineNumbers/lineNumbers","vs/css!vs/editor/browser/viewParts/lines/viewLines","vs/css!vs/editor/browser/viewParts/linesDecorations/linesDecorations","vs/css!vs/editor/browser/viewParts/marginDecorations/marginDecorations","vs/css!vs/editor/browser/viewParts/minimap/minimap","vs/css!vs/editor/browser/viewParts/overlayWidgets/overlayWidgets","vs/css!vs/editor/browser/viewParts/rulers/rulers","vs/css!vs/editor/browser/viewParts/scrollDecoration/scrollDecoration","vs/css!vs/editor/browser/viewParts/selections/selections","vs/css!vs/editor/browser/viewParts/viewCursors/viewCursors","vs/css!vs/editor/browser/widget/media/diffEditor","vs/css!vs/editor/browser/widget/media/diffReview","vs/css!vs/editor/browser/widget/media/editor","vs/css!vs/editor/contrib/bracketMatching/bracketMatching","vs/css!vs/editor/contrib/clipboard/clipboard","vs/css!vs/editor/contrib/codeAction/lightBulbWidget","vs/css!vs/editor/contrib/codelens/codelensWidget","vs/css!vs/editor/contrib/colorPicker/colorPicker","vs/css!vs/editor/contrib/dnd/dnd","vs/css!vs/editor/contrib/documentSymbols/media/outlineTree","vs/css!vs/editor/contrib/documentSymbols/media/symbol-icons","vs/css!vs/editor/contrib/find/findWidget","vs/css!vs/editor/contrib/folding/folding","vs/css!vs/editor/contrib/gotoError/media/gotoErrorWidget","vs/css!vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition","vs/css!vs/editor/contrib/gotoSymbol/peek/referencesWidget","vs/css!vs/editor/contrib/hover/hover","vs/css!vs/editor/contrib/links/links","vs/css!vs/editor/contrib/message/messageController","vs/css!vs/editor/contrib/parameterHints/parameterHints","vs/css!vs/editor/contrib/peekView/media/peekViewWidget","vs/css!vs/editor/contrib/rename/renameInputField","vs/css!vs/editor/contrib/snippet/snippetSession","vs/css!vs/editor/contrib/suggest/media/suggest","vs/css!vs/editor/contrib/suggest/media/suggestStatusBar","vs/css!vs/editor/contrib/zoneWidget/zoneWidget","vs/css!vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp","vs/css!vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard","vs/css!vs/editor/standalone/browser/inspectTokens/inspectTokens","vs/css!vs/editor/standalone/browser/quickOpen/editorQuickOpen","vs/css!vs/editor/standalone/browser/quickOpen/gotoLine","vs/css!vs/editor/standalone/browser/quickOpen/quickOutline","vs/css!vs/editor/standalone/browser/standalone-tokens","vs/css!vs/platform/contextview/browser/contextMenuHandler","vs/editor/browser/config/charWidthReader","vs/editor/browser/services/abstractCodeEditorService","vs/editor/browser/viewParts/minimap/minimapCharRenderer","vs/editor/browser/viewParts/minimap/minimapPreBaked","vs/editor/browser/viewParts/minimap/minimapCharRendererFactory","vs/editor/common/commands/trimTrailingWhitespaceCommand","vs/editor/common/core/rgba","vs/editor/common/commands/surroundSelectionCommand","vs/editor/common/diff/diffComputer","vs/editor/common/model/editStack","vs/editor/common/model/indentationGuesser","vs/editor/common/model/intervalTree","vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase","vs/editor/common/model/textModelEvents","vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer","vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder","vs/editor/common/modes/abstractMode","vs/editor/common/modes/languageSelector","vs/editor/common/modes/linkComputer","vs/editor/common/modes/supports/characterPair","vs/editor/common/modes/supports/indentRules","vs/editor/common/modes/supports/inplaceReplaceSupport","vs/editor/common/modes/supports/onEnter","vs/editor/common/modes/supports/electricCharacter","vs/editor/common/modes/supports/tokenization","vs/editor/common/modes/tokenizationRegistry","vs/editor/browser/viewParts/lines/rangeUtil","vs/editor/common/view/viewContext","vs/editor/common/view/viewEventDispatcher","vs/editor/common/viewLayout/linesLayout","vs/editor/common/viewLayout/viewLinesViewportData","vs/editor/common/model/mirrorTextModel","vs/editor/common/services/editorSimpleWorker","vs/editor/browser/viewParts/contentWidgets/contentWidgets","vs/editor/browser/viewParts/decorations/decorations","vs/editor/browser/viewParts/linesDecorations/linesDecorations","vs/editor/browser/viewParts/marginDecorations/marginDecorations","vs/editor/browser/viewParts/overlayWidgets/overlayWidgets","vs/editor/browser/viewParts/overviewRuler/overviewRuler","vs/editor/browser/viewParts/viewZones/viewZones","vs/editor/common/viewLayout/viewLayout","vs/editor/contrib/caretOperations/moveCaretCommand","vs/editor/contrib/colorPicker/colorPickerModel","vs/editor/contrib/comment/lineCommentCommand","vs/editor/contrib/dnd/dragAndDropCommand","vs/editor/contrib/find/findState","vs/editor/contrib/find/replaceAllCommand","vs/editor/contrib/find/replacePattern","vs/editor/contrib/folding/foldingModel","vs/editor/contrib/folding/hiddenRangeModel","vs/editor/contrib/folding/intializingRangeProvider","vs/editor/contrib/inPlaceReplace/inPlaceReplaceCommand","vs/editor/contrib/indentation/indentUtils","vs/editor/contrib/linesOperations/copyLinesCommand","vs/editor/contrib/linesOperations/sortLinesCommand","vs/editor/contrib/smartSelect/wordSelections","vs/editor/contrib/suggest/completionModel","vs/editor/contrib/suggest/suggestCommitCharacters","vs/editor/contrib/suggest/suggestRangeHighlighter","vs/editor/contrib/suggest/wordDistance","vs/editor/standalone/common/monarch/monarchCompile","vs/nls!vs/base/browser/ui/actionbar/actionbar","vs/nls!vs/base/browser/ui/aria/aria","vs/nls!vs/base/browser/ui/findinput/findInput","vs/nls!vs/base/browser/ui/findinput/findInputCheckboxes","vs/nls!vs/base/browser/ui/findinput/replaceInput","vs/nls!vs/base/browser/ui/inputbox/inputBox","vs/base/browser/ui/findinput/findInput","vs/base/browser/ui/findinput/replaceInput","vs/nls!vs/base/browser/ui/keybindingLabel/keybindingLabel","vs/nls!vs/base/browser/ui/list/listWidget","vs/nls!vs/base/browser/ui/menu/menu","vs/base/browser/contextmenu","vs/nls!vs/base/browser/ui/tree/abstractTree","vs/base/browser/ui/tree/dataTree","vs/base/browser/ui/tree/asyncDataTree","vs/nls!vs/base/common/keybindingLabels","vs/base/browser/ui/keybindingLabel/keybindingLabel","vs/nls!vs/base/common/severity","vs/nls!vs/base/parts/quickopen/browser/quickOpenModel","vs/nls!vs/base/parts/quickopen/browser/quickOpenWidget","vs/base/parts/quickopen/browser/quickOpenWidget","vs/nls!vs/editor/browser/controller/coreCommands","vs/nls!vs/editor/browser/controller/textAreaHandler","vs/nls!vs/editor/browser/widget/codeEditorWidget","vs/nls!vs/editor/browser/widget/diffEditorWidget","vs/nls!vs/editor/browser/widget/diffReview","vs/nls!vs/editor/browser/widget/inlineDiffMargin","vs/editor/browser/widget/inlineDiffMargin","vs/nls!vs/editor/common/config/commonEditorConfig","vs/nls!vs/editor/common/config/editorOptions","vs/editor/common/viewModel/viewModelDecorations","vs/nls!vs/editor/common/modes/modesRegistry","vs/nls!vs/editor/common/standaloneStrings","vs/nls!vs/editor/common/view/editorColorRegistry","vs/nls!vs/editor/contrib/bracketMatching/bracketMatching","vs/nls!vs/editor/contrib/caretOperations/caretOperations","vs/nls!vs/editor/contrib/caretOperations/transpose","vs/nls!vs/editor/contrib/clipboard/clipboard","vs/nls!vs/editor/contrib/codeAction/codeActionCommands","vs/nls!vs/editor/contrib/codeAction/lightBulbWidget","vs/nls!vs/editor/contrib/comment/comment","vs/nls!vs/editor/contrib/contextmenu/contextmenu","vs/nls!vs/editor/contrib/cursorUndo/cursorUndo","vs/nls!vs/editor/contrib/documentSymbols/outlineTree","vs/nls!vs/editor/contrib/find/findController","vs/nls!vs/editor/contrib/find/findWidget","vs/nls!vs/editor/contrib/folding/folding","vs/nls!vs/editor/contrib/fontZoom/fontZoom","vs/nls!vs/editor/contrib/format/format","vs/nls!vs/editor/contrib/format/formatActions","vs/nls!vs/editor/contrib/gotoError/gotoError","vs/nls!vs/editor/contrib/gotoError/gotoErrorWidget","vs/nls!vs/editor/contrib/gotoSymbol/goToCommands","vs/nls!vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition","vs/nls!vs/editor/contrib/gotoSymbol/peek/referencesController","vs/nls!vs/editor/contrib/gotoSymbol/peek/referencesTree","vs/nls!vs/editor/contrib/gotoSymbol/peek/referencesWidget","vs/nls!vs/editor/contrib/gotoSymbol/referencesModel","vs/nls!vs/editor/contrib/gotoSymbol/symbolNavigation","vs/nls!vs/editor/contrib/hover/hover","vs/nls!vs/editor/contrib/hover/modesContentHover","vs/nls!vs/editor/contrib/inPlaceReplace/inPlaceReplace","vs/nls!vs/editor/contrib/linesOperations/linesOperations","vs/nls!vs/editor/contrib/links/links","vs/nls!vs/editor/contrib/message/messageController","vs/nls!vs/editor/contrib/multicursor/multicursor","vs/nls!vs/editor/contrib/parameterHints/parameterHints","vs/nls!vs/editor/contrib/parameterHints/parameterHintsWidget","vs/nls!vs/editor/contrib/peekView/peekView","vs/nls!vs/editor/contrib/rename/rename","vs/nls!vs/editor/contrib/rename/renameInputField","vs/nls!vs/editor/contrib/smartSelect/smartSelect","vs/nls!vs/editor/contrib/snippet/snippetVariables","vs/nls!vs/editor/contrib/suggest/suggestController","vs/nls!vs/editor/contrib/suggest/suggestWidget","vs/nls!vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode","vs/nls!vs/editor/contrib/tokenization/tokenization","vs/nls!vs/editor/contrib/wordHighlighter/wordHighlighter","vs/nls!vs/platform/configuration/common/configurationRegistry","vs/nls!vs/platform/keybinding/common/abstractKeybindingService","vs/nls!vs/platform/list/browser/listService","vs/nls!vs/platform/markers/common/markers","vs/nls!vs/platform/theme/common/colorRegistry","vs/platform/contextkey/common/contextkeys","vs/platform/editor/common/editor","vs/platform/extensions/common/extensions","vs/platform/instantiation/common/graph","vs/editor/common/modes/languageFeatureRegistry","vs/editor/common/model/textModelTokens","vs/editor/common/controller/cursorColumnSelection","vs/editor/common/controller/oneCursor","vs/editor/common/controller/cursorCollection","vs/editor/common/controller/cursor","vs/editor/common/viewModel/monospaceLineBreaksComputer","vs/editor/common/viewModel/viewModelImpl","vs/editor/contrib/documentSymbols/outlineModel","vs/editor/contrib/folding/foldingDecorations","vs/editor/contrib/folding/indentRangeProvider","vs/editor/contrib/linesOperations/moveLinesCommand","vs/editor/contrib/zoneWidget/zoneWidget","vs/editor/standalone/browser/colorizer","vs/editor/contrib/links/getLinks","vs/editor/contrib/quickOpen/quickOpen","vs/editor/contrib/suggest/suggestAlternatives","vs/editor/contrib/suggest/wordContextKey","vs/platform/actions/common/menuService","vs/platform/dialogs/common/dialogs","vs/platform/instantiation/common/instantiationService","vs/platform/keybinding/common/abstractKeybindingService","vs/platform/keybinding/common/baseResolvedKeybinding","vs/platform/keybinding/common/resolvedKeybindingItem","vs/platform/keybinding/common/usLayoutResolvedKeybinding","vs/platform/contextview/browser/contextViewService","vs/editor/common/services/webWorker","vs/platform/markers/common/markerService","vs/editor/browser/services/openerService","vs/editor/contrib/hover/modesGlyphHover","vs/editor/common/services/getIconClasses","vs/editor/browser/view/domLineBreaksComputer","vs/editor/browser/view/viewOverlays","vs/editor/browser/viewParts/viewCursors/viewCursor","vs/editor/common/services/languagesRegistry","vs/editor/common/services/modeServiceImpl","vs/platform/accessibility/common/accessibilityService","vs/platform/configuration/common/configurationModels","vs/platform/contextkey/browser/contextKeyService","vs/platform/browser/contextScopedHistoryWidget","vs/editor/contrib/suggest/suggestMemory","vs/editor/browser/core/keybindingCancellation","vs/editor/browser/view/viewController","vs/editor/contrib/caretOperations/caretOperations","vs/editor/contrib/caretOperations/transpose","vs/editor/contrib/clipboard/clipboard","vs/editor/contrib/codeAction/codeActionMenu","vs/editor/contrib/codeAction/codeActionModel","vs/editor/contrib/codelens/codeLensCache","vs/editor/contrib/comment/comment","vs/editor/contrib/contextmenu/contextmenu","vs/editor/contrib/cursorUndo/cursorUndo","vs/editor/contrib/dnd/dnd","vs/editor/contrib/fontZoom/fontZoom","vs/editor/contrib/format/format","vs/editor/contrib/format/formatActions","vs/editor/contrib/gotoSymbol/symbolNavigation","vs/editor/contrib/hover/getHover","vs/editor/contrib/linesOperations/linesOperations","vs/editor/contrib/parameterHints/parameterHintsModel","vs/editor/contrib/smartSelect/smartSelect","vs/editor/contrib/tokenization/tokenization","vs/editor/contrib/wordPartOperations/wordPartOperations","vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard","vs/editor/standalone/browser/toggleHighContrast/toggleHighContrast","vs/editor/standalone/browser/quickOpen/quickOpenEditorWidget","vs/platform/contextview/browser/contextMenuHandler","vs/editor/browser/services/codeEditorServiceImpl","vs/editor/browser/viewParts/editorScrollbar/editorScrollbar","vs/editor/browser/controller/mouseHandler","vs/editor/browser/controller/pointerHandler","vs/editor/browser/viewParts/lines/viewLines","vs/editor/browser/viewParts/minimap/minimap","vs/editor/browser/viewParts/scrollDecoration/scrollDecoration","vs/editor/browser/viewParts/selections/selections","vs/editor/common/services/modelServiceImpl","vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight","vs/editor/browser/viewParts/indentGuides/indentGuides","vs/editor/browser/controller/textAreaHandler","vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler","vs/editor/browser/viewParts/rulers/rulers","vs/editor/browser/viewParts/viewCursors/viewCursors","vs/editor/browser/view/viewImpl","vs/editor/browser/widget/diffReview","vs/editor/common/services/markerDecorationsServiceImpl","vs/editor/contrib/bracketMatching/bracketMatching","vs/editor/contrib/codeAction/lightBulbWidget","vs/editor/contrib/codelens/codelensWidget","vs/editor/contrib/codelens/codelensController","vs/editor/contrib/colorPicker/colorPickerWidget","vs/editor/contrib/find/findDecorations","vs/editor/contrib/find/findOptionsWidget","vs/editor/contrib/find/findWidget","vs/editor/contrib/folding/folding","vs/editor/contrib/gotoSymbol/peek/referencesTree","vs/editor/contrib/inPlaceReplace/inPlaceReplace","vs/editor/contrib/links/links","vs/editor/contrib/codeAction/codeActionUi","vs/editor/contrib/codeAction/codeActionContributions","vs/editor/contrib/multicursor/multicursor","vs/editor/contrib/parameterHints/parameterHintsWidget","vs/editor/contrib/parameterHints/parameterHints","vs/editor/contrib/rename/renameInputField","vs/editor/contrib/rename/rename","vs/editor/contrib/suggest/suggestWidget","vs/editor/contrib/wordHighlighter/wordHighlighter","vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp","vs/editor/standalone/browser/inspectTokens/inspectTokens","vs/editor/standalone/browser/quickOpen/gotoLine","vs/editor/standalone/browser/quickOpen/quickCommand","vs/editor/standalone/browser/quickOpen/quickOutline","vs/editor/standalone/browser/standaloneCodeServiceImpl","vs/editor/standalone/common/themes","vs/editor/standalone/browser/standaloneThemeServiceImpl","vs/platform/contextview/browser/contextMenuService","vs/editor/contrib/gotoSymbol/peek/referencesWidget","vs/editor/standalone/browser/referenceSearch/standaloneReferenceSearch","vs/platform/severityIcon/common/severityIcon","vs/editor/contrib/gotoError/gotoErrorWidget","vs/editor/contrib/hover/modesContentHover","vs/editor/contrib/hover/hover","vs/editor/standalone/browser/standaloneCodeEditor","vs/editor/standalone/browser/standaloneEditor","vs/editor/standalone/browser/standaloneLanguages","vs/editor/editor.api","vs/platform/workspaces/common/workspaces","vs/editor/contrib/snippet/snippetVariables","vs/editor/contrib/snippet/snippetSession","vs/editor/contrib/suggest/suggestModel","vs/editor/contrib/suggest/suggestController","vs/editor/editor.all","vs/base/common/marked/marked","vs/base/common/insane/insane","vs/editor/common/standalone/promise-polyfill/polyfill","vs/editor/edcore.main"];
  9. var __M = function(deps) {
  10. var result = [];
  11. for (var i = 0, len = deps.length; i < len; i++) {
  12. result[i] = __m[deps[i]];
  13. }
  14. return result;
  15. };
  16. /*---------------------------------------------------------------------------------------------
  17. * Copyright (c) Microsoft Corporation. All rights reserved.
  18. * Licensed under the MIT License. See License.txt in the project root for license information.
  19. *--------------------------------------------------------------------------------------------*/
  20. /*---------------------------------------------------------------------------------------------
  21. *---------------------------------------------------------------------------------------------
  22. *---------------------------------------------------------------------------------------------
  23. *---------------------------------------------------------------------------------------------
  24. *---------------------------------------------------------------------------------------------
  25. * Please make sure to make edits in the .ts file at https://github.com/Microsoft/vscode-loader/
  26. *---------------------------------------------------------------------------------------------
  27. *---------------------------------------------------------------------------------------------
  28. *---------------------------------------------------------------------------------------------
  29. *---------------------------------------------------------------------------------------------
  30. *--------------------------------------------------------------------------------------------*/
  31. 'use strict';
  32. var CSSLoaderPlugin;
  33. (function (CSSLoaderPlugin) {
  34. /**
  35. * Known issue:
  36. * - In IE there is no way to know if the CSS file loaded successfully or not.
  37. */
  38. var BrowserCSSLoader = /** @class */ (function () {
  39. function BrowserCSSLoader() {
  40. this._pendingLoads = 0;
  41. }
  42. BrowserCSSLoader.prototype.attachListeners = function (name, linkNode, callback, errorback) {
  43. var unbind = function () {
  44. linkNode.removeEventListener('load', loadEventListener);
  45. linkNode.removeEventListener('error', errorEventListener);
  46. };
  47. var loadEventListener = function (e) {
  48. unbind();
  49. callback();
  50. };
  51. var errorEventListener = function (e) {
  52. unbind();
  53. errorback(e);
  54. };
  55. linkNode.addEventListener('load', loadEventListener);
  56. linkNode.addEventListener('error', errorEventListener);
  57. };
  58. BrowserCSSLoader.prototype._onLoad = function (name, callback) {
  59. this._pendingLoads--;
  60. callback();
  61. };
  62. BrowserCSSLoader.prototype._onLoadError = function (name, errorback, err) {
  63. this._pendingLoads--;
  64. errorback(err);
  65. };
  66. BrowserCSSLoader.prototype._insertLinkNode = function (linkNode) {
  67. this._pendingLoads++;
  68. var head = document.head || document.getElementsByTagName('head')[0];
  69. var other = head.getElementsByTagName('link') || document.head.getElementsByTagName('script');
  70. if (other.length > 0) {
  71. head.insertBefore(linkNode, other[other.length - 1]);
  72. }
  73. else {
  74. head.appendChild(linkNode);
  75. }
  76. };
  77. BrowserCSSLoader.prototype.createLinkTag = function (name, cssUrl, externalCallback, externalErrorback) {
  78. var _this = this;
  79. var linkNode = document.createElement('link');
  80. linkNode.setAttribute('rel', 'stylesheet');
  81. linkNode.setAttribute('type', 'text/css');
  82. linkNode.setAttribute('data-name', name);
  83. var callback = function () { return _this._onLoad(name, externalCallback); };
  84. var errorback = function (err) { return _this._onLoadError(name, externalErrorback, err); };
  85. this.attachListeners(name, linkNode, callback, errorback);
  86. linkNode.setAttribute('href', cssUrl);
  87. return linkNode;
  88. };
  89. BrowserCSSLoader.prototype._linkTagExists = function (name, cssUrl) {
  90. var i, len, nameAttr, hrefAttr, links = document.getElementsByTagName('link');
  91. for (i = 0, len = links.length; i < len; i++) {
  92. nameAttr = links[i].getAttribute('data-name');
  93. hrefAttr = links[i].getAttribute('href');
  94. if (nameAttr === name || hrefAttr === cssUrl) {
  95. return true;
  96. }
  97. }
  98. return false;
  99. };
  100. BrowserCSSLoader.prototype.load = function (name, cssUrl, externalCallback, externalErrorback) {
  101. if (this._linkTagExists(name, cssUrl)) {
  102. externalCallback();
  103. return;
  104. }
  105. var linkNode = this.createLinkTag(name, cssUrl, externalCallback, externalErrorback);
  106. this._insertLinkNode(linkNode);
  107. };
  108. return BrowserCSSLoader;
  109. }());
  110. // ------------------------------ Finally, the plugin
  111. var CSSPlugin = /** @class */ (function () {
  112. function CSSPlugin() {
  113. this._cssLoader = new BrowserCSSLoader();
  114. }
  115. CSSPlugin.prototype.load = function (name, req, load) {
  116. var cssUrl = req.toUrl(name + '.css');
  117. this._cssLoader.load(name, cssUrl, function (contents) {
  118. load({});
  119. }, function (err) {
  120. if (typeof load.error === 'function') {
  121. load.error('Could not find ' + cssUrl + ' or it was empty');
  122. }
  123. });
  124. };
  125. return CSSPlugin;
  126. }());
  127. CSSLoaderPlugin.CSSPlugin = CSSPlugin;
  128. define('vs/css', new CSSPlugin());
  129. })(CSSLoaderPlugin || (CSSLoaderPlugin = {}));
  130. /*---------------------------------------------------------------------------------------------
  131. * Copyright (c) Microsoft Corporation. All rights reserved.
  132. * Licensed under the MIT License. See License.txt in the project root for license information.
  133. *--------------------------------------------------------------------------------------------*/
  134. /*---------------------------------------------------------------------------------------------
  135. *---------------------------------------------------------------------------------------------
  136. *---------------------------------------------------------------------------------------------
  137. *---------------------------------------------------------------------------------------------
  138. *---------------------------------------------------------------------------------------------
  139. * Please make sure to make edits in the .ts file at https://github.com/Microsoft/vscode-loader/
  140. *---------------------------------------------------------------------------------------------
  141. *---------------------------------------------------------------------------------------------
  142. *---------------------------------------------------------------------------------------------
  143. *---------------------------------------------------------------------------------------------
  144. *--------------------------------------------------------------------------------------------*/
  145. 'use strict';
  146. var NLSLoaderPlugin;
  147. (function (NLSLoaderPlugin) {
  148. var Environment = /** @class */ (function () {
  149. function Environment() {
  150. this._detected = false;
  151. this._isPseudo = false;
  152. }
  153. Object.defineProperty(Environment.prototype, "isPseudo", {
  154. get: function () {
  155. this._detect();
  156. return this._isPseudo;
  157. },
  158. enumerable: true,
  159. configurable: true
  160. });
  161. Environment.prototype._detect = function () {
  162. if (this._detected) {
  163. return;
  164. }
  165. this._detected = true;
  166. this._isPseudo = (typeof document !== 'undefined' && document.location && document.location.hash.indexOf('pseudo=true') >= 0);
  167. };
  168. return Environment;
  169. }());
  170. function _format(message, args, env) {
  171. var result;
  172. if (args.length === 0) {
  173. result = message;
  174. }
  175. else {
  176. result = message.replace(/\{(\d+)\}/g, function (match, rest) {
  177. var index = rest[0];
  178. var arg = args[index];
  179. var result = match;
  180. if (typeof arg === 'string') {
  181. result = arg;
  182. }
  183. else if (typeof arg === 'number' || typeof arg === 'boolean' || arg === void 0 || arg === null) {
  184. result = String(arg);
  185. }
  186. return result;
  187. });
  188. }
  189. if (env.isPseudo) {
  190. // FF3B and FF3D is the Unicode zenkaku representation for [ and ]
  191. result = '\uFF3B' + result.replace(/[aouei]/g, '$&$&') + '\uFF3D';
  192. }
  193. return result;
  194. }
  195. function findLanguageForModule(config, name) {
  196. var result = config[name];
  197. if (result)
  198. return result;
  199. result = config['*'];
  200. if (result)
  201. return result;
  202. return null;
  203. }
  204. function localize(env, data, message) {
  205. var args = [];
  206. for (var _i = 3; _i < arguments.length; _i++) {
  207. args[_i - 3] = arguments[_i];
  208. }
  209. return _format(message, args, env);
  210. }
  211. function createScopedLocalize(scope, env) {
  212. return function (idx, defaultValue) {
  213. var restArgs = Array.prototype.slice.call(arguments, 2);
  214. return _format(scope[idx], restArgs, env);
  215. };
  216. }
  217. var NLSPlugin = /** @class */ (function () {
  218. function NLSPlugin(env) {
  219. var _this = this;
  220. this._env = env;
  221. this.localize = function (data, message) {
  222. var args = [];
  223. for (var _i = 2; _i < arguments.length; _i++) {
  224. args[_i - 2] = arguments[_i];
  225. }
  226. return localize.apply(void 0, [_this._env, data, message].concat(args));
  227. };
  228. }
  229. NLSPlugin.prototype.setPseudoTranslation = function (value) {
  230. this._env._isPseudo = value;
  231. };
  232. NLSPlugin.prototype.create = function (key, data) {
  233. return {
  234. localize: createScopedLocalize(data[key], this._env)
  235. };
  236. };
  237. NLSPlugin.prototype.load = function (name, req, load, config) {
  238. var _this = this;
  239. config = config || {};
  240. if (!name || name.length === 0) {
  241. load({
  242. localize: this.localize
  243. });
  244. }
  245. else {
  246. var pluginConfig = config['vs/nls'] || {};
  247. var language = pluginConfig.availableLanguages ? findLanguageForModule(pluginConfig.availableLanguages, name) : null;
  248. var suffix = '.nls';
  249. if (language !== null && language !== NLSPlugin.DEFAULT_TAG) {
  250. suffix = suffix + '.' + language;
  251. }
  252. var messagesLoaded_1 = function (messages) {
  253. if (Array.isArray(messages)) {
  254. messages.localize = createScopedLocalize(messages, _this._env);
  255. }
  256. else {
  257. messages.localize = createScopedLocalize(messages[name], _this._env);
  258. }
  259. load(messages);
  260. };
  261. if (typeof pluginConfig.loadBundle === 'function') {
  262. pluginConfig.loadBundle(name, language, function (err, messages) {
  263. // We have an error. Load the English default strings to not fail
  264. if (err) {
  265. req([name + '.nls'], messagesLoaded_1);
  266. }
  267. else {
  268. messagesLoaded_1(messages);
  269. }
  270. });
  271. }
  272. else {
  273. req([name + suffix], messagesLoaded_1);
  274. }
  275. }
  276. };
  277. NLSPlugin.DEFAULT_TAG = 'i-default';
  278. return NLSPlugin;
  279. }());
  280. NLSLoaderPlugin.NLSPlugin = NLSPlugin;
  281. define('vs/nls', new NLSPlugin(new Environment()));
  282. })(NLSLoaderPlugin || (NLSLoaderPlugin = {}));
  283. define(__m[98/*vs/base/browser/dnd*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  284. "use strict";
  285. Object.defineProperty(exports, "__esModule", { value: true });
  286. // Common data transfers
  287. exports.DataTransfers = {
  288. /**
  289. * Application specific resource transfer type
  290. */
  291. RESOURCES: 'ResourceURLs',
  292. /**
  293. * Browser specific transfer type to download
  294. */
  295. DOWNLOAD_URL: 'DownloadURL',
  296. /**
  297. * Browser specific transfer type for files
  298. */
  299. FILES: 'Files',
  300. /**
  301. * Typically transfer type for copy/paste transfers.
  302. */
  303. TEXT: 'text/plain'
  304. };
  305. var DragAndDropData = /** @class */ (function () {
  306. function DragAndDropData(data) {
  307. this.data = data;
  308. }
  309. DragAndDropData.prototype.update = function () {
  310. // noop
  311. };
  312. DragAndDropData.prototype.getData = function () {
  313. return this.data;
  314. };
  315. return DragAndDropData;
  316. }());
  317. exports.DragAndDropData = DragAndDropData;
  318. exports.StaticDND = {
  319. CurrentDragAndDropData: undefined
  320. };
  321. });
  322. /*---------------------------------------------------------------------------------------------
  323. * Copyright (c) Microsoft Corporation. All rights reserved.
  324. * Licensed under the MIT License. See License.txt in the project root for license information.
  325. *--------------------------------------------------------------------------------------------*/
  326. define(__m[174/*vs/base/browser/iframe*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  327. "use strict";
  328. Object.defineProperty(exports, "__esModule", { value: true });
  329. var hasDifferentOriginAncestorFlag = false;
  330. var sameOriginWindowChainCache = null;
  331. function getParentWindowIfSameOrigin(w) {
  332. if (!w.parent || w.parent === w) {
  333. return null;
  334. }
  335. // Cannot really tell if we have access to the parent window unless we try to access something in it
  336. try {
  337. var location_1 = w.location;
  338. var parentLocation = w.parent.location;
  339. if (location_1.protocol !== parentLocation.protocol || location_1.hostname !== parentLocation.hostname || location_1.port !== parentLocation.port) {
  340. hasDifferentOriginAncestorFlag = true;
  341. return null;
  342. }
  343. }
  344. catch (e) {
  345. hasDifferentOriginAncestorFlag = true;
  346. return null;
  347. }
  348. return w.parent;
  349. }
  350. function findIframeElementInParentWindow(parentWindow, childWindow) {
  351. var parentWindowIframes = parentWindow.document.getElementsByTagName('iframe');
  352. var iframe;
  353. for (var i = 0, len = parentWindowIframes.length; i < len; i++) {
  354. iframe = parentWindowIframes[i];
  355. if (iframe.contentWindow === childWindow) {
  356. return iframe;
  357. }
  358. }
  359. return null;
  360. }
  361. var IframeUtils = /** @class */ (function () {
  362. function IframeUtils() {
  363. }
  364. /**
  365. * Returns a chain of embedded windows with the same origin (which can be accessed programmatically).
  366. * Having a chain of length 1 might mean that the current execution environment is running outside of an iframe or inside an iframe embedded in a window with a different origin.
  367. * To distinguish if at one point the current execution environment is running inside a window with a different origin, see hasDifferentOriginAncestor()
  368. */
  369. IframeUtils.getSameOriginWindowChain = function () {
  370. if (!sameOriginWindowChainCache) {
  371. sameOriginWindowChainCache = [];
  372. var w = window;
  373. var parent_1;
  374. do {
  375. parent_1 = getParentWindowIfSameOrigin(w);
  376. if (parent_1) {
  377. sameOriginWindowChainCache.push({
  378. window: w,
  379. iframeElement: findIframeElementInParentWindow(parent_1, w)
  380. });
  381. }
  382. else {
  383. sameOriginWindowChainCache.push({
  384. window: w,
  385. iframeElement: null
  386. });
  387. }
  388. w = parent_1;
  389. } while (w);
  390. }
  391. return sameOriginWindowChainCache.slice(0);
  392. };
  393. /**
  394. * Returns true if the current execution environment is chained in a list of iframes which at one point ends in a window with a different origin.
  395. * Returns false if the current execution environment is not running inside an iframe or if the entire chain of iframes have the same origin.
  396. */
  397. IframeUtils.hasDifferentOriginAncestor = function () {
  398. if (!sameOriginWindowChainCache) {
  399. this.getSameOriginWindowChain();
  400. }
  401. return hasDifferentOriginAncestorFlag;
  402. };
  403. /**
  404. * Returns the position of `childWindow` relative to `ancestorWindow`
  405. */
  406. IframeUtils.getPositionOfChildWindowRelativeToAncestorWindow = function (childWindow, ancestorWindow) {
  407. if (!ancestorWindow || childWindow === ancestorWindow) {
  408. return {
  409. top: 0,
  410. left: 0
  411. };
  412. }
  413. var top = 0, left = 0;
  414. var windowChain = this.getSameOriginWindowChain();
  415. for (var _i = 0, windowChain_1 = windowChain; _i < windowChain_1.length; _i++) {
  416. var windowChainEl = windowChain_1[_i];
  417. if (windowChainEl.window === ancestorWindow) {
  418. break;
  419. }
  420. if (!windowChainEl.iframeElement) {
  421. break;
  422. }
  423. var boundingRect = windowChainEl.iframeElement.getBoundingClientRect();
  424. top += boundingRect.top;
  425. left += boundingRect.left;
  426. }
  427. return {
  428. top: top,
  429. left: left
  430. };
  431. };
  432. return IframeUtils;
  433. }());
  434. exports.IframeUtils = IframeUtils;
  435. });
  436. /*---------------------------------------------------------------------------------------------
  437. * Copyright (c) Microsoft Corporation. All rights reserved.
  438. * Licensed under the MIT License. See License.txt in the project root for license information.
  439. *--------------------------------------------------------------------------------------------*/
  440. var __extends = (this && this.__extends) || (function () {
  441. var extendStatics = function (d, b) {
  442. extendStatics = Object.setPrototypeOf ||
  443. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  444. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  445. return extendStatics(d, b);
  446. };
  447. return function (d, b) {
  448. extendStatics(d, b);
  449. function __() { this.constructor = d; }
  450. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  451. };
  452. })();
  453. define(__m[239/*vs/base/browser/ui/list/list*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  454. "use strict";
  455. Object.defineProperty(exports, "__esModule", { value: true });
  456. var ListAriaRootRole;
  457. (function (ListAriaRootRole) {
  458. /** default tree structure role */
  459. ListAriaRootRole["TREE"] = "tree";
  460. /** role='tree' can interfere with screenreaders reading nested elements inside the tree row. Use FORM in that case. */
  461. ListAriaRootRole["FORM"] = "form";
  462. })(ListAriaRootRole = exports.ListAriaRootRole || (exports.ListAriaRootRole = {}));
  463. var ListError = /** @class */ (function (_super) {
  464. __extends(ListError, _super);
  465. function ListError(user, message) {
  466. return _super.call(this, "ListError [" + user + "] " + message) || this;
  467. }
  468. return ListError;
  469. }(Error));
  470. exports.ListError = ListError;
  471. });
  472. /*---------------------------------------------------------------------------------------------
  473. * Copyright (c) Microsoft Corporation. All rights reserved.
  474. * Licensed under the MIT License. See License.txt in the project root for license information.
  475. *--------------------------------------------------------------------------------------------*/
  476. define(__m[240/*vs/base/browser/ui/list/splice*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  477. "use strict";
  478. Object.defineProperty(exports, "__esModule", { value: true });
  479. var CombinedSpliceable = /** @class */ (function () {
  480. function CombinedSpliceable(spliceables) {
  481. this.spliceables = spliceables;
  482. }
  483. CombinedSpliceable.prototype.splice = function (start, deleteCount, elements) {
  484. this.spliceables.forEach(function (s) { return s.splice(start, deleteCount, elements); });
  485. };
  486. return CombinedSpliceable;
  487. }());
  488. exports.CombinedSpliceable = CombinedSpliceable;
  489. });
  490. /*---------------------------------------------------------------------------------------------
  491. * Copyright (c) Microsoft Corporation. All rights reserved.
  492. * Licensed under the MIT License. See License.txt in the project root for license information.
  493. *--------------------------------------------------------------------------------------------*/
  494. define(__m[175/*vs/base/browser/ui/scrollbar/scrollbarState*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  495. "use strict";
  496. Object.defineProperty(exports, "__esModule", { value: true });
  497. /**
  498. * The minimal size of the slider (such that it can still be clickable) -- it is artificially enlarged.
  499. */
  500. var MINIMUM_SLIDER_SIZE = 20;
  501. var ScrollbarState = /** @class */ (function () {
  502. function ScrollbarState(arrowSize, scrollbarSize, oppositeScrollbarSize, visibleSize, scrollSize, scrollPosition) {
  503. this._scrollbarSize = Math.round(scrollbarSize);
  504. this._oppositeScrollbarSize = Math.round(oppositeScrollbarSize);
  505. this._arrowSize = Math.round(arrowSize);
  506. this._visibleSize = visibleSize;
  507. this._scrollSize = scrollSize;
  508. this._scrollPosition = scrollPosition;
  509. this._computedAvailableSize = 0;
  510. this._computedIsNeeded = false;
  511. this._computedSliderSize = 0;
  512. this._computedSliderRatio = 0;
  513. this._computedSliderPosition = 0;
  514. this._refreshComputedValues();
  515. }
  516. ScrollbarState.prototype.clone = function () {
  517. return new ScrollbarState(this._arrowSize, this._scrollbarSize, this._oppositeScrollbarSize, this._visibleSize, this._scrollSize, this._scrollPosition);
  518. };
  519. ScrollbarState.prototype.setVisibleSize = function (visibleSize) {
  520. var iVisibleSize = Math.round(visibleSize);
  521. if (this._visibleSize !== iVisibleSize) {
  522. this._visibleSize = iVisibleSize;
  523. this._refreshComputedValues();
  524. return true;
  525. }
  526. return false;
  527. };
  528. ScrollbarState.prototype.setScrollSize = function (scrollSize) {
  529. var iScrollSize = Math.round(scrollSize);
  530. if (this._scrollSize !== iScrollSize) {
  531. this._scrollSize = iScrollSize;
  532. this._refreshComputedValues();
  533. return true;
  534. }
  535. return false;
  536. };
  537. ScrollbarState.prototype.setScrollPosition = function (scrollPosition) {
  538. var iScrollPosition = Math.round(scrollPosition);
  539. if (this._scrollPosition !== iScrollPosition) {
  540. this._scrollPosition = iScrollPosition;
  541. this._refreshComputedValues();
  542. return true;
  543. }
  544. return false;
  545. };
  546. ScrollbarState._computeValues = function (oppositeScrollbarSize, arrowSize, visibleSize, scrollSize, scrollPosition) {
  547. var computedAvailableSize = Math.max(0, visibleSize - oppositeScrollbarSize);
  548. var computedRepresentableSize = Math.max(0, computedAvailableSize - 2 * arrowSize);
  549. var computedIsNeeded = (scrollSize > 0 && scrollSize > visibleSize);
  550. if (!computedIsNeeded) {
  551. // There is no need for a slider
  552. return {
  553. computedAvailableSize: Math.round(computedAvailableSize),
  554. computedIsNeeded: computedIsNeeded,
  555. computedSliderSize: Math.round(computedRepresentableSize),
  556. computedSliderRatio: 0,
  557. computedSliderPosition: 0,
  558. };
  559. }
  560. // We must artificially increase the size of the slider if needed, since the slider would be too small to grab with the mouse otherwise
  561. var computedSliderSize = Math.round(Math.max(MINIMUM_SLIDER_SIZE, Math.floor(visibleSize * computedRepresentableSize / scrollSize)));
  562. // The slider can move from 0 to `computedRepresentableSize` - `computedSliderSize`
  563. // in the same way `scrollPosition` can move from 0 to `scrollSize` - `visibleSize`.
  564. var computedSliderRatio = (computedRepresentableSize - computedSliderSize) / (scrollSize - visibleSize);
  565. var computedSliderPosition = (scrollPosition * computedSliderRatio);
  566. return {
  567. computedAvailableSize: Math.round(computedAvailableSize),
  568. computedIsNeeded: computedIsNeeded,
  569. computedSliderSize: Math.round(computedSliderSize),
  570. computedSliderRatio: computedSliderRatio,
  571. computedSliderPosition: Math.round(computedSliderPosition),
  572. };
  573. };
  574. ScrollbarState.prototype._refreshComputedValues = function () {
  575. var r = ScrollbarState._computeValues(this._oppositeScrollbarSize, this._arrowSize, this._visibleSize, this._scrollSize, this._scrollPosition);
  576. this._computedAvailableSize = r.computedAvailableSize;
  577. this._computedIsNeeded = r.computedIsNeeded;
  578. this._computedSliderSize = r.computedSliderSize;
  579. this._computedSliderRatio = r.computedSliderRatio;
  580. this._computedSliderPosition = r.computedSliderPosition;
  581. };
  582. ScrollbarState.prototype.getArrowSize = function () {
  583. return this._arrowSize;
  584. };
  585. ScrollbarState.prototype.getScrollPosition = function () {
  586. return this._scrollPosition;
  587. };
  588. ScrollbarState.prototype.getRectangleLargeSize = function () {
  589. return this._computedAvailableSize;
  590. };
  591. ScrollbarState.prototype.getRectangleSmallSize = function () {
  592. return this._scrollbarSize;
  593. };
  594. ScrollbarState.prototype.isNeeded = function () {
  595. return this._computedIsNeeded;
  596. };
  597. ScrollbarState.prototype.getSliderSize = function () {
  598. return this._computedSliderSize;
  599. };
  600. ScrollbarState.prototype.getSliderPosition = function () {
  601. return this._computedSliderPosition;
  602. };
  603. /**
  604. * Compute a desired `scrollPosition` such that `offset` ends up in the center of the slider.
  605. * `offset` is based on the same coordinate system as the `sliderPosition`.
  606. */
  607. ScrollbarState.prototype.getDesiredScrollPositionFromOffset = function (offset) {
  608. if (!this._computedIsNeeded) {
  609. // no need for a slider
  610. return 0;
  611. }
  612. var desiredSliderPosition = offset - this._arrowSize - this._computedSliderSize / 2;
  613. return Math.round(desiredSliderPosition / this._computedSliderRatio);
  614. };
  615. /**
  616. * Compute a desired `scrollPosition` such that the slider moves by `delta`.
  617. */
  618. ScrollbarState.prototype.getDesiredScrollPositionFromDelta = function (delta) {
  619. if (!this._computedIsNeeded) {
  620. // no need for a slider
  621. return 0;
  622. }
  623. var desiredSliderPosition = this._computedSliderPosition + delta;
  624. return Math.round(desiredSliderPosition / this._computedSliderRatio);
  625. };
  626. return ScrollbarState;
  627. }());
  628. exports.ScrollbarState = ScrollbarState;
  629. });
  630. /*---------------------------------------------------------------------------------------------
  631. * Copyright (c) Microsoft Corporation. All rights reserved.
  632. * Licensed under the MIT License. See License.txt in the project root for license information.
  633. *--------------------------------------------------------------------------------------------*/
  634. define(__m[99/*vs/base/browser/ui/tree/tree*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  635. "use strict";
  636. Object.defineProperty(exports, "__esModule", { value: true });
  637. var TreeError = /** @class */ (function (_super) {
  638. __extends(TreeError, _super);
  639. function TreeError(user, message) {
  640. return _super.call(this, "TreeError [" + user + "] " + message) || this;
  641. }
  642. return TreeError;
  643. }(Error));
  644. exports.TreeError = TreeError;
  645. var WeakMapper = /** @class */ (function () {
  646. function WeakMapper(fn) {
  647. this.fn = fn;
  648. this._map = new WeakMap();
  649. }
  650. WeakMapper.prototype.map = function (key) {
  651. var result = this._map.get(key);
  652. if (!result) {
  653. result = this.fn(key);
  654. this._map.set(key, result);
  655. }
  656. return result;
  657. };
  658. return WeakMapper;
  659. }());
  660. exports.WeakMapper = WeakMapper;
  661. });
  662. define(__m[19/*vs/base/common/arrays*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  663. "use strict";
  664. Object.defineProperty(exports, "__esModule", { value: true });
  665. /**
  666. * Returns the last element of an array.
  667. * @param array The array.
  668. * @param n Which element from the end (default is zero).
  669. */
  670. function tail(array, n) {
  671. if (n === void 0) { n = 0; }
  672. return array[array.length - (1 + n)];
  673. }
  674. exports.tail = tail;
  675. function tail2(arr) {
  676. if (arr.length === 0) {
  677. throw new Error('Invalid tail call');
  678. }
  679. return [arr.slice(0, arr.length - 1), arr[arr.length - 1]];
  680. }
  681. exports.tail2 = tail2;
  682. function equals(one, other, itemEquals) {
  683. if (itemEquals === void 0) { itemEquals = function (a, b) { return a === b; }; }
  684. if (one === other) {
  685. return true;
  686. }
  687. if (!one || !other) {
  688. return false;
  689. }
  690. if (one.length !== other.length) {
  691. return false;
  692. }
  693. for (var i = 0, len = one.length; i < len; i++) {
  694. if (!itemEquals(one[i], other[i])) {
  695. return false;
  696. }
  697. }
  698. return true;
  699. }
  700. exports.equals = equals;
  701. function binarySearch(array, key, comparator) {
  702. var low = 0, high = array.length - 1;
  703. while (low <= high) {
  704. var mid = ((low + high) / 2) | 0;
  705. var comp = comparator(array[mid], key);
  706. if (comp < 0) {
  707. low = mid + 1;
  708. }
  709. else if (comp > 0) {
  710. high = mid - 1;
  711. }
  712. else {
  713. return mid;
  714. }
  715. }
  716. return -(low + 1);
  717. }
  718. exports.binarySearch = binarySearch;
  719. /**
  720. * Takes a sorted array and a function p. The array is sorted in such a way that all elements where p(x) is false
  721. * are located before all elements where p(x) is true.
  722. * @returns the least x for which p(x) is true or array.length if no element fullfills the given function.
  723. */
  724. function findFirstInSorted(array, p) {
  725. var low = 0, high = array.length;
  726. if (high === 0) {
  727. return 0; // no children
  728. }
  729. while (low < high) {
  730. var mid = Math.floor((low + high) / 2);
  731. if (p(array[mid])) {
  732. high = mid;
  733. }
  734. else {
  735. low = mid + 1;
  736. }
  737. }
  738. return low;
  739. }
  740. exports.findFirstInSorted = findFirstInSorted;
  741. /**
  742. * Like `Array#sort` but always stable. Usually runs a little slower `than Array#sort`
  743. * so only use this when actually needing stable sort.
  744. */
  745. function mergeSort(data, compare) {
  746. _sort(data, compare, 0, data.length - 1, []);
  747. return data;
  748. }
  749. exports.mergeSort = mergeSort;
  750. function _merge(a, compare, lo, mid, hi, aux) {
  751. var leftIdx = lo, rightIdx = mid + 1;
  752. for (var i = lo; i <= hi; i++) {
  753. aux[i] = a[i];
  754. }
  755. for (var i = lo; i <= hi; i++) {
  756. if (leftIdx > mid) {
  757. // left side consumed
  758. a[i] = aux[rightIdx++];
  759. }
  760. else if (rightIdx > hi) {
  761. // right side consumed
  762. a[i] = aux[leftIdx++];
  763. }
  764. else if (compare(aux[rightIdx], aux[leftIdx]) < 0) {
  765. // right element is less -> comes first
  766. a[i] = aux[rightIdx++];
  767. }
  768. else {
  769. // left element comes first (less or equal)
  770. a[i] = aux[leftIdx++];
  771. }
  772. }
  773. }
  774. function _sort(a, compare, lo, hi, aux) {
  775. if (hi <= lo) {
  776. return;
  777. }
  778. var mid = lo + ((hi - lo) / 2) | 0;
  779. _sort(a, compare, lo, mid, aux);
  780. _sort(a, compare, mid + 1, hi, aux);
  781. if (compare(a[mid], a[mid + 1]) <= 0) {
  782. // left and right are sorted and if the last-left element is less
  783. // or equals than the first-right element there is nothing else
  784. // to do
  785. return;
  786. }
  787. _merge(a, compare, lo, mid, hi, aux);
  788. }
  789. function groupBy(data, compare) {
  790. var result = [];
  791. var currentGroup = undefined;
  792. for (var _i = 0, _a = mergeSort(data.slice(0), compare); _i < _a.length; _i++) {
  793. var element = _a[_i];
  794. if (!currentGroup || compare(currentGroup[0], element) !== 0) {
  795. currentGroup = [element];
  796. result.push(currentGroup);
  797. }
  798. else {
  799. currentGroup.push(element);
  800. }
  801. }
  802. return result;
  803. }
  804. exports.groupBy = groupBy;
  805. /**
  806. * @returns New array with all falsy values removed. The original array IS NOT modified.
  807. */
  808. function coalesce(array) {
  809. return array.filter(function (e) { return !!e; });
  810. }
  811. exports.coalesce = coalesce;
  812. /**
  813. * @returns false if the provided object is an array and not empty.
  814. */
  815. function isFalsyOrEmpty(obj) {
  816. return !Array.isArray(obj) || obj.length === 0;
  817. }
  818. exports.isFalsyOrEmpty = isFalsyOrEmpty;
  819. function isNonEmptyArray(obj) {
  820. return Array.isArray(obj) && obj.length > 0;
  821. }
  822. exports.isNonEmptyArray = isNonEmptyArray;
  823. /**
  824. * Removes duplicates from the given array. The optional keyFn allows to specify
  825. * how elements are checked for equalness by returning a unique string for each.
  826. */
  827. function distinct(array, keyFn) {
  828. if (!keyFn) {
  829. return array.filter(function (element, position) {
  830. return array.indexOf(element) === position;
  831. });
  832. }
  833. var seen = Object.create(null);
  834. return array.filter(function (elem) {
  835. var key = keyFn(elem);
  836. if (seen[key]) {
  837. return false;
  838. }
  839. seen[key] = true;
  840. return true;
  841. });
  842. }
  843. exports.distinct = distinct;
  844. function distinctES6(array) {
  845. var seen = new Set();
  846. return array.filter(function (element) {
  847. if (seen.has(element)) {
  848. return false;
  849. }
  850. seen.add(element);
  851. return true;
  852. });
  853. }
  854. exports.distinctES6 = distinctES6;
  855. function fromSet(set) {
  856. var result = [];
  857. set.forEach(function (o) { return result.push(o); });
  858. return result;
  859. }
  860. exports.fromSet = fromSet;
  861. function firstIndex(array, fn) {
  862. for (var i = 0; i < array.length; i++) {
  863. var element = array[i];
  864. if (fn(element)) {
  865. return i;
  866. }
  867. }
  868. return -1;
  869. }
  870. exports.firstIndex = firstIndex;
  871. function first(array, fn, notFoundValue) {
  872. if (notFoundValue === void 0) { notFoundValue = undefined; }
  873. var index = firstIndex(array, fn);
  874. return index < 0 ? notFoundValue : array[index];
  875. }
  876. exports.first = first;
  877. function firstOrDefault(array, notFoundValue) {
  878. return array.length > 0 ? array[0] : notFoundValue;
  879. }
  880. exports.firstOrDefault = firstOrDefault;
  881. function flatten(arr) {
  882. var _a;
  883. return (_a = []).concat.apply(_a, arr);
  884. }
  885. exports.flatten = flatten;
  886. function range(arg, to) {
  887. var from = typeof to === 'number' ? arg : 0;
  888. if (typeof to === 'number') {
  889. from = arg;
  890. }
  891. else {
  892. from = 0;
  893. to = arg;
  894. }
  895. var result = [];
  896. if (from <= to) {
  897. for (var i = from; i < to; i++) {
  898. result.push(i);
  899. }
  900. }
  901. else {
  902. for (var i = from; i > to; i--) {
  903. result.push(i);
  904. }
  905. }
  906. return result;
  907. }
  908. exports.range = range;
  909. /**
  910. * Insert `insertArr` inside `target` at `insertIndex`.
  911. * Please don't touch unless you understand https://jsperf.com/inserting-an-array-within-an-array
  912. */
  913. function arrayInsert(target, insertIndex, insertArr) {
  914. var before = target.slice(0, insertIndex);
  915. var after = target.slice(insertIndex);
  916. return before.concat(insertArr, after);
  917. }
  918. exports.arrayInsert = arrayInsert;
  919. /**
  920. * Pushes an element to the start of the array, if found.
  921. */
  922. function pushToStart(arr, value) {
  923. var index = arr.indexOf(value);
  924. if (index > -1) {
  925. arr.splice(index, 1);
  926. arr.unshift(value);
  927. }
  928. }
  929. exports.pushToStart = pushToStart;
  930. /**
  931. * Pushes an element to the end of the array, if found.
  932. */
  933. function pushToEnd(arr, value) {
  934. var index = arr.indexOf(value);
  935. if (index > -1) {
  936. arr.splice(index, 1);
  937. arr.push(value);
  938. }
  939. }
  940. exports.pushToEnd = pushToEnd;
  941. function find(arr, predicate) {
  942. for (var i = 0; i < arr.length; i++) {
  943. var element = arr[i];
  944. if (predicate(element, i, arr)) {
  945. return element;
  946. }
  947. }
  948. return undefined;
  949. }
  950. exports.find = find;
  951. function asArray(x) {
  952. return Array.isArray(x) ? x : [x];
  953. }
  954. exports.asArray = asArray;
  955. });
  956. /*---------------------------------------------------------------------------------------------
  957. * Copyright (c) Microsoft Corporation. All rights reserved.
  958. * Licensed under the MIT License. See License.txt in the project root for license information.
  959. *--------------------------------------------------------------------------------------------*/
  960. define(__m[124/*vs/base/common/assert*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  961. "use strict";
  962. Object.defineProperty(exports, "__esModule", { value: true });
  963. /**
  964. * Throws an error with the provided message if the provided value does not evaluate to a true Javascript value.
  965. */
  966. function ok(value, message) {
  967. if (!value) {
  968. throw new Error(message ? 'Assertion failed (' + message + ')' : 'Assertion Failed');
  969. }
  970. }
  971. exports.ok = ok;
  972. });
  973. /*---------------------------------------------------------------------------------------------
  974. * Copyright (c) Microsoft Corporation. All rights reserved.
  975. * Licensed under the MIT License. See License.txt in the project root for license information.
  976. *--------------------------------------------------------------------------------------------*/
  977. define(__m[100/*vs/base/common/codicons*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  978. "use strict";
  979. Object.defineProperty(exports, "__esModule", { value: true });
  980. var escapeCodiconsRegex = /(\\)?\$\([a-z0-9\-]+?(?:~[a-z0-9\-]*?)?\)/gi;
  981. function escapeCodicons(text) {
  982. return text.replace(escapeCodiconsRegex, function (match, escaped) { return escaped ? match : "\\" + match; });
  983. }
  984. exports.escapeCodicons = escapeCodicons;
  985. var markdownEscapedCodiconsRegex = /\\\$\([a-z0-9\-]+?(?:~[a-z0-9\-]*?)?\)/gi;
  986. function markdownEscapeEscapedCodicons(text) {
  987. // Need to add an extra \ for escaping in markdown
  988. return text.replace(markdownEscapedCodiconsRegex, function (match) { return "\\" + match; });
  989. }
  990. exports.markdownEscapeEscapedCodicons = markdownEscapeEscapedCodicons;
  991. var renderCodiconsRegex = /(\\)?\$\((([a-z0-9\-]+?)(?:~([a-z0-9\-]*?))?)\)/gi;
  992. function renderCodicons(text) {
  993. return text.replace(renderCodiconsRegex, function (_, escaped, codicon, name, animation) {
  994. return escaped
  995. ? "$(" + codicon + ")"
  996. : "<span class=\"codicon codicon-" + name + (animation ? " codicon-animation-" + animation : '') + "\"></span>";
  997. });
  998. }
  999. exports.renderCodicons = renderCodicons;
  1000. });
  1001. /*---------------------------------------------------------------------------------------------
  1002. * Copyright (c) Microsoft Corporation. All rights reserved.
  1003. * Licensed under the MIT License. See License.txt in the project root for license information.
  1004. *--------------------------------------------------------------------------------------------*/
  1005. define(__m[87/*vs/base/common/collections*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  1006. "use strict";
  1007. Object.defineProperty(exports, "__esModule", { value: true });
  1008. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1009. /**
  1010. * Returns an array which contains all values that reside
  1011. * in the given set.
  1012. */
  1013. function values(from) {
  1014. var result = [];
  1015. for (var key in from) {
  1016. if (hasOwnProperty.call(from, key)) {
  1017. result.push(from[key]);
  1018. }
  1019. }
  1020. return result;
  1021. }
  1022. exports.values = values;
  1023. function first(from) {
  1024. for (var key in from) {
  1025. if (hasOwnProperty.call(from, key)) {
  1026. return from[key];
  1027. }
  1028. }
  1029. return undefined;
  1030. }
  1031. exports.first = first;
  1032. /**
  1033. * Iterates over each entry in the provided set. The iterator allows
  1034. * to remove elements and will stop when the callback returns {{false}}.
  1035. */
  1036. function forEach(from, callback) {
  1037. var _loop_1 = function (key) {
  1038. if (hasOwnProperty.call(from, key)) {
  1039. var result = callback({ key: key, value: from[key] }, function () {
  1040. delete from[key];
  1041. });
  1042. if (result === false) {
  1043. return { value: void 0 };
  1044. }
  1045. }
  1046. };
  1047. for (var key in from) {
  1048. var state_1 = _loop_1(key);
  1049. if (typeof state_1 === "object")
  1050. return state_1.value;
  1051. }
  1052. }
  1053. exports.forEach = forEach;
  1054. var SetMap = /** @class */ (function () {
  1055. function SetMap() {
  1056. this.map = new Map();
  1057. }
  1058. SetMap.prototype.add = function (key, value) {
  1059. var values = this.map.get(key);
  1060. if (!values) {
  1061. values = new Set();
  1062. this.map.set(key, values);
  1063. }
  1064. values.add(value);
  1065. };
  1066. SetMap.prototype.delete = function (key, value) {
  1067. var values = this.map.get(key);
  1068. if (!values) {
  1069. return;
  1070. }
  1071. values.delete(value);
  1072. if (values.size === 0) {
  1073. this.map.delete(key);
  1074. }
  1075. };
  1076. SetMap.prototype.forEach = function (key, fn) {
  1077. var values = this.map.get(key);
  1078. if (!values) {
  1079. return;
  1080. }
  1081. values.forEach(fn);
  1082. };
  1083. return SetMap;
  1084. }());
  1085. exports.SetMap = SetMap;
  1086. });
  1087. /*---------------------------------------------------------------------------------------------
  1088. * Copyright (c) Microsoft Corporation. All rights reserved.
  1089. * Licensed under the MIT License. See License.txt in the project root for license information.
  1090. *--------------------------------------------------------------------------------------------*/
  1091. define(__m[27/*vs/base/common/color*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  1092. "use strict";
  1093. Object.defineProperty(exports, "__esModule", { value: true });
  1094. function roundFloat(number, decimalPoints) {
  1095. var decimal = Math.pow(10, decimalPoints);
  1096. return Math.round(number * decimal) / decimal;
  1097. }
  1098. var RGBA = /** @class */ (function () {
  1099. function RGBA(r, g, b, a) {
  1100. if (a === void 0) { a = 1; }
  1101. this.r = Math.min(255, Math.max(0, r)) | 0;
  1102. this.g = Math.min(255, Math.max(0, g)) | 0;
  1103. this.b = Math.min(255, Math.max(0, b)) | 0;
  1104. this.a = roundFloat(Math.max(Math.min(1, a), 0), 3);
  1105. }
  1106. RGBA.equals = function (a, b) {
  1107. return a.r === b.r && a.g === b.g && a.b === b.b && a.a === b.a;
  1108. };
  1109. return RGBA;
  1110. }());
  1111. exports.RGBA = RGBA;
  1112. var HSLA = /** @class */ (function () {
  1113. function HSLA(h, s, l, a) {
  1114. this.h = Math.max(Math.min(360, h), 0) | 0;
  1115. this.s = roundFloat(Math.max(Math.min(1, s), 0), 3);
  1116. this.l = roundFloat(Math.max(Math.min(1, l), 0), 3);
  1117. this.a = roundFloat(Math.max(Math.min(1, a), 0), 3);
  1118. }
  1119. HSLA.equals = function (a, b) {
  1120. return a.h === b.h && a.s === b.s && a.l === b.l && a.a === b.a;
  1121. };
  1122. /**
  1123. * Converts an RGB color value to HSL. Conversion formula
  1124. * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
  1125. * Assumes r, g, and b are contained in the set [0, 255] and
  1126. * returns h in the set [0, 360], s, and l in the set [0, 1].
  1127. */
  1128. HSLA.fromRGBA = function (rgba) {
  1129. var r = rgba.r / 255;
  1130. var g = rgba.g / 255;
  1131. var b = rgba.b / 255;
  1132. var a = rgba.a;
  1133. var max = Math.max(r, g, b);
  1134. var min = Math.min(r, g, b);
  1135. var h = 0;
  1136. var s = 0;
  1137. var l = (min + max) / 2;
  1138. var chroma = max - min;
  1139. if (chroma > 0) {
  1140. s = Math.min((l <= 0.5 ? chroma / (2 * l) : chroma / (2 - (2 * l))), 1);
  1141. switch (max) {
  1142. case r:
  1143. h = (g - b) / chroma + (g < b ? 6 : 0);
  1144. break;
  1145. case g:
  1146. h = (b - r) / chroma + 2;
  1147. break;
  1148. case b:
  1149. h = (r - g) / chroma + 4;
  1150. break;
  1151. }
  1152. h *= 60;
  1153. h = Math.round(h);
  1154. }
  1155. return new HSLA(h, s, l, a);
  1156. };
  1157. HSLA._hue2rgb = function (p, q, t) {
  1158. if (t < 0) {
  1159. t += 1;
  1160. }
  1161. if (t > 1) {
  1162. t -= 1;
  1163. }
  1164. if (t < 1 / 6) {
  1165. return p + (q - p) * 6 * t;
  1166. }
  1167. if (t < 1 / 2) {
  1168. return q;
  1169. }
  1170. if (t < 2 / 3) {
  1171. return p + (q - p) * (2 / 3 - t) * 6;
  1172. }
  1173. return p;
  1174. };
  1175. /**
  1176. * Converts an HSL color value to RGB. Conversion formula
  1177. * adapted from http://en.wikipedia.org/wiki/HSL_color_space.
  1178. * Assumes h in the set [0, 360] s, and l are contained in the set [0, 1] and
  1179. * returns r, g, and b in the set [0, 255].
  1180. */
  1181. HSLA.toRGBA = function (hsla) {
  1182. var h = hsla.h / 360;
  1183. var s = hsla.s, l = hsla.l, a = hsla.a;
  1184. var r, g, b;
  1185. if (s === 0) {
  1186. r = g = b = l; // achromatic
  1187. }
  1188. else {
  1189. var q = l < 0.5 ? l * (1 + s) : l + s - l * s;
  1190. var p = 2 * l - q;
  1191. r = HSLA._hue2rgb(p, q, h + 1 / 3);
  1192. g = HSLA._hue2rgb(p, q, h);
  1193. b = HSLA._hue2rgb(p, q, h - 1 / 3);
  1194. }
  1195. return new RGBA(Math.round(r * 255), Math.round(g * 255), Math.round(b * 255), a);
  1196. };
  1197. return HSLA;
  1198. }());
  1199. exports.HSLA = HSLA;
  1200. var HSVA = /** @class */ (function () {
  1201. function HSVA(h, s, v, a) {
  1202. this.h = Math.max(Math.min(360, h), 0) | 0;
  1203. this.s = roundFloat(Math.max(Math.min(1, s), 0), 3);
  1204. this.v = roundFloat(Math.max(Math.min(1, v), 0), 3);
  1205. this.a = roundFloat(Math.max(Math.min(1, a), 0), 3);
  1206. }
  1207. HSVA.equals = function (a, b) {
  1208. return a.h === b.h && a.s === b.s && a.v === b.v && a.a === b.a;
  1209. };
  1210. // from http://www.rapidtables.com/convert/color/rgb-to-hsv.htm
  1211. HSVA.fromRGBA = function (rgba) {
  1212. var r = rgba.r / 255;
  1213. var g = rgba.g / 255;
  1214. var b = rgba.b / 255;
  1215. var cmax = Math.max(r, g, b);
  1216. var cmin = Math.min(r, g, b);
  1217. var delta = cmax - cmin;
  1218. var s = cmax === 0 ? 0 : (delta / cmax);
  1219. var m;
  1220. if (delta === 0) {
  1221. m = 0;
  1222. }
  1223. else if (cmax === r) {
  1224. m = ((((g - b) / delta) % 6) + 6) % 6;
  1225. }
  1226. else if (cmax === g) {
  1227. m = ((b - r) / delta) + 2;
  1228. }
  1229. else {
  1230. m = ((r - g) / delta) + 4;
  1231. }
  1232. return new HSVA(Math.round(m * 60), s, cmax, rgba.a);
  1233. };
  1234. // from http://www.rapidtables.com/convert/color/hsv-to-rgb.htm
  1235. HSVA.toRGBA = function (hsva) {
  1236. var h = hsva.h, s = hsva.s, v = hsva.v, a = hsva.a;
  1237. var c = v * s;
  1238. var x = c * (1 - Math.abs((h / 60) % 2 - 1));
  1239. var m = v - c;
  1240. var _a = [0, 0, 0], r = _a[0], g = _a[1], b = _a[2];
  1241. if (h < 60) {
  1242. r = c;
  1243. g = x;
  1244. }
  1245. else if (h < 120) {
  1246. r = x;
  1247. g = c;
  1248. }
  1249. else if (h < 180) {
  1250. g = c;
  1251. b = x;
  1252. }
  1253. else if (h < 240) {
  1254. g = x;
  1255. b = c;
  1256. }
  1257. else if (h < 300) {
  1258. r = x;
  1259. b = c;
  1260. }
  1261. else if (h < 360) {
  1262. r = c;
  1263. b = x;
  1264. }
  1265. r = Math.round((r + m) * 255);
  1266. g = Math.round((g + m) * 255);
  1267. b = Math.round((b + m) * 255);
  1268. return new RGBA(r, g, b, a);
  1269. };
  1270. return HSVA;
  1271. }());
  1272. exports.HSVA = HSVA;
  1273. var Color = /** @class */ (function () {
  1274. function Color(arg) {
  1275. if (!arg) {
  1276. throw new Error('Color needs a value');
  1277. }
  1278. else if (arg instanceof RGBA) {
  1279. this.rgba = arg;
  1280. }
  1281. else if (arg instanceof HSLA) {
  1282. this._hsla = arg;
  1283. this.rgba = HSLA.toRGBA(arg);
  1284. }
  1285. else if (arg instanceof HSVA) {
  1286. this._hsva = arg;
  1287. this.rgba = HSVA.toRGBA(arg);
  1288. }
  1289. else {
  1290. throw new Error('Invalid color ctor argument');
  1291. }
  1292. }
  1293. Color.fromHex = function (hex) {
  1294. return Color.Format.CSS.parseHex(hex) || Color.red;
  1295. };
  1296. Object.defineProperty(Color.prototype, "hsla", {
  1297. get: function () {
  1298. if (this._hsla) {
  1299. return this._hsla;
  1300. }
  1301. else {
  1302. return HSLA.fromRGBA(this.rgba);
  1303. }
  1304. },
  1305. enumerable: true,
  1306. configurable: true
  1307. });
  1308. Object.defineProperty(Color.prototype, "hsva", {
  1309. get: function () {
  1310. if (this._hsva) {
  1311. return this._hsva;
  1312. }
  1313. return HSVA.fromRGBA(this.rgba);
  1314. },
  1315. enumerable: true,
  1316. configurable: true
  1317. });
  1318. Color.prototype.equals = function (other) {
  1319. return !!other && RGBA.equals(this.rgba, other.rgba) && HSLA.equals(this.hsla, other.hsla) && HSVA.equals(this.hsva, other.hsva);
  1320. };
  1321. /**
  1322. * http://www.w3.org/TR/WCAG20/#relativeluminancedef
  1323. * Returns the number in the set [0, 1]. O => Darkest Black. 1 => Lightest white.
  1324. */
  1325. Color.prototype.getRelativeLuminance = function () {
  1326. var R = Color._relativeLuminanceForComponent(this.rgba.r);
  1327. var G = Color._relativeLuminanceForComponent(this.rgba.g);
  1328. var B = Color._relativeLuminanceForComponent(this.rgba.b);
  1329. var luminance = 0.2126 * R + 0.7152 * G + 0.0722 * B;
  1330. return roundFloat(luminance, 4);
  1331. };
  1332. Color._relativeLuminanceForComponent = function (color) {
  1333. var c = color / 255;
  1334. return (c <= 0.03928) ? c / 12.92 : Math.pow(((c + 0.055) / 1.055), 2.4);
  1335. };
  1336. /**
  1337. * http://24ways.org/2010/calculating-color-contrast
  1338. * Return 'true' if lighter color otherwise 'false'
  1339. */
  1340. Color.prototype.isLighter = function () {
  1341. var yiq = (this.rgba.r * 299 + this.rgba.g * 587 + this.rgba.b * 114) / 1000;
  1342. return yiq >= 128;
  1343. };
  1344. Color.prototype.isLighterThan = function (another) {
  1345. var lum1 = this.getRelativeLuminance();
  1346. var lum2 = another.getRelativeLuminance();
  1347. return lum1 > lum2;
  1348. };
  1349. Color.prototype.isDarkerThan = function (another) {
  1350. var lum1 = this.getRelativeLuminance();
  1351. var lum2 = another.getRelativeLuminance();
  1352. return lum1 < lum2;
  1353. };
  1354. Color.prototype.lighten = function (factor) {
  1355. return new Color(new HSLA(this.hsla.h, this.hsla.s, this.hsla.l + this.hsla.l * factor, this.hsla.a));
  1356. };
  1357. Color.prototype.darken = function (factor) {
  1358. return new Color(new HSLA(this.hsla.h, this.hsla.s, this.hsla.l - this.hsla.l * factor, this.hsla.a));
  1359. };
  1360. Color.prototype.transparent = function (factor) {
  1361. var _a = this.rgba, r = _a.r, g = _a.g, b = _a.b, a = _a.a;
  1362. return new Color(new RGBA(r, g, b, a * factor));
  1363. };
  1364. Color.prototype.isTransparent = function () {
  1365. return this.rgba.a === 0;
  1366. };
  1367. Color.prototype.isOpaque = function () {
  1368. return this.rgba.a === 1;
  1369. };
  1370. Color.prototype.opposite = function () {
  1371. return new Color(new RGBA(255 - this.rgba.r, 255 - this.rgba.g, 255 - this.rgba.b, this.rgba.a));
  1372. };
  1373. Color.prototype.toString = function () {
  1374. return '' + Color.Format.CSS.format(this);
  1375. };
  1376. Color.getLighterColor = function (of, relative, factor) {
  1377. if (of.isLighterThan(relative)) {
  1378. return of;
  1379. }
  1380. factor = factor ? factor : 0.5;
  1381. var lum1 = of.getRelativeLuminance();
  1382. var lum2 = relative.getRelativeLuminance();
  1383. factor = factor * (lum2 - lum1) / lum2;
  1384. return of.lighten(factor);
  1385. };
  1386. Color.getDarkerColor = function (of, relative, factor) {
  1387. if (of.isDarkerThan(relative)) {
  1388. return of;
  1389. }
  1390. factor = factor ? factor : 0.5;
  1391. var lum1 = of.getRelativeLuminance();
  1392. var lum2 = relative.getRelativeLuminance();
  1393. factor = factor * (lum1 - lum2) / lum1;
  1394. return of.darken(factor);
  1395. };
  1396. Color.white = new Color(new RGBA(255, 255, 255, 1));
  1397. Color.black = new Color(new RGBA(0, 0, 0, 1));
  1398. Color.red = new Color(new RGBA(255, 0, 0, 1));
  1399. Color.blue = new Color(new RGBA(0, 0, 255, 1));
  1400. Color.cyan = new Color(new RGBA(0, 255, 255, 1));
  1401. Color.lightgrey = new Color(new RGBA(211, 211, 211, 1));
  1402. Color.transparent = new Color(new RGBA(0, 0, 0, 0));
  1403. return Color;
  1404. }());
  1405. exports.Color = Color;
  1406. (function (Color) {
  1407. var Format;
  1408. (function (Format) {
  1409. var CSS;
  1410. (function (CSS) {
  1411. function formatRGB(color) {
  1412. if (color.rgba.a === 1) {
  1413. return "rgb(" + color.rgba.r + ", " + color.rgba.g + ", " + color.rgba.b + ")";
  1414. }
  1415. return Color.Format.CSS.formatRGBA(color);
  1416. }
  1417. CSS.formatRGB = formatRGB;
  1418. function formatRGBA(color) {
  1419. return "rgba(" + color.rgba.r + ", " + color.rgba.g + ", " + color.rgba.b + ", " + +(color.rgba.a).toFixed(2) + ")";
  1420. }
  1421. CSS.formatRGBA = formatRGBA;
  1422. function formatHSL(color) {
  1423. if (color.hsla.a === 1) {
  1424. return "hsl(" + color.hsla.h + ", " + (color.hsla.s * 100).toFixed(2) + "%, " + (color.hsla.l * 100).toFixed(2) + "%)";
  1425. }
  1426. return Color.Format.CSS.formatHSLA(color);
  1427. }
  1428. CSS.formatHSL = formatHSL;
  1429. function formatHSLA(color) {
  1430. return "hsla(" + color.hsla.h + ", " + (color.hsla.s * 100).toFixed(2) + "%, " + (color.hsla.l * 100).toFixed(2) + "%, " + color.hsla.a.toFixed(2) + ")";
  1431. }
  1432. CSS.formatHSLA = formatHSLA;
  1433. function _toTwoDigitHex(n) {
  1434. var r = n.toString(16);
  1435. return r.length !== 2 ? '0' + r : r;
  1436. }
  1437. /**
  1438. * Formats the color as #RRGGBB
  1439. */
  1440. function formatHex(color) {
  1441. return "#" + _toTwoDigitHex(color.rgba.r) + _toTwoDigitHex(color.rgba.g) + _toTwoDigitHex(color.rgba.b);
  1442. }
  1443. CSS.formatHex = formatHex;
  1444. /**
  1445. * Formats the color as #RRGGBBAA
  1446. * If 'compact' is set, colors without transparancy will be printed as #RRGGBB
  1447. */
  1448. function formatHexA(color, compact) {
  1449. if (compact === void 0) { compact = false; }
  1450. if (compact && color.rgba.a === 1) {
  1451. return Color.Format.CSS.formatHex(color);
  1452. }
  1453. return "#" + _toTwoDigitHex(color.rgba.r) + _toTwoDigitHex(color.rgba.g) + _toTwoDigitHex(color.rgba.b) + _toTwoDigitHex(Math.round(color.rgba.a * 255));
  1454. }
  1455. CSS.formatHexA = formatHexA;
  1456. /**
  1457. * The default format will use HEX if opaque and RGBA otherwise.
  1458. */
  1459. function format(color) {
  1460. if (color.isOpaque()) {
  1461. return Color.Format.CSS.formatHex(color);
  1462. }
  1463. return Color.Format.CSS.formatRGBA(color);
  1464. }
  1465. CSS.format = format;
  1466. /**
  1467. * Converts an Hex color value to a Color.
  1468. * returns r, g, and b are contained in the set [0, 255]
  1469. * @param hex string (#RGB, #RGBA, #RRGGBB or #RRGGBBAA).
  1470. */
  1471. function parseHex(hex) {
  1472. var length = hex.length;
  1473. if (length === 0) {
  1474. // Invalid color
  1475. return null;
  1476. }
  1477. if (hex.charCodeAt(0) !== 35 /* Hash */) {
  1478. // Does not begin with a #
  1479. return null;
  1480. }
  1481. if (length === 7) {
  1482. // #RRGGBB format
  1483. var r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
  1484. var g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
  1485. var b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
  1486. return new Color(new RGBA(r, g, b, 1));
  1487. }
  1488. if (length === 9) {
  1489. // #RRGGBBAA format
  1490. var r = 16 * _parseHexDigit(hex.charCodeAt(1)) + _parseHexDigit(hex.charCodeAt(2));
  1491. var g = 16 * _parseHexDigit(hex.charCodeAt(3)) + _parseHexDigit(hex.charCodeAt(4));
  1492. var b = 16 * _parseHexDigit(hex.charCodeAt(5)) + _parseHexDigit(hex.charCodeAt(6));
  1493. var a = 16 * _parseHexDigit(hex.charCodeAt(7)) + _parseHexDigit(hex.charCodeAt(8));
  1494. return new Color(new RGBA(r, g, b, a / 255));
  1495. }
  1496. if (length === 4) {
  1497. // #RGB format
  1498. var r = _parseHexDigit(hex.charCodeAt(1));
  1499. var g = _parseHexDigit(hex.charCodeAt(2));
  1500. var b = _parseHexDigit(hex.charCodeAt(3));
  1501. return new Color(new RGBA(16 * r + r, 16 * g + g, 16 * b + b));
  1502. }
  1503. if (length === 5) {
  1504. // #RGBA format
  1505. var r = _parseHexDigit(hex.charCodeAt(1));
  1506. var g = _parseHexDigit(hex.charCodeAt(2));
  1507. var b = _parseHexDigit(hex.charCodeAt(3));
  1508. var a = _parseHexDigit(hex.charCodeAt(4));
  1509. return new Color(new RGBA(16 * r + r, 16 * g + g, 16 * b + b, (16 * a + a) / 255));
  1510. }
  1511. // Invalid color
  1512. return null;
  1513. }
  1514. CSS.parseHex = parseHex;
  1515. function _parseHexDigit(charCode) {
  1516. switch (charCode) {
  1517. case 48 /* Digit0 */: return 0;
  1518. case 49 /* Digit1 */: return 1;
  1519. case 50 /* Digit2 */: return 2;
  1520. case 51 /* Digit3 */: return 3;
  1521. case 52 /* Digit4 */: return 4;
  1522. case 53 /* Digit5 */: return 5;
  1523. case 54 /* Digit6 */: return 6;
  1524. case 55 /* Digit7 */: return 7;
  1525. case 56 /* Digit8 */: return 8;
  1526. case 57 /* Digit9 */: return 9;
  1527. case 97 /* a */: return 10;
  1528. case 65 /* A */: return 10;
  1529. case 98 /* b */: return 11;
  1530. case 66 /* B */: return 11;
  1531. case 99 /* c */: return 12;
  1532. case 67 /* C */: return 12;
  1533. case 100 /* d */: return 13;
  1534. case 68 /* D */: return 13;
  1535. case 101 /* e */: return 14;
  1536. case 69 /* E */: return 14;
  1537. case 102 /* f */: return 15;
  1538. case 70 /* F */: return 15;
  1539. }
  1540. return 0;
  1541. }
  1542. })(CSS = Format.CSS || (Format.CSS = {}));
  1543. })(Format = Color.Format || (Color.Format = {}));
  1544. })(Color = exports.Color || (exports.Color = {}));
  1545. exports.Color = Color;
  1546. });
  1547. define(__m[101/*vs/base/common/decorators*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  1548. "use strict";
  1549. Object.defineProperty(exports, "__esModule", { value: true });
  1550. var memoizeId = 0;
  1551. function createMemoizer() {
  1552. var memoizeKeyPrefix = "$memoize" + memoizeId++;
  1553. var self = undefined;
  1554. var result = function memoize(target, key, descriptor) {
  1555. var fnKey = null;
  1556. var fn = null;
  1557. if (typeof descriptor.value === 'function') {
  1558. fnKey = 'value';
  1559. fn = descriptor.value;
  1560. if (fn.length !== 0) {
  1561. console.warn('Memoize should only be used in functions with zero parameters');
  1562. }
  1563. }
  1564. else if (typeof descriptor.get === 'function') {
  1565. fnKey = 'get';
  1566. fn = descriptor.get;
  1567. }
  1568. if (!fn) {
  1569. throw new Error('not supported');
  1570. }
  1571. var memoizeKey = memoizeKeyPrefix + ":" + key;
  1572. descriptor[fnKey] = function () {
  1573. var args = [];
  1574. for (var _i = 0; _i < arguments.length; _i++) {
  1575. args[_i] = arguments[_i];
  1576. }
  1577. self = this;
  1578. if (!this.hasOwnProperty(memoizeKey)) {
  1579. Object.defineProperty(this, memoizeKey, {
  1580. configurable: true,
  1581. enumerable: false,
  1582. writable: true,
  1583. value: fn.apply(this, args)
  1584. });
  1585. }
  1586. return this[memoizeKey];
  1587. };
  1588. };
  1589. result.clear = function () {
  1590. if (typeof self === 'undefined') {
  1591. return;
  1592. }
  1593. Object.getOwnPropertyNames(self).forEach(function (property) {
  1594. if (property.indexOf(memoizeKeyPrefix) === 0) {
  1595. delete self[property];
  1596. }
  1597. });
  1598. };
  1599. return result;
  1600. }
  1601. exports.createMemoizer = createMemoizer;
  1602. function memoize(target, key, descriptor) {
  1603. return createMemoizer()(target, key, descriptor);
  1604. }
  1605. exports.memoize = memoize;
  1606. });
  1607. /*---------------------------------------------------------------------------------------------
  1608. * Copyright (c) Microsoft Corporation. All rights reserved.
  1609. * Licensed under the MIT License. See License.txt in the project root for license information.
  1610. *--------------------------------------------------------------------------------------------*/
  1611. define(__m[241/*vs/base/common/diff/diffChange*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  1612. "use strict";
  1613. Object.defineProperty(exports, "__esModule", { value: true });
  1614. /**
  1615. * Represents information about a specific difference between two sequences.
  1616. */
  1617. var DiffChange = /** @class */ (function () {
  1618. /**
  1619. * Constructs a new DiffChange with the given sequence information
  1620. * and content.
  1621. */
  1622. function DiffChange(originalStart, originalLength, modifiedStart, modifiedLength) {
  1623. //Debug.Assert(originalLength > 0 || modifiedLength > 0, "originalLength and modifiedLength cannot both be <= 0");
  1624. this.originalStart = originalStart;
  1625. this.originalLength = originalLength;
  1626. this.modifiedStart = modifiedStart;
  1627. this.modifiedLength = modifiedLength;
  1628. }
  1629. /**
  1630. * The end point (exclusive) of the change in the original sequence.
  1631. */
  1632. DiffChange.prototype.getOriginalEnd = function () {
  1633. return this.originalStart + this.originalLength;
  1634. };
  1635. /**
  1636. * The end point (exclusive) of the change in the modified sequence.
  1637. */
  1638. DiffChange.prototype.getModifiedEnd = function () {
  1639. return this.modifiedStart + this.modifiedLength;
  1640. };
  1641. return DiffChange;
  1642. }());
  1643. exports.DiffChange = DiffChange;
  1644. });
  1645. /*---------------------------------------------------------------------------------------------
  1646. * Copyright (c) Microsoft Corporation. All rights reserved.
  1647. * Licensed under the MIT License. See License.txt in the project root for license information.
  1648. *--------------------------------------------------------------------------------------------*/
  1649. define(__m[10/*vs/base/common/errors*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  1650. "use strict";
  1651. Object.defineProperty(exports, "__esModule", { value: true });
  1652. // Avoid circular dependency on EventEmitter by implementing a subset of the interface.
  1653. var ErrorHandler = /** @class */ (function () {
  1654. function ErrorHandler() {
  1655. this.listeners = [];
  1656. this.unexpectedErrorHandler = function (e) {
  1657. setTimeout(function () {
  1658. if (e.stack) {
  1659. throw new Error(e.message + '\n\n' + e.stack);
  1660. }
  1661. throw e;
  1662. }, 0);
  1663. };
  1664. }
  1665. ErrorHandler.prototype.emit = function (e) {
  1666. this.listeners.forEach(function (listener) {
  1667. listener(e);
  1668. });
  1669. };
  1670. ErrorHandler.prototype.onUnexpectedError = function (e) {
  1671. this.unexpectedErrorHandler(e);
  1672. this.emit(e);
  1673. };
  1674. // For external errors, we don't want the listeners to be called
  1675. ErrorHandler.prototype.onUnexpectedExternalError = function (e) {
  1676. this.unexpectedErrorHandler(e);
  1677. };
  1678. return ErrorHandler;
  1679. }());
  1680. exports.ErrorHandler = ErrorHandler;
  1681. exports.errorHandler = new ErrorHandler();
  1682. function onUnexpectedError(e) {
  1683. // ignore errors from cancelled promises
  1684. if (!isPromiseCanceledError(e)) {
  1685. exports.errorHandler.onUnexpectedError(e);
  1686. }
  1687. return undefined;
  1688. }
  1689. exports.onUnexpectedError = onUnexpectedError;
  1690. function onUnexpectedExternalError(e) {
  1691. // ignore errors from cancelled promises
  1692. if (!isPromiseCanceledError(e)) {
  1693. exports.errorHandler.onUnexpectedExternalError(e);
  1694. }
  1695. return undefined;
  1696. }
  1697. exports.onUnexpectedExternalError = onUnexpectedExternalError;
  1698. function transformErrorForSerialization(error) {
  1699. if (error instanceof Error) {
  1700. var name_1 = error.name, message = error.message;
  1701. var stack = error.stacktrace || error.stack;
  1702. return {
  1703. $isError: true,
  1704. name: name_1,
  1705. message: message,
  1706. stack: stack
  1707. };
  1708. }
  1709. // return as is
  1710. return error;
  1711. }
  1712. exports.transformErrorForSerialization = transformErrorForSerialization;
  1713. var canceledName = 'Canceled';
  1714. /**
  1715. * Checks if the given error is a promise in canceled state
  1716. */
  1717. function isPromiseCanceledError(error) {
  1718. return error instanceof Error && error.name === canceledName && error.message === canceledName;
  1719. }
  1720. exports.isPromiseCanceledError = isPromiseCanceledError;
  1721. /**
  1722. * Returns an error that signals cancellation.
  1723. */
  1724. function canceled() {
  1725. var error = new Error(canceledName);
  1726. error.name = error.message;
  1727. return error;
  1728. }
  1729. exports.canceled = canceled;
  1730. function illegalArgument(name) {
  1731. if (name) {
  1732. return new Error("Illegal argument: " + name);
  1733. }
  1734. else {
  1735. return new Error('Illegal argument');
  1736. }
  1737. }
  1738. exports.illegalArgument = illegalArgument;
  1739. function illegalState(name) {
  1740. if (name) {
  1741. return new Error("Illegal state: " + name);
  1742. }
  1743. else {
  1744. return new Error('Illegal state');
  1745. }
  1746. }
  1747. exports.illegalState = illegalState;
  1748. });
  1749. /*---------------------------------------------------------------------------------------------
  1750. * Copyright (c) Microsoft Corporation. All rights reserved.
  1751. * Licensed under the MIT License. See License.txt in the project root for license information.
  1752. *--------------------------------------------------------------------------------------------*/
  1753. define(__m[102/*vs/base/common/functional*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  1754. "use strict";
  1755. Object.defineProperty(exports, "__esModule", { value: true });
  1756. function once(fn) {
  1757. var _this = this;
  1758. var didCall = false;
  1759. var result;
  1760. return function () {
  1761. if (didCall) {
  1762. return result;
  1763. }
  1764. didCall = true;
  1765. result = fn.apply(_this, arguments);
  1766. return result;
  1767. };
  1768. }
  1769. exports.once = once;
  1770. });
  1771. /*---------------------------------------------------------------------------------------------
  1772. * Copyright (c) Microsoft Corporation. All rights reserved.
  1773. * Licensed under the MIT License. See License.txt in the project root for license information.
  1774. *--------------------------------------------------------------------------------------------*/
  1775. define(__m[125/*vs/base/common/hash*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  1776. "use strict";
  1777. Object.defineProperty(exports, "__esModule", { value: true });
  1778. /**
  1779. * Return a hash value for an object.
  1780. */
  1781. function hash(obj, hashVal) {
  1782. if (hashVal === void 0) { hashVal = 0; }
  1783. switch (typeof obj) {
  1784. case 'object':
  1785. if (obj === null) {
  1786. return numberHash(349, hashVal);
  1787. }
  1788. else if (Array.isArray(obj)) {
  1789. return arrayHash(obj, hashVal);
  1790. }
  1791. return objectHash(obj, hashVal);
  1792. case 'string':
  1793. return stringHash(obj, hashVal);
  1794. case 'boolean':
  1795. return booleanHash(obj, hashVal);
  1796. case 'number':
  1797. return numberHash(obj, hashVal);
  1798. case 'undefined':
  1799. return numberHash(0, 937);
  1800. default:
  1801. return numberHash(0, 617);
  1802. }
  1803. }
  1804. exports.hash = hash;
  1805. function numberHash(val, initialHashVal) {
  1806. return (((initialHashVal << 5) - initialHashVal) + val) | 0; // hashVal * 31 + ch, keep as int32
  1807. }
  1808. function booleanHash(b, initialHashVal) {
  1809. return numberHash(b ? 433 : 863, initialHashVal);
  1810. }
  1811. function stringHash(s, hashVal) {
  1812. hashVal = numberHash(149417, hashVal);
  1813. for (var i = 0, length_1 = s.length; i < length_1; i++) {
  1814. hashVal = numberHash(s.charCodeAt(i), hashVal);
  1815. }
  1816. return hashVal;
  1817. }
  1818. exports.stringHash = stringHash;
  1819. function arrayHash(arr, initialHashVal) {
  1820. initialHashVal = numberHash(104579, initialHashVal);
  1821. return arr.reduce(function (hashVal, item) { return hash(item, hashVal); }, initialHashVal);
  1822. }
  1823. function objectHash(obj, initialHashVal) {
  1824. initialHashVal = numberHash(181387, initialHashVal);
  1825. return Object.keys(obj).sort().reduce(function (hashVal, key) {
  1826. hashVal = stringHash(key, hashVal);
  1827. return hash(obj[key], hashVal);
  1828. }, initialHashVal);
  1829. }
  1830. });
  1831. /*---------------------------------------------------------------------------------------------
  1832. * Copyright (c) Microsoft Corporation. All rights reserved.
  1833. * Licensed under the MIT License. See License.txt in the project root for license information.
  1834. *--------------------------------------------------------------------------------------------*/
  1835. define(__m[126/*vs/base/common/diff/diff*/], __M([0/*require*/,1/*exports*/,241/*vs/base/common/diff/diffChange*/,125/*vs/base/common/hash*/]), function (require, exports, diffChange_1, hash_1) {
  1836. "use strict";
  1837. Object.defineProperty(exports, "__esModule", { value: true });
  1838. var StringDiffSequence = /** @class */ (function () {
  1839. function StringDiffSequence(source) {
  1840. this.source = source;
  1841. }
  1842. StringDiffSequence.prototype.getElements = function () {
  1843. var source = this.source;
  1844. var characters = new Int32Array(source.length);
  1845. for (var i = 0, len = source.length; i < len; i++) {
  1846. characters[i] = source.charCodeAt(i);
  1847. }
  1848. return characters;
  1849. };
  1850. return StringDiffSequence;
  1851. }());
  1852. exports.StringDiffSequence = StringDiffSequence;
  1853. function stringDiff(original, modified, pretty) {
  1854. return new LcsDiff(new StringDiffSequence(original), new StringDiffSequence(modified)).ComputeDiff(pretty).changes;
  1855. }
  1856. exports.stringDiff = stringDiff;
  1857. //
  1858. // The code below has been ported from a C# implementation in VS
  1859. //
  1860. var Debug = /** @class */ (function () {
  1861. function Debug() {
  1862. }
  1863. Debug.Assert = function (condition, message) {
  1864. if (!condition) {
  1865. throw new Error(message);
  1866. }
  1867. };
  1868. return Debug;
  1869. }());
  1870. exports.Debug = Debug;
  1871. var MyArray = /** @class */ (function () {
  1872. function MyArray() {
  1873. }
  1874. /**
  1875. * Copies a range of elements from an Array starting at the specified source index and pastes
  1876. * them to another Array starting at the specified destination index. The length and the indexes
  1877. * are specified as 64-bit integers.
  1878. * sourceArray:
  1879. * The Array that contains the data to copy.
  1880. * sourceIndex:
  1881. * A 64-bit integer that represents the index in the sourceArray at which copying begins.
  1882. * destinationArray:
  1883. * The Array that receives the data.
  1884. * destinationIndex:
  1885. * A 64-bit integer that represents the index in the destinationArray at which storing begins.
  1886. * length:
  1887. * A 64-bit integer that represents the number of elements to copy.
  1888. */
  1889. MyArray.Copy = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) {
  1890. for (var i = 0; i < length; i++) {
  1891. destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];
  1892. }
  1893. };
  1894. MyArray.Copy2 = function (sourceArray, sourceIndex, destinationArray, destinationIndex, length) {
  1895. for (var i = 0; i < length; i++) {
  1896. destinationArray[destinationIndex + i] = sourceArray[sourceIndex + i];
  1897. }
  1898. };
  1899. return MyArray;
  1900. }());
  1901. exports.MyArray = MyArray;
  1902. /**
  1903. * A utility class which helps to create the set of DiffChanges from
  1904. * a difference operation. This class accepts original DiffElements and
  1905. * modified DiffElements that are involved in a particular change. The
  1906. * MarktNextChange() method can be called to mark the separation between
  1907. * distinct changes. At the end, the Changes property can be called to retrieve
  1908. * the constructed changes.
  1909. */
  1910. var DiffChangeHelper = /** @class */ (function () {
  1911. /**
  1912. * Constructs a new DiffChangeHelper for the given DiffSequences.
  1913. */
  1914. function DiffChangeHelper() {
  1915. this.m_changes = [];
  1916. this.m_originalStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  1917. this.m_modifiedStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  1918. this.m_originalCount = 0;
  1919. this.m_modifiedCount = 0;
  1920. }
  1921. /**
  1922. * Marks the beginning of the next change in the set of differences.
  1923. */
  1924. DiffChangeHelper.prototype.MarkNextChange = function () {
  1925. // Only add to the list if there is something to add
  1926. if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
  1927. // Add the new change to our list
  1928. this.m_changes.push(new diffChange_1.DiffChange(this.m_originalStart, this.m_originalCount, this.m_modifiedStart, this.m_modifiedCount));
  1929. }
  1930. // Reset for the next change
  1931. this.m_originalCount = 0;
  1932. this.m_modifiedCount = 0;
  1933. this.m_originalStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  1934. this.m_modifiedStart = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  1935. };
  1936. /**
  1937. * Adds the original element at the given position to the elements
  1938. * affected by the current change. The modified index gives context
  1939. * to the change position with respect to the original sequence.
  1940. * @param originalIndex The index of the original element to add.
  1941. * @param modifiedIndex The index of the modified element that provides corresponding position in the modified sequence.
  1942. */
  1943. DiffChangeHelper.prototype.AddOriginalElement = function (originalIndex, modifiedIndex) {
  1944. // The 'true' start index is the smallest of the ones we've seen
  1945. this.m_originalStart = Math.min(this.m_originalStart, originalIndex);
  1946. this.m_modifiedStart = Math.min(this.m_modifiedStart, modifiedIndex);
  1947. this.m_originalCount++;
  1948. };
  1949. /**
  1950. * Adds the modified element at the given position to the elements
  1951. * affected by the current change. The original index gives context
  1952. * to the change position with respect to the modified sequence.
  1953. * @param originalIndex The index of the original element that provides corresponding position in the original sequence.
  1954. * @param modifiedIndex The index of the modified element to add.
  1955. */
  1956. DiffChangeHelper.prototype.AddModifiedElement = function (originalIndex, modifiedIndex) {
  1957. // The 'true' start index is the smallest of the ones we've seen
  1958. this.m_originalStart = Math.min(this.m_originalStart, originalIndex);
  1959. this.m_modifiedStart = Math.min(this.m_modifiedStart, modifiedIndex);
  1960. this.m_modifiedCount++;
  1961. };
  1962. /**
  1963. * Retrieves all of the changes marked by the class.
  1964. */
  1965. DiffChangeHelper.prototype.getChanges = function () {
  1966. if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
  1967. // Finish up on whatever is left
  1968. this.MarkNextChange();
  1969. }
  1970. return this.m_changes;
  1971. };
  1972. /**
  1973. * Retrieves all of the changes marked by the class in the reverse order
  1974. */
  1975. DiffChangeHelper.prototype.getReverseChanges = function () {
  1976. if (this.m_originalCount > 0 || this.m_modifiedCount > 0) {
  1977. // Finish up on whatever is left
  1978. this.MarkNextChange();
  1979. }
  1980. this.m_changes.reverse();
  1981. return this.m_changes;
  1982. };
  1983. return DiffChangeHelper;
  1984. }());
  1985. /**
  1986. * An implementation of the difference algorithm described in
  1987. * "An O(ND) Difference Algorithm and its variations" by Eugene W. Myers
  1988. */
  1989. var LcsDiff = /** @class */ (function () {
  1990. /**
  1991. * Constructs the DiffFinder
  1992. */
  1993. function LcsDiff(originalSequence, modifiedSequence, continueProcessingPredicate) {
  1994. if (continueProcessingPredicate === void 0) { continueProcessingPredicate = null; }
  1995. this.ContinueProcessingPredicate = continueProcessingPredicate;
  1996. var _a = LcsDiff._getElements(originalSequence), originalStringElements = _a[0], originalElementsOrHash = _a[1], originalHasStrings = _a[2];
  1997. var _b = LcsDiff._getElements(modifiedSequence), modifiedStringElements = _b[0], modifiedElementsOrHash = _b[1], modifiedHasStrings = _b[2];
  1998. this._hasStrings = (originalHasStrings && modifiedHasStrings);
  1999. this._originalStringElements = originalStringElements;
  2000. this._originalElementsOrHash = originalElementsOrHash;
  2001. this._modifiedStringElements = modifiedStringElements;
  2002. this._modifiedElementsOrHash = modifiedElementsOrHash;
  2003. this.m_forwardHistory = [];
  2004. this.m_reverseHistory = [];
  2005. }
  2006. LcsDiff._isStringArray = function (arr) {
  2007. return (arr.length > 0 && typeof arr[0] === 'string');
  2008. };
  2009. LcsDiff._getElements = function (sequence) {
  2010. var elements = sequence.getElements();
  2011. if (LcsDiff._isStringArray(elements)) {
  2012. var hashes = new Int32Array(elements.length);
  2013. for (var i = 0, len = elements.length; i < len; i++) {
  2014. hashes[i] = hash_1.stringHash(elements[i], 0);
  2015. }
  2016. return [elements, hashes, true];
  2017. }
  2018. if (elements instanceof Int32Array) {
  2019. return [[], elements, false];
  2020. }
  2021. return [[], new Int32Array(elements), false];
  2022. };
  2023. LcsDiff.prototype.ElementsAreEqual = function (originalIndex, newIndex) {
  2024. if (this._originalElementsOrHash[originalIndex] !== this._modifiedElementsOrHash[newIndex]) {
  2025. return false;
  2026. }
  2027. return (this._hasStrings ? this._originalStringElements[originalIndex] === this._modifiedStringElements[newIndex] : true);
  2028. };
  2029. LcsDiff.prototype.OriginalElementsAreEqual = function (index1, index2) {
  2030. if (this._originalElementsOrHash[index1] !== this._originalElementsOrHash[index2]) {
  2031. return false;
  2032. }
  2033. return (this._hasStrings ? this._originalStringElements[index1] === this._originalStringElements[index2] : true);
  2034. };
  2035. LcsDiff.prototype.ModifiedElementsAreEqual = function (index1, index2) {
  2036. if (this._modifiedElementsOrHash[index1] !== this._modifiedElementsOrHash[index2]) {
  2037. return false;
  2038. }
  2039. return (this._hasStrings ? this._modifiedStringElements[index1] === this._modifiedStringElements[index2] : true);
  2040. };
  2041. LcsDiff.prototype.ComputeDiff = function (pretty) {
  2042. return this._ComputeDiff(0, this._originalElementsOrHash.length - 1, 0, this._modifiedElementsOrHash.length - 1, pretty);
  2043. };
  2044. /**
  2045. * Computes the differences between the original and modified input
  2046. * sequences on the bounded range.
  2047. * @returns An array of the differences between the two input sequences.
  2048. */
  2049. LcsDiff.prototype._ComputeDiff = function (originalStart, originalEnd, modifiedStart, modifiedEnd, pretty) {
  2050. var quitEarlyArr = [false];
  2051. var changes = this.ComputeDiffRecursive(originalStart, originalEnd, modifiedStart, modifiedEnd, quitEarlyArr);
  2052. if (pretty) {
  2053. // We have to clean up the computed diff to be more intuitive
  2054. // but it turns out this cannot be done correctly until the entire set
  2055. // of diffs have been computed
  2056. changes = this.PrettifyChanges(changes);
  2057. }
  2058. return {
  2059. quitEarly: quitEarlyArr[0],
  2060. changes: changes
  2061. };
  2062. };
  2063. /**
  2064. * Private helper method which computes the differences on the bounded range
  2065. * recursively.
  2066. * @returns An array of the differences between the two input sequences.
  2067. */
  2068. LcsDiff.prototype.ComputeDiffRecursive = function (originalStart, originalEnd, modifiedStart, modifiedEnd, quitEarlyArr) {
  2069. quitEarlyArr[0] = false;
  2070. // Find the start of the differences
  2071. while (originalStart <= originalEnd && modifiedStart <= modifiedEnd && this.ElementsAreEqual(originalStart, modifiedStart)) {
  2072. originalStart++;
  2073. modifiedStart++;
  2074. }
  2075. // Find the end of the differences
  2076. while (originalEnd >= originalStart && modifiedEnd >= modifiedStart && this.ElementsAreEqual(originalEnd, modifiedEnd)) {
  2077. originalEnd--;
  2078. modifiedEnd--;
  2079. }
  2080. // In the special case where we either have all insertions or all deletions or the sequences are identical
  2081. if (originalStart > originalEnd || modifiedStart > modifiedEnd) {
  2082. var changes = void 0;
  2083. if (modifiedStart <= modifiedEnd) {
  2084. Debug.Assert(originalStart === originalEnd + 1, 'originalStart should only be one more than originalEnd');
  2085. // All insertions
  2086. changes = [
  2087. new diffChange_1.DiffChange(originalStart, 0, modifiedStart, modifiedEnd - modifiedStart + 1)
  2088. ];
  2089. }
  2090. else if (originalStart <= originalEnd) {
  2091. Debug.Assert(modifiedStart === modifiedEnd + 1, 'modifiedStart should only be one more than modifiedEnd');
  2092. // All deletions
  2093. changes = [
  2094. new diffChange_1.DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, 0)
  2095. ];
  2096. }
  2097. else {
  2098. Debug.Assert(originalStart === originalEnd + 1, 'originalStart should only be one more than originalEnd');
  2099. Debug.Assert(modifiedStart === modifiedEnd + 1, 'modifiedStart should only be one more than modifiedEnd');
  2100. // Identical sequences - No differences
  2101. changes = [];
  2102. }
  2103. return changes;
  2104. }
  2105. // This problem can be solved using the Divide-And-Conquer technique.
  2106. var midOriginalArr = [0];
  2107. var midModifiedArr = [0];
  2108. var result = this.ComputeRecursionPoint(originalStart, originalEnd, modifiedStart, modifiedEnd, midOriginalArr, midModifiedArr, quitEarlyArr);
  2109. var midOriginal = midOriginalArr[0];
  2110. var midModified = midModifiedArr[0];
  2111. if (result !== null) {
  2112. // Result is not-null when there was enough memory to compute the changes while
  2113. // searching for the recursion point
  2114. return result;
  2115. }
  2116. else if (!quitEarlyArr[0]) {
  2117. // We can break the problem down recursively by finding the changes in the
  2118. // First Half: (originalStart, modifiedStart) to (midOriginal, midModified)
  2119. // Second Half: (midOriginal + 1, minModified + 1) to (originalEnd, modifiedEnd)
  2120. // NOTE: ComputeDiff() is inclusive, therefore the second range starts on the next point
  2121. var leftChanges = this.ComputeDiffRecursive(originalStart, midOriginal, modifiedStart, midModified, quitEarlyArr);
  2122. var rightChanges = [];
  2123. if (!quitEarlyArr[0]) {
  2124. rightChanges = this.ComputeDiffRecursive(midOriginal + 1, originalEnd, midModified + 1, modifiedEnd, quitEarlyArr);
  2125. }
  2126. else {
  2127. // We did't have time to finish the first half, so we don't have time to compute this half.
  2128. // Consider the entire rest of the sequence different.
  2129. rightChanges = [
  2130. new diffChange_1.DiffChange(midOriginal + 1, originalEnd - (midOriginal + 1) + 1, midModified + 1, modifiedEnd - (midModified + 1) + 1)
  2131. ];
  2132. }
  2133. return this.ConcatenateChanges(leftChanges, rightChanges);
  2134. }
  2135. // If we hit here, we quit early, and so can't return anything meaningful
  2136. return [
  2137. new diffChange_1.DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, modifiedEnd - modifiedStart + 1)
  2138. ];
  2139. };
  2140. LcsDiff.prototype.WALKTRACE = function (diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr) {
  2141. var forwardChanges = null;
  2142. var reverseChanges = null;
  2143. // First, walk backward through the forward diagonals history
  2144. var changeHelper = new DiffChangeHelper();
  2145. var diagonalMin = diagonalForwardStart;
  2146. var diagonalMax = diagonalForwardEnd;
  2147. var diagonalRelative = (midOriginalArr[0] - midModifiedArr[0]) - diagonalForwardOffset;
  2148. var lastOriginalIndex = -1073741824 /* MIN_SAFE_SMALL_INTEGER */;
  2149. var historyIndex = this.m_forwardHistory.length - 1;
  2150. do {
  2151. // Get the diagonal index from the relative diagonal number
  2152. var diagonal = diagonalRelative + diagonalForwardBase;
  2153. // Figure out where we came from
  2154. if (diagonal === diagonalMin || (diagonal < diagonalMax && forwardPoints[diagonal - 1] < forwardPoints[diagonal + 1])) {
  2155. // Vertical line (the element is an insert)
  2156. originalIndex = forwardPoints[diagonal + 1];
  2157. modifiedIndex = originalIndex - diagonalRelative - diagonalForwardOffset;
  2158. if (originalIndex < lastOriginalIndex) {
  2159. changeHelper.MarkNextChange();
  2160. }
  2161. lastOriginalIndex = originalIndex;
  2162. changeHelper.AddModifiedElement(originalIndex + 1, modifiedIndex);
  2163. diagonalRelative = (diagonal + 1) - diagonalForwardBase; //Setup for the next iteration
  2164. }
  2165. else {
  2166. // Horizontal line (the element is a deletion)
  2167. originalIndex = forwardPoints[diagonal - 1] + 1;
  2168. modifiedIndex = originalIndex - diagonalRelative - diagonalForwardOffset;
  2169. if (originalIndex < lastOriginalIndex) {
  2170. changeHelper.MarkNextChange();
  2171. }
  2172. lastOriginalIndex = originalIndex - 1;
  2173. changeHelper.AddOriginalElement(originalIndex, modifiedIndex + 1);
  2174. diagonalRelative = (diagonal - 1) - diagonalForwardBase; //Setup for the next iteration
  2175. }
  2176. if (historyIndex >= 0) {
  2177. forwardPoints = this.m_forwardHistory[historyIndex];
  2178. diagonalForwardBase = forwardPoints[0]; //We stored this in the first spot
  2179. diagonalMin = 1;
  2180. diagonalMax = forwardPoints.length - 1;
  2181. }
  2182. } while (--historyIndex >= -1);
  2183. // Ironically, we get the forward changes as the reverse of the
  2184. // order we added them since we technically added them backwards
  2185. forwardChanges = changeHelper.getReverseChanges();
  2186. if (quitEarlyArr[0]) {
  2187. // TODO: Calculate a partial from the reverse diagonals.
  2188. // For now, just assume everything after the midOriginal/midModified point is a diff
  2189. var originalStartPoint = midOriginalArr[0] + 1;
  2190. var modifiedStartPoint = midModifiedArr[0] + 1;
  2191. if (forwardChanges !== null && forwardChanges.length > 0) {
  2192. var lastForwardChange = forwardChanges[forwardChanges.length - 1];
  2193. originalStartPoint = Math.max(originalStartPoint, lastForwardChange.getOriginalEnd());
  2194. modifiedStartPoint = Math.max(modifiedStartPoint, lastForwardChange.getModifiedEnd());
  2195. }
  2196. reverseChanges = [
  2197. new diffChange_1.DiffChange(originalStartPoint, originalEnd - originalStartPoint + 1, modifiedStartPoint, modifiedEnd - modifiedStartPoint + 1)
  2198. ];
  2199. }
  2200. else {
  2201. // Now walk backward through the reverse diagonals history
  2202. changeHelper = new DiffChangeHelper();
  2203. diagonalMin = diagonalReverseStart;
  2204. diagonalMax = diagonalReverseEnd;
  2205. diagonalRelative = (midOriginalArr[0] - midModifiedArr[0]) - diagonalReverseOffset;
  2206. lastOriginalIndex = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  2207. historyIndex = (deltaIsEven) ? this.m_reverseHistory.length - 1 : this.m_reverseHistory.length - 2;
  2208. do {
  2209. // Get the diagonal index from the relative diagonal number
  2210. var diagonal = diagonalRelative + diagonalReverseBase;
  2211. // Figure out where we came from
  2212. if (diagonal === diagonalMin || (diagonal < diagonalMax && reversePoints[diagonal - 1] >= reversePoints[diagonal + 1])) {
  2213. // Horizontal line (the element is a deletion))
  2214. originalIndex = reversePoints[diagonal + 1] - 1;
  2215. modifiedIndex = originalIndex - diagonalRelative - diagonalReverseOffset;
  2216. if (originalIndex > lastOriginalIndex) {
  2217. changeHelper.MarkNextChange();
  2218. }
  2219. lastOriginalIndex = originalIndex + 1;
  2220. changeHelper.AddOriginalElement(originalIndex + 1, modifiedIndex + 1);
  2221. diagonalRelative = (diagonal + 1) - diagonalReverseBase; //Setup for the next iteration
  2222. }
  2223. else {
  2224. // Vertical line (the element is an insertion)
  2225. originalIndex = reversePoints[diagonal - 1];
  2226. modifiedIndex = originalIndex - diagonalRelative - diagonalReverseOffset;
  2227. if (originalIndex > lastOriginalIndex) {
  2228. changeHelper.MarkNextChange();
  2229. }
  2230. lastOriginalIndex = originalIndex;
  2231. changeHelper.AddModifiedElement(originalIndex + 1, modifiedIndex + 1);
  2232. diagonalRelative = (diagonal - 1) - diagonalReverseBase; //Setup for the next iteration
  2233. }
  2234. if (historyIndex >= 0) {
  2235. reversePoints = this.m_reverseHistory[historyIndex];
  2236. diagonalReverseBase = reversePoints[0]; //We stored this in the first spot
  2237. diagonalMin = 1;
  2238. diagonalMax = reversePoints.length - 1;
  2239. }
  2240. } while (--historyIndex >= -1);
  2241. // There are cases where the reverse history will find diffs that
  2242. // are correct, but not intuitive, so we need shift them.
  2243. reverseChanges = changeHelper.getChanges();
  2244. }
  2245. return this.ConcatenateChanges(forwardChanges, reverseChanges);
  2246. };
  2247. /**
  2248. * Given the range to compute the diff on, this method finds the point:
  2249. * (midOriginal, midModified)
  2250. * that exists in the middle of the LCS of the two sequences and
  2251. * is the point at which the LCS problem may be broken down recursively.
  2252. * This method will try to keep the LCS trace in memory. If the LCS recursion
  2253. * point is calculated and the full trace is available in memory, then this method
  2254. * will return the change list.
  2255. * @param originalStart The start bound of the original sequence range
  2256. * @param originalEnd The end bound of the original sequence range
  2257. * @param modifiedStart The start bound of the modified sequence range
  2258. * @param modifiedEnd The end bound of the modified sequence range
  2259. * @param midOriginal The middle point of the original sequence range
  2260. * @param midModified The middle point of the modified sequence range
  2261. * @returns The diff changes, if available, otherwise null
  2262. */
  2263. LcsDiff.prototype.ComputeRecursionPoint = function (originalStart, originalEnd, modifiedStart, modifiedEnd, midOriginalArr, midModifiedArr, quitEarlyArr) {
  2264. var originalIndex = 0, modifiedIndex = 0;
  2265. var diagonalForwardStart = 0, diagonalForwardEnd = 0;
  2266. var diagonalReverseStart = 0, diagonalReverseEnd = 0;
  2267. // To traverse the edit graph and produce the proper LCS, our actual
  2268. // start position is just outside the given boundary
  2269. originalStart--;
  2270. modifiedStart--;
  2271. // We set these up to make the compiler happy, but they will
  2272. // be replaced before we return with the actual recursion point
  2273. midOriginalArr[0] = 0;
  2274. midModifiedArr[0] = 0;
  2275. // Clear out the history
  2276. this.m_forwardHistory = [];
  2277. this.m_reverseHistory = [];
  2278. // Each cell in the two arrays corresponds to a diagonal in the edit graph.
  2279. // The integer value in the cell represents the originalIndex of the furthest
  2280. // reaching point found so far that ends in that diagonal.
  2281. // The modifiedIndex can be computed mathematically from the originalIndex and the diagonal number.
  2282. var maxDifferences = (originalEnd - originalStart) + (modifiedEnd - modifiedStart);
  2283. var numDiagonals = maxDifferences + 1;
  2284. var forwardPoints = new Int32Array(numDiagonals);
  2285. var reversePoints = new Int32Array(numDiagonals);
  2286. // diagonalForwardBase: Index into forwardPoints of the diagonal which passes through (originalStart, modifiedStart)
  2287. // diagonalReverseBase: Index into reversePoints of the diagonal which passes through (originalEnd, modifiedEnd)
  2288. var diagonalForwardBase = (modifiedEnd - modifiedStart);
  2289. var diagonalReverseBase = (originalEnd - originalStart);
  2290. // diagonalForwardOffset: Geometric offset which allows modifiedIndex to be computed from originalIndex and the
  2291. // diagonal number (relative to diagonalForwardBase)
  2292. // diagonalReverseOffset: Geometric offset which allows modifiedIndex to be computed from originalIndex and the
  2293. // diagonal number (relative to diagonalReverseBase)
  2294. var diagonalForwardOffset = (originalStart - modifiedStart);
  2295. var diagonalReverseOffset = (originalEnd - modifiedEnd);
  2296. // delta: The difference between the end diagonal and the start diagonal. This is used to relate diagonal numbers
  2297. // relative to the start diagonal with diagonal numbers relative to the end diagonal.
  2298. // The Even/Oddn-ness of this delta is important for determining when we should check for overlap
  2299. var delta = diagonalReverseBase - diagonalForwardBase;
  2300. var deltaIsEven = (delta % 2 === 0);
  2301. // Here we set up the start and end points as the furthest points found so far
  2302. // in both the forward and reverse directions, respectively
  2303. forwardPoints[diagonalForwardBase] = originalStart;
  2304. reversePoints[diagonalReverseBase] = originalEnd;
  2305. // Remember if we quit early, and thus need to do a best-effort result instead of a real result.
  2306. quitEarlyArr[0] = false;
  2307. // A couple of points:
  2308. // --With this method, we iterate on the number of differences between the two sequences.
  2309. // The more differences there actually are, the longer this will take.
  2310. // --Also, as the number of differences increases, we have to search on diagonals further
  2311. // away from the reference diagonal (which is diagonalForwardBase for forward, diagonalReverseBase for reverse).
  2312. // --We extend on even diagonals (relative to the reference diagonal) only when numDifferences
  2313. // is even and odd diagonals only when numDifferences is odd.
  2314. for (var numDifferences = 1; numDifferences <= (maxDifferences / 2) + 1; numDifferences++) {
  2315. var furthestOriginalIndex = 0;
  2316. var furthestModifiedIndex = 0;
  2317. // Run the algorithm in the forward direction
  2318. diagonalForwardStart = this.ClipDiagonalBound(diagonalForwardBase - numDifferences, numDifferences, diagonalForwardBase, numDiagonals);
  2319. diagonalForwardEnd = this.ClipDiagonalBound(diagonalForwardBase + numDifferences, numDifferences, diagonalForwardBase, numDiagonals);
  2320. for (var diagonal = diagonalForwardStart; diagonal <= diagonalForwardEnd; diagonal += 2) {
  2321. // STEP 1: We extend the furthest reaching point in the present diagonal
  2322. // by looking at the diagonals above and below and picking the one whose point
  2323. // is further away from the start point (originalStart, modifiedStart)
  2324. if (diagonal === diagonalForwardStart || (diagonal < diagonalForwardEnd && forwardPoints[diagonal - 1] < forwardPoints[diagonal + 1])) {
  2325. originalIndex = forwardPoints[diagonal + 1];
  2326. }
  2327. else {
  2328. originalIndex = forwardPoints[diagonal - 1] + 1;
  2329. }
  2330. modifiedIndex = originalIndex - (diagonal - diagonalForwardBase) - diagonalForwardOffset;
  2331. // Save the current originalIndex so we can test for false overlap in step 3
  2332. var tempOriginalIndex = originalIndex;
  2333. // STEP 2: We can continue to extend the furthest reaching point in the present diagonal
  2334. // so long as the elements are equal.
  2335. while (originalIndex < originalEnd && modifiedIndex < modifiedEnd && this.ElementsAreEqual(originalIndex + 1, modifiedIndex + 1)) {
  2336. originalIndex++;
  2337. modifiedIndex++;
  2338. }
  2339. forwardPoints[diagonal] = originalIndex;
  2340. if (originalIndex + modifiedIndex > furthestOriginalIndex + furthestModifiedIndex) {
  2341. furthestOriginalIndex = originalIndex;
  2342. furthestModifiedIndex = modifiedIndex;
  2343. }
  2344. // STEP 3: If delta is odd (overlap first happens on forward when delta is odd)
  2345. // and diagonal is in the range of reverse diagonals computed for numDifferences-1
  2346. // (the previous iteration; we haven't computed reverse diagonals for numDifferences yet)
  2347. // then check for overlap.
  2348. if (!deltaIsEven && Math.abs(diagonal - diagonalReverseBase) <= (numDifferences - 1)) {
  2349. if (originalIndex >= reversePoints[diagonal]) {
  2350. midOriginalArr[0] = originalIndex;
  2351. midModifiedArr[0] = modifiedIndex;
  2352. if (tempOriginalIndex <= reversePoints[diagonal] && 1447 /* MaxDifferencesHistory */ > 0 && numDifferences <= (1447 /* MaxDifferencesHistory */ + 1)) {
  2353. // BINGO! We overlapped, and we have the full trace in memory!
  2354. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  2355. }
  2356. else {
  2357. // Either false overlap, or we didn't have enough memory for the full trace
  2358. // Just return the recursion point
  2359. return null;
  2360. }
  2361. }
  2362. }
  2363. }
  2364. // Check to see if we should be quitting early, before moving on to the next iteration.
  2365. var matchLengthOfLongest = ((furthestOriginalIndex - originalStart) + (furthestModifiedIndex - modifiedStart) - numDifferences) / 2;
  2366. if (this.ContinueProcessingPredicate !== null && !this.ContinueProcessingPredicate(furthestOriginalIndex, matchLengthOfLongest)) {
  2367. // We can't finish, so skip ahead to generating a result from what we have.
  2368. quitEarlyArr[0] = true;
  2369. // Use the furthest distance we got in the forward direction.
  2370. midOriginalArr[0] = furthestOriginalIndex;
  2371. midModifiedArr[0] = furthestModifiedIndex;
  2372. if (matchLengthOfLongest > 0 && 1447 /* MaxDifferencesHistory */ > 0 && numDifferences <= (1447 /* MaxDifferencesHistory */ + 1)) {
  2373. // Enough of the history is in memory to walk it backwards
  2374. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  2375. }
  2376. else {
  2377. // We didn't actually remember enough of the history.
  2378. //Since we are quiting the diff early, we need to shift back the originalStart and modified start
  2379. //back into the boundary limits since we decremented their value above beyond the boundary limit.
  2380. originalStart++;
  2381. modifiedStart++;
  2382. return [
  2383. new diffChange_1.DiffChange(originalStart, originalEnd - originalStart + 1, modifiedStart, modifiedEnd - modifiedStart + 1)
  2384. ];
  2385. }
  2386. }
  2387. // Run the algorithm in the reverse direction
  2388. diagonalReverseStart = this.ClipDiagonalBound(diagonalReverseBase - numDifferences, numDifferences, diagonalReverseBase, numDiagonals);
  2389. diagonalReverseEnd = this.ClipDiagonalBound(diagonalReverseBase + numDifferences, numDifferences, diagonalReverseBase, numDiagonals);
  2390. for (var diagonal = diagonalReverseStart; diagonal <= diagonalReverseEnd; diagonal += 2) {
  2391. // STEP 1: We extend the furthest reaching point in the present diagonal
  2392. // by looking at the diagonals above and below and picking the one whose point
  2393. // is further away from the start point (originalEnd, modifiedEnd)
  2394. if (diagonal === diagonalReverseStart || (diagonal < diagonalReverseEnd && reversePoints[diagonal - 1] >= reversePoints[diagonal + 1])) {
  2395. originalIndex = reversePoints[diagonal + 1] - 1;
  2396. }
  2397. else {
  2398. originalIndex = reversePoints[diagonal - 1];
  2399. }
  2400. modifiedIndex = originalIndex - (diagonal - diagonalReverseBase) - diagonalReverseOffset;
  2401. // Save the current originalIndex so we can test for false overlap
  2402. var tempOriginalIndex = originalIndex;
  2403. // STEP 2: We can continue to extend the furthest reaching point in the present diagonal
  2404. // as long as the elements are equal.
  2405. while (originalIndex > originalStart && modifiedIndex > modifiedStart && this.ElementsAreEqual(originalIndex, modifiedIndex)) {
  2406. originalIndex--;
  2407. modifiedIndex--;
  2408. }
  2409. reversePoints[diagonal] = originalIndex;
  2410. // STEP 4: If delta is even (overlap first happens on reverse when delta is even)
  2411. // and diagonal is in the range of forward diagonals computed for numDifferences
  2412. // then check for overlap.
  2413. if (deltaIsEven && Math.abs(diagonal - diagonalForwardBase) <= numDifferences) {
  2414. if (originalIndex <= forwardPoints[diagonal]) {
  2415. midOriginalArr[0] = originalIndex;
  2416. midModifiedArr[0] = modifiedIndex;
  2417. if (tempOriginalIndex >= forwardPoints[diagonal] && 1447 /* MaxDifferencesHistory */ > 0 && numDifferences <= (1447 /* MaxDifferencesHistory */ + 1)) {
  2418. // BINGO! We overlapped, and we have the full trace in memory!
  2419. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  2420. }
  2421. else {
  2422. // Either false overlap, or we didn't have enough memory for the full trace
  2423. // Just return the recursion point
  2424. return null;
  2425. }
  2426. }
  2427. }
  2428. }
  2429. // Save current vectors to history before the next iteration
  2430. if (numDifferences <= 1447 /* MaxDifferencesHistory */) {
  2431. // We are allocating space for one extra int, which we fill with
  2432. // the index of the diagonal base index
  2433. var temp = new Int32Array(diagonalForwardEnd - diagonalForwardStart + 2);
  2434. temp[0] = diagonalForwardBase - diagonalForwardStart + 1;
  2435. MyArray.Copy2(forwardPoints, diagonalForwardStart, temp, 1, diagonalForwardEnd - diagonalForwardStart + 1);
  2436. this.m_forwardHistory.push(temp);
  2437. temp = new Int32Array(diagonalReverseEnd - diagonalReverseStart + 2);
  2438. temp[0] = diagonalReverseBase - diagonalReverseStart + 1;
  2439. MyArray.Copy2(reversePoints, diagonalReverseStart, temp, 1, diagonalReverseEnd - diagonalReverseStart + 1);
  2440. this.m_reverseHistory.push(temp);
  2441. }
  2442. }
  2443. // If we got here, then we have the full trace in history. We just have to convert it to a change list
  2444. // NOTE: This part is a bit messy
  2445. return this.WALKTRACE(diagonalForwardBase, diagonalForwardStart, diagonalForwardEnd, diagonalForwardOffset, diagonalReverseBase, diagonalReverseStart, diagonalReverseEnd, diagonalReverseOffset, forwardPoints, reversePoints, originalIndex, originalEnd, midOriginalArr, modifiedIndex, modifiedEnd, midModifiedArr, deltaIsEven, quitEarlyArr);
  2446. };
  2447. /**
  2448. * Shifts the given changes to provide a more intuitive diff.
  2449. * While the first element in a diff matches the first element after the diff,
  2450. * we shift the diff down.
  2451. *
  2452. * @param changes The list of changes to shift
  2453. * @returns The shifted changes
  2454. */
  2455. LcsDiff.prototype.PrettifyChanges = function (changes) {
  2456. // Shift all the changes down first
  2457. for (var i = 0; i < changes.length; i++) {
  2458. var change = changes[i];
  2459. var originalStop = (i < changes.length - 1) ? changes[i + 1].originalStart : this._originalElementsOrHash.length;
  2460. var modifiedStop = (i < changes.length - 1) ? changes[i + 1].modifiedStart : this._modifiedElementsOrHash.length;
  2461. var checkOriginal = change.originalLength > 0;
  2462. var checkModified = change.modifiedLength > 0;
  2463. while (change.originalStart + change.originalLength < originalStop &&
  2464. change.modifiedStart + change.modifiedLength < modifiedStop &&
  2465. (!checkOriginal || this.OriginalElementsAreEqual(change.originalStart, change.originalStart + change.originalLength)) &&
  2466. (!checkModified || this.ModifiedElementsAreEqual(change.modifiedStart, change.modifiedStart + change.modifiedLength))) {
  2467. change.originalStart++;
  2468. change.modifiedStart++;
  2469. }
  2470. var mergedChangeArr = [null];
  2471. if (i < changes.length - 1 && this.ChangesOverlap(changes[i], changes[i + 1], mergedChangeArr)) {
  2472. changes[i] = mergedChangeArr[0];
  2473. changes.splice(i + 1, 1);
  2474. i--;
  2475. continue;
  2476. }
  2477. }
  2478. // Shift changes back up until we hit empty or whitespace-only lines
  2479. for (var i = changes.length - 1; i >= 0; i--) {
  2480. var change = changes[i];
  2481. var originalStop = 0;
  2482. var modifiedStop = 0;
  2483. if (i > 0) {
  2484. var prevChange = changes[i - 1];
  2485. if (prevChange.originalLength > 0) {
  2486. originalStop = prevChange.originalStart + prevChange.originalLength;
  2487. }
  2488. if (prevChange.modifiedLength > 0) {
  2489. modifiedStop = prevChange.modifiedStart + prevChange.modifiedLength;
  2490. }
  2491. }
  2492. var checkOriginal = change.originalLength > 0;
  2493. var checkModified = change.modifiedLength > 0;
  2494. var bestDelta = 0;
  2495. var bestScore = this._boundaryScore(change.originalStart, change.originalLength, change.modifiedStart, change.modifiedLength);
  2496. for (var delta = 1;; delta++) {
  2497. var originalStart = change.originalStart - delta;
  2498. var modifiedStart = change.modifiedStart - delta;
  2499. if (originalStart < originalStop || modifiedStart < modifiedStop) {
  2500. break;
  2501. }
  2502. if (checkOriginal && !this.OriginalElementsAreEqual(originalStart, originalStart + change.originalLength)) {
  2503. break;
  2504. }
  2505. if (checkModified && !this.ModifiedElementsAreEqual(modifiedStart, modifiedStart + change.modifiedLength)) {
  2506. break;
  2507. }
  2508. var score = this._boundaryScore(originalStart, change.originalLength, modifiedStart, change.modifiedLength);
  2509. if (score > bestScore) {
  2510. bestScore = score;
  2511. bestDelta = delta;
  2512. }
  2513. }
  2514. change.originalStart -= bestDelta;
  2515. change.modifiedStart -= bestDelta;
  2516. }
  2517. return changes;
  2518. };
  2519. LcsDiff.prototype._OriginalIsBoundary = function (index) {
  2520. if (index <= 0 || index >= this._originalElementsOrHash.length - 1) {
  2521. return true;
  2522. }
  2523. return (this._hasStrings && /^\s*$/.test(this._originalStringElements[index]));
  2524. };
  2525. LcsDiff.prototype._OriginalRegionIsBoundary = function (originalStart, originalLength) {
  2526. if (this._OriginalIsBoundary(originalStart) || this._OriginalIsBoundary(originalStart - 1)) {
  2527. return true;
  2528. }
  2529. if (originalLength > 0) {
  2530. var originalEnd = originalStart + originalLength;
  2531. if (this._OriginalIsBoundary(originalEnd - 1) || this._OriginalIsBoundary(originalEnd)) {
  2532. return true;
  2533. }
  2534. }
  2535. return false;
  2536. };
  2537. LcsDiff.prototype._ModifiedIsBoundary = function (index) {
  2538. if (index <= 0 || index >= this._modifiedElementsOrHash.length - 1) {
  2539. return true;
  2540. }
  2541. return (this._hasStrings && /^\s*$/.test(this._modifiedStringElements[index]));
  2542. };
  2543. LcsDiff.prototype._ModifiedRegionIsBoundary = function (modifiedStart, modifiedLength) {
  2544. if (this._ModifiedIsBoundary(modifiedStart) || this._ModifiedIsBoundary(modifiedStart - 1)) {
  2545. return true;
  2546. }
  2547. if (modifiedLength > 0) {
  2548. var modifiedEnd = modifiedStart + modifiedLength;
  2549. if (this._ModifiedIsBoundary(modifiedEnd - 1) || this._ModifiedIsBoundary(modifiedEnd)) {
  2550. return true;
  2551. }
  2552. }
  2553. return false;
  2554. };
  2555. LcsDiff.prototype._boundaryScore = function (originalStart, originalLength, modifiedStart, modifiedLength) {
  2556. var originalScore = (this._OriginalRegionIsBoundary(originalStart, originalLength) ? 1 : 0);
  2557. var modifiedScore = (this._ModifiedRegionIsBoundary(modifiedStart, modifiedLength) ? 1 : 0);
  2558. return (originalScore + modifiedScore);
  2559. };
  2560. /**
  2561. * Concatenates the two input DiffChange lists and returns the resulting
  2562. * list.
  2563. * @param The left changes
  2564. * @param The right changes
  2565. * @returns The concatenated list
  2566. */
  2567. LcsDiff.prototype.ConcatenateChanges = function (left, right) {
  2568. var mergedChangeArr = [];
  2569. if (left.length === 0 || right.length === 0) {
  2570. return (right.length > 0) ? right : left;
  2571. }
  2572. else if (this.ChangesOverlap(left[left.length - 1], right[0], mergedChangeArr)) {
  2573. // Since we break the problem down recursively, it is possible that we
  2574. // might recurse in the middle of a change thereby splitting it into
  2575. // two changes. Here in the combining stage, we detect and fuse those
  2576. // changes back together
  2577. var result = new Array(left.length + right.length - 1);
  2578. MyArray.Copy(left, 0, result, 0, left.length - 1);
  2579. result[left.length - 1] = mergedChangeArr[0];
  2580. MyArray.Copy(right, 1, result, left.length, right.length - 1);
  2581. return result;
  2582. }
  2583. else {
  2584. var result = new Array(left.length + right.length);
  2585. MyArray.Copy(left, 0, result, 0, left.length);
  2586. MyArray.Copy(right, 0, result, left.length, right.length);
  2587. return result;
  2588. }
  2589. };
  2590. /**
  2591. * Returns true if the two changes overlap and can be merged into a single
  2592. * change
  2593. * @param left The left change
  2594. * @param right The right change
  2595. * @param mergedChange The merged change if the two overlap, null otherwise
  2596. * @returns True if the two changes overlap
  2597. */
  2598. LcsDiff.prototype.ChangesOverlap = function (left, right, mergedChangeArr) {
  2599. Debug.Assert(left.originalStart <= right.originalStart, 'Left change is not less than or equal to right change');
  2600. Debug.Assert(left.modifiedStart <= right.modifiedStart, 'Left change is not less than or equal to right change');
  2601. if (left.originalStart + left.originalLength >= right.originalStart || left.modifiedStart + left.modifiedLength >= right.modifiedStart) {
  2602. var originalStart = left.originalStart;
  2603. var originalLength = left.originalLength;
  2604. var modifiedStart = left.modifiedStart;
  2605. var modifiedLength = left.modifiedLength;
  2606. if (left.originalStart + left.originalLength >= right.originalStart) {
  2607. originalLength = right.originalStart + right.originalLength - left.originalStart;
  2608. }
  2609. if (left.modifiedStart + left.modifiedLength >= right.modifiedStart) {
  2610. modifiedLength = right.modifiedStart + right.modifiedLength - left.modifiedStart;
  2611. }
  2612. mergedChangeArr[0] = new diffChange_1.DiffChange(originalStart, originalLength, modifiedStart, modifiedLength);
  2613. return true;
  2614. }
  2615. else {
  2616. mergedChangeArr[0] = null;
  2617. return false;
  2618. }
  2619. };
  2620. /**
  2621. * Helper method used to clip a diagonal index to the range of valid
  2622. * diagonals. This also decides whether or not the diagonal index,
  2623. * if it exceeds the boundary, should be clipped to the boundary or clipped
  2624. * one inside the boundary depending on the Even/Odd status of the boundary
  2625. * and numDifferences.
  2626. * @param diagonal The index of the diagonal to clip.
  2627. * @param numDifferences The current number of differences being iterated upon.
  2628. * @param diagonalBaseIndex The base reference diagonal.
  2629. * @param numDiagonals The total number of diagonals.
  2630. * @returns The clipped diagonal index.
  2631. */
  2632. LcsDiff.prototype.ClipDiagonalBound = function (diagonal, numDifferences, diagonalBaseIndex, numDiagonals) {
  2633. if (diagonal >= 0 && diagonal < numDiagonals) {
  2634. // Nothing to clip, its in range
  2635. return diagonal;
  2636. }
  2637. // diagonalsBelow: The number of diagonals below the reference diagonal
  2638. // diagonalsAbove: The number of diagonals above the reference diagonal
  2639. var diagonalsBelow = diagonalBaseIndex;
  2640. var diagonalsAbove = numDiagonals - diagonalBaseIndex - 1;
  2641. var diffEven = (numDifferences % 2 === 0);
  2642. if (diagonal < 0) {
  2643. var lowerBoundEven = (diagonalsBelow % 2 === 0);
  2644. return (diffEven === lowerBoundEven) ? 0 : 1;
  2645. }
  2646. else {
  2647. var upperBoundEven = (diagonalsAbove % 2 === 0);
  2648. return (diffEven === upperBoundEven) ? numDiagonals - 1 : numDiagonals - 2;
  2649. }
  2650. };
  2651. return LcsDiff;
  2652. }());
  2653. exports.LcsDiff = LcsDiff;
  2654. });
  2655. /*---------------------------------------------------------------------------------------------
  2656. * Copyright (c) Microsoft Corporation. All rights reserved.
  2657. * Licensed under the MIT License. See License.txt in the project root for license information.
  2658. *--------------------------------------------------------------------------------------------*/
  2659. define(__m[75/*vs/base/common/htmlContent*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,100/*vs/base/common/codicons*/]), function (require, exports, arrays_1, codicons_1) {
  2660. "use strict";
  2661. Object.defineProperty(exports, "__esModule", { value: true });
  2662. var MarkdownString = /** @class */ (function () {
  2663. function MarkdownString(_value, isTrustedOrOptions) {
  2664. if (_value === void 0) { _value = ''; }
  2665. if (isTrustedOrOptions === void 0) { isTrustedOrOptions = false; }
  2666. var _a, _b;
  2667. this._value = _value;
  2668. if (typeof isTrustedOrOptions === 'boolean') {
  2669. this._isTrusted = isTrustedOrOptions;
  2670. this._supportThemeIcons = false;
  2671. }
  2672. else {
  2673. this._isTrusted = (_a = isTrustedOrOptions.isTrusted) !== null && _a !== void 0 ? _a : false;
  2674. this._supportThemeIcons = (_b = isTrustedOrOptions.supportThemeIcons) !== null && _b !== void 0 ? _b : false;
  2675. }
  2676. }
  2677. Object.defineProperty(MarkdownString.prototype, "value", {
  2678. get: function () { return this._value; },
  2679. enumerable: true,
  2680. configurable: true
  2681. });
  2682. Object.defineProperty(MarkdownString.prototype, "isTrusted", {
  2683. get: function () { return this._isTrusted; },
  2684. enumerable: true,
  2685. configurable: true
  2686. });
  2687. Object.defineProperty(MarkdownString.prototype, "supportThemeIcons", {
  2688. get: function () { return this._supportThemeIcons; },
  2689. enumerable: true,
  2690. configurable: true
  2691. });
  2692. MarkdownString.prototype.appendText = function (value) {
  2693. // escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
  2694. this._value += (this._supportThemeIcons ? codicons_1.escapeCodicons(value) : value)
  2695. .replace(/[\\`*_{}[\]()#+\-.!]/g, '\\$&')
  2696. .replace('\n', '\n\n');
  2697. return this;
  2698. };
  2699. MarkdownString.prototype.appendMarkdown = function (value) {
  2700. this._value += value;
  2701. return this;
  2702. };
  2703. MarkdownString.prototype.appendCodeblock = function (langId, code) {
  2704. this._value += '\n```';
  2705. this._value += langId;
  2706. this._value += '\n';
  2707. this._value += code;
  2708. this._value += '\n```\n';
  2709. return this;
  2710. };
  2711. return MarkdownString;
  2712. }());
  2713. exports.MarkdownString = MarkdownString;
  2714. function isEmptyMarkdownString(oneOrMany) {
  2715. if (isMarkdownString(oneOrMany)) {
  2716. return !oneOrMany.value;
  2717. }
  2718. else if (Array.isArray(oneOrMany)) {
  2719. return oneOrMany.every(isEmptyMarkdownString);
  2720. }
  2721. else {
  2722. return true;
  2723. }
  2724. }
  2725. exports.isEmptyMarkdownString = isEmptyMarkdownString;
  2726. function isMarkdownString(thing) {
  2727. if (thing instanceof MarkdownString) {
  2728. return true;
  2729. }
  2730. else if (thing && typeof thing === 'object') {
  2731. return typeof thing.value === 'string'
  2732. && (typeof thing.isTrusted === 'boolean' || thing.isTrusted === undefined)
  2733. && (typeof thing.supportThemeIcons === 'boolean' || thing.supportThemeIcons === undefined);
  2734. }
  2735. return false;
  2736. }
  2737. exports.isMarkdownString = isMarkdownString;
  2738. function markedStringsEquals(a, b) {
  2739. if (!a && !b) {
  2740. return true;
  2741. }
  2742. else if (!a || !b) {
  2743. return false;
  2744. }
  2745. else if (Array.isArray(a) && Array.isArray(b)) {
  2746. return arrays_1.equals(a, b, markdownStringEqual);
  2747. }
  2748. else if (isMarkdownString(a) && isMarkdownString(b)) {
  2749. return markdownStringEqual(a, b);
  2750. }
  2751. else {
  2752. return false;
  2753. }
  2754. }
  2755. exports.markedStringsEquals = markedStringsEquals;
  2756. function markdownStringEqual(a, b) {
  2757. if (a === b) {
  2758. return true;
  2759. }
  2760. else if (!a || !b) {
  2761. return false;
  2762. }
  2763. else {
  2764. return a.value === b.value && a.isTrusted === b.isTrusted && a.supportThemeIcons === b.supportThemeIcons;
  2765. }
  2766. }
  2767. function removeMarkdownEscapes(text) {
  2768. if (!text) {
  2769. return text;
  2770. }
  2771. return text.replace(/\\([\\`*_{}[\]()#+\-.!])/g, '$1');
  2772. }
  2773. exports.removeMarkdownEscapes = removeMarkdownEscapes;
  2774. function parseHrefAndDimensions(href) {
  2775. var dimensions = [];
  2776. var splitted = href.split('|').map(function (s) { return s.trim(); });
  2777. href = splitted[0];
  2778. var parameters = splitted[1];
  2779. if (parameters) {
  2780. var heightFromParams = /height=(\d+)/.exec(parameters);
  2781. var widthFromParams = /width=(\d+)/.exec(parameters);
  2782. var height = heightFromParams ? heightFromParams[1] : '';
  2783. var width = widthFromParams ? widthFromParams[1] : '';
  2784. var widthIsFinite = isFinite(parseInt(width));
  2785. var heightIsFinite = isFinite(parseInt(height));
  2786. if (widthIsFinite) {
  2787. dimensions.push("width=\"" + width + "\"");
  2788. }
  2789. if (heightIsFinite) {
  2790. dimensions.push("height=\"" + height + "\"");
  2791. }
  2792. }
  2793. return { href: href, dimensions: dimensions };
  2794. }
  2795. exports.parseHrefAndDimensions = parseHrefAndDimensions;
  2796. });
  2797. /*---------------------------------------------------------------------------------------------
  2798. * Copyright (c) Microsoft Corporation. All rights reserved.
  2799. * Licensed under the MIT License. See License.txt in the project root for license information.
  2800. *--------------------------------------------------------------------------------------------*/
  2801. define(__m[127/*vs/base/common/idGenerator*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  2802. "use strict";
  2803. Object.defineProperty(exports, "__esModule", { value: true });
  2804. var IdGenerator = /** @class */ (function () {
  2805. function IdGenerator(prefix) {
  2806. this._prefix = prefix;
  2807. this._lastId = 0;
  2808. }
  2809. IdGenerator.prototype.nextId = function () {
  2810. return this._prefix + (++this._lastId);
  2811. };
  2812. return IdGenerator;
  2813. }());
  2814. exports.IdGenerator = IdGenerator;
  2815. exports.defaultGenerator = new IdGenerator('id#');
  2816. });
  2817. /*
  2818. The MIT License (MIT)
  2819. Copyright © 2015 Nicolas Bevacqua
  2820. Permission is hereby granted, free of charge, to any person obtaining a copy of
  2821. this software and associated documentation files (the "Software"), to deal in
  2822. the Software without restriction, including without limitation the rights to
  2823. use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  2824. the Software, and to permit persons to whom the Software is furnished to do so,
  2825. subject to the following conditions:
  2826. The above copyright notice and this permission notice shall be included in all
  2827. copies or substantial portions of the Software.
  2828. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  2829. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  2830. FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  2831. COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  2832. IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  2833. CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  2834. */
  2835. let __insane_func;
  2836. (function () { function r(e, n, t) { function o(i, f) { if (!n[i]) { if (!e[i]) { var c = "function" == typeof require && require; if (!f && c) return c(i, !0); if (u) return u(i, !0); var a = new Error("Cannot find module '" + i + "'"); throw a.code = "MODULE_NOT_FOUND", a } var p = n[i] = { exports: {} }; e[i][0].call(p.exports, function (r) { var n = e[i][1][r]; return o(n || r) }, p, p.exports, r, e, n, t) } return n[i].exports } for (var u = "function" == typeof require && require, i = 0; i < t.length; i++)o(t[i]); return o } return r })()({
  2837. 1: [function (require, module, exports) {
  2838. 'use strict';
  2839. var toMap = require('./toMap');
  2840. var uris = ['background', 'base', 'cite', 'href', 'longdesc', 'src', 'usemap'];
  2841. module.exports = {
  2842. uris: toMap(uris) // attributes that have an href and hence need to be sanitized
  2843. };
  2844. }, { "./toMap": 10 }], 2: [function (require, module, exports) {
  2845. 'use strict';
  2846. var defaults = {
  2847. allowedAttributes: {
  2848. '*': ['title', 'accesskey'],
  2849. a: ['href', 'name', 'target', 'aria-label'],
  2850. iframe: ['allowfullscreen', 'frameborder', 'src'],
  2851. img: ['src', 'alt', 'title', 'aria-label']
  2852. },
  2853. allowedClasses: {},
  2854. allowedSchemes: ['http', 'https', 'mailto'],
  2855. allowedTags: [
  2856. 'a', 'abbr', 'article', 'b', 'blockquote', 'br', 'caption', 'code', 'del', 'details', 'div', 'em',
  2857. 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'hr', 'i', 'img', 'ins', 'kbd', 'li', 'main', 'mark',
  2858. 'ol', 'p', 'pre', 'section', 'span', 'strike', 'strong', 'sub', 'summary', 'sup', 'table',
  2859. 'tbody', 'td', 'th', 'thead', 'tr', 'u', 'ul'
  2860. ],
  2861. filter: null
  2862. };
  2863. module.exports = defaults;
  2864. }, {}], 3: [function (require, module, exports) {
  2865. 'use strict';
  2866. var toMap = require('./toMap');
  2867. var voids = ['area', 'br', 'col', 'hr', 'img', 'wbr', 'input', 'base', 'basefont', 'link', 'meta'];
  2868. module.exports = {
  2869. voids: toMap(voids)
  2870. };
  2871. }, { "./toMap": 10 }], 4: [function (require, module, exports) {
  2872. 'use strict';
  2873. var he = require('he');
  2874. var assign = require('assignment');
  2875. var parser = require('./parser');
  2876. var sanitizer = require('./sanitizer');
  2877. var defaults = require('./defaults');
  2878. function insane(html, options, strict) {
  2879. var buffer = [];
  2880. var configuration = strict === true ? options : assign({}, defaults, options);
  2881. var handler = sanitizer(buffer, configuration);
  2882. parser(html, handler);
  2883. return buffer.join('');
  2884. }
  2885. insane.defaults = defaults;
  2886. module.exports = insane;
  2887. __insane_func = insane;
  2888. }, { "./defaults": 2, "./parser": 7, "./sanitizer": 8, "assignment": 6, "he": 9 }], 5: [function (require, module, exports) {
  2889. 'use strict';
  2890. module.exports = function lowercase(string) {
  2891. return typeof string === 'string' ? string.toLowerCase() : string;
  2892. };
  2893. }, {}], 6: [function (require, module, exports) {
  2894. 'use strict';
  2895. function assignment(result) {
  2896. var stack = Array.prototype.slice.call(arguments, 1);
  2897. var item;
  2898. var key;
  2899. while (stack.length) {
  2900. item = stack.shift();
  2901. for (key in item) {
  2902. if (item.hasOwnProperty(key)) {
  2903. if (Object.prototype.toString.call(result[key]) === '[object Object]') {
  2904. result[key] = assignment(result[key], item[key]);
  2905. } else {
  2906. result[key] = item[key];
  2907. }
  2908. }
  2909. }
  2910. }
  2911. return result;
  2912. }
  2913. module.exports = assignment;
  2914. }, {}], 7: [function (require, module, exports) {
  2915. 'use strict';
  2916. var he = require('he');
  2917. var lowercase = require('./lowercase');
  2918. var attributes = require('./attributes');
  2919. var elements = require('./elements');
  2920. var rstart = /^<\s*([\w:-]+)((?:\s+[\w:-]+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)\s*>/;
  2921. var rend = /^<\s*\/\s*([\w:-]+)[^>]*>/;
  2922. var rattrs = /([\w:-]+)(?:\s*=\s*(?:(?:"((?:[^"])*)")|(?:'((?:[^'])*)')|([^>\s]+)))?/g;
  2923. var rtag = /^</;
  2924. var rtagend = /^<\s*\//;
  2925. function createStack() {
  2926. var stack = [];
  2927. stack.lastItem = function lastItem() {
  2928. return stack[stack.length - 1];
  2929. };
  2930. return stack;
  2931. }
  2932. function parser(html, handler) {
  2933. var stack = createStack();
  2934. var last = html;
  2935. var chars;
  2936. while (html) {
  2937. parsePart();
  2938. }
  2939. parseEndTag(); // clean up any remaining tags
  2940. function parsePart() {
  2941. chars = true;
  2942. parseTag();
  2943. var same = html === last;
  2944. last = html;
  2945. if (same) { // discard, because it's invalid
  2946. html = '';
  2947. }
  2948. }
  2949. function parseTag() {
  2950. if (html.substr(0, 4) === '<!--') { // comments
  2951. parseComment();
  2952. } else if (rtagend.test(html)) {
  2953. parseEdge(rend, parseEndTag);
  2954. } else if (rtag.test(html)) {
  2955. parseEdge(rstart, parseStartTag);
  2956. }
  2957. parseTagDecode();
  2958. }
  2959. function parseEdge(regex, parser) {
  2960. var match = html.match(regex);
  2961. if (match) {
  2962. html = html.substring(match[0].length);
  2963. match[0].replace(regex, parser);
  2964. chars = false;
  2965. }
  2966. }
  2967. function parseComment() {
  2968. var index = html.indexOf('-->');
  2969. if (index >= 0) {
  2970. if (handler.comment) {
  2971. handler.comment(html.substring(4, index));
  2972. }
  2973. html = html.substring(index + 3);
  2974. chars = false;
  2975. }
  2976. }
  2977. function parseTagDecode() {
  2978. if (!chars) {
  2979. return;
  2980. }
  2981. var text;
  2982. var index = html.indexOf('<');
  2983. if (index >= 0) {
  2984. text = html.substring(0, index);
  2985. html = html.substring(index);
  2986. } else {
  2987. text = html;
  2988. html = '';
  2989. }
  2990. if (handler.chars) {
  2991. handler.chars(text);
  2992. }
  2993. }
  2994. function parseStartTag(tag, tagName, rest, unary) {
  2995. var attrs = {};
  2996. var low = lowercase(tagName);
  2997. var u = elements.voids[low] || !!unary;
  2998. rest.replace(rattrs, attrReplacer);
  2999. if (!u) {
  3000. stack.push(low);
  3001. }
  3002. if (handler.start) {
  3003. handler.start(low, attrs, u);
  3004. }
  3005. function attrReplacer(match, name, doubleQuotedValue, singleQuotedValue, unquotedValue) {
  3006. if (doubleQuotedValue === void 0 && singleQuotedValue === void 0 && unquotedValue === void 0) {
  3007. attrs[name] = void 0; // attribute is like <button disabled></button>
  3008. } else {
  3009. attrs[name] = he.decode(doubleQuotedValue || singleQuotedValue || unquotedValue || '');
  3010. }
  3011. }
  3012. }
  3013. function parseEndTag(tag, tagName) {
  3014. var i;
  3015. var pos = 0;
  3016. var low = lowercase(tagName);
  3017. if (low) {
  3018. for (pos = stack.length - 1; pos >= 0; pos--) {
  3019. if (stack[pos] === low) {
  3020. break; // find the closest opened tag of the same type
  3021. }
  3022. }
  3023. }
  3024. if (pos >= 0) {
  3025. for (i = stack.length - 1; i >= pos; i--) {
  3026. if (handler.end) { // close all the open elements, up the stack
  3027. handler.end(stack[i]);
  3028. }
  3029. }
  3030. stack.length = pos;
  3031. }
  3032. }
  3033. }
  3034. module.exports = parser;
  3035. }, { "./attributes": 1, "./elements": 3, "./lowercase": 5, "he": 9 }], 8: [function (require, module, exports) {
  3036. 'use strict';
  3037. var he = require('he');
  3038. var lowercase = require('./lowercase');
  3039. var attributes = require('./attributes');
  3040. var elements = require('./elements');
  3041. function sanitizer(buffer, options) {
  3042. var last;
  3043. var context;
  3044. var o = options || {};
  3045. reset();
  3046. return {
  3047. start: start,
  3048. end: end,
  3049. chars: chars
  3050. };
  3051. function out(value) {
  3052. buffer.push(value);
  3053. }
  3054. function start(tag, attrs, unary) {
  3055. var low = lowercase(tag);
  3056. if (context.ignoring) {
  3057. ignore(low); return;
  3058. }
  3059. if ((o.allowedTags || []).indexOf(low) === -1) {
  3060. ignore(low); return;
  3061. }
  3062. if (o.filter && !o.filter({ tag: low, attrs: attrs })) {
  3063. ignore(low); return;
  3064. }
  3065. out('<');
  3066. out(low);
  3067. Object.keys(attrs).forEach(parse);
  3068. out(unary ? '/>' : '>');
  3069. function parse(key) {
  3070. var value = attrs[key];
  3071. var classesOk = (o.allowedClasses || {})[low] || [];
  3072. var attrsOk = (o.allowedAttributes || {})[low] || [];
  3073. attrsOk = attrsOk.concat((o.allowedAttributes || {})['*'] || []);
  3074. var valid;
  3075. var lkey = lowercase(key);
  3076. if (lkey === 'class' && attrsOk.indexOf(lkey) === -1) {
  3077. value = value.split(' ').filter(isValidClass).join(' ').trim();
  3078. valid = value.length;
  3079. } else {
  3080. valid = attrsOk.indexOf(lkey) !== -1 && (attributes.uris[lkey] !== true || testUrl(value));
  3081. }
  3082. if (valid) {
  3083. out(' ');
  3084. out(key);
  3085. if (typeof value === 'string') {
  3086. out('="');
  3087. out(he.encode(value));
  3088. out('"');
  3089. }
  3090. }
  3091. function isValidClass(className) {
  3092. return classesOk && classesOk.indexOf(className) !== -1;
  3093. }
  3094. }
  3095. }
  3096. function end(tag) {
  3097. var low = lowercase(tag);
  3098. var allowed = (o.allowedTags || []).indexOf(low) !== -1;
  3099. if (allowed) {
  3100. if (context.ignoring === false) {
  3101. out('</');
  3102. out(low);
  3103. out('>');
  3104. } else {
  3105. unignore(low);
  3106. }
  3107. } else {
  3108. unignore(low);
  3109. }
  3110. }
  3111. function testUrl(text) {
  3112. var start = text[0];
  3113. if (start === '#' || start === '/') {
  3114. return true;
  3115. }
  3116. var colon = text.indexOf(':');
  3117. if (colon === -1) {
  3118. return true;
  3119. }
  3120. var questionmark = text.indexOf('?');
  3121. if (questionmark !== -1 && colon > questionmark) {
  3122. return true;
  3123. }
  3124. var hash = text.indexOf('#');
  3125. if (hash !== -1 && colon > hash) {
  3126. return true;
  3127. }
  3128. return o.allowedSchemes.some(matches);
  3129. function matches(scheme) {
  3130. return text.indexOf(scheme + ':') === 0;
  3131. }
  3132. }
  3133. function chars(text) {
  3134. if (context.ignoring === false) {
  3135. out(o.transformText ? o.transformText(text) : text);
  3136. }
  3137. }
  3138. function ignore(tag) {
  3139. if (elements.voids[tag]) {
  3140. return;
  3141. }
  3142. if (context.ignoring === false) {
  3143. context = { ignoring: tag, depth: 1 };
  3144. } else if (context.ignoring === tag) {
  3145. context.depth++;
  3146. }
  3147. }
  3148. function unignore(tag) {
  3149. if (context.ignoring === tag) {
  3150. if (--context.depth <= 0) {
  3151. reset();
  3152. }
  3153. }
  3154. }
  3155. function reset() {
  3156. context = { ignoring: false, depth: 0 };
  3157. }
  3158. }
  3159. module.exports = sanitizer;
  3160. }, { "./attributes": 1, "./elements": 3, "./lowercase": 5, "he": 9 }], 9: [function (require, module, exports) {
  3161. 'use strict';
  3162. var escapes = {
  3163. '&': '&amp;',
  3164. '<': '&lt;',
  3165. '>': '&gt;',
  3166. '"': '&quot;',
  3167. "'": '&#39;'
  3168. };
  3169. var unescapes = {
  3170. '&amp;': '&',
  3171. '&lt;': '<',
  3172. '&gt;': '>',
  3173. '&quot;': '"',
  3174. '&#39;': "'"
  3175. };
  3176. var rescaped = /(&amp;|&lt;|&gt;|&quot;|&#39;)/g;
  3177. var runescaped = /[&<>"']/g;
  3178. function escapeHtmlChar(match) {
  3179. return escapes[match];
  3180. }
  3181. function unescapeHtmlChar(match) {
  3182. return unescapes[match];
  3183. }
  3184. function escapeHtml(text) {
  3185. return text == null ? '' : String(text).replace(runescaped, escapeHtmlChar);
  3186. }
  3187. function unescapeHtml(html) {
  3188. return html == null ? '' : String(html).replace(rescaped, unescapeHtmlChar);
  3189. }
  3190. escapeHtml.options = unescapeHtml.options = {};
  3191. module.exports = {
  3192. encode: escapeHtml,
  3193. escape: escapeHtml,
  3194. decode: unescapeHtml,
  3195. unescape: unescapeHtml,
  3196. version: '1.0.0-browser'
  3197. };
  3198. }, {}], 10: [function (require, module, exports) {
  3199. 'use strict';
  3200. function toMap(list) {
  3201. return list.reduce(asKey, {});
  3202. }
  3203. function asKey(accumulator, item) {
  3204. accumulator[item] = true;
  3205. return accumulator;
  3206. }
  3207. module.exports = toMap;
  3208. }, {}]
  3209. }, {}, [4]);
  3210. // ESM-comment-begin
  3211. define("vs/base/common/insane/insane", function() { return { insane: __insane_func }; });
  3212. // ESM-comment-end
  3213. // ESM-uncomment-begin
  3214. // export var insane = __insane_func;
  3215. // ESM-uncomment-end
  3216. /*---------------------------------------------------------------------------------------------
  3217. * Copyright (c) Microsoft Corporation. All rights reserved.
  3218. * Licensed under the MIT License. See License.txt in the project root for license information.
  3219. *--------------------------------------------------------------------------------------------*/
  3220. define(__m[54/*vs/base/common/iterator*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  3221. "use strict";
  3222. Object.defineProperty(exports, "__esModule", { value: true });
  3223. exports.FIN = { done: true, value: undefined };
  3224. var Iterator;
  3225. (function (Iterator) {
  3226. var _empty = {
  3227. next: function () {
  3228. return exports.FIN;
  3229. }
  3230. };
  3231. function empty() {
  3232. return _empty;
  3233. }
  3234. Iterator.empty = empty;
  3235. function single(value) {
  3236. var done = false;
  3237. return {
  3238. next: function () {
  3239. if (done) {
  3240. return exports.FIN;
  3241. }
  3242. done = true;
  3243. return { done: false, value: value };
  3244. }
  3245. };
  3246. }
  3247. Iterator.single = single;
  3248. function fromArray(array, index, length) {
  3249. if (index === void 0) { index = 0; }
  3250. if (length === void 0) { length = array.length; }
  3251. return {
  3252. next: function () {
  3253. if (index >= length) {
  3254. return exports.FIN;
  3255. }
  3256. return { done: false, value: array[index++] };
  3257. }
  3258. };
  3259. }
  3260. Iterator.fromArray = fromArray;
  3261. function fromNativeIterator(it) {
  3262. return {
  3263. next: function () {
  3264. var result = it.next();
  3265. if (result.done) {
  3266. return exports.FIN;
  3267. }
  3268. return { done: false, value: result.value };
  3269. }
  3270. };
  3271. }
  3272. Iterator.fromNativeIterator = fromNativeIterator;
  3273. function from(elements) {
  3274. if (!elements) {
  3275. return Iterator.empty();
  3276. }
  3277. else if (Array.isArray(elements)) {
  3278. return Iterator.fromArray(elements);
  3279. }
  3280. else {
  3281. return elements;
  3282. }
  3283. }
  3284. Iterator.from = from;
  3285. function map(iterator, fn) {
  3286. return {
  3287. next: function () {
  3288. var element = iterator.next();
  3289. if (element.done) {
  3290. return exports.FIN;
  3291. }
  3292. else {
  3293. return { done: false, value: fn(element.value) };
  3294. }
  3295. }
  3296. };
  3297. }
  3298. Iterator.map = map;
  3299. function filter(iterator, fn) {
  3300. return {
  3301. next: function () {
  3302. while (true) {
  3303. var element = iterator.next();
  3304. if (element.done) {
  3305. return exports.FIN;
  3306. }
  3307. if (fn(element.value)) {
  3308. return { done: false, value: element.value };
  3309. }
  3310. }
  3311. }
  3312. };
  3313. }
  3314. Iterator.filter = filter;
  3315. function forEach(iterator, fn) {
  3316. for (var next = iterator.next(); !next.done; next = iterator.next()) {
  3317. fn(next.value);
  3318. }
  3319. }
  3320. Iterator.forEach = forEach;
  3321. function collect(iterator, atMost) {
  3322. if (atMost === void 0) { atMost = Number.POSITIVE_INFINITY; }
  3323. var result = [];
  3324. if (atMost === 0) {
  3325. return result;
  3326. }
  3327. var i = 0;
  3328. for (var next = iterator.next(); !next.done; next = iterator.next()) {
  3329. result.push(next.value);
  3330. if (++i >= atMost) {
  3331. break;
  3332. }
  3333. }
  3334. return result;
  3335. }
  3336. Iterator.collect = collect;
  3337. function concat() {
  3338. var iterators = [];
  3339. for (var _i = 0; _i < arguments.length; _i++) {
  3340. iterators[_i] = arguments[_i];
  3341. }
  3342. var i = 0;
  3343. return {
  3344. next: function () {
  3345. if (i >= iterators.length) {
  3346. return exports.FIN;
  3347. }
  3348. var iterator = iterators[i];
  3349. var result = iterator.next();
  3350. if (result.done) {
  3351. i++;
  3352. return this.next();
  3353. }
  3354. return result;
  3355. }
  3356. };
  3357. }
  3358. Iterator.concat = concat;
  3359. function chain(iterator) {
  3360. return new ChainableIterator(iterator);
  3361. }
  3362. Iterator.chain = chain;
  3363. })(Iterator = exports.Iterator || (exports.Iterator = {}));
  3364. var ChainableIterator = /** @class */ (function () {
  3365. function ChainableIterator(it) {
  3366. this.it = it;
  3367. }
  3368. ChainableIterator.prototype.next = function () { return this.it.next(); };
  3369. return ChainableIterator;
  3370. }());
  3371. exports.ChainableIterator = ChainableIterator;
  3372. function getSequenceIterator(arg) {
  3373. if (Array.isArray(arg)) {
  3374. return Iterator.fromArray(arg);
  3375. }
  3376. else if (!arg) {
  3377. return Iterator.empty();
  3378. }
  3379. else {
  3380. return arg;
  3381. }
  3382. }
  3383. exports.getSequenceIterator = getSequenceIterator;
  3384. var ArrayIterator = /** @class */ (function () {
  3385. function ArrayIterator(items, start, end, index) {
  3386. if (start === void 0) { start = 0; }
  3387. if (end === void 0) { end = items.length; }
  3388. if (index === void 0) { index = start - 1; }
  3389. this.items = items;
  3390. this.start = start;
  3391. this.end = end;
  3392. this.index = index;
  3393. }
  3394. ArrayIterator.prototype.first = function () {
  3395. this.index = this.start;
  3396. return this.current();
  3397. };
  3398. ArrayIterator.prototype.next = function () {
  3399. this.index = Math.min(this.index + 1, this.end);
  3400. return this.current();
  3401. };
  3402. ArrayIterator.prototype.current = function () {
  3403. if (this.index === this.start - 1 || this.index === this.end) {
  3404. return null;
  3405. }
  3406. return this.items[this.index];
  3407. };
  3408. return ArrayIterator;
  3409. }());
  3410. exports.ArrayIterator = ArrayIterator;
  3411. var ArrayNavigator = /** @class */ (function (_super) {
  3412. __extends(ArrayNavigator, _super);
  3413. function ArrayNavigator(items, start, end, index) {
  3414. if (start === void 0) { start = 0; }
  3415. if (end === void 0) { end = items.length; }
  3416. if (index === void 0) { index = start - 1; }
  3417. return _super.call(this, items, start, end, index) || this;
  3418. }
  3419. ArrayNavigator.prototype.current = function () {
  3420. return _super.prototype.current.call(this);
  3421. };
  3422. ArrayNavigator.prototype.previous = function () {
  3423. this.index = Math.max(this.index - 1, this.start - 1);
  3424. return this.current();
  3425. };
  3426. ArrayNavigator.prototype.first = function () {
  3427. this.index = this.start;
  3428. return this.current();
  3429. };
  3430. ArrayNavigator.prototype.last = function () {
  3431. this.index = this.end - 1;
  3432. return this.current();
  3433. };
  3434. ArrayNavigator.prototype.parent = function () {
  3435. return null;
  3436. };
  3437. return ArrayNavigator;
  3438. }(ArrayIterator));
  3439. exports.ArrayNavigator = ArrayNavigator;
  3440. var MappedIterator = /** @class */ (function () {
  3441. function MappedIterator(iterator, fn) {
  3442. this.iterator = iterator;
  3443. this.fn = fn;
  3444. // noop
  3445. }
  3446. MappedIterator.prototype.next = function () { return this.fn(this.iterator.next()); };
  3447. return MappedIterator;
  3448. }());
  3449. exports.MappedIterator = MappedIterator;
  3450. });
  3451. /*---------------------------------------------------------------------------------------------
  3452. * Copyright (c) Microsoft Corporation. All rights reserved.
  3453. * Licensed under the MIT License. See License.txt in the project root for license information.
  3454. *--------------------------------------------------------------------------------------------*/
  3455. define(__m[242/*vs/base/common/history*/], __M([0/*require*/,1/*exports*/,54/*vs/base/common/iterator*/]), function (require, exports, iterator_1) {
  3456. "use strict";
  3457. Object.defineProperty(exports, "__esModule", { value: true });
  3458. var HistoryNavigator = /** @class */ (function () {
  3459. function HistoryNavigator(history, limit) {
  3460. if (history === void 0) { history = []; }
  3461. if (limit === void 0) { limit = 10; }
  3462. this._initialize(history);
  3463. this._limit = limit;
  3464. this._onChange();
  3465. }
  3466. HistoryNavigator.prototype.add = function (t) {
  3467. this._history.delete(t);
  3468. this._history.add(t);
  3469. this._onChange();
  3470. };
  3471. HistoryNavigator.prototype.next = function () {
  3472. return this._navigator.next();
  3473. };
  3474. HistoryNavigator.prototype.previous = function () {
  3475. return this._navigator.previous();
  3476. };
  3477. HistoryNavigator.prototype.current = function () {
  3478. return this._navigator.current();
  3479. };
  3480. HistoryNavigator.prototype.parent = function () {
  3481. return null;
  3482. };
  3483. HistoryNavigator.prototype.first = function () {
  3484. return this._navigator.first();
  3485. };
  3486. HistoryNavigator.prototype.last = function () {
  3487. return this._navigator.last();
  3488. };
  3489. HistoryNavigator.prototype.has = function (t) {
  3490. return this._history.has(t);
  3491. };
  3492. HistoryNavigator.prototype._onChange = function () {
  3493. this._reduceToLimit();
  3494. var elements = this._elements;
  3495. this._navigator = new iterator_1.ArrayNavigator(elements, 0, elements.length, elements.length);
  3496. };
  3497. HistoryNavigator.prototype._reduceToLimit = function () {
  3498. var data = this._elements;
  3499. if (data.length > this._limit) {
  3500. this._initialize(data.slice(data.length - this._limit));
  3501. }
  3502. };
  3503. HistoryNavigator.prototype._initialize = function (history) {
  3504. this._history = new Set();
  3505. for (var _i = 0, history_1 = history; _i < history_1.length; _i++) {
  3506. var entry = history_1[_i];
  3507. this._history.add(entry);
  3508. }
  3509. };
  3510. Object.defineProperty(HistoryNavigator.prototype, "_elements", {
  3511. get: function () {
  3512. var elements = [];
  3513. this._history.forEach(function (e) { return elements.push(e); });
  3514. return elements;
  3515. },
  3516. enumerable: true,
  3517. configurable: true
  3518. });
  3519. return HistoryNavigator;
  3520. }());
  3521. exports.HistoryNavigator = HistoryNavigator;
  3522. });
  3523. /*---------------------------------------------------------------------------------------------
  3524. * Copyright (c) Microsoft Corporation. All rights reserved.
  3525. * Licensed under the MIT License. See License.txt in the project root for license information.
  3526. *--------------------------------------------------------------------------------------------*/
  3527. define(__m[36/*vs/base/common/keyCodes*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/]), function (require, exports, errors_1) {
  3528. "use strict";
  3529. Object.defineProperty(exports, "__esModule", { value: true });
  3530. var KeyCodeStrMap = /** @class */ (function () {
  3531. function KeyCodeStrMap() {
  3532. this._keyCodeToStr = [];
  3533. this._strToKeyCode = Object.create(null);
  3534. }
  3535. KeyCodeStrMap.prototype.define = function (keyCode, str) {
  3536. this._keyCodeToStr[keyCode] = str;
  3537. this._strToKeyCode[str.toLowerCase()] = keyCode;
  3538. };
  3539. KeyCodeStrMap.prototype.keyCodeToStr = function (keyCode) {
  3540. return this._keyCodeToStr[keyCode];
  3541. };
  3542. KeyCodeStrMap.prototype.strToKeyCode = function (str) {
  3543. return this._strToKeyCode[str.toLowerCase()] || 0 /* Unknown */;
  3544. };
  3545. return KeyCodeStrMap;
  3546. }());
  3547. var uiMap = new KeyCodeStrMap();
  3548. var userSettingsUSMap = new KeyCodeStrMap();
  3549. var userSettingsGeneralMap = new KeyCodeStrMap();
  3550. (function () {
  3551. function define(keyCode, uiLabel, usUserSettingsLabel, generalUserSettingsLabel) {
  3552. if (usUserSettingsLabel === void 0) { usUserSettingsLabel = uiLabel; }
  3553. if (generalUserSettingsLabel === void 0) { generalUserSettingsLabel = usUserSettingsLabel; }
  3554. uiMap.define(keyCode, uiLabel);
  3555. userSettingsUSMap.define(keyCode, usUserSettingsLabel);
  3556. userSettingsGeneralMap.define(keyCode, generalUserSettingsLabel);
  3557. }
  3558. define(0 /* Unknown */, 'unknown');
  3559. define(1 /* Backspace */, 'Backspace');
  3560. define(2 /* Tab */, 'Tab');
  3561. define(3 /* Enter */, 'Enter');
  3562. define(4 /* Shift */, 'Shift');
  3563. define(5 /* Ctrl */, 'Ctrl');
  3564. define(6 /* Alt */, 'Alt');
  3565. define(7 /* PauseBreak */, 'PauseBreak');
  3566. define(8 /* CapsLock */, 'CapsLock');
  3567. define(9 /* Escape */, 'Escape');
  3568. define(10 /* Space */, 'Space');
  3569. define(11 /* PageUp */, 'PageUp');
  3570. define(12 /* PageDown */, 'PageDown');
  3571. define(13 /* End */, 'End');
  3572. define(14 /* Home */, 'Home');
  3573. define(15 /* LeftArrow */, 'LeftArrow', 'Left');
  3574. define(16 /* UpArrow */, 'UpArrow', 'Up');
  3575. define(17 /* RightArrow */, 'RightArrow', 'Right');
  3576. define(18 /* DownArrow */, 'DownArrow', 'Down');
  3577. define(19 /* Insert */, 'Insert');
  3578. define(20 /* Delete */, 'Delete');
  3579. define(21 /* KEY_0 */, '0');
  3580. define(22 /* KEY_1 */, '1');
  3581. define(23 /* KEY_2 */, '2');
  3582. define(24 /* KEY_3 */, '3');
  3583. define(25 /* KEY_4 */, '4');
  3584. define(26 /* KEY_5 */, '5');
  3585. define(27 /* KEY_6 */, '6');
  3586. define(28 /* KEY_7 */, '7');
  3587. define(29 /* KEY_8 */, '8');
  3588. define(30 /* KEY_9 */, '9');
  3589. define(31 /* KEY_A */, 'A');
  3590. define(32 /* KEY_B */, 'B');
  3591. define(33 /* KEY_C */, 'C');
  3592. define(34 /* KEY_D */, 'D');
  3593. define(35 /* KEY_E */, 'E');
  3594. define(36 /* KEY_F */, 'F');
  3595. define(37 /* KEY_G */, 'G');
  3596. define(38 /* KEY_H */, 'H');
  3597. define(39 /* KEY_I */, 'I');
  3598. define(40 /* KEY_J */, 'J');
  3599. define(41 /* KEY_K */, 'K');
  3600. define(42 /* KEY_L */, 'L');
  3601. define(43 /* KEY_M */, 'M');
  3602. define(44 /* KEY_N */, 'N');
  3603. define(45 /* KEY_O */, 'O');
  3604. define(46 /* KEY_P */, 'P');
  3605. define(47 /* KEY_Q */, 'Q');
  3606. define(48 /* KEY_R */, 'R');
  3607. define(49 /* KEY_S */, 'S');
  3608. define(50 /* KEY_T */, 'T');
  3609. define(51 /* KEY_U */, 'U');
  3610. define(52 /* KEY_V */, 'V');
  3611. define(53 /* KEY_W */, 'W');
  3612. define(54 /* KEY_X */, 'X');
  3613. define(55 /* KEY_Y */, 'Y');
  3614. define(56 /* KEY_Z */, 'Z');
  3615. define(57 /* Meta */, 'Meta');
  3616. define(58 /* ContextMenu */, 'ContextMenu');
  3617. define(59 /* F1 */, 'F1');
  3618. define(60 /* F2 */, 'F2');
  3619. define(61 /* F3 */, 'F3');
  3620. define(62 /* F4 */, 'F4');
  3621. define(63 /* F5 */, 'F5');
  3622. define(64 /* F6 */, 'F6');
  3623. define(65 /* F7 */, 'F7');
  3624. define(66 /* F8 */, 'F8');
  3625. define(67 /* F9 */, 'F9');
  3626. define(68 /* F10 */, 'F10');
  3627. define(69 /* F11 */, 'F11');
  3628. define(70 /* F12 */, 'F12');
  3629. define(71 /* F13 */, 'F13');
  3630. define(72 /* F14 */, 'F14');
  3631. define(73 /* F15 */, 'F15');
  3632. define(74 /* F16 */, 'F16');
  3633. define(75 /* F17 */, 'F17');
  3634. define(76 /* F18 */, 'F18');
  3635. define(77 /* F19 */, 'F19');
  3636. define(78 /* NumLock */, 'NumLock');
  3637. define(79 /* ScrollLock */, 'ScrollLock');
  3638. define(80 /* US_SEMICOLON */, ';', ';', 'OEM_1');
  3639. define(81 /* US_EQUAL */, '=', '=', 'OEM_PLUS');
  3640. define(82 /* US_COMMA */, ',', ',', 'OEM_COMMA');
  3641. define(83 /* US_MINUS */, '-', '-', 'OEM_MINUS');
  3642. define(84 /* US_DOT */, '.', '.', 'OEM_PERIOD');
  3643. define(85 /* US_SLASH */, '/', '/', 'OEM_2');
  3644. define(86 /* US_BACKTICK */, '`', '`', 'OEM_3');
  3645. define(110 /* ABNT_C1 */, 'ABNT_C1');
  3646. define(111 /* ABNT_C2 */, 'ABNT_C2');
  3647. define(87 /* US_OPEN_SQUARE_BRACKET */, '[', '[', 'OEM_4');
  3648. define(88 /* US_BACKSLASH */, '\\', '\\', 'OEM_5');
  3649. define(89 /* US_CLOSE_SQUARE_BRACKET */, ']', ']', 'OEM_6');
  3650. define(90 /* US_QUOTE */, '\'', '\'', 'OEM_7');
  3651. define(91 /* OEM_8 */, 'OEM_8');
  3652. define(92 /* OEM_102 */, 'OEM_102');
  3653. define(93 /* NUMPAD_0 */, 'NumPad0');
  3654. define(94 /* NUMPAD_1 */, 'NumPad1');
  3655. define(95 /* NUMPAD_2 */, 'NumPad2');
  3656. define(96 /* NUMPAD_3 */, 'NumPad3');
  3657. define(97 /* NUMPAD_4 */, 'NumPad4');
  3658. define(98 /* NUMPAD_5 */, 'NumPad5');
  3659. define(99 /* NUMPAD_6 */, 'NumPad6');
  3660. define(100 /* NUMPAD_7 */, 'NumPad7');
  3661. define(101 /* NUMPAD_8 */, 'NumPad8');
  3662. define(102 /* NUMPAD_9 */, 'NumPad9');
  3663. define(103 /* NUMPAD_MULTIPLY */, 'NumPad_Multiply');
  3664. define(104 /* NUMPAD_ADD */, 'NumPad_Add');
  3665. define(105 /* NUMPAD_SEPARATOR */, 'NumPad_Separator');
  3666. define(106 /* NUMPAD_SUBTRACT */, 'NumPad_Subtract');
  3667. define(107 /* NUMPAD_DECIMAL */, 'NumPad_Decimal');
  3668. define(108 /* NUMPAD_DIVIDE */, 'NumPad_Divide');
  3669. })();
  3670. var KeyCodeUtils;
  3671. (function (KeyCodeUtils) {
  3672. function toString(keyCode) {
  3673. return uiMap.keyCodeToStr(keyCode);
  3674. }
  3675. KeyCodeUtils.toString = toString;
  3676. function fromString(key) {
  3677. return uiMap.strToKeyCode(key);
  3678. }
  3679. KeyCodeUtils.fromString = fromString;
  3680. function toUserSettingsUS(keyCode) {
  3681. return userSettingsUSMap.keyCodeToStr(keyCode);
  3682. }
  3683. KeyCodeUtils.toUserSettingsUS = toUserSettingsUS;
  3684. function toUserSettingsGeneral(keyCode) {
  3685. return userSettingsGeneralMap.keyCodeToStr(keyCode);
  3686. }
  3687. KeyCodeUtils.toUserSettingsGeneral = toUserSettingsGeneral;
  3688. function fromUserSettings(key) {
  3689. return userSettingsUSMap.strToKeyCode(key) || userSettingsGeneralMap.strToKeyCode(key);
  3690. }
  3691. KeyCodeUtils.fromUserSettings = fromUserSettings;
  3692. })(KeyCodeUtils = exports.KeyCodeUtils || (exports.KeyCodeUtils = {}));
  3693. function KeyChord(firstPart, secondPart) {
  3694. var chordPart = ((secondPart & 0x0000FFFF) << 16) >>> 0;
  3695. return (firstPart | chordPart) >>> 0;
  3696. }
  3697. exports.KeyChord = KeyChord;
  3698. function createKeybinding(keybinding, OS) {
  3699. if (keybinding === 0) {
  3700. return null;
  3701. }
  3702. var firstPart = (keybinding & 0x0000FFFF) >>> 0;
  3703. var chordPart = (keybinding & 0xFFFF0000) >>> 16;
  3704. if (chordPart !== 0) {
  3705. return new ChordKeybinding([
  3706. createSimpleKeybinding(firstPart, OS),
  3707. createSimpleKeybinding(chordPart, OS)
  3708. ]);
  3709. }
  3710. return new ChordKeybinding([createSimpleKeybinding(firstPart, OS)]);
  3711. }
  3712. exports.createKeybinding = createKeybinding;
  3713. function createSimpleKeybinding(keybinding, OS) {
  3714. var ctrlCmd = (keybinding & 2048 /* CtrlCmd */ ? true : false);
  3715. var winCtrl = (keybinding & 256 /* WinCtrl */ ? true : false);
  3716. var ctrlKey = (OS === 2 /* Macintosh */ ? winCtrl : ctrlCmd);
  3717. var shiftKey = (keybinding & 1024 /* Shift */ ? true : false);
  3718. var altKey = (keybinding & 512 /* Alt */ ? true : false);
  3719. var metaKey = (OS === 2 /* Macintosh */ ? ctrlCmd : winCtrl);
  3720. var keyCode = (keybinding & 255 /* KeyCode */);
  3721. return new SimpleKeybinding(ctrlKey, shiftKey, altKey, metaKey, keyCode);
  3722. }
  3723. exports.createSimpleKeybinding = createSimpleKeybinding;
  3724. var SimpleKeybinding = /** @class */ (function () {
  3725. function SimpleKeybinding(ctrlKey, shiftKey, altKey, metaKey, keyCode) {
  3726. this.ctrlKey = ctrlKey;
  3727. this.shiftKey = shiftKey;
  3728. this.altKey = altKey;
  3729. this.metaKey = metaKey;
  3730. this.keyCode = keyCode;
  3731. }
  3732. SimpleKeybinding.prototype.equals = function (other) {
  3733. return (this.ctrlKey === other.ctrlKey
  3734. && this.shiftKey === other.shiftKey
  3735. && this.altKey === other.altKey
  3736. && this.metaKey === other.metaKey
  3737. && this.keyCode === other.keyCode);
  3738. };
  3739. SimpleKeybinding.prototype.isModifierKey = function () {
  3740. return (this.keyCode === 0 /* Unknown */
  3741. || this.keyCode === 5 /* Ctrl */
  3742. || this.keyCode === 57 /* Meta */
  3743. || this.keyCode === 6 /* Alt */
  3744. || this.keyCode === 4 /* Shift */);
  3745. };
  3746. SimpleKeybinding.prototype.toChord = function () {
  3747. return new ChordKeybinding([this]);
  3748. };
  3749. /**
  3750. * Does this keybinding refer to the key code of a modifier and it also has the modifier flag?
  3751. */
  3752. SimpleKeybinding.prototype.isDuplicateModifierCase = function () {
  3753. return ((this.ctrlKey && this.keyCode === 5 /* Ctrl */)
  3754. || (this.shiftKey && this.keyCode === 4 /* Shift */)
  3755. || (this.altKey && this.keyCode === 6 /* Alt */)
  3756. || (this.metaKey && this.keyCode === 57 /* Meta */));
  3757. };
  3758. return SimpleKeybinding;
  3759. }());
  3760. exports.SimpleKeybinding = SimpleKeybinding;
  3761. var ChordKeybinding = /** @class */ (function () {
  3762. function ChordKeybinding(parts) {
  3763. if (parts.length === 0) {
  3764. throw errors_1.illegalArgument("parts");
  3765. }
  3766. this.parts = parts;
  3767. }
  3768. ChordKeybinding.prototype.equals = function (other) {
  3769. if (other === null) {
  3770. return false;
  3771. }
  3772. if (this.parts.length !== other.parts.length) {
  3773. return false;
  3774. }
  3775. for (var i = 0; i < this.parts.length; i++) {
  3776. if (!this.parts[i].equals(other.parts[i])) {
  3777. return false;
  3778. }
  3779. }
  3780. return true;
  3781. };
  3782. return ChordKeybinding;
  3783. }());
  3784. exports.ChordKeybinding = ChordKeybinding;
  3785. var ResolvedKeybindingPart = /** @class */ (function () {
  3786. function ResolvedKeybindingPart(ctrlKey, shiftKey, altKey, metaKey, kbLabel, kbAriaLabel) {
  3787. this.ctrlKey = ctrlKey;
  3788. this.shiftKey = shiftKey;
  3789. this.altKey = altKey;
  3790. this.metaKey = metaKey;
  3791. this.keyLabel = kbLabel;
  3792. this.keyAriaLabel = kbAriaLabel;
  3793. }
  3794. return ResolvedKeybindingPart;
  3795. }());
  3796. exports.ResolvedKeybindingPart = ResolvedKeybindingPart;
  3797. /**
  3798. * A resolved keybinding. Can be a simple keybinding or a chord keybinding.
  3799. */
  3800. var ResolvedKeybinding = /** @class */ (function () {
  3801. function ResolvedKeybinding() {
  3802. }
  3803. return ResolvedKeybinding;
  3804. }());
  3805. exports.ResolvedKeybinding = ResolvedKeybinding;
  3806. });
  3807. /*---------------------------------------------------------------------------------------------
  3808. * Copyright (c) Microsoft Corporation. All rights reserved.
  3809. * Licensed under the MIT License. See License.txt in the project root for license information.
  3810. *--------------------------------------------------------------------------------------------*/
  3811. define(__m[128/*vs/base/common/lazy*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  3812. "use strict";
  3813. Object.defineProperty(exports, "__esModule", { value: true });
  3814. var Lazy = /** @class */ (function () {
  3815. function Lazy(executor) {
  3816. this.executor = executor;
  3817. this._didRun = false;
  3818. }
  3819. /**
  3820. * Get the wrapped value.
  3821. *
  3822. * This will force evaluation of the lazy value if it has not been resolved yet. Lazy values are only
  3823. * resolved once. `getValue` will re-throw exceptions that are hit while resolving the value
  3824. */
  3825. Lazy.prototype.getValue = function () {
  3826. if (!this._didRun) {
  3827. try {
  3828. this._value = this.executor();
  3829. }
  3830. catch (err) {
  3831. this._error = err;
  3832. }
  3833. finally {
  3834. this._didRun = true;
  3835. }
  3836. }
  3837. if (this._error) {
  3838. throw this._error;
  3839. }
  3840. return this._value;
  3841. };
  3842. Object.defineProperty(Lazy.prototype, "rawValue", {
  3843. /**
  3844. * Get the wrapped value without forcing evaluation.
  3845. */
  3846. get: function () { return this._value; },
  3847. enumerable: true,
  3848. configurable: true
  3849. });
  3850. return Lazy;
  3851. }());
  3852. exports.Lazy = Lazy;
  3853. });
  3854. define(__m[2/*vs/base/common/lifecycle*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  3855. "use strict";
  3856. Object.defineProperty(exports, "__esModule", { value: true });
  3857. /**
  3858. * Enables logging of potentially leaked disposables.
  3859. *
  3860. * A disposable is considered leaked if it is not disposed or not registered as the child of
  3861. * another disposable. This tracking is very simple an only works for classes that either
  3862. * extend Disposable or use a DisposableStore. This means there are a lot of false positives.
  3863. */
  3864. var TRACK_DISPOSABLES = false;
  3865. var __is_disposable_tracked__ = '__is_disposable_tracked__';
  3866. function markTracked(x) {
  3867. if (!TRACK_DISPOSABLES) {
  3868. return;
  3869. }
  3870. if (x && x !== Disposable.None) {
  3871. try {
  3872. x[__is_disposable_tracked__] = true;
  3873. }
  3874. catch (_a) {
  3875. // noop
  3876. }
  3877. }
  3878. }
  3879. function trackDisposable(x) {
  3880. if (!TRACK_DISPOSABLES) {
  3881. return x;
  3882. }
  3883. var stack = new Error('Potentially leaked disposable').stack;
  3884. setTimeout(function () {
  3885. if (!x[__is_disposable_tracked__]) {
  3886. console.log(stack);
  3887. }
  3888. }, 3000);
  3889. return x;
  3890. }
  3891. function isDisposable(thing) {
  3892. return typeof thing.dispose === 'function'
  3893. && thing.dispose.length === 0;
  3894. }
  3895. exports.isDisposable = isDisposable;
  3896. function dispose(disposables) {
  3897. if (Array.isArray(disposables)) {
  3898. disposables.forEach(function (d) {
  3899. if (d) {
  3900. markTracked(d);
  3901. d.dispose();
  3902. }
  3903. });
  3904. return [];
  3905. }
  3906. else if (disposables) {
  3907. markTracked(disposables);
  3908. disposables.dispose();
  3909. return disposables;
  3910. }
  3911. else {
  3912. return undefined;
  3913. }
  3914. }
  3915. exports.dispose = dispose;
  3916. function combinedDisposable() {
  3917. var disposables = [];
  3918. for (var _i = 0; _i < arguments.length; _i++) {
  3919. disposables[_i] = arguments[_i];
  3920. }
  3921. disposables.forEach(markTracked);
  3922. return trackDisposable({ dispose: function () { return dispose(disposables); } });
  3923. }
  3924. exports.combinedDisposable = combinedDisposable;
  3925. function toDisposable(fn) {
  3926. var self = trackDisposable({
  3927. dispose: function () {
  3928. markTracked(self);
  3929. fn();
  3930. }
  3931. });
  3932. return self;
  3933. }
  3934. exports.toDisposable = toDisposable;
  3935. var DisposableStore = /** @class */ (function () {
  3936. function DisposableStore() {
  3937. this._toDispose = new Set();
  3938. this._isDisposed = false;
  3939. }
  3940. /**
  3941. * Dispose of all registered disposables and mark this object as disposed.
  3942. *
  3943. * Any future disposables added to this object will be disposed of on `add`.
  3944. */
  3945. DisposableStore.prototype.dispose = function () {
  3946. if (this._isDisposed) {
  3947. return;
  3948. }
  3949. markTracked(this);
  3950. this._isDisposed = true;
  3951. this.clear();
  3952. };
  3953. /**
  3954. * Dispose of all registered disposables but do not mark this object as disposed.
  3955. */
  3956. DisposableStore.prototype.clear = function () {
  3957. this._toDispose.forEach(function (item) { return item.dispose(); });
  3958. this._toDispose.clear();
  3959. };
  3960. DisposableStore.prototype.add = function (t) {
  3961. if (!t) {
  3962. return t;
  3963. }
  3964. if (t === this) {
  3965. throw new Error('Cannot register a disposable on itself!');
  3966. }
  3967. markTracked(t);
  3968. if (this._isDisposed) {
  3969. console.warn(new Error('Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!').stack);
  3970. }
  3971. else {
  3972. this._toDispose.add(t);
  3973. }
  3974. return t;
  3975. };
  3976. return DisposableStore;
  3977. }());
  3978. exports.DisposableStore = DisposableStore;
  3979. var Disposable = /** @class */ (function () {
  3980. function Disposable() {
  3981. this._store = new DisposableStore();
  3982. trackDisposable(this);
  3983. }
  3984. Disposable.prototype.dispose = function () {
  3985. markTracked(this);
  3986. this._store.dispose();
  3987. };
  3988. Disposable.prototype._register = function (t) {
  3989. if (t === this) {
  3990. throw new Error('Cannot register a disposable on itself!');
  3991. }
  3992. return this._store.add(t);
  3993. };
  3994. Disposable.None = Object.freeze({ dispose: function () { } });
  3995. return Disposable;
  3996. }());
  3997. exports.Disposable = Disposable;
  3998. /**
  3999. * Manages the lifecycle of a disposable value that may be changed.
  4000. *
  4001. * This ensures that when the disposable value is changed, the previously held disposable is disposed of. You can
  4002. * also register a `MutableDisposable` on a `Disposable` to ensure it is automatically cleaned up.
  4003. */
  4004. var MutableDisposable = /** @class */ (function () {
  4005. function MutableDisposable() {
  4006. this._isDisposed = false;
  4007. trackDisposable(this);
  4008. }
  4009. Object.defineProperty(MutableDisposable.prototype, "value", {
  4010. get: function () {
  4011. return this._isDisposed ? undefined : this._value;
  4012. },
  4013. set: function (value) {
  4014. if (this._isDisposed || value === this._value) {
  4015. return;
  4016. }
  4017. if (this._value) {
  4018. this._value.dispose();
  4019. }
  4020. if (value) {
  4021. markTracked(value);
  4022. }
  4023. this._value = value;
  4024. },
  4025. enumerable: true,
  4026. configurable: true
  4027. });
  4028. MutableDisposable.prototype.clear = function () {
  4029. this.value = undefined;
  4030. };
  4031. MutableDisposable.prototype.dispose = function () {
  4032. this._isDisposed = true;
  4033. markTracked(this);
  4034. if (this._value) {
  4035. this._value.dispose();
  4036. }
  4037. this._value = undefined;
  4038. };
  4039. return MutableDisposable;
  4040. }());
  4041. exports.MutableDisposable = MutableDisposable;
  4042. var ImmortalReference = /** @class */ (function () {
  4043. function ImmortalReference(object) {
  4044. this.object = object;
  4045. }
  4046. ImmortalReference.prototype.dispose = function () { };
  4047. return ImmortalReference;
  4048. }());
  4049. exports.ImmortalReference = ImmortalReference;
  4050. });
  4051. /*---------------------------------------------------------------------------------------------
  4052. * Copyright (c) Microsoft Corporation. All rights reserved.
  4053. * Licensed under the MIT License. See License.txt in the project root for license information.
  4054. *--------------------------------------------------------------------------------------------*/
  4055. define(__m[76/*vs/base/common/linkedList*/], __M([0/*require*/,1/*exports*/,54/*vs/base/common/iterator*/]), function (require, exports, iterator_1) {
  4056. "use strict";
  4057. Object.defineProperty(exports, "__esModule", { value: true });
  4058. var Node = /** @class */ (function () {
  4059. function Node(element) {
  4060. this.element = element;
  4061. this.next = Node.Undefined;
  4062. this.prev = Node.Undefined;
  4063. }
  4064. Node.Undefined = new Node(undefined);
  4065. return Node;
  4066. }());
  4067. var LinkedList = /** @class */ (function () {
  4068. function LinkedList() {
  4069. this._first = Node.Undefined;
  4070. this._last = Node.Undefined;
  4071. this._size = 0;
  4072. }
  4073. Object.defineProperty(LinkedList.prototype, "size", {
  4074. get: function () {
  4075. return this._size;
  4076. },
  4077. enumerable: true,
  4078. configurable: true
  4079. });
  4080. LinkedList.prototype.isEmpty = function () {
  4081. return this._first === Node.Undefined;
  4082. };
  4083. LinkedList.prototype.clear = function () {
  4084. this._first = Node.Undefined;
  4085. this._last = Node.Undefined;
  4086. this._size = 0;
  4087. };
  4088. LinkedList.prototype.unshift = function (element) {
  4089. return this._insert(element, false);
  4090. };
  4091. LinkedList.prototype.push = function (element) {
  4092. return this._insert(element, true);
  4093. };
  4094. LinkedList.prototype._insert = function (element, atTheEnd) {
  4095. var _this = this;
  4096. var newNode = new Node(element);
  4097. if (this._first === Node.Undefined) {
  4098. this._first = newNode;
  4099. this._last = newNode;
  4100. }
  4101. else if (atTheEnd) {
  4102. // push
  4103. var oldLast = this._last;
  4104. this._last = newNode;
  4105. newNode.prev = oldLast;
  4106. oldLast.next = newNode;
  4107. }
  4108. else {
  4109. // unshift
  4110. var oldFirst = this._first;
  4111. this._first = newNode;
  4112. newNode.next = oldFirst;
  4113. oldFirst.prev = newNode;
  4114. }
  4115. this._size += 1;
  4116. var didRemove = false;
  4117. return function () {
  4118. if (!didRemove) {
  4119. didRemove = true;
  4120. _this._remove(newNode);
  4121. }
  4122. };
  4123. };
  4124. LinkedList.prototype.shift = function () {
  4125. if (this._first === Node.Undefined) {
  4126. return undefined;
  4127. }
  4128. else {
  4129. var res = this._first.element;
  4130. this._remove(this._first);
  4131. return res;
  4132. }
  4133. };
  4134. LinkedList.prototype.pop = function () {
  4135. if (this._last === Node.Undefined) {
  4136. return undefined;
  4137. }
  4138. else {
  4139. var res = this._last.element;
  4140. this._remove(this._last);
  4141. return res;
  4142. }
  4143. };
  4144. LinkedList.prototype._remove = function (node) {
  4145. if (node.prev !== Node.Undefined && node.next !== Node.Undefined) {
  4146. // middle
  4147. var anchor = node.prev;
  4148. anchor.next = node.next;
  4149. node.next.prev = anchor;
  4150. }
  4151. else if (node.prev === Node.Undefined && node.next === Node.Undefined) {
  4152. // only node
  4153. this._first = Node.Undefined;
  4154. this._last = Node.Undefined;
  4155. }
  4156. else if (node.next === Node.Undefined) {
  4157. // last
  4158. this._last = this._last.prev;
  4159. this._last.next = Node.Undefined;
  4160. }
  4161. else if (node.prev === Node.Undefined) {
  4162. // first
  4163. this._first = this._first.next;
  4164. this._first.prev = Node.Undefined;
  4165. }
  4166. // done
  4167. this._size -= 1;
  4168. };
  4169. LinkedList.prototype.iterator = function () {
  4170. var element;
  4171. var node = this._first;
  4172. return {
  4173. next: function () {
  4174. if (node === Node.Undefined) {
  4175. return iterator_1.FIN;
  4176. }
  4177. if (!element) {
  4178. element = { done: false, value: node.element };
  4179. }
  4180. else {
  4181. element.value = node.element;
  4182. }
  4183. node = node.next;
  4184. return element;
  4185. }
  4186. };
  4187. };
  4188. LinkedList.prototype.toArray = function () {
  4189. var result = [];
  4190. for (var node = this._first; node !== Node.Undefined; node = node.next) {
  4191. result.push(node.element);
  4192. }
  4193. return result;
  4194. };
  4195. return LinkedList;
  4196. }());
  4197. exports.LinkedList = LinkedList;
  4198. });
  4199. /*---------------------------------------------------------------------------------------------
  4200. * Copyright (c) Microsoft Corporation. All rights reserved.
  4201. * Licensed under the MIT License. See License.txt in the project root for license information.
  4202. *--------------------------------------------------------------------------------------------*/
  4203. define(__m[4/*vs/base/common/event*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,102/*vs/base/common/functional*/,2/*vs/base/common/lifecycle*/,76/*vs/base/common/linkedList*/]), function (require, exports, errors_1, functional_1, lifecycle_1, linkedList_1) {
  4204. "use strict";
  4205. Object.defineProperty(exports, "__esModule", { value: true });
  4206. var Event;
  4207. (function (Event) {
  4208. Event.None = function () { return lifecycle_1.Disposable.None; };
  4209. /**
  4210. * Given an event, returns another event which only fires once.
  4211. */
  4212. function once(event) {
  4213. return function (listener, thisArgs, disposables) {
  4214. if (thisArgs === void 0) { thisArgs = null; }
  4215. // we need this, in case the event fires during the listener call
  4216. var didFire = false;
  4217. var result;
  4218. result = event(function (e) {
  4219. if (didFire) {
  4220. return;
  4221. }
  4222. else if (result) {
  4223. result.dispose();
  4224. }
  4225. else {
  4226. didFire = true;
  4227. }
  4228. return listener.call(thisArgs, e);
  4229. }, null, disposables);
  4230. if (didFire) {
  4231. result.dispose();
  4232. }
  4233. return result;
  4234. };
  4235. }
  4236. Event.once = once;
  4237. /**
  4238. * Given an event and a `map` function, returns another event which maps each element
  4239. * through the mapping function.
  4240. */
  4241. function map(event, map) {
  4242. return snapshot(function (listener, thisArgs, disposables) {
  4243. if (thisArgs === void 0) { thisArgs = null; }
  4244. return event(function (i) { return listener.call(thisArgs, map(i)); }, null, disposables);
  4245. });
  4246. }
  4247. Event.map = map;
  4248. /**
  4249. * Given an event and an `each` function, returns another identical event and calls
  4250. * the `each` function per each element.
  4251. */
  4252. function forEach(event, each) {
  4253. return snapshot(function (listener, thisArgs, disposables) {
  4254. if (thisArgs === void 0) { thisArgs = null; }
  4255. return event(function (i) { each(i); listener.call(thisArgs, i); }, null, disposables);
  4256. });
  4257. }
  4258. Event.forEach = forEach;
  4259. function filter(event, filter) {
  4260. return snapshot(function (listener, thisArgs, disposables) {
  4261. if (thisArgs === void 0) { thisArgs = null; }
  4262. return event(function (e) { return filter(e) && listener.call(thisArgs, e); }, null, disposables);
  4263. });
  4264. }
  4265. Event.filter = filter;
  4266. /**
  4267. * Given an event, returns the same event but typed as `Event<void>`.
  4268. */
  4269. function signal(event) {
  4270. return event;
  4271. }
  4272. Event.signal = signal;
  4273. /**
  4274. * Given a collection of events, returns a single event which emits
  4275. * whenever any of the provided events emit.
  4276. */
  4277. function any() {
  4278. var events = [];
  4279. for (var _i = 0; _i < arguments.length; _i++) {
  4280. events[_i] = arguments[_i];
  4281. }
  4282. return function (listener, thisArgs, disposables) {
  4283. if (thisArgs === void 0) { thisArgs = null; }
  4284. return lifecycle_1.combinedDisposable.apply(void 0, events.map(function (event) { return event(function (e) { return listener.call(thisArgs, e); }, null, disposables); }));
  4285. };
  4286. }
  4287. Event.any = any;
  4288. /**
  4289. * Given an event and a `merge` function, returns another event which maps each element
  4290. * and the cumulative result through the `merge` function. Similar to `map`, but with memory.
  4291. */
  4292. function reduce(event, merge, initial) {
  4293. var output = initial;
  4294. return map(event, function (e) {
  4295. output = merge(output, e);
  4296. return output;
  4297. });
  4298. }
  4299. Event.reduce = reduce;
  4300. /**
  4301. * Given a chain of event processing functions (filter, map, etc), each
  4302. * function will be invoked per event & per listener. Snapshotting an event
  4303. * chain allows each function to be invoked just once per event.
  4304. */
  4305. function snapshot(event) {
  4306. var listener;
  4307. var emitter = new Emitter({
  4308. onFirstListenerAdd: function () {
  4309. listener = event(emitter.fire, emitter);
  4310. },
  4311. onLastListenerRemove: function () {
  4312. listener.dispose();
  4313. }
  4314. });
  4315. return emitter.event;
  4316. }
  4317. Event.snapshot = snapshot;
  4318. function debounce(event, merge, delay, leading, leakWarningThreshold) {
  4319. if (delay === void 0) { delay = 100; }
  4320. if (leading === void 0) { leading = false; }
  4321. var subscription;
  4322. var output = undefined;
  4323. var handle = undefined;
  4324. var numDebouncedCalls = 0;
  4325. var emitter = new Emitter({
  4326. leakWarningThreshold: leakWarningThreshold,
  4327. onFirstListenerAdd: function () {
  4328. subscription = event(function (cur) {
  4329. numDebouncedCalls++;
  4330. output = merge(output, cur);
  4331. if (leading && !handle) {
  4332. emitter.fire(output);
  4333. output = undefined;
  4334. }
  4335. clearTimeout(handle);
  4336. handle = setTimeout(function () {
  4337. var _output = output;
  4338. output = undefined;
  4339. handle = undefined;
  4340. if (!leading || numDebouncedCalls > 1) {
  4341. emitter.fire(_output);
  4342. }
  4343. numDebouncedCalls = 0;
  4344. }, delay);
  4345. });
  4346. },
  4347. onLastListenerRemove: function () {
  4348. subscription.dispose();
  4349. }
  4350. });
  4351. return emitter.event;
  4352. }
  4353. Event.debounce = debounce;
  4354. /**
  4355. * Given an event, it returns another event which fires only once and as soon as
  4356. * the input event emits. The event data is the number of millis it took for the
  4357. * event to fire.
  4358. */
  4359. function stopwatch(event) {
  4360. var start = new Date().getTime();
  4361. return map(once(event), function (_) { return new Date().getTime() - start; });
  4362. }
  4363. Event.stopwatch = stopwatch;
  4364. /**
  4365. * Given an event, it returns another event which fires only when the event
  4366. * element changes.
  4367. */
  4368. function latch(event) {
  4369. var firstCall = true;
  4370. var cache;
  4371. return filter(event, function (value) {
  4372. var shouldEmit = firstCall || value !== cache;
  4373. firstCall = false;
  4374. cache = value;
  4375. return shouldEmit;
  4376. });
  4377. }
  4378. Event.latch = latch;
  4379. /**
  4380. * Buffers the provided event until a first listener comes
  4381. * along, at which point fire all the events at once and
  4382. * pipe the event from then on.
  4383. *
  4384. * ```typescript
  4385. * const emitter = new Emitter<number>();
  4386. * const event = emitter.event;
  4387. * const bufferedEvent = buffer(event);
  4388. *
  4389. * emitter.fire(1);
  4390. * emitter.fire(2);
  4391. * emitter.fire(3);
  4392. * // nothing...
  4393. *
  4394. * const listener = bufferedEvent(num => console.log(num));
  4395. * // 1, 2, 3
  4396. *
  4397. * emitter.fire(4);
  4398. * // 4
  4399. * ```
  4400. */
  4401. function buffer(event, nextTick, _buffer) {
  4402. if (nextTick === void 0) { nextTick = false; }
  4403. if (_buffer === void 0) { _buffer = []; }
  4404. var buffer = _buffer.slice();
  4405. var listener = event(function (e) {
  4406. if (buffer) {
  4407. buffer.push(e);
  4408. }
  4409. else {
  4410. emitter.fire(e);
  4411. }
  4412. });
  4413. var flush = function () {
  4414. if (buffer) {
  4415. buffer.forEach(function (e) { return emitter.fire(e); });
  4416. }
  4417. buffer = null;
  4418. };
  4419. var emitter = new Emitter({
  4420. onFirstListenerAdd: function () {
  4421. if (!listener) {
  4422. listener = event(function (e) { return emitter.fire(e); });
  4423. }
  4424. },
  4425. onFirstListenerDidAdd: function () {
  4426. if (buffer) {
  4427. if (nextTick) {
  4428. setTimeout(flush);
  4429. }
  4430. else {
  4431. flush();
  4432. }
  4433. }
  4434. },
  4435. onLastListenerRemove: function () {
  4436. if (listener) {
  4437. listener.dispose();
  4438. }
  4439. listener = null;
  4440. }
  4441. });
  4442. return emitter.event;
  4443. }
  4444. Event.buffer = buffer;
  4445. var ChainableEvent = /** @class */ (function () {
  4446. function ChainableEvent(event) {
  4447. this.event = event;
  4448. }
  4449. ChainableEvent.prototype.map = function (fn) {
  4450. return new ChainableEvent(map(this.event, fn));
  4451. };
  4452. ChainableEvent.prototype.forEach = function (fn) {
  4453. return new ChainableEvent(forEach(this.event, fn));
  4454. };
  4455. ChainableEvent.prototype.filter = function (fn) {
  4456. return new ChainableEvent(filter(this.event, fn));
  4457. };
  4458. ChainableEvent.prototype.reduce = function (merge, initial) {
  4459. return new ChainableEvent(reduce(this.event, merge, initial));
  4460. };
  4461. ChainableEvent.prototype.latch = function () {
  4462. return new ChainableEvent(latch(this.event));
  4463. };
  4464. ChainableEvent.prototype.debounce = function (merge, delay, leading, leakWarningThreshold) {
  4465. if (delay === void 0) { delay = 100; }
  4466. if (leading === void 0) { leading = false; }
  4467. return new ChainableEvent(debounce(this.event, merge, delay, leading, leakWarningThreshold));
  4468. };
  4469. ChainableEvent.prototype.on = function (listener, thisArgs, disposables) {
  4470. return this.event(listener, thisArgs, disposables);
  4471. };
  4472. ChainableEvent.prototype.once = function (listener, thisArgs, disposables) {
  4473. return once(this.event)(listener, thisArgs, disposables);
  4474. };
  4475. return ChainableEvent;
  4476. }());
  4477. function chain(event) {
  4478. return new ChainableEvent(event);
  4479. }
  4480. Event.chain = chain;
  4481. function fromNodeEventEmitter(emitter, eventName, map) {
  4482. if (map === void 0) { map = function (id) { return id; }; }
  4483. var fn = function () {
  4484. var args = [];
  4485. for (var _i = 0; _i < arguments.length; _i++) {
  4486. args[_i] = arguments[_i];
  4487. }
  4488. return result.fire(map.apply(void 0, args));
  4489. };
  4490. var onFirstListenerAdd = function () { return emitter.on(eventName, fn); };
  4491. var onLastListenerRemove = function () { return emitter.removeListener(eventName, fn); };
  4492. var result = new Emitter({ onFirstListenerAdd: onFirstListenerAdd, onLastListenerRemove: onLastListenerRemove });
  4493. return result.event;
  4494. }
  4495. Event.fromNodeEventEmitter = fromNodeEventEmitter;
  4496. function fromDOMEventEmitter(emitter, eventName, map) {
  4497. if (map === void 0) { map = function (id) { return id; }; }
  4498. var fn = function () {
  4499. var args = [];
  4500. for (var _i = 0; _i < arguments.length; _i++) {
  4501. args[_i] = arguments[_i];
  4502. }
  4503. return result.fire(map.apply(void 0, args));
  4504. };
  4505. var onFirstListenerAdd = function () { return emitter.addEventListener(eventName, fn); };
  4506. var onLastListenerRemove = function () { return emitter.removeEventListener(eventName, fn); };
  4507. var result = new Emitter({ onFirstListenerAdd: onFirstListenerAdd, onLastListenerRemove: onLastListenerRemove });
  4508. return result.event;
  4509. }
  4510. Event.fromDOMEventEmitter = fromDOMEventEmitter;
  4511. function fromPromise(promise) {
  4512. var emitter = new Emitter();
  4513. var shouldEmit = false;
  4514. promise
  4515. .then(undefined, function () { return null; })
  4516. .then(function () {
  4517. if (!shouldEmit) {
  4518. setTimeout(function () { return emitter.fire(undefined); }, 0);
  4519. }
  4520. else {
  4521. emitter.fire(undefined);
  4522. }
  4523. });
  4524. shouldEmit = true;
  4525. return emitter.event;
  4526. }
  4527. Event.fromPromise = fromPromise;
  4528. function toPromise(event) {
  4529. return new Promise(function (c) { return once(event)(c); });
  4530. }
  4531. Event.toPromise = toPromise;
  4532. })(Event = exports.Event || (exports.Event = {}));
  4533. var _globalLeakWarningThreshold = -1;
  4534. var LeakageMonitor = /** @class */ (function () {
  4535. function LeakageMonitor(customThreshold, name) {
  4536. if (name === void 0) { name = Math.random().toString(18).slice(2, 5); }
  4537. this.customThreshold = customThreshold;
  4538. this.name = name;
  4539. this._warnCountdown = 0;
  4540. }
  4541. LeakageMonitor.prototype.dispose = function () {
  4542. if (this._stacks) {
  4543. this._stacks.clear();
  4544. }
  4545. };
  4546. LeakageMonitor.prototype.check = function (listenerCount) {
  4547. var _this = this;
  4548. var threshold = _globalLeakWarningThreshold;
  4549. if (typeof this.customThreshold === 'number') {
  4550. threshold = this.customThreshold;
  4551. }
  4552. if (threshold <= 0 || listenerCount < threshold) {
  4553. return undefined;
  4554. }
  4555. if (!this._stacks) {
  4556. this._stacks = new Map();
  4557. }
  4558. var stack = new Error().stack.split('\n').slice(3).join('\n');
  4559. var count = (this._stacks.get(stack) || 0);
  4560. this._stacks.set(stack, count + 1);
  4561. this._warnCountdown -= 1;
  4562. if (this._warnCountdown <= 0) {
  4563. // only warn on first exceed and then every time the limit
  4564. // is exceeded by 50% again
  4565. this._warnCountdown = threshold * 0.5;
  4566. // find most frequent listener and print warning
  4567. var topStack_1;
  4568. var topCount_1 = 0;
  4569. this._stacks.forEach(function (count, stack) {
  4570. if (!topStack_1 || topCount_1 < count) {
  4571. topStack_1 = stack;
  4572. topCount_1 = count;
  4573. }
  4574. });
  4575. console.warn("[" + this.name + "] potential listener LEAK detected, having " + listenerCount + " listeners already. MOST frequent listener (" + topCount_1 + "):");
  4576. console.warn(topStack_1);
  4577. }
  4578. return function () {
  4579. var count = (_this._stacks.get(stack) || 0);
  4580. _this._stacks.set(stack, count - 1);
  4581. };
  4582. };
  4583. return LeakageMonitor;
  4584. }());
  4585. /**
  4586. * The Emitter can be used to expose an Event to the public
  4587. * to fire it from the insides.
  4588. * Sample:
  4589. class Document {
  4590. private readonly _onDidChange = new Emitter<(value:string)=>any>();
  4591. public onDidChange = this._onDidChange.event;
  4592. // getter-style
  4593. // get onDidChange(): Event<(value:string)=>any> {
  4594. // return this._onDidChange.event;
  4595. // }
  4596. private _doIt() {
  4597. //...
  4598. this._onDidChange.fire(value);
  4599. }
  4600. }
  4601. */
  4602. var Emitter = /** @class */ (function () {
  4603. function Emitter(options) {
  4604. this._disposed = false;
  4605. this._options = options;
  4606. this._leakageMon = _globalLeakWarningThreshold > 0
  4607. ? new LeakageMonitor(this._options && this._options.leakWarningThreshold)
  4608. : undefined;
  4609. }
  4610. Object.defineProperty(Emitter.prototype, "event", {
  4611. /**
  4612. * For the public to allow to subscribe
  4613. * to events from this Emitter
  4614. */
  4615. get: function () {
  4616. var _this = this;
  4617. if (!this._event) {
  4618. this._event = function (listener, thisArgs, disposables) {
  4619. if (!_this._listeners) {
  4620. _this._listeners = new linkedList_1.LinkedList();
  4621. }
  4622. var firstListener = _this._listeners.isEmpty();
  4623. if (firstListener && _this._options && _this._options.onFirstListenerAdd) {
  4624. _this._options.onFirstListenerAdd(_this);
  4625. }
  4626. var remove = _this._listeners.push(!thisArgs ? listener : [listener, thisArgs]);
  4627. if (firstListener && _this._options && _this._options.onFirstListenerDidAdd) {
  4628. _this._options.onFirstListenerDidAdd(_this);
  4629. }
  4630. if (_this._options && _this._options.onListenerDidAdd) {
  4631. _this._options.onListenerDidAdd(_this, listener, thisArgs);
  4632. }
  4633. // check and record this emitter for potential leakage
  4634. var removeMonitor;
  4635. if (_this._leakageMon) {
  4636. removeMonitor = _this._leakageMon.check(_this._listeners.size);
  4637. }
  4638. var result;
  4639. result = {
  4640. dispose: function () {
  4641. if (removeMonitor) {
  4642. removeMonitor();
  4643. }
  4644. result.dispose = Emitter._noop;
  4645. if (!_this._disposed) {
  4646. remove();
  4647. if (_this._options && _this._options.onLastListenerRemove) {
  4648. var hasListeners = (_this._listeners && !_this._listeners.isEmpty());
  4649. if (!hasListeners) {
  4650. _this._options.onLastListenerRemove(_this);
  4651. }
  4652. }
  4653. }
  4654. }
  4655. };
  4656. if (disposables instanceof lifecycle_1.DisposableStore) {
  4657. disposables.add(result);
  4658. }
  4659. else if (Array.isArray(disposables)) {
  4660. disposables.push(result);
  4661. }
  4662. return result;
  4663. };
  4664. }
  4665. return this._event;
  4666. },
  4667. enumerable: true,
  4668. configurable: true
  4669. });
  4670. /**
  4671. * To be kept private to fire an event to
  4672. * subscribers
  4673. */
  4674. Emitter.prototype.fire = function (event) {
  4675. if (this._listeners) {
  4676. // put all [listener,event]-pairs into delivery queue
  4677. // then emit all event. an inner/nested event might be
  4678. // the driver of this
  4679. if (!this._deliveryQueue) {
  4680. this._deliveryQueue = new linkedList_1.LinkedList();
  4681. }
  4682. for (var iter = this._listeners.iterator(), e = iter.next(); !e.done; e = iter.next()) {
  4683. this._deliveryQueue.push([e.value, event]);
  4684. }
  4685. while (this._deliveryQueue.size > 0) {
  4686. var _a = this._deliveryQueue.shift(), listener = _a[0], event_1 = _a[1];
  4687. try {
  4688. if (typeof listener === 'function') {
  4689. listener.call(undefined, event_1);
  4690. }
  4691. else {
  4692. listener[0].call(listener[1], event_1);
  4693. }
  4694. }
  4695. catch (e) {
  4696. errors_1.onUnexpectedError(e);
  4697. }
  4698. }
  4699. }
  4700. };
  4701. Emitter.prototype.dispose = function () {
  4702. if (this._listeners) {
  4703. this._listeners.clear();
  4704. }
  4705. if (this._deliveryQueue) {
  4706. this._deliveryQueue.clear();
  4707. }
  4708. if (this._leakageMon) {
  4709. this._leakageMon.dispose();
  4710. }
  4711. this._disposed = true;
  4712. };
  4713. Emitter._noop = function () { };
  4714. return Emitter;
  4715. }());
  4716. exports.Emitter = Emitter;
  4717. var PauseableEmitter = /** @class */ (function (_super) {
  4718. __extends(PauseableEmitter, _super);
  4719. function PauseableEmitter(options) {
  4720. var _this = _super.call(this, options) || this;
  4721. _this._isPaused = 0;
  4722. _this._eventQueue = new linkedList_1.LinkedList();
  4723. _this._mergeFn = options && options.merge;
  4724. return _this;
  4725. }
  4726. PauseableEmitter.prototype.pause = function () {
  4727. this._isPaused++;
  4728. };
  4729. PauseableEmitter.prototype.resume = function () {
  4730. if (this._isPaused !== 0 && --this._isPaused === 0) {
  4731. if (this._mergeFn) {
  4732. // use the merge function to create a single composite
  4733. // event. make a copy in case firing pauses this emitter
  4734. var events = this._eventQueue.toArray();
  4735. this._eventQueue.clear();
  4736. _super.prototype.fire.call(this, this._mergeFn(events));
  4737. }
  4738. else {
  4739. // no merging, fire each event individually and test
  4740. // that this emitter isn't paused halfway through
  4741. while (!this._isPaused && this._eventQueue.size !== 0) {
  4742. _super.prototype.fire.call(this, this._eventQueue.shift());
  4743. }
  4744. }
  4745. }
  4746. };
  4747. PauseableEmitter.prototype.fire = function (event) {
  4748. if (this._listeners) {
  4749. if (this._isPaused !== 0) {
  4750. this._eventQueue.push(event);
  4751. }
  4752. else {
  4753. _super.prototype.fire.call(this, event);
  4754. }
  4755. }
  4756. };
  4757. return PauseableEmitter;
  4758. }(Emitter));
  4759. exports.PauseableEmitter = PauseableEmitter;
  4760. var EventMultiplexer = /** @class */ (function () {
  4761. function EventMultiplexer() {
  4762. var _this = this;
  4763. this.hasListeners = false;
  4764. this.events = [];
  4765. this.emitter = new Emitter({
  4766. onFirstListenerAdd: function () { return _this.onFirstListenerAdd(); },
  4767. onLastListenerRemove: function () { return _this.onLastListenerRemove(); }
  4768. });
  4769. }
  4770. Object.defineProperty(EventMultiplexer.prototype, "event", {
  4771. get: function () {
  4772. return this.emitter.event;
  4773. },
  4774. enumerable: true,
  4775. configurable: true
  4776. });
  4777. EventMultiplexer.prototype.add = function (event) {
  4778. var _this = this;
  4779. var e = { event: event, listener: null };
  4780. this.events.push(e);
  4781. if (this.hasListeners) {
  4782. this.hook(e);
  4783. }
  4784. var dispose = function () {
  4785. if (_this.hasListeners) {
  4786. _this.unhook(e);
  4787. }
  4788. var idx = _this.events.indexOf(e);
  4789. _this.events.splice(idx, 1);
  4790. };
  4791. return lifecycle_1.toDisposable(functional_1.once(dispose));
  4792. };
  4793. EventMultiplexer.prototype.onFirstListenerAdd = function () {
  4794. var _this = this;
  4795. this.hasListeners = true;
  4796. this.events.forEach(function (e) { return _this.hook(e); });
  4797. };
  4798. EventMultiplexer.prototype.onLastListenerRemove = function () {
  4799. var _this = this;
  4800. this.hasListeners = false;
  4801. this.events.forEach(function (e) { return _this.unhook(e); });
  4802. };
  4803. EventMultiplexer.prototype.hook = function (e) {
  4804. var _this = this;
  4805. e.listener = e.event(function (r) { return _this.emitter.fire(r); });
  4806. };
  4807. EventMultiplexer.prototype.unhook = function (e) {
  4808. if (e.listener) {
  4809. e.listener.dispose();
  4810. }
  4811. e.listener = null;
  4812. };
  4813. EventMultiplexer.prototype.dispose = function () {
  4814. this.emitter.dispose();
  4815. };
  4816. return EventMultiplexer;
  4817. }());
  4818. exports.EventMultiplexer = EventMultiplexer;
  4819. /**
  4820. * The EventBufferer is useful in situations in which you want
  4821. * to delay firing your events during some code.
  4822. * You can wrap that code and be sure that the event will not
  4823. * be fired during that wrap.
  4824. *
  4825. * ```
  4826. * const emitter: Emitter;
  4827. * const delayer = new EventDelayer();
  4828. * const delayedEvent = delayer.wrapEvent(emitter.event);
  4829. *
  4830. * delayedEvent(console.log);
  4831. *
  4832. * delayer.bufferEvents(() => {
  4833. * emitter.fire(); // event will not be fired yet
  4834. * });
  4835. *
  4836. * // event will only be fired at this point
  4837. * ```
  4838. */
  4839. var EventBufferer = /** @class */ (function () {
  4840. function EventBufferer() {
  4841. this.buffers = [];
  4842. }
  4843. EventBufferer.prototype.wrapEvent = function (event) {
  4844. var _this = this;
  4845. return function (listener, thisArgs, disposables) {
  4846. return event(function (i) {
  4847. var buffer = _this.buffers[_this.buffers.length - 1];
  4848. if (buffer) {
  4849. buffer.push(function () { return listener.call(thisArgs, i); });
  4850. }
  4851. else {
  4852. listener.call(thisArgs, i);
  4853. }
  4854. }, undefined, disposables);
  4855. };
  4856. };
  4857. EventBufferer.prototype.bufferEvents = function (fn) {
  4858. var buffer = [];
  4859. this.buffers.push(buffer);
  4860. var r = fn();
  4861. this.buffers.pop();
  4862. buffer.forEach(function (flush) { return flush(); });
  4863. return r;
  4864. };
  4865. return EventBufferer;
  4866. }());
  4867. exports.EventBufferer = EventBufferer;
  4868. /**
  4869. * A Relay is an event forwarder which functions as a replugabble event pipe.
  4870. * Once created, you can connect an input event to it and it will simply forward
  4871. * events from that input event through its own `event` property. The `input`
  4872. * can be changed at any point in time.
  4873. */
  4874. var Relay = /** @class */ (function () {
  4875. function Relay() {
  4876. var _this = this;
  4877. this.listening = false;
  4878. this.inputEvent = Event.None;
  4879. this.inputEventListener = lifecycle_1.Disposable.None;
  4880. this.emitter = new Emitter({
  4881. onFirstListenerDidAdd: function () {
  4882. _this.listening = true;
  4883. _this.inputEventListener = _this.inputEvent(_this.emitter.fire, _this.emitter);
  4884. },
  4885. onLastListenerRemove: function () {
  4886. _this.listening = false;
  4887. _this.inputEventListener.dispose();
  4888. }
  4889. });
  4890. this.event = this.emitter.event;
  4891. }
  4892. Object.defineProperty(Relay.prototype, "input", {
  4893. set: function (event) {
  4894. this.inputEvent = event;
  4895. if (this.listening) {
  4896. this.inputEventListener.dispose();
  4897. this.inputEventListener = event(this.emitter.fire, this.emitter);
  4898. }
  4899. },
  4900. enumerable: true,
  4901. configurable: true
  4902. });
  4903. Relay.prototype.dispose = function () {
  4904. this.inputEventListener.dispose();
  4905. this.emitter.dispose();
  4906. };
  4907. return Relay;
  4908. }());
  4909. exports.Relay = Relay;
  4910. });
  4911. /*---------------------------------------------------------------------------------------------
  4912. * Copyright (c) Microsoft Corporation. All rights reserved.
  4913. * Licensed under the MIT License. See License.txt in the project root for license information.
  4914. *--------------------------------------------------------------------------------------------*/
  4915. define(__m[24/*vs/base/browser/browser*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/]), function (require, exports, event_1) {
  4916. "use strict";
  4917. Object.defineProperty(exports, "__esModule", { value: true });
  4918. var WindowManager = /** @class */ (function () {
  4919. function WindowManager() {
  4920. // --- Zoom Level
  4921. this._zoomLevel = 0;
  4922. this._lastZoomLevelChangeTime = 0;
  4923. this._onDidChangeZoomLevel = new event_1.Emitter();
  4924. this.onDidChangeZoomLevel = this._onDidChangeZoomLevel.event;
  4925. }
  4926. WindowManager.prototype.getZoomLevel = function () {
  4927. return this._zoomLevel;
  4928. };
  4929. WindowManager.prototype.getTimeSinceLastZoomLevelChanged = function () {
  4930. return Date.now() - this._lastZoomLevelChangeTime;
  4931. };
  4932. // --- Pixel Ratio
  4933. WindowManager.prototype.getPixelRatio = function () {
  4934. var ctx = document.createElement('canvas').getContext('2d');
  4935. var dpr = window.devicePixelRatio || 1;
  4936. var bsr = ctx.webkitBackingStorePixelRatio ||
  4937. ctx.mozBackingStorePixelRatio ||
  4938. ctx.msBackingStorePixelRatio ||
  4939. ctx.oBackingStorePixelRatio ||
  4940. ctx.backingStorePixelRatio || 1;
  4941. return dpr / bsr;
  4942. };
  4943. WindowManager.INSTANCE = new WindowManager();
  4944. return WindowManager;
  4945. }());
  4946. function getZoomLevel() {
  4947. return WindowManager.INSTANCE.getZoomLevel();
  4948. }
  4949. exports.getZoomLevel = getZoomLevel;
  4950. /** Returns the time (in ms) since the zoom level was changed */
  4951. function getTimeSinceLastZoomLevelChanged() {
  4952. return WindowManager.INSTANCE.getTimeSinceLastZoomLevelChanged();
  4953. }
  4954. exports.getTimeSinceLastZoomLevelChanged = getTimeSinceLastZoomLevelChanged;
  4955. function onDidChangeZoomLevel(callback) {
  4956. return WindowManager.INSTANCE.onDidChangeZoomLevel(callback);
  4957. }
  4958. exports.onDidChangeZoomLevel = onDidChangeZoomLevel;
  4959. function getPixelRatio() {
  4960. return WindowManager.INSTANCE.getPixelRatio();
  4961. }
  4962. exports.getPixelRatio = getPixelRatio;
  4963. var userAgent = navigator.userAgent;
  4964. exports.isIE = (userAgent.indexOf('Trident') >= 0);
  4965. exports.isEdge = (userAgent.indexOf('Edge/') >= 0);
  4966. exports.isEdgeOrIE = exports.isIE || exports.isEdge;
  4967. exports.isFirefox = (userAgent.indexOf('Firefox') >= 0);
  4968. exports.isWebKit = (userAgent.indexOf('AppleWebKit') >= 0);
  4969. exports.isChrome = (userAgent.indexOf('Chrome') >= 0);
  4970. exports.isSafari = (!exports.isChrome && (userAgent.indexOf('Safari') >= 0));
  4971. exports.isWebkitWebView = (!exports.isChrome && !exports.isSafari && exports.isWebKit);
  4972. exports.isIPad = (userAgent.indexOf('iPad') >= 0 || (exports.isSafari && navigator.maxTouchPoints > 0));
  4973. exports.isEdgeWebView = exports.isEdge && (userAgent.indexOf('WebView/') >= 0);
  4974. exports.isStandalone = (window.matchMedia && window.matchMedia('(display-mode: standalone)').matches);
  4975. });
  4976. /*---------------------------------------------------------------------------------------------
  4977. * Copyright (c) Microsoft Corporation. All rights reserved.
  4978. * Licensed under the MIT License. See License.txt in the project root for license information.
  4979. *--------------------------------------------------------------------------------------------*/
  4980. define(__m[52/*vs/base/browser/event*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/]), function (require, exports, event_1) {
  4981. "use strict";
  4982. Object.defineProperty(exports, "__esModule", { value: true });
  4983. exports.domEvent = function (element, type, useCapture) {
  4984. var fn = function (e) { return emitter.fire(e); };
  4985. var emitter = new event_1.Emitter({
  4986. onFirstListenerAdd: function () {
  4987. element.addEventListener(type, fn, useCapture);
  4988. },
  4989. onLastListenerRemove: function () {
  4990. element.removeEventListener(type, fn, useCapture);
  4991. }
  4992. });
  4993. return emitter.event;
  4994. };
  4995. function stop(event) {
  4996. return event_1.Event.map(event, function (e) {
  4997. e.preventDefault();
  4998. e.stopPropagation();
  4999. return e;
  5000. });
  5001. }
  5002. exports.stop = stop;
  5003. });
  5004. /*---------------------------------------------------------------------------------------------
  5005. * Copyright (c) Microsoft Corporation. All rights reserved.
  5006. * Licensed under the MIT License. See License.txt in the project root for license information.
  5007. *--------------------------------------------------------------------------------------------*/
  5008. var __spreadArrays = (this && this.__spreadArrays) || function () {
  5009. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  5010. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  5011. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  5012. r[k] = a[j];
  5013. return r;
  5014. };
  5015. define(__m[129/*vs/base/browser/ui/tree/indexTreeModel*/], __M([0/*require*/,1/*exports*/,99/*vs/base/browser/ui/tree/tree*/,19/*vs/base/common/arrays*/,4/*vs/base/common/event*/,54/*vs/base/common/iterator*/]), function (require, exports, tree_1, arrays_1, event_1, iterator_1) {
  5016. "use strict";
  5017. Object.defineProperty(exports, "__esModule", { value: true });
  5018. function isFilterResult(obj) {
  5019. return typeof obj === 'object' && 'visibility' in obj && 'data' in obj;
  5020. }
  5021. exports.isFilterResult = isFilterResult;
  5022. function getVisibleState(visibility) {
  5023. switch (visibility) {
  5024. case true: return 1 /* Visible */;
  5025. case false: return 0 /* Hidden */;
  5026. default: return visibility;
  5027. }
  5028. }
  5029. exports.getVisibleState = getVisibleState;
  5030. function isCollapsibleStateUpdate(update) {
  5031. return typeof update.collapsible === 'boolean';
  5032. }
  5033. var IndexTreeModel = /** @class */ (function () {
  5034. function IndexTreeModel(user, list, rootElement, options) {
  5035. if (options === void 0) { options = {}; }
  5036. this.user = user;
  5037. this.list = list;
  5038. this.rootRef = [];
  5039. this.eventBufferer = new event_1.EventBufferer();
  5040. this._onDidChangeCollapseState = new event_1.Emitter();
  5041. this.onDidChangeCollapseState = this.eventBufferer.wrapEvent(this._onDidChangeCollapseState.event);
  5042. this._onDidChangeRenderNodeCount = new event_1.Emitter();
  5043. this.onDidChangeRenderNodeCount = this.eventBufferer.wrapEvent(this._onDidChangeRenderNodeCount.event);
  5044. this._onDidSplice = new event_1.Emitter();
  5045. this.onDidSplice = this._onDidSplice.event;
  5046. this.collapseByDefault = typeof options.collapseByDefault === 'undefined' ? false : options.collapseByDefault;
  5047. this.filter = options.filter;
  5048. this.autoExpandSingleChildren = typeof options.autoExpandSingleChildren === 'undefined' ? false : options.autoExpandSingleChildren;
  5049. this.root = {
  5050. parent: undefined,
  5051. element: rootElement,
  5052. children: [],
  5053. depth: 0,
  5054. visibleChildrenCount: 0,
  5055. visibleChildIndex: -1,
  5056. collapsible: false,
  5057. collapsed: false,
  5058. renderNodeCount: 0,
  5059. visible: true,
  5060. filterData: undefined
  5061. };
  5062. }
  5063. IndexTreeModel.prototype.splice = function (location, deleteCount, toInsert, onDidCreateNode, onDidDeleteNode) {
  5064. var _a;
  5065. var _this = this;
  5066. if (location.length === 0) {
  5067. throw new tree_1.TreeError(this.user, 'Invalid tree location');
  5068. }
  5069. var _b = this.getParentNodeWithListIndex(location), parentNode = _b.parentNode, listIndex = _b.listIndex, revealed = _b.revealed, visible = _b.visible;
  5070. var treeListElementsToInsert = [];
  5071. var nodesToInsertIterator = iterator_1.Iterator.map(iterator_1.Iterator.from(toInsert), function (el) { return _this.createTreeNode(el, parentNode, parentNode.visible ? 1 /* Visible */ : 0 /* Hidden */, revealed, treeListElementsToInsert, onDidCreateNode); });
  5072. var lastIndex = location[location.length - 1];
  5073. // figure out what's the visible child start index right before the
  5074. // splice point
  5075. var visibleChildStartIndex = 0;
  5076. for (var i = lastIndex; i >= 0 && i < parentNode.children.length; i--) {
  5077. var child = parentNode.children[i];
  5078. if (child.visible) {
  5079. visibleChildStartIndex = child.visibleChildIndex;
  5080. break;
  5081. }
  5082. }
  5083. var nodesToInsert = [];
  5084. var insertedVisibleChildrenCount = 0;
  5085. var renderNodeCount = 0;
  5086. iterator_1.Iterator.forEach(nodesToInsertIterator, function (child) {
  5087. nodesToInsert.push(child);
  5088. renderNodeCount += child.renderNodeCount;
  5089. if (child.visible) {
  5090. child.visibleChildIndex = visibleChildStartIndex + insertedVisibleChildrenCount++;
  5091. }
  5092. });
  5093. var deletedNodes = (_a = parentNode.children).splice.apply(_a, __spreadArrays([lastIndex, deleteCount], nodesToInsert));
  5094. // figure out what is the count of deleted visible children
  5095. var deletedVisibleChildrenCount = 0;
  5096. for (var _i = 0, deletedNodes_1 = deletedNodes; _i < deletedNodes_1.length; _i++) {
  5097. var child = deletedNodes_1[_i];
  5098. if (child.visible) {
  5099. deletedVisibleChildrenCount++;
  5100. }
  5101. }
  5102. // and adjust for all visible children after the splice point
  5103. if (deletedVisibleChildrenCount !== 0) {
  5104. for (var i = lastIndex + nodesToInsert.length; i < parentNode.children.length; i++) {
  5105. var child = parentNode.children[i];
  5106. if (child.visible) {
  5107. child.visibleChildIndex -= deletedVisibleChildrenCount;
  5108. }
  5109. }
  5110. }
  5111. // update parent's visible children count
  5112. parentNode.visibleChildrenCount += insertedVisibleChildrenCount - deletedVisibleChildrenCount;
  5113. if (revealed && visible) {
  5114. var visibleDeleteCount = deletedNodes.reduce(function (r, node) { return r + (node.visible ? node.renderNodeCount : 0); }, 0);
  5115. this._updateAncestorsRenderNodeCount(parentNode, renderNodeCount - visibleDeleteCount);
  5116. this.list.splice(listIndex, visibleDeleteCount, treeListElementsToInsert);
  5117. }
  5118. if (deletedNodes.length > 0 && onDidDeleteNode) {
  5119. var visit_1 = function (node) {
  5120. onDidDeleteNode(node);
  5121. node.children.forEach(visit_1);
  5122. };
  5123. deletedNodes.forEach(visit_1);
  5124. }
  5125. this._onDidSplice.fire({ insertedNodes: nodesToInsert, deletedNodes: deletedNodes });
  5126. };
  5127. IndexTreeModel.prototype.rerender = function (location) {
  5128. if (location.length === 0) {
  5129. throw new tree_1.TreeError(this.user, 'Invalid tree location');
  5130. }
  5131. var _a = this.getTreeNodeWithListIndex(location), node = _a.node, listIndex = _a.listIndex, revealed = _a.revealed;
  5132. if (revealed) {
  5133. this.list.splice(listIndex, 1, [node]);
  5134. }
  5135. };
  5136. IndexTreeModel.prototype.has = function (location) {
  5137. return this.hasTreeNode(location);
  5138. };
  5139. IndexTreeModel.prototype.getListIndex = function (location) {
  5140. var _a = this.getTreeNodeWithListIndex(location), listIndex = _a.listIndex, visible = _a.visible, revealed = _a.revealed;
  5141. return visible && revealed ? listIndex : -1;
  5142. };
  5143. IndexTreeModel.prototype.getListRenderCount = function (location) {
  5144. return this.getTreeNode(location).renderNodeCount;
  5145. };
  5146. IndexTreeModel.prototype.isCollapsible = function (location) {
  5147. return this.getTreeNode(location).collapsible;
  5148. };
  5149. IndexTreeModel.prototype.setCollapsible = function (location, collapsible) {
  5150. var _this = this;
  5151. var node = this.getTreeNode(location);
  5152. if (typeof collapsible === 'undefined') {
  5153. collapsible = !node.collapsible;
  5154. }
  5155. var update = { collapsible: collapsible };
  5156. return this.eventBufferer.bufferEvents(function () { return _this._setCollapseState(location, update); });
  5157. };
  5158. IndexTreeModel.prototype.isCollapsed = function (location) {
  5159. return this.getTreeNode(location).collapsed;
  5160. };
  5161. IndexTreeModel.prototype.setCollapsed = function (location, collapsed, recursive) {
  5162. var _this = this;
  5163. var node = this.getTreeNode(location);
  5164. if (typeof collapsed === 'undefined') {
  5165. collapsed = !node.collapsed;
  5166. }
  5167. var update = { collapsed: collapsed, recursive: recursive || false };
  5168. return this.eventBufferer.bufferEvents(function () { return _this._setCollapseState(location, update); });
  5169. };
  5170. IndexTreeModel.prototype._setCollapseState = function (location, update) {
  5171. var _a = this.getTreeNodeWithListIndex(location), node = _a.node, listIndex = _a.listIndex, revealed = _a.revealed;
  5172. var result = this._setListNodeCollapseState(node, listIndex, revealed, update);
  5173. if (node !== this.root && this.autoExpandSingleChildren && result && !isCollapsibleStateUpdate(update) && node.collapsible && !node.collapsed && !update.recursive) {
  5174. var onlyVisibleChildIndex = -1;
  5175. for (var i = 0; i < node.children.length; i++) {
  5176. var child = node.children[i];
  5177. if (child.visible) {
  5178. if (onlyVisibleChildIndex > -1) {
  5179. onlyVisibleChildIndex = -1;
  5180. break;
  5181. }
  5182. else {
  5183. onlyVisibleChildIndex = i;
  5184. }
  5185. }
  5186. }
  5187. if (onlyVisibleChildIndex > -1) {
  5188. this._setCollapseState(__spreadArrays(location, [onlyVisibleChildIndex]), update);
  5189. }
  5190. }
  5191. return result;
  5192. };
  5193. IndexTreeModel.prototype._setListNodeCollapseState = function (node, listIndex, revealed, update) {
  5194. var result = this._setNodeCollapseState(node, update, false);
  5195. if (!revealed || !node.visible || !result) {
  5196. return result;
  5197. }
  5198. var previousRenderNodeCount = node.renderNodeCount;
  5199. var toInsert = this.updateNodeAfterCollapseChange(node);
  5200. var deleteCount = previousRenderNodeCount - (listIndex === -1 ? 0 : 1);
  5201. this.list.splice(listIndex + 1, deleteCount, toInsert.slice(1));
  5202. return result;
  5203. };
  5204. IndexTreeModel.prototype._setNodeCollapseState = function (node, update, deep) {
  5205. var result;
  5206. if (node === this.root) {
  5207. result = false;
  5208. }
  5209. else {
  5210. if (isCollapsibleStateUpdate(update)) {
  5211. result = node.collapsible !== update.collapsible;
  5212. node.collapsible = update.collapsible;
  5213. }
  5214. else if (!node.collapsible) {
  5215. result = false;
  5216. }
  5217. else {
  5218. result = node.collapsed !== update.collapsed;
  5219. node.collapsed = update.collapsed;
  5220. }
  5221. if (result) {
  5222. this._onDidChangeCollapseState.fire({ node: node, deep: deep });
  5223. }
  5224. }
  5225. if (!isCollapsibleStateUpdate(update) && update.recursive) {
  5226. for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
  5227. var child = _a[_i];
  5228. result = this._setNodeCollapseState(child, update, true) || result;
  5229. }
  5230. }
  5231. return result;
  5232. };
  5233. IndexTreeModel.prototype.expandTo = function (location) {
  5234. var _this = this;
  5235. this.eventBufferer.bufferEvents(function () {
  5236. var node = _this.getTreeNode(location);
  5237. while (node.parent) {
  5238. node = node.parent;
  5239. location = location.slice(0, location.length - 1);
  5240. if (node.collapsed) {
  5241. _this._setCollapseState(location, { collapsed: false, recursive: false });
  5242. }
  5243. }
  5244. });
  5245. };
  5246. IndexTreeModel.prototype.refilter = function () {
  5247. var previousRenderNodeCount = this.root.renderNodeCount;
  5248. var toInsert = this.updateNodeAfterFilterChange(this.root);
  5249. this.list.splice(0, previousRenderNodeCount, toInsert);
  5250. };
  5251. IndexTreeModel.prototype.createTreeNode = function (treeElement, parent, parentVisibility, revealed, treeListElements, onDidCreateNode) {
  5252. var _this = this;
  5253. var node = {
  5254. parent: parent,
  5255. element: treeElement.element,
  5256. children: [],
  5257. depth: parent.depth + 1,
  5258. visibleChildrenCount: 0,
  5259. visibleChildIndex: -1,
  5260. collapsible: typeof treeElement.collapsible === 'boolean' ? treeElement.collapsible : (typeof treeElement.collapsed !== 'undefined'),
  5261. collapsed: typeof treeElement.collapsed === 'undefined' ? this.collapseByDefault : treeElement.collapsed,
  5262. renderNodeCount: 1,
  5263. visible: true,
  5264. filterData: undefined
  5265. };
  5266. var visibility = this._filterNode(node, parentVisibility);
  5267. if (revealed) {
  5268. treeListElements.push(node);
  5269. }
  5270. var childElements = iterator_1.Iterator.from(treeElement.children);
  5271. var childRevealed = revealed && visibility !== 0 /* Hidden */ && !node.collapsed;
  5272. var childNodes = iterator_1.Iterator.map(childElements, function (el) { return _this.createTreeNode(el, node, visibility, childRevealed, treeListElements, onDidCreateNode); });
  5273. var visibleChildrenCount = 0;
  5274. var renderNodeCount = 1;
  5275. iterator_1.Iterator.forEach(childNodes, function (child) {
  5276. node.children.push(child);
  5277. renderNodeCount += child.renderNodeCount;
  5278. if (child.visible) {
  5279. child.visibleChildIndex = visibleChildrenCount++;
  5280. }
  5281. });
  5282. node.collapsible = node.collapsible || node.children.length > 0;
  5283. node.visibleChildrenCount = visibleChildrenCount;
  5284. node.visible = visibility === 2 /* Recurse */ ? visibleChildrenCount > 0 : (visibility === 1 /* Visible */);
  5285. if (!node.visible) {
  5286. node.renderNodeCount = 0;
  5287. if (revealed) {
  5288. treeListElements.pop();
  5289. }
  5290. }
  5291. else if (!node.collapsed) {
  5292. node.renderNodeCount = renderNodeCount;
  5293. }
  5294. if (onDidCreateNode) {
  5295. onDidCreateNode(node);
  5296. }
  5297. return node;
  5298. };
  5299. IndexTreeModel.prototype.updateNodeAfterCollapseChange = function (node) {
  5300. var previousRenderNodeCount = node.renderNodeCount;
  5301. var result = [];
  5302. this._updateNodeAfterCollapseChange(node, result);
  5303. this._updateAncestorsRenderNodeCount(node.parent, result.length - previousRenderNodeCount);
  5304. return result;
  5305. };
  5306. IndexTreeModel.prototype._updateNodeAfterCollapseChange = function (node, result) {
  5307. if (node.visible === false) {
  5308. return 0;
  5309. }
  5310. result.push(node);
  5311. node.renderNodeCount = 1;
  5312. if (!node.collapsed) {
  5313. for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
  5314. var child = _a[_i];
  5315. node.renderNodeCount += this._updateNodeAfterCollapseChange(child, result);
  5316. }
  5317. }
  5318. this._onDidChangeRenderNodeCount.fire(node);
  5319. return node.renderNodeCount;
  5320. };
  5321. IndexTreeModel.prototype.updateNodeAfterFilterChange = function (node) {
  5322. var previousRenderNodeCount = node.renderNodeCount;
  5323. var result = [];
  5324. this._updateNodeAfterFilterChange(node, node.visible ? 1 /* Visible */ : 0 /* Hidden */, result);
  5325. this._updateAncestorsRenderNodeCount(node.parent, result.length - previousRenderNodeCount);
  5326. return result;
  5327. };
  5328. IndexTreeModel.prototype._updateNodeAfterFilterChange = function (node, parentVisibility, result, revealed) {
  5329. if (revealed === void 0) { revealed = true; }
  5330. var visibility;
  5331. if (node !== this.root) {
  5332. visibility = this._filterNode(node, parentVisibility);
  5333. if (visibility === 0 /* Hidden */) {
  5334. node.visible = false;
  5335. node.renderNodeCount = 0;
  5336. return false;
  5337. }
  5338. if (revealed) {
  5339. result.push(node);
  5340. }
  5341. }
  5342. var resultStartLength = result.length;
  5343. node.renderNodeCount = node === this.root ? 0 : 1;
  5344. var hasVisibleDescendants = false;
  5345. if (!node.collapsed || visibility !== 0 /* Hidden */) {
  5346. var visibleChildIndex = 0;
  5347. for (var _i = 0, _a = node.children; _i < _a.length; _i++) {
  5348. var child = _a[_i];
  5349. hasVisibleDescendants = this._updateNodeAfterFilterChange(child, visibility, result, revealed && !node.collapsed) || hasVisibleDescendants;
  5350. if (child.visible) {
  5351. child.visibleChildIndex = visibleChildIndex++;
  5352. }
  5353. }
  5354. node.visibleChildrenCount = visibleChildIndex;
  5355. }
  5356. else {
  5357. node.visibleChildrenCount = 0;
  5358. }
  5359. if (node !== this.root) {
  5360. node.visible = visibility === 2 /* Recurse */ ? hasVisibleDescendants : (visibility === 1 /* Visible */);
  5361. }
  5362. if (!node.visible) {
  5363. node.renderNodeCount = 0;
  5364. if (revealed) {
  5365. result.pop();
  5366. }
  5367. }
  5368. else if (!node.collapsed) {
  5369. node.renderNodeCount += result.length - resultStartLength;
  5370. }
  5371. this._onDidChangeRenderNodeCount.fire(node);
  5372. return node.visible;
  5373. };
  5374. IndexTreeModel.prototype._updateAncestorsRenderNodeCount = function (node, diff) {
  5375. if (diff === 0) {
  5376. return;
  5377. }
  5378. while (node) {
  5379. node.renderNodeCount += diff;
  5380. this._onDidChangeRenderNodeCount.fire(node);
  5381. node = node.parent;
  5382. }
  5383. };
  5384. IndexTreeModel.prototype._filterNode = function (node, parentVisibility) {
  5385. var result = this.filter ? this.filter.filter(node.element, parentVisibility) : 1 /* Visible */;
  5386. if (typeof result === 'boolean') {
  5387. node.filterData = undefined;
  5388. return result ? 1 /* Visible */ : 0 /* Hidden */;
  5389. }
  5390. else if (isFilterResult(result)) {
  5391. node.filterData = result.data;
  5392. return getVisibleState(result.visibility);
  5393. }
  5394. else {
  5395. node.filterData = undefined;
  5396. return getVisibleState(result);
  5397. }
  5398. };
  5399. // cheap
  5400. IndexTreeModel.prototype.hasTreeNode = function (location, node) {
  5401. if (node === void 0) { node = this.root; }
  5402. if (!location || location.length === 0) {
  5403. return true;
  5404. }
  5405. var index = location[0], rest = location.slice(1);
  5406. if (index < 0 || index > node.children.length) {
  5407. return false;
  5408. }
  5409. return this.hasTreeNode(rest, node.children[index]);
  5410. };
  5411. // cheap
  5412. IndexTreeModel.prototype.getTreeNode = function (location, node) {
  5413. if (node === void 0) { node = this.root; }
  5414. if (!location || location.length === 0) {
  5415. return node;
  5416. }
  5417. var index = location[0], rest = location.slice(1);
  5418. if (index < 0 || index > node.children.length) {
  5419. throw new tree_1.TreeError(this.user, 'Invalid tree location');
  5420. }
  5421. return this.getTreeNode(rest, node.children[index]);
  5422. };
  5423. // expensive
  5424. IndexTreeModel.prototype.getTreeNodeWithListIndex = function (location) {
  5425. if (location.length === 0) {
  5426. return { node: this.root, listIndex: -1, revealed: true, visible: false };
  5427. }
  5428. var _a = this.getParentNodeWithListIndex(location), parentNode = _a.parentNode, listIndex = _a.listIndex, revealed = _a.revealed, visible = _a.visible;
  5429. var index = location[location.length - 1];
  5430. if (index < 0 || index > parentNode.children.length) {
  5431. throw new tree_1.TreeError(this.user, 'Invalid tree location');
  5432. }
  5433. var node = parentNode.children[index];
  5434. return { node: node, listIndex: listIndex, revealed: revealed, visible: visible && node.visible };
  5435. };
  5436. IndexTreeModel.prototype.getParentNodeWithListIndex = function (location, node, listIndex, revealed, visible) {
  5437. if (node === void 0) { node = this.root; }
  5438. if (listIndex === void 0) { listIndex = 0; }
  5439. if (revealed === void 0) { revealed = true; }
  5440. if (visible === void 0) { visible = true; }
  5441. var index = location[0], rest = location.slice(1);
  5442. if (index < 0 || index > node.children.length) {
  5443. throw new tree_1.TreeError(this.user, 'Invalid tree location');
  5444. }
  5445. // TODO@joao perf!
  5446. for (var i = 0; i < index; i++) {
  5447. listIndex += node.children[i].renderNodeCount;
  5448. }
  5449. revealed = revealed && !node.collapsed;
  5450. visible = visible && node.visible;
  5451. if (rest.length === 0) {
  5452. return { parentNode: node, listIndex: listIndex, revealed: revealed, visible: visible };
  5453. }
  5454. return this.getParentNodeWithListIndex(rest, node.children[index], listIndex + 1, revealed, visible);
  5455. };
  5456. IndexTreeModel.prototype.getNode = function (location) {
  5457. if (location === void 0) { location = []; }
  5458. return this.getTreeNode(location);
  5459. };
  5460. // TODO@joao perf!
  5461. IndexTreeModel.prototype.getNodeLocation = function (node) {
  5462. var location = [];
  5463. var indexTreeNode = node; // typing woes
  5464. while (indexTreeNode.parent) {
  5465. location.push(indexTreeNode.parent.children.indexOf(indexTreeNode));
  5466. indexTreeNode = indexTreeNode.parent;
  5467. }
  5468. return location.reverse();
  5469. };
  5470. IndexTreeModel.prototype.getParentNodeLocation = function (location) {
  5471. if (location.length === 0) {
  5472. return undefined;
  5473. }
  5474. else if (location.length === 1) {
  5475. return [];
  5476. }
  5477. else {
  5478. return arrays_1.tail2(location)[0];
  5479. }
  5480. };
  5481. return IndexTreeModel;
  5482. }());
  5483. exports.IndexTreeModel = IndexTreeModel;
  5484. });
  5485. /*---------------------------------------------------------------------------------------------
  5486. * Copyright (c) Microsoft Corporation. All rights reserved.
  5487. * Licensed under the MIT License. See License.txt in the project root for license information.
  5488. *--------------------------------------------------------------------------------------------*/
  5489. var __assign = (this && this.__assign) || function () {
  5490. __assign = Object.assign || function(t) {
  5491. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5492. s = arguments[i];
  5493. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  5494. t[p] = s[p];
  5495. }
  5496. return t;
  5497. };
  5498. return __assign.apply(this, arguments);
  5499. };
  5500. var __spreadArrays = (this && this.__spreadArrays) || function () {
  5501. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  5502. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  5503. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  5504. r[k] = a[j];
  5505. return r;
  5506. };
  5507. define(__m[130/*vs/base/browser/ui/tree/objectTreeModel*/], __M([0/*require*/,1/*exports*/,54/*vs/base/common/iterator*/,129/*vs/base/browser/ui/tree/indexTreeModel*/,99/*vs/base/browser/ui/tree/tree*/,19/*vs/base/common/arrays*/]), function (require, exports, iterator_1, indexTreeModel_1, tree_1, arrays_1) {
  5508. "use strict";
  5509. Object.defineProperty(exports, "__esModule", { value: true });
  5510. var ObjectTreeModel = /** @class */ (function () {
  5511. function ObjectTreeModel(user, list, options) {
  5512. if (options === void 0) { options = {}; }
  5513. this.user = user;
  5514. this.nodes = new Map();
  5515. this.nodesByIdentity = new Map();
  5516. this.model = new indexTreeModel_1.IndexTreeModel(user, list, null, options);
  5517. this.onDidSplice = this.model.onDidSplice;
  5518. this.onDidChangeCollapseState = this.model.onDidChangeCollapseState;
  5519. this.onDidChangeRenderNodeCount = this.model.onDidChangeRenderNodeCount;
  5520. if (options.sorter) {
  5521. this.sorter = {
  5522. compare: function (a, b) {
  5523. return options.sorter.compare(a.element, b.element);
  5524. }
  5525. };
  5526. }
  5527. this.identityProvider = options.identityProvider;
  5528. }
  5529. ObjectTreeModel.prototype.setChildren = function (element, children, onDidCreateNode, onDidDeleteNode) {
  5530. var location = this.getElementLocation(element);
  5531. this._setChildren(location, this.preserveCollapseState(children), onDidCreateNode, onDidDeleteNode);
  5532. };
  5533. ObjectTreeModel.prototype._setChildren = function (location, children, onDidCreateNode, onDidDeleteNode) {
  5534. var _this = this;
  5535. var insertedElements = new Set();
  5536. var insertedElementIds = new Set();
  5537. var _onDidCreateNode = function (node) {
  5538. insertedElements.add(node.element);
  5539. _this.nodes.set(node.element, node);
  5540. if (_this.identityProvider) {
  5541. var id = _this.identityProvider.getId(node.element).toString();
  5542. insertedElementIds.add(id);
  5543. _this.nodesByIdentity.set(id, node);
  5544. }
  5545. if (onDidCreateNode) {
  5546. onDidCreateNode(node);
  5547. }
  5548. };
  5549. var _onDidDeleteNode = function (node) {
  5550. if (!insertedElements.has(node.element)) {
  5551. _this.nodes.delete(node.element);
  5552. }
  5553. if (_this.identityProvider) {
  5554. var id = _this.identityProvider.getId(node.element).toString();
  5555. if (!insertedElementIds.has(id)) {
  5556. _this.nodesByIdentity.delete(id);
  5557. }
  5558. }
  5559. if (onDidDeleteNode) {
  5560. onDidDeleteNode(node);
  5561. }
  5562. };
  5563. this.model.splice(__spreadArrays(location, [0]), Number.MAX_VALUE, children, _onDidCreateNode, _onDidDeleteNode);
  5564. };
  5565. ObjectTreeModel.prototype.preserveCollapseState = function (elements) {
  5566. var _this = this;
  5567. var iterator = elements ? iterator_1.getSequenceIterator(elements) : iterator_1.Iterator.empty();
  5568. if (this.sorter) {
  5569. iterator = iterator_1.Iterator.fromArray(arrays_1.mergeSort(iterator_1.Iterator.collect(iterator), this.sorter.compare.bind(this.sorter)));
  5570. }
  5571. return iterator_1.Iterator.map(iterator, function (treeElement) {
  5572. var node = _this.nodes.get(treeElement.element);
  5573. if (!node && _this.identityProvider) {
  5574. var id = _this.identityProvider.getId(treeElement.element).toString();
  5575. node = _this.nodesByIdentity.get(id);
  5576. }
  5577. if (!node) {
  5578. return __assign(__assign({}, treeElement), { children: _this.preserveCollapseState(treeElement.children) });
  5579. }
  5580. var collapsible = typeof treeElement.collapsible === 'boolean' ? treeElement.collapsible : node.collapsible;
  5581. var collapsed = typeof treeElement.collapsed !== 'undefined' ? treeElement.collapsed : node.collapsed;
  5582. return __assign(__assign({}, treeElement), { collapsible: collapsible,
  5583. collapsed: collapsed, children: _this.preserveCollapseState(treeElement.children) });
  5584. });
  5585. };
  5586. ObjectTreeModel.prototype.rerender = function (element) {
  5587. var location = this.getElementLocation(element);
  5588. this.model.rerender(location);
  5589. };
  5590. ObjectTreeModel.prototype.has = function (element) {
  5591. return this.nodes.has(element);
  5592. };
  5593. ObjectTreeModel.prototype.getListIndex = function (element) {
  5594. var location = this.getElementLocation(element);
  5595. return this.model.getListIndex(location);
  5596. };
  5597. ObjectTreeModel.prototype.getListRenderCount = function (element) {
  5598. var location = this.getElementLocation(element);
  5599. return this.model.getListRenderCount(location);
  5600. };
  5601. ObjectTreeModel.prototype.isCollapsible = function (element) {
  5602. var location = this.getElementLocation(element);
  5603. return this.model.isCollapsible(location);
  5604. };
  5605. ObjectTreeModel.prototype.setCollapsible = function (element, collapsible) {
  5606. var location = this.getElementLocation(element);
  5607. return this.model.setCollapsible(location, collapsible);
  5608. };
  5609. ObjectTreeModel.prototype.isCollapsed = function (element) {
  5610. var location = this.getElementLocation(element);
  5611. return this.model.isCollapsed(location);
  5612. };
  5613. ObjectTreeModel.prototype.setCollapsed = function (element, collapsed, recursive) {
  5614. var location = this.getElementLocation(element);
  5615. return this.model.setCollapsed(location, collapsed, recursive);
  5616. };
  5617. ObjectTreeModel.prototype.expandTo = function (element) {
  5618. var location = this.getElementLocation(element);
  5619. this.model.expandTo(location);
  5620. };
  5621. ObjectTreeModel.prototype.refilter = function () {
  5622. this.model.refilter();
  5623. };
  5624. ObjectTreeModel.prototype.getNode = function (element) {
  5625. if (element === void 0) { element = null; }
  5626. if (element === null) {
  5627. return this.model.getNode(this.model.rootRef);
  5628. }
  5629. var node = this.nodes.get(element);
  5630. if (!node) {
  5631. throw new tree_1.TreeError(this.user, "Tree element not found: " + element);
  5632. }
  5633. return node;
  5634. };
  5635. ObjectTreeModel.prototype.getNodeLocation = function (node) {
  5636. return node.element;
  5637. };
  5638. ObjectTreeModel.prototype.getParentNodeLocation = function (element) {
  5639. if (element === null) {
  5640. throw new tree_1.TreeError(this.user, "Invalid getParentNodeLocation call");
  5641. }
  5642. var node = this.nodes.get(element);
  5643. if (!node) {
  5644. throw new tree_1.TreeError(this.user, "Tree element not found: " + element);
  5645. }
  5646. var location = this.model.getNodeLocation(node);
  5647. var parentLocation = this.model.getParentNodeLocation(location);
  5648. var parent = this.model.getNode(parentLocation);
  5649. return parent.element;
  5650. };
  5651. ObjectTreeModel.prototype.getElementLocation = function (element) {
  5652. if (element === null) {
  5653. return [];
  5654. }
  5655. var node = this.nodes.get(element);
  5656. if (!node) {
  5657. throw new tree_1.TreeError(this.user, "Tree element not found: " + element);
  5658. }
  5659. return this.model.getNodeLocation(node);
  5660. };
  5661. return ObjectTreeModel;
  5662. }());
  5663. exports.ObjectTreeModel = ObjectTreeModel;
  5664. });
  5665. /*---------------------------------------------------------------------------------------------
  5666. * Copyright (c) Microsoft Corporation. All rights reserved.
  5667. * Licensed under the MIT License. See License.txt in the project root for license information.
  5668. *--------------------------------------------------------------------------------------------*/
  5669. define(__m[243/*vs/base/browser/ui/tree/compressedObjectTreeModel*/], __M([0/*require*/,1/*exports*/,54/*vs/base/common/iterator*/,4/*vs/base/common/event*/,99/*vs/base/browser/ui/tree/tree*/,130/*vs/base/browser/ui/tree/objectTreeModel*/]), function (require, exports, iterator_1, event_1, tree_1, objectTreeModel_1) {
  5670. "use strict";
  5671. Object.defineProperty(exports, "__esModule", { value: true });
  5672. function noCompress(element) {
  5673. var elements = [element.element];
  5674. var incompressible = element.incompressible || false;
  5675. return {
  5676. element: { elements: elements, incompressible: incompressible },
  5677. children: iterator_1.Iterator.map(iterator_1.Iterator.from(element.children), noCompress),
  5678. collapsible: element.collapsible,
  5679. collapsed: element.collapsed
  5680. };
  5681. }
  5682. // Exported only for test reasons, do not use directly
  5683. function compress(element) {
  5684. var elements = [element.element];
  5685. var incompressible = element.incompressible || false;
  5686. var childrenIterator;
  5687. var children;
  5688. while (true) {
  5689. childrenIterator = iterator_1.Iterator.from(element.children);
  5690. children = iterator_1.Iterator.collect(childrenIterator, 2);
  5691. if (children.length !== 1) {
  5692. break;
  5693. }
  5694. element = children[0];
  5695. if (element.incompressible) {
  5696. break;
  5697. }
  5698. elements.push(element.element);
  5699. }
  5700. return {
  5701. element: { elements: elements, incompressible: incompressible },
  5702. children: iterator_1.Iterator.map(iterator_1.Iterator.concat(iterator_1.Iterator.fromArray(children), childrenIterator), compress),
  5703. collapsible: element.collapsible,
  5704. collapsed: element.collapsed
  5705. };
  5706. }
  5707. exports.compress = compress;
  5708. function _decompress(element, index) {
  5709. if (index === void 0) { index = 0; }
  5710. var children;
  5711. if (index < element.element.elements.length - 1) {
  5712. children = iterator_1.Iterator.single(_decompress(element, index + 1));
  5713. }
  5714. else {
  5715. children = iterator_1.Iterator.map(iterator_1.Iterator.from(element.children), function (el) { return _decompress(el, 0); });
  5716. }
  5717. if (index === 0 && element.element.incompressible) {
  5718. return {
  5719. element: element.element.elements[index],
  5720. children: children,
  5721. incompressible: true,
  5722. collapsible: element.collapsible,
  5723. collapsed: element.collapsed
  5724. };
  5725. }
  5726. return {
  5727. element: element.element.elements[index],
  5728. children: children,
  5729. collapsible: element.collapsible,
  5730. collapsed: element.collapsed
  5731. };
  5732. }
  5733. // Exported only for test reasons, do not use directly
  5734. function decompress(element) {
  5735. return _decompress(element, 0);
  5736. }
  5737. exports.decompress = decompress;
  5738. function splice(treeElement, element, children) {
  5739. if (treeElement.element === element) {
  5740. return __assign(__assign({}, treeElement), { children: children });
  5741. }
  5742. return __assign(__assign({}, treeElement), { children: iterator_1.Iterator.map(iterator_1.Iterator.from(treeElement.children), function (e) { return splice(e, element, children); }) });
  5743. }
  5744. // Exported only for test reasons, do not use directly
  5745. var CompressedObjectTreeModel = /** @class */ (function () {
  5746. function CompressedObjectTreeModel(user, list, options) {
  5747. if (options === void 0) { options = {}; }
  5748. this.user = user;
  5749. this.nodes = new Map();
  5750. this.model = new objectTreeModel_1.ObjectTreeModel(user, list, options);
  5751. this.enabled = typeof options.compressionEnabled === 'undefined' ? true : options.compressionEnabled;
  5752. }
  5753. Object.defineProperty(CompressedObjectTreeModel.prototype, "onDidSplice", {
  5754. get: function () { return this.model.onDidSplice; },
  5755. enumerable: true,
  5756. configurable: true
  5757. });
  5758. Object.defineProperty(CompressedObjectTreeModel.prototype, "onDidChangeCollapseState", {
  5759. get: function () { return this.model.onDidChangeCollapseState; },
  5760. enumerable: true,
  5761. configurable: true
  5762. });
  5763. CompressedObjectTreeModel.prototype.setChildren = function (element, children) {
  5764. if (element === null) {
  5765. var compressedChildren = iterator_1.Iterator.map(iterator_1.Iterator.from(children), this.enabled ? compress : noCompress);
  5766. this._setChildren(null, compressedChildren);
  5767. return;
  5768. }
  5769. var compressedNode = this.nodes.get(element);
  5770. if (!compressedNode) {
  5771. throw new Error('Unknown compressed tree node');
  5772. }
  5773. var node = this.model.getNode(compressedNode);
  5774. var compressedParentNode = this.model.getParentNodeLocation(compressedNode);
  5775. var parent = this.model.getNode(compressedParentNode);
  5776. var decompressedElement = decompress(node);
  5777. var splicedElement = splice(decompressedElement, element, iterator_1.Iterator.from(children));
  5778. var recompressedElement = (this.enabled ? compress : noCompress)(splicedElement);
  5779. var parentChildren = parent.children
  5780. .map(function (child) { return child === node ? recompressedElement : child; });
  5781. this._setChildren(parent.element, parentChildren);
  5782. };
  5783. CompressedObjectTreeModel.prototype.setCompressionEnabled = function (enabled) {
  5784. if (enabled === this.enabled) {
  5785. return;
  5786. }
  5787. this.enabled = enabled;
  5788. var root = this.model.getNode();
  5789. var rootChildren = iterator_1.Iterator.from(root.children);
  5790. var decompressedRootChildren = iterator_1.Iterator.map(rootChildren, decompress);
  5791. var recompressedRootChildren = iterator_1.Iterator.map(decompressedRootChildren, enabled ? compress : noCompress);
  5792. this._setChildren(null, recompressedRootChildren);
  5793. };
  5794. CompressedObjectTreeModel.prototype._setChildren = function (node, children) {
  5795. var _this = this;
  5796. var insertedElements = new Set();
  5797. var _onDidCreateNode = function (node) {
  5798. for (var _i = 0, _a = node.element.elements; _i < _a.length; _i++) {
  5799. var element = _a[_i];
  5800. insertedElements.add(element);
  5801. _this.nodes.set(element, node.element);
  5802. }
  5803. };
  5804. var _onDidDeleteNode = function (node) {
  5805. for (var _i = 0, _a = node.element.elements; _i < _a.length; _i++) {
  5806. var element = _a[_i];
  5807. if (!insertedElements.has(element)) {
  5808. _this.nodes.delete(element);
  5809. }
  5810. }
  5811. };
  5812. this.model.setChildren(node, children, _onDidCreateNode, _onDidDeleteNode);
  5813. };
  5814. CompressedObjectTreeModel.prototype.has = function (element) {
  5815. return this.nodes.has(element);
  5816. };
  5817. CompressedObjectTreeModel.prototype.getListIndex = function (location) {
  5818. var node = this.getCompressedNode(location);
  5819. return this.model.getListIndex(node);
  5820. };
  5821. CompressedObjectTreeModel.prototype.getListRenderCount = function (location) {
  5822. var node = this.getCompressedNode(location);
  5823. return this.model.getListRenderCount(node);
  5824. };
  5825. CompressedObjectTreeModel.prototype.getNode = function (location) {
  5826. if (typeof location === 'undefined') {
  5827. return this.model.getNode();
  5828. }
  5829. var node = this.getCompressedNode(location);
  5830. return this.model.getNode(node);
  5831. };
  5832. // TODO: review this
  5833. CompressedObjectTreeModel.prototype.getNodeLocation = function (node) {
  5834. var compressedNode = this.model.getNodeLocation(node);
  5835. if (compressedNode === null) {
  5836. return null;
  5837. }
  5838. return compressedNode.elements[compressedNode.elements.length - 1];
  5839. };
  5840. // TODO: review this
  5841. CompressedObjectTreeModel.prototype.getParentNodeLocation = function (location) {
  5842. var compressedNode = this.getCompressedNode(location);
  5843. var parentNode = this.model.getParentNodeLocation(compressedNode);
  5844. if (parentNode === null) {
  5845. return null;
  5846. }
  5847. return parentNode.elements[parentNode.elements.length - 1];
  5848. };
  5849. CompressedObjectTreeModel.prototype.isCollapsible = function (location) {
  5850. var compressedNode = this.getCompressedNode(location);
  5851. return this.model.isCollapsible(compressedNode);
  5852. };
  5853. CompressedObjectTreeModel.prototype.setCollapsible = function (location, collapsible) {
  5854. var compressedNode = this.getCompressedNode(location);
  5855. return this.model.setCollapsible(compressedNode, collapsible);
  5856. };
  5857. CompressedObjectTreeModel.prototype.isCollapsed = function (location) {
  5858. var compressedNode = this.getCompressedNode(location);
  5859. return this.model.isCollapsed(compressedNode);
  5860. };
  5861. CompressedObjectTreeModel.prototype.setCollapsed = function (location, collapsed, recursive) {
  5862. var compressedNode = this.getCompressedNode(location);
  5863. return this.model.setCollapsed(compressedNode, collapsed, recursive);
  5864. };
  5865. CompressedObjectTreeModel.prototype.expandTo = function (location) {
  5866. var compressedNode = this.getCompressedNode(location);
  5867. this.model.expandTo(compressedNode);
  5868. };
  5869. CompressedObjectTreeModel.prototype.rerender = function (location) {
  5870. var compressedNode = this.getCompressedNode(location);
  5871. this.model.rerender(compressedNode);
  5872. };
  5873. CompressedObjectTreeModel.prototype.refilter = function () {
  5874. this.model.refilter();
  5875. };
  5876. CompressedObjectTreeModel.prototype.getCompressedNode = function (element) {
  5877. if (element === null) {
  5878. return null;
  5879. }
  5880. var node = this.nodes.get(element);
  5881. if (!node) {
  5882. throw new tree_1.TreeError(this.user, "Tree element not found: " + element);
  5883. }
  5884. return node;
  5885. };
  5886. return CompressedObjectTreeModel;
  5887. }());
  5888. exports.CompressedObjectTreeModel = CompressedObjectTreeModel;
  5889. exports.DefaultElementMapper = function (elements) { return elements[elements.length - 1]; };
  5890. var CompressedTreeNodeWrapper = /** @class */ (function () {
  5891. function CompressedTreeNodeWrapper(unwrapper, node) {
  5892. this.unwrapper = unwrapper;
  5893. this.node = node;
  5894. }
  5895. Object.defineProperty(CompressedTreeNodeWrapper.prototype, "element", {
  5896. get: function () { return this.node.element === null ? null : this.unwrapper(this.node.element); },
  5897. enumerable: true,
  5898. configurable: true
  5899. });
  5900. Object.defineProperty(CompressedTreeNodeWrapper.prototype, "children", {
  5901. get: function () {
  5902. var _this = this;
  5903. return this.node.children.map(function (node) { return new CompressedTreeNodeWrapper(_this.unwrapper, node); });
  5904. },
  5905. enumerable: true,
  5906. configurable: true
  5907. });
  5908. Object.defineProperty(CompressedTreeNodeWrapper.prototype, "depth", {
  5909. get: function () { return this.node.depth; },
  5910. enumerable: true,
  5911. configurable: true
  5912. });
  5913. Object.defineProperty(CompressedTreeNodeWrapper.prototype, "visibleChildrenCount", {
  5914. get: function () { return this.node.visibleChildrenCount; },
  5915. enumerable: true,
  5916. configurable: true
  5917. });
  5918. Object.defineProperty(CompressedTreeNodeWrapper.prototype, "visibleChildIndex", {
  5919. get: function () { return this.node.visibleChildIndex; },
  5920. enumerable: true,
  5921. configurable: true
  5922. });
  5923. Object.defineProperty(CompressedTreeNodeWrapper.prototype, "collapsible", {
  5924. get: function () { return this.node.collapsible; },
  5925. enumerable: true,
  5926. configurable: true
  5927. });
  5928. Object.defineProperty(CompressedTreeNodeWrapper.prototype, "collapsed", {
  5929. get: function () { return this.node.collapsed; },
  5930. enumerable: true,
  5931. configurable: true
  5932. });
  5933. Object.defineProperty(CompressedTreeNodeWrapper.prototype, "visible", {
  5934. get: function () { return this.node.visible; },
  5935. enumerable: true,
  5936. configurable: true
  5937. });
  5938. Object.defineProperty(CompressedTreeNodeWrapper.prototype, "filterData", {
  5939. get: function () { return this.node.filterData; },
  5940. enumerable: true,
  5941. configurable: true
  5942. });
  5943. return CompressedTreeNodeWrapper;
  5944. }());
  5945. function mapList(nodeMapper, list) {
  5946. return {
  5947. splice: function (start, deleteCount, toInsert) {
  5948. list.splice(start, deleteCount, toInsert.map(function (node) { return nodeMapper.map(node); }));
  5949. }
  5950. };
  5951. }
  5952. function mapOptions(compressedNodeUnwrapper, options) {
  5953. return __assign(__assign({}, options), { sorter: options.sorter && {
  5954. compare: function (node, otherNode) {
  5955. return options.sorter.compare(node.elements[0], otherNode.elements[0]);
  5956. }
  5957. }, identityProvider: options.identityProvider && {
  5958. getId: function (node) {
  5959. return options.identityProvider.getId(compressedNodeUnwrapper(node));
  5960. }
  5961. }, filter: options.filter && {
  5962. filter: function (node, parentVisibility) {
  5963. return options.filter.filter(compressedNodeUnwrapper(node), parentVisibility);
  5964. }
  5965. } });
  5966. }
  5967. var CompressibleObjectTreeModel = /** @class */ (function () {
  5968. function CompressibleObjectTreeModel(user, list, options) {
  5969. var _this = this;
  5970. if (options === void 0) { options = {}; }
  5971. this.elementMapper = options.elementMapper || exports.DefaultElementMapper;
  5972. var compressedNodeUnwrapper = function (node) { return _this.elementMapper(node.elements); };
  5973. this.nodeMapper = new tree_1.WeakMapper(function (node) { return new CompressedTreeNodeWrapper(compressedNodeUnwrapper, node); });
  5974. this.model = new CompressedObjectTreeModel(user, mapList(this.nodeMapper, list), mapOptions(compressedNodeUnwrapper, options));
  5975. }
  5976. Object.defineProperty(CompressibleObjectTreeModel.prototype, "onDidSplice", {
  5977. get: function () {
  5978. var _this = this;
  5979. return event_1.Event.map(this.model.onDidSplice, function (_a) {
  5980. var insertedNodes = _a.insertedNodes, deletedNodes = _a.deletedNodes;
  5981. return ({
  5982. insertedNodes: insertedNodes.map(function (node) { return _this.nodeMapper.map(node); }),
  5983. deletedNodes: deletedNodes.map(function (node) { return _this.nodeMapper.map(node); }),
  5984. });
  5985. });
  5986. },
  5987. enumerable: true,
  5988. configurable: true
  5989. });
  5990. Object.defineProperty(CompressibleObjectTreeModel.prototype, "onDidChangeCollapseState", {
  5991. get: function () {
  5992. var _this = this;
  5993. return event_1.Event.map(this.model.onDidChangeCollapseState, function (_a) {
  5994. var node = _a.node, deep = _a.deep;
  5995. return ({
  5996. node: _this.nodeMapper.map(node),
  5997. deep: deep
  5998. });
  5999. });
  6000. },
  6001. enumerable: true,
  6002. configurable: true
  6003. });
  6004. CompressibleObjectTreeModel.prototype.setChildren = function (element, children) {
  6005. this.model.setChildren(element, children);
  6006. };
  6007. CompressibleObjectTreeModel.prototype.setCompressionEnabled = function (enabled) {
  6008. this.model.setCompressionEnabled(enabled);
  6009. };
  6010. CompressibleObjectTreeModel.prototype.has = function (location) {
  6011. return this.model.has(location);
  6012. };
  6013. CompressibleObjectTreeModel.prototype.getListIndex = function (location) {
  6014. return this.model.getListIndex(location);
  6015. };
  6016. CompressibleObjectTreeModel.prototype.getListRenderCount = function (location) {
  6017. return this.model.getListRenderCount(location);
  6018. };
  6019. CompressibleObjectTreeModel.prototype.getNode = function (location) {
  6020. return this.nodeMapper.map(this.model.getNode(location));
  6021. };
  6022. CompressibleObjectTreeModel.prototype.getNodeLocation = function (node) {
  6023. return node.element;
  6024. };
  6025. CompressibleObjectTreeModel.prototype.getParentNodeLocation = function (location) {
  6026. return this.model.getParentNodeLocation(location);
  6027. };
  6028. CompressibleObjectTreeModel.prototype.isCollapsible = function (location) {
  6029. return this.model.isCollapsible(location);
  6030. };
  6031. CompressibleObjectTreeModel.prototype.setCollapsible = function (location, collapsed) {
  6032. return this.model.setCollapsible(location, collapsed);
  6033. };
  6034. CompressibleObjectTreeModel.prototype.isCollapsed = function (location) {
  6035. return this.model.isCollapsed(location);
  6036. };
  6037. CompressibleObjectTreeModel.prototype.setCollapsed = function (location, collapsed, recursive) {
  6038. return this.model.setCollapsed(location, collapsed, recursive);
  6039. };
  6040. CompressibleObjectTreeModel.prototype.expandTo = function (location) {
  6041. return this.model.expandTo(location);
  6042. };
  6043. CompressibleObjectTreeModel.prototype.rerender = function (location) {
  6044. return this.model.rerender(location);
  6045. };
  6046. CompressibleObjectTreeModel.prototype.refilter = function () {
  6047. return this.model.refilter();
  6048. };
  6049. CompressibleObjectTreeModel.prototype.getCompressedTreeNode = function (location) {
  6050. if (location === void 0) { location = null; }
  6051. return this.model.getNode(location);
  6052. };
  6053. return CompressibleObjectTreeModel;
  6054. }());
  6055. exports.CompressibleObjectTreeModel = CompressibleObjectTreeModel;
  6056. });
  6057. /*---------------------------------------------------------------------------------------------
  6058. * Copyright (c) Microsoft Corporation. All rights reserved.
  6059. * Licensed under the MIT License. See License.txt in the project root for license information.
  6060. *--------------------------------------------------------------------------------------------*/
  6061. var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
  6062. function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
  6063. return new (P || (P = Promise))(function (resolve, reject) {
  6064. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  6065. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  6066. function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
  6067. step((generator = generator.apply(thisArg, _arguments || [])).next());
  6068. });
  6069. };
  6070. var __generator = (this && this.__generator) || function (thisArg, body) {
  6071. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  6072. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  6073. function verb(n) { return function (v) { return step([n, v]); }; }
  6074. function step(op) {
  6075. if (f) throw new TypeError("Generator is already executing.");
  6076. while (_) try {
  6077. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  6078. if (y = 0, t) op = [op[0] & 2, t.value];
  6079. switch (op[0]) {
  6080. case 0: case 1: t = op; break;
  6081. case 4: _.label++; return { value: op[1], done: false };
  6082. case 5: _.label++; y = op[1]; op = [0]; continue;
  6083. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  6084. default:
  6085. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  6086. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  6087. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  6088. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  6089. if (t[2]) _.ops.pop();
  6090. _.trys.pop(); continue;
  6091. }
  6092. op = body.call(thisArg, _);
  6093. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  6094. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  6095. }
  6096. };
  6097. define(__m[55/*vs/base/common/actions*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,4/*vs/base/common/event*/]), function (require, exports, lifecycle_1, event_1) {
  6098. "use strict";
  6099. Object.defineProperty(exports, "__esModule", { value: true });
  6100. var Action = /** @class */ (function (_super) {
  6101. __extends(Action, _super);
  6102. function Action(id, label, cssClass, enabled, actionCallback) {
  6103. if (label === void 0) { label = ''; }
  6104. if (cssClass === void 0) { cssClass = ''; }
  6105. if (enabled === void 0) { enabled = true; }
  6106. var _this = _super.call(this) || this;
  6107. _this._onDidChange = _this._register(new event_1.Emitter());
  6108. _this.onDidChange = _this._onDidChange.event;
  6109. _this._enabled = true;
  6110. _this._checked = false;
  6111. _this._id = id;
  6112. _this._label = label;
  6113. _this._cssClass = cssClass;
  6114. _this._enabled = enabled;
  6115. _this._actionCallback = actionCallback;
  6116. return _this;
  6117. }
  6118. Object.defineProperty(Action.prototype, "id", {
  6119. get: function () {
  6120. return this._id;
  6121. },
  6122. enumerable: true,
  6123. configurable: true
  6124. });
  6125. Object.defineProperty(Action.prototype, "label", {
  6126. get: function () {
  6127. return this._label;
  6128. },
  6129. set: function (value) {
  6130. this._setLabel(value);
  6131. },
  6132. enumerable: true,
  6133. configurable: true
  6134. });
  6135. Action.prototype._setLabel = function (value) {
  6136. if (this._label !== value) {
  6137. this._label = value;
  6138. this._onDidChange.fire({ label: value });
  6139. }
  6140. };
  6141. Object.defineProperty(Action.prototype, "tooltip", {
  6142. get: function () {
  6143. return this._tooltip || '';
  6144. },
  6145. set: function (value) {
  6146. this._setTooltip(value);
  6147. },
  6148. enumerable: true,
  6149. configurable: true
  6150. });
  6151. Action.prototype._setTooltip = function (value) {
  6152. if (this._tooltip !== value) {
  6153. this._tooltip = value;
  6154. this._onDidChange.fire({ tooltip: value });
  6155. }
  6156. };
  6157. Object.defineProperty(Action.prototype, "class", {
  6158. get: function () {
  6159. return this._cssClass;
  6160. },
  6161. set: function (value) {
  6162. this._setClass(value);
  6163. },
  6164. enumerable: true,
  6165. configurable: true
  6166. });
  6167. Action.prototype._setClass = function (value) {
  6168. if (this._cssClass !== value) {
  6169. this._cssClass = value;
  6170. this._onDidChange.fire({ class: value });
  6171. }
  6172. };
  6173. Object.defineProperty(Action.prototype, "enabled", {
  6174. get: function () {
  6175. return this._enabled;
  6176. },
  6177. set: function (value) {
  6178. this._setEnabled(value);
  6179. },
  6180. enumerable: true,
  6181. configurable: true
  6182. });
  6183. Action.prototype._setEnabled = function (value) {
  6184. if (this._enabled !== value) {
  6185. this._enabled = value;
  6186. this._onDidChange.fire({ enabled: value });
  6187. }
  6188. };
  6189. Object.defineProperty(Action.prototype, "checked", {
  6190. get: function () {
  6191. return this._checked;
  6192. },
  6193. set: function (value) {
  6194. this._setChecked(value);
  6195. },
  6196. enumerable: true,
  6197. configurable: true
  6198. });
  6199. Action.prototype._setChecked = function (value) {
  6200. if (this._checked !== value) {
  6201. this._checked = value;
  6202. this._onDidChange.fire({ checked: value });
  6203. }
  6204. };
  6205. Action.prototype.run = function (event, _data) {
  6206. if (this._actionCallback) {
  6207. return this._actionCallback(event);
  6208. }
  6209. return Promise.resolve(true);
  6210. };
  6211. return Action;
  6212. }(lifecycle_1.Disposable));
  6213. exports.Action = Action;
  6214. var ActionRunner = /** @class */ (function (_super) {
  6215. __extends(ActionRunner, _super);
  6216. function ActionRunner() {
  6217. var _this = _super !== null && _super.apply(this, arguments) || this;
  6218. _this._onDidBeforeRun = _this._register(new event_1.Emitter());
  6219. _this.onDidBeforeRun = _this._onDidBeforeRun.event;
  6220. _this._onDidRun = _this._register(new event_1.Emitter());
  6221. _this.onDidRun = _this._onDidRun.event;
  6222. return _this;
  6223. }
  6224. ActionRunner.prototype.run = function (action, context) {
  6225. return __awaiter(this, void 0, void 0, function () {
  6226. var result, error_1;
  6227. return __generator(this, function (_a) {
  6228. switch (_a.label) {
  6229. case 0:
  6230. if (!action.enabled) {
  6231. return [2 /*return*/, Promise.resolve(null)];
  6232. }
  6233. this._onDidBeforeRun.fire({ action: action });
  6234. _a.label = 1;
  6235. case 1:
  6236. _a.trys.push([1, 3, , 4]);
  6237. return [4 /*yield*/, this.runAction(action, context)];
  6238. case 2:
  6239. result = _a.sent();
  6240. this._onDidRun.fire({ action: action, result: result });
  6241. return [3 /*break*/, 4];
  6242. case 3:
  6243. error_1 = _a.sent();
  6244. this._onDidRun.fire({ action: action, error: error_1 });
  6245. return [3 /*break*/, 4];
  6246. case 4: return [2 /*return*/];
  6247. }
  6248. });
  6249. });
  6250. };
  6251. ActionRunner.prototype.runAction = function (action, context) {
  6252. var res = context ? action.run(context) : action.run();
  6253. return Promise.resolve(res);
  6254. };
  6255. return ActionRunner;
  6256. }(lifecycle_1.Disposable));
  6257. exports.ActionRunner = ActionRunner;
  6258. });
  6259. /*---------------------------------------------------------------------------------------------
  6260. * Copyright (c) Microsoft Corporation. All rights reserved.
  6261. * Licensed under the MIT License. See License.txt in the project root for license information.
  6262. *--------------------------------------------------------------------------------------------*/
  6263. define(__m[26/*vs/base/common/cancellation*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/]), function (require, exports, event_1) {
  6264. "use strict";
  6265. Object.defineProperty(exports, "__esModule", { value: true });
  6266. var shortcutEvent = Object.freeze(function (callback, context) {
  6267. var handle = setTimeout(callback.bind(context), 0);
  6268. return { dispose: function () { clearTimeout(handle); } };
  6269. });
  6270. var CancellationToken;
  6271. (function (CancellationToken) {
  6272. function isCancellationToken(thing) {
  6273. if (thing === CancellationToken.None || thing === CancellationToken.Cancelled) {
  6274. return true;
  6275. }
  6276. if (thing instanceof MutableToken) {
  6277. return true;
  6278. }
  6279. if (!thing || typeof thing !== 'object') {
  6280. return false;
  6281. }
  6282. return typeof thing.isCancellationRequested === 'boolean'
  6283. && typeof thing.onCancellationRequested === 'function';
  6284. }
  6285. CancellationToken.isCancellationToken = isCancellationToken;
  6286. CancellationToken.None = Object.freeze({
  6287. isCancellationRequested: false,
  6288. onCancellationRequested: event_1.Event.None
  6289. });
  6290. CancellationToken.Cancelled = Object.freeze({
  6291. isCancellationRequested: true,
  6292. onCancellationRequested: shortcutEvent
  6293. });
  6294. })(CancellationToken = exports.CancellationToken || (exports.CancellationToken = {}));
  6295. var MutableToken = /** @class */ (function () {
  6296. function MutableToken() {
  6297. this._isCancelled = false;
  6298. this._emitter = null;
  6299. }
  6300. MutableToken.prototype.cancel = function () {
  6301. if (!this._isCancelled) {
  6302. this._isCancelled = true;
  6303. if (this._emitter) {
  6304. this._emitter.fire(undefined);
  6305. this.dispose();
  6306. }
  6307. }
  6308. };
  6309. Object.defineProperty(MutableToken.prototype, "isCancellationRequested", {
  6310. get: function () {
  6311. return this._isCancelled;
  6312. },
  6313. enumerable: true,
  6314. configurable: true
  6315. });
  6316. Object.defineProperty(MutableToken.prototype, "onCancellationRequested", {
  6317. get: function () {
  6318. if (this._isCancelled) {
  6319. return shortcutEvent;
  6320. }
  6321. if (!this._emitter) {
  6322. this._emitter = new event_1.Emitter();
  6323. }
  6324. return this._emitter.event;
  6325. },
  6326. enumerable: true,
  6327. configurable: true
  6328. });
  6329. MutableToken.prototype.dispose = function () {
  6330. if (this._emitter) {
  6331. this._emitter.dispose();
  6332. this._emitter = null;
  6333. }
  6334. };
  6335. return MutableToken;
  6336. }());
  6337. var CancellationTokenSource = /** @class */ (function () {
  6338. function CancellationTokenSource(parent) {
  6339. this._token = undefined;
  6340. this._parentListener = undefined;
  6341. this._parentListener = parent && parent.onCancellationRequested(this.cancel, this);
  6342. }
  6343. Object.defineProperty(CancellationTokenSource.prototype, "token", {
  6344. get: function () {
  6345. if (!this._token) {
  6346. // be lazy and create the token only when
  6347. // actually needed
  6348. this._token = new MutableToken();
  6349. }
  6350. return this._token;
  6351. },
  6352. enumerable: true,
  6353. configurable: true
  6354. });
  6355. CancellationTokenSource.prototype.cancel = function () {
  6356. if (!this._token) {
  6357. // save an object by returning the default
  6358. // cancelled token when cancellation happens
  6359. // before someone asks for the token
  6360. this._token = CancellationToken.Cancelled;
  6361. }
  6362. else if (this._token instanceof MutableToken) {
  6363. // actually cancel
  6364. this._token.cancel();
  6365. }
  6366. };
  6367. CancellationTokenSource.prototype.dispose = function (cancel) {
  6368. if (cancel === void 0) { cancel = false; }
  6369. if (cancel) {
  6370. this.cancel();
  6371. }
  6372. if (this._parentListener) {
  6373. this._parentListener.dispose();
  6374. }
  6375. if (!this._token) {
  6376. // ensure to initialize with an empty token if we had none
  6377. this._token = CancellationToken.None;
  6378. }
  6379. else if (this._token instanceof MutableToken) {
  6380. // actually dispose
  6381. this._token.dispose();
  6382. }
  6383. };
  6384. return CancellationTokenSource;
  6385. }());
  6386. exports.CancellationTokenSource = CancellationTokenSource;
  6387. });
  6388. /*---------------------------------------------------------------------------------------------
  6389. * Copyright (c) Microsoft Corporation. All rights reserved.
  6390. * Licensed under the MIT License. See License.txt in the project root for license information.
  6391. *--------------------------------------------------------------------------------------------*/
  6392. define(__m[15/*vs/base/common/async*/], __M([0/*require*/,1/*exports*/,26/*vs/base/common/cancellation*/,10/*vs/base/common/errors*/,2/*vs/base/common/lifecycle*/]), function (require, exports, cancellation_1, errors, lifecycle_1) {
  6393. "use strict";
  6394. Object.defineProperty(exports, "__esModule", { value: true });
  6395. function isThenable(obj) {
  6396. return obj && typeof obj.then === 'function';
  6397. }
  6398. exports.isThenable = isThenable;
  6399. function createCancelablePromise(callback) {
  6400. var source = new cancellation_1.CancellationTokenSource();
  6401. var thenable = callback(source.token);
  6402. var promise = new Promise(function (resolve, reject) {
  6403. source.token.onCancellationRequested(function () {
  6404. reject(errors.canceled());
  6405. });
  6406. Promise.resolve(thenable).then(function (value) {
  6407. source.dispose();
  6408. resolve(value);
  6409. }, function (err) {
  6410. source.dispose();
  6411. reject(err);
  6412. });
  6413. });
  6414. return new /** @class */ (function () {
  6415. function class_1() {
  6416. }
  6417. class_1.prototype.cancel = function () {
  6418. source.cancel();
  6419. };
  6420. class_1.prototype.then = function (resolve, reject) {
  6421. return promise.then(resolve, reject);
  6422. };
  6423. class_1.prototype.catch = function (reject) {
  6424. return this.then(undefined, reject);
  6425. };
  6426. class_1.prototype.finally = function (onfinally) {
  6427. return promise.finally(onfinally);
  6428. };
  6429. return class_1;
  6430. }());
  6431. }
  6432. exports.createCancelablePromise = createCancelablePromise;
  6433. function raceCancellation(promise, token, defaultValue) {
  6434. return Promise.race([promise, new Promise(function (resolve) { return token.onCancellationRequested(function () { return resolve(defaultValue); }); })]);
  6435. }
  6436. exports.raceCancellation = raceCancellation;
  6437. /**
  6438. * A helper to delay execution of a task that is being requested often.
  6439. *
  6440. * Following the throttler, now imagine the mail man wants to optimize the number of
  6441. * trips proactively. The trip itself can be long, so he decides not to make the trip
  6442. * as soon as a letter is submitted. Instead he waits a while, in case more
  6443. * letters are submitted. After said waiting period, if no letters were submitted, he
  6444. * decides to make the trip. Imagine that N more letters were submitted after the first
  6445. * one, all within a short period of time between each other. Even though N+1
  6446. * submissions occurred, only 1 delivery was made.
  6447. *
  6448. * The delayer offers this behavior via the trigger() method, into which both the task
  6449. * to be executed and the waiting period (delay) must be passed in as arguments. Following
  6450. * the example:
  6451. *
  6452. * const delayer = new Delayer(WAITING_PERIOD);
  6453. * const letters = [];
  6454. *
  6455. * function letterReceived(l) {
  6456. * letters.push(l);
  6457. * delayer.trigger(() => { return makeTheTrip(); });
  6458. * }
  6459. */
  6460. var Delayer = /** @class */ (function () {
  6461. function Delayer(defaultDelay) {
  6462. this.defaultDelay = defaultDelay;
  6463. this.timeout = null;
  6464. this.completionPromise = null;
  6465. this.doResolve = null;
  6466. this.doReject = null;
  6467. this.task = null;
  6468. }
  6469. Delayer.prototype.trigger = function (task, delay) {
  6470. var _this = this;
  6471. if (delay === void 0) { delay = this.defaultDelay; }
  6472. this.task = task;
  6473. this.cancelTimeout();
  6474. if (!this.completionPromise) {
  6475. this.completionPromise = new Promise(function (c, e) {
  6476. _this.doResolve = c;
  6477. _this.doReject = e;
  6478. }).then(function () {
  6479. _this.completionPromise = null;
  6480. _this.doResolve = null;
  6481. if (_this.task) {
  6482. var task_1 = _this.task;
  6483. _this.task = null;
  6484. return task_1();
  6485. }
  6486. return undefined;
  6487. });
  6488. }
  6489. this.timeout = setTimeout(function () {
  6490. _this.timeout = null;
  6491. if (_this.doResolve) {
  6492. _this.doResolve(null);
  6493. }
  6494. }, delay);
  6495. return this.completionPromise;
  6496. };
  6497. Delayer.prototype.isTriggered = function () {
  6498. return this.timeout !== null;
  6499. };
  6500. Delayer.prototype.cancel = function () {
  6501. this.cancelTimeout();
  6502. if (this.completionPromise) {
  6503. if (this.doReject) {
  6504. this.doReject(errors.canceled());
  6505. }
  6506. this.completionPromise = null;
  6507. }
  6508. };
  6509. Delayer.prototype.cancelTimeout = function () {
  6510. if (this.timeout !== null) {
  6511. clearTimeout(this.timeout);
  6512. this.timeout = null;
  6513. }
  6514. };
  6515. Delayer.prototype.dispose = function () {
  6516. this.cancelTimeout();
  6517. };
  6518. return Delayer;
  6519. }());
  6520. exports.Delayer = Delayer;
  6521. function timeout(millis, token) {
  6522. if (!token) {
  6523. return createCancelablePromise(function (token) { return timeout(millis, token); });
  6524. }
  6525. return new Promise(function (resolve, reject) {
  6526. var handle = setTimeout(resolve, millis);
  6527. token.onCancellationRequested(function () {
  6528. clearTimeout(handle);
  6529. reject(errors.canceled());
  6530. });
  6531. });
  6532. }
  6533. exports.timeout = timeout;
  6534. function disposableTimeout(handler, timeout) {
  6535. if (timeout === void 0) { timeout = 0; }
  6536. var timer = setTimeout(handler, timeout);
  6537. return lifecycle_1.toDisposable(function () { return clearTimeout(timer); });
  6538. }
  6539. exports.disposableTimeout = disposableTimeout;
  6540. function first(promiseFactories, shouldStop, defaultValue) {
  6541. if (shouldStop === void 0) { shouldStop = function (t) { return !!t; }; }
  6542. if (defaultValue === void 0) { defaultValue = null; }
  6543. var index = 0;
  6544. var len = promiseFactories.length;
  6545. var loop = function () {
  6546. if (index >= len) {
  6547. return Promise.resolve(defaultValue);
  6548. }
  6549. var factory = promiseFactories[index++];
  6550. var promise = Promise.resolve(factory());
  6551. return promise.then(function (result) {
  6552. if (shouldStop(result)) {
  6553. return Promise.resolve(result);
  6554. }
  6555. return loop();
  6556. });
  6557. };
  6558. return loop();
  6559. }
  6560. exports.first = first;
  6561. var TimeoutTimer = /** @class */ (function () {
  6562. function TimeoutTimer(runner, timeout) {
  6563. this._token = -1;
  6564. if (typeof runner === 'function' && typeof timeout === 'number') {
  6565. this.setIfNotSet(runner, timeout);
  6566. }
  6567. }
  6568. TimeoutTimer.prototype.dispose = function () {
  6569. this.cancel();
  6570. };
  6571. TimeoutTimer.prototype.cancel = function () {
  6572. if (this._token !== -1) {
  6573. clearTimeout(this._token);
  6574. this._token = -1;
  6575. }
  6576. };
  6577. TimeoutTimer.prototype.cancelAndSet = function (runner, timeout) {
  6578. var _this = this;
  6579. this.cancel();
  6580. this._token = setTimeout(function () {
  6581. _this._token = -1;
  6582. runner();
  6583. }, timeout);
  6584. };
  6585. TimeoutTimer.prototype.setIfNotSet = function (runner, timeout) {
  6586. var _this = this;
  6587. if (this._token !== -1) {
  6588. // timer is already set
  6589. return;
  6590. }
  6591. this._token = setTimeout(function () {
  6592. _this._token = -1;
  6593. runner();
  6594. }, timeout);
  6595. };
  6596. return TimeoutTimer;
  6597. }());
  6598. exports.TimeoutTimer = TimeoutTimer;
  6599. var IntervalTimer = /** @class */ (function () {
  6600. function IntervalTimer() {
  6601. this._token = -1;
  6602. }
  6603. IntervalTimer.prototype.dispose = function () {
  6604. this.cancel();
  6605. };
  6606. IntervalTimer.prototype.cancel = function () {
  6607. if (this._token !== -1) {
  6608. clearInterval(this._token);
  6609. this._token = -1;
  6610. }
  6611. };
  6612. IntervalTimer.prototype.cancelAndSet = function (runner, interval) {
  6613. this.cancel();
  6614. this._token = setInterval(function () {
  6615. runner();
  6616. }, interval);
  6617. };
  6618. return IntervalTimer;
  6619. }());
  6620. exports.IntervalTimer = IntervalTimer;
  6621. var RunOnceScheduler = /** @class */ (function () {
  6622. function RunOnceScheduler(runner, timeout) {
  6623. this.timeoutToken = -1;
  6624. this.runner = runner;
  6625. this.timeout = timeout;
  6626. this.timeoutHandler = this.onTimeout.bind(this);
  6627. }
  6628. /**
  6629. * Dispose RunOnceScheduler
  6630. */
  6631. RunOnceScheduler.prototype.dispose = function () {
  6632. this.cancel();
  6633. this.runner = null;
  6634. };
  6635. /**
  6636. * Cancel current scheduled runner (if any).
  6637. */
  6638. RunOnceScheduler.prototype.cancel = function () {
  6639. if (this.isScheduled()) {
  6640. clearTimeout(this.timeoutToken);
  6641. this.timeoutToken = -1;
  6642. }
  6643. };
  6644. /**
  6645. * Cancel previous runner (if any) & schedule a new runner.
  6646. */
  6647. RunOnceScheduler.prototype.schedule = function (delay) {
  6648. if (delay === void 0) { delay = this.timeout; }
  6649. this.cancel();
  6650. this.timeoutToken = setTimeout(this.timeoutHandler, delay);
  6651. };
  6652. /**
  6653. * Returns true if scheduled.
  6654. */
  6655. RunOnceScheduler.prototype.isScheduled = function () {
  6656. return this.timeoutToken !== -1;
  6657. };
  6658. RunOnceScheduler.prototype.onTimeout = function () {
  6659. this.timeoutToken = -1;
  6660. if (this.runner) {
  6661. this.doRun();
  6662. }
  6663. };
  6664. RunOnceScheduler.prototype.doRun = function () {
  6665. if (this.runner) {
  6666. this.runner();
  6667. }
  6668. };
  6669. return RunOnceScheduler;
  6670. }());
  6671. exports.RunOnceScheduler = RunOnceScheduler;
  6672. (function () {
  6673. if (typeof requestIdleCallback !== 'function' || typeof cancelIdleCallback !== 'function') {
  6674. var dummyIdle_1 = Object.freeze({
  6675. didTimeout: true,
  6676. timeRemaining: function () { return 15; }
  6677. });
  6678. exports.runWhenIdle = function (runner) {
  6679. var handle = setTimeout(function () { return runner(dummyIdle_1); });
  6680. var disposed = false;
  6681. return {
  6682. dispose: function () {
  6683. if (disposed) {
  6684. return;
  6685. }
  6686. disposed = true;
  6687. clearTimeout(handle);
  6688. }
  6689. };
  6690. };
  6691. }
  6692. else {
  6693. exports.runWhenIdle = function (runner, timeout) {
  6694. var handle = requestIdleCallback(runner, typeof timeout === 'number' ? { timeout: timeout } : undefined);
  6695. var disposed = false;
  6696. return {
  6697. dispose: function () {
  6698. if (disposed) {
  6699. return;
  6700. }
  6701. disposed = true;
  6702. cancelIdleCallback(handle);
  6703. }
  6704. };
  6705. };
  6706. }
  6707. })();
  6708. /**
  6709. * An implementation of the "idle-until-urgent"-strategy as introduced
  6710. * here: https://philipwalton.com/articles/idle-until-urgent/
  6711. */
  6712. var IdleValue = /** @class */ (function () {
  6713. function IdleValue(executor) {
  6714. var _this = this;
  6715. this._didRun = false;
  6716. this._executor = function () {
  6717. try {
  6718. _this._value = executor();
  6719. }
  6720. catch (err) {
  6721. _this._error = err;
  6722. }
  6723. finally {
  6724. _this._didRun = true;
  6725. }
  6726. };
  6727. this._handle = exports.runWhenIdle(function () { return _this._executor(); });
  6728. }
  6729. IdleValue.prototype.dispose = function () {
  6730. this._handle.dispose();
  6731. };
  6732. IdleValue.prototype.getValue = function () {
  6733. if (!this._didRun) {
  6734. this._handle.dispose();
  6735. this._executor();
  6736. }
  6737. if (this._error) {
  6738. throw this._error;
  6739. }
  6740. return this._value;
  6741. };
  6742. return IdleValue;
  6743. }());
  6744. exports.IdleValue = IdleValue;
  6745. });
  6746. /*---------------------------------------------------------------------------------------------
  6747. * Copyright (c) Microsoft Corporation. All rights reserved.
  6748. * Licensed under the MIT License. See License.txt in the project root for license information.
  6749. *--------------------------------------------------------------------------------------------*/
  6750. define(__m[244/*vs/base/browser/ui/scrollbar/scrollbarVisibilityController*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,2/*vs/base/common/lifecycle*/]), function (require, exports, async_1, lifecycle_1) {
  6751. "use strict";
  6752. Object.defineProperty(exports, "__esModule", { value: true });
  6753. var ScrollbarVisibilityController = /** @class */ (function (_super) {
  6754. __extends(ScrollbarVisibilityController, _super);
  6755. function ScrollbarVisibilityController(visibility, visibleClassName, invisibleClassName) {
  6756. var _this = _super.call(this) || this;
  6757. _this._visibility = visibility;
  6758. _this._visibleClassName = visibleClassName;
  6759. _this._invisibleClassName = invisibleClassName;
  6760. _this._domNode = null;
  6761. _this._isVisible = false;
  6762. _this._isNeeded = false;
  6763. _this._shouldBeVisible = false;
  6764. _this._revealTimer = _this._register(new async_1.TimeoutTimer());
  6765. return _this;
  6766. }
  6767. // ----------------- Hide / Reveal
  6768. ScrollbarVisibilityController.prototype.applyVisibilitySetting = function (shouldBeVisible) {
  6769. if (this._visibility === 2 /* Hidden */) {
  6770. return false;
  6771. }
  6772. if (this._visibility === 3 /* Visible */) {
  6773. return true;
  6774. }
  6775. return shouldBeVisible;
  6776. };
  6777. ScrollbarVisibilityController.prototype.setShouldBeVisible = function (rawShouldBeVisible) {
  6778. var shouldBeVisible = this.applyVisibilitySetting(rawShouldBeVisible);
  6779. if (this._shouldBeVisible !== shouldBeVisible) {
  6780. this._shouldBeVisible = shouldBeVisible;
  6781. this.ensureVisibility();
  6782. }
  6783. };
  6784. ScrollbarVisibilityController.prototype.setIsNeeded = function (isNeeded) {
  6785. if (this._isNeeded !== isNeeded) {
  6786. this._isNeeded = isNeeded;
  6787. this.ensureVisibility();
  6788. }
  6789. };
  6790. ScrollbarVisibilityController.prototype.setDomNode = function (domNode) {
  6791. this._domNode = domNode;
  6792. this._domNode.setClassName(this._invisibleClassName);
  6793. // Now that the flags & the dom node are in a consistent state, ensure the Hidden/Visible configuration
  6794. this.setShouldBeVisible(false);
  6795. };
  6796. ScrollbarVisibilityController.prototype.ensureVisibility = function () {
  6797. if (!this._isNeeded) {
  6798. // Nothing to be rendered
  6799. this._hide(false);
  6800. return;
  6801. }
  6802. if (this._shouldBeVisible) {
  6803. this._reveal();
  6804. }
  6805. else {
  6806. this._hide(true);
  6807. }
  6808. };
  6809. ScrollbarVisibilityController.prototype._reveal = function () {
  6810. var _this = this;
  6811. if (this._isVisible) {
  6812. return;
  6813. }
  6814. this._isVisible = true;
  6815. // The CSS animation doesn't play otherwise
  6816. this._revealTimer.setIfNotSet(function () {
  6817. if (_this._domNode) {
  6818. _this._domNode.setClassName(_this._visibleClassName);
  6819. }
  6820. }, 0);
  6821. };
  6822. ScrollbarVisibilityController.prototype._hide = function (withFadeAway) {
  6823. this._revealTimer.cancel();
  6824. if (!this._isVisible) {
  6825. return;
  6826. }
  6827. this._isVisible = false;
  6828. if (this._domNode) {
  6829. this._domNode.setClassName(this._invisibleClassName + (withFadeAway ? ' fade' : ''));
  6830. }
  6831. };
  6832. return ScrollbarVisibilityController;
  6833. }(lifecycle_1.Disposable));
  6834. exports.ScrollbarVisibilityController = ScrollbarVisibilityController;
  6835. });
  6836. /*---------------------------------------------------------------------------------------------
  6837. * Copyright (c) Microsoft Corporation. All rights reserved.
  6838. * Licensed under the MIT License. See License.txt in the project root for license information.
  6839. *--------------------------------------------------------------------------------------------*/
  6840. define(__m[38/*vs/base/common/map*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  6841. "use strict";
  6842. Object.defineProperty(exports, "__esModule", { value: true });
  6843. function values(forEachable) {
  6844. var result = [];
  6845. forEachable.forEach(function (value) { return result.push(value); });
  6846. return result;
  6847. }
  6848. exports.values = values;
  6849. function keys(map) {
  6850. var result = [];
  6851. map.forEach(function (_value, key) { return result.push(key); });
  6852. return result;
  6853. }
  6854. exports.keys = keys;
  6855. var StringIterator = /** @class */ (function () {
  6856. function StringIterator() {
  6857. this._value = '';
  6858. this._pos = 0;
  6859. }
  6860. StringIterator.prototype.reset = function (key) {
  6861. this._value = key;
  6862. this._pos = 0;
  6863. return this;
  6864. };
  6865. StringIterator.prototype.next = function () {
  6866. this._pos += 1;
  6867. return this;
  6868. };
  6869. StringIterator.prototype.hasNext = function () {
  6870. return this._pos < this._value.length - 1;
  6871. };
  6872. StringIterator.prototype.cmp = function (a) {
  6873. var aCode = a.charCodeAt(0);
  6874. var thisCode = this._value.charCodeAt(this._pos);
  6875. return aCode - thisCode;
  6876. };
  6877. StringIterator.prototype.value = function () {
  6878. return this._value[this._pos];
  6879. };
  6880. return StringIterator;
  6881. }());
  6882. exports.StringIterator = StringIterator;
  6883. var PathIterator = /** @class */ (function () {
  6884. function PathIterator(_splitOnBackslash) {
  6885. if (_splitOnBackslash === void 0) { _splitOnBackslash = true; }
  6886. this._splitOnBackslash = _splitOnBackslash;
  6887. }
  6888. PathIterator.prototype.reset = function (key) {
  6889. this._value = key.replace(/\\$|\/$/, '');
  6890. this._from = 0;
  6891. this._to = 0;
  6892. return this.next();
  6893. };
  6894. PathIterator.prototype.hasNext = function () {
  6895. return this._to < this._value.length;
  6896. };
  6897. PathIterator.prototype.next = function () {
  6898. // this._data = key.split(/[\\/]/).filter(s => !!s);
  6899. this._from = this._to;
  6900. var justSeps = true;
  6901. for (; this._to < this._value.length; this._to++) {
  6902. var ch = this._value.charCodeAt(this._to);
  6903. if (ch === 47 /* Slash */ || this._splitOnBackslash && ch === 92 /* Backslash */) {
  6904. if (justSeps) {
  6905. this._from++;
  6906. }
  6907. else {
  6908. break;
  6909. }
  6910. }
  6911. else {
  6912. justSeps = false;
  6913. }
  6914. }
  6915. return this;
  6916. };
  6917. PathIterator.prototype.cmp = function (a) {
  6918. var aPos = 0;
  6919. var aLen = a.length;
  6920. var thisPos = this._from;
  6921. while (aPos < aLen && thisPos < this._to) {
  6922. var cmp = a.charCodeAt(aPos) - this._value.charCodeAt(thisPos);
  6923. if (cmp !== 0) {
  6924. return cmp;
  6925. }
  6926. aPos += 1;
  6927. thisPos += 1;
  6928. }
  6929. if (aLen === this._to - this._from) {
  6930. return 0;
  6931. }
  6932. else if (aPos < aLen) {
  6933. return -1;
  6934. }
  6935. else {
  6936. return 1;
  6937. }
  6938. };
  6939. PathIterator.prototype.value = function () {
  6940. return this._value.substring(this._from, this._to);
  6941. };
  6942. return PathIterator;
  6943. }());
  6944. exports.PathIterator = PathIterator;
  6945. var TernarySearchTreeNode = /** @class */ (function () {
  6946. function TernarySearchTreeNode() {
  6947. }
  6948. return TernarySearchTreeNode;
  6949. }());
  6950. var TernarySearchTree = /** @class */ (function () {
  6951. function TernarySearchTree(segments) {
  6952. this._iter = segments;
  6953. }
  6954. TernarySearchTree.forPaths = function () {
  6955. return new TernarySearchTree(new PathIterator());
  6956. };
  6957. TernarySearchTree.forStrings = function () {
  6958. return new TernarySearchTree(new StringIterator());
  6959. };
  6960. TernarySearchTree.prototype.clear = function () {
  6961. this._root = undefined;
  6962. };
  6963. TernarySearchTree.prototype.set = function (key, element) {
  6964. var iter = this._iter.reset(key);
  6965. var node;
  6966. if (!this._root) {
  6967. this._root = new TernarySearchTreeNode();
  6968. this._root.segment = iter.value();
  6969. }
  6970. node = this._root;
  6971. while (true) {
  6972. var val = iter.cmp(node.segment);
  6973. if (val > 0) {
  6974. // left
  6975. if (!node.left) {
  6976. node.left = new TernarySearchTreeNode();
  6977. node.left.segment = iter.value();
  6978. }
  6979. node = node.left;
  6980. }
  6981. else if (val < 0) {
  6982. // right
  6983. if (!node.right) {
  6984. node.right = new TernarySearchTreeNode();
  6985. node.right.segment = iter.value();
  6986. }
  6987. node = node.right;
  6988. }
  6989. else if (iter.hasNext()) {
  6990. // mid
  6991. iter.next();
  6992. if (!node.mid) {
  6993. node.mid = new TernarySearchTreeNode();
  6994. node.mid.segment = iter.value();
  6995. }
  6996. node = node.mid;
  6997. }
  6998. else {
  6999. break;
  7000. }
  7001. }
  7002. var oldElement = node.value;
  7003. node.value = element;
  7004. node.key = key;
  7005. return oldElement;
  7006. };
  7007. TernarySearchTree.prototype.get = function (key) {
  7008. var iter = this._iter.reset(key);
  7009. var node = this._root;
  7010. while (node) {
  7011. var val = iter.cmp(node.segment);
  7012. if (val > 0) {
  7013. // left
  7014. node = node.left;
  7015. }
  7016. else if (val < 0) {
  7017. // right
  7018. node = node.right;
  7019. }
  7020. else if (iter.hasNext()) {
  7021. // mid
  7022. iter.next();
  7023. node = node.mid;
  7024. }
  7025. else {
  7026. break;
  7027. }
  7028. }
  7029. return node ? node.value : undefined;
  7030. };
  7031. TernarySearchTree.prototype.findSubstr = function (key) {
  7032. var iter = this._iter.reset(key);
  7033. var node = this._root;
  7034. var candidate = undefined;
  7035. while (node) {
  7036. var val = iter.cmp(node.segment);
  7037. if (val > 0) {
  7038. // left
  7039. node = node.left;
  7040. }
  7041. else if (val < 0) {
  7042. // right
  7043. node = node.right;
  7044. }
  7045. else if (iter.hasNext()) {
  7046. // mid
  7047. iter.next();
  7048. candidate = node.value || candidate;
  7049. node = node.mid;
  7050. }
  7051. else {
  7052. break;
  7053. }
  7054. }
  7055. return node && node.value || candidate;
  7056. };
  7057. TernarySearchTree.prototype.forEach = function (callback) {
  7058. this._forEach(this._root, callback);
  7059. };
  7060. TernarySearchTree.prototype._forEach = function (node, callback) {
  7061. if (node) {
  7062. // left
  7063. this._forEach(node.left, callback);
  7064. // node
  7065. if (node.value) {
  7066. // callback(node.value, this._iter.join(parts));
  7067. callback(node.value, node.key);
  7068. }
  7069. // mid
  7070. this._forEach(node.mid, callback);
  7071. // right
  7072. this._forEach(node.right, callback);
  7073. }
  7074. };
  7075. return TernarySearchTree;
  7076. }());
  7077. exports.TernarySearchTree = TernarySearchTree;
  7078. var ResourceMap = /** @class */ (function () {
  7079. function ResourceMap() {
  7080. this.map = new Map();
  7081. this.ignoreCase = false; // in the future this should be an uri-comparator
  7082. }
  7083. ResourceMap.prototype.set = function (resource, value) {
  7084. this.map.set(this.toKey(resource), value);
  7085. };
  7086. ResourceMap.prototype.get = function (resource) {
  7087. return this.map.get(this.toKey(resource));
  7088. };
  7089. ResourceMap.prototype.toKey = function (resource) {
  7090. var key = resource.toString();
  7091. if (this.ignoreCase) {
  7092. key = key.toLowerCase();
  7093. }
  7094. return key;
  7095. };
  7096. return ResourceMap;
  7097. }());
  7098. exports.ResourceMap = ResourceMap;
  7099. var LinkedMap = /** @class */ (function () {
  7100. function LinkedMap() {
  7101. this._map = new Map();
  7102. this._head = undefined;
  7103. this._tail = undefined;
  7104. this._size = 0;
  7105. }
  7106. LinkedMap.prototype.clear = function () {
  7107. this._map.clear();
  7108. this._head = undefined;
  7109. this._tail = undefined;
  7110. this._size = 0;
  7111. };
  7112. Object.defineProperty(LinkedMap.prototype, "size", {
  7113. get: function () {
  7114. return this._size;
  7115. },
  7116. enumerable: true,
  7117. configurable: true
  7118. });
  7119. LinkedMap.prototype.get = function (key, touch) {
  7120. if (touch === void 0) { touch = 0 /* None */; }
  7121. var item = this._map.get(key);
  7122. if (!item) {
  7123. return undefined;
  7124. }
  7125. if (touch !== 0 /* None */) {
  7126. this.touch(item, touch);
  7127. }
  7128. return item.value;
  7129. };
  7130. LinkedMap.prototype.set = function (key, value, touch) {
  7131. if (touch === void 0) { touch = 0 /* None */; }
  7132. var item = this._map.get(key);
  7133. if (item) {
  7134. item.value = value;
  7135. if (touch !== 0 /* None */) {
  7136. this.touch(item, touch);
  7137. }
  7138. }
  7139. else {
  7140. item = { key: key, value: value, next: undefined, previous: undefined };
  7141. switch (touch) {
  7142. case 0 /* None */:
  7143. this.addItemLast(item);
  7144. break;
  7145. case 1 /* AsOld */:
  7146. this.addItemFirst(item);
  7147. break;
  7148. case 2 /* AsNew */:
  7149. this.addItemLast(item);
  7150. break;
  7151. default:
  7152. this.addItemLast(item);
  7153. break;
  7154. }
  7155. this._map.set(key, item);
  7156. this._size++;
  7157. }
  7158. };
  7159. LinkedMap.prototype.delete = function (key) {
  7160. return !!this.remove(key);
  7161. };
  7162. LinkedMap.prototype.remove = function (key) {
  7163. var item = this._map.get(key);
  7164. if (!item) {
  7165. return undefined;
  7166. }
  7167. this._map.delete(key);
  7168. this.removeItem(item);
  7169. this._size--;
  7170. return item.value;
  7171. };
  7172. LinkedMap.prototype.forEach = function (callbackfn, thisArg) {
  7173. var current = this._head;
  7174. while (current) {
  7175. if (thisArg) {
  7176. callbackfn.bind(thisArg)(current.value, current.key, this);
  7177. }
  7178. else {
  7179. callbackfn(current.value, current.key, this);
  7180. }
  7181. current = current.next;
  7182. }
  7183. };
  7184. /* VS Code / Monaco editor runs on es5 which has no Symbol.iterator
  7185. keys(): IterableIterator<K> {
  7186. const current = this._head;
  7187. const iterator: IterableIterator<K> = {
  7188. [Symbol.iterator]() {
  7189. return iterator;
  7190. },
  7191. next():IteratorResult<K> {
  7192. if (current) {
  7193. const result = { value: current.key, done: false };
  7194. current = current.next;
  7195. return result;
  7196. } else {
  7197. return { value: undefined, done: true };
  7198. }
  7199. }
  7200. };
  7201. return iterator;
  7202. }
  7203. values(): IterableIterator<V> {
  7204. const current = this._head;
  7205. const iterator: IterableIterator<V> = {
  7206. [Symbol.iterator]() {
  7207. return iterator;
  7208. },
  7209. next():IteratorResult<V> {
  7210. if (current) {
  7211. const result = { value: current.value, done: false };
  7212. current = current.next;
  7213. return result;
  7214. } else {
  7215. return { value: undefined, done: true };
  7216. }
  7217. }
  7218. };
  7219. return iterator;
  7220. }
  7221. */
  7222. LinkedMap.prototype.trimOld = function (newSize) {
  7223. if (newSize >= this.size) {
  7224. return;
  7225. }
  7226. if (newSize === 0) {
  7227. this.clear();
  7228. return;
  7229. }
  7230. var current = this._head;
  7231. var currentSize = this.size;
  7232. while (current && currentSize > newSize) {
  7233. this._map.delete(current.key);
  7234. current = current.next;
  7235. currentSize--;
  7236. }
  7237. this._head = current;
  7238. this._size = currentSize;
  7239. if (current) {
  7240. current.previous = undefined;
  7241. }
  7242. };
  7243. LinkedMap.prototype.addItemFirst = function (item) {
  7244. // First time Insert
  7245. if (!this._head && !this._tail) {
  7246. this._tail = item;
  7247. }
  7248. else if (!this._head) {
  7249. throw new Error('Invalid list');
  7250. }
  7251. else {
  7252. item.next = this._head;
  7253. this._head.previous = item;
  7254. }
  7255. this._head = item;
  7256. };
  7257. LinkedMap.prototype.addItemLast = function (item) {
  7258. // First time Insert
  7259. if (!this._head && !this._tail) {
  7260. this._head = item;
  7261. }
  7262. else if (!this._tail) {
  7263. throw new Error('Invalid list');
  7264. }
  7265. else {
  7266. item.previous = this._tail;
  7267. this._tail.next = item;
  7268. }
  7269. this._tail = item;
  7270. };
  7271. LinkedMap.prototype.removeItem = function (item) {
  7272. if (item === this._head && item === this._tail) {
  7273. this._head = undefined;
  7274. this._tail = undefined;
  7275. }
  7276. else if (item === this._head) {
  7277. // This can only happend if size === 1 which is handle
  7278. // by the case above.
  7279. if (!item.next) {
  7280. throw new Error('Invalid list');
  7281. }
  7282. item.next.previous = undefined;
  7283. this._head = item.next;
  7284. }
  7285. else if (item === this._tail) {
  7286. // This can only happend if size === 1 which is handle
  7287. // by the case above.
  7288. if (!item.previous) {
  7289. throw new Error('Invalid list');
  7290. }
  7291. item.previous.next = undefined;
  7292. this._tail = item.previous;
  7293. }
  7294. else {
  7295. var next = item.next;
  7296. var previous = item.previous;
  7297. if (!next || !previous) {
  7298. throw new Error('Invalid list');
  7299. }
  7300. next.previous = previous;
  7301. previous.next = next;
  7302. }
  7303. item.next = undefined;
  7304. item.previous = undefined;
  7305. };
  7306. LinkedMap.prototype.touch = function (item, touch) {
  7307. if (!this._head || !this._tail) {
  7308. throw new Error('Invalid list');
  7309. }
  7310. if ((touch !== 1 /* AsOld */ && touch !== 2 /* AsNew */)) {
  7311. return;
  7312. }
  7313. if (touch === 1 /* AsOld */) {
  7314. if (item === this._head) {
  7315. return;
  7316. }
  7317. var next = item.next;
  7318. var previous = item.previous;
  7319. // Unlink the item
  7320. if (item === this._tail) {
  7321. // previous must be defined since item was not head but is tail
  7322. // So there are more than on item in the map
  7323. previous.next = undefined;
  7324. this._tail = previous;
  7325. }
  7326. else {
  7327. // Both next and previous are not undefined since item was neither head nor tail.
  7328. next.previous = previous;
  7329. previous.next = next;
  7330. }
  7331. // Insert the node at head
  7332. item.previous = undefined;
  7333. item.next = this._head;
  7334. this._head.previous = item;
  7335. this._head = item;
  7336. }
  7337. else if (touch === 2 /* AsNew */) {
  7338. if (item === this._tail) {
  7339. return;
  7340. }
  7341. var next = item.next;
  7342. var previous = item.previous;
  7343. // Unlink the item.
  7344. if (item === this._head) {
  7345. // next must be defined since item was not tail but is head
  7346. // So there are more than on item in the map
  7347. next.previous = undefined;
  7348. this._head = next;
  7349. }
  7350. else {
  7351. // Both next and previous are not undefined since item was neither head nor tail.
  7352. next.previous = previous;
  7353. previous.next = next;
  7354. }
  7355. item.next = undefined;
  7356. item.previous = this._tail;
  7357. this._tail.next = item;
  7358. this._tail = item;
  7359. }
  7360. };
  7361. LinkedMap.prototype.toJSON = function () {
  7362. var data = [];
  7363. this.forEach(function (value, key) {
  7364. data.push([key, value]);
  7365. });
  7366. return data;
  7367. };
  7368. return LinkedMap;
  7369. }());
  7370. exports.LinkedMap = LinkedMap;
  7371. var LRUCache = /** @class */ (function (_super) {
  7372. __extends(LRUCache, _super);
  7373. function LRUCache(limit, ratio) {
  7374. if (ratio === void 0) { ratio = 1; }
  7375. var _this = _super.call(this) || this;
  7376. _this._limit = limit;
  7377. _this._ratio = Math.min(Math.max(0, ratio), 1);
  7378. return _this;
  7379. }
  7380. LRUCache.prototype.get = function (key) {
  7381. return _super.prototype.get.call(this, key, 2 /* AsNew */);
  7382. };
  7383. LRUCache.prototype.peek = function (key) {
  7384. return _super.prototype.get.call(this, key, 0 /* None */);
  7385. };
  7386. LRUCache.prototype.set = function (key, value) {
  7387. _super.prototype.set.call(this, key, value, 2 /* AsNew */);
  7388. this.checkTrim();
  7389. };
  7390. LRUCache.prototype.checkTrim = function () {
  7391. if (this.size > this._limit) {
  7392. this.trimOld(Math.round(this._limit * this._ratio));
  7393. }
  7394. };
  7395. return LRUCache;
  7396. }(LinkedMap));
  7397. exports.LRUCache = LRUCache;
  7398. });
  7399. /**
  7400. * marked - a markdown parser
  7401. * Copyright (c) 2011-2014, Christopher Jeffrey. (MIT Licensed)
  7402. * https://github.com/markedjs/marked
  7403. */
  7404. // BEGIN MONACOCHANGE
  7405. var __marked_exports;
  7406. // END MONACOCHANGE
  7407. ;(function(root) {
  7408. 'use strict';
  7409. /**
  7410. * Block-Level Grammar
  7411. */
  7412. var block = {
  7413. newline: /^\n+/,
  7414. code: /^( {4}[^\n]+\n*)+/,
  7415. fences: noop,
  7416. hr: /^ {0,3}((?:- *){3,}|(?:_ *){3,}|(?:\* *){3,})(?:\n+|$)/,
  7417. heading: /^ *(#{1,6}) *([^\n]+?) *(?:#+ *)?(?:\n+|$)/,
  7418. nptable: noop,
  7419. blockquote: /^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/,
  7420. list: /^( {0,3})(bull) [\s\S]+?(?:hr|def|\n{2,}(?! )(?!\1bull )\n*|\s*$)/,
  7421. html: '^ {0,3}(?:' // optional indentation
  7422. + '<(script|pre|style)[\\s>][\\s\\S]*?(?:</\\1>[^\\n]*\\n+|$)' // (1)
  7423. + '|comment[^\\n]*(\\n+|$)' // (2)
  7424. + '|<\\?[\\s\\S]*?\\?>\\n*' // (3)
  7425. + '|<![A-Z][\\s\\S]*?>\\n*' // (4)
  7426. + '|<!\\[CDATA\\[[\\s\\S]*?\\]\\]>\\n*' // (5)
  7427. + '|</?(tag)(?: +|\\n|/?>)[\\s\\S]*?(?:\\n{2,}|$)' // (6)
  7428. + '|<(?!script|pre|style)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) open tag
  7429. + '|</(?!script|pre|style)[a-z][\\w-]*\\s*>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:\\n{2,}|$)' // (7) closing tag
  7430. + ')',
  7431. def: /^ {0,3}\[(label)\]: *\n? *<?([^\s>]+)>?(?:(?: +\n? *| *\n *)(title))? *(?:\n+|$)/,
  7432. table: noop,
  7433. lheading: /^([^\n]+)\n *(=|-){2,} *(?:\n+|$)/,
  7434. paragraph: /^([^\n]+(?:\n(?!hr|heading|lheading| {0,3}>|<\/?(?:tag)(?: +|\n|\/?>)|<(?:script|pre|style|!--))[^\n]+)*)/,
  7435. text: /^[^\n]+/
  7436. };
  7437. block._label = /(?!\s*\])(?:\\[\[\]]|[^\[\]])+/;
  7438. block._title = /(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/;
  7439. block.def = edit(block.def)
  7440. .replace('label', block._label)
  7441. .replace('title', block._title)
  7442. .getRegex();
  7443. block.bullet = /(?:[*+-]|\d{1,9}\.)/;
  7444. block.item = /^( *)(bull) ?[^\n]*(?:\n(?!\1bull ?)[^\n]*)*/;
  7445. block.item = edit(block.item, 'gm')
  7446. .replace(/bull/g, block.bullet)
  7447. .getRegex();
  7448. block.list = edit(block.list)
  7449. .replace(/bull/g, block.bullet)
  7450. .replace('hr', '\\n+(?=\\1?(?:(?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$))')
  7451. .replace('def', '\\n+(?=' + block.def.source + ')')
  7452. .getRegex();
  7453. block._tag = 'address|article|aside|base|basefont|blockquote|body|caption'
  7454. + '|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption'
  7455. + '|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe'
  7456. + '|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option'
  7457. + '|p|param|section|source|summary|table|tbody|td|tfoot|th|thead|title|tr'
  7458. + '|track|ul';
  7459. block._comment = /<!--(?!-?>)[\s\S]*?-->/;
  7460. block.html = edit(block.html, 'i')
  7461. .replace('comment', block._comment)
  7462. .replace('tag', block._tag)
  7463. .replace('attribute', / +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/)
  7464. .getRegex();
  7465. block.paragraph = edit(block.paragraph)
  7466. .replace('hr', block.hr)
  7467. .replace('heading', block.heading)
  7468. .replace('lheading', block.lheading)
  7469. .replace('tag', block._tag) // pars can be interrupted by type (6) html blocks
  7470. .getRegex();
  7471. block.blockquote = edit(block.blockquote)
  7472. .replace('paragraph', block.paragraph)
  7473. .getRegex();
  7474. /**
  7475. * Normal Block Grammar
  7476. */
  7477. block.normal = merge({}, block);
  7478. /**
  7479. * GFM Block Grammar
  7480. */
  7481. block.gfm = merge({}, block.normal, {
  7482. fences: /^ {0,3}(`{3,}|~{3,})([^`\n]*)\n(?:|([\s\S]*?)\n)(?: {0,3}\1[~`]* *(?:\n+|$)|$)/,
  7483. paragraph: /^/,
  7484. heading: /^ *(#{1,6}) +([^\n]+?) *#* *(?:\n+|$)/
  7485. });
  7486. block.gfm.paragraph = edit(block.paragraph)
  7487. .replace('(?!', '(?!'
  7488. + block.gfm.fences.source.replace('\\1', '\\2') + '|'
  7489. + block.list.source.replace('\\1', '\\3') + '|')
  7490. .getRegex();
  7491. /**
  7492. * GFM + Tables Block Grammar
  7493. */
  7494. block.tables = merge({}, block.gfm, {
  7495. nptable: /^ *([^|\n ].*\|.*)\n *([-:]+ *\|[-| :]*)(?:\n((?:.*[^>\n ].*(?:\n|$))*)\n*|$)/,
  7496. table: /^ *\|(.+)\n *\|?( *[-:]+[-| :]*)(?:\n((?: *[^>\n ].*(?:\n|$))*)\n*|$)/
  7497. });
  7498. /**
  7499. * Pedantic grammar
  7500. */
  7501. block.pedantic = merge({}, block.normal, {
  7502. html: edit(
  7503. '^ *(?:comment *(?:\\n|\\s*$)'
  7504. + '|<(tag)[\\s\\S]+?</\\1> *(?:\\n{2,}|\\s*$)' // closed tag
  7505. + '|<tag(?:"[^"]*"|\'[^\']*\'|\\s[^\'"/>\\s]*)*?/?> *(?:\\n{2,}|\\s*$))')
  7506. .replace('comment', block._comment)
  7507. .replace(/tag/g, '(?!(?:'
  7508. + 'a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub'
  7509. + '|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)'
  7510. + '\\b)\\w+(?!:|[^\\w\\s@]*@)\\b')
  7511. .getRegex(),
  7512. def: /^ *\[([^\]]+)\]: *<?([^\s>]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/
  7513. });
  7514. /**
  7515. * Block Lexer
  7516. */
  7517. function Lexer(options) {
  7518. this.tokens = [];
  7519. this.tokens.links = Object.create(null);
  7520. this.options = options || marked.defaults;
  7521. this.rules = block.normal;
  7522. if (this.options.pedantic) {
  7523. this.rules = block.pedantic;
  7524. } else if (this.options.gfm) {
  7525. if (this.options.tables) {
  7526. this.rules = block.tables;
  7527. } else {
  7528. this.rules = block.gfm;
  7529. }
  7530. }
  7531. }
  7532. /**
  7533. * Expose Block Rules
  7534. */
  7535. Lexer.rules = block;
  7536. /**
  7537. * Static Lex Method
  7538. */
  7539. Lexer.lex = function(src, options) {
  7540. var lexer = new Lexer(options);
  7541. return lexer.lex(src);
  7542. };
  7543. /**
  7544. * Preprocessing
  7545. */
  7546. Lexer.prototype.lex = function(src) {
  7547. src = src
  7548. .replace(/\r\n|\r/g, '\n')
  7549. .replace(/\t/g, ' ')
  7550. .replace(/\u00a0/g, ' ')
  7551. .replace(/\u2424/g, '\n');
  7552. return this.token(src, true);
  7553. };
  7554. /**
  7555. * Lexing
  7556. */
  7557. Lexer.prototype.token = function(src, top) {
  7558. src = src.replace(/^ +$/gm, '');
  7559. var next,
  7560. loose,
  7561. cap,
  7562. bull,
  7563. b,
  7564. item,
  7565. listStart,
  7566. listItems,
  7567. t,
  7568. space,
  7569. i,
  7570. tag,
  7571. l,
  7572. isordered,
  7573. istask,
  7574. ischecked;
  7575. while (src) {
  7576. // newline
  7577. if (cap = this.rules.newline.exec(src)) {
  7578. src = src.substring(cap[0].length);
  7579. if (cap[0].length > 1) {
  7580. this.tokens.push({
  7581. type: 'space'
  7582. });
  7583. }
  7584. }
  7585. // code
  7586. if (cap = this.rules.code.exec(src)) {
  7587. src = src.substring(cap[0].length);
  7588. cap = cap[0].replace(/^ {4}/gm, '');
  7589. this.tokens.push({
  7590. type: 'code',
  7591. text: !this.options.pedantic
  7592. ? rtrim(cap, '\n')
  7593. : cap
  7594. });
  7595. continue;
  7596. }
  7597. // fences (gfm)
  7598. if (cap = this.rules.fences.exec(src)) {
  7599. src = src.substring(cap[0].length);
  7600. this.tokens.push({
  7601. type: 'code',
  7602. lang: cap[2] ? cap[2].trim() : cap[2],
  7603. text: cap[3] || ''
  7604. });
  7605. continue;
  7606. }
  7607. // heading
  7608. if (cap = this.rules.heading.exec(src)) {
  7609. src = src.substring(cap[0].length);
  7610. this.tokens.push({
  7611. type: 'heading',
  7612. depth: cap[1].length,
  7613. text: cap[2]
  7614. });
  7615. continue;
  7616. }
  7617. // table no leading pipe (gfm)
  7618. if (cap = this.rules.nptable.exec(src)) {
  7619. item = {
  7620. type: 'table',
  7621. header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
  7622. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  7623. cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
  7624. };
  7625. if (item.header.length === item.align.length) {
  7626. src = src.substring(cap[0].length);
  7627. for (i = 0; i < item.align.length; i++) {
  7628. if (/^ *-+: *$/.test(item.align[i])) {
  7629. item.align[i] = 'right';
  7630. } else if (/^ *:-+: *$/.test(item.align[i])) {
  7631. item.align[i] = 'center';
  7632. } else if (/^ *:-+ *$/.test(item.align[i])) {
  7633. item.align[i] = 'left';
  7634. } else {
  7635. item.align[i] = null;
  7636. }
  7637. }
  7638. for (i = 0; i < item.cells.length; i++) {
  7639. item.cells[i] = splitCells(item.cells[i], item.header.length);
  7640. }
  7641. this.tokens.push(item);
  7642. continue;
  7643. }
  7644. }
  7645. // hr
  7646. if (cap = this.rules.hr.exec(src)) {
  7647. src = src.substring(cap[0].length);
  7648. this.tokens.push({
  7649. type: 'hr'
  7650. });
  7651. continue;
  7652. }
  7653. // blockquote
  7654. if (cap = this.rules.blockquote.exec(src)) {
  7655. src = src.substring(cap[0].length);
  7656. this.tokens.push({
  7657. type: 'blockquote_start'
  7658. });
  7659. cap = cap[0].replace(/^ *> ?/gm, '');
  7660. // Pass `top` to keep the current
  7661. // "toplevel" state. This is exactly
  7662. // how markdown.pl works.
  7663. this.token(cap, top);
  7664. this.tokens.push({
  7665. type: 'blockquote_end'
  7666. });
  7667. continue;
  7668. }
  7669. // list
  7670. if (cap = this.rules.list.exec(src)) {
  7671. src = src.substring(cap[0].length);
  7672. bull = cap[2];
  7673. isordered = bull.length > 1;
  7674. listStart = {
  7675. type: 'list_start',
  7676. ordered: isordered,
  7677. start: isordered ? +bull : '',
  7678. loose: false
  7679. };
  7680. this.tokens.push(listStart);
  7681. // Get each top-level item.
  7682. cap = cap[0].match(this.rules.item);
  7683. listItems = [];
  7684. next = false;
  7685. l = cap.length;
  7686. i = 0;
  7687. for (; i < l; i++) {
  7688. item = cap[i];
  7689. // Remove the list item's bullet
  7690. // so it is seen as the next token.
  7691. space = item.length;
  7692. item = item.replace(/^ *([*+-]|\d+\.) */, '');
  7693. // Outdent whatever the
  7694. // list item contains. Hacky.
  7695. if (~item.indexOf('\n ')) {
  7696. space -= item.length;
  7697. item = !this.options.pedantic
  7698. ? item.replace(new RegExp('^ {1,' + space + '}', 'gm'), '')
  7699. : item.replace(/^ {1,4}/gm, '');
  7700. }
  7701. // Determine whether the next list item belongs here.
  7702. // Backpedal if it does not belong in this list.
  7703. if (i !== l - 1) {
  7704. b = block.bullet.exec(cap[i + 1])[0];
  7705. if (bull.length > 1 ? b.length === 1
  7706. : (b.length > 1 || (this.options.smartLists && b !== bull))) {
  7707. src = cap.slice(i + 1).join('\n') + src;
  7708. i = l - 1;
  7709. }
  7710. }
  7711. // Determine whether item is loose or not.
  7712. // Use: /(^|\n)(?! )[^\n]+\n\n(?!\s*$)/
  7713. // for discount behavior.
  7714. loose = next || /\n\n(?!\s*$)/.test(item);
  7715. if (i !== l - 1) {
  7716. next = item.charAt(item.length - 1) === '\n';
  7717. if (!loose) loose = next;
  7718. }
  7719. if (loose) {
  7720. listStart.loose = true;
  7721. }
  7722. // Check for task list items
  7723. istask = /^\[[ xX]\] /.test(item);
  7724. ischecked = undefined;
  7725. if (istask) {
  7726. ischecked = item[1] !== ' ';
  7727. item = item.replace(/^\[[ xX]\] +/, '');
  7728. }
  7729. t = {
  7730. type: 'list_item_start',
  7731. task: istask,
  7732. checked: ischecked,
  7733. loose: loose
  7734. };
  7735. listItems.push(t);
  7736. this.tokens.push(t);
  7737. // Recurse.
  7738. this.token(item, false);
  7739. this.tokens.push({
  7740. type: 'list_item_end'
  7741. });
  7742. }
  7743. if (listStart.loose) {
  7744. l = listItems.length;
  7745. i = 0;
  7746. for (; i < l; i++) {
  7747. listItems[i].loose = true;
  7748. }
  7749. }
  7750. this.tokens.push({
  7751. type: 'list_end'
  7752. });
  7753. continue;
  7754. }
  7755. // html
  7756. if (cap = this.rules.html.exec(src)) {
  7757. src = src.substring(cap[0].length);
  7758. this.tokens.push({
  7759. type: this.options.sanitize
  7760. ? 'paragraph'
  7761. : 'html',
  7762. pre: !this.options.sanitizer
  7763. && (cap[1] === 'pre' || cap[1] === 'script' || cap[1] === 'style'),
  7764. text: cap[0]
  7765. });
  7766. continue;
  7767. }
  7768. // def
  7769. if (top && (cap = this.rules.def.exec(src))) {
  7770. src = src.substring(cap[0].length);
  7771. if (cap[3]) cap[3] = cap[3].substring(1, cap[3].length - 1);
  7772. tag = cap[1].toLowerCase().replace(/\s+/g, ' ');
  7773. if (!this.tokens.links[tag]) {
  7774. this.tokens.links[tag] = {
  7775. href: cap[2],
  7776. title: cap[3]
  7777. };
  7778. }
  7779. continue;
  7780. }
  7781. // table (gfm)
  7782. if (cap = this.rules.table.exec(src)) {
  7783. item = {
  7784. type: 'table',
  7785. header: splitCells(cap[1].replace(/^ *| *\| *$/g, '')),
  7786. align: cap[2].replace(/^ *|\| *$/g, '').split(/ *\| */),
  7787. cells: cap[3] ? cap[3].replace(/\n$/, '').split('\n') : []
  7788. };
  7789. if (item.header.length === item.align.length) {
  7790. src = src.substring(cap[0].length);
  7791. for (i = 0; i < item.align.length; i++) {
  7792. if (/^ *-+: *$/.test(item.align[i])) {
  7793. item.align[i] = 'right';
  7794. } else if (/^ *:-+: *$/.test(item.align[i])) {
  7795. item.align[i] = 'center';
  7796. } else if (/^ *:-+ *$/.test(item.align[i])) {
  7797. item.align[i] = 'left';
  7798. } else {
  7799. item.align[i] = null;
  7800. }
  7801. }
  7802. for (i = 0; i < item.cells.length; i++) {
  7803. item.cells[i] = splitCells(
  7804. item.cells[i].replace(/^ *\| *| *\| *$/g, ''),
  7805. item.header.length);
  7806. }
  7807. this.tokens.push(item);
  7808. continue;
  7809. }
  7810. }
  7811. // lheading
  7812. if (cap = this.rules.lheading.exec(src)) {
  7813. src = src.substring(cap[0].length);
  7814. this.tokens.push({
  7815. type: 'heading',
  7816. depth: cap[2] === '=' ? 1 : 2,
  7817. text: cap[1]
  7818. });
  7819. continue;
  7820. }
  7821. // top-level paragraph
  7822. if (top && (cap = this.rules.paragraph.exec(src))) {
  7823. src = src.substring(cap[0].length);
  7824. this.tokens.push({
  7825. type: 'paragraph',
  7826. text: cap[1].charAt(cap[1].length - 1) === '\n'
  7827. ? cap[1].slice(0, -1)
  7828. : cap[1]
  7829. });
  7830. continue;
  7831. }
  7832. // text
  7833. if (cap = this.rules.text.exec(src)) {
  7834. // Top-level should never reach here.
  7835. src = src.substring(cap[0].length);
  7836. this.tokens.push({
  7837. type: 'text',
  7838. text: cap[0]
  7839. });
  7840. continue;
  7841. }
  7842. if (src) {
  7843. throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
  7844. }
  7845. }
  7846. return this.tokens;
  7847. };
  7848. /**
  7849. * Inline-Level Grammar
  7850. */
  7851. var inline = {
  7852. escape: /^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,
  7853. autolink: /^<(scheme:[^\s\x00-\x1f<>]*|email)>/,
  7854. url: noop,
  7855. tag: '^comment'
  7856. + '|^</[a-zA-Z][\\w:-]*\\s*>' // self-closing tag
  7857. + '|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>' // open tag
  7858. + '|^<\\?[\\s\\S]*?\\?>' // processing instruction, e.g. <?php ?>
  7859. + '|^<![a-zA-Z]+\\s[\\s\\S]*?>' // declaration, e.g. <!DOCTYPE html>
  7860. + '|^<!\\[CDATA\\[[\\s\\S]*?\\]\\]>', // CDATA section
  7861. link: /^!?\[(label)\]\(href(?:\s+(title))?\s*\)/,
  7862. reflink: /^!?\[(label)\]\[(?!\s*\])((?:\\[\[\]]?|[^\[\]\\])+)\]/,
  7863. nolink: /^!?\[(?!\s*\])((?:\[[^\[\]]*\]|\\[\[\]]|[^\[\]])*)\](?:\[\])?/,
  7864. strong: /^__([^\s_])__(?!_)|^\*\*([^\s*])\*\*(?!\*)|^__([^\s][\s\S]*?[^\s])__(?!_)|^\*\*([^\s][\s\S]*?[^\s])\*\*(?!\*)/,
  7865. em: /^_([^\s_])_(?!_)|^\*([^\s*"<\[])\*(?!\*)|^_([^\s][\s\S]*?[^\s_])_(?!_|[^\spunctuation])|^_([^\s_][\s\S]*?[^\s])_(?!_|[^\spunctuation])|^\*([^\s"<\[][\s\S]*?[^\s*])\*(?!\*)|^\*([^\s*"<\[][\s\S]*?[^\s])\*(?!\*)/,
  7866. code: /^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,
  7867. br: /^( {2,}|\\)\n(?!\s*$)/,
  7868. del: noop,
  7869. text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*]|\b_|$)|[^ ](?= {2,}\n))|(?= {2,}\n))/
  7870. };
  7871. // list of punctuation marks from common mark spec
  7872. // without ` and ] to workaround Rule 17 (inline code blocks/links)
  7873. inline._punctuation = '!"#$%&\'()*+,\\-./:;<=>?@\\[^_{|}~';
  7874. inline.em = edit(inline.em).replace(/punctuation/g, inline._punctuation).getRegex();
  7875. inline._escapes = /\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/g;
  7876. inline._scheme = /[a-zA-Z][a-zA-Z0-9+.-]{1,31}/;
  7877. inline._email = /[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/;
  7878. inline.autolink = edit(inline.autolink)
  7879. .replace('scheme', inline._scheme)
  7880. .replace('email', inline._email)
  7881. .getRegex();
  7882. inline._attribute = /\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/;
  7883. inline.tag = edit(inline.tag)
  7884. .replace('comment', block._comment)
  7885. .replace('attribute', inline._attribute)
  7886. .getRegex();
  7887. inline._label = /(?:\[[^\[\]]*\]|\\[\[\]]?|`[^`]*`|`(?!`)|[^\[\]\\`])*?/;
  7888. inline._href = /\s*(<(?:\\[<>]?|[^\s<>\\])*>|[^\s\x00-\x1f]*)/;
  7889. inline._title = /"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/;
  7890. inline.link = edit(inline.link)
  7891. .replace('label', inline._label)
  7892. .replace('href', inline._href)
  7893. .replace('title', inline._title)
  7894. .getRegex();
  7895. inline.reflink = edit(inline.reflink)
  7896. .replace('label', inline._label)
  7897. .getRegex();
  7898. /**
  7899. * Normal Inline Grammar
  7900. */
  7901. inline.normal = merge({}, inline);
  7902. /**
  7903. * Pedantic Inline Grammar
  7904. */
  7905. inline.pedantic = merge({}, inline.normal, {
  7906. strong: /^__(?=\S)([\s\S]*?\S)__(?!_)|^\*\*(?=\S)([\s\S]*?\S)\*\*(?!\*)/,
  7907. em: /^_(?=\S)([\s\S]*?\S)_(?!_)|^\*(?=\S)([\s\S]*?\S)\*(?!\*)/,
  7908. link: edit(/^!?\[(label)\]\((.*?)\)/)
  7909. .replace('label', inline._label)
  7910. .getRegex(),
  7911. reflink: edit(/^!?\[(label)\]\s*\[([^\]]*)\]/)
  7912. .replace('label', inline._label)
  7913. .getRegex()
  7914. });
  7915. /**
  7916. * GFM Inline Grammar
  7917. */
  7918. inline.gfm = merge({}, inline.normal, {
  7919. escape: edit(inline.escape).replace('])', '~|])').getRegex(),
  7920. _extended_email: /[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/,
  7921. url: /^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,
  7922. _backpedal: /(?:[^?!.,:;*_~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_~)]+(?!$))+/,
  7923. del: /^~+(?=\S)([\s\S]*?\S)~+/,
  7924. text: /^(`+|[^`])(?:[\s\S]*?(?:(?=[\\<!\[`*~]|\b_|https?:\/\/|ftp:\/\/|www\.|$)|[^ ](?= {2,}\n)|[^a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-](?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))|(?= {2,}\n|[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@))/
  7925. });
  7926. inline.gfm.url = edit(inline.gfm.url, 'i')
  7927. .replace('email', inline.gfm._extended_email)
  7928. .getRegex();
  7929. /**
  7930. * GFM + Line Breaks Inline Grammar
  7931. */
  7932. inline.breaks = merge({}, inline.gfm, {
  7933. br: edit(inline.br).replace('{2,}', '*').getRegex(),
  7934. text: edit(inline.gfm.text).replace(/\{2,\}/g, '*').getRegex()
  7935. });
  7936. /**
  7937. * Inline Lexer & Compiler
  7938. */
  7939. function InlineLexer(links, options) {
  7940. this.options = options || marked.defaults;
  7941. this.links = links;
  7942. this.rules = inline.normal;
  7943. this.renderer = this.options.renderer || new Renderer();
  7944. this.renderer.options = this.options;
  7945. if (!this.links) {
  7946. throw new Error('Tokens array requires a `links` property.');
  7947. }
  7948. if (this.options.pedantic) {
  7949. this.rules = inline.pedantic;
  7950. } else if (this.options.gfm) {
  7951. if (this.options.breaks) {
  7952. this.rules = inline.breaks;
  7953. } else {
  7954. this.rules = inline.gfm;
  7955. }
  7956. }
  7957. }
  7958. /**
  7959. * Expose Inline Rules
  7960. */
  7961. InlineLexer.rules = inline;
  7962. /**
  7963. * Static Lexing/Compiling Method
  7964. */
  7965. InlineLexer.output = function(src, links, options) {
  7966. var inline = new InlineLexer(links, options);
  7967. return inline.output(src);
  7968. };
  7969. /**
  7970. * Lexing/Compiling
  7971. */
  7972. InlineLexer.prototype.output = function(src) {
  7973. var out = '',
  7974. link,
  7975. text,
  7976. href,
  7977. title,
  7978. cap,
  7979. prevCapZero;
  7980. while (src) {
  7981. // escape
  7982. if (cap = this.rules.escape.exec(src)) {
  7983. src = src.substring(cap[0].length);
  7984. out += escape(cap[1]);
  7985. continue;
  7986. }
  7987. // tag
  7988. if (cap = this.rules.tag.exec(src)) {
  7989. if (!this.inLink && /^<a /i.test(cap[0])) {
  7990. this.inLink = true;
  7991. } else if (this.inLink && /^<\/a>/i.test(cap[0])) {
  7992. this.inLink = false;
  7993. }
  7994. if (!this.inRawBlock && /^<(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
  7995. this.inRawBlock = true;
  7996. } else if (this.inRawBlock && /^<\/(pre|code|kbd|script)(\s|>)/i.test(cap[0])) {
  7997. this.inRawBlock = false;
  7998. }
  7999. src = src.substring(cap[0].length);
  8000. out += this.options.sanitize
  8001. ? this.options.sanitizer
  8002. ? this.options.sanitizer(cap[0])
  8003. : escape(cap[0])
  8004. : cap[0];
  8005. continue;
  8006. }
  8007. // link
  8008. if (cap = this.rules.link.exec(src)) {
  8009. var lastParenIndex = findClosingBracket(cap[2], '()');
  8010. if (lastParenIndex > -1) {
  8011. var linkLen = cap[0].length - (cap[2].length - lastParenIndex) - (cap[3] || '').length;
  8012. cap[2] = cap[2].substring(0, lastParenIndex);
  8013. cap[0] = cap[0].substring(0, linkLen).trim();
  8014. cap[3] = '';
  8015. }
  8016. src = src.substring(cap[0].length);
  8017. this.inLink = true;
  8018. href = cap[2];
  8019. if (this.options.pedantic) {
  8020. link = /^([^'"]*[^\s])\s+(['"])(.*)\2/.exec(href);
  8021. if (link) {
  8022. href = link[1];
  8023. title = link[3];
  8024. } else {
  8025. title = '';
  8026. }
  8027. } else {
  8028. title = cap[3] ? cap[3].slice(1, -1) : '';
  8029. }
  8030. href = href.trim().replace(/^<([\s\S]*)>$/, '$1');
  8031. out += this.outputLink(cap, {
  8032. href: InlineLexer.escapes(href),
  8033. title: InlineLexer.escapes(title)
  8034. });
  8035. this.inLink = false;
  8036. continue;
  8037. }
  8038. // reflink, nolink
  8039. if ((cap = this.rules.reflink.exec(src))
  8040. || (cap = this.rules.nolink.exec(src))) {
  8041. src = src.substring(cap[0].length);
  8042. link = (cap[2] || cap[1]).replace(/\s+/g, ' ');
  8043. link = this.links[link.toLowerCase()];
  8044. if (!link || !link.href) {
  8045. out += cap[0].charAt(0);
  8046. src = cap[0].substring(1) + src;
  8047. continue;
  8048. }
  8049. this.inLink = true;
  8050. out += this.outputLink(cap, link);
  8051. this.inLink = false;
  8052. continue;
  8053. }
  8054. // strong
  8055. if (cap = this.rules.strong.exec(src)) {
  8056. src = src.substring(cap[0].length);
  8057. out += this.renderer.strong(this.output(cap[4] || cap[3] || cap[2] || cap[1]));
  8058. continue;
  8059. }
  8060. // em
  8061. if (cap = this.rules.em.exec(src)) {
  8062. src = src.substring(cap[0].length);
  8063. out += this.renderer.em(this.output(cap[6] || cap[5] || cap[4] || cap[3] || cap[2] || cap[1]));
  8064. continue;
  8065. }
  8066. // code
  8067. if (cap = this.rules.code.exec(src)) {
  8068. src = src.substring(cap[0].length);
  8069. out += this.renderer.codespan(escape(cap[2].trim(), true));
  8070. continue;
  8071. }
  8072. // br
  8073. if (cap = this.rules.br.exec(src)) {
  8074. src = src.substring(cap[0].length);
  8075. out += this.renderer.br();
  8076. continue;
  8077. }
  8078. // del (gfm)
  8079. if (cap = this.rules.del.exec(src)) {
  8080. src = src.substring(cap[0].length);
  8081. out += this.renderer.del(this.output(cap[1]));
  8082. continue;
  8083. }
  8084. // autolink
  8085. if (cap = this.rules.autolink.exec(src)) {
  8086. src = src.substring(cap[0].length);
  8087. if (cap[2] === '@') {
  8088. text = escape(this.mangle(cap[1]));
  8089. href = 'mailto:' + text;
  8090. } else {
  8091. text = escape(cap[1]);
  8092. href = text;
  8093. }
  8094. out += this.renderer.link(href, null, text);
  8095. continue;
  8096. }
  8097. // url (gfm)
  8098. if (!this.inLink && (cap = this.rules.url.exec(src))) {
  8099. if (cap[2] === '@') {
  8100. text = escape(cap[0]);
  8101. href = 'mailto:' + text;
  8102. } else {
  8103. // do extended autolink path validation
  8104. do {
  8105. prevCapZero = cap[0];
  8106. cap[0] = this.rules._backpedal.exec(cap[0])[0];
  8107. } while (prevCapZero !== cap[0]);
  8108. text = escape(cap[0]);
  8109. if (cap[1] === 'www.') {
  8110. href = 'http://' + text;
  8111. } else {
  8112. href = text;
  8113. }
  8114. }
  8115. src = src.substring(cap[0].length);
  8116. out += this.renderer.link(href, null, text);
  8117. continue;
  8118. }
  8119. // text
  8120. if (cap = this.rules.text.exec(src)) {
  8121. src = src.substring(cap[0].length);
  8122. if (this.inRawBlock) {
  8123. out += this.renderer.text(cap[0]);
  8124. } else {
  8125. out += this.renderer.text(escape(this.smartypants(cap[0])));
  8126. }
  8127. continue;
  8128. }
  8129. if (src) {
  8130. throw new Error('Infinite loop on byte: ' + src.charCodeAt(0));
  8131. }
  8132. }
  8133. return out;
  8134. };
  8135. InlineLexer.escapes = function(text) {
  8136. return text ? text.replace(InlineLexer.rules._escapes, '$1') : text;
  8137. };
  8138. /**
  8139. * Compile Link
  8140. */
  8141. InlineLexer.prototype.outputLink = function(cap, link) {
  8142. var href = link.href,
  8143. title = link.title ? escape(link.title) : null;
  8144. return cap[0].charAt(0) !== '!'
  8145. ? this.renderer.link(href, title, this.output(cap[1]))
  8146. : this.renderer.image(href, title, escape(cap[1]));
  8147. };
  8148. /**
  8149. * Smartypants Transformations
  8150. */
  8151. InlineLexer.prototype.smartypants = function(text) {
  8152. if (!this.options.smartypants) return text;
  8153. return text
  8154. // em-dashes
  8155. .replace(/---/g, '\u2014')
  8156. // en-dashes
  8157. .replace(/--/g, '\u2013')
  8158. // opening singles
  8159. .replace(/(^|[-\u2014/(\[{"\s])'/g, '$1\u2018')
  8160. // closing singles & apostrophes
  8161. .replace(/'/g, '\u2019')
  8162. // opening doubles
  8163. .replace(/(^|[-\u2014/(\[{\u2018\s])"/g, '$1\u201c')
  8164. // closing doubles
  8165. .replace(/"/g, '\u201d')
  8166. // ellipses
  8167. .replace(/\.{3}/g, '\u2026');
  8168. };
  8169. /**
  8170. * Mangle Links
  8171. */
  8172. InlineLexer.prototype.mangle = function(text) {
  8173. if (!this.options.mangle) return text;
  8174. var out = '',
  8175. l = text.length,
  8176. i = 0,
  8177. ch;
  8178. for (; i < l; i++) {
  8179. ch = text.charCodeAt(i);
  8180. if (Math.random() > 0.5) {
  8181. ch = 'x' + ch.toString(16);
  8182. }
  8183. out += '&#' + ch + ';';
  8184. }
  8185. return out;
  8186. };
  8187. /**
  8188. * Renderer
  8189. */
  8190. function Renderer(options) {
  8191. this.options = options || marked.defaults;
  8192. }
  8193. Renderer.prototype.code = function(code, infostring, escaped) {
  8194. var lang = (infostring || '').match(/\S*/)[0];
  8195. if (this.options.highlight) {
  8196. var out = this.options.highlight(code, lang);
  8197. if (out != null && out !== code) {
  8198. escaped = true;
  8199. code = out;
  8200. }
  8201. }
  8202. if (!lang) {
  8203. return '<pre><code>'
  8204. + (escaped ? code : escape(code, true))
  8205. + '</code></pre>';
  8206. }
  8207. return '<pre><code class="'
  8208. + this.options.langPrefix
  8209. + escape(lang, true)
  8210. + '">'
  8211. + (escaped ? code : escape(code, true))
  8212. + '</code></pre>\n';
  8213. };
  8214. Renderer.prototype.blockquote = function(quote) {
  8215. return '<blockquote>\n' + quote + '</blockquote>\n';
  8216. };
  8217. Renderer.prototype.html = function(html) {
  8218. return html;
  8219. };
  8220. Renderer.prototype.heading = function(text, level, raw, slugger) {
  8221. if (this.options.headerIds) {
  8222. return '<h'
  8223. + level
  8224. + ' id="'
  8225. + this.options.headerPrefix
  8226. + slugger.slug(raw)
  8227. + '">'
  8228. + text
  8229. + '</h'
  8230. + level
  8231. + '>\n';
  8232. }
  8233. // ignore IDs
  8234. return '<h' + level + '>' + text + '</h' + level + '>\n';
  8235. };
  8236. Renderer.prototype.hr = function() {
  8237. return this.options.xhtml ? '<hr/>\n' : '<hr>\n';
  8238. };
  8239. Renderer.prototype.list = function(body, ordered, start) {
  8240. var type = ordered ? 'ol' : 'ul',
  8241. startatt = (ordered && start !== 1) ? (' start="' + start + '"') : '';
  8242. return '<' + type + startatt + '>\n' + body + '</' + type + '>\n';
  8243. };
  8244. Renderer.prototype.listitem = function(text) {
  8245. return '<li>' + text + '</li>\n';
  8246. };
  8247. Renderer.prototype.checkbox = function(checked) {
  8248. return '<input '
  8249. + (checked ? 'checked="" ' : '')
  8250. + 'disabled="" type="checkbox"'
  8251. + (this.options.xhtml ? ' /' : '')
  8252. + '> ';
  8253. };
  8254. Renderer.prototype.paragraph = function(text) {
  8255. return '<p>' + text + '</p>\n';
  8256. };
  8257. Renderer.prototype.table = function(header, body) {
  8258. if (body) body = '<tbody>' + body + '</tbody>';
  8259. return '<table>\n'
  8260. + '<thead>\n'
  8261. + header
  8262. + '</thead>\n'
  8263. + body
  8264. + '</table>\n';
  8265. };
  8266. Renderer.prototype.tablerow = function(content) {
  8267. return '<tr>\n' + content + '</tr>\n';
  8268. };
  8269. Renderer.prototype.tablecell = function(content, flags) {
  8270. var type = flags.header ? 'th' : 'td';
  8271. var tag = flags.align
  8272. ? '<' + type + ' align="' + flags.align + '">'
  8273. : '<' + type + '>';
  8274. return tag + content + '</' + type + '>\n';
  8275. };
  8276. // span level renderer
  8277. Renderer.prototype.strong = function(text) {
  8278. return '<strong>' + text + '</strong>';
  8279. };
  8280. Renderer.prototype.em = function(text) {
  8281. return '<em>' + text + '</em>';
  8282. };
  8283. Renderer.prototype.codespan = function(text) {
  8284. return '<code>' + text + '</code>';
  8285. };
  8286. Renderer.prototype.br = function() {
  8287. return this.options.xhtml ? '<br/>' : '<br>';
  8288. };
  8289. Renderer.prototype.del = function(text) {
  8290. return '<del>' + text + '</del>';
  8291. };
  8292. Renderer.prototype.link = function(href, title, text) {
  8293. href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
  8294. if (href === null) {
  8295. return text;
  8296. }
  8297. var out = '<a href="' + escape(href) + '"';
  8298. if (title) {
  8299. out += ' title="' + title + '"';
  8300. }
  8301. out += '>' + text + '</a>';
  8302. return out;
  8303. };
  8304. Renderer.prototype.image = function(href, title, text) {
  8305. href = cleanUrl(this.options.sanitize, this.options.baseUrl, href);
  8306. if (href === null) {
  8307. return text;
  8308. }
  8309. var out = '<img src="' + href + '" alt="' + text + '"';
  8310. if (title) {
  8311. out += ' title="' + title + '"';
  8312. }
  8313. out += this.options.xhtml ? '/>' : '>';
  8314. return out;
  8315. };
  8316. Renderer.prototype.text = function(text) {
  8317. return text;
  8318. };
  8319. /**
  8320. * TextRenderer
  8321. * returns only the textual part of the token
  8322. */
  8323. function TextRenderer() {}
  8324. // no need for block level renderers
  8325. TextRenderer.prototype.strong =
  8326. TextRenderer.prototype.em =
  8327. TextRenderer.prototype.codespan =
  8328. TextRenderer.prototype.del =
  8329. TextRenderer.prototype.text = function (text) {
  8330. return text;
  8331. };
  8332. TextRenderer.prototype.link =
  8333. TextRenderer.prototype.image = function(href, title, text) {
  8334. return '' + text;
  8335. };
  8336. TextRenderer.prototype.br = function() {
  8337. return '';
  8338. };
  8339. /**
  8340. * Parsing & Compiling
  8341. */
  8342. function Parser(options) {
  8343. this.tokens = [];
  8344. this.token = null;
  8345. this.options = options || marked.defaults;
  8346. this.options.renderer = this.options.renderer || new Renderer();
  8347. this.renderer = this.options.renderer;
  8348. this.renderer.options = this.options;
  8349. this.slugger = new Slugger();
  8350. }
  8351. /**
  8352. * Static Parse Method
  8353. */
  8354. Parser.parse = function(src, options) {
  8355. var parser = new Parser(options);
  8356. return parser.parse(src);
  8357. };
  8358. /**
  8359. * Parse Loop
  8360. */
  8361. Parser.prototype.parse = function(src) {
  8362. this.inline = new InlineLexer(src.links, this.options);
  8363. // use an InlineLexer with a TextRenderer to extract pure text
  8364. this.inlineText = new InlineLexer(
  8365. src.links,
  8366. merge({}, this.options, {renderer: new TextRenderer()})
  8367. );
  8368. this.tokens = src.reverse();
  8369. var out = '';
  8370. while (this.next()) {
  8371. out += this.tok();
  8372. }
  8373. return out;
  8374. };
  8375. /**
  8376. * Next Token
  8377. */
  8378. Parser.prototype.next = function() {
  8379. return this.token = this.tokens.pop();
  8380. };
  8381. /**
  8382. * Preview Next Token
  8383. */
  8384. Parser.prototype.peek = function() {
  8385. return this.tokens[this.tokens.length - 1] || 0;
  8386. };
  8387. /**
  8388. * Parse Text Tokens
  8389. */
  8390. Parser.prototype.parseText = function() {
  8391. var body = this.token.text;
  8392. while (this.peek().type === 'text') {
  8393. body += '\n' + this.next().text;
  8394. }
  8395. return this.inline.output(body);
  8396. };
  8397. /**
  8398. * Parse Current Token
  8399. */
  8400. Parser.prototype.tok = function() {
  8401. switch (this.token.type) {
  8402. case 'space': {
  8403. return '';
  8404. }
  8405. case 'hr': {
  8406. return this.renderer.hr();
  8407. }
  8408. case 'heading': {
  8409. return this.renderer.heading(
  8410. this.inline.output(this.token.text),
  8411. this.token.depth,
  8412. unescape(this.inlineText.output(this.token.text)),
  8413. this.slugger);
  8414. }
  8415. case 'code': {
  8416. return this.renderer.code(this.token.text,
  8417. this.token.lang,
  8418. this.token.escaped);
  8419. }
  8420. case 'table': {
  8421. var header = '',
  8422. body = '',
  8423. i,
  8424. row,
  8425. cell,
  8426. j;
  8427. // header
  8428. cell = '';
  8429. for (i = 0; i < this.token.header.length; i++) {
  8430. cell += this.renderer.tablecell(
  8431. this.inline.output(this.token.header[i]),
  8432. { header: true, align: this.token.align[i] }
  8433. );
  8434. }
  8435. header += this.renderer.tablerow(cell);
  8436. for (i = 0; i < this.token.cells.length; i++) {
  8437. row = this.token.cells[i];
  8438. cell = '';
  8439. for (j = 0; j < row.length; j++) {
  8440. cell += this.renderer.tablecell(
  8441. this.inline.output(row[j]),
  8442. { header: false, align: this.token.align[j] }
  8443. );
  8444. }
  8445. body += this.renderer.tablerow(cell);
  8446. }
  8447. return this.renderer.table(header, body);
  8448. }
  8449. case 'blockquote_start': {
  8450. body = '';
  8451. while (this.next().type !== 'blockquote_end') {
  8452. body += this.tok();
  8453. }
  8454. return this.renderer.blockquote(body);
  8455. }
  8456. case 'list_start': {
  8457. body = '';
  8458. var ordered = this.token.ordered,
  8459. start = this.token.start;
  8460. while (this.next().type !== 'list_end') {
  8461. body += this.tok();
  8462. }
  8463. return this.renderer.list(body, ordered, start);
  8464. }
  8465. case 'list_item_start': {
  8466. body = '';
  8467. var loose = this.token.loose;
  8468. var checked = this.token.checked;
  8469. var task = this.token.task;
  8470. if (this.token.task) {
  8471. body += this.renderer.checkbox(checked);
  8472. }
  8473. while (this.next().type !== 'list_item_end') {
  8474. body += !loose && this.token.type === 'text'
  8475. ? this.parseText()
  8476. : this.tok();
  8477. }
  8478. return this.renderer.listitem(body, task, checked);
  8479. }
  8480. case 'html': {
  8481. // TODO parse inline content if parameter markdown=1
  8482. return this.renderer.html(this.token.text);
  8483. }
  8484. case 'paragraph': {
  8485. return this.renderer.paragraph(this.inline.output(this.token.text));
  8486. }
  8487. case 'text': {
  8488. return this.renderer.paragraph(this.parseText());
  8489. }
  8490. default: {
  8491. var errMsg = 'Token with "' + this.token.type + '" type was not found.';
  8492. if (this.options.silent) {
  8493. console.log(errMsg);
  8494. } else {
  8495. throw new Error(errMsg);
  8496. }
  8497. }
  8498. }
  8499. };
  8500. /**
  8501. * Slugger generates header id
  8502. */
  8503. function Slugger () {
  8504. this.seen = {};
  8505. }
  8506. /**
  8507. * Convert string to unique id
  8508. */
  8509. Slugger.prototype.slug = function (value) {
  8510. var slug = value
  8511. .toLowerCase()
  8512. .trim()
  8513. .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,./:;<=>?@[\]^`{|}~]/g, '')
  8514. .replace(/\s/g, '-');
  8515. if (this.seen.hasOwnProperty(slug)) {
  8516. var originalSlug = slug;
  8517. do {
  8518. this.seen[originalSlug]++;
  8519. slug = originalSlug + '-' + this.seen[originalSlug];
  8520. } while (this.seen.hasOwnProperty(slug));
  8521. }
  8522. this.seen[slug] = 0;
  8523. return slug;
  8524. };
  8525. /**
  8526. * Helpers
  8527. */
  8528. function escape(html, encode) {
  8529. if (encode) {
  8530. if (escape.escapeTest.test(html)) {
  8531. return html.replace(escape.escapeReplace, function (ch) { return escape.replacements[ch]; });
  8532. }
  8533. } else {
  8534. if (escape.escapeTestNoEncode.test(html)) {
  8535. return html.replace(escape.escapeReplaceNoEncode, function (ch) { return escape.replacements[ch]; });
  8536. }
  8537. }
  8538. return html;
  8539. }
  8540. escape.escapeTest = /[&<>"']/;
  8541. escape.escapeReplace = /[&<>"']/g;
  8542. escape.replacements = {
  8543. '&': '&amp;',
  8544. '<': '&lt;',
  8545. '>': '&gt;',
  8546. '"': '&quot;',
  8547. "'": '&#39;'
  8548. };
  8549. escape.escapeTestNoEncode = /[<>"']|&(?!#?\w+;)/;
  8550. escape.escapeReplaceNoEncode = /[<>"']|&(?!#?\w+;)/g;
  8551. function unescape(html) {
  8552. // explicitly match decimal, hex, and named HTML entities
  8553. return html.replace(/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig, function(_, n) {
  8554. n = n.toLowerCase();
  8555. if (n === 'colon') return ':';
  8556. if (n.charAt(0) === '#') {
  8557. return n.charAt(1) === 'x'
  8558. ? String.fromCharCode(parseInt(n.substring(2), 16))
  8559. : String.fromCharCode(+n.substring(1));
  8560. }
  8561. return '';
  8562. });
  8563. }
  8564. function edit(regex, opt) {
  8565. regex = regex.source || regex;
  8566. opt = opt || '';
  8567. return {
  8568. replace: function(name, val) {
  8569. val = val.source || val;
  8570. val = val.replace(/(^|[^\[])\^/g, '$1');
  8571. regex = regex.replace(name, val);
  8572. return this;
  8573. },
  8574. getRegex: function() {
  8575. return new RegExp(regex, opt);
  8576. }
  8577. };
  8578. }
  8579. function cleanUrl(sanitize, base, href) {
  8580. if (sanitize) {
  8581. try {
  8582. var prot = decodeURIComponent(unescape(href))
  8583. .replace(/[^\w:]/g, '')
  8584. .toLowerCase();
  8585. } catch (e) {
  8586. return null;
  8587. }
  8588. if (prot.indexOf('javascript:') === 0 || prot.indexOf('vbscript:') === 0 || prot.indexOf('data:') === 0) {
  8589. return null;
  8590. }
  8591. }
  8592. if (base && !originIndependentUrl.test(href)) {
  8593. href = resolveUrl(base, href);
  8594. }
  8595. try {
  8596. href = encodeURI(href).replace(/%25/g, '%');
  8597. } catch (e) {
  8598. return null;
  8599. }
  8600. return href;
  8601. }
  8602. function resolveUrl(base, href) {
  8603. if (!baseUrls[' ' + base]) {
  8604. // we can ignore everything in base after the last slash of its path component,
  8605. // but we might need to add _that_
  8606. // https://tools.ietf.org/html/rfc3986#section-3
  8607. if (/^[^:]+:\/*[^/]*$/.test(base)) {
  8608. baseUrls[' ' + base] = base + '/';
  8609. } else {
  8610. baseUrls[' ' + base] = rtrim(base, '/', true);
  8611. }
  8612. }
  8613. base = baseUrls[' ' + base];
  8614. if (href.slice(0, 2) === '//') {
  8615. return base.replace(/:[\s\S]*/, ':') + href;
  8616. } else if (href.charAt(0) === '/') {
  8617. return base.replace(/(:\/*[^/]*)[\s\S]*/, '$1') + href;
  8618. } else {
  8619. return base + href;
  8620. }
  8621. }
  8622. var baseUrls = {};
  8623. var originIndependentUrl = /^$|^[a-z][a-z0-9+.-]*:|^[?#]/i;
  8624. function noop() {}
  8625. noop.exec = noop;
  8626. function merge(obj) {
  8627. var i = 1,
  8628. target,
  8629. key;
  8630. for (; i < arguments.length; i++) {
  8631. target = arguments[i];
  8632. for (key in target) {
  8633. if (Object.prototype.hasOwnProperty.call(target, key)) {
  8634. obj[key] = target[key];
  8635. }
  8636. }
  8637. }
  8638. return obj;
  8639. }
  8640. function splitCells(tableRow, count) {
  8641. // ensure that every cell-delimiting pipe has a space
  8642. // before it to distinguish it from an escaped pipe
  8643. var row = tableRow.replace(/\|/g, function (match, offset, str) {
  8644. var escaped = false,
  8645. curr = offset;
  8646. while (--curr >= 0 && str[curr] === '\\') escaped = !escaped;
  8647. if (escaped) {
  8648. // odd number of slashes means | is escaped
  8649. // so we leave it alone
  8650. return '|';
  8651. } else {
  8652. // add space before unescaped |
  8653. return ' |';
  8654. }
  8655. }),
  8656. cells = row.split(/ \|/),
  8657. i = 0;
  8658. if (cells.length > count) {
  8659. cells.splice(count);
  8660. } else {
  8661. while (cells.length < count) cells.push('');
  8662. }
  8663. for (; i < cells.length; i++) {
  8664. // leading or trailing whitespace is ignored per the gfm spec
  8665. cells[i] = cells[i].trim().replace(/\\\|/g, '|');
  8666. }
  8667. return cells;
  8668. }
  8669. // Remove trailing 'c's. Equivalent to str.replace(/c*$/, '').
  8670. // /c*$/ is vulnerable to REDOS.
  8671. // invert: Remove suffix of non-c chars instead. Default falsey.
  8672. function rtrim(str, c, invert) {
  8673. if (str.length === 0) {
  8674. return '';
  8675. }
  8676. // Length of suffix matching the invert condition.
  8677. var suffLen = 0;
  8678. // Step left until we fail to match the invert condition.
  8679. while (suffLen < str.length) {
  8680. var currChar = str.charAt(str.length - suffLen - 1);
  8681. if (currChar === c && !invert) {
  8682. suffLen++;
  8683. } else if (currChar !== c && invert) {
  8684. suffLen++;
  8685. } else {
  8686. break;
  8687. }
  8688. }
  8689. return str.substr(0, str.length - suffLen);
  8690. }
  8691. function findClosingBracket(str, b) {
  8692. if (str.indexOf(b[1]) === -1) {
  8693. return -1;
  8694. }
  8695. var level = 0;
  8696. for (var i = 0; i < str.length; i++) {
  8697. if (str[i] === '\\') {
  8698. i++;
  8699. } else if (str[i] === b[0]) {
  8700. level++;
  8701. } else if (str[i] === b[1]) {
  8702. level--;
  8703. if (level < 0) {
  8704. return i;
  8705. }
  8706. }
  8707. }
  8708. return -1;
  8709. }
  8710. /**
  8711. * Marked
  8712. */
  8713. function marked(src, opt, callback) {
  8714. // throw error in case of non string input
  8715. if (typeof src === 'undefined' || src === null) {
  8716. throw new Error('marked(): input parameter is undefined or null');
  8717. }
  8718. if (typeof src !== 'string') {
  8719. throw new Error('marked(): input parameter is of type '
  8720. + Object.prototype.toString.call(src) + ', string expected');
  8721. }
  8722. if (callback || typeof opt === 'function') {
  8723. if (!callback) {
  8724. callback = opt;
  8725. opt = null;
  8726. }
  8727. opt = merge({}, marked.defaults, opt || {});
  8728. var highlight = opt.highlight,
  8729. tokens,
  8730. pending,
  8731. i = 0;
  8732. try {
  8733. tokens = Lexer.lex(src, opt);
  8734. } catch (e) {
  8735. return callback(e);
  8736. }
  8737. pending = tokens.length;
  8738. var done = function(err) {
  8739. if (err) {
  8740. opt.highlight = highlight;
  8741. return callback(err);
  8742. }
  8743. var out;
  8744. try {
  8745. out = Parser.parse(tokens, opt);
  8746. } catch (e) {
  8747. err = e;
  8748. }
  8749. opt.highlight = highlight;
  8750. return err
  8751. ? callback(err)
  8752. : callback(null, out);
  8753. };
  8754. if (!highlight || highlight.length < 3) {
  8755. return done();
  8756. }
  8757. delete opt.highlight;
  8758. if (!pending) return done();
  8759. for (; i < tokens.length; i++) {
  8760. (function(token) {
  8761. if (token.type !== 'code') {
  8762. return --pending || done();
  8763. }
  8764. return highlight(token.text, token.lang, function(err, code) {
  8765. if (err) return done(err);
  8766. if (code == null || code === token.text) {
  8767. return --pending || done();
  8768. }
  8769. token.text = code;
  8770. token.escaped = true;
  8771. --pending || done();
  8772. });
  8773. })(tokens[i]);
  8774. }
  8775. return;
  8776. }
  8777. try {
  8778. if (opt) opt = merge({}, marked.defaults, opt);
  8779. return Parser.parse(Lexer.lex(src, opt), opt);
  8780. } catch (e) {
  8781. e.message += '\nPlease report this to https://github.com/markedjs/marked.';
  8782. if ((opt || marked.defaults).silent) {
  8783. return '<p>An error occurred:</p><pre>'
  8784. + escape(e.message + '', true)
  8785. + '</pre>';
  8786. }
  8787. throw e;
  8788. }
  8789. }
  8790. /**
  8791. * Options
  8792. */
  8793. marked.options =
  8794. marked.setOptions = function(opt) {
  8795. merge(marked.defaults, opt);
  8796. return marked;
  8797. };
  8798. marked.getDefaults = function () {
  8799. return {
  8800. baseUrl: null,
  8801. breaks: false,
  8802. gfm: true,
  8803. headerIds: true,
  8804. headerPrefix: '',
  8805. highlight: null,
  8806. langPrefix: 'language-',
  8807. mangle: true,
  8808. pedantic: false,
  8809. renderer: new Renderer(),
  8810. sanitize: false,
  8811. sanitizer: null,
  8812. silent: false,
  8813. smartLists: false,
  8814. smartypants: false,
  8815. tables: true,
  8816. xhtml: false
  8817. };
  8818. };
  8819. marked.defaults = marked.getDefaults();
  8820. /**
  8821. * Expose
  8822. */
  8823. marked.Parser = Parser;
  8824. marked.parser = Parser.parse;
  8825. marked.Renderer = Renderer;
  8826. marked.TextRenderer = TextRenderer;
  8827. marked.Lexer = Lexer;
  8828. marked.lexer = Lexer.lex;
  8829. marked.InlineLexer = InlineLexer;
  8830. marked.inlineLexer = InlineLexer.output;
  8831. marked.Slugger = Slugger;
  8832. marked.parse = marked;
  8833. // BEGIN MONACOCHANGE
  8834. // if (typeof module !== 'undefined' && typeof exports === 'object') {
  8835. // module.exports = marked;
  8836. // } else if (typeof define === 'function' && define.amd) {
  8837. // define(function() { return marked; });
  8838. // } else {
  8839. // root.marked = marked;
  8840. // }
  8841. // })(this || (typeof window !== 'undefined' ? window : global));
  8842. __marked_exports = marked;
  8843. }).call(this);
  8844. // ESM-comment-begin
  8845. define("vs/base/common/marked/marked", function() { return __marked_exports; });
  8846. // ESM-comment-end
  8847. // ESM-uncomment-begin
  8848. // export var marked = __marked_exports;
  8849. // export var Parser = __marked_exports.Parser;
  8850. // export var parser = __marked_exports.parser;
  8851. // export var Renderer = __marked_exports.Renderer;
  8852. // export var TextRenderer = __marked_exports.TextRenderer;
  8853. // export var Lexer = __marked_exports.Lexer;
  8854. // export var lexer = __marked_exports.lexer;
  8855. // export var InlineLexer = __marked_exports.InlineLexer;
  8856. // export var inlineLexer = __marked_exports.inlineLexer;
  8857. // export var parse = __marked_exports.parse;
  8858. // ESM-uncomment-end
  8859. // END MONACOCHANGE
  8860. /*---------------------------------------------------------------------------------------------
  8861. * Copyright (c) Microsoft Corporation. All rights reserved.
  8862. * Licensed under the MIT License. See License.txt in the project root for license information.
  8863. *--------------------------------------------------------------------------------------------*/
  8864. define(__m[131/*vs/base/common/numbers*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  8865. "use strict";
  8866. Object.defineProperty(exports, "__esModule", { value: true });
  8867. function clamp(value, min, max) {
  8868. return Math.min(Math.max(value, min), max);
  8869. }
  8870. exports.clamp = clamp;
  8871. });
  8872. /*---------------------------------------------------------------------------------------------
  8873. * Copyright (c) Microsoft Corporation. All rights reserved.
  8874. * Licensed under the MIT License. See License.txt in the project root for license information.
  8875. *--------------------------------------------------------------------------------------------*/
  8876. define(__m[16/*vs/base/common/platform*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  8877. "use strict";
  8878. Object.defineProperty(exports, "__esModule", { value: true });
  8879. var LANGUAGE_DEFAULT = 'en';
  8880. var _isWindows = false;
  8881. var _isMacintosh = false;
  8882. var _isLinux = false;
  8883. var _isNative = false;
  8884. var _isWeb = false;
  8885. var _isIOS = false;
  8886. var _locale = undefined;
  8887. var _language = LANGUAGE_DEFAULT;
  8888. var _translationsConfigFile = undefined;
  8889. var _userAgent = undefined;
  8890. var isElectronRenderer = (typeof process !== 'undefined' && typeof process.versions !== 'undefined' && typeof process.versions.electron !== 'undefined' && process.type === 'renderer');
  8891. // OS detection
  8892. if (typeof navigator === 'object' && !isElectronRenderer) {
  8893. _userAgent = navigator.userAgent;
  8894. _isWindows = _userAgent.indexOf('Windows') >= 0;
  8895. _isMacintosh = _userAgent.indexOf('Macintosh') >= 0;
  8896. _isIOS = _userAgent.indexOf('Macintosh') >= 0 && !!navigator.maxTouchPoints && navigator.maxTouchPoints > 0;
  8897. _isLinux = _userAgent.indexOf('Linux') >= 0;
  8898. _isWeb = true;
  8899. _locale = navigator.language;
  8900. _language = _locale;
  8901. }
  8902. else if (typeof process === 'object') {
  8903. _isWindows = (process.platform === 'win32');
  8904. _isMacintosh = (process.platform === 'darwin');
  8905. _isLinux = (process.platform === 'linux');
  8906. _locale = LANGUAGE_DEFAULT;
  8907. _language = LANGUAGE_DEFAULT;
  8908. var rawNlsConfig = process.env['VSCODE_NLS_CONFIG'];
  8909. if (rawNlsConfig) {
  8910. try {
  8911. var nlsConfig = JSON.parse(rawNlsConfig);
  8912. var resolved = nlsConfig.availableLanguages['*'];
  8913. _locale = nlsConfig.locale;
  8914. // VSCode's default language is 'en'
  8915. _language = resolved ? resolved : LANGUAGE_DEFAULT;
  8916. _translationsConfigFile = nlsConfig._translationsConfigFile;
  8917. }
  8918. catch (e) {
  8919. }
  8920. }
  8921. _isNative = true;
  8922. }
  8923. var _platform = 0 /* Web */;
  8924. if (_isMacintosh) {
  8925. _platform = 1 /* Mac */;
  8926. }
  8927. else if (_isWindows) {
  8928. _platform = 3 /* Windows */;
  8929. }
  8930. else if (_isLinux) {
  8931. _platform = 2 /* Linux */;
  8932. }
  8933. exports.isWindows = _isWindows;
  8934. exports.isMacintosh = _isMacintosh;
  8935. exports.isLinux = _isLinux;
  8936. exports.isNative = _isNative;
  8937. exports.isWeb = _isWeb;
  8938. exports.isIOS = _isIOS;
  8939. var _globals = (typeof self === 'object' ? self : typeof global === 'object' ? global : {});
  8940. exports.globals = _globals;
  8941. exports.setImmediate = (function defineSetImmediate() {
  8942. if (exports.globals.setImmediate) {
  8943. return exports.globals.setImmediate.bind(exports.globals);
  8944. }
  8945. if (typeof exports.globals.postMessage === 'function' && !exports.globals.importScripts) {
  8946. var pending_1 = [];
  8947. exports.globals.addEventListener('message', function (e) {
  8948. if (e.data && e.data.vscodeSetImmediateId) {
  8949. for (var i = 0, len = pending_1.length; i < len; i++) {
  8950. var candidate = pending_1[i];
  8951. if (candidate.id === e.data.vscodeSetImmediateId) {
  8952. pending_1.splice(i, 1);
  8953. candidate.callback();
  8954. return;
  8955. }
  8956. }
  8957. }
  8958. });
  8959. var lastId_1 = 0;
  8960. return function (callback) {
  8961. var myId = ++lastId_1;
  8962. pending_1.push({
  8963. id: myId,
  8964. callback: callback
  8965. });
  8966. exports.globals.postMessage({ vscodeSetImmediateId: myId }, '*');
  8967. };
  8968. }
  8969. if (typeof process !== 'undefined' && typeof process.nextTick === 'function') {
  8970. return process.nextTick.bind(process);
  8971. }
  8972. var _promise = Promise.resolve();
  8973. return function (callback) { return _promise.then(callback); };
  8974. })();
  8975. exports.OS = (_isMacintosh ? 2 /* Macintosh */ : (_isWindows ? 1 /* Windows */ : 3 /* Linux */));
  8976. });
  8977. /*---------------------------------------------------------------------------------------------
  8978. * Copyright (c) Microsoft Corporation. All rights reserved.
  8979. * Licensed under the MIT License. See License.txt in the project root for license information.
  8980. *--------------------------------------------------------------------------------------------*/
  8981. define(__m[88/*vs/base/browser/canIUse*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,16/*vs/base/common/platform*/]), function (require, exports, browser, platform) {
  8982. "use strict";
  8983. Object.defineProperty(exports, "__esModule", { value: true });
  8984. /**
  8985. * Browser feature we can support in current platform, browser and environment.
  8986. */
  8987. exports.BrowserFeatures = {
  8988. clipboard: {
  8989. writeText: (platform.isNative
  8990. || (document.queryCommandSupported && document.queryCommandSupported('copy'))
  8991. || !!(navigator && navigator.clipboard && navigator.clipboard.writeText)),
  8992. readText: (platform.isNative
  8993. || !!(navigator && navigator.clipboard && navigator.clipboard.readText)),
  8994. richText: (function () {
  8995. if (browser.isIE) {
  8996. return false;
  8997. }
  8998. if (browser.isEdge) {
  8999. var index = navigator.userAgent.indexOf('Edge/');
  9000. var version = parseInt(navigator.userAgent.substring(index + 5, navigator.userAgent.indexOf('.', index)), 10);
  9001. if (!version || (version >= 12 && version <= 16)) {
  9002. return false;
  9003. }
  9004. }
  9005. return true;
  9006. })()
  9007. },
  9008. keyboard: (function () {
  9009. if (platform.isNative || browser.isStandalone) {
  9010. return 0 /* Always */;
  9011. }
  9012. if (navigator.keyboard || browser.isSafari) {
  9013. return 1 /* FullScreen */;
  9014. }
  9015. return 2 /* None */;
  9016. })(),
  9017. touch: 'ontouchstart' in window || navigator.maxTouchPoints > 0 || window.navigator.msMaxTouchPoints > 0,
  9018. pointerEvents: window.PointerEvent && ('ontouchstart' in window || window.navigator.maxTouchPoints > 0 || navigator.maxTouchPoints > 0 || window.navigator.msMaxTouchPoints > 0)
  9019. };
  9020. });
  9021. /*---------------------------------------------------------------------------------------------
  9022. * Copyright (c) Microsoft Corporation. All rights reserved.
  9023. * Licensed under the MIT License. See License.txt in the project root for license information.
  9024. *--------------------------------------------------------------------------------------------*/
  9025. define(__m[56/*vs/base/browser/keyboardEvent*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,36/*vs/base/common/keyCodes*/,16/*vs/base/common/platform*/]), function (require, exports, browser, keyCodes_1, platform) {
  9026. "use strict";
  9027. Object.defineProperty(exports, "__esModule", { value: true });
  9028. var KEY_CODE_MAP = new Array(230);
  9029. var INVERSE_KEY_CODE_MAP = new Array(112 /* MAX_VALUE */);
  9030. (function () {
  9031. for (var i = 0; i < INVERSE_KEY_CODE_MAP.length; i++) {
  9032. INVERSE_KEY_CODE_MAP[i] = -1;
  9033. }
  9034. function define(code, keyCode) {
  9035. KEY_CODE_MAP[code] = keyCode;
  9036. INVERSE_KEY_CODE_MAP[keyCode] = code;
  9037. }
  9038. define(3, 7 /* PauseBreak */); // VK_CANCEL 0x03 Control-break processing
  9039. define(8, 1 /* Backspace */);
  9040. define(9, 2 /* Tab */);
  9041. define(13, 3 /* Enter */);
  9042. define(16, 4 /* Shift */);
  9043. define(17, 5 /* Ctrl */);
  9044. define(18, 6 /* Alt */);
  9045. define(19, 7 /* PauseBreak */);
  9046. define(20, 8 /* CapsLock */);
  9047. define(27, 9 /* Escape */);
  9048. define(32, 10 /* Space */);
  9049. define(33, 11 /* PageUp */);
  9050. define(34, 12 /* PageDown */);
  9051. define(35, 13 /* End */);
  9052. define(36, 14 /* Home */);
  9053. define(37, 15 /* LeftArrow */);
  9054. define(38, 16 /* UpArrow */);
  9055. define(39, 17 /* RightArrow */);
  9056. define(40, 18 /* DownArrow */);
  9057. define(45, 19 /* Insert */);
  9058. define(46, 20 /* Delete */);
  9059. define(48, 21 /* KEY_0 */);
  9060. define(49, 22 /* KEY_1 */);
  9061. define(50, 23 /* KEY_2 */);
  9062. define(51, 24 /* KEY_3 */);
  9063. define(52, 25 /* KEY_4 */);
  9064. define(53, 26 /* KEY_5 */);
  9065. define(54, 27 /* KEY_6 */);
  9066. define(55, 28 /* KEY_7 */);
  9067. define(56, 29 /* KEY_8 */);
  9068. define(57, 30 /* KEY_9 */);
  9069. define(65, 31 /* KEY_A */);
  9070. define(66, 32 /* KEY_B */);
  9071. define(67, 33 /* KEY_C */);
  9072. define(68, 34 /* KEY_D */);
  9073. define(69, 35 /* KEY_E */);
  9074. define(70, 36 /* KEY_F */);
  9075. define(71, 37 /* KEY_G */);
  9076. define(72, 38 /* KEY_H */);
  9077. define(73, 39 /* KEY_I */);
  9078. define(74, 40 /* KEY_J */);
  9079. define(75, 41 /* KEY_K */);
  9080. define(76, 42 /* KEY_L */);
  9081. define(77, 43 /* KEY_M */);
  9082. define(78, 44 /* KEY_N */);
  9083. define(79, 45 /* KEY_O */);
  9084. define(80, 46 /* KEY_P */);
  9085. define(81, 47 /* KEY_Q */);
  9086. define(82, 48 /* KEY_R */);
  9087. define(83, 49 /* KEY_S */);
  9088. define(84, 50 /* KEY_T */);
  9089. define(85, 51 /* KEY_U */);
  9090. define(86, 52 /* KEY_V */);
  9091. define(87, 53 /* KEY_W */);
  9092. define(88, 54 /* KEY_X */);
  9093. define(89, 55 /* KEY_Y */);
  9094. define(90, 56 /* KEY_Z */);
  9095. define(93, 58 /* ContextMenu */);
  9096. define(96, 93 /* NUMPAD_0 */);
  9097. define(97, 94 /* NUMPAD_1 */);
  9098. define(98, 95 /* NUMPAD_2 */);
  9099. define(99, 96 /* NUMPAD_3 */);
  9100. define(100, 97 /* NUMPAD_4 */);
  9101. define(101, 98 /* NUMPAD_5 */);
  9102. define(102, 99 /* NUMPAD_6 */);
  9103. define(103, 100 /* NUMPAD_7 */);
  9104. define(104, 101 /* NUMPAD_8 */);
  9105. define(105, 102 /* NUMPAD_9 */);
  9106. define(106, 103 /* NUMPAD_MULTIPLY */);
  9107. define(107, 104 /* NUMPAD_ADD */);
  9108. define(108, 105 /* NUMPAD_SEPARATOR */);
  9109. define(109, 106 /* NUMPAD_SUBTRACT */);
  9110. define(110, 107 /* NUMPAD_DECIMAL */);
  9111. define(111, 108 /* NUMPAD_DIVIDE */);
  9112. define(112, 59 /* F1 */);
  9113. define(113, 60 /* F2 */);
  9114. define(114, 61 /* F3 */);
  9115. define(115, 62 /* F4 */);
  9116. define(116, 63 /* F5 */);
  9117. define(117, 64 /* F6 */);
  9118. define(118, 65 /* F7 */);
  9119. define(119, 66 /* F8 */);
  9120. define(120, 67 /* F9 */);
  9121. define(121, 68 /* F10 */);
  9122. define(122, 69 /* F11 */);
  9123. define(123, 70 /* F12 */);
  9124. define(124, 71 /* F13 */);
  9125. define(125, 72 /* F14 */);
  9126. define(126, 73 /* F15 */);
  9127. define(127, 74 /* F16 */);
  9128. define(128, 75 /* F17 */);
  9129. define(129, 76 /* F18 */);
  9130. define(130, 77 /* F19 */);
  9131. define(144, 78 /* NumLock */);
  9132. define(145, 79 /* ScrollLock */);
  9133. define(186, 80 /* US_SEMICOLON */);
  9134. define(187, 81 /* US_EQUAL */);
  9135. define(188, 82 /* US_COMMA */);
  9136. define(189, 83 /* US_MINUS */);
  9137. define(190, 84 /* US_DOT */);
  9138. define(191, 85 /* US_SLASH */);
  9139. define(192, 86 /* US_BACKTICK */);
  9140. define(193, 110 /* ABNT_C1 */);
  9141. define(194, 111 /* ABNT_C2 */);
  9142. define(219, 87 /* US_OPEN_SQUARE_BRACKET */);
  9143. define(220, 88 /* US_BACKSLASH */);
  9144. define(221, 89 /* US_CLOSE_SQUARE_BRACKET */);
  9145. define(222, 90 /* US_QUOTE */);
  9146. define(223, 91 /* OEM_8 */);
  9147. define(226, 92 /* OEM_102 */);
  9148. /**
  9149. * https://lists.w3.org/Archives/Public/www-dom/2010JulSep/att-0182/keyCode-spec.html
  9150. * If an Input Method Editor is processing key input and the event is keydown, return 229.
  9151. */
  9152. define(229, 109 /* KEY_IN_COMPOSITION */);
  9153. if (browser.isIE) {
  9154. define(91, 57 /* Meta */);
  9155. }
  9156. else if (browser.isFirefox) {
  9157. define(59, 80 /* US_SEMICOLON */);
  9158. define(107, 81 /* US_EQUAL */);
  9159. define(109, 83 /* US_MINUS */);
  9160. if (platform.isMacintosh) {
  9161. define(224, 57 /* Meta */);
  9162. }
  9163. }
  9164. else if (browser.isWebKit) {
  9165. define(91, 57 /* Meta */);
  9166. if (platform.isMacintosh) {
  9167. // the two meta keys in the Mac have different key codes (91 and 93)
  9168. define(93, 57 /* Meta */);
  9169. }
  9170. else {
  9171. define(92, 57 /* Meta */);
  9172. }
  9173. }
  9174. })();
  9175. function extractKeyCode(e) {
  9176. if (e.charCode) {
  9177. // "keypress" events mostly
  9178. var char = String.fromCharCode(e.charCode).toUpperCase();
  9179. return keyCodes_1.KeyCodeUtils.fromString(char);
  9180. }
  9181. return KEY_CODE_MAP[e.keyCode] || 0 /* Unknown */;
  9182. }
  9183. var ctrlKeyMod = (platform.isMacintosh ? 256 /* WinCtrl */ : 2048 /* CtrlCmd */);
  9184. var altKeyMod = 512 /* Alt */;
  9185. var shiftKeyMod = 1024 /* Shift */;
  9186. var metaKeyMod = (platform.isMacintosh ? 2048 /* CtrlCmd */ : 256 /* WinCtrl */);
  9187. var StandardKeyboardEvent = /** @class */ (function () {
  9188. function StandardKeyboardEvent(source) {
  9189. this._standardKeyboardEventBrand = true;
  9190. var e = source;
  9191. this.browserEvent = e;
  9192. this.target = e.target;
  9193. this.ctrlKey = e.ctrlKey;
  9194. this.shiftKey = e.shiftKey;
  9195. this.altKey = e.altKey;
  9196. this.metaKey = e.metaKey;
  9197. this.keyCode = extractKeyCode(e);
  9198. this.code = e.code;
  9199. // console.info(e.type + ": keyCode: " + e.keyCode + ", which: " + e.which + ", charCode: " + e.charCode + ", detail: " + e.detail + " ====> " + this.keyCode + ' -- ' + KeyCode[this.keyCode]);
  9200. this.ctrlKey = this.ctrlKey || this.keyCode === 5 /* Ctrl */;
  9201. this.altKey = this.altKey || this.keyCode === 6 /* Alt */;
  9202. this.shiftKey = this.shiftKey || this.keyCode === 4 /* Shift */;
  9203. this.metaKey = this.metaKey || this.keyCode === 57 /* Meta */;
  9204. this._asKeybinding = this._computeKeybinding();
  9205. this._asRuntimeKeybinding = this._computeRuntimeKeybinding();
  9206. // console.log(`code: ${e.code}, keyCode: ${e.keyCode}, key: ${e.key}`);
  9207. }
  9208. StandardKeyboardEvent.prototype.preventDefault = function () {
  9209. if (this.browserEvent && this.browserEvent.preventDefault) {
  9210. this.browserEvent.preventDefault();
  9211. }
  9212. };
  9213. StandardKeyboardEvent.prototype.stopPropagation = function () {
  9214. if (this.browserEvent && this.browserEvent.stopPropagation) {
  9215. this.browserEvent.stopPropagation();
  9216. }
  9217. };
  9218. StandardKeyboardEvent.prototype.toKeybinding = function () {
  9219. return this._asRuntimeKeybinding;
  9220. };
  9221. StandardKeyboardEvent.prototype.equals = function (other) {
  9222. return this._asKeybinding === other;
  9223. };
  9224. StandardKeyboardEvent.prototype._computeKeybinding = function () {
  9225. var key = 0 /* Unknown */;
  9226. if (this.keyCode !== 5 /* Ctrl */ && this.keyCode !== 4 /* Shift */ && this.keyCode !== 6 /* Alt */ && this.keyCode !== 57 /* Meta */) {
  9227. key = this.keyCode;
  9228. }
  9229. var result = 0;
  9230. if (this.ctrlKey) {
  9231. result |= ctrlKeyMod;
  9232. }
  9233. if (this.altKey) {
  9234. result |= altKeyMod;
  9235. }
  9236. if (this.shiftKey) {
  9237. result |= shiftKeyMod;
  9238. }
  9239. if (this.metaKey) {
  9240. result |= metaKeyMod;
  9241. }
  9242. result |= key;
  9243. return result;
  9244. };
  9245. StandardKeyboardEvent.prototype._computeRuntimeKeybinding = function () {
  9246. var key = 0 /* Unknown */;
  9247. if (this.keyCode !== 5 /* Ctrl */ && this.keyCode !== 4 /* Shift */ && this.keyCode !== 6 /* Alt */ && this.keyCode !== 57 /* Meta */) {
  9248. key = this.keyCode;
  9249. }
  9250. return new keyCodes_1.SimpleKeybinding(this.ctrlKey, this.shiftKey, this.altKey, this.metaKey, key);
  9251. };
  9252. return StandardKeyboardEvent;
  9253. }());
  9254. exports.StandardKeyboardEvent = StandardKeyboardEvent;
  9255. });
  9256. /*---------------------------------------------------------------------------------------------
  9257. * Copyright (c) Microsoft Corporation. All rights reserved.
  9258. * Licensed under the MIT License. See License.txt in the project root for license information.
  9259. *--------------------------------------------------------------------------------------------*/
  9260. define(__m[45/*vs/base/browser/mouseEvent*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,174/*vs/base/browser/iframe*/,16/*vs/base/common/platform*/]), function (require, exports, browser, iframe_1, platform) {
  9261. "use strict";
  9262. Object.defineProperty(exports, "__esModule", { value: true });
  9263. var StandardMouseEvent = /** @class */ (function () {
  9264. function StandardMouseEvent(e) {
  9265. this.timestamp = Date.now();
  9266. this.browserEvent = e;
  9267. this.leftButton = e.button === 0;
  9268. this.middleButton = e.button === 1;
  9269. this.rightButton = e.button === 2;
  9270. this.buttons = e.buttons;
  9271. this.target = e.target;
  9272. this.detail = e.detail || 1;
  9273. if (e.type === 'dblclick') {
  9274. this.detail = 2;
  9275. }
  9276. this.ctrlKey = e.ctrlKey;
  9277. this.shiftKey = e.shiftKey;
  9278. this.altKey = e.altKey;
  9279. this.metaKey = e.metaKey;
  9280. if (typeof e.pageX === 'number') {
  9281. this.posx = e.pageX;
  9282. this.posy = e.pageY;
  9283. }
  9284. else {
  9285. // Probably hit by MSGestureEvent
  9286. this.posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
  9287. this.posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
  9288. }
  9289. // Find the position of the iframe this code is executing in relative to the iframe where the event was captured.
  9290. var iframeOffsets = iframe_1.IframeUtils.getPositionOfChildWindowRelativeToAncestorWindow(self, e.view);
  9291. this.posx -= iframeOffsets.left;
  9292. this.posy -= iframeOffsets.top;
  9293. }
  9294. StandardMouseEvent.prototype.preventDefault = function () {
  9295. if (this.browserEvent.preventDefault) {
  9296. this.browserEvent.preventDefault();
  9297. }
  9298. };
  9299. StandardMouseEvent.prototype.stopPropagation = function () {
  9300. if (this.browserEvent.stopPropagation) {
  9301. this.browserEvent.stopPropagation();
  9302. }
  9303. };
  9304. return StandardMouseEvent;
  9305. }());
  9306. exports.StandardMouseEvent = StandardMouseEvent;
  9307. var DragMouseEvent = /** @class */ (function (_super) {
  9308. __extends(DragMouseEvent, _super);
  9309. function DragMouseEvent(e) {
  9310. var _this = _super.call(this, e) || this;
  9311. _this.dataTransfer = e.dataTransfer;
  9312. return _this;
  9313. }
  9314. return DragMouseEvent;
  9315. }(StandardMouseEvent));
  9316. exports.DragMouseEvent = DragMouseEvent;
  9317. var StandardWheelEvent = /** @class */ (function () {
  9318. function StandardWheelEvent(e, deltaX, deltaY) {
  9319. if (deltaX === void 0) { deltaX = 0; }
  9320. if (deltaY === void 0) { deltaY = 0; }
  9321. this.browserEvent = e || null;
  9322. this.target = e ? (e.target || e.targetNode || e.srcElement) : null;
  9323. this.deltaY = deltaY;
  9324. this.deltaX = deltaX;
  9325. if (e) {
  9326. // Old (deprecated) wheel events
  9327. var e1 = e;
  9328. var e2 = e;
  9329. // vertical delta scroll
  9330. if (typeof e1.wheelDeltaY !== 'undefined') {
  9331. this.deltaY = e1.wheelDeltaY / 120;
  9332. }
  9333. else if (typeof e2.VERTICAL_AXIS !== 'undefined' && e2.axis === e2.VERTICAL_AXIS) {
  9334. this.deltaY = -e2.detail / 3;
  9335. }
  9336. else if (e.type === 'wheel') {
  9337. // Modern wheel event
  9338. // https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
  9339. var ev = e;
  9340. if (ev.deltaMode === ev.DOM_DELTA_LINE) {
  9341. // the deltas are expressed in lines
  9342. this.deltaY = -e.deltaY;
  9343. }
  9344. else {
  9345. this.deltaY = -e.deltaY / 40;
  9346. }
  9347. }
  9348. // horizontal delta scroll
  9349. if (typeof e1.wheelDeltaX !== 'undefined') {
  9350. if (browser.isSafari && platform.isWindows) {
  9351. this.deltaX = -(e1.wheelDeltaX / 120);
  9352. }
  9353. else {
  9354. this.deltaX = e1.wheelDeltaX / 120;
  9355. }
  9356. }
  9357. else if (typeof e2.HORIZONTAL_AXIS !== 'undefined' && e2.axis === e2.HORIZONTAL_AXIS) {
  9358. this.deltaX = -e.detail / 3;
  9359. }
  9360. else if (e.type === 'wheel') {
  9361. // Modern wheel event
  9362. // https://developer.mozilla.org/en-US/docs/Web/API/WheelEvent
  9363. var ev = e;
  9364. if (ev.deltaMode === ev.DOM_DELTA_LINE) {
  9365. // the deltas are expressed in lines
  9366. this.deltaX = -e.deltaX;
  9367. }
  9368. else {
  9369. this.deltaX = -e.deltaX / 40;
  9370. }
  9371. }
  9372. // Assume a vertical scroll if nothing else worked
  9373. if (this.deltaY === 0 && this.deltaX === 0 && e.wheelDelta) {
  9374. this.deltaY = e.wheelDelta / 120;
  9375. }
  9376. }
  9377. }
  9378. StandardWheelEvent.prototype.preventDefault = function () {
  9379. if (this.browserEvent) {
  9380. if (this.browserEvent.preventDefault) {
  9381. this.browserEvent.preventDefault();
  9382. }
  9383. }
  9384. };
  9385. StandardWheelEvent.prototype.stopPropagation = function () {
  9386. if (this.browserEvent) {
  9387. if (this.browserEvent.stopPropagation) {
  9388. this.browserEvent.stopPropagation();
  9389. }
  9390. }
  9391. };
  9392. return StandardWheelEvent;
  9393. }());
  9394. exports.StandardWheelEvent = StandardWheelEvent;
  9395. });
  9396. /*---------------------------------------------------------------------------------------------
  9397. * Copyright (c) Microsoft Corporation. All rights reserved.
  9398. * Licensed under the MIT License. See License.txt in the project root for license information.
  9399. *--------------------------------------------------------------------------------------------*/
  9400. define(__m[245/*vs/base/common/process*/], __M([0/*require*/,1/*exports*/,16/*vs/base/common/platform*/]), function (require, exports, platform_1) {
  9401. "use strict";
  9402. Object.defineProperty(exports, "__esModule", { value: true });
  9403. var safeProcess = (typeof process === 'undefined') ? {
  9404. cwd: function () { return '/'; },
  9405. env: Object.create(null),
  9406. get platform() { return platform_1.isWindows ? 'win32' : platform_1.isMacintosh ? 'darwin' : 'linux'; },
  9407. nextTick: function (callback) { return platform_1.setImmediate(callback); }
  9408. } : process;
  9409. exports.cwd = safeProcess.cwd;
  9410. exports.env = safeProcess.env;
  9411. exports.platform = safeProcess.platform;
  9412. });
  9413. /*---------------------------------------------------------------------------------------------
  9414. * Copyright (c) Microsoft Corporation. All rights reserved.
  9415. * Licensed under the MIT License. See License.txt in the project root for license information.
  9416. *--------------------------------------------------------------------------------------------*/
  9417. define(__m[77/*vs/base/common/path*/], __M([0/*require*/,1/*exports*/,245/*vs/base/common/process*/]), function (require, exports, process) {
  9418. "use strict";
  9419. Object.defineProperty(exports, "__esModule", { value: true });
  9420. var CHAR_UPPERCASE_A = 65; /* A */
  9421. var CHAR_LOWERCASE_A = 97; /* a */
  9422. var CHAR_UPPERCASE_Z = 90; /* Z */
  9423. var CHAR_LOWERCASE_Z = 122; /* z */
  9424. var CHAR_DOT = 46; /* . */
  9425. var CHAR_FORWARD_SLASH = 47; /* / */
  9426. var CHAR_BACKWARD_SLASH = 92; /* \ */
  9427. var CHAR_COLON = 58; /* : */
  9428. var CHAR_QUESTION_MARK = 63; /* ? */
  9429. var ErrorInvalidArgType = /** @class */ (function (_super) {
  9430. __extends(ErrorInvalidArgType, _super);
  9431. function ErrorInvalidArgType(name, expected, actual) {
  9432. var _this = this;
  9433. // determiner: 'must be' or 'must not be'
  9434. var determiner;
  9435. if (typeof expected === 'string' && expected.indexOf('not ') === 0) {
  9436. determiner = 'must not be';
  9437. expected = expected.replace(/^not /, '');
  9438. }
  9439. else {
  9440. determiner = 'must be';
  9441. }
  9442. var type = name.indexOf('.') !== -1 ? 'property' : 'argument';
  9443. var msg = "The \"" + name + "\" " + type + " " + determiner + " of type " + expected;
  9444. msg += ". Received type " + typeof actual;
  9445. _this = _super.call(this, msg) || this;
  9446. _this.code = 'ERR_INVALID_ARG_TYPE';
  9447. return _this;
  9448. }
  9449. return ErrorInvalidArgType;
  9450. }(Error));
  9451. function validateString(value, name) {
  9452. if (typeof value !== 'string') {
  9453. throw new ErrorInvalidArgType(name, 'string', value);
  9454. }
  9455. }
  9456. function isPathSeparator(code) {
  9457. return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
  9458. }
  9459. function isPosixPathSeparator(code) {
  9460. return code === CHAR_FORWARD_SLASH;
  9461. }
  9462. function isWindowsDeviceRoot(code) {
  9463. return code >= CHAR_UPPERCASE_A && code <= CHAR_UPPERCASE_Z ||
  9464. code >= CHAR_LOWERCASE_A && code <= CHAR_LOWERCASE_Z;
  9465. }
  9466. // Resolves . and .. elements in a path with directory names
  9467. function normalizeString(path, allowAboveRoot, separator, isPathSeparator) {
  9468. var res = '';
  9469. var lastSegmentLength = 0;
  9470. var lastSlash = -1;
  9471. var dots = 0;
  9472. var code;
  9473. for (var i = 0; i <= path.length; ++i) {
  9474. if (i < path.length) {
  9475. code = path.charCodeAt(i);
  9476. }
  9477. else if (isPathSeparator(code)) {
  9478. break;
  9479. }
  9480. else {
  9481. code = CHAR_FORWARD_SLASH;
  9482. }
  9483. if (isPathSeparator(code)) {
  9484. if (lastSlash === i - 1 || dots === 1) {
  9485. // NOOP
  9486. }
  9487. else if (lastSlash !== i - 1 && dots === 2) {
  9488. if (res.length < 2 || lastSegmentLength !== 2 ||
  9489. res.charCodeAt(res.length - 1) !== CHAR_DOT ||
  9490. res.charCodeAt(res.length - 2) !== CHAR_DOT) {
  9491. if (res.length > 2) {
  9492. var lastSlashIndex = res.lastIndexOf(separator);
  9493. if (lastSlashIndex === -1) {
  9494. res = '';
  9495. lastSegmentLength = 0;
  9496. }
  9497. else {
  9498. res = res.slice(0, lastSlashIndex);
  9499. lastSegmentLength = res.length - 1 - res.lastIndexOf(separator);
  9500. }
  9501. lastSlash = i;
  9502. dots = 0;
  9503. continue;
  9504. }
  9505. else if (res.length === 2 || res.length === 1) {
  9506. res = '';
  9507. lastSegmentLength = 0;
  9508. lastSlash = i;
  9509. dots = 0;
  9510. continue;
  9511. }
  9512. }
  9513. if (allowAboveRoot) {
  9514. if (res.length > 0) {
  9515. res += separator + "..";
  9516. }
  9517. else {
  9518. res = '..';
  9519. }
  9520. lastSegmentLength = 2;
  9521. }
  9522. }
  9523. else {
  9524. if (res.length > 0) {
  9525. res += separator + path.slice(lastSlash + 1, i);
  9526. }
  9527. else {
  9528. res = path.slice(lastSlash + 1, i);
  9529. }
  9530. lastSegmentLength = i - lastSlash - 1;
  9531. }
  9532. lastSlash = i;
  9533. dots = 0;
  9534. }
  9535. else if (code === CHAR_DOT && dots !== -1) {
  9536. ++dots;
  9537. }
  9538. else {
  9539. dots = -1;
  9540. }
  9541. }
  9542. return res;
  9543. }
  9544. function _format(sep, pathObject) {
  9545. var dir = pathObject.dir || pathObject.root;
  9546. var base = pathObject.base ||
  9547. ((pathObject.name || '') + (pathObject.ext || ''));
  9548. if (!dir) {
  9549. return base;
  9550. }
  9551. if (dir === pathObject.root) {
  9552. return dir + base;
  9553. }
  9554. return dir + sep + base;
  9555. }
  9556. exports.win32 = {
  9557. // path.resolve([from ...], to)
  9558. resolve: function () {
  9559. var pathSegments = [];
  9560. for (var _i = 0; _i < arguments.length; _i++) {
  9561. pathSegments[_i] = arguments[_i];
  9562. }
  9563. var resolvedDevice = '';
  9564. var resolvedTail = '';
  9565. var resolvedAbsolute = false;
  9566. for (var i = pathSegments.length - 1; i >= -1; i--) {
  9567. var path = void 0;
  9568. if (i >= 0) {
  9569. path = pathSegments[i];
  9570. }
  9571. else if (!resolvedDevice) {
  9572. path = process.cwd();
  9573. }
  9574. else {
  9575. // Windows has the concept of drive-specific current working
  9576. // directories. If we've resolved a drive letter but not yet an
  9577. // absolute path, get cwd for that drive, or the process cwd if
  9578. // the drive cwd is not available. We're sure the device is not
  9579. // a UNC path at this points, because UNC paths are always absolute.
  9580. path = process.env['=' + resolvedDevice] || process.cwd();
  9581. // Verify that a cwd was found and that it actually points
  9582. // to our drive. If not, default to the drive's root.
  9583. if (path === undefined ||
  9584. path.slice(0, 3).toLowerCase() !==
  9585. resolvedDevice.toLowerCase() + '\\') {
  9586. path = resolvedDevice + '\\';
  9587. }
  9588. }
  9589. validateString(path, 'path');
  9590. // Skip empty entries
  9591. if (path.length === 0) {
  9592. continue;
  9593. }
  9594. var len = path.length;
  9595. var rootEnd = 0;
  9596. var device = '';
  9597. var isAbsolute = false;
  9598. var code = path.charCodeAt(0);
  9599. // Try to match a root
  9600. if (len > 1) {
  9601. if (isPathSeparator(code)) {
  9602. // Possible UNC root
  9603. // If we started with a separator, we know we at least have an
  9604. // absolute path of some kind (UNC or otherwise)
  9605. isAbsolute = true;
  9606. if (isPathSeparator(path.charCodeAt(1))) {
  9607. // Matched double path separator at beginning
  9608. var j = 2;
  9609. var last = j;
  9610. // Match 1 or more non-path separators
  9611. for (; j < len; ++j) {
  9612. if (isPathSeparator(path.charCodeAt(j))) {
  9613. break;
  9614. }
  9615. }
  9616. if (j < len && j !== last) {
  9617. var firstPart = path.slice(last, j);
  9618. // Matched!
  9619. last = j;
  9620. // Match 1 or more path separators
  9621. for (; j < len; ++j) {
  9622. if (!isPathSeparator(path.charCodeAt(j))) {
  9623. break;
  9624. }
  9625. }
  9626. if (j < len && j !== last) {
  9627. // Matched!
  9628. last = j;
  9629. // Match 1 or more non-path separators
  9630. for (; j < len; ++j) {
  9631. if (isPathSeparator(path.charCodeAt(j))) {
  9632. break;
  9633. }
  9634. }
  9635. if (j === len) {
  9636. // We matched a UNC root only
  9637. device = '\\\\' + firstPart + '\\' + path.slice(last);
  9638. rootEnd = j;
  9639. }
  9640. else if (j !== last) {
  9641. // We matched a UNC root with leftovers
  9642. device = '\\\\' + firstPart + '\\' + path.slice(last, j);
  9643. rootEnd = j;
  9644. }
  9645. }
  9646. }
  9647. }
  9648. else {
  9649. rootEnd = 1;
  9650. }
  9651. }
  9652. else if (isWindowsDeviceRoot(code)) {
  9653. // Possible device root
  9654. if (path.charCodeAt(1) === CHAR_COLON) {
  9655. device = path.slice(0, 2);
  9656. rootEnd = 2;
  9657. if (len > 2) {
  9658. if (isPathSeparator(path.charCodeAt(2))) {
  9659. // Treat separator following drive name as an absolute path
  9660. // indicator
  9661. isAbsolute = true;
  9662. rootEnd = 3;
  9663. }
  9664. }
  9665. }
  9666. }
  9667. }
  9668. else if (isPathSeparator(code)) {
  9669. // `path` contains just a path separator
  9670. rootEnd = 1;
  9671. isAbsolute = true;
  9672. }
  9673. if (device.length > 0 &&
  9674. resolvedDevice.length > 0 &&
  9675. device.toLowerCase() !== resolvedDevice.toLowerCase()) {
  9676. // This path points to another device so it is not applicable
  9677. continue;
  9678. }
  9679. if (resolvedDevice.length === 0 && device.length > 0) {
  9680. resolvedDevice = device;
  9681. }
  9682. if (!resolvedAbsolute) {
  9683. resolvedTail = path.slice(rootEnd) + '\\' + resolvedTail;
  9684. resolvedAbsolute = isAbsolute;
  9685. }
  9686. if (resolvedDevice.length > 0 && resolvedAbsolute) {
  9687. break;
  9688. }
  9689. }
  9690. // At this point the path should be resolved to a full absolute path,
  9691. // but handle relative paths to be safe (might happen when process.cwd()
  9692. // fails)
  9693. // Normalize the tail path
  9694. resolvedTail = normalizeString(resolvedTail, !resolvedAbsolute, '\\', isPathSeparator);
  9695. return (resolvedDevice + (resolvedAbsolute ? '\\' : '') + resolvedTail) ||
  9696. '.';
  9697. },
  9698. normalize: function (path) {
  9699. validateString(path, 'path');
  9700. var len = path.length;
  9701. if (len === 0) {
  9702. return '.';
  9703. }
  9704. var rootEnd = 0;
  9705. var device;
  9706. var isAbsolute = false;
  9707. var code = path.charCodeAt(0);
  9708. // Try to match a root
  9709. if (len > 1) {
  9710. if (isPathSeparator(code)) {
  9711. // Possible UNC root
  9712. // If we started with a separator, we know we at least have an absolute
  9713. // path of some kind (UNC or otherwise)
  9714. isAbsolute = true;
  9715. if (isPathSeparator(path.charCodeAt(1))) {
  9716. // Matched double path separator at beginning
  9717. var j = 2;
  9718. var last = j;
  9719. // Match 1 or more non-path separators
  9720. for (; j < len; ++j) {
  9721. if (isPathSeparator(path.charCodeAt(j))) {
  9722. break;
  9723. }
  9724. }
  9725. if (j < len && j !== last) {
  9726. var firstPart = path.slice(last, j);
  9727. // Matched!
  9728. last = j;
  9729. // Match 1 or more path separators
  9730. for (; j < len; ++j) {
  9731. if (!isPathSeparator(path.charCodeAt(j))) {
  9732. break;
  9733. }
  9734. }
  9735. if (j < len && j !== last) {
  9736. // Matched!
  9737. last = j;
  9738. // Match 1 or more non-path separators
  9739. for (; j < len; ++j) {
  9740. if (isPathSeparator(path.charCodeAt(j))) {
  9741. break;
  9742. }
  9743. }
  9744. if (j === len) {
  9745. // We matched a UNC root only
  9746. // Return the normalized version of the UNC root since there
  9747. // is nothing left to process
  9748. return '\\\\' + firstPart + '\\' + path.slice(last) + '\\';
  9749. }
  9750. else if (j !== last) {
  9751. // We matched a UNC root with leftovers
  9752. device = '\\\\' + firstPart + '\\' + path.slice(last, j);
  9753. rootEnd = j;
  9754. }
  9755. }
  9756. }
  9757. }
  9758. else {
  9759. rootEnd = 1;
  9760. }
  9761. }
  9762. else if (isWindowsDeviceRoot(code)) {
  9763. // Possible device root
  9764. if (path.charCodeAt(1) === CHAR_COLON) {
  9765. device = path.slice(0, 2);
  9766. rootEnd = 2;
  9767. if (len > 2) {
  9768. if (isPathSeparator(path.charCodeAt(2))) {
  9769. // Treat separator following drive name as an absolute path
  9770. // indicator
  9771. isAbsolute = true;
  9772. rootEnd = 3;
  9773. }
  9774. }
  9775. }
  9776. }
  9777. }
  9778. else if (isPathSeparator(code)) {
  9779. // `path` contains just a path separator, exit early to avoid unnecessary
  9780. // work
  9781. return '\\';
  9782. }
  9783. var tail;
  9784. if (rootEnd < len) {
  9785. tail = normalizeString(path.slice(rootEnd), !isAbsolute, '\\', isPathSeparator);
  9786. }
  9787. else {
  9788. tail = '';
  9789. }
  9790. if (tail.length === 0 && !isAbsolute) {
  9791. tail = '.';
  9792. }
  9793. if (tail.length > 0 && isPathSeparator(path.charCodeAt(len - 1))) {
  9794. tail += '\\';
  9795. }
  9796. if (device === undefined) {
  9797. if (isAbsolute) {
  9798. if (tail.length > 0) {
  9799. return '\\' + tail;
  9800. }
  9801. else {
  9802. return '\\';
  9803. }
  9804. }
  9805. else if (tail.length > 0) {
  9806. return tail;
  9807. }
  9808. else {
  9809. return '';
  9810. }
  9811. }
  9812. else if (isAbsolute) {
  9813. if (tail.length > 0) {
  9814. return device + '\\' + tail;
  9815. }
  9816. else {
  9817. return device + '\\';
  9818. }
  9819. }
  9820. else if (tail.length > 0) {
  9821. return device + tail;
  9822. }
  9823. else {
  9824. return device;
  9825. }
  9826. },
  9827. isAbsolute: function (path) {
  9828. validateString(path, 'path');
  9829. var len = path.length;
  9830. if (len === 0) {
  9831. return false;
  9832. }
  9833. var code = path.charCodeAt(0);
  9834. if (isPathSeparator(code)) {
  9835. return true;
  9836. }
  9837. else if (isWindowsDeviceRoot(code)) {
  9838. // Possible device root
  9839. if (len > 2 && path.charCodeAt(1) === CHAR_COLON) {
  9840. if (isPathSeparator(path.charCodeAt(2))) {
  9841. return true;
  9842. }
  9843. }
  9844. }
  9845. return false;
  9846. },
  9847. join: function () {
  9848. var paths = [];
  9849. for (var _i = 0; _i < arguments.length; _i++) {
  9850. paths[_i] = arguments[_i];
  9851. }
  9852. if (paths.length === 0) {
  9853. return '.';
  9854. }
  9855. var joined;
  9856. var firstPart;
  9857. for (var i = 0; i < paths.length; ++i) {
  9858. var arg = paths[i];
  9859. validateString(arg, 'path');
  9860. if (arg.length > 0) {
  9861. if (joined === undefined) {
  9862. joined = firstPart = arg;
  9863. }
  9864. else {
  9865. joined += '\\' + arg;
  9866. }
  9867. }
  9868. }
  9869. if (joined === undefined) {
  9870. return '.';
  9871. }
  9872. // Make sure that the joined path doesn't start with two slashes, because
  9873. // normalize() will mistake it for an UNC path then.
  9874. //
  9875. // This step is skipped when it is very clear that the user actually
  9876. // intended to point at an UNC path. This is assumed when the first
  9877. // non-empty string arguments starts with exactly two slashes followed by
  9878. // at least one more non-slash character.
  9879. //
  9880. // Note that for normalize() to treat a path as an UNC path it needs to
  9881. // have at least 2 components, so we don't filter for that here.
  9882. // This means that the user can use join to construct UNC paths from
  9883. // a server name and a share name; for example:
  9884. // path.join('//server', 'share') -> '\\\\server\\share\\')
  9885. var needsReplace = true;
  9886. var slashCount = 0;
  9887. if (typeof firstPart === 'string' && isPathSeparator(firstPart.charCodeAt(0))) {
  9888. ++slashCount;
  9889. var firstLen = firstPart.length;
  9890. if (firstLen > 1) {
  9891. if (isPathSeparator(firstPart.charCodeAt(1))) {
  9892. ++slashCount;
  9893. if (firstLen > 2) {
  9894. if (isPathSeparator(firstPart.charCodeAt(2))) {
  9895. ++slashCount;
  9896. }
  9897. else {
  9898. // We matched a UNC path in the first part
  9899. needsReplace = false;
  9900. }
  9901. }
  9902. }
  9903. }
  9904. }
  9905. if (needsReplace) {
  9906. // Find any more consecutive slashes we need to replace
  9907. for (; slashCount < joined.length; ++slashCount) {
  9908. if (!isPathSeparator(joined.charCodeAt(slashCount))) {
  9909. break;
  9910. }
  9911. }
  9912. // Replace the slashes if needed
  9913. if (slashCount >= 2) {
  9914. joined = '\\' + joined.slice(slashCount);
  9915. }
  9916. }
  9917. return exports.win32.normalize(joined);
  9918. },
  9919. // It will solve the relative path from `from` to `to`, for instance:
  9920. // from = 'C:\\orandea\\test\\aaa'
  9921. // to = 'C:\\orandea\\impl\\bbb'
  9922. // The output of the function should be: '..\\..\\impl\\bbb'
  9923. relative: function (from, to) {
  9924. validateString(from, 'from');
  9925. validateString(to, 'to');
  9926. if (from === to) {
  9927. return '';
  9928. }
  9929. var fromOrig = exports.win32.resolve(from);
  9930. var toOrig = exports.win32.resolve(to);
  9931. if (fromOrig === toOrig) {
  9932. return '';
  9933. }
  9934. from = fromOrig.toLowerCase();
  9935. to = toOrig.toLowerCase();
  9936. if (from === to) {
  9937. return '';
  9938. }
  9939. // Trim any leading backslashes
  9940. var fromStart = 0;
  9941. for (; fromStart < from.length; ++fromStart) {
  9942. if (from.charCodeAt(fromStart) !== CHAR_BACKWARD_SLASH) {
  9943. break;
  9944. }
  9945. }
  9946. // Trim trailing backslashes (applicable to UNC paths only)
  9947. var fromEnd = from.length;
  9948. for (; fromEnd - 1 > fromStart; --fromEnd) {
  9949. if (from.charCodeAt(fromEnd - 1) !== CHAR_BACKWARD_SLASH) {
  9950. break;
  9951. }
  9952. }
  9953. var fromLen = (fromEnd - fromStart);
  9954. // Trim any leading backslashes
  9955. var toStart = 0;
  9956. for (; toStart < to.length; ++toStart) {
  9957. if (to.charCodeAt(toStart) !== CHAR_BACKWARD_SLASH) {
  9958. break;
  9959. }
  9960. }
  9961. // Trim trailing backslashes (applicable to UNC paths only)
  9962. var toEnd = to.length;
  9963. for (; toEnd - 1 > toStart; --toEnd) {
  9964. if (to.charCodeAt(toEnd - 1) !== CHAR_BACKWARD_SLASH) {
  9965. break;
  9966. }
  9967. }
  9968. var toLen = (toEnd - toStart);
  9969. // Compare paths to find the longest common path from root
  9970. var length = (fromLen < toLen ? fromLen : toLen);
  9971. var lastCommonSep = -1;
  9972. var i = 0;
  9973. for (; i <= length; ++i) {
  9974. if (i === length) {
  9975. if (toLen > length) {
  9976. if (to.charCodeAt(toStart + i) === CHAR_BACKWARD_SLASH) {
  9977. // We get here if `from` is the exact base path for `to`.
  9978. // For example: from='C:\\foo\\bar'; to='C:\\foo\\bar\\baz'
  9979. return toOrig.slice(toStart + i + 1);
  9980. }
  9981. else if (i === 2) {
  9982. // We get here if `from` is the device root.
  9983. // For example: from='C:\\'; to='C:\\foo'
  9984. return toOrig.slice(toStart + i);
  9985. }
  9986. }
  9987. if (fromLen > length) {
  9988. if (from.charCodeAt(fromStart + i) === CHAR_BACKWARD_SLASH) {
  9989. // We get here if `to` is the exact base path for `from`.
  9990. // For example: from='C:\\foo\\bar'; to='C:\\foo'
  9991. lastCommonSep = i;
  9992. }
  9993. else if (i === 2) {
  9994. // We get here if `to` is the device root.
  9995. // For example: from='C:\\foo\\bar'; to='C:\\'
  9996. lastCommonSep = 3;
  9997. }
  9998. }
  9999. break;
  10000. }
  10001. var fromCode = from.charCodeAt(fromStart + i);
  10002. var toCode = to.charCodeAt(toStart + i);
  10003. if (fromCode !== toCode) {
  10004. break;
  10005. }
  10006. else if (fromCode === CHAR_BACKWARD_SLASH) {
  10007. lastCommonSep = i;
  10008. }
  10009. }
  10010. // We found a mismatch before the first common path separator was seen, so
  10011. // return the original `to`.
  10012. if (i !== length && lastCommonSep === -1) {
  10013. return toOrig;
  10014. }
  10015. var out = '';
  10016. if (lastCommonSep === -1) {
  10017. lastCommonSep = 0;
  10018. }
  10019. // Generate the relative path based on the path difference between `to` and
  10020. // `from`
  10021. for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
  10022. if (i === fromEnd || from.charCodeAt(i) === CHAR_BACKWARD_SLASH) {
  10023. if (out.length === 0) {
  10024. out += '..';
  10025. }
  10026. else {
  10027. out += '\\..';
  10028. }
  10029. }
  10030. }
  10031. // Lastly, append the rest of the destination (`to`) path that comes after
  10032. // the common path parts
  10033. if (out.length > 0) {
  10034. return out + toOrig.slice(toStart + lastCommonSep, toEnd);
  10035. }
  10036. else {
  10037. toStart += lastCommonSep;
  10038. if (toOrig.charCodeAt(toStart) === CHAR_BACKWARD_SLASH) {
  10039. ++toStart;
  10040. }
  10041. return toOrig.slice(toStart, toEnd);
  10042. }
  10043. },
  10044. toNamespacedPath: function (path) {
  10045. // Note: this will *probably* throw somewhere.
  10046. if (typeof path !== 'string') {
  10047. return path;
  10048. }
  10049. if (path.length === 0) {
  10050. return '';
  10051. }
  10052. var resolvedPath = exports.win32.resolve(path);
  10053. if (resolvedPath.length >= 3) {
  10054. if (resolvedPath.charCodeAt(0) === CHAR_BACKWARD_SLASH) {
  10055. // Possible UNC root
  10056. if (resolvedPath.charCodeAt(1) === CHAR_BACKWARD_SLASH) {
  10057. var code = resolvedPath.charCodeAt(2);
  10058. if (code !== CHAR_QUESTION_MARK && code !== CHAR_DOT) {
  10059. // Matched non-long UNC root, convert the path to a long UNC path
  10060. return '\\\\?\\UNC\\' + resolvedPath.slice(2);
  10061. }
  10062. }
  10063. }
  10064. else if (isWindowsDeviceRoot(resolvedPath.charCodeAt(0))) {
  10065. // Possible device root
  10066. if (resolvedPath.charCodeAt(1) === CHAR_COLON &&
  10067. resolvedPath.charCodeAt(2) === CHAR_BACKWARD_SLASH) {
  10068. // Matched device root, convert the path to a long UNC path
  10069. return '\\\\?\\' + resolvedPath;
  10070. }
  10071. }
  10072. }
  10073. return path;
  10074. },
  10075. dirname: function (path) {
  10076. validateString(path, 'path');
  10077. var len = path.length;
  10078. if (len === 0) {
  10079. return '.';
  10080. }
  10081. var rootEnd = -1;
  10082. var end = -1;
  10083. var matchedSlash = true;
  10084. var offset = 0;
  10085. var code = path.charCodeAt(0);
  10086. // Try to match a root
  10087. if (len > 1) {
  10088. if (isPathSeparator(code)) {
  10089. // Possible UNC root
  10090. rootEnd = offset = 1;
  10091. if (isPathSeparator(path.charCodeAt(1))) {
  10092. // Matched double path separator at beginning
  10093. var j = 2;
  10094. var last = j;
  10095. // Match 1 or more non-path separators
  10096. for (; j < len; ++j) {
  10097. if (isPathSeparator(path.charCodeAt(j))) {
  10098. break;
  10099. }
  10100. }
  10101. if (j < len && j !== last) {
  10102. // Matched!
  10103. last = j;
  10104. // Match 1 or more path separators
  10105. for (; j < len; ++j) {
  10106. if (!isPathSeparator(path.charCodeAt(j))) {
  10107. break;
  10108. }
  10109. }
  10110. if (j < len && j !== last) {
  10111. // Matched!
  10112. last = j;
  10113. // Match 1 or more non-path separators
  10114. for (; j < len; ++j) {
  10115. if (isPathSeparator(path.charCodeAt(j))) {
  10116. break;
  10117. }
  10118. }
  10119. if (j === len) {
  10120. // We matched a UNC root only
  10121. return path;
  10122. }
  10123. if (j !== last) {
  10124. // We matched a UNC root with leftovers
  10125. // Offset by 1 to include the separator after the UNC root to
  10126. // treat it as a "normal root" on top of a (UNC) root
  10127. rootEnd = offset = j + 1;
  10128. }
  10129. }
  10130. }
  10131. }
  10132. }
  10133. else if (isWindowsDeviceRoot(code)) {
  10134. // Possible device root
  10135. if (path.charCodeAt(1) === CHAR_COLON) {
  10136. rootEnd = offset = 2;
  10137. if (len > 2) {
  10138. if (isPathSeparator(path.charCodeAt(2))) {
  10139. rootEnd = offset = 3;
  10140. }
  10141. }
  10142. }
  10143. }
  10144. }
  10145. else if (isPathSeparator(code)) {
  10146. // `path` contains just a path separator, exit early to avoid
  10147. // unnecessary work
  10148. return path;
  10149. }
  10150. for (var i = len - 1; i >= offset; --i) {
  10151. if (isPathSeparator(path.charCodeAt(i))) {
  10152. if (!matchedSlash) {
  10153. end = i;
  10154. break;
  10155. }
  10156. }
  10157. else {
  10158. // We saw the first non-path separator
  10159. matchedSlash = false;
  10160. }
  10161. }
  10162. if (end === -1) {
  10163. if (rootEnd === -1) {
  10164. return '.';
  10165. }
  10166. else {
  10167. end = rootEnd;
  10168. }
  10169. }
  10170. return path.slice(0, end);
  10171. },
  10172. basename: function (path, ext) {
  10173. if (ext !== undefined) {
  10174. validateString(ext, 'ext');
  10175. }
  10176. validateString(path, 'path');
  10177. var start = 0;
  10178. var end = -1;
  10179. var matchedSlash = true;
  10180. var i;
  10181. // Check for a drive letter prefix so as not to mistake the following
  10182. // path separator as an extra separator at the end of the path that can be
  10183. // disregarded
  10184. if (path.length >= 2) {
  10185. var drive = path.charCodeAt(0);
  10186. if (isWindowsDeviceRoot(drive)) {
  10187. if (path.charCodeAt(1) === CHAR_COLON) {
  10188. start = 2;
  10189. }
  10190. }
  10191. }
  10192. if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
  10193. if (ext.length === path.length && ext === path) {
  10194. return '';
  10195. }
  10196. var extIdx = ext.length - 1;
  10197. var firstNonSlashEnd = -1;
  10198. for (i = path.length - 1; i >= start; --i) {
  10199. var code = path.charCodeAt(i);
  10200. if (isPathSeparator(code)) {
  10201. // If we reached a path separator that was not part of a set of path
  10202. // separators at the end of the string, stop now
  10203. if (!matchedSlash) {
  10204. start = i + 1;
  10205. break;
  10206. }
  10207. }
  10208. else {
  10209. if (firstNonSlashEnd === -1) {
  10210. // We saw the first non-path separator, remember this index in case
  10211. // we need it if the extension ends up not matching
  10212. matchedSlash = false;
  10213. firstNonSlashEnd = i + 1;
  10214. }
  10215. if (extIdx >= 0) {
  10216. // Try to match the explicit extension
  10217. if (code === ext.charCodeAt(extIdx)) {
  10218. if (--extIdx === -1) {
  10219. // We matched the extension, so mark this as the end of our path
  10220. // component
  10221. end = i;
  10222. }
  10223. }
  10224. else {
  10225. // Extension does not match, so our result is the entire path
  10226. // component
  10227. extIdx = -1;
  10228. end = firstNonSlashEnd;
  10229. }
  10230. }
  10231. }
  10232. }
  10233. if (start === end) {
  10234. end = firstNonSlashEnd;
  10235. }
  10236. else if (end === -1) {
  10237. end = path.length;
  10238. }
  10239. return path.slice(start, end);
  10240. }
  10241. else {
  10242. for (i = path.length - 1; i >= start; --i) {
  10243. if (isPathSeparator(path.charCodeAt(i))) {
  10244. // If we reached a path separator that was not part of a set of path
  10245. // separators at the end of the string, stop now
  10246. if (!matchedSlash) {
  10247. start = i + 1;
  10248. break;
  10249. }
  10250. }
  10251. else if (end === -1) {
  10252. // We saw the first non-path separator, mark this as the end of our
  10253. // path component
  10254. matchedSlash = false;
  10255. end = i + 1;
  10256. }
  10257. }
  10258. if (end === -1) {
  10259. return '';
  10260. }
  10261. return path.slice(start, end);
  10262. }
  10263. },
  10264. extname: function (path) {
  10265. validateString(path, 'path');
  10266. var start = 0;
  10267. var startDot = -1;
  10268. var startPart = 0;
  10269. var end = -1;
  10270. var matchedSlash = true;
  10271. // Track the state of characters (if any) we see before our first dot and
  10272. // after any path separator we find
  10273. var preDotState = 0;
  10274. // Check for a drive letter prefix so as not to mistake the following
  10275. // path separator as an extra separator at the end of the path that can be
  10276. // disregarded
  10277. if (path.length >= 2 &&
  10278. path.charCodeAt(1) === CHAR_COLON &&
  10279. isWindowsDeviceRoot(path.charCodeAt(0))) {
  10280. start = startPart = 2;
  10281. }
  10282. for (var i = path.length - 1; i >= start; --i) {
  10283. var code = path.charCodeAt(i);
  10284. if (isPathSeparator(code)) {
  10285. // If we reached a path separator that was not part of a set of path
  10286. // separators at the end of the string, stop now
  10287. if (!matchedSlash) {
  10288. startPart = i + 1;
  10289. break;
  10290. }
  10291. continue;
  10292. }
  10293. if (end === -1) {
  10294. // We saw the first non-path separator, mark this as the end of our
  10295. // extension
  10296. matchedSlash = false;
  10297. end = i + 1;
  10298. }
  10299. if (code === CHAR_DOT) {
  10300. // If this is our first dot, mark it as the start of our extension
  10301. if (startDot === -1) {
  10302. startDot = i;
  10303. }
  10304. else if (preDotState !== 1) {
  10305. preDotState = 1;
  10306. }
  10307. }
  10308. else if (startDot !== -1) {
  10309. // We saw a non-dot and non-path separator before our dot, so we should
  10310. // have a good chance at having a non-empty extension
  10311. preDotState = -1;
  10312. }
  10313. }
  10314. if (startDot === -1 ||
  10315. end === -1 ||
  10316. // We saw a non-dot character immediately before the dot
  10317. preDotState === 0 ||
  10318. // The (right-most) trimmed path component is exactly '..'
  10319. (preDotState === 1 &&
  10320. startDot === end - 1 &&
  10321. startDot === startPart + 1)) {
  10322. return '';
  10323. }
  10324. return path.slice(startDot, end);
  10325. },
  10326. format: function (pathObject) {
  10327. if (pathObject === null || typeof pathObject !== 'object') {
  10328. throw new ErrorInvalidArgType('pathObject', 'Object', pathObject);
  10329. }
  10330. return _format('\\', pathObject);
  10331. },
  10332. parse: function (path) {
  10333. validateString(path, 'path');
  10334. var ret = { root: '', dir: '', base: '', ext: '', name: '' };
  10335. if (path.length === 0) {
  10336. return ret;
  10337. }
  10338. var len = path.length;
  10339. var rootEnd = 0;
  10340. var code = path.charCodeAt(0);
  10341. // Try to match a root
  10342. if (len > 1) {
  10343. if (isPathSeparator(code)) {
  10344. // Possible UNC root
  10345. rootEnd = 1;
  10346. if (isPathSeparator(path.charCodeAt(1))) {
  10347. // Matched double path separator at beginning
  10348. var j = 2;
  10349. var last = j;
  10350. // Match 1 or more non-path separators
  10351. for (; j < len; ++j) {
  10352. if (isPathSeparator(path.charCodeAt(j))) {
  10353. break;
  10354. }
  10355. }
  10356. if (j < len && j !== last) {
  10357. // Matched!
  10358. last = j;
  10359. // Match 1 or more path separators
  10360. for (; j < len; ++j) {
  10361. if (!isPathSeparator(path.charCodeAt(j))) {
  10362. break;
  10363. }
  10364. }
  10365. if (j < len && j !== last) {
  10366. // Matched!
  10367. last = j;
  10368. // Match 1 or more non-path separators
  10369. for (; j < len; ++j) {
  10370. if (isPathSeparator(path.charCodeAt(j))) {
  10371. break;
  10372. }
  10373. }
  10374. if (j === len) {
  10375. // We matched a UNC root only
  10376. rootEnd = j;
  10377. }
  10378. else if (j !== last) {
  10379. // We matched a UNC root with leftovers
  10380. rootEnd = j + 1;
  10381. }
  10382. }
  10383. }
  10384. }
  10385. }
  10386. else if (isWindowsDeviceRoot(code)) {
  10387. // Possible device root
  10388. if (path.charCodeAt(1) === CHAR_COLON) {
  10389. rootEnd = 2;
  10390. if (len > 2) {
  10391. if (isPathSeparator(path.charCodeAt(2))) {
  10392. if (len === 3) {
  10393. // `path` contains just a drive root, exit early to avoid
  10394. // unnecessary work
  10395. ret.root = ret.dir = path;
  10396. return ret;
  10397. }
  10398. rootEnd = 3;
  10399. }
  10400. }
  10401. else {
  10402. // `path` contains just a drive root, exit early to avoid
  10403. // unnecessary work
  10404. ret.root = ret.dir = path;
  10405. return ret;
  10406. }
  10407. }
  10408. }
  10409. }
  10410. else if (isPathSeparator(code)) {
  10411. // `path` contains just a path separator, exit early to avoid
  10412. // unnecessary work
  10413. ret.root = ret.dir = path;
  10414. return ret;
  10415. }
  10416. if (rootEnd > 0) {
  10417. ret.root = path.slice(0, rootEnd);
  10418. }
  10419. var startDot = -1;
  10420. var startPart = rootEnd;
  10421. var end = -1;
  10422. var matchedSlash = true;
  10423. var i = path.length - 1;
  10424. // Track the state of characters (if any) we see before our first dot and
  10425. // after any path separator we find
  10426. var preDotState = 0;
  10427. // Get non-dir info
  10428. for (; i >= rootEnd; --i) {
  10429. code = path.charCodeAt(i);
  10430. if (isPathSeparator(code)) {
  10431. // If we reached a path separator that was not part of a set of path
  10432. // separators at the end of the string, stop now
  10433. if (!matchedSlash) {
  10434. startPart = i + 1;
  10435. break;
  10436. }
  10437. continue;
  10438. }
  10439. if (end === -1) {
  10440. // We saw the first non-path separator, mark this as the end of our
  10441. // extension
  10442. matchedSlash = false;
  10443. end = i + 1;
  10444. }
  10445. if (code === CHAR_DOT) {
  10446. // If this is our first dot, mark it as the start of our extension
  10447. if (startDot === -1) {
  10448. startDot = i;
  10449. }
  10450. else if (preDotState !== 1) {
  10451. preDotState = 1;
  10452. }
  10453. }
  10454. else if (startDot !== -1) {
  10455. // We saw a non-dot and non-path separator before our dot, so we should
  10456. // have a good chance at having a non-empty extension
  10457. preDotState = -1;
  10458. }
  10459. }
  10460. if (startDot === -1 ||
  10461. end === -1 ||
  10462. // We saw a non-dot character immediately before the dot
  10463. preDotState === 0 ||
  10464. // The (right-most) trimmed path component is exactly '..'
  10465. (preDotState === 1 &&
  10466. startDot === end - 1 &&
  10467. startDot === startPart + 1)) {
  10468. if (end !== -1) {
  10469. ret.base = ret.name = path.slice(startPart, end);
  10470. }
  10471. }
  10472. else {
  10473. ret.name = path.slice(startPart, startDot);
  10474. ret.base = path.slice(startPart, end);
  10475. ret.ext = path.slice(startDot, end);
  10476. }
  10477. // If the directory is the root, use the entire root as the `dir` including
  10478. // the trailing slash if any (`C:\abc` -> `C:\`). Otherwise, strip out the
  10479. // trailing slash (`C:\abc\def` -> `C:\abc`).
  10480. if (startPart > 0 && startPart !== rootEnd) {
  10481. ret.dir = path.slice(0, startPart - 1);
  10482. }
  10483. else {
  10484. ret.dir = ret.root;
  10485. }
  10486. return ret;
  10487. },
  10488. sep: '\\',
  10489. delimiter: ';',
  10490. win32: null,
  10491. posix: null
  10492. };
  10493. exports.posix = {
  10494. // path.resolve([from ...], to)
  10495. resolve: function () {
  10496. var pathSegments = [];
  10497. for (var _i = 0; _i < arguments.length; _i++) {
  10498. pathSegments[_i] = arguments[_i];
  10499. }
  10500. var resolvedPath = '';
  10501. var resolvedAbsolute = false;
  10502. for (var i = pathSegments.length - 1; i >= -1 && !resolvedAbsolute; i--) {
  10503. var path = void 0;
  10504. if (i >= 0) {
  10505. path = pathSegments[i];
  10506. }
  10507. else {
  10508. path = process.cwd();
  10509. }
  10510. validateString(path, 'path');
  10511. // Skip empty entries
  10512. if (path.length === 0) {
  10513. continue;
  10514. }
  10515. resolvedPath = path + '/' + resolvedPath;
  10516. resolvedAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
  10517. }
  10518. // At this point the path should be resolved to a full absolute path, but
  10519. // handle relative paths to be safe (might happen when process.cwd() fails)
  10520. // Normalize the path
  10521. resolvedPath = normalizeString(resolvedPath, !resolvedAbsolute, '/', isPosixPathSeparator);
  10522. if (resolvedAbsolute) {
  10523. if (resolvedPath.length > 0) {
  10524. return '/' + resolvedPath;
  10525. }
  10526. else {
  10527. return '/';
  10528. }
  10529. }
  10530. else if (resolvedPath.length > 0) {
  10531. return resolvedPath;
  10532. }
  10533. else {
  10534. return '.';
  10535. }
  10536. },
  10537. normalize: function (path) {
  10538. validateString(path, 'path');
  10539. if (path.length === 0) {
  10540. return '.';
  10541. }
  10542. var isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
  10543. var trailingSeparator = path.charCodeAt(path.length - 1) === CHAR_FORWARD_SLASH;
  10544. // Normalize the path
  10545. path = normalizeString(path, !isAbsolute, '/', isPosixPathSeparator);
  10546. if (path.length === 0 && !isAbsolute) {
  10547. path = '.';
  10548. }
  10549. if (path.length > 0 && trailingSeparator) {
  10550. path += '/';
  10551. }
  10552. if (isAbsolute) {
  10553. return '/' + path;
  10554. }
  10555. return path;
  10556. },
  10557. isAbsolute: function (path) {
  10558. validateString(path, 'path');
  10559. return path.length > 0 && path.charCodeAt(0) === CHAR_FORWARD_SLASH;
  10560. },
  10561. join: function () {
  10562. var paths = [];
  10563. for (var _i = 0; _i < arguments.length; _i++) {
  10564. paths[_i] = arguments[_i];
  10565. }
  10566. if (paths.length === 0) {
  10567. return '.';
  10568. }
  10569. var joined;
  10570. for (var i = 0; i < paths.length; ++i) {
  10571. var arg = arguments[i];
  10572. validateString(arg, 'path');
  10573. if (arg.length > 0) {
  10574. if (joined === undefined) {
  10575. joined = arg;
  10576. }
  10577. else {
  10578. joined += '/' + arg;
  10579. }
  10580. }
  10581. }
  10582. if (joined === undefined) {
  10583. return '.';
  10584. }
  10585. return exports.posix.normalize(joined);
  10586. },
  10587. relative: function (from, to) {
  10588. validateString(from, 'from');
  10589. validateString(to, 'to');
  10590. if (from === to) {
  10591. return '';
  10592. }
  10593. from = exports.posix.resolve(from);
  10594. to = exports.posix.resolve(to);
  10595. if (from === to) {
  10596. return '';
  10597. }
  10598. // Trim any leading backslashes
  10599. var fromStart = 1;
  10600. for (; fromStart < from.length; ++fromStart) {
  10601. if (from.charCodeAt(fromStart) !== CHAR_FORWARD_SLASH) {
  10602. break;
  10603. }
  10604. }
  10605. var fromEnd = from.length;
  10606. var fromLen = (fromEnd - fromStart);
  10607. // Trim any leading backslashes
  10608. var toStart = 1;
  10609. for (; toStart < to.length; ++toStart) {
  10610. if (to.charCodeAt(toStart) !== CHAR_FORWARD_SLASH) {
  10611. break;
  10612. }
  10613. }
  10614. var toEnd = to.length;
  10615. var toLen = (toEnd - toStart);
  10616. // Compare paths to find the longest common path from root
  10617. var length = (fromLen < toLen ? fromLen : toLen);
  10618. var lastCommonSep = -1;
  10619. var i = 0;
  10620. for (; i <= length; ++i) {
  10621. if (i === length) {
  10622. if (toLen > length) {
  10623. if (to.charCodeAt(toStart + i) === CHAR_FORWARD_SLASH) {
  10624. // We get here if `from` is the exact base path for `to`.
  10625. // For example: from='/foo/bar'; to='/foo/bar/baz'
  10626. return to.slice(toStart + i + 1);
  10627. }
  10628. else if (i === 0) {
  10629. // We get here if `from` is the root
  10630. // For example: from='/'; to='/foo'
  10631. return to.slice(toStart + i);
  10632. }
  10633. }
  10634. else if (fromLen > length) {
  10635. if (from.charCodeAt(fromStart + i) === CHAR_FORWARD_SLASH) {
  10636. // We get here if `to` is the exact base path for `from`.
  10637. // For example: from='/foo/bar/baz'; to='/foo/bar'
  10638. lastCommonSep = i;
  10639. }
  10640. else if (i === 0) {
  10641. // We get here if `to` is the root.
  10642. // For example: from='/foo'; to='/'
  10643. lastCommonSep = 0;
  10644. }
  10645. }
  10646. break;
  10647. }
  10648. var fromCode = from.charCodeAt(fromStart + i);
  10649. var toCode = to.charCodeAt(toStart + i);
  10650. if (fromCode !== toCode) {
  10651. break;
  10652. }
  10653. else if (fromCode === CHAR_FORWARD_SLASH) {
  10654. lastCommonSep = i;
  10655. }
  10656. }
  10657. var out = '';
  10658. // Generate the relative path based on the path difference between `to`
  10659. // and `from`
  10660. for (i = fromStart + lastCommonSep + 1; i <= fromEnd; ++i) {
  10661. if (i === fromEnd || from.charCodeAt(i) === CHAR_FORWARD_SLASH) {
  10662. if (out.length === 0) {
  10663. out += '..';
  10664. }
  10665. else {
  10666. out += '/..';
  10667. }
  10668. }
  10669. }
  10670. // Lastly, append the rest of the destination (`to`) path that comes after
  10671. // the common path parts
  10672. if (out.length > 0) {
  10673. return out + to.slice(toStart + lastCommonSep);
  10674. }
  10675. else {
  10676. toStart += lastCommonSep;
  10677. if (to.charCodeAt(toStart) === CHAR_FORWARD_SLASH) {
  10678. ++toStart;
  10679. }
  10680. return to.slice(toStart);
  10681. }
  10682. },
  10683. toNamespacedPath: function (path) {
  10684. // Non-op on posix systems
  10685. return path;
  10686. },
  10687. dirname: function (path) {
  10688. validateString(path, 'path');
  10689. if (path.length === 0) {
  10690. return '.';
  10691. }
  10692. var hasRoot = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
  10693. var end = -1;
  10694. var matchedSlash = true;
  10695. for (var i = path.length - 1; i >= 1; --i) {
  10696. if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
  10697. if (!matchedSlash) {
  10698. end = i;
  10699. break;
  10700. }
  10701. }
  10702. else {
  10703. // We saw the first non-path separator
  10704. matchedSlash = false;
  10705. }
  10706. }
  10707. if (end === -1) {
  10708. return hasRoot ? '/' : '.';
  10709. }
  10710. if (hasRoot && end === 1) {
  10711. return '//';
  10712. }
  10713. return path.slice(0, end);
  10714. },
  10715. basename: function (path, ext) {
  10716. if (ext !== undefined) {
  10717. validateString(ext, 'ext');
  10718. }
  10719. validateString(path, 'path');
  10720. var start = 0;
  10721. var end = -1;
  10722. var matchedSlash = true;
  10723. var i;
  10724. if (ext !== undefined && ext.length > 0 && ext.length <= path.length) {
  10725. if (ext.length === path.length && ext === path) {
  10726. return '';
  10727. }
  10728. var extIdx = ext.length - 1;
  10729. var firstNonSlashEnd = -1;
  10730. for (i = path.length - 1; i >= 0; --i) {
  10731. var code = path.charCodeAt(i);
  10732. if (code === CHAR_FORWARD_SLASH) {
  10733. // If we reached a path separator that was not part of a set of path
  10734. // separators at the end of the string, stop now
  10735. if (!matchedSlash) {
  10736. start = i + 1;
  10737. break;
  10738. }
  10739. }
  10740. else {
  10741. if (firstNonSlashEnd === -1) {
  10742. // We saw the first non-path separator, remember this index in case
  10743. // we need it if the extension ends up not matching
  10744. matchedSlash = false;
  10745. firstNonSlashEnd = i + 1;
  10746. }
  10747. if (extIdx >= 0) {
  10748. // Try to match the explicit extension
  10749. if (code === ext.charCodeAt(extIdx)) {
  10750. if (--extIdx === -1) {
  10751. // We matched the extension, so mark this as the end of our path
  10752. // component
  10753. end = i;
  10754. }
  10755. }
  10756. else {
  10757. // Extension does not match, so our result is the entire path
  10758. // component
  10759. extIdx = -1;
  10760. end = firstNonSlashEnd;
  10761. }
  10762. }
  10763. }
  10764. }
  10765. if (start === end) {
  10766. end = firstNonSlashEnd;
  10767. }
  10768. else if (end === -1) {
  10769. end = path.length;
  10770. }
  10771. return path.slice(start, end);
  10772. }
  10773. else {
  10774. for (i = path.length - 1; i >= 0; --i) {
  10775. if (path.charCodeAt(i) === CHAR_FORWARD_SLASH) {
  10776. // If we reached a path separator that was not part of a set of path
  10777. // separators at the end of the string, stop now
  10778. if (!matchedSlash) {
  10779. start = i + 1;
  10780. break;
  10781. }
  10782. }
  10783. else if (end === -1) {
  10784. // We saw the first non-path separator, mark this as the end of our
  10785. // path component
  10786. matchedSlash = false;
  10787. end = i + 1;
  10788. }
  10789. }
  10790. if (end === -1) {
  10791. return '';
  10792. }
  10793. return path.slice(start, end);
  10794. }
  10795. },
  10796. extname: function (path) {
  10797. validateString(path, 'path');
  10798. var startDot = -1;
  10799. var startPart = 0;
  10800. var end = -1;
  10801. var matchedSlash = true;
  10802. // Track the state of characters (if any) we see before our first dot and
  10803. // after any path separator we find
  10804. var preDotState = 0;
  10805. for (var i = path.length - 1; i >= 0; --i) {
  10806. var code = path.charCodeAt(i);
  10807. if (code === CHAR_FORWARD_SLASH) {
  10808. // If we reached a path separator that was not part of a set of path
  10809. // separators at the end of the string, stop now
  10810. if (!matchedSlash) {
  10811. startPart = i + 1;
  10812. break;
  10813. }
  10814. continue;
  10815. }
  10816. if (end === -1) {
  10817. // We saw the first non-path separator, mark this as the end of our
  10818. // extension
  10819. matchedSlash = false;
  10820. end = i + 1;
  10821. }
  10822. if (code === CHAR_DOT) {
  10823. // If this is our first dot, mark it as the start of our extension
  10824. if (startDot === -1) {
  10825. startDot = i;
  10826. }
  10827. else if (preDotState !== 1) {
  10828. preDotState = 1;
  10829. }
  10830. }
  10831. else if (startDot !== -1) {
  10832. // We saw a non-dot and non-path separator before our dot, so we should
  10833. // have a good chance at having a non-empty extension
  10834. preDotState = -1;
  10835. }
  10836. }
  10837. if (startDot === -1 ||
  10838. end === -1 ||
  10839. // We saw a non-dot character immediately before the dot
  10840. preDotState === 0 ||
  10841. // The (right-most) trimmed path component is exactly '..'
  10842. (preDotState === 1 &&
  10843. startDot === end - 1 &&
  10844. startDot === startPart + 1)) {
  10845. return '';
  10846. }
  10847. return path.slice(startDot, end);
  10848. },
  10849. format: function (pathObject) {
  10850. if (pathObject === null || typeof pathObject !== 'object') {
  10851. throw new ErrorInvalidArgType('pathObject', 'Object', pathObject);
  10852. }
  10853. return _format('/', pathObject);
  10854. },
  10855. parse: function (path) {
  10856. validateString(path, 'path');
  10857. var ret = { root: '', dir: '', base: '', ext: '', name: '' };
  10858. if (path.length === 0) {
  10859. return ret;
  10860. }
  10861. var isAbsolute = path.charCodeAt(0) === CHAR_FORWARD_SLASH;
  10862. var start;
  10863. if (isAbsolute) {
  10864. ret.root = '/';
  10865. start = 1;
  10866. }
  10867. else {
  10868. start = 0;
  10869. }
  10870. var startDot = -1;
  10871. var startPart = 0;
  10872. var end = -1;
  10873. var matchedSlash = true;
  10874. var i = path.length - 1;
  10875. // Track the state of characters (if any) we see before our first dot and
  10876. // after any path separator we find
  10877. var preDotState = 0;
  10878. // Get non-dir info
  10879. for (; i >= start; --i) {
  10880. var code = path.charCodeAt(i);
  10881. if (code === CHAR_FORWARD_SLASH) {
  10882. // If we reached a path separator that was not part of a set of path
  10883. // separators at the end of the string, stop now
  10884. if (!matchedSlash) {
  10885. startPart = i + 1;
  10886. break;
  10887. }
  10888. continue;
  10889. }
  10890. if (end === -1) {
  10891. // We saw the first non-path separator, mark this as the end of our
  10892. // extension
  10893. matchedSlash = false;
  10894. end = i + 1;
  10895. }
  10896. if (code === CHAR_DOT) {
  10897. // If this is our first dot, mark it as the start of our extension
  10898. if (startDot === -1) {
  10899. startDot = i;
  10900. }
  10901. else if (preDotState !== 1) {
  10902. preDotState = 1;
  10903. }
  10904. }
  10905. else if (startDot !== -1) {
  10906. // We saw a non-dot and non-path separator before our dot, so we should
  10907. // have a good chance at having a non-empty extension
  10908. preDotState = -1;
  10909. }
  10910. }
  10911. if (startDot === -1 ||
  10912. end === -1 ||
  10913. // We saw a non-dot character immediately before the dot
  10914. preDotState === 0 ||
  10915. // The (right-most) trimmed path component is exactly '..'
  10916. (preDotState === 1 &&
  10917. startDot === end - 1 &&
  10918. startDot === startPart + 1)) {
  10919. if (end !== -1) {
  10920. if (startPart === 0 && isAbsolute) {
  10921. ret.base = ret.name = path.slice(1, end);
  10922. }
  10923. else {
  10924. ret.base = ret.name = path.slice(startPart, end);
  10925. }
  10926. }
  10927. }
  10928. else {
  10929. if (startPart === 0 && isAbsolute) {
  10930. ret.name = path.slice(1, startDot);
  10931. ret.base = path.slice(1, end);
  10932. }
  10933. else {
  10934. ret.name = path.slice(startPart, startDot);
  10935. ret.base = path.slice(startPart, end);
  10936. }
  10937. ret.ext = path.slice(startDot, end);
  10938. }
  10939. if (startPart > 0) {
  10940. ret.dir = path.slice(0, startPart - 1);
  10941. }
  10942. else if (isAbsolute) {
  10943. ret.dir = '/';
  10944. }
  10945. return ret;
  10946. },
  10947. sep: '/',
  10948. delimiter: ':',
  10949. win32: null,
  10950. posix: null
  10951. };
  10952. exports.posix.win32 = exports.win32.win32 = exports.win32;
  10953. exports.posix.posix = exports.win32.posix = exports.posix;
  10954. exports.normalize = (process.platform === 'win32' ? exports.win32.normalize : exports.posix.normalize);
  10955. exports.join = (process.platform === 'win32' ? exports.win32.join : exports.posix.join);
  10956. exports.relative = (process.platform === 'win32' ? exports.win32.relative : exports.posix.relative);
  10957. exports.dirname = (process.platform === 'win32' ? exports.win32.dirname : exports.posix.dirname);
  10958. exports.basename = (process.platform === 'win32' ? exports.win32.basename : exports.posix.basename);
  10959. exports.extname = (process.platform === 'win32' ? exports.win32.extname : exports.posix.extname);
  10960. exports.sep = (process.platform === 'win32' ? exports.win32.sep : exports.posix.sep);
  10961. });
  10962. /*---------------------------------------------------------------------------------------------
  10963. * Copyright (c) Microsoft Corporation. All rights reserved.
  10964. * Licensed under the MIT License. See License.txt in the project root for license information.
  10965. *--------------------------------------------------------------------------------------------*/
  10966. define(__m[103/*vs/base/common/range*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  10967. "use strict";
  10968. Object.defineProperty(exports, "__esModule", { value: true });
  10969. var Range;
  10970. (function (Range) {
  10971. /**
  10972. * Returns the intersection between two ranges as a range itself.
  10973. * Returns `{ start: 0, end: 0 }` if the intersection is empty.
  10974. */
  10975. function intersect(one, other) {
  10976. if (one.start >= other.end || other.start >= one.end) {
  10977. return { start: 0, end: 0 };
  10978. }
  10979. var start = Math.max(one.start, other.start);
  10980. var end = Math.min(one.end, other.end);
  10981. if (end - start <= 0) {
  10982. return { start: 0, end: 0 };
  10983. }
  10984. return { start: start, end: end };
  10985. }
  10986. Range.intersect = intersect;
  10987. function isEmpty(range) {
  10988. return range.end - range.start <= 0;
  10989. }
  10990. Range.isEmpty = isEmpty;
  10991. function intersects(one, other) {
  10992. return !isEmpty(intersect(one, other));
  10993. }
  10994. Range.intersects = intersects;
  10995. function relativeComplement(one, other) {
  10996. var result = [];
  10997. var first = { start: one.start, end: Math.min(other.start, one.end) };
  10998. var second = { start: Math.max(other.end, one.start), end: one.end };
  10999. if (!isEmpty(first)) {
  11000. result.push(first);
  11001. }
  11002. if (!isEmpty(second)) {
  11003. result.push(second);
  11004. }
  11005. return result;
  11006. }
  11007. Range.relativeComplement = relativeComplement;
  11008. })(Range = exports.Range || (exports.Range = {}));
  11009. });
  11010. /*---------------------------------------------------------------------------------------------
  11011. * Copyright (c) Microsoft Corporation. All rights reserved.
  11012. * Licensed under the MIT License. See License.txt in the project root for license information.
  11013. *--------------------------------------------------------------------------------------------*/
  11014. define(__m[246/*vs/base/browser/ui/list/rangeMap*/], __M([0/*require*/,1/*exports*/,103/*vs/base/common/range*/]), function (require, exports, range_1) {
  11015. "use strict";
  11016. Object.defineProperty(exports, "__esModule", { value: true });
  11017. /**
  11018. * Returns the intersection between a ranged group and a range.
  11019. * Returns `[]` if the intersection is empty.
  11020. */
  11021. function groupIntersect(range, groups) {
  11022. var result = [];
  11023. for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
  11024. var r = groups_1[_i];
  11025. if (range.start >= r.range.end) {
  11026. continue;
  11027. }
  11028. if (range.end < r.range.start) {
  11029. break;
  11030. }
  11031. var intersection = range_1.Range.intersect(range, r.range);
  11032. if (range_1.Range.isEmpty(intersection)) {
  11033. continue;
  11034. }
  11035. result.push({
  11036. range: intersection,
  11037. size: r.size
  11038. });
  11039. }
  11040. return result;
  11041. }
  11042. exports.groupIntersect = groupIntersect;
  11043. /**
  11044. * Shifts a range by that `much`.
  11045. */
  11046. function shift(_a, much) {
  11047. var start = _a.start, end = _a.end;
  11048. return { start: start + much, end: end + much };
  11049. }
  11050. exports.shift = shift;
  11051. /**
  11052. * Consolidates a collection of ranged groups.
  11053. *
  11054. * Consolidation is the process of merging consecutive ranged groups
  11055. * that share the same `size`.
  11056. */
  11057. function consolidate(groups) {
  11058. var result = [];
  11059. var previousGroup = null;
  11060. for (var _i = 0, groups_2 = groups; _i < groups_2.length; _i++) {
  11061. var group = groups_2[_i];
  11062. var start = group.range.start;
  11063. var end = group.range.end;
  11064. var size = group.size;
  11065. if (previousGroup && size === previousGroup.size) {
  11066. previousGroup.range.end = end;
  11067. continue;
  11068. }
  11069. previousGroup = { range: { start: start, end: end }, size: size };
  11070. result.push(previousGroup);
  11071. }
  11072. return result;
  11073. }
  11074. exports.consolidate = consolidate;
  11075. /**
  11076. * Concatenates several collections of ranged groups into a single
  11077. * collection.
  11078. */
  11079. function concat() {
  11080. var groups = [];
  11081. for (var _i = 0; _i < arguments.length; _i++) {
  11082. groups[_i] = arguments[_i];
  11083. }
  11084. return consolidate(groups.reduce(function (r, g) { return r.concat(g); }, []));
  11085. }
  11086. var RangeMap = /** @class */ (function () {
  11087. function RangeMap() {
  11088. this.groups = [];
  11089. this._size = 0;
  11090. }
  11091. RangeMap.prototype.splice = function (index, deleteCount, items) {
  11092. if (items === void 0) { items = []; }
  11093. var diff = items.length - deleteCount;
  11094. var before = groupIntersect({ start: 0, end: index }, this.groups);
  11095. var after = groupIntersect({ start: index + deleteCount, end: Number.POSITIVE_INFINITY }, this.groups)
  11096. .map(function (g) { return ({ range: shift(g.range, diff), size: g.size }); });
  11097. var middle = items.map(function (item, i) { return ({
  11098. range: { start: index + i, end: index + i + 1 },
  11099. size: item.size
  11100. }); });
  11101. this.groups = concat(before, middle, after);
  11102. this._size = this.groups.reduce(function (t, g) { return t + (g.size * (g.range.end - g.range.start)); }, 0);
  11103. };
  11104. Object.defineProperty(RangeMap.prototype, "count", {
  11105. /**
  11106. * Returns the number of items in the range map.
  11107. */
  11108. get: function () {
  11109. var len = this.groups.length;
  11110. if (!len) {
  11111. return 0;
  11112. }
  11113. return this.groups[len - 1].range.end;
  11114. },
  11115. enumerable: true,
  11116. configurable: true
  11117. });
  11118. Object.defineProperty(RangeMap.prototype, "size", {
  11119. /**
  11120. * Returns the sum of the sizes of all items in the range map.
  11121. */
  11122. get: function () {
  11123. return this._size;
  11124. },
  11125. enumerable: true,
  11126. configurable: true
  11127. });
  11128. /**
  11129. * Returns the index of the item at the given position.
  11130. */
  11131. RangeMap.prototype.indexAt = function (position) {
  11132. if (position < 0) {
  11133. return -1;
  11134. }
  11135. var index = 0;
  11136. var size = 0;
  11137. for (var _i = 0, _a = this.groups; _i < _a.length; _i++) {
  11138. var group = _a[_i];
  11139. var count = group.range.end - group.range.start;
  11140. var newSize = size + (count * group.size);
  11141. if (position < newSize) {
  11142. return index + Math.floor((position - size) / group.size);
  11143. }
  11144. index += count;
  11145. size = newSize;
  11146. }
  11147. return index;
  11148. };
  11149. /**
  11150. * Returns the index of the item right after the item at the
  11151. * index of the given position.
  11152. */
  11153. RangeMap.prototype.indexAfter = function (position) {
  11154. return Math.min(this.indexAt(position) + 1, this.count);
  11155. };
  11156. /**
  11157. * Returns the start position of the item at the given index.
  11158. */
  11159. RangeMap.prototype.positionAt = function (index) {
  11160. if (index < 0) {
  11161. return -1;
  11162. }
  11163. var position = 0;
  11164. var count = 0;
  11165. for (var _i = 0, _a = this.groups; _i < _a.length; _i++) {
  11166. var group = _a[_i];
  11167. var groupCount = group.range.end - group.range.start;
  11168. var newCount = count + groupCount;
  11169. if (index < newCount) {
  11170. return position + ((index - count) * group.size);
  11171. }
  11172. position += groupCount * group.size;
  11173. count = newCount;
  11174. }
  11175. return -1;
  11176. };
  11177. return RangeMap;
  11178. }());
  11179. exports.RangeMap = RangeMap;
  11180. });
  11181. /*---------------------------------------------------------------------------------------------
  11182. * Copyright (c) Microsoft Corporation. All rights reserved.
  11183. * Licensed under the MIT License. See License.txt in the project root for license information.
  11184. *--------------------------------------------------------------------------------------------*/
  11185. define(__m[176/*vs/base/common/scrollable*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/]), function (require, exports, event_1, lifecycle_1) {
  11186. "use strict";
  11187. Object.defineProperty(exports, "__esModule", { value: true });
  11188. var ScrollState = /** @class */ (function () {
  11189. function ScrollState(width, scrollWidth, scrollLeft, height, scrollHeight, scrollTop) {
  11190. width = width | 0;
  11191. scrollWidth = scrollWidth | 0;
  11192. scrollLeft = scrollLeft | 0;
  11193. height = height | 0;
  11194. scrollHeight = scrollHeight | 0;
  11195. scrollTop = scrollTop | 0;
  11196. if (width < 0) {
  11197. width = 0;
  11198. }
  11199. if (scrollLeft + width > scrollWidth) {
  11200. scrollLeft = scrollWidth - width;
  11201. }
  11202. if (scrollLeft < 0) {
  11203. scrollLeft = 0;
  11204. }
  11205. if (height < 0) {
  11206. height = 0;
  11207. }
  11208. if (scrollTop + height > scrollHeight) {
  11209. scrollTop = scrollHeight - height;
  11210. }
  11211. if (scrollTop < 0) {
  11212. scrollTop = 0;
  11213. }
  11214. this.width = width;
  11215. this.scrollWidth = scrollWidth;
  11216. this.scrollLeft = scrollLeft;
  11217. this.height = height;
  11218. this.scrollHeight = scrollHeight;
  11219. this.scrollTop = scrollTop;
  11220. }
  11221. ScrollState.prototype.equals = function (other) {
  11222. return (this.width === other.width
  11223. && this.scrollWidth === other.scrollWidth
  11224. && this.scrollLeft === other.scrollLeft
  11225. && this.height === other.height
  11226. && this.scrollHeight === other.scrollHeight
  11227. && this.scrollTop === other.scrollTop);
  11228. };
  11229. ScrollState.prototype.withScrollDimensions = function (update) {
  11230. return new ScrollState((typeof update.width !== 'undefined' ? update.width : this.width), (typeof update.scrollWidth !== 'undefined' ? update.scrollWidth : this.scrollWidth), this.scrollLeft, (typeof update.height !== 'undefined' ? update.height : this.height), (typeof update.scrollHeight !== 'undefined' ? update.scrollHeight : this.scrollHeight), this.scrollTop);
  11231. };
  11232. ScrollState.prototype.withScrollPosition = function (update) {
  11233. return new ScrollState(this.width, this.scrollWidth, (typeof update.scrollLeft !== 'undefined' ? update.scrollLeft : this.scrollLeft), this.height, this.scrollHeight, (typeof update.scrollTop !== 'undefined' ? update.scrollTop : this.scrollTop));
  11234. };
  11235. ScrollState.prototype.createScrollEvent = function (previous) {
  11236. var widthChanged = (this.width !== previous.width);
  11237. var scrollWidthChanged = (this.scrollWidth !== previous.scrollWidth);
  11238. var scrollLeftChanged = (this.scrollLeft !== previous.scrollLeft);
  11239. var heightChanged = (this.height !== previous.height);
  11240. var scrollHeightChanged = (this.scrollHeight !== previous.scrollHeight);
  11241. var scrollTopChanged = (this.scrollTop !== previous.scrollTop);
  11242. return {
  11243. width: this.width,
  11244. scrollWidth: this.scrollWidth,
  11245. scrollLeft: this.scrollLeft,
  11246. height: this.height,
  11247. scrollHeight: this.scrollHeight,
  11248. scrollTop: this.scrollTop,
  11249. widthChanged: widthChanged,
  11250. scrollWidthChanged: scrollWidthChanged,
  11251. scrollLeftChanged: scrollLeftChanged,
  11252. heightChanged: heightChanged,
  11253. scrollHeightChanged: scrollHeightChanged,
  11254. scrollTopChanged: scrollTopChanged,
  11255. };
  11256. };
  11257. return ScrollState;
  11258. }());
  11259. exports.ScrollState = ScrollState;
  11260. var Scrollable = /** @class */ (function (_super) {
  11261. __extends(Scrollable, _super);
  11262. function Scrollable(smoothScrollDuration, scheduleAtNextAnimationFrame) {
  11263. var _this = _super.call(this) || this;
  11264. _this._onScroll = _this._register(new event_1.Emitter());
  11265. _this.onScroll = _this._onScroll.event;
  11266. _this._smoothScrollDuration = smoothScrollDuration;
  11267. _this._scheduleAtNextAnimationFrame = scheduleAtNextAnimationFrame;
  11268. _this._state = new ScrollState(0, 0, 0, 0, 0, 0);
  11269. _this._smoothScrolling = null;
  11270. return _this;
  11271. }
  11272. Scrollable.prototype.dispose = function () {
  11273. if (this._smoothScrolling) {
  11274. this._smoothScrolling.dispose();
  11275. this._smoothScrolling = null;
  11276. }
  11277. _super.prototype.dispose.call(this);
  11278. };
  11279. Scrollable.prototype.setSmoothScrollDuration = function (smoothScrollDuration) {
  11280. this._smoothScrollDuration = smoothScrollDuration;
  11281. };
  11282. Scrollable.prototype.validateScrollPosition = function (scrollPosition) {
  11283. return this._state.withScrollPosition(scrollPosition);
  11284. };
  11285. Scrollable.prototype.getScrollDimensions = function () {
  11286. return this._state;
  11287. };
  11288. Scrollable.prototype.setScrollDimensions = function (dimensions) {
  11289. var newState = this._state.withScrollDimensions(dimensions);
  11290. this._setState(newState);
  11291. // Validate outstanding animated scroll position target
  11292. if (this._smoothScrolling) {
  11293. this._smoothScrolling.acceptScrollDimensions(this._state);
  11294. }
  11295. };
  11296. /**
  11297. * Returns the final scroll position that the instance will have once the smooth scroll animation concludes.
  11298. * If no scroll animation is occurring, it will return the current scroll position instead.
  11299. */
  11300. Scrollable.prototype.getFutureScrollPosition = function () {
  11301. if (this._smoothScrolling) {
  11302. return this._smoothScrolling.to;
  11303. }
  11304. return this._state;
  11305. };
  11306. /**
  11307. * Returns the current scroll position.
  11308. * Note: This result might be an intermediate scroll position, as there might be an ongoing smooth scroll animation.
  11309. */
  11310. Scrollable.prototype.getCurrentScrollPosition = function () {
  11311. return this._state;
  11312. };
  11313. Scrollable.prototype.setScrollPositionNow = function (update) {
  11314. // no smooth scrolling requested
  11315. var newState = this._state.withScrollPosition(update);
  11316. // Terminate any outstanding smooth scrolling
  11317. if (this._smoothScrolling) {
  11318. this._smoothScrolling.dispose();
  11319. this._smoothScrolling = null;
  11320. }
  11321. this._setState(newState);
  11322. };
  11323. Scrollable.prototype.setScrollPositionSmooth = function (update) {
  11324. var _this = this;
  11325. if (this._smoothScrollDuration === 0) {
  11326. // Smooth scrolling not supported.
  11327. return this.setScrollPositionNow(update);
  11328. }
  11329. if (this._smoothScrolling) {
  11330. // Combine our pending scrollLeft/scrollTop with incoming scrollLeft/scrollTop
  11331. update = {
  11332. scrollLeft: (typeof update.scrollLeft === 'undefined' ? this._smoothScrolling.to.scrollLeft : update.scrollLeft),
  11333. scrollTop: (typeof update.scrollTop === 'undefined' ? this._smoothScrolling.to.scrollTop : update.scrollTop)
  11334. };
  11335. // Validate `update`
  11336. var validTarget = this._state.withScrollPosition(update);
  11337. if (this._smoothScrolling.to.scrollLeft === validTarget.scrollLeft && this._smoothScrolling.to.scrollTop === validTarget.scrollTop) {
  11338. // No need to interrupt or extend the current animation since we're going to the same place
  11339. return;
  11340. }
  11341. var newSmoothScrolling = this._smoothScrolling.combine(this._state, validTarget, this._smoothScrollDuration);
  11342. this._smoothScrolling.dispose();
  11343. this._smoothScrolling = newSmoothScrolling;
  11344. }
  11345. else {
  11346. // Validate `update`
  11347. var validTarget = this._state.withScrollPosition(update);
  11348. this._smoothScrolling = SmoothScrollingOperation.start(this._state, validTarget, this._smoothScrollDuration);
  11349. }
  11350. // Begin smooth scrolling animation
  11351. this._smoothScrolling.animationFrameDisposable = this._scheduleAtNextAnimationFrame(function () {
  11352. if (!_this._smoothScrolling) {
  11353. return;
  11354. }
  11355. _this._smoothScrolling.animationFrameDisposable = null;
  11356. _this._performSmoothScrolling();
  11357. });
  11358. };
  11359. Scrollable.prototype._performSmoothScrolling = function () {
  11360. var _this = this;
  11361. if (!this._smoothScrolling) {
  11362. return;
  11363. }
  11364. var update = this._smoothScrolling.tick();
  11365. var newState = this._state.withScrollPosition(update);
  11366. this._setState(newState);
  11367. if (update.isDone) {
  11368. this._smoothScrolling.dispose();
  11369. this._smoothScrolling = null;
  11370. return;
  11371. }
  11372. // Continue smooth scrolling animation
  11373. this._smoothScrolling.animationFrameDisposable = this._scheduleAtNextAnimationFrame(function () {
  11374. if (!_this._smoothScrolling) {
  11375. return;
  11376. }
  11377. _this._smoothScrolling.animationFrameDisposable = null;
  11378. _this._performSmoothScrolling();
  11379. });
  11380. };
  11381. Scrollable.prototype._setState = function (newState) {
  11382. var oldState = this._state;
  11383. if (oldState.equals(newState)) {
  11384. // no change
  11385. return;
  11386. }
  11387. this._state = newState;
  11388. this._onScroll.fire(this._state.createScrollEvent(oldState));
  11389. };
  11390. return Scrollable;
  11391. }(lifecycle_1.Disposable));
  11392. exports.Scrollable = Scrollable;
  11393. var SmoothScrollingUpdate = /** @class */ (function () {
  11394. function SmoothScrollingUpdate(scrollLeft, scrollTop, isDone) {
  11395. this.scrollLeft = scrollLeft;
  11396. this.scrollTop = scrollTop;
  11397. this.isDone = isDone;
  11398. }
  11399. return SmoothScrollingUpdate;
  11400. }());
  11401. exports.SmoothScrollingUpdate = SmoothScrollingUpdate;
  11402. function createEaseOutCubic(from, to) {
  11403. var delta = to - from;
  11404. return function (completion) {
  11405. return from + delta * easeOutCubic(completion);
  11406. };
  11407. }
  11408. function createComposed(a, b, cut) {
  11409. return function (completion) {
  11410. if (completion < cut) {
  11411. return a(completion / cut);
  11412. }
  11413. return b((completion - cut) / (1 - cut));
  11414. };
  11415. }
  11416. var SmoothScrollingOperation = /** @class */ (function () {
  11417. function SmoothScrollingOperation(from, to, startTime, duration) {
  11418. this.from = from;
  11419. this.to = to;
  11420. this.duration = duration;
  11421. this._startTime = startTime;
  11422. this.animationFrameDisposable = null;
  11423. this._initAnimations();
  11424. }
  11425. SmoothScrollingOperation.prototype._initAnimations = function () {
  11426. this.scrollLeft = this._initAnimation(this.from.scrollLeft, this.to.scrollLeft, this.to.width);
  11427. this.scrollTop = this._initAnimation(this.from.scrollTop, this.to.scrollTop, this.to.height);
  11428. };
  11429. SmoothScrollingOperation.prototype._initAnimation = function (from, to, viewportSize) {
  11430. var delta = Math.abs(from - to);
  11431. if (delta > 2.5 * viewportSize) {
  11432. var stop1 = void 0, stop2 = void 0;
  11433. if (from < to) {
  11434. // scroll to 75% of the viewportSize
  11435. stop1 = from + 0.75 * viewportSize;
  11436. stop2 = to - 0.75 * viewportSize;
  11437. }
  11438. else {
  11439. stop1 = from - 0.75 * viewportSize;
  11440. stop2 = to + 0.75 * viewportSize;
  11441. }
  11442. return createComposed(createEaseOutCubic(from, stop1), createEaseOutCubic(stop2, to), 0.33);
  11443. }
  11444. return createEaseOutCubic(from, to);
  11445. };
  11446. SmoothScrollingOperation.prototype.dispose = function () {
  11447. if (this.animationFrameDisposable !== null) {
  11448. this.animationFrameDisposable.dispose();
  11449. this.animationFrameDisposable = null;
  11450. }
  11451. };
  11452. SmoothScrollingOperation.prototype.acceptScrollDimensions = function (state) {
  11453. this.to = state.withScrollPosition(this.to);
  11454. this._initAnimations();
  11455. };
  11456. SmoothScrollingOperation.prototype.tick = function () {
  11457. return this._tick(Date.now());
  11458. };
  11459. SmoothScrollingOperation.prototype._tick = function (now) {
  11460. var completion = (now - this._startTime) / this.duration;
  11461. if (completion < 1) {
  11462. var newScrollLeft = this.scrollLeft(completion);
  11463. var newScrollTop = this.scrollTop(completion);
  11464. return new SmoothScrollingUpdate(newScrollLeft, newScrollTop, false);
  11465. }
  11466. return new SmoothScrollingUpdate(this.to.scrollLeft, this.to.scrollTop, true);
  11467. };
  11468. SmoothScrollingOperation.prototype.combine = function (from, to, duration) {
  11469. return SmoothScrollingOperation.start(from, to, duration);
  11470. };
  11471. SmoothScrollingOperation.start = function (from, to, duration) {
  11472. // +10 / -10 : pretend the animation already started for a quicker response to a scroll request
  11473. duration = duration + 10;
  11474. var startTime = Date.now() - 10;
  11475. return new SmoothScrollingOperation(from, to, startTime, duration);
  11476. };
  11477. return SmoothScrollingOperation;
  11478. }());
  11479. exports.SmoothScrollingOperation = SmoothScrollingOperation;
  11480. function easeInCubic(t) {
  11481. return Math.pow(t, 3);
  11482. }
  11483. function easeOutCubic(t) {
  11484. return 1 - easeInCubic(1 - t);
  11485. }
  11486. });
  11487. /*---------------------------------------------------------------------------------------------
  11488. * Copyright (c) Microsoft Corporation. All rights reserved.
  11489. * Licensed under the MIT License. See License.txt in the project root for license information.
  11490. *--------------------------------------------------------------------------------------------*/
  11491. define(__m[132/*vs/base/common/stopwatch*/], __M([0/*require*/,1/*exports*/,16/*vs/base/common/platform*/]), function (require, exports, platform_1) {
  11492. "use strict";
  11493. Object.defineProperty(exports, "__esModule", { value: true });
  11494. var hasPerformanceNow = (platform_1.globals.performance && typeof platform_1.globals.performance.now === 'function');
  11495. var StopWatch = /** @class */ (function () {
  11496. function StopWatch(highResolution) {
  11497. this._highResolution = hasPerformanceNow && highResolution;
  11498. this._startTime = this._now();
  11499. this._stopTime = -1;
  11500. }
  11501. StopWatch.create = function (highResolution) {
  11502. if (highResolution === void 0) { highResolution = true; }
  11503. return new StopWatch(highResolution);
  11504. };
  11505. StopWatch.prototype.stop = function () {
  11506. this._stopTime = this._now();
  11507. };
  11508. StopWatch.prototype.elapsed = function () {
  11509. if (this._stopTime !== -1) {
  11510. return this._stopTime - this._startTime;
  11511. }
  11512. return this._now() - this._startTime;
  11513. };
  11514. StopWatch.prototype._now = function () {
  11515. return this._highResolution ? platform_1.globals.performance.now() : new Date().getTime();
  11516. };
  11517. return StopWatch;
  11518. }());
  11519. exports.StopWatch = StopWatch;
  11520. });
  11521. /*---------------------------------------------------------------------------------------------
  11522. * Copyright (c) Microsoft Corporation. All rights reserved.
  11523. * Licensed under the MIT License. See License.txt in the project root for license information.
  11524. *--------------------------------------------------------------------------------------------*/
  11525. define(__m[5/*vs/base/common/strings*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  11526. "use strict";
  11527. Object.defineProperty(exports, "__esModule", { value: true });
  11528. function isFalsyOrWhitespace(str) {
  11529. if (!str || typeof str !== 'string') {
  11530. return true;
  11531. }
  11532. return str.trim().length === 0;
  11533. }
  11534. exports.isFalsyOrWhitespace = isFalsyOrWhitespace;
  11535. /**
  11536. * @returns the provided number with the given number of preceding zeros.
  11537. */
  11538. function pad(n, l, char) {
  11539. if (char === void 0) { char = '0'; }
  11540. var str = '' + n;
  11541. var r = [str];
  11542. for (var i = str.length; i < l; i++) {
  11543. r.push(char);
  11544. }
  11545. return r.reverse().join('');
  11546. }
  11547. exports.pad = pad;
  11548. var _formatRegexp = /{(\d+)}/g;
  11549. /**
  11550. * Helper to produce a string with a variable number of arguments. Insert variable segments
  11551. * into the string using the {n} notation where N is the index of the argument following the string.
  11552. * @param value string to which formatting is applied
  11553. * @param args replacements for {n}-entries
  11554. */
  11555. function format(value) {
  11556. var args = [];
  11557. for (var _i = 1; _i < arguments.length; _i++) {
  11558. args[_i - 1] = arguments[_i];
  11559. }
  11560. if (args.length === 0) {
  11561. return value;
  11562. }
  11563. return value.replace(_formatRegexp, function (match, group) {
  11564. var idx = parseInt(group, 10);
  11565. return isNaN(idx) || idx < 0 || idx >= args.length ?
  11566. match :
  11567. args[idx];
  11568. });
  11569. }
  11570. exports.format = format;
  11571. /**
  11572. * Converts HTML characters inside the string to use entities instead. Makes the string safe from
  11573. * being used e.g. in HTMLElement.innerHTML.
  11574. */
  11575. function escape(html) {
  11576. return html.replace(/[<>&]/g, function (match) {
  11577. switch (match) {
  11578. case '<': return '&lt;';
  11579. case '>': return '&gt;';
  11580. case '&': return '&amp;';
  11581. default: return match;
  11582. }
  11583. });
  11584. }
  11585. exports.escape = escape;
  11586. /**
  11587. * Escapes regular expression characters in a given string
  11588. */
  11589. function escapeRegExpCharacters(value) {
  11590. return value.replace(/[\\\{\}\*\+\?\|\^\$\.\[\]\(\)]/g, '\\$&');
  11591. }
  11592. exports.escapeRegExpCharacters = escapeRegExpCharacters;
  11593. /**
  11594. * Removes all occurrences of needle from the beginning and end of haystack.
  11595. * @param haystack string to trim
  11596. * @param needle the thing to trim (default is a blank)
  11597. */
  11598. function trim(haystack, needle) {
  11599. if (needle === void 0) { needle = ' '; }
  11600. var trimmed = ltrim(haystack, needle);
  11601. return rtrim(trimmed, needle);
  11602. }
  11603. exports.trim = trim;
  11604. /**
  11605. * Removes all occurrences of needle from the beginning of haystack.
  11606. * @param haystack string to trim
  11607. * @param needle the thing to trim
  11608. */
  11609. function ltrim(haystack, needle) {
  11610. if (!haystack || !needle) {
  11611. return haystack;
  11612. }
  11613. var needleLen = needle.length;
  11614. if (needleLen === 0 || haystack.length === 0) {
  11615. return haystack;
  11616. }
  11617. var offset = 0;
  11618. while (haystack.indexOf(needle, offset) === offset) {
  11619. offset = offset + needleLen;
  11620. }
  11621. return haystack.substring(offset);
  11622. }
  11623. exports.ltrim = ltrim;
  11624. /**
  11625. * Removes all occurrences of needle from the end of haystack.
  11626. * @param haystack string to trim
  11627. * @param needle the thing to trim
  11628. */
  11629. function rtrim(haystack, needle) {
  11630. if (!haystack || !needle) {
  11631. return haystack;
  11632. }
  11633. var needleLen = needle.length, haystackLen = haystack.length;
  11634. if (needleLen === 0 || haystackLen === 0) {
  11635. return haystack;
  11636. }
  11637. var offset = haystackLen, idx = -1;
  11638. while (true) {
  11639. idx = haystack.lastIndexOf(needle, offset - 1);
  11640. if (idx === -1 || idx + needleLen !== offset) {
  11641. break;
  11642. }
  11643. if (idx === 0) {
  11644. return '';
  11645. }
  11646. offset = idx;
  11647. }
  11648. return haystack.substring(0, offset);
  11649. }
  11650. exports.rtrim = rtrim;
  11651. function convertSimple2RegExpPattern(pattern) {
  11652. return pattern.replace(/[\-\\\{\}\+\?\|\^\$\.\,\[\]\(\)\#\s]/g, '\\$&').replace(/[\*]/g, '.*');
  11653. }
  11654. exports.convertSimple2RegExpPattern = convertSimple2RegExpPattern;
  11655. /**
  11656. * Determines if haystack starts with needle.
  11657. */
  11658. function startsWith(haystack, needle) {
  11659. if (haystack.length < needle.length) {
  11660. return false;
  11661. }
  11662. if (haystack === needle) {
  11663. return true;
  11664. }
  11665. for (var i = 0; i < needle.length; i++) {
  11666. if (haystack[i] !== needle[i]) {
  11667. return false;
  11668. }
  11669. }
  11670. return true;
  11671. }
  11672. exports.startsWith = startsWith;
  11673. /**
  11674. * Determines if haystack ends with needle.
  11675. */
  11676. function endsWith(haystack, needle) {
  11677. var diff = haystack.length - needle.length;
  11678. if (diff > 0) {
  11679. return haystack.indexOf(needle, diff) === diff;
  11680. }
  11681. else if (diff === 0) {
  11682. return haystack === needle;
  11683. }
  11684. else {
  11685. return false;
  11686. }
  11687. }
  11688. exports.endsWith = endsWith;
  11689. function createRegExp(searchString, isRegex, options) {
  11690. if (options === void 0) { options = {}; }
  11691. if (!searchString) {
  11692. throw new Error('Cannot create regex from empty string');
  11693. }
  11694. if (!isRegex) {
  11695. searchString = escapeRegExpCharacters(searchString);
  11696. }
  11697. if (options.wholeWord) {
  11698. if (!/\B/.test(searchString.charAt(0))) {
  11699. searchString = '\\b' + searchString;
  11700. }
  11701. if (!/\B/.test(searchString.charAt(searchString.length - 1))) {
  11702. searchString = searchString + '\\b';
  11703. }
  11704. }
  11705. var modifiers = '';
  11706. if (options.global) {
  11707. modifiers += 'g';
  11708. }
  11709. if (!options.matchCase) {
  11710. modifiers += 'i';
  11711. }
  11712. if (options.multiline) {
  11713. modifiers += 'm';
  11714. }
  11715. if (options.unicode) {
  11716. modifiers += 'u';
  11717. }
  11718. return new RegExp(searchString, modifiers);
  11719. }
  11720. exports.createRegExp = createRegExp;
  11721. function regExpLeadsToEndlessLoop(regexp) {
  11722. // Exit early if it's one of these special cases which are meant to match
  11723. // against an empty string
  11724. if (regexp.source === '^' || regexp.source === '^$' || regexp.source === '$' || regexp.source === '^\\s*$') {
  11725. return false;
  11726. }
  11727. // We check against an empty string. If the regular expression doesn't advance
  11728. // (e.g. ends in an endless loop) it will match an empty string.
  11729. var match = regexp.exec('');
  11730. return !!(match && regexp.lastIndex === 0);
  11731. }
  11732. exports.regExpLeadsToEndlessLoop = regExpLeadsToEndlessLoop;
  11733. function regExpFlags(regexp) {
  11734. return (regexp.global ? 'g' : '')
  11735. + (regexp.ignoreCase ? 'i' : '')
  11736. + (regexp.multiline ? 'm' : '')
  11737. + (regexp.unicode ? 'u' : '');
  11738. }
  11739. exports.regExpFlags = regExpFlags;
  11740. /**
  11741. * Returns first index of the string that is not whitespace.
  11742. * If string is empty or contains only whitespaces, returns -1
  11743. */
  11744. function firstNonWhitespaceIndex(str) {
  11745. for (var i = 0, len = str.length; i < len; i++) {
  11746. var chCode = str.charCodeAt(i);
  11747. if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
  11748. return i;
  11749. }
  11750. }
  11751. return -1;
  11752. }
  11753. exports.firstNonWhitespaceIndex = firstNonWhitespaceIndex;
  11754. /**
  11755. * Returns the leading whitespace of the string.
  11756. * If the string contains only whitespaces, returns entire string
  11757. */
  11758. function getLeadingWhitespace(str, start, end) {
  11759. if (start === void 0) { start = 0; }
  11760. if (end === void 0) { end = str.length; }
  11761. for (var i = start; i < end; i++) {
  11762. var chCode = str.charCodeAt(i);
  11763. if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
  11764. return str.substring(start, i);
  11765. }
  11766. }
  11767. return str.substring(start, end);
  11768. }
  11769. exports.getLeadingWhitespace = getLeadingWhitespace;
  11770. /**
  11771. * Returns last index of the string that is not whitespace.
  11772. * If string is empty or contains only whitespaces, returns -1
  11773. */
  11774. function lastNonWhitespaceIndex(str, startIndex) {
  11775. if (startIndex === void 0) { startIndex = str.length - 1; }
  11776. for (var i = startIndex; i >= 0; i--) {
  11777. var chCode = str.charCodeAt(i);
  11778. if (chCode !== 32 /* Space */ && chCode !== 9 /* Tab */) {
  11779. return i;
  11780. }
  11781. }
  11782. return -1;
  11783. }
  11784. exports.lastNonWhitespaceIndex = lastNonWhitespaceIndex;
  11785. function compare(a, b) {
  11786. if (a < b) {
  11787. return -1;
  11788. }
  11789. else if (a > b) {
  11790. return 1;
  11791. }
  11792. else {
  11793. return 0;
  11794. }
  11795. }
  11796. exports.compare = compare;
  11797. function compareIgnoreCase(a, b) {
  11798. var len = Math.min(a.length, b.length);
  11799. for (var i = 0; i < len; i++) {
  11800. var codeA = a.charCodeAt(i);
  11801. var codeB = b.charCodeAt(i);
  11802. if (codeA === codeB) {
  11803. // equal
  11804. continue;
  11805. }
  11806. if (isUpperAsciiLetter(codeA)) {
  11807. codeA += 32;
  11808. }
  11809. if (isUpperAsciiLetter(codeB)) {
  11810. codeB += 32;
  11811. }
  11812. var diff = codeA - codeB;
  11813. if (diff === 0) {
  11814. // equal -> ignoreCase
  11815. continue;
  11816. }
  11817. else if (isLowerAsciiLetter(codeA) && isLowerAsciiLetter(codeB)) {
  11818. //
  11819. return diff;
  11820. }
  11821. else {
  11822. return compare(a.toLowerCase(), b.toLowerCase());
  11823. }
  11824. }
  11825. if (a.length < b.length) {
  11826. return -1;
  11827. }
  11828. else if (a.length > b.length) {
  11829. return 1;
  11830. }
  11831. else {
  11832. return 0;
  11833. }
  11834. }
  11835. exports.compareIgnoreCase = compareIgnoreCase;
  11836. function isLowerAsciiLetter(code) {
  11837. return code >= 97 /* a */ && code <= 122 /* z */;
  11838. }
  11839. exports.isLowerAsciiLetter = isLowerAsciiLetter;
  11840. function isUpperAsciiLetter(code) {
  11841. return code >= 65 /* A */ && code <= 90 /* Z */;
  11842. }
  11843. exports.isUpperAsciiLetter = isUpperAsciiLetter;
  11844. function isAsciiLetter(code) {
  11845. return isLowerAsciiLetter(code) || isUpperAsciiLetter(code);
  11846. }
  11847. function equalsIgnoreCase(a, b) {
  11848. return a.length === b.length && doEqualsIgnoreCase(a, b);
  11849. }
  11850. exports.equalsIgnoreCase = equalsIgnoreCase;
  11851. function doEqualsIgnoreCase(a, b, stopAt) {
  11852. if (stopAt === void 0) { stopAt = a.length; }
  11853. for (var i = 0; i < stopAt; i++) {
  11854. var codeA = a.charCodeAt(i);
  11855. var codeB = b.charCodeAt(i);
  11856. if (codeA === codeB) {
  11857. continue;
  11858. }
  11859. // a-z A-Z
  11860. if (isAsciiLetter(codeA) && isAsciiLetter(codeB)) {
  11861. var diff = Math.abs(codeA - codeB);
  11862. if (diff !== 0 && diff !== 32) {
  11863. return false;
  11864. }
  11865. }
  11866. // Any other charcode
  11867. else {
  11868. if (String.fromCharCode(codeA).toLowerCase() !== String.fromCharCode(codeB).toLowerCase()) {
  11869. return false;
  11870. }
  11871. }
  11872. }
  11873. return true;
  11874. }
  11875. function startsWithIgnoreCase(str, candidate) {
  11876. var candidateLength = candidate.length;
  11877. if (candidate.length > str.length) {
  11878. return false;
  11879. }
  11880. return doEqualsIgnoreCase(str, candidate, candidateLength);
  11881. }
  11882. exports.startsWithIgnoreCase = startsWithIgnoreCase;
  11883. /**
  11884. * @returns the length of the common prefix of the two strings.
  11885. */
  11886. function commonPrefixLength(a, b) {
  11887. var i, len = Math.min(a.length, b.length);
  11888. for (i = 0; i < len; i++) {
  11889. if (a.charCodeAt(i) !== b.charCodeAt(i)) {
  11890. return i;
  11891. }
  11892. }
  11893. return len;
  11894. }
  11895. exports.commonPrefixLength = commonPrefixLength;
  11896. /**
  11897. * @returns the length of the common suffix of the two strings.
  11898. */
  11899. function commonSuffixLength(a, b) {
  11900. var i, len = Math.min(a.length, b.length);
  11901. var aLastIndex = a.length - 1;
  11902. var bLastIndex = b.length - 1;
  11903. for (i = 0; i < len; i++) {
  11904. if (a.charCodeAt(aLastIndex - i) !== b.charCodeAt(bLastIndex - i)) {
  11905. return i;
  11906. }
  11907. }
  11908. return len;
  11909. }
  11910. exports.commonSuffixLength = commonSuffixLength;
  11911. // --- unicode
  11912. // http://en.wikipedia.org/wiki/Surrogate_pair
  11913. // Returns the code point starting at a specified index in a string
  11914. // Code points U+0000 to U+D7FF and U+E000 to U+FFFF are represented on a single character
  11915. // Code points U+10000 to U+10FFFF are represented on two consecutive characters
  11916. //export function getUnicodePoint(str:string, index:number, len:number):number {
  11917. // const chrCode = str.charCodeAt(index);
  11918. // if (0xD800 <= chrCode && chrCode <= 0xDBFF && index + 1 < len) {
  11919. // const nextChrCode = str.charCodeAt(index + 1);
  11920. // if (0xDC00 <= nextChrCode && nextChrCode <= 0xDFFF) {
  11921. // return (chrCode - 0xD800) << 10 + (nextChrCode - 0xDC00) + 0x10000;
  11922. // }
  11923. // }
  11924. // return chrCode;
  11925. //}
  11926. function isHighSurrogate(charCode) {
  11927. return (0xD800 <= charCode && charCode <= 0xDBFF);
  11928. }
  11929. exports.isHighSurrogate = isHighSurrogate;
  11930. function isLowSurrogate(charCode) {
  11931. return (0xDC00 <= charCode && charCode <= 0xDFFF);
  11932. }
  11933. exports.isLowSurrogate = isLowSurrogate;
  11934. /**
  11935. * get the code point that begins at offset `offset`
  11936. */
  11937. function getNextCodePoint(str, len, offset) {
  11938. var charCode = str.charCodeAt(offset);
  11939. if (isHighSurrogate(charCode) && offset + 1 < len) {
  11940. var nextCharCode = str.charCodeAt(offset + 1);
  11941. if (isLowSurrogate(nextCharCode)) {
  11942. return ((charCode - 0xD800) << 10) + (nextCharCode - 0xDC00) + 0x10000;
  11943. }
  11944. }
  11945. return charCode;
  11946. }
  11947. exports.getNextCodePoint = getNextCodePoint;
  11948. /**
  11949. * get the code point that ends right before offset `offset`
  11950. */
  11951. function getPrevCodePoint(str, offset) {
  11952. var charCode = str.charCodeAt(offset - 1);
  11953. if (isLowSurrogate(charCode) && offset > 1) {
  11954. var prevCharCode = str.charCodeAt(offset - 2);
  11955. if (isHighSurrogate(prevCharCode)) {
  11956. return ((prevCharCode - 0xD800) << 10) + (charCode - 0xDC00) + 0x10000;
  11957. }
  11958. }
  11959. return charCode;
  11960. }
  11961. function nextCharLength(str, offset) {
  11962. var graphemeBreakTree = GraphemeBreakTree.getInstance();
  11963. var initialOffset = offset;
  11964. var len = str.length;
  11965. var initialCodePoint = getNextCodePoint(str, len, offset);
  11966. offset += (initialCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  11967. var graphemeBreakType = graphemeBreakTree.getGraphemeBreakType(initialCodePoint);
  11968. while (offset < len) {
  11969. var nextCodePoint = getNextCodePoint(str, len, offset);
  11970. var nextGraphemeBreakType = graphemeBreakTree.getGraphemeBreakType(nextCodePoint);
  11971. if (breakBetweenGraphemeBreakType(graphemeBreakType, nextGraphemeBreakType)) {
  11972. break;
  11973. }
  11974. offset += (nextCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  11975. graphemeBreakType = nextGraphemeBreakType;
  11976. }
  11977. return (offset - initialOffset);
  11978. }
  11979. exports.nextCharLength = nextCharLength;
  11980. function prevCharLength(str, offset) {
  11981. var graphemeBreakTree = GraphemeBreakTree.getInstance();
  11982. var initialOffset = offset;
  11983. var initialCodePoint = getPrevCodePoint(str, offset);
  11984. offset -= (initialCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  11985. var graphemeBreakType = graphemeBreakTree.getGraphemeBreakType(initialCodePoint);
  11986. while (offset > 0) {
  11987. var prevCodePoint = getPrevCodePoint(str, offset);
  11988. var prevGraphemeBreakType = graphemeBreakTree.getGraphemeBreakType(prevCodePoint);
  11989. if (breakBetweenGraphemeBreakType(prevGraphemeBreakType, graphemeBreakType)) {
  11990. break;
  11991. }
  11992. offset -= (prevCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  11993. graphemeBreakType = prevGraphemeBreakType;
  11994. }
  11995. return (initialOffset - offset);
  11996. }
  11997. exports.prevCharLength = prevCharLength;
  11998. /**
  11999. * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-rtl-test.js
  12000. */
  12001. var CONTAINS_RTL = /(?:[\u05BE\u05C0\u05C3\u05C6\u05D0-\u05F4\u0608\u060B\u060D\u061B-\u064A\u066D-\u066F\u0671-\u06D5\u06E5\u06E6\u06EE\u06EF\u06FA-\u0710\u0712-\u072F\u074D-\u07A5\u07B1-\u07EA\u07F4\u07F5\u07FA-\u0815\u081A\u0824\u0828\u0830-\u0858\u085E-\u08BD\u200F\uFB1D\uFB1F-\uFB28\uFB2A-\uFD3D\uFD50-\uFDFC\uFE70-\uFEFC]|\uD802[\uDC00-\uDD1B\uDD20-\uDE00\uDE10-\uDE33\uDE40-\uDEE4\uDEEB-\uDF35\uDF40-\uDFFF]|\uD803[\uDC00-\uDCFF]|\uD83A[\uDC00-\uDCCF\uDD00-\uDD43\uDD50-\uDFFF]|\uD83B[\uDC00-\uDEBB])/;
  12002. /**
  12003. * Returns true if `str` contains any Unicode character that is classified as "R" or "AL".
  12004. */
  12005. function containsRTL(str) {
  12006. return CONTAINS_RTL.test(str);
  12007. }
  12008. exports.containsRTL = containsRTL;
  12009. /**
  12010. * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-emoji-test.js
  12011. */
  12012. var CONTAINS_EMOJI = /(?:[\u231A\u231B\u23F0\u23F3\u2600-\u27BF\u2B50\u2B55]|\uD83C[\uDDE6-\uDDFF\uDF00-\uDFFF]|\uD83D[\uDC00-\uDE4F\uDE80-\uDEFC\uDFE0-\uDFEB]|\uD83E[\uDD00-\uDDFF\uDE70-\uDE73\uDE78-\uDE82\uDE90-\uDE95])/;
  12013. function containsEmoji(str) {
  12014. return CONTAINS_EMOJI.test(str);
  12015. }
  12016. exports.containsEmoji = containsEmoji;
  12017. var IS_BASIC_ASCII = /^[\t\n\r\x20-\x7E]*$/;
  12018. /**
  12019. * Returns true if `str` contains only basic ASCII characters in the range 32 - 126 (including 32 and 126) or \n, \r, \t
  12020. */
  12021. function isBasicASCII(str) {
  12022. return IS_BASIC_ASCII.test(str);
  12023. }
  12024. exports.isBasicASCII = isBasicASCII;
  12025. function containsFullWidthCharacter(str) {
  12026. for (var i = 0, len = str.length; i < len; i++) {
  12027. if (isFullWidthCharacter(str.charCodeAt(i))) {
  12028. return true;
  12029. }
  12030. }
  12031. return false;
  12032. }
  12033. exports.containsFullWidthCharacter = containsFullWidthCharacter;
  12034. function isFullWidthCharacter(charCode) {
  12035. // Do a cheap trick to better support wrapping of wide characters, treat them as 2 columns
  12036. // http://jrgraphix.net/research/unicode_blocks.php
  12037. // 2E80 — 2EFF CJK Radicals Supplement
  12038. // 2F00 — 2FDF Kangxi Radicals
  12039. // 2FF0 — 2FFF Ideographic Description Characters
  12040. // 3000 — 303F CJK Symbols and Punctuation
  12041. // 3040 — 309F Hiragana
  12042. // 30A0 — 30FF Katakana
  12043. // 3100 — 312F Bopomofo
  12044. // 3130 — 318F Hangul Compatibility Jamo
  12045. // 3190 — 319F Kanbun
  12046. // 31A0 — 31BF Bopomofo Extended
  12047. // 31F0 — 31FF Katakana Phonetic Extensions
  12048. // 3200 — 32FF Enclosed CJK Letters and Months
  12049. // 3300 — 33FF CJK Compatibility
  12050. // 3400 — 4DBF CJK Unified Ideographs Extension A
  12051. // 4DC0 — 4DFF Yijing Hexagram Symbols
  12052. // 4E00 — 9FFF CJK Unified Ideographs
  12053. // A000 — A48F Yi Syllables
  12054. // A490 — A4CF Yi Radicals
  12055. // AC00 — D7AF Hangul Syllables
  12056. // [IGNORE] D800 — DB7F High Surrogates
  12057. // [IGNORE] DB80 — DBFF High Private Use Surrogates
  12058. // [IGNORE] DC00 — DFFF Low Surrogates
  12059. // [IGNORE] E000 — F8FF Private Use Area
  12060. // F900 — FAFF CJK Compatibility Ideographs
  12061. // [IGNORE] FB00 — FB4F Alphabetic Presentation Forms
  12062. // [IGNORE] FB50 — FDFF Arabic Presentation Forms-A
  12063. // [IGNORE] FE00 — FE0F Variation Selectors
  12064. // [IGNORE] FE20 — FE2F Combining Half Marks
  12065. // [IGNORE] FE30 — FE4F CJK Compatibility Forms
  12066. // [IGNORE] FE50 — FE6F Small Form Variants
  12067. // [IGNORE] FE70 — FEFF Arabic Presentation Forms-B
  12068. // FF00 — FFEF Halfwidth and Fullwidth Forms
  12069. // [https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms]
  12070. // of which FF01 - FF5E fullwidth ASCII of 21 to 7E
  12071. // [IGNORE] and FF65 - FFDC halfwidth of Katakana and Hangul
  12072. // [IGNORE] FFF0 — FFFF Specials
  12073. charCode = +charCode; // @perf
  12074. return ((charCode >= 0x2E80 && charCode <= 0xD7AF)
  12075. || (charCode >= 0xF900 && charCode <= 0xFAFF)
  12076. || (charCode >= 0xFF01 && charCode <= 0xFF5E));
  12077. }
  12078. exports.isFullWidthCharacter = isFullWidthCharacter;
  12079. /**
  12080. * A fast function (therefore imprecise) to check if code points are emojis.
  12081. * Generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-emoji-test.js
  12082. */
  12083. function isEmojiImprecise(x) {
  12084. return ((x >= 0x1F1E6 && x <= 0x1F1FF) || (x >= 9728 && x <= 10175) || (x >= 127744 && x <= 128591)
  12085. || (x >= 128640 && x <= 128764) || (x >= 128992 && x <= 129003) || (x >= 129280 && x <= 129535)
  12086. || (x >= 129648 && x <= 129651) || (x >= 129656 && x <= 129666) || (x >= 129680 && x <= 129685));
  12087. }
  12088. exports.isEmojiImprecise = isEmojiImprecise;
  12089. // -- UTF-8 BOM
  12090. exports.UTF8_BOM_CHARACTER = String.fromCharCode(65279 /* UTF8_BOM */);
  12091. function startsWithUTF8BOM(str) {
  12092. return !!(str && str.length > 0 && str.charCodeAt(0) === 65279 /* UTF8_BOM */);
  12093. }
  12094. exports.startsWithUTF8BOM = startsWithUTF8BOM;
  12095. function safeBtoa(str) {
  12096. return btoa(encodeURIComponent(str)); // we use encodeURIComponent because btoa fails for non Latin 1 values
  12097. }
  12098. exports.safeBtoa = safeBtoa;
  12099. function repeat(s, count) {
  12100. var result = '';
  12101. for (var i = 0; i < count; i++) {
  12102. result += s;
  12103. }
  12104. return result;
  12105. }
  12106. exports.repeat = repeat;
  12107. function containsUppercaseCharacter(target, ignoreEscapedChars) {
  12108. if (ignoreEscapedChars === void 0) { ignoreEscapedChars = false; }
  12109. if (!target) {
  12110. return false;
  12111. }
  12112. if (ignoreEscapedChars) {
  12113. target = target.replace(/\\./g, '');
  12114. }
  12115. return target.toLowerCase() !== target;
  12116. }
  12117. exports.containsUppercaseCharacter = containsUppercaseCharacter;
  12118. /**
  12119. * Produces 'a'-'z', followed by 'A'-'Z'... followed by 'a'-'z', etc.
  12120. */
  12121. function singleLetterHash(n) {
  12122. var LETTERS_CNT = (90 /* Z */ - 65 /* A */ + 1);
  12123. n = n % (2 * LETTERS_CNT);
  12124. if (n < LETTERS_CNT) {
  12125. return String.fromCharCode(97 /* a */ + n);
  12126. }
  12127. return String.fromCharCode(65 /* A */ + n - LETTERS_CNT);
  12128. }
  12129. exports.singleLetterHash = singleLetterHash;
  12130. //#region Unicode Grapheme Break
  12131. function getGraphemeBreakType(codePoint) {
  12132. var graphemeBreakTree = GraphemeBreakTree.getInstance();
  12133. return graphemeBreakTree.getGraphemeBreakType(codePoint);
  12134. }
  12135. exports.getGraphemeBreakType = getGraphemeBreakType;
  12136. function breakBetweenGraphemeBreakType(breakTypeA, breakTypeB) {
  12137. // http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundary_Rules
  12138. // !!! Let's make the common case a bit faster
  12139. if (breakTypeA === 0 /* Other */) {
  12140. // see https://www.unicode.org/Public/13.0.0/ucd/auxiliary/GraphemeBreakTest-13.0.0d10.html#table
  12141. return (breakTypeB !== 5 /* Extend */ && breakTypeB !== 7 /* SpacingMark */);
  12142. }
  12143. // Do not break between a CR and LF. Otherwise, break before and after controls.
  12144. // GB3 CR × LF
  12145. // GB4 (Control | CR | LF) ÷
  12146. // GB5 ÷ (Control | CR | LF)
  12147. if (breakTypeA === 2 /* CR */) {
  12148. if (breakTypeB === 3 /* LF */) {
  12149. return false; // GB3
  12150. }
  12151. }
  12152. if (breakTypeA === 4 /* Control */ || breakTypeA === 2 /* CR */ || breakTypeA === 3 /* LF */) {
  12153. return true; // GB4
  12154. }
  12155. if (breakTypeB === 4 /* Control */ || breakTypeB === 2 /* CR */ || breakTypeB === 3 /* LF */) {
  12156. return true; // GB5
  12157. }
  12158. // Do not break Hangul syllable sequences.
  12159. // GB6 L × (L | V | LV | LVT)
  12160. // GB7 (LV | V) × (V | T)
  12161. // GB8 (LVT | T) × T
  12162. if (breakTypeA === 8 /* L */) {
  12163. if (breakTypeB === 8 /* L */ || breakTypeB === 9 /* V */ || breakTypeB === 11 /* LV */ || breakTypeB === 12 /* LVT */) {
  12164. return false; // GB6
  12165. }
  12166. }
  12167. if (breakTypeA === 11 /* LV */ || breakTypeA === 9 /* V */) {
  12168. if (breakTypeB === 9 /* V */ || breakTypeB === 10 /* T */) {
  12169. return false; // GB7
  12170. }
  12171. }
  12172. if (breakTypeA === 12 /* LVT */ || breakTypeA === 10 /* T */) {
  12173. if (breakTypeB === 10 /* T */) {
  12174. return false; // GB8
  12175. }
  12176. }
  12177. // Do not break before extending characters or ZWJ.
  12178. // GB9 × (Extend | ZWJ)
  12179. if (breakTypeB === 5 /* Extend */ || breakTypeB === 13 /* ZWJ */) {
  12180. return false; // GB9
  12181. }
  12182. // The GB9a and GB9b rules only apply to extended grapheme clusters:
  12183. // Do not break before SpacingMarks, or after Prepend characters.
  12184. // GB9a × SpacingMark
  12185. // GB9b Prepend ×
  12186. if (breakTypeB === 7 /* SpacingMark */) {
  12187. return false; // GB9a
  12188. }
  12189. if (breakTypeA === 1 /* Prepend */) {
  12190. return false; // GB9b
  12191. }
  12192. // Do not break within emoji modifier sequences or emoji zwj sequences.
  12193. // GB11 \p{Extended_Pictographic} Extend* ZWJ × \p{Extended_Pictographic}
  12194. if (breakTypeA === 13 /* ZWJ */ && breakTypeB === 14 /* Extended_Pictographic */) {
  12195. // Note: we are not implementing the rule entirely here to avoid introducing states
  12196. return false; // GB11
  12197. }
  12198. // GB12 sot (RI RI)* RI × RI
  12199. // GB13 [^RI] (RI RI)* RI × RI
  12200. if (breakTypeA === 6 /* Regional_Indicator */ && breakTypeB === 6 /* Regional_Indicator */) {
  12201. // Note: we are not implementing the rule entirely here to avoid introducing states
  12202. return false; // GB12 & GB13
  12203. }
  12204. // GB999 Any ÷ Any
  12205. return true;
  12206. }
  12207. exports.breakBetweenGraphemeBreakType = breakBetweenGraphemeBreakType;
  12208. var GraphemeBreakTree = /** @class */ (function () {
  12209. function GraphemeBreakTree() {
  12210. this._data = getGraphemeBreakRawData();
  12211. }
  12212. GraphemeBreakTree.getInstance = function () {
  12213. if (!GraphemeBreakTree._INSTANCE) {
  12214. GraphemeBreakTree._INSTANCE = new GraphemeBreakTree();
  12215. }
  12216. return GraphemeBreakTree._INSTANCE;
  12217. };
  12218. GraphemeBreakTree.prototype.getGraphemeBreakType = function (codePoint) {
  12219. // !!! Let's make 7bit ASCII a bit faster: 0..31
  12220. if (codePoint < 32) {
  12221. if (codePoint === 10 /* LineFeed */) {
  12222. return 3 /* LF */;
  12223. }
  12224. if (codePoint === 13 /* CarriageReturn */) {
  12225. return 2 /* CR */;
  12226. }
  12227. return 4 /* Control */;
  12228. }
  12229. // !!! Let's make 7bit ASCII a bit faster: 32..126
  12230. if (codePoint < 127) {
  12231. return 0 /* Other */;
  12232. }
  12233. var data = this._data;
  12234. var nodeCount = data.length / 3;
  12235. var nodeIndex = 1;
  12236. while (nodeIndex <= nodeCount) {
  12237. if (codePoint < data[3 * nodeIndex]) {
  12238. // go left
  12239. nodeIndex = 2 * nodeIndex;
  12240. }
  12241. else if (codePoint > data[3 * nodeIndex + 1]) {
  12242. // go right
  12243. nodeIndex = 2 * nodeIndex + 1;
  12244. }
  12245. else {
  12246. // hit
  12247. return data[3 * nodeIndex + 2];
  12248. }
  12249. }
  12250. return 0 /* Other */;
  12251. };
  12252. GraphemeBreakTree._INSTANCE = null;
  12253. return GraphemeBreakTree;
  12254. }());
  12255. function getGraphemeBreakRawData() {
  12256. // generated using https://github.com/alexandrudima/unicode-utils/blob/master/generate-grapheme-break.js
  12257. return JSON.parse('[0,0,0,51592,51592,11,44424,44424,11,72251,72254,5,7150,7150,7,48008,48008,11,55176,55176,11,128420,128420,14,3276,3277,5,9979,9980,14,46216,46216,11,49800,49800,11,53384,53384,11,70726,70726,5,122915,122916,5,129320,129327,14,2558,2558,5,5906,5908,5,9762,9763,14,43360,43388,8,45320,45320,11,47112,47112,11,48904,48904,11,50696,50696,11,52488,52488,11,54280,54280,11,70082,70083,1,71350,71350,7,73111,73111,5,127892,127893,14,128726,128727,14,129473,129474,14,2027,2035,5,2901,2902,5,3784,3789,5,6754,6754,5,8418,8420,5,9877,9877,14,11088,11088,14,44008,44008,5,44872,44872,11,45768,45768,11,46664,46664,11,47560,47560,11,48456,48456,11,49352,49352,11,50248,50248,11,51144,51144,11,52040,52040,11,52936,52936,11,53832,53832,11,54728,54728,11,69811,69814,5,70459,70460,5,71096,71099,7,71998,71998,5,72874,72880,5,119149,119149,7,127374,127374,14,128335,128335,14,128482,128482,14,128765,128767,14,129399,129400,14,129680,129685,14,1476,1477,5,2377,2380,7,2759,2760,5,3137,3140,7,3458,3459,7,4153,4154,5,6432,6434,5,6978,6978,5,7675,7679,5,9723,9726,14,9823,9823,14,9919,9923,14,10035,10036,14,42736,42737,5,43596,43596,5,44200,44200,11,44648,44648,11,45096,45096,11,45544,45544,11,45992,45992,11,46440,46440,11,46888,46888,11,47336,47336,11,47784,47784,11,48232,48232,11,48680,48680,11,49128,49128,11,49576,49576,11,50024,50024,11,50472,50472,11,50920,50920,11,51368,51368,11,51816,51816,11,52264,52264,11,52712,52712,11,53160,53160,11,53608,53608,11,54056,54056,11,54504,54504,11,54952,54952,11,68108,68111,5,69933,69940,5,70197,70197,7,70498,70499,7,70845,70845,5,71229,71229,5,71727,71735,5,72154,72155,5,72344,72345,5,73023,73029,5,94095,94098,5,121403,121452,5,126981,127182,14,127538,127546,14,127990,127990,14,128391,128391,14,128445,128449,14,128500,128505,14,128752,128752,14,129160,129167,14,129356,129356,14,129432,129442,14,129648,129651,14,129751,131069,14,173,173,4,1757,1757,1,2274,2274,1,2494,2494,5,2641,2641,5,2876,2876,5,3014,3016,7,3262,3262,7,3393,3396,5,3570,3571,7,3968,3972,5,4228,4228,7,6086,6086,5,6679,6680,5,6912,6915,5,7080,7081,5,7380,7392,5,8252,8252,14,9096,9096,14,9748,9749,14,9784,9786,14,9833,9850,14,9890,9894,14,9938,9938,14,9999,9999,14,10085,10087,14,12349,12349,14,43136,43137,7,43454,43456,7,43755,43755,7,44088,44088,11,44312,44312,11,44536,44536,11,44760,44760,11,44984,44984,11,45208,45208,11,45432,45432,11,45656,45656,11,45880,45880,11,46104,46104,11,46328,46328,11,46552,46552,11,46776,46776,11,47000,47000,11,47224,47224,11,47448,47448,11,47672,47672,11,47896,47896,11,48120,48120,11,48344,48344,11,48568,48568,11,48792,48792,11,49016,49016,11,49240,49240,11,49464,49464,11,49688,49688,11,49912,49912,11,50136,50136,11,50360,50360,11,50584,50584,11,50808,50808,11,51032,51032,11,51256,51256,11,51480,51480,11,51704,51704,11,51928,51928,11,52152,52152,11,52376,52376,11,52600,52600,11,52824,52824,11,53048,53048,11,53272,53272,11,53496,53496,11,53720,53720,11,53944,53944,11,54168,54168,11,54392,54392,11,54616,54616,11,54840,54840,11,55064,55064,11,65438,65439,5,69633,69633,5,69837,69837,1,70018,70018,7,70188,70190,7,70368,70370,7,70465,70468,7,70712,70719,5,70835,70840,5,70850,70851,5,71132,71133,5,71340,71340,7,71458,71461,5,71985,71989,7,72002,72002,7,72193,72202,5,72281,72283,5,72766,72766,7,72885,72886,5,73104,73105,5,92912,92916,5,113824,113827,4,119173,119179,5,121505,121519,5,125136,125142,5,127279,127279,14,127489,127490,14,127570,127743,14,127900,127901,14,128254,128254,14,128369,128370,14,128400,128400,14,128425,128432,14,128468,128475,14,128489,128494,14,128715,128720,14,128745,128745,14,128759,128760,14,129004,129023,14,129296,129304,14,129340,129342,14,129388,129392,14,129404,129407,14,129454,129455,14,129485,129487,14,129659,129663,14,129719,129727,14,917536,917631,5,13,13,2,1160,1161,5,1564,1564,4,1807,1807,1,2085,2087,5,2363,2363,7,2402,2403,5,2507,2508,7,2622,2624,7,2691,2691,7,2786,2787,5,2881,2884,5,3006,3006,5,3072,3072,5,3170,3171,5,3267,3268,7,3330,3331,7,3406,3406,1,3538,3540,5,3655,3662,5,3897,3897,5,4038,4038,5,4184,4185,5,4352,4447,8,6068,6069,5,6155,6157,5,6448,6449,7,6742,6742,5,6783,6783,5,6966,6970,5,7042,7042,7,7143,7143,7,7212,7219,5,7412,7412,5,8206,8207,4,8294,8303,4,8596,8601,14,9410,9410,14,9742,9742,14,9757,9757,14,9770,9770,14,9794,9794,14,9828,9828,14,9855,9855,14,9882,9882,14,9900,9903,14,9929,9933,14,9963,9967,14,9987,9988,14,10006,10006,14,10062,10062,14,10175,10175,14,11744,11775,5,42607,42607,5,43043,43044,7,43263,43263,5,43444,43445,7,43569,43570,5,43698,43700,5,43766,43766,5,44032,44032,11,44144,44144,11,44256,44256,11,44368,44368,11,44480,44480,11,44592,44592,11,44704,44704,11,44816,44816,11,44928,44928,11,45040,45040,11,45152,45152,11,45264,45264,11,45376,45376,11,45488,45488,11,45600,45600,11,45712,45712,11,45824,45824,11,45936,45936,11,46048,46048,11,46160,46160,11,46272,46272,11,46384,46384,11,46496,46496,11,46608,46608,11,46720,46720,11,46832,46832,11,46944,46944,11,47056,47056,11,47168,47168,11,47280,47280,11,47392,47392,11,47504,47504,11,47616,47616,11,47728,47728,11,47840,47840,11,47952,47952,11,48064,48064,11,48176,48176,11,48288,48288,11,48400,48400,11,48512,48512,11,48624,48624,11,48736,48736,11,48848,48848,11,48960,48960,11,49072,49072,11,49184,49184,11,49296,49296,11,49408,49408,11,49520,49520,11,49632,49632,11,49744,49744,11,49856,49856,11,49968,49968,11,50080,50080,11,50192,50192,11,50304,50304,11,50416,50416,11,50528,50528,11,50640,50640,11,50752,50752,11,50864,50864,11,50976,50976,11,51088,51088,11,51200,51200,11,51312,51312,11,51424,51424,11,51536,51536,11,51648,51648,11,51760,51760,11,51872,51872,11,51984,51984,11,52096,52096,11,52208,52208,11,52320,52320,11,52432,52432,11,52544,52544,11,52656,52656,11,52768,52768,11,52880,52880,11,52992,52992,11,53104,53104,11,53216,53216,11,53328,53328,11,53440,53440,11,53552,53552,11,53664,53664,11,53776,53776,11,53888,53888,11,54000,54000,11,54112,54112,11,54224,54224,11,54336,54336,11,54448,54448,11,54560,54560,11,54672,54672,11,54784,54784,11,54896,54896,11,55008,55008,11,55120,55120,11,64286,64286,5,66272,66272,5,68900,68903,5,69762,69762,7,69817,69818,5,69927,69931,5,70003,70003,5,70070,70078,5,70094,70094,7,70194,70195,7,70206,70206,5,70400,70401,5,70463,70463,7,70475,70477,7,70512,70516,5,70722,70724,5,70832,70832,5,70842,70842,5,70847,70848,5,71088,71089,7,71102,71102,7,71219,71226,5,71231,71232,5,71342,71343,7,71453,71455,5,71463,71467,5,71737,71738,5,71995,71996,5,72000,72000,7,72145,72147,7,72160,72160,5,72249,72249,7,72273,72278,5,72330,72342,5,72752,72758,5,72850,72871,5,72882,72883,5,73018,73018,5,73031,73031,5,73109,73109,5,73461,73462,7,94031,94031,5,94192,94193,7,119142,119142,7,119155,119162,4,119362,119364,5,121476,121476,5,122888,122904,5,123184,123190,5,126976,126979,14,127184,127231,14,127344,127345,14,127405,127461,14,127514,127514,14,127561,127567,14,127778,127779,14,127896,127896,14,127985,127986,14,127995,127999,5,128326,128328,14,128360,128366,14,128378,128378,14,128394,128397,14,128405,128406,14,128422,128423,14,128435,128443,14,128453,128464,14,128479,128480,14,128484,128487,14,128496,128498,14,128640,128709,14,128723,128724,14,128736,128741,14,128747,128748,14,128755,128755,14,128762,128762,14,128981,128991,14,129096,129103,14,129292,129292,14,129311,129311,14,129329,129330,14,129344,129349,14,129360,129374,14,129394,129394,14,129402,129402,14,129413,129425,14,129445,129450,14,129466,129471,14,129483,129483,14,129511,129535,14,129653,129655,14,129667,129670,14,129705,129711,14,129731,129743,14,917505,917505,4,917760,917999,5,10,10,3,127,159,4,768,879,5,1471,1471,5,1536,1541,1,1648,1648,5,1767,1768,5,1840,1866,5,2070,2073,5,2137,2139,5,2307,2307,7,2366,2368,7,2382,2383,7,2434,2435,7,2497,2500,5,2519,2519,5,2563,2563,7,2631,2632,5,2677,2677,5,2750,2752,7,2763,2764,7,2817,2817,5,2879,2879,5,2891,2892,7,2914,2915,5,3008,3008,5,3021,3021,5,3076,3076,5,3146,3149,5,3202,3203,7,3264,3265,7,3271,3272,7,3298,3299,5,3390,3390,5,3402,3404,7,3426,3427,5,3535,3535,5,3544,3550,7,3635,3635,7,3763,3763,7,3893,3893,5,3953,3966,5,3981,3991,5,4145,4145,7,4157,4158,5,4209,4212,5,4237,4237,5,4520,4607,10,5970,5971,5,6071,6077,5,6089,6099,5,6277,6278,5,6439,6440,5,6451,6456,7,6683,6683,5,6744,6750,5,6765,6770,7,6846,6846,5,6964,6964,5,6972,6972,5,7019,7027,5,7074,7077,5,7083,7085,5,7146,7148,7,7154,7155,7,7222,7223,5,7394,7400,5,7416,7417,5,8204,8204,5,8233,8233,4,8288,8292,4,8413,8416,5,8482,8482,14,8986,8987,14,9193,9203,14,9654,9654,14,9733,9733,14,9745,9745,14,9752,9752,14,9760,9760,14,9766,9766,14,9774,9775,14,9792,9792,14,9800,9811,14,9825,9826,14,9831,9831,14,9852,9853,14,9872,9873,14,9880,9880,14,9885,9887,14,9896,9897,14,9906,9916,14,9926,9927,14,9936,9936,14,9941,9960,14,9974,9974,14,9982,9985,14,9992,9997,14,10002,10002,14,10017,10017,14,10055,10055,14,10071,10071,14,10145,10145,14,11013,11015,14,11503,11505,5,12334,12335,5,12951,12951,14,42612,42621,5,43014,43014,5,43047,43047,7,43204,43205,5,43335,43345,5,43395,43395,7,43450,43451,7,43561,43566,5,43573,43574,5,43644,43644,5,43710,43711,5,43758,43759,7,44005,44005,5,44012,44012,7,44060,44060,11,44116,44116,11,44172,44172,11,44228,44228,11,44284,44284,11,44340,44340,11,44396,44396,11,44452,44452,11,44508,44508,11,44564,44564,11,44620,44620,11,44676,44676,11,44732,44732,11,44788,44788,11,44844,44844,11,44900,44900,11,44956,44956,11,45012,45012,11,45068,45068,11,45124,45124,11,45180,45180,11,45236,45236,11,45292,45292,11,45348,45348,11,45404,45404,11,45460,45460,11,45516,45516,11,45572,45572,11,45628,45628,11,45684,45684,11,45740,45740,11,45796,45796,11,45852,45852,11,45908,45908,11,45964,45964,11,46020,46020,11,46076,46076,11,46132,46132,11,46188,46188,11,46244,46244,11,46300,46300,11,46356,46356,11,46412,46412,11,46468,46468,11,46524,46524,11,46580,46580,11,46636,46636,11,46692,46692,11,46748,46748,11,46804,46804,11,46860,46860,11,46916,46916,11,46972,46972,11,47028,47028,11,47084,47084,11,47140,47140,11,47196,47196,11,47252,47252,11,47308,47308,11,47364,47364,11,47420,47420,11,47476,47476,11,47532,47532,11,47588,47588,11,47644,47644,11,47700,47700,11,47756,47756,11,47812,47812,11,47868,47868,11,47924,47924,11,47980,47980,11,48036,48036,11,48092,48092,11,48148,48148,11,48204,48204,11,48260,48260,11,48316,48316,11,48372,48372,11,48428,48428,11,48484,48484,11,48540,48540,11,48596,48596,11,48652,48652,11,48708,48708,11,48764,48764,11,48820,48820,11,48876,48876,11,48932,48932,11,48988,48988,11,49044,49044,11,49100,49100,11,49156,49156,11,49212,49212,11,49268,49268,11,49324,49324,11,49380,49380,11,49436,49436,11,49492,49492,11,49548,49548,11,49604,49604,11,49660,49660,11,49716,49716,11,49772,49772,11,49828,49828,11,49884,49884,11,49940,49940,11,49996,49996,11,50052,50052,11,50108,50108,11,50164,50164,11,50220,50220,11,50276,50276,11,50332,50332,11,50388,50388,11,50444,50444,11,50500,50500,11,50556,50556,11,50612,50612,11,50668,50668,11,50724,50724,11,50780,50780,11,50836,50836,11,50892,50892,11,50948,50948,11,51004,51004,11,51060,51060,11,51116,51116,11,51172,51172,11,51228,51228,11,51284,51284,11,51340,51340,11,51396,51396,11,51452,51452,11,51508,51508,11,51564,51564,11,51620,51620,11,51676,51676,11,51732,51732,11,51788,51788,11,51844,51844,11,51900,51900,11,51956,51956,11,52012,52012,11,52068,52068,11,52124,52124,11,52180,52180,11,52236,52236,11,52292,52292,11,52348,52348,11,52404,52404,11,52460,52460,11,52516,52516,11,52572,52572,11,52628,52628,11,52684,52684,11,52740,52740,11,52796,52796,11,52852,52852,11,52908,52908,11,52964,52964,11,53020,53020,11,53076,53076,11,53132,53132,11,53188,53188,11,53244,53244,11,53300,53300,11,53356,53356,11,53412,53412,11,53468,53468,11,53524,53524,11,53580,53580,11,53636,53636,11,53692,53692,11,53748,53748,11,53804,53804,11,53860,53860,11,53916,53916,11,53972,53972,11,54028,54028,11,54084,54084,11,54140,54140,11,54196,54196,11,54252,54252,11,54308,54308,11,54364,54364,11,54420,54420,11,54476,54476,11,54532,54532,11,54588,54588,11,54644,54644,11,54700,54700,11,54756,54756,11,54812,54812,11,54868,54868,11,54924,54924,11,54980,54980,11,55036,55036,11,55092,55092,11,55148,55148,11,55216,55238,9,65056,65071,5,65529,65531,4,68097,68099,5,68159,68159,5,69446,69456,5,69688,69702,5,69808,69810,7,69815,69816,7,69821,69821,1,69888,69890,5,69932,69932,7,69957,69958,7,70016,70017,5,70067,70069,7,70079,70080,7,70089,70092,5,70095,70095,5,70191,70193,5,70196,70196,5,70198,70199,5,70367,70367,5,70371,70378,5,70402,70403,7,70462,70462,5,70464,70464,5,70471,70472,7,70487,70487,5,70502,70508,5,70709,70711,7,70720,70721,7,70725,70725,7,70750,70750,5,70833,70834,7,70841,70841,7,70843,70844,7,70846,70846,7,70849,70849,7,71087,71087,5,71090,71093,5,71100,71101,5,71103,71104,5,71216,71218,7,71227,71228,7,71230,71230,7,71339,71339,5,71341,71341,5,71344,71349,5,71351,71351,5,71456,71457,7,71462,71462,7,71724,71726,7,71736,71736,7,71984,71984,5,71991,71992,7,71997,71997,7,71999,71999,1,72001,72001,1,72003,72003,5,72148,72151,5,72156,72159,7,72164,72164,7,72243,72248,5,72250,72250,1,72263,72263,5,72279,72280,7,72324,72329,1,72343,72343,7,72751,72751,7,72760,72765,5,72767,72767,5,72873,72873,7,72881,72881,7,72884,72884,7,73009,73014,5,73020,73021,5,73030,73030,1,73098,73102,7,73107,73108,7,73110,73110,7,73459,73460,5,78896,78904,4,92976,92982,5,94033,94087,7,94180,94180,5,113821,113822,5,119141,119141,5,119143,119145,5,119150,119154,5,119163,119170,5,119210,119213,5,121344,121398,5,121461,121461,5,121499,121503,5,122880,122886,5,122907,122913,5,122918,122922,5,123628,123631,5,125252,125258,5,126980,126980,14,127183,127183,14,127245,127247,14,127340,127343,14,127358,127359,14,127377,127386,14,127462,127487,6,127491,127503,14,127535,127535,14,127548,127551,14,127568,127569,14,127744,127777,14,127780,127891,14,127894,127895,14,127897,127899,14,127902,127984,14,127987,127989,14,127991,127994,14,128000,128253,14,128255,128317,14,128329,128334,14,128336,128359,14,128367,128368,14,128371,128377,14,128379,128390,14,128392,128393,14,128398,128399,14,128401,128404,14,128407,128419,14,128421,128421,14,128424,128424,14,128433,128434,14,128444,128444,14,128450,128452,14,128465,128467,14,128476,128478,14,128481,128481,14,128483,128483,14,128488,128488,14,128495,128495,14,128499,128499,14,128506,128591,14,128710,128714,14,128721,128722,14,128725,128725,14,128728,128735,14,128742,128744,14,128746,128746,14,128749,128751,14,128753,128754,14,128756,128758,14,128761,128761,14,128763,128764,14,128884,128895,14,128992,129003,14,129036,129039,14,129114,129119,14,129198,129279,14,129293,129295,14,129305,129310,14,129312,129319,14,129328,129328,14,129331,129338,14,129343,129343,14,129351,129355,14,129357,129359,14,129375,129387,14,129393,129393,14,129395,129398,14,129401,129401,14,129403,129403,14,129408,129412,14,129426,129431,14,129443,129444,14,129451,129453,14,129456,129465,14,129472,129472,14,129475,129482,14,129484,129484,14,129488,129510,14,129536,129647,14,129652,129652,14,129656,129658,14,129664,129666,14,129671,129679,14,129686,129704,14,129712,129718,14,129728,129730,14,129744,129750,14,917504,917504,4,917506,917535,4,917632,917759,4,918000,921599,4,0,9,4,11,12,4,14,31,4,169,169,14,174,174,14,1155,1159,5,1425,1469,5,1473,1474,5,1479,1479,5,1552,1562,5,1611,1631,5,1750,1756,5,1759,1764,5,1770,1773,5,1809,1809,5,1958,1968,5,2045,2045,5,2075,2083,5,2089,2093,5,2259,2273,5,2275,2306,5,2362,2362,5,2364,2364,5,2369,2376,5,2381,2381,5,2385,2391,5,2433,2433,5,2492,2492,5,2495,2496,7,2503,2504,7,2509,2509,5,2530,2531,5,2561,2562,5,2620,2620,5,2625,2626,5,2635,2637,5,2672,2673,5,2689,2690,5,2748,2748,5,2753,2757,5,2761,2761,7,2765,2765,5,2810,2815,5,2818,2819,7,2878,2878,5,2880,2880,7,2887,2888,7,2893,2893,5,2903,2903,5,2946,2946,5,3007,3007,7,3009,3010,7,3018,3020,7,3031,3031,5,3073,3075,7,3134,3136,5,3142,3144,5,3157,3158,5,3201,3201,5,3260,3260,5,3263,3263,5,3266,3266,5,3270,3270,5,3274,3275,7,3285,3286,5,3328,3329,5,3387,3388,5,3391,3392,7,3398,3400,7,3405,3405,5,3415,3415,5,3457,3457,5,3530,3530,5,3536,3537,7,3542,3542,5,3551,3551,5,3633,3633,5,3636,3642,5,3761,3761,5,3764,3772,5,3864,3865,5,3895,3895,5,3902,3903,7,3967,3967,7,3974,3975,5,3993,4028,5,4141,4144,5,4146,4151,5,4155,4156,7,4182,4183,7,4190,4192,5,4226,4226,5,4229,4230,5,4253,4253,5,4448,4519,9,4957,4959,5,5938,5940,5,6002,6003,5,6070,6070,7,6078,6085,7,6087,6088,7,6109,6109,5,6158,6158,4,6313,6313,5,6435,6438,7,6441,6443,7,6450,6450,5,6457,6459,5,6681,6682,7,6741,6741,7,6743,6743,7,6752,6752,5,6757,6764,5,6771,6780,5,6832,6845,5,6847,6848,5,6916,6916,7,6965,6965,5,6971,6971,7,6973,6977,7,6979,6980,7,7040,7041,5,7073,7073,7,7078,7079,7,7082,7082,7,7142,7142,5,7144,7145,5,7149,7149,5,7151,7153,5,7204,7211,7,7220,7221,7,7376,7378,5,7393,7393,7,7405,7405,5,7415,7415,7,7616,7673,5,8203,8203,4,8205,8205,13,8232,8232,4,8234,8238,4,8265,8265,14,8293,8293,4,8400,8412,5,8417,8417,5,8421,8432,5,8505,8505,14,8617,8618,14,9000,9000,14,9167,9167,14,9208,9210,14,9642,9643,14,9664,9664,14,9728,9732,14,9735,9741,14,9743,9744,14,9746,9746,14,9750,9751,14,9753,9756,14,9758,9759,14,9761,9761,14,9764,9765,14,9767,9769,14,9771,9773,14,9776,9783,14,9787,9791,14,9793,9793,14,9795,9799,14,9812,9822,14,9824,9824,14,9827,9827,14,9829,9830,14,9832,9832,14,9851,9851,14,9854,9854,14,9856,9861,14,9874,9876,14,9878,9879,14,9881,9881,14,9883,9884,14,9888,9889,14,9895,9895,14,9898,9899,14,9904,9905,14,9917,9918,14,9924,9925,14,9928,9928,14,9934,9935,14,9937,9937,14,9939,9940,14,9961,9962,14,9968,9973,14,9975,9978,14,9981,9981,14,9986,9986,14,9989,9989,14,9998,9998,14,10000,10001,14,10004,10004,14,10013,10013,14,10024,10024,14,10052,10052,14,10060,10060,14,10067,10069,14,10083,10084,14,10133,10135,14,10160,10160,14,10548,10549,14,11035,11036,14,11093,11093,14,11647,11647,5,12330,12333,5,12336,12336,14,12441,12442,5,12953,12953,14,42608,42610,5,42654,42655,5,43010,43010,5,43019,43019,5,43045,43046,5,43052,43052,5,43188,43203,7,43232,43249,5,43302,43309,5,43346,43347,7,43392,43394,5,43443,43443,5,43446,43449,5,43452,43453,5,43493,43493,5,43567,43568,7,43571,43572,7,43587,43587,5,43597,43597,7,43696,43696,5,43703,43704,5,43713,43713,5,43756,43757,5,43765,43765,7,44003,44004,7,44006,44007,7,44009,44010,7,44013,44013,5,44033,44059,12,44061,44087,12,44089,44115,12,44117,44143,12,44145,44171,12,44173,44199,12,44201,44227,12,44229,44255,12,44257,44283,12,44285,44311,12,44313,44339,12,44341,44367,12,44369,44395,12,44397,44423,12,44425,44451,12,44453,44479,12,44481,44507,12,44509,44535,12,44537,44563,12,44565,44591,12,44593,44619,12,44621,44647,12,44649,44675,12,44677,44703,12,44705,44731,12,44733,44759,12,44761,44787,12,44789,44815,12,44817,44843,12,44845,44871,12,44873,44899,12,44901,44927,12,44929,44955,12,44957,44983,12,44985,45011,12,45013,45039,12,45041,45067,12,45069,45095,12,45097,45123,12,45125,45151,12,45153,45179,12,45181,45207,12,45209,45235,12,45237,45263,12,45265,45291,12,45293,45319,12,45321,45347,12,45349,45375,12,45377,45403,12,45405,45431,12,45433,45459,12,45461,45487,12,45489,45515,12,45517,45543,12,45545,45571,12,45573,45599,12,45601,45627,12,45629,45655,12,45657,45683,12,45685,45711,12,45713,45739,12,45741,45767,12,45769,45795,12,45797,45823,12,45825,45851,12,45853,45879,12,45881,45907,12,45909,45935,12,45937,45963,12,45965,45991,12,45993,46019,12,46021,46047,12,46049,46075,12,46077,46103,12,46105,46131,12,46133,46159,12,46161,46187,12,46189,46215,12,46217,46243,12,46245,46271,12,46273,46299,12,46301,46327,12,46329,46355,12,46357,46383,12,46385,46411,12,46413,46439,12,46441,46467,12,46469,46495,12,46497,46523,12,46525,46551,12,46553,46579,12,46581,46607,12,46609,46635,12,46637,46663,12,46665,46691,12,46693,46719,12,46721,46747,12,46749,46775,12,46777,46803,12,46805,46831,12,46833,46859,12,46861,46887,12,46889,46915,12,46917,46943,12,46945,46971,12,46973,46999,12,47001,47027,12,47029,47055,12,47057,47083,12,47085,47111,12,47113,47139,12,47141,47167,12,47169,47195,12,47197,47223,12,47225,47251,12,47253,47279,12,47281,47307,12,47309,47335,12,47337,47363,12,47365,47391,12,47393,47419,12,47421,47447,12,47449,47475,12,47477,47503,12,47505,47531,12,47533,47559,12,47561,47587,12,47589,47615,12,47617,47643,12,47645,47671,12,47673,47699,12,47701,47727,12,47729,47755,12,47757,47783,12,47785,47811,12,47813,47839,12,47841,47867,12,47869,47895,12,47897,47923,12,47925,47951,12,47953,47979,12,47981,48007,12,48009,48035,12,48037,48063,12,48065,48091,12,48093,48119,12,48121,48147,12,48149,48175,12,48177,48203,12,48205,48231,12,48233,48259,12,48261,48287,12,48289,48315,12,48317,48343,12,48345,48371,12,48373,48399,12,48401,48427,12,48429,48455,12,48457,48483,12,48485,48511,12,48513,48539,12,48541,48567,12,48569,48595,12,48597,48623,12,48625,48651,12,48653,48679,12,48681,48707,12,48709,48735,12,48737,48763,12,48765,48791,12,48793,48819,12,48821,48847,12,48849,48875,12,48877,48903,12,48905,48931,12,48933,48959,12,48961,48987,12,48989,49015,12,49017,49043,12,49045,49071,12,49073,49099,12,49101,49127,12,49129,49155,12,49157,49183,12,49185,49211,12,49213,49239,12,49241,49267,12,49269,49295,12,49297,49323,12,49325,49351,12,49353,49379,12,49381,49407,12,49409,49435,12,49437,49463,12,49465,49491,12,49493,49519,12,49521,49547,12,49549,49575,12,49577,49603,12,49605,49631,12,49633,49659,12,49661,49687,12,49689,49715,12,49717,49743,12,49745,49771,12,49773,49799,12,49801,49827,12,49829,49855,12,49857,49883,12,49885,49911,12,49913,49939,12,49941,49967,12,49969,49995,12,49997,50023,12,50025,50051,12,50053,50079,12,50081,50107,12,50109,50135,12,50137,50163,12,50165,50191,12,50193,50219,12,50221,50247,12,50249,50275,12,50277,50303,12,50305,50331,12,50333,50359,12,50361,50387,12,50389,50415,12,50417,50443,12,50445,50471,12,50473,50499,12,50501,50527,12,50529,50555,12,50557,50583,12,50585,50611,12,50613,50639,12,50641,50667,12,50669,50695,12,50697,50723,12,50725,50751,12,50753,50779,12,50781,50807,12,50809,50835,12,50837,50863,12,50865,50891,12,50893,50919,12,50921,50947,12,50949,50975,12,50977,51003,12,51005,51031,12,51033,51059,12,51061,51087,12,51089,51115,12,51117,51143,12,51145,51171,12,51173,51199,12,51201,51227,12,51229,51255,12,51257,51283,12,51285,51311,12,51313,51339,12,51341,51367,12,51369,51395,12,51397,51423,12,51425,51451,12,51453,51479,12,51481,51507,12,51509,51535,12,51537,51563,12,51565,51591,12,51593,51619,12,51621,51647,12,51649,51675,12,51677,51703,12,51705,51731,12,51733,51759,12,51761,51787,12,51789,51815,12,51817,51843,12,51845,51871,12,51873,51899,12,51901,51927,12,51929,51955,12,51957,51983,12,51985,52011,12,52013,52039,12,52041,52067,12,52069,52095,12,52097,52123,12,52125,52151,12,52153,52179,12,52181,52207,12,52209,52235,12,52237,52263,12,52265,52291,12,52293,52319,12,52321,52347,12,52349,52375,12,52377,52403,12,52405,52431,12,52433,52459,12,52461,52487,12,52489,52515,12,52517,52543,12,52545,52571,12,52573,52599,12,52601,52627,12,52629,52655,12,52657,52683,12,52685,52711,12,52713,52739,12,52741,52767,12,52769,52795,12,52797,52823,12,52825,52851,12,52853,52879,12,52881,52907,12,52909,52935,12,52937,52963,12,52965,52991,12,52993,53019,12,53021,53047,12,53049,53075,12,53077,53103,12,53105,53131,12,53133,53159,12,53161,53187,12,53189,53215,12,53217,53243,12,53245,53271,12,53273,53299,12,53301,53327,12,53329,53355,12,53357,53383,12,53385,53411,12,53413,53439,12,53441,53467,12,53469,53495,12,53497,53523,12,53525,53551,12,53553,53579,12,53581,53607,12,53609,53635,12,53637,53663,12,53665,53691,12,53693,53719,12,53721,53747,12,53749,53775,12,53777,53803,12,53805,53831,12,53833,53859,12,53861,53887,12,53889,53915,12,53917,53943,12,53945,53971,12,53973,53999,12,54001,54027,12,54029,54055,12,54057,54083,12,54085,54111,12,54113,54139,12,54141,54167,12,54169,54195,12,54197,54223,12,54225,54251,12,54253,54279,12,54281,54307,12,54309,54335,12,54337,54363,12,54365,54391,12,54393,54419,12,54421,54447,12,54449,54475,12,54477,54503,12,54505,54531,12,54533,54559,12,54561,54587,12,54589,54615,12,54617,54643,12,54645,54671,12,54673,54699,12,54701,54727,12,54729,54755,12,54757,54783,12,54785,54811,12,54813,54839,12,54841,54867,12,54869,54895,12,54897,54923,12,54925,54951,12,54953,54979,12,54981,55007,12,55009,55035,12,55037,55063,12,55065,55091,12,55093,55119,12,55121,55147,12,55149,55175,12,55177,55203,12,55243,55291,10,65024,65039,5,65279,65279,4,65520,65528,4,66045,66045,5,66422,66426,5,68101,68102,5,68152,68154,5,68325,68326,5,69291,69292,5,69632,69632,7,69634,69634,7,69759,69761,5]');
  12258. }
  12259. });
  12260. //#endregion
  12261. define(__m[177/*vs/base/common/extpath*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,77/*vs/base/common/path*/]), function (require, exports, strings_1, path_1) {
  12262. "use strict";
  12263. Object.defineProperty(exports, "__esModule", { value: true });
  12264. /**
  12265. * Takes a Windows OS path and changes backward slashes to forward slashes.
  12266. * This should only be done for OS paths from Windows (or user provided paths potentially from Windows).
  12267. * Using it on a Linux or MaxOS path might change it.
  12268. */
  12269. function toSlashes(osPath) {
  12270. return osPath.replace(/[\\/]/g, path_1.posix.sep);
  12271. }
  12272. exports.toSlashes = toSlashes;
  12273. function isEqualOrParent(path, candidate, ignoreCase, separator) {
  12274. if (separator === void 0) { separator = path_1.sep; }
  12275. if (path === candidate) {
  12276. return true;
  12277. }
  12278. if (!path || !candidate) {
  12279. return false;
  12280. }
  12281. if (candidate.length > path.length) {
  12282. return false;
  12283. }
  12284. if (ignoreCase) {
  12285. var beginsWith = strings_1.startsWithIgnoreCase(path, candidate);
  12286. if (!beginsWith) {
  12287. return false;
  12288. }
  12289. if (candidate.length === path.length) {
  12290. return true; // same path, different casing
  12291. }
  12292. var sepOffset = candidate.length;
  12293. if (candidate.charAt(candidate.length - 1) === separator) {
  12294. sepOffset--; // adjust the expected sep offset in case our candidate already ends in separator character
  12295. }
  12296. return path.charAt(sepOffset) === separator;
  12297. }
  12298. if (candidate.charAt(candidate.length - 1) !== separator) {
  12299. candidate += separator;
  12300. }
  12301. return path.indexOf(candidate) === 0;
  12302. }
  12303. exports.isEqualOrParent = isEqualOrParent;
  12304. function isWindowsDriveLetter(char0) {
  12305. return char0 >= 65 /* A */ && char0 <= 90 /* Z */ || char0 >= 97 /* a */ && char0 <= 122 /* z */;
  12306. }
  12307. exports.isWindowsDriveLetter = isWindowsDriveLetter;
  12308. });
  12309. /*---------------------------------------------------------------------------------------------
  12310. * Copyright (c) Microsoft Corporation. All rights reserved.
  12311. * Licensed under the MIT License. See License.txt in the project root for license information.
  12312. *--------------------------------------------------------------------------------------------*/
  12313. define(__m[61/*vs/base/common/filters*/], __M([0/*require*/,1/*exports*/,38/*vs/base/common/map*/,5/*vs/base/common/strings*/]), function (require, exports, map_1, strings) {
  12314. "use strict";
  12315. Object.defineProperty(exports, "__esModule", { value: true });
  12316. // Combined filters
  12317. /**
  12318. * @returns A filter which combines the provided set
  12319. * of filters with an or. The *first* filters that
  12320. * matches defined the return value of the returned
  12321. * filter.
  12322. */
  12323. function or() {
  12324. var filter = [];
  12325. for (var _i = 0; _i < arguments.length; _i++) {
  12326. filter[_i] = arguments[_i];
  12327. }
  12328. return function (word, wordToMatchAgainst) {
  12329. for (var i = 0, len = filter.length; i < len; i++) {
  12330. var match = filter[i](word, wordToMatchAgainst);
  12331. if (match) {
  12332. return match;
  12333. }
  12334. }
  12335. return null;
  12336. };
  12337. }
  12338. exports.or = or;
  12339. exports.matchesPrefix = _matchesPrefix.bind(undefined, true);
  12340. function _matchesPrefix(ignoreCase, word, wordToMatchAgainst) {
  12341. if (!wordToMatchAgainst || wordToMatchAgainst.length < word.length) {
  12342. return null;
  12343. }
  12344. var matches;
  12345. if (ignoreCase) {
  12346. matches = strings.startsWithIgnoreCase(wordToMatchAgainst, word);
  12347. }
  12348. else {
  12349. matches = wordToMatchAgainst.indexOf(word) === 0;
  12350. }
  12351. if (!matches) {
  12352. return null;
  12353. }
  12354. return word.length > 0 ? [{ start: 0, end: word.length }] : [];
  12355. }
  12356. // Contiguous Substring
  12357. function matchesContiguousSubString(word, wordToMatchAgainst) {
  12358. var index = wordToMatchAgainst.toLowerCase().indexOf(word.toLowerCase());
  12359. if (index === -1) {
  12360. return null;
  12361. }
  12362. return [{ start: index, end: index + word.length }];
  12363. }
  12364. exports.matchesContiguousSubString = matchesContiguousSubString;
  12365. // Substring
  12366. function matchesSubString(word, wordToMatchAgainst) {
  12367. return _matchesSubString(word.toLowerCase(), wordToMatchAgainst.toLowerCase(), 0, 0);
  12368. }
  12369. exports.matchesSubString = matchesSubString;
  12370. function _matchesSubString(word, wordToMatchAgainst, i, j) {
  12371. if (i === word.length) {
  12372. return [];
  12373. }
  12374. else if (j === wordToMatchAgainst.length) {
  12375. return null;
  12376. }
  12377. else {
  12378. if (word[i] === wordToMatchAgainst[j]) {
  12379. var result = null;
  12380. if (result = _matchesSubString(word, wordToMatchAgainst, i + 1, j + 1)) {
  12381. return join({ start: j, end: j + 1 }, result);
  12382. }
  12383. return null;
  12384. }
  12385. return _matchesSubString(word, wordToMatchAgainst, i, j + 1);
  12386. }
  12387. }
  12388. // CamelCase
  12389. function isLower(code) {
  12390. return 97 /* a */ <= code && code <= 122 /* z */;
  12391. }
  12392. function isUpper(code) {
  12393. return 65 /* A */ <= code && code <= 90 /* Z */;
  12394. }
  12395. exports.isUpper = isUpper;
  12396. function isNumber(code) {
  12397. return 48 /* Digit0 */ <= code && code <= 57 /* Digit9 */;
  12398. }
  12399. function isWhitespace(code) {
  12400. return (code === 32 /* Space */
  12401. || code === 9 /* Tab */
  12402. || code === 10 /* LineFeed */
  12403. || code === 13 /* CarriageReturn */);
  12404. }
  12405. var wordSeparators = new Set();
  12406. '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?'
  12407. .split('')
  12408. .forEach(function (s) { return wordSeparators.add(s.charCodeAt(0)); });
  12409. function isAlphanumeric(code) {
  12410. return isLower(code) || isUpper(code) || isNumber(code);
  12411. }
  12412. function join(head, tail) {
  12413. if (tail.length === 0) {
  12414. tail = [head];
  12415. }
  12416. else if (head.end === tail[0].start) {
  12417. tail[0].start = head.start;
  12418. }
  12419. else {
  12420. tail.unshift(head);
  12421. }
  12422. return tail;
  12423. }
  12424. function nextAnchor(camelCaseWord, start) {
  12425. for (var i = start; i < camelCaseWord.length; i++) {
  12426. var c = camelCaseWord.charCodeAt(i);
  12427. if (isUpper(c) || isNumber(c) || (i > 0 && !isAlphanumeric(camelCaseWord.charCodeAt(i - 1)))) {
  12428. return i;
  12429. }
  12430. }
  12431. return camelCaseWord.length;
  12432. }
  12433. function _matchesCamelCase(word, camelCaseWord, i, j) {
  12434. if (i === word.length) {
  12435. return [];
  12436. }
  12437. else if (j === camelCaseWord.length) {
  12438. return null;
  12439. }
  12440. else if (word[i] !== camelCaseWord[j].toLowerCase()) {
  12441. return null;
  12442. }
  12443. else {
  12444. var result = null;
  12445. var nextUpperIndex = j + 1;
  12446. result = _matchesCamelCase(word, camelCaseWord, i + 1, j + 1);
  12447. while (!result && (nextUpperIndex = nextAnchor(camelCaseWord, nextUpperIndex)) < camelCaseWord.length) {
  12448. result = _matchesCamelCase(word, camelCaseWord, i + 1, nextUpperIndex);
  12449. nextUpperIndex++;
  12450. }
  12451. return result === null ? null : join({ start: j, end: j + 1 }, result);
  12452. }
  12453. }
  12454. // Heuristic to avoid computing camel case matcher for words that don't
  12455. // look like camelCaseWords.
  12456. function analyzeCamelCaseWord(word) {
  12457. var upper = 0, lower = 0, alpha = 0, numeric = 0, code = 0;
  12458. for (var i = 0; i < word.length; i++) {
  12459. code = word.charCodeAt(i);
  12460. if (isUpper(code)) {
  12461. upper++;
  12462. }
  12463. if (isLower(code)) {
  12464. lower++;
  12465. }
  12466. if (isAlphanumeric(code)) {
  12467. alpha++;
  12468. }
  12469. if (isNumber(code)) {
  12470. numeric++;
  12471. }
  12472. }
  12473. var upperPercent = upper / word.length;
  12474. var lowerPercent = lower / word.length;
  12475. var alphaPercent = alpha / word.length;
  12476. var numericPercent = numeric / word.length;
  12477. return { upperPercent: upperPercent, lowerPercent: lowerPercent, alphaPercent: alphaPercent, numericPercent: numericPercent };
  12478. }
  12479. function isUpperCaseWord(analysis) {
  12480. var upperPercent = analysis.upperPercent, lowerPercent = analysis.lowerPercent;
  12481. return lowerPercent === 0 && upperPercent > 0.6;
  12482. }
  12483. function isCamelCaseWord(analysis) {
  12484. var upperPercent = analysis.upperPercent, lowerPercent = analysis.lowerPercent, alphaPercent = analysis.alphaPercent, numericPercent = analysis.numericPercent;
  12485. return lowerPercent > 0.2 && upperPercent < 0.8 && alphaPercent > 0.6 && numericPercent < 0.2;
  12486. }
  12487. // Heuristic to avoid computing camel case matcher for words that don't
  12488. // look like camel case patterns.
  12489. function isCamelCasePattern(word) {
  12490. var upper = 0, lower = 0, code = 0, whitespace = 0;
  12491. for (var i = 0; i < word.length; i++) {
  12492. code = word.charCodeAt(i);
  12493. if (isUpper(code)) {
  12494. upper++;
  12495. }
  12496. if (isLower(code)) {
  12497. lower++;
  12498. }
  12499. if (isWhitespace(code)) {
  12500. whitespace++;
  12501. }
  12502. }
  12503. if ((upper === 0 || lower === 0) && whitespace === 0) {
  12504. return word.length <= 30;
  12505. }
  12506. else {
  12507. return upper <= 5;
  12508. }
  12509. }
  12510. function matchesCamelCase(word, camelCaseWord) {
  12511. if (!camelCaseWord) {
  12512. return null;
  12513. }
  12514. camelCaseWord = camelCaseWord.trim();
  12515. if (camelCaseWord.length === 0) {
  12516. return null;
  12517. }
  12518. if (!isCamelCasePattern(word)) {
  12519. return null;
  12520. }
  12521. if (camelCaseWord.length > 60) {
  12522. return null;
  12523. }
  12524. var analysis = analyzeCamelCaseWord(camelCaseWord);
  12525. if (!isCamelCaseWord(analysis)) {
  12526. if (!isUpperCaseWord(analysis)) {
  12527. return null;
  12528. }
  12529. camelCaseWord = camelCaseWord.toLowerCase();
  12530. }
  12531. var result = null;
  12532. var i = 0;
  12533. word = word.toLowerCase();
  12534. while (i < camelCaseWord.length && (result = _matchesCamelCase(word, camelCaseWord, 0, i)) === null) {
  12535. i = nextAnchor(camelCaseWord, i + 1);
  12536. }
  12537. return result;
  12538. }
  12539. exports.matchesCamelCase = matchesCamelCase;
  12540. // Fuzzy
  12541. var fuzzyContiguousFilter = or(exports.matchesPrefix, matchesCamelCase, matchesContiguousSubString);
  12542. var fuzzySeparateFilter = or(exports.matchesPrefix, matchesCamelCase, matchesSubString);
  12543. var fuzzyRegExpCache = new map_1.LRUCache(10000); // bounded to 10000 elements
  12544. function matchesFuzzy(word, wordToMatchAgainst, enableSeparateSubstringMatching) {
  12545. if (enableSeparateSubstringMatching === void 0) { enableSeparateSubstringMatching = false; }
  12546. if (typeof word !== 'string' || typeof wordToMatchAgainst !== 'string') {
  12547. return null; // return early for invalid input
  12548. }
  12549. // Form RegExp for wildcard matches
  12550. var regexp = fuzzyRegExpCache.get(word);
  12551. if (!regexp) {
  12552. regexp = new RegExp(strings.convertSimple2RegExpPattern(word), 'i');
  12553. fuzzyRegExpCache.set(word, regexp);
  12554. }
  12555. // RegExp Filter
  12556. var match = regexp.exec(wordToMatchAgainst);
  12557. if (match) {
  12558. return [{ start: match.index, end: match.index + match[0].length }];
  12559. }
  12560. // Default Filter
  12561. return enableSeparateSubstringMatching ? fuzzySeparateFilter(word, wordToMatchAgainst) : fuzzyContiguousFilter(word, wordToMatchAgainst);
  12562. }
  12563. exports.matchesFuzzy = matchesFuzzy;
  12564. function anyScore(pattern, lowPattern, _patternPos, word, lowWord, _wordPos) {
  12565. var result = fuzzyScore(pattern, lowPattern, 0, word, lowWord, 0, true);
  12566. if (result) {
  12567. return result;
  12568. }
  12569. var matches = 0;
  12570. var score = 0;
  12571. var idx = _wordPos;
  12572. for (var patternPos = 0; patternPos < lowPattern.length && patternPos < _maxLen; ++patternPos) {
  12573. var wordPos = lowWord.indexOf(lowPattern.charAt(patternPos), idx);
  12574. if (wordPos >= 0) {
  12575. score += 1;
  12576. matches += Math.pow(2, wordPos);
  12577. idx = wordPos + 1;
  12578. }
  12579. else if (matches !== 0) {
  12580. // once we have started matching things
  12581. // we need to match the remaining pattern
  12582. // characters
  12583. break;
  12584. }
  12585. }
  12586. return [score, matches, _wordPos];
  12587. }
  12588. exports.anyScore = anyScore;
  12589. //#region --- fuzzyScore ---
  12590. function createMatches(score) {
  12591. if (typeof score === 'undefined') {
  12592. return [];
  12593. }
  12594. var matches = score[1].toString(2);
  12595. var wordStart = score[2];
  12596. var res = [];
  12597. for (var pos = wordStart; pos < _maxLen; pos++) {
  12598. if (matches[matches.length - (pos + 1)] === '1') {
  12599. var last = res[res.length - 1];
  12600. if (last && last.end === pos) {
  12601. last.end = pos + 1;
  12602. }
  12603. else {
  12604. res.push({ start: pos, end: pos + 1 });
  12605. }
  12606. }
  12607. }
  12608. return res;
  12609. }
  12610. exports.createMatches = createMatches;
  12611. var _maxLen = 128;
  12612. function initTable() {
  12613. var table = [];
  12614. var row = [0];
  12615. for (var i = 1; i <= _maxLen; i++) {
  12616. row.push(-i);
  12617. }
  12618. for (var i = 0; i <= _maxLen; i++) {
  12619. var thisRow = row.slice(0);
  12620. thisRow[0] = -i;
  12621. table.push(thisRow);
  12622. }
  12623. return table;
  12624. }
  12625. var _table = initTable();
  12626. var _scores = initTable();
  12627. var _arrows = initTable();
  12628. var _debug = false;
  12629. function printTable(table, pattern, patternLen, word, wordLen) {
  12630. function pad(s, n, pad) {
  12631. if (pad === void 0) { pad = ' '; }
  12632. while (s.length < n) {
  12633. s = pad + s;
  12634. }
  12635. return s;
  12636. }
  12637. var ret = " | |" + word.split('').map(function (c) { return pad(c, 3); }).join('|') + "\n";
  12638. for (var i = 0; i <= patternLen; i++) {
  12639. if (i === 0) {
  12640. ret += ' |';
  12641. }
  12642. else {
  12643. ret += pattern[i - 1] + "|";
  12644. }
  12645. ret += table[i].slice(0, wordLen + 1).map(function (n) { return pad(n.toString(), 3); }).join('|') + '\n';
  12646. }
  12647. return ret;
  12648. }
  12649. function printTables(pattern, patternStart, word, wordStart) {
  12650. pattern = pattern.substr(patternStart);
  12651. word = word.substr(wordStart);
  12652. console.log(printTable(_table, pattern, pattern.length, word, word.length));
  12653. console.log(printTable(_arrows, pattern, pattern.length, word, word.length));
  12654. console.log(printTable(_scores, pattern, pattern.length, word, word.length));
  12655. }
  12656. function isSeparatorAtPos(value, index) {
  12657. if (index < 0 || index >= value.length) {
  12658. return false;
  12659. }
  12660. var code = value.charCodeAt(index);
  12661. switch (code) {
  12662. case 95 /* Underline */:
  12663. case 45 /* Dash */:
  12664. case 46 /* Period */:
  12665. case 32 /* Space */:
  12666. case 47 /* Slash */:
  12667. case 92 /* Backslash */:
  12668. case 39 /* SingleQuote */:
  12669. case 34 /* DoubleQuote */:
  12670. case 58 /* Colon */:
  12671. case 36 /* DollarSign */:
  12672. return true;
  12673. default:
  12674. return false;
  12675. }
  12676. }
  12677. function isWhitespaceAtPos(value, index) {
  12678. if (index < 0 || index >= value.length) {
  12679. return false;
  12680. }
  12681. var code = value.charCodeAt(index);
  12682. switch (code) {
  12683. case 32 /* Space */:
  12684. case 9 /* Tab */:
  12685. return true;
  12686. default:
  12687. return false;
  12688. }
  12689. }
  12690. function isUpperCaseAtPos(pos, word, wordLow) {
  12691. return word[pos] !== wordLow[pos];
  12692. }
  12693. function isPatternInWord(patternLow, patternPos, patternLen, wordLow, wordPos, wordLen) {
  12694. while (patternPos < patternLen && wordPos < wordLen) {
  12695. if (patternLow[patternPos] === wordLow[wordPos]) {
  12696. patternPos += 1;
  12697. }
  12698. wordPos += 1;
  12699. }
  12700. return patternPos === patternLen; // pattern must be exhausted
  12701. }
  12702. exports.isPatternInWord = isPatternInWord;
  12703. var FuzzyScore;
  12704. (function (FuzzyScore) {
  12705. /**
  12706. * No matches and value `-100`
  12707. */
  12708. FuzzyScore.Default = Object.freeze([-100, 0, 0]);
  12709. function isDefault(score) {
  12710. return !score || (score[0] === -100 && score[1] === 0 && score[2] === 0);
  12711. }
  12712. FuzzyScore.isDefault = isDefault;
  12713. })(FuzzyScore = exports.FuzzyScore || (exports.FuzzyScore = {}));
  12714. function fuzzyScore(pattern, patternLow, patternStart, word, wordLow, wordStart, firstMatchCanBeWeak) {
  12715. var patternLen = pattern.length > _maxLen ? _maxLen : pattern.length;
  12716. var wordLen = word.length > _maxLen ? _maxLen : word.length;
  12717. if (patternStart >= patternLen || wordStart >= wordLen || (patternLen - patternStart) > (wordLen - wordStart)) {
  12718. return undefined;
  12719. }
  12720. // Run a simple check if the characters of pattern occur
  12721. // (in order) at all in word. If that isn't the case we
  12722. // stop because no match will be possible
  12723. if (!isPatternInWord(patternLow, patternStart, patternLen, wordLow, wordStart, wordLen)) {
  12724. return undefined;
  12725. }
  12726. var row = 1;
  12727. var column = 1;
  12728. var patternPos = patternStart;
  12729. var wordPos = wordStart;
  12730. // There will be a match, fill in tables
  12731. for (row = 1, patternPos = patternStart; patternPos < patternLen; row++, patternPos++) {
  12732. for (column = 1, wordPos = wordStart; wordPos < wordLen; column++, wordPos++) {
  12733. var score = _doScore(pattern, patternLow, patternPos, patternStart, word, wordLow, wordPos);
  12734. _scores[row][column] = score;
  12735. var diag = _table[row - 1][column - 1] + (score > 1 ? 1 : score);
  12736. var top_1 = _table[row - 1][column] + -1;
  12737. var left = _table[row][column - 1] + -1;
  12738. if (left >= top_1) {
  12739. // left or diag
  12740. if (left > diag) {
  12741. _table[row][column] = left;
  12742. _arrows[row][column] = 4 /* Left */;
  12743. }
  12744. else if (left === diag) {
  12745. _table[row][column] = left;
  12746. _arrows[row][column] = 4 /* Left */ | 2 /* Diag */;
  12747. }
  12748. else {
  12749. _table[row][column] = diag;
  12750. _arrows[row][column] = 2 /* Diag */;
  12751. }
  12752. }
  12753. else {
  12754. // top or diag
  12755. if (top_1 > diag) {
  12756. _table[row][column] = top_1;
  12757. _arrows[row][column] = 1 /* Top */;
  12758. }
  12759. else if (top_1 === diag) {
  12760. _table[row][column] = top_1;
  12761. _arrows[row][column] = 1 /* Top */ | 2 /* Diag */;
  12762. }
  12763. else {
  12764. _table[row][column] = diag;
  12765. _arrows[row][column] = 2 /* Diag */;
  12766. }
  12767. }
  12768. }
  12769. }
  12770. if (_debug) {
  12771. printTables(pattern, patternStart, word, wordStart);
  12772. }
  12773. _matchesCount = 0;
  12774. _topScore = -100;
  12775. _wordStart = wordStart;
  12776. _firstMatchCanBeWeak = firstMatchCanBeWeak;
  12777. _findAllMatches2(row - 1, column - 1, patternLen === wordLen ? 1 : 0, 0, false);
  12778. if (_matchesCount === 0) {
  12779. return undefined;
  12780. }
  12781. return [_topScore, _topMatch2, wordStart];
  12782. }
  12783. exports.fuzzyScore = fuzzyScore;
  12784. function _doScore(pattern, patternLow, patternPos, patternStart, word, wordLow, wordPos) {
  12785. if (patternLow[patternPos] !== wordLow[wordPos]) {
  12786. return -1;
  12787. }
  12788. if (wordPos === (patternPos - patternStart)) {
  12789. // common prefix: `foobar <-> foobaz`
  12790. // ^^^^^
  12791. if (pattern[patternPos] === word[wordPos]) {
  12792. return 7;
  12793. }
  12794. else {
  12795. return 5;
  12796. }
  12797. }
  12798. else if (isUpperCaseAtPos(wordPos, word, wordLow) && (wordPos === 0 || !isUpperCaseAtPos(wordPos - 1, word, wordLow))) {
  12799. // hitting upper-case: `foo <-> forOthers`
  12800. // ^^ ^
  12801. if (pattern[patternPos] === word[wordPos]) {
  12802. return 7;
  12803. }
  12804. else {
  12805. return 5;
  12806. }
  12807. }
  12808. else if (isSeparatorAtPos(wordLow, wordPos) && (wordPos === 0 || !isSeparatorAtPos(wordLow, wordPos - 1))) {
  12809. // hitting a separator: `. <-> foo.bar`
  12810. // ^
  12811. return 5;
  12812. }
  12813. else if (isSeparatorAtPos(wordLow, wordPos - 1) || isWhitespaceAtPos(wordLow, wordPos - 1)) {
  12814. // post separator: `foo <-> bar_foo`
  12815. // ^^^
  12816. return 5;
  12817. }
  12818. else {
  12819. return 1;
  12820. }
  12821. }
  12822. var _matchesCount = 0;
  12823. var _topMatch2 = 0;
  12824. var _topScore = 0;
  12825. var _wordStart = 0;
  12826. var _firstMatchCanBeWeak = false;
  12827. function _findAllMatches2(row, column, total, matches, lastMatched) {
  12828. if (_matchesCount >= 10 || total < -25) {
  12829. // stop when having already 10 results, or
  12830. // when a potential alignment as already 5 gaps
  12831. return;
  12832. }
  12833. var simpleMatchCount = 0;
  12834. while (row > 0 && column > 0) {
  12835. var score = _scores[row][column];
  12836. var arrow = _arrows[row][column];
  12837. if (arrow === 4 /* Left */) {
  12838. // left -> no match, skip a word character
  12839. column -= 1;
  12840. if (lastMatched) {
  12841. total -= 5; // new gap penalty
  12842. }
  12843. else if (matches !== 0) {
  12844. total -= 1; // gap penalty after first match
  12845. }
  12846. lastMatched = false;
  12847. simpleMatchCount = 0;
  12848. }
  12849. else if (arrow & 2 /* Diag */) {
  12850. if (arrow & 4 /* Left */) {
  12851. // left
  12852. _findAllMatches2(row, column - 1, matches !== 0 ? total - 1 : total, // gap penalty after first match
  12853. matches, lastMatched);
  12854. }
  12855. // diag
  12856. total += score;
  12857. row -= 1;
  12858. column -= 1;
  12859. lastMatched = true;
  12860. // match -> set a 1 at the word pos
  12861. matches += Math.pow(2, (column + _wordStart));
  12862. // count simple matches and boost a row of
  12863. // simple matches when they yield in a
  12864. // strong match.
  12865. if (score === 1) {
  12866. simpleMatchCount += 1;
  12867. if (row === 0 && !_firstMatchCanBeWeak) {
  12868. // when the first match is a weak
  12869. // match we discard it
  12870. return undefined;
  12871. }
  12872. }
  12873. else {
  12874. // boost
  12875. total += 1 + (simpleMatchCount * (score - 1));
  12876. simpleMatchCount = 0;
  12877. }
  12878. }
  12879. else {
  12880. return undefined;
  12881. }
  12882. }
  12883. total -= column >= 3 ? 9 : column * 3; // late start penalty
  12884. // dynamically keep track of the current top score
  12885. // and insert the current best score at head, the rest at tail
  12886. _matchesCount += 1;
  12887. if (total > _topScore) {
  12888. _topScore = total;
  12889. _topMatch2 = matches;
  12890. }
  12891. }
  12892. //#endregion
  12893. //#region --- graceful ---
  12894. function fuzzyScoreGracefulAggressive(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak) {
  12895. return fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, true, firstMatchCanBeWeak);
  12896. }
  12897. exports.fuzzyScoreGracefulAggressive = fuzzyScoreGracefulAggressive;
  12898. function fuzzyScoreWithPermutations(pattern, lowPattern, patternPos, word, lowWord, wordPos, aggressive, firstMatchCanBeWeak) {
  12899. var top = fuzzyScore(pattern, lowPattern, patternPos, word, lowWord, wordPos, firstMatchCanBeWeak);
  12900. if (top && !aggressive) {
  12901. // when using the original pattern yield a result we`
  12902. // return it unless we are aggressive and try to find
  12903. // a better alignment, e.g. `cno` -> `^co^ns^ole` or `^c^o^nsole`.
  12904. return top;
  12905. }
  12906. if (pattern.length >= 3) {
  12907. // When the pattern is long enough then try a few (max 7)
  12908. // permutations of the pattern to find a better match. The
  12909. // permutations only swap neighbouring characters, e.g
  12910. // `cnoso` becomes `conso`, `cnsoo`, `cnoos`.
  12911. var tries = Math.min(7, pattern.length - 1);
  12912. for (var movingPatternPos = patternPos + 1; movingPatternPos < tries; movingPatternPos++) {
  12913. var newPattern = nextTypoPermutation(pattern, movingPatternPos);
  12914. if (newPattern) {
  12915. var candidate = fuzzyScore(newPattern, newPattern.toLowerCase(), patternPos, word, lowWord, wordPos, firstMatchCanBeWeak);
  12916. if (candidate) {
  12917. candidate[0] -= 3; // permutation penalty
  12918. if (!top || candidate[0] > top[0]) {
  12919. top = candidate;
  12920. }
  12921. }
  12922. }
  12923. }
  12924. }
  12925. return top;
  12926. }
  12927. function nextTypoPermutation(pattern, patternPos) {
  12928. if (patternPos + 1 >= pattern.length) {
  12929. return undefined;
  12930. }
  12931. var swap1 = pattern[patternPos];
  12932. var swap2 = pattern[patternPos + 1];
  12933. if (swap1 === swap2) {
  12934. return undefined;
  12935. }
  12936. return pattern.slice(0, patternPos)
  12937. + swap2
  12938. + swap1
  12939. + pattern.slice(patternPos + 2);
  12940. }
  12941. });
  12942. //#endregion
  12943. /*---------------------------------------------------------------------------------------------
  12944. * Copyright (c) Microsoft Corporation. All rights reserved.
  12945. * Licensed under the MIT License. See License.txt in the project root for license information.
  12946. *--------------------------------------------------------------------------------------------*/
  12947. define(__m[178/*vs/base/common/glob*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,5/*vs/base/common/strings*/,177/*vs/base/common/extpath*/,77/*vs/base/common/path*/,38/*vs/base/common/map*/,15/*vs/base/common/async*/]), function (require, exports, arrays, strings, extpath, paths, map_1, async_1) {
  12948. "use strict";
  12949. Object.defineProperty(exports, "__esModule", { value: true });
  12950. var GLOBSTAR = '**';
  12951. var GLOB_SPLIT = '/';
  12952. var PATH_REGEX = '[/\\\\]'; // any slash or backslash
  12953. var NO_PATH_REGEX = '[^/\\\\]'; // any non-slash and non-backslash
  12954. var ALL_FORWARD_SLASHES = /\//g;
  12955. function starsToRegExp(starCount) {
  12956. switch (starCount) {
  12957. case 0:
  12958. return '';
  12959. case 1:
  12960. return NO_PATH_REGEX + "*?"; // 1 star matches any number of characters except path separator (/ and \) - non greedy (?)
  12961. default:
  12962. // Matches: (Path Sep OR Path Val followed by Path Sep OR Path Sep followed by Path Val) 0-many times
  12963. // Group is non capturing because we don't need to capture at all (?:...)
  12964. // Overall we use non-greedy matching because it could be that we match too much
  12965. return "(?:" + PATH_REGEX + "|" + NO_PATH_REGEX + "+" + PATH_REGEX + "|" + PATH_REGEX + NO_PATH_REGEX + "+)*?";
  12966. }
  12967. }
  12968. function splitGlobAware(pattern, splitChar) {
  12969. if (!pattern) {
  12970. return [];
  12971. }
  12972. var segments = [];
  12973. var inBraces = false;
  12974. var inBrackets = false;
  12975. var curVal = '';
  12976. for (var _i = 0, pattern_1 = pattern; _i < pattern_1.length; _i++) {
  12977. var char = pattern_1[_i];
  12978. switch (char) {
  12979. case splitChar:
  12980. if (!inBraces && !inBrackets) {
  12981. segments.push(curVal);
  12982. curVal = '';
  12983. continue;
  12984. }
  12985. break;
  12986. case '{':
  12987. inBraces = true;
  12988. break;
  12989. case '}':
  12990. inBraces = false;
  12991. break;
  12992. case '[':
  12993. inBrackets = true;
  12994. break;
  12995. case ']':
  12996. inBrackets = false;
  12997. break;
  12998. }
  12999. curVal += char;
  13000. }
  13001. // Tail
  13002. if (curVal) {
  13003. segments.push(curVal);
  13004. }
  13005. return segments;
  13006. }
  13007. exports.splitGlobAware = splitGlobAware;
  13008. function parseRegExp(pattern) {
  13009. if (!pattern) {
  13010. return '';
  13011. }
  13012. var regEx = '';
  13013. // Split up into segments for each slash found
  13014. var segments = splitGlobAware(pattern, GLOB_SPLIT);
  13015. // Special case where we only have globstars
  13016. if (segments.every(function (s) { return s === GLOBSTAR; })) {
  13017. regEx = '.*';
  13018. }
  13019. // Build regex over segments
  13020. else {
  13021. var previousSegmentWasGlobStar_1 = false;
  13022. segments.forEach(function (segment, index) {
  13023. // Globstar is special
  13024. if (segment === GLOBSTAR) {
  13025. // if we have more than one globstar after another, just ignore it
  13026. if (!previousSegmentWasGlobStar_1) {
  13027. regEx += starsToRegExp(2);
  13028. previousSegmentWasGlobStar_1 = true;
  13029. }
  13030. return;
  13031. }
  13032. // States
  13033. var inBraces = false;
  13034. var braceVal = '';
  13035. var inBrackets = false;
  13036. var bracketVal = '';
  13037. for (var _i = 0, segment_1 = segment; _i < segment_1.length; _i++) {
  13038. var char = segment_1[_i];
  13039. // Support brace expansion
  13040. if (char !== '}' && inBraces) {
  13041. braceVal += char;
  13042. continue;
  13043. }
  13044. // Support brackets
  13045. if (inBrackets && (char !== ']' || !bracketVal) /* ] is literally only allowed as first character in brackets to match it */) {
  13046. var res = void 0;
  13047. // range operator
  13048. if (char === '-') {
  13049. res = char;
  13050. }
  13051. // negation operator (only valid on first index in bracket)
  13052. else if ((char === '^' || char === '!') && !bracketVal) {
  13053. res = '^';
  13054. }
  13055. // glob split matching is not allowed within character ranges
  13056. // see http://man7.org/linux/man-pages/man7/glob.7.html
  13057. else if (char === GLOB_SPLIT) {
  13058. res = '';
  13059. }
  13060. // anything else gets escaped
  13061. else {
  13062. res = strings.escapeRegExpCharacters(char);
  13063. }
  13064. bracketVal += res;
  13065. continue;
  13066. }
  13067. switch (char) {
  13068. case '{':
  13069. inBraces = true;
  13070. continue;
  13071. case '[':
  13072. inBrackets = true;
  13073. continue;
  13074. case '}':
  13075. var choices = splitGlobAware(braceVal, ',');
  13076. // Converts {foo,bar} => [foo|bar]
  13077. var braceRegExp = "(?:" + choices.map(function (c) { return parseRegExp(c); }).join('|') + ")";
  13078. regEx += braceRegExp;
  13079. inBraces = false;
  13080. braceVal = '';
  13081. break;
  13082. case ']':
  13083. regEx += ('[' + bracketVal + ']');
  13084. inBrackets = false;
  13085. bracketVal = '';
  13086. break;
  13087. case '?':
  13088. regEx += NO_PATH_REGEX; // 1 ? matches any single character except path separator (/ and \)
  13089. continue;
  13090. case '*':
  13091. regEx += starsToRegExp(1);
  13092. continue;
  13093. default:
  13094. regEx += strings.escapeRegExpCharacters(char);
  13095. }
  13096. }
  13097. // Tail: Add the slash we had split on if there is more to come and the remaining pattern is not a globstar
  13098. // For example if pattern: some/**/*.js we want the "/" after some to be included in the RegEx to prevent
  13099. // a folder called "something" to match as well.
  13100. // However, if pattern: some/**, we tolerate that we also match on "something" because our globstar behaviour
  13101. // is to match 0-N segments.
  13102. if (index < segments.length - 1 && (segments[index + 1] !== GLOBSTAR || index + 2 < segments.length)) {
  13103. regEx += PATH_REGEX;
  13104. }
  13105. // reset state
  13106. previousSegmentWasGlobStar_1 = false;
  13107. });
  13108. }
  13109. return regEx;
  13110. }
  13111. // regexes to check for trival glob patterns that just check for String#endsWith
  13112. var T1 = /^\*\*\/\*\.[\w\.-]+$/; // **/*.something
  13113. var T2 = /^\*\*\/([\w\.-]+)\/?$/; // **/something
  13114. var T3 = /^{\*\*\/[\*\.]?[\w\.-]+\/?(,\*\*\/[\*\.]?[\w\.-]+\/?)*}$/; // {**/*.something,**/*.else} or {**/package.json,**/project.json}
  13115. var T3_2 = /^{\*\*\/[\*\.]?[\w\.-]+(\/(\*\*)?)?(,\*\*\/[\*\.]?[\w\.-]+(\/(\*\*)?)?)*}$/; // Like T3, with optional trailing /**
  13116. var T4 = /^\*\*((\/[\w\.-]+)+)\/?$/; // **/something/else
  13117. var T5 = /^([\w\.-]+(\/[\w\.-]+)*)\/?$/; // something/else
  13118. var CACHE = new map_1.LRUCache(10000); // bounded to 10000 elements
  13119. var FALSE = function () {
  13120. return false;
  13121. };
  13122. var NULL = function () {
  13123. return null;
  13124. };
  13125. function parsePattern(arg1, options) {
  13126. if (!arg1) {
  13127. return NULL;
  13128. }
  13129. // Handle IRelativePattern
  13130. var pattern;
  13131. if (typeof arg1 !== 'string') {
  13132. pattern = arg1.pattern;
  13133. }
  13134. else {
  13135. pattern = arg1;
  13136. }
  13137. // Whitespace trimming
  13138. pattern = pattern.trim();
  13139. // Check cache
  13140. var patternKey = pattern + "_" + !!options.trimForExclusions;
  13141. var parsedPattern = CACHE.get(patternKey);
  13142. if (parsedPattern) {
  13143. return wrapRelativePattern(parsedPattern, arg1);
  13144. }
  13145. // Check for Trivias
  13146. var match;
  13147. if (T1.test(pattern)) { // common pattern: **/*.txt just need endsWith check
  13148. var base_1 = pattern.substr(4); // '**/*'.length === 4
  13149. parsedPattern = function (path, basename) {
  13150. return typeof path === 'string' && strings.endsWith(path, base_1) ? pattern : null;
  13151. };
  13152. }
  13153. else if (match = T2.exec(trimForExclusions(pattern, options))) { // common pattern: **/some.txt just need basename check
  13154. parsedPattern = trivia2(match[1], pattern);
  13155. }
  13156. else if ((options.trimForExclusions ? T3_2 : T3).test(pattern)) { // repetition of common patterns (see above) {**/*.txt,**/*.png}
  13157. parsedPattern = trivia3(pattern, options);
  13158. }
  13159. else if (match = T4.exec(trimForExclusions(pattern, options))) { // common pattern: **/something/else just need endsWith check
  13160. parsedPattern = trivia4and5(match[1].substr(1), pattern, true);
  13161. }
  13162. else if (match = T5.exec(trimForExclusions(pattern, options))) { // common pattern: something/else just need equals check
  13163. parsedPattern = trivia4and5(match[1], pattern, false);
  13164. }
  13165. // Otherwise convert to pattern
  13166. else {
  13167. parsedPattern = toRegExp(pattern);
  13168. }
  13169. // Cache
  13170. CACHE.set(patternKey, parsedPattern);
  13171. return wrapRelativePattern(parsedPattern, arg1);
  13172. }
  13173. function wrapRelativePattern(parsedPattern, arg2) {
  13174. if (typeof arg2 === 'string') {
  13175. return parsedPattern;
  13176. }
  13177. return function (path, basename) {
  13178. if (!extpath.isEqualOrParent(path, arg2.base)) {
  13179. return null;
  13180. }
  13181. return parsedPattern(paths.relative(arg2.base, path), basename);
  13182. };
  13183. }
  13184. function trimForExclusions(pattern, options) {
  13185. return options.trimForExclusions && strings.endsWith(pattern, '/**') ? pattern.substr(0, pattern.length - 2) : pattern; // dropping **, tailing / is dropped later
  13186. }
  13187. // common pattern: **/some.txt just need basename check
  13188. function trivia2(base, originalPattern) {
  13189. var slashBase = "/" + base;
  13190. var backslashBase = "\\" + base;
  13191. var parsedPattern = function (path, basename) {
  13192. if (typeof path !== 'string') {
  13193. return null;
  13194. }
  13195. if (basename) {
  13196. return basename === base ? originalPattern : null;
  13197. }
  13198. return path === base || strings.endsWith(path, slashBase) || strings.endsWith(path, backslashBase) ? originalPattern : null;
  13199. };
  13200. var basenames = [base];
  13201. parsedPattern.basenames = basenames;
  13202. parsedPattern.patterns = [originalPattern];
  13203. parsedPattern.allBasenames = basenames;
  13204. return parsedPattern;
  13205. }
  13206. // repetition of common patterns (see above) {**/*.txt,**/*.png}
  13207. function trivia3(pattern, options) {
  13208. var parsedPatterns = aggregateBasenameMatches(pattern.slice(1, -1).split(',')
  13209. .map(function (pattern) { return parsePattern(pattern, options); })
  13210. .filter(function (pattern) { return pattern !== NULL; }), pattern);
  13211. var n = parsedPatterns.length;
  13212. if (!n) {
  13213. return NULL;
  13214. }
  13215. if (n === 1) {
  13216. return parsedPatterns[0];
  13217. }
  13218. var parsedPattern = function (path, basename) {
  13219. for (var i = 0, n_1 = parsedPatterns.length; i < n_1; i++) {
  13220. if (parsedPatterns[i](path, basename)) {
  13221. return pattern;
  13222. }
  13223. }
  13224. return null;
  13225. };
  13226. var withBasenames = arrays.first(parsedPatterns, function (pattern) { return !!pattern.allBasenames; });
  13227. if (withBasenames) {
  13228. parsedPattern.allBasenames = withBasenames.allBasenames;
  13229. }
  13230. var allPaths = parsedPatterns.reduce(function (all, current) { return current.allPaths ? all.concat(current.allPaths) : all; }, []);
  13231. if (allPaths.length) {
  13232. parsedPattern.allPaths = allPaths;
  13233. }
  13234. return parsedPattern;
  13235. }
  13236. // common patterns: **/something/else just need endsWith check, something/else just needs and equals check
  13237. function trivia4and5(path, pattern, matchPathEnds) {
  13238. var nativePath = paths.sep !== paths.posix.sep ? path.replace(ALL_FORWARD_SLASHES, paths.sep) : path;
  13239. var nativePathEnd = paths.sep + nativePath;
  13240. var parsedPattern = matchPathEnds ? function (path, basename) {
  13241. return typeof path === 'string' && (path === nativePath || strings.endsWith(path, nativePathEnd)) ? pattern : null;
  13242. } : function (path, basename) {
  13243. return typeof path === 'string' && path === nativePath ? pattern : null;
  13244. };
  13245. parsedPattern.allPaths = [(matchPathEnds ? '*/' : './') + path];
  13246. return parsedPattern;
  13247. }
  13248. function toRegExp(pattern) {
  13249. try {
  13250. var regExp_1 = new RegExp("^" + parseRegExp(pattern) + "$");
  13251. return function (path, basename) {
  13252. regExp_1.lastIndex = 0; // reset RegExp to its initial state to reuse it!
  13253. return typeof path === 'string' && regExp_1.test(path) ? pattern : null;
  13254. };
  13255. }
  13256. catch (error) {
  13257. return NULL;
  13258. }
  13259. }
  13260. function match(arg1, path, hasSibling) {
  13261. if (!arg1 || typeof path !== 'string') {
  13262. return false;
  13263. }
  13264. return parse(arg1)(path, undefined, hasSibling);
  13265. }
  13266. exports.match = match;
  13267. function parse(arg1, options) {
  13268. if (options === void 0) { options = {}; }
  13269. if (!arg1) {
  13270. return FALSE;
  13271. }
  13272. // Glob with String
  13273. if (typeof arg1 === 'string' || isRelativePattern(arg1)) {
  13274. var parsedPattern_1 = parsePattern(arg1, options);
  13275. if (parsedPattern_1 === NULL) {
  13276. return FALSE;
  13277. }
  13278. var resultPattern = function (path, basename) {
  13279. return !!parsedPattern_1(path, basename);
  13280. };
  13281. if (parsedPattern_1.allBasenames) {
  13282. resultPattern.allBasenames = parsedPattern_1.allBasenames;
  13283. }
  13284. if (parsedPattern_1.allPaths) {
  13285. resultPattern.allPaths = parsedPattern_1.allPaths;
  13286. }
  13287. return resultPattern;
  13288. }
  13289. // Glob with Expression
  13290. return parsedExpression(arg1, options);
  13291. }
  13292. exports.parse = parse;
  13293. function isRelativePattern(obj) {
  13294. var rp = obj;
  13295. return rp && typeof rp.base === 'string' && typeof rp.pattern === 'string';
  13296. }
  13297. exports.isRelativePattern = isRelativePattern;
  13298. function parsedExpression(expression, options) {
  13299. var parsedPatterns = aggregateBasenameMatches(Object.getOwnPropertyNames(expression)
  13300. .map(function (pattern) { return parseExpressionPattern(pattern, expression[pattern], options); })
  13301. .filter(function (pattern) { return pattern !== NULL; }));
  13302. var n = parsedPatterns.length;
  13303. if (!n) {
  13304. return NULL;
  13305. }
  13306. if (!parsedPatterns.some(function (parsedPattern) { return !!parsedPattern.requiresSiblings; })) {
  13307. if (n === 1) {
  13308. return parsedPatterns[0];
  13309. }
  13310. var resultExpression_1 = function (path, basename) {
  13311. for (var i = 0, n_2 = parsedPatterns.length; i < n_2; i++) {
  13312. // Pattern matches path
  13313. var result = parsedPatterns[i](path, basename);
  13314. if (result) {
  13315. return result;
  13316. }
  13317. }
  13318. return null;
  13319. };
  13320. var withBasenames_1 = arrays.first(parsedPatterns, function (pattern) { return !!pattern.allBasenames; });
  13321. if (withBasenames_1) {
  13322. resultExpression_1.allBasenames = withBasenames_1.allBasenames;
  13323. }
  13324. var allPaths_1 = parsedPatterns.reduce(function (all, current) { return current.allPaths ? all.concat(current.allPaths) : all; }, []);
  13325. if (allPaths_1.length) {
  13326. resultExpression_1.allPaths = allPaths_1;
  13327. }
  13328. return resultExpression_1;
  13329. }
  13330. var resultExpression = function (path, basename, hasSibling) {
  13331. var name = undefined;
  13332. for (var i = 0, n_3 = parsedPatterns.length; i < n_3; i++) {
  13333. // Pattern matches path
  13334. var parsedPattern = parsedPatterns[i];
  13335. if (parsedPattern.requiresSiblings && hasSibling) {
  13336. if (!basename) {
  13337. basename = paths.basename(path);
  13338. }
  13339. if (!name) {
  13340. name = basename.substr(0, basename.length - paths.extname(path).length);
  13341. }
  13342. }
  13343. var result = parsedPattern(path, basename, name, hasSibling);
  13344. if (result) {
  13345. return result;
  13346. }
  13347. }
  13348. return null;
  13349. };
  13350. var withBasenames = arrays.first(parsedPatterns, function (pattern) { return !!pattern.allBasenames; });
  13351. if (withBasenames) {
  13352. resultExpression.allBasenames = withBasenames.allBasenames;
  13353. }
  13354. var allPaths = parsedPatterns.reduce(function (all, current) { return current.allPaths ? all.concat(current.allPaths) : all; }, []);
  13355. if (allPaths.length) {
  13356. resultExpression.allPaths = allPaths;
  13357. }
  13358. return resultExpression;
  13359. }
  13360. function parseExpressionPattern(pattern, value, options) {
  13361. if (value === false) {
  13362. return NULL; // pattern is disabled
  13363. }
  13364. var parsedPattern = parsePattern(pattern, options);
  13365. if (parsedPattern === NULL) {
  13366. return NULL;
  13367. }
  13368. // Expression Pattern is <boolean>
  13369. if (typeof value === 'boolean') {
  13370. return parsedPattern;
  13371. }
  13372. // Expression Pattern is <SiblingClause>
  13373. if (value) {
  13374. var when_1 = value.when;
  13375. if (typeof when_1 === 'string') {
  13376. var result = function (path, basename, name, hasSibling) {
  13377. if (!hasSibling || !parsedPattern(path, basename)) {
  13378. return null;
  13379. }
  13380. var clausePattern = when_1.replace('$(basename)', name);
  13381. var matched = hasSibling(clausePattern);
  13382. return async_1.isThenable(matched) ?
  13383. matched.then(function (m) { return m ? pattern : null; }) :
  13384. matched ? pattern : null;
  13385. };
  13386. result.requiresSiblings = true;
  13387. return result;
  13388. }
  13389. }
  13390. // Expression is Anything
  13391. return parsedPattern;
  13392. }
  13393. function aggregateBasenameMatches(parsedPatterns, result) {
  13394. var basenamePatterns = parsedPatterns.filter(function (parsedPattern) { return !!parsedPattern.basenames; });
  13395. if (basenamePatterns.length < 2) {
  13396. return parsedPatterns;
  13397. }
  13398. var basenames = basenamePatterns.reduce(function (all, current) {
  13399. var basenames = current.basenames;
  13400. return basenames ? all.concat(basenames) : all;
  13401. }, []);
  13402. var patterns;
  13403. if (result) {
  13404. patterns = [];
  13405. for (var i = 0, n = basenames.length; i < n; i++) {
  13406. patterns.push(result);
  13407. }
  13408. }
  13409. else {
  13410. patterns = basenamePatterns.reduce(function (all, current) {
  13411. var patterns = current.patterns;
  13412. return patterns ? all.concat(patterns) : all;
  13413. }, []);
  13414. }
  13415. var aggregate = function (path, basename) {
  13416. if (typeof path !== 'string') {
  13417. return null;
  13418. }
  13419. if (!basename) {
  13420. var i = void 0;
  13421. for (i = path.length; i > 0; i--) {
  13422. var ch = path.charCodeAt(i - 1);
  13423. if (ch === 47 /* Slash */ || ch === 92 /* Backslash */) {
  13424. break;
  13425. }
  13426. }
  13427. basename = path.substr(i);
  13428. }
  13429. var index = basenames.indexOf(basename);
  13430. return index !== -1 ? patterns[index] : null;
  13431. };
  13432. aggregate.basenames = basenames;
  13433. aggregate.patterns = patterns;
  13434. aggregate.allBasenames = basenames;
  13435. var aggregatedPatterns = parsedPatterns.filter(function (parsedPattern) { return !parsedPattern.basenames; });
  13436. aggregatedPatterns.push(aggregate);
  13437. return aggregatedPatterns;
  13438. }
  13439. });
  13440. /*---------------------------------------------------------------------------------------------
  13441. * Copyright (c) Microsoft Corporation. All rights reserved.
  13442. * Licensed under the MIT License. See License.txt in the project root for license information.
  13443. *--------------------------------------------------------------------------------------------*/
  13444. define(__m[247/*vs/base/common/search*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/]), function (require, exports, strings) {
  13445. "use strict";
  13446. Object.defineProperty(exports, "__esModule", { value: true });
  13447. function buildReplaceStringWithCasePreserved(matches, pattern) {
  13448. if (matches && (matches[0] !== '')) {
  13449. var containsHyphens = validateSpecificSpecialCharacter(matches, pattern, '-');
  13450. var containsUnderscores = validateSpecificSpecialCharacter(matches, pattern, '_');
  13451. if (containsHyphens && !containsUnderscores) {
  13452. return buildReplaceStringForSpecificSpecialCharacter(matches, pattern, '-');
  13453. }
  13454. else if (!containsHyphens && containsUnderscores) {
  13455. return buildReplaceStringForSpecificSpecialCharacter(matches, pattern, '_');
  13456. }
  13457. if (matches[0].toUpperCase() === matches[0]) {
  13458. return pattern.toUpperCase();
  13459. }
  13460. else if (matches[0].toLowerCase() === matches[0]) {
  13461. return pattern.toLowerCase();
  13462. }
  13463. else if (strings.containsUppercaseCharacter(matches[0][0])) {
  13464. return pattern[0].toUpperCase() + pattern.substr(1);
  13465. }
  13466. else {
  13467. // we don't understand its pattern yet.
  13468. return pattern;
  13469. }
  13470. }
  13471. else {
  13472. return pattern;
  13473. }
  13474. }
  13475. exports.buildReplaceStringWithCasePreserved = buildReplaceStringWithCasePreserved;
  13476. function validateSpecificSpecialCharacter(matches, pattern, specialCharacter) {
  13477. var doesContainSpecialCharacter = matches[0].indexOf(specialCharacter) !== -1 && pattern.indexOf(specialCharacter) !== -1;
  13478. return doesContainSpecialCharacter && matches[0].split(specialCharacter).length === pattern.split(specialCharacter).length;
  13479. }
  13480. function buildReplaceStringForSpecificSpecialCharacter(matches, pattern, specialCharacter) {
  13481. var splitPatternAtSpecialCharacter = pattern.split(specialCharacter);
  13482. var splitMatchAtSpecialCharacter = matches[0].split(specialCharacter);
  13483. var replaceString = '';
  13484. splitPatternAtSpecialCharacter.forEach(function (splitValue, index) {
  13485. replaceString += buildReplaceStringWithCasePreserved([splitMatchAtSpecialCharacter[index]], splitValue) + specialCharacter;
  13486. });
  13487. return replaceString.slice(0, -1);
  13488. }
  13489. });
  13490. /*---------------------------------------------------------------------------------------------
  13491. * Copyright (c) Microsoft Corporation. All rights reserved.
  13492. * Licensed under the MIT License. See License.txt in the project root for license information.
  13493. *--------------------------------------------------------------------------------------------*/
  13494. define(__m[21/*vs/base/common/types*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  13495. "use strict";
  13496. Object.defineProperty(exports, "__esModule", { value: true });
  13497. var _typeof = {
  13498. number: 'number',
  13499. string: 'string',
  13500. undefined: 'undefined',
  13501. object: 'object',
  13502. function: 'function'
  13503. };
  13504. /**
  13505. * @returns whether the provided parameter is a JavaScript Array or not.
  13506. */
  13507. function isArray(array) {
  13508. if (Array.isArray) {
  13509. return Array.isArray(array);
  13510. }
  13511. if (array && typeof (array.length) === _typeof.number && array.constructor === Array) {
  13512. return true;
  13513. }
  13514. return false;
  13515. }
  13516. exports.isArray = isArray;
  13517. /**
  13518. * @returns whether the provided parameter is a JavaScript String or not.
  13519. */
  13520. function isString(str) {
  13521. if (typeof (str) === _typeof.string || str instanceof String) {
  13522. return true;
  13523. }
  13524. return false;
  13525. }
  13526. exports.isString = isString;
  13527. /**
  13528. *
  13529. * @returns whether the provided parameter is of type `object` but **not**
  13530. * `null`, an `array`, a `regexp`, nor a `date`.
  13531. */
  13532. function isObject(obj) {
  13533. // The method can't do a type cast since there are type (like strings) which
  13534. // are subclasses of any put not positvely matched by the function. Hence type
  13535. // narrowing results in wrong results.
  13536. return typeof obj === _typeof.object
  13537. && obj !== null
  13538. && !Array.isArray(obj)
  13539. && !(obj instanceof RegExp)
  13540. && !(obj instanceof Date);
  13541. }
  13542. exports.isObject = isObject;
  13543. /**
  13544. * In **contrast** to just checking `typeof` this will return `false` for `NaN`.
  13545. * @returns whether the provided parameter is a JavaScript Number or not.
  13546. */
  13547. function isNumber(obj) {
  13548. if ((typeof (obj) === _typeof.number || obj instanceof Number) && !isNaN(obj)) {
  13549. return true;
  13550. }
  13551. return false;
  13552. }
  13553. exports.isNumber = isNumber;
  13554. /**
  13555. * @returns whether the provided parameter is a JavaScript Boolean or not.
  13556. */
  13557. function isBoolean(obj) {
  13558. return obj === true || obj === false;
  13559. }
  13560. exports.isBoolean = isBoolean;
  13561. /**
  13562. * @returns whether the provided parameter is undefined.
  13563. */
  13564. function isUndefined(obj) {
  13565. return typeof (obj) === _typeof.undefined;
  13566. }
  13567. exports.isUndefined = isUndefined;
  13568. /**
  13569. * @returns whether the provided parameter is undefined or null.
  13570. */
  13571. function isUndefinedOrNull(obj) {
  13572. return isUndefined(obj) || obj === null;
  13573. }
  13574. exports.isUndefinedOrNull = isUndefinedOrNull;
  13575. function assertType(condition, type) {
  13576. if (!condition) {
  13577. throw new Error(type ? "Unexpected type, expected '" + type + "'" : 'Unexpected type');
  13578. }
  13579. }
  13580. exports.assertType = assertType;
  13581. var hasOwnProperty = Object.prototype.hasOwnProperty;
  13582. /**
  13583. * @returns whether the provided parameter is an empty JavaScript Object or not.
  13584. */
  13585. function isEmptyObject(obj) {
  13586. if (!isObject(obj)) {
  13587. return false;
  13588. }
  13589. for (var key in obj) {
  13590. if (hasOwnProperty.call(obj, key)) {
  13591. return false;
  13592. }
  13593. }
  13594. return true;
  13595. }
  13596. exports.isEmptyObject = isEmptyObject;
  13597. /**
  13598. * @returns whether the provided parameter is a JavaScript Function or not.
  13599. */
  13600. function isFunction(obj) {
  13601. return typeof obj === _typeof.function;
  13602. }
  13603. exports.isFunction = isFunction;
  13604. function validateConstraints(args, constraints) {
  13605. var len = Math.min(args.length, constraints.length);
  13606. for (var i = 0; i < len; i++) {
  13607. validateConstraint(args[i], constraints[i]);
  13608. }
  13609. }
  13610. exports.validateConstraints = validateConstraints;
  13611. function validateConstraint(arg, constraint) {
  13612. if (isString(constraint)) {
  13613. if (typeof arg !== constraint) {
  13614. throw new Error("argument does not match constraint: typeof " + constraint);
  13615. }
  13616. }
  13617. else if (isFunction(constraint)) {
  13618. try {
  13619. if (arg instanceof constraint) {
  13620. return;
  13621. }
  13622. }
  13623. catch (_a) {
  13624. // ignore
  13625. }
  13626. if (!isUndefinedOrNull(arg) && arg.constructor === constraint) {
  13627. return;
  13628. }
  13629. if (constraint.length === 1 && constraint.call(undefined, arg) === true) {
  13630. return;
  13631. }
  13632. throw new Error("argument does not match one of these constraints: arg instanceof constraint, arg.constructor === constraint, nor constraint(arg) === true");
  13633. }
  13634. }
  13635. exports.validateConstraint = validateConstraint;
  13636. function getAllPropertyNames(obj) {
  13637. var res = [];
  13638. var proto = Object.getPrototypeOf(obj);
  13639. while (Object.prototype !== proto) {
  13640. res = res.concat(Object.getOwnPropertyNames(proto));
  13641. proto = Object.getPrototypeOf(proto);
  13642. }
  13643. return res;
  13644. }
  13645. exports.getAllPropertyNames = getAllPropertyNames;
  13646. function getAllMethodNames(obj) {
  13647. var methods = [];
  13648. for (var _i = 0, _a = getAllPropertyNames(obj); _i < _a.length; _i++) {
  13649. var prop = _a[_i];
  13650. if (typeof obj[prop] === 'function') {
  13651. methods.push(prop);
  13652. }
  13653. }
  13654. return methods;
  13655. }
  13656. exports.getAllMethodNames = getAllMethodNames;
  13657. function createProxyObject(methodNames, invoke) {
  13658. var createProxyMethod = function (method) {
  13659. return function () {
  13660. var args = Array.prototype.slice.call(arguments, 0);
  13661. return invoke(method, args);
  13662. };
  13663. };
  13664. var result = {};
  13665. for (var _i = 0, methodNames_1 = methodNames; _i < methodNames_1.length; _i++) {
  13666. var methodName = methodNames_1[_i];
  13667. result[methodName] = createProxyMethod(methodName);
  13668. }
  13669. return result;
  13670. }
  13671. exports.createProxyObject = createProxyObject;
  13672. /**
  13673. * Converts null to undefined, passes all other values through.
  13674. */
  13675. function withNullAsUndefined(x) {
  13676. return x === null ? undefined : x;
  13677. }
  13678. exports.withNullAsUndefined = withNullAsUndefined;
  13679. /**
  13680. * Converts undefined to null, passes all other values through.
  13681. */
  13682. function withUndefinedAsNull(x) {
  13683. return typeof x === 'undefined' ? null : x;
  13684. }
  13685. exports.withUndefinedAsNull = withUndefinedAsNull;
  13686. });
  13687. /*---------------------------------------------------------------------------------------------
  13688. * Copyright (c) Microsoft Corporation. All rights reserved.
  13689. * Licensed under the MIT License. See License.txt in the project root for license information.
  13690. *--------------------------------------------------------------------------------------------*/
  13691. define(__m[31/*vs/base/common/objects*/], __M([0/*require*/,1/*exports*/,21/*vs/base/common/types*/]), function (require, exports, types_1) {
  13692. "use strict";
  13693. Object.defineProperty(exports, "__esModule", { value: true });
  13694. function deepClone(obj) {
  13695. if (!obj || typeof obj !== 'object') {
  13696. return obj;
  13697. }
  13698. if (obj instanceof RegExp) {
  13699. // See https://github.com/Microsoft/TypeScript/issues/10990
  13700. return obj;
  13701. }
  13702. var result = Array.isArray(obj) ? [] : {};
  13703. Object.keys(obj).forEach(function (key) {
  13704. if (obj[key] && typeof obj[key] === 'object') {
  13705. result[key] = deepClone(obj[key]);
  13706. }
  13707. else {
  13708. result[key] = obj[key];
  13709. }
  13710. });
  13711. return result;
  13712. }
  13713. exports.deepClone = deepClone;
  13714. function deepFreeze(obj) {
  13715. if (!obj || typeof obj !== 'object') {
  13716. return obj;
  13717. }
  13718. var stack = [obj];
  13719. while (stack.length > 0) {
  13720. var obj_1 = stack.shift();
  13721. Object.freeze(obj_1);
  13722. for (var key in obj_1) {
  13723. if (_hasOwnProperty.call(obj_1, key)) {
  13724. var prop = obj_1[key];
  13725. if (typeof prop === 'object' && !Object.isFrozen(prop)) {
  13726. stack.push(prop);
  13727. }
  13728. }
  13729. }
  13730. }
  13731. return obj;
  13732. }
  13733. exports.deepFreeze = deepFreeze;
  13734. var _hasOwnProperty = Object.prototype.hasOwnProperty;
  13735. function cloneAndChange(obj, changer) {
  13736. return _cloneAndChange(obj, changer, new Set());
  13737. }
  13738. exports.cloneAndChange = cloneAndChange;
  13739. function _cloneAndChange(obj, changer, seen) {
  13740. if (types_1.isUndefinedOrNull(obj)) {
  13741. return obj;
  13742. }
  13743. var changed = changer(obj);
  13744. if (typeof changed !== 'undefined') {
  13745. return changed;
  13746. }
  13747. if (types_1.isArray(obj)) {
  13748. var r1 = [];
  13749. for (var _i = 0, obj_2 = obj; _i < obj_2.length; _i++) {
  13750. var e = obj_2[_i];
  13751. r1.push(_cloneAndChange(e, changer, seen));
  13752. }
  13753. return r1;
  13754. }
  13755. if (types_1.isObject(obj)) {
  13756. if (seen.has(obj)) {
  13757. throw new Error('Cannot clone recursive data-structure');
  13758. }
  13759. seen.add(obj);
  13760. var r2 = {};
  13761. for (var i2 in obj) {
  13762. if (_hasOwnProperty.call(obj, i2)) {
  13763. r2[i2] = _cloneAndChange(obj[i2], changer, seen);
  13764. }
  13765. }
  13766. seen.delete(obj);
  13767. return r2;
  13768. }
  13769. return obj;
  13770. }
  13771. /**
  13772. * Copies all properties of source into destination. The optional parameter "overwrite" allows to control
  13773. * if existing properties on the destination should be overwritten or not. Defaults to true (overwrite).
  13774. */
  13775. function mixin(destination, source, overwrite) {
  13776. if (overwrite === void 0) { overwrite = true; }
  13777. if (!types_1.isObject(destination)) {
  13778. return source;
  13779. }
  13780. if (types_1.isObject(source)) {
  13781. Object.keys(source).forEach(function (key) {
  13782. if (key in destination) {
  13783. if (overwrite) {
  13784. if (types_1.isObject(destination[key]) && types_1.isObject(source[key])) {
  13785. mixin(destination[key], source[key], overwrite);
  13786. }
  13787. else {
  13788. destination[key] = source[key];
  13789. }
  13790. }
  13791. }
  13792. else {
  13793. destination[key] = source[key];
  13794. }
  13795. });
  13796. }
  13797. return destination;
  13798. }
  13799. exports.mixin = mixin;
  13800. function assign(destination) {
  13801. var sources = [];
  13802. for (var _i = 1; _i < arguments.length; _i++) {
  13803. sources[_i - 1] = arguments[_i];
  13804. }
  13805. sources.forEach(function (source) { return Object.keys(source).forEach(function (key) { return destination[key] = source[key]; }); });
  13806. return destination;
  13807. }
  13808. exports.assign = assign;
  13809. function equals(one, other) {
  13810. if (one === other) {
  13811. return true;
  13812. }
  13813. if (one === null || one === undefined || other === null || other === undefined) {
  13814. return false;
  13815. }
  13816. if (typeof one !== typeof other) {
  13817. return false;
  13818. }
  13819. if (typeof one !== 'object') {
  13820. return false;
  13821. }
  13822. if ((Array.isArray(one)) !== (Array.isArray(other))) {
  13823. return false;
  13824. }
  13825. var i;
  13826. var key;
  13827. if (Array.isArray(one)) {
  13828. if (one.length !== other.length) {
  13829. return false;
  13830. }
  13831. for (i = 0; i < one.length; i++) {
  13832. if (!equals(one[i], other[i])) {
  13833. return false;
  13834. }
  13835. }
  13836. }
  13837. else {
  13838. var oneKeys = [];
  13839. for (key in one) {
  13840. oneKeys.push(key);
  13841. }
  13842. oneKeys.sort();
  13843. var otherKeys = [];
  13844. for (key in other) {
  13845. otherKeys.push(key);
  13846. }
  13847. otherKeys.sort();
  13848. if (!equals(oneKeys, otherKeys)) {
  13849. return false;
  13850. }
  13851. for (i = 0; i < oneKeys.length; i++) {
  13852. if (!equals(one[oneKeys[i]], other[oneKeys[i]])) {
  13853. return false;
  13854. }
  13855. }
  13856. }
  13857. return true;
  13858. }
  13859. exports.equals = equals;
  13860. function getOrDefault(obj, fn, defaultValue) {
  13861. var result = fn(obj);
  13862. return typeof result === 'undefined' ? defaultValue : result;
  13863. }
  13864. exports.getOrDefault = getOrDefault;
  13865. });
  13866. /*---------------------------------------------------------------------------------------------
  13867. * Copyright (c) Microsoft Corporation. All rights reserved.
  13868. * Licensed under the MIT License. See License.txt in the project root for license information.
  13869. *--------------------------------------------------------------------------------------------*/
  13870. define(__m[133/*vs/base/browser/ui/highlightedlabel/highlightedLabel*/], __M([0/*require*/,1/*exports*/,31/*vs/base/common/objects*/,100/*vs/base/common/codicons*/,5/*vs/base/common/strings*/]), function (require, exports, objects, codicons_1, strings_1) {
  13871. "use strict";
  13872. Object.defineProperty(exports, "__esModule", { value: true });
  13873. var HighlightedLabel = /** @class */ (function () {
  13874. function HighlightedLabel(container, supportCodicons) {
  13875. this.supportCodicons = supportCodicons;
  13876. this.text = '';
  13877. this.title = '';
  13878. this.highlights = [];
  13879. this.didEverRender = false;
  13880. this.domNode = document.createElement('span');
  13881. this.domNode.className = 'monaco-highlighted-label';
  13882. container.appendChild(this.domNode);
  13883. }
  13884. Object.defineProperty(HighlightedLabel.prototype, "element", {
  13885. get: function () {
  13886. return this.domNode;
  13887. },
  13888. enumerable: true,
  13889. configurable: true
  13890. });
  13891. HighlightedLabel.prototype.set = function (text, highlights, title, escapeNewLines) {
  13892. if (highlights === void 0) { highlights = []; }
  13893. if (title === void 0) { title = ''; }
  13894. if (!text) {
  13895. text = '';
  13896. }
  13897. if (escapeNewLines) {
  13898. // adjusts highlights inplace
  13899. text = HighlightedLabel.escapeNewLines(text, highlights);
  13900. }
  13901. if (this.didEverRender && this.text === text && this.title === title && objects.equals(this.highlights, highlights)) {
  13902. return;
  13903. }
  13904. if (!Array.isArray(highlights)) {
  13905. highlights = [];
  13906. }
  13907. this.text = text;
  13908. this.title = title;
  13909. this.highlights = highlights;
  13910. this.render();
  13911. };
  13912. HighlightedLabel.prototype.render = function () {
  13913. var htmlContent = '';
  13914. var pos = 0;
  13915. for (var _i = 0, _a = this.highlights; _i < _a.length; _i++) {
  13916. var highlight = _a[_i];
  13917. if (highlight.end === highlight.start) {
  13918. continue;
  13919. }
  13920. if (pos < highlight.start) {
  13921. htmlContent += '<span>';
  13922. var substring_1 = this.text.substring(pos, highlight.start);
  13923. htmlContent += this.supportCodicons ? codicons_1.renderCodicons(strings_1.escape(substring_1)) : strings_1.escape(substring_1);
  13924. htmlContent += '</span>';
  13925. pos = highlight.end;
  13926. }
  13927. if (highlight.extraClasses) {
  13928. htmlContent += "<span class=\"highlight " + highlight.extraClasses + "\">";
  13929. }
  13930. else {
  13931. htmlContent += "<span class=\"highlight\">";
  13932. }
  13933. var substring = this.text.substring(highlight.start, highlight.end);
  13934. htmlContent += this.supportCodicons ? codicons_1.renderCodicons(strings_1.escape(substring)) : strings_1.escape(substring);
  13935. htmlContent += '</span>';
  13936. pos = highlight.end;
  13937. }
  13938. if (pos < this.text.length) {
  13939. htmlContent += '<span>';
  13940. var substring = this.text.substring(pos);
  13941. htmlContent += this.supportCodicons ? codicons_1.renderCodicons(strings_1.escape(substring)) : strings_1.escape(substring);
  13942. htmlContent += '</span>';
  13943. }
  13944. this.domNode.innerHTML = htmlContent;
  13945. if (this.title) {
  13946. this.domNode.title = this.title;
  13947. }
  13948. else {
  13949. this.domNode.removeAttribute('title');
  13950. }
  13951. this.didEverRender = true;
  13952. };
  13953. HighlightedLabel.escapeNewLines = function (text, highlights) {
  13954. var total = 0;
  13955. var extra = 0;
  13956. return text.replace(/\r\n|\r|\n/g, function (match, offset) {
  13957. extra = match === '\r\n' ? -1 : 0;
  13958. offset += total;
  13959. for (var _i = 0, highlights_1 = highlights; _i < highlights_1.length; _i++) {
  13960. var highlight = highlights_1[_i];
  13961. if (highlight.end <= offset) {
  13962. continue;
  13963. }
  13964. if (highlight.start >= offset) {
  13965. highlight.start += extra;
  13966. }
  13967. if (highlight.end >= offset) {
  13968. highlight.end += extra;
  13969. }
  13970. }
  13971. total += extra;
  13972. return '\u23CE';
  13973. });
  13974. };
  13975. return HighlightedLabel;
  13976. }());
  13977. exports.HighlightedLabel = HighlightedLabel;
  13978. });
  13979. /*---------------------------------------------------------------------------------------------
  13980. * Copyright (c) Microsoft Corporation. All rights reserved.
  13981. * Licensed under the MIT License. See License.txt in the project root for license information.
  13982. *--------------------------------------------------------------------------------------------*/
  13983. define(__m[179/*vs/base/common/uint*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  13984. "use strict";
  13985. Object.defineProperty(exports, "__esModule", { value: true });
  13986. function toUint8(v) {
  13987. if (v < 0) {
  13988. return 0;
  13989. }
  13990. if (v > 255 /* MAX_UINT_8 */) {
  13991. return 255 /* MAX_UINT_8 */;
  13992. }
  13993. return v | 0;
  13994. }
  13995. exports.toUint8 = toUint8;
  13996. function toUint32(v) {
  13997. if (v < 0) {
  13998. return 0;
  13999. }
  14000. if (v > 4294967295 /* MAX_UINT_32 */) {
  14001. return 4294967295 /* MAX_UINT_32 */;
  14002. }
  14003. return v | 0;
  14004. }
  14005. exports.toUint32 = toUint32;
  14006. });
  14007. /*---------------------------------------------------------------------------------------------
  14008. * Copyright (c) Microsoft Corporation. All rights reserved.
  14009. * Licensed under the MIT License. See License.txt in the project root for license information.
  14010. *--------------------------------------------------------------------------------------------*/
  14011. define(__m[25/*vs/base/common/uri*/], __M([0/*require*/,1/*exports*/,16/*vs/base/common/platform*/]), function (require, exports, platform_1) {
  14012. "use strict";
  14013. var _a;
  14014. Object.defineProperty(exports, "__esModule", { value: true });
  14015. var _schemePattern = /^\w[\w\d+.-]*$/;
  14016. var _singleSlashStart = /^\//;
  14017. var _doubleSlashStart = /^\/\//;
  14018. function _validateUri(ret, _strict) {
  14019. // scheme, must be set
  14020. if (!ret.scheme && _strict) {
  14021. throw new Error("[UriError]: Scheme is missing: {scheme: \"\", authority: \"" + ret.authority + "\", path: \"" + ret.path + "\", query: \"" + ret.query + "\", fragment: \"" + ret.fragment + "\"}");
  14022. }
  14023. // scheme, https://tools.ietf.org/html/rfc3986#section-3.1
  14024. // ALPHA *( ALPHA / DIGIT / "+" / "-" / "." )
  14025. if (ret.scheme && !_schemePattern.test(ret.scheme)) {
  14026. throw new Error('[UriError]: Scheme contains illegal characters.');
  14027. }
  14028. // path, http://tools.ietf.org/html/rfc3986#section-3.3
  14029. // If a URI contains an authority component, then the path component
  14030. // must either be empty or begin with a slash ("/") character. If a URI
  14031. // does not contain an authority component, then the path cannot begin
  14032. // with two slash characters ("//").
  14033. if (ret.path) {
  14034. if (ret.authority) {
  14035. if (!_singleSlashStart.test(ret.path)) {
  14036. throw new Error('[UriError]: If a URI contains an authority component, then the path component must either be empty or begin with a slash ("/") character');
  14037. }
  14038. }
  14039. else {
  14040. if (_doubleSlashStart.test(ret.path)) {
  14041. throw new Error('[UriError]: If a URI does not contain an authority component, then the path cannot begin with two slash characters ("//")');
  14042. }
  14043. }
  14044. }
  14045. }
  14046. // for a while we allowed uris *without* schemes and this is the migration
  14047. // for them, e.g. an uri without scheme and without strict-mode warns and falls
  14048. // back to the file-scheme. that should cause the least carnage and still be a
  14049. // clear warning
  14050. function _schemeFix(scheme, _strict) {
  14051. if (!scheme && !_strict) {
  14052. return 'file';
  14053. }
  14054. return scheme;
  14055. }
  14056. // implements a bit of https://tools.ietf.org/html/rfc3986#section-5
  14057. function _referenceResolution(scheme, path) {
  14058. // the slash-character is our 'default base' as we don't
  14059. // support constructing URIs relative to other URIs. This
  14060. // also means that we alter and potentially break paths.
  14061. // see https://tools.ietf.org/html/rfc3986#section-5.1.4
  14062. switch (scheme) {
  14063. case 'https':
  14064. case 'http':
  14065. case 'file':
  14066. if (!path) {
  14067. path = _slash;
  14068. }
  14069. else if (path[0] !== _slash) {
  14070. path = _slash + path;
  14071. }
  14072. break;
  14073. }
  14074. return path;
  14075. }
  14076. var _empty = '';
  14077. var _slash = '/';
  14078. var _regexp = /^(([^:/?#]+?):)?(\/\/([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?/;
  14079. /**
  14080. * Uniform Resource Identifier (URI) http://tools.ietf.org/html/rfc3986.
  14081. * This class is a simple parser which creates the basic component parts
  14082. * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
  14083. * and encoding.
  14084. *
  14085. * foo://example.com:8042/over/there?name=ferret#nose
  14086. * \_/ \______________/\_________/ \_________/ \__/
  14087. * | | | | |
  14088. * scheme authority path query fragment
  14089. * | _____________________|__
  14090. * / \ / \
  14091. * urn:example:animal:ferret:nose
  14092. */
  14093. var URI = /** @class */ (function () {
  14094. /**
  14095. * @internal
  14096. */
  14097. function URI(schemeOrData, authority, path, query, fragment, _strict) {
  14098. if (_strict === void 0) { _strict = false; }
  14099. if (typeof schemeOrData === 'object') {
  14100. this.scheme = schemeOrData.scheme || _empty;
  14101. this.authority = schemeOrData.authority || _empty;
  14102. this.path = schemeOrData.path || _empty;
  14103. this.query = schemeOrData.query || _empty;
  14104. this.fragment = schemeOrData.fragment || _empty;
  14105. // no validation because it's this URI
  14106. // that creates uri components.
  14107. // _validateUri(this);
  14108. }
  14109. else {
  14110. this.scheme = _schemeFix(schemeOrData, _strict);
  14111. this.authority = authority || _empty;
  14112. this.path = _referenceResolution(this.scheme, path || _empty);
  14113. this.query = query || _empty;
  14114. this.fragment = fragment || _empty;
  14115. _validateUri(this, _strict);
  14116. }
  14117. }
  14118. URI.isUri = function (thing) {
  14119. if (thing instanceof URI) {
  14120. return true;
  14121. }
  14122. if (!thing) {
  14123. return false;
  14124. }
  14125. return typeof thing.authority === 'string'
  14126. && typeof thing.fragment === 'string'
  14127. && typeof thing.path === 'string'
  14128. && typeof thing.query === 'string'
  14129. && typeof thing.scheme === 'string'
  14130. && typeof thing.fsPath === 'function'
  14131. && typeof thing.with === 'function'
  14132. && typeof thing.toString === 'function';
  14133. };
  14134. Object.defineProperty(URI.prototype, "fsPath", {
  14135. // ---- filesystem path -----------------------
  14136. /**
  14137. * Returns a string representing the corresponding file system path of this URI.
  14138. * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
  14139. * platform specific path separator.
  14140. *
  14141. * * Will *not* validate the path for invalid characters and semantics.
  14142. * * Will *not* look at the scheme of this URI.
  14143. * * The result shall *not* be used for display purposes but for accessing a file on disk.
  14144. *
  14145. *
  14146. * The *difference* to `URI#path` is the use of the platform specific separator and the handling
  14147. * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
  14148. *
  14149. * ```ts
  14150. const u = URI.parse('file://server/c$/folder/file.txt')
  14151. u.authority === 'server'
  14152. u.path === '/shares/c$/file.txt'
  14153. u.fsPath === '\\server\c$\folder\file.txt'
  14154. ```
  14155. *
  14156. * Using `URI#path` to read a file (using fs-apis) would not be enough because parts of the path,
  14157. * namely the server name, would be missing. Therefore `URI#fsPath` exists - it's sugar to ease working
  14158. * with URIs that represent files on disk (`file` scheme).
  14159. */
  14160. get: function () {
  14161. // if (this.scheme !== 'file') {
  14162. // console.warn(`[UriError] calling fsPath with scheme ${this.scheme}`);
  14163. // }
  14164. return _makeFsPath(this);
  14165. },
  14166. enumerable: true,
  14167. configurable: true
  14168. });
  14169. // ---- modify to new -------------------------
  14170. URI.prototype.with = function (change) {
  14171. if (!change) {
  14172. return this;
  14173. }
  14174. var scheme = change.scheme, authority = change.authority, path = change.path, query = change.query, fragment = change.fragment;
  14175. if (scheme === undefined) {
  14176. scheme = this.scheme;
  14177. }
  14178. else if (scheme === null) {
  14179. scheme = _empty;
  14180. }
  14181. if (authority === undefined) {
  14182. authority = this.authority;
  14183. }
  14184. else if (authority === null) {
  14185. authority = _empty;
  14186. }
  14187. if (path === undefined) {
  14188. path = this.path;
  14189. }
  14190. else if (path === null) {
  14191. path = _empty;
  14192. }
  14193. if (query === undefined) {
  14194. query = this.query;
  14195. }
  14196. else if (query === null) {
  14197. query = _empty;
  14198. }
  14199. if (fragment === undefined) {
  14200. fragment = this.fragment;
  14201. }
  14202. else if (fragment === null) {
  14203. fragment = _empty;
  14204. }
  14205. if (scheme === this.scheme
  14206. && authority === this.authority
  14207. && path === this.path
  14208. && query === this.query
  14209. && fragment === this.fragment) {
  14210. return this;
  14211. }
  14212. return new _URI(scheme, authority, path, query, fragment);
  14213. };
  14214. // ---- parse & validate ------------------------
  14215. /**
  14216. * Creates a new URI from a string, e.g. `http://www.msft.com/some/path`,
  14217. * `file:///usr/home`, or `scheme:with/path`.
  14218. *
  14219. * @param value A string which represents an URI (see `URI#toString`).
  14220. */
  14221. URI.parse = function (value, _strict) {
  14222. if (_strict === void 0) { _strict = false; }
  14223. var match = _regexp.exec(value);
  14224. if (!match) {
  14225. return new _URI(_empty, _empty, _empty, _empty, _empty);
  14226. }
  14227. return new _URI(match[2] || _empty, percentDecode(match[4] || _empty), percentDecode(match[5] || _empty), percentDecode(match[7] || _empty), percentDecode(match[9] || _empty), _strict);
  14228. };
  14229. /**
  14230. * Creates a new URI from a file system path, e.g. `c:\my\files`,
  14231. * `/usr/home`, or `\\server\share\some\path`.
  14232. *
  14233. * The *difference* between `URI#parse` and `URI#file` is that the latter treats the argument
  14234. * as path, not as stringified-uri. E.g. `URI.file(path)` is **not the same as**
  14235. * `URI.parse('file://' + path)` because the path might contain characters that are
  14236. * interpreted (# and ?). See the following sample:
  14237. * ```ts
  14238. const good = URI.file('/coding/c#/project1');
  14239. good.scheme === 'file';
  14240. good.path === '/coding/c#/project1';
  14241. good.fragment === '';
  14242. const bad = URI.parse('file://' + '/coding/c#/project1');
  14243. bad.scheme === 'file';
  14244. bad.path === '/coding/c'; // path is now broken
  14245. bad.fragment === '/project1';
  14246. ```
  14247. *
  14248. * @param path A file system path (see `URI#fsPath`)
  14249. */
  14250. URI.file = function (path) {
  14251. var authority = _empty;
  14252. // normalize to fwd-slashes on windows,
  14253. // on other systems bwd-slashes are valid
  14254. // filename character, eg /f\oo/ba\r.txt
  14255. if (platform_1.isWindows) {
  14256. path = path.replace(/\\/g, _slash);
  14257. }
  14258. // check for authority as used in UNC shares
  14259. // or use the path as given
  14260. if (path[0] === _slash && path[1] === _slash) {
  14261. var idx = path.indexOf(_slash, 2);
  14262. if (idx === -1) {
  14263. authority = path.substring(2);
  14264. path = _slash;
  14265. }
  14266. else {
  14267. authority = path.substring(2, idx);
  14268. path = path.substring(idx) || _slash;
  14269. }
  14270. }
  14271. return new _URI('file', authority, path, _empty, _empty);
  14272. };
  14273. URI.from = function (components) {
  14274. return new _URI(components.scheme, components.authority, components.path, components.query, components.fragment);
  14275. };
  14276. // ---- printing/externalize ---------------------------
  14277. /**
  14278. * Creates a string representation for this URI. It's guaranteed that calling
  14279. * `URI.parse` with the result of this function creates an URI which is equal
  14280. * to this URI.
  14281. *
  14282. * * The result shall *not* be used for display purposes but for externalization or transport.
  14283. * * The result will be encoded using the percentage encoding and encoding happens mostly
  14284. * ignore the scheme-specific encoding rules.
  14285. *
  14286. * @param skipEncoding Do not encode the result, default is `false`
  14287. */
  14288. URI.prototype.toString = function (skipEncoding) {
  14289. if (skipEncoding === void 0) { skipEncoding = false; }
  14290. return _asFormatted(this, skipEncoding);
  14291. };
  14292. URI.prototype.toJSON = function () {
  14293. return this;
  14294. };
  14295. URI.revive = function (data) {
  14296. if (!data) {
  14297. return data;
  14298. }
  14299. else if (data instanceof URI) {
  14300. return data;
  14301. }
  14302. else {
  14303. var result = new _URI(data);
  14304. result._formatted = data.external;
  14305. result._fsPath = data._sep === _pathSepMarker ? data.fsPath : null;
  14306. return result;
  14307. }
  14308. };
  14309. return URI;
  14310. }());
  14311. exports.URI = URI;
  14312. var _pathSepMarker = platform_1.isWindows ? 1 : undefined;
  14313. // eslint-disable-next-line @typescript-eslint/class-name-casing
  14314. var _URI = /** @class */ (function (_super) {
  14315. __extends(_URI, _super);
  14316. function _URI() {
  14317. var _this = _super !== null && _super.apply(this, arguments) || this;
  14318. _this._formatted = null;
  14319. _this._fsPath = null;
  14320. return _this;
  14321. }
  14322. Object.defineProperty(_URI.prototype, "fsPath", {
  14323. get: function () {
  14324. if (!this._fsPath) {
  14325. this._fsPath = _makeFsPath(this);
  14326. }
  14327. return this._fsPath;
  14328. },
  14329. enumerable: true,
  14330. configurable: true
  14331. });
  14332. _URI.prototype.toString = function (skipEncoding) {
  14333. if (skipEncoding === void 0) { skipEncoding = false; }
  14334. if (!skipEncoding) {
  14335. if (!this._formatted) {
  14336. this._formatted = _asFormatted(this, false);
  14337. }
  14338. return this._formatted;
  14339. }
  14340. else {
  14341. // we don't cache that
  14342. return _asFormatted(this, true);
  14343. }
  14344. };
  14345. _URI.prototype.toJSON = function () {
  14346. var res = {
  14347. $mid: 1
  14348. };
  14349. // cached state
  14350. if (this._fsPath) {
  14351. res.fsPath = this._fsPath;
  14352. res._sep = _pathSepMarker;
  14353. }
  14354. if (this._formatted) {
  14355. res.external = this._formatted;
  14356. }
  14357. // uri components
  14358. if (this.path) {
  14359. res.path = this.path;
  14360. }
  14361. if (this.scheme) {
  14362. res.scheme = this.scheme;
  14363. }
  14364. if (this.authority) {
  14365. res.authority = this.authority;
  14366. }
  14367. if (this.query) {
  14368. res.query = this.query;
  14369. }
  14370. if (this.fragment) {
  14371. res.fragment = this.fragment;
  14372. }
  14373. return res;
  14374. };
  14375. return _URI;
  14376. }(URI));
  14377. // reserved characters: https://tools.ietf.org/html/rfc3986#section-2.2
  14378. var encodeTable = (_a = {},
  14379. _a[58 /* Colon */] = '%3A',
  14380. _a[47 /* Slash */] = '%2F',
  14381. _a[63 /* QuestionMark */] = '%3F',
  14382. _a[35 /* Hash */] = '%23',
  14383. _a[91 /* OpenSquareBracket */] = '%5B',
  14384. _a[93 /* CloseSquareBracket */] = '%5D',
  14385. _a[64 /* AtSign */] = '%40',
  14386. _a[33 /* ExclamationMark */] = '%21',
  14387. _a[36 /* DollarSign */] = '%24',
  14388. _a[38 /* Ampersand */] = '%26',
  14389. _a[39 /* SingleQuote */] = '%27',
  14390. _a[40 /* OpenParen */] = '%28',
  14391. _a[41 /* CloseParen */] = '%29',
  14392. _a[42 /* Asterisk */] = '%2A',
  14393. _a[43 /* Plus */] = '%2B',
  14394. _a[44 /* Comma */] = '%2C',
  14395. _a[59 /* Semicolon */] = '%3B',
  14396. _a[61 /* Equals */] = '%3D',
  14397. _a[32 /* Space */] = '%20',
  14398. _a);
  14399. function encodeURIComponentFast(uriComponent, allowSlash) {
  14400. var res = undefined;
  14401. var nativeEncodePos = -1;
  14402. for (var pos = 0; pos < uriComponent.length; pos++) {
  14403. var code = uriComponent.charCodeAt(pos);
  14404. // unreserved characters: https://tools.ietf.org/html/rfc3986#section-2.3
  14405. if ((code >= 97 /* a */ && code <= 122 /* z */)
  14406. || (code >= 65 /* A */ && code <= 90 /* Z */)
  14407. || (code >= 48 /* Digit0 */ && code <= 57 /* Digit9 */)
  14408. || code === 45 /* Dash */
  14409. || code === 46 /* Period */
  14410. || code === 95 /* Underline */
  14411. || code === 126 /* Tilde */
  14412. || (allowSlash && code === 47 /* Slash */)) {
  14413. // check if we are delaying native encode
  14414. if (nativeEncodePos !== -1) {
  14415. res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
  14416. nativeEncodePos = -1;
  14417. }
  14418. // check if we write into a new string (by default we try to return the param)
  14419. if (res !== undefined) {
  14420. res += uriComponent.charAt(pos);
  14421. }
  14422. }
  14423. else {
  14424. // encoding needed, we need to allocate a new string
  14425. if (res === undefined) {
  14426. res = uriComponent.substr(0, pos);
  14427. }
  14428. // check with default table first
  14429. var escaped = encodeTable[code];
  14430. if (escaped !== undefined) {
  14431. // check if we are delaying native encode
  14432. if (nativeEncodePos !== -1) {
  14433. res += encodeURIComponent(uriComponent.substring(nativeEncodePos, pos));
  14434. nativeEncodePos = -1;
  14435. }
  14436. // append escaped variant to result
  14437. res += escaped;
  14438. }
  14439. else if (nativeEncodePos === -1) {
  14440. // use native encode only when needed
  14441. nativeEncodePos = pos;
  14442. }
  14443. }
  14444. }
  14445. if (nativeEncodePos !== -1) {
  14446. res += encodeURIComponent(uriComponent.substring(nativeEncodePos));
  14447. }
  14448. return res !== undefined ? res : uriComponent;
  14449. }
  14450. function encodeURIComponentMinimal(path) {
  14451. var res = undefined;
  14452. for (var pos = 0; pos < path.length; pos++) {
  14453. var code = path.charCodeAt(pos);
  14454. if (code === 35 /* Hash */ || code === 63 /* QuestionMark */) {
  14455. if (res === undefined) {
  14456. res = path.substr(0, pos);
  14457. }
  14458. res += encodeTable[code];
  14459. }
  14460. else {
  14461. if (res !== undefined) {
  14462. res += path[pos];
  14463. }
  14464. }
  14465. }
  14466. return res !== undefined ? res : path;
  14467. }
  14468. /**
  14469. * Compute `fsPath` for the given uri
  14470. */
  14471. function _makeFsPath(uri) {
  14472. var value;
  14473. if (uri.authority && uri.path.length > 1 && uri.scheme === 'file') {
  14474. // unc path: file://shares/c$/far/boo
  14475. value = "//" + uri.authority + uri.path;
  14476. }
  14477. else if (uri.path.charCodeAt(0) === 47 /* Slash */
  14478. && (uri.path.charCodeAt(1) >= 65 /* A */ && uri.path.charCodeAt(1) <= 90 /* Z */ || uri.path.charCodeAt(1) >= 97 /* a */ && uri.path.charCodeAt(1) <= 122 /* z */)
  14479. && uri.path.charCodeAt(2) === 58 /* Colon */) {
  14480. // windows drive letter: file:///c:/far/boo
  14481. value = uri.path[1].toLowerCase() + uri.path.substr(2);
  14482. }
  14483. else {
  14484. // other path
  14485. value = uri.path;
  14486. }
  14487. if (platform_1.isWindows) {
  14488. value = value.replace(/\//g, '\\');
  14489. }
  14490. return value;
  14491. }
  14492. /**
  14493. * Create the external version of a uri
  14494. */
  14495. function _asFormatted(uri, skipEncoding) {
  14496. var encoder = !skipEncoding
  14497. ? encodeURIComponentFast
  14498. : encodeURIComponentMinimal;
  14499. var res = '';
  14500. var scheme = uri.scheme, authority = uri.authority, path = uri.path, query = uri.query, fragment = uri.fragment;
  14501. if (scheme) {
  14502. res += scheme;
  14503. res += ':';
  14504. }
  14505. if (authority || scheme === 'file') {
  14506. res += _slash;
  14507. res += _slash;
  14508. }
  14509. if (authority) {
  14510. var idx = authority.indexOf('@');
  14511. if (idx !== -1) {
  14512. // <user>@<auth>
  14513. var userinfo = authority.substr(0, idx);
  14514. authority = authority.substr(idx + 1);
  14515. idx = userinfo.indexOf(':');
  14516. if (idx === -1) {
  14517. res += encoder(userinfo, false);
  14518. }
  14519. else {
  14520. // <user>:<pass>@<auth>
  14521. res += encoder(userinfo.substr(0, idx), false);
  14522. res += ':';
  14523. res += encoder(userinfo.substr(idx + 1), false);
  14524. }
  14525. res += '@';
  14526. }
  14527. authority = authority.toLowerCase();
  14528. idx = authority.indexOf(':');
  14529. if (idx === -1) {
  14530. res += encoder(authority, false);
  14531. }
  14532. else {
  14533. // <auth>:<port>
  14534. res += encoder(authority.substr(0, idx), false);
  14535. res += authority.substr(idx);
  14536. }
  14537. }
  14538. if (path) {
  14539. // lower-case windows drive letters in /C:/fff or C:/fff
  14540. if (path.length >= 3 && path.charCodeAt(0) === 47 /* Slash */ && path.charCodeAt(2) === 58 /* Colon */) {
  14541. var code = path.charCodeAt(1);
  14542. if (code >= 65 /* A */ && code <= 90 /* Z */) {
  14543. path = "/" + String.fromCharCode(code + 32) + ":" + path.substr(3); // "/c:".length === 3
  14544. }
  14545. }
  14546. else if (path.length >= 2 && path.charCodeAt(1) === 58 /* Colon */) {
  14547. var code = path.charCodeAt(0);
  14548. if (code >= 65 /* A */ && code <= 90 /* Z */) {
  14549. path = String.fromCharCode(code + 32) + ":" + path.substr(2); // "/c:".length === 3
  14550. }
  14551. }
  14552. // encode the rest of the path
  14553. res += encoder(path, true);
  14554. }
  14555. if (query) {
  14556. res += '?';
  14557. res += encoder(query, false);
  14558. }
  14559. if (fragment) {
  14560. res += '#';
  14561. res += !skipEncoding ? encodeURIComponentFast(fragment, false) : fragment;
  14562. }
  14563. return res;
  14564. }
  14565. // --- decode
  14566. function decodeURIComponentGraceful(str) {
  14567. try {
  14568. return decodeURIComponent(str);
  14569. }
  14570. catch (_a) {
  14571. if (str.length > 3) {
  14572. return str.substr(0, 3) + decodeURIComponentGraceful(str.substr(3));
  14573. }
  14574. else {
  14575. return str;
  14576. }
  14577. }
  14578. }
  14579. var _rEncodedAsHex = /(%[0-9A-Za-z][0-9A-Za-z])+/g;
  14580. function percentDecode(str) {
  14581. if (!str.match(_rEncodedAsHex)) {
  14582. return str;
  14583. }
  14584. return str.replace(_rEncodedAsHex, function (match) { return decodeURIComponentGraceful(match); });
  14585. }
  14586. });
  14587. /*---------------------------------------------------------------------------------------------
  14588. * Copyright (c) Microsoft Corporation. All rights reserved.
  14589. * Licensed under the MIT License. See License.txt in the project root for license information.
  14590. *--------------------------------------------------------------------------------------------*/
  14591. define(__m[180/*vs/base/common/marshalling*/], __M([0/*require*/,1/*exports*/,25/*vs/base/common/uri*/]), function (require, exports, uri_1) {
  14592. "use strict";
  14593. Object.defineProperty(exports, "__esModule", { value: true });
  14594. function parse(text) {
  14595. var data = JSON.parse(text);
  14596. data = revive(data);
  14597. return data;
  14598. }
  14599. exports.parse = parse;
  14600. function revive(obj, depth) {
  14601. if (depth === void 0) { depth = 0; }
  14602. if (!obj || depth > 200) {
  14603. return obj;
  14604. }
  14605. if (typeof obj === 'object') {
  14606. switch (obj.$mid) {
  14607. case 1: return uri_1.URI.revive(obj);
  14608. case 2: return new RegExp(obj.source, obj.flags);
  14609. }
  14610. // walk object (or array)
  14611. for (var key in obj) {
  14612. if (Object.hasOwnProperty.call(obj, key)) {
  14613. obj[key] = revive(obj[key], depth + 1);
  14614. }
  14615. }
  14616. }
  14617. return obj;
  14618. }
  14619. exports.revive = revive;
  14620. });
  14621. /*---------------------------------------------------------------------------------------------
  14622. * Copyright (c) Microsoft Corporation. All rights reserved.
  14623. * Licensed under the MIT License. See License.txt in the project root for license information.
  14624. *--------------------------------------------------------------------------------------------*/
  14625. define(__m[46/*vs/base/common/network*/], __M([0/*require*/,1/*exports*/,25/*vs/base/common/uri*/,16/*vs/base/common/platform*/]), function (require, exports, uri_1, platform) {
  14626. "use strict";
  14627. Object.defineProperty(exports, "__esModule", { value: true });
  14628. var Schemas;
  14629. (function (Schemas) {
  14630. /**
  14631. * A schema that is used for models that exist in memory
  14632. * only and that have no correspondence on a server or such.
  14633. */
  14634. Schemas.inMemory = 'inmemory';
  14635. /**
  14636. * A schema that is used for setting files
  14637. */
  14638. Schemas.vscode = 'vscode';
  14639. /**
  14640. * A schema that is used for internal private files
  14641. */
  14642. Schemas.internal = 'private';
  14643. /**
  14644. * A walk-through document.
  14645. */
  14646. Schemas.walkThrough = 'walkThrough';
  14647. /**
  14648. * An embedded code snippet.
  14649. */
  14650. Schemas.walkThroughSnippet = 'walkThroughSnippet';
  14651. Schemas.http = 'http';
  14652. Schemas.https = 'https';
  14653. Schemas.file = 'file';
  14654. Schemas.mailto = 'mailto';
  14655. Schemas.untitled = 'untitled';
  14656. Schemas.data = 'data';
  14657. Schemas.command = 'command';
  14658. Schemas.vscodeRemote = 'vscode-remote';
  14659. Schemas.vscodeRemoteResource = 'vscode-remote-resource';
  14660. Schemas.userData = 'vscode-userdata';
  14661. })(Schemas = exports.Schemas || (exports.Schemas = {}));
  14662. var RemoteAuthoritiesImpl = /** @class */ (function () {
  14663. function RemoteAuthoritiesImpl() {
  14664. this._hosts = Object.create(null);
  14665. this._ports = Object.create(null);
  14666. this._connectionTokens = Object.create(null);
  14667. this._preferredWebSchema = 'http';
  14668. this._delegate = null;
  14669. }
  14670. RemoteAuthoritiesImpl.prototype.setPreferredWebSchema = function (schema) {
  14671. this._preferredWebSchema = schema;
  14672. };
  14673. RemoteAuthoritiesImpl.prototype.rewrite = function (uri) {
  14674. if (this._delegate) {
  14675. return this._delegate(uri);
  14676. }
  14677. var authority = uri.authority;
  14678. var host = this._hosts[authority];
  14679. if (host && host.indexOf(':') !== -1) {
  14680. host = "[" + host + "]";
  14681. }
  14682. var port = this._ports[authority];
  14683. var connectionToken = this._connectionTokens[authority];
  14684. var query = "path=" + encodeURIComponent(uri.path);
  14685. if (typeof connectionToken === 'string') {
  14686. query += "&tkn=" + encodeURIComponent(connectionToken);
  14687. }
  14688. return uri_1.URI.from({
  14689. scheme: platform.isWeb ? this._preferredWebSchema : Schemas.vscodeRemoteResource,
  14690. authority: host + ":" + port,
  14691. path: "/vscode-remote-resource",
  14692. query: query
  14693. });
  14694. };
  14695. return RemoteAuthoritiesImpl;
  14696. }());
  14697. exports.RemoteAuthorities = new RemoteAuthoritiesImpl();
  14698. });
  14699. /*---------------------------------------------------------------------------------------------
  14700. * Copyright (c) Microsoft Corporation. All rights reserved.
  14701. * Licensed under the MIT License. See License.txt in the project root for license information.
  14702. *--------------------------------------------------------------------------------------------*/
  14703. var __spreadArrays = (this && this.__spreadArrays) || function () {
  14704. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  14705. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  14706. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  14707. r[k] = a[j];
  14708. return r;
  14709. };
  14710. define(__m[6/*vs/base/browser/dom*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,52/*vs/base/browser/event*/,56/*vs/base/browser/keyboardEvent*/,45/*vs/base/browser/mouseEvent*/,15/*vs/base/common/async*/,10/*vs/base/common/errors*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,19/*vs/base/common/arrays*/,46/*vs/base/common/network*/,88/*vs/base/browser/canIUse*/]), function (require, exports, browser, event_1, keyboardEvent_1, mouseEvent_1, async_1, errors_1, event_2, lifecycle_1, platform, arrays_1, network_1, canIUse_1) {
  14711. "use strict";
  14712. Object.defineProperty(exports, "__esModule", { value: true });
  14713. function clearNode(node) {
  14714. while (node.firstChild) {
  14715. node.removeChild(node.firstChild);
  14716. }
  14717. }
  14718. exports.clearNode = clearNode;
  14719. function removeNode(node) {
  14720. if (node.parentNode) {
  14721. node.parentNode.removeChild(node);
  14722. }
  14723. }
  14724. exports.removeNode = removeNode;
  14725. function isInDOM(node) {
  14726. while (node) {
  14727. if (node === document.body) {
  14728. return true;
  14729. }
  14730. node = node.parentNode || node.host;
  14731. }
  14732. return false;
  14733. }
  14734. exports.isInDOM = isInDOM;
  14735. var _manualClassList = new /** @class */ (function () {
  14736. function class_1() {
  14737. this._lastStart = -1;
  14738. this._lastEnd = -1;
  14739. }
  14740. class_1.prototype._findClassName = function (node, className) {
  14741. var classes = node.className;
  14742. if (!classes) {
  14743. this._lastStart = -1;
  14744. return;
  14745. }
  14746. className = className.trim();
  14747. var classesLen = classes.length, classLen = className.length;
  14748. if (classLen === 0) {
  14749. this._lastStart = -1;
  14750. return;
  14751. }
  14752. if (classesLen < classLen) {
  14753. this._lastStart = -1;
  14754. return;
  14755. }
  14756. if (classes === className) {
  14757. this._lastStart = 0;
  14758. this._lastEnd = classesLen;
  14759. return;
  14760. }
  14761. var idx = -1, idxEnd;
  14762. while ((idx = classes.indexOf(className, idx + 1)) >= 0) {
  14763. idxEnd = idx + classLen;
  14764. // a class that is followed by another class
  14765. if ((idx === 0 || classes.charCodeAt(idx - 1) === 32 /* Space */) && classes.charCodeAt(idxEnd) === 32 /* Space */) {
  14766. this._lastStart = idx;
  14767. this._lastEnd = idxEnd + 1;
  14768. return;
  14769. }
  14770. // last class
  14771. if (idx > 0 && classes.charCodeAt(idx - 1) === 32 /* Space */ && idxEnd === classesLen) {
  14772. this._lastStart = idx - 1;
  14773. this._lastEnd = idxEnd;
  14774. return;
  14775. }
  14776. // equal - duplicate of cmp above
  14777. if (idx === 0 && idxEnd === classesLen) {
  14778. this._lastStart = 0;
  14779. this._lastEnd = idxEnd;
  14780. return;
  14781. }
  14782. }
  14783. this._lastStart = -1;
  14784. };
  14785. class_1.prototype.hasClass = function (node, className) {
  14786. this._findClassName(node, className);
  14787. return this._lastStart !== -1;
  14788. };
  14789. class_1.prototype.addClasses = function (node) {
  14790. var _this = this;
  14791. var classNames = [];
  14792. for (var _i = 1; _i < arguments.length; _i++) {
  14793. classNames[_i - 1] = arguments[_i];
  14794. }
  14795. classNames.forEach(function (nameValue) { return nameValue.split(' ').forEach(function (name) { return _this.addClass(node, name); }); });
  14796. };
  14797. class_1.prototype.addClass = function (node, className) {
  14798. if (!node.className) { // doesn't have it for sure
  14799. node.className = className;
  14800. }
  14801. else {
  14802. this._findClassName(node, className); // see if it's already there
  14803. if (this._lastStart === -1) {
  14804. node.className = node.className + ' ' + className;
  14805. }
  14806. }
  14807. };
  14808. class_1.prototype.removeClass = function (node, className) {
  14809. this._findClassName(node, className);
  14810. if (this._lastStart === -1) {
  14811. return; // Prevent styles invalidation if not necessary
  14812. }
  14813. else {
  14814. node.className = node.className.substring(0, this._lastStart) + node.className.substring(this._lastEnd);
  14815. }
  14816. };
  14817. class_1.prototype.removeClasses = function (node) {
  14818. var _this = this;
  14819. var classNames = [];
  14820. for (var _i = 1; _i < arguments.length; _i++) {
  14821. classNames[_i - 1] = arguments[_i];
  14822. }
  14823. classNames.forEach(function (nameValue) { return nameValue.split(' ').forEach(function (name) { return _this.removeClass(node, name); }); });
  14824. };
  14825. class_1.prototype.toggleClass = function (node, className, shouldHaveIt) {
  14826. this._findClassName(node, className);
  14827. if (this._lastStart !== -1 && (shouldHaveIt === undefined || !shouldHaveIt)) {
  14828. this.removeClass(node, className);
  14829. }
  14830. if (this._lastStart === -1 && (shouldHaveIt === undefined || shouldHaveIt)) {
  14831. this.addClass(node, className);
  14832. }
  14833. };
  14834. return class_1;
  14835. }());
  14836. var _nativeClassList = new /** @class */ (function () {
  14837. function class_2() {
  14838. }
  14839. class_2.prototype.hasClass = function (node, className) {
  14840. return Boolean(className) && node.classList && node.classList.contains(className);
  14841. };
  14842. class_2.prototype.addClasses = function (node) {
  14843. var _this = this;
  14844. var classNames = [];
  14845. for (var _i = 1; _i < arguments.length; _i++) {
  14846. classNames[_i - 1] = arguments[_i];
  14847. }
  14848. classNames.forEach(function (nameValue) { return nameValue.split(' ').forEach(function (name) { return _this.addClass(node, name); }); });
  14849. };
  14850. class_2.prototype.addClass = function (node, className) {
  14851. if (className && node.classList) {
  14852. node.classList.add(className);
  14853. }
  14854. };
  14855. class_2.prototype.removeClass = function (node, className) {
  14856. if (className && node.classList) {
  14857. node.classList.remove(className);
  14858. }
  14859. };
  14860. class_2.prototype.removeClasses = function (node) {
  14861. var _this = this;
  14862. var classNames = [];
  14863. for (var _i = 1; _i < arguments.length; _i++) {
  14864. classNames[_i - 1] = arguments[_i];
  14865. }
  14866. classNames.forEach(function (nameValue) { return nameValue.split(' ').forEach(function (name) { return _this.removeClass(node, name); }); });
  14867. };
  14868. class_2.prototype.toggleClass = function (node, className, shouldHaveIt) {
  14869. if (node.classList) {
  14870. node.classList.toggle(className, shouldHaveIt);
  14871. }
  14872. };
  14873. return class_2;
  14874. }());
  14875. // In IE11 there is only partial support for `classList` which makes us keep our
  14876. // custom implementation. Otherwise use the native implementation, see: http://caniuse.com/#search=classlist
  14877. var _classList = browser.isIE ? _manualClassList : _nativeClassList;
  14878. exports.hasClass = _classList.hasClass.bind(_classList);
  14879. exports.addClass = _classList.addClass.bind(_classList);
  14880. exports.addClasses = _classList.addClasses.bind(_classList);
  14881. exports.removeClass = _classList.removeClass.bind(_classList);
  14882. exports.removeClasses = _classList.removeClasses.bind(_classList);
  14883. exports.toggleClass = _classList.toggleClass.bind(_classList);
  14884. var DomListener = /** @class */ (function () {
  14885. function DomListener(node, type, handler, options) {
  14886. this._node = node;
  14887. this._type = type;
  14888. this._handler = handler;
  14889. this._options = (options || false);
  14890. this._node.addEventListener(this._type, this._handler, this._options);
  14891. }
  14892. DomListener.prototype.dispose = function () {
  14893. if (!this._handler) {
  14894. // Already disposed
  14895. return;
  14896. }
  14897. this._node.removeEventListener(this._type, this._handler, this._options);
  14898. // Prevent leakers from holding on to the dom or handler func
  14899. this._node = null;
  14900. this._handler = null;
  14901. };
  14902. return DomListener;
  14903. }());
  14904. function addDisposableListener(node, type, handler, useCaptureOrOptions) {
  14905. return new DomListener(node, type, handler, useCaptureOrOptions);
  14906. }
  14907. exports.addDisposableListener = addDisposableListener;
  14908. function _wrapAsStandardMouseEvent(handler) {
  14909. return function (e) {
  14910. return handler(new mouseEvent_1.StandardMouseEvent(e));
  14911. };
  14912. }
  14913. function _wrapAsStandardKeyboardEvent(handler) {
  14914. return function (e) {
  14915. return handler(new keyboardEvent_1.StandardKeyboardEvent(e));
  14916. };
  14917. }
  14918. exports.addStandardDisposableListener = function addStandardDisposableListener(node, type, handler, useCapture) {
  14919. var wrapHandler = handler;
  14920. if (type === 'click' || type === 'mousedown') {
  14921. wrapHandler = _wrapAsStandardMouseEvent(handler);
  14922. }
  14923. else if (type === 'keydown' || type === 'keypress' || type === 'keyup') {
  14924. wrapHandler = _wrapAsStandardKeyboardEvent(handler);
  14925. }
  14926. return addDisposableListener(node, type, wrapHandler, useCapture);
  14927. };
  14928. exports.addStandardDisposableGenericMouseDownListner = function addStandardDisposableListener(node, handler, useCapture) {
  14929. var wrapHandler = _wrapAsStandardMouseEvent(handler);
  14930. return addDisposableGenericMouseDownListner(node, wrapHandler, useCapture);
  14931. };
  14932. function addDisposableGenericMouseDownListner(node, handler, useCapture) {
  14933. return addDisposableListener(node, platform.isIOS && canIUse_1.BrowserFeatures.pointerEvents ? exports.EventType.POINTER_DOWN : exports.EventType.MOUSE_DOWN, handler, useCapture);
  14934. }
  14935. exports.addDisposableGenericMouseDownListner = addDisposableGenericMouseDownListner;
  14936. function addDisposableGenericMouseUpListner(node, handler, useCapture) {
  14937. return addDisposableListener(node, platform.isIOS && canIUse_1.BrowserFeatures.pointerEvents ? exports.EventType.POINTER_UP : exports.EventType.MOUSE_UP, handler, useCapture);
  14938. }
  14939. exports.addDisposableGenericMouseUpListner = addDisposableGenericMouseUpListner;
  14940. function addDisposableNonBubblingMouseOutListener(node, handler) {
  14941. return addDisposableListener(node, 'mouseout', function (e) {
  14942. // Mouse out bubbles, so this is an attempt to ignore faux mouse outs coming from children elements
  14943. var toElement = (e.relatedTarget);
  14944. while (toElement && toElement !== node) {
  14945. toElement = toElement.parentNode;
  14946. }
  14947. if (toElement === node) {
  14948. return;
  14949. }
  14950. handler(e);
  14951. });
  14952. }
  14953. exports.addDisposableNonBubblingMouseOutListener = addDisposableNonBubblingMouseOutListener;
  14954. function addDisposableNonBubblingPointerOutListener(node, handler) {
  14955. return addDisposableListener(node, 'pointerout', function (e) {
  14956. // Mouse out bubbles, so this is an attempt to ignore faux mouse outs coming from children elements
  14957. var toElement = (e.relatedTarget);
  14958. while (toElement && toElement !== node) {
  14959. toElement = toElement.parentNode;
  14960. }
  14961. if (toElement === node) {
  14962. return;
  14963. }
  14964. handler(e);
  14965. });
  14966. }
  14967. exports.addDisposableNonBubblingPointerOutListener = addDisposableNonBubblingPointerOutListener;
  14968. var _animationFrame = null;
  14969. function doRequestAnimationFrame(callback) {
  14970. if (!_animationFrame) {
  14971. var emulatedRequestAnimationFrame = function (callback) {
  14972. return setTimeout(function () { return callback(new Date().getTime()); }, 0);
  14973. };
  14974. _animationFrame = (self.requestAnimationFrame
  14975. || self.msRequestAnimationFrame
  14976. || self.webkitRequestAnimationFrame
  14977. || self.mozRequestAnimationFrame
  14978. || self.oRequestAnimationFrame
  14979. || emulatedRequestAnimationFrame);
  14980. }
  14981. return _animationFrame.call(self, callback);
  14982. }
  14983. var AnimationFrameQueueItem = /** @class */ (function () {
  14984. function AnimationFrameQueueItem(runner, priority) {
  14985. if (priority === void 0) { priority = 0; }
  14986. this._runner = runner;
  14987. this.priority = priority;
  14988. this._canceled = false;
  14989. }
  14990. AnimationFrameQueueItem.prototype.dispose = function () {
  14991. this._canceled = true;
  14992. };
  14993. AnimationFrameQueueItem.prototype.execute = function () {
  14994. if (this._canceled) {
  14995. return;
  14996. }
  14997. try {
  14998. this._runner();
  14999. }
  15000. catch (e) {
  15001. errors_1.onUnexpectedError(e);
  15002. }
  15003. };
  15004. // Sort by priority (largest to lowest)
  15005. AnimationFrameQueueItem.sort = function (a, b) {
  15006. return b.priority - a.priority;
  15007. };
  15008. return AnimationFrameQueueItem;
  15009. }());
  15010. (function () {
  15011. /**
  15012. * The runners scheduled at the next animation frame
  15013. */
  15014. var NEXT_QUEUE = [];
  15015. /**
  15016. * The runners scheduled at the current animation frame
  15017. */
  15018. var CURRENT_QUEUE = null;
  15019. /**
  15020. * A flag to keep track if the native requestAnimationFrame was already called
  15021. */
  15022. var animFrameRequested = false;
  15023. /**
  15024. * A flag to indicate if currently handling a native requestAnimationFrame callback
  15025. */
  15026. var inAnimationFrameRunner = false;
  15027. var animationFrameRunner = function () {
  15028. animFrameRequested = false;
  15029. CURRENT_QUEUE = NEXT_QUEUE;
  15030. NEXT_QUEUE = [];
  15031. inAnimationFrameRunner = true;
  15032. while (CURRENT_QUEUE.length > 0) {
  15033. CURRENT_QUEUE.sort(AnimationFrameQueueItem.sort);
  15034. var top_1 = CURRENT_QUEUE.shift();
  15035. top_1.execute();
  15036. }
  15037. inAnimationFrameRunner = false;
  15038. };
  15039. exports.scheduleAtNextAnimationFrame = function (runner, priority) {
  15040. if (priority === void 0) { priority = 0; }
  15041. var item = new AnimationFrameQueueItem(runner, priority);
  15042. NEXT_QUEUE.push(item);
  15043. if (!animFrameRequested) {
  15044. animFrameRequested = true;
  15045. doRequestAnimationFrame(animationFrameRunner);
  15046. }
  15047. return item;
  15048. };
  15049. exports.runAtThisOrScheduleAtNextAnimationFrame = function (runner, priority) {
  15050. if (inAnimationFrameRunner) {
  15051. var item = new AnimationFrameQueueItem(runner, priority);
  15052. CURRENT_QUEUE.push(item);
  15053. return item;
  15054. }
  15055. else {
  15056. return exports.scheduleAtNextAnimationFrame(runner, priority);
  15057. }
  15058. };
  15059. })();
  15060. var MINIMUM_TIME_MS = 16;
  15061. var DEFAULT_EVENT_MERGER = function (lastEvent, currentEvent) {
  15062. return currentEvent;
  15063. };
  15064. var TimeoutThrottledDomListener = /** @class */ (function (_super) {
  15065. __extends(TimeoutThrottledDomListener, _super);
  15066. function TimeoutThrottledDomListener(node, type, handler, eventMerger, minimumTimeMs) {
  15067. if (eventMerger === void 0) { eventMerger = DEFAULT_EVENT_MERGER; }
  15068. if (minimumTimeMs === void 0) { minimumTimeMs = MINIMUM_TIME_MS; }
  15069. var _this = _super.call(this) || this;
  15070. var lastEvent = null;
  15071. var lastHandlerTime = 0;
  15072. var timeout = _this._register(new async_1.TimeoutTimer());
  15073. var invokeHandler = function () {
  15074. lastHandlerTime = (new Date()).getTime();
  15075. handler(lastEvent);
  15076. lastEvent = null;
  15077. };
  15078. _this._register(addDisposableListener(node, type, function (e) {
  15079. lastEvent = eventMerger(lastEvent, e);
  15080. var elapsedTime = (new Date()).getTime() - lastHandlerTime;
  15081. if (elapsedTime >= minimumTimeMs) {
  15082. timeout.cancel();
  15083. invokeHandler();
  15084. }
  15085. else {
  15086. timeout.setIfNotSet(invokeHandler, minimumTimeMs - elapsedTime);
  15087. }
  15088. }));
  15089. return _this;
  15090. }
  15091. return TimeoutThrottledDomListener;
  15092. }(lifecycle_1.Disposable));
  15093. function addDisposableThrottledListener(node, type, handler, eventMerger, minimumTimeMs) {
  15094. return new TimeoutThrottledDomListener(node, type, handler, eventMerger, minimumTimeMs);
  15095. }
  15096. exports.addDisposableThrottledListener = addDisposableThrottledListener;
  15097. function getComputedStyle(el) {
  15098. return document.defaultView.getComputedStyle(el, null);
  15099. }
  15100. exports.getComputedStyle = getComputedStyle;
  15101. function getClientArea(element) {
  15102. // Try with DOM clientWidth / clientHeight
  15103. if (element !== document.body) {
  15104. return new Dimension(element.clientWidth, element.clientHeight);
  15105. }
  15106. // If visual view port exits and it's on mobile, it should be used instead of window innerWidth / innerHeight, or document.body.clientWidth / document.body.clientHeight
  15107. if (platform.isIOS && window.visualViewport) {
  15108. var width = window.visualViewport.width;
  15109. var height = window.visualViewport.height - (browser.isStandalone
  15110. // in PWA mode, the visual viewport always includes the safe-area-inset-bottom (which is for the home indicator)
  15111. // even when you are using the onscreen monitor, the visual viewport will include the area between system statusbar and the onscreen keyboard
  15112. // plus the area between onscreen keyboard and the bottom bezel, which is 20px on iOS.
  15113. ? (20 + 4) // + 4px for body margin
  15114. : 0);
  15115. return new Dimension(width, height);
  15116. }
  15117. // Try innerWidth / innerHeight
  15118. if (window.innerWidth && window.innerHeight) {
  15119. return new Dimension(window.innerWidth, window.innerHeight);
  15120. }
  15121. // Try with document.body.clientWidth / document.body.clientHeight
  15122. if (document.body && document.body.clientWidth && document.body.clientHeight) {
  15123. return new Dimension(document.body.clientWidth, document.body.clientHeight);
  15124. }
  15125. // Try with document.documentElement.clientWidth / document.documentElement.clientHeight
  15126. if (document.documentElement && document.documentElement.clientWidth && document.documentElement.clientHeight) {
  15127. return new Dimension(document.documentElement.clientWidth, document.documentElement.clientHeight);
  15128. }
  15129. throw new Error('Unable to figure out browser width and height');
  15130. }
  15131. exports.getClientArea = getClientArea;
  15132. var SizeUtils = /** @class */ (function () {
  15133. function SizeUtils() {
  15134. }
  15135. // Adapted from WinJS
  15136. // Converts a CSS positioning string for the specified element to pixels.
  15137. SizeUtils.convertToPixels = function (element, value) {
  15138. return parseFloat(value) || 0;
  15139. };
  15140. SizeUtils.getDimension = function (element, cssPropertyName, jsPropertyName) {
  15141. var computedStyle = getComputedStyle(element);
  15142. var value = '0';
  15143. if (computedStyle) {
  15144. if (computedStyle.getPropertyValue) {
  15145. value = computedStyle.getPropertyValue(cssPropertyName);
  15146. }
  15147. else {
  15148. // IE8
  15149. value = computedStyle.getAttribute(jsPropertyName);
  15150. }
  15151. }
  15152. return SizeUtils.convertToPixels(element, value);
  15153. };
  15154. SizeUtils.getBorderLeftWidth = function (element) {
  15155. return SizeUtils.getDimension(element, 'border-left-width', 'borderLeftWidth');
  15156. };
  15157. SizeUtils.getBorderRightWidth = function (element) {
  15158. return SizeUtils.getDimension(element, 'border-right-width', 'borderRightWidth');
  15159. };
  15160. SizeUtils.getBorderTopWidth = function (element) {
  15161. return SizeUtils.getDimension(element, 'border-top-width', 'borderTopWidth');
  15162. };
  15163. SizeUtils.getBorderBottomWidth = function (element) {
  15164. return SizeUtils.getDimension(element, 'border-bottom-width', 'borderBottomWidth');
  15165. };
  15166. SizeUtils.getPaddingLeft = function (element) {
  15167. return SizeUtils.getDimension(element, 'padding-left', 'paddingLeft');
  15168. };
  15169. SizeUtils.getPaddingRight = function (element) {
  15170. return SizeUtils.getDimension(element, 'padding-right', 'paddingRight');
  15171. };
  15172. SizeUtils.getPaddingTop = function (element) {
  15173. return SizeUtils.getDimension(element, 'padding-top', 'paddingTop');
  15174. };
  15175. SizeUtils.getPaddingBottom = function (element) {
  15176. return SizeUtils.getDimension(element, 'padding-bottom', 'paddingBottom');
  15177. };
  15178. SizeUtils.getMarginLeft = function (element) {
  15179. return SizeUtils.getDimension(element, 'margin-left', 'marginLeft');
  15180. };
  15181. SizeUtils.getMarginTop = function (element) {
  15182. return SizeUtils.getDimension(element, 'margin-top', 'marginTop');
  15183. };
  15184. SizeUtils.getMarginRight = function (element) {
  15185. return SizeUtils.getDimension(element, 'margin-right', 'marginRight');
  15186. };
  15187. SizeUtils.getMarginBottom = function (element) {
  15188. return SizeUtils.getDimension(element, 'margin-bottom', 'marginBottom');
  15189. };
  15190. return SizeUtils;
  15191. }());
  15192. // ----------------------------------------------------------------------------------------
  15193. // Position & Dimension
  15194. var Dimension = /** @class */ (function () {
  15195. function Dimension(width, height) {
  15196. this.width = width;
  15197. this.height = height;
  15198. }
  15199. return Dimension;
  15200. }());
  15201. exports.Dimension = Dimension;
  15202. function getTopLeftOffset(element) {
  15203. // Adapted from WinJS.Utilities.getPosition
  15204. // and added borders to the mix
  15205. var offsetParent = element.offsetParent;
  15206. var top = element.offsetTop;
  15207. var left = element.offsetLeft;
  15208. while ((element = element.parentNode) !== null
  15209. && element !== document.body
  15210. && element !== document.documentElement) {
  15211. top -= element.scrollTop;
  15212. var c = isShadowRoot(element) ? null : getComputedStyle(element);
  15213. if (c) {
  15214. left -= c.direction !== 'rtl' ? element.scrollLeft : -element.scrollLeft;
  15215. }
  15216. if (element === offsetParent) {
  15217. left += SizeUtils.getBorderLeftWidth(element);
  15218. top += SizeUtils.getBorderTopWidth(element);
  15219. top += element.offsetTop;
  15220. left += element.offsetLeft;
  15221. offsetParent = element.offsetParent;
  15222. }
  15223. }
  15224. return {
  15225. left: left,
  15226. top: top
  15227. };
  15228. }
  15229. exports.getTopLeftOffset = getTopLeftOffset;
  15230. /**
  15231. * Returns the position of a dom node relative to the entire page.
  15232. */
  15233. function getDomNodePagePosition(domNode) {
  15234. var bb = domNode.getBoundingClientRect();
  15235. return {
  15236. left: bb.left + exports.StandardWindow.scrollX,
  15237. top: bb.top + exports.StandardWindow.scrollY,
  15238. width: bb.width,
  15239. height: bb.height
  15240. };
  15241. }
  15242. exports.getDomNodePagePosition = getDomNodePagePosition;
  15243. exports.StandardWindow = new /** @class */ (function () {
  15244. function class_3() {
  15245. }
  15246. Object.defineProperty(class_3.prototype, "scrollX", {
  15247. get: function () {
  15248. if (typeof window.scrollX === 'number') {
  15249. // modern browsers
  15250. return window.scrollX;
  15251. }
  15252. else {
  15253. return document.body.scrollLeft + document.documentElement.scrollLeft;
  15254. }
  15255. },
  15256. enumerable: true,
  15257. configurable: true
  15258. });
  15259. Object.defineProperty(class_3.prototype, "scrollY", {
  15260. get: function () {
  15261. if (typeof window.scrollY === 'number') {
  15262. // modern browsers
  15263. return window.scrollY;
  15264. }
  15265. else {
  15266. return document.body.scrollTop + document.documentElement.scrollTop;
  15267. }
  15268. },
  15269. enumerable: true,
  15270. configurable: true
  15271. });
  15272. return class_3;
  15273. }());
  15274. // Adapted from WinJS
  15275. // Gets the width of the element, including margins.
  15276. function getTotalWidth(element) {
  15277. var margin = SizeUtils.getMarginLeft(element) + SizeUtils.getMarginRight(element);
  15278. return element.offsetWidth + margin;
  15279. }
  15280. exports.getTotalWidth = getTotalWidth;
  15281. function getContentWidth(element) {
  15282. var border = SizeUtils.getBorderLeftWidth(element) + SizeUtils.getBorderRightWidth(element);
  15283. var padding = SizeUtils.getPaddingLeft(element) + SizeUtils.getPaddingRight(element);
  15284. return element.offsetWidth - border - padding;
  15285. }
  15286. exports.getContentWidth = getContentWidth;
  15287. // Adapted from WinJS
  15288. // Gets the height of the content of the specified element. The content height does not include borders or padding.
  15289. function getContentHeight(element) {
  15290. var border = SizeUtils.getBorderTopWidth(element) + SizeUtils.getBorderBottomWidth(element);
  15291. var padding = SizeUtils.getPaddingTop(element) + SizeUtils.getPaddingBottom(element);
  15292. return element.offsetHeight - border - padding;
  15293. }
  15294. exports.getContentHeight = getContentHeight;
  15295. // Adapted from WinJS
  15296. // Gets the height of the element, including its margins.
  15297. function getTotalHeight(element) {
  15298. var margin = SizeUtils.getMarginTop(element) + SizeUtils.getMarginBottom(element);
  15299. return element.offsetHeight + margin;
  15300. }
  15301. exports.getTotalHeight = getTotalHeight;
  15302. // ----------------------------------------------------------------------------------------
  15303. function isAncestor(testChild, testAncestor) {
  15304. while (testChild) {
  15305. if (testChild === testAncestor) {
  15306. return true;
  15307. }
  15308. testChild = testChild.parentNode;
  15309. }
  15310. return false;
  15311. }
  15312. exports.isAncestor = isAncestor;
  15313. function findParentWithClass(node, clazz, stopAtClazzOrNode) {
  15314. while (node && node.nodeType === node.ELEMENT_NODE) {
  15315. if (exports.hasClass(node, clazz)) {
  15316. return node;
  15317. }
  15318. if (stopAtClazzOrNode) {
  15319. if (typeof stopAtClazzOrNode === 'string') {
  15320. if (exports.hasClass(node, stopAtClazzOrNode)) {
  15321. return null;
  15322. }
  15323. }
  15324. else {
  15325. if (node === stopAtClazzOrNode) {
  15326. return null;
  15327. }
  15328. }
  15329. }
  15330. node = node.parentNode;
  15331. }
  15332. return null;
  15333. }
  15334. exports.findParentWithClass = findParentWithClass;
  15335. function isShadowRoot(node) {
  15336. return (node && !!node.host && !!node.mode);
  15337. }
  15338. exports.isShadowRoot = isShadowRoot;
  15339. function isInShadowDOM(domNode) {
  15340. return !!getShadowRoot(domNode);
  15341. }
  15342. exports.isInShadowDOM = isInShadowDOM;
  15343. function getShadowRoot(domNode) {
  15344. while (domNode.parentNode) {
  15345. if (domNode === document.body) {
  15346. // reached the body
  15347. return null;
  15348. }
  15349. domNode = domNode.parentNode;
  15350. }
  15351. return isShadowRoot(domNode) ? domNode : null;
  15352. }
  15353. exports.getShadowRoot = getShadowRoot;
  15354. function createStyleSheet(container) {
  15355. if (container === void 0) { container = document.getElementsByTagName('head')[0]; }
  15356. var style = document.createElement('style');
  15357. style.type = 'text/css';
  15358. style.media = 'screen';
  15359. container.appendChild(style);
  15360. return style;
  15361. }
  15362. exports.createStyleSheet = createStyleSheet;
  15363. var _sharedStyleSheet = null;
  15364. function getSharedStyleSheet() {
  15365. if (!_sharedStyleSheet) {
  15366. _sharedStyleSheet = createStyleSheet();
  15367. }
  15368. return _sharedStyleSheet;
  15369. }
  15370. function getDynamicStyleSheetRules(style) {
  15371. if (style && style.sheet && style.sheet.rules) {
  15372. // Chrome, IE
  15373. return style.sheet.rules;
  15374. }
  15375. if (style && style.sheet && style.sheet.cssRules) {
  15376. // FF
  15377. return style.sheet.cssRules;
  15378. }
  15379. return [];
  15380. }
  15381. function createCSSRule(selector, cssText, style) {
  15382. if (style === void 0) { style = getSharedStyleSheet(); }
  15383. if (!style || !cssText) {
  15384. return;
  15385. }
  15386. style.sheet.insertRule(selector + '{' + cssText + '}', 0);
  15387. }
  15388. exports.createCSSRule = createCSSRule;
  15389. function removeCSSRulesContainingSelector(ruleName, style) {
  15390. if (style === void 0) { style = getSharedStyleSheet(); }
  15391. if (!style) {
  15392. return;
  15393. }
  15394. var rules = getDynamicStyleSheetRules(style);
  15395. var toDelete = [];
  15396. for (var i = 0; i < rules.length; i++) {
  15397. var rule = rules[i];
  15398. if (rule.selectorText.indexOf(ruleName) !== -1) {
  15399. toDelete.push(i);
  15400. }
  15401. }
  15402. for (var i = toDelete.length - 1; i >= 0; i--) {
  15403. style.sheet.deleteRule(toDelete[i]);
  15404. }
  15405. }
  15406. exports.removeCSSRulesContainingSelector = removeCSSRulesContainingSelector;
  15407. function isHTMLElement(o) {
  15408. if (typeof HTMLElement === 'object') {
  15409. return o instanceof HTMLElement;
  15410. }
  15411. return o && typeof o === 'object' && o.nodeType === 1 && typeof o.nodeName === 'string';
  15412. }
  15413. exports.isHTMLElement = isHTMLElement;
  15414. exports.EventType = {
  15415. // Mouse
  15416. CLICK: 'click',
  15417. DBLCLICK: 'dblclick',
  15418. MOUSE_UP: 'mouseup',
  15419. MOUSE_DOWN: 'mousedown',
  15420. MOUSE_OVER: 'mouseover',
  15421. MOUSE_MOVE: 'mousemove',
  15422. MOUSE_OUT: 'mouseout',
  15423. MOUSE_ENTER: 'mouseenter',
  15424. MOUSE_LEAVE: 'mouseleave',
  15425. POINTER_UP: 'pointerup',
  15426. POINTER_DOWN: 'pointerdown',
  15427. POINTER_MOVE: 'pointermove',
  15428. CONTEXT_MENU: 'contextmenu',
  15429. WHEEL: 'wheel',
  15430. // Keyboard
  15431. KEY_DOWN: 'keydown',
  15432. KEY_PRESS: 'keypress',
  15433. KEY_UP: 'keyup',
  15434. // HTML Document
  15435. LOAD: 'load',
  15436. BEFORE_UNLOAD: 'beforeunload',
  15437. UNLOAD: 'unload',
  15438. ABORT: 'abort',
  15439. ERROR: 'error',
  15440. RESIZE: 'resize',
  15441. SCROLL: 'scroll',
  15442. FULLSCREEN_CHANGE: 'fullscreenchange',
  15443. WK_FULLSCREEN_CHANGE: 'webkitfullscreenchange',
  15444. // Form
  15445. SELECT: 'select',
  15446. CHANGE: 'change',
  15447. SUBMIT: 'submit',
  15448. RESET: 'reset',
  15449. FOCUS: 'focus',
  15450. FOCUS_IN: 'focusin',
  15451. FOCUS_OUT: 'focusout',
  15452. BLUR: 'blur',
  15453. INPUT: 'input',
  15454. // Local Storage
  15455. STORAGE: 'storage',
  15456. // Drag
  15457. DRAG_START: 'dragstart',
  15458. DRAG: 'drag',
  15459. DRAG_ENTER: 'dragenter',
  15460. DRAG_LEAVE: 'dragleave',
  15461. DRAG_OVER: 'dragover',
  15462. DROP: 'drop',
  15463. DRAG_END: 'dragend',
  15464. // Animation
  15465. ANIMATION_START: browser.isWebKit ? 'webkitAnimationStart' : 'animationstart',
  15466. ANIMATION_END: browser.isWebKit ? 'webkitAnimationEnd' : 'animationend',
  15467. ANIMATION_ITERATION: browser.isWebKit ? 'webkitAnimationIteration' : 'animationiteration'
  15468. };
  15469. exports.EventHelper = {
  15470. stop: function (e, cancelBubble) {
  15471. if (e.preventDefault) {
  15472. e.preventDefault();
  15473. }
  15474. else {
  15475. // IE8
  15476. e.returnValue = false;
  15477. }
  15478. if (cancelBubble) {
  15479. if (e.stopPropagation) {
  15480. e.stopPropagation();
  15481. }
  15482. else {
  15483. // IE8
  15484. e.cancelBubble = true;
  15485. }
  15486. }
  15487. }
  15488. };
  15489. function saveParentsScrollTop(node) {
  15490. var r = [];
  15491. for (var i = 0; node && node.nodeType === node.ELEMENT_NODE; i++) {
  15492. r[i] = node.scrollTop;
  15493. node = node.parentNode;
  15494. }
  15495. return r;
  15496. }
  15497. exports.saveParentsScrollTop = saveParentsScrollTop;
  15498. function restoreParentsScrollTop(node, state) {
  15499. for (var i = 0; node && node.nodeType === node.ELEMENT_NODE; i++) {
  15500. if (node.scrollTop !== state[i]) {
  15501. node.scrollTop = state[i];
  15502. }
  15503. node = node.parentNode;
  15504. }
  15505. }
  15506. exports.restoreParentsScrollTop = restoreParentsScrollTop;
  15507. var FocusTracker = /** @class */ (function (_super) {
  15508. __extends(FocusTracker, _super);
  15509. function FocusTracker(element) {
  15510. var _this = _super.call(this) || this;
  15511. _this._onDidFocus = _this._register(new event_2.Emitter());
  15512. _this.onDidFocus = _this._onDidFocus.event;
  15513. _this._onDidBlur = _this._register(new event_2.Emitter());
  15514. _this.onDidBlur = _this._onDidBlur.event;
  15515. var hasFocus = isAncestor(document.activeElement, element);
  15516. var loosingFocus = false;
  15517. var onFocus = function () {
  15518. loosingFocus = false;
  15519. if (!hasFocus) {
  15520. hasFocus = true;
  15521. _this._onDidFocus.fire();
  15522. }
  15523. };
  15524. var onBlur = function () {
  15525. if (hasFocus) {
  15526. loosingFocus = true;
  15527. window.setTimeout(function () {
  15528. if (loosingFocus) {
  15529. loosingFocus = false;
  15530. hasFocus = false;
  15531. _this._onDidBlur.fire();
  15532. }
  15533. }, 0);
  15534. }
  15535. };
  15536. _this._refreshStateHandler = function () {
  15537. var currentNodeHasFocus = isAncestor(document.activeElement, element);
  15538. if (currentNodeHasFocus !== hasFocus) {
  15539. if (hasFocus) {
  15540. onBlur();
  15541. }
  15542. else {
  15543. onFocus();
  15544. }
  15545. }
  15546. };
  15547. _this._register(event_1.domEvent(element, exports.EventType.FOCUS, true)(onFocus));
  15548. _this._register(event_1.domEvent(element, exports.EventType.BLUR, true)(onBlur));
  15549. return _this;
  15550. }
  15551. return FocusTracker;
  15552. }(lifecycle_1.Disposable));
  15553. function trackFocus(element) {
  15554. return new FocusTracker(element);
  15555. }
  15556. exports.trackFocus = trackFocus;
  15557. function append(parent) {
  15558. var children = [];
  15559. for (var _i = 1; _i < arguments.length; _i++) {
  15560. children[_i - 1] = arguments[_i];
  15561. }
  15562. children.forEach(function (child) { return parent.appendChild(child); });
  15563. return children[children.length - 1];
  15564. }
  15565. exports.append = append;
  15566. var SELECTOR_REGEX = /([\w\-]+)?(#([\w\-]+))?((.([\w\-]+))*)/;
  15567. var Namespace;
  15568. (function (Namespace) {
  15569. Namespace["HTML"] = "http://www.w3.org/1999/xhtml";
  15570. Namespace["SVG"] = "http://www.w3.org/2000/svg";
  15571. })(Namespace = exports.Namespace || (exports.Namespace = {}));
  15572. function _$(namespace, description, attrs) {
  15573. var children = [];
  15574. for (var _i = 3; _i < arguments.length; _i++) {
  15575. children[_i - 3] = arguments[_i];
  15576. }
  15577. var match = SELECTOR_REGEX.exec(description);
  15578. if (!match) {
  15579. throw new Error('Bad use of emmet');
  15580. }
  15581. attrs = __assign({}, (attrs || {}));
  15582. var tagName = match[1] || 'div';
  15583. var result;
  15584. if (namespace !== Namespace.HTML) {
  15585. result = document.createElementNS(namespace, tagName);
  15586. }
  15587. else {
  15588. result = document.createElement(tagName);
  15589. }
  15590. if (match[3]) {
  15591. result.id = match[3];
  15592. }
  15593. if (match[4]) {
  15594. result.className = match[4].replace(/\./g, ' ').trim();
  15595. }
  15596. Object.keys(attrs).forEach(function (name) {
  15597. var value = attrs[name];
  15598. if (typeof value === 'undefined') {
  15599. return;
  15600. }
  15601. if (/^on\w+$/.test(name)) {
  15602. result[name] = value;
  15603. }
  15604. else if (name === 'selected') {
  15605. if (value) {
  15606. result.setAttribute(name, 'true');
  15607. }
  15608. }
  15609. else {
  15610. result.setAttribute(name, value);
  15611. }
  15612. });
  15613. arrays_1.coalesce(children)
  15614. .forEach(function (child) {
  15615. if (child instanceof Node) {
  15616. result.appendChild(child);
  15617. }
  15618. else {
  15619. result.appendChild(document.createTextNode(child));
  15620. }
  15621. });
  15622. return result;
  15623. }
  15624. function $(description, attrs) {
  15625. var children = [];
  15626. for (var _i = 2; _i < arguments.length; _i++) {
  15627. children[_i - 2] = arguments[_i];
  15628. }
  15629. return _$.apply(void 0, __spreadArrays([Namespace.HTML, description, attrs], children));
  15630. }
  15631. exports.$ = $;
  15632. $.SVG = function (description, attrs) {
  15633. var children = [];
  15634. for (var _i = 2; _i < arguments.length; _i++) {
  15635. children[_i - 2] = arguments[_i];
  15636. }
  15637. return _$.apply(void 0, __spreadArrays([Namespace.SVG, description, attrs], children));
  15638. };
  15639. function show() {
  15640. var elements = [];
  15641. for (var _i = 0; _i < arguments.length; _i++) {
  15642. elements[_i] = arguments[_i];
  15643. }
  15644. for (var _a = 0, elements_1 = elements; _a < elements_1.length; _a++) {
  15645. var element = elements_1[_a];
  15646. element.style.display = '';
  15647. element.removeAttribute('aria-hidden');
  15648. }
  15649. }
  15650. exports.show = show;
  15651. function hide() {
  15652. var elements = [];
  15653. for (var _i = 0; _i < arguments.length; _i++) {
  15654. elements[_i] = arguments[_i];
  15655. }
  15656. for (var _a = 0, elements_2 = elements; _a < elements_2.length; _a++) {
  15657. var element = elements_2[_a];
  15658. element.style.display = 'none';
  15659. element.setAttribute('aria-hidden', 'true');
  15660. }
  15661. }
  15662. exports.hide = hide;
  15663. function findParentWithAttribute(node, attribute) {
  15664. while (node && node.nodeType === node.ELEMENT_NODE) {
  15665. if (node instanceof HTMLElement && node.hasAttribute(attribute)) {
  15666. return node;
  15667. }
  15668. node = node.parentNode;
  15669. }
  15670. return null;
  15671. }
  15672. function removeTabIndexAndUpdateFocus(node) {
  15673. if (!node || !node.hasAttribute('tabIndex')) {
  15674. return;
  15675. }
  15676. // If we are the currently focused element and tabIndex is removed,
  15677. // standard DOM behavior is to move focus to the <body> element. We
  15678. // typically never want that, rather put focus to the closest element
  15679. // in the hierarchy of the parent DOM nodes.
  15680. if (document.activeElement === node) {
  15681. var parentFocusable = findParentWithAttribute(node.parentElement, 'tabIndex');
  15682. if (parentFocusable) {
  15683. parentFocusable.focus();
  15684. }
  15685. }
  15686. node.removeAttribute('tabindex');
  15687. }
  15688. exports.removeTabIndexAndUpdateFocus = removeTabIndexAndUpdateFocus;
  15689. function getElementsByTagName(tag) {
  15690. return Array.prototype.slice.call(document.getElementsByTagName(tag), 0);
  15691. }
  15692. exports.getElementsByTagName = getElementsByTagName;
  15693. /**
  15694. * Find a value usable for a dom node size such that the likelihood that it would be
  15695. * displayed with constant screen pixels size is as high as possible.
  15696. *
  15697. * e.g. We would desire for the cursors to be 2px (CSS px) wide. Under a devicePixelRatio
  15698. * of 1.25, the cursor will be 2.5 screen pixels wide. Depending on how the dom node aligns/"snaps"
  15699. * with the screen pixels, it will sometimes be rendered with 2 screen pixels, and sometimes with 3 screen pixels.
  15700. */
  15701. function computeScreenAwareSize(cssPx) {
  15702. var screenPx = window.devicePixelRatio * cssPx;
  15703. return Math.max(1, Math.floor(screenPx)) / window.devicePixelRatio;
  15704. }
  15705. exports.computeScreenAwareSize = computeScreenAwareSize;
  15706. /**
  15707. * See https://github.com/Microsoft/monaco-editor/issues/601
  15708. * To protect against malicious code in the linked site, particularly phishing attempts,
  15709. * the window.opener should be set to null to prevent the linked site from having access
  15710. * to change the location of the current page.
  15711. * See https://mathiasbynens.github.io/rel-noopener/
  15712. */
  15713. function windowOpenNoOpener(url) {
  15714. if (platform.isNative || browser.isEdgeWebView) {
  15715. // In VSCode, window.open() always returns null...
  15716. // The same is true for a WebView (see https://github.com/Microsoft/monaco-editor/issues/628)
  15717. window.open(url);
  15718. }
  15719. else {
  15720. var newTab = window.open();
  15721. if (newTab) {
  15722. newTab.opener = null;
  15723. newTab.location.href = url;
  15724. }
  15725. }
  15726. }
  15727. exports.windowOpenNoOpener = windowOpenNoOpener;
  15728. function animate(fn) {
  15729. var step = function () {
  15730. fn();
  15731. stepDisposable = exports.scheduleAtNextAnimationFrame(step);
  15732. };
  15733. var stepDisposable = exports.scheduleAtNextAnimationFrame(step);
  15734. return lifecycle_1.toDisposable(function () { return stepDisposable.dispose(); });
  15735. }
  15736. exports.animate = animate;
  15737. network_1.RemoteAuthorities.setPreferredWebSchema(/^https:/.test(window.location.href) ? 'https' : 'http');
  15738. function asDomUri(uri) {
  15739. if (!uri) {
  15740. return uri;
  15741. }
  15742. if (network_1.Schemas.vscodeRemote === uri.scheme) {
  15743. return network_1.RemoteAuthorities.rewrite(uri);
  15744. }
  15745. return uri;
  15746. }
  15747. exports.asDomUri = asDomUri;
  15748. /**
  15749. * returns url('...')
  15750. */
  15751. function asCSSUrl(uri) {
  15752. if (!uri) {
  15753. return "url('')";
  15754. }
  15755. return "url('" + asDomUri(uri).toString(true).replace(/'/g, '%27') + "')";
  15756. }
  15757. exports.asCSSUrl = asCSSUrl;
  15758. });
  15759. /*---------------------------------------------------------------------------------------------
  15760. * Copyright (c) Microsoft Corporation. All rights reserved.
  15761. * Licensed under the MIT License. See License.txt in the project root for license information.
  15762. *--------------------------------------------------------------------------------------------*/
  15763. define(__m[28/*vs/base/browser/fastDomNode*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/]), function (require, exports, dom) {
  15764. "use strict";
  15765. Object.defineProperty(exports, "__esModule", { value: true });
  15766. var FastDomNode = /** @class */ (function () {
  15767. function FastDomNode(domNode) {
  15768. this.domNode = domNode;
  15769. this._maxWidth = -1;
  15770. this._width = -1;
  15771. this._height = -1;
  15772. this._top = -1;
  15773. this._left = -1;
  15774. this._bottom = -1;
  15775. this._right = -1;
  15776. this._fontFamily = '';
  15777. this._fontWeight = '';
  15778. this._fontSize = -1;
  15779. this._fontFeatureSettings = '';
  15780. this._lineHeight = -1;
  15781. this._letterSpacing = -100;
  15782. this._className = '';
  15783. this._display = '';
  15784. this._position = '';
  15785. this._visibility = '';
  15786. this._backgroundColor = '';
  15787. this._layerHint = false;
  15788. this._contain = 'none';
  15789. }
  15790. FastDomNode.prototype.setMaxWidth = function (maxWidth) {
  15791. if (this._maxWidth === maxWidth) {
  15792. return;
  15793. }
  15794. this._maxWidth = maxWidth;
  15795. this.domNode.style.maxWidth = this._maxWidth + 'px';
  15796. };
  15797. FastDomNode.prototype.setWidth = function (width) {
  15798. if (this._width === width) {
  15799. return;
  15800. }
  15801. this._width = width;
  15802. this.domNode.style.width = this._width + 'px';
  15803. };
  15804. FastDomNode.prototype.setHeight = function (height) {
  15805. if (this._height === height) {
  15806. return;
  15807. }
  15808. this._height = height;
  15809. this.domNode.style.height = this._height + 'px';
  15810. };
  15811. FastDomNode.prototype.setTop = function (top) {
  15812. if (this._top === top) {
  15813. return;
  15814. }
  15815. this._top = top;
  15816. this.domNode.style.top = this._top + 'px';
  15817. };
  15818. FastDomNode.prototype.unsetTop = function () {
  15819. if (this._top === -1) {
  15820. return;
  15821. }
  15822. this._top = -1;
  15823. this.domNode.style.top = '';
  15824. };
  15825. FastDomNode.prototype.setLeft = function (left) {
  15826. if (this._left === left) {
  15827. return;
  15828. }
  15829. this._left = left;
  15830. this.domNode.style.left = this._left + 'px';
  15831. };
  15832. FastDomNode.prototype.setBottom = function (bottom) {
  15833. if (this._bottom === bottom) {
  15834. return;
  15835. }
  15836. this._bottom = bottom;
  15837. this.domNode.style.bottom = this._bottom + 'px';
  15838. };
  15839. FastDomNode.prototype.setRight = function (right) {
  15840. if (this._right === right) {
  15841. return;
  15842. }
  15843. this._right = right;
  15844. this.domNode.style.right = this._right + 'px';
  15845. };
  15846. FastDomNode.prototype.setFontFamily = function (fontFamily) {
  15847. if (this._fontFamily === fontFamily) {
  15848. return;
  15849. }
  15850. this._fontFamily = fontFamily;
  15851. this.domNode.style.fontFamily = this._fontFamily;
  15852. };
  15853. FastDomNode.prototype.setFontWeight = function (fontWeight) {
  15854. if (this._fontWeight === fontWeight) {
  15855. return;
  15856. }
  15857. this._fontWeight = fontWeight;
  15858. this.domNode.style.fontWeight = this._fontWeight;
  15859. };
  15860. FastDomNode.prototype.setFontSize = function (fontSize) {
  15861. if (this._fontSize === fontSize) {
  15862. return;
  15863. }
  15864. this._fontSize = fontSize;
  15865. this.domNode.style.fontSize = this._fontSize + 'px';
  15866. };
  15867. FastDomNode.prototype.setFontFeatureSettings = function (fontFeatureSettings) {
  15868. if (this._fontFeatureSettings === fontFeatureSettings) {
  15869. return;
  15870. }
  15871. this._fontFeatureSettings = fontFeatureSettings;
  15872. this.domNode.style.fontFeatureSettings = this._fontFeatureSettings;
  15873. };
  15874. FastDomNode.prototype.setLineHeight = function (lineHeight) {
  15875. if (this._lineHeight === lineHeight) {
  15876. return;
  15877. }
  15878. this._lineHeight = lineHeight;
  15879. this.domNode.style.lineHeight = this._lineHeight + 'px';
  15880. };
  15881. FastDomNode.prototype.setLetterSpacing = function (letterSpacing) {
  15882. if (this._letterSpacing === letterSpacing) {
  15883. return;
  15884. }
  15885. this._letterSpacing = letterSpacing;
  15886. this.domNode.style.letterSpacing = this._letterSpacing + 'px';
  15887. };
  15888. FastDomNode.prototype.setClassName = function (className) {
  15889. if (this._className === className) {
  15890. return;
  15891. }
  15892. this._className = className;
  15893. this.domNode.className = this._className;
  15894. };
  15895. FastDomNode.prototype.toggleClassName = function (className, shouldHaveIt) {
  15896. dom.toggleClass(this.domNode, className, shouldHaveIt);
  15897. this._className = this.domNode.className;
  15898. };
  15899. FastDomNode.prototype.setDisplay = function (display) {
  15900. if (this._display === display) {
  15901. return;
  15902. }
  15903. this._display = display;
  15904. this.domNode.style.display = this._display;
  15905. };
  15906. FastDomNode.prototype.setPosition = function (position) {
  15907. if (this._position === position) {
  15908. return;
  15909. }
  15910. this._position = position;
  15911. this.domNode.style.position = this._position;
  15912. };
  15913. FastDomNode.prototype.setVisibility = function (visibility) {
  15914. if (this._visibility === visibility) {
  15915. return;
  15916. }
  15917. this._visibility = visibility;
  15918. this.domNode.style.visibility = this._visibility;
  15919. };
  15920. FastDomNode.prototype.setBackgroundColor = function (backgroundColor) {
  15921. if (this._backgroundColor === backgroundColor) {
  15922. return;
  15923. }
  15924. this._backgroundColor = backgroundColor;
  15925. this.domNode.style.backgroundColor = this._backgroundColor;
  15926. };
  15927. FastDomNode.prototype.setLayerHinting = function (layerHint) {
  15928. if (this._layerHint === layerHint) {
  15929. return;
  15930. }
  15931. this._layerHint = layerHint;
  15932. this.domNode.style.transform = this._layerHint ? 'translate3d(0px, 0px, 0px)' : '';
  15933. };
  15934. FastDomNode.prototype.setContain = function (contain) {
  15935. if (this._contain === contain) {
  15936. return;
  15937. }
  15938. this._contain = contain;
  15939. this.domNode.style.contain = this._contain;
  15940. };
  15941. FastDomNode.prototype.setAttribute = function (name, value) {
  15942. this.domNode.setAttribute(name, value);
  15943. };
  15944. FastDomNode.prototype.removeAttribute = function (name) {
  15945. this.domNode.removeAttribute(name);
  15946. };
  15947. FastDomNode.prototype.appendChild = function (child) {
  15948. this.domNode.appendChild(child.domNode);
  15949. };
  15950. FastDomNode.prototype.removeChild = function (child) {
  15951. this.domNode.removeChild(child.domNode);
  15952. };
  15953. return FastDomNode;
  15954. }());
  15955. exports.FastDomNode = FastDomNode;
  15956. function createFastDomNode(domNode) {
  15957. return new FastDomNode(domNode);
  15958. }
  15959. exports.createFastDomNode = createFastDomNode;
  15960. });
  15961. /*---------------------------------------------------------------------------------------------
  15962. * Copyright (c) Microsoft Corporation. All rights reserved.
  15963. * Licensed under the MIT License. See License.txt in the project root for license information.
  15964. *--------------------------------------------------------------------------------------------*/
  15965. define(__m[134/*vs/base/browser/formattedTextRenderer*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/]), function (require, exports, DOM) {
  15966. "use strict";
  15967. Object.defineProperty(exports, "__esModule", { value: true });
  15968. function renderText(text, options) {
  15969. if (options === void 0) { options = {}; }
  15970. var element = createElement(options);
  15971. element.textContent = text;
  15972. return element;
  15973. }
  15974. exports.renderText = renderText;
  15975. function renderFormattedText(formattedText, options) {
  15976. if (options === void 0) { options = {}; }
  15977. var element = createElement(options);
  15978. _renderFormattedText(element, parseFormattedText(formattedText), options.actionHandler);
  15979. return element;
  15980. }
  15981. exports.renderFormattedText = renderFormattedText;
  15982. function createElement(options) {
  15983. var tagName = options.inline ? 'span' : 'div';
  15984. var element = document.createElement(tagName);
  15985. if (options.className) {
  15986. element.className = options.className;
  15987. }
  15988. return element;
  15989. }
  15990. exports.createElement = createElement;
  15991. var StringStream = /** @class */ (function () {
  15992. function StringStream(source) {
  15993. this.source = source;
  15994. this.index = 0;
  15995. }
  15996. StringStream.prototype.eos = function () {
  15997. return this.index >= this.source.length;
  15998. };
  15999. StringStream.prototype.next = function () {
  16000. var next = this.peek();
  16001. this.advance();
  16002. return next;
  16003. };
  16004. StringStream.prototype.peek = function () {
  16005. return this.source[this.index];
  16006. };
  16007. StringStream.prototype.advance = function () {
  16008. this.index++;
  16009. };
  16010. return StringStream;
  16011. }());
  16012. function _renderFormattedText(element, treeNode, actionHandler) {
  16013. var child;
  16014. if (treeNode.type === 2 /* Text */) {
  16015. child = document.createTextNode(treeNode.content || '');
  16016. }
  16017. else if (treeNode.type === 3 /* Bold */) {
  16018. child = document.createElement('b');
  16019. }
  16020. else if (treeNode.type === 4 /* Italics */) {
  16021. child = document.createElement('i');
  16022. }
  16023. else if (treeNode.type === 5 /* Action */ && actionHandler) {
  16024. var a = document.createElement('a');
  16025. a.href = '#';
  16026. actionHandler.disposeables.add(DOM.addStandardDisposableListener(a, 'click', function (event) {
  16027. actionHandler.callback(String(treeNode.index), event);
  16028. }));
  16029. child = a;
  16030. }
  16031. else if (treeNode.type === 7 /* NewLine */) {
  16032. child = document.createElement('br');
  16033. }
  16034. else if (treeNode.type === 1 /* Root */) {
  16035. child = element;
  16036. }
  16037. if (child && element !== child) {
  16038. element.appendChild(child);
  16039. }
  16040. if (child && Array.isArray(treeNode.children)) {
  16041. treeNode.children.forEach(function (nodeChild) {
  16042. _renderFormattedText(child, nodeChild, actionHandler);
  16043. });
  16044. }
  16045. }
  16046. function parseFormattedText(content) {
  16047. var root = {
  16048. type: 1 /* Root */,
  16049. children: []
  16050. };
  16051. var actionViewItemIndex = 0;
  16052. var current = root;
  16053. var stack = [];
  16054. var stream = new StringStream(content);
  16055. while (!stream.eos()) {
  16056. var next = stream.next();
  16057. var isEscapedFormatType = (next === '\\' && formatTagType(stream.peek()) !== 0 /* Invalid */);
  16058. if (isEscapedFormatType) {
  16059. next = stream.next(); // unread the backslash if it escapes a format tag type
  16060. }
  16061. if (!isEscapedFormatType && isFormatTag(next) && next === stream.peek()) {
  16062. stream.advance();
  16063. if (current.type === 2 /* Text */) {
  16064. current = stack.pop();
  16065. }
  16066. var type = formatTagType(next);
  16067. if (current.type === type || (current.type === 5 /* Action */ && type === 6 /* ActionClose */)) {
  16068. current = stack.pop();
  16069. }
  16070. else {
  16071. var newCurrent = {
  16072. type: type,
  16073. children: []
  16074. };
  16075. if (type === 5 /* Action */) {
  16076. newCurrent.index = actionViewItemIndex;
  16077. actionViewItemIndex++;
  16078. }
  16079. current.children.push(newCurrent);
  16080. stack.push(current);
  16081. current = newCurrent;
  16082. }
  16083. }
  16084. else if (next === '\n') {
  16085. if (current.type === 2 /* Text */) {
  16086. current = stack.pop();
  16087. }
  16088. current.children.push({
  16089. type: 7 /* NewLine */
  16090. });
  16091. }
  16092. else {
  16093. if (current.type !== 2 /* Text */) {
  16094. var textCurrent = {
  16095. type: 2 /* Text */,
  16096. content: next
  16097. };
  16098. current.children.push(textCurrent);
  16099. stack.push(current);
  16100. current = textCurrent;
  16101. }
  16102. else {
  16103. current.content += next;
  16104. }
  16105. }
  16106. }
  16107. if (current.type === 2 /* Text */) {
  16108. current = stack.pop();
  16109. }
  16110. if (stack.length) {
  16111. // incorrectly formatted string literal
  16112. }
  16113. return root;
  16114. }
  16115. function isFormatTag(char) {
  16116. return formatTagType(char) !== 0 /* Invalid */;
  16117. }
  16118. function formatTagType(char) {
  16119. switch (char) {
  16120. case '*':
  16121. return 3 /* Bold */;
  16122. case '_':
  16123. return 4 /* Italics */;
  16124. case '[':
  16125. return 5 /* Action */;
  16126. case ']':
  16127. return 6 /* ActionClose */;
  16128. default:
  16129. return 0 /* Invalid */;
  16130. }
  16131. }
  16132. });
  16133. /*---------------------------------------------------------------------------------------------
  16134. * Copyright (c) Microsoft Corporation. All rights reserved.
  16135. * Licensed under the MIT License. See License.txt in the project root for license information.
  16136. *--------------------------------------------------------------------------------------------*/
  16137. define(__m[78/*vs/base/browser/globalMouseMoveMonitor*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,16/*vs/base/common/platform*/,24/*vs/base/browser/browser*/,174/*vs/base/browser/iframe*/,45/*vs/base/browser/mouseEvent*/,2/*vs/base/common/lifecycle*/,88/*vs/base/browser/canIUse*/]), function (require, exports, dom, platform, browser, iframe_1, mouseEvent_1, lifecycle_1, canIUse_1) {
  16138. "use strict";
  16139. Object.defineProperty(exports, "__esModule", { value: true });
  16140. function standardMouseMoveMerger(lastEvent, currentEvent) {
  16141. var ev = new mouseEvent_1.StandardMouseEvent(currentEvent);
  16142. ev.preventDefault();
  16143. return {
  16144. leftButton: ev.leftButton,
  16145. buttons: ev.buttons,
  16146. posx: ev.posx,
  16147. posy: ev.posy
  16148. };
  16149. }
  16150. exports.standardMouseMoveMerger = standardMouseMoveMerger;
  16151. var GlobalMouseMoveMonitor = /** @class */ (function () {
  16152. function GlobalMouseMoveMonitor() {
  16153. this._hooks = new lifecycle_1.DisposableStore();
  16154. this._mouseMoveEventMerger = null;
  16155. this._mouseMoveCallback = null;
  16156. this._onStopCallback = null;
  16157. }
  16158. GlobalMouseMoveMonitor.prototype.dispose = function () {
  16159. this.stopMonitoring(false);
  16160. this._hooks.dispose();
  16161. };
  16162. GlobalMouseMoveMonitor.prototype.stopMonitoring = function (invokeStopCallback) {
  16163. if (!this.isMonitoring()) {
  16164. // Not monitoring
  16165. return;
  16166. }
  16167. // Unhook
  16168. this._hooks.clear();
  16169. this._mouseMoveEventMerger = null;
  16170. this._mouseMoveCallback = null;
  16171. var onStopCallback = this._onStopCallback;
  16172. this._onStopCallback = null;
  16173. if (invokeStopCallback && onStopCallback) {
  16174. onStopCallback();
  16175. }
  16176. };
  16177. GlobalMouseMoveMonitor.prototype.isMonitoring = function () {
  16178. return !!this._mouseMoveEventMerger;
  16179. };
  16180. GlobalMouseMoveMonitor.prototype.startMonitoring = function (initialElement, initialButtons, mouseMoveEventMerger, mouseMoveCallback, onStopCallback) {
  16181. var _this = this;
  16182. if (this.isMonitoring()) {
  16183. // I am already hooked
  16184. return;
  16185. }
  16186. this._mouseMoveEventMerger = mouseMoveEventMerger;
  16187. this._mouseMoveCallback = mouseMoveCallback;
  16188. this._onStopCallback = onStopCallback;
  16189. var windowChain = iframe_1.IframeUtils.getSameOriginWindowChain();
  16190. var mouseMove = platform.isIOS && canIUse_1.BrowserFeatures.pointerEvents ? 'pointermove' : 'mousemove';
  16191. var mouseUp = platform.isIOS && canIUse_1.BrowserFeatures.pointerEvents ? 'pointerup' : 'mouseup';
  16192. var listenTo = windowChain.map(function (element) { return element.window.document; });
  16193. var shadowRoot = dom.getShadowRoot(initialElement);
  16194. if (shadowRoot) {
  16195. listenTo.unshift(shadowRoot);
  16196. }
  16197. for (var _i = 0, listenTo_1 = listenTo; _i < listenTo_1.length; _i++) {
  16198. var element = listenTo_1[_i];
  16199. this._hooks.add(dom.addDisposableThrottledListener(element, mouseMove, function (data) {
  16200. if (!browser.isIE && data.buttons !== initialButtons) {
  16201. // Buttons state has changed in the meantime
  16202. _this.stopMonitoring(true);
  16203. return;
  16204. }
  16205. _this._mouseMoveCallback(data);
  16206. }, function (lastEvent, currentEvent) { return _this._mouseMoveEventMerger(lastEvent, currentEvent); }));
  16207. this._hooks.add(dom.addDisposableListener(element, mouseUp, function (e) { return _this.stopMonitoring(true); }));
  16208. }
  16209. if (iframe_1.IframeUtils.hasDifferentOriginAncestor()) {
  16210. var lastSameOriginAncestor = windowChain[windowChain.length - 1];
  16211. // We might miss a mouse up if it happens outside the iframe
  16212. // This one is for Chrome
  16213. this._hooks.add(dom.addDisposableListener(lastSameOriginAncestor.window.document, 'mouseout', function (browserEvent) {
  16214. var e = new mouseEvent_1.StandardMouseEvent(browserEvent);
  16215. if (e.target.tagName.toLowerCase() === 'html') {
  16216. _this.stopMonitoring(true);
  16217. }
  16218. }));
  16219. // This one is for FF
  16220. this._hooks.add(dom.addDisposableListener(lastSameOriginAncestor.window.document, 'mouseover', function (browserEvent) {
  16221. var e = new mouseEvent_1.StandardMouseEvent(browserEvent);
  16222. if (e.target.tagName.toLowerCase() === 'html') {
  16223. _this.stopMonitoring(true);
  16224. }
  16225. }));
  16226. // This one is for IE
  16227. this._hooks.add(dom.addDisposableListener(lastSameOriginAncestor.window.document.body, 'mouseleave', function (browserEvent) {
  16228. _this.stopMonitoring(true);
  16229. }));
  16230. }
  16231. };
  16232. return GlobalMouseMoveMonitor;
  16233. }());
  16234. exports.GlobalMouseMoveMonitor = GlobalMouseMoveMonitor;
  16235. });
  16236. /*---------------------------------------------------------------------------------------------
  16237. * Copyright (c) Microsoft Corporation. All rights reserved.
  16238. * Licensed under the MIT License. See License.txt in the project root for license information.
  16239. *--------------------------------------------------------------------------------------------*/
  16240. define(__m[248/*vs/base/browser/markdownRenderer*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,134/*vs/base/browser/formattedTextRenderer*/,10/*vs/base/common/errors*/,75/*vs/base/common/htmlContent*/,127/*vs/base/common/idGenerator*/,612/*vs/base/common/marked/marked*/,613/*vs/base/common/insane/insane*/,180/*vs/base/common/marshalling*/,31/*vs/base/common/objects*/,5/*vs/base/common/strings*/,25/*vs/base/common/uri*/,46/*vs/base/common/network*/,100/*vs/base/common/codicons*/]), function (require, exports, DOM, formattedTextRenderer_1, errors_1, htmlContent_1, idGenerator_1, marked, insane_1, marshalling_1, objects_1, strings_1, uri_1, network_1, codicons_1) {
  16241. "use strict";
  16242. Object.defineProperty(exports, "__esModule", { value: true });
  16243. /**
  16244. * Create html nodes for the given content element.
  16245. */
  16246. function renderMarkdown(markdown, options) {
  16247. if (options === void 0) { options = {}; }
  16248. var element = formattedTextRenderer_1.createElement(options);
  16249. var _uriMassage = function (part) {
  16250. var data;
  16251. try {
  16252. data = marshalling_1.parse(decodeURIComponent(part));
  16253. }
  16254. catch (e) {
  16255. // ignore
  16256. }
  16257. if (!data) {
  16258. return part;
  16259. }
  16260. data = objects_1.cloneAndChange(data, function (value) {
  16261. if (markdown.uris && markdown.uris[value]) {
  16262. return uri_1.URI.revive(markdown.uris[value]);
  16263. }
  16264. else {
  16265. return undefined;
  16266. }
  16267. });
  16268. return encodeURIComponent(JSON.stringify(data));
  16269. };
  16270. var _href = function (href, isDomUri) {
  16271. var data = markdown.uris && markdown.uris[href];
  16272. if (!data) {
  16273. return href; // no uri exists
  16274. }
  16275. var uri = uri_1.URI.revive(data);
  16276. if (uri_1.URI.parse(href).toString() === uri.toString()) {
  16277. return href; // no tranformation performed
  16278. }
  16279. if (isDomUri) {
  16280. uri = DOM.asDomUri(uri);
  16281. }
  16282. if (uri.query) {
  16283. uri = uri.with({ query: _uriMassage(uri.query) });
  16284. }
  16285. return uri.toString(true);
  16286. };
  16287. // signal to code-block render that the
  16288. // element has been created
  16289. var signalInnerHTML;
  16290. var withInnerHTML = new Promise(function (c) { return signalInnerHTML = c; });
  16291. var renderer = new marked.Renderer();
  16292. renderer.image = function (href, title, text) {
  16293. var _a;
  16294. var dimensions = [];
  16295. var attributes = [];
  16296. if (href) {
  16297. (_a = htmlContent_1.parseHrefAndDimensions(href), href = _a.href, dimensions = _a.dimensions);
  16298. href = _href(href, true);
  16299. attributes.push("src=\"" + href + "\"");
  16300. }
  16301. if (text) {
  16302. attributes.push("alt=\"" + text + "\"");
  16303. }
  16304. if (title) {
  16305. attributes.push("title=\"" + title + "\"");
  16306. }
  16307. if (dimensions.length) {
  16308. attributes = attributes.concat(dimensions);
  16309. }
  16310. return '<img ' + attributes.join(' ') + '>';
  16311. };
  16312. renderer.link = function (href, title, text) {
  16313. // Remove markdown escapes. Workaround for https://github.com/chjj/marked/issues/829
  16314. if (href === text) { // raw link case
  16315. text = htmlContent_1.removeMarkdownEscapes(text);
  16316. }
  16317. href = _href(href, false);
  16318. title = htmlContent_1.removeMarkdownEscapes(title);
  16319. href = htmlContent_1.removeMarkdownEscapes(href);
  16320. if (!href
  16321. || href.match(/^data:|javascript:/i)
  16322. || (href.match(/^command:/i) && !markdown.isTrusted)
  16323. || href.match(/^command:(\/\/\/)?_workbench\.downloadResource/i)) {
  16324. // drop the link
  16325. return text;
  16326. }
  16327. else {
  16328. // HTML Encode href
  16329. href = href.replace(/&/g, '&amp;')
  16330. .replace(/</g, '&lt;')
  16331. .replace(/>/g, '&gt;')
  16332. .replace(/"/g, '&quot;')
  16333. .replace(/'/g, '&#39;');
  16334. return "<a href=\"#\" data-href=\"" + href + "\" title=\"" + (title || href) + "\">" + text + "</a>";
  16335. }
  16336. };
  16337. renderer.paragraph = function (text) {
  16338. return "<p>" + (markdown.supportThemeIcons ? codicons_1.renderCodicons(text) : text) + "</p>";
  16339. };
  16340. if (options.codeBlockRenderer) {
  16341. renderer.code = function (code, lang) {
  16342. var value = options.codeBlockRenderer(lang, code);
  16343. // when code-block rendering is async we return sync
  16344. // but update the node with the real result later.
  16345. var id = idGenerator_1.defaultGenerator.nextId();
  16346. var promise = Promise.all([value, withInnerHTML]).then(function (values) {
  16347. var strValue = values[0];
  16348. var span = element.querySelector("div[data-code=\"" + id + "\"]");
  16349. if (span) {
  16350. span.innerHTML = strValue;
  16351. }
  16352. }).catch(function (err) {
  16353. // ignore
  16354. });
  16355. if (options.codeBlockRenderCallback) {
  16356. promise.then(options.codeBlockRenderCallback);
  16357. }
  16358. return "<div class=\"code\" data-code=\"" + id + "\">" + strings_1.escape(code) + "</div>";
  16359. };
  16360. }
  16361. var actionHandler = options.actionHandler;
  16362. if (actionHandler) {
  16363. actionHandler.disposeables.add(DOM.addStandardDisposableListener(element, 'click', function (event) {
  16364. var target = event.target;
  16365. if (target.tagName !== 'A') {
  16366. target = target.parentElement;
  16367. if (!target || target.tagName !== 'A') {
  16368. return;
  16369. }
  16370. }
  16371. try {
  16372. var href = target.dataset['href'];
  16373. if (href) {
  16374. actionHandler.callback(href, event);
  16375. }
  16376. }
  16377. catch (err) {
  16378. errors_1.onUnexpectedError(err);
  16379. }
  16380. finally {
  16381. event.preventDefault();
  16382. }
  16383. }));
  16384. }
  16385. var markedOptions = {
  16386. sanitize: true,
  16387. renderer: renderer
  16388. };
  16389. var allowedSchemes = [network_1.Schemas.http, network_1.Schemas.https, network_1.Schemas.mailto, network_1.Schemas.data, network_1.Schemas.file, network_1.Schemas.vscodeRemote, network_1.Schemas.vscodeRemoteResource];
  16390. if (markdown.isTrusted) {
  16391. allowedSchemes.push(network_1.Schemas.command);
  16392. }
  16393. var renderedMarkdown = marked.parse(markdown.supportThemeIcons
  16394. ? codicons_1.markdownEscapeEscapedCodicons(markdown.value)
  16395. : markdown.value, markedOptions);
  16396. element.innerHTML = insane_1.insane(renderedMarkdown, {
  16397. allowedSchemes: allowedSchemes,
  16398. allowedAttributes: {
  16399. 'a': ['href', 'name', 'target', 'data-href'],
  16400. 'iframe': ['allowfullscreen', 'frameborder', 'src'],
  16401. 'img': ['src', 'title', 'alt', 'width', 'height'],
  16402. 'div': ['class', 'data-code'],
  16403. 'span': ['class']
  16404. }
  16405. });
  16406. signalInnerHTML();
  16407. return element;
  16408. }
  16409. exports.renderMarkdown = renderMarkdown;
  16410. });
  16411. /*---------------------------------------------------------------------------------------------
  16412. * Copyright (c) Microsoft Corporation. All rights reserved.
  16413. * Licensed under the MIT License. See License.txt in the project root for license information.
  16414. *--------------------------------------------------------------------------------------------*/
  16415. var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
  16416. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  16417. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  16418. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  16419. return c > 3 && r && Object.defineProperty(target, key, r), r;
  16420. };
  16421. define(__m[57/*vs/base/browser/touch*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,2/*vs/base/common/lifecycle*/,6/*vs/base/browser/dom*/,101/*vs/base/common/decorators*/]), function (require, exports, arrays, lifecycle_1, DomUtils, decorators_1) {
  16422. "use strict";
  16423. Object.defineProperty(exports, "__esModule", { value: true });
  16424. var EventType;
  16425. (function (EventType) {
  16426. EventType.Tap = '-monaco-gesturetap';
  16427. EventType.Change = '-monaco-gesturechange';
  16428. EventType.Start = '-monaco-gesturestart';
  16429. EventType.End = '-monaco-gesturesend';
  16430. EventType.Contextmenu = '-monaco-gesturecontextmenu';
  16431. })(EventType = exports.EventType || (exports.EventType = {}));
  16432. var Gesture = /** @class */ (function (_super) {
  16433. __extends(Gesture, _super);
  16434. function Gesture() {
  16435. var _this = _super.call(this) || this;
  16436. _this.dispatched = false;
  16437. _this.activeTouches = {};
  16438. _this.handle = null;
  16439. _this.targets = [];
  16440. _this.ignoreTargets = [];
  16441. _this._lastSetTapCountTime = 0;
  16442. _this._register(DomUtils.addDisposableListener(document, 'touchstart', function (e) { return _this.onTouchStart(e); }));
  16443. _this._register(DomUtils.addDisposableListener(document, 'touchend', function (e) { return _this.onTouchEnd(e); }));
  16444. _this._register(DomUtils.addDisposableListener(document, 'touchmove', function (e) { return _this.onTouchMove(e); }));
  16445. return _this;
  16446. }
  16447. Gesture.addTarget = function (element) {
  16448. if (!Gesture.isTouchDevice()) {
  16449. return lifecycle_1.Disposable.None;
  16450. }
  16451. if (!Gesture.INSTANCE) {
  16452. Gesture.INSTANCE = new Gesture();
  16453. }
  16454. Gesture.INSTANCE.targets.push(element);
  16455. return {
  16456. dispose: function () {
  16457. Gesture.INSTANCE.targets = Gesture.INSTANCE.targets.filter(function (t) { return t !== element; });
  16458. }
  16459. };
  16460. };
  16461. Gesture.ignoreTarget = function (element) {
  16462. if (!Gesture.isTouchDevice()) {
  16463. return lifecycle_1.Disposable.None;
  16464. }
  16465. if (!Gesture.INSTANCE) {
  16466. Gesture.INSTANCE = new Gesture();
  16467. }
  16468. Gesture.INSTANCE.ignoreTargets.push(element);
  16469. return {
  16470. dispose: function () {
  16471. Gesture.INSTANCE.ignoreTargets = Gesture.INSTANCE.ignoreTargets.filter(function (t) { return t !== element; });
  16472. }
  16473. };
  16474. };
  16475. Gesture.isTouchDevice = function () {
  16476. return 'ontouchstart' in window || navigator.maxTouchPoints > 0 || window.navigator.msMaxTouchPoints > 0;
  16477. };
  16478. Gesture.prototype.dispose = function () {
  16479. if (this.handle) {
  16480. this.handle.dispose();
  16481. this.handle = null;
  16482. }
  16483. _super.prototype.dispose.call(this);
  16484. };
  16485. Gesture.prototype.onTouchStart = function (e) {
  16486. var timestamp = Date.now(); // use Date.now() because on FF e.timeStamp is not epoch based.
  16487. if (this.handle) {
  16488. this.handle.dispose();
  16489. this.handle = null;
  16490. }
  16491. for (var i = 0, len = e.targetTouches.length; i < len; i++) {
  16492. var touch = e.targetTouches.item(i);
  16493. this.activeTouches[touch.identifier] = {
  16494. id: touch.identifier,
  16495. initialTarget: touch.target,
  16496. initialTimeStamp: timestamp,
  16497. initialPageX: touch.pageX,
  16498. initialPageY: touch.pageY,
  16499. rollingTimestamps: [timestamp],
  16500. rollingPageX: [touch.pageX],
  16501. rollingPageY: [touch.pageY]
  16502. };
  16503. var evt = this.newGestureEvent(EventType.Start, touch.target);
  16504. evt.pageX = touch.pageX;
  16505. evt.pageY = touch.pageY;
  16506. this.dispatchEvent(evt);
  16507. }
  16508. if (this.dispatched) {
  16509. e.preventDefault();
  16510. e.stopPropagation();
  16511. this.dispatched = false;
  16512. }
  16513. };
  16514. Gesture.prototype.onTouchEnd = function (e) {
  16515. var timestamp = Date.now(); // use Date.now() because on FF e.timeStamp is not epoch based.
  16516. var activeTouchCount = Object.keys(this.activeTouches).length;
  16517. var _loop_1 = function (i, len) {
  16518. var touch = e.changedTouches.item(i);
  16519. if (!this_1.activeTouches.hasOwnProperty(String(touch.identifier))) {
  16520. console.warn('move of an UNKNOWN touch', touch);
  16521. return "continue";
  16522. }
  16523. var data = this_1.activeTouches[touch.identifier], holdTime = Date.now() - data.initialTimeStamp;
  16524. if (holdTime < Gesture.HOLD_DELAY
  16525. && Math.abs(data.initialPageX - arrays.tail(data.rollingPageX)) < 30
  16526. && Math.abs(data.initialPageY - arrays.tail(data.rollingPageY)) < 30) {
  16527. var evt = this_1.newGestureEvent(EventType.Tap, data.initialTarget);
  16528. evt.pageX = arrays.tail(data.rollingPageX);
  16529. evt.pageY = arrays.tail(data.rollingPageY);
  16530. this_1.dispatchEvent(evt);
  16531. }
  16532. else if (holdTime >= Gesture.HOLD_DELAY
  16533. && Math.abs(data.initialPageX - arrays.tail(data.rollingPageX)) < 30
  16534. && Math.abs(data.initialPageY - arrays.tail(data.rollingPageY)) < 30) {
  16535. var evt = this_1.newGestureEvent(EventType.Contextmenu, data.initialTarget);
  16536. evt.pageX = arrays.tail(data.rollingPageX);
  16537. evt.pageY = arrays.tail(data.rollingPageY);
  16538. this_1.dispatchEvent(evt);
  16539. }
  16540. else if (activeTouchCount === 1) {
  16541. var finalX = arrays.tail(data.rollingPageX);
  16542. var finalY = arrays.tail(data.rollingPageY);
  16543. var deltaT = arrays.tail(data.rollingTimestamps) - data.rollingTimestamps[0];
  16544. var deltaX = finalX - data.rollingPageX[0];
  16545. var deltaY = finalY - data.rollingPageY[0];
  16546. // We need to get all the dispatch targets on the start of the inertia event
  16547. var dispatchTo = this_1.targets.filter(function (t) { return data.initialTarget instanceof Node && t.contains(data.initialTarget); });
  16548. this_1.inertia(dispatchTo, timestamp, // time now
  16549. Math.abs(deltaX) / deltaT, // speed
  16550. deltaX > 0 ? 1 : -1, // x direction
  16551. finalX, // x now
  16552. Math.abs(deltaY) / deltaT, // y speed
  16553. deltaY > 0 ? 1 : -1, // y direction
  16554. finalY // y now
  16555. );
  16556. }
  16557. this_1.dispatchEvent(this_1.newGestureEvent(EventType.End, data.initialTarget));
  16558. // forget about this touch
  16559. delete this_1.activeTouches[touch.identifier];
  16560. };
  16561. var this_1 = this;
  16562. for (var i = 0, len = e.changedTouches.length; i < len; i++) {
  16563. _loop_1(i, len);
  16564. }
  16565. if (this.dispatched) {
  16566. e.preventDefault();
  16567. e.stopPropagation();
  16568. this.dispatched = false;
  16569. }
  16570. };
  16571. Gesture.prototype.newGestureEvent = function (type, initialTarget) {
  16572. var event = document.createEvent('CustomEvent');
  16573. event.initEvent(type, false, true);
  16574. event.initialTarget = initialTarget;
  16575. event.tapCount = 0;
  16576. return event;
  16577. };
  16578. Gesture.prototype.dispatchEvent = function (event) {
  16579. var _this = this;
  16580. if (event.type === EventType.Tap) {
  16581. var currentTime = (new Date()).getTime();
  16582. var setTapCount = 0;
  16583. if (currentTime - this._lastSetTapCountTime > Gesture.CLEAR_TAP_COUNT_TIME) {
  16584. setTapCount = 1;
  16585. }
  16586. else {
  16587. setTapCount = 2;
  16588. }
  16589. this._lastSetTapCountTime = currentTime;
  16590. event.tapCount = setTapCount;
  16591. }
  16592. else if (event.type === EventType.Change || event.type === EventType.Contextmenu) {
  16593. // tap is canceled by scrolling or context menu
  16594. this._lastSetTapCountTime = 0;
  16595. }
  16596. for (var i = 0; i < this.ignoreTargets.length; i++) {
  16597. if (event.initialTarget instanceof Node && this.ignoreTargets[i].contains(event.initialTarget)) {
  16598. return;
  16599. }
  16600. }
  16601. this.targets.forEach(function (target) {
  16602. if (event.initialTarget instanceof Node && target.contains(event.initialTarget)) {
  16603. target.dispatchEvent(event);
  16604. _this.dispatched = true;
  16605. }
  16606. });
  16607. };
  16608. Gesture.prototype.inertia = function (dispatchTo, t1, vX, dirX, x, vY, dirY, y) {
  16609. var _this = this;
  16610. this.handle = DomUtils.scheduleAtNextAnimationFrame(function () {
  16611. var now = Date.now();
  16612. // velocity: old speed + accel_over_time
  16613. var deltaT = now - t1, delta_pos_x = 0, delta_pos_y = 0, stopped = true;
  16614. vX += Gesture.SCROLL_FRICTION * deltaT;
  16615. vY += Gesture.SCROLL_FRICTION * deltaT;
  16616. if (vX > 0) {
  16617. stopped = false;
  16618. delta_pos_x = dirX * vX * deltaT;
  16619. }
  16620. if (vY > 0) {
  16621. stopped = false;
  16622. delta_pos_y = dirY * vY * deltaT;
  16623. }
  16624. // dispatch translation event
  16625. var evt = _this.newGestureEvent(EventType.Change);
  16626. evt.translationX = delta_pos_x;
  16627. evt.translationY = delta_pos_y;
  16628. dispatchTo.forEach(function (d) { return d.dispatchEvent(evt); });
  16629. if (!stopped) {
  16630. _this.inertia(dispatchTo, now, vX, dirX, x + delta_pos_x, vY, dirY, y + delta_pos_y);
  16631. }
  16632. });
  16633. };
  16634. Gesture.prototype.onTouchMove = function (e) {
  16635. var timestamp = Date.now(); // use Date.now() because on FF e.timeStamp is not epoch based.
  16636. for (var i = 0, len = e.changedTouches.length; i < len; i++) {
  16637. var touch = e.changedTouches.item(i);
  16638. if (!this.activeTouches.hasOwnProperty(String(touch.identifier))) {
  16639. console.warn('end of an UNKNOWN touch', touch);
  16640. continue;
  16641. }
  16642. var data = this.activeTouches[touch.identifier];
  16643. var evt = this.newGestureEvent(EventType.Change, data.initialTarget);
  16644. evt.translationX = touch.pageX - arrays.tail(data.rollingPageX);
  16645. evt.translationY = touch.pageY - arrays.tail(data.rollingPageY);
  16646. evt.pageX = touch.pageX;
  16647. evt.pageY = touch.pageY;
  16648. this.dispatchEvent(evt);
  16649. // only keep a few data points, to average the final speed
  16650. if (data.rollingPageX.length > 3) {
  16651. data.rollingPageX.shift();
  16652. data.rollingPageY.shift();
  16653. data.rollingTimestamps.shift();
  16654. }
  16655. data.rollingPageX.push(touch.pageX);
  16656. data.rollingPageY.push(touch.pageY);
  16657. data.rollingTimestamps.push(timestamp);
  16658. }
  16659. if (this.dispatched) {
  16660. e.preventDefault();
  16661. e.stopPropagation();
  16662. this.dispatched = false;
  16663. }
  16664. };
  16665. Gesture.SCROLL_FRICTION = -0.005;
  16666. Gesture.HOLD_DELAY = 700;
  16667. Gesture.CLEAR_TAP_COUNT_TIME = 400; // ms
  16668. __decorate([
  16669. decorators_1.memoize
  16670. ], Gesture, "isTouchDevice", null);
  16671. return Gesture;
  16672. }(lifecycle_1.Disposable));
  16673. exports.Gesture = Gesture;
  16674. });
  16675. /*---------------------------------------------------------------------------------------------
  16676. * Copyright (c) Microsoft Corporation. All rights reserved.
  16677. * Licensed under the MIT License. See License.txt in the project root for license information.
  16678. *--------------------------------------------------------------------------------------------*/
  16679. define(__m[249/*vs/base/browser/ui/list/rowCache*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/]), function (require, exports, dom_1) {
  16680. "use strict";
  16681. Object.defineProperty(exports, "__esModule", { value: true });
  16682. function removeFromParent(element) {
  16683. try {
  16684. if (element.parentElement) {
  16685. element.parentElement.removeChild(element);
  16686. }
  16687. }
  16688. catch (e) {
  16689. // this will throw if this happens due to a blur event, nasty business
  16690. }
  16691. }
  16692. var RowCache = /** @class */ (function () {
  16693. function RowCache(renderers) {
  16694. this.renderers = renderers;
  16695. this.cache = new Map();
  16696. }
  16697. /**
  16698. * Returns a row either by creating a new one or reusing
  16699. * a previously released row which shares the same templateId.
  16700. */
  16701. RowCache.prototype.alloc = function (templateId) {
  16702. var result = this.getTemplateCache(templateId).pop();
  16703. if (!result) {
  16704. var domNode = dom_1.$('.monaco-list-row');
  16705. var renderer = this.getRenderer(templateId);
  16706. var templateData = renderer.renderTemplate(domNode);
  16707. result = { domNode: domNode, templateId: templateId, templateData: templateData };
  16708. }
  16709. return result;
  16710. };
  16711. /**
  16712. * Releases the row for eventual reuse.
  16713. */
  16714. RowCache.prototype.release = function (row) {
  16715. if (!row) {
  16716. return;
  16717. }
  16718. this.releaseRow(row);
  16719. };
  16720. RowCache.prototype.releaseRow = function (row) {
  16721. var domNode = row.domNode, templateId = row.templateId;
  16722. if (domNode) {
  16723. dom_1.removeClass(domNode, 'scrolling');
  16724. removeFromParent(domNode);
  16725. }
  16726. var cache = this.getTemplateCache(templateId);
  16727. cache.push(row);
  16728. };
  16729. RowCache.prototype.getTemplateCache = function (templateId) {
  16730. var result = this.cache.get(templateId);
  16731. if (!result) {
  16732. result = [];
  16733. this.cache.set(templateId, result);
  16734. }
  16735. return result;
  16736. };
  16737. RowCache.prototype.dispose = function () {
  16738. var _this = this;
  16739. this.cache.forEach(function (cachedRows, templateId) {
  16740. for (var _i = 0, cachedRows_1 = cachedRows; _i < cachedRows_1.length; _i++) {
  16741. var cachedRow = cachedRows_1[_i];
  16742. var renderer = _this.getRenderer(templateId);
  16743. renderer.disposeTemplate(cachedRow.templateData);
  16744. cachedRow.domNode = null;
  16745. cachedRow.templateData = null;
  16746. }
  16747. });
  16748. this.cache.clear();
  16749. };
  16750. RowCache.prototype.getRenderer = function (templateId) {
  16751. var renderer = this.renderers.get(templateId);
  16752. if (!renderer) {
  16753. throw new Error("No renderer found for " + templateId);
  16754. }
  16755. return renderer;
  16756. };
  16757. return RowCache;
  16758. }());
  16759. exports.RowCache = RowCache;
  16760. });
  16761. /*---------------------------------------------------------------------------------------------
  16762. * Copyright (c) Microsoft Corporation. All rights reserved.
  16763. * Licensed under the MIT License. See License.txt in the project root for license information.
  16764. *--------------------------------------------------------------------------------------------*/
  16765. define(__m[47/*vs/base/browser/ui/widget*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,56/*vs/base/browser/keyboardEvent*/,45/*vs/base/browser/mouseEvent*/,2/*vs/base/common/lifecycle*/,57/*vs/base/browser/touch*/]), function (require, exports, dom, keyboardEvent_1, mouseEvent_1, lifecycle_1, touch_1) {
  16766. "use strict";
  16767. Object.defineProperty(exports, "__esModule", { value: true });
  16768. var Widget = /** @class */ (function (_super) {
  16769. __extends(Widget, _super);
  16770. function Widget() {
  16771. return _super !== null && _super.apply(this, arguments) || this;
  16772. }
  16773. Widget.prototype.onclick = function (domNode, listener) {
  16774. this._register(dom.addDisposableListener(domNode, dom.EventType.CLICK, function (e) { return listener(new mouseEvent_1.StandardMouseEvent(e)); }));
  16775. };
  16776. Widget.prototype.onmousedown = function (domNode, listener) {
  16777. this._register(dom.addDisposableListener(domNode, dom.EventType.MOUSE_DOWN, function (e) { return listener(new mouseEvent_1.StandardMouseEvent(e)); }));
  16778. };
  16779. Widget.prototype.onmouseover = function (domNode, listener) {
  16780. this._register(dom.addDisposableListener(domNode, dom.EventType.MOUSE_OVER, function (e) { return listener(new mouseEvent_1.StandardMouseEvent(e)); }));
  16781. };
  16782. Widget.prototype.onnonbubblingmouseout = function (domNode, listener) {
  16783. this._register(dom.addDisposableNonBubblingMouseOutListener(domNode, function (e) { return listener(new mouseEvent_1.StandardMouseEvent(e)); }));
  16784. };
  16785. Widget.prototype.onkeydown = function (domNode, listener) {
  16786. this._register(dom.addDisposableListener(domNode, dom.EventType.KEY_DOWN, function (e) { return listener(new keyboardEvent_1.StandardKeyboardEvent(e)); }));
  16787. };
  16788. Widget.prototype.onkeyup = function (domNode, listener) {
  16789. this._register(dom.addDisposableListener(domNode, dom.EventType.KEY_UP, function (e) { return listener(new keyboardEvent_1.StandardKeyboardEvent(e)); }));
  16790. };
  16791. Widget.prototype.oninput = function (domNode, listener) {
  16792. this._register(dom.addDisposableListener(domNode, dom.EventType.INPUT, listener));
  16793. };
  16794. Widget.prototype.onblur = function (domNode, listener) {
  16795. this._register(dom.addDisposableListener(domNode, dom.EventType.BLUR, listener));
  16796. };
  16797. Widget.prototype.onfocus = function (domNode, listener) {
  16798. this._register(dom.addDisposableListener(domNode, dom.EventType.FOCUS, listener));
  16799. };
  16800. Widget.prototype.ignoreGesture = function (domNode) {
  16801. touch_1.Gesture.ignoreTarget(domNode);
  16802. };
  16803. return Widget;
  16804. }(lifecycle_1.Disposable));
  16805. exports.Widget = Widget;
  16806. });
  16807. /*---------------------------------------------------------------------------------------------
  16808. * Copyright (c) Microsoft Corporation. All rights reserved.
  16809. * Licensed under the MIT License. See License.txt in the project root for license information.
  16810. *--------------------------------------------------------------------------------------------*/
  16811. define(__m[135/*vs/base/browser/ui/scrollbar/scrollbarArrow*/], __M([0/*require*/,1/*exports*/,78/*vs/base/browser/globalMouseMoveMonitor*/,47/*vs/base/browser/ui/widget*/,15/*vs/base/common/async*/]), function (require, exports, globalMouseMoveMonitor_1, widget_1, async_1) {
  16812. "use strict";
  16813. Object.defineProperty(exports, "__esModule", { value: true });
  16814. /**
  16815. * The arrow image size.
  16816. */
  16817. exports.ARROW_IMG_SIZE = 11;
  16818. var ScrollbarArrow = /** @class */ (function (_super) {
  16819. __extends(ScrollbarArrow, _super);
  16820. function ScrollbarArrow(opts) {
  16821. var _this = _super.call(this) || this;
  16822. _this._onActivate = opts.onActivate;
  16823. _this.bgDomNode = document.createElement('div');
  16824. _this.bgDomNode.className = 'arrow-background';
  16825. _this.bgDomNode.style.position = 'absolute';
  16826. _this.bgDomNode.style.width = opts.bgWidth + 'px';
  16827. _this.bgDomNode.style.height = opts.bgHeight + 'px';
  16828. if (typeof opts.top !== 'undefined') {
  16829. _this.bgDomNode.style.top = '0px';
  16830. }
  16831. if (typeof opts.left !== 'undefined') {
  16832. _this.bgDomNode.style.left = '0px';
  16833. }
  16834. if (typeof opts.bottom !== 'undefined') {
  16835. _this.bgDomNode.style.bottom = '0px';
  16836. }
  16837. if (typeof opts.right !== 'undefined') {
  16838. _this.bgDomNode.style.right = '0px';
  16839. }
  16840. _this.domNode = document.createElement('div');
  16841. _this.domNode.className = opts.className;
  16842. _this.domNode.style.position = 'absolute';
  16843. _this.domNode.style.width = exports.ARROW_IMG_SIZE + 'px';
  16844. _this.domNode.style.height = exports.ARROW_IMG_SIZE + 'px';
  16845. if (typeof opts.top !== 'undefined') {
  16846. _this.domNode.style.top = opts.top + 'px';
  16847. }
  16848. if (typeof opts.left !== 'undefined') {
  16849. _this.domNode.style.left = opts.left + 'px';
  16850. }
  16851. if (typeof opts.bottom !== 'undefined') {
  16852. _this.domNode.style.bottom = opts.bottom + 'px';
  16853. }
  16854. if (typeof opts.right !== 'undefined') {
  16855. _this.domNode.style.right = opts.right + 'px';
  16856. }
  16857. _this._mouseMoveMonitor = _this._register(new globalMouseMoveMonitor_1.GlobalMouseMoveMonitor());
  16858. _this.onmousedown(_this.bgDomNode, function (e) { return _this._arrowMouseDown(e); });
  16859. _this.onmousedown(_this.domNode, function (e) { return _this._arrowMouseDown(e); });
  16860. _this._mousedownRepeatTimer = _this._register(new async_1.IntervalTimer());
  16861. _this._mousedownScheduleRepeatTimer = _this._register(new async_1.TimeoutTimer());
  16862. return _this;
  16863. }
  16864. ScrollbarArrow.prototype._arrowMouseDown = function (e) {
  16865. var _this = this;
  16866. var scheduleRepeater = function () {
  16867. _this._mousedownRepeatTimer.cancelAndSet(function () { return _this._onActivate(); }, 1000 / 24);
  16868. };
  16869. this._onActivate();
  16870. this._mousedownRepeatTimer.cancel();
  16871. this._mousedownScheduleRepeatTimer.cancelAndSet(scheduleRepeater, 200);
  16872. this._mouseMoveMonitor.startMonitoring(e.target, e.buttons, globalMouseMoveMonitor_1.standardMouseMoveMerger, function (mouseMoveData) {
  16873. /* Intentional empty */
  16874. }, function () {
  16875. _this._mousedownRepeatTimer.cancel();
  16876. _this._mousedownScheduleRepeatTimer.cancel();
  16877. });
  16878. e.preventDefault();
  16879. };
  16880. return ScrollbarArrow;
  16881. }(widget_1.Widget));
  16882. exports.ScrollbarArrow = ScrollbarArrow;
  16883. });
  16884. /*---------------------------------------------------------------------------------------------
  16885. * Copyright (c) Microsoft Corporation. All rights reserved.
  16886. * Licensed under the MIT License. See License.txt in the project root for license information.
  16887. *--------------------------------------------------------------------------------------------*/
  16888. define(__m[181/*vs/base/browser/ui/scrollbar/abstractScrollbar*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,28/*vs/base/browser/fastDomNode*/,78/*vs/base/browser/globalMouseMoveMonitor*/,135/*vs/base/browser/ui/scrollbar/scrollbarArrow*/,244/*vs/base/browser/ui/scrollbar/scrollbarVisibilityController*/,47/*vs/base/browser/ui/widget*/,16/*vs/base/common/platform*/]), function (require, exports, dom, fastDomNode_1, globalMouseMoveMonitor_1, scrollbarArrow_1, scrollbarVisibilityController_1, widget_1, platform) {
  16889. "use strict";
  16890. Object.defineProperty(exports, "__esModule", { value: true });
  16891. /**
  16892. * The orthogonal distance to the slider at which dragging "resets". This implements "snapping"
  16893. */
  16894. var MOUSE_DRAG_RESET_DISTANCE = 140;
  16895. var AbstractScrollbar = /** @class */ (function (_super) {
  16896. __extends(AbstractScrollbar, _super);
  16897. function AbstractScrollbar(opts) {
  16898. var _this = _super.call(this) || this;
  16899. _this._lazyRender = opts.lazyRender;
  16900. _this._host = opts.host;
  16901. _this._scrollable = opts.scrollable;
  16902. _this._scrollbarState = opts.scrollbarState;
  16903. _this._visibilityController = _this._register(new scrollbarVisibilityController_1.ScrollbarVisibilityController(opts.visibility, 'visible scrollbar ' + opts.extraScrollbarClassName, 'invisible scrollbar ' + opts.extraScrollbarClassName));
  16904. _this._visibilityController.setIsNeeded(_this._scrollbarState.isNeeded());
  16905. _this._mouseMoveMonitor = _this._register(new globalMouseMoveMonitor_1.GlobalMouseMoveMonitor());
  16906. _this._shouldRender = true;
  16907. _this.domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  16908. _this.domNode.setAttribute('role', 'presentation');
  16909. _this.domNode.setAttribute('aria-hidden', 'true');
  16910. _this._visibilityController.setDomNode(_this.domNode);
  16911. _this.domNode.setPosition('absolute');
  16912. _this.onmousedown(_this.domNode.domNode, function (e) { return _this._domNodeMouseDown(e); });
  16913. return _this;
  16914. }
  16915. // ----------------- creation
  16916. /**
  16917. * Creates the dom node for an arrow & adds it to the container
  16918. */
  16919. AbstractScrollbar.prototype._createArrow = function (opts) {
  16920. var arrow = this._register(new scrollbarArrow_1.ScrollbarArrow(opts));
  16921. this.domNode.domNode.appendChild(arrow.bgDomNode);
  16922. this.domNode.domNode.appendChild(arrow.domNode);
  16923. };
  16924. /**
  16925. * Creates the slider dom node, adds it to the container & hooks up the events
  16926. */
  16927. AbstractScrollbar.prototype._createSlider = function (top, left, width, height) {
  16928. var _this = this;
  16929. this.slider = fastDomNode_1.createFastDomNode(document.createElement('div'));
  16930. this.slider.setClassName('slider');
  16931. this.slider.setPosition('absolute');
  16932. this.slider.setTop(top);
  16933. this.slider.setLeft(left);
  16934. if (typeof width === 'number') {
  16935. this.slider.setWidth(width);
  16936. }
  16937. if (typeof height === 'number') {
  16938. this.slider.setHeight(height);
  16939. }
  16940. this.slider.setLayerHinting(true);
  16941. this.slider.setContain('strict');
  16942. this.domNode.domNode.appendChild(this.slider.domNode);
  16943. this.onmousedown(this.slider.domNode, function (e) {
  16944. if (e.leftButton) {
  16945. e.preventDefault();
  16946. _this._sliderMouseDown(e, function () { });
  16947. }
  16948. });
  16949. this.onclick(this.slider.domNode, function (e) {
  16950. if (e.leftButton) {
  16951. e.stopPropagation();
  16952. }
  16953. });
  16954. };
  16955. // ----------------- Update state
  16956. AbstractScrollbar.prototype._onElementSize = function (visibleSize) {
  16957. if (this._scrollbarState.setVisibleSize(visibleSize)) {
  16958. this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded());
  16959. this._shouldRender = true;
  16960. if (!this._lazyRender) {
  16961. this.render();
  16962. }
  16963. }
  16964. return this._shouldRender;
  16965. };
  16966. AbstractScrollbar.prototype._onElementScrollSize = function (elementScrollSize) {
  16967. if (this._scrollbarState.setScrollSize(elementScrollSize)) {
  16968. this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded());
  16969. this._shouldRender = true;
  16970. if (!this._lazyRender) {
  16971. this.render();
  16972. }
  16973. }
  16974. return this._shouldRender;
  16975. };
  16976. AbstractScrollbar.prototype._onElementScrollPosition = function (elementScrollPosition) {
  16977. if (this._scrollbarState.setScrollPosition(elementScrollPosition)) {
  16978. this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded());
  16979. this._shouldRender = true;
  16980. if (!this._lazyRender) {
  16981. this.render();
  16982. }
  16983. }
  16984. return this._shouldRender;
  16985. };
  16986. // ----------------- rendering
  16987. AbstractScrollbar.prototype.beginReveal = function () {
  16988. this._visibilityController.setShouldBeVisible(true);
  16989. };
  16990. AbstractScrollbar.prototype.beginHide = function () {
  16991. this._visibilityController.setShouldBeVisible(false);
  16992. };
  16993. AbstractScrollbar.prototype.render = function () {
  16994. if (!this._shouldRender) {
  16995. return;
  16996. }
  16997. this._shouldRender = false;
  16998. this._renderDomNode(this._scrollbarState.getRectangleLargeSize(), this._scrollbarState.getRectangleSmallSize());
  16999. this._updateSlider(this._scrollbarState.getSliderSize(), this._scrollbarState.getArrowSize() + this._scrollbarState.getSliderPosition());
  17000. };
  17001. // ----------------- DOM events
  17002. AbstractScrollbar.prototype._domNodeMouseDown = function (e) {
  17003. if (e.target !== this.domNode.domNode) {
  17004. return;
  17005. }
  17006. this._onMouseDown(e);
  17007. };
  17008. AbstractScrollbar.prototype.delegateMouseDown = function (e) {
  17009. var domTop = this.domNode.domNode.getClientRects()[0].top;
  17010. var sliderStart = domTop + this._scrollbarState.getSliderPosition();
  17011. var sliderStop = domTop + this._scrollbarState.getSliderPosition() + this._scrollbarState.getSliderSize();
  17012. var mousePos = this._sliderMousePosition(e);
  17013. if (sliderStart <= mousePos && mousePos <= sliderStop) {
  17014. // Act as if it was a mouse down on the slider
  17015. if (e.leftButton) {
  17016. e.preventDefault();
  17017. this._sliderMouseDown(e, function () { });
  17018. }
  17019. }
  17020. else {
  17021. // Act as if it was a mouse down on the scrollbar
  17022. this._onMouseDown(e);
  17023. }
  17024. };
  17025. AbstractScrollbar.prototype._onMouseDown = function (e) {
  17026. var offsetX;
  17027. var offsetY;
  17028. if (e.target === this.domNode.domNode && typeof e.browserEvent.offsetX === 'number' && typeof e.browserEvent.offsetY === 'number') {
  17029. offsetX = e.browserEvent.offsetX;
  17030. offsetY = e.browserEvent.offsetY;
  17031. }
  17032. else {
  17033. var domNodePosition = dom.getDomNodePagePosition(this.domNode.domNode);
  17034. offsetX = e.posx - domNodePosition.left;
  17035. offsetY = e.posy - domNodePosition.top;
  17036. }
  17037. this._setDesiredScrollPositionNow(this._scrollbarState.getDesiredScrollPositionFromOffset(this._mouseDownRelativePosition(offsetX, offsetY)));
  17038. if (e.leftButton) {
  17039. e.preventDefault();
  17040. this._sliderMouseDown(e, function () { });
  17041. }
  17042. };
  17043. AbstractScrollbar.prototype._sliderMouseDown = function (e, onDragFinished) {
  17044. var _this = this;
  17045. var initialMousePosition = this._sliderMousePosition(e);
  17046. var initialMouseOrthogonalPosition = this._sliderOrthogonalMousePosition(e);
  17047. var initialScrollbarState = this._scrollbarState.clone();
  17048. this.slider.toggleClassName('active', true);
  17049. this._mouseMoveMonitor.startMonitoring(e.target, e.buttons, globalMouseMoveMonitor_1.standardMouseMoveMerger, function (mouseMoveData) {
  17050. var mouseOrthogonalPosition = _this._sliderOrthogonalMousePosition(mouseMoveData);
  17051. var mouseOrthogonalDelta = Math.abs(mouseOrthogonalPosition - initialMouseOrthogonalPosition);
  17052. if (platform.isWindows && mouseOrthogonalDelta > MOUSE_DRAG_RESET_DISTANCE) {
  17053. // The mouse has wondered away from the scrollbar => reset dragging
  17054. _this._setDesiredScrollPositionNow(initialScrollbarState.getScrollPosition());
  17055. return;
  17056. }
  17057. var mousePosition = _this._sliderMousePosition(mouseMoveData);
  17058. var mouseDelta = mousePosition - initialMousePosition;
  17059. _this._setDesiredScrollPositionNow(initialScrollbarState.getDesiredScrollPositionFromDelta(mouseDelta));
  17060. }, function () {
  17061. _this.slider.toggleClassName('active', false);
  17062. _this._host.onDragEnd();
  17063. onDragFinished();
  17064. });
  17065. this._host.onDragStart();
  17066. };
  17067. AbstractScrollbar.prototype._setDesiredScrollPositionNow = function (_desiredScrollPosition) {
  17068. var desiredScrollPosition = {};
  17069. this.writeScrollPosition(desiredScrollPosition, _desiredScrollPosition);
  17070. this._scrollable.setScrollPositionNow(desiredScrollPosition);
  17071. };
  17072. return AbstractScrollbar;
  17073. }(widget_1.Widget));
  17074. exports.AbstractScrollbar = AbstractScrollbar;
  17075. });
  17076. /*---------------------------------------------------------------------------------------------
  17077. * Copyright (c) Microsoft Corporation. All rights reserved.
  17078. * Licensed under the MIT License. See License.txt in the project root for license information.
  17079. *--------------------------------------------------------------------------------------------*/
  17080. define(__m[250/*vs/base/browser/ui/scrollbar/horizontalScrollbar*/], __M([0/*require*/,1/*exports*/,45/*vs/base/browser/mouseEvent*/,181/*vs/base/browser/ui/scrollbar/abstractScrollbar*/,135/*vs/base/browser/ui/scrollbar/scrollbarArrow*/,175/*vs/base/browser/ui/scrollbar/scrollbarState*/]), function (require, exports, mouseEvent_1, abstractScrollbar_1, scrollbarArrow_1, scrollbarState_1) {
  17081. "use strict";
  17082. Object.defineProperty(exports, "__esModule", { value: true });
  17083. var HorizontalScrollbar = /** @class */ (function (_super) {
  17084. __extends(HorizontalScrollbar, _super);
  17085. function HorizontalScrollbar(scrollable, options, host) {
  17086. var _this = this;
  17087. var scrollDimensions = scrollable.getScrollDimensions();
  17088. var scrollPosition = scrollable.getCurrentScrollPosition();
  17089. _this = _super.call(this, {
  17090. lazyRender: options.lazyRender,
  17091. host: host,
  17092. scrollbarState: new scrollbarState_1.ScrollbarState((options.horizontalHasArrows ? options.arrowSize : 0), (options.horizontal === 2 /* Hidden */ ? 0 : options.horizontalScrollbarSize), (options.vertical === 2 /* Hidden */ ? 0 : options.verticalScrollbarSize), scrollDimensions.width, scrollDimensions.scrollWidth, scrollPosition.scrollLeft),
  17093. visibility: options.horizontal,
  17094. extraScrollbarClassName: 'horizontal',
  17095. scrollable: scrollable
  17096. }) || this;
  17097. if (options.horizontalHasArrows) {
  17098. var arrowDelta = (options.arrowSize - scrollbarArrow_1.ARROW_IMG_SIZE) / 2;
  17099. var scrollbarDelta = (options.horizontalScrollbarSize - scrollbarArrow_1.ARROW_IMG_SIZE) / 2;
  17100. _this._createArrow({
  17101. className: 'left-arrow',
  17102. top: scrollbarDelta,
  17103. left: arrowDelta,
  17104. bottom: undefined,
  17105. right: undefined,
  17106. bgWidth: options.arrowSize,
  17107. bgHeight: options.horizontalScrollbarSize,
  17108. onActivate: function () { return _this._host.onMouseWheel(new mouseEvent_1.StandardWheelEvent(null, 1, 0)); },
  17109. });
  17110. _this._createArrow({
  17111. className: 'right-arrow',
  17112. top: scrollbarDelta,
  17113. left: undefined,
  17114. bottom: undefined,
  17115. right: arrowDelta,
  17116. bgWidth: options.arrowSize,
  17117. bgHeight: options.horizontalScrollbarSize,
  17118. onActivate: function () { return _this._host.onMouseWheel(new mouseEvent_1.StandardWheelEvent(null, -1, 0)); },
  17119. });
  17120. }
  17121. _this._createSlider(Math.floor((options.horizontalScrollbarSize - options.horizontalSliderSize) / 2), 0, undefined, options.horizontalSliderSize);
  17122. return _this;
  17123. }
  17124. HorizontalScrollbar.prototype._updateSlider = function (sliderSize, sliderPosition) {
  17125. this.slider.setWidth(sliderSize);
  17126. this.slider.setLeft(sliderPosition);
  17127. };
  17128. HorizontalScrollbar.prototype._renderDomNode = function (largeSize, smallSize) {
  17129. this.domNode.setWidth(largeSize);
  17130. this.domNode.setHeight(smallSize);
  17131. this.domNode.setLeft(0);
  17132. this.domNode.setBottom(0);
  17133. };
  17134. HorizontalScrollbar.prototype.onDidScroll = function (e) {
  17135. this._shouldRender = this._onElementScrollSize(e.scrollWidth) || this._shouldRender;
  17136. this._shouldRender = this._onElementScrollPosition(e.scrollLeft) || this._shouldRender;
  17137. this._shouldRender = this._onElementSize(e.width) || this._shouldRender;
  17138. return this._shouldRender;
  17139. };
  17140. HorizontalScrollbar.prototype._mouseDownRelativePosition = function (offsetX, offsetY) {
  17141. return offsetX;
  17142. };
  17143. HorizontalScrollbar.prototype._sliderMousePosition = function (e) {
  17144. return e.posx;
  17145. };
  17146. HorizontalScrollbar.prototype._sliderOrthogonalMousePosition = function (e) {
  17147. return e.posy;
  17148. };
  17149. HorizontalScrollbar.prototype.writeScrollPosition = function (target, scrollPosition) {
  17150. target.scrollLeft = scrollPosition;
  17151. };
  17152. return HorizontalScrollbar;
  17153. }(abstractScrollbar_1.AbstractScrollbar));
  17154. exports.HorizontalScrollbar = HorizontalScrollbar;
  17155. });
  17156. /*---------------------------------------------------------------------------------------------
  17157. * Copyright (c) Microsoft Corporation. All rights reserved.
  17158. * Licensed under the MIT License. See License.txt in the project root for license information.
  17159. *--------------------------------------------------------------------------------------------*/
  17160. define(__m[251/*vs/base/browser/ui/scrollbar/verticalScrollbar*/], __M([0/*require*/,1/*exports*/,45/*vs/base/browser/mouseEvent*/,181/*vs/base/browser/ui/scrollbar/abstractScrollbar*/,135/*vs/base/browser/ui/scrollbar/scrollbarArrow*/,175/*vs/base/browser/ui/scrollbar/scrollbarState*/]), function (require, exports, mouseEvent_1, abstractScrollbar_1, scrollbarArrow_1, scrollbarState_1) {
  17161. "use strict";
  17162. Object.defineProperty(exports, "__esModule", { value: true });
  17163. var VerticalScrollbar = /** @class */ (function (_super) {
  17164. __extends(VerticalScrollbar, _super);
  17165. function VerticalScrollbar(scrollable, options, host) {
  17166. var _this = this;
  17167. var scrollDimensions = scrollable.getScrollDimensions();
  17168. var scrollPosition = scrollable.getCurrentScrollPosition();
  17169. _this = _super.call(this, {
  17170. lazyRender: options.lazyRender,
  17171. host: host,
  17172. scrollbarState: new scrollbarState_1.ScrollbarState((options.verticalHasArrows ? options.arrowSize : 0), (options.vertical === 2 /* Hidden */ ? 0 : options.verticalScrollbarSize),
  17173. // give priority to vertical scroll bar over horizontal and let it scroll all the way to the bottom
  17174. 0, scrollDimensions.height, scrollDimensions.scrollHeight, scrollPosition.scrollTop),
  17175. visibility: options.vertical,
  17176. extraScrollbarClassName: 'vertical',
  17177. scrollable: scrollable
  17178. }) || this;
  17179. if (options.verticalHasArrows) {
  17180. var arrowDelta = (options.arrowSize - scrollbarArrow_1.ARROW_IMG_SIZE) / 2;
  17181. var scrollbarDelta = (options.verticalScrollbarSize - scrollbarArrow_1.ARROW_IMG_SIZE) / 2;
  17182. _this._createArrow({
  17183. className: 'up-arrow',
  17184. top: arrowDelta,
  17185. left: scrollbarDelta,
  17186. bottom: undefined,
  17187. right: undefined,
  17188. bgWidth: options.verticalScrollbarSize,
  17189. bgHeight: options.arrowSize,
  17190. onActivate: function () { return _this._host.onMouseWheel(new mouseEvent_1.StandardWheelEvent(null, 0, 1)); },
  17191. });
  17192. _this._createArrow({
  17193. className: 'down-arrow',
  17194. top: undefined,
  17195. left: scrollbarDelta,
  17196. bottom: arrowDelta,
  17197. right: undefined,
  17198. bgWidth: options.verticalScrollbarSize,
  17199. bgHeight: options.arrowSize,
  17200. onActivate: function () { return _this._host.onMouseWheel(new mouseEvent_1.StandardWheelEvent(null, 0, -1)); },
  17201. });
  17202. }
  17203. _this._createSlider(0, Math.floor((options.verticalScrollbarSize - options.verticalSliderSize) / 2), options.verticalSliderSize, undefined);
  17204. return _this;
  17205. }
  17206. VerticalScrollbar.prototype._updateSlider = function (sliderSize, sliderPosition) {
  17207. this.slider.setHeight(sliderSize);
  17208. this.slider.setTop(sliderPosition);
  17209. };
  17210. VerticalScrollbar.prototype._renderDomNode = function (largeSize, smallSize) {
  17211. this.domNode.setWidth(smallSize);
  17212. this.domNode.setHeight(largeSize);
  17213. this.domNode.setRight(0);
  17214. this.domNode.setTop(0);
  17215. };
  17216. VerticalScrollbar.prototype.onDidScroll = function (e) {
  17217. this._shouldRender = this._onElementScrollSize(e.scrollHeight) || this._shouldRender;
  17218. this._shouldRender = this._onElementScrollPosition(e.scrollTop) || this._shouldRender;
  17219. this._shouldRender = this._onElementSize(e.height) || this._shouldRender;
  17220. return this._shouldRender;
  17221. };
  17222. VerticalScrollbar.prototype._mouseDownRelativePosition = function (offsetX, offsetY) {
  17223. return offsetY;
  17224. };
  17225. VerticalScrollbar.prototype._sliderMousePosition = function (e) {
  17226. return e.posy;
  17227. };
  17228. VerticalScrollbar.prototype._sliderOrthogonalMousePosition = function (e) {
  17229. return e.posx;
  17230. };
  17231. VerticalScrollbar.prototype.writeScrollPosition = function (target, scrollPosition) {
  17232. target.scrollTop = scrollPosition;
  17233. };
  17234. return VerticalScrollbar;
  17235. }(abstractScrollbar_1.AbstractScrollbar));
  17236. exports.VerticalScrollbar = VerticalScrollbar;
  17237. });
  17238. /*---------------------------------------------------------------------------------------------
  17239. * Copyright (c) Microsoft Corporation. All rights reserved.
  17240. * Licensed under the MIT License. See License.txt in the project root for license information.
  17241. *--------------------------------------------------------------------------------------------*/
  17242. var __spreadArrays = (this && this.__spreadArrays) || function () {
  17243. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  17244. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  17245. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  17246. r[k] = a[j];
  17247. return r;
  17248. };
  17249. define(__m[39/*vs/base/common/resources*/], __M([0/*require*/,1/*exports*/,177/*vs/base/common/extpath*/,77/*vs/base/common/path*/,25/*vs/base/common/uri*/,5/*vs/base/common/strings*/,46/*vs/base/common/network*/,16/*vs/base/common/platform*/]), function (require, exports, extpath, paths, uri_1, strings_1, network_1, platform_1) {
  17250. "use strict";
  17251. Object.defineProperty(exports, "__esModule", { value: true });
  17252. function hasToIgnoreCase(resource) {
  17253. // A file scheme resource is in the same platform as code, so ignore case for non linux platforms
  17254. // Resource can be from another platform. Lowering the case as an hack. Should come from File system provider
  17255. return resource && resource.scheme === network_1.Schemas.file ? !platform_1.isLinux : true;
  17256. }
  17257. exports.hasToIgnoreCase = hasToIgnoreCase;
  17258. function basenameOrAuthority(resource) {
  17259. return basename(resource) || resource.authority;
  17260. }
  17261. exports.basenameOrAuthority = basenameOrAuthority;
  17262. /**
  17263. * Tests wheter the two authorities are the same
  17264. */
  17265. function isEqualAuthority(a1, a2) {
  17266. return a1 === a2 || strings_1.equalsIgnoreCase(a1, a2);
  17267. }
  17268. exports.isEqualAuthority = isEqualAuthority;
  17269. function isEqual(first, second, ignoreCase) {
  17270. if (ignoreCase === void 0) { ignoreCase = hasToIgnoreCase(first); }
  17271. if (first === second) {
  17272. return true;
  17273. }
  17274. if (!first || !second) {
  17275. return false;
  17276. }
  17277. if (first.scheme !== second.scheme || !isEqualAuthority(first.authority, second.authority)) {
  17278. return false;
  17279. }
  17280. var p1 = first.path || '/', p2 = second.path || '/';
  17281. return p1 === p2 || ignoreCase && strings_1.equalsIgnoreCase(p1 || '/', p2 || '/');
  17282. }
  17283. exports.isEqual = isEqual;
  17284. function basename(resource) {
  17285. return paths.posix.basename(resource.path);
  17286. }
  17287. exports.basename = basename;
  17288. /**
  17289. * Return a URI representing the directory of a URI path.
  17290. *
  17291. * @param resource The input URI.
  17292. * @returns The URI representing the directory of the input URI.
  17293. */
  17294. function dirname(resource) {
  17295. if (resource.path.length === 0) {
  17296. return resource;
  17297. }
  17298. if (resource.scheme === network_1.Schemas.file) {
  17299. return uri_1.URI.file(paths.dirname(originalFSPath(resource)));
  17300. }
  17301. var dirname = paths.posix.dirname(resource.path);
  17302. if (resource.authority && dirname.length && dirname.charCodeAt(0) !== 47 /* Slash */) {
  17303. console.error("dirname(\"" + resource.toString + ")) resulted in a relative path");
  17304. dirname = '/'; // If a URI contains an authority component, then the path component must either be empty or begin with a CharCode.Slash ("/") character
  17305. }
  17306. return resource.with({
  17307. path: dirname
  17308. });
  17309. }
  17310. exports.dirname = dirname;
  17311. /**
  17312. * Join a URI path with path fragments and normalizes the resulting path.
  17313. *
  17314. * @param resource The input URI.
  17315. * @param pathFragment The path fragment to add to the URI path.
  17316. * @returns The resulting URI.
  17317. */
  17318. function joinPath(resource) {
  17319. var _a;
  17320. var pathFragment = [];
  17321. for (var _i = 1; _i < arguments.length; _i++) {
  17322. pathFragment[_i - 1] = arguments[_i];
  17323. }
  17324. var joinedPath;
  17325. if (resource.scheme === network_1.Schemas.file) {
  17326. joinedPath = uri_1.URI.file(paths.join.apply(paths, __spreadArrays([originalFSPath(resource)], pathFragment))).path;
  17327. }
  17328. else {
  17329. joinedPath = (_a = paths.posix).join.apply(_a, __spreadArrays([resource.path || '/'], pathFragment));
  17330. }
  17331. return resource.with({
  17332. path: joinedPath
  17333. });
  17334. }
  17335. exports.joinPath = joinPath;
  17336. /**
  17337. * Normalizes the path part of a URI: Resolves `.` and `..` elements with directory names.
  17338. *
  17339. * @param resource The URI to normalize the path.
  17340. * @returns The URI with the normalized path.
  17341. */
  17342. function normalizePath(resource) {
  17343. if (!resource.path.length) {
  17344. return resource;
  17345. }
  17346. var normalizedPath;
  17347. if (resource.scheme === network_1.Schemas.file) {
  17348. normalizedPath = uri_1.URI.file(paths.normalize(originalFSPath(resource))).path;
  17349. }
  17350. else {
  17351. normalizedPath = paths.posix.normalize(resource.path);
  17352. }
  17353. return resource.with({
  17354. path: normalizedPath
  17355. });
  17356. }
  17357. exports.normalizePath = normalizePath;
  17358. /**
  17359. * Returns the fsPath of an URI where the drive letter is not normalized.
  17360. * See #56403.
  17361. */
  17362. function originalFSPath(uri) {
  17363. var value;
  17364. var uriPath = uri.path;
  17365. if (uri.authority && uriPath.length > 1 && uri.scheme === network_1.Schemas.file) {
  17366. // unc path: file://shares/c$/far/boo
  17367. value = "//" + uri.authority + uriPath;
  17368. }
  17369. else if (platform_1.isWindows
  17370. && uriPath.charCodeAt(0) === 47 /* Slash */
  17371. && extpath.isWindowsDriveLetter(uriPath.charCodeAt(1))
  17372. && uriPath.charCodeAt(2) === 58 /* Colon */) {
  17373. value = uriPath.substr(1);
  17374. }
  17375. else {
  17376. // other path
  17377. value = uriPath;
  17378. }
  17379. if (platform_1.isWindows) {
  17380. value = value.replace(/\//g, '\\');
  17381. }
  17382. return value;
  17383. }
  17384. exports.originalFSPath = originalFSPath;
  17385. /**
  17386. * Returns a relative path between two URIs. If the URIs don't have the same schema or authority, `undefined` is returned.
  17387. * The returned relative path always uses forward slashes.
  17388. */
  17389. function relativePath(from, to, ignoreCase) {
  17390. if (ignoreCase === void 0) { ignoreCase = hasToIgnoreCase(from); }
  17391. if (from.scheme !== to.scheme || !isEqualAuthority(from.authority, to.authority)) {
  17392. return undefined;
  17393. }
  17394. if (from.scheme === network_1.Schemas.file) {
  17395. var relativePath_1 = paths.relative(from.path, to.path);
  17396. return platform_1.isWindows ? extpath.toSlashes(relativePath_1) : relativePath_1;
  17397. }
  17398. var fromPath = from.path || '/', toPath = to.path || '/';
  17399. if (ignoreCase) {
  17400. // make casing of fromPath match toPath
  17401. var i = 0;
  17402. for (var len = Math.min(fromPath.length, toPath.length); i < len; i++) {
  17403. if (fromPath.charCodeAt(i) !== toPath.charCodeAt(i)) {
  17404. if (fromPath.charAt(i).toLowerCase() !== toPath.charAt(i).toLowerCase()) {
  17405. break;
  17406. }
  17407. }
  17408. }
  17409. fromPath = toPath.substr(0, i) + fromPath.substr(i);
  17410. }
  17411. return paths.posix.relative(fromPath, toPath);
  17412. }
  17413. exports.relativePath = relativePath;
  17414. /**
  17415. * Data URI related helpers.
  17416. */
  17417. var DataUri;
  17418. (function (DataUri) {
  17419. DataUri.META_DATA_LABEL = 'label';
  17420. DataUri.META_DATA_DESCRIPTION = 'description';
  17421. DataUri.META_DATA_SIZE = 'size';
  17422. DataUri.META_DATA_MIME = 'mime';
  17423. function parseMetaData(dataUri) {
  17424. var metadata = new Map();
  17425. // Given a URI of: data:image/png;size:2313;label:SomeLabel;description:SomeDescription;base64,77+9UE5...
  17426. // the metadata is: size:2313;label:SomeLabel;description:SomeDescription
  17427. var meta = dataUri.path.substring(dataUri.path.indexOf(';') + 1, dataUri.path.lastIndexOf(';'));
  17428. meta.split(';').forEach(function (property) {
  17429. var _a = property.split(':'), key = _a[0], value = _a[1];
  17430. if (key && value) {
  17431. metadata.set(key, value);
  17432. }
  17433. });
  17434. // Given a URI of: data:image/png;size:2313;label:SomeLabel;description:SomeDescription;base64,77+9UE5...
  17435. // the mime is: image/png
  17436. var mime = dataUri.path.substring(0, dataUri.path.indexOf(';'));
  17437. if (mime) {
  17438. metadata.set(DataUri.META_DATA_MIME, mime);
  17439. }
  17440. return metadata;
  17441. }
  17442. DataUri.parseMetaData = parseMetaData;
  17443. })(DataUri = exports.DataUri || (exports.DataUri = {}));
  17444. });
  17445. /*---------------------------------------------------------------------------------------------
  17446. * Copyright (c) Microsoft Corporation. All rights reserved.
  17447. * Licensed under the MIT License. See License.txt in the project root for license information.
  17448. *--------------------------------------------------------------------------------------------*/
  17449. define(__m[136/*vs/base/common/labels*/], __M([0/*require*/,1/*exports*/,25/*vs/base/common/uri*/,77/*vs/base/common/path*/,5/*vs/base/common/strings*/,46/*vs/base/common/network*/,16/*vs/base/common/platform*/,39/*vs/base/common/resources*/]), function (require, exports, uri_1, path_1, strings_1, network_1, platform_1, resources_1) {
  17450. "use strict";
  17451. Object.defineProperty(exports, "__esModule", { value: true });
  17452. /**
  17453. * @deprecated use LabelService instead
  17454. */
  17455. function getPathLabel(resource, userHomeProvider, rootProvider) {
  17456. if (typeof resource === 'string') {
  17457. resource = uri_1.URI.file(resource);
  17458. }
  17459. // return early if we can resolve a relative path label from the root
  17460. if (rootProvider) {
  17461. var baseResource = rootProvider.getWorkspaceFolder(resource);
  17462. if (baseResource) {
  17463. var hasMultipleRoots = rootProvider.getWorkspace().folders.length > 1;
  17464. var pathLabel = void 0;
  17465. if (resources_1.isEqual(baseResource.uri, resource)) {
  17466. pathLabel = ''; // no label if paths are identical
  17467. }
  17468. else {
  17469. pathLabel = resources_1.relativePath(baseResource.uri, resource);
  17470. }
  17471. if (hasMultipleRoots) {
  17472. var rootName = baseResource.name ? baseResource.name : resources_1.basename(baseResource.uri);
  17473. pathLabel = pathLabel ? (rootName + ' • ' + pathLabel) : rootName; // always show root basename if there are multiple
  17474. }
  17475. return pathLabel;
  17476. }
  17477. }
  17478. // return if the resource is neither file:// nor untitled:// and no baseResource was provided
  17479. if (resource.scheme !== network_1.Schemas.file && resource.scheme !== network_1.Schemas.untitled) {
  17480. return resource.with({ query: null, fragment: null }).toString(true);
  17481. }
  17482. // convert c:\something => C:\something
  17483. if (hasDriveLetter(resource.fsPath)) {
  17484. return path_1.normalize(normalizeDriveLetter(resource.fsPath));
  17485. }
  17486. // normalize and tildify (macOS, Linux only)
  17487. var res = path_1.normalize(resource.fsPath);
  17488. if (!platform_1.isWindows && userHomeProvider) {
  17489. res = tildify(res, userHomeProvider.userHome);
  17490. }
  17491. return res;
  17492. }
  17493. exports.getPathLabel = getPathLabel;
  17494. function getBaseLabel(resource) {
  17495. if (!resource) {
  17496. return undefined;
  17497. }
  17498. if (typeof resource === 'string') {
  17499. resource = uri_1.URI.file(resource);
  17500. }
  17501. var base = resources_1.basename(resource) || (resource.scheme === network_1.Schemas.file ? resource.fsPath : resource.path) /* can be empty string if '/' is passed in */;
  17502. // convert c: => C:
  17503. if (hasDriveLetter(base)) {
  17504. return normalizeDriveLetter(base);
  17505. }
  17506. return base;
  17507. }
  17508. exports.getBaseLabel = getBaseLabel;
  17509. function hasDriveLetter(path) {
  17510. return !!(platform_1.isWindows && path && path[1] === ':');
  17511. }
  17512. function normalizeDriveLetter(path) {
  17513. if (hasDriveLetter(path)) {
  17514. return path.charAt(0).toUpperCase() + path.slice(1);
  17515. }
  17516. return path;
  17517. }
  17518. exports.normalizeDriveLetter = normalizeDriveLetter;
  17519. var normalizedUserHomeCached = Object.create(null);
  17520. function tildify(path, userHome) {
  17521. if (platform_1.isWindows || !path || !userHome) {
  17522. return path; // unsupported
  17523. }
  17524. // Keep a normalized user home path as cache to prevent accumulated string creation
  17525. var normalizedUserHome = normalizedUserHomeCached.original === userHome ? normalizedUserHomeCached.normalized : undefined;
  17526. if (!normalizedUserHome) {
  17527. normalizedUserHome = "" + strings_1.rtrim(userHome, path_1.posix.sep) + path_1.posix.sep;
  17528. normalizedUserHomeCached = { original: userHome, normalized: normalizedUserHome };
  17529. }
  17530. // Linux: case sensitive, macOS: case insensitive
  17531. if (platform_1.isLinux ? strings_1.startsWith(path, normalizedUserHome) : strings_1.startsWithIgnoreCase(path, normalizedUserHome)) {
  17532. path = "~/" + path.substr(normalizedUserHome.length);
  17533. }
  17534. return path;
  17535. }
  17536. exports.tildify = tildify;
  17537. });
  17538. /*---------------------------------------------------------------------------------------------
  17539. * Copyright (c) Microsoft Corporation. All rights reserved.
  17540. * Licensed under the MIT License. See License.txt in the project root for license information.
  17541. *--------------------------------------------------------------------------------------------*/
  17542. define(__m[252/*vs/base/common/mime*/], __M([0/*require*/,1/*exports*/,77/*vs/base/common/path*/,5/*vs/base/common/strings*/,178/*vs/base/common/glob*/,46/*vs/base/common/network*/,39/*vs/base/common/resources*/]), function (require, exports, path_1, strings_1, glob_1, network_1, resources_1) {
  17543. "use strict";
  17544. Object.defineProperty(exports, "__esModule", { value: true });
  17545. exports.MIME_TEXT = 'text/plain';
  17546. exports.MIME_UNKNOWN = 'application/unknown';
  17547. var registeredAssociations = [];
  17548. var nonUserRegisteredAssociations = [];
  17549. var userRegisteredAssociations = [];
  17550. /**
  17551. * Associate a text mime to the registry.
  17552. */
  17553. function registerTextMime(association, warnOnOverwrite) {
  17554. if (warnOnOverwrite === void 0) { warnOnOverwrite = false; }
  17555. // Register
  17556. var associationItem = toTextMimeAssociationItem(association);
  17557. registeredAssociations.push(associationItem);
  17558. if (!associationItem.userConfigured) {
  17559. nonUserRegisteredAssociations.push(associationItem);
  17560. }
  17561. else {
  17562. userRegisteredAssociations.push(associationItem);
  17563. }
  17564. // Check for conflicts unless this is a user configured association
  17565. if (warnOnOverwrite && !associationItem.userConfigured) {
  17566. registeredAssociations.forEach(function (a) {
  17567. if (a.mime === associationItem.mime || a.userConfigured) {
  17568. return; // same mime or userConfigured is ok
  17569. }
  17570. if (associationItem.extension && a.extension === associationItem.extension) {
  17571. console.warn("Overwriting extension <<" + associationItem.extension + ">> to now point to mime <<" + associationItem.mime + ">>");
  17572. }
  17573. if (associationItem.filename && a.filename === associationItem.filename) {
  17574. console.warn("Overwriting filename <<" + associationItem.filename + ">> to now point to mime <<" + associationItem.mime + ">>");
  17575. }
  17576. if (associationItem.filepattern && a.filepattern === associationItem.filepattern) {
  17577. console.warn("Overwriting filepattern <<" + associationItem.filepattern + ">> to now point to mime <<" + associationItem.mime + ">>");
  17578. }
  17579. if (associationItem.firstline && a.firstline === associationItem.firstline) {
  17580. console.warn("Overwriting firstline <<" + associationItem.firstline + ">> to now point to mime <<" + associationItem.mime + ">>");
  17581. }
  17582. });
  17583. }
  17584. }
  17585. exports.registerTextMime = registerTextMime;
  17586. function toTextMimeAssociationItem(association) {
  17587. return {
  17588. id: association.id,
  17589. mime: association.mime,
  17590. filename: association.filename,
  17591. extension: association.extension,
  17592. filepattern: association.filepattern,
  17593. firstline: association.firstline,
  17594. userConfigured: association.userConfigured,
  17595. filenameLowercase: association.filename ? association.filename.toLowerCase() : undefined,
  17596. extensionLowercase: association.extension ? association.extension.toLowerCase() : undefined,
  17597. filepatternLowercase: association.filepattern ? association.filepattern.toLowerCase() : undefined,
  17598. filepatternOnPath: association.filepattern ? association.filepattern.indexOf(path_1.posix.sep) >= 0 : false
  17599. };
  17600. }
  17601. /**
  17602. * Given a file, return the best matching mime type for it
  17603. */
  17604. function guessMimeTypes(resource, firstLine) {
  17605. var path;
  17606. if (resource) {
  17607. switch (resource.scheme) {
  17608. case network_1.Schemas.file:
  17609. path = resource.fsPath;
  17610. break;
  17611. case network_1.Schemas.data:
  17612. var metadata = resources_1.DataUri.parseMetaData(resource);
  17613. path = metadata.get(resources_1.DataUri.META_DATA_LABEL);
  17614. break;
  17615. default:
  17616. path = resource.path;
  17617. }
  17618. }
  17619. if (!path) {
  17620. return [exports.MIME_UNKNOWN];
  17621. }
  17622. path = path.toLowerCase();
  17623. var filename = path_1.basename(path);
  17624. // 1.) User configured mappings have highest priority
  17625. var configuredMime = guessMimeTypeByPath(path, filename, userRegisteredAssociations);
  17626. if (configuredMime) {
  17627. return [configuredMime, exports.MIME_TEXT];
  17628. }
  17629. // 2.) Registered mappings have middle priority
  17630. var registeredMime = guessMimeTypeByPath(path, filename, nonUserRegisteredAssociations);
  17631. if (registeredMime) {
  17632. return [registeredMime, exports.MIME_TEXT];
  17633. }
  17634. // 3.) Firstline has lowest priority
  17635. if (firstLine) {
  17636. var firstlineMime = guessMimeTypeByFirstline(firstLine);
  17637. if (firstlineMime) {
  17638. return [firstlineMime, exports.MIME_TEXT];
  17639. }
  17640. }
  17641. return [exports.MIME_UNKNOWN];
  17642. }
  17643. exports.guessMimeTypes = guessMimeTypes;
  17644. function guessMimeTypeByPath(path, filename, associations) {
  17645. var filenameMatch = null;
  17646. var patternMatch = null;
  17647. var extensionMatch = null;
  17648. // We want to prioritize associations based on the order they are registered so that the last registered
  17649. // association wins over all other. This is for https://github.com/Microsoft/vscode/issues/20074
  17650. for (var i = associations.length - 1; i >= 0; i--) {
  17651. var association = associations[i];
  17652. // First exact name match
  17653. if (filename === association.filenameLowercase) {
  17654. filenameMatch = association;
  17655. break; // take it!
  17656. }
  17657. // Longest pattern match
  17658. if (association.filepattern) {
  17659. if (!patternMatch || association.filepattern.length > patternMatch.filepattern.length) {
  17660. var target = association.filepatternOnPath ? path : filename; // match on full path if pattern contains path separator
  17661. if (glob_1.match(association.filepatternLowercase, target)) {
  17662. patternMatch = association;
  17663. }
  17664. }
  17665. }
  17666. // Longest extension match
  17667. if (association.extension) {
  17668. if (!extensionMatch || association.extension.length > extensionMatch.extension.length) {
  17669. if (strings_1.endsWith(filename, association.extensionLowercase)) {
  17670. extensionMatch = association;
  17671. }
  17672. }
  17673. }
  17674. }
  17675. // 1.) Exact name match has second highest prio
  17676. if (filenameMatch) {
  17677. return filenameMatch.mime;
  17678. }
  17679. // 2.) Match on pattern
  17680. if (patternMatch) {
  17681. return patternMatch.mime;
  17682. }
  17683. // 3.) Match on extension comes next
  17684. if (extensionMatch) {
  17685. return extensionMatch.mime;
  17686. }
  17687. return null;
  17688. }
  17689. function guessMimeTypeByFirstline(firstLine) {
  17690. if (strings_1.startsWithUTF8BOM(firstLine)) {
  17691. firstLine = firstLine.substr(1);
  17692. }
  17693. if (firstLine.length > 0) {
  17694. // We want to prioritize associations based on the order they are registered so that the last registered
  17695. // association wins over all other. This is for https://github.com/Microsoft/vscode/issues/20074
  17696. for (var i = registeredAssociations.length - 1; i >= 0; i--) {
  17697. var association = registeredAssociations[i];
  17698. if (!association.firstline) {
  17699. continue;
  17700. }
  17701. var matches = firstLine.match(association.firstline);
  17702. if (matches && matches.length > 0) {
  17703. return association.mime;
  17704. }
  17705. }
  17706. }
  17707. return null;
  17708. }
  17709. });
  17710. /*---------------------------------------------------------------------------------------------
  17711. * Copyright (c) Microsoft Corporation. All rights reserved.
  17712. * Licensed under the MIT License. See License.txt in the project root for license information.
  17713. *--------------------------------------------------------------------------------------------*/
  17714. define(__m[182/*vs/base/common/worker/simpleWorker*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,21/*vs/base/common/types*/]), function (require, exports, errors_1, lifecycle_1, platform_1, types) {
  17715. "use strict";
  17716. Object.defineProperty(exports, "__esModule", { value: true });
  17717. var INITIALIZE = '$initialize';
  17718. var webWorkerWarningLogged = false;
  17719. function logOnceWebWorkerWarning(err) {
  17720. if (!platform_1.isWeb) {
  17721. // running tests
  17722. return;
  17723. }
  17724. if (!webWorkerWarningLogged) {
  17725. webWorkerWarningLogged = true;
  17726. console.warn('Could not create web worker(s). Falling back to loading web worker code in main thread, which might cause UI freezes. Please see https://github.com/Microsoft/monaco-editor#faq');
  17727. }
  17728. console.warn(err.message);
  17729. }
  17730. exports.logOnceWebWorkerWarning = logOnceWebWorkerWarning;
  17731. var SimpleWorkerProtocol = /** @class */ (function () {
  17732. function SimpleWorkerProtocol(handler) {
  17733. this._workerId = -1;
  17734. this._handler = handler;
  17735. this._lastSentReq = 0;
  17736. this._pendingReplies = Object.create(null);
  17737. }
  17738. SimpleWorkerProtocol.prototype.setWorkerId = function (workerId) {
  17739. this._workerId = workerId;
  17740. };
  17741. SimpleWorkerProtocol.prototype.sendMessage = function (method, args) {
  17742. var _this = this;
  17743. var req = String(++this._lastSentReq);
  17744. return new Promise(function (resolve, reject) {
  17745. _this._pendingReplies[req] = {
  17746. resolve: resolve,
  17747. reject: reject
  17748. };
  17749. _this._send({
  17750. vsWorker: _this._workerId,
  17751. req: req,
  17752. method: method,
  17753. args: args
  17754. });
  17755. });
  17756. };
  17757. SimpleWorkerProtocol.prototype.handleMessage = function (message) {
  17758. if (!message || !message.vsWorker) {
  17759. return;
  17760. }
  17761. if (this._workerId !== -1 && message.vsWorker !== this._workerId) {
  17762. return;
  17763. }
  17764. this._handleMessage(message);
  17765. };
  17766. SimpleWorkerProtocol.prototype._handleMessage = function (msg) {
  17767. var _this = this;
  17768. if (msg.seq) {
  17769. var replyMessage = msg;
  17770. if (!this._pendingReplies[replyMessage.seq]) {
  17771. console.warn('Got reply to unknown seq');
  17772. return;
  17773. }
  17774. var reply = this._pendingReplies[replyMessage.seq];
  17775. delete this._pendingReplies[replyMessage.seq];
  17776. if (replyMessage.err) {
  17777. var err = replyMessage.err;
  17778. if (replyMessage.err.$isError) {
  17779. err = new Error();
  17780. err.name = replyMessage.err.name;
  17781. err.message = replyMessage.err.message;
  17782. err.stack = replyMessage.err.stack;
  17783. }
  17784. reply.reject(err);
  17785. return;
  17786. }
  17787. reply.resolve(replyMessage.res);
  17788. return;
  17789. }
  17790. var requestMessage = msg;
  17791. var req = requestMessage.req;
  17792. var result = this._handler.handleMessage(requestMessage.method, requestMessage.args);
  17793. result.then(function (r) {
  17794. _this._send({
  17795. vsWorker: _this._workerId,
  17796. seq: req,
  17797. res: r,
  17798. err: undefined
  17799. });
  17800. }, function (e) {
  17801. if (e.detail instanceof Error) {
  17802. // Loading errors have a detail property that points to the actual error
  17803. e.detail = errors_1.transformErrorForSerialization(e.detail);
  17804. }
  17805. _this._send({
  17806. vsWorker: _this._workerId,
  17807. seq: req,
  17808. res: undefined,
  17809. err: errors_1.transformErrorForSerialization(e)
  17810. });
  17811. });
  17812. };
  17813. SimpleWorkerProtocol.prototype._send = function (msg) {
  17814. var transfer = [];
  17815. if (msg.req) {
  17816. var m = msg;
  17817. for (var i = 0; i < m.args.length; i++) {
  17818. if (m.args[i] instanceof ArrayBuffer) {
  17819. transfer.push(m.args[i]);
  17820. }
  17821. }
  17822. }
  17823. else {
  17824. var m = msg;
  17825. if (m.res instanceof ArrayBuffer) {
  17826. transfer.push(m.res);
  17827. }
  17828. }
  17829. this._handler.sendMessage(msg, transfer);
  17830. };
  17831. return SimpleWorkerProtocol;
  17832. }());
  17833. /**
  17834. * Main thread side
  17835. */
  17836. var SimpleWorkerClient = /** @class */ (function (_super) {
  17837. __extends(SimpleWorkerClient, _super);
  17838. function SimpleWorkerClient(workerFactory, moduleId, host) {
  17839. var _this = _super.call(this) || this;
  17840. var lazyProxyReject = null;
  17841. _this._worker = _this._register(workerFactory.create('vs/base/common/worker/simpleWorker', function (msg) {
  17842. _this._protocol.handleMessage(msg);
  17843. }, function (err) {
  17844. // in Firefox, web workers fail lazily :(
  17845. // we will reject the proxy
  17846. if (lazyProxyReject) {
  17847. lazyProxyReject(err);
  17848. }
  17849. }));
  17850. _this._protocol = new SimpleWorkerProtocol({
  17851. sendMessage: function (msg, transfer) {
  17852. _this._worker.postMessage(msg, transfer);
  17853. },
  17854. handleMessage: function (method, args) {
  17855. if (typeof host[method] !== 'function') {
  17856. return Promise.reject(new Error('Missing method ' + method + ' on main thread host.'));
  17857. }
  17858. try {
  17859. return Promise.resolve(host[method].apply(host, args));
  17860. }
  17861. catch (e) {
  17862. return Promise.reject(e);
  17863. }
  17864. }
  17865. });
  17866. _this._protocol.setWorkerId(_this._worker.getId());
  17867. // Gather loader configuration
  17868. var loaderConfiguration = null;
  17869. if (typeof self.require !== 'undefined' && typeof self.require.getConfig === 'function') {
  17870. // Get the configuration from the Monaco AMD Loader
  17871. loaderConfiguration = self.require.getConfig();
  17872. }
  17873. else if (typeof self.requirejs !== 'undefined') {
  17874. // Get the configuration from requirejs
  17875. loaderConfiguration = self.requirejs.s.contexts._.config;
  17876. }
  17877. var hostMethods = types.getAllMethodNames(host);
  17878. // Send initialize message
  17879. _this._onModuleLoaded = _this._protocol.sendMessage(INITIALIZE, [
  17880. _this._worker.getId(),
  17881. JSON.parse(JSON.stringify(loaderConfiguration)),
  17882. moduleId,
  17883. hostMethods,
  17884. ]);
  17885. // Create proxy to loaded code
  17886. var proxyMethodRequest = function (method, args) {
  17887. return _this._request(method, args);
  17888. };
  17889. _this._lazyProxy = new Promise(function (resolve, reject) {
  17890. lazyProxyReject = reject;
  17891. _this._onModuleLoaded.then(function (availableMethods) {
  17892. resolve(types.createProxyObject(availableMethods, proxyMethodRequest));
  17893. }, function (e) {
  17894. reject(e);
  17895. _this._onError('Worker failed to load ' + moduleId, e);
  17896. });
  17897. });
  17898. return _this;
  17899. }
  17900. SimpleWorkerClient.prototype.getProxyObject = function () {
  17901. return this._lazyProxy;
  17902. };
  17903. SimpleWorkerClient.prototype._request = function (method, args) {
  17904. var _this = this;
  17905. return new Promise(function (resolve, reject) {
  17906. _this._onModuleLoaded.then(function () {
  17907. _this._protocol.sendMessage(method, args).then(resolve, reject);
  17908. }, reject);
  17909. });
  17910. };
  17911. SimpleWorkerClient.prototype._onError = function (message, error) {
  17912. console.error(message);
  17913. console.info(error);
  17914. };
  17915. return SimpleWorkerClient;
  17916. }(lifecycle_1.Disposable));
  17917. exports.SimpleWorkerClient = SimpleWorkerClient;
  17918. /**
  17919. * Worker side
  17920. */
  17921. var SimpleWorkerServer = /** @class */ (function () {
  17922. function SimpleWorkerServer(postMessage, requestHandlerFactory) {
  17923. var _this = this;
  17924. this._requestHandlerFactory = requestHandlerFactory;
  17925. this._requestHandler = null;
  17926. this._protocol = new SimpleWorkerProtocol({
  17927. sendMessage: function (msg, transfer) {
  17928. postMessage(msg, transfer);
  17929. },
  17930. handleMessage: function (method, args) { return _this._handleMessage(method, args); }
  17931. });
  17932. }
  17933. SimpleWorkerServer.prototype.onmessage = function (msg) {
  17934. this._protocol.handleMessage(msg);
  17935. };
  17936. SimpleWorkerServer.prototype._handleMessage = function (method, args) {
  17937. if (method === INITIALIZE) {
  17938. return this.initialize(args[0], args[1], args[2], args[3]);
  17939. }
  17940. if (!this._requestHandler || typeof this._requestHandler[method] !== 'function') {
  17941. return Promise.reject(new Error('Missing requestHandler or method: ' + method));
  17942. }
  17943. try {
  17944. return Promise.resolve(this._requestHandler[method].apply(this._requestHandler, args));
  17945. }
  17946. catch (e) {
  17947. return Promise.reject(e);
  17948. }
  17949. };
  17950. SimpleWorkerServer.prototype.initialize = function (workerId, loaderConfig, moduleId, hostMethods) {
  17951. var _this = this;
  17952. this._protocol.setWorkerId(workerId);
  17953. var proxyMethodRequest = function (method, args) {
  17954. return _this._protocol.sendMessage(method, args);
  17955. };
  17956. var hostProxy = types.createProxyObject(hostMethods, proxyMethodRequest);
  17957. if (this._requestHandlerFactory) {
  17958. // static request handler
  17959. this._requestHandler = this._requestHandlerFactory(hostProxy);
  17960. return Promise.resolve(types.getAllMethodNames(this._requestHandler));
  17961. }
  17962. if (loaderConfig) {
  17963. // Remove 'baseUrl', handling it is beyond scope for now
  17964. if (typeof loaderConfig.baseUrl !== 'undefined') {
  17965. delete loaderConfig['baseUrl'];
  17966. }
  17967. if (typeof loaderConfig.paths !== 'undefined') {
  17968. if (typeof loaderConfig.paths.vs !== 'undefined') {
  17969. delete loaderConfig.paths['vs'];
  17970. }
  17971. }
  17972. // Since this is in a web worker, enable catching errors
  17973. loaderConfig.catchError = true;
  17974. self.require.config(loaderConfig);
  17975. }
  17976. return new Promise(function (resolve, reject) {
  17977. // Use the global require to be sure to get the global config
  17978. self.require([moduleId], function (module) {
  17979. _this._requestHandler = module.create(hostProxy);
  17980. if (!_this._requestHandler) {
  17981. reject(new Error("No RequestHandler!"));
  17982. return;
  17983. }
  17984. resolve(types.getAllMethodNames(_this._requestHandler));
  17985. }, reject);
  17986. });
  17987. };
  17988. return SimpleWorkerServer;
  17989. }());
  17990. exports.SimpleWorkerServer = SimpleWorkerServer;
  17991. /**
  17992. * Called on the worker side
  17993. */
  17994. function create(postMessage) {
  17995. return new SimpleWorkerServer(postMessage, null);
  17996. }
  17997. exports.create = create;
  17998. });
  17999. /*---------------------------------------------------------------------------------------------
  18000. * Copyright (c) Microsoft Corporation. All rights reserved.
  18001. * Licensed under the MIT License. See License.txt in the project root for license information.
  18002. *--------------------------------------------------------------------------------------------*/
  18003. define(__m[253/*vs/base/parts/quickopen/browser/quickOpenViewer*/], __M([0/*require*/,1/*exports*/,21/*vs/base/common/types*/]), function (require, exports, types_1) {
  18004. "use strict";
  18005. Object.defineProperty(exports, "__esModule", { value: true });
  18006. var DataSource = /** @class */ (function () {
  18007. function DataSource(arg) {
  18008. this.modelProvider = types_1.isFunction(arg.getModel) ? arg : { getModel: function () { return arg; } };
  18009. }
  18010. DataSource.prototype.getId = function (tree, element) {
  18011. if (!element) {
  18012. return null;
  18013. }
  18014. var model = this.modelProvider.getModel();
  18015. return model === element ? '__root__' : model.dataSource.getId(element);
  18016. };
  18017. DataSource.prototype.hasChildren = function (tree, element) {
  18018. var model = this.modelProvider.getModel();
  18019. return !!(model && model === element && model.entries.length > 0);
  18020. };
  18021. DataSource.prototype.getChildren = function (tree, element) {
  18022. var model = this.modelProvider.getModel();
  18023. return Promise.resolve(model === element ? model.entries : []);
  18024. };
  18025. DataSource.prototype.getParent = function (tree, element) {
  18026. return Promise.resolve(null);
  18027. };
  18028. return DataSource;
  18029. }());
  18030. exports.DataSource = DataSource;
  18031. var AccessibilityProvider = /** @class */ (function () {
  18032. function AccessibilityProvider(modelProvider) {
  18033. this.modelProvider = modelProvider;
  18034. }
  18035. AccessibilityProvider.prototype.getAriaLabel = function (tree, element) {
  18036. var model = this.modelProvider.getModel();
  18037. return model.accessibilityProvider ? model.accessibilityProvider.getAriaLabel(element) : null;
  18038. };
  18039. AccessibilityProvider.prototype.getPosInSet = function (tree, element) {
  18040. var model = this.modelProvider.getModel();
  18041. var i = 0;
  18042. if (model.filter) {
  18043. for (var _i = 0, _a = model.entries; _i < _a.length; _i++) {
  18044. var entry = _a[_i];
  18045. if (model.filter.isVisible(entry)) {
  18046. i++;
  18047. }
  18048. if (entry === element) {
  18049. break;
  18050. }
  18051. }
  18052. }
  18053. else {
  18054. i = model.entries.indexOf(element) + 1;
  18055. }
  18056. return String(i);
  18057. };
  18058. AccessibilityProvider.prototype.getSetSize = function () {
  18059. var model = this.modelProvider.getModel();
  18060. var n = 0;
  18061. if (model.filter) {
  18062. for (var _i = 0, _a = model.entries; _i < _a.length; _i++) {
  18063. var entry = _a[_i];
  18064. if (model.filter.isVisible(entry)) {
  18065. n++;
  18066. }
  18067. }
  18068. }
  18069. else {
  18070. n = model.entries.length;
  18071. }
  18072. return String(n);
  18073. };
  18074. return AccessibilityProvider;
  18075. }());
  18076. exports.AccessibilityProvider = AccessibilityProvider;
  18077. var Filter = /** @class */ (function () {
  18078. function Filter(modelProvider) {
  18079. this.modelProvider = modelProvider;
  18080. }
  18081. Filter.prototype.isVisible = function (tree, element) {
  18082. var model = this.modelProvider.getModel();
  18083. if (!model.filter) {
  18084. return true;
  18085. }
  18086. return model.filter.isVisible(element);
  18087. };
  18088. return Filter;
  18089. }());
  18090. exports.Filter = Filter;
  18091. var Renderer = /** @class */ (function () {
  18092. function Renderer(modelProvider, styles) {
  18093. this.modelProvider = modelProvider;
  18094. this.styles = styles;
  18095. }
  18096. Renderer.prototype.updateStyles = function (styles) {
  18097. this.styles = styles;
  18098. };
  18099. Renderer.prototype.getHeight = function (tree, element) {
  18100. var model = this.modelProvider.getModel();
  18101. return model.renderer.getHeight(element);
  18102. };
  18103. Renderer.prototype.getTemplateId = function (tree, element) {
  18104. var model = this.modelProvider.getModel();
  18105. return model.renderer.getTemplateId(element);
  18106. };
  18107. Renderer.prototype.renderTemplate = function (tree, templateId, container) {
  18108. var model = this.modelProvider.getModel();
  18109. return model.renderer.renderTemplate(templateId, container, this.styles);
  18110. };
  18111. Renderer.prototype.renderElement = function (tree, element, templateId, templateData) {
  18112. var model = this.modelProvider.getModel();
  18113. model.renderer.renderElement(element, templateId, templateData, this.styles);
  18114. };
  18115. Renderer.prototype.disposeTemplate = function (tree, templateId, templateData) {
  18116. var model = this.modelProvider.getModel();
  18117. model.renderer.disposeTemplate(templateId, templateData);
  18118. };
  18119. return Renderer;
  18120. }());
  18121. exports.Renderer = Renderer;
  18122. });
  18123. /*---------------------------------------------------------------------------------------------
  18124. * Copyright (c) Microsoft Corporation. All rights reserved.
  18125. * Licensed under the MIT License. See License.txt in the project root for license information.
  18126. *--------------------------------------------------------------------------------------------*/
  18127. define(__m[254/*vs/base/parts/tree/browser/tree*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  18128. "use strict";
  18129. Object.defineProperty(exports, "__esModule", { value: true });
  18130. var ContextMenuEvent = /** @class */ (function () {
  18131. function ContextMenuEvent(posx, posy, target) {
  18132. this._posx = posx;
  18133. this._posy = posy;
  18134. this._target = target;
  18135. }
  18136. ContextMenuEvent.prototype.preventDefault = function () {
  18137. // no-op
  18138. };
  18139. ContextMenuEvent.prototype.stopPropagation = function () {
  18140. // no-op
  18141. };
  18142. Object.defineProperty(ContextMenuEvent.prototype, "target", {
  18143. get: function () {
  18144. return this._target;
  18145. },
  18146. enumerable: true,
  18147. configurable: true
  18148. });
  18149. return ContextMenuEvent;
  18150. }());
  18151. exports.ContextMenuEvent = ContextMenuEvent;
  18152. var MouseContextMenuEvent = /** @class */ (function (_super) {
  18153. __extends(MouseContextMenuEvent, _super);
  18154. function MouseContextMenuEvent(originalEvent) {
  18155. var _this = _super.call(this, originalEvent.posx, originalEvent.posy, originalEvent.target) || this;
  18156. _this.originalEvent = originalEvent;
  18157. return _this;
  18158. }
  18159. MouseContextMenuEvent.prototype.preventDefault = function () {
  18160. this.originalEvent.preventDefault();
  18161. };
  18162. MouseContextMenuEvent.prototype.stopPropagation = function () {
  18163. this.originalEvent.stopPropagation();
  18164. };
  18165. return MouseContextMenuEvent;
  18166. }(ContextMenuEvent));
  18167. exports.MouseContextMenuEvent = MouseContextMenuEvent;
  18168. var KeyboardContextMenuEvent = /** @class */ (function (_super) {
  18169. __extends(KeyboardContextMenuEvent, _super);
  18170. function KeyboardContextMenuEvent(posx, posy, originalEvent) {
  18171. var _this = _super.call(this, posx, posy, originalEvent.target) || this;
  18172. _this.originalEvent = originalEvent;
  18173. return _this;
  18174. }
  18175. KeyboardContextMenuEvent.prototype.preventDefault = function () {
  18176. this.originalEvent.preventDefault();
  18177. };
  18178. KeyboardContextMenuEvent.prototype.stopPropagation = function () {
  18179. this.originalEvent.stopPropagation();
  18180. };
  18181. return KeyboardContextMenuEvent;
  18182. }(ContextMenuEvent));
  18183. exports.KeyboardContextMenuEvent = KeyboardContextMenuEvent;
  18184. });
  18185. define(__m[137/*vs/base/parts/tree/browser/treeDefaults*/], __M([0/*require*/,1/*exports*/,16/*vs/base/common/platform*/,10/*vs/base/common/errors*/,6/*vs/base/browser/dom*/,36/*vs/base/common/keyCodes*/]), function (require, exports, platform, errors, dom, keyCodes_1) {
  18186. "use strict";
  18187. Object.defineProperty(exports, "__esModule", { value: true });
  18188. var KeybindingDispatcher = /** @class */ (function () {
  18189. function KeybindingDispatcher() {
  18190. this._arr = [];
  18191. }
  18192. KeybindingDispatcher.prototype.set = function (keybinding, callback) {
  18193. this._arr.push({
  18194. keybinding: keyCodes_1.createKeybinding(keybinding, platform.OS),
  18195. callback: callback
  18196. });
  18197. };
  18198. KeybindingDispatcher.prototype.dispatch = function (keybinding) {
  18199. // Loop from the last to the first to handle overwrites
  18200. for (var i = this._arr.length - 1; i >= 0; i--) {
  18201. var item = this._arr[i];
  18202. if (keybinding.toChord().equals(item.keybinding)) {
  18203. return item.callback;
  18204. }
  18205. }
  18206. return null;
  18207. };
  18208. return KeybindingDispatcher;
  18209. }());
  18210. exports.KeybindingDispatcher = KeybindingDispatcher;
  18211. var DefaultController = /** @class */ (function () {
  18212. function DefaultController(options) {
  18213. var _this = this;
  18214. if (options === void 0) { options = { clickBehavior: 0 /* ON_MOUSE_DOWN */, keyboardSupport: true, openMode: 0 /* SINGLE_CLICK */ }; }
  18215. this.options = options;
  18216. this.downKeyBindingDispatcher = new KeybindingDispatcher();
  18217. this.upKeyBindingDispatcher = new KeybindingDispatcher();
  18218. if (typeof options.keyboardSupport !== 'boolean' || options.keyboardSupport) {
  18219. this.downKeyBindingDispatcher.set(16 /* UpArrow */, function (t, e) { return _this.onUp(t, e); });
  18220. this.downKeyBindingDispatcher.set(18 /* DownArrow */, function (t, e) { return _this.onDown(t, e); });
  18221. this.downKeyBindingDispatcher.set(15 /* LeftArrow */, function (t, e) { return _this.onLeft(t, e); });
  18222. this.downKeyBindingDispatcher.set(17 /* RightArrow */, function (t, e) { return _this.onRight(t, e); });
  18223. if (platform.isMacintosh) {
  18224. this.downKeyBindingDispatcher.set(2048 /* CtrlCmd */ | 16 /* UpArrow */, function (t, e) { return _this.onLeft(t, e); });
  18225. this.downKeyBindingDispatcher.set(256 /* WinCtrl */ | 44 /* KEY_N */, function (t, e) { return _this.onDown(t, e); });
  18226. this.downKeyBindingDispatcher.set(256 /* WinCtrl */ | 46 /* KEY_P */, function (t, e) { return _this.onUp(t, e); });
  18227. }
  18228. this.downKeyBindingDispatcher.set(11 /* PageUp */, function (t, e) { return _this.onPageUp(t, e); });
  18229. this.downKeyBindingDispatcher.set(12 /* PageDown */, function (t, e) { return _this.onPageDown(t, e); });
  18230. this.downKeyBindingDispatcher.set(14 /* Home */, function (t, e) { return _this.onHome(t, e); });
  18231. this.downKeyBindingDispatcher.set(13 /* End */, function (t, e) { return _this.onEnd(t, e); });
  18232. this.downKeyBindingDispatcher.set(10 /* Space */, function (t, e) { return _this.onSpace(t, e); });
  18233. this.downKeyBindingDispatcher.set(9 /* Escape */, function (t, e) { return _this.onEscape(t, e); });
  18234. this.upKeyBindingDispatcher.set(3 /* Enter */, this.onEnter.bind(this));
  18235. this.upKeyBindingDispatcher.set(2048 /* CtrlCmd */ | 3 /* Enter */, this.onEnter.bind(this));
  18236. }
  18237. }
  18238. DefaultController.prototype.onMouseDown = function (tree, element, event, origin) {
  18239. if (origin === void 0) { origin = 'mouse'; }
  18240. if (this.options.clickBehavior === 0 /* ON_MOUSE_DOWN */ && (event.leftButton || event.middleButton)) {
  18241. if (event.target) {
  18242. if (event.target.tagName && event.target.tagName.toLowerCase() === 'input') {
  18243. return false; // Ignore event if target is a form input field (avoids browser specific issues)
  18244. }
  18245. if (dom.findParentWithClass(event.target, 'scrollbar', 'monaco-tree')) {
  18246. return false;
  18247. }
  18248. if (dom.findParentWithClass(event.target, 'monaco-action-bar', 'row')) { // TODO@Joao not very nice way of checking for the action bar (implicit knowledge)
  18249. return false; // Ignore event if target is over an action bar of the row
  18250. }
  18251. }
  18252. // Propagate to onLeftClick now
  18253. return this.onLeftClick(tree, element, event, origin);
  18254. }
  18255. return false;
  18256. };
  18257. DefaultController.prototype.onClick = function (tree, element, event) {
  18258. var isMac = platform.isMacintosh;
  18259. // A Ctrl click on the Mac is a context menu event
  18260. if (isMac && event.ctrlKey) {
  18261. event.preventDefault();
  18262. event.stopPropagation();
  18263. return false;
  18264. }
  18265. if (event.target && event.target.tagName && event.target.tagName.toLowerCase() === 'input') {
  18266. return false; // Ignore event if target is a form input field (avoids browser specific issues)
  18267. }
  18268. if (this.options.clickBehavior === 0 /* ON_MOUSE_DOWN */ && (event.leftButton || event.middleButton)) {
  18269. return false; // Already handled by onMouseDown
  18270. }
  18271. return this.onLeftClick(tree, element, event);
  18272. };
  18273. DefaultController.prototype.onLeftClick = function (tree, element, eventish, origin) {
  18274. if (origin === void 0) { origin = 'mouse'; }
  18275. var event = eventish;
  18276. var payload = { origin: origin, originalEvent: eventish, didClickOnTwistie: this.isClickOnTwistie(event) };
  18277. if (tree.getInput() === element) {
  18278. tree.clearFocus(payload);
  18279. tree.clearSelection(payload);
  18280. }
  18281. else {
  18282. var isSingleMouseDown = eventish && event.browserEvent && event.browserEvent.type === 'mousedown' && event.browserEvent.detail === 1;
  18283. if (!isSingleMouseDown) {
  18284. eventish.preventDefault(); // we cannot preventDefault onMouseDown with single click because this would break DND otherwise
  18285. }
  18286. eventish.stopPropagation();
  18287. tree.domFocus();
  18288. tree.setSelection([element], payload);
  18289. tree.setFocus(element, payload);
  18290. if (this.shouldToggleExpansion(element, event, origin)) {
  18291. if (tree.isExpanded(element)) {
  18292. tree.collapse(element).then(undefined, errors.onUnexpectedError);
  18293. }
  18294. else {
  18295. tree.expand(element).then(undefined, errors.onUnexpectedError);
  18296. }
  18297. }
  18298. }
  18299. return true;
  18300. };
  18301. DefaultController.prototype.shouldToggleExpansion = function (element, event, origin) {
  18302. var isDoubleClick = (origin === 'mouse' && event.detail === 2);
  18303. return this.openOnSingleClick || isDoubleClick || this.isClickOnTwistie(event);
  18304. };
  18305. Object.defineProperty(DefaultController.prototype, "openOnSingleClick", {
  18306. get: function () {
  18307. return this.options.openMode === 0 /* SINGLE_CLICK */;
  18308. },
  18309. enumerable: true,
  18310. configurable: true
  18311. });
  18312. DefaultController.prototype.isClickOnTwistie = function (event) {
  18313. var element = event.target;
  18314. if (!dom.hasClass(element, 'content')) {
  18315. return false;
  18316. }
  18317. var twistieStyle = window.getComputedStyle(element, ':before');
  18318. if (twistieStyle.backgroundImage === 'none' || twistieStyle.display === 'none') {
  18319. return false;
  18320. }
  18321. var twistieWidth = parseInt(twistieStyle.width) + parseInt(twistieStyle.paddingRight);
  18322. return event.browserEvent.offsetX <= twistieWidth;
  18323. };
  18324. DefaultController.prototype.onContextMenu = function (tree, element, event) {
  18325. if (event.target && event.target.tagName && event.target.tagName.toLowerCase() === 'input') {
  18326. return false; // allow context menu on input fields
  18327. }
  18328. // Prevent native context menu from showing up
  18329. if (event) {
  18330. event.preventDefault();
  18331. event.stopPropagation();
  18332. }
  18333. return false;
  18334. };
  18335. DefaultController.prototype.onTap = function (tree, element, event) {
  18336. var target = event.initialTarget;
  18337. if (target && target.tagName && target.tagName.toLowerCase() === 'input') {
  18338. return false; // Ignore event if target is a form input field (avoids browser specific issues)
  18339. }
  18340. return this.onLeftClick(tree, element, event, 'touch');
  18341. };
  18342. DefaultController.prototype.onKeyDown = function (tree, event) {
  18343. return this.onKey(this.downKeyBindingDispatcher, tree, event);
  18344. };
  18345. DefaultController.prototype.onKeyUp = function (tree, event) {
  18346. return this.onKey(this.upKeyBindingDispatcher, tree, event);
  18347. };
  18348. DefaultController.prototype.onKey = function (bindings, tree, event) {
  18349. var handler = bindings.dispatch(event.toKeybinding());
  18350. if (handler) {
  18351. // TODO: TS 3.1 upgrade. Why are we checking against void?
  18352. if (handler(tree, event)) {
  18353. event.preventDefault();
  18354. event.stopPropagation();
  18355. return true;
  18356. }
  18357. }
  18358. return false;
  18359. };
  18360. DefaultController.prototype.onUp = function (tree, event) {
  18361. var payload = { origin: 'keyboard', originalEvent: event };
  18362. if (tree.getHighlight()) {
  18363. tree.clearHighlight(payload);
  18364. }
  18365. else {
  18366. tree.focusPrevious(1, payload);
  18367. tree.reveal(tree.getFocus()).then(undefined, errors.onUnexpectedError);
  18368. }
  18369. return true;
  18370. };
  18371. DefaultController.prototype.onPageUp = function (tree, event) {
  18372. var payload = { origin: 'keyboard', originalEvent: event };
  18373. if (tree.getHighlight()) {
  18374. tree.clearHighlight(payload);
  18375. }
  18376. else {
  18377. tree.focusPreviousPage(payload);
  18378. tree.reveal(tree.getFocus()).then(undefined, errors.onUnexpectedError);
  18379. }
  18380. return true;
  18381. };
  18382. DefaultController.prototype.onDown = function (tree, event) {
  18383. var payload = { origin: 'keyboard', originalEvent: event };
  18384. if (tree.getHighlight()) {
  18385. tree.clearHighlight(payload);
  18386. }
  18387. else {
  18388. tree.focusNext(1, payload);
  18389. tree.reveal(tree.getFocus()).then(undefined, errors.onUnexpectedError);
  18390. }
  18391. return true;
  18392. };
  18393. DefaultController.prototype.onPageDown = function (tree, event) {
  18394. var payload = { origin: 'keyboard', originalEvent: event };
  18395. if (tree.getHighlight()) {
  18396. tree.clearHighlight(payload);
  18397. }
  18398. else {
  18399. tree.focusNextPage(payload);
  18400. tree.reveal(tree.getFocus()).then(undefined, errors.onUnexpectedError);
  18401. }
  18402. return true;
  18403. };
  18404. DefaultController.prototype.onHome = function (tree, event) {
  18405. var payload = { origin: 'keyboard', originalEvent: event };
  18406. if (tree.getHighlight()) {
  18407. tree.clearHighlight(payload);
  18408. }
  18409. else {
  18410. tree.focusFirst(payload);
  18411. tree.reveal(tree.getFocus()).then(undefined, errors.onUnexpectedError);
  18412. }
  18413. return true;
  18414. };
  18415. DefaultController.prototype.onEnd = function (tree, event) {
  18416. var payload = { origin: 'keyboard', originalEvent: event };
  18417. if (tree.getHighlight()) {
  18418. tree.clearHighlight(payload);
  18419. }
  18420. else {
  18421. tree.focusLast(payload);
  18422. tree.reveal(tree.getFocus()).then(undefined, errors.onUnexpectedError);
  18423. }
  18424. return true;
  18425. };
  18426. DefaultController.prototype.onLeft = function (tree, event) {
  18427. var payload = { origin: 'keyboard', originalEvent: event };
  18428. if (tree.getHighlight()) {
  18429. tree.clearHighlight(payload);
  18430. }
  18431. else {
  18432. var focus_1 = tree.getFocus();
  18433. tree.collapse(focus_1).then(function (didCollapse) {
  18434. if (focus_1 && !didCollapse) {
  18435. tree.focusParent(payload);
  18436. return tree.reveal(tree.getFocus());
  18437. }
  18438. return undefined;
  18439. }).then(undefined, errors.onUnexpectedError);
  18440. }
  18441. return true;
  18442. };
  18443. DefaultController.prototype.onRight = function (tree, event) {
  18444. var payload = { origin: 'keyboard', originalEvent: event };
  18445. if (tree.getHighlight()) {
  18446. tree.clearHighlight(payload);
  18447. }
  18448. else {
  18449. var focus_2 = tree.getFocus();
  18450. tree.expand(focus_2).then(function (didExpand) {
  18451. if (focus_2 && !didExpand) {
  18452. tree.focusFirstChild(payload);
  18453. return tree.reveal(tree.getFocus());
  18454. }
  18455. return undefined;
  18456. }).then(undefined, errors.onUnexpectedError);
  18457. }
  18458. return true;
  18459. };
  18460. DefaultController.prototype.onEnter = function (tree, event) {
  18461. var payload = { origin: 'keyboard', originalEvent: event };
  18462. if (tree.getHighlight()) {
  18463. return false;
  18464. }
  18465. var focus = tree.getFocus();
  18466. if (focus) {
  18467. tree.setSelection([focus], payload);
  18468. }
  18469. return true;
  18470. };
  18471. DefaultController.prototype.onSpace = function (tree, event) {
  18472. if (tree.getHighlight()) {
  18473. return false;
  18474. }
  18475. var focus = tree.getFocus();
  18476. if (focus) {
  18477. tree.toggleExpansion(focus);
  18478. }
  18479. return true;
  18480. };
  18481. DefaultController.prototype.onEscape = function (tree, event) {
  18482. var payload = { origin: 'keyboard', originalEvent: event };
  18483. if (tree.getHighlight()) {
  18484. tree.clearHighlight(payload);
  18485. return true;
  18486. }
  18487. if (tree.getSelection().length) {
  18488. tree.clearSelection(payload);
  18489. return true;
  18490. }
  18491. if (tree.getFocus()) {
  18492. tree.clearFocus(payload);
  18493. return true;
  18494. }
  18495. return false;
  18496. };
  18497. return DefaultController;
  18498. }());
  18499. exports.DefaultController = DefaultController;
  18500. var DefaultDragAndDrop = /** @class */ (function () {
  18501. function DefaultDragAndDrop() {
  18502. }
  18503. DefaultDragAndDrop.prototype.getDragURI = function (tree, element) {
  18504. return null;
  18505. };
  18506. DefaultDragAndDrop.prototype.onDragStart = function (tree, data, originalEvent) {
  18507. return;
  18508. };
  18509. DefaultDragAndDrop.prototype.onDragOver = function (tree, data, targetElement, originalEvent) {
  18510. return null;
  18511. };
  18512. DefaultDragAndDrop.prototype.drop = function (tree, data, targetElement, originalEvent) {
  18513. return;
  18514. };
  18515. return DefaultDragAndDrop;
  18516. }());
  18517. exports.DefaultDragAndDrop = DefaultDragAndDrop;
  18518. var DefaultFilter = /** @class */ (function () {
  18519. function DefaultFilter() {
  18520. }
  18521. DefaultFilter.prototype.isVisible = function (tree, element) {
  18522. return true;
  18523. };
  18524. return DefaultFilter;
  18525. }());
  18526. exports.DefaultFilter = DefaultFilter;
  18527. var DefaultAccessibilityProvider = /** @class */ (function () {
  18528. function DefaultAccessibilityProvider() {
  18529. }
  18530. DefaultAccessibilityProvider.prototype.getAriaLabel = function (tree, element) {
  18531. return null;
  18532. };
  18533. return DefaultAccessibilityProvider;
  18534. }());
  18535. exports.DefaultAccessibilityProvider = DefaultAccessibilityProvider;
  18536. var DefaultTreestyler = /** @class */ (function () {
  18537. function DefaultTreestyler(styleElement, selectorSuffix) {
  18538. this.styleElement = styleElement;
  18539. this.selectorSuffix = selectorSuffix;
  18540. }
  18541. DefaultTreestyler.prototype.style = function (styles) {
  18542. var suffix = this.selectorSuffix ? "." + this.selectorSuffix : '';
  18543. var content = [];
  18544. if (styles.listFocusBackground) {
  18545. content.push(".monaco-tree" + suffix + ".focused .monaco-tree-rows > .monaco-tree-row.focused:not(.highlighted) { background-color: " + styles.listFocusBackground + "; }");
  18546. }
  18547. if (styles.listFocusForeground) {
  18548. content.push(".monaco-tree" + suffix + ".focused .monaco-tree-rows > .monaco-tree-row.focused:not(.highlighted) { color: " + styles.listFocusForeground + "; }");
  18549. }
  18550. if (styles.listActiveSelectionBackground) {
  18551. content.push(".monaco-tree" + suffix + ".focused .monaco-tree-rows > .monaco-tree-row.selected:not(.highlighted) { background-color: " + styles.listActiveSelectionBackground + "; }");
  18552. }
  18553. if (styles.listActiveSelectionForeground) {
  18554. content.push(".monaco-tree" + suffix + ".focused .monaco-tree-rows > .monaco-tree-row.selected:not(.highlighted) { color: " + styles.listActiveSelectionForeground + "; }");
  18555. }
  18556. if (styles.listFocusAndSelectionBackground) {
  18557. content.push("\n\t\t\t\t.monaco-tree-drag-image,\n\t\t\t\t.monaco-tree" + suffix + ".focused .monaco-tree-rows > .monaco-tree-row.focused.selected:not(.highlighted) { background-color: " + styles.listFocusAndSelectionBackground + "; }\n\t\t\t");
  18558. }
  18559. if (styles.listFocusAndSelectionForeground) {
  18560. content.push("\n\t\t\t\t.monaco-tree-drag-image,\n\t\t\t\t.monaco-tree" + suffix + ".focused .monaco-tree-rows > .monaco-tree-row.focused.selected:not(.highlighted) { color: " + styles.listFocusAndSelectionForeground + "; }\n\t\t\t");
  18561. }
  18562. if (styles.listInactiveSelectionBackground) {
  18563. content.push(".monaco-tree" + suffix + " .monaco-tree-rows > .monaco-tree-row.selected:not(.highlighted) { background-color: " + styles.listInactiveSelectionBackground + "; }");
  18564. }
  18565. if (styles.listInactiveSelectionForeground) {
  18566. content.push(".monaco-tree" + suffix + " .monaco-tree-rows > .monaco-tree-row.selected:not(.highlighted) { color: " + styles.listInactiveSelectionForeground + "; }");
  18567. }
  18568. if (styles.listHoverBackground) {
  18569. content.push(".monaco-tree" + suffix + " .monaco-tree-rows > .monaco-tree-row:hover:not(.highlighted):not(.selected):not(.focused) { background-color: " + styles.listHoverBackground + "; }");
  18570. }
  18571. if (styles.listHoverForeground) {
  18572. content.push(".monaco-tree" + suffix + " .monaco-tree-rows > .monaco-tree-row:hover:not(.highlighted):not(.selected):not(.focused) { color: " + styles.listHoverForeground + "; }");
  18573. }
  18574. if (styles.listDropBackground) {
  18575. content.push("\n\t\t\t\t.monaco-tree" + suffix + " .monaco-tree-wrapper.drop-target,\n\t\t\t\t.monaco-tree" + suffix + " .monaco-tree-rows > .monaco-tree-row.drop-target { background-color: " + styles.listDropBackground + " !important; color: inherit !important; }\n\t\t\t");
  18576. }
  18577. if (styles.listFocusOutline) {
  18578. content.push("\n\t\t\t\t.monaco-tree-drag-image\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t{ border: 1px solid " + styles.listFocusOutline + "; background: #000; }\n\t\t\t\t.monaco-tree" + suffix + " .monaco-tree-rows > .monaco-tree-row \t\t\t\t\t\t\t\t\t\t\t\t\t\t{ border: 1px solid transparent; }\n\t\t\t\t.monaco-tree" + suffix + ".focused .monaco-tree-rows > .monaco-tree-row.focused:not(.highlighted) \t\t\t\t\t\t{ border: 1px dotted " + styles.listFocusOutline + "; }\n\t\t\t\t.monaco-tree" + suffix + ".focused .monaco-tree-rows > .monaco-tree-row.selected:not(.highlighted) \t\t\t\t\t\t{ border: 1px solid " + styles.listFocusOutline + "; }\n\t\t\t\t.monaco-tree" + suffix + " .monaco-tree-rows > .monaco-tree-row.selected:not(.highlighted) \t\t\t\t\t\t\t{ border: 1px solid " + styles.listFocusOutline + "; }\n\t\t\t\t.monaco-tree" + suffix + " .monaco-tree-rows > .monaco-tree-row:hover:not(.highlighted):not(.selected):not(.focused) \t{ border: 1px dashed " + styles.listFocusOutline + "; }\n\t\t\t\t.monaco-tree" + suffix + " .monaco-tree-wrapper.drop-target,\n\t\t\t\t.monaco-tree" + suffix + " .monaco-tree-rows > .monaco-tree-row.drop-target\t\t\t\t\t\t\t\t\t\t\t\t{ border: 1px dashed " + styles.listFocusOutline + "; }\n\t\t\t");
  18579. }
  18580. var newStyles = content.join('\n');
  18581. if (newStyles !== this.styleElement.innerHTML) {
  18582. this.styleElement.innerHTML = newStyles;
  18583. }
  18584. };
  18585. return DefaultTreestyler;
  18586. }());
  18587. exports.DefaultTreestyler = DefaultTreestyler;
  18588. });
  18589. define(__m[255/*vs/base/parts/tree/browser/treeDnd*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  18590. "use strict";
  18591. Object.defineProperty(exports, "__esModule", { value: true });
  18592. var ElementsDragAndDropData = /** @class */ (function () {
  18593. function ElementsDragAndDropData(elements) {
  18594. this.elements = elements;
  18595. }
  18596. ElementsDragAndDropData.prototype.update = function (dataTransfer) {
  18597. // no-op
  18598. };
  18599. ElementsDragAndDropData.prototype.getData = function () {
  18600. return this.elements;
  18601. };
  18602. return ElementsDragAndDropData;
  18603. }());
  18604. exports.ElementsDragAndDropData = ElementsDragAndDropData;
  18605. var ExternalElementsDragAndDropData = /** @class */ (function () {
  18606. function ExternalElementsDragAndDropData(elements) {
  18607. this.elements = elements;
  18608. }
  18609. ExternalElementsDragAndDropData.prototype.update = function (dataTransfer) {
  18610. // no-op
  18611. };
  18612. ExternalElementsDragAndDropData.prototype.getData = function () {
  18613. return this.elements;
  18614. };
  18615. return ExternalElementsDragAndDropData;
  18616. }());
  18617. exports.ExternalElementsDragAndDropData = ExternalElementsDragAndDropData;
  18618. var DesktopDragAndDropData = /** @class */ (function () {
  18619. function DesktopDragAndDropData() {
  18620. this.types = [];
  18621. this.files = [];
  18622. }
  18623. DesktopDragAndDropData.prototype.update = function (dataTransfer) {
  18624. if (dataTransfer.types) {
  18625. this.types = [];
  18626. Array.prototype.push.apply(this.types, dataTransfer.types);
  18627. }
  18628. if (dataTransfer.files) {
  18629. this.files = [];
  18630. Array.prototype.push.apply(this.files, dataTransfer.files);
  18631. this.files = this.files.filter(function (f) { return f.size || f.type; });
  18632. }
  18633. };
  18634. DesktopDragAndDropData.prototype.getData = function () {
  18635. return {
  18636. types: this.types,
  18637. files: this.files
  18638. };
  18639. };
  18640. return DesktopDragAndDropData;
  18641. }());
  18642. exports.DesktopDragAndDropData = DesktopDragAndDropData;
  18643. });
  18644. /*---------------------------------------------------------------------------------------------
  18645. * Copyright (c) Microsoft Corporation. All rights reserved.
  18646. * Licensed under the MIT License. See License.txt in the project root for license information.
  18647. *--------------------------------------------------------------------------------------------*/
  18648. define(__m[256/*vs/base/parts/tree/browser/treeModel*/], __M([0/*require*/,1/*exports*/,124/*vs/base/common/assert*/,10/*vs/base/common/errors*/,2/*vs/base/common/lifecycle*/,4/*vs/base/common/event*/]), function (require, exports, Assert, errors_1, lifecycle_1, event_1) {
  18649. "use strict";
  18650. Object.defineProperty(exports, "__esModule", { value: true });
  18651. var LockData = /** @class */ (function () {
  18652. function LockData(item) {
  18653. this._onDispose = new event_1.Emitter();
  18654. this.onDispose = this._onDispose.event;
  18655. this._item = item;
  18656. }
  18657. Object.defineProperty(LockData.prototype, "item", {
  18658. get: function () {
  18659. return this._item;
  18660. },
  18661. enumerable: true,
  18662. configurable: true
  18663. });
  18664. LockData.prototype.dispose = function () {
  18665. if (this._onDispose) {
  18666. this._onDispose.fire();
  18667. this._onDispose.dispose();
  18668. this._onDispose = undefined;
  18669. }
  18670. };
  18671. return LockData;
  18672. }());
  18673. exports.LockData = LockData;
  18674. var Lock = /** @class */ (function () {
  18675. function Lock() {
  18676. this.locks = Object.create({});
  18677. }
  18678. Lock.prototype.isLocked = function (item) {
  18679. return !!this.locks[item.id];
  18680. };
  18681. Lock.prototype.run = function (item, fn) {
  18682. var _this = this;
  18683. var lock = this.getLock(item);
  18684. if (lock) {
  18685. return new Promise(function (c, e) {
  18686. event_1.Event.once(lock.onDispose)(function () {
  18687. return _this.run(item, fn).then(c, e);
  18688. });
  18689. });
  18690. }
  18691. var result;
  18692. return new Promise(function (c, e) {
  18693. if (item.isDisposed()) {
  18694. return e(new Error('Item is disposed.'));
  18695. }
  18696. var lock = _this.locks[item.id] = new LockData(item);
  18697. result = fn().then(function (r) {
  18698. delete _this.locks[item.id];
  18699. lock.dispose();
  18700. return r;
  18701. }).then(c, e);
  18702. return result;
  18703. });
  18704. };
  18705. Lock.prototype.getLock = function (item) {
  18706. var key;
  18707. for (key in this.locks) {
  18708. var lock = this.locks[key];
  18709. if (item.intersects(lock.item)) {
  18710. return lock;
  18711. }
  18712. }
  18713. return null;
  18714. };
  18715. return Lock;
  18716. }());
  18717. exports.Lock = Lock;
  18718. var ItemRegistry = /** @class */ (function () {
  18719. function ItemRegistry() {
  18720. this._isDisposed = false;
  18721. this._onDidRevealItem = new event_1.EventMultiplexer();
  18722. this.onDidRevealItem = this._onDidRevealItem.event;
  18723. this._onExpandItem = new event_1.EventMultiplexer();
  18724. this.onExpandItem = this._onExpandItem.event;
  18725. this._onDidExpandItem = new event_1.EventMultiplexer();
  18726. this.onDidExpandItem = this._onDidExpandItem.event;
  18727. this._onCollapseItem = new event_1.EventMultiplexer();
  18728. this.onCollapseItem = this._onCollapseItem.event;
  18729. this._onDidCollapseItem = new event_1.EventMultiplexer();
  18730. this.onDidCollapseItem = this._onDidCollapseItem.event;
  18731. this._onDidAddTraitItem = new event_1.EventMultiplexer();
  18732. this.onDidAddTraitItem = this._onDidAddTraitItem.event;
  18733. this._onDidRemoveTraitItem = new event_1.EventMultiplexer();
  18734. this.onDidRemoveTraitItem = this._onDidRemoveTraitItem.event;
  18735. this._onDidRefreshItem = new event_1.EventMultiplexer();
  18736. this.onDidRefreshItem = this._onDidRefreshItem.event;
  18737. this._onRefreshItemChildren = new event_1.EventMultiplexer();
  18738. this.onRefreshItemChildren = this._onRefreshItemChildren.event;
  18739. this._onDidRefreshItemChildren = new event_1.EventMultiplexer();
  18740. this.onDidRefreshItemChildren = this._onDidRefreshItemChildren.event;
  18741. this._onDidDisposeItem = new event_1.EventMultiplexer();
  18742. this.onDidDisposeItem = this._onDidDisposeItem.event;
  18743. this.items = {};
  18744. }
  18745. ItemRegistry.prototype.register = function (item) {
  18746. Assert.ok(!this.isRegistered(item.id), 'item already registered: ' + item.id);
  18747. var disposable = lifecycle_1.combinedDisposable(this._onDidRevealItem.add(item.onDidReveal), this._onExpandItem.add(item.onExpand), this._onDidExpandItem.add(item.onDidExpand), this._onCollapseItem.add(item.onCollapse), this._onDidCollapseItem.add(item.onDidCollapse), this._onDidAddTraitItem.add(item.onDidAddTrait), this._onDidRemoveTraitItem.add(item.onDidRemoveTrait), this._onDidRefreshItem.add(item.onDidRefresh), this._onRefreshItemChildren.add(item.onRefreshChildren), this._onDidRefreshItemChildren.add(item.onDidRefreshChildren), this._onDidDisposeItem.add(item.onDidDispose));
  18748. this.items[item.id] = { item: item, disposable: disposable };
  18749. };
  18750. ItemRegistry.prototype.deregister = function (item) {
  18751. Assert.ok(this.isRegistered(item.id), 'item not registered: ' + item.id);
  18752. this.items[item.id].disposable.dispose();
  18753. delete this.items[item.id];
  18754. };
  18755. ItemRegistry.prototype.isRegistered = function (id) {
  18756. return this.items.hasOwnProperty(id);
  18757. };
  18758. ItemRegistry.prototype.getItem = function (id) {
  18759. var result = this.items[id];
  18760. return result ? result.item : null;
  18761. };
  18762. ItemRegistry.prototype.dispose = function () {
  18763. this.items = {};
  18764. this._onDidRevealItem.dispose();
  18765. this._onExpandItem.dispose();
  18766. this._onDidExpandItem.dispose();
  18767. this._onCollapseItem.dispose();
  18768. this._onDidCollapseItem.dispose();
  18769. this._onDidAddTraitItem.dispose();
  18770. this._onDidRemoveTraitItem.dispose();
  18771. this._onDidRefreshItem.dispose();
  18772. this._onRefreshItemChildren.dispose();
  18773. this._onDidRefreshItemChildren.dispose();
  18774. this._isDisposed = true;
  18775. };
  18776. ItemRegistry.prototype.isDisposed = function () {
  18777. return this._isDisposed;
  18778. };
  18779. return ItemRegistry;
  18780. }());
  18781. exports.ItemRegistry = ItemRegistry;
  18782. var Item = /** @class */ (function () {
  18783. function Item(id, registry, context, lock, element) {
  18784. this._onDidCreate = new event_1.Emitter();
  18785. this._onDidReveal = new event_1.Emitter();
  18786. this.onDidReveal = this._onDidReveal.event;
  18787. this._onExpand = new event_1.Emitter();
  18788. this.onExpand = this._onExpand.event;
  18789. this._onDidExpand = new event_1.Emitter();
  18790. this.onDidExpand = this._onDidExpand.event;
  18791. this._onCollapse = new event_1.Emitter();
  18792. this.onCollapse = this._onCollapse.event;
  18793. this._onDidCollapse = new event_1.Emitter();
  18794. this.onDidCollapse = this._onDidCollapse.event;
  18795. this._onDidAddTrait = new event_1.Emitter();
  18796. this.onDidAddTrait = this._onDidAddTrait.event;
  18797. this._onDidRemoveTrait = new event_1.Emitter();
  18798. this.onDidRemoveTrait = this._onDidRemoveTrait.event;
  18799. this._onDidRefresh = new event_1.Emitter();
  18800. this.onDidRefresh = this._onDidRefresh.event;
  18801. this._onRefreshChildren = new event_1.Emitter();
  18802. this.onRefreshChildren = this._onRefreshChildren.event;
  18803. this._onDidRefreshChildren = new event_1.Emitter();
  18804. this.onDidRefreshChildren = this._onDidRefreshChildren.event;
  18805. this._onDidDispose = new event_1.Emitter();
  18806. this.onDidDispose = this._onDidDispose.event;
  18807. this.registry = registry;
  18808. this.context = context;
  18809. this.lock = lock;
  18810. this.element = element;
  18811. this.id = id;
  18812. this.registry.register(this);
  18813. this.doesHaveChildren = this.context.dataSource.hasChildren(this.context.tree, this.element);
  18814. this.needsChildrenRefresh = true;
  18815. this.parent = null;
  18816. this.previous = null;
  18817. this.next = null;
  18818. this.firstChild = null;
  18819. this.lastChild = null;
  18820. this.traits = {};
  18821. this.depth = 0;
  18822. this.expanded = !!(this.context.dataSource.shouldAutoexpand && this.context.dataSource.shouldAutoexpand(this.context.tree, element));
  18823. this._onDidCreate.fire(this);
  18824. this.visible = this._isVisible();
  18825. this.height = this._getHeight();
  18826. this._isDisposed = false;
  18827. }
  18828. Item.prototype.getElement = function () {
  18829. return this.element;
  18830. };
  18831. Item.prototype.hasChildren = function () {
  18832. return this.doesHaveChildren;
  18833. };
  18834. Item.prototype.getDepth = function () {
  18835. return this.depth;
  18836. };
  18837. Item.prototype.isVisible = function () {
  18838. return this.visible;
  18839. };
  18840. Item.prototype.setVisible = function (value) {
  18841. this.visible = value;
  18842. };
  18843. Item.prototype.isExpanded = function () {
  18844. return this.expanded;
  18845. };
  18846. /* protected */ Item.prototype._setExpanded = function (value) {
  18847. this.expanded = value;
  18848. };
  18849. Item.prototype.reveal = function (relativeTop) {
  18850. if (relativeTop === void 0) { relativeTop = null; }
  18851. var eventData = { item: this, relativeTop: relativeTop };
  18852. this._onDidReveal.fire(eventData);
  18853. };
  18854. Item.prototype.expand = function () {
  18855. var _this = this;
  18856. if (this.isExpanded() || !this.doesHaveChildren || this.lock.isLocked(this)) {
  18857. return Promise.resolve(false);
  18858. }
  18859. var result = this.lock.run(this, function () {
  18860. if (_this.isExpanded() || !_this.doesHaveChildren) {
  18861. return Promise.resolve(false);
  18862. }
  18863. var eventData = { item: _this };
  18864. var result;
  18865. _this._onExpand.fire(eventData);
  18866. if (_this.needsChildrenRefresh) {
  18867. result = _this.refreshChildren(false, true, true);
  18868. }
  18869. else {
  18870. result = Promise.resolve(null);
  18871. }
  18872. return result.then(function () {
  18873. _this._setExpanded(true);
  18874. _this._onDidExpand.fire(eventData);
  18875. return true;
  18876. });
  18877. });
  18878. return result.then(function (r) {
  18879. if (_this.isDisposed()) {
  18880. return false;
  18881. }
  18882. // Auto expand single child folders
  18883. if (_this.context.options.autoExpandSingleChildren && r && _this.firstChild !== null && _this.firstChild === _this.lastChild && _this.firstChild.isVisible()) {
  18884. return _this.firstChild.expand().then(function () { return true; });
  18885. }
  18886. return r;
  18887. });
  18888. };
  18889. Item.prototype.collapse = function (recursive) {
  18890. var _this = this;
  18891. if (recursive === void 0) { recursive = false; }
  18892. if (recursive) {
  18893. var collapseChildrenPromise_1 = Promise.resolve(null);
  18894. this.forEachChild(function (child) {
  18895. collapseChildrenPromise_1 = collapseChildrenPromise_1.then(function () { return child.collapse(true); });
  18896. });
  18897. return collapseChildrenPromise_1.then(function () {
  18898. return _this.collapse(false);
  18899. });
  18900. }
  18901. else {
  18902. if (!this.isExpanded() || this.lock.isLocked(this)) {
  18903. return Promise.resolve(false);
  18904. }
  18905. return this.lock.run(this, function () {
  18906. var eventData = { item: _this };
  18907. _this._onCollapse.fire(eventData);
  18908. _this._setExpanded(false);
  18909. _this._onDidCollapse.fire(eventData);
  18910. return Promise.resolve(true);
  18911. });
  18912. }
  18913. };
  18914. Item.prototype.addTrait = function (trait) {
  18915. var eventData = { item: this, trait: trait };
  18916. this.traits[trait] = true;
  18917. this._onDidAddTrait.fire(eventData);
  18918. };
  18919. Item.prototype.removeTrait = function (trait) {
  18920. var eventData = { item: this, trait: trait };
  18921. delete this.traits[trait];
  18922. this._onDidRemoveTrait.fire(eventData);
  18923. };
  18924. Item.prototype.hasTrait = function (trait) {
  18925. return this.traits[trait] || false;
  18926. };
  18927. Item.prototype.getAllTraits = function () {
  18928. var result = [];
  18929. var trait;
  18930. for (trait in this.traits) {
  18931. if (this.traits.hasOwnProperty(trait) && this.traits[trait]) {
  18932. result.push(trait);
  18933. }
  18934. }
  18935. return result;
  18936. };
  18937. Item.prototype.getHeight = function () {
  18938. return this.height;
  18939. };
  18940. Item.prototype.refreshChildren = function (recursive, safe, force) {
  18941. var _this = this;
  18942. if (safe === void 0) { safe = false; }
  18943. if (force === void 0) { force = false; }
  18944. if (!force && !this.isExpanded()) {
  18945. var setNeedsChildrenRefresh_1 = function (item) {
  18946. item.needsChildrenRefresh = true;
  18947. item.forEachChild(setNeedsChildrenRefresh_1);
  18948. };
  18949. setNeedsChildrenRefresh_1(this);
  18950. return Promise.resolve(this);
  18951. }
  18952. this.needsChildrenRefresh = false;
  18953. var doRefresh = function () {
  18954. var eventData = { item: _this, isNested: safe };
  18955. _this._onRefreshChildren.fire(eventData);
  18956. var childrenPromise;
  18957. if (_this.doesHaveChildren) {
  18958. childrenPromise = _this.context.dataSource.getChildren(_this.context.tree, _this.element);
  18959. }
  18960. else {
  18961. childrenPromise = Promise.resolve([]);
  18962. }
  18963. var result = childrenPromise.then(function (elements) {
  18964. if (_this.isDisposed() || _this.registry.isDisposed()) {
  18965. return Promise.resolve(null);
  18966. }
  18967. if (!Array.isArray(elements)) {
  18968. return Promise.reject(new Error('Please return an array of children.'));
  18969. }
  18970. elements = !elements ? [] : elements.slice(0);
  18971. elements = _this.sort(elements);
  18972. var staleItems = {};
  18973. while (_this.firstChild !== null) {
  18974. staleItems[_this.firstChild.id] = _this.firstChild;
  18975. _this.removeChild(_this.firstChild);
  18976. }
  18977. for (var i = 0, len = elements.length; i < len; i++) {
  18978. var element = elements[i];
  18979. var id = _this.context.dataSource.getId(_this.context.tree, element);
  18980. var item = staleItems[id] || new Item(id, _this.registry, _this.context, _this.lock, element);
  18981. item.element = element;
  18982. if (recursive) {
  18983. item.needsChildrenRefresh = recursive;
  18984. }
  18985. delete staleItems[id];
  18986. _this.addChild(item);
  18987. }
  18988. for (var staleItemId in staleItems) {
  18989. if (staleItems.hasOwnProperty(staleItemId)) {
  18990. staleItems[staleItemId].dispose();
  18991. }
  18992. }
  18993. if (recursive) {
  18994. return Promise.all(_this.mapEachChild(function (child) {
  18995. return child.doRefresh(recursive, true);
  18996. }));
  18997. }
  18998. else {
  18999. return Promise.all(_this.mapEachChild(function (child) {
  19000. if (child.isExpanded() && child.needsChildrenRefresh) {
  19001. return child.doRefresh(recursive, true);
  19002. }
  19003. else {
  19004. child.updateVisibility();
  19005. return Promise.resolve(null);
  19006. }
  19007. }));
  19008. }
  19009. });
  19010. return result
  19011. .then(undefined, errors_1.onUnexpectedError)
  19012. .then(function () { return _this._onDidRefreshChildren.fire(eventData); });
  19013. };
  19014. return safe ? doRefresh() : this.lock.run(this, doRefresh);
  19015. };
  19016. Item.prototype.doRefresh = function (recursive, safe) {
  19017. if (safe === void 0) { safe = false; }
  19018. this.doesHaveChildren = this.context.dataSource.hasChildren(this.context.tree, this.element);
  19019. this.height = this._getHeight();
  19020. this.updateVisibility();
  19021. this._onDidRefresh.fire(this);
  19022. return this.refreshChildren(recursive, safe);
  19023. };
  19024. Item.prototype.updateVisibility = function () {
  19025. this.setVisible(this._isVisible());
  19026. };
  19027. Item.prototype.refresh = function (recursive) {
  19028. return this.doRefresh(recursive);
  19029. };
  19030. Item.prototype.getNavigator = function () {
  19031. return new TreeNavigator(this);
  19032. };
  19033. Item.prototype.intersects = function (other) {
  19034. return this.isAncestorOf(other) || other.isAncestorOf(this);
  19035. };
  19036. Item.prototype.isAncestorOf = function (startItem) {
  19037. var item = startItem;
  19038. while (item) {
  19039. if (item.id === this.id) {
  19040. return true;
  19041. }
  19042. item = item.parent;
  19043. }
  19044. return false;
  19045. };
  19046. Item.prototype.addChild = function (item, afterItem) {
  19047. if (afterItem === void 0) { afterItem = this.lastChild; }
  19048. var isEmpty = this.firstChild === null;
  19049. var atHead = afterItem === null;
  19050. var atTail = afterItem === this.lastChild;
  19051. if (isEmpty) {
  19052. this.firstChild = this.lastChild = item;
  19053. item.next = item.previous = null;
  19054. }
  19055. else if (atHead) {
  19056. if (!this.firstChild) {
  19057. throw new Error('Invalid tree state');
  19058. }
  19059. this.firstChild.previous = item;
  19060. item.next = this.firstChild;
  19061. item.previous = null;
  19062. this.firstChild = item;
  19063. }
  19064. else if (atTail) {
  19065. if (!this.lastChild) {
  19066. throw new Error('Invalid tree state');
  19067. }
  19068. this.lastChild.next = item;
  19069. item.next = null;
  19070. item.previous = this.lastChild;
  19071. this.lastChild = item;
  19072. }
  19073. else {
  19074. item.previous = afterItem;
  19075. if (!afterItem) {
  19076. throw new Error('Invalid tree state');
  19077. }
  19078. item.next = afterItem.next;
  19079. if (!afterItem.next) {
  19080. throw new Error('Invalid tree state');
  19081. }
  19082. afterItem.next.previous = item;
  19083. afterItem.next = item;
  19084. }
  19085. item.parent = this;
  19086. item.depth = this.depth + 1;
  19087. };
  19088. Item.prototype.removeChild = function (item) {
  19089. var isFirstChild = this.firstChild === item;
  19090. var isLastChild = this.lastChild === item;
  19091. if (isFirstChild && isLastChild) {
  19092. this.firstChild = this.lastChild = null;
  19093. }
  19094. else if (isFirstChild) {
  19095. if (!item.next) {
  19096. throw new Error('Invalid tree state');
  19097. }
  19098. item.next.previous = null;
  19099. this.firstChild = item.next;
  19100. }
  19101. else if (isLastChild) {
  19102. if (!item.previous) {
  19103. throw new Error('Invalid tree state');
  19104. }
  19105. item.previous.next = null;
  19106. this.lastChild = item.previous;
  19107. }
  19108. else {
  19109. if (!item.next) {
  19110. throw new Error('Invalid tree state');
  19111. }
  19112. item.next.previous = item.previous;
  19113. if (!item.previous) {
  19114. throw new Error('Invalid tree state');
  19115. }
  19116. item.previous.next = item.next;
  19117. }
  19118. item.parent = null;
  19119. item.depth = NaN;
  19120. };
  19121. Item.prototype.forEachChild = function (fn) {
  19122. var child = this.firstChild;
  19123. var next;
  19124. while (child) {
  19125. next = child.next;
  19126. fn(child);
  19127. child = next;
  19128. }
  19129. };
  19130. Item.prototype.mapEachChild = function (fn) {
  19131. var result = [];
  19132. this.forEachChild(function (child) {
  19133. result.push(fn(child));
  19134. });
  19135. return result;
  19136. };
  19137. Item.prototype.sort = function (elements) {
  19138. var _this = this;
  19139. var sorter = this.context.sorter;
  19140. if (sorter) {
  19141. return elements.sort(function (element, otherElement) {
  19142. return sorter.compare(_this.context.tree, element, otherElement);
  19143. });
  19144. }
  19145. return elements;
  19146. };
  19147. /* protected */ Item.prototype._getHeight = function () {
  19148. if (!this.context.renderer) {
  19149. return 0;
  19150. }
  19151. return this.context.renderer.getHeight(this.context.tree, this.element);
  19152. };
  19153. /* protected */ Item.prototype._isVisible = function () {
  19154. if (!this.context.filter) {
  19155. return false;
  19156. }
  19157. return this.context.filter.isVisible(this.context.tree, this.element);
  19158. };
  19159. Item.prototype.isDisposed = function () {
  19160. return this._isDisposed;
  19161. };
  19162. Item.prototype.dispose = function () {
  19163. this.forEachChild(function (child) { return child.dispose(); });
  19164. this.parent = null;
  19165. this.previous = null;
  19166. this.next = null;
  19167. this.firstChild = null;
  19168. this.lastChild = null;
  19169. this._onDidDispose.fire(this);
  19170. this.registry.deregister(this);
  19171. this._onDidCreate.dispose();
  19172. this._onDidReveal.dispose();
  19173. this._onExpand.dispose();
  19174. this._onDidExpand.dispose();
  19175. this._onCollapse.dispose();
  19176. this._onDidCollapse.dispose();
  19177. this._onDidAddTrait.dispose();
  19178. this._onDidRemoveTrait.dispose();
  19179. this._onDidRefresh.dispose();
  19180. this._onRefreshChildren.dispose();
  19181. this._onDidRefreshChildren.dispose();
  19182. this._onDidDispose.dispose();
  19183. this._isDisposed = true;
  19184. };
  19185. return Item;
  19186. }());
  19187. exports.Item = Item;
  19188. var RootItem = /** @class */ (function (_super) {
  19189. __extends(RootItem, _super);
  19190. function RootItem(id, registry, context, lock, element) {
  19191. return _super.call(this, id, registry, context, lock, element) || this;
  19192. }
  19193. RootItem.prototype.isVisible = function () {
  19194. return false;
  19195. };
  19196. RootItem.prototype.setVisible = function (value) {
  19197. // no-op
  19198. };
  19199. RootItem.prototype.isExpanded = function () {
  19200. return true;
  19201. };
  19202. /* protected */ RootItem.prototype._setExpanded = function (value) {
  19203. // no-op
  19204. };
  19205. /* protected */ RootItem.prototype._getHeight = function () {
  19206. return 0;
  19207. };
  19208. /* protected */ RootItem.prototype._isVisible = function () {
  19209. return false;
  19210. };
  19211. return RootItem;
  19212. }(Item));
  19213. var TreeNavigator = /** @class */ (function () {
  19214. function TreeNavigator(item, subTreeOnly) {
  19215. if (subTreeOnly === void 0) { subTreeOnly = true; }
  19216. this.item = item;
  19217. this.start = subTreeOnly ? item : null;
  19218. }
  19219. TreeNavigator.lastDescendantOf = function (item) {
  19220. if (!item) {
  19221. return null;
  19222. }
  19223. if (item instanceof RootItem) {
  19224. return TreeNavigator.lastDescendantOf(item.lastChild);
  19225. }
  19226. if (!item.isVisible()) {
  19227. return TreeNavigator.lastDescendantOf(item.previous);
  19228. }
  19229. if (!item.isExpanded() || item.lastChild === null) {
  19230. return item;
  19231. }
  19232. return TreeNavigator.lastDescendantOf(item.lastChild);
  19233. };
  19234. TreeNavigator.prototype.current = function () {
  19235. return this.item || null;
  19236. };
  19237. TreeNavigator.prototype.next = function () {
  19238. if (this.item) {
  19239. do {
  19240. if ((this.item instanceof RootItem || (this.item.isVisible() && this.item.isExpanded())) && this.item.firstChild) {
  19241. this.item = this.item.firstChild;
  19242. }
  19243. else if (this.item === this.start) {
  19244. this.item = null;
  19245. }
  19246. else {
  19247. // select next brother, next uncle, next great-uncle, etc...
  19248. while (this.item && this.item !== this.start && !this.item.next) {
  19249. this.item = this.item.parent;
  19250. }
  19251. if (this.item === this.start) {
  19252. this.item = null;
  19253. }
  19254. this.item = !this.item ? null : this.item.next;
  19255. }
  19256. } while (this.item && !this.item.isVisible());
  19257. }
  19258. return this.item || null;
  19259. };
  19260. TreeNavigator.prototype.previous = function () {
  19261. if (this.item) {
  19262. do {
  19263. var previous = TreeNavigator.lastDescendantOf(this.item.previous);
  19264. if (previous) {
  19265. this.item = previous;
  19266. }
  19267. else if (this.item.parent && this.item.parent !== this.start && this.item.parent.isVisible()) {
  19268. this.item = this.item.parent;
  19269. }
  19270. else {
  19271. this.item = null;
  19272. }
  19273. } while (this.item && !this.item.isVisible());
  19274. }
  19275. return this.item || null;
  19276. };
  19277. TreeNavigator.prototype.parent = function () {
  19278. if (this.item) {
  19279. var parent_1 = this.item.parent;
  19280. if (parent_1 && parent_1 !== this.start && parent_1.isVisible()) {
  19281. this.item = parent_1;
  19282. }
  19283. else {
  19284. this.item = null;
  19285. }
  19286. }
  19287. return this.item || null;
  19288. };
  19289. TreeNavigator.prototype.first = function () {
  19290. this.item = this.start;
  19291. this.next();
  19292. return this.item || null;
  19293. };
  19294. TreeNavigator.prototype.last = function () {
  19295. return TreeNavigator.lastDescendantOf(this.start);
  19296. };
  19297. return TreeNavigator;
  19298. }());
  19299. exports.TreeNavigator = TreeNavigator;
  19300. var TreeModel = /** @class */ (function () {
  19301. function TreeModel(context) {
  19302. this.registry = new ItemRegistry();
  19303. this.registryDisposable = lifecycle_1.Disposable.None;
  19304. this._onSetInput = new event_1.Emitter();
  19305. this.onSetInput = this._onSetInput.event;
  19306. this._onDidSetInput = new event_1.Emitter();
  19307. this.onDidSetInput = this._onDidSetInput.event;
  19308. this._onRefresh = new event_1.Emitter();
  19309. this.onRefresh = this._onRefresh.event;
  19310. this._onDidRefresh = new event_1.Emitter();
  19311. this.onDidRefresh = this._onDidRefresh.event;
  19312. this._onDidHighlight = new event_1.Emitter();
  19313. this.onDidHighlight = this._onDidHighlight.event;
  19314. this._onDidSelect = new event_1.Emitter();
  19315. this.onDidSelect = this._onDidSelect.event;
  19316. this._onDidFocus = new event_1.Emitter();
  19317. this.onDidFocus = this._onDidFocus.event;
  19318. this._onDidRevealItem = new event_1.Relay();
  19319. this.onDidRevealItem = this._onDidRevealItem.event;
  19320. this._onExpandItem = new event_1.Relay();
  19321. this.onExpandItem = this._onExpandItem.event;
  19322. this._onDidExpandItem = new event_1.Relay();
  19323. this.onDidExpandItem = this._onDidExpandItem.event;
  19324. this._onCollapseItem = new event_1.Relay();
  19325. this.onCollapseItem = this._onCollapseItem.event;
  19326. this._onDidCollapseItem = new event_1.Relay();
  19327. this.onDidCollapseItem = this._onDidCollapseItem.event;
  19328. this._onDidAddTraitItem = new event_1.Relay();
  19329. this.onDidAddTraitItem = this._onDidAddTraitItem.event;
  19330. this._onDidRemoveTraitItem = new event_1.Relay();
  19331. this.onDidRemoveTraitItem = this._onDidRemoveTraitItem.event;
  19332. this._onDidRefreshItem = new event_1.Relay();
  19333. this.onDidRefreshItem = this._onDidRefreshItem.event;
  19334. this._onRefreshItemChildren = new event_1.Relay();
  19335. this.onRefreshItemChildren = this._onRefreshItemChildren.event;
  19336. this._onDidRefreshItemChildren = new event_1.Relay();
  19337. this.onDidRefreshItemChildren = this._onDidRefreshItemChildren.event;
  19338. this._onDidDisposeItem = new event_1.Relay();
  19339. this.context = context;
  19340. this.input = null;
  19341. this.traitsToItems = {};
  19342. }
  19343. TreeModel.prototype.setInput = function (element) {
  19344. var _this = this;
  19345. var eventData = { item: this.input };
  19346. this._onSetInput.fire(eventData);
  19347. this.setSelection([]);
  19348. this.setFocus();
  19349. this.setHighlight();
  19350. this.lock = new Lock();
  19351. if (this.input) {
  19352. this.input.dispose();
  19353. }
  19354. if (this.registry) {
  19355. this.registry.dispose();
  19356. this.registryDisposable.dispose();
  19357. }
  19358. this.registry = new ItemRegistry();
  19359. this._onDidRevealItem.input = this.registry.onDidRevealItem;
  19360. this._onExpandItem.input = this.registry.onExpandItem;
  19361. this._onDidExpandItem.input = this.registry.onDidExpandItem;
  19362. this._onCollapseItem.input = this.registry.onCollapseItem;
  19363. this._onDidCollapseItem.input = this.registry.onDidCollapseItem;
  19364. this._onDidAddTraitItem.input = this.registry.onDidAddTraitItem;
  19365. this._onDidRemoveTraitItem.input = this.registry.onDidRemoveTraitItem;
  19366. this._onDidRefreshItem.input = this.registry.onDidRefreshItem;
  19367. this._onRefreshItemChildren.input = this.registry.onRefreshItemChildren;
  19368. this._onDidRefreshItemChildren.input = this.registry.onDidRefreshItemChildren;
  19369. this._onDidDisposeItem.input = this.registry.onDidDisposeItem;
  19370. this.registryDisposable = this.registry
  19371. .onDidDisposeItem(function (item) { return item.getAllTraits().forEach(function (trait) { return delete _this.traitsToItems[trait][item.id]; }); });
  19372. var id = this.context.dataSource.getId(this.context.tree, element);
  19373. this.input = new RootItem(id, this.registry, this.context, this.lock, element);
  19374. eventData = { item: this.input };
  19375. this._onDidSetInput.fire(eventData);
  19376. return this.refresh(this.input);
  19377. };
  19378. TreeModel.prototype.getInput = function () {
  19379. return this.input ? this.input.getElement() : null;
  19380. };
  19381. TreeModel.prototype.refresh = function (element, recursive) {
  19382. var _this = this;
  19383. if (element === void 0) { element = null; }
  19384. if (recursive === void 0) { recursive = true; }
  19385. var item = this.getItem(element);
  19386. if (!item) {
  19387. return Promise.resolve(null);
  19388. }
  19389. var eventData = { item: item, recursive: recursive };
  19390. this._onRefresh.fire(eventData);
  19391. return item.refresh(recursive).then(function () {
  19392. _this._onDidRefresh.fire(eventData);
  19393. });
  19394. };
  19395. TreeModel.prototype.expand = function (element) {
  19396. var item = this.getItem(element);
  19397. if (!item) {
  19398. return Promise.resolve(false);
  19399. }
  19400. return item.expand();
  19401. };
  19402. TreeModel.prototype.collapse = function (element, recursive) {
  19403. if (recursive === void 0) { recursive = false; }
  19404. var item = this.getItem(element);
  19405. if (!item) {
  19406. return Promise.resolve(false);
  19407. }
  19408. return item.collapse(recursive);
  19409. };
  19410. TreeModel.prototype.toggleExpansion = function (element, recursive) {
  19411. if (recursive === void 0) { recursive = false; }
  19412. return this.isExpanded(element) ? this.collapse(element, recursive) : this.expand(element);
  19413. };
  19414. TreeModel.prototype.isExpanded = function (element) {
  19415. var item = this.getItem(element);
  19416. if (!item) {
  19417. return false;
  19418. }
  19419. return item.isExpanded();
  19420. };
  19421. TreeModel.prototype.reveal = function (element, relativeTop) {
  19422. var _this = this;
  19423. if (relativeTop === void 0) { relativeTop = null; }
  19424. return this.resolveUnknownParentChain(element).then(function (chain) {
  19425. var result = Promise.resolve(null);
  19426. chain.forEach(function (e) {
  19427. result = result.then(function () { return _this.expand(e); });
  19428. });
  19429. return result;
  19430. }).then(function () {
  19431. var item = _this.getItem(element);
  19432. if (item) {
  19433. return item.reveal(relativeTop);
  19434. }
  19435. });
  19436. };
  19437. TreeModel.prototype.resolveUnknownParentChain = function (element) {
  19438. var _this = this;
  19439. return this.context.dataSource.getParent(this.context.tree, element).then(function (parent) {
  19440. if (!parent) {
  19441. return Promise.resolve([]);
  19442. }
  19443. return _this.resolveUnknownParentChain(parent).then(function (result) {
  19444. result.push(parent);
  19445. return result;
  19446. });
  19447. });
  19448. };
  19449. TreeModel.prototype.setHighlight = function (element, eventPayload) {
  19450. this.setTraits('highlighted', element ? [element] : []);
  19451. var eventData = { highlight: this.getHighlight(), payload: eventPayload };
  19452. this._onDidHighlight.fire(eventData);
  19453. };
  19454. TreeModel.prototype.getHighlight = function (includeHidden) {
  19455. if (includeHidden === void 0) { includeHidden = false; }
  19456. var result = this.getElementsWithTrait('highlighted', includeHidden);
  19457. return result.length === 0 ? null : result[0];
  19458. };
  19459. TreeModel.prototype.setSelection = function (elements, eventPayload) {
  19460. this.setTraits('selected', elements);
  19461. var eventData = { selection: this.getSelection(), payload: eventPayload };
  19462. this._onDidSelect.fire(eventData);
  19463. };
  19464. TreeModel.prototype.getSelection = function (includeHidden) {
  19465. if (includeHidden === void 0) { includeHidden = false; }
  19466. return this.getElementsWithTrait('selected', includeHidden);
  19467. };
  19468. TreeModel.prototype.setFocus = function (element, eventPayload) {
  19469. this.setTraits('focused', element ? [element] : []);
  19470. var eventData = { focus: this.getFocus(), payload: eventPayload };
  19471. this._onDidFocus.fire(eventData);
  19472. };
  19473. TreeModel.prototype.getFocus = function (includeHidden) {
  19474. if (includeHidden === void 0) { includeHidden = false; }
  19475. var result = this.getElementsWithTrait('focused', includeHidden);
  19476. return result.length === 0 ? null : result[0];
  19477. };
  19478. TreeModel.prototype.focusNext = function (count, eventPayload) {
  19479. if (count === void 0) { count = 1; }
  19480. var item = this.getFocus() || this.input;
  19481. var nextItem;
  19482. var nav = this.getNavigator(item, false);
  19483. for (var i = 0; i < count; i++) {
  19484. nextItem = nav.next();
  19485. if (!nextItem) {
  19486. break;
  19487. }
  19488. item = nextItem;
  19489. }
  19490. this.setFocus(item, eventPayload);
  19491. };
  19492. TreeModel.prototype.focusPrevious = function (count, eventPayload) {
  19493. if (count === void 0) { count = 1; }
  19494. var item = this.getFocus() || this.input;
  19495. var previousItem;
  19496. var nav = this.getNavigator(item, false);
  19497. for (var i = 0; i < count; i++) {
  19498. previousItem = nav.previous();
  19499. if (!previousItem) {
  19500. break;
  19501. }
  19502. item = previousItem;
  19503. }
  19504. this.setFocus(item, eventPayload);
  19505. };
  19506. TreeModel.prototype.focusParent = function (eventPayload) {
  19507. var item = this.getFocus() || this.input;
  19508. var nav = this.getNavigator(item, false);
  19509. var parent = nav.parent();
  19510. if (parent) {
  19511. this.setFocus(parent, eventPayload);
  19512. }
  19513. };
  19514. TreeModel.prototype.focusFirstChild = function (eventPayload) {
  19515. var item = this.getItem(this.getFocus() || this.input);
  19516. var nav = this.getNavigator(item, false);
  19517. var next = nav.next();
  19518. var parent = nav.parent();
  19519. if (parent === item) {
  19520. this.setFocus(next, eventPayload);
  19521. }
  19522. };
  19523. TreeModel.prototype.focusFirst = function (eventPayload, from) {
  19524. this.focusNth(0, eventPayload, from);
  19525. };
  19526. TreeModel.prototype.focusNth = function (index, eventPayload, from) {
  19527. var navItem = this.getParent(from);
  19528. var nav = this.getNavigator(navItem);
  19529. var item = nav.first();
  19530. for (var i = 0; i < index; i++) {
  19531. item = nav.next();
  19532. }
  19533. if (item) {
  19534. this.setFocus(item, eventPayload);
  19535. }
  19536. };
  19537. TreeModel.prototype.focusLast = function (eventPayload, from) {
  19538. var navItem = this.getParent(from);
  19539. var item;
  19540. if (from && navItem) {
  19541. item = navItem.lastChild;
  19542. }
  19543. else {
  19544. var nav = this.getNavigator(navItem);
  19545. item = nav.last();
  19546. }
  19547. if (item) {
  19548. this.setFocus(item, eventPayload);
  19549. }
  19550. };
  19551. TreeModel.prototype.getParent = function (from) {
  19552. if (from) {
  19553. var fromItem = this.getItem(from);
  19554. if (fromItem && fromItem.parent) {
  19555. return fromItem.parent;
  19556. }
  19557. }
  19558. return this.getItem(this.input);
  19559. };
  19560. TreeModel.prototype.getNavigator = function (element, subTreeOnly) {
  19561. if (element === void 0) { element = null; }
  19562. if (subTreeOnly === void 0) { subTreeOnly = true; }
  19563. return new TreeNavigator(this.getItem(element), subTreeOnly);
  19564. };
  19565. TreeModel.prototype.getItem = function (element) {
  19566. if (element === void 0) { element = null; }
  19567. if (element === null) {
  19568. return this.input;
  19569. }
  19570. else if (element instanceof Item) {
  19571. return element;
  19572. }
  19573. else if (typeof element === 'string') {
  19574. return this.registry.getItem(element);
  19575. }
  19576. else {
  19577. return this.registry.getItem(this.context.dataSource.getId(this.context.tree, element));
  19578. }
  19579. };
  19580. TreeModel.prototype.removeTraits = function (trait, elements) {
  19581. var items = this.traitsToItems[trait] || {};
  19582. var item;
  19583. var id;
  19584. if (elements.length === 0) {
  19585. for (id in items) {
  19586. if (items.hasOwnProperty(id)) {
  19587. item = items[id];
  19588. item.removeTrait(trait);
  19589. }
  19590. }
  19591. delete this.traitsToItems[trait];
  19592. }
  19593. else {
  19594. for (var i = 0, len = elements.length; i < len; i++) {
  19595. item = this.getItem(elements[i]);
  19596. if (item) {
  19597. item.removeTrait(trait);
  19598. delete items[item.id];
  19599. }
  19600. }
  19601. }
  19602. };
  19603. TreeModel.prototype.setTraits = function (trait, elements) {
  19604. if (elements.length === 0) {
  19605. this.removeTraits(trait, elements);
  19606. }
  19607. else {
  19608. var items = {};
  19609. var item = void 0;
  19610. for (var i = 0, len = elements.length; i < len; i++) {
  19611. item = this.getItem(elements[i]);
  19612. if (item) {
  19613. items[item.id] = item;
  19614. }
  19615. }
  19616. var traitItems = this.traitsToItems[trait] || {};
  19617. var itemsToRemoveTrait = [];
  19618. var id = void 0;
  19619. for (id in traitItems) {
  19620. if (traitItems.hasOwnProperty(id)) {
  19621. if (items.hasOwnProperty(id)) {
  19622. delete items[id];
  19623. }
  19624. else {
  19625. itemsToRemoveTrait.push(traitItems[id]);
  19626. }
  19627. }
  19628. }
  19629. for (var i = 0, len = itemsToRemoveTrait.length; i < len; i++) {
  19630. item = itemsToRemoveTrait[i];
  19631. item.removeTrait(trait);
  19632. delete traitItems[item.id];
  19633. }
  19634. for (id in items) {
  19635. if (items.hasOwnProperty(id)) {
  19636. item = items[id];
  19637. item.addTrait(trait);
  19638. traitItems[id] = item;
  19639. }
  19640. }
  19641. this.traitsToItems[trait] = traitItems;
  19642. }
  19643. };
  19644. TreeModel.prototype.getElementsWithTrait = function (trait, includeHidden) {
  19645. var elements = [];
  19646. var items = this.traitsToItems[trait] || {};
  19647. var id;
  19648. for (id in items) {
  19649. if (items.hasOwnProperty(id) && (items[id].isVisible() || includeHidden)) {
  19650. elements.push(items[id].getElement());
  19651. }
  19652. }
  19653. return elements;
  19654. };
  19655. TreeModel.prototype.dispose = function () {
  19656. this.registry.dispose();
  19657. this._onSetInput.dispose();
  19658. this._onDidSetInput.dispose();
  19659. this._onRefresh.dispose();
  19660. this._onDidRefresh.dispose();
  19661. this._onDidHighlight.dispose();
  19662. this._onDidSelect.dispose();
  19663. this._onDidFocus.dispose();
  19664. this._onDidRevealItem.dispose();
  19665. this._onExpandItem.dispose();
  19666. this._onDidExpandItem.dispose();
  19667. this._onCollapseItem.dispose();
  19668. this._onDidCollapseItem.dispose();
  19669. this._onDidAddTraitItem.dispose();
  19670. this._onDidRemoveTraitItem.dispose();
  19671. this._onDidRefreshItem.dispose();
  19672. this._onRefreshItemChildren.dispose();
  19673. this._onDidRefreshItemChildren.dispose();
  19674. this._onDidDisposeItem.dispose();
  19675. };
  19676. return TreeModel;
  19677. }());
  19678. exports.TreeModel = TreeModel;
  19679. });
  19680. /*---------------------------------------------------------------------------------------------
  19681. * Copyright (c) Microsoft Corporation. All rights reserved.
  19682. * Licensed under the MIT License. See License.txt in the project root for license information.
  19683. *--------------------------------------------------------------------------------------------*/
  19684. define(__m[257/*vs/base/parts/tree/browser/treeViewModel*/], __M([0/*require*/,1/*exports*/,54/*vs/base/common/iterator*/]), function (require, exports, iterator_1) {
  19685. "use strict";
  19686. Object.defineProperty(exports, "__esModule", { value: true });
  19687. var HeightMap = /** @class */ (function () {
  19688. function HeightMap() {
  19689. this.heightMap = [];
  19690. this.indexes = {};
  19691. }
  19692. HeightMap.prototype.getContentHeight = function () {
  19693. var last = this.heightMap[this.heightMap.length - 1];
  19694. return !last ? 0 : last.top + last.height;
  19695. };
  19696. HeightMap.prototype.onInsertItems = function (iterator, afterItemId) {
  19697. if (afterItemId === void 0) { afterItemId = null; }
  19698. var item = null;
  19699. var viewItem;
  19700. var i, j;
  19701. var totalSize;
  19702. var sizeDiff = 0;
  19703. if (afterItemId === null) {
  19704. i = 0;
  19705. totalSize = 0;
  19706. }
  19707. else {
  19708. i = this.indexes[afterItemId] + 1;
  19709. viewItem = this.heightMap[i - 1];
  19710. if (!viewItem) {
  19711. console.error('view item doesnt exist');
  19712. return undefined;
  19713. }
  19714. totalSize = viewItem.top + viewItem.height;
  19715. }
  19716. var boundSplice = this.heightMap.splice.bind(this.heightMap, i, 0);
  19717. var itemsToInsert = [];
  19718. while (item = iterator.next()) {
  19719. viewItem = this.createViewItem(item);
  19720. viewItem.top = totalSize + sizeDiff;
  19721. this.indexes[item.id] = i++;
  19722. itemsToInsert.push(viewItem);
  19723. sizeDiff += viewItem.height;
  19724. }
  19725. boundSplice.apply(this.heightMap, itemsToInsert);
  19726. for (j = i; j < this.heightMap.length; j++) {
  19727. viewItem = this.heightMap[j];
  19728. viewItem.top += sizeDiff;
  19729. this.indexes[viewItem.model.id] = j;
  19730. }
  19731. for (j = itemsToInsert.length - 1; j >= 0; j--) {
  19732. this.onInsertItem(itemsToInsert[j]);
  19733. }
  19734. for (j = this.heightMap.length - 1; j >= i; j--) {
  19735. this.onRefreshItem(this.heightMap[j]);
  19736. }
  19737. return sizeDiff;
  19738. };
  19739. HeightMap.prototype.onInsertItem = function (item) {
  19740. // noop
  19741. };
  19742. // Contiguous items
  19743. HeightMap.prototype.onRemoveItems = function (iterator) {
  19744. var itemId = null;
  19745. var viewItem;
  19746. var startIndex = null;
  19747. var i = 0;
  19748. var sizeDiff = 0;
  19749. while (itemId = iterator.next()) {
  19750. i = this.indexes[itemId];
  19751. viewItem = this.heightMap[i];
  19752. if (!viewItem) {
  19753. console.error('view item doesnt exist');
  19754. return;
  19755. }
  19756. sizeDiff -= viewItem.height;
  19757. delete this.indexes[itemId];
  19758. this.onRemoveItem(viewItem);
  19759. if (startIndex === null) {
  19760. startIndex = i;
  19761. }
  19762. }
  19763. if (sizeDiff === 0 || startIndex === null) {
  19764. return;
  19765. }
  19766. this.heightMap.splice(startIndex, i - startIndex + 1);
  19767. for (i = startIndex; i < this.heightMap.length; i++) {
  19768. viewItem = this.heightMap[i];
  19769. viewItem.top += sizeDiff;
  19770. this.indexes[viewItem.model.id] = i;
  19771. this.onRefreshItem(viewItem);
  19772. }
  19773. };
  19774. HeightMap.prototype.onRemoveItem = function (item) {
  19775. // noop
  19776. };
  19777. HeightMap.prototype.onRefreshItemSet = function (items) {
  19778. var _this = this;
  19779. var sortedItems = items.sort(function (a, b) { return _this.indexes[a.id] - _this.indexes[b.id]; });
  19780. this.onRefreshItems(new iterator_1.ArrayIterator(sortedItems));
  19781. };
  19782. // Ordered, but not necessarily contiguous items
  19783. HeightMap.prototype.onRefreshItems = function (iterator) {
  19784. var item = null;
  19785. var viewItem;
  19786. var newHeight;
  19787. var i, j = null;
  19788. var cummDiff = 0;
  19789. while (item = iterator.next()) {
  19790. i = this.indexes[item.id];
  19791. for (; cummDiff !== 0 && j !== null && j < i; j++) {
  19792. viewItem = this.heightMap[j];
  19793. viewItem.top += cummDiff;
  19794. this.onRefreshItem(viewItem);
  19795. }
  19796. viewItem = this.heightMap[i];
  19797. newHeight = item.getHeight();
  19798. viewItem.top += cummDiff;
  19799. cummDiff += newHeight - viewItem.height;
  19800. viewItem.height = newHeight;
  19801. this.onRefreshItem(viewItem, true);
  19802. j = i + 1;
  19803. }
  19804. if (cummDiff !== 0 && j !== null) {
  19805. for (; j < this.heightMap.length; j++) {
  19806. viewItem = this.heightMap[j];
  19807. viewItem.top += cummDiff;
  19808. this.onRefreshItem(viewItem);
  19809. }
  19810. }
  19811. };
  19812. HeightMap.prototype.onRefreshItem = function (item, needsRender) {
  19813. if (needsRender === void 0) { needsRender = false; }
  19814. // noop
  19815. };
  19816. HeightMap.prototype.indexAt = function (position) {
  19817. var left = 0;
  19818. var right = this.heightMap.length;
  19819. var center;
  19820. var item;
  19821. // Binary search
  19822. while (left < right) {
  19823. center = Math.floor((left + right) / 2);
  19824. item = this.heightMap[center];
  19825. if (position < item.top) {
  19826. right = center;
  19827. }
  19828. else if (position >= item.top + item.height) {
  19829. if (left === center) {
  19830. break;
  19831. }
  19832. left = center;
  19833. }
  19834. else {
  19835. return center;
  19836. }
  19837. }
  19838. return this.heightMap.length;
  19839. };
  19840. HeightMap.prototype.indexAfter = function (position) {
  19841. return Math.min(this.indexAt(position) + 1, this.heightMap.length);
  19842. };
  19843. HeightMap.prototype.itemAtIndex = function (index) {
  19844. return this.heightMap[index];
  19845. };
  19846. HeightMap.prototype.itemAfter = function (item) {
  19847. return this.heightMap[this.indexes[item.model.id] + 1] || null;
  19848. };
  19849. HeightMap.prototype.createViewItem = function (item) {
  19850. throw new Error('not implemented');
  19851. };
  19852. HeightMap.prototype.dispose = function () {
  19853. this.heightMap = [];
  19854. this.indexes = {};
  19855. };
  19856. return HeightMap;
  19857. }());
  19858. exports.HeightMap = HeightMap;
  19859. });
  19860. /*---------------------------------------------------------------------------------------------
  19861. * Copyright (c) Microsoft Corporation. All rights reserved.
  19862. * Licensed under the MIT License. See License.txt in the project root for license information.
  19863. *--------------------------------------------------------------------------------------------*/
  19864. define(__m[258/*vs/base/worker/defaultWorkerFactory*/], __M([0/*require*/,1/*exports*/,16/*vs/base/common/platform*/,182/*vs/base/common/worker/simpleWorker*/]), function (require, exports, platform_1, simpleWorker_1) {
  19865. "use strict";
  19866. Object.defineProperty(exports, "__esModule", { value: true });
  19867. function getWorker(workerId, label) {
  19868. // Option for hosts to overwrite the worker script (used in the standalone editor)
  19869. if (platform_1.globals.MonacoEnvironment) {
  19870. if (typeof platform_1.globals.MonacoEnvironment.getWorker === 'function') {
  19871. return platform_1.globals.MonacoEnvironment.getWorker(workerId, label);
  19872. }
  19873. if (typeof platform_1.globals.MonacoEnvironment.getWorkerUrl === 'function') {
  19874. return new Worker(platform_1.globals.MonacoEnvironment.getWorkerUrl(workerId, label));
  19875. }
  19876. }
  19877. // ESM-comment-begin
  19878. if (typeof require === 'function') {
  19879. // check if the JS lives on a different origin
  19880. var workerMain = require.toUrl('./' + workerId);
  19881. var workerUrl = getWorkerBootstrapUrl(workerMain, label);
  19882. return new Worker(workerUrl, { name: label });
  19883. }
  19884. // ESM-comment-end
  19885. throw new Error("You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker");
  19886. }
  19887. // ESM-comment-begin
  19888. function getWorkerBootstrapUrl(scriptPath, label) {
  19889. if (/^(http:)|(https:)|(file:)/.test(scriptPath)) {
  19890. var currentUrl = String(window.location);
  19891. var currentOrigin = currentUrl.substr(0, currentUrl.length - window.location.hash.length - window.location.search.length - window.location.pathname.length);
  19892. if (scriptPath.substring(0, currentOrigin.length) !== currentOrigin) {
  19893. // this is the cross-origin case
  19894. // i.e. the webpage is running at a different origin than where the scripts are loaded from
  19895. var myPath = 'vs/base/worker/defaultWorkerFactory.js';
  19896. var workerBaseUrl = require.toUrl(myPath).slice(0, -myPath.length);
  19897. var js = "/*" + label + "*/self.MonacoEnvironment={baseUrl: '" + workerBaseUrl + "'};importScripts('" + scriptPath + "');/*" + label + "*/";
  19898. var url = "data:text/javascript;charset=utf-8," + encodeURIComponent(js);
  19899. return url;
  19900. }
  19901. }
  19902. return scriptPath + '#' + label;
  19903. }
  19904. exports.getWorkerBootstrapUrl = getWorkerBootstrapUrl;
  19905. // ESM-comment-end
  19906. function isPromiseLike(obj) {
  19907. if (typeof obj.then === 'function') {
  19908. return true;
  19909. }
  19910. return false;
  19911. }
  19912. /**
  19913. * A worker that uses HTML5 web workers so that is has
  19914. * its own global scope and its own thread.
  19915. */
  19916. var WebWorker = /** @class */ (function () {
  19917. function WebWorker(moduleId, id, label, onMessageCallback, onErrorCallback) {
  19918. this.id = id;
  19919. var workerOrPromise = getWorker('workerMain.js', label);
  19920. if (isPromiseLike(workerOrPromise)) {
  19921. this.worker = workerOrPromise;
  19922. }
  19923. else {
  19924. this.worker = Promise.resolve(workerOrPromise);
  19925. }
  19926. this.postMessage(moduleId, []);
  19927. this.worker.then(function (w) {
  19928. w.onmessage = function (ev) {
  19929. onMessageCallback(ev.data);
  19930. };
  19931. w.onmessageerror = onErrorCallback;
  19932. if (typeof w.addEventListener === 'function') {
  19933. w.addEventListener('error', onErrorCallback);
  19934. }
  19935. });
  19936. }
  19937. WebWorker.prototype.getId = function () {
  19938. return this.id;
  19939. };
  19940. WebWorker.prototype.postMessage = function (message, transfer) {
  19941. if (this.worker) {
  19942. this.worker.then(function (w) { return w.postMessage(message, transfer); });
  19943. }
  19944. };
  19945. WebWorker.prototype.dispose = function () {
  19946. if (this.worker) {
  19947. this.worker.then(function (w) { return w.terminate(); });
  19948. }
  19949. this.worker = null;
  19950. };
  19951. return WebWorker;
  19952. }());
  19953. var DefaultWorkerFactory = /** @class */ (function () {
  19954. function DefaultWorkerFactory(label) {
  19955. this._label = label;
  19956. this._webWorkerFailedBeforeError = false;
  19957. }
  19958. DefaultWorkerFactory.prototype.create = function (moduleId, onMessageCallback, onErrorCallback) {
  19959. var _this = this;
  19960. var workerId = (++DefaultWorkerFactory.LAST_WORKER_ID);
  19961. if (this._webWorkerFailedBeforeError) {
  19962. throw this._webWorkerFailedBeforeError;
  19963. }
  19964. return new WebWorker(moduleId, workerId, this._label || 'anonymous' + workerId, onMessageCallback, function (err) {
  19965. simpleWorker_1.logOnceWebWorkerWarning(err);
  19966. _this._webWorkerFailedBeforeError = err;
  19967. onErrorCallback(err);
  19968. });
  19969. };
  19970. DefaultWorkerFactory.LAST_WORKER_ID = 0;
  19971. return DefaultWorkerFactory;
  19972. }());
  19973. exports.DefaultWorkerFactory = DefaultWorkerFactory;
  19974. });
  19975. define(__m[259/*vs/css!vs/base/browser/ui/actionbar/actionbar*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  19976. define(__m[260/*vs/css!vs/base/browser/ui/aria/aria*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  19977. define(__m[261/*vs/css!vs/base/browser/ui/checkbox/checkbox*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  19978. /*---------------------------------------------------------------------------------------------
  19979. * Copyright (c) Microsoft Corporation. All rights reserved.
  19980. * Licensed under the MIT License. See License.txt in the project root for license information.
  19981. *--------------------------------------------------------------------------------------------*/
  19982. define(__m[138/*vs/base/browser/ui/checkbox/checkbox*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,47/*vs/base/browser/ui/widget*/,27/*vs/base/common/color*/,4/*vs/base/common/event*/,31/*vs/base/common/objects*/,261/*vs/css!vs/base/browser/ui/checkbox/checkbox*/]), function (require, exports, DOM, widget_1, color_1, event_1, objects) {
  19983. "use strict";
  19984. Object.defineProperty(exports, "__esModule", { value: true });
  19985. var defaultOpts = {
  19986. inputActiveOptionBorder: color_1.Color.fromHex('#007ACC00'),
  19987. inputActiveOptionBackground: color_1.Color.fromHex('#0E639C50')
  19988. };
  19989. var Checkbox = /** @class */ (function (_super) {
  19990. __extends(Checkbox, _super);
  19991. function Checkbox(opts) {
  19992. var _this = _super.call(this) || this;
  19993. _this._onChange = _this._register(new event_1.Emitter());
  19994. _this.onChange = _this._onChange.event;
  19995. _this._onKeyDown = _this._register(new event_1.Emitter());
  19996. _this.onKeyDown = _this._onKeyDown.event;
  19997. _this._opts = objects.deepClone(opts);
  19998. objects.mixin(_this._opts, defaultOpts, false);
  19999. _this._checked = _this._opts.isChecked;
  20000. _this.domNode = document.createElement('div');
  20001. _this.domNode.title = _this._opts.title;
  20002. _this.domNode.className = 'monaco-custom-checkbox codicon ' + (_this._opts.actionClassName || '') + ' ' + (_this._checked ? 'checked' : 'unchecked');
  20003. _this.domNode.tabIndex = 0;
  20004. _this.domNode.setAttribute('role', 'checkbox');
  20005. _this.domNode.setAttribute('aria-checked', String(_this._checked));
  20006. _this.domNode.setAttribute('aria-label', _this._opts.title);
  20007. _this.applyStyles();
  20008. _this.onclick(_this.domNode, function (ev) {
  20009. _this.checked = !_this._checked;
  20010. _this._onChange.fire(false);
  20011. ev.preventDefault();
  20012. });
  20013. _this.ignoreGesture(_this.domNode);
  20014. _this.onkeydown(_this.domNode, function (keyboardEvent) {
  20015. if (keyboardEvent.keyCode === 10 /* Space */ || keyboardEvent.keyCode === 3 /* Enter */) {
  20016. _this.checked = !_this._checked;
  20017. _this._onChange.fire(true);
  20018. keyboardEvent.preventDefault();
  20019. return;
  20020. }
  20021. _this._onKeyDown.fire(keyboardEvent);
  20022. });
  20023. return _this;
  20024. }
  20025. Object.defineProperty(Checkbox.prototype, "enabled", {
  20026. get: function () {
  20027. return this.domNode.getAttribute('aria-disabled') !== 'true';
  20028. },
  20029. enumerable: true,
  20030. configurable: true
  20031. });
  20032. Checkbox.prototype.focus = function () {
  20033. this.domNode.focus();
  20034. };
  20035. Object.defineProperty(Checkbox.prototype, "checked", {
  20036. get: function () {
  20037. return this._checked;
  20038. },
  20039. set: function (newIsChecked) {
  20040. this._checked = newIsChecked;
  20041. this.domNode.setAttribute('aria-checked', String(this._checked));
  20042. if (this._checked) {
  20043. this.domNode.classList.add('checked');
  20044. }
  20045. else {
  20046. this.domNode.classList.remove('checked');
  20047. }
  20048. this.applyStyles();
  20049. },
  20050. enumerable: true,
  20051. configurable: true
  20052. });
  20053. Checkbox.prototype.width = function () {
  20054. return 2 /*marginleft*/ + 2 /*border*/ + 2 /*padding*/ + 16 /* icon width */;
  20055. };
  20056. Checkbox.prototype.style = function (styles) {
  20057. if (styles.inputActiveOptionBorder) {
  20058. this._opts.inputActiveOptionBorder = styles.inputActiveOptionBorder;
  20059. }
  20060. if (styles.inputActiveOptionBackground) {
  20061. this._opts.inputActiveOptionBackground = styles.inputActiveOptionBackground;
  20062. }
  20063. this.applyStyles();
  20064. };
  20065. Checkbox.prototype.applyStyles = function () {
  20066. if (this.domNode) {
  20067. this.domNode.style.borderColor = this._checked && this._opts.inputActiveOptionBorder ? this._opts.inputActiveOptionBorder.toString() : 'transparent';
  20068. this.domNode.style.backgroundColor = this._checked && this._opts.inputActiveOptionBackground ? this._opts.inputActiveOptionBackground.toString() : 'transparent';
  20069. }
  20070. };
  20071. Checkbox.prototype.enable = function () {
  20072. this.domNode.tabIndex = 0;
  20073. this.domNode.setAttribute('aria-disabled', String(false));
  20074. };
  20075. Checkbox.prototype.disable = function () {
  20076. DOM.removeTabIndexAndUpdateFocus(this.domNode);
  20077. this.domNode.setAttribute('aria-disabled', String(true));
  20078. };
  20079. return Checkbox;
  20080. }(widget_1.Widget));
  20081. exports.Checkbox = Checkbox;
  20082. });
  20083. define(__m[262/*vs/css!vs/base/browser/ui/codiconLabel/codicon/codicon*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20084. define(__m[263/*vs/css!vs/base/browser/ui/codiconLabel/codicon/codicon-animations*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20085. /*---------------------------------------------------------------------------------------------
  20086. * Copyright (c) Microsoft Corporation. All rights reserved.
  20087. * Licensed under the MIT License. See License.txt in the project root for license information.
  20088. *--------------------------------------------------------------------------------------------*/
  20089. define(__m[183/*vs/base/browser/ui/codiconLabel/codiconLabel*/], __M([0/*require*/,1/*exports*/,262/*vs/css!vs/base/browser/ui/codiconLabel/codicon/codicon*/,263/*vs/css!vs/base/browser/ui/codiconLabel/codicon/codicon-animations*/]), function (require, exports) {
  20090. "use strict";
  20091. Object.defineProperty(exports, "__esModule", { value: true });
  20092. });
  20093. define(__m[264/*vs/css!vs/base/browser/ui/contextview/contextview*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20094. /*---------------------------------------------------------------------------------------------
  20095. * Copyright (c) Microsoft Corporation. All rights reserved.
  20096. * Licensed under the MIT License. See License.txt in the project root for license information.
  20097. *--------------------------------------------------------------------------------------------*/
  20098. define(__m[265/*vs/base/browser/ui/contextview/contextview*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,16/*vs/base/common/platform*/,2/*vs/base/common/lifecycle*/,103/*vs/base/common/range*/,88/*vs/base/browser/canIUse*/,264/*vs/css!vs/base/browser/ui/contextview/contextview*/]), function (require, exports, DOM, platform, lifecycle_1, range_1, canIUse_1) {
  20099. "use strict";
  20100. Object.defineProperty(exports, "__esModule", { value: true });
  20101. /**
  20102. * Lays out a one dimensional view next to an anchor in a viewport.
  20103. *
  20104. * @returns The view offset within the viewport.
  20105. */
  20106. function layout(viewportSize, viewSize, anchor) {
  20107. var anchorEnd = anchor.offset + anchor.size;
  20108. if (anchor.position === 0 /* Before */) {
  20109. if (viewSize <= viewportSize - anchorEnd) {
  20110. return anchorEnd; // happy case, lay it out after the anchor
  20111. }
  20112. if (viewSize <= anchor.offset) {
  20113. return anchor.offset - viewSize; // ok case, lay it out before the anchor
  20114. }
  20115. return Math.max(viewportSize - viewSize, 0); // sad case, lay it over the anchor
  20116. }
  20117. else {
  20118. if (viewSize <= anchor.offset) {
  20119. return anchor.offset - viewSize; // happy case, lay it out before the anchor
  20120. }
  20121. if (viewSize <= viewportSize - anchorEnd) {
  20122. return anchorEnd; // ok case, lay it out after the anchor
  20123. }
  20124. return 0; // sad case, lay it over the anchor
  20125. }
  20126. }
  20127. exports.layout = layout;
  20128. var ContextView = /** @class */ (function (_super) {
  20129. __extends(ContextView, _super);
  20130. function ContextView(container) {
  20131. var _this = _super.call(this) || this;
  20132. _this.container = null;
  20133. _this.delegate = null;
  20134. _this.toDisposeOnClean = lifecycle_1.Disposable.None;
  20135. _this.toDisposeOnSetContainer = lifecycle_1.Disposable.None;
  20136. _this.view = DOM.$('.context-view');
  20137. DOM.hide(_this.view);
  20138. _this.setContainer(container);
  20139. _this._register(lifecycle_1.toDisposable(function () { return _this.setContainer(null); }));
  20140. return _this;
  20141. }
  20142. ContextView.prototype.setContainer = function (container) {
  20143. var _this = this;
  20144. if (this.container) {
  20145. this.toDisposeOnSetContainer.dispose();
  20146. this.container.removeChild(this.view);
  20147. this.container = null;
  20148. }
  20149. if (container) {
  20150. this.container = container;
  20151. this.container.appendChild(this.view);
  20152. var toDisposeOnSetContainer_1 = new lifecycle_1.DisposableStore();
  20153. ContextView.BUBBLE_UP_EVENTS.forEach(function (event) {
  20154. toDisposeOnSetContainer_1.add(DOM.addStandardDisposableListener(_this.container, event, function (e) {
  20155. _this.onDOMEvent(e, false);
  20156. }));
  20157. });
  20158. ContextView.BUBBLE_DOWN_EVENTS.forEach(function (event) {
  20159. toDisposeOnSetContainer_1.add(DOM.addStandardDisposableListener(_this.container, event, function (e) {
  20160. _this.onDOMEvent(e, true);
  20161. }, true));
  20162. });
  20163. this.toDisposeOnSetContainer = toDisposeOnSetContainer_1;
  20164. }
  20165. };
  20166. ContextView.prototype.show = function (delegate) {
  20167. if (this.isVisible()) {
  20168. this.hide();
  20169. }
  20170. // Show static box
  20171. DOM.clearNode(this.view);
  20172. this.view.className = 'context-view';
  20173. this.view.style.top = '0px';
  20174. this.view.style.left = '0px';
  20175. DOM.show(this.view);
  20176. // Render content
  20177. this.toDisposeOnClean = delegate.render(this.view) || lifecycle_1.Disposable.None;
  20178. // Set active delegate
  20179. this.delegate = delegate;
  20180. // Layout
  20181. this.doLayout();
  20182. // Focus
  20183. if (this.delegate.focus) {
  20184. this.delegate.focus();
  20185. }
  20186. };
  20187. ContextView.prototype.layout = function () {
  20188. if (!this.isVisible()) {
  20189. return;
  20190. }
  20191. if (this.delegate.canRelayout === false && !(platform.isIOS && canIUse_1.BrowserFeatures.pointerEvents)) {
  20192. this.hide();
  20193. return;
  20194. }
  20195. if (this.delegate.layout) {
  20196. this.delegate.layout();
  20197. }
  20198. this.doLayout();
  20199. };
  20200. ContextView.prototype.doLayout = function () {
  20201. // Check that we still have a delegate - this.delegate.layout may have hidden
  20202. if (!this.isVisible()) {
  20203. return;
  20204. }
  20205. // Get anchor
  20206. var anchor = this.delegate.getAnchor();
  20207. // Compute around
  20208. var around;
  20209. // Get the element's position and size (to anchor the view)
  20210. if (DOM.isHTMLElement(anchor)) {
  20211. var elementPosition = DOM.getDomNodePagePosition(anchor);
  20212. around = {
  20213. top: elementPosition.top,
  20214. left: elementPosition.left,
  20215. width: elementPosition.width,
  20216. height: elementPosition.height
  20217. };
  20218. }
  20219. else {
  20220. around = {
  20221. top: anchor.y,
  20222. left: anchor.x,
  20223. width: anchor.width || 1,
  20224. height: anchor.height || 2
  20225. };
  20226. }
  20227. var viewSizeWidth = DOM.getTotalWidth(this.view);
  20228. var viewSizeHeight = DOM.getTotalHeight(this.view);
  20229. var anchorPosition = this.delegate.anchorPosition || 0 /* BELOW */;
  20230. var anchorAlignment = this.delegate.anchorAlignment || 0 /* LEFT */;
  20231. var verticalAnchor = { offset: around.top - window.pageYOffset, size: around.height, position: anchorPosition === 0 /* BELOW */ ? 0 /* Before */ : 1 /* After */ };
  20232. var horizontalAnchor;
  20233. if (anchorAlignment === 0 /* LEFT */) {
  20234. horizontalAnchor = { offset: around.left, size: 0, position: 0 /* Before */ };
  20235. }
  20236. else {
  20237. horizontalAnchor = { offset: around.left + around.width, size: 0, position: 1 /* After */ };
  20238. }
  20239. var top = layout(window.innerHeight, viewSizeHeight, verticalAnchor) + window.pageYOffset;
  20240. // if view intersects vertically with anchor, shift it horizontally
  20241. if (range_1.Range.intersects({ start: top, end: top + viewSizeHeight }, { start: verticalAnchor.offset, end: verticalAnchor.offset + verticalAnchor.size })) {
  20242. horizontalAnchor.size = around.width;
  20243. if (anchorAlignment === 1 /* RIGHT */) {
  20244. horizontalAnchor.offset = around.left;
  20245. }
  20246. }
  20247. var left = layout(window.innerWidth, viewSizeWidth, horizontalAnchor);
  20248. DOM.removeClasses(this.view, 'top', 'bottom', 'left', 'right');
  20249. DOM.addClass(this.view, anchorPosition === 0 /* BELOW */ ? 'bottom' : 'top');
  20250. DOM.addClass(this.view, anchorAlignment === 0 /* LEFT */ ? 'left' : 'right');
  20251. var containerPosition = DOM.getDomNodePagePosition(this.container);
  20252. this.view.style.top = top - containerPosition.top + "px";
  20253. this.view.style.left = left - containerPosition.left + "px";
  20254. this.view.style.width = 'initial';
  20255. };
  20256. ContextView.prototype.hide = function (data) {
  20257. var delegate = this.delegate;
  20258. this.delegate = null;
  20259. if (delegate === null || delegate === void 0 ? void 0 : delegate.onHide) {
  20260. delegate.onHide(data);
  20261. }
  20262. this.toDisposeOnClean.dispose();
  20263. DOM.hide(this.view);
  20264. };
  20265. ContextView.prototype.isVisible = function () {
  20266. return !!this.delegate;
  20267. };
  20268. ContextView.prototype.onDOMEvent = function (e, onCapture) {
  20269. if (this.delegate) {
  20270. if (this.delegate.onDOMEvent) {
  20271. this.delegate.onDOMEvent(e, document.activeElement);
  20272. }
  20273. else if (onCapture && !DOM.isAncestor(e.target, this.container)) {
  20274. this.hide();
  20275. }
  20276. }
  20277. };
  20278. ContextView.prototype.dispose = function () {
  20279. this.hide();
  20280. _super.prototype.dispose.call(this);
  20281. };
  20282. ContextView.BUBBLE_UP_EVENTS = ['click', 'keydown', 'focus', 'blur'];
  20283. ContextView.BUBBLE_DOWN_EVENTS = ['click'];
  20284. return ContextView;
  20285. }(lifecycle_1.Disposable));
  20286. exports.ContextView = ContextView;
  20287. });
  20288. define(__m[266/*vs/css!vs/base/browser/ui/countBadge/countBadge*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20289. /*---------------------------------------------------------------------------------------------
  20290. * Copyright (c) Microsoft Corporation. All rights reserved.
  20291. * Licensed under the MIT License. See License.txt in the project root for license information.
  20292. *--------------------------------------------------------------------------------------------*/
  20293. define(__m[267/*vs/base/browser/ui/countBadge/countBadge*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,5/*vs/base/common/strings*/,27/*vs/base/common/color*/,31/*vs/base/common/objects*/,266/*vs/css!vs/base/browser/ui/countBadge/countBadge*/]), function (require, exports, dom_1, strings_1, color_1, objects_1) {
  20294. "use strict";
  20295. Object.defineProperty(exports, "__esModule", { value: true });
  20296. var defaultOpts = {
  20297. badgeBackground: color_1.Color.fromHex('#4D4D4D'),
  20298. badgeForeground: color_1.Color.fromHex('#FFFFFF')
  20299. };
  20300. var CountBadge = /** @class */ (function () {
  20301. function CountBadge(container, options) {
  20302. this.count = 0;
  20303. this.options = options || Object.create(null);
  20304. objects_1.mixin(this.options, defaultOpts, false);
  20305. this.badgeBackground = this.options.badgeBackground;
  20306. this.badgeForeground = this.options.badgeForeground;
  20307. this.badgeBorder = this.options.badgeBorder;
  20308. this.element = dom_1.append(container, dom_1.$('.monaco-count-badge'));
  20309. this.countFormat = this.options.countFormat || '{0}';
  20310. this.titleFormat = this.options.titleFormat || '';
  20311. this.setCount(this.options.count || 0);
  20312. }
  20313. CountBadge.prototype.setCount = function (count) {
  20314. this.count = count;
  20315. this.render();
  20316. };
  20317. CountBadge.prototype.setTitleFormat = function (titleFormat) {
  20318. this.titleFormat = titleFormat;
  20319. this.render();
  20320. };
  20321. CountBadge.prototype.render = function () {
  20322. this.element.textContent = strings_1.format(this.countFormat, this.count);
  20323. this.element.title = strings_1.format(this.titleFormat, this.count);
  20324. this.applyStyles();
  20325. };
  20326. CountBadge.prototype.style = function (styles) {
  20327. this.badgeBackground = styles.badgeBackground;
  20328. this.badgeForeground = styles.badgeForeground;
  20329. this.badgeBorder = styles.badgeBorder;
  20330. this.applyStyles();
  20331. };
  20332. CountBadge.prototype.applyStyles = function () {
  20333. if (this.element) {
  20334. var background = this.badgeBackground ? this.badgeBackground.toString() : '';
  20335. var foreground = this.badgeForeground ? this.badgeForeground.toString() : '';
  20336. var border = this.badgeBorder ? this.badgeBorder.toString() : '';
  20337. this.element.style.backgroundColor = background;
  20338. this.element.style.color = foreground;
  20339. this.element.style.borderWidth = border ? '1px' : '';
  20340. this.element.style.borderStyle = border ? 'solid' : '';
  20341. this.element.style.borderColor = border;
  20342. }
  20343. };
  20344. return CountBadge;
  20345. }());
  20346. exports.CountBadge = CountBadge;
  20347. });
  20348. define(__m[184/*vs/css!vs/base/browser/ui/findinput/findInput*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20349. define(__m[268/*vs/css!vs/base/browser/ui/iconLabel/iconlabel*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20350. /*---------------------------------------------------------------------------------------------
  20351. * Copyright (c) Microsoft Corporation. All rights reserved.
  20352. * Licensed under the MIT License. See License.txt in the project root for license information.
  20353. *--------------------------------------------------------------------------------------------*/
  20354. define(__m[139/*vs/base/browser/ui/iconLabel/iconLabel*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,133/*vs/base/browser/ui/highlightedlabel/highlightedLabel*/,2/*vs/base/common/lifecycle*/,103/*vs/base/common/range*/,31/*vs/base/common/objects*/,268/*vs/css!vs/base/browser/ui/iconLabel/iconlabel*/]), function (require, exports, dom, highlightedLabel_1, lifecycle_1, range_1, objects_1) {
  20355. "use strict";
  20356. Object.defineProperty(exports, "__esModule", { value: true });
  20357. var FastLabelNode = /** @class */ (function () {
  20358. function FastLabelNode(_element) {
  20359. this._element = _element;
  20360. }
  20361. Object.defineProperty(FastLabelNode.prototype, "element", {
  20362. get: function () {
  20363. return this._element;
  20364. },
  20365. enumerable: true,
  20366. configurable: true
  20367. });
  20368. Object.defineProperty(FastLabelNode.prototype, "textContent", {
  20369. set: function (content) {
  20370. if (this.disposed || content === this._textContent) {
  20371. return;
  20372. }
  20373. this._textContent = content;
  20374. this._element.textContent = content;
  20375. },
  20376. enumerable: true,
  20377. configurable: true
  20378. });
  20379. Object.defineProperty(FastLabelNode.prototype, "className", {
  20380. set: function (className) {
  20381. if (this.disposed || className === this._className) {
  20382. return;
  20383. }
  20384. this._className = className;
  20385. this._element.className = className;
  20386. },
  20387. enumerable: true,
  20388. configurable: true
  20389. });
  20390. Object.defineProperty(FastLabelNode.prototype, "title", {
  20391. set: function (title) {
  20392. if (this.disposed || title === this._title) {
  20393. return;
  20394. }
  20395. this._title = title;
  20396. if (this._title) {
  20397. this._element.title = title;
  20398. }
  20399. else {
  20400. this._element.removeAttribute('title');
  20401. }
  20402. },
  20403. enumerable: true,
  20404. configurable: true
  20405. });
  20406. Object.defineProperty(FastLabelNode.prototype, "empty", {
  20407. set: function (empty) {
  20408. if (this.disposed || empty === this._empty) {
  20409. return;
  20410. }
  20411. this._empty = empty;
  20412. this._element.style.marginLeft = empty ? '0' : '';
  20413. },
  20414. enumerable: true,
  20415. configurable: true
  20416. });
  20417. FastLabelNode.prototype.dispose = function () {
  20418. this.disposed = true;
  20419. };
  20420. return FastLabelNode;
  20421. }());
  20422. var IconLabel = /** @class */ (function (_super) {
  20423. __extends(IconLabel, _super);
  20424. function IconLabel(container, options) {
  20425. var _this = _super.call(this) || this;
  20426. _this.domNode = _this._register(new FastLabelNode(dom.append(container, dom.$('.monaco-icon-label'))));
  20427. var labelContainer = dom.append(_this.domNode.element, dom.$('.monaco-icon-label-container'));
  20428. var nameContainer = dom.append(labelContainer, dom.$('span.monaco-icon-name-container'));
  20429. _this.descriptionContainer = _this._register(new FastLabelNode(dom.append(labelContainer, dom.$('span.monaco-icon-description-container'))));
  20430. if (options === null || options === void 0 ? void 0 : options.supportHighlights) {
  20431. _this.nameNode = new LabelWithHighlights(nameContainer, !!options.supportCodicons);
  20432. }
  20433. else {
  20434. _this.nameNode = new Label(nameContainer);
  20435. }
  20436. if (options === null || options === void 0 ? void 0 : options.supportDescriptionHighlights) {
  20437. _this.descriptionNodeFactory = function () { return new highlightedLabel_1.HighlightedLabel(dom.append(_this.descriptionContainer.element, dom.$('span.label-description')), !!options.supportCodicons); };
  20438. }
  20439. else {
  20440. _this.descriptionNodeFactory = function () { return _this._register(new FastLabelNode(dom.append(_this.descriptionContainer.element, dom.$('span.label-description')))); };
  20441. }
  20442. return _this;
  20443. }
  20444. IconLabel.prototype.setLabel = function (label, description, options) {
  20445. var classes = ['monaco-icon-label'];
  20446. if (options) {
  20447. if (options.extraClasses) {
  20448. classes.push.apply(classes, options.extraClasses);
  20449. }
  20450. if (options.italic) {
  20451. classes.push('italic');
  20452. }
  20453. }
  20454. this.domNode.className = classes.join(' ');
  20455. this.domNode.title = (options === null || options === void 0 ? void 0 : options.title) || '';
  20456. this.nameNode.setLabel(label, options);
  20457. if (description || this.descriptionNode) {
  20458. if (!this.descriptionNode) {
  20459. this.descriptionNode = this.descriptionNodeFactory(); // description node is created lazily on demand
  20460. }
  20461. if (this.descriptionNode instanceof highlightedLabel_1.HighlightedLabel) {
  20462. this.descriptionNode.set(description || '', options ? options.descriptionMatches : undefined);
  20463. if (options === null || options === void 0 ? void 0 : options.descriptionTitle) {
  20464. this.descriptionNode.element.title = options.descriptionTitle;
  20465. }
  20466. else {
  20467. this.descriptionNode.element.removeAttribute('title');
  20468. }
  20469. }
  20470. else {
  20471. this.descriptionNode.textContent = description || '';
  20472. this.descriptionNode.title = (options === null || options === void 0 ? void 0 : options.descriptionTitle) || '';
  20473. this.descriptionNode.empty = !description;
  20474. }
  20475. }
  20476. };
  20477. return IconLabel;
  20478. }(lifecycle_1.Disposable));
  20479. exports.IconLabel = IconLabel;
  20480. var Label = /** @class */ (function () {
  20481. function Label(container) {
  20482. this.container = container;
  20483. this.label = undefined;
  20484. this.singleLabel = undefined;
  20485. }
  20486. Label.prototype.setLabel = function (label, options) {
  20487. if (this.label === label && objects_1.equals(this.options, options)) {
  20488. return;
  20489. }
  20490. this.label = label;
  20491. this.options = options;
  20492. if (typeof label === 'string') {
  20493. if (!this.singleLabel) {
  20494. this.container.innerHTML = '';
  20495. dom.removeClass(this.container, 'multiple');
  20496. this.singleLabel = dom.append(this.container, dom.$('a.label-name', { id: options === null || options === void 0 ? void 0 : options.domId }));
  20497. }
  20498. this.singleLabel.textContent = label;
  20499. }
  20500. else {
  20501. this.container.innerHTML = '';
  20502. dom.addClass(this.container, 'multiple');
  20503. this.singleLabel = undefined;
  20504. for (var i = 0; i < label.length; i++) {
  20505. var l = label[i];
  20506. var id = (options === null || options === void 0 ? void 0 : options.domId) && (options === null || options === void 0 ? void 0 : options.domId) + "_" + i;
  20507. dom.append(this.container, dom.$('a.label-name', { id: id, 'data-icon-label-count': label.length, 'data-icon-label-index': i }, l));
  20508. if (i < label.length - 1) {
  20509. dom.append(this.container, dom.$('span.label-separator', undefined, (options === null || options === void 0 ? void 0 : options.separator) || '/'));
  20510. }
  20511. }
  20512. }
  20513. };
  20514. return Label;
  20515. }());
  20516. function splitMatches(labels, separator, matches) {
  20517. if (!matches) {
  20518. return undefined;
  20519. }
  20520. var labelStart = 0;
  20521. return labels.map(function (label) {
  20522. var labelRange = { start: labelStart, end: labelStart + label.length };
  20523. var result = matches
  20524. .map(function (match) { return range_1.Range.intersect(labelRange, match); })
  20525. .filter(function (range) { return !range_1.Range.isEmpty(range); })
  20526. .map(function (_a) {
  20527. var start = _a.start, end = _a.end;
  20528. return ({ start: start - labelStart, end: end - labelStart });
  20529. });
  20530. labelStart = labelRange.end + separator.length;
  20531. return result;
  20532. });
  20533. }
  20534. var LabelWithHighlights = /** @class */ (function () {
  20535. function LabelWithHighlights(container, supportCodicons) {
  20536. this.container = container;
  20537. this.supportCodicons = supportCodicons;
  20538. this.label = undefined;
  20539. this.singleLabel = undefined;
  20540. }
  20541. LabelWithHighlights.prototype.setLabel = function (label, options) {
  20542. if (this.label === label && objects_1.equals(this.options, options)) {
  20543. return;
  20544. }
  20545. this.label = label;
  20546. this.options = options;
  20547. if (typeof label === 'string') {
  20548. if (!this.singleLabel) {
  20549. this.container.innerHTML = '';
  20550. dom.removeClass(this.container, 'multiple');
  20551. this.singleLabel = new highlightedLabel_1.HighlightedLabel(dom.append(this.container, dom.$('a.label-name', { id: options === null || options === void 0 ? void 0 : options.domId })), this.supportCodicons);
  20552. }
  20553. this.singleLabel.set(label, options === null || options === void 0 ? void 0 : options.matches, options === null || options === void 0 ? void 0 : options.title, options === null || options === void 0 ? void 0 : options.labelEscapeNewLines);
  20554. }
  20555. else {
  20556. this.container.innerHTML = '';
  20557. dom.addClass(this.container, 'multiple');
  20558. this.singleLabel = undefined;
  20559. var separator = (options === null || options === void 0 ? void 0 : options.separator) || '/';
  20560. var matches = splitMatches(label, separator, options === null || options === void 0 ? void 0 : options.matches);
  20561. for (var i = 0; i < label.length; i++) {
  20562. var l = label[i];
  20563. var m = matches ? matches[i] : undefined;
  20564. var id = (options === null || options === void 0 ? void 0 : options.domId) && (options === null || options === void 0 ? void 0 : options.domId) + "_" + i;
  20565. var name_1 = dom.$('a.label-name', { id: id, 'data-icon-label-count': label.length, 'data-icon-label-index': i });
  20566. var highlightedLabel = new highlightedLabel_1.HighlightedLabel(dom.append(this.container, name_1), this.supportCodicons);
  20567. highlightedLabel.set(l, m, options === null || options === void 0 ? void 0 : options.title, options === null || options === void 0 ? void 0 : options.labelEscapeNewLines);
  20568. if (i < label.length - 1) {
  20569. dom.append(name_1, dom.$('span.label-separator', undefined, separator));
  20570. }
  20571. }
  20572. }
  20573. };
  20574. return LabelWithHighlights;
  20575. }());
  20576. });
  20577. define(__m[269/*vs/css!vs/base/browser/ui/inputbox/inputBox*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20578. define(__m[270/*vs/css!vs/base/browser/ui/keybindingLabel/keybindingLabel*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20579. define(__m[271/*vs/css!vs/base/browser/ui/list/list*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20580. define(__m[272/*vs/css!vs/base/browser/ui/menu/menu*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20581. define(__m[273/*vs/css!vs/base/browser/ui/progressbar/progressbar*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20582. /*---------------------------------------------------------------------------------------------
  20583. * Copyright (c) Microsoft Corporation. All rights reserved.
  20584. * Licensed under the MIT License. See License.txt in the project root for license information.
  20585. *--------------------------------------------------------------------------------------------*/
  20586. define(__m[274/*vs/base/browser/ui/progressbar/progressbar*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,27/*vs/base/common/color*/,31/*vs/base/common/objects*/,6/*vs/base/browser/dom*/,15/*vs/base/common/async*/,273/*vs/css!vs/base/browser/ui/progressbar/progressbar*/]), function (require, exports, lifecycle_1, color_1, objects_1, dom_1, async_1) {
  20587. "use strict";
  20588. Object.defineProperty(exports, "__esModule", { value: true });
  20589. var css_done = 'done';
  20590. var css_active = 'active';
  20591. var css_infinite = 'infinite';
  20592. var css_discrete = 'discrete';
  20593. var css_progress_container = 'monaco-progress-container';
  20594. var css_progress_bit = 'progress-bit';
  20595. var defaultOpts = {
  20596. progressBarBackground: color_1.Color.fromHex('#0E70C0')
  20597. };
  20598. /**
  20599. * A progress bar with support for infinite or discrete progress.
  20600. */
  20601. var ProgressBar = /** @class */ (function (_super) {
  20602. __extends(ProgressBar, _super);
  20603. function ProgressBar(container, options) {
  20604. var _this = _super.call(this) || this;
  20605. _this.options = options || Object.create(null);
  20606. objects_1.mixin(_this.options, defaultOpts, false);
  20607. _this.workedVal = 0;
  20608. _this.progressBarBackground = _this.options.progressBarBackground;
  20609. _this._register(_this.showDelayedScheduler = new async_1.RunOnceScheduler(function () { return dom_1.show(_this.element); }, 0));
  20610. _this.create(container);
  20611. return _this;
  20612. }
  20613. ProgressBar.prototype.create = function (container) {
  20614. this.element = document.createElement('div');
  20615. dom_1.addClass(this.element, css_progress_container);
  20616. container.appendChild(this.element);
  20617. this.bit = document.createElement('div');
  20618. dom_1.addClass(this.bit, css_progress_bit);
  20619. this.element.appendChild(this.bit);
  20620. this.applyStyles();
  20621. };
  20622. ProgressBar.prototype.off = function () {
  20623. this.bit.style.width = 'inherit';
  20624. this.bit.style.opacity = '1';
  20625. dom_1.removeClasses(this.element, css_active, css_infinite, css_discrete);
  20626. this.workedVal = 0;
  20627. this.totalWork = undefined;
  20628. };
  20629. /**
  20630. * Stops the progressbar from showing any progress instantly without fading out.
  20631. */
  20632. ProgressBar.prototype.stop = function () {
  20633. return this.doDone(false);
  20634. };
  20635. ProgressBar.prototype.doDone = function (delayed) {
  20636. var _this = this;
  20637. dom_1.addClass(this.element, css_done);
  20638. // let it grow to 100% width and hide afterwards
  20639. if (!dom_1.hasClass(this.element, css_infinite)) {
  20640. this.bit.style.width = 'inherit';
  20641. if (delayed) {
  20642. setTimeout(function () { return _this.off(); }, 200);
  20643. }
  20644. else {
  20645. this.off();
  20646. }
  20647. }
  20648. // let it fade out and hide afterwards
  20649. else {
  20650. this.bit.style.opacity = '0';
  20651. if (delayed) {
  20652. setTimeout(function () { return _this.off(); }, 200);
  20653. }
  20654. else {
  20655. this.off();
  20656. }
  20657. }
  20658. return this;
  20659. };
  20660. ProgressBar.prototype.hide = function () {
  20661. dom_1.hide(this.element);
  20662. this.showDelayedScheduler.cancel();
  20663. };
  20664. ProgressBar.prototype.style = function (styles) {
  20665. this.progressBarBackground = styles.progressBarBackground;
  20666. this.applyStyles();
  20667. };
  20668. ProgressBar.prototype.applyStyles = function () {
  20669. if (this.bit) {
  20670. var background = this.progressBarBackground ? this.progressBarBackground.toString() : '';
  20671. this.bit.style.backgroundColor = background;
  20672. }
  20673. };
  20674. return ProgressBar;
  20675. }(lifecycle_1.Disposable));
  20676. exports.ProgressBar = ProgressBar;
  20677. });
  20678. define(__m[275/*vs/css!vs/base/browser/ui/sash/sash*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20679. /*---------------------------------------------------------------------------------------------
  20680. * Copyright (c) Microsoft Corporation. All rights reserved.
  20681. * Licensed under the MIT License. See License.txt in the project root for license information.
  20682. *--------------------------------------------------------------------------------------------*/
  20683. var __spreadArrays = (this && this.__spreadArrays) || function () {
  20684. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  20685. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  20686. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  20687. r[k] = a[j];
  20688. return r;
  20689. };
  20690. define(__m[104/*vs/base/browser/ui/sash/sash*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,24/*vs/base/browser/browser*/,16/*vs/base/common/platform*/,21/*vs/base/common/types*/,57/*vs/base/browser/touch*/,45/*vs/base/browser/mouseEvent*/,4/*vs/base/common/event*/,6/*vs/base/browser/dom*/,52/*vs/base/browser/event*/,275/*vs/css!vs/base/browser/ui/sash/sash*/]), function (require, exports, lifecycle_1, browser_1, platform_1, types, touch_1, mouseEvent_1, event_1, dom_1, event_2) {
  20691. "use strict";
  20692. Object.defineProperty(exports, "__esModule", { value: true });
  20693. var DEBUG = false;
  20694. var Sash = /** @class */ (function (_super) {
  20695. __extends(Sash, _super);
  20696. function Sash(container, layoutProvider, options) {
  20697. if (options === void 0) { options = {}; }
  20698. var _this = _super.call(this) || this;
  20699. _this._state = 3 /* Enabled */;
  20700. _this._onDidEnablementChange = _this._register(new event_1.Emitter());
  20701. _this.onDidEnablementChange = _this._onDidEnablementChange.event;
  20702. _this._onDidStart = _this._register(new event_1.Emitter());
  20703. _this.onDidStart = _this._onDidStart.event;
  20704. _this._onDidChange = _this._register(new event_1.Emitter());
  20705. _this.onDidChange = _this._onDidChange.event;
  20706. _this._onDidReset = _this._register(new event_1.Emitter());
  20707. _this.onDidReset = _this._onDidReset.event;
  20708. _this._onDidEnd = _this._register(new event_1.Emitter());
  20709. _this.onDidEnd = _this._onDidEnd.event;
  20710. _this.linkedSash = undefined;
  20711. _this.orthogonalStartSashDisposables = _this._register(new lifecycle_1.DisposableStore());
  20712. _this.orthogonalEndSashDisposables = _this._register(new lifecycle_1.DisposableStore());
  20713. _this.el = dom_1.append(container, dom_1.$('.monaco-sash'));
  20714. if (platform_1.isMacintosh) {
  20715. dom_1.addClass(_this.el, 'mac');
  20716. }
  20717. _this._register(event_2.domEvent(_this.el, 'mousedown')(_this.onMouseDown, _this));
  20718. _this._register(event_2.domEvent(_this.el, 'dblclick')(_this.onMouseDoubleClick, _this));
  20719. _this._register(touch_1.Gesture.addTarget(_this.el));
  20720. _this._register(event_2.domEvent(_this.el, touch_1.EventType.Start)(_this.onTouchStart, _this));
  20721. if (browser_1.isIPad) {
  20722. // see also https://ux.stackexchange.com/questions/39023/what-is-the-optimum-button-size-of-touch-screen-applications
  20723. dom_1.addClass(_this.el, 'touch');
  20724. }
  20725. _this.setOrientation(options.orientation || 0 /* VERTICAL */);
  20726. _this.hidden = false;
  20727. _this.layoutProvider = layoutProvider;
  20728. _this.orthogonalStartSash = options.orthogonalStartSash;
  20729. _this.orthogonalEndSash = options.orthogonalEndSash;
  20730. dom_1.toggleClass(_this.el, 'debug', DEBUG);
  20731. return _this;
  20732. }
  20733. Object.defineProperty(Sash.prototype, "state", {
  20734. get: function () { return this._state; },
  20735. set: function (state) {
  20736. if (this._state === state) {
  20737. return;
  20738. }
  20739. dom_1.toggleClass(this.el, 'disabled', state === 0 /* Disabled */);
  20740. dom_1.toggleClass(this.el, 'minimum', state === 1 /* Minimum */);
  20741. dom_1.toggleClass(this.el, 'maximum', state === 2 /* Maximum */);
  20742. this._state = state;
  20743. this._onDidEnablementChange.fire(state);
  20744. },
  20745. enumerable: true,
  20746. configurable: true
  20747. });
  20748. Object.defineProperty(Sash.prototype, "orthogonalStartSash", {
  20749. get: function () { return this._orthogonalStartSash; },
  20750. set: function (sash) {
  20751. this.orthogonalStartSashDisposables.clear();
  20752. if (sash) {
  20753. this.orthogonalStartSashDisposables.add(sash.onDidEnablementChange(this.onOrthogonalStartSashEnablementChange, this));
  20754. this.onOrthogonalStartSashEnablementChange(sash.state);
  20755. }
  20756. else {
  20757. this.onOrthogonalStartSashEnablementChange(0 /* Disabled */);
  20758. }
  20759. this._orthogonalStartSash = sash;
  20760. },
  20761. enumerable: true,
  20762. configurable: true
  20763. });
  20764. Object.defineProperty(Sash.prototype, "orthogonalEndSash", {
  20765. get: function () { return this._orthogonalEndSash; },
  20766. set: function (sash) {
  20767. this.orthogonalEndSashDisposables.clear();
  20768. if (sash) {
  20769. this.orthogonalEndSashDisposables.add(sash.onDidEnablementChange(this.onOrthogonalEndSashEnablementChange, this));
  20770. this.onOrthogonalEndSashEnablementChange(sash.state);
  20771. }
  20772. else {
  20773. this.onOrthogonalEndSashEnablementChange(0 /* Disabled */);
  20774. }
  20775. this._orthogonalEndSash = sash;
  20776. },
  20777. enumerable: true,
  20778. configurable: true
  20779. });
  20780. Sash.prototype.setOrientation = function (orientation) {
  20781. this.orientation = orientation;
  20782. if (this.orientation === 1 /* HORIZONTAL */) {
  20783. dom_1.addClass(this.el, 'horizontal');
  20784. dom_1.removeClass(this.el, 'vertical');
  20785. }
  20786. else {
  20787. dom_1.removeClass(this.el, 'horizontal');
  20788. dom_1.addClass(this.el, 'vertical');
  20789. }
  20790. if (this.layoutProvider) {
  20791. this.layout();
  20792. }
  20793. };
  20794. Sash.prototype.onMouseDown = function (e) {
  20795. var _this = this;
  20796. dom_1.EventHelper.stop(e, false);
  20797. var isMultisashResize = false;
  20798. if (!e.__orthogonalSashEvent) {
  20799. var orthogonalSash = this.getOrthogonalSash(e);
  20800. if (orthogonalSash) {
  20801. isMultisashResize = true;
  20802. e.__orthogonalSashEvent = true;
  20803. orthogonalSash.onMouseDown(e);
  20804. }
  20805. }
  20806. if (this.linkedSash && !e.__linkedSashEvent) {
  20807. e.__linkedSashEvent = true;
  20808. this.linkedSash.onMouseDown(e);
  20809. }
  20810. if (!this.state) {
  20811. return;
  20812. }
  20813. // Select both iframes and webviews; internally Electron nests an iframe
  20814. // in its <webview> component, but this isn't queryable.
  20815. var iframes = __spreadArrays(dom_1.getElementsByTagName('iframe'), dom_1.getElementsByTagName('webview'));
  20816. for (var _i = 0, iframes_1 = iframes; _i < iframes_1.length; _i++) {
  20817. var iframe = iframes_1[_i];
  20818. iframe.style.pointerEvents = 'none'; // disable mouse events on iframes as long as we drag the sash
  20819. }
  20820. var mouseDownEvent = new mouseEvent_1.StandardMouseEvent(e);
  20821. var startX = mouseDownEvent.posx;
  20822. var startY = mouseDownEvent.posy;
  20823. var altKey = mouseDownEvent.altKey;
  20824. var startEvent = { startX: startX, currentX: startX, startY: startY, currentY: startY, altKey: altKey };
  20825. dom_1.addClass(this.el, 'active');
  20826. this._onDidStart.fire(startEvent);
  20827. // fix https://github.com/Microsoft/vscode/issues/21675
  20828. var style = dom_1.createStyleSheet(this.el);
  20829. var updateStyle = function () {
  20830. var cursor = '';
  20831. if (isMultisashResize) {
  20832. cursor = 'all-scroll';
  20833. }
  20834. else if (_this.orientation === 1 /* HORIZONTAL */) {
  20835. if (_this.state === 1 /* Minimum */) {
  20836. cursor = 's-resize';
  20837. }
  20838. else if (_this.state === 2 /* Maximum */) {
  20839. cursor = 'n-resize';
  20840. }
  20841. else {
  20842. cursor = platform_1.isMacintosh ? 'row-resize' : 'ns-resize';
  20843. }
  20844. }
  20845. else {
  20846. if (_this.state === 1 /* Minimum */) {
  20847. cursor = 'e-resize';
  20848. }
  20849. else if (_this.state === 2 /* Maximum */) {
  20850. cursor = 'w-resize';
  20851. }
  20852. else {
  20853. cursor = platform_1.isMacintosh ? 'col-resize' : 'ew-resize';
  20854. }
  20855. }
  20856. style.innerHTML = "* { cursor: " + cursor + " !important; }";
  20857. };
  20858. var disposables = new lifecycle_1.DisposableStore();
  20859. updateStyle();
  20860. if (!isMultisashResize) {
  20861. this.onDidEnablementChange(updateStyle, null, disposables);
  20862. }
  20863. var onMouseMove = function (e) {
  20864. dom_1.EventHelper.stop(e, false);
  20865. var mouseMoveEvent = new mouseEvent_1.StandardMouseEvent(e);
  20866. var event = { startX: startX, currentX: mouseMoveEvent.posx, startY: startY, currentY: mouseMoveEvent.posy, altKey: altKey };
  20867. _this._onDidChange.fire(event);
  20868. };
  20869. var onMouseUp = function (e) {
  20870. dom_1.EventHelper.stop(e, false);
  20871. _this.el.removeChild(style);
  20872. dom_1.removeClass(_this.el, 'active');
  20873. _this._onDidEnd.fire();
  20874. disposables.dispose();
  20875. for (var _i = 0, iframes_2 = iframes; _i < iframes_2.length; _i++) {
  20876. var iframe = iframes_2[_i];
  20877. iframe.style.pointerEvents = 'auto';
  20878. }
  20879. };
  20880. event_2.domEvent(window, 'mousemove')(onMouseMove, null, disposables);
  20881. event_2.domEvent(window, 'mouseup')(onMouseUp, null, disposables);
  20882. };
  20883. Sash.prototype.onMouseDoubleClick = function (e) {
  20884. var orthogonalSash = this.getOrthogonalSash(e);
  20885. if (orthogonalSash) {
  20886. orthogonalSash._onDidReset.fire();
  20887. }
  20888. if (this.linkedSash) {
  20889. this.linkedSash._onDidReset.fire();
  20890. }
  20891. this._onDidReset.fire();
  20892. };
  20893. Sash.prototype.onTouchStart = function (event) {
  20894. var _this = this;
  20895. dom_1.EventHelper.stop(event);
  20896. var listeners = [];
  20897. var startX = event.pageX;
  20898. var startY = event.pageY;
  20899. var altKey = event.altKey;
  20900. this._onDidStart.fire({
  20901. startX: startX,
  20902. currentX: startX,
  20903. startY: startY,
  20904. currentY: startY,
  20905. altKey: altKey
  20906. });
  20907. listeners.push(dom_1.addDisposableListener(this.el, touch_1.EventType.Change, function (event) {
  20908. if (types.isNumber(event.pageX) && types.isNumber(event.pageY)) {
  20909. _this._onDidChange.fire({
  20910. startX: startX,
  20911. currentX: event.pageX,
  20912. startY: startY,
  20913. currentY: event.pageY,
  20914. altKey: altKey
  20915. });
  20916. }
  20917. }));
  20918. listeners.push(dom_1.addDisposableListener(this.el, touch_1.EventType.End, function (event) {
  20919. _this._onDidEnd.fire();
  20920. lifecycle_1.dispose(listeners);
  20921. }));
  20922. };
  20923. Sash.prototype.layout = function () {
  20924. var size = browser_1.isIPad ? 20 : 4;
  20925. if (this.orientation === 0 /* VERTICAL */) {
  20926. var verticalProvider = this.layoutProvider;
  20927. this.el.style.left = verticalProvider.getVerticalSashLeft(this) - (size / 2) + 'px';
  20928. if (verticalProvider.getVerticalSashTop) {
  20929. this.el.style.top = verticalProvider.getVerticalSashTop(this) + 'px';
  20930. }
  20931. if (verticalProvider.getVerticalSashHeight) {
  20932. this.el.style.height = verticalProvider.getVerticalSashHeight(this) + 'px';
  20933. }
  20934. }
  20935. else {
  20936. var horizontalProvider = this.layoutProvider;
  20937. this.el.style.top = horizontalProvider.getHorizontalSashTop(this) - (size / 2) + 'px';
  20938. if (horizontalProvider.getHorizontalSashLeft) {
  20939. this.el.style.left = horizontalProvider.getHorizontalSashLeft(this) + 'px';
  20940. }
  20941. if (horizontalProvider.getHorizontalSashWidth) {
  20942. this.el.style.width = horizontalProvider.getHorizontalSashWidth(this) + 'px';
  20943. }
  20944. }
  20945. };
  20946. Sash.prototype.hide = function () {
  20947. this.hidden = true;
  20948. this.el.style.display = 'none';
  20949. this.el.setAttribute('aria-hidden', 'true');
  20950. };
  20951. Sash.prototype.onOrthogonalStartSashEnablementChange = function (state) {
  20952. dom_1.toggleClass(this.el, 'orthogonal-start', state !== 0 /* Disabled */);
  20953. };
  20954. Sash.prototype.onOrthogonalEndSashEnablementChange = function (state) {
  20955. dom_1.toggleClass(this.el, 'orthogonal-end', state !== 0 /* Disabled */);
  20956. };
  20957. Sash.prototype.getOrthogonalSash = function (e) {
  20958. if (this.orientation === 0 /* VERTICAL */) {
  20959. if (e.offsetY <= 4) {
  20960. return this.orthogonalStartSash;
  20961. }
  20962. else if (e.offsetY >= this.el.clientHeight - 4) {
  20963. return this.orthogonalEndSash;
  20964. }
  20965. }
  20966. else {
  20967. if (e.offsetX <= 4) {
  20968. return this.orthogonalStartSash;
  20969. }
  20970. else if (e.offsetX >= this.el.clientWidth - 4) {
  20971. return this.orthogonalEndSash;
  20972. }
  20973. }
  20974. return undefined;
  20975. };
  20976. Sash.prototype.dispose = function () {
  20977. _super.prototype.dispose.call(this);
  20978. this.el.remove();
  20979. };
  20980. return Sash;
  20981. }(lifecycle_1.Disposable));
  20982. exports.Sash = Sash;
  20983. });
  20984. define(__m[276/*vs/css!vs/base/browser/ui/scrollbar/media/scrollbars*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  20985. /*---------------------------------------------------------------------------------------------
  20986. * Copyright (c) Microsoft Corporation. All rights reserved.
  20987. * Licensed under the MIT License. See License.txt in the project root for license information.
  20988. *--------------------------------------------------------------------------------------------*/
  20989. define(__m[53/*vs/base/browser/ui/scrollbar/scrollableElement*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,6/*vs/base/browser/dom*/,28/*vs/base/browser/fastDomNode*/,45/*vs/base/browser/mouseEvent*/,250/*vs/base/browser/ui/scrollbar/horizontalScrollbar*/,251/*vs/base/browser/ui/scrollbar/verticalScrollbar*/,47/*vs/base/browser/ui/widget*/,15/*vs/base/common/async*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,176/*vs/base/common/scrollable*/,276/*vs/css!vs/base/browser/ui/scrollbar/media/scrollbars*/]), function (require, exports, browser_1, dom, fastDomNode_1, mouseEvent_1, horizontalScrollbar_1, verticalScrollbar_1, widget_1, async_1, event_1, lifecycle_1, platform, scrollable_1) {
  20990. "use strict";
  20991. Object.defineProperty(exports, "__esModule", { value: true });
  20992. var HIDE_TIMEOUT = 500;
  20993. var SCROLL_WHEEL_SENSITIVITY = 50;
  20994. var SCROLL_WHEEL_SMOOTH_SCROLL_ENABLED = true;
  20995. var MouseWheelClassifierItem = /** @class */ (function () {
  20996. function MouseWheelClassifierItem(timestamp, deltaX, deltaY) {
  20997. this.timestamp = timestamp;
  20998. this.deltaX = deltaX;
  20999. this.deltaY = deltaY;
  21000. this.score = 0;
  21001. }
  21002. return MouseWheelClassifierItem;
  21003. }());
  21004. var MouseWheelClassifier = /** @class */ (function () {
  21005. function MouseWheelClassifier() {
  21006. this._capacity = 5;
  21007. this._memory = [];
  21008. this._front = -1;
  21009. this._rear = -1;
  21010. }
  21011. MouseWheelClassifier.prototype.isPhysicalMouseWheel = function () {
  21012. if (this._front === -1 && this._rear === -1) {
  21013. // no elements
  21014. return false;
  21015. }
  21016. // 0.5 * last + 0.25 * 2nd last + 0.125 * 3rd last + ...
  21017. var remainingInfluence = 1;
  21018. var score = 0;
  21019. var iteration = 1;
  21020. var index = this._rear;
  21021. do {
  21022. var influence = (index === this._front ? remainingInfluence : Math.pow(2, -iteration));
  21023. remainingInfluence -= influence;
  21024. score += this._memory[index].score * influence;
  21025. if (index === this._front) {
  21026. break;
  21027. }
  21028. index = (this._capacity + index - 1) % this._capacity;
  21029. iteration++;
  21030. } while (true);
  21031. return (score <= 0.5);
  21032. };
  21033. MouseWheelClassifier.prototype.accept = function (timestamp, deltaX, deltaY) {
  21034. var item = new MouseWheelClassifierItem(timestamp, deltaX, deltaY);
  21035. item.score = this._computeScore(item);
  21036. if (this._front === -1 && this._rear === -1) {
  21037. this._memory[0] = item;
  21038. this._front = 0;
  21039. this._rear = 0;
  21040. }
  21041. else {
  21042. this._rear = (this._rear + 1) % this._capacity;
  21043. if (this._rear === this._front) {
  21044. // Drop oldest
  21045. this._front = (this._front + 1) % this._capacity;
  21046. }
  21047. this._memory[this._rear] = item;
  21048. }
  21049. };
  21050. /**
  21051. * A score between 0 and 1 for `item`.
  21052. * - a score towards 0 indicates that the source appears to be a physical mouse wheel
  21053. * - a score towards 1 indicates that the source appears to be a touchpad or magic mouse, etc.
  21054. */
  21055. MouseWheelClassifier.prototype._computeScore = function (item) {
  21056. if (Math.abs(item.deltaX) > 0 && Math.abs(item.deltaY) > 0) {
  21057. // both axes exercised => definitely not a physical mouse wheel
  21058. return 1;
  21059. }
  21060. var score = 0.5;
  21061. var prev = (this._front === -1 && this._rear === -1 ? null : this._memory[this._rear]);
  21062. if (prev) {
  21063. // const deltaT = item.timestamp - prev.timestamp;
  21064. // if (deltaT < 1000 / 30) {
  21065. // // sooner than X times per second => indicator that this is not a physical mouse wheel
  21066. // score += 0.25;
  21067. // }
  21068. // if (item.deltaX === prev.deltaX && item.deltaY === prev.deltaY) {
  21069. // // equal amplitude => indicator that this is a physical mouse wheel
  21070. // score -= 0.25;
  21071. // }
  21072. }
  21073. if (Math.abs(item.deltaX - Math.round(item.deltaX)) > 0 || Math.abs(item.deltaY - Math.round(item.deltaY)) > 0) {
  21074. // non-integer deltas => indicator that this is not a physical mouse wheel
  21075. score += 0.25;
  21076. }
  21077. return Math.min(Math.max(score, 0), 1);
  21078. };
  21079. MouseWheelClassifier.INSTANCE = new MouseWheelClassifier();
  21080. return MouseWheelClassifier;
  21081. }());
  21082. exports.MouseWheelClassifier = MouseWheelClassifier;
  21083. var AbstractScrollableElement = /** @class */ (function (_super) {
  21084. __extends(AbstractScrollableElement, _super);
  21085. function AbstractScrollableElement(element, options, scrollable) {
  21086. var _this = _super.call(this) || this;
  21087. _this._onScroll = _this._register(new event_1.Emitter());
  21088. _this.onScroll = _this._onScroll.event;
  21089. element.style.overflow = 'hidden';
  21090. _this._options = resolveOptions(options);
  21091. _this._scrollable = scrollable;
  21092. _this._register(_this._scrollable.onScroll(function (e) {
  21093. _this._onDidScroll(e);
  21094. _this._onScroll.fire(e);
  21095. }));
  21096. var scrollbarHost = {
  21097. onMouseWheel: function (mouseWheelEvent) { return _this._onMouseWheel(mouseWheelEvent); },
  21098. onDragStart: function () { return _this._onDragStart(); },
  21099. onDragEnd: function () { return _this._onDragEnd(); },
  21100. };
  21101. _this._verticalScrollbar = _this._register(new verticalScrollbar_1.VerticalScrollbar(_this._scrollable, _this._options, scrollbarHost));
  21102. _this._horizontalScrollbar = _this._register(new horizontalScrollbar_1.HorizontalScrollbar(_this._scrollable, _this._options, scrollbarHost));
  21103. _this._domNode = document.createElement('div');
  21104. _this._domNode.className = 'monaco-scrollable-element ' + _this._options.className;
  21105. _this._domNode.setAttribute('role', 'presentation');
  21106. _this._domNode.style.position = 'relative';
  21107. _this._domNode.style.overflow = 'hidden';
  21108. _this._domNode.appendChild(element);
  21109. _this._domNode.appendChild(_this._horizontalScrollbar.domNode.domNode);
  21110. _this._domNode.appendChild(_this._verticalScrollbar.domNode.domNode);
  21111. if (_this._options.useShadows) {
  21112. _this._leftShadowDomNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  21113. _this._leftShadowDomNode.setClassName('shadow');
  21114. _this._domNode.appendChild(_this._leftShadowDomNode.domNode);
  21115. _this._topShadowDomNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  21116. _this._topShadowDomNode.setClassName('shadow');
  21117. _this._domNode.appendChild(_this._topShadowDomNode.domNode);
  21118. _this._topLeftShadowDomNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  21119. _this._topLeftShadowDomNode.setClassName('shadow top-left-corner');
  21120. _this._domNode.appendChild(_this._topLeftShadowDomNode.domNode);
  21121. }
  21122. else {
  21123. _this._leftShadowDomNode = null;
  21124. _this._topShadowDomNode = null;
  21125. _this._topLeftShadowDomNode = null;
  21126. }
  21127. _this._listenOnDomNode = _this._options.listenOnDomNode || _this._domNode;
  21128. _this._mouseWheelToDispose = [];
  21129. _this._setListeningToMouseWheel(_this._options.handleMouseWheel);
  21130. _this.onmouseover(_this._listenOnDomNode, function (e) { return _this._onMouseOver(e); });
  21131. _this.onnonbubblingmouseout(_this._listenOnDomNode, function (e) { return _this._onMouseOut(e); });
  21132. _this._hideTimeout = _this._register(new async_1.TimeoutTimer());
  21133. _this._isDragging = false;
  21134. _this._mouseIsOver = false;
  21135. _this._shouldRender = true;
  21136. _this._revealOnScroll = true;
  21137. return _this;
  21138. }
  21139. AbstractScrollableElement.prototype.dispose = function () {
  21140. this._mouseWheelToDispose = lifecycle_1.dispose(this._mouseWheelToDispose);
  21141. _super.prototype.dispose.call(this);
  21142. };
  21143. /**
  21144. * Get the generated 'scrollable' dom node
  21145. */
  21146. AbstractScrollableElement.prototype.getDomNode = function () {
  21147. return this._domNode;
  21148. };
  21149. AbstractScrollableElement.prototype.getOverviewRulerLayoutInfo = function () {
  21150. return {
  21151. parent: this._domNode,
  21152. insertBefore: this._verticalScrollbar.domNode.domNode,
  21153. };
  21154. };
  21155. /**
  21156. * Delegate a mouse down event to the vertical scrollbar.
  21157. * This is to help with clicking somewhere else and having the scrollbar react.
  21158. */
  21159. AbstractScrollableElement.prototype.delegateVerticalScrollbarMouseDown = function (browserEvent) {
  21160. this._verticalScrollbar.delegateMouseDown(browserEvent);
  21161. };
  21162. AbstractScrollableElement.prototype.getScrollDimensions = function () {
  21163. return this._scrollable.getScrollDimensions();
  21164. };
  21165. AbstractScrollableElement.prototype.setScrollDimensions = function (dimensions) {
  21166. this._scrollable.setScrollDimensions(dimensions);
  21167. };
  21168. /**
  21169. * Update the class name of the scrollable element.
  21170. */
  21171. AbstractScrollableElement.prototype.updateClassName = function (newClassName) {
  21172. this._options.className = newClassName;
  21173. // Defaults are different on Macs
  21174. if (platform.isMacintosh) {
  21175. this._options.className += ' mac';
  21176. }
  21177. this._domNode.className = 'monaco-scrollable-element ' + this._options.className;
  21178. };
  21179. /**
  21180. * Update configuration options for the scrollbar.
  21181. * Really this is Editor.IEditorScrollbarOptions, but base shouldn't
  21182. * depend on Editor.
  21183. */
  21184. AbstractScrollableElement.prototype.updateOptions = function (newOptions) {
  21185. var massagedOptions = resolveOptions(newOptions);
  21186. this._options.handleMouseWheel = massagedOptions.handleMouseWheel;
  21187. this._options.mouseWheelScrollSensitivity = massagedOptions.mouseWheelScrollSensitivity;
  21188. this._options.fastScrollSensitivity = massagedOptions.fastScrollSensitivity;
  21189. this._setListeningToMouseWheel(this._options.handleMouseWheel);
  21190. if (!this._options.lazyRender) {
  21191. this._render();
  21192. }
  21193. };
  21194. // -------------------- mouse wheel scrolling --------------------
  21195. AbstractScrollableElement.prototype._setListeningToMouseWheel = function (shouldListen) {
  21196. var _this = this;
  21197. var isListening = (this._mouseWheelToDispose.length > 0);
  21198. if (isListening === shouldListen) {
  21199. // No change
  21200. return;
  21201. }
  21202. // Stop listening (if necessary)
  21203. this._mouseWheelToDispose = lifecycle_1.dispose(this._mouseWheelToDispose);
  21204. // Start listening (if necessary)
  21205. if (shouldListen) {
  21206. var onMouseWheel = function (browserEvent) {
  21207. _this._onMouseWheel(new mouseEvent_1.StandardWheelEvent(browserEvent));
  21208. };
  21209. this._mouseWheelToDispose.push(dom.addDisposableListener(this._listenOnDomNode, browser_1.isEdgeOrIE ? 'mousewheel' : 'wheel', onMouseWheel, { passive: false }));
  21210. }
  21211. };
  21212. AbstractScrollableElement.prototype._onMouseWheel = function (e) {
  21213. var _a;
  21214. var classifier = MouseWheelClassifier.INSTANCE;
  21215. if (SCROLL_WHEEL_SMOOTH_SCROLL_ENABLED) {
  21216. classifier.accept(Date.now(), e.deltaX, e.deltaY);
  21217. }
  21218. // console.log(`${Date.now()}, ${e.deltaY}, ${e.deltaX}`);
  21219. if (e.deltaY || e.deltaX) {
  21220. var deltaY = e.deltaY * this._options.mouseWheelScrollSensitivity;
  21221. var deltaX = e.deltaX * this._options.mouseWheelScrollSensitivity;
  21222. if (this._options.flipAxes) {
  21223. _a = [deltaX, deltaY], deltaY = _a[0], deltaX = _a[1];
  21224. }
  21225. // Convert vertical scrolling to horizontal if shift is held, this
  21226. // is handled at a higher level on Mac
  21227. var shiftConvert = !platform.isMacintosh && e.browserEvent && e.browserEvent.shiftKey;
  21228. if ((this._options.scrollYToX || shiftConvert) && !deltaX) {
  21229. deltaX = deltaY;
  21230. deltaY = 0;
  21231. }
  21232. if (e.browserEvent && e.browserEvent.altKey) {
  21233. // fastScrolling
  21234. deltaX = deltaX * this._options.fastScrollSensitivity;
  21235. deltaY = deltaY * this._options.fastScrollSensitivity;
  21236. }
  21237. var futureScrollPosition = this._scrollable.getFutureScrollPosition();
  21238. var desiredScrollPosition = {};
  21239. if (deltaY) {
  21240. var desiredScrollTop = futureScrollPosition.scrollTop - SCROLL_WHEEL_SENSITIVITY * deltaY;
  21241. this._verticalScrollbar.writeScrollPosition(desiredScrollPosition, desiredScrollTop);
  21242. }
  21243. if (deltaX) {
  21244. var desiredScrollLeft = futureScrollPosition.scrollLeft - SCROLL_WHEEL_SENSITIVITY * deltaX;
  21245. this._horizontalScrollbar.writeScrollPosition(desiredScrollPosition, desiredScrollLeft);
  21246. }
  21247. // Check that we are scrolling towards a location which is valid
  21248. desiredScrollPosition = this._scrollable.validateScrollPosition(desiredScrollPosition);
  21249. if (futureScrollPosition.scrollLeft !== desiredScrollPosition.scrollLeft || futureScrollPosition.scrollTop !== desiredScrollPosition.scrollTop) {
  21250. var canPerformSmoothScroll = (SCROLL_WHEEL_SMOOTH_SCROLL_ENABLED
  21251. && this._options.mouseWheelSmoothScroll
  21252. && classifier.isPhysicalMouseWheel());
  21253. if (canPerformSmoothScroll) {
  21254. this._scrollable.setScrollPositionSmooth(desiredScrollPosition);
  21255. }
  21256. else {
  21257. this._scrollable.setScrollPositionNow(desiredScrollPosition);
  21258. }
  21259. this._shouldRender = true;
  21260. }
  21261. }
  21262. if (this._options.alwaysConsumeMouseWheel || this._shouldRender) {
  21263. e.preventDefault();
  21264. e.stopPropagation();
  21265. }
  21266. };
  21267. AbstractScrollableElement.prototype._onDidScroll = function (e) {
  21268. this._shouldRender = this._horizontalScrollbar.onDidScroll(e) || this._shouldRender;
  21269. this._shouldRender = this._verticalScrollbar.onDidScroll(e) || this._shouldRender;
  21270. if (this._options.useShadows) {
  21271. this._shouldRender = true;
  21272. }
  21273. if (this._revealOnScroll) {
  21274. this._reveal();
  21275. }
  21276. if (!this._options.lazyRender) {
  21277. this._render();
  21278. }
  21279. };
  21280. /**
  21281. * Render / mutate the DOM now.
  21282. * Should be used together with the ctor option `lazyRender`.
  21283. */
  21284. AbstractScrollableElement.prototype.renderNow = function () {
  21285. if (!this._options.lazyRender) {
  21286. throw new Error('Please use `lazyRender` together with `renderNow`!');
  21287. }
  21288. this._render();
  21289. };
  21290. AbstractScrollableElement.prototype._render = function () {
  21291. if (!this._shouldRender) {
  21292. return;
  21293. }
  21294. this._shouldRender = false;
  21295. this._horizontalScrollbar.render();
  21296. this._verticalScrollbar.render();
  21297. if (this._options.useShadows) {
  21298. var scrollState = this._scrollable.getCurrentScrollPosition();
  21299. var enableTop = scrollState.scrollTop > 0;
  21300. var enableLeft = scrollState.scrollLeft > 0;
  21301. this._leftShadowDomNode.setClassName('shadow' + (enableLeft ? ' left' : ''));
  21302. this._topShadowDomNode.setClassName('shadow' + (enableTop ? ' top' : ''));
  21303. this._topLeftShadowDomNode.setClassName('shadow top-left-corner' + (enableTop ? ' top' : '') + (enableLeft ? ' left' : ''));
  21304. }
  21305. };
  21306. // -------------------- fade in / fade out --------------------
  21307. AbstractScrollableElement.prototype._onDragStart = function () {
  21308. this._isDragging = true;
  21309. this._reveal();
  21310. };
  21311. AbstractScrollableElement.prototype._onDragEnd = function () {
  21312. this._isDragging = false;
  21313. this._hide();
  21314. };
  21315. AbstractScrollableElement.prototype._onMouseOut = function (e) {
  21316. this._mouseIsOver = false;
  21317. this._hide();
  21318. };
  21319. AbstractScrollableElement.prototype._onMouseOver = function (e) {
  21320. this._mouseIsOver = true;
  21321. this._reveal();
  21322. };
  21323. AbstractScrollableElement.prototype._reveal = function () {
  21324. this._verticalScrollbar.beginReveal();
  21325. this._horizontalScrollbar.beginReveal();
  21326. this._scheduleHide();
  21327. };
  21328. AbstractScrollableElement.prototype._hide = function () {
  21329. if (!this._mouseIsOver && !this._isDragging) {
  21330. this._verticalScrollbar.beginHide();
  21331. this._horizontalScrollbar.beginHide();
  21332. }
  21333. };
  21334. AbstractScrollableElement.prototype._scheduleHide = function () {
  21335. var _this = this;
  21336. if (!this._mouseIsOver && !this._isDragging) {
  21337. this._hideTimeout.cancelAndSet(function () { return _this._hide(); }, HIDE_TIMEOUT);
  21338. }
  21339. };
  21340. return AbstractScrollableElement;
  21341. }(widget_1.Widget));
  21342. exports.AbstractScrollableElement = AbstractScrollableElement;
  21343. var ScrollableElement = /** @class */ (function (_super) {
  21344. __extends(ScrollableElement, _super);
  21345. function ScrollableElement(element, options) {
  21346. var _this = this;
  21347. options = options || {};
  21348. options.mouseWheelSmoothScroll = false;
  21349. var scrollable = new scrollable_1.Scrollable(0, function (callback) { return dom.scheduleAtNextAnimationFrame(callback); });
  21350. _this = _super.call(this, element, options, scrollable) || this;
  21351. _this._register(scrollable);
  21352. return _this;
  21353. }
  21354. ScrollableElement.prototype.setScrollPosition = function (update) {
  21355. this._scrollable.setScrollPositionNow(update);
  21356. };
  21357. ScrollableElement.prototype.getScrollPosition = function () {
  21358. return this._scrollable.getCurrentScrollPosition();
  21359. };
  21360. return ScrollableElement;
  21361. }(AbstractScrollableElement));
  21362. exports.ScrollableElement = ScrollableElement;
  21363. var SmoothScrollableElement = /** @class */ (function (_super) {
  21364. __extends(SmoothScrollableElement, _super);
  21365. function SmoothScrollableElement(element, options, scrollable) {
  21366. return _super.call(this, element, options, scrollable) || this;
  21367. }
  21368. return SmoothScrollableElement;
  21369. }(AbstractScrollableElement));
  21370. exports.SmoothScrollableElement = SmoothScrollableElement;
  21371. var DomScrollableElement = /** @class */ (function (_super) {
  21372. __extends(DomScrollableElement, _super);
  21373. function DomScrollableElement(element, options) {
  21374. var _this = _super.call(this, element, options) || this;
  21375. _this._element = element;
  21376. _this.onScroll(function (e) {
  21377. if (e.scrollTopChanged) {
  21378. _this._element.scrollTop = e.scrollTop;
  21379. }
  21380. if (e.scrollLeftChanged) {
  21381. _this._element.scrollLeft = e.scrollLeft;
  21382. }
  21383. });
  21384. _this.scanDomNode();
  21385. return _this;
  21386. }
  21387. DomScrollableElement.prototype.scanDomNode = function () {
  21388. // width, scrollLeft, scrollWidth, height, scrollTop, scrollHeight
  21389. this.setScrollDimensions({
  21390. width: this._element.clientWidth,
  21391. scrollWidth: this._element.scrollWidth,
  21392. height: this._element.clientHeight,
  21393. scrollHeight: this._element.scrollHeight
  21394. });
  21395. this.setScrollPosition({
  21396. scrollLeft: this._element.scrollLeft,
  21397. scrollTop: this._element.scrollTop,
  21398. });
  21399. };
  21400. return DomScrollableElement;
  21401. }(ScrollableElement));
  21402. exports.DomScrollableElement = DomScrollableElement;
  21403. function resolveOptions(opts) {
  21404. var result = {
  21405. lazyRender: (typeof opts.lazyRender !== 'undefined' ? opts.lazyRender : false),
  21406. className: (typeof opts.className !== 'undefined' ? opts.className : ''),
  21407. useShadows: (typeof opts.useShadows !== 'undefined' ? opts.useShadows : true),
  21408. handleMouseWheel: (typeof opts.handleMouseWheel !== 'undefined' ? opts.handleMouseWheel : true),
  21409. flipAxes: (typeof opts.flipAxes !== 'undefined' ? opts.flipAxes : false),
  21410. alwaysConsumeMouseWheel: (typeof opts.alwaysConsumeMouseWheel !== 'undefined' ? opts.alwaysConsumeMouseWheel : false),
  21411. scrollYToX: (typeof opts.scrollYToX !== 'undefined' ? opts.scrollYToX : false),
  21412. mouseWheelScrollSensitivity: (typeof opts.mouseWheelScrollSensitivity !== 'undefined' ? opts.mouseWheelScrollSensitivity : 1),
  21413. fastScrollSensitivity: (typeof opts.fastScrollSensitivity !== 'undefined' ? opts.fastScrollSensitivity : 5),
  21414. mouseWheelSmoothScroll: (typeof opts.mouseWheelSmoothScroll !== 'undefined' ? opts.mouseWheelSmoothScroll : true),
  21415. arrowSize: (typeof opts.arrowSize !== 'undefined' ? opts.arrowSize : 11),
  21416. listenOnDomNode: (typeof opts.listenOnDomNode !== 'undefined' ? opts.listenOnDomNode : null),
  21417. horizontal: (typeof opts.horizontal !== 'undefined' ? opts.horizontal : 1 /* Auto */),
  21418. horizontalScrollbarSize: (typeof opts.horizontalScrollbarSize !== 'undefined' ? opts.horizontalScrollbarSize : 10),
  21419. horizontalSliderSize: (typeof opts.horizontalSliderSize !== 'undefined' ? opts.horizontalSliderSize : 0),
  21420. horizontalHasArrows: (typeof opts.horizontalHasArrows !== 'undefined' ? opts.horizontalHasArrows : false),
  21421. vertical: (typeof opts.vertical !== 'undefined' ? opts.vertical : 1 /* Auto */),
  21422. verticalScrollbarSize: (typeof opts.verticalScrollbarSize !== 'undefined' ? opts.verticalScrollbarSize : 10),
  21423. verticalHasArrows: (typeof opts.verticalHasArrows !== 'undefined' ? opts.verticalHasArrows : false),
  21424. verticalSliderSize: (typeof opts.verticalSliderSize !== 'undefined' ? opts.verticalSliderSize : 0)
  21425. };
  21426. result.horizontalSliderSize = (typeof opts.horizontalSliderSize !== 'undefined' ? opts.horizontalSliderSize : result.horizontalScrollbarSize);
  21427. result.verticalSliderSize = (typeof opts.verticalSliderSize !== 'undefined' ? opts.verticalSliderSize : result.verticalScrollbarSize);
  21428. // Defaults are different on Macs
  21429. if (platform.isMacintosh) {
  21430. result.className += ' mac';
  21431. }
  21432. return result;
  21433. }
  21434. });
  21435. /*---------------------------------------------------------------------------------------------
  21436. * Copyright (c) Microsoft Corporation. All rights reserved.
  21437. * Licensed under the MIT License. See License.txt in the project root for license information.
  21438. *--------------------------------------------------------------------------------------------*/
  21439. var __spreadArrays = (this && this.__spreadArrays) || function () {
  21440. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  21441. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  21442. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  21443. r[k] = a[j];
  21444. return r;
  21445. };
  21446. define(__m[140/*vs/base/browser/ui/list/listView*/], __M([0/*require*/,1/*exports*/,31/*vs/base/common/objects*/,2/*vs/base/common/lifecycle*/,57/*vs/base/browser/touch*/,6/*vs/base/browser/dom*/,4/*vs/base/common/event*/,52/*vs/base/browser/event*/,53/*vs/base/browser/ui/scrollbar/scrollableElement*/,246/*vs/base/browser/ui/list/rangeMap*/,249/*vs/base/browser/ui/list/rowCache*/,101/*vs/base/common/decorators*/,103/*vs/base/common/range*/,19/*vs/base/common/arrays*/,98/*vs/base/browser/dnd*/,15/*vs/base/common/async*/,24/*vs/base/browser/browser*/]), function (require, exports, objects_1, lifecycle_1, touch_1, DOM, event_1, event_2, scrollableElement_1, rangeMap_1, rowCache_1, decorators_1, range_1, arrays_1, dnd_1, async_1, browser_1) {
  21447. "use strict";
  21448. Object.defineProperty(exports, "__esModule", { value: true });
  21449. var DefaultOptions = {
  21450. useShadows: true,
  21451. verticalScrollMode: 1 /* Auto */,
  21452. setRowLineHeight: true,
  21453. supportDynamicHeights: false,
  21454. dnd: {
  21455. getDragElements: function (e) { return [e]; },
  21456. getDragURI: function () { return null; },
  21457. onDragStart: function () { },
  21458. onDragOver: function () { return false; },
  21459. drop: function () { }
  21460. },
  21461. horizontalScrolling: false
  21462. };
  21463. var ElementsDragAndDropData = /** @class */ (function () {
  21464. function ElementsDragAndDropData(elements) {
  21465. this.elements = elements;
  21466. }
  21467. ElementsDragAndDropData.prototype.update = function () { };
  21468. ElementsDragAndDropData.prototype.getData = function () {
  21469. return this.elements;
  21470. };
  21471. return ElementsDragAndDropData;
  21472. }());
  21473. exports.ElementsDragAndDropData = ElementsDragAndDropData;
  21474. var ExternalElementsDragAndDropData = /** @class */ (function () {
  21475. function ExternalElementsDragAndDropData(elements) {
  21476. this.elements = elements;
  21477. }
  21478. ExternalElementsDragAndDropData.prototype.update = function () { };
  21479. ExternalElementsDragAndDropData.prototype.getData = function () {
  21480. return this.elements;
  21481. };
  21482. return ExternalElementsDragAndDropData;
  21483. }());
  21484. exports.ExternalElementsDragAndDropData = ExternalElementsDragAndDropData;
  21485. var DesktopDragAndDropData = /** @class */ (function () {
  21486. function DesktopDragAndDropData() {
  21487. this.types = [];
  21488. this.files = [];
  21489. }
  21490. DesktopDragAndDropData.prototype.update = function (dataTransfer) {
  21491. var _a;
  21492. if (dataTransfer.types) {
  21493. (_a = this.types).splice.apply(_a, __spreadArrays([0, this.types.length], dataTransfer.types));
  21494. }
  21495. if (dataTransfer.files) {
  21496. this.files.splice(0, this.files.length);
  21497. for (var i = 0; i < dataTransfer.files.length; i++) {
  21498. var file = dataTransfer.files.item(i);
  21499. if (file && (file.size || file.type)) {
  21500. this.files.push(file);
  21501. }
  21502. }
  21503. }
  21504. };
  21505. DesktopDragAndDropData.prototype.getData = function () {
  21506. return {
  21507. types: this.types,
  21508. files: this.files
  21509. };
  21510. };
  21511. return DesktopDragAndDropData;
  21512. }());
  21513. exports.DesktopDragAndDropData = DesktopDragAndDropData;
  21514. function equalsDragFeedback(f1, f2) {
  21515. if (Array.isArray(f1) && Array.isArray(f2)) {
  21516. return arrays_1.equals(f1, f2);
  21517. }
  21518. return f1 === f2;
  21519. }
  21520. var ListView = /** @class */ (function () {
  21521. function ListView(container, virtualDelegate, renderers, options) {
  21522. var _this = this;
  21523. if (options === void 0) { options = DefaultOptions; }
  21524. this.virtualDelegate = virtualDelegate;
  21525. this.domId = "list_id_" + ++ListView.InstanceCount;
  21526. this.renderers = new Map();
  21527. this.renderWidth = 0;
  21528. this._scrollHeight = 0;
  21529. this.scrollableElementUpdateDisposable = null;
  21530. this.scrollableElementWidthDelayer = new async_1.Delayer(50);
  21531. this.splicing = false;
  21532. this.dragOverAnimationStopDisposable = lifecycle_1.Disposable.None;
  21533. this.dragOverMouseY = 0;
  21534. this.canDrop = false;
  21535. this.currentDragFeedbackDisposable = lifecycle_1.Disposable.None;
  21536. this.onDragLeaveTimeout = lifecycle_1.Disposable.None;
  21537. this.disposables = new lifecycle_1.DisposableStore();
  21538. this._onDidChangeContentHeight = new event_1.Emitter();
  21539. if (options.horizontalScrolling && options.supportDynamicHeights) {
  21540. throw new Error('Horizontal scrolling and dynamic heights not supported simultaneously');
  21541. }
  21542. this.items = [];
  21543. this.itemId = 0;
  21544. this.rangeMap = new rangeMap_1.RangeMap();
  21545. for (var _i = 0, renderers_1 = renderers; _i < renderers_1.length; _i++) {
  21546. var renderer = renderers_1[_i];
  21547. this.renderers.set(renderer.templateId, renderer);
  21548. }
  21549. this.cache = this.disposables.add(new rowCache_1.RowCache(this.renderers));
  21550. this.lastRenderTop = 0;
  21551. this.lastRenderHeight = 0;
  21552. this.domNode = document.createElement('div');
  21553. this.domNode.className = 'monaco-list';
  21554. DOM.addClass(this.domNode, this.domId);
  21555. this.domNode.tabIndex = 0;
  21556. DOM.toggleClass(this.domNode, 'mouse-support', typeof options.mouseSupport === 'boolean' ? options.mouseSupport : true);
  21557. this.horizontalScrolling = objects_1.getOrDefault(options, function (o) { return o.horizontalScrolling; }, DefaultOptions.horizontalScrolling);
  21558. DOM.toggleClass(this.domNode, 'horizontal-scrolling', this.horizontalScrolling);
  21559. this.additionalScrollHeight = typeof options.additionalScrollHeight === 'undefined' ? 0 : options.additionalScrollHeight;
  21560. this.ariaProvider = options.ariaProvider || { getSetSize: function (e, i, length) { return length; }, getPosInSet: function (_, index) { return index + 1; } };
  21561. this.rowsContainer = document.createElement('div');
  21562. this.rowsContainer.className = 'monaco-list-rows';
  21563. this.rowsContainer.style.transform = 'translate3d(0px, 0px, 0px)';
  21564. this.disposables.add(touch_1.Gesture.addTarget(this.rowsContainer));
  21565. this.scrollableElement = this.disposables.add(new scrollableElement_1.ScrollableElement(this.rowsContainer, {
  21566. alwaysConsumeMouseWheel: true,
  21567. horizontal: this.horizontalScrolling ? 1 /* Auto */ : 2 /* Hidden */,
  21568. vertical: objects_1.getOrDefault(options, function (o) { return o.verticalScrollMode; }, DefaultOptions.verticalScrollMode),
  21569. useShadows: objects_1.getOrDefault(options, function (o) { return o.useShadows; }, DefaultOptions.useShadows)
  21570. }));
  21571. this.domNode.appendChild(this.scrollableElement.getDomNode());
  21572. container.appendChild(this.domNode);
  21573. this.scrollableElement.onScroll(this.onScroll, this, this.disposables);
  21574. event_2.domEvent(this.rowsContainer, touch_1.EventType.Change)(this.onTouchChange, this, this.disposables);
  21575. // Prevent the monaco-scrollable-element from scrolling
  21576. // https://github.com/Microsoft/vscode/issues/44181
  21577. event_2.domEvent(this.scrollableElement.getDomNode(), 'scroll')(function (e) { return e.target.scrollTop = 0; }, null, this.disposables);
  21578. event_1.Event.map(event_2.domEvent(this.domNode, 'dragover'), function (e) { return _this.toDragEvent(e); })(this.onDragOver, this, this.disposables);
  21579. event_1.Event.map(event_2.domEvent(this.domNode, 'drop'), function (e) { return _this.toDragEvent(e); })(this.onDrop, this, this.disposables);
  21580. event_2.domEvent(this.domNode, 'dragleave')(this.onDragLeave, this, this.disposables);
  21581. event_2.domEvent(window, 'dragend')(this.onDragEnd, this, this.disposables);
  21582. this.setRowLineHeight = objects_1.getOrDefault(options, function (o) { return o.setRowLineHeight; }, DefaultOptions.setRowLineHeight);
  21583. this.supportDynamicHeights = objects_1.getOrDefault(options, function (o) { return o.supportDynamicHeights; }, DefaultOptions.supportDynamicHeights);
  21584. this.dnd = objects_1.getOrDefault(options, function (o) { return o.dnd; }, DefaultOptions.dnd);
  21585. this.layout();
  21586. }
  21587. Object.defineProperty(ListView.prototype, "contentHeight", {
  21588. get: function () { return this.rangeMap.size; },
  21589. enumerable: true,
  21590. configurable: true
  21591. });
  21592. ListView.prototype.splice = function (start, deleteCount, elements) {
  21593. if (elements === void 0) { elements = []; }
  21594. if (this.splicing) {
  21595. throw new Error('Can\'t run recursive splices.');
  21596. }
  21597. this.splicing = true;
  21598. try {
  21599. return this._splice(start, deleteCount, elements);
  21600. }
  21601. finally {
  21602. this.splicing = false;
  21603. this._onDidChangeContentHeight.fire(this.contentHeight);
  21604. }
  21605. };
  21606. ListView.prototype._splice = function (start, deleteCount, elements) {
  21607. var _a;
  21608. var _this = this;
  21609. if (elements === void 0) { elements = []; }
  21610. var previousRenderRange = this.getRenderRange(this.lastRenderTop, this.lastRenderHeight);
  21611. var deleteRange = { start: start, end: start + deleteCount };
  21612. var removeRange = range_1.Range.intersect(previousRenderRange, deleteRange);
  21613. for (var i = removeRange.start; i < removeRange.end; i++) {
  21614. this.removeItemFromDOM(i);
  21615. }
  21616. var previousRestRange = { start: start + deleteCount, end: this.items.length };
  21617. var previousRenderedRestRange = range_1.Range.intersect(previousRestRange, previousRenderRange);
  21618. var previousUnrenderedRestRanges = range_1.Range.relativeComplement(previousRestRange, previousRenderRange);
  21619. var inserted = elements.map(function (element) { return ({
  21620. id: String(_this.itemId++),
  21621. element: element,
  21622. templateId: _this.virtualDelegate.getTemplateId(element),
  21623. size: _this.virtualDelegate.getHeight(element),
  21624. width: undefined,
  21625. hasDynamicHeight: !!_this.virtualDelegate.hasDynamicHeight && _this.virtualDelegate.hasDynamicHeight(element),
  21626. lastDynamicHeightWidth: undefined,
  21627. row: null,
  21628. uri: undefined,
  21629. dropTarget: false,
  21630. dragStartDisposable: lifecycle_1.Disposable.None
  21631. }); });
  21632. var deleted;
  21633. // TODO@joao: improve this optimization to catch even more cases
  21634. if (start === 0 && deleteCount >= this.items.length) {
  21635. this.rangeMap = new rangeMap_1.RangeMap();
  21636. this.rangeMap.splice(0, 0, inserted);
  21637. this.items = inserted;
  21638. deleted = [];
  21639. }
  21640. else {
  21641. this.rangeMap.splice(start, deleteCount, inserted);
  21642. deleted = (_a = this.items).splice.apply(_a, __spreadArrays([start, deleteCount], inserted));
  21643. }
  21644. var delta = elements.length - deleteCount;
  21645. var renderRange = this.getRenderRange(this.lastRenderTop, this.lastRenderHeight);
  21646. var renderedRestRange = rangeMap_1.shift(previousRenderedRestRange, delta);
  21647. var updateRange = range_1.Range.intersect(renderRange, renderedRestRange);
  21648. for (var i = updateRange.start; i < updateRange.end; i++) {
  21649. this.updateItemInDOM(this.items[i], i);
  21650. }
  21651. var removeRanges = range_1.Range.relativeComplement(renderedRestRange, renderRange);
  21652. for (var _i = 0, removeRanges_1 = removeRanges; _i < removeRanges_1.length; _i++) {
  21653. var range = removeRanges_1[_i];
  21654. for (var i = range.start; i < range.end; i++) {
  21655. this.removeItemFromDOM(i);
  21656. }
  21657. }
  21658. var unrenderedRestRanges = previousUnrenderedRestRanges.map(function (r) { return rangeMap_1.shift(r, delta); });
  21659. var elementsRange = { start: start, end: start + elements.length };
  21660. var insertRanges = __spreadArrays([elementsRange], unrenderedRestRanges).map(function (r) { return range_1.Range.intersect(renderRange, r); });
  21661. var beforeElement = this.getNextToLastElement(insertRanges);
  21662. for (var _b = 0, insertRanges_1 = insertRanges; _b < insertRanges_1.length; _b++) {
  21663. var range = insertRanges_1[_b];
  21664. for (var i = range.start; i < range.end; i++) {
  21665. this.insertItemInDOM(i, beforeElement);
  21666. }
  21667. }
  21668. this.eventuallyUpdateScrollDimensions();
  21669. if (this.supportDynamicHeights) {
  21670. this._rerender(this.scrollTop, this.renderHeight);
  21671. }
  21672. return deleted.map(function (i) { return i.element; });
  21673. };
  21674. ListView.prototype.eventuallyUpdateScrollDimensions = function () {
  21675. var _this = this;
  21676. this._scrollHeight = this.contentHeight;
  21677. this.rowsContainer.style.height = this._scrollHeight + "px";
  21678. if (!this.scrollableElementUpdateDisposable) {
  21679. this.scrollableElementUpdateDisposable = DOM.scheduleAtNextAnimationFrame(function () {
  21680. _this.scrollableElement.setScrollDimensions({ scrollHeight: _this.scrollHeight });
  21681. _this.updateScrollWidth();
  21682. _this.scrollableElementUpdateDisposable = null;
  21683. });
  21684. }
  21685. };
  21686. ListView.prototype.eventuallyUpdateScrollWidth = function () {
  21687. var _this = this;
  21688. if (!this.horizontalScrolling) {
  21689. return;
  21690. }
  21691. this.scrollableElementWidthDelayer.trigger(function () { return _this.updateScrollWidth(); });
  21692. };
  21693. ListView.prototype.updateScrollWidth = function () {
  21694. if (!this.horizontalScrolling) {
  21695. return;
  21696. }
  21697. if (this.items.length === 0) {
  21698. this.scrollableElement.setScrollDimensions({ scrollWidth: 0 });
  21699. }
  21700. var scrollWidth = 0;
  21701. for (var _i = 0, _a = this.items; _i < _a.length; _i++) {
  21702. var item = _a[_i];
  21703. if (typeof item.width !== 'undefined') {
  21704. scrollWidth = Math.max(scrollWidth, item.width);
  21705. }
  21706. }
  21707. this.scrollWidth = scrollWidth;
  21708. this.scrollableElement.setScrollDimensions({ scrollWidth: scrollWidth + 10 });
  21709. };
  21710. ListView.prototype.rerender = function () {
  21711. if (!this.supportDynamicHeights) {
  21712. return;
  21713. }
  21714. for (var _i = 0, _a = this.items; _i < _a.length; _i++) {
  21715. var item = _a[_i];
  21716. item.lastDynamicHeightWidth = undefined;
  21717. }
  21718. this._rerender(this.lastRenderTop, this.lastRenderHeight);
  21719. };
  21720. Object.defineProperty(ListView.prototype, "length", {
  21721. get: function () {
  21722. return this.items.length;
  21723. },
  21724. enumerable: true,
  21725. configurable: true
  21726. });
  21727. Object.defineProperty(ListView.prototype, "renderHeight", {
  21728. get: function () {
  21729. var scrollDimensions = this.scrollableElement.getScrollDimensions();
  21730. return scrollDimensions.height;
  21731. },
  21732. enumerable: true,
  21733. configurable: true
  21734. });
  21735. ListView.prototype.element = function (index) {
  21736. return this.items[index].element;
  21737. };
  21738. ListView.prototype.domElement = function (index) {
  21739. var row = this.items[index].row;
  21740. return row && row.domNode;
  21741. };
  21742. ListView.prototype.elementHeight = function (index) {
  21743. return this.items[index].size;
  21744. };
  21745. ListView.prototype.elementTop = function (index) {
  21746. return this.rangeMap.positionAt(index);
  21747. };
  21748. ListView.prototype.indexAt = function (position) {
  21749. return this.rangeMap.indexAt(position);
  21750. };
  21751. ListView.prototype.indexAfter = function (position) {
  21752. return this.rangeMap.indexAfter(position);
  21753. };
  21754. ListView.prototype.layout = function (height, width) {
  21755. var scrollDimensions = {
  21756. height: typeof height === 'number' ? height : DOM.getContentHeight(this.domNode)
  21757. };
  21758. if (this.scrollableElementUpdateDisposable) {
  21759. this.scrollableElementUpdateDisposable.dispose();
  21760. this.scrollableElementUpdateDisposable = null;
  21761. scrollDimensions.scrollHeight = this.scrollHeight;
  21762. }
  21763. this.scrollableElement.setScrollDimensions(scrollDimensions);
  21764. if (typeof width !== 'undefined') {
  21765. this.renderWidth = width;
  21766. if (this.supportDynamicHeights) {
  21767. this._rerender(this.scrollTop, this.renderHeight);
  21768. }
  21769. if (this.horizontalScrolling) {
  21770. this.scrollableElement.setScrollDimensions({
  21771. width: typeof width === 'number' ? width : DOM.getContentWidth(this.domNode)
  21772. });
  21773. }
  21774. }
  21775. };
  21776. // Render
  21777. ListView.prototype.render = function (renderTop, renderHeight, renderLeft, scrollWidth) {
  21778. var previousRenderRange = this.getRenderRange(this.lastRenderTop, this.lastRenderHeight);
  21779. var renderRange = this.getRenderRange(renderTop, renderHeight);
  21780. var rangesToInsert = range_1.Range.relativeComplement(renderRange, previousRenderRange);
  21781. var rangesToRemove = range_1.Range.relativeComplement(previousRenderRange, renderRange);
  21782. var beforeElement = this.getNextToLastElement(rangesToInsert);
  21783. for (var _i = 0, rangesToInsert_1 = rangesToInsert; _i < rangesToInsert_1.length; _i++) {
  21784. var range = rangesToInsert_1[_i];
  21785. for (var i = range.start; i < range.end; i++) {
  21786. this.insertItemInDOM(i, beforeElement);
  21787. }
  21788. }
  21789. for (var _a = 0, rangesToRemove_1 = rangesToRemove; _a < rangesToRemove_1.length; _a++) {
  21790. var range = rangesToRemove_1[_a];
  21791. for (var i = range.start; i < range.end; i++) {
  21792. this.removeItemFromDOM(i);
  21793. }
  21794. }
  21795. this.rowsContainer.style.left = "-" + renderLeft + "px";
  21796. this.rowsContainer.style.top = "-" + renderTop + "px";
  21797. if (this.horizontalScrolling) {
  21798. this.rowsContainer.style.width = Math.max(scrollWidth, this.renderWidth) + "px";
  21799. }
  21800. this.lastRenderTop = renderTop;
  21801. this.lastRenderHeight = renderHeight;
  21802. };
  21803. // DOM operations
  21804. ListView.prototype.insertItemInDOM = function (index, beforeElement) {
  21805. var _this = this;
  21806. var item = this.items[index];
  21807. if (!item.row) {
  21808. item.row = this.cache.alloc(item.templateId);
  21809. var role = this.ariaProvider.getRole ? this.ariaProvider.getRole(item.element) : 'treeitem';
  21810. item.row.domNode.setAttribute('role', role);
  21811. var checked = this.ariaProvider.isChecked ? this.ariaProvider.isChecked(item.element) : undefined;
  21812. if (typeof checked !== 'undefined') {
  21813. item.row.domNode.setAttribute('aria-checked', String(checked));
  21814. }
  21815. }
  21816. if (!item.row.domNode.parentElement) {
  21817. if (beforeElement) {
  21818. this.rowsContainer.insertBefore(item.row.domNode, beforeElement);
  21819. }
  21820. else {
  21821. this.rowsContainer.appendChild(item.row.domNode);
  21822. }
  21823. }
  21824. this.updateItemInDOM(item, index);
  21825. var renderer = this.renderers.get(item.templateId);
  21826. if (!renderer) {
  21827. throw new Error("No renderer found for template id " + item.templateId);
  21828. }
  21829. if (renderer) {
  21830. renderer.renderElement(item.element, index, item.row.templateData, item.size);
  21831. }
  21832. var uri = this.dnd.getDragURI(item.element);
  21833. item.dragStartDisposable.dispose();
  21834. item.row.domNode.draggable = !!uri;
  21835. if (uri) {
  21836. var onDragStart = event_2.domEvent(item.row.domNode, 'dragstart');
  21837. item.dragStartDisposable = onDragStart(function (event) { return _this.onDragStart(item.element, uri, event); });
  21838. }
  21839. if (this.horizontalScrolling) {
  21840. this.measureItemWidth(item);
  21841. this.eventuallyUpdateScrollWidth();
  21842. }
  21843. };
  21844. ListView.prototype.measureItemWidth = function (item) {
  21845. if (!item.row || !item.row.domNode) {
  21846. return;
  21847. }
  21848. item.row.domNode.style.width = browser_1.isFirefox ? '-moz-fit-content' : 'fit-content';
  21849. item.width = DOM.getContentWidth(item.row.domNode);
  21850. var style = window.getComputedStyle(item.row.domNode);
  21851. if (style.paddingLeft) {
  21852. item.width += parseFloat(style.paddingLeft);
  21853. }
  21854. if (style.paddingRight) {
  21855. item.width += parseFloat(style.paddingRight);
  21856. }
  21857. item.row.domNode.style.width = '';
  21858. };
  21859. ListView.prototype.updateItemInDOM = function (item, index) {
  21860. item.row.domNode.style.top = this.elementTop(index) + "px";
  21861. item.row.domNode.style.height = item.size + "px";
  21862. if (this.setRowLineHeight) {
  21863. item.row.domNode.style.lineHeight = item.size + "px";
  21864. }
  21865. item.row.domNode.setAttribute('data-index', "" + index);
  21866. item.row.domNode.setAttribute('data-last-element', index === this.length - 1 ? 'true' : 'false');
  21867. item.row.domNode.setAttribute('aria-setsize', String(this.ariaProvider.getSetSize(item.element, index, this.length)));
  21868. item.row.domNode.setAttribute('aria-posinset', String(this.ariaProvider.getPosInSet(item.element, index)));
  21869. item.row.domNode.setAttribute('id', this.getElementDomId(index));
  21870. DOM.toggleClass(item.row.domNode, 'drop-target', item.dropTarget);
  21871. };
  21872. ListView.prototype.removeItemFromDOM = function (index) {
  21873. var item = this.items[index];
  21874. item.dragStartDisposable.dispose();
  21875. var renderer = this.renderers.get(item.templateId);
  21876. if (renderer && renderer.disposeElement) {
  21877. renderer.disposeElement(item.element, index, item.row.templateData, item.size);
  21878. }
  21879. this.cache.release(item.row);
  21880. item.row = null;
  21881. if (this.horizontalScrolling) {
  21882. this.eventuallyUpdateScrollWidth();
  21883. }
  21884. };
  21885. ListView.prototype.getScrollTop = function () {
  21886. var scrollPosition = this.scrollableElement.getScrollPosition();
  21887. return scrollPosition.scrollTop;
  21888. };
  21889. ListView.prototype.setScrollTop = function (scrollTop) {
  21890. if (this.scrollableElementUpdateDisposable) {
  21891. this.scrollableElementUpdateDisposable.dispose();
  21892. this.scrollableElementUpdateDisposable = null;
  21893. this.scrollableElement.setScrollDimensions({ scrollHeight: this.scrollHeight });
  21894. }
  21895. this.scrollableElement.setScrollPosition({ scrollTop: scrollTop });
  21896. };
  21897. Object.defineProperty(ListView.prototype, "scrollTop", {
  21898. get: function () {
  21899. return this.getScrollTop();
  21900. },
  21901. set: function (scrollTop) {
  21902. this.setScrollTop(scrollTop);
  21903. },
  21904. enumerable: true,
  21905. configurable: true
  21906. });
  21907. Object.defineProperty(ListView.prototype, "scrollHeight", {
  21908. get: function () {
  21909. return this._scrollHeight + (this.horizontalScrolling ? 10 : 0) + this.additionalScrollHeight;
  21910. },
  21911. enumerable: true,
  21912. configurable: true
  21913. });
  21914. Object.defineProperty(ListView.prototype, "onMouseClick", {
  21915. // Events
  21916. get: function () {
  21917. var _this = this;
  21918. return event_1.Event.map(event_2.domEvent(this.domNode, 'click'), function (e) { return _this.toMouseEvent(e); });
  21919. },
  21920. enumerable: true,
  21921. configurable: true
  21922. });
  21923. Object.defineProperty(ListView.prototype, "onMouseDblClick", {
  21924. get: function () {
  21925. var _this = this;
  21926. return event_1.Event.map(event_2.domEvent(this.domNode, 'dblclick'), function (e) { return _this.toMouseEvent(e); });
  21927. },
  21928. enumerable: true,
  21929. configurable: true
  21930. });
  21931. Object.defineProperty(ListView.prototype, "onMouseMiddleClick", {
  21932. get: function () {
  21933. var _this = this;
  21934. return event_1.Event.filter(event_1.Event.map(event_2.domEvent(this.domNode, 'auxclick'), function (e) { return _this.toMouseEvent(e); }), function (e) { return e.browserEvent.button === 1; });
  21935. },
  21936. enumerable: true,
  21937. configurable: true
  21938. });
  21939. Object.defineProperty(ListView.prototype, "onMouseDown", {
  21940. get: function () {
  21941. var _this = this;
  21942. return event_1.Event.map(event_2.domEvent(this.domNode, 'mousedown'), function (e) { return _this.toMouseEvent(e); });
  21943. },
  21944. enumerable: true,
  21945. configurable: true
  21946. });
  21947. Object.defineProperty(ListView.prototype, "onContextMenu", {
  21948. get: function () {
  21949. var _this = this;
  21950. return event_1.Event.map(event_2.domEvent(this.domNode, 'contextmenu'), function (e) { return _this.toMouseEvent(e); });
  21951. },
  21952. enumerable: true,
  21953. configurable: true
  21954. });
  21955. Object.defineProperty(ListView.prototype, "onTouchStart", {
  21956. get: function () {
  21957. var _this = this;
  21958. return event_1.Event.map(event_2.domEvent(this.domNode, 'touchstart'), function (e) { return _this.toTouchEvent(e); });
  21959. },
  21960. enumerable: true,
  21961. configurable: true
  21962. });
  21963. Object.defineProperty(ListView.prototype, "onTap", {
  21964. get: function () {
  21965. var _this = this;
  21966. return event_1.Event.map(event_2.domEvent(this.rowsContainer, touch_1.EventType.Tap), function (e) { return _this.toGestureEvent(e); });
  21967. },
  21968. enumerable: true,
  21969. configurable: true
  21970. });
  21971. ListView.prototype.toMouseEvent = function (browserEvent) {
  21972. var index = this.getItemIndexFromEventTarget(browserEvent.target || null);
  21973. var item = typeof index === 'undefined' ? undefined : this.items[index];
  21974. var element = item && item.element;
  21975. return { browserEvent: browserEvent, index: index, element: element };
  21976. };
  21977. ListView.prototype.toTouchEvent = function (browserEvent) {
  21978. var index = this.getItemIndexFromEventTarget(browserEvent.target || null);
  21979. var item = typeof index === 'undefined' ? undefined : this.items[index];
  21980. var element = item && item.element;
  21981. return { browserEvent: browserEvent, index: index, element: element };
  21982. };
  21983. ListView.prototype.toGestureEvent = function (browserEvent) {
  21984. var index = this.getItemIndexFromEventTarget(browserEvent.initialTarget || null);
  21985. var item = typeof index === 'undefined' ? undefined : this.items[index];
  21986. var element = item && item.element;
  21987. return { browserEvent: browserEvent, index: index, element: element };
  21988. };
  21989. ListView.prototype.toDragEvent = function (browserEvent) {
  21990. var index = this.getItemIndexFromEventTarget(browserEvent.target || null);
  21991. var item = typeof index === 'undefined' ? undefined : this.items[index];
  21992. var element = item && item.element;
  21993. return { browserEvent: browserEvent, index: index, element: element };
  21994. };
  21995. ListView.prototype.onScroll = function (e) {
  21996. try {
  21997. this.render(e.scrollTop, e.height, e.scrollLeft, e.scrollWidth);
  21998. if (this.supportDynamicHeights) {
  21999. this._rerender(e.scrollTop, e.height);
  22000. }
  22001. }
  22002. catch (err) {
  22003. console.error('Got bad scroll event:', e);
  22004. throw err;
  22005. }
  22006. };
  22007. ListView.prototype.onTouchChange = function (event) {
  22008. event.preventDefault();
  22009. event.stopPropagation();
  22010. this.scrollTop -= event.translationY;
  22011. };
  22012. // DND
  22013. ListView.prototype.onDragStart = function (element, uri, event) {
  22014. if (!event.dataTransfer) {
  22015. return;
  22016. }
  22017. var elements = this.dnd.getDragElements(element);
  22018. event.dataTransfer.effectAllowed = 'copyMove';
  22019. event.dataTransfer.setData(dnd_1.DataTransfers.RESOURCES, JSON.stringify([uri]));
  22020. if (event.dataTransfer.setDragImage) {
  22021. var label = void 0;
  22022. if (this.dnd.getDragLabel) {
  22023. label = this.dnd.getDragLabel(elements, event);
  22024. }
  22025. if (typeof label === 'undefined') {
  22026. label = String(elements.length);
  22027. }
  22028. var dragImage_1 = DOM.$('.monaco-drag-image');
  22029. dragImage_1.textContent = label;
  22030. document.body.appendChild(dragImage_1);
  22031. event.dataTransfer.setDragImage(dragImage_1, -10, -10);
  22032. setTimeout(function () { return document.body.removeChild(dragImage_1); }, 0);
  22033. }
  22034. this.currentDragData = new ElementsDragAndDropData(elements);
  22035. dnd_1.StaticDND.CurrentDragAndDropData = new ExternalElementsDragAndDropData(elements);
  22036. if (this.dnd.onDragStart) {
  22037. this.dnd.onDragStart(this.currentDragData, event);
  22038. }
  22039. };
  22040. ListView.prototype.onDragOver = function (event) {
  22041. var _this = this;
  22042. event.browserEvent.preventDefault(); // needed so that the drop event fires (https://stackoverflow.com/questions/21339924/drop-event-not-firing-in-chrome)
  22043. this.onDragLeaveTimeout.dispose();
  22044. if (dnd_1.StaticDND.CurrentDragAndDropData && dnd_1.StaticDND.CurrentDragAndDropData.getData() === 'vscode-ui') {
  22045. return false;
  22046. }
  22047. this.setupDragAndDropScrollTopAnimation(event.browserEvent);
  22048. if (!event.browserEvent.dataTransfer) {
  22049. return false;
  22050. }
  22051. // Drag over from outside
  22052. if (!this.currentDragData) {
  22053. if (dnd_1.StaticDND.CurrentDragAndDropData) {
  22054. // Drag over from another list
  22055. this.currentDragData = dnd_1.StaticDND.CurrentDragAndDropData;
  22056. }
  22057. else {
  22058. // Drag over from the desktop
  22059. if (!event.browserEvent.dataTransfer.types) {
  22060. return false;
  22061. }
  22062. this.currentDragData = new DesktopDragAndDropData();
  22063. }
  22064. }
  22065. var result = this.dnd.onDragOver(this.currentDragData, event.element, event.index, event.browserEvent);
  22066. this.canDrop = typeof result === 'boolean' ? result : result.accept;
  22067. if (!this.canDrop) {
  22068. this.currentDragFeedback = undefined;
  22069. this.currentDragFeedbackDisposable.dispose();
  22070. return false;
  22071. }
  22072. event.browserEvent.dataTransfer.dropEffect = (typeof result !== 'boolean' && result.effect === 0 /* Copy */) ? 'copy' : 'move';
  22073. var feedback;
  22074. if (typeof result !== 'boolean' && result.feedback) {
  22075. feedback = result.feedback;
  22076. }
  22077. else {
  22078. if (typeof event.index === 'undefined') {
  22079. feedback = [-1];
  22080. }
  22081. else {
  22082. feedback = [event.index];
  22083. }
  22084. }
  22085. // sanitize feedback list
  22086. feedback = arrays_1.distinct(feedback).filter(function (i) { return i >= -1 && i < _this.length; }).sort(function (a, b) { return a - b; });
  22087. feedback = feedback[0] === -1 ? [-1] : feedback;
  22088. if (equalsDragFeedback(this.currentDragFeedback, feedback)) {
  22089. return true;
  22090. }
  22091. this.currentDragFeedback = feedback;
  22092. this.currentDragFeedbackDisposable.dispose();
  22093. if (feedback[0] === -1) { // entire list feedback
  22094. DOM.addClass(this.domNode, 'drop-target');
  22095. DOM.addClass(this.rowsContainer, 'drop-target');
  22096. this.currentDragFeedbackDisposable = lifecycle_1.toDisposable(function () {
  22097. DOM.removeClass(_this.domNode, 'drop-target');
  22098. DOM.removeClass(_this.rowsContainer, 'drop-target');
  22099. });
  22100. }
  22101. else {
  22102. for (var _i = 0, feedback_1 = feedback; _i < feedback_1.length; _i++) {
  22103. var index = feedback_1[_i];
  22104. var item = this.items[index];
  22105. item.dropTarget = true;
  22106. if (item.row && item.row.domNode) {
  22107. DOM.addClass(item.row.domNode, 'drop-target');
  22108. }
  22109. }
  22110. this.currentDragFeedbackDisposable = lifecycle_1.toDisposable(function () {
  22111. for (var _i = 0, feedback_2 = feedback; _i < feedback_2.length; _i++) {
  22112. var index = feedback_2[_i];
  22113. var item = _this.items[index];
  22114. item.dropTarget = false;
  22115. if (item.row && item.row.domNode) {
  22116. DOM.removeClass(item.row.domNode, 'drop-target');
  22117. }
  22118. }
  22119. });
  22120. }
  22121. return true;
  22122. };
  22123. ListView.prototype.onDragLeave = function () {
  22124. var _this = this;
  22125. this.onDragLeaveTimeout.dispose();
  22126. this.onDragLeaveTimeout = async_1.disposableTimeout(function () { return _this.clearDragOverFeedback(); }, 100);
  22127. };
  22128. ListView.prototype.onDrop = function (event) {
  22129. if (!this.canDrop) {
  22130. return;
  22131. }
  22132. var dragData = this.currentDragData;
  22133. this.teardownDragAndDropScrollTopAnimation();
  22134. this.clearDragOverFeedback();
  22135. this.currentDragData = undefined;
  22136. dnd_1.StaticDND.CurrentDragAndDropData = undefined;
  22137. if (!dragData || !event.browserEvent.dataTransfer) {
  22138. return;
  22139. }
  22140. event.browserEvent.preventDefault();
  22141. dragData.update(event.browserEvent.dataTransfer);
  22142. this.dnd.drop(dragData, event.element, event.index, event.browserEvent);
  22143. };
  22144. ListView.prototype.onDragEnd = function (event) {
  22145. this.canDrop = false;
  22146. this.teardownDragAndDropScrollTopAnimation();
  22147. this.clearDragOverFeedback();
  22148. this.currentDragData = undefined;
  22149. dnd_1.StaticDND.CurrentDragAndDropData = undefined;
  22150. if (this.dnd.onDragEnd) {
  22151. this.dnd.onDragEnd(event);
  22152. }
  22153. };
  22154. ListView.prototype.clearDragOverFeedback = function () {
  22155. this.currentDragFeedback = undefined;
  22156. this.currentDragFeedbackDisposable.dispose();
  22157. this.currentDragFeedbackDisposable = lifecycle_1.Disposable.None;
  22158. };
  22159. // DND scroll top animation
  22160. ListView.prototype.setupDragAndDropScrollTopAnimation = function (event) {
  22161. var _this = this;
  22162. if (!this.dragOverAnimationDisposable) {
  22163. var viewTop = DOM.getTopLeftOffset(this.domNode).top;
  22164. this.dragOverAnimationDisposable = DOM.animate(this.animateDragAndDropScrollTop.bind(this, viewTop));
  22165. }
  22166. this.dragOverAnimationStopDisposable.dispose();
  22167. this.dragOverAnimationStopDisposable = async_1.disposableTimeout(function () {
  22168. if (_this.dragOverAnimationDisposable) {
  22169. _this.dragOverAnimationDisposable.dispose();
  22170. _this.dragOverAnimationDisposable = undefined;
  22171. }
  22172. }, 1000);
  22173. this.dragOverMouseY = event.pageY;
  22174. };
  22175. ListView.prototype.animateDragAndDropScrollTop = function (viewTop) {
  22176. if (this.dragOverMouseY === undefined) {
  22177. return;
  22178. }
  22179. var diff = this.dragOverMouseY - viewTop;
  22180. var upperLimit = this.renderHeight - 35;
  22181. if (diff < 35) {
  22182. this.scrollTop += Math.max(-14, Math.floor(0.3 * (diff - 35)));
  22183. }
  22184. else if (diff > upperLimit) {
  22185. this.scrollTop += Math.min(14, Math.floor(0.3 * (diff - upperLimit)));
  22186. }
  22187. };
  22188. ListView.prototype.teardownDragAndDropScrollTopAnimation = function () {
  22189. this.dragOverAnimationStopDisposable.dispose();
  22190. if (this.dragOverAnimationDisposable) {
  22191. this.dragOverAnimationDisposable.dispose();
  22192. this.dragOverAnimationDisposable = undefined;
  22193. }
  22194. };
  22195. // Util
  22196. ListView.prototype.getItemIndexFromEventTarget = function (target) {
  22197. var element = target;
  22198. while (element instanceof HTMLElement && element !== this.rowsContainer) {
  22199. var rawIndex = element.getAttribute('data-index');
  22200. if (rawIndex) {
  22201. var index = Number(rawIndex);
  22202. if (!isNaN(index)) {
  22203. return index;
  22204. }
  22205. }
  22206. element = element.parentElement;
  22207. }
  22208. return undefined;
  22209. };
  22210. ListView.prototype.getRenderRange = function (renderTop, renderHeight) {
  22211. return {
  22212. start: this.rangeMap.indexAt(renderTop),
  22213. end: this.rangeMap.indexAfter(renderTop + renderHeight - 1)
  22214. };
  22215. };
  22216. /**
  22217. * Given a stable rendered state, checks every rendered element whether it needs
  22218. * to be probed for dynamic height. Adjusts scroll height and top if necessary.
  22219. */
  22220. ListView.prototype._rerender = function (renderTop, renderHeight) {
  22221. var previousRenderRange = this.getRenderRange(renderTop, renderHeight);
  22222. // Let's remember the second element's position, this helps in scrolling up
  22223. // and preserving a linear upwards scroll movement
  22224. var anchorElementIndex;
  22225. var anchorElementTopDelta;
  22226. if (renderTop === this.elementTop(previousRenderRange.start)) {
  22227. anchorElementIndex = previousRenderRange.start;
  22228. anchorElementTopDelta = 0;
  22229. }
  22230. else if (previousRenderRange.end - previousRenderRange.start > 1) {
  22231. anchorElementIndex = previousRenderRange.start + 1;
  22232. anchorElementTopDelta = this.elementTop(anchorElementIndex) - renderTop;
  22233. }
  22234. var heightDiff = 0;
  22235. while (true) {
  22236. var renderRange = this.getRenderRange(renderTop, renderHeight);
  22237. var didChange = false;
  22238. for (var i = renderRange.start; i < renderRange.end; i++) {
  22239. var diff = this.probeDynamicHeight(i);
  22240. if (diff !== 0) {
  22241. this.rangeMap.splice(i, 1, [this.items[i]]);
  22242. }
  22243. heightDiff += diff;
  22244. didChange = didChange || diff !== 0;
  22245. }
  22246. if (!didChange) {
  22247. if (heightDiff !== 0) {
  22248. this.eventuallyUpdateScrollDimensions();
  22249. }
  22250. var unrenderRanges = range_1.Range.relativeComplement(previousRenderRange, renderRange);
  22251. for (var _i = 0, unrenderRanges_1 = unrenderRanges; _i < unrenderRanges_1.length; _i++) {
  22252. var range = unrenderRanges_1[_i];
  22253. for (var i = range.start; i < range.end; i++) {
  22254. if (this.items[i].row) {
  22255. this.removeItemFromDOM(i);
  22256. }
  22257. }
  22258. }
  22259. var renderRanges = range_1.Range.relativeComplement(renderRange, previousRenderRange);
  22260. for (var _a = 0, renderRanges_1 = renderRanges; _a < renderRanges_1.length; _a++) {
  22261. var range = renderRanges_1[_a];
  22262. for (var i = range.start; i < range.end; i++) {
  22263. var afterIndex = i + 1;
  22264. var beforeRow = afterIndex < this.items.length ? this.items[afterIndex].row : null;
  22265. var beforeElement = beforeRow ? beforeRow.domNode : null;
  22266. this.insertItemInDOM(i, beforeElement);
  22267. }
  22268. }
  22269. for (var i = renderRange.start; i < renderRange.end; i++) {
  22270. if (this.items[i].row) {
  22271. this.updateItemInDOM(this.items[i], i);
  22272. }
  22273. }
  22274. if (typeof anchorElementIndex === 'number') {
  22275. this.scrollTop = this.elementTop(anchorElementIndex) - anchorElementTopDelta;
  22276. }
  22277. this._onDidChangeContentHeight.fire(this.contentHeight);
  22278. return;
  22279. }
  22280. }
  22281. };
  22282. ListView.prototype.probeDynamicHeight = function (index) {
  22283. var item = this.items[index];
  22284. if (!item.hasDynamicHeight || item.lastDynamicHeightWidth === this.renderWidth) {
  22285. return 0;
  22286. }
  22287. var size = item.size;
  22288. var row = this.cache.alloc(item.templateId);
  22289. row.domNode.style.height = '';
  22290. this.rowsContainer.appendChild(row.domNode);
  22291. var renderer = this.renderers.get(item.templateId);
  22292. if (renderer) {
  22293. renderer.renderElement(item.element, index, row.templateData, undefined);
  22294. if (renderer.disposeElement) {
  22295. renderer.disposeElement(item.element, index, row.templateData, undefined);
  22296. }
  22297. }
  22298. item.size = row.domNode.offsetHeight;
  22299. if (this.virtualDelegate.setDynamicHeight) {
  22300. this.virtualDelegate.setDynamicHeight(item.element, item.size);
  22301. }
  22302. item.lastDynamicHeightWidth = this.renderWidth;
  22303. this.rowsContainer.removeChild(row.domNode);
  22304. this.cache.release(row);
  22305. return item.size - size;
  22306. };
  22307. ListView.prototype.getNextToLastElement = function (ranges) {
  22308. var lastRange = ranges[ranges.length - 1];
  22309. if (!lastRange) {
  22310. return null;
  22311. }
  22312. var nextToLastItem = this.items[lastRange.end];
  22313. if (!nextToLastItem) {
  22314. return null;
  22315. }
  22316. if (!nextToLastItem.row) {
  22317. return null;
  22318. }
  22319. return nextToLastItem.row.domNode;
  22320. };
  22321. ListView.prototype.getElementDomId = function (index) {
  22322. return this.domId + "_" + index;
  22323. };
  22324. // Dispose
  22325. ListView.prototype.dispose = function () {
  22326. if (this.items) {
  22327. for (var _i = 0, _a = this.items; _i < _a.length; _i++) {
  22328. var item = _a[_i];
  22329. if (item.row) {
  22330. var renderer = this.renderers.get(item.row.templateId);
  22331. if (renderer) {
  22332. renderer.disposeTemplate(item.row.templateData);
  22333. }
  22334. }
  22335. }
  22336. this.items = [];
  22337. }
  22338. if (this.domNode && this.domNode.parentNode) {
  22339. this.domNode.parentNode.removeChild(this.domNode);
  22340. }
  22341. lifecycle_1.dispose(this.disposables);
  22342. };
  22343. ListView.InstanceCount = 0;
  22344. __decorate([
  22345. decorators_1.memoize
  22346. ], ListView.prototype, "onMouseClick", null);
  22347. __decorate([
  22348. decorators_1.memoize
  22349. ], ListView.prototype, "onMouseDblClick", null);
  22350. __decorate([
  22351. decorators_1.memoize
  22352. ], ListView.prototype, "onMouseMiddleClick", null);
  22353. __decorate([
  22354. decorators_1.memoize
  22355. ], ListView.prototype, "onMouseDown", null);
  22356. __decorate([
  22357. decorators_1.memoize
  22358. ], ListView.prototype, "onContextMenu", null);
  22359. __decorate([
  22360. decorators_1.memoize
  22361. ], ListView.prototype, "onTouchStart", null);
  22362. __decorate([
  22363. decorators_1.memoize
  22364. ], ListView.prototype, "onTap", null);
  22365. return ListView;
  22366. }());
  22367. exports.ListView = ListView;
  22368. });
  22369. /*---------------------------------------------------------------------------------------------
  22370. * Copyright (c) Microsoft Corporation. All rights reserved.
  22371. * Licensed under the MIT License. See License.txt in the project root for license information.
  22372. *--------------------------------------------------------------------------------------------*/
  22373. define(__m[277/*vs/base/parts/tree/browser/treeView*/], __M([0/*require*/,1/*exports*/,16/*vs/base/common/platform*/,24/*vs/base/browser/browser*/,2/*vs/base/common/lifecycle*/,6/*vs/base/browser/dom*/,126/*vs/base/common/diff/diff*/,57/*vs/base/browser/touch*/,5/*vs/base/common/strings*/,45/*vs/base/browser/mouseEvent*/,56/*vs/base/browser/keyboardEvent*/,255/*vs/base/parts/tree/browser/treeDnd*/,54/*vs/base/common/iterator*/,53/*vs/base/browser/ui/scrollbar/scrollableElement*/,257/*vs/base/parts/tree/browser/treeViewModel*/,254/*vs/base/parts/tree/browser/tree*/,4/*vs/base/common/event*/,98/*vs/base/browser/dnd*/,137/*vs/base/parts/tree/browser/treeDefaults*/,15/*vs/base/common/async*/]), function (require, exports, Platform, Browser, Lifecycle, DOM, Diff, Touch, strings, Mouse, Keyboard, dnd, iterator_1, scrollableElement_1, treeViewModel_1, _, event_1, dnd_1, treeDefaults_1, async_1) {
  22374. "use strict";
  22375. Object.defineProperty(exports, "__esModule", { value: true });
  22376. function removeFromParent(element) {
  22377. try {
  22378. element.parentElement.removeChild(element);
  22379. }
  22380. catch (e) {
  22381. // this will throw if this happens due to a blur event, nasty business
  22382. }
  22383. }
  22384. var RowCache = /** @class */ (function () {
  22385. function RowCache(context) {
  22386. this.context = context;
  22387. this._cache = { '': [] };
  22388. }
  22389. RowCache.prototype.alloc = function (templateId) {
  22390. var result = this.cache(templateId).pop();
  22391. if (!result) {
  22392. var content = document.createElement('div');
  22393. content.className = 'content';
  22394. var row = document.createElement('div');
  22395. row.appendChild(content);
  22396. var templateData = null;
  22397. try {
  22398. templateData = this.context.renderer.renderTemplate(this.context.tree, templateId, content);
  22399. }
  22400. catch (err) {
  22401. console.error('Tree usage error: exception while rendering template');
  22402. console.error(err);
  22403. }
  22404. result = {
  22405. element: row,
  22406. templateId: templateId,
  22407. templateData: templateData
  22408. };
  22409. }
  22410. return result;
  22411. };
  22412. RowCache.prototype.release = function (templateId, row) {
  22413. removeFromParent(row.element);
  22414. this.cache(templateId).push(row);
  22415. };
  22416. RowCache.prototype.cache = function (templateId) {
  22417. return this._cache[templateId] || (this._cache[templateId] = []);
  22418. };
  22419. RowCache.prototype.garbageCollect = function () {
  22420. var _this = this;
  22421. if (this._cache) {
  22422. Object.keys(this._cache).forEach(function (templateId) {
  22423. _this._cache[templateId].forEach(function (cachedRow) {
  22424. _this.context.renderer.disposeTemplate(_this.context.tree, templateId, cachedRow.templateData);
  22425. cachedRow.element = null;
  22426. cachedRow.templateData = null;
  22427. });
  22428. delete _this._cache[templateId];
  22429. });
  22430. }
  22431. };
  22432. RowCache.prototype.dispose = function () {
  22433. this.garbageCollect();
  22434. this._cache = null;
  22435. };
  22436. return RowCache;
  22437. }());
  22438. exports.RowCache = RowCache;
  22439. var ViewItem = /** @class */ (function () {
  22440. function ViewItem(context, model) {
  22441. var _this = this;
  22442. this.width = 0;
  22443. this.needsRender = false;
  22444. this.uri = null;
  22445. this.unbindDragStart = Lifecycle.Disposable.None;
  22446. this._draggable = false;
  22447. this.context = context;
  22448. this.model = model;
  22449. this.id = this.model.id;
  22450. this.row = null;
  22451. this.top = 0;
  22452. this.height = model.getHeight();
  22453. this._styles = {};
  22454. model.getAllTraits().forEach(function (t) { return _this._styles[t] = true; });
  22455. if (model.isExpanded()) {
  22456. this.addClass('expanded');
  22457. }
  22458. }
  22459. Object.defineProperty(ViewItem.prototype, "expanded", {
  22460. set: function (value) {
  22461. value ? this.addClass('expanded') : this.removeClass('expanded');
  22462. },
  22463. enumerable: true,
  22464. configurable: true
  22465. });
  22466. Object.defineProperty(ViewItem.prototype, "loading", {
  22467. set: function (value) {
  22468. value ? this.addClass('codicon-loading') : this.removeClass('codicon-loading');
  22469. },
  22470. enumerable: true,
  22471. configurable: true
  22472. });
  22473. Object.defineProperty(ViewItem.prototype, "draggable", {
  22474. get: function () {
  22475. return this._draggable;
  22476. },
  22477. set: function (value) {
  22478. this._draggable = value;
  22479. this.render(true);
  22480. },
  22481. enumerable: true,
  22482. configurable: true
  22483. });
  22484. Object.defineProperty(ViewItem.prototype, "dropTarget", {
  22485. set: function (value) {
  22486. value ? this.addClass('drop-target') : this.removeClass('drop-target');
  22487. },
  22488. enumerable: true,
  22489. configurable: true
  22490. });
  22491. Object.defineProperty(ViewItem.prototype, "element", {
  22492. get: function () {
  22493. return (this.row && this.row.element);
  22494. },
  22495. enumerable: true,
  22496. configurable: true
  22497. });
  22498. Object.defineProperty(ViewItem.prototype, "templateId", {
  22499. get: function () {
  22500. return this._templateId || (this._templateId = (this.context.renderer.getTemplateId && this.context.renderer.getTemplateId(this.context.tree, this.model.getElement())));
  22501. },
  22502. enumerable: true,
  22503. configurable: true
  22504. });
  22505. ViewItem.prototype.addClass = function (name) {
  22506. this._styles[name] = true;
  22507. this.render(true);
  22508. };
  22509. ViewItem.prototype.removeClass = function (name) {
  22510. delete this._styles[name]; // is this slow?
  22511. this.render(true);
  22512. };
  22513. ViewItem.prototype.render = function (skipUserRender) {
  22514. var _this = this;
  22515. if (skipUserRender === void 0) { skipUserRender = false; }
  22516. if (!this.model || !this.element) {
  22517. return;
  22518. }
  22519. var classes = ['monaco-tree-row'];
  22520. classes.push.apply(classes, Object.keys(this._styles));
  22521. if (this.model.hasChildren()) {
  22522. classes.push('has-children');
  22523. }
  22524. this.element.className = classes.join(' ');
  22525. this.element.draggable = this.draggable;
  22526. this.element.style.height = this.height + 'px';
  22527. // ARIA
  22528. this.element.setAttribute('role', 'treeitem');
  22529. var accessibility = this.context.accessibilityProvider;
  22530. var ariaLabel = accessibility.getAriaLabel(this.context.tree, this.model.getElement());
  22531. if (ariaLabel) {
  22532. this.element.setAttribute('aria-label', ariaLabel);
  22533. }
  22534. if (accessibility.getPosInSet && accessibility.getSetSize) {
  22535. this.element.setAttribute('aria-setsize', accessibility.getSetSize());
  22536. this.element.setAttribute('aria-posinset', accessibility.getPosInSet(this.context.tree, this.model.getElement()));
  22537. }
  22538. if (this.model.hasTrait('focused')) {
  22539. var base64Id = strings.safeBtoa(this.model.id);
  22540. this.element.setAttribute('aria-selected', 'true');
  22541. this.element.setAttribute('id', base64Id);
  22542. }
  22543. else {
  22544. this.element.setAttribute('aria-selected', 'false');
  22545. this.element.removeAttribute('id');
  22546. }
  22547. if (this.model.hasChildren()) {
  22548. this.element.setAttribute('aria-expanded', String(!!this._styles['expanded']));
  22549. }
  22550. else {
  22551. this.element.removeAttribute('aria-expanded');
  22552. }
  22553. this.element.setAttribute('aria-level', String(this.model.getDepth()));
  22554. if (this.context.options.paddingOnRow) {
  22555. this.element.style.paddingLeft = this.context.options.twistiePixels + ((this.model.getDepth() - 1) * this.context.options.indentPixels) + 'px';
  22556. }
  22557. else {
  22558. this.element.style.paddingLeft = ((this.model.getDepth() - 1) * this.context.options.indentPixels) + 'px';
  22559. this.row.element.firstElementChild.style.paddingLeft = this.context.options.twistiePixels + 'px';
  22560. }
  22561. var uri = this.context.dnd.getDragURI(this.context.tree, this.model.getElement());
  22562. if (uri !== this.uri) {
  22563. if (this.unbindDragStart) {
  22564. this.unbindDragStart.dispose();
  22565. }
  22566. if (uri) {
  22567. this.uri = uri;
  22568. this.draggable = true;
  22569. this.unbindDragStart = DOM.addDisposableListener(this.element, 'dragstart', function (e) {
  22570. _this.onDragStart(e);
  22571. });
  22572. }
  22573. else {
  22574. this.uri = null;
  22575. }
  22576. }
  22577. if (!skipUserRender && this.element) {
  22578. var paddingLeft = 0;
  22579. if (this.context.horizontalScrolling) {
  22580. var style = window.getComputedStyle(this.element);
  22581. paddingLeft = parseFloat(style.paddingLeft);
  22582. }
  22583. if (this.context.horizontalScrolling) {
  22584. this.element.style.width = Browser.isFirefox ? '-moz-fit-content' : 'fit-content';
  22585. }
  22586. try {
  22587. this.context.renderer.renderElement(this.context.tree, this.model.getElement(), this.templateId, this.row.templateData);
  22588. }
  22589. catch (err) {
  22590. console.error('Tree usage error: exception while rendering element');
  22591. console.error(err);
  22592. }
  22593. if (this.context.horizontalScrolling) {
  22594. this.width = DOM.getContentWidth(this.element) + paddingLeft;
  22595. this.element.style.width = '';
  22596. }
  22597. }
  22598. };
  22599. ViewItem.prototype.insertInDOM = function (container, afterElement) {
  22600. if (!this.row) {
  22601. this.row = this.context.cache.alloc(this.templateId);
  22602. // used in reverse lookup from HTMLElement to Item
  22603. this.element[TreeView.BINDING] = this;
  22604. }
  22605. if (this.element.parentElement) {
  22606. return;
  22607. }
  22608. if (afterElement === null) {
  22609. container.appendChild(this.element);
  22610. }
  22611. else {
  22612. try {
  22613. container.insertBefore(this.element, afterElement);
  22614. }
  22615. catch (e) {
  22616. console.warn('Failed to locate previous tree element');
  22617. container.appendChild(this.element);
  22618. }
  22619. }
  22620. this.render();
  22621. };
  22622. ViewItem.prototype.removeFromDOM = function () {
  22623. if (!this.row) {
  22624. return;
  22625. }
  22626. this.unbindDragStart.dispose();
  22627. this.uri = null;
  22628. this.element[TreeView.BINDING] = null;
  22629. this.context.cache.release(this.templateId, this.row);
  22630. this.row = null;
  22631. };
  22632. ViewItem.prototype.dispose = function () {
  22633. this.row = null;
  22634. };
  22635. return ViewItem;
  22636. }());
  22637. exports.ViewItem = ViewItem;
  22638. var RootViewItem = /** @class */ (function (_super) {
  22639. __extends(RootViewItem, _super);
  22640. function RootViewItem(context, model, wrapper) {
  22641. var _this = _super.call(this, context, model) || this;
  22642. _this.row = {
  22643. element: wrapper,
  22644. templateData: null,
  22645. templateId: null
  22646. };
  22647. return _this;
  22648. }
  22649. RootViewItem.prototype.render = function () {
  22650. if (!this.model || !this.element) {
  22651. return;
  22652. }
  22653. var classes = ['monaco-tree-wrapper'];
  22654. classes.push.apply(classes, Object.keys(this._styles));
  22655. if (this.model.hasChildren()) {
  22656. classes.push('has-children');
  22657. }
  22658. this.element.className = classes.join(' ');
  22659. };
  22660. RootViewItem.prototype.insertInDOM = function (container, afterElement) {
  22661. // noop
  22662. };
  22663. RootViewItem.prototype.removeFromDOM = function () {
  22664. // noop
  22665. };
  22666. return RootViewItem;
  22667. }(ViewItem));
  22668. function reactionEquals(one, other) {
  22669. if (!one && !other) {
  22670. return true;
  22671. }
  22672. else if (!one || !other) {
  22673. return false;
  22674. }
  22675. else if (one.accept !== other.accept) {
  22676. return false;
  22677. }
  22678. else if (one.bubble !== other.bubble) {
  22679. return false;
  22680. }
  22681. else if (one.effect !== other.effect) {
  22682. return false;
  22683. }
  22684. else {
  22685. return true;
  22686. }
  22687. }
  22688. var TreeView = /** @class */ (function (_super) {
  22689. __extends(TreeView, _super);
  22690. function TreeView(context, container) {
  22691. var _this = _super.call(this) || this;
  22692. _this.model = null;
  22693. _this.lastPointerType = '';
  22694. _this.lastClickTimeStamp = 0;
  22695. _this.contentWidthUpdateDelayer = new async_1.Delayer(50);
  22696. _this.isRefreshing = false;
  22697. _this.refreshingPreviousChildrenIds = {};
  22698. _this.currentDragAndDropData = null;
  22699. _this.currentDropTarget = null;
  22700. _this.currentDropTargets = null;
  22701. _this.currentDropDisposable = Lifecycle.Disposable.None;
  22702. _this.gestureDisposable = Lifecycle.Disposable.None;
  22703. _this.dragAndDropScrollInterval = null;
  22704. _this.dragAndDropScrollTimeout = null;
  22705. _this.dragAndDropMouseY = null;
  22706. _this.highlightedItemWasDraggable = false;
  22707. _this.onHiddenScrollTop = null;
  22708. _this._onDOMFocus = new event_1.Emitter();
  22709. _this.onDOMFocus = _this._onDOMFocus.event;
  22710. _this._onDOMBlur = new event_1.Emitter();
  22711. _this._onDidScroll = new event_1.Emitter();
  22712. TreeView.counter++;
  22713. _this.instance = TreeView.counter;
  22714. var horizontalScrollMode = typeof context.options.horizontalScrollMode === 'undefined' ? 2 /* Hidden */ : context.options.horizontalScrollMode;
  22715. _this.horizontalScrolling = horizontalScrollMode !== 2 /* Hidden */;
  22716. _this.context = {
  22717. dataSource: context.dataSource,
  22718. renderer: context.renderer,
  22719. controller: context.controller,
  22720. dnd: context.dnd,
  22721. filter: context.filter,
  22722. sorter: context.sorter,
  22723. tree: context.tree,
  22724. accessibilityProvider: context.accessibilityProvider,
  22725. options: context.options,
  22726. cache: new RowCache(context),
  22727. horizontalScrolling: _this.horizontalScrolling
  22728. };
  22729. _this.modelListeners = [];
  22730. _this.viewListeners = [];
  22731. _this.items = {};
  22732. _this.domNode = document.createElement('div');
  22733. _this.domNode.className = "monaco-tree no-focused-item monaco-tree-instance-" + _this.instance;
  22734. // to allow direct tabbing into the tree instead of first focusing the tree
  22735. _this.domNode.tabIndex = context.options.preventRootFocus ? -1 : 0;
  22736. _this.styleElement = DOM.createStyleSheet(_this.domNode);
  22737. _this.treeStyler = context.styler || new treeDefaults_1.DefaultTreestyler(_this.styleElement, "monaco-tree-instance-" + _this.instance);
  22738. // ARIA
  22739. _this.domNode.setAttribute('role', 'tree');
  22740. if (_this.context.options.ariaLabel) {
  22741. _this.domNode.setAttribute('aria-label', _this.context.options.ariaLabel);
  22742. }
  22743. if (_this.context.options.alwaysFocused) {
  22744. DOM.addClass(_this.domNode, 'focused');
  22745. }
  22746. if (!_this.context.options.paddingOnRow) {
  22747. DOM.addClass(_this.domNode, 'no-row-padding');
  22748. }
  22749. _this.wrapper = document.createElement('div');
  22750. _this.wrapper.className = 'monaco-tree-wrapper';
  22751. _this.scrollableElement = new scrollableElement_1.ScrollableElement(_this.wrapper, {
  22752. alwaysConsumeMouseWheel: true,
  22753. horizontal: horizontalScrollMode,
  22754. vertical: (typeof context.options.verticalScrollMode !== 'undefined' ? context.options.verticalScrollMode : 1 /* Auto */),
  22755. useShadows: context.options.useShadows
  22756. });
  22757. _this.scrollableElement.onScroll(function (e) {
  22758. _this.render(e.scrollTop, e.height, e.scrollLeft, e.width, e.scrollWidth);
  22759. _this._onDidScroll.fire();
  22760. });
  22761. if (Browser.isIE) {
  22762. _this.wrapper.style.msTouchAction = 'none';
  22763. _this.wrapper.style.msContentZooming = 'none';
  22764. }
  22765. else {
  22766. _this.gestureDisposable = Touch.Gesture.addTarget(_this.wrapper);
  22767. }
  22768. _this.rowsContainer = document.createElement('div');
  22769. _this.rowsContainer.className = 'monaco-tree-rows';
  22770. if (context.options.showTwistie) {
  22771. _this.rowsContainer.className += ' show-twisties';
  22772. }
  22773. var focusTracker = DOM.trackFocus(_this.domNode);
  22774. _this.viewListeners.push(focusTracker.onDidFocus(function () { return _this.onFocus(); }));
  22775. _this.viewListeners.push(focusTracker.onDidBlur(function () { return _this.onBlur(); }));
  22776. _this.viewListeners.push(focusTracker);
  22777. _this.viewListeners.push(DOM.addDisposableListener(_this.domNode, 'keydown', function (e) { return _this.onKeyDown(e); }));
  22778. _this.viewListeners.push(DOM.addDisposableListener(_this.domNode, 'keyup', function (e) { return _this.onKeyUp(e); }));
  22779. _this.viewListeners.push(DOM.addDisposableListener(_this.domNode, 'mousedown', function (e) { return _this.onMouseDown(e); }));
  22780. _this.viewListeners.push(DOM.addDisposableListener(_this.domNode, 'mouseup', function (e) { return _this.onMouseUp(e); }));
  22781. _this.viewListeners.push(DOM.addDisposableListener(_this.wrapper, 'auxclick', function (e) {
  22782. if (e && e.button === 1) {
  22783. _this.onMouseMiddleClick(e);
  22784. }
  22785. }));
  22786. _this.viewListeners.push(DOM.addDisposableListener(_this.wrapper, 'click', function (e) { return _this.onClick(e); }));
  22787. _this.viewListeners.push(DOM.addDisposableListener(_this.domNode, 'contextmenu', function (e) { return _this.onContextMenu(e); }));
  22788. _this.viewListeners.push(DOM.addDisposableListener(_this.wrapper, Touch.EventType.Tap, function (e) { return _this.onTap(e); }));
  22789. _this.viewListeners.push(DOM.addDisposableListener(_this.wrapper, Touch.EventType.Change, function (e) { return _this.onTouchChange(e); }));
  22790. if (Browser.isIE) {
  22791. _this.viewListeners.push(DOM.addDisposableListener(_this.wrapper, 'MSPointerDown', function (e) { return _this.onMsPointerDown(e); }));
  22792. _this.viewListeners.push(DOM.addDisposableListener(_this.wrapper, 'MSGestureTap', function (e) { return _this.onMsGestureTap(e); }));
  22793. // these events come too fast, we throttle them
  22794. _this.viewListeners.push(DOM.addDisposableThrottledListener(_this.wrapper, 'MSGestureChange', function (e) { return _this.onThrottledMsGestureChange(e); }, function (lastEvent, event) {
  22795. event.stopPropagation();
  22796. event.preventDefault();
  22797. var result = { translationY: event.translationY, translationX: event.translationX };
  22798. if (lastEvent) {
  22799. result.translationY += lastEvent.translationY;
  22800. result.translationX += lastEvent.translationX;
  22801. }
  22802. return result;
  22803. }));
  22804. }
  22805. _this.viewListeners.push(DOM.addDisposableListener(window, 'dragover', function (e) { return _this.onDragOver(e); }));
  22806. _this.viewListeners.push(DOM.addDisposableListener(_this.wrapper, 'drop', function (e) { return _this.onDrop(e); }));
  22807. _this.viewListeners.push(DOM.addDisposableListener(window, 'dragend', function (e) { return _this.onDragEnd(e); }));
  22808. _this.viewListeners.push(DOM.addDisposableListener(window, 'dragleave', function (e) { return _this.onDragOver(e); }));
  22809. _this.wrapper.appendChild(_this.rowsContainer);
  22810. _this.domNode.appendChild(_this.scrollableElement.getDomNode());
  22811. container.appendChild(_this.domNode);
  22812. _this.lastRenderTop = 0;
  22813. _this.lastRenderHeight = 0;
  22814. _this.didJustPressContextMenuKey = false;
  22815. _this.currentDropTarget = null;
  22816. _this.currentDropTargets = [];
  22817. _this.shouldInvalidateDropReaction = false;
  22818. _this.dragAndDropScrollInterval = null;
  22819. _this.dragAndDropScrollTimeout = null;
  22820. _this.onRowsChanged();
  22821. _this.layout();
  22822. _this.setupMSGesture();
  22823. _this.applyStyles(context.options);
  22824. return _this;
  22825. }
  22826. TreeView.prototype.applyStyles = function (styles) {
  22827. this.treeStyler.style(styles);
  22828. };
  22829. TreeView.prototype.createViewItem = function (item) {
  22830. return new ViewItem(this.context, item);
  22831. };
  22832. TreeView.prototype.getHTMLElement = function () {
  22833. return this.domNode;
  22834. };
  22835. TreeView.prototype.focus = function () {
  22836. this.domNode.focus();
  22837. };
  22838. TreeView.prototype.isFocused = function () {
  22839. return document.activeElement === this.domNode;
  22840. };
  22841. TreeView.prototype.blur = function () {
  22842. this.domNode.blur();
  22843. };
  22844. TreeView.prototype.setupMSGesture = function () {
  22845. var _this = this;
  22846. if (window.MSGesture) {
  22847. this.msGesture = new MSGesture();
  22848. setTimeout(function () { return _this.msGesture.target = _this.wrapper; }, 100); // TODO@joh, TODO@IETeam
  22849. }
  22850. };
  22851. TreeView.prototype.isTreeVisible = function () {
  22852. return this.onHiddenScrollTop === null;
  22853. };
  22854. TreeView.prototype.layout = function (height, width) {
  22855. if (!this.isTreeVisible()) {
  22856. return;
  22857. }
  22858. this.viewHeight = height || DOM.getContentHeight(this.wrapper); // render
  22859. this.scrollHeight = this.getContentHeight();
  22860. if (this.horizontalScrolling) {
  22861. this.viewWidth = width || DOM.getContentWidth(this.wrapper);
  22862. }
  22863. };
  22864. TreeView.prototype.render = function (scrollTop, viewHeight, scrollLeft, viewWidth, scrollWidth) {
  22865. var i;
  22866. var stop;
  22867. var renderTop = scrollTop;
  22868. var renderBottom = scrollTop + viewHeight;
  22869. var thisRenderBottom = this.lastRenderTop + this.lastRenderHeight;
  22870. // when view scrolls down, start rendering from the renderBottom
  22871. for (i = this.indexAfter(renderBottom) - 1, stop = this.indexAt(Math.max(thisRenderBottom, renderTop)); i >= stop; i--) {
  22872. this.insertItemInDOM(this.itemAtIndex(i));
  22873. }
  22874. // when view scrolls up, start rendering from either this.renderTop or renderBottom
  22875. for (i = Math.min(this.indexAt(this.lastRenderTop), this.indexAfter(renderBottom)) - 1, stop = this.indexAt(renderTop); i >= stop; i--) {
  22876. this.insertItemInDOM(this.itemAtIndex(i));
  22877. }
  22878. // when view scrolls down, start unrendering from renderTop
  22879. for (i = this.indexAt(this.lastRenderTop), stop = Math.min(this.indexAt(renderTop), this.indexAfter(thisRenderBottom)); i < stop; i++) {
  22880. this.removeItemFromDOM(this.itemAtIndex(i));
  22881. }
  22882. // when view scrolls up, start unrendering from either renderBottom this.renderTop
  22883. for (i = Math.max(this.indexAfter(renderBottom), this.indexAt(this.lastRenderTop)), stop = this.indexAfter(thisRenderBottom); i < stop; i++) {
  22884. this.removeItemFromDOM(this.itemAtIndex(i));
  22885. }
  22886. var topItem = this.itemAtIndex(this.indexAt(renderTop));
  22887. if (topItem) {
  22888. this.rowsContainer.style.top = (topItem.top - renderTop) + 'px';
  22889. }
  22890. if (this.horizontalScrolling) {
  22891. this.rowsContainer.style.left = -scrollLeft + 'px';
  22892. this.rowsContainer.style.width = Math.max(scrollWidth, viewWidth) + "px";
  22893. }
  22894. this.lastRenderTop = renderTop;
  22895. this.lastRenderHeight = renderBottom - renderTop;
  22896. };
  22897. TreeView.prototype.setModel = function (newModel) {
  22898. this.releaseModel();
  22899. this.model = newModel;
  22900. this.model.onRefresh(this.onRefreshing, this, this.modelListeners);
  22901. this.model.onDidRefresh(this.onRefreshed, this, this.modelListeners);
  22902. this.model.onSetInput(this.onClearingInput, this, this.modelListeners);
  22903. this.model.onDidSetInput(this.onSetInput, this, this.modelListeners);
  22904. this.model.onDidFocus(this.onModelFocusChange, this, this.modelListeners);
  22905. this.model.onRefreshItemChildren(this.onItemChildrenRefreshing, this, this.modelListeners);
  22906. this.model.onDidRefreshItemChildren(this.onItemChildrenRefreshed, this, this.modelListeners);
  22907. this.model.onDidRefreshItem(this.onItemRefresh, this, this.modelListeners);
  22908. this.model.onExpandItem(this.onItemExpanding, this, this.modelListeners);
  22909. this.model.onDidExpandItem(this.onItemExpanded, this, this.modelListeners);
  22910. this.model.onCollapseItem(this.onItemCollapsing, this, this.modelListeners);
  22911. this.model.onDidRevealItem(this.onItemReveal, this, this.modelListeners);
  22912. this.model.onDidAddTraitItem(this.onItemAddTrait, this, this.modelListeners);
  22913. this.model.onDidRemoveTraitItem(this.onItemRemoveTrait, this, this.modelListeners);
  22914. };
  22915. TreeView.prototype.onRefreshing = function () {
  22916. this.isRefreshing = true;
  22917. };
  22918. TreeView.prototype.onRefreshed = function () {
  22919. this.isRefreshing = false;
  22920. this.onRowsChanged();
  22921. };
  22922. TreeView.prototype.onRowsChanged = function (scrollTop) {
  22923. if (scrollTop === void 0) { scrollTop = this.scrollTop; }
  22924. if (this.isRefreshing) {
  22925. return;
  22926. }
  22927. this.scrollTop = scrollTop;
  22928. this.updateScrollWidth();
  22929. };
  22930. TreeView.prototype.updateScrollWidth = function () {
  22931. var _this = this;
  22932. if (!this.horizontalScrolling) {
  22933. return;
  22934. }
  22935. this.contentWidthUpdateDelayer.trigger(function () {
  22936. var keys = Object.keys(_this.items);
  22937. var scrollWidth = 0;
  22938. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  22939. var key = keys_1[_i];
  22940. scrollWidth = Math.max(scrollWidth, _this.items[key].width);
  22941. }
  22942. _this.scrollWidth = scrollWidth + 10 /* scrollbar */;
  22943. });
  22944. };
  22945. TreeView.prototype.focusNextPage = function (eventPayload) {
  22946. var _this = this;
  22947. var lastPageIndex = this.indexAt(this.scrollTop + this.viewHeight);
  22948. lastPageIndex = lastPageIndex === 0 ? 0 : lastPageIndex - 1;
  22949. var lastPageElement = this.itemAtIndex(lastPageIndex).model.getElement();
  22950. var currentlyFocusedElement = this.model.getFocus();
  22951. if (currentlyFocusedElement !== lastPageElement) {
  22952. this.model.setFocus(lastPageElement, eventPayload);
  22953. }
  22954. else {
  22955. var previousScrollTop = this.scrollTop;
  22956. this.scrollTop += this.viewHeight;
  22957. if (this.scrollTop !== previousScrollTop) {
  22958. // Let the scroll event listener run
  22959. setTimeout(function () {
  22960. _this.focusNextPage(eventPayload);
  22961. }, 0);
  22962. }
  22963. }
  22964. };
  22965. TreeView.prototype.focusPreviousPage = function (eventPayload) {
  22966. var _this = this;
  22967. var firstPageIndex;
  22968. if (this.scrollTop === 0) {
  22969. firstPageIndex = this.indexAt(this.scrollTop);
  22970. }
  22971. else {
  22972. firstPageIndex = this.indexAfter(this.scrollTop - 1);
  22973. }
  22974. var firstPageElement = this.itemAtIndex(firstPageIndex).model.getElement();
  22975. var currentlyFocusedElement = this.model.getFocus();
  22976. if (currentlyFocusedElement !== firstPageElement) {
  22977. this.model.setFocus(firstPageElement, eventPayload);
  22978. }
  22979. else {
  22980. var previousScrollTop = this.scrollTop;
  22981. this.scrollTop -= this.viewHeight;
  22982. if (this.scrollTop !== previousScrollTop) {
  22983. // Let the scroll event listener run
  22984. setTimeout(function () {
  22985. _this.focusPreviousPage(eventPayload);
  22986. }, 0);
  22987. }
  22988. }
  22989. };
  22990. Object.defineProperty(TreeView.prototype, "viewHeight", {
  22991. get: function () {
  22992. var scrollDimensions = this.scrollableElement.getScrollDimensions();
  22993. return scrollDimensions.height;
  22994. },
  22995. set: function (height) {
  22996. this.scrollableElement.setScrollDimensions({ height: height });
  22997. },
  22998. enumerable: true,
  22999. configurable: true
  23000. });
  23001. Object.defineProperty(TreeView.prototype, "scrollHeight", {
  23002. set: function (scrollHeight) {
  23003. scrollHeight = scrollHeight + (this.horizontalScrolling ? 10 : 0);
  23004. this.scrollableElement.setScrollDimensions({ scrollHeight: scrollHeight });
  23005. },
  23006. enumerable: true,
  23007. configurable: true
  23008. });
  23009. Object.defineProperty(TreeView.prototype, "viewWidth", {
  23010. get: function () {
  23011. var scrollDimensions = this.scrollableElement.getScrollDimensions();
  23012. return scrollDimensions.width;
  23013. },
  23014. set: function (viewWidth) {
  23015. this.scrollableElement.setScrollDimensions({ width: viewWidth });
  23016. },
  23017. enumerable: true,
  23018. configurable: true
  23019. });
  23020. Object.defineProperty(TreeView.prototype, "scrollWidth", {
  23021. set: function (scrollWidth) {
  23022. this.scrollableElement.setScrollDimensions({ scrollWidth: scrollWidth });
  23023. },
  23024. enumerable: true,
  23025. configurable: true
  23026. });
  23027. Object.defineProperty(TreeView.prototype, "scrollTop", {
  23028. get: function () {
  23029. var scrollPosition = this.scrollableElement.getScrollPosition();
  23030. return scrollPosition.scrollTop;
  23031. },
  23032. set: function (scrollTop) {
  23033. var scrollHeight = this.getContentHeight() + (this.horizontalScrolling ? 10 : 0);
  23034. this.scrollableElement.setScrollDimensions({ scrollHeight: scrollHeight });
  23035. this.scrollableElement.setScrollPosition({ scrollTop: scrollTop });
  23036. },
  23037. enumerable: true,
  23038. configurable: true
  23039. });
  23040. // Events
  23041. TreeView.prototype.onClearingInput = function (e) {
  23042. var item = e.item;
  23043. if (item) {
  23044. this.onRemoveItems(new iterator_1.MappedIterator(item.getNavigator(), function (item) { return item && item.id; }));
  23045. this.onRowsChanged();
  23046. }
  23047. };
  23048. TreeView.prototype.onSetInput = function (e) {
  23049. this.context.cache.garbageCollect();
  23050. this.inputItem = new RootViewItem(this.context, e.item, this.wrapper);
  23051. };
  23052. TreeView.prototype.onItemChildrenRefreshing = function (e) {
  23053. var item = e.item;
  23054. var viewItem = this.items[item.id];
  23055. if (viewItem && this.context.options.showLoading) {
  23056. viewItem.loadingTimer = setTimeout(function () {
  23057. viewItem.loadingTimer = 0;
  23058. viewItem.loading = true;
  23059. }, TreeView.LOADING_DECORATION_DELAY);
  23060. }
  23061. if (!e.isNested) {
  23062. var childrenIds = [];
  23063. var navigator_1 = item.getNavigator();
  23064. var childItem = void 0;
  23065. while (childItem = navigator_1.next()) {
  23066. childrenIds.push(childItem.id);
  23067. }
  23068. this.refreshingPreviousChildrenIds[item.id] = childrenIds;
  23069. }
  23070. };
  23071. TreeView.prototype.onItemChildrenRefreshed = function (e) {
  23072. var _this = this;
  23073. var item = e.item;
  23074. var viewItem = this.items[item.id];
  23075. if (viewItem) {
  23076. if (viewItem.loadingTimer) {
  23077. clearTimeout(viewItem.loadingTimer);
  23078. viewItem.loadingTimer = 0;
  23079. }
  23080. viewItem.loading = false;
  23081. }
  23082. if (!e.isNested) {
  23083. var previousChildrenIds_1 = this.refreshingPreviousChildrenIds[item.id];
  23084. var afterModelItems_1 = [];
  23085. var navigator_2 = item.getNavigator();
  23086. var childItem = void 0;
  23087. while (childItem = navigator_2.next()) {
  23088. afterModelItems_1.push(childItem);
  23089. }
  23090. var skipDiff = Math.abs(previousChildrenIds_1.length - afterModelItems_1.length) > 1000;
  23091. var diff = [];
  23092. var doToInsertItemsAlreadyExist = false;
  23093. if (!skipDiff) {
  23094. var lcs = new Diff.LcsDiff({
  23095. getElements: function () { return previousChildrenIds_1; }
  23096. }, {
  23097. getElements: function () { return afterModelItems_1.map(function (item) { return item.id; }); }
  23098. }, null);
  23099. diff = lcs.ComputeDiff(false).changes;
  23100. // this means that the result of the diff algorithm would result
  23101. // in inserting items that were already registered. this can only
  23102. // happen if the data provider returns bad ids OR if the sorting
  23103. // of the elements has changed
  23104. doToInsertItemsAlreadyExist = diff.some(function (d) {
  23105. if (d.modifiedLength > 0) {
  23106. for (var i = d.modifiedStart, len = d.modifiedStart + d.modifiedLength; i < len; i++) {
  23107. if (_this.items.hasOwnProperty(afterModelItems_1[i].id)) {
  23108. return true;
  23109. }
  23110. }
  23111. }
  23112. return false;
  23113. });
  23114. }
  23115. // 50 is an optimization number, at some point we're better off
  23116. // just replacing everything
  23117. if (!skipDiff && !doToInsertItemsAlreadyExist && diff.length < 50) {
  23118. for (var _i = 0, diff_1 = diff; _i < diff_1.length; _i++) {
  23119. var diffChange = diff_1[_i];
  23120. if (diffChange.originalLength > 0) {
  23121. this.onRemoveItems(new iterator_1.ArrayIterator(previousChildrenIds_1, diffChange.originalStart, diffChange.originalStart + diffChange.originalLength));
  23122. }
  23123. if (diffChange.modifiedLength > 0) {
  23124. var beforeItem = afterModelItems_1[diffChange.modifiedStart - 1] || item;
  23125. beforeItem = beforeItem.getDepth() > 0 ? beforeItem : null;
  23126. this.onInsertItems(new iterator_1.ArrayIterator(afterModelItems_1, diffChange.modifiedStart, diffChange.modifiedStart + diffChange.modifiedLength), beforeItem ? beforeItem.id : null);
  23127. }
  23128. }
  23129. }
  23130. else if (skipDiff || diff.length) {
  23131. this.onRemoveItems(new iterator_1.ArrayIterator(previousChildrenIds_1));
  23132. this.onInsertItems(new iterator_1.ArrayIterator(afterModelItems_1), item.getDepth() > 0 ? item.id : null);
  23133. }
  23134. if (skipDiff || diff.length) {
  23135. this.onRowsChanged();
  23136. }
  23137. }
  23138. };
  23139. TreeView.prototype.onItemRefresh = function (item) {
  23140. this.onItemsRefresh([item]);
  23141. };
  23142. TreeView.prototype.onItemsRefresh = function (items) {
  23143. var _this = this;
  23144. this.onRefreshItemSet(items.filter(function (item) { return _this.items.hasOwnProperty(item.id); }));
  23145. this.onRowsChanged();
  23146. };
  23147. TreeView.prototype.onItemExpanding = function (e) {
  23148. var viewItem = this.items[e.item.id];
  23149. if (viewItem) {
  23150. viewItem.expanded = true;
  23151. }
  23152. };
  23153. TreeView.prototype.onItemExpanded = function (e) {
  23154. var item = e.item;
  23155. var viewItem = this.items[item.id];
  23156. if (viewItem) {
  23157. viewItem.expanded = true;
  23158. var height = this.onInsertItems(item.getNavigator(), item.id) || 0;
  23159. var scrollTop = this.scrollTop;
  23160. if (viewItem.top + viewItem.height <= this.scrollTop) {
  23161. scrollTop += height;
  23162. }
  23163. this.onRowsChanged(scrollTop);
  23164. }
  23165. };
  23166. TreeView.prototype.onItemCollapsing = function (e) {
  23167. var item = e.item;
  23168. var viewItem = this.items[item.id];
  23169. if (viewItem) {
  23170. viewItem.expanded = false;
  23171. this.onRemoveItems(new iterator_1.MappedIterator(item.getNavigator(), function (item) { return item && item.id; }));
  23172. this.onRowsChanged();
  23173. }
  23174. };
  23175. TreeView.prototype.onItemReveal = function (e) {
  23176. var item = e.item;
  23177. var relativeTop = e.relativeTop;
  23178. var viewItem = this.items[item.id];
  23179. if (viewItem) {
  23180. if (relativeTop !== null) {
  23181. relativeTop = relativeTop < 0 ? 0 : relativeTop;
  23182. relativeTop = relativeTop > 1 ? 1 : relativeTop;
  23183. // y = mx + b
  23184. var m = viewItem.height - this.viewHeight;
  23185. this.scrollTop = m * relativeTop + viewItem.top;
  23186. }
  23187. else {
  23188. var viewItemBottom = viewItem.top + viewItem.height;
  23189. var wrapperBottom = this.scrollTop + this.viewHeight;
  23190. if (viewItem.top < this.scrollTop) {
  23191. this.scrollTop = viewItem.top;
  23192. }
  23193. else if (viewItemBottom >= wrapperBottom) {
  23194. this.scrollTop = viewItemBottom - this.viewHeight;
  23195. }
  23196. }
  23197. }
  23198. };
  23199. TreeView.prototype.onItemAddTrait = function (e) {
  23200. var item = e.item;
  23201. var trait = e.trait;
  23202. var viewItem = this.items[item.id];
  23203. if (viewItem) {
  23204. viewItem.addClass(trait);
  23205. }
  23206. if (trait === 'highlighted') {
  23207. DOM.addClass(this.domNode, trait);
  23208. // Ugly Firefox fix: input fields can't be selected if parent nodes are draggable
  23209. if (viewItem) {
  23210. this.highlightedItemWasDraggable = !!viewItem.draggable;
  23211. if (viewItem.draggable) {
  23212. viewItem.draggable = false;
  23213. }
  23214. }
  23215. }
  23216. };
  23217. TreeView.prototype.onItemRemoveTrait = function (e) {
  23218. var item = e.item;
  23219. var trait = e.trait;
  23220. var viewItem = this.items[item.id];
  23221. if (viewItem) {
  23222. viewItem.removeClass(trait);
  23223. }
  23224. if (trait === 'highlighted') {
  23225. DOM.removeClass(this.domNode, trait);
  23226. // Ugly Firefox fix: input fields can't be selected if parent nodes are draggable
  23227. if (this.highlightedItemWasDraggable) {
  23228. viewItem.draggable = true;
  23229. }
  23230. this.highlightedItemWasDraggable = false;
  23231. }
  23232. };
  23233. TreeView.prototype.onModelFocusChange = function () {
  23234. var focus = this.model && this.model.getFocus();
  23235. DOM.toggleClass(this.domNode, 'no-focused-item', !focus);
  23236. // ARIA
  23237. if (focus) {
  23238. this.domNode.setAttribute('aria-activedescendant', strings.safeBtoa(this.context.dataSource.getId(this.context.tree, focus)));
  23239. }
  23240. else {
  23241. this.domNode.removeAttribute('aria-activedescendant');
  23242. }
  23243. };
  23244. // HeightMap "events"
  23245. TreeView.prototype.onInsertItem = function (item) {
  23246. var _this = this;
  23247. item.onDragStart = function (e) { _this.onDragStart(item, e); };
  23248. item.needsRender = true;
  23249. this.refreshViewItem(item);
  23250. this.items[item.id] = item;
  23251. };
  23252. TreeView.prototype.onRefreshItem = function (item, needsRender) {
  23253. if (needsRender === void 0) { needsRender = false; }
  23254. item.needsRender = item.needsRender || needsRender;
  23255. this.refreshViewItem(item);
  23256. };
  23257. TreeView.prototype.onRemoveItem = function (item) {
  23258. this.removeItemFromDOM(item);
  23259. item.dispose();
  23260. delete this.items[item.id];
  23261. };
  23262. // ViewItem refresh
  23263. TreeView.prototype.refreshViewItem = function (item) {
  23264. item.render();
  23265. if (this.shouldBeRendered(item)) {
  23266. this.insertItemInDOM(item);
  23267. }
  23268. else {
  23269. this.removeItemFromDOM(item);
  23270. }
  23271. };
  23272. // DOM Events
  23273. TreeView.prototype.onClick = function (e) {
  23274. if (this.lastPointerType && this.lastPointerType !== 'mouse') {
  23275. return;
  23276. }
  23277. var event = new Mouse.StandardMouseEvent(e);
  23278. var item = this.getItemAround(event.target);
  23279. if (!item) {
  23280. return;
  23281. }
  23282. if (Browser.isIE && Date.now() - this.lastClickTimeStamp < 300) {
  23283. // IE10+ doesn't set the detail property correctly. While IE10 simply
  23284. // counts the number of clicks, IE11 reports always 1. To align with
  23285. // other browser, we set the value to 2 if clicks events come in a 300ms
  23286. // sequence.
  23287. event.detail = 2;
  23288. }
  23289. this.lastClickTimeStamp = Date.now();
  23290. this.context.controller.onClick(this.context.tree, item.model.getElement(), event);
  23291. };
  23292. TreeView.prototype.onMouseMiddleClick = function (e) {
  23293. if (!this.context.controller.onMouseMiddleClick) {
  23294. return;
  23295. }
  23296. var event = new Mouse.StandardMouseEvent(e);
  23297. var item = this.getItemAround(event.target);
  23298. if (!item) {
  23299. return;
  23300. }
  23301. this.context.controller.onMouseMiddleClick(this.context.tree, item.model.getElement(), event);
  23302. };
  23303. TreeView.prototype.onMouseDown = function (e) {
  23304. this.didJustPressContextMenuKey = false;
  23305. if (!this.context.controller.onMouseDown) {
  23306. return;
  23307. }
  23308. if (this.lastPointerType && this.lastPointerType !== 'mouse') {
  23309. return;
  23310. }
  23311. var event = new Mouse.StandardMouseEvent(e);
  23312. if (event.ctrlKey && Platform.isNative && Platform.isMacintosh) {
  23313. return;
  23314. }
  23315. var item = this.getItemAround(event.target);
  23316. if (!item) {
  23317. return;
  23318. }
  23319. this.context.controller.onMouseDown(this.context.tree, item.model.getElement(), event);
  23320. };
  23321. TreeView.prototype.onMouseUp = function (e) {
  23322. if (!this.context.controller.onMouseUp) {
  23323. return;
  23324. }
  23325. if (this.lastPointerType && this.lastPointerType !== 'mouse') {
  23326. return;
  23327. }
  23328. var event = new Mouse.StandardMouseEvent(e);
  23329. if (event.ctrlKey && Platform.isNative && Platform.isMacintosh) {
  23330. return;
  23331. }
  23332. var item = this.getItemAround(event.target);
  23333. if (!item) {
  23334. return;
  23335. }
  23336. this.context.controller.onMouseUp(this.context.tree, item.model.getElement(), event);
  23337. };
  23338. TreeView.prototype.onTap = function (e) {
  23339. var item = this.getItemAround(e.initialTarget);
  23340. if (!item) {
  23341. return;
  23342. }
  23343. this.context.controller.onTap(this.context.tree, item.model.getElement(), e);
  23344. };
  23345. TreeView.prototype.onTouchChange = function (event) {
  23346. event.preventDefault();
  23347. event.stopPropagation();
  23348. this.scrollTop -= event.translationY;
  23349. };
  23350. TreeView.prototype.onContextMenu = function (event) {
  23351. var resultEvent;
  23352. var element;
  23353. if (event instanceof KeyboardEvent || this.didJustPressContextMenuKey) {
  23354. this.didJustPressContextMenuKey = false;
  23355. var keyboardEvent = new Keyboard.StandardKeyboardEvent(event);
  23356. element = this.model.getFocus();
  23357. var position = void 0;
  23358. if (!element) {
  23359. element = this.model.getInput();
  23360. position = DOM.getDomNodePagePosition(this.inputItem.element);
  23361. }
  23362. else {
  23363. var id = this.context.dataSource.getId(this.context.tree, element);
  23364. var viewItem = this.items[id];
  23365. position = DOM.getDomNodePagePosition(viewItem.element);
  23366. }
  23367. resultEvent = new _.KeyboardContextMenuEvent(position.left + position.width, position.top, keyboardEvent);
  23368. }
  23369. else {
  23370. var mouseEvent = new Mouse.StandardMouseEvent(event);
  23371. var item = this.getItemAround(mouseEvent.target);
  23372. if (!item) {
  23373. return;
  23374. }
  23375. element = item.model.getElement();
  23376. resultEvent = new _.MouseContextMenuEvent(mouseEvent);
  23377. }
  23378. this.context.controller.onContextMenu(this.context.tree, element, resultEvent);
  23379. };
  23380. TreeView.prototype.onKeyDown = function (e) {
  23381. var event = new Keyboard.StandardKeyboardEvent(e);
  23382. this.didJustPressContextMenuKey = event.keyCode === 58 /* ContextMenu */ || (event.shiftKey && event.keyCode === 68 /* F10 */);
  23383. if (event.target && event.target.tagName && event.target.tagName.toLowerCase() === 'input') {
  23384. return; // Ignore event if target is a form input field (avoids browser specific issues)
  23385. }
  23386. if (this.didJustPressContextMenuKey) {
  23387. event.preventDefault();
  23388. event.stopPropagation();
  23389. }
  23390. this.context.controller.onKeyDown(this.context.tree, event);
  23391. };
  23392. TreeView.prototype.onKeyUp = function (e) {
  23393. if (this.didJustPressContextMenuKey) {
  23394. this.onContextMenu(e);
  23395. }
  23396. this.didJustPressContextMenuKey = false;
  23397. this.context.controller.onKeyUp(this.context.tree, new Keyboard.StandardKeyboardEvent(e));
  23398. };
  23399. TreeView.prototype.onDragStart = function (item, e) {
  23400. if (this.model.getHighlight()) {
  23401. return;
  23402. }
  23403. var element = item.model.getElement();
  23404. var selection = this.model.getSelection();
  23405. var elements;
  23406. if (selection.indexOf(element) > -1) {
  23407. elements = selection;
  23408. }
  23409. else {
  23410. elements = [element];
  23411. }
  23412. e.dataTransfer.effectAllowed = 'copyMove';
  23413. e.dataTransfer.setData(dnd_1.DataTransfers.RESOURCES, JSON.stringify([item.uri]));
  23414. if (e.dataTransfer.setDragImage) {
  23415. var label = void 0;
  23416. if (this.context.dnd.getDragLabel) {
  23417. label = this.context.dnd.getDragLabel(this.context.tree, elements);
  23418. }
  23419. else {
  23420. label = String(elements.length);
  23421. }
  23422. var dragImage_1 = document.createElement('div');
  23423. dragImage_1.className = 'monaco-tree-drag-image';
  23424. dragImage_1.textContent = label;
  23425. document.body.appendChild(dragImage_1);
  23426. e.dataTransfer.setDragImage(dragImage_1, -10, -10);
  23427. setTimeout(function () { return document.body.removeChild(dragImage_1); }, 0);
  23428. }
  23429. this.currentDragAndDropData = new dnd.ElementsDragAndDropData(elements);
  23430. dnd_1.StaticDND.CurrentDragAndDropData = new dnd.ExternalElementsDragAndDropData(elements);
  23431. this.context.dnd.onDragStart(this.context.tree, this.currentDragAndDropData, new Mouse.DragMouseEvent(e));
  23432. };
  23433. TreeView.prototype.setupDragAndDropScrollInterval = function () {
  23434. var _this = this;
  23435. var viewTop = DOM.getTopLeftOffset(this.wrapper).top;
  23436. if (!this.dragAndDropScrollInterval) {
  23437. this.dragAndDropScrollInterval = window.setInterval(function () {
  23438. if (_this.dragAndDropMouseY === null) {
  23439. return;
  23440. }
  23441. var diff = _this.dragAndDropMouseY - viewTop;
  23442. var scrollDiff = 0;
  23443. var upperLimit = _this.viewHeight - 35;
  23444. if (diff < 35) {
  23445. scrollDiff = Math.max(-14, 0.2 * (diff - 35));
  23446. }
  23447. else if (diff > upperLimit) {
  23448. scrollDiff = Math.min(14, 0.2 * (diff - upperLimit));
  23449. }
  23450. _this.scrollTop += scrollDiff;
  23451. }, 10);
  23452. this.cancelDragAndDropScrollTimeout();
  23453. this.dragAndDropScrollTimeout = window.setTimeout(function () {
  23454. _this.cancelDragAndDropScrollInterval();
  23455. _this.dragAndDropScrollTimeout = null;
  23456. }, 1000);
  23457. }
  23458. };
  23459. TreeView.prototype.cancelDragAndDropScrollInterval = function () {
  23460. if (this.dragAndDropScrollInterval) {
  23461. window.clearInterval(this.dragAndDropScrollInterval);
  23462. this.dragAndDropScrollInterval = null;
  23463. }
  23464. this.cancelDragAndDropScrollTimeout();
  23465. };
  23466. TreeView.prototype.cancelDragAndDropScrollTimeout = function () {
  23467. if (this.dragAndDropScrollTimeout) {
  23468. window.clearTimeout(this.dragAndDropScrollTimeout);
  23469. this.dragAndDropScrollTimeout = null;
  23470. }
  23471. };
  23472. TreeView.prototype.onDragOver = function (e) {
  23473. var _this = this;
  23474. e.preventDefault(); // needed so that the drop event fires (https://stackoverflow.com/questions/21339924/drop-event-not-firing-in-chrome)
  23475. var event = new Mouse.DragMouseEvent(e);
  23476. var viewItem = this.getItemAround(event.target);
  23477. if (!viewItem || (event.posx === 0 && event.posy === 0 && event.browserEvent.type === DOM.EventType.DRAG_LEAVE)) {
  23478. // dragging outside of tree
  23479. if (this.currentDropTarget) {
  23480. // clear previously hovered element feedback
  23481. this.currentDropTargets.forEach(function (i) { return i.dropTarget = false; });
  23482. this.currentDropTargets = [];
  23483. this.currentDropDisposable.dispose();
  23484. }
  23485. this.cancelDragAndDropScrollInterval();
  23486. this.currentDropTarget = null;
  23487. this.currentDropElement = null;
  23488. this.dragAndDropMouseY = null;
  23489. return false;
  23490. }
  23491. // dragging inside the tree
  23492. this.setupDragAndDropScrollInterval();
  23493. this.dragAndDropMouseY = event.posy;
  23494. if (!this.currentDragAndDropData) {
  23495. // just started dragging
  23496. if (dnd_1.StaticDND.CurrentDragAndDropData) {
  23497. this.currentDragAndDropData = dnd_1.StaticDND.CurrentDragAndDropData;
  23498. }
  23499. else {
  23500. if (!event.dataTransfer.types) {
  23501. return false;
  23502. }
  23503. this.currentDragAndDropData = new dnd.DesktopDragAndDropData();
  23504. }
  23505. }
  23506. this.currentDragAndDropData.update(event.browserEvent.dataTransfer);
  23507. var element;
  23508. var item = viewItem.model;
  23509. var reaction;
  23510. // check the bubble up behavior
  23511. do {
  23512. element = item ? item.getElement() : this.model.getInput();
  23513. reaction = this.context.dnd.onDragOver(this.context.tree, this.currentDragAndDropData, element, event);
  23514. if (!reaction || reaction.bubble !== 1 /* BUBBLE_UP */) {
  23515. break;
  23516. }
  23517. item = item && item.parent;
  23518. } while (item);
  23519. if (!item) {
  23520. this.currentDropElement = null;
  23521. return false;
  23522. }
  23523. var canDrop = reaction && reaction.accept;
  23524. if (canDrop) {
  23525. this.currentDropElement = item.getElement();
  23526. event.preventDefault();
  23527. event.dataTransfer.dropEffect = reaction.effect === 0 /* COPY */ ? 'copy' : 'move';
  23528. }
  23529. else {
  23530. this.currentDropElement = null;
  23531. }
  23532. // item is the model item where drop() should be called
  23533. // can be null
  23534. var currentDropTarget = item.id === this.inputItem.id ? this.inputItem : this.items[item.id];
  23535. if (this.shouldInvalidateDropReaction || this.currentDropTarget !== currentDropTarget || !reactionEquals(this.currentDropElementReaction, reaction)) {
  23536. this.shouldInvalidateDropReaction = false;
  23537. if (this.currentDropTarget) {
  23538. this.currentDropTargets.forEach(function (i) { return i.dropTarget = false; });
  23539. this.currentDropTargets = [];
  23540. this.currentDropDisposable.dispose();
  23541. }
  23542. this.currentDropTarget = currentDropTarget;
  23543. this.currentDropElementReaction = reaction;
  23544. if (canDrop) {
  23545. // setup hover feedback for drop target
  23546. if (this.currentDropTarget) {
  23547. this.currentDropTarget.dropTarget = true;
  23548. this.currentDropTargets.push(this.currentDropTarget);
  23549. }
  23550. if (reaction.bubble === 0 /* BUBBLE_DOWN */) {
  23551. var nav = item.getNavigator();
  23552. var child = void 0;
  23553. while (child = nav.next()) {
  23554. viewItem = this.items[child.id];
  23555. if (viewItem) {
  23556. viewItem.dropTarget = true;
  23557. this.currentDropTargets.push(viewItem);
  23558. }
  23559. }
  23560. }
  23561. if (reaction.autoExpand) {
  23562. var timeoutPromise_1 = async_1.timeout(500);
  23563. this.currentDropDisposable = Lifecycle.toDisposable(function () { return timeoutPromise_1.cancel(); });
  23564. timeoutPromise_1
  23565. .then(function () { return _this.context.tree.expand(_this.currentDropElement); })
  23566. .then(function () { return _this.shouldInvalidateDropReaction = true; });
  23567. }
  23568. }
  23569. }
  23570. return true;
  23571. };
  23572. TreeView.prototype.onDrop = function (e) {
  23573. if (this.currentDropElement) {
  23574. var event_2 = new Mouse.DragMouseEvent(e);
  23575. event_2.preventDefault();
  23576. this.currentDragAndDropData.update(event_2.browserEvent.dataTransfer);
  23577. this.context.dnd.drop(this.context.tree, this.currentDragAndDropData, this.currentDropElement, event_2);
  23578. this.onDragEnd(e);
  23579. }
  23580. this.cancelDragAndDropScrollInterval();
  23581. };
  23582. TreeView.prototype.onDragEnd = function (e) {
  23583. if (this.currentDropTarget) {
  23584. this.currentDropTargets.forEach(function (i) { return i.dropTarget = false; });
  23585. this.currentDropTargets = [];
  23586. }
  23587. this.currentDropDisposable.dispose();
  23588. this.cancelDragAndDropScrollInterval();
  23589. this.currentDragAndDropData = null;
  23590. dnd_1.StaticDND.CurrentDragAndDropData = undefined;
  23591. this.currentDropElement = null;
  23592. this.currentDropTarget = null;
  23593. this.dragAndDropMouseY = null;
  23594. };
  23595. TreeView.prototype.onFocus = function () {
  23596. if (!this.context.options.alwaysFocused) {
  23597. DOM.addClass(this.domNode, 'focused');
  23598. }
  23599. this._onDOMFocus.fire();
  23600. };
  23601. TreeView.prototype.onBlur = function () {
  23602. if (!this.context.options.alwaysFocused) {
  23603. DOM.removeClass(this.domNode, 'focused');
  23604. }
  23605. this.domNode.removeAttribute('aria-activedescendant'); // ARIA
  23606. this._onDOMBlur.fire();
  23607. };
  23608. // MS specific DOM Events
  23609. TreeView.prototype.onMsPointerDown = function (event) {
  23610. if (!this.msGesture) {
  23611. return;
  23612. }
  23613. // Circumvent IE11 breaking change in e.pointerType & TypeScript's stale definitions
  23614. var pointerType = event.pointerType;
  23615. if (pointerType === (event.MSPOINTER_TYPE_MOUSE || 'mouse')) {
  23616. this.lastPointerType = 'mouse';
  23617. return;
  23618. }
  23619. else if (pointerType === (event.MSPOINTER_TYPE_TOUCH || 'touch')) {
  23620. this.lastPointerType = 'touch';
  23621. }
  23622. else {
  23623. return;
  23624. }
  23625. event.stopPropagation();
  23626. event.preventDefault();
  23627. this.msGesture.addPointer(event.pointerId);
  23628. };
  23629. TreeView.prototype.onThrottledMsGestureChange = function (event) {
  23630. this.scrollTop -= event.translationY;
  23631. };
  23632. TreeView.prototype.onMsGestureTap = function (event) {
  23633. event.initialTarget = document.elementFromPoint(event.clientX, event.clientY);
  23634. this.onTap(event);
  23635. };
  23636. // DOM changes
  23637. TreeView.prototype.insertItemInDOM = function (item) {
  23638. var elementAfter = null;
  23639. var itemAfter = this.itemAfter(item);
  23640. if (itemAfter && itemAfter.element) {
  23641. elementAfter = itemAfter.element;
  23642. }
  23643. item.insertInDOM(this.rowsContainer, elementAfter);
  23644. };
  23645. TreeView.prototype.removeItemFromDOM = function (item) {
  23646. if (!item) {
  23647. return;
  23648. }
  23649. item.removeFromDOM();
  23650. };
  23651. // Helpers
  23652. TreeView.prototype.shouldBeRendered = function (item) {
  23653. return item.top < this.lastRenderTop + this.lastRenderHeight && item.top + item.height > this.lastRenderTop;
  23654. };
  23655. TreeView.prototype.getItemAround = function (element) {
  23656. var candidate = this.inputItem;
  23657. var el = element;
  23658. do {
  23659. if (el[TreeView.BINDING]) {
  23660. candidate = el[TreeView.BINDING];
  23661. }
  23662. if (el === this.wrapper || el === this.domNode) {
  23663. return candidate;
  23664. }
  23665. if (el === this.scrollableElement.getDomNode() || el === document.body) {
  23666. return undefined;
  23667. }
  23668. } while (el = el.parentElement);
  23669. return undefined;
  23670. };
  23671. // Cleanup
  23672. TreeView.prototype.releaseModel = function () {
  23673. if (this.model) {
  23674. this.modelListeners = Lifecycle.dispose(this.modelListeners);
  23675. this.model = null;
  23676. }
  23677. };
  23678. TreeView.prototype.dispose = function () {
  23679. var _this = this;
  23680. // TODO@joao: improve
  23681. this.scrollableElement.dispose();
  23682. this.releaseModel();
  23683. this.viewListeners = Lifecycle.dispose(this.viewListeners);
  23684. this._onDOMFocus.dispose();
  23685. this._onDOMBlur.dispose();
  23686. if (this.domNode.parentNode) {
  23687. this.domNode.parentNode.removeChild(this.domNode);
  23688. }
  23689. if (this.items) {
  23690. Object.keys(this.items).forEach(function (key) { return _this.items[key].removeFromDOM(); });
  23691. }
  23692. if (this.context.cache) {
  23693. this.context.cache.dispose();
  23694. }
  23695. this.gestureDisposable.dispose();
  23696. _super.prototype.dispose.call(this);
  23697. };
  23698. TreeView.BINDING = 'monaco-tree-row';
  23699. TreeView.LOADING_DECORATION_DELAY = 800;
  23700. TreeView.counter = 0;
  23701. return TreeView;
  23702. }(treeViewModel_1.HeightMap));
  23703. exports.TreeView = TreeView;
  23704. });
  23705. define(__m[278/*vs/css!vs/base/browser/ui/splitview/splitview*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  23706. /*---------------------------------------------------------------------------------------------
  23707. * Copyright (c) Microsoft Corporation. All rights reserved.
  23708. * Licensed under the MIT License. See License.txt in the project root for license information.
  23709. *--------------------------------------------------------------------------------------------*/
  23710. var __spreadArrays = (this && this.__spreadArrays) || function () {
  23711. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  23712. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  23713. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  23714. r[k] = a[j];
  23715. return r;
  23716. };
  23717. define(__m[279/*vs/base/browser/ui/splitview/splitview*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,4/*vs/base/common/event*/,21/*vs/base/common/types*/,6/*vs/base/browser/dom*/,131/*vs/base/common/numbers*/,19/*vs/base/common/arrays*/,104/*vs/base/browser/ui/sash/sash*/,27/*vs/base/common/color*/,52/*vs/base/browser/event*/,278/*vs/css!vs/base/browser/ui/splitview/splitview*/]), function (require, exports, lifecycle_1, event_1, types, dom, numbers_1, arrays_1, sash_1, color_1, event_2) {
  23718. "use strict";
  23719. Object.defineProperty(exports, "__esModule", { value: true });
  23720. var defaultStyles = {
  23721. separatorBorder: color_1.Color.transparent
  23722. };
  23723. var ViewItem = /** @class */ (function () {
  23724. function ViewItem(container, view, size, disposable) {
  23725. this.container = container;
  23726. this.view = view;
  23727. this.disposable = disposable;
  23728. this._cachedVisibleSize = undefined;
  23729. if (typeof size === 'number') {
  23730. this._size = size;
  23731. this._cachedVisibleSize = undefined;
  23732. dom.addClass(container, 'visible');
  23733. }
  23734. else {
  23735. this._size = 0;
  23736. this._cachedVisibleSize = size.cachedVisibleSize;
  23737. }
  23738. }
  23739. Object.defineProperty(ViewItem.prototype, "size", {
  23740. get: function () {
  23741. return this._size;
  23742. },
  23743. set: function (size) {
  23744. this._size = size;
  23745. },
  23746. enumerable: true,
  23747. configurable: true
  23748. });
  23749. Object.defineProperty(ViewItem.prototype, "visible", {
  23750. get: function () {
  23751. return typeof this._cachedVisibleSize === 'undefined';
  23752. },
  23753. enumerable: true,
  23754. configurable: true
  23755. });
  23756. ViewItem.prototype.setVisible = function (visible, size) {
  23757. if (visible === this.visible) {
  23758. return;
  23759. }
  23760. if (visible) {
  23761. this.size = numbers_1.clamp(this._cachedVisibleSize, this.viewMinimumSize, this.viewMaximumSize);
  23762. this._cachedVisibleSize = undefined;
  23763. }
  23764. else {
  23765. this._cachedVisibleSize = typeof size === 'number' ? size : this.size;
  23766. this.size = 0;
  23767. }
  23768. dom.toggleClass(this.container, 'visible', visible);
  23769. if (this.view.setVisible) {
  23770. this.view.setVisible(visible);
  23771. }
  23772. };
  23773. Object.defineProperty(ViewItem.prototype, "minimumSize", {
  23774. get: function () { return this.visible ? this.view.minimumSize : 0; },
  23775. enumerable: true,
  23776. configurable: true
  23777. });
  23778. Object.defineProperty(ViewItem.prototype, "viewMinimumSize", {
  23779. get: function () { return this.view.minimumSize; },
  23780. enumerable: true,
  23781. configurable: true
  23782. });
  23783. Object.defineProperty(ViewItem.prototype, "maximumSize", {
  23784. get: function () { return this.visible ? this.view.maximumSize : 0; },
  23785. enumerable: true,
  23786. configurable: true
  23787. });
  23788. Object.defineProperty(ViewItem.prototype, "viewMaximumSize", {
  23789. get: function () { return this.view.maximumSize; },
  23790. enumerable: true,
  23791. configurable: true
  23792. });
  23793. Object.defineProperty(ViewItem.prototype, "priority", {
  23794. get: function () { return this.view.priority; },
  23795. enumerable: true,
  23796. configurable: true
  23797. });
  23798. Object.defineProperty(ViewItem.prototype, "snap", {
  23799. get: function () { return !!this.view.snap; },
  23800. enumerable: true,
  23801. configurable: true
  23802. });
  23803. Object.defineProperty(ViewItem.prototype, "enabled", {
  23804. set: function (enabled) {
  23805. this.container.style.pointerEvents = enabled ? null : 'none';
  23806. },
  23807. enumerable: true,
  23808. configurable: true
  23809. });
  23810. ViewItem.prototype.layout = function (offset, layoutContext) {
  23811. this.layoutContainer(offset);
  23812. this.view.layout(this.size, offset, layoutContext);
  23813. };
  23814. ViewItem.prototype.dispose = function () {
  23815. this.disposable.dispose();
  23816. return this.view;
  23817. };
  23818. return ViewItem;
  23819. }());
  23820. var VerticalViewItem = /** @class */ (function (_super) {
  23821. __extends(VerticalViewItem, _super);
  23822. function VerticalViewItem() {
  23823. return _super !== null && _super.apply(this, arguments) || this;
  23824. }
  23825. VerticalViewItem.prototype.layoutContainer = function (offset) {
  23826. this.container.style.top = offset + "px";
  23827. this.container.style.height = this.size + "px";
  23828. };
  23829. return VerticalViewItem;
  23830. }(ViewItem));
  23831. var HorizontalViewItem = /** @class */ (function (_super) {
  23832. __extends(HorizontalViewItem, _super);
  23833. function HorizontalViewItem() {
  23834. return _super !== null && _super.apply(this, arguments) || this;
  23835. }
  23836. HorizontalViewItem.prototype.layoutContainer = function (offset) {
  23837. this.container.style.left = offset + "px";
  23838. this.container.style.width = this.size + "px";
  23839. };
  23840. return HorizontalViewItem;
  23841. }(ViewItem));
  23842. var State;
  23843. (function (State) {
  23844. State[State["Idle"] = 0] = "Idle";
  23845. State[State["Busy"] = 1] = "Busy";
  23846. })(State || (State = {}));
  23847. var Sizing;
  23848. (function (Sizing) {
  23849. Sizing.Distribute = { type: 'distribute' };
  23850. function Split(index) { return { type: 'split', index: index }; }
  23851. Sizing.Split = Split;
  23852. function Invisible(cachedVisibleSize) { return { type: 'invisible', cachedVisibleSize: cachedVisibleSize }; }
  23853. Sizing.Invisible = Invisible;
  23854. })(Sizing = exports.Sizing || (exports.Sizing = {}));
  23855. var SplitView = /** @class */ (function (_super) {
  23856. __extends(SplitView, _super);
  23857. function SplitView(container, options) {
  23858. if (options === void 0) { options = {}; }
  23859. var _this = _super.call(this) || this;
  23860. _this.size = 0;
  23861. _this.contentSize = 0;
  23862. _this.proportions = undefined;
  23863. _this.viewItems = [];
  23864. _this.sashItems = [];
  23865. _this.state = State.Idle;
  23866. _this._onDidSashChange = _this._register(new event_1.Emitter());
  23867. _this.onDidSashChange = _this._onDidSashChange.event;
  23868. _this._onDidSashReset = _this._register(new event_1.Emitter());
  23869. _this._startSnappingEnabled = true;
  23870. _this._endSnappingEnabled = true;
  23871. _this.orientation = types.isUndefined(options.orientation) ? 0 /* VERTICAL */ : options.orientation;
  23872. _this.inverseAltBehavior = !!options.inverseAltBehavior;
  23873. _this.proportionalLayout = types.isUndefined(options.proportionalLayout) ? true : !!options.proportionalLayout;
  23874. _this.el = document.createElement('div');
  23875. dom.addClass(_this.el, 'monaco-split-view2');
  23876. dom.addClass(_this.el, _this.orientation === 0 /* VERTICAL */ ? 'vertical' : 'horizontal');
  23877. container.appendChild(_this.el);
  23878. _this.sashContainer = dom.append(_this.el, dom.$('.sash-container'));
  23879. _this.viewContainer = dom.append(_this.el, dom.$('.split-view-container'));
  23880. _this.style(options.styles || defaultStyles);
  23881. // We have an existing set of view, add them now
  23882. if (options.descriptor) {
  23883. _this.size = options.descriptor.size;
  23884. options.descriptor.views.forEach(function (viewDescriptor, index) {
  23885. var sizing = types.isUndefined(viewDescriptor.visible) || viewDescriptor.visible ? viewDescriptor.size : { type: 'invisible', cachedVisibleSize: viewDescriptor.size };
  23886. var view = viewDescriptor.view;
  23887. _this.doAddView(view, sizing, index, true);
  23888. });
  23889. // Initialize content size and proportions for first layout
  23890. _this.contentSize = _this.viewItems.reduce(function (r, i) { return r + i.size; }, 0);
  23891. _this.saveProportions();
  23892. }
  23893. return _this;
  23894. }
  23895. Object.defineProperty(SplitView.prototype, "orthogonalStartSash", {
  23896. get: function () { return this._orthogonalStartSash; },
  23897. set: function (sash) {
  23898. for (var _i = 0, _a = this.sashItems; _i < _a.length; _i++) {
  23899. var sashItem = _a[_i];
  23900. sashItem.sash.orthogonalStartSash = sash;
  23901. }
  23902. this._orthogonalStartSash = sash;
  23903. },
  23904. enumerable: true,
  23905. configurable: true
  23906. });
  23907. Object.defineProperty(SplitView.prototype, "orthogonalEndSash", {
  23908. get: function () { return this._orthogonalEndSash; },
  23909. set: function (sash) {
  23910. for (var _i = 0, _a = this.sashItems; _i < _a.length; _i++) {
  23911. var sashItem = _a[_i];
  23912. sashItem.sash.orthogonalEndSash = sash;
  23913. }
  23914. this._orthogonalEndSash = sash;
  23915. },
  23916. enumerable: true,
  23917. configurable: true
  23918. });
  23919. Object.defineProperty(SplitView.prototype, "startSnappingEnabled", {
  23920. get: function () { return this._startSnappingEnabled; },
  23921. set: function (startSnappingEnabled) {
  23922. if (this._startSnappingEnabled === startSnappingEnabled) {
  23923. return;
  23924. }
  23925. this._startSnappingEnabled = startSnappingEnabled;
  23926. this.updateSashEnablement();
  23927. },
  23928. enumerable: true,
  23929. configurable: true
  23930. });
  23931. Object.defineProperty(SplitView.prototype, "endSnappingEnabled", {
  23932. get: function () { return this._endSnappingEnabled; },
  23933. set: function (endSnappingEnabled) {
  23934. if (this._endSnappingEnabled === endSnappingEnabled) {
  23935. return;
  23936. }
  23937. this._endSnappingEnabled = endSnappingEnabled;
  23938. this.updateSashEnablement();
  23939. },
  23940. enumerable: true,
  23941. configurable: true
  23942. });
  23943. SplitView.prototype.style = function (styles) {
  23944. if (styles.separatorBorder.isTransparent()) {
  23945. dom.removeClass(this.el, 'separator-border');
  23946. this.el.style.removeProperty('--separator-border');
  23947. }
  23948. else {
  23949. dom.addClass(this.el, 'separator-border');
  23950. this.el.style.setProperty('--separator-border', styles.separatorBorder.toString());
  23951. }
  23952. };
  23953. SplitView.prototype.addView = function (view, size, index) {
  23954. if (index === void 0) { index = this.viewItems.length; }
  23955. this.doAddView(view, size, index, false);
  23956. };
  23957. SplitView.prototype.layout = function (size, layoutContext) {
  23958. var _this = this;
  23959. var previousSize = Math.max(this.size, this.contentSize);
  23960. this.size = size;
  23961. this.layoutContext = layoutContext;
  23962. if (!this.proportions) {
  23963. var indexes = arrays_1.range(this.viewItems.length);
  23964. var lowPriorityIndexes = indexes.filter(function (i) { return _this.viewItems[i].priority === 1 /* Low */; });
  23965. var highPriorityIndexes = indexes.filter(function (i) { return _this.viewItems[i].priority === 2 /* High */; });
  23966. this.resize(this.viewItems.length - 1, size - previousSize, undefined, lowPriorityIndexes, highPriorityIndexes);
  23967. }
  23968. else {
  23969. for (var i = 0; i < this.viewItems.length; i++) {
  23970. var item = this.viewItems[i];
  23971. item.size = numbers_1.clamp(Math.round(this.proportions[i] * size), item.minimumSize, item.maximumSize);
  23972. }
  23973. }
  23974. this.distributeEmptySpace();
  23975. this.layoutViews();
  23976. };
  23977. SplitView.prototype.saveProportions = function () {
  23978. var _this = this;
  23979. if (this.proportionalLayout && this.contentSize > 0) {
  23980. this.proportions = this.viewItems.map(function (i) { return i.size / _this.contentSize; });
  23981. }
  23982. };
  23983. SplitView.prototype.onSashStart = function (_a) {
  23984. var _this = this;
  23985. var sash = _a.sash, start = _a.start, alt = _a.alt;
  23986. for (var _i = 0, _b = this.viewItems; _i < _b.length; _i++) {
  23987. var item = _b[_i];
  23988. item.enabled = false;
  23989. }
  23990. var index = arrays_1.firstIndex(this.sashItems, function (item) { return item.sash === sash; });
  23991. // This way, we can press Alt while we resize a sash, macOS style!
  23992. var disposable = lifecycle_1.combinedDisposable(event_2.domEvent(document.body, 'keydown')(function (e) { return resetSashDragState(_this.sashDragState.current, e.altKey); }), event_2.domEvent(document.body, 'keyup')(function () { return resetSashDragState(_this.sashDragState.current, false); }));
  23993. var resetSashDragState = function (start, alt) {
  23994. var sizes = _this.viewItems.map(function (i) { return i.size; });
  23995. var minDelta = Number.NEGATIVE_INFINITY;
  23996. var maxDelta = Number.POSITIVE_INFINITY;
  23997. if (_this.inverseAltBehavior) {
  23998. alt = !alt;
  23999. }
  24000. if (alt) {
  24001. // When we're using the last sash with Alt, we're resizing
  24002. // the view to the left/up, instead of right/down as usual
  24003. // Thus, we must do the inverse of the usual
  24004. var isLastSash = index === _this.sashItems.length - 1;
  24005. if (isLastSash) {
  24006. var viewItem = _this.viewItems[index];
  24007. minDelta = (viewItem.minimumSize - viewItem.size) / 2;
  24008. maxDelta = (viewItem.maximumSize - viewItem.size) / 2;
  24009. }
  24010. else {
  24011. var viewItem = _this.viewItems[index + 1];
  24012. minDelta = (viewItem.size - viewItem.maximumSize) / 2;
  24013. maxDelta = (viewItem.size - viewItem.minimumSize) / 2;
  24014. }
  24015. }
  24016. var snapBefore;
  24017. var snapAfter;
  24018. if (!alt) {
  24019. var upIndexes = arrays_1.range(index, -1);
  24020. var downIndexes = arrays_1.range(index + 1, _this.viewItems.length);
  24021. var minDeltaUp = upIndexes.reduce(function (r, i) { return r + (_this.viewItems[i].minimumSize - sizes[i]); }, 0);
  24022. var maxDeltaUp = upIndexes.reduce(function (r, i) { return r + (_this.viewItems[i].viewMaximumSize - sizes[i]); }, 0);
  24023. var maxDeltaDown = downIndexes.length === 0 ? Number.POSITIVE_INFINITY : downIndexes.reduce(function (r, i) { return r + (sizes[i] - _this.viewItems[i].minimumSize); }, 0);
  24024. var minDeltaDown = downIndexes.length === 0 ? Number.NEGATIVE_INFINITY : downIndexes.reduce(function (r, i) { return r + (sizes[i] - _this.viewItems[i].viewMaximumSize); }, 0);
  24025. var minDelta_1 = Math.max(minDeltaUp, minDeltaDown);
  24026. var maxDelta_1 = Math.min(maxDeltaDown, maxDeltaUp);
  24027. var snapBeforeIndex = _this.findFirstSnapIndex(upIndexes);
  24028. var snapAfterIndex = _this.findFirstSnapIndex(downIndexes);
  24029. if (typeof snapBeforeIndex === 'number') {
  24030. var viewItem = _this.viewItems[snapBeforeIndex];
  24031. var halfSize = Math.floor(viewItem.viewMinimumSize / 2);
  24032. snapBefore = {
  24033. index: snapBeforeIndex,
  24034. limitDelta: viewItem.visible ? minDelta_1 - halfSize : minDelta_1 + halfSize,
  24035. size: viewItem.size
  24036. };
  24037. }
  24038. if (typeof snapAfterIndex === 'number') {
  24039. var viewItem = _this.viewItems[snapAfterIndex];
  24040. var halfSize = Math.floor(viewItem.viewMinimumSize / 2);
  24041. snapAfter = {
  24042. index: snapAfterIndex,
  24043. limitDelta: viewItem.visible ? maxDelta_1 + halfSize : maxDelta_1 - halfSize,
  24044. size: viewItem.size
  24045. };
  24046. }
  24047. }
  24048. _this.sashDragState = { start: start, current: start, index: index, sizes: sizes, minDelta: minDelta, maxDelta: maxDelta, alt: alt, snapBefore: snapBefore, snapAfter: snapAfter, disposable: disposable };
  24049. };
  24050. resetSashDragState(start, alt);
  24051. };
  24052. SplitView.prototype.onSashChange = function (_a) {
  24053. var current = _a.current;
  24054. var _b = this.sashDragState, index = _b.index, start = _b.start, sizes = _b.sizes, alt = _b.alt, minDelta = _b.minDelta, maxDelta = _b.maxDelta, snapBefore = _b.snapBefore, snapAfter = _b.snapAfter;
  24055. this.sashDragState.current = current;
  24056. var delta = current - start;
  24057. var newDelta = this.resize(index, delta, sizes, undefined, undefined, minDelta, maxDelta, snapBefore, snapAfter);
  24058. if (alt) {
  24059. var isLastSash = index === this.sashItems.length - 1;
  24060. var newSizes = this.viewItems.map(function (i) { return i.size; });
  24061. var viewItemIndex = isLastSash ? index : index + 1;
  24062. var viewItem = this.viewItems[viewItemIndex];
  24063. var newMinDelta = viewItem.size - viewItem.maximumSize;
  24064. var newMaxDelta = viewItem.size - viewItem.minimumSize;
  24065. var resizeIndex = isLastSash ? index - 1 : index + 1;
  24066. this.resize(resizeIndex, -newDelta, newSizes, undefined, undefined, newMinDelta, newMaxDelta);
  24067. }
  24068. this.distributeEmptySpace();
  24069. this.layoutViews();
  24070. };
  24071. SplitView.prototype.onSashEnd = function (index) {
  24072. this._onDidSashChange.fire(index);
  24073. this.sashDragState.disposable.dispose();
  24074. this.saveProportions();
  24075. for (var _i = 0, _a = this.viewItems; _i < _a.length; _i++) {
  24076. var item = _a[_i];
  24077. item.enabled = true;
  24078. }
  24079. };
  24080. SplitView.prototype.onViewChange = function (item, size) {
  24081. var index = this.viewItems.indexOf(item);
  24082. if (index < 0 || index >= this.viewItems.length) {
  24083. return;
  24084. }
  24085. size = typeof size === 'number' ? size : item.size;
  24086. size = numbers_1.clamp(size, item.minimumSize, item.maximumSize);
  24087. if (this.inverseAltBehavior && index > 0) {
  24088. // In this case, we want the view to grow or shrink both sides equally
  24089. // so we just resize the "left" side by half and let `resize` do the clamping magic
  24090. this.resize(index - 1, Math.floor((item.size - size) / 2));
  24091. this.distributeEmptySpace();
  24092. this.layoutViews();
  24093. }
  24094. else {
  24095. item.size = size;
  24096. this.relayout([index], undefined);
  24097. }
  24098. };
  24099. SplitView.prototype.resizeView = function (index, size) {
  24100. var _this = this;
  24101. if (this.state !== State.Idle) {
  24102. throw new Error('Cant modify splitview');
  24103. }
  24104. this.state = State.Busy;
  24105. if (index < 0 || index >= this.viewItems.length) {
  24106. return;
  24107. }
  24108. var indexes = arrays_1.range(this.viewItems.length).filter(function (i) { return i !== index; });
  24109. var lowPriorityIndexes = __spreadArrays(indexes.filter(function (i) { return _this.viewItems[i].priority === 1 /* Low */; }), [index]);
  24110. var highPriorityIndexes = indexes.filter(function (i) { return _this.viewItems[i].priority === 2 /* High */; });
  24111. var item = this.viewItems[index];
  24112. size = Math.round(size);
  24113. size = numbers_1.clamp(size, item.minimumSize, Math.min(item.maximumSize, this.size));
  24114. item.size = size;
  24115. this.relayout(lowPriorityIndexes, highPriorityIndexes);
  24116. this.state = State.Idle;
  24117. };
  24118. SplitView.prototype.distributeViewSizes = function () {
  24119. var _this = this;
  24120. var flexibleViewItems = [];
  24121. var flexibleSize = 0;
  24122. for (var _i = 0, _a = this.viewItems; _i < _a.length; _i++) {
  24123. var item = _a[_i];
  24124. if (item.maximumSize - item.minimumSize > 0) {
  24125. flexibleViewItems.push(item);
  24126. flexibleSize += item.size;
  24127. }
  24128. }
  24129. var size = Math.floor(flexibleSize / flexibleViewItems.length);
  24130. for (var _b = 0, flexibleViewItems_1 = flexibleViewItems; _b < flexibleViewItems_1.length; _b++) {
  24131. var item = flexibleViewItems_1[_b];
  24132. item.size = numbers_1.clamp(size, item.minimumSize, item.maximumSize);
  24133. }
  24134. var indexes = arrays_1.range(this.viewItems.length);
  24135. var lowPriorityIndexes = indexes.filter(function (i) { return _this.viewItems[i].priority === 1 /* Low */; });
  24136. var highPriorityIndexes = indexes.filter(function (i) { return _this.viewItems[i].priority === 2 /* High */; });
  24137. this.relayout(lowPriorityIndexes, highPriorityIndexes);
  24138. };
  24139. SplitView.prototype.getViewSize = function (index) {
  24140. if (index < 0 || index >= this.viewItems.length) {
  24141. return -1;
  24142. }
  24143. return this.viewItems[index].size;
  24144. };
  24145. SplitView.prototype.doAddView = function (view, size, index, skipLayout) {
  24146. var _this = this;
  24147. if (index === void 0) { index = this.viewItems.length; }
  24148. if (this.state !== State.Idle) {
  24149. throw new Error('Cant modify splitview');
  24150. }
  24151. this.state = State.Busy;
  24152. // Add view
  24153. var container = dom.$('.split-view-view');
  24154. if (index === this.viewItems.length) {
  24155. this.viewContainer.appendChild(container);
  24156. }
  24157. else {
  24158. this.viewContainer.insertBefore(container, this.viewContainer.children.item(index));
  24159. }
  24160. var onChangeDisposable = view.onDidChange(function (size) { return _this.onViewChange(item, size); });
  24161. var containerDisposable = lifecycle_1.toDisposable(function () { return _this.viewContainer.removeChild(container); });
  24162. var disposable = lifecycle_1.combinedDisposable(onChangeDisposable, containerDisposable);
  24163. var viewSize;
  24164. if (typeof size === 'number') {
  24165. viewSize = size;
  24166. }
  24167. else if (size.type === 'split') {
  24168. viewSize = this.getViewSize(size.index) / 2;
  24169. }
  24170. else if (size.type === 'invisible') {
  24171. viewSize = { cachedVisibleSize: size.cachedVisibleSize };
  24172. }
  24173. else {
  24174. viewSize = view.minimumSize;
  24175. }
  24176. var item = this.orientation === 0 /* VERTICAL */
  24177. ? new VerticalViewItem(container, view, viewSize, disposable)
  24178. : new HorizontalViewItem(container, view, viewSize, disposable);
  24179. this.viewItems.splice(index, 0, item);
  24180. // Add sash
  24181. if (this.viewItems.length > 1) {
  24182. var orientation_1 = this.orientation === 0 /* VERTICAL */ ? 1 /* HORIZONTAL */ : 0 /* VERTICAL */;
  24183. var layoutProvider = this.orientation === 0 /* VERTICAL */ ? { getHorizontalSashTop: function (sash) { return _this.getSashPosition(sash); } } : { getVerticalSashLeft: function (sash) { return _this.getSashPosition(sash); } };
  24184. var sash_2 = new sash_1.Sash(this.sashContainer, layoutProvider, {
  24185. orientation: orientation_1,
  24186. orthogonalStartSash: this.orthogonalStartSash,
  24187. orthogonalEndSash: this.orthogonalEndSash
  24188. });
  24189. var sashEventMapper = this.orientation === 0 /* VERTICAL */
  24190. ? function (e) { return ({ sash: sash_2, start: e.startY, current: e.currentY, alt: e.altKey }); }
  24191. : function (e) { return ({ sash: sash_2, start: e.startX, current: e.currentX, alt: e.altKey }); };
  24192. var onStart = event_1.Event.map(sash_2.onDidStart, sashEventMapper);
  24193. var onStartDisposable = onStart(this.onSashStart, this);
  24194. var onChange = event_1.Event.map(sash_2.onDidChange, sashEventMapper);
  24195. var onChangeDisposable_1 = onChange(this.onSashChange, this);
  24196. var onEnd = event_1.Event.map(sash_2.onDidEnd, function () { return arrays_1.firstIndex(_this.sashItems, function (item) { return item.sash === sash_2; }); });
  24197. var onEndDisposable = onEnd(this.onSashEnd, this);
  24198. var onDidResetDisposable = sash_2.onDidReset(function () {
  24199. var index = arrays_1.firstIndex(_this.sashItems, function (item) { return item.sash === sash_2; });
  24200. var upIndexes = arrays_1.range(index, -1);
  24201. var downIndexes = arrays_1.range(index + 1, _this.viewItems.length);
  24202. var snapBeforeIndex = _this.findFirstSnapIndex(upIndexes);
  24203. var snapAfterIndex = _this.findFirstSnapIndex(downIndexes);
  24204. if (typeof snapBeforeIndex === 'number' && !_this.viewItems[snapBeforeIndex].visible) {
  24205. return;
  24206. }
  24207. if (typeof snapAfterIndex === 'number' && !_this.viewItems[snapAfterIndex].visible) {
  24208. return;
  24209. }
  24210. _this._onDidSashReset.fire(index);
  24211. });
  24212. var disposable_1 = lifecycle_1.combinedDisposable(onStartDisposable, onChangeDisposable_1, onEndDisposable, onDidResetDisposable, sash_2);
  24213. var sashItem = { sash: sash_2, disposable: disposable_1 };
  24214. this.sashItems.splice(index - 1, 0, sashItem);
  24215. }
  24216. container.appendChild(view.element);
  24217. var highPriorityIndexes;
  24218. if (typeof size !== 'number' && size.type === 'split') {
  24219. highPriorityIndexes = [size.index];
  24220. }
  24221. if (!skipLayout) {
  24222. this.relayout([index], highPriorityIndexes);
  24223. }
  24224. this.state = State.Idle;
  24225. if (!skipLayout && typeof size !== 'number' && size.type === 'distribute') {
  24226. this.distributeViewSizes();
  24227. }
  24228. };
  24229. SplitView.prototype.relayout = function (lowPriorityIndexes, highPriorityIndexes) {
  24230. var contentSize = this.viewItems.reduce(function (r, i) { return r + i.size; }, 0);
  24231. this.resize(this.viewItems.length - 1, this.size - contentSize, undefined, lowPriorityIndexes, highPriorityIndexes);
  24232. this.distributeEmptySpace();
  24233. this.layoutViews();
  24234. this.saveProportions();
  24235. };
  24236. SplitView.prototype.resize = function (index, delta, sizes, lowPriorityIndexes, highPriorityIndexes, overloadMinDelta, overloadMaxDelta, snapBefore, snapAfter) {
  24237. var _this = this;
  24238. if (sizes === void 0) { sizes = this.viewItems.map(function (i) { return i.size; }); }
  24239. if (overloadMinDelta === void 0) { overloadMinDelta = Number.NEGATIVE_INFINITY; }
  24240. if (overloadMaxDelta === void 0) { overloadMaxDelta = Number.POSITIVE_INFINITY; }
  24241. if (index < 0 || index >= this.viewItems.length) {
  24242. return 0;
  24243. }
  24244. var upIndexes = arrays_1.range(index, -1);
  24245. var downIndexes = arrays_1.range(index + 1, this.viewItems.length);
  24246. if (highPriorityIndexes) {
  24247. for (var _i = 0, highPriorityIndexes_1 = highPriorityIndexes; _i < highPriorityIndexes_1.length; _i++) {
  24248. var index_1 = highPriorityIndexes_1[_i];
  24249. arrays_1.pushToStart(upIndexes, index_1);
  24250. arrays_1.pushToStart(downIndexes, index_1);
  24251. }
  24252. }
  24253. if (lowPriorityIndexes) {
  24254. for (var _a = 0, lowPriorityIndexes_1 = lowPriorityIndexes; _a < lowPriorityIndexes_1.length; _a++) {
  24255. var index_2 = lowPriorityIndexes_1[_a];
  24256. arrays_1.pushToEnd(upIndexes, index_2);
  24257. arrays_1.pushToEnd(downIndexes, index_2);
  24258. }
  24259. }
  24260. var upItems = upIndexes.map(function (i) { return _this.viewItems[i]; });
  24261. var upSizes = upIndexes.map(function (i) { return sizes[i]; });
  24262. var downItems = downIndexes.map(function (i) { return _this.viewItems[i]; });
  24263. var downSizes = downIndexes.map(function (i) { return sizes[i]; });
  24264. var minDeltaUp = upIndexes.reduce(function (r, i) { return r + (_this.viewItems[i].minimumSize - sizes[i]); }, 0);
  24265. var maxDeltaUp = upIndexes.reduce(function (r, i) { return r + (_this.viewItems[i].maximumSize - sizes[i]); }, 0);
  24266. var maxDeltaDown = downIndexes.length === 0 ? Number.POSITIVE_INFINITY : downIndexes.reduce(function (r, i) { return r + (sizes[i] - _this.viewItems[i].minimumSize); }, 0);
  24267. var minDeltaDown = downIndexes.length === 0 ? Number.NEGATIVE_INFINITY : downIndexes.reduce(function (r, i) { return r + (sizes[i] - _this.viewItems[i].maximumSize); }, 0);
  24268. var minDelta = Math.max(minDeltaUp, minDeltaDown, overloadMinDelta);
  24269. var maxDelta = Math.min(maxDeltaDown, maxDeltaUp, overloadMaxDelta);
  24270. var snapped = false;
  24271. if (snapBefore) {
  24272. var snapView = this.viewItems[snapBefore.index];
  24273. var visible = delta >= snapBefore.limitDelta;
  24274. snapped = visible !== snapView.visible;
  24275. snapView.setVisible(visible, snapBefore.size);
  24276. }
  24277. if (!snapped && snapAfter) {
  24278. var snapView = this.viewItems[snapAfter.index];
  24279. var visible = delta < snapAfter.limitDelta;
  24280. snapped = visible !== snapView.visible;
  24281. snapView.setVisible(visible, snapAfter.size);
  24282. }
  24283. if (snapped) {
  24284. return this.resize(index, delta, sizes, lowPriorityIndexes, highPriorityIndexes, overloadMinDelta, overloadMaxDelta);
  24285. }
  24286. delta = numbers_1.clamp(delta, minDelta, maxDelta);
  24287. for (var i = 0, deltaUp = delta; i < upItems.length; i++) {
  24288. var item = upItems[i];
  24289. var size = numbers_1.clamp(upSizes[i] + deltaUp, item.minimumSize, item.maximumSize);
  24290. var viewDelta = size - upSizes[i];
  24291. deltaUp -= viewDelta;
  24292. item.size = size;
  24293. }
  24294. for (var i = 0, deltaDown = delta; i < downItems.length; i++) {
  24295. var item = downItems[i];
  24296. var size = numbers_1.clamp(downSizes[i] - deltaDown, item.minimumSize, item.maximumSize);
  24297. var viewDelta = size - downSizes[i];
  24298. deltaDown += viewDelta;
  24299. item.size = size;
  24300. }
  24301. return delta;
  24302. };
  24303. SplitView.prototype.distributeEmptySpace = function (lowPriorityIndex) {
  24304. var _this = this;
  24305. var contentSize = this.viewItems.reduce(function (r, i) { return r + i.size; }, 0);
  24306. var emptyDelta = this.size - contentSize;
  24307. var indexes = arrays_1.range(this.viewItems.length - 1, -1);
  24308. var lowPriorityIndexes = indexes.filter(function (i) { return _this.viewItems[i].priority === 1 /* Low */; });
  24309. var highPriorityIndexes = indexes.filter(function (i) { return _this.viewItems[i].priority === 2 /* High */; });
  24310. for (var _i = 0, highPriorityIndexes_2 = highPriorityIndexes; _i < highPriorityIndexes_2.length; _i++) {
  24311. var index = highPriorityIndexes_2[_i];
  24312. arrays_1.pushToStart(indexes, index);
  24313. }
  24314. for (var _a = 0, lowPriorityIndexes_2 = lowPriorityIndexes; _a < lowPriorityIndexes_2.length; _a++) {
  24315. var index = lowPriorityIndexes_2[_a];
  24316. arrays_1.pushToEnd(indexes, index);
  24317. }
  24318. if (typeof lowPriorityIndex === 'number') {
  24319. arrays_1.pushToEnd(indexes, lowPriorityIndex);
  24320. }
  24321. for (var i = 0; emptyDelta !== 0 && i < indexes.length; i++) {
  24322. var item = this.viewItems[indexes[i]];
  24323. var size = numbers_1.clamp(item.size + emptyDelta, item.minimumSize, item.maximumSize);
  24324. var viewDelta = size - item.size;
  24325. emptyDelta -= viewDelta;
  24326. item.size = size;
  24327. }
  24328. };
  24329. SplitView.prototype.layoutViews = function () {
  24330. // Save new content size
  24331. this.contentSize = this.viewItems.reduce(function (r, i) { return r + i.size; }, 0);
  24332. // Layout views
  24333. var offset = 0;
  24334. for (var _i = 0, _a = this.viewItems; _i < _a.length; _i++) {
  24335. var viewItem = _a[_i];
  24336. viewItem.layout(offset, this.layoutContext);
  24337. offset += viewItem.size;
  24338. }
  24339. // Layout sashes
  24340. this.sashItems.forEach(function (item) { return item.sash.layout(); });
  24341. this.updateSashEnablement();
  24342. };
  24343. SplitView.prototype.updateSashEnablement = function () {
  24344. var previous = false;
  24345. var collapsesDown = this.viewItems.map(function (i) { return previous = (i.size - i.minimumSize > 0) || previous; });
  24346. previous = false;
  24347. var expandsDown = this.viewItems.map(function (i) { return previous = (i.maximumSize - i.size > 0) || previous; });
  24348. var reverseViews = __spreadArrays(this.viewItems).reverse();
  24349. previous = false;
  24350. var collapsesUp = reverseViews.map(function (i) { return previous = (i.size - i.minimumSize > 0) || previous; }).reverse();
  24351. previous = false;
  24352. var expandsUp = reverseViews.map(function (i) { return previous = (i.maximumSize - i.size > 0) || previous; }).reverse();
  24353. var position = 0;
  24354. for (var index = 0; index < this.sashItems.length; index++) {
  24355. var sash = this.sashItems[index].sash;
  24356. var viewItem = this.viewItems[index];
  24357. position += viewItem.size;
  24358. var min = !(collapsesDown[index] && expandsUp[index + 1]);
  24359. var max = !(expandsDown[index] && collapsesUp[index + 1]);
  24360. if (min && max) {
  24361. var upIndexes = arrays_1.range(index, -1);
  24362. var downIndexes = arrays_1.range(index + 1, this.viewItems.length);
  24363. var snapBeforeIndex = this.findFirstSnapIndex(upIndexes);
  24364. var snapAfterIndex = this.findFirstSnapIndex(downIndexes);
  24365. var snappedBefore = typeof snapBeforeIndex === 'number' && !this.viewItems[snapBeforeIndex].visible;
  24366. var snappedAfter = typeof snapAfterIndex === 'number' && !this.viewItems[snapAfterIndex].visible;
  24367. if (snappedBefore && collapsesUp[index] && (position > 0 || this.startSnappingEnabled)) {
  24368. sash.state = 1 /* Minimum */;
  24369. }
  24370. else if (snappedAfter && collapsesDown[index] && (position < this.contentSize || this.endSnappingEnabled)) {
  24371. sash.state = 2 /* Maximum */;
  24372. }
  24373. else {
  24374. sash.state = 0 /* Disabled */;
  24375. }
  24376. }
  24377. else if (min && !max) {
  24378. sash.state = 1 /* Minimum */;
  24379. }
  24380. else if (!min && max) {
  24381. sash.state = 2 /* Maximum */;
  24382. }
  24383. else {
  24384. sash.state = 3 /* Enabled */;
  24385. }
  24386. }
  24387. };
  24388. SplitView.prototype.getSashPosition = function (sash) {
  24389. var position = 0;
  24390. for (var i = 0; i < this.sashItems.length; i++) {
  24391. position += this.viewItems[i].size;
  24392. if (this.sashItems[i].sash === sash) {
  24393. return Math.min(position, this.contentSize - 2);
  24394. }
  24395. }
  24396. return 0;
  24397. };
  24398. SplitView.prototype.findFirstSnapIndex = function (indexes) {
  24399. // visible views first
  24400. for (var _i = 0, indexes_1 = indexes; _i < indexes_1.length; _i++) {
  24401. var index = indexes_1[_i];
  24402. var viewItem = this.viewItems[index];
  24403. if (!viewItem.visible) {
  24404. continue;
  24405. }
  24406. if (viewItem.snap) {
  24407. return index;
  24408. }
  24409. }
  24410. // then, hidden views
  24411. for (var _a = 0, indexes_2 = indexes; _a < indexes_2.length; _a++) {
  24412. var index = indexes_2[_a];
  24413. var viewItem = this.viewItems[index];
  24414. if (viewItem.visible && viewItem.maximumSize - viewItem.minimumSize > 0) {
  24415. return undefined;
  24416. }
  24417. if (!viewItem.visible && viewItem.snap) {
  24418. return index;
  24419. }
  24420. }
  24421. return undefined;
  24422. };
  24423. SplitView.prototype.dispose = function () {
  24424. _super.prototype.dispose.call(this);
  24425. this.viewItems.forEach(function (i) { return i.dispose(); });
  24426. this.viewItems = [];
  24427. this.sashItems.forEach(function (i) { return i.disposable.dispose(); });
  24428. this.sashItems = [];
  24429. };
  24430. return SplitView;
  24431. }(lifecycle_1.Disposable));
  24432. exports.SplitView = SplitView;
  24433. });
  24434. define(__m[280/*vs/css!vs/base/browser/ui/tree/media/tree*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24435. define(__m[281/*vs/css!vs/base/parts/quickopen/browser/quickopen*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24436. define(__m[282/*vs/css!vs/base/parts/tree/browser/tree*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24437. /*---------------------------------------------------------------------------------------------
  24438. * Copyright (c) Microsoft Corporation. All rights reserved.
  24439. * Licensed under the MIT License. See License.txt in the project root for license information.
  24440. *--------------------------------------------------------------------------------------------*/
  24441. define(__m[283/*vs/base/parts/tree/browser/treeImpl*/], __M([0/*require*/,1/*exports*/,137/*vs/base/parts/tree/browser/treeDefaults*/,256/*vs/base/parts/tree/browser/treeModel*/,277/*vs/base/parts/tree/browser/treeView*/,4/*vs/base/common/event*/,27/*vs/base/common/color*/,31/*vs/base/common/objects*/,282/*vs/css!vs/base/parts/tree/browser/tree*/]), function (require, exports, TreeDefaults, Model, View, event_1, color_1, objects_1) {
  24442. "use strict";
  24443. Object.defineProperty(exports, "__esModule", { value: true });
  24444. var TreeContext = /** @class */ (function () {
  24445. function TreeContext(tree, configuration, options) {
  24446. if (options === void 0) { options = {}; }
  24447. this.tree = tree;
  24448. this.configuration = configuration;
  24449. this.options = options;
  24450. if (!configuration.dataSource) {
  24451. throw new Error('You must provide a Data Source to the tree.');
  24452. }
  24453. this.dataSource = configuration.dataSource;
  24454. this.renderer = configuration.renderer;
  24455. this.controller = configuration.controller || new TreeDefaults.DefaultController({ clickBehavior: 1 /* ON_MOUSE_UP */, keyboardSupport: typeof options.keyboardSupport !== 'boolean' || options.keyboardSupport });
  24456. this.dnd = configuration.dnd || new TreeDefaults.DefaultDragAndDrop();
  24457. this.filter = configuration.filter || new TreeDefaults.DefaultFilter();
  24458. this.sorter = configuration.sorter;
  24459. this.accessibilityProvider = configuration.accessibilityProvider || new TreeDefaults.DefaultAccessibilityProvider();
  24460. this.styler = configuration.styler;
  24461. }
  24462. return TreeContext;
  24463. }());
  24464. exports.TreeContext = TreeContext;
  24465. var defaultStyles = {
  24466. listFocusBackground: color_1.Color.fromHex('#073655'),
  24467. listActiveSelectionBackground: color_1.Color.fromHex('#0E639C'),
  24468. listActiveSelectionForeground: color_1.Color.fromHex('#FFFFFF'),
  24469. listFocusAndSelectionBackground: color_1.Color.fromHex('#094771'),
  24470. listFocusAndSelectionForeground: color_1.Color.fromHex('#FFFFFF'),
  24471. listInactiveSelectionBackground: color_1.Color.fromHex('#3F3F46'),
  24472. listHoverBackground: color_1.Color.fromHex('#2A2D2E'),
  24473. listDropBackground: color_1.Color.fromHex('#383B3D')
  24474. };
  24475. var Tree = /** @class */ (function () {
  24476. function Tree(container, configuration, options) {
  24477. if (options === void 0) { options = {}; }
  24478. this._onDidChangeFocus = new event_1.Relay();
  24479. this.onDidChangeFocus = this._onDidChangeFocus.event;
  24480. this._onDidChangeSelection = new event_1.Relay();
  24481. this.onDidChangeSelection = this._onDidChangeSelection.event;
  24482. this._onHighlightChange = new event_1.Relay();
  24483. this._onDidExpandItem = new event_1.Relay();
  24484. this._onDidCollapseItem = new event_1.Relay();
  24485. this._onDispose = new event_1.Emitter();
  24486. this.onDidDispose = this._onDispose.event;
  24487. this.container = container;
  24488. objects_1.mixin(options, defaultStyles, false);
  24489. options.twistiePixels = typeof options.twistiePixels === 'number' ? options.twistiePixels : 32;
  24490. options.showTwistie = options.showTwistie === false ? false : true;
  24491. options.indentPixels = typeof options.indentPixels === 'number' ? options.indentPixels : 12;
  24492. options.alwaysFocused = options.alwaysFocused === true ? true : false;
  24493. options.useShadows = options.useShadows === false ? false : true;
  24494. options.paddingOnRow = options.paddingOnRow === false ? false : true;
  24495. options.showLoading = options.showLoading === false ? false : true;
  24496. this.context = new TreeContext(this, configuration, options);
  24497. this.model = new Model.TreeModel(this.context);
  24498. this.view = new View.TreeView(this.context, this.container);
  24499. this.view.setModel(this.model);
  24500. this._onDidChangeFocus.input = this.model.onDidFocus;
  24501. this._onDidChangeSelection.input = this.model.onDidSelect;
  24502. this._onHighlightChange.input = this.model.onDidHighlight;
  24503. this._onDidExpandItem.input = this.model.onDidExpandItem;
  24504. this._onDidCollapseItem.input = this.model.onDidCollapseItem;
  24505. }
  24506. Tree.prototype.style = function (styles) {
  24507. this.view.applyStyles(styles);
  24508. };
  24509. Object.defineProperty(Tree.prototype, "onDidFocus", {
  24510. get: function () {
  24511. return this.view.onDOMFocus;
  24512. },
  24513. enumerable: true,
  24514. configurable: true
  24515. });
  24516. Tree.prototype.getHTMLElement = function () {
  24517. return this.view.getHTMLElement();
  24518. };
  24519. Tree.prototype.layout = function (height, width) {
  24520. this.view.layout(height, width);
  24521. };
  24522. Tree.prototype.domFocus = function () {
  24523. this.view.focus();
  24524. };
  24525. Tree.prototype.isDOMFocused = function () {
  24526. return this.view.isFocused();
  24527. };
  24528. Tree.prototype.domBlur = function () {
  24529. this.view.blur();
  24530. };
  24531. Tree.prototype.setInput = function (element) {
  24532. return this.model.setInput(element);
  24533. };
  24534. Tree.prototype.getInput = function () {
  24535. return this.model.getInput();
  24536. };
  24537. Tree.prototype.expand = function (element) {
  24538. return this.model.expand(element);
  24539. };
  24540. Tree.prototype.collapse = function (element, recursive) {
  24541. if (recursive === void 0) { recursive = false; }
  24542. return this.model.collapse(element, recursive);
  24543. };
  24544. Tree.prototype.toggleExpansion = function (element, recursive) {
  24545. if (recursive === void 0) { recursive = false; }
  24546. return this.model.toggleExpansion(element, recursive);
  24547. };
  24548. Tree.prototype.isExpanded = function (element) {
  24549. return this.model.isExpanded(element);
  24550. };
  24551. Tree.prototype.reveal = function (element, relativeTop) {
  24552. if (relativeTop === void 0) { relativeTop = null; }
  24553. return this.model.reveal(element, relativeTop);
  24554. };
  24555. Tree.prototype.getHighlight = function () {
  24556. return this.model.getHighlight();
  24557. };
  24558. Tree.prototype.clearHighlight = function (eventPayload) {
  24559. this.model.setHighlight(null, eventPayload);
  24560. };
  24561. Tree.prototype.setSelection = function (elements, eventPayload) {
  24562. this.model.setSelection(elements, eventPayload);
  24563. };
  24564. Tree.prototype.getSelection = function () {
  24565. return this.model.getSelection();
  24566. };
  24567. Tree.prototype.clearSelection = function (eventPayload) {
  24568. this.model.setSelection([], eventPayload);
  24569. };
  24570. Tree.prototype.setFocus = function (element, eventPayload) {
  24571. this.model.setFocus(element, eventPayload);
  24572. };
  24573. Tree.prototype.getFocus = function () {
  24574. return this.model.getFocus();
  24575. };
  24576. Tree.prototype.focusNext = function (count, eventPayload) {
  24577. this.model.focusNext(count, eventPayload);
  24578. };
  24579. Tree.prototype.focusPrevious = function (count, eventPayload) {
  24580. this.model.focusPrevious(count, eventPayload);
  24581. };
  24582. Tree.prototype.focusParent = function (eventPayload) {
  24583. this.model.focusParent(eventPayload);
  24584. };
  24585. Tree.prototype.focusFirstChild = function (eventPayload) {
  24586. this.model.focusFirstChild(eventPayload);
  24587. };
  24588. Tree.prototype.focusFirst = function (eventPayload, from) {
  24589. this.model.focusFirst(eventPayload, from);
  24590. };
  24591. Tree.prototype.focusNth = function (index, eventPayload) {
  24592. this.model.focusNth(index, eventPayload);
  24593. };
  24594. Tree.prototype.focusLast = function (eventPayload, from) {
  24595. this.model.focusLast(eventPayload, from);
  24596. };
  24597. Tree.prototype.focusNextPage = function (eventPayload) {
  24598. this.view.focusNextPage(eventPayload);
  24599. };
  24600. Tree.prototype.focusPreviousPage = function (eventPayload) {
  24601. this.view.focusPreviousPage(eventPayload);
  24602. };
  24603. Tree.prototype.clearFocus = function (eventPayload) {
  24604. this.model.setFocus(null, eventPayload);
  24605. };
  24606. Tree.prototype.dispose = function () {
  24607. this._onDispose.fire();
  24608. this.model.dispose();
  24609. this.view.dispose();
  24610. this._onDidChangeFocus.dispose();
  24611. this._onDidChangeSelection.dispose();
  24612. this._onHighlightChange.dispose();
  24613. this._onDidExpandItem.dispose();
  24614. this._onDidCollapseItem.dispose();
  24615. this._onDispose.dispose();
  24616. };
  24617. return Tree;
  24618. }());
  24619. exports.Tree = Tree;
  24620. });
  24621. define(__m[284/*vs/css!vs/editor/browser/controller/textAreaHandler*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24622. define(__m[285/*vs/css!vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24623. define(__m[286/*vs/css!vs/editor/browser/viewParts/decorations/decorations*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24624. define(__m[287/*vs/css!vs/editor/browser/viewParts/glyphMargin/glyphMargin*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24625. define(__m[288/*vs/css!vs/editor/browser/viewParts/indentGuides/indentGuides*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24626. define(__m[289/*vs/css!vs/editor/browser/viewParts/lineNumbers/lineNumbers*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24627. define(__m[290/*vs/css!vs/editor/browser/viewParts/lines/viewLines*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24628. define(__m[291/*vs/css!vs/editor/browser/viewParts/linesDecorations/linesDecorations*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24629. define(__m[292/*vs/css!vs/editor/browser/viewParts/marginDecorations/marginDecorations*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24630. define(__m[293/*vs/css!vs/editor/browser/viewParts/minimap/minimap*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24631. define(__m[294/*vs/css!vs/editor/browser/viewParts/overlayWidgets/overlayWidgets*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24632. define(__m[295/*vs/css!vs/editor/browser/viewParts/rulers/rulers*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24633. define(__m[296/*vs/css!vs/editor/browser/viewParts/scrollDecoration/scrollDecoration*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24634. define(__m[297/*vs/css!vs/editor/browser/viewParts/selections/selections*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24635. define(__m[298/*vs/css!vs/editor/browser/viewParts/viewCursors/viewCursors*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24636. define(__m[299/*vs/css!vs/editor/browser/widget/media/diffEditor*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24637. define(__m[300/*vs/css!vs/editor/browser/widget/media/diffReview*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24638. define(__m[301/*vs/css!vs/editor/browser/widget/media/editor*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24639. define(__m[302/*vs/css!vs/editor/contrib/bracketMatching/bracketMatching*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24640. define(__m[303/*vs/css!vs/editor/contrib/clipboard/clipboard*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24641. define(__m[304/*vs/css!vs/editor/contrib/codeAction/lightBulbWidget*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24642. define(__m[305/*vs/css!vs/editor/contrib/codelens/codelensWidget*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24643. define(__m[306/*vs/css!vs/editor/contrib/colorPicker/colorPicker*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24644. define(__m[307/*vs/css!vs/editor/contrib/dnd/dnd*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24645. define(__m[308/*vs/css!vs/editor/contrib/documentSymbols/media/outlineTree*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24646. define(__m[309/*vs/css!vs/editor/contrib/documentSymbols/media/symbol-icons*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24647. define(__m[310/*vs/css!vs/editor/contrib/find/findWidget*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24648. define(__m[311/*vs/css!vs/editor/contrib/folding/folding*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24649. define(__m[312/*vs/css!vs/editor/contrib/gotoError/media/gotoErrorWidget*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24650. define(__m[313/*vs/css!vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24651. define(__m[314/*vs/css!vs/editor/contrib/gotoSymbol/peek/referencesWidget*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24652. define(__m[315/*vs/css!vs/editor/contrib/hover/hover*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24653. define(__m[316/*vs/css!vs/editor/contrib/links/links*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24654. define(__m[317/*vs/css!vs/editor/contrib/message/messageController*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24655. define(__m[318/*vs/css!vs/editor/contrib/parameterHints/parameterHints*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24656. define(__m[319/*vs/css!vs/editor/contrib/peekView/media/peekViewWidget*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24657. define(__m[320/*vs/css!vs/editor/contrib/rename/renameInputField*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24658. define(__m[321/*vs/css!vs/editor/contrib/snippet/snippetSession*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24659. define(__m[322/*vs/css!vs/editor/contrib/suggest/media/suggest*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24660. define(__m[323/*vs/css!vs/editor/contrib/suggest/media/suggestStatusBar*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24661. define(__m[324/*vs/css!vs/editor/contrib/zoneWidget/zoneWidget*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24662. define(__m[325/*vs/css!vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24663. define(__m[326/*vs/css!vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24664. define(__m[327/*vs/css!vs/editor/standalone/browser/inspectTokens/inspectTokens*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24665. define(__m[328/*vs/css!vs/editor/standalone/browser/quickOpen/editorQuickOpen*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24666. define(__m[329/*vs/css!vs/editor/standalone/browser/quickOpen/gotoLine*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24667. define(__m[330/*vs/css!vs/editor/standalone/browser/quickOpen/quickOutline*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24668. define(__m[331/*vs/css!vs/editor/standalone/browser/standalone-tokens*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24669. define(__m[332/*vs/css!vs/platform/contextview/browser/contextMenuHandler*/], __M([9/*vs/css!vs/editor/editor.main*/]), {});
  24670. /*---------------------------------------------------------------------------------------------
  24671. * Copyright (c) Microsoft Corporation. All rights reserved.
  24672. * Licensed under the MIT License. See License.txt in the project root for license information.
  24673. *--------------------------------------------------------------------------------------------*/
  24674. define(__m[333/*vs/editor/browser/config/charWidthReader*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  24675. "use strict";
  24676. Object.defineProperty(exports, "__esModule", { value: true });
  24677. var CharWidthRequest = /** @class */ (function () {
  24678. function CharWidthRequest(chr, type) {
  24679. this.chr = chr;
  24680. this.type = type;
  24681. this.width = 0;
  24682. }
  24683. CharWidthRequest.prototype.fulfill = function (width) {
  24684. this.width = width;
  24685. };
  24686. return CharWidthRequest;
  24687. }());
  24688. exports.CharWidthRequest = CharWidthRequest;
  24689. var DomCharWidthReader = /** @class */ (function () {
  24690. function DomCharWidthReader(bareFontInfo, requests) {
  24691. this._bareFontInfo = bareFontInfo;
  24692. this._requests = requests;
  24693. this._container = null;
  24694. this._testElements = null;
  24695. }
  24696. DomCharWidthReader.prototype.read = function () {
  24697. // Create a test container with all these test elements
  24698. this._createDomElements();
  24699. // Add the container to the DOM
  24700. document.body.appendChild(this._container);
  24701. // Read character widths
  24702. this._readFromDomElements();
  24703. // Remove the container from the DOM
  24704. document.body.removeChild(this._container);
  24705. this._container = null;
  24706. this._testElements = null;
  24707. };
  24708. DomCharWidthReader.prototype._createDomElements = function () {
  24709. var container = document.createElement('div');
  24710. container.style.position = 'absolute';
  24711. container.style.top = '-50000px';
  24712. container.style.width = '50000px';
  24713. var regularDomNode = document.createElement('div');
  24714. regularDomNode.style.fontFamily = this._bareFontInfo.getMassagedFontFamily();
  24715. regularDomNode.style.fontWeight = this._bareFontInfo.fontWeight;
  24716. regularDomNode.style.fontSize = this._bareFontInfo.fontSize + 'px';
  24717. regularDomNode.style.fontFeatureSettings = this._bareFontInfo.fontFeatureSettings;
  24718. regularDomNode.style.lineHeight = this._bareFontInfo.lineHeight + 'px';
  24719. regularDomNode.style.letterSpacing = this._bareFontInfo.letterSpacing + 'px';
  24720. container.appendChild(regularDomNode);
  24721. var boldDomNode = document.createElement('div');
  24722. boldDomNode.style.fontFamily = this._bareFontInfo.getMassagedFontFamily();
  24723. boldDomNode.style.fontWeight = 'bold';
  24724. boldDomNode.style.fontSize = this._bareFontInfo.fontSize + 'px';
  24725. boldDomNode.style.fontFeatureSettings = this._bareFontInfo.fontFeatureSettings;
  24726. boldDomNode.style.lineHeight = this._bareFontInfo.lineHeight + 'px';
  24727. boldDomNode.style.letterSpacing = this._bareFontInfo.letterSpacing + 'px';
  24728. container.appendChild(boldDomNode);
  24729. var italicDomNode = document.createElement('div');
  24730. italicDomNode.style.fontFamily = this._bareFontInfo.getMassagedFontFamily();
  24731. italicDomNode.style.fontWeight = this._bareFontInfo.fontWeight;
  24732. italicDomNode.style.fontSize = this._bareFontInfo.fontSize + 'px';
  24733. italicDomNode.style.fontFeatureSettings = this._bareFontInfo.fontFeatureSettings;
  24734. italicDomNode.style.lineHeight = this._bareFontInfo.lineHeight + 'px';
  24735. italicDomNode.style.letterSpacing = this._bareFontInfo.letterSpacing + 'px';
  24736. italicDomNode.style.fontStyle = 'italic';
  24737. container.appendChild(italicDomNode);
  24738. var testElements = [];
  24739. for (var _i = 0, _a = this._requests; _i < _a.length; _i++) {
  24740. var request = _a[_i];
  24741. var parent_1 = void 0;
  24742. if (request.type === 0 /* Regular */) {
  24743. parent_1 = regularDomNode;
  24744. }
  24745. if (request.type === 2 /* Bold */) {
  24746. parent_1 = boldDomNode;
  24747. }
  24748. if (request.type === 1 /* Italic */) {
  24749. parent_1 = italicDomNode;
  24750. }
  24751. parent_1.appendChild(document.createElement('br'));
  24752. var testElement = document.createElement('span');
  24753. DomCharWidthReader._render(testElement, request);
  24754. parent_1.appendChild(testElement);
  24755. testElements.push(testElement);
  24756. }
  24757. this._container = container;
  24758. this._testElements = testElements;
  24759. };
  24760. DomCharWidthReader._render = function (testElement, request) {
  24761. if (request.chr === ' ') {
  24762. var htmlString = '&#160;';
  24763. // Repeat character 256 (2^8) times
  24764. for (var i = 0; i < 8; i++) {
  24765. htmlString += htmlString;
  24766. }
  24767. testElement.innerHTML = htmlString;
  24768. }
  24769. else {
  24770. var testString = request.chr;
  24771. // Repeat character 256 (2^8) times
  24772. for (var i = 0; i < 8; i++) {
  24773. testString += testString;
  24774. }
  24775. testElement.textContent = testString;
  24776. }
  24777. };
  24778. DomCharWidthReader.prototype._readFromDomElements = function () {
  24779. for (var i = 0, len = this._requests.length; i < len; i++) {
  24780. var request = this._requests[i];
  24781. var testElement = this._testElements[i];
  24782. request.fulfill(testElement.offsetWidth / 256);
  24783. }
  24784. };
  24785. return DomCharWidthReader;
  24786. }());
  24787. function readCharWidths(bareFontInfo, requests) {
  24788. var reader = new DomCharWidthReader(bareFontInfo, requests);
  24789. reader.read();
  24790. }
  24791. exports.readCharWidths = readCharWidths;
  24792. });
  24793. /*---------------------------------------------------------------------------------------------
  24794. * Copyright (c) Microsoft Corporation. All rights reserved.
  24795. * Licensed under the MIT License. See License.txt in the project root for license information.
  24796. *--------------------------------------------------------------------------------------------*/
  24797. define(__m[185/*vs/editor/browser/config/elementSizeObserver*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,6/*vs/base/browser/dom*/]), function (require, exports, lifecycle_1, dom) {
  24798. "use strict";
  24799. Object.defineProperty(exports, "__esModule", { value: true });
  24800. var ElementSizeObserver = /** @class */ (function (_super) {
  24801. __extends(ElementSizeObserver, _super);
  24802. function ElementSizeObserver(referenceDomElement, dimension, changeCallback) {
  24803. var _this = _super.call(this) || this;
  24804. _this.referenceDomElement = referenceDomElement;
  24805. _this.changeCallback = changeCallback;
  24806. _this.width = -1;
  24807. _this.height = -1;
  24808. _this.mutationObserver = null;
  24809. _this.windowSizeListener = null;
  24810. _this.measureReferenceDomElement(false, dimension);
  24811. return _this;
  24812. }
  24813. ElementSizeObserver.prototype.dispose = function () {
  24814. this.stopObserving();
  24815. _super.prototype.dispose.call(this);
  24816. };
  24817. ElementSizeObserver.prototype.getWidth = function () {
  24818. return this.width;
  24819. };
  24820. ElementSizeObserver.prototype.getHeight = function () {
  24821. return this.height;
  24822. };
  24823. ElementSizeObserver.prototype.startObserving = function () {
  24824. var _this = this;
  24825. if (!this.mutationObserver && this.referenceDomElement) {
  24826. this.mutationObserver = new MutationObserver(function () { return _this._onDidMutate(); });
  24827. this.mutationObserver.observe(this.referenceDomElement, {
  24828. attributes: true,
  24829. });
  24830. }
  24831. if (!this.windowSizeListener) {
  24832. this.windowSizeListener = dom.addDisposableListener(window, 'resize', function () { return _this._onDidResizeWindow(); });
  24833. }
  24834. };
  24835. ElementSizeObserver.prototype.stopObserving = function () {
  24836. if (this.mutationObserver) {
  24837. this.mutationObserver.disconnect();
  24838. this.mutationObserver = null;
  24839. }
  24840. if (this.windowSizeListener) {
  24841. this.windowSizeListener.dispose();
  24842. this.windowSizeListener = null;
  24843. }
  24844. };
  24845. ElementSizeObserver.prototype.observe = function (dimension) {
  24846. this.measureReferenceDomElement(true, dimension);
  24847. };
  24848. ElementSizeObserver.prototype._onDidMutate = function () {
  24849. this.measureReferenceDomElement(true);
  24850. };
  24851. ElementSizeObserver.prototype._onDidResizeWindow = function () {
  24852. this.measureReferenceDomElement(true);
  24853. };
  24854. ElementSizeObserver.prototype.measureReferenceDomElement = function (callChangeCallback, dimension) {
  24855. var observedWidth = 0;
  24856. var observedHeight = 0;
  24857. if (dimension) {
  24858. observedWidth = dimension.width;
  24859. observedHeight = dimension.height;
  24860. }
  24861. else if (this.referenceDomElement) {
  24862. observedWidth = this.referenceDomElement.clientWidth;
  24863. observedHeight = this.referenceDomElement.clientHeight;
  24864. }
  24865. observedWidth = Math.max(5, observedWidth);
  24866. observedHeight = Math.max(5, observedHeight);
  24867. if (this.width !== observedWidth || this.height !== observedHeight) {
  24868. this.width = observedWidth;
  24869. this.height = observedHeight;
  24870. if (callChangeCallback) {
  24871. this.changeCallback();
  24872. }
  24873. }
  24874. };
  24875. return ElementSizeObserver;
  24876. }(lifecycle_1.Disposable));
  24877. exports.ElementSizeObserver = ElementSizeObserver;
  24878. });
  24879. /*---------------------------------------------------------------------------------------------
  24880. * Copyright (c) Microsoft Corporation. All rights reserved.
  24881. * Licensed under the MIT License. See License.txt in the project root for license information.
  24882. *--------------------------------------------------------------------------------------------*/
  24883. define(__m[141/*vs/editor/browser/editorDom*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,78/*vs/base/browser/globalMouseMoveMonitor*/,45/*vs/base/browser/mouseEvent*/,2/*vs/base/common/lifecycle*/]), function (require, exports, dom, globalMouseMoveMonitor_1, mouseEvent_1, lifecycle_1) {
  24884. "use strict";
  24885. Object.defineProperty(exports, "__esModule", { value: true });
  24886. /**
  24887. * Coordinates relative to the whole document (e.g. mouse event's pageX and pageY)
  24888. */
  24889. var PageCoordinates = /** @class */ (function () {
  24890. function PageCoordinates(x, y) {
  24891. this.x = x;
  24892. this.y = y;
  24893. }
  24894. PageCoordinates.prototype.toClientCoordinates = function () {
  24895. return new ClientCoordinates(this.x - dom.StandardWindow.scrollX, this.y - dom.StandardWindow.scrollY);
  24896. };
  24897. return PageCoordinates;
  24898. }());
  24899. exports.PageCoordinates = PageCoordinates;
  24900. /**
  24901. * Coordinates within the application's client area (i.e. origin is document's scroll position).
  24902. *
  24903. * For example, clicking in the top-left corner of the client area will
  24904. * always result in a mouse event with a client.x value of 0, regardless
  24905. * of whether the page is scrolled horizontally.
  24906. */
  24907. var ClientCoordinates = /** @class */ (function () {
  24908. function ClientCoordinates(clientX, clientY) {
  24909. this.clientX = clientX;
  24910. this.clientY = clientY;
  24911. }
  24912. ClientCoordinates.prototype.toPageCoordinates = function () {
  24913. return new PageCoordinates(this.clientX + dom.StandardWindow.scrollX, this.clientY + dom.StandardWindow.scrollY);
  24914. };
  24915. return ClientCoordinates;
  24916. }());
  24917. exports.ClientCoordinates = ClientCoordinates;
  24918. /**
  24919. * The position of the editor in the page.
  24920. */
  24921. var EditorPagePosition = /** @class */ (function () {
  24922. function EditorPagePosition(x, y, width, height) {
  24923. this.x = x;
  24924. this.y = y;
  24925. this.width = width;
  24926. this.height = height;
  24927. }
  24928. return EditorPagePosition;
  24929. }());
  24930. exports.EditorPagePosition = EditorPagePosition;
  24931. function createEditorPagePosition(editorViewDomNode) {
  24932. var editorPos = dom.getDomNodePagePosition(editorViewDomNode);
  24933. return new EditorPagePosition(editorPos.left, editorPos.top, editorPos.width, editorPos.height);
  24934. }
  24935. exports.createEditorPagePosition = createEditorPagePosition;
  24936. var EditorMouseEvent = /** @class */ (function (_super) {
  24937. __extends(EditorMouseEvent, _super);
  24938. function EditorMouseEvent(e, editorViewDomNode) {
  24939. var _this = _super.call(this, e) || this;
  24940. _this.pos = new PageCoordinates(_this.posx, _this.posy);
  24941. _this.editorPos = createEditorPagePosition(editorViewDomNode);
  24942. return _this;
  24943. }
  24944. return EditorMouseEvent;
  24945. }(mouseEvent_1.StandardMouseEvent));
  24946. exports.EditorMouseEvent = EditorMouseEvent;
  24947. var EditorMouseEventFactory = /** @class */ (function () {
  24948. function EditorMouseEventFactory(editorViewDomNode) {
  24949. this._editorViewDomNode = editorViewDomNode;
  24950. }
  24951. EditorMouseEventFactory.prototype._create = function (e) {
  24952. return new EditorMouseEvent(e, this._editorViewDomNode);
  24953. };
  24954. EditorMouseEventFactory.prototype.onContextMenu = function (target, callback) {
  24955. var _this = this;
  24956. return dom.addDisposableListener(target, 'contextmenu', function (e) {
  24957. callback(_this._create(e));
  24958. });
  24959. };
  24960. EditorMouseEventFactory.prototype.onMouseUp = function (target, callback) {
  24961. var _this = this;
  24962. return dom.addDisposableListener(target, 'mouseup', function (e) {
  24963. callback(_this._create(e));
  24964. });
  24965. };
  24966. EditorMouseEventFactory.prototype.onMouseDown = function (target, callback) {
  24967. var _this = this;
  24968. return dom.addDisposableListener(target, 'mousedown', function (e) {
  24969. callback(_this._create(e));
  24970. });
  24971. };
  24972. EditorMouseEventFactory.prototype.onMouseLeave = function (target, callback) {
  24973. var _this = this;
  24974. return dom.addDisposableNonBubblingMouseOutListener(target, function (e) {
  24975. callback(_this._create(e));
  24976. });
  24977. };
  24978. EditorMouseEventFactory.prototype.onMouseMoveThrottled = function (target, callback, merger, minimumTimeMs) {
  24979. var _this = this;
  24980. var myMerger = function (lastEvent, currentEvent) {
  24981. return merger(lastEvent, _this._create(currentEvent));
  24982. };
  24983. return dom.addDisposableThrottledListener(target, 'mousemove', callback, myMerger, minimumTimeMs);
  24984. };
  24985. return EditorMouseEventFactory;
  24986. }());
  24987. exports.EditorMouseEventFactory = EditorMouseEventFactory;
  24988. var EditorPointerEventFactory = /** @class */ (function () {
  24989. function EditorPointerEventFactory(editorViewDomNode) {
  24990. this._editorViewDomNode = editorViewDomNode;
  24991. }
  24992. EditorPointerEventFactory.prototype._create = function (e) {
  24993. return new EditorMouseEvent(e, this._editorViewDomNode);
  24994. };
  24995. EditorPointerEventFactory.prototype.onPointerUp = function (target, callback) {
  24996. var _this = this;
  24997. return dom.addDisposableListener(target, 'pointerup', function (e) {
  24998. callback(_this._create(e));
  24999. });
  25000. };
  25001. EditorPointerEventFactory.prototype.onPointerDown = function (target, callback) {
  25002. var _this = this;
  25003. return dom.addDisposableListener(target, 'pointerdown', function (e) {
  25004. callback(_this._create(e));
  25005. });
  25006. };
  25007. EditorPointerEventFactory.prototype.onPointerLeave = function (target, callback) {
  25008. var _this = this;
  25009. return dom.addDisposableNonBubblingPointerOutListener(target, function (e) {
  25010. callback(_this._create(e));
  25011. });
  25012. };
  25013. EditorPointerEventFactory.prototype.onPointerMoveThrottled = function (target, callback, merger, minimumTimeMs) {
  25014. var _this = this;
  25015. var myMerger = function (lastEvent, currentEvent) {
  25016. return merger(lastEvent, _this._create(currentEvent));
  25017. };
  25018. return dom.addDisposableThrottledListener(target, 'pointermove', callback, myMerger, minimumTimeMs);
  25019. };
  25020. return EditorPointerEventFactory;
  25021. }());
  25022. exports.EditorPointerEventFactory = EditorPointerEventFactory;
  25023. var GlobalEditorMouseMoveMonitor = /** @class */ (function (_super) {
  25024. __extends(GlobalEditorMouseMoveMonitor, _super);
  25025. function GlobalEditorMouseMoveMonitor(editorViewDomNode) {
  25026. var _this = _super.call(this) || this;
  25027. _this._editorViewDomNode = editorViewDomNode;
  25028. _this._globalMouseMoveMonitor = _this._register(new globalMouseMoveMonitor_1.GlobalMouseMoveMonitor());
  25029. _this._keydownListener = null;
  25030. return _this;
  25031. }
  25032. GlobalEditorMouseMoveMonitor.prototype.startMonitoring = function (initialElement, initialButtons, merger, mouseMoveCallback, onStopCallback) {
  25033. var _this = this;
  25034. // Add a <<capture>> keydown event listener that will cancel the monitoring
  25035. // if something other than a modifier key is pressed
  25036. this._keydownListener = dom.addStandardDisposableListener(document, 'keydown', function (e) {
  25037. var kb = e.toKeybinding();
  25038. if (kb.isModifierKey()) {
  25039. // Allow modifier keys
  25040. return;
  25041. }
  25042. _this._globalMouseMoveMonitor.stopMonitoring(true);
  25043. }, true);
  25044. var myMerger = function (lastEvent, currentEvent) {
  25045. return merger(lastEvent, new EditorMouseEvent(currentEvent, _this._editorViewDomNode));
  25046. };
  25047. this._globalMouseMoveMonitor.startMonitoring(initialElement, initialButtons, myMerger, mouseMoveCallback, function () {
  25048. _this._keydownListener.dispose();
  25049. onStopCallback();
  25050. });
  25051. };
  25052. return GlobalEditorMouseMoveMonitor;
  25053. }(lifecycle_1.Disposable));
  25054. exports.GlobalEditorMouseMoveMonitor = GlobalEditorMouseMoveMonitor;
  25055. });
  25056. /*---------------------------------------------------------------------------------------------
  25057. * Copyright (c) Microsoft Corporation. All rights reserved.
  25058. * Licensed under the MIT License. See License.txt in the project root for license information.
  25059. *--------------------------------------------------------------------------------------------*/
  25060. define(__m[334/*vs/editor/browser/services/abstractCodeEditorService*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/]), function (require, exports, event_1, lifecycle_1) {
  25061. "use strict";
  25062. Object.defineProperty(exports, "__esModule", { value: true });
  25063. var AbstractCodeEditorService = /** @class */ (function (_super) {
  25064. __extends(AbstractCodeEditorService, _super);
  25065. function AbstractCodeEditorService() {
  25066. var _this = _super.call(this) || this;
  25067. _this._onCodeEditorAdd = _this._register(new event_1.Emitter());
  25068. _this.onCodeEditorAdd = _this._onCodeEditorAdd.event;
  25069. _this._onCodeEditorRemove = _this._register(new event_1.Emitter());
  25070. _this.onCodeEditorRemove = _this._onCodeEditorRemove.event;
  25071. _this._onDiffEditorAdd = _this._register(new event_1.Emitter());
  25072. _this._onDiffEditorRemove = _this._register(new event_1.Emitter());
  25073. _this._codeEditors = Object.create(null);
  25074. _this._diffEditors = Object.create(null);
  25075. return _this;
  25076. }
  25077. AbstractCodeEditorService.prototype.addCodeEditor = function (editor) {
  25078. this._codeEditors[editor.getId()] = editor;
  25079. this._onCodeEditorAdd.fire(editor);
  25080. };
  25081. AbstractCodeEditorService.prototype.removeCodeEditor = function (editor) {
  25082. if (delete this._codeEditors[editor.getId()]) {
  25083. this._onCodeEditorRemove.fire(editor);
  25084. }
  25085. };
  25086. AbstractCodeEditorService.prototype.listCodeEditors = function () {
  25087. var _this = this;
  25088. return Object.keys(this._codeEditors).map(function (id) { return _this._codeEditors[id]; });
  25089. };
  25090. AbstractCodeEditorService.prototype.addDiffEditor = function (editor) {
  25091. this._diffEditors[editor.getId()] = editor;
  25092. this._onDiffEditorAdd.fire(editor);
  25093. };
  25094. AbstractCodeEditorService.prototype.removeDiffEditor = function (editor) {
  25095. if (delete this._diffEditors[editor.getId()]) {
  25096. this._onDiffEditorRemove.fire(editor);
  25097. }
  25098. };
  25099. AbstractCodeEditorService.prototype.listDiffEditors = function () {
  25100. var _this = this;
  25101. return Object.keys(this._diffEditors).map(function (id) { return _this._diffEditors[id]; });
  25102. };
  25103. AbstractCodeEditorService.prototype.getFocusedCodeEditor = function () {
  25104. var editorWithWidgetFocus = null;
  25105. var editors = this.listCodeEditors();
  25106. for (var _i = 0, editors_1 = editors; _i < editors_1.length; _i++) {
  25107. var editor = editors_1[_i];
  25108. if (editor.hasTextFocus()) {
  25109. // bingo!
  25110. return editor;
  25111. }
  25112. if (editor.hasWidgetFocus()) {
  25113. editorWithWidgetFocus = editor;
  25114. }
  25115. }
  25116. return editorWithWidgetFocus;
  25117. };
  25118. return AbstractCodeEditorService;
  25119. }(lifecycle_1.Disposable));
  25120. exports.AbstractCodeEditorService = AbstractCodeEditorService;
  25121. });
  25122. /*---------------------------------------------------------------------------------------------
  25123. * Copyright (c) Microsoft Corporation. All rights reserved.
  25124. * Licensed under the MIT License. See License.txt in the project root for license information.
  25125. *--------------------------------------------------------------------------------------------*/
  25126. define(__m[186/*vs/editor/browser/viewParts/minimap/minimapCharSheet*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  25127. "use strict";
  25128. Object.defineProperty(exports, "__esModule", { value: true });
  25129. exports.allCharCodes = (function () {
  25130. var v = [];
  25131. for (var i = 32 /* START_CH_CODE */; i <= 126 /* END_CH_CODE */; i++) {
  25132. v.push(i);
  25133. }
  25134. v.push(65533 /* UNKNOWN_CODE */);
  25135. return v;
  25136. })();
  25137. exports.getCharIndex = function (chCode, fontScale) {
  25138. chCode -= 32 /* START_CH_CODE */;
  25139. if (chCode < 0 || chCode > 96 /* CHAR_COUNT */) {
  25140. if (fontScale <= 2) {
  25141. // for smaller scales, we can get away with using any ASCII character...
  25142. return (chCode + 96 /* CHAR_COUNT */) % 96 /* CHAR_COUNT */;
  25143. }
  25144. return 96 /* CHAR_COUNT */ - 1; // unknown symbol
  25145. }
  25146. return chCode;
  25147. };
  25148. });
  25149. /*---------------------------------------------------------------------------------------------
  25150. * Copyright (c) Microsoft Corporation. All rights reserved.
  25151. * Licensed under the MIT License. See License.txt in the project root for license information.
  25152. *--------------------------------------------------------------------------------------------*/
  25153. define(__m[335/*vs/editor/browser/viewParts/minimap/minimapCharRenderer*/], __M([0/*require*/,1/*exports*/,186/*vs/editor/browser/viewParts/minimap/minimapCharSheet*/]), function (require, exports, minimapCharSheet_1) {
  25154. "use strict";
  25155. Object.defineProperty(exports, "__esModule", { value: true });
  25156. var MinimapCharRenderer = /** @class */ (function () {
  25157. function MinimapCharRenderer(charData, scale) {
  25158. this.scale = scale;
  25159. this.charDataNormal = MinimapCharRenderer.soften(charData, 12 / 15);
  25160. this.charDataLight = MinimapCharRenderer.soften(charData, 50 / 60);
  25161. }
  25162. MinimapCharRenderer.soften = function (input, ratio) {
  25163. var result = new Uint8ClampedArray(input.length);
  25164. for (var i = 0, len = input.length; i < len; i++) {
  25165. result[i] = input[i] * ratio;
  25166. }
  25167. return result;
  25168. };
  25169. MinimapCharRenderer.prototype.renderChar = function (target, dx, dy, chCode, color, backgroundColor, fontScale, useLighterFont) {
  25170. var charWidth = 1 /* BASE_CHAR_WIDTH */ * this.scale;
  25171. var charHeight = 2 /* BASE_CHAR_HEIGHT */ * this.scale;
  25172. if (dx + charWidth > target.width || dy + charHeight > target.height) {
  25173. console.warn('bad render request outside image data');
  25174. return;
  25175. }
  25176. var charData = useLighterFont ? this.charDataLight : this.charDataNormal;
  25177. var charIndex = minimapCharSheet_1.getCharIndex(chCode, fontScale);
  25178. var destWidth = target.width * 4 /* RGBA_CHANNELS_CNT */;
  25179. var backgroundR = backgroundColor.r;
  25180. var backgroundG = backgroundColor.g;
  25181. var backgroundB = backgroundColor.b;
  25182. var deltaR = color.r - backgroundR;
  25183. var deltaG = color.g - backgroundG;
  25184. var deltaB = color.b - backgroundB;
  25185. var dest = target.data;
  25186. var sourceOffset = charIndex * charWidth * charHeight;
  25187. var row = dy * destWidth + dx * 4 /* RGBA_CHANNELS_CNT */;
  25188. for (var y = 0; y < charHeight; y++) {
  25189. var column = row;
  25190. for (var x = 0; x < charWidth; x++) {
  25191. var c = charData[sourceOffset++] / 255;
  25192. dest[column++] = backgroundR + deltaR * c;
  25193. dest[column++] = backgroundG + deltaG * c;
  25194. dest[column++] = backgroundB + deltaB * c;
  25195. column++;
  25196. }
  25197. row += destWidth;
  25198. }
  25199. };
  25200. MinimapCharRenderer.prototype.blockRenderChar = function (target, dx, dy, color, backgroundColor, useLighterFont) {
  25201. var charWidth = 1 /* BASE_CHAR_WIDTH */ * this.scale;
  25202. var charHeight = 2 /* BASE_CHAR_HEIGHT */ * this.scale;
  25203. if (dx + charWidth > target.width || dy + charHeight > target.height) {
  25204. console.warn('bad render request outside image data');
  25205. return;
  25206. }
  25207. var destWidth = target.width * 4 /* RGBA_CHANNELS_CNT */;
  25208. var c = 0.5;
  25209. var backgroundR = backgroundColor.r;
  25210. var backgroundG = backgroundColor.g;
  25211. var backgroundB = backgroundColor.b;
  25212. var deltaR = color.r - backgroundR;
  25213. var deltaG = color.g - backgroundG;
  25214. var deltaB = color.b - backgroundB;
  25215. var colorR = backgroundR + deltaR * c;
  25216. var colorG = backgroundG + deltaG * c;
  25217. var colorB = backgroundB + deltaB * c;
  25218. var dest = target.data;
  25219. var row = dy * destWidth + dx * 4 /* RGBA_CHANNELS_CNT */;
  25220. for (var y = 0; y < charHeight; y++) {
  25221. var column = row;
  25222. for (var x = 0; x < charWidth; x++) {
  25223. dest[column++] = colorR;
  25224. dest[column++] = colorG;
  25225. dest[column++] = colorB;
  25226. column++;
  25227. }
  25228. row += destWidth;
  25229. }
  25230. };
  25231. return MinimapCharRenderer;
  25232. }());
  25233. exports.MinimapCharRenderer = MinimapCharRenderer;
  25234. });
  25235. /*---------------------------------------------------------------------------------------------
  25236. * Copyright (c) Microsoft Corporation. All rights reserved.
  25237. * Licensed under the MIT License. See License.txt in the project root for license information.
  25238. *--------------------------------------------------------------------------------------------*/
  25239. define(__m[336/*vs/editor/browser/viewParts/minimap/minimapPreBaked*/], __M([0/*require*/,1/*exports*/,102/*vs/base/common/functional*/]), function (require, exports, functional_1) {
  25240. "use strict";
  25241. Object.defineProperty(exports, "__esModule", { value: true });
  25242. var charTable = {
  25243. '0': 0,
  25244. '1': 1,
  25245. '2': 2,
  25246. '3': 3,
  25247. '4': 4,
  25248. '5': 5,
  25249. '6': 6,
  25250. '7': 7,
  25251. '8': 8,
  25252. '9': 9,
  25253. A: 10,
  25254. B: 11,
  25255. C: 12,
  25256. D: 13,
  25257. E: 14,
  25258. F: 15
  25259. };
  25260. var decodeData = function (str) {
  25261. var output = new Uint8ClampedArray(str.length / 2);
  25262. for (var i = 0; i < str.length; i += 2) {
  25263. output[i >> 1] = (charTable[str[i]] << 4) | (charTable[str[i + 1]] & 0xF);
  25264. }
  25265. return output;
  25266. };
  25267. /*
  25268. const encodeData = (data: Uint8ClampedArray, length: string) => {
  25269. const chars = '0123456789ABCDEF';
  25270. let output = '';
  25271. for (let i = 0; i < data.length; i++) {
  25272. output += chars[data[i] >> 4] + chars[data[i] & 0xf];
  25273. }
  25274. return output;
  25275. };
  25276. */
  25277. /**
  25278. * Map of minimap scales to prebaked sample data at those scales. We don't
  25279. * sample much larger data, because then font family becomes visible, which
  25280. * is use-configurable.
  25281. */
  25282. exports.prebakedMiniMaps = {
  25283. 1: functional_1.once(function () {
  25284. return decodeData('0000511D6300CF609C709645A78432005642574171487021003C451900274D35D762755E8B629C5BA856AF57BA649530C167D1512A272A3F6038604460398526BCA2A968DB6F8957C768BE5FBE2FB467CF5D8D5B795DC7625B5DFF50DE64C466DB2FC47CD860A65E9A2EB96CB54CE06DA763AB2EA26860524D3763536601005116008177A8705E53AB738E6A982F88BAA35B5F5B626D9C636B449B737E5B7B678598869A662F6B5B8542706C704C80736A607578685B70594A49715A4522E792');
  25285. }),
  25286. 2: functional_1.once(function () {
  25287. return decodeData('000000000000000055394F383D2800008B8B1F210002000081B1CBCBCC820000847AAF6B9AAF2119BE08B8881AD60000A44FD07DCCF107015338130C00000000385972265F390B406E2437634B4B48031B12B8A0847000001E15B29A402F0000000000004B33460B00007A752C2A0000000000004D3900000084394B82013400ABA5CFC7AD9C0302A45A3E5A98AB000089A43382D97900008BA54AA087A70A0248A6A7AE6DBE0000BF6F94987EA40A01A06DCFA7A7A9030496C32F77891D0000A99FB1A0AFA80603B29AB9CA75930D010C0948354D3900000C0948354F37460D0028BE673D8400000000AF9D7B6E00002B007AA8933400007AA642675C2700007984CFB9C3985B768772A8A6B7B20000CAAECAAFC4B700009F94A6009F840009D09F9BA4CA9C0000CC8FC76DC87F0000C991C472A2000000A894A48CA7B501079BA2C9C69BA20000B19A5D3FA89000005CA6009DA2960901B0A7F0669FB200009D009E00B7890000DAD0F5D092820000D294D4C48BD10000B5A7A4A3B1A50402CAB6CBA6A2000000B5A7A4A3B1A8044FCDADD19D9CB00000B7778F7B8AAE0803C9AB5D3F5D3F00009EA09EA0BAB006039EA0989A8C7900009B9EF4D6B7C00000A9A7816CACA80000ABAC84705D3F000096DA635CDC8C00006F486F266F263D4784006124097B00374F6D2D6D2D6D4A3A95872322000000030000000000008D8939130000000000002E22A5C9CBC70600AB25C0B5C9B400061A2DB04CA67001082AA6BEBEBFC606002321DACBC19E03087AA08B6768380000282FBAC0B8CA7A88AD25BBA5A29900004C396C5894A6000040485A6E356E9442A32CD17EADA70000B4237923628600003E2DE9C1D7B500002F25BBA5A2990000231DB6AFB4A804023025C0B5CAB588062B2CBDBEC0C706882435A75CA20000002326BD6A82A908048B4B9A5A668000002423A09CB4BB060025259C9D8A7900001C1FCAB2C7C700002A2A9387ABA200002626A4A47D6E9D14333163A0C87500004B6F9C2D643A257049364936493647358A34438355497F1A0000A24C1D590000D38DFFBDD4CD3126');
  25288. })
  25289. };
  25290. });
  25291. /*---------------------------------------------------------------------------------------------
  25292. * Copyright (c) Microsoft Corporation. All rights reserved.
  25293. * Licensed under the MIT License. See License.txt in the project root for license information.
  25294. *--------------------------------------------------------------------------------------------*/
  25295. define(__m[337/*vs/editor/browser/viewParts/minimap/minimapCharRendererFactory*/], __M([0/*require*/,1/*exports*/,335/*vs/editor/browser/viewParts/minimap/minimapCharRenderer*/,186/*vs/editor/browser/viewParts/minimap/minimapCharSheet*/,336/*vs/editor/browser/viewParts/minimap/minimapPreBaked*/]), function (require, exports, minimapCharRenderer_1, minimapCharSheet_1, minimapPreBaked_1) {
  25296. "use strict";
  25297. Object.defineProperty(exports, "__esModule", { value: true });
  25298. /**
  25299. * Creates character renderers. It takes a 'scale' that determines how large
  25300. * characters should be drawn. Using this, it draws data into a canvas and
  25301. * then downsamples the characters as necessary for the current display.
  25302. * This makes rendering more efficient, rather than drawing a full (tiny)
  25303. * font, or downsampling in real-time.
  25304. */
  25305. var MinimapCharRendererFactory = /** @class */ (function () {
  25306. function MinimapCharRendererFactory() {
  25307. }
  25308. /**
  25309. * Creates a new character renderer factory with the given scale.
  25310. */
  25311. MinimapCharRendererFactory.create = function (scale, fontFamily) {
  25312. // renderers are immutable. By default we'll 'create' a new minimap
  25313. // character renderer whenever we switch editors, no need to do extra work.
  25314. if (this.lastCreated && scale === this.lastCreated.scale && fontFamily === this.lastFontFamily) {
  25315. return this.lastCreated;
  25316. }
  25317. var factory;
  25318. if (minimapPreBaked_1.prebakedMiniMaps[scale]) {
  25319. factory = new minimapCharRenderer_1.MinimapCharRenderer(minimapPreBaked_1.prebakedMiniMaps[scale](), scale);
  25320. }
  25321. else {
  25322. factory = MinimapCharRendererFactory.createFromSampleData(MinimapCharRendererFactory.createSampleData(fontFamily).data, scale);
  25323. }
  25324. this.lastFontFamily = fontFamily;
  25325. this.lastCreated = factory;
  25326. return factory;
  25327. };
  25328. /**
  25329. * Creates the font sample data, writing to a canvas.
  25330. */
  25331. MinimapCharRendererFactory.createSampleData = function (fontFamily) {
  25332. var canvas = document.createElement('canvas');
  25333. var ctx = canvas.getContext('2d');
  25334. canvas.style.height = 16 /* SAMPLED_CHAR_HEIGHT */ + "px";
  25335. canvas.height = 16 /* SAMPLED_CHAR_HEIGHT */;
  25336. canvas.width = 96 /* CHAR_COUNT */ * 10 /* SAMPLED_CHAR_WIDTH */;
  25337. canvas.style.width = 96 /* CHAR_COUNT */ * 10 /* SAMPLED_CHAR_WIDTH */ + 'px';
  25338. ctx.fillStyle = '#ffffff';
  25339. ctx.font = "bold " + 16 /* SAMPLED_CHAR_HEIGHT */ + "px " + fontFamily;
  25340. ctx.textBaseline = 'middle';
  25341. var x = 0;
  25342. for (var _i = 0, allCharCodes_1 = minimapCharSheet_1.allCharCodes; _i < allCharCodes_1.length; _i++) {
  25343. var code = allCharCodes_1[_i];
  25344. ctx.fillText(String.fromCharCode(code), x, 16 /* SAMPLED_CHAR_HEIGHT */ / 2);
  25345. x += 10 /* SAMPLED_CHAR_WIDTH */;
  25346. }
  25347. return ctx.getImageData(0, 0, 96 /* CHAR_COUNT */ * 10 /* SAMPLED_CHAR_WIDTH */, 16 /* SAMPLED_CHAR_HEIGHT */);
  25348. };
  25349. /**
  25350. * Creates a character renderer from the canvas sample data.
  25351. */
  25352. MinimapCharRendererFactory.createFromSampleData = function (source, scale) {
  25353. var expectedLength = 16 /* SAMPLED_CHAR_HEIGHT */ * 10 /* SAMPLED_CHAR_WIDTH */ * 4 /* RGBA_CHANNELS_CNT */ * 96 /* CHAR_COUNT */;
  25354. if (source.length !== expectedLength) {
  25355. throw new Error('Unexpected source in MinimapCharRenderer');
  25356. }
  25357. var charData = MinimapCharRendererFactory._downsample(source, scale);
  25358. return new minimapCharRenderer_1.MinimapCharRenderer(charData, scale);
  25359. };
  25360. MinimapCharRendererFactory._downsampleChar = function (source, sourceOffset, dest, destOffset, scale) {
  25361. var width = 1 /* BASE_CHAR_WIDTH */ * scale;
  25362. var height = 2 /* BASE_CHAR_HEIGHT */ * scale;
  25363. var targetIndex = destOffset;
  25364. var brightest = 0;
  25365. // This is essentially an ad-hoc rescaling algorithm. Standard approaches
  25366. // like bicubic interpolation are awesome for scaling between image sizes,
  25367. // but don't work so well when scaling to very small pixel values, we end
  25368. // up with blurry, indistinct forms.
  25369. //
  25370. // The approach taken here is simply mapping each source pixel to the target
  25371. // pixels, and taking the weighted values for all pixels in each, and then
  25372. // averaging them out. Finally we apply an intensity boost in _downsample,
  25373. // since when scaling to the smallest pixel sizes there's more black space
  25374. // which causes characters to be much less distinct.
  25375. for (var y = 0; y < height; y++) {
  25376. // 1. For this destination pixel, get the source pixels we're sampling
  25377. // from (x1, y1) to the next pixel (x2, y2)
  25378. var sourceY1 = (y / height) * 16 /* SAMPLED_CHAR_HEIGHT */;
  25379. var sourceY2 = ((y + 1) / height) * 16 /* SAMPLED_CHAR_HEIGHT */;
  25380. for (var x = 0; x < width; x++) {
  25381. var sourceX1 = (x / width) * 10 /* SAMPLED_CHAR_WIDTH */;
  25382. var sourceX2 = ((x + 1) / width) * 10 /* SAMPLED_CHAR_WIDTH */;
  25383. // 2. Sample all of them, summing them up and weighting them. Similar
  25384. // to bilinear interpolation.
  25385. var value = 0;
  25386. var samples = 0;
  25387. for (var sy = sourceY1; sy < sourceY2; sy++) {
  25388. var sourceRow = sourceOffset + Math.floor(sy) * 3840 /* RGBA_SAMPLED_ROW_WIDTH */;
  25389. var yBalance = 1 - (sy - Math.floor(sy));
  25390. for (var sx = sourceX1; sx < sourceX2; sx++) {
  25391. var xBalance = 1 - (sx - Math.floor(sx));
  25392. var sourceIndex = sourceRow + Math.floor(sx) * 4 /* RGBA_CHANNELS_CNT */;
  25393. var weight = xBalance * yBalance;
  25394. samples += weight;
  25395. value += ((source[sourceIndex] * source[sourceIndex + 3]) / 255) * weight;
  25396. }
  25397. }
  25398. var final = value / samples;
  25399. brightest = Math.max(brightest, final);
  25400. dest[targetIndex++] = final;
  25401. }
  25402. }
  25403. return brightest;
  25404. };
  25405. MinimapCharRendererFactory._downsample = function (data, scale) {
  25406. var pixelsPerCharacter = 2 /* BASE_CHAR_HEIGHT */ * scale * 1 /* BASE_CHAR_WIDTH */ * scale;
  25407. var resultLen = pixelsPerCharacter * 96 /* CHAR_COUNT */;
  25408. var result = new Uint8ClampedArray(resultLen);
  25409. var resultOffset = 0;
  25410. var sourceOffset = 0;
  25411. var brightest = 0;
  25412. for (var charIndex = 0; charIndex < 96 /* CHAR_COUNT */; charIndex++) {
  25413. brightest = Math.max(brightest, this._downsampleChar(data, sourceOffset, result, resultOffset, scale));
  25414. resultOffset += pixelsPerCharacter;
  25415. sourceOffset += 10 /* SAMPLED_CHAR_WIDTH */ * 4 /* RGBA_CHANNELS_CNT */;
  25416. }
  25417. if (brightest > 0) {
  25418. var adjust = 255 / brightest;
  25419. for (var i = 0; i < resultLen; i++) {
  25420. result[i] *= adjust;
  25421. }
  25422. }
  25423. return result;
  25424. };
  25425. return MinimapCharRendererFactory;
  25426. }());
  25427. exports.MinimapCharRendererFactory = MinimapCharRendererFactory;
  25428. });
  25429. /*---------------------------------------------------------------------------------------------
  25430. * Copyright (c) Microsoft Corporation. All rights reserved.
  25431. * Licensed under the MIT License. See License.txt in the project root for license information.
  25432. *--------------------------------------------------------------------------------------------*/
  25433. define(__m[105/*vs/editor/common/config/editorZoom*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/]), function (require, exports, event_1) {
  25434. "use strict";
  25435. Object.defineProperty(exports, "__esModule", { value: true });
  25436. exports.EditorZoom = new /** @class */ (function () {
  25437. function class_1() {
  25438. this._zoomLevel = 0;
  25439. this._onDidChangeZoomLevel = new event_1.Emitter();
  25440. this.onDidChangeZoomLevel = this._onDidChangeZoomLevel.event;
  25441. }
  25442. class_1.prototype.getZoomLevel = function () {
  25443. return this._zoomLevel;
  25444. };
  25445. class_1.prototype.setZoomLevel = function (zoomLevel) {
  25446. zoomLevel = Math.min(Math.max(-5, zoomLevel), 20);
  25447. if (this._zoomLevel === zoomLevel) {
  25448. return;
  25449. }
  25450. this._zoomLevel = zoomLevel;
  25451. this._onDidChangeZoomLevel.fire(this._zoomLevel);
  25452. };
  25453. return class_1;
  25454. }());
  25455. });
  25456. /*---------------------------------------------------------------------------------------------
  25457. * Copyright (c) Microsoft Corporation. All rights reserved.
  25458. * Licensed under the MIT License. See License.txt in the project root for license information.
  25459. *--------------------------------------------------------------------------------------------*/
  25460. define(__m[142/*vs/editor/common/config/fontInfo*/], __M([0/*require*/,1/*exports*/,16/*vs/base/common/platform*/,105/*vs/editor/common/config/editorZoom*/]), function (require, exports, platform, editorZoom_1) {
  25461. "use strict";
  25462. Object.defineProperty(exports, "__esModule", { value: true });
  25463. /**
  25464. * Determined from empirical observations.
  25465. * @internal
  25466. */
  25467. var GOLDEN_LINE_HEIGHT_RATIO = platform.isMacintosh ? 1.5 : 1.35;
  25468. /**
  25469. * @internal
  25470. */
  25471. var MINIMUM_LINE_HEIGHT = 8;
  25472. var BareFontInfo = /** @class */ (function () {
  25473. /**
  25474. * @internal
  25475. */
  25476. function BareFontInfo(opts) {
  25477. this.zoomLevel = opts.zoomLevel;
  25478. this.fontFamily = String(opts.fontFamily);
  25479. this.fontWeight = String(opts.fontWeight);
  25480. this.fontSize = opts.fontSize;
  25481. this.fontFeatureSettings = opts.fontFeatureSettings;
  25482. this.lineHeight = opts.lineHeight | 0;
  25483. this.letterSpacing = opts.letterSpacing;
  25484. }
  25485. /**
  25486. * @internal
  25487. */
  25488. BareFontInfo.createFromValidatedSettings = function (options, zoomLevel, ignoreEditorZoom) {
  25489. var fontFamily = options.get(33 /* fontFamily */);
  25490. var fontWeight = options.get(37 /* fontWeight */);
  25491. var fontSize = options.get(36 /* fontSize */);
  25492. var fontFeatureSettings = options.get(35 /* fontLigatures */);
  25493. var lineHeight = options.get(49 /* lineHeight */);
  25494. var letterSpacing = options.get(46 /* letterSpacing */);
  25495. return BareFontInfo._create(fontFamily, fontWeight, fontSize, fontFeatureSettings, lineHeight, letterSpacing, zoomLevel, ignoreEditorZoom);
  25496. };
  25497. /**
  25498. * @internal
  25499. */
  25500. BareFontInfo._create = function (fontFamily, fontWeight, fontSize, fontFeatureSettings, lineHeight, letterSpacing, zoomLevel, ignoreEditorZoom) {
  25501. if (lineHeight === 0) {
  25502. lineHeight = Math.round(GOLDEN_LINE_HEIGHT_RATIO * fontSize);
  25503. }
  25504. else if (lineHeight < MINIMUM_LINE_HEIGHT) {
  25505. lineHeight = MINIMUM_LINE_HEIGHT;
  25506. }
  25507. var editorZoomLevelMultiplier = 1 + (ignoreEditorZoom ? 0 : editorZoom_1.EditorZoom.getZoomLevel() * 0.1);
  25508. fontSize *= editorZoomLevelMultiplier;
  25509. lineHeight *= editorZoomLevelMultiplier;
  25510. return new BareFontInfo({
  25511. zoomLevel: zoomLevel,
  25512. fontFamily: fontFamily,
  25513. fontWeight: fontWeight,
  25514. fontSize: fontSize,
  25515. fontFeatureSettings: fontFeatureSettings,
  25516. lineHeight: lineHeight,
  25517. letterSpacing: letterSpacing
  25518. });
  25519. };
  25520. /**
  25521. * @internal
  25522. */
  25523. BareFontInfo.prototype.getId = function () {
  25524. return this.zoomLevel + '-' + this.fontFamily + '-' + this.fontWeight + '-' + this.fontSize + '-' + this.fontFeatureSettings + '-' + this.lineHeight + '-' + this.letterSpacing;
  25525. };
  25526. /**
  25527. * @internal
  25528. */
  25529. BareFontInfo.prototype.getMassagedFontFamily = function () {
  25530. if (/[,"']/.test(this.fontFamily)) {
  25531. // Looks like the font family might be already escaped
  25532. return this.fontFamily;
  25533. }
  25534. if (/[+ ]/.test(this.fontFamily)) {
  25535. // Wrap a font family using + or <space> with quotes
  25536. return "\"" + this.fontFamily + "\"";
  25537. }
  25538. return this.fontFamily;
  25539. };
  25540. return BareFontInfo;
  25541. }());
  25542. exports.BareFontInfo = BareFontInfo;
  25543. var FontInfo = /** @class */ (function (_super) {
  25544. __extends(FontInfo, _super);
  25545. /**
  25546. * @internal
  25547. */
  25548. function FontInfo(opts, isTrusted) {
  25549. var _this = _super.call(this, opts) || this;
  25550. _this.isTrusted = isTrusted;
  25551. _this.isMonospace = opts.isMonospace;
  25552. _this.typicalHalfwidthCharacterWidth = opts.typicalHalfwidthCharacterWidth;
  25553. _this.typicalFullwidthCharacterWidth = opts.typicalFullwidthCharacterWidth;
  25554. _this.canUseHalfwidthRightwardsArrow = opts.canUseHalfwidthRightwardsArrow;
  25555. _this.spaceWidth = opts.spaceWidth;
  25556. _this.middotWidth = opts.middotWidth;
  25557. _this.maxDigitWidth = opts.maxDigitWidth;
  25558. return _this;
  25559. }
  25560. /**
  25561. * @internal
  25562. */
  25563. FontInfo.prototype.equals = function (other) {
  25564. return (this.fontFamily === other.fontFamily
  25565. && this.fontWeight === other.fontWeight
  25566. && this.fontSize === other.fontSize
  25567. && this.fontFeatureSettings === other.fontFeatureSettings
  25568. && this.lineHeight === other.lineHeight
  25569. && this.letterSpacing === other.letterSpacing
  25570. && this.typicalHalfwidthCharacterWidth === other.typicalHalfwidthCharacterWidth
  25571. && this.typicalFullwidthCharacterWidth === other.typicalFullwidthCharacterWidth
  25572. && this.canUseHalfwidthRightwardsArrow === other.canUseHalfwidthRightwardsArrow
  25573. && this.spaceWidth === other.spaceWidth
  25574. && this.middotWidth === other.middotWidth
  25575. && this.maxDigitWidth === other.maxDigitWidth);
  25576. };
  25577. return FontInfo;
  25578. }(BareFontInfo));
  25579. exports.FontInfo = FontInfo;
  25580. });
  25581. /*---------------------------------------------------------------------------------------------
  25582. * Copyright (c) Microsoft Corporation. All rights reserved.
  25583. * Licensed under the MIT License. See License.txt in the project root for license information.
  25584. *--------------------------------------------------------------------------------------------*/
  25585. define(__m[79/*vs/editor/common/core/characterClassifier*/], __M([0/*require*/,1/*exports*/,179/*vs/base/common/uint*/]), function (require, exports, uint_1) {
  25586. "use strict";
  25587. Object.defineProperty(exports, "__esModule", { value: true });
  25588. /**
  25589. * A fast character classifier that uses a compact array for ASCII values.
  25590. */
  25591. var CharacterClassifier = /** @class */ (function () {
  25592. function CharacterClassifier(_defaultValue) {
  25593. var defaultValue = uint_1.toUint8(_defaultValue);
  25594. this._defaultValue = defaultValue;
  25595. this._asciiMap = CharacterClassifier._createAsciiMap(defaultValue);
  25596. this._map = new Map();
  25597. }
  25598. CharacterClassifier._createAsciiMap = function (defaultValue) {
  25599. var asciiMap = new Uint8Array(256);
  25600. for (var i = 0; i < 256; i++) {
  25601. asciiMap[i] = defaultValue;
  25602. }
  25603. return asciiMap;
  25604. };
  25605. CharacterClassifier.prototype.set = function (charCode, _value) {
  25606. var value = uint_1.toUint8(_value);
  25607. if (charCode >= 0 && charCode < 256) {
  25608. this._asciiMap[charCode] = value;
  25609. }
  25610. else {
  25611. this._map.set(charCode, value);
  25612. }
  25613. };
  25614. CharacterClassifier.prototype.get = function (charCode) {
  25615. if (charCode >= 0 && charCode < 256) {
  25616. return this._asciiMap[charCode];
  25617. }
  25618. else {
  25619. return (this._map.get(charCode) || this._defaultValue);
  25620. }
  25621. };
  25622. return CharacterClassifier;
  25623. }());
  25624. exports.CharacterClassifier = CharacterClassifier;
  25625. var CharacterSet = /** @class */ (function () {
  25626. function CharacterSet() {
  25627. this._actual = new CharacterClassifier(0 /* False */);
  25628. }
  25629. CharacterSet.prototype.add = function (charCode) {
  25630. this._actual.set(charCode, 1 /* True */);
  25631. };
  25632. CharacterSet.prototype.has = function (charCode) {
  25633. return (this._actual.get(charCode) === 1 /* True */);
  25634. };
  25635. return CharacterSet;
  25636. }());
  25637. exports.CharacterSet = CharacterSet;
  25638. });
  25639. /*---------------------------------------------------------------------------------------------
  25640. * Copyright (c) Microsoft Corporation. All rights reserved.
  25641. * Licensed under the MIT License. See License.txt in the project root for license information.
  25642. *--------------------------------------------------------------------------------------------*/
  25643. define(__m[89/*vs/editor/common/controller/wordCharacterClassifier*/], __M([0/*require*/,1/*exports*/,79/*vs/editor/common/core/characterClassifier*/]), function (require, exports, characterClassifier_1) {
  25644. "use strict";
  25645. Object.defineProperty(exports, "__esModule", { value: true });
  25646. var WordCharacterClassifier = /** @class */ (function (_super) {
  25647. __extends(WordCharacterClassifier, _super);
  25648. function WordCharacterClassifier(wordSeparators) {
  25649. var _this = _super.call(this, 0 /* Regular */) || this;
  25650. for (var i = 0, len = wordSeparators.length; i < len; i++) {
  25651. _this.set(wordSeparators.charCodeAt(i), 2 /* WordSeparator */);
  25652. }
  25653. _this.set(32 /* Space */, 1 /* Whitespace */);
  25654. _this.set(9 /* Tab */, 1 /* Whitespace */);
  25655. return _this;
  25656. }
  25657. return WordCharacterClassifier;
  25658. }(characterClassifier_1.CharacterClassifier));
  25659. exports.WordCharacterClassifier = WordCharacterClassifier;
  25660. function once(computeFn) {
  25661. var cache = {}; // TODO@Alex unbounded cache
  25662. return function (input) {
  25663. if (!cache.hasOwnProperty(input)) {
  25664. cache[input] = computeFn(input);
  25665. }
  25666. return cache[input];
  25667. };
  25668. }
  25669. exports.getMapForWordSeparators = once(function (input) { return new WordCharacterClassifier(input); });
  25670. });
  25671. /*---------------------------------------------------------------------------------------------
  25672. * Copyright (c) Microsoft Corporation. All rights reserved.
  25673. * Licensed under the MIT License. See License.txt in the project root for license information.
  25674. *--------------------------------------------------------------------------------------------*/
  25675. define(__m[13/*vs/editor/common/core/position*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  25676. "use strict";
  25677. Object.defineProperty(exports, "__esModule", { value: true });
  25678. /**
  25679. * A position in the editor.
  25680. */
  25681. var Position = /** @class */ (function () {
  25682. function Position(lineNumber, column) {
  25683. this.lineNumber = lineNumber;
  25684. this.column = column;
  25685. }
  25686. /**
  25687. * Create a new position from this position.
  25688. *
  25689. * @param newLineNumber new line number
  25690. * @param newColumn new column
  25691. */
  25692. Position.prototype.with = function (newLineNumber, newColumn) {
  25693. if (newLineNumber === void 0) { newLineNumber = this.lineNumber; }
  25694. if (newColumn === void 0) { newColumn = this.column; }
  25695. if (newLineNumber === this.lineNumber && newColumn === this.column) {
  25696. return this;
  25697. }
  25698. else {
  25699. return new Position(newLineNumber, newColumn);
  25700. }
  25701. };
  25702. /**
  25703. * Derive a new position from this position.
  25704. *
  25705. * @param deltaLineNumber line number delta
  25706. * @param deltaColumn column delta
  25707. */
  25708. Position.prototype.delta = function (deltaLineNumber, deltaColumn) {
  25709. if (deltaLineNumber === void 0) { deltaLineNumber = 0; }
  25710. if (deltaColumn === void 0) { deltaColumn = 0; }
  25711. return this.with(this.lineNumber + deltaLineNumber, this.column + deltaColumn);
  25712. };
  25713. /**
  25714. * Test if this position equals other position
  25715. */
  25716. Position.prototype.equals = function (other) {
  25717. return Position.equals(this, other);
  25718. };
  25719. /**
  25720. * Test if position `a` equals position `b`
  25721. */
  25722. Position.equals = function (a, b) {
  25723. if (!a && !b) {
  25724. return true;
  25725. }
  25726. return (!!a &&
  25727. !!b &&
  25728. a.lineNumber === b.lineNumber &&
  25729. a.column === b.column);
  25730. };
  25731. /**
  25732. * Test if this position is before other position.
  25733. * If the two positions are equal, the result will be false.
  25734. */
  25735. Position.prototype.isBefore = function (other) {
  25736. return Position.isBefore(this, other);
  25737. };
  25738. /**
  25739. * Test if position `a` is before position `b`.
  25740. * If the two positions are equal, the result will be false.
  25741. */
  25742. Position.isBefore = function (a, b) {
  25743. if (a.lineNumber < b.lineNumber) {
  25744. return true;
  25745. }
  25746. if (b.lineNumber < a.lineNumber) {
  25747. return false;
  25748. }
  25749. return a.column < b.column;
  25750. };
  25751. /**
  25752. * Test if this position is before other position.
  25753. * If the two positions are equal, the result will be true.
  25754. */
  25755. Position.prototype.isBeforeOrEqual = function (other) {
  25756. return Position.isBeforeOrEqual(this, other);
  25757. };
  25758. /**
  25759. * Test if position `a` is before position `b`.
  25760. * If the two positions are equal, the result will be true.
  25761. */
  25762. Position.isBeforeOrEqual = function (a, b) {
  25763. if (a.lineNumber < b.lineNumber) {
  25764. return true;
  25765. }
  25766. if (b.lineNumber < a.lineNumber) {
  25767. return false;
  25768. }
  25769. return a.column <= b.column;
  25770. };
  25771. /**
  25772. * A function that compares positions, useful for sorting
  25773. */
  25774. Position.compare = function (a, b) {
  25775. var aLineNumber = a.lineNumber | 0;
  25776. var bLineNumber = b.lineNumber | 0;
  25777. if (aLineNumber === bLineNumber) {
  25778. var aColumn = a.column | 0;
  25779. var bColumn = b.column | 0;
  25780. return aColumn - bColumn;
  25781. }
  25782. return aLineNumber - bLineNumber;
  25783. };
  25784. /**
  25785. * Clone this position.
  25786. */
  25787. Position.prototype.clone = function () {
  25788. return new Position(this.lineNumber, this.column);
  25789. };
  25790. /**
  25791. * Convert to a human-readable representation.
  25792. */
  25793. Position.prototype.toString = function () {
  25794. return '(' + this.lineNumber + ',' + this.column + ')';
  25795. };
  25796. // ---
  25797. /**
  25798. * Create a `Position` from an `IPosition`.
  25799. */
  25800. Position.lift = function (pos) {
  25801. return new Position(pos.lineNumber, pos.column);
  25802. };
  25803. /**
  25804. * Test if `obj` is an `IPosition`.
  25805. */
  25806. Position.isIPosition = function (obj) {
  25807. return (obj
  25808. && (typeof obj.lineNumber === 'number')
  25809. && (typeof obj.column === 'number'));
  25810. };
  25811. return Position;
  25812. }());
  25813. exports.Position = Position;
  25814. });
  25815. /*---------------------------------------------------------------------------------------------
  25816. * Copyright (c) Microsoft Corporation. All rights reserved.
  25817. * Licensed under the MIT License. See License.txt in the project root for license information.
  25818. *--------------------------------------------------------------------------------------------*/
  25819. define(__m[3/*vs/editor/common/core/range*/], __M([0/*require*/,1/*exports*/,13/*vs/editor/common/core/position*/]), function (require, exports, position_1) {
  25820. "use strict";
  25821. Object.defineProperty(exports, "__esModule", { value: true });
  25822. /**
  25823. * A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)
  25824. */
  25825. var Range = /** @class */ (function () {
  25826. function Range(startLineNumber, startColumn, endLineNumber, endColumn) {
  25827. if ((startLineNumber > endLineNumber) || (startLineNumber === endLineNumber && startColumn > endColumn)) {
  25828. this.startLineNumber = endLineNumber;
  25829. this.startColumn = endColumn;
  25830. this.endLineNumber = startLineNumber;
  25831. this.endColumn = startColumn;
  25832. }
  25833. else {
  25834. this.startLineNumber = startLineNumber;
  25835. this.startColumn = startColumn;
  25836. this.endLineNumber = endLineNumber;
  25837. this.endColumn = endColumn;
  25838. }
  25839. }
  25840. /**
  25841. * Test if this range is empty.
  25842. */
  25843. Range.prototype.isEmpty = function () {
  25844. return Range.isEmpty(this);
  25845. };
  25846. /**
  25847. * Test if `range` is empty.
  25848. */
  25849. Range.isEmpty = function (range) {
  25850. return (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn);
  25851. };
  25852. /**
  25853. * Test if position is in this range. If the position is at the edges, will return true.
  25854. */
  25855. Range.prototype.containsPosition = function (position) {
  25856. return Range.containsPosition(this, position);
  25857. };
  25858. /**
  25859. * Test if `position` is in `range`. If the position is at the edges, will return true.
  25860. */
  25861. Range.containsPosition = function (range, position) {
  25862. if (position.lineNumber < range.startLineNumber || position.lineNumber > range.endLineNumber) {
  25863. return false;
  25864. }
  25865. if (position.lineNumber === range.startLineNumber && position.column < range.startColumn) {
  25866. return false;
  25867. }
  25868. if (position.lineNumber === range.endLineNumber && position.column > range.endColumn) {
  25869. return false;
  25870. }
  25871. return true;
  25872. };
  25873. /**
  25874. * Test if range is in this range. If the range is equal to this range, will return true.
  25875. */
  25876. Range.prototype.containsRange = function (range) {
  25877. return Range.containsRange(this, range);
  25878. };
  25879. /**
  25880. * Test if `otherRange` is in `range`. If the ranges are equal, will return true.
  25881. */
  25882. Range.containsRange = function (range, otherRange) {
  25883. if (otherRange.startLineNumber < range.startLineNumber || otherRange.endLineNumber < range.startLineNumber) {
  25884. return false;
  25885. }
  25886. if (otherRange.startLineNumber > range.endLineNumber || otherRange.endLineNumber > range.endLineNumber) {
  25887. return false;
  25888. }
  25889. if (otherRange.startLineNumber === range.startLineNumber && otherRange.startColumn < range.startColumn) {
  25890. return false;
  25891. }
  25892. if (otherRange.endLineNumber === range.endLineNumber && otherRange.endColumn > range.endColumn) {
  25893. return false;
  25894. }
  25895. return true;
  25896. };
  25897. /**
  25898. * Test if `range` is strictly in this range. `range` must start after and end before this range for the result to be true.
  25899. */
  25900. Range.prototype.strictContainsRange = function (range) {
  25901. return Range.strictContainsRange(this, range);
  25902. };
  25903. /**
  25904. * Test if `otherRange` is strinctly in `range` (must start after, and end before). If the ranges are equal, will return false.
  25905. */
  25906. Range.strictContainsRange = function (range, otherRange) {
  25907. if (otherRange.startLineNumber < range.startLineNumber || otherRange.endLineNumber < range.startLineNumber) {
  25908. return false;
  25909. }
  25910. if (otherRange.startLineNumber > range.endLineNumber || otherRange.endLineNumber > range.endLineNumber) {
  25911. return false;
  25912. }
  25913. if (otherRange.startLineNumber === range.startLineNumber && otherRange.startColumn <= range.startColumn) {
  25914. return false;
  25915. }
  25916. if (otherRange.endLineNumber === range.endLineNumber && otherRange.endColumn >= range.endColumn) {
  25917. return false;
  25918. }
  25919. return true;
  25920. };
  25921. /**
  25922. * A reunion of the two ranges.
  25923. * The smallest position will be used as the start point, and the largest one as the end point.
  25924. */
  25925. Range.prototype.plusRange = function (range) {
  25926. return Range.plusRange(this, range);
  25927. };
  25928. /**
  25929. * A reunion of the two ranges.
  25930. * The smallest position will be used as the start point, and the largest one as the end point.
  25931. */
  25932. Range.plusRange = function (a, b) {
  25933. var startLineNumber;
  25934. var startColumn;
  25935. var endLineNumber;
  25936. var endColumn;
  25937. if (b.startLineNumber < a.startLineNumber) {
  25938. startLineNumber = b.startLineNumber;
  25939. startColumn = b.startColumn;
  25940. }
  25941. else if (b.startLineNumber === a.startLineNumber) {
  25942. startLineNumber = b.startLineNumber;
  25943. startColumn = Math.min(b.startColumn, a.startColumn);
  25944. }
  25945. else {
  25946. startLineNumber = a.startLineNumber;
  25947. startColumn = a.startColumn;
  25948. }
  25949. if (b.endLineNumber > a.endLineNumber) {
  25950. endLineNumber = b.endLineNumber;
  25951. endColumn = b.endColumn;
  25952. }
  25953. else if (b.endLineNumber === a.endLineNumber) {
  25954. endLineNumber = b.endLineNumber;
  25955. endColumn = Math.max(b.endColumn, a.endColumn);
  25956. }
  25957. else {
  25958. endLineNumber = a.endLineNumber;
  25959. endColumn = a.endColumn;
  25960. }
  25961. return new Range(startLineNumber, startColumn, endLineNumber, endColumn);
  25962. };
  25963. /**
  25964. * A intersection of the two ranges.
  25965. */
  25966. Range.prototype.intersectRanges = function (range) {
  25967. return Range.intersectRanges(this, range);
  25968. };
  25969. /**
  25970. * A intersection of the two ranges.
  25971. */
  25972. Range.intersectRanges = function (a, b) {
  25973. var resultStartLineNumber = a.startLineNumber;
  25974. var resultStartColumn = a.startColumn;
  25975. var resultEndLineNumber = a.endLineNumber;
  25976. var resultEndColumn = a.endColumn;
  25977. var otherStartLineNumber = b.startLineNumber;
  25978. var otherStartColumn = b.startColumn;
  25979. var otherEndLineNumber = b.endLineNumber;
  25980. var otherEndColumn = b.endColumn;
  25981. if (resultStartLineNumber < otherStartLineNumber) {
  25982. resultStartLineNumber = otherStartLineNumber;
  25983. resultStartColumn = otherStartColumn;
  25984. }
  25985. else if (resultStartLineNumber === otherStartLineNumber) {
  25986. resultStartColumn = Math.max(resultStartColumn, otherStartColumn);
  25987. }
  25988. if (resultEndLineNumber > otherEndLineNumber) {
  25989. resultEndLineNumber = otherEndLineNumber;
  25990. resultEndColumn = otherEndColumn;
  25991. }
  25992. else if (resultEndLineNumber === otherEndLineNumber) {
  25993. resultEndColumn = Math.min(resultEndColumn, otherEndColumn);
  25994. }
  25995. // Check if selection is now empty
  25996. if (resultStartLineNumber > resultEndLineNumber) {
  25997. return null;
  25998. }
  25999. if (resultStartLineNumber === resultEndLineNumber && resultStartColumn > resultEndColumn) {
  26000. return null;
  26001. }
  26002. return new Range(resultStartLineNumber, resultStartColumn, resultEndLineNumber, resultEndColumn);
  26003. };
  26004. /**
  26005. * Test if this range equals other.
  26006. */
  26007. Range.prototype.equalsRange = function (other) {
  26008. return Range.equalsRange(this, other);
  26009. };
  26010. /**
  26011. * Test if range `a` equals `b`.
  26012. */
  26013. Range.equalsRange = function (a, b) {
  26014. return (!!a &&
  26015. !!b &&
  26016. a.startLineNumber === b.startLineNumber &&
  26017. a.startColumn === b.startColumn &&
  26018. a.endLineNumber === b.endLineNumber &&
  26019. a.endColumn === b.endColumn);
  26020. };
  26021. /**
  26022. * Return the end position (which will be after or equal to the start position)
  26023. */
  26024. Range.prototype.getEndPosition = function () {
  26025. return new position_1.Position(this.endLineNumber, this.endColumn);
  26026. };
  26027. /**
  26028. * Return the start position (which will be before or equal to the end position)
  26029. */
  26030. Range.prototype.getStartPosition = function () {
  26031. return new position_1.Position(this.startLineNumber, this.startColumn);
  26032. };
  26033. /**
  26034. * Transform to a user presentable string representation.
  26035. */
  26036. Range.prototype.toString = function () {
  26037. return '[' + this.startLineNumber + ',' + this.startColumn + ' -> ' + this.endLineNumber + ',' + this.endColumn + ']';
  26038. };
  26039. /**
  26040. * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
  26041. */
  26042. Range.prototype.setEndPosition = function (endLineNumber, endColumn) {
  26043. return new Range(this.startLineNumber, this.startColumn, endLineNumber, endColumn);
  26044. };
  26045. /**
  26046. * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
  26047. */
  26048. Range.prototype.setStartPosition = function (startLineNumber, startColumn) {
  26049. return new Range(startLineNumber, startColumn, this.endLineNumber, this.endColumn);
  26050. };
  26051. /**
  26052. * Create a new empty range using this range's start position.
  26053. */
  26054. Range.prototype.collapseToStart = function () {
  26055. return Range.collapseToStart(this);
  26056. };
  26057. /**
  26058. * Create a new empty range using this range's start position.
  26059. */
  26060. Range.collapseToStart = function (range) {
  26061. return new Range(range.startLineNumber, range.startColumn, range.startLineNumber, range.startColumn);
  26062. };
  26063. // ---
  26064. Range.fromPositions = function (start, end) {
  26065. if (end === void 0) { end = start; }
  26066. return new Range(start.lineNumber, start.column, end.lineNumber, end.column);
  26067. };
  26068. Range.lift = function (range) {
  26069. if (!range) {
  26070. return null;
  26071. }
  26072. return new Range(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
  26073. };
  26074. /**
  26075. * Test if `obj` is an `IRange`.
  26076. */
  26077. Range.isIRange = function (obj) {
  26078. return (obj
  26079. && (typeof obj.startLineNumber === 'number')
  26080. && (typeof obj.startColumn === 'number')
  26081. && (typeof obj.endLineNumber === 'number')
  26082. && (typeof obj.endColumn === 'number'));
  26083. };
  26084. /**
  26085. * Test if the two ranges are touching in any way.
  26086. */
  26087. Range.areIntersectingOrTouching = function (a, b) {
  26088. // Check if `a` is before `b`
  26089. if (a.endLineNumber < b.startLineNumber || (a.endLineNumber === b.startLineNumber && a.endColumn < b.startColumn)) {
  26090. return false;
  26091. }
  26092. // Check if `b` is before `a`
  26093. if (b.endLineNumber < a.startLineNumber || (b.endLineNumber === a.startLineNumber && b.endColumn < a.startColumn)) {
  26094. return false;
  26095. }
  26096. // These ranges must intersect
  26097. return true;
  26098. };
  26099. /**
  26100. * Test if the two ranges are intersecting. If the ranges are touching it returns true.
  26101. */
  26102. Range.areIntersecting = function (a, b) {
  26103. // Check if `a` is before `b`
  26104. if (a.endLineNumber < b.startLineNumber || (a.endLineNumber === b.startLineNumber && a.endColumn <= b.startColumn)) {
  26105. return false;
  26106. }
  26107. // Check if `b` is before `a`
  26108. if (b.endLineNumber < a.startLineNumber || (b.endLineNumber === a.startLineNumber && b.endColumn <= a.startColumn)) {
  26109. return false;
  26110. }
  26111. // These ranges must intersect
  26112. return true;
  26113. };
  26114. /**
  26115. * A function that compares ranges, useful for sorting ranges
  26116. * It will first compare ranges on the startPosition and then on the endPosition
  26117. */
  26118. Range.compareRangesUsingStarts = function (a, b) {
  26119. if (a && b) {
  26120. var aStartLineNumber = a.startLineNumber | 0;
  26121. var bStartLineNumber = b.startLineNumber | 0;
  26122. if (aStartLineNumber === bStartLineNumber) {
  26123. var aStartColumn = a.startColumn | 0;
  26124. var bStartColumn = b.startColumn | 0;
  26125. if (aStartColumn === bStartColumn) {
  26126. var aEndLineNumber = a.endLineNumber | 0;
  26127. var bEndLineNumber = b.endLineNumber | 0;
  26128. if (aEndLineNumber === bEndLineNumber) {
  26129. var aEndColumn = a.endColumn | 0;
  26130. var bEndColumn = b.endColumn | 0;
  26131. return aEndColumn - bEndColumn;
  26132. }
  26133. return aEndLineNumber - bEndLineNumber;
  26134. }
  26135. return aStartColumn - bStartColumn;
  26136. }
  26137. return aStartLineNumber - bStartLineNumber;
  26138. }
  26139. var aExists = (a ? 1 : 0);
  26140. var bExists = (b ? 1 : 0);
  26141. return aExists - bExists;
  26142. };
  26143. /**
  26144. * A function that compares ranges, useful for sorting ranges
  26145. * It will first compare ranges on the endPosition and then on the startPosition
  26146. */
  26147. Range.compareRangesUsingEnds = function (a, b) {
  26148. if (a.endLineNumber === b.endLineNumber) {
  26149. if (a.endColumn === b.endColumn) {
  26150. if (a.startLineNumber === b.startLineNumber) {
  26151. return a.startColumn - b.startColumn;
  26152. }
  26153. return a.startLineNumber - b.startLineNumber;
  26154. }
  26155. return a.endColumn - b.endColumn;
  26156. }
  26157. return a.endLineNumber - b.endLineNumber;
  26158. };
  26159. /**
  26160. * Test if the range spans multiple lines.
  26161. */
  26162. Range.spansMultipleLines = function (range) {
  26163. return range.endLineNumber > range.startLineNumber;
  26164. };
  26165. return Range;
  26166. }());
  26167. exports.Range = Range;
  26168. });
  26169. /*---------------------------------------------------------------------------------------------
  26170. * Copyright (c) Microsoft Corporation. All rights reserved.
  26171. * Licensed under the MIT License. See License.txt in the project root for license information.
  26172. *--------------------------------------------------------------------------------------------*/
  26173. define(__m[187/*vs/editor/browser/controller/textAreaState*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/]), function (require, exports, strings, position_1, range_1) {
  26174. "use strict";
  26175. Object.defineProperty(exports, "__esModule", { value: true });
  26176. var TextAreaState = /** @class */ (function () {
  26177. function TextAreaState(value, selectionStart, selectionEnd, selectionStartPosition, selectionEndPosition) {
  26178. this.value = value;
  26179. this.selectionStart = selectionStart;
  26180. this.selectionEnd = selectionEnd;
  26181. this.selectionStartPosition = selectionStartPosition;
  26182. this.selectionEndPosition = selectionEndPosition;
  26183. }
  26184. TextAreaState.prototype.toString = function () {
  26185. return '[ <' + this.value + '>, selectionStart: ' + this.selectionStart + ', selectionEnd: ' + this.selectionEnd + ']';
  26186. };
  26187. TextAreaState.readFromTextArea = function (textArea) {
  26188. return new TextAreaState(textArea.getValue(), textArea.getSelectionStart(), textArea.getSelectionEnd(), null, null);
  26189. };
  26190. TextAreaState.prototype.collapseSelection = function () {
  26191. return new TextAreaState(this.value, this.value.length, this.value.length, null, null);
  26192. };
  26193. TextAreaState.prototype.writeToTextArea = function (reason, textArea, select) {
  26194. // console.log(Date.now() + ': writeToTextArea ' + reason + ': ' + this.toString());
  26195. textArea.setValue(reason, this.value);
  26196. if (select) {
  26197. textArea.setSelectionRange(reason, this.selectionStart, this.selectionEnd);
  26198. }
  26199. };
  26200. TextAreaState.prototype.deduceEditorPosition = function (offset) {
  26201. if (offset <= this.selectionStart) {
  26202. var str = this.value.substring(offset, this.selectionStart);
  26203. return this._finishDeduceEditorPosition(this.selectionStartPosition, str, -1);
  26204. }
  26205. if (offset >= this.selectionEnd) {
  26206. var str = this.value.substring(this.selectionEnd, offset);
  26207. return this._finishDeduceEditorPosition(this.selectionEndPosition, str, 1);
  26208. }
  26209. var str1 = this.value.substring(this.selectionStart, offset);
  26210. if (str1.indexOf(String.fromCharCode(8230)) === -1) {
  26211. return this._finishDeduceEditorPosition(this.selectionStartPosition, str1, 1);
  26212. }
  26213. var str2 = this.value.substring(offset, this.selectionEnd);
  26214. return this._finishDeduceEditorPosition(this.selectionEndPosition, str2, -1);
  26215. };
  26216. TextAreaState.prototype._finishDeduceEditorPosition = function (anchor, deltaText, signum) {
  26217. var lineFeedCnt = 0;
  26218. var lastLineFeedIndex = -1;
  26219. while ((lastLineFeedIndex = deltaText.indexOf('\n', lastLineFeedIndex + 1)) !== -1) {
  26220. lineFeedCnt++;
  26221. }
  26222. return [anchor, signum * deltaText.length, lineFeedCnt];
  26223. };
  26224. TextAreaState.selectedText = function (text) {
  26225. return new TextAreaState(text, 0, text.length, null, null);
  26226. };
  26227. TextAreaState.deduceInput = function (previousState, currentState, couldBeEmojiInput) {
  26228. if (!previousState) {
  26229. // This is the EMPTY state
  26230. return {
  26231. text: '',
  26232. replaceCharCnt: 0
  26233. };
  26234. }
  26235. // console.log('------------------------deduceInput');
  26236. // console.log('PREVIOUS STATE: ' + previousState.toString());
  26237. // console.log('CURRENT STATE: ' + currentState.toString());
  26238. var previousValue = previousState.value;
  26239. var previousSelectionStart = previousState.selectionStart;
  26240. var previousSelectionEnd = previousState.selectionEnd;
  26241. var currentValue = currentState.value;
  26242. var currentSelectionStart = currentState.selectionStart;
  26243. var currentSelectionEnd = currentState.selectionEnd;
  26244. // Strip the previous suffix from the value (without interfering with the current selection)
  26245. var previousSuffix = previousValue.substring(previousSelectionEnd);
  26246. var currentSuffix = currentValue.substring(currentSelectionEnd);
  26247. var suffixLength = strings.commonSuffixLength(previousSuffix, currentSuffix);
  26248. currentValue = currentValue.substring(0, currentValue.length - suffixLength);
  26249. previousValue = previousValue.substring(0, previousValue.length - suffixLength);
  26250. var previousPrefix = previousValue.substring(0, previousSelectionStart);
  26251. var currentPrefix = currentValue.substring(0, currentSelectionStart);
  26252. var prefixLength = strings.commonPrefixLength(previousPrefix, currentPrefix);
  26253. currentValue = currentValue.substring(prefixLength);
  26254. previousValue = previousValue.substring(prefixLength);
  26255. currentSelectionStart -= prefixLength;
  26256. previousSelectionStart -= prefixLength;
  26257. currentSelectionEnd -= prefixLength;
  26258. previousSelectionEnd -= prefixLength;
  26259. // console.log('AFTER DIFFING PREVIOUS STATE: <' + previousValue + '>, selectionStart: ' + previousSelectionStart + ', selectionEnd: ' + previousSelectionEnd);
  26260. // console.log('AFTER DIFFING CURRENT STATE: <' + currentValue + '>, selectionStart: ' + currentSelectionStart + ', selectionEnd: ' + currentSelectionEnd);
  26261. if (couldBeEmojiInput && currentSelectionStart === currentSelectionEnd && previousValue.length > 0) {
  26262. // on OSX, emojis from the emoji picker are inserted at random locations
  26263. // the only hints we can use is that the selection is immediately after the inserted emoji
  26264. // and that none of the old text has been deleted
  26265. var potentialEmojiInput = null;
  26266. if (currentSelectionStart === currentValue.length) {
  26267. // emoji potentially inserted "somewhere" after the previous selection => it should appear at the end of `currentValue`
  26268. if (strings.startsWith(currentValue, previousValue)) {
  26269. // only if all of the old text is accounted for
  26270. potentialEmojiInput = currentValue.substring(previousValue.length);
  26271. }
  26272. }
  26273. else {
  26274. // emoji potentially inserted "somewhere" before the previous selection => it should appear at the start of `currentValue`
  26275. if (strings.endsWith(currentValue, previousValue)) {
  26276. // only if all of the old text is accounted for
  26277. potentialEmojiInput = currentValue.substring(0, currentValue.length - previousValue.length);
  26278. }
  26279. }
  26280. if (potentialEmojiInput !== null && potentialEmojiInput.length > 0) {
  26281. // now we check that this is indeed an emoji
  26282. // emojis can grow quite long, so a length check is of no help
  26283. // e.g. 1F3F4 E0067 E0062 E0065 E006E E0067 E007F ; fully-qualified # 🏴󠁧󠁢󠁥󠁮󠁧󠁿 England
  26284. // Oftentimes, emojis use Variation Selector-16 (U+FE0F), so that is a good hint
  26285. // http://emojipedia.org/variation-selector-16/
  26286. // > An invisible codepoint which specifies that the preceding character
  26287. // > should be displayed with emoji presentation. Only required if the
  26288. // > preceding character defaults to text presentation.
  26289. if (/\uFE0F/.test(potentialEmojiInput) || strings.containsEmoji(potentialEmojiInput)) {
  26290. return {
  26291. text: potentialEmojiInput,
  26292. replaceCharCnt: 0
  26293. };
  26294. }
  26295. }
  26296. }
  26297. if (currentSelectionStart === currentSelectionEnd) {
  26298. // composition accept case (noticed in FF + Japanese)
  26299. // [blahblah] => blahblah|
  26300. if (previousValue === currentValue
  26301. && previousSelectionStart === 0
  26302. && previousSelectionEnd === previousValue.length
  26303. && currentSelectionStart === currentValue.length
  26304. && currentValue.indexOf('\n') === -1) {
  26305. if (strings.containsFullWidthCharacter(currentValue)) {
  26306. return {
  26307. text: '',
  26308. replaceCharCnt: 0
  26309. };
  26310. }
  26311. }
  26312. // no current selection
  26313. var replacePreviousCharacters_1 = (previousPrefix.length - prefixLength);
  26314. // console.log('REMOVE PREVIOUS: ' + (previousPrefix.length - prefixLength) + ' chars');
  26315. return {
  26316. text: currentValue,
  26317. replaceCharCnt: replacePreviousCharacters_1
  26318. };
  26319. }
  26320. // there is a current selection => composition case
  26321. var replacePreviousCharacters = previousSelectionEnd - previousSelectionStart;
  26322. return {
  26323. text: currentValue,
  26324. replaceCharCnt: replacePreviousCharacters
  26325. };
  26326. };
  26327. TextAreaState.EMPTY = new TextAreaState('', 0, 0, null, null);
  26328. return TextAreaState;
  26329. }());
  26330. exports.TextAreaState = TextAreaState;
  26331. var PagedScreenReaderStrategy = /** @class */ (function () {
  26332. function PagedScreenReaderStrategy() {
  26333. }
  26334. PagedScreenReaderStrategy._getPageOfLine = function (lineNumber, linesPerPage) {
  26335. return Math.floor((lineNumber - 1) / linesPerPage);
  26336. };
  26337. PagedScreenReaderStrategy._getRangeForPage = function (page, linesPerPage) {
  26338. var offset = page * linesPerPage;
  26339. var startLineNumber = offset + 1;
  26340. var endLineNumber = offset + linesPerPage;
  26341. return new range_1.Range(startLineNumber, 1, endLineNumber + 1, 1);
  26342. };
  26343. PagedScreenReaderStrategy.fromEditorSelection = function (previousState, model, selection, linesPerPage, trimLongText) {
  26344. var selectionStartPage = PagedScreenReaderStrategy._getPageOfLine(selection.startLineNumber, linesPerPage);
  26345. var selectionStartPageRange = PagedScreenReaderStrategy._getRangeForPage(selectionStartPage, linesPerPage);
  26346. var selectionEndPage = PagedScreenReaderStrategy._getPageOfLine(selection.endLineNumber, linesPerPage);
  26347. var selectionEndPageRange = PagedScreenReaderStrategy._getRangeForPage(selectionEndPage, linesPerPage);
  26348. var pretextRange = selectionStartPageRange.intersectRanges(new range_1.Range(1, 1, selection.startLineNumber, selection.startColumn));
  26349. var pretext = model.getValueInRange(pretextRange, 1 /* LF */);
  26350. var lastLine = model.getLineCount();
  26351. var lastLineMaxColumn = model.getLineMaxColumn(lastLine);
  26352. var posttextRange = selectionEndPageRange.intersectRanges(new range_1.Range(selection.endLineNumber, selection.endColumn, lastLine, lastLineMaxColumn));
  26353. var posttext = model.getValueInRange(posttextRange, 1 /* LF */);
  26354. var text;
  26355. if (selectionStartPage === selectionEndPage || selectionStartPage + 1 === selectionEndPage) {
  26356. // take full selection
  26357. text = model.getValueInRange(selection, 1 /* LF */);
  26358. }
  26359. else {
  26360. var selectionRange1 = selectionStartPageRange.intersectRanges(selection);
  26361. var selectionRange2 = selectionEndPageRange.intersectRanges(selection);
  26362. text = (model.getValueInRange(selectionRange1, 1 /* LF */)
  26363. + String.fromCharCode(8230)
  26364. + model.getValueInRange(selectionRange2, 1 /* LF */));
  26365. }
  26366. // Chromium handles very poorly text even of a few thousand chars
  26367. // Cut text to avoid stalling the entire UI
  26368. if (trimLongText) {
  26369. var LIMIT_CHARS = 500;
  26370. if (pretext.length > LIMIT_CHARS) {
  26371. pretext = pretext.substring(pretext.length - LIMIT_CHARS, pretext.length);
  26372. }
  26373. if (posttext.length > LIMIT_CHARS) {
  26374. posttext = posttext.substring(0, LIMIT_CHARS);
  26375. }
  26376. if (text.length > 2 * LIMIT_CHARS) {
  26377. text = text.substring(0, LIMIT_CHARS) + String.fromCharCode(8230) + text.substring(text.length - LIMIT_CHARS, text.length);
  26378. }
  26379. }
  26380. return new TextAreaState(pretext + text + posttext, pretext.length, pretext.length + text.length, new position_1.Position(selection.startLineNumber, selection.startColumn), new position_1.Position(selection.endLineNumber, selection.endColumn));
  26381. };
  26382. return PagedScreenReaderStrategy;
  26383. }());
  26384. exports.PagedScreenReaderStrategy = PagedScreenReaderStrategy;
  26385. });
  26386. /*---------------------------------------------------------------------------------------------
  26387. * Copyright (c) Microsoft Corporation. All rights reserved.
  26388. * Licensed under the MIT License. See License.txt in the project root for license information.
  26389. *--------------------------------------------------------------------------------------------*/
  26390. define(__m[188/*vs/editor/browser/widget/diffNavigator*/], __M([0/*require*/,1/*exports*/,124/*vs/base/common/assert*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,31/*vs/base/common/objects*/,3/*vs/editor/common/core/range*/]), function (require, exports, assert, event_1, lifecycle_1, objects, range_1) {
  26391. "use strict";
  26392. Object.defineProperty(exports, "__esModule", { value: true });
  26393. var defaultOptions = {
  26394. followsCaret: true,
  26395. ignoreCharChanges: true,
  26396. alwaysRevealFirst: true
  26397. };
  26398. /**
  26399. * Create a new diff navigator for the provided diff editor.
  26400. */
  26401. var DiffNavigator = /** @class */ (function (_super) {
  26402. __extends(DiffNavigator, _super);
  26403. function DiffNavigator(editor, options) {
  26404. if (options === void 0) { options = {}; }
  26405. var _this = _super.call(this) || this;
  26406. _this._onDidUpdate = _this._register(new event_1.Emitter());
  26407. _this._editor = editor;
  26408. _this._options = objects.mixin(options, defaultOptions, false);
  26409. _this.disposed = false;
  26410. _this.nextIdx = -1;
  26411. _this.ranges = [];
  26412. _this.ignoreSelectionChange = false;
  26413. _this.revealFirst = Boolean(_this._options.alwaysRevealFirst);
  26414. // hook up to diff editor for diff, disposal, and caret move
  26415. _this._register(_this._editor.onDidDispose(function () { return _this.dispose(); }));
  26416. _this._register(_this._editor.onDidUpdateDiff(function () { return _this._onDiffUpdated(); }));
  26417. if (_this._options.followsCaret) {
  26418. _this._register(_this._editor.getModifiedEditor().onDidChangeCursorPosition(function (e) {
  26419. if (_this.ignoreSelectionChange) {
  26420. return;
  26421. }
  26422. _this.nextIdx = -1;
  26423. }));
  26424. }
  26425. if (_this._options.alwaysRevealFirst) {
  26426. _this._register(_this._editor.getModifiedEditor().onDidChangeModel(function (e) {
  26427. _this.revealFirst = true;
  26428. }));
  26429. }
  26430. // init things
  26431. _this._init();
  26432. return _this;
  26433. }
  26434. DiffNavigator.prototype._init = function () {
  26435. var changes = this._editor.getLineChanges();
  26436. if (!changes) {
  26437. return;
  26438. }
  26439. };
  26440. DiffNavigator.prototype._onDiffUpdated = function () {
  26441. this._init();
  26442. this._compute(this._editor.getLineChanges());
  26443. if (this.revealFirst) {
  26444. // Only reveal first on first non-null changes
  26445. if (this._editor.getLineChanges() !== null) {
  26446. this.revealFirst = false;
  26447. this.nextIdx = -1;
  26448. this.next(1 /* Immediate */);
  26449. }
  26450. }
  26451. };
  26452. DiffNavigator.prototype._compute = function (lineChanges) {
  26453. var _this = this;
  26454. // new ranges
  26455. this.ranges = [];
  26456. if (lineChanges) {
  26457. // create ranges from changes
  26458. lineChanges.forEach(function (lineChange) {
  26459. if (!_this._options.ignoreCharChanges && lineChange.charChanges) {
  26460. lineChange.charChanges.forEach(function (charChange) {
  26461. _this.ranges.push({
  26462. rhs: true,
  26463. range: new range_1.Range(charChange.modifiedStartLineNumber, charChange.modifiedStartColumn, charChange.modifiedEndLineNumber, charChange.modifiedEndColumn)
  26464. });
  26465. });
  26466. }
  26467. else {
  26468. _this.ranges.push({
  26469. rhs: true,
  26470. range: new range_1.Range(lineChange.modifiedStartLineNumber, 1, lineChange.modifiedStartLineNumber, 1)
  26471. });
  26472. }
  26473. });
  26474. }
  26475. // sort
  26476. this.ranges.sort(function (left, right) {
  26477. if (left.range.getStartPosition().isBeforeOrEqual(right.range.getStartPosition())) {
  26478. return -1;
  26479. }
  26480. else if (right.range.getStartPosition().isBeforeOrEqual(left.range.getStartPosition())) {
  26481. return 1;
  26482. }
  26483. else {
  26484. return 0;
  26485. }
  26486. });
  26487. this._onDidUpdate.fire(this);
  26488. };
  26489. DiffNavigator.prototype._initIdx = function (fwd) {
  26490. var found = false;
  26491. var position = this._editor.getPosition();
  26492. if (!position) {
  26493. this.nextIdx = 0;
  26494. return;
  26495. }
  26496. for (var i = 0, len = this.ranges.length; i < len && !found; i++) {
  26497. var range = this.ranges[i].range;
  26498. if (position.isBeforeOrEqual(range.getStartPosition())) {
  26499. this.nextIdx = i + (fwd ? 0 : -1);
  26500. found = true;
  26501. }
  26502. }
  26503. if (!found) {
  26504. // after the last change
  26505. this.nextIdx = fwd ? 0 : this.ranges.length - 1;
  26506. }
  26507. if (this.nextIdx < 0) {
  26508. this.nextIdx = this.ranges.length - 1;
  26509. }
  26510. };
  26511. DiffNavigator.prototype._move = function (fwd, scrollType) {
  26512. assert.ok(!this.disposed, 'Illegal State - diff navigator has been disposed');
  26513. if (!this.canNavigate()) {
  26514. return;
  26515. }
  26516. if (this.nextIdx === -1) {
  26517. this._initIdx(fwd);
  26518. }
  26519. else if (fwd) {
  26520. this.nextIdx += 1;
  26521. if (this.nextIdx >= this.ranges.length) {
  26522. this.nextIdx = 0;
  26523. }
  26524. }
  26525. else {
  26526. this.nextIdx -= 1;
  26527. if (this.nextIdx < 0) {
  26528. this.nextIdx = this.ranges.length - 1;
  26529. }
  26530. }
  26531. var info = this.ranges[this.nextIdx];
  26532. this.ignoreSelectionChange = true;
  26533. try {
  26534. var pos = info.range.getStartPosition();
  26535. this._editor.setPosition(pos);
  26536. this._editor.revealPositionInCenter(pos, scrollType);
  26537. }
  26538. finally {
  26539. this.ignoreSelectionChange = false;
  26540. }
  26541. };
  26542. DiffNavigator.prototype.canNavigate = function () {
  26543. return this.ranges && this.ranges.length > 0;
  26544. };
  26545. DiffNavigator.prototype.next = function (scrollType) {
  26546. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  26547. this._move(true, scrollType);
  26548. };
  26549. DiffNavigator.prototype.previous = function (scrollType) {
  26550. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  26551. this._move(false, scrollType);
  26552. };
  26553. DiffNavigator.prototype.dispose = function () {
  26554. _super.prototype.dispose.call(this);
  26555. this.ranges = [];
  26556. this.disposed = true;
  26557. };
  26558. return DiffNavigator;
  26559. }(lifecycle_1.Disposable));
  26560. exports.DiffNavigator = DiffNavigator;
  26561. });
  26562. /*---------------------------------------------------------------------------------------------
  26563. * Copyright (c) Microsoft Corporation. All rights reserved.
  26564. * Licensed under the MIT License. See License.txt in the project root for license information.
  26565. *--------------------------------------------------------------------------------------------*/
  26566. define(__m[58/*vs/editor/common/core/editOperation*/], __M([0/*require*/,1/*exports*/,3/*vs/editor/common/core/range*/]), function (require, exports, range_1) {
  26567. "use strict";
  26568. Object.defineProperty(exports, "__esModule", { value: true });
  26569. var EditOperation = /** @class */ (function () {
  26570. function EditOperation() {
  26571. }
  26572. EditOperation.insert = function (position, text) {
  26573. return {
  26574. range: new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column),
  26575. text: text,
  26576. forceMoveMarkers: true
  26577. };
  26578. };
  26579. EditOperation.delete = function (range) {
  26580. return {
  26581. range: range,
  26582. text: null
  26583. };
  26584. };
  26585. EditOperation.replace = function (range, text) {
  26586. return {
  26587. range: range,
  26588. text: text
  26589. };
  26590. };
  26591. EditOperation.replaceMove = function (range, text) {
  26592. return {
  26593. range: range,
  26594. text: text,
  26595. forceMoveMarkers: true
  26596. };
  26597. };
  26598. return EditOperation;
  26599. }());
  26600. exports.EditOperation = EditOperation;
  26601. });
  26602. /*---------------------------------------------------------------------------------------------
  26603. * Copyright (c) Microsoft Corporation. All rights reserved.
  26604. * Licensed under the MIT License. See License.txt in the project root for license information.
  26605. *--------------------------------------------------------------------------------------------*/
  26606. define(__m[338/*vs/editor/common/commands/trimTrailingWhitespaceCommand*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,58/*vs/editor/common/core/editOperation*/,3/*vs/editor/common/core/range*/]), function (require, exports, strings, editOperation_1, range_1) {
  26607. "use strict";
  26608. Object.defineProperty(exports, "__esModule", { value: true });
  26609. var TrimTrailingWhitespaceCommand = /** @class */ (function () {
  26610. function TrimTrailingWhitespaceCommand(selection, cursors) {
  26611. this._selection = selection;
  26612. this._cursors = cursors;
  26613. this._selectionId = null;
  26614. }
  26615. TrimTrailingWhitespaceCommand.prototype.getEditOperations = function (model, builder) {
  26616. var ops = trimTrailingWhitespace(model, this._cursors);
  26617. for (var i = 0, len = ops.length; i < len; i++) {
  26618. var op = ops[i];
  26619. builder.addEditOperation(op.range, op.text);
  26620. }
  26621. this._selectionId = builder.trackSelection(this._selection);
  26622. };
  26623. TrimTrailingWhitespaceCommand.prototype.computeCursorState = function (model, helper) {
  26624. return helper.getTrackedSelection(this._selectionId);
  26625. };
  26626. return TrimTrailingWhitespaceCommand;
  26627. }());
  26628. exports.TrimTrailingWhitespaceCommand = TrimTrailingWhitespaceCommand;
  26629. /**
  26630. * Generate commands for trimming trailing whitespace on a model and ignore lines on which cursors are sitting.
  26631. */
  26632. function trimTrailingWhitespace(model, cursors) {
  26633. // Sort cursors ascending
  26634. cursors.sort(function (a, b) {
  26635. if (a.lineNumber === b.lineNumber) {
  26636. return a.column - b.column;
  26637. }
  26638. return a.lineNumber - b.lineNumber;
  26639. });
  26640. // Reduce multiple cursors on the same line and only keep the last one on the line
  26641. for (var i = cursors.length - 2; i >= 0; i--) {
  26642. if (cursors[i].lineNumber === cursors[i + 1].lineNumber) {
  26643. // Remove cursor at `i`
  26644. cursors.splice(i, 1);
  26645. }
  26646. }
  26647. var r = [];
  26648. var rLen = 0;
  26649. var cursorIndex = 0;
  26650. var cursorLen = cursors.length;
  26651. for (var lineNumber = 1, lineCount = model.getLineCount(); lineNumber <= lineCount; lineNumber++) {
  26652. var lineContent = model.getLineContent(lineNumber);
  26653. var maxLineColumn = lineContent.length + 1;
  26654. var minEditColumn = 0;
  26655. if (cursorIndex < cursorLen && cursors[cursorIndex].lineNumber === lineNumber) {
  26656. minEditColumn = cursors[cursorIndex].column;
  26657. cursorIndex++;
  26658. if (minEditColumn === maxLineColumn) {
  26659. // The cursor is at the end of the line => no edits for sure on this line
  26660. continue;
  26661. }
  26662. }
  26663. if (lineContent.length === 0) {
  26664. continue;
  26665. }
  26666. var lastNonWhitespaceIndex = strings.lastNonWhitespaceIndex(lineContent);
  26667. var fromColumn = 0;
  26668. if (lastNonWhitespaceIndex === -1) {
  26669. // Entire line is whitespace
  26670. fromColumn = 1;
  26671. }
  26672. else if (lastNonWhitespaceIndex !== lineContent.length - 1) {
  26673. // There is trailing whitespace
  26674. fromColumn = lastNonWhitespaceIndex + 2;
  26675. }
  26676. else {
  26677. // There is no trailing whitespace
  26678. continue;
  26679. }
  26680. fromColumn = Math.max(minEditColumn, fromColumn);
  26681. r[rLen++] = editOperation_1.EditOperation.delete(new range_1.Range(lineNumber, fromColumn, lineNumber, maxLineColumn));
  26682. }
  26683. return r;
  26684. }
  26685. exports.trimTrailingWhitespace = trimTrailingWhitespace;
  26686. });
  26687. /*---------------------------------------------------------------------------------------------
  26688. * Copyright (c) Microsoft Corporation. All rights reserved.
  26689. * Licensed under the MIT License. See License.txt in the project root for license information.
  26690. *--------------------------------------------------------------------------------------------*/
  26691. define(__m[339/*vs/editor/common/core/rgba*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  26692. "use strict";
  26693. Object.defineProperty(exports, "__esModule", { value: true });
  26694. /**
  26695. * A very VM friendly rgba datastructure.
  26696. * Please don't touch unless you take a look at the IR.
  26697. */
  26698. var RGBA8 = /** @class */ (function () {
  26699. function RGBA8(r, g, b, a) {
  26700. this.r = RGBA8._clamp(r);
  26701. this.g = RGBA8._clamp(g);
  26702. this.b = RGBA8._clamp(b);
  26703. this.a = RGBA8._clamp(a);
  26704. }
  26705. RGBA8._clamp = function (c) {
  26706. if (c < 0) {
  26707. return 0;
  26708. }
  26709. if (c > 255) {
  26710. return 255;
  26711. }
  26712. return c | 0;
  26713. };
  26714. RGBA8.Empty = new RGBA8(0, 0, 0, 0);
  26715. return RGBA8;
  26716. }());
  26717. exports.RGBA8 = RGBA8;
  26718. });
  26719. /*---------------------------------------------------------------------------------------------
  26720. * Copyright (c) Microsoft Corporation. All rights reserved.
  26721. * Licensed under the MIT License. See License.txt in the project root for license information.
  26722. *--------------------------------------------------------------------------------------------*/
  26723. define(__m[22/*vs/editor/common/core/selection*/], __M([0/*require*/,1/*exports*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/]), function (require, exports, position_1, range_1) {
  26724. "use strict";
  26725. Object.defineProperty(exports, "__esModule", { value: true });
  26726. /**
  26727. * A selection in the editor.
  26728. * The selection is a range that has an orientation.
  26729. */
  26730. var Selection = /** @class */ (function (_super) {
  26731. __extends(Selection, _super);
  26732. function Selection(selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn) {
  26733. var _this = _super.call(this, selectionStartLineNumber, selectionStartColumn, positionLineNumber, positionColumn) || this;
  26734. _this.selectionStartLineNumber = selectionStartLineNumber;
  26735. _this.selectionStartColumn = selectionStartColumn;
  26736. _this.positionLineNumber = positionLineNumber;
  26737. _this.positionColumn = positionColumn;
  26738. return _this;
  26739. }
  26740. /**
  26741. * Transform to a human-readable representation.
  26742. */
  26743. Selection.prototype.toString = function () {
  26744. return '[' + this.selectionStartLineNumber + ',' + this.selectionStartColumn + ' -> ' + this.positionLineNumber + ',' + this.positionColumn + ']';
  26745. };
  26746. /**
  26747. * Test if equals other selection.
  26748. */
  26749. Selection.prototype.equalsSelection = function (other) {
  26750. return (Selection.selectionsEqual(this, other));
  26751. };
  26752. /**
  26753. * Test if the two selections are equal.
  26754. */
  26755. Selection.selectionsEqual = function (a, b) {
  26756. return (a.selectionStartLineNumber === b.selectionStartLineNumber &&
  26757. a.selectionStartColumn === b.selectionStartColumn &&
  26758. a.positionLineNumber === b.positionLineNumber &&
  26759. a.positionColumn === b.positionColumn);
  26760. };
  26761. /**
  26762. * Get directions (LTR or RTL).
  26763. */
  26764. Selection.prototype.getDirection = function () {
  26765. if (this.selectionStartLineNumber === this.startLineNumber && this.selectionStartColumn === this.startColumn) {
  26766. return 0 /* LTR */;
  26767. }
  26768. return 1 /* RTL */;
  26769. };
  26770. /**
  26771. * Create a new selection with a different `positionLineNumber` and `positionColumn`.
  26772. */
  26773. Selection.prototype.setEndPosition = function (endLineNumber, endColumn) {
  26774. if (this.getDirection() === 0 /* LTR */) {
  26775. return new Selection(this.startLineNumber, this.startColumn, endLineNumber, endColumn);
  26776. }
  26777. return new Selection(endLineNumber, endColumn, this.startLineNumber, this.startColumn);
  26778. };
  26779. /**
  26780. * Get the position at `positionLineNumber` and `positionColumn`.
  26781. */
  26782. Selection.prototype.getPosition = function () {
  26783. return new position_1.Position(this.positionLineNumber, this.positionColumn);
  26784. };
  26785. /**
  26786. * Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`.
  26787. */
  26788. Selection.prototype.setStartPosition = function (startLineNumber, startColumn) {
  26789. if (this.getDirection() === 0 /* LTR */) {
  26790. return new Selection(startLineNumber, startColumn, this.endLineNumber, this.endColumn);
  26791. }
  26792. return new Selection(this.endLineNumber, this.endColumn, startLineNumber, startColumn);
  26793. };
  26794. // ----
  26795. /**
  26796. * Create a `Selection` from one or two positions
  26797. */
  26798. Selection.fromPositions = function (start, end) {
  26799. if (end === void 0) { end = start; }
  26800. return new Selection(start.lineNumber, start.column, end.lineNumber, end.column);
  26801. };
  26802. /**
  26803. * Create a `Selection` from an `ISelection`.
  26804. */
  26805. Selection.liftSelection = function (sel) {
  26806. return new Selection(sel.selectionStartLineNumber, sel.selectionStartColumn, sel.positionLineNumber, sel.positionColumn);
  26807. };
  26808. /**
  26809. * `a` equals `b`.
  26810. */
  26811. Selection.selectionsArrEqual = function (a, b) {
  26812. if (a && !b || !a && b) {
  26813. return false;
  26814. }
  26815. if (!a && !b) {
  26816. return true;
  26817. }
  26818. if (a.length !== b.length) {
  26819. return false;
  26820. }
  26821. for (var i = 0, len = a.length; i < len; i++) {
  26822. if (!this.selectionsEqual(a[i], b[i])) {
  26823. return false;
  26824. }
  26825. }
  26826. return true;
  26827. };
  26828. /**
  26829. * Test if `obj` is an `ISelection`.
  26830. */
  26831. Selection.isISelection = function (obj) {
  26832. return (obj
  26833. && (typeof obj.selectionStartLineNumber === 'number')
  26834. && (typeof obj.selectionStartColumn === 'number')
  26835. && (typeof obj.positionLineNumber === 'number')
  26836. && (typeof obj.positionColumn === 'number'));
  26837. };
  26838. /**
  26839. * Create with a direction.
  26840. */
  26841. Selection.createWithDirection = function (startLineNumber, startColumn, endLineNumber, endColumn, direction) {
  26842. if (direction === 0 /* LTR */) {
  26843. return new Selection(startLineNumber, startColumn, endLineNumber, endColumn);
  26844. }
  26845. return new Selection(endLineNumber, endColumn, startLineNumber, startColumn);
  26846. };
  26847. return Selection;
  26848. }(range_1.Range));
  26849. exports.Selection = Selection;
  26850. });
  26851. /*---------------------------------------------------------------------------------------------
  26852. * Copyright (c) Microsoft Corporation. All rights reserved.
  26853. * Licensed under the MIT License. See License.txt in the project root for license information.
  26854. *--------------------------------------------------------------------------------------------*/
  26855. define(__m[189/*vs/editor/browser/controller/textAreaInput*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,6/*vs/base/browser/dom*/,15/*vs/base/common/async*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,5/*vs/base/common/strings*/,187/*vs/editor/browser/controller/textAreaState*/,22/*vs/editor/common/core/selection*/,88/*vs/base/browser/canIUse*/]), function (require, exports, browser, dom, async_1, event_1, lifecycle_1, platform, strings, textAreaState_1, selection_1, canIUse_1) {
  26856. "use strict";
  26857. Object.defineProperty(exports, "__esModule", { value: true });
  26858. exports.CopyOptions = {
  26859. forceCopyWithSyntaxHighlighting: false
  26860. };
  26861. /**
  26862. * Every time we write to the clipboard, we record a bit of extra metadata here.
  26863. * Every time we read from the cipboard, if the text matches our last written text,
  26864. * we can fetch the previous metadata.
  26865. */
  26866. var InMemoryClipboardMetadataManager = /** @class */ (function () {
  26867. function InMemoryClipboardMetadataManager() {
  26868. this._lastState = null;
  26869. }
  26870. InMemoryClipboardMetadataManager.prototype.set = function (lastCopiedValue, data) {
  26871. this._lastState = { lastCopiedValue: lastCopiedValue, data: data };
  26872. };
  26873. InMemoryClipboardMetadataManager.prototype.get = function (pastedText) {
  26874. if (this._lastState && this._lastState.lastCopiedValue === pastedText) {
  26875. // match!
  26876. return this._lastState.data;
  26877. }
  26878. this._lastState = null;
  26879. return null;
  26880. };
  26881. InMemoryClipboardMetadataManager.INSTANCE = new InMemoryClipboardMetadataManager();
  26882. return InMemoryClipboardMetadataManager;
  26883. }());
  26884. /**
  26885. * Writes screen reader content to the textarea and is able to analyze its input events to generate:
  26886. * - onCut
  26887. * - onPaste
  26888. * - onType
  26889. *
  26890. * Composition events are generated for presentation purposes (composition input is reflected in onType).
  26891. */
  26892. var TextAreaInput = /** @class */ (function (_super) {
  26893. __extends(TextAreaInput, _super);
  26894. function TextAreaInput(host, textArea) {
  26895. var _this = _super.call(this) || this;
  26896. _this.textArea = textArea;
  26897. _this._onFocus = _this._register(new event_1.Emitter());
  26898. _this.onFocus = _this._onFocus.event;
  26899. _this._onBlur = _this._register(new event_1.Emitter());
  26900. _this.onBlur = _this._onBlur.event;
  26901. _this._onKeyDown = _this._register(new event_1.Emitter());
  26902. _this.onKeyDown = _this._onKeyDown.event;
  26903. _this._onKeyUp = _this._register(new event_1.Emitter());
  26904. _this.onKeyUp = _this._onKeyUp.event;
  26905. _this._onCut = _this._register(new event_1.Emitter());
  26906. _this.onCut = _this._onCut.event;
  26907. _this._onPaste = _this._register(new event_1.Emitter());
  26908. _this.onPaste = _this._onPaste.event;
  26909. _this._onType = _this._register(new event_1.Emitter());
  26910. _this.onType = _this._onType.event;
  26911. _this._onCompositionStart = _this._register(new event_1.Emitter());
  26912. _this.onCompositionStart = _this._onCompositionStart.event;
  26913. _this._onCompositionUpdate = _this._register(new event_1.Emitter());
  26914. _this.onCompositionUpdate = _this._onCompositionUpdate.event;
  26915. _this._onCompositionEnd = _this._register(new event_1.Emitter());
  26916. _this.onCompositionEnd = _this._onCompositionEnd.event;
  26917. _this._onSelectionChangeRequest = _this._register(new event_1.Emitter());
  26918. _this.onSelectionChangeRequest = _this._onSelectionChangeRequest.event;
  26919. _this._host = host;
  26920. _this._textArea = _this._register(new TextAreaWrapper(textArea));
  26921. _this._asyncTriggerCut = _this._register(new async_1.RunOnceScheduler(function () { return _this._onCut.fire(); }, 0));
  26922. _this._textAreaState = textAreaState_1.TextAreaState.EMPTY;
  26923. _this._selectionChangeListener = null;
  26924. _this.writeScreenReaderContent('ctor');
  26925. _this._hasFocus = false;
  26926. _this._isDoingComposition = false;
  26927. _this._nextCommand = 0 /* Type */;
  26928. _this._register(dom.addStandardDisposableListener(textArea.domNode, 'keydown', function (e) {
  26929. if (_this._isDoingComposition &&
  26930. (e.keyCode === 109 /* KEY_IN_COMPOSITION */ || e.keyCode === 1 /* Backspace */)) {
  26931. // Stop propagation for keyDown events if the IME is processing key input
  26932. e.stopPropagation();
  26933. }
  26934. if (e.equals(9 /* Escape */)) {
  26935. // Prevent default always for `Esc`, otherwise it will generate a keypress
  26936. // See https://msdn.microsoft.com/en-us/library/ie/ms536939(v=vs.85).aspx
  26937. e.preventDefault();
  26938. }
  26939. _this._onKeyDown.fire(e);
  26940. }));
  26941. _this._register(dom.addStandardDisposableListener(textArea.domNode, 'keyup', function (e) {
  26942. _this._onKeyUp.fire(e);
  26943. }));
  26944. _this._register(dom.addDisposableListener(textArea.domNode, 'compositionstart', function (e) {
  26945. if (_this._isDoingComposition) {
  26946. return;
  26947. }
  26948. _this._isDoingComposition = true;
  26949. // In IE we cannot set .value when handling 'compositionstart' because the entire composition will get canceled.
  26950. if (!browser.isEdgeOrIE) {
  26951. _this._setAndWriteTextAreaState('compositionstart', textAreaState_1.TextAreaState.EMPTY);
  26952. }
  26953. _this._onCompositionStart.fire();
  26954. }));
  26955. /**
  26956. * Deduce the typed input from a text area's value and the last observed state.
  26957. */
  26958. var deduceInputFromTextAreaValue = function (couldBeEmojiInput) {
  26959. var oldState = _this._textAreaState;
  26960. var newState = textAreaState_1.TextAreaState.readFromTextArea(_this._textArea);
  26961. return [newState, textAreaState_1.TextAreaState.deduceInput(oldState, newState, couldBeEmojiInput)];
  26962. };
  26963. /**
  26964. * Deduce the composition input from a string.
  26965. */
  26966. var deduceComposition = function (text) {
  26967. var oldState = _this._textAreaState;
  26968. var newState = textAreaState_1.TextAreaState.selectedText(text);
  26969. var typeInput = {
  26970. text: newState.value,
  26971. replaceCharCnt: oldState.selectionEnd - oldState.selectionStart
  26972. };
  26973. return [newState, typeInput];
  26974. };
  26975. var compositionDataInValid = function (locale) {
  26976. // https://github.com/Microsoft/monaco-editor/issues/339
  26977. // Multi-part Japanese compositions reset cursor in Edge/IE, Chinese and Korean IME don't have this issue.
  26978. // The reason that we can't use this path for all CJK IME is IE and Edge behave differently when handling Korean IME,
  26979. // which breaks this path of code.
  26980. if (browser.isEdgeOrIE && locale === 'ja') {
  26981. return true;
  26982. }
  26983. // https://github.com/Microsoft/monaco-editor/issues/545
  26984. // On IE11, we can't trust composition data when typing Chinese as IE11 doesn't emit correct
  26985. // events when users type numbers in IME.
  26986. // Chinese: zh-Hans-CN, zh-Hans-SG, zh-Hant-TW, zh-Hant-HK
  26987. if (browser.isIE && locale.indexOf('zh-Han') === 0) {
  26988. return true;
  26989. }
  26990. return false;
  26991. };
  26992. _this._register(dom.addDisposableListener(textArea.domNode, 'compositionupdate', function (e) {
  26993. if (compositionDataInValid(e.locale)) {
  26994. var _a = deduceInputFromTextAreaValue(/*couldBeEmojiInput*/ false), newState_1 = _a[0], typeInput_1 = _a[1];
  26995. _this._textAreaState = newState_1;
  26996. _this._onType.fire(typeInput_1);
  26997. _this._onCompositionUpdate.fire(e);
  26998. return;
  26999. }
  27000. var _b = deduceComposition(e.data), newState = _b[0], typeInput = _b[1];
  27001. _this._textAreaState = newState;
  27002. _this._onType.fire(typeInput);
  27003. _this._onCompositionUpdate.fire(e);
  27004. }));
  27005. _this._register(dom.addDisposableListener(textArea.domNode, 'compositionend', function (e) {
  27006. // https://github.com/microsoft/monaco-editor/issues/1663
  27007. // On iOS 13.2, Chinese system IME randomly trigger an additional compositionend event with empty data
  27008. if (!_this._isDoingComposition) {
  27009. return;
  27010. }
  27011. if (compositionDataInValid(e.locale)) {
  27012. // https://github.com/Microsoft/monaco-editor/issues/339
  27013. var _a = deduceInputFromTextAreaValue(/*couldBeEmojiInput*/ false), newState = _a[0], typeInput = _a[1];
  27014. _this._textAreaState = newState;
  27015. _this._onType.fire(typeInput);
  27016. }
  27017. else {
  27018. var _b = deduceComposition(e.data), newState = _b[0], typeInput = _b[1];
  27019. _this._textAreaState = newState;
  27020. _this._onType.fire(typeInput);
  27021. }
  27022. // Due to isEdgeOrIE (where the textarea was not cleared initially) and isChrome (the textarea is not updated correctly when composition ends)
  27023. // we cannot assume the text at the end consists only of the composited text
  27024. if (browser.isEdgeOrIE || browser.isChrome) {
  27025. _this._textAreaState = textAreaState_1.TextAreaState.readFromTextArea(_this._textArea);
  27026. }
  27027. if (!_this._isDoingComposition) {
  27028. return;
  27029. }
  27030. _this._isDoingComposition = false;
  27031. _this._onCompositionEnd.fire();
  27032. }));
  27033. _this._register(dom.addDisposableListener(textArea.domNode, 'input', function () {
  27034. // Pretend here we touched the text area, as the `input` event will most likely
  27035. // result in a `selectionchange` event which we want to ignore
  27036. _this._textArea.setIgnoreSelectionChangeTime('received input event');
  27037. if (_this._isDoingComposition) {
  27038. return;
  27039. }
  27040. var _a = deduceInputFromTextAreaValue(/*couldBeEmojiInput*/ platform.isMacintosh), newState = _a[0], typeInput = _a[1];
  27041. if (typeInput.replaceCharCnt === 0 && typeInput.text.length === 1 && strings.isHighSurrogate(typeInput.text.charCodeAt(0))) {
  27042. // Ignore invalid input but keep it around for next time
  27043. return;
  27044. }
  27045. _this._textAreaState = newState;
  27046. if (_this._nextCommand === 0 /* Type */) {
  27047. if (typeInput.text !== '') {
  27048. _this._onType.fire(typeInput);
  27049. }
  27050. }
  27051. else {
  27052. if (typeInput.text !== '' || typeInput.replaceCharCnt !== 0) {
  27053. _this._firePaste(typeInput.text, null);
  27054. }
  27055. _this._nextCommand = 0 /* Type */;
  27056. }
  27057. }));
  27058. // --- Clipboard operations
  27059. _this._register(dom.addDisposableListener(textArea.domNode, 'cut', function (e) {
  27060. // Pretend here we touched the text area, as the `cut` event will most likely
  27061. // result in a `selectionchange` event which we want to ignore
  27062. _this._textArea.setIgnoreSelectionChangeTime('received cut event');
  27063. _this._ensureClipboardGetsEditorSelection(e);
  27064. _this._asyncTriggerCut.schedule();
  27065. }));
  27066. _this._register(dom.addDisposableListener(textArea.domNode, 'copy', function (e) {
  27067. _this._ensureClipboardGetsEditorSelection(e);
  27068. }));
  27069. _this._register(dom.addDisposableListener(textArea.domNode, 'paste', function (e) {
  27070. // Pretend here we touched the text area, as the `paste` event will most likely
  27071. // result in a `selectionchange` event which we want to ignore
  27072. _this._textArea.setIgnoreSelectionChangeTime('received paste event');
  27073. if (ClipboardEventUtils.canUseTextData(e)) {
  27074. var _a = ClipboardEventUtils.getTextData(e), pastePlainText = _a[0], metadata = _a[1];
  27075. if (pastePlainText !== '') {
  27076. _this._firePaste(pastePlainText, metadata);
  27077. }
  27078. }
  27079. else {
  27080. if (_this._textArea.getSelectionStart() !== _this._textArea.getSelectionEnd()) {
  27081. // Clean up the textarea, to get a clean paste
  27082. _this._setAndWriteTextAreaState('paste', textAreaState_1.TextAreaState.EMPTY);
  27083. }
  27084. _this._nextCommand = 1 /* Paste */;
  27085. }
  27086. }));
  27087. _this._register(dom.addDisposableListener(textArea.domNode, 'focus', function () {
  27088. _this._setHasFocus(true);
  27089. }));
  27090. _this._register(dom.addDisposableListener(textArea.domNode, 'blur', function () {
  27091. _this._setHasFocus(false);
  27092. }));
  27093. return _this;
  27094. }
  27095. TextAreaInput.prototype._installSelectionChangeListener = function () {
  27096. // See https://github.com/Microsoft/vscode/issues/27216
  27097. // When using a Braille display, it is possible for users to reposition the
  27098. // system caret. This is reflected in Chrome as a `selectionchange` event.
  27099. //
  27100. // The `selectionchange` event appears to be emitted under numerous other circumstances,
  27101. // so it is quite a challenge to distinguish a `selectionchange` coming in from a user
  27102. // using a Braille display from all the other cases.
  27103. //
  27104. // The problems with the `selectionchange` event are:
  27105. // * the event is emitted when the textarea is focused programmatically -- textarea.focus()
  27106. // * the event is emitted when the selection is changed in the textarea programmatically -- textarea.setSelectionRange(...)
  27107. // * the event is emitted when the value of the textarea is changed programmatically -- textarea.value = '...'
  27108. // * the event is emitted when tabbing into the textarea
  27109. // * the event is emitted asynchronously (sometimes with a delay as high as a few tens of ms)
  27110. // * the event sometimes comes in bursts for a single logical textarea operation
  27111. var _this = this;
  27112. // `selectionchange` events often come multiple times for a single logical change
  27113. // so throttle multiple `selectionchange` events that burst in a short period of time.
  27114. var previousSelectionChangeEventTime = 0;
  27115. return dom.addDisposableListener(document, 'selectionchange', function (e) {
  27116. if (!_this._hasFocus) {
  27117. return;
  27118. }
  27119. if (_this._isDoingComposition) {
  27120. return;
  27121. }
  27122. if (!browser.isChrome || !platform.isWindows) {
  27123. // Support only for Chrome on Windows until testing happens on other browsers + OS configurations
  27124. return;
  27125. }
  27126. var now = Date.now();
  27127. var delta1 = now - previousSelectionChangeEventTime;
  27128. previousSelectionChangeEventTime = now;
  27129. if (delta1 < 5) {
  27130. // received another `selectionchange` event within 5ms of the previous `selectionchange` event
  27131. // => ignore it
  27132. return;
  27133. }
  27134. var delta2 = now - _this._textArea.getIgnoreSelectionChangeTime();
  27135. _this._textArea.resetSelectionChangeTime();
  27136. if (delta2 < 100) {
  27137. // received a `selectionchange` event within 100ms since we touched the textarea
  27138. // => ignore it, since we caused it
  27139. return;
  27140. }
  27141. if (!_this._textAreaState.selectionStartPosition || !_this._textAreaState.selectionEndPosition) {
  27142. // Cannot correlate a position in the textarea with a position in the editor...
  27143. return;
  27144. }
  27145. var newValue = _this._textArea.getValue();
  27146. if (_this._textAreaState.value !== newValue) {
  27147. // Cannot correlate a position in the textarea with a position in the editor...
  27148. return;
  27149. }
  27150. var newSelectionStart = _this._textArea.getSelectionStart();
  27151. var newSelectionEnd = _this._textArea.getSelectionEnd();
  27152. if (_this._textAreaState.selectionStart === newSelectionStart && _this._textAreaState.selectionEnd === newSelectionEnd) {
  27153. // Nothing to do...
  27154. return;
  27155. }
  27156. var _newSelectionStartPosition = _this._textAreaState.deduceEditorPosition(newSelectionStart);
  27157. var newSelectionStartPosition = _this._host.deduceModelPosition(_newSelectionStartPosition[0], _newSelectionStartPosition[1], _newSelectionStartPosition[2]);
  27158. var _newSelectionEndPosition = _this._textAreaState.deduceEditorPosition(newSelectionEnd);
  27159. var newSelectionEndPosition = _this._host.deduceModelPosition(_newSelectionEndPosition[0], _newSelectionEndPosition[1], _newSelectionEndPosition[2]);
  27160. var newSelection = new selection_1.Selection(newSelectionStartPosition.lineNumber, newSelectionStartPosition.column, newSelectionEndPosition.lineNumber, newSelectionEndPosition.column);
  27161. _this._onSelectionChangeRequest.fire(newSelection);
  27162. });
  27163. };
  27164. TextAreaInput.prototype.dispose = function () {
  27165. _super.prototype.dispose.call(this);
  27166. if (this._selectionChangeListener) {
  27167. this._selectionChangeListener.dispose();
  27168. this._selectionChangeListener = null;
  27169. }
  27170. };
  27171. TextAreaInput.prototype.focusTextArea = function () {
  27172. // Setting this._hasFocus and writing the screen reader content
  27173. // will result in a focus() and setSelectionRange() in the textarea
  27174. this._setHasFocus(true);
  27175. // If the editor is off DOM, focus cannot be really set, so let's double check that we have managed to set the focus
  27176. this.refreshFocusState();
  27177. };
  27178. TextAreaInput.prototype.isFocused = function () {
  27179. return this._hasFocus;
  27180. };
  27181. TextAreaInput.prototype.refreshFocusState = function () {
  27182. var shadowRoot = dom.getShadowRoot(this.textArea.domNode);
  27183. if (shadowRoot) {
  27184. this._setHasFocus(shadowRoot.activeElement === this.textArea.domNode);
  27185. }
  27186. else if (dom.isInDOM(this.textArea.domNode)) {
  27187. this._setHasFocus(document.activeElement === this.textArea.domNode);
  27188. }
  27189. else {
  27190. this._setHasFocus(false);
  27191. }
  27192. };
  27193. TextAreaInput.prototype._setHasFocus = function (newHasFocus) {
  27194. if (this._hasFocus === newHasFocus) {
  27195. // no change
  27196. return;
  27197. }
  27198. this._hasFocus = newHasFocus;
  27199. if (this._selectionChangeListener) {
  27200. this._selectionChangeListener.dispose();
  27201. this._selectionChangeListener = null;
  27202. }
  27203. if (this._hasFocus) {
  27204. this._selectionChangeListener = this._installSelectionChangeListener();
  27205. }
  27206. if (this._hasFocus) {
  27207. if (browser.isEdge) {
  27208. // Edge has a bug where setting the selection range while the focus event
  27209. // is dispatching doesn't work. To reproduce, "tab into" the editor.
  27210. this._setAndWriteTextAreaState('focusgain', textAreaState_1.TextAreaState.EMPTY);
  27211. }
  27212. else {
  27213. this.writeScreenReaderContent('focusgain');
  27214. }
  27215. }
  27216. if (this._hasFocus) {
  27217. this._onFocus.fire();
  27218. }
  27219. else {
  27220. this._onBlur.fire();
  27221. }
  27222. };
  27223. TextAreaInput.prototype._setAndWriteTextAreaState = function (reason, textAreaState) {
  27224. if (!this._hasFocus) {
  27225. textAreaState = textAreaState.collapseSelection();
  27226. }
  27227. textAreaState.writeToTextArea(reason, this._textArea, this._hasFocus);
  27228. this._textAreaState = textAreaState;
  27229. };
  27230. TextAreaInput.prototype.writeScreenReaderContent = function (reason) {
  27231. if (this._isDoingComposition) {
  27232. // Do not write to the text area when doing composition
  27233. return;
  27234. }
  27235. this._setAndWriteTextAreaState(reason, this._host.getScreenReaderContent(this._textAreaState));
  27236. };
  27237. TextAreaInput.prototype._ensureClipboardGetsEditorSelection = function (e) {
  27238. var dataToCopy = this._host.getDataToCopy(ClipboardEventUtils.canUseTextData(e) && canIUse_1.BrowserFeatures.clipboard.richText);
  27239. var storedMetadata = {
  27240. version: 1,
  27241. isFromEmptySelection: dataToCopy.isFromEmptySelection,
  27242. multicursorText: dataToCopy.multicursorText,
  27243. mode: dataToCopy.mode
  27244. };
  27245. InMemoryClipboardMetadataManager.INSTANCE.set(
  27246. // When writing "LINE\r\n" to the clipboard and then pasting,
  27247. // Firefox pastes "LINE\n", so let's work around this quirk
  27248. (browser.isFirefox ? dataToCopy.text.replace(/\r\n/g, '\n') : dataToCopy.text), storedMetadata);
  27249. if (!ClipboardEventUtils.canUseTextData(e)) {
  27250. // Looks like an old browser. The strategy is to place the text
  27251. // we'd like to be copied to the clipboard in the textarea and select it.
  27252. this._setAndWriteTextAreaState('copy or cut', textAreaState_1.TextAreaState.selectedText(dataToCopy.text));
  27253. return;
  27254. }
  27255. ClipboardEventUtils.setTextData(e, dataToCopy.text, dataToCopy.html, storedMetadata);
  27256. };
  27257. TextAreaInput.prototype._firePaste = function (text, metadata) {
  27258. if (!metadata) {
  27259. // try the in-memory store
  27260. metadata = InMemoryClipboardMetadataManager.INSTANCE.get(text);
  27261. }
  27262. this._onPaste.fire({
  27263. text: text,
  27264. metadata: metadata
  27265. });
  27266. };
  27267. return TextAreaInput;
  27268. }(lifecycle_1.Disposable));
  27269. exports.TextAreaInput = TextAreaInput;
  27270. var ClipboardEventUtils = /** @class */ (function () {
  27271. function ClipboardEventUtils() {
  27272. }
  27273. ClipboardEventUtils.canUseTextData = function (e) {
  27274. if (e.clipboardData) {
  27275. return true;
  27276. }
  27277. if (window.clipboardData) {
  27278. return true;
  27279. }
  27280. return false;
  27281. };
  27282. ClipboardEventUtils.getTextData = function (e) {
  27283. if (e.clipboardData) {
  27284. e.preventDefault();
  27285. var text = e.clipboardData.getData('text/plain');
  27286. var metadata = null;
  27287. var rawmetadata = e.clipboardData.getData('vscode-editor-data');
  27288. if (typeof rawmetadata === 'string') {
  27289. try {
  27290. metadata = JSON.parse(rawmetadata);
  27291. if (metadata.version !== 1) {
  27292. metadata = null;
  27293. }
  27294. }
  27295. catch (err) {
  27296. // no problem!
  27297. }
  27298. }
  27299. return [text, metadata];
  27300. }
  27301. if (window.clipboardData) {
  27302. e.preventDefault();
  27303. var text = window.clipboardData.getData('Text');
  27304. return [text, null];
  27305. }
  27306. throw new Error('ClipboardEventUtils.getTextData: Cannot use text data!');
  27307. };
  27308. ClipboardEventUtils.setTextData = function (e, text, html, metadata) {
  27309. if (e.clipboardData) {
  27310. e.clipboardData.setData('text/plain', text);
  27311. if (typeof html === 'string') {
  27312. e.clipboardData.setData('text/html', html);
  27313. }
  27314. e.clipboardData.setData('vscode-editor-data', JSON.stringify(metadata));
  27315. e.preventDefault();
  27316. return;
  27317. }
  27318. if (window.clipboardData) {
  27319. window.clipboardData.setData('Text', text);
  27320. e.preventDefault();
  27321. return;
  27322. }
  27323. throw new Error('ClipboardEventUtils.setTextData: Cannot use text data!');
  27324. };
  27325. return ClipboardEventUtils;
  27326. }());
  27327. var TextAreaWrapper = /** @class */ (function (_super) {
  27328. __extends(TextAreaWrapper, _super);
  27329. function TextAreaWrapper(_textArea) {
  27330. var _this = _super.call(this) || this;
  27331. _this._actual = _textArea;
  27332. _this._ignoreSelectionChangeTime = 0;
  27333. return _this;
  27334. }
  27335. TextAreaWrapper.prototype.setIgnoreSelectionChangeTime = function (reason) {
  27336. this._ignoreSelectionChangeTime = Date.now();
  27337. };
  27338. TextAreaWrapper.prototype.getIgnoreSelectionChangeTime = function () {
  27339. return this._ignoreSelectionChangeTime;
  27340. };
  27341. TextAreaWrapper.prototype.resetSelectionChangeTime = function () {
  27342. this._ignoreSelectionChangeTime = 0;
  27343. };
  27344. TextAreaWrapper.prototype.getValue = function () {
  27345. // console.log('current value: ' + this._textArea.value);
  27346. return this._actual.domNode.value;
  27347. };
  27348. TextAreaWrapper.prototype.setValue = function (reason, value) {
  27349. var textArea = this._actual.domNode;
  27350. if (textArea.value === value) {
  27351. // No change
  27352. return;
  27353. }
  27354. // console.log('reason: ' + reason + ', current value: ' + textArea.value + ' => new value: ' + value);
  27355. this.setIgnoreSelectionChangeTime('setValue');
  27356. textArea.value = value;
  27357. };
  27358. TextAreaWrapper.prototype.getSelectionStart = function () {
  27359. return this._actual.domNode.selectionStart;
  27360. };
  27361. TextAreaWrapper.prototype.getSelectionEnd = function () {
  27362. return this._actual.domNode.selectionEnd;
  27363. };
  27364. TextAreaWrapper.prototype.setSelectionRange = function (reason, selectionStart, selectionEnd) {
  27365. var textArea = this._actual.domNode;
  27366. var activeElement = null;
  27367. var shadowRoot = dom.getShadowRoot(textArea);
  27368. if (shadowRoot) {
  27369. activeElement = shadowRoot.activeElement;
  27370. }
  27371. else {
  27372. activeElement = document.activeElement;
  27373. }
  27374. var currentIsFocused = (activeElement === textArea);
  27375. var currentSelectionStart = textArea.selectionStart;
  27376. var currentSelectionEnd = textArea.selectionEnd;
  27377. if (currentIsFocused && currentSelectionStart === selectionStart && currentSelectionEnd === selectionEnd) {
  27378. // No change
  27379. // Firefox iframe bug https://github.com/Microsoft/monaco-editor/issues/643#issuecomment-367871377
  27380. if (browser.isFirefox && window.parent !== window) {
  27381. textArea.focus();
  27382. }
  27383. return;
  27384. }
  27385. // console.log('reason: ' + reason + ', setSelectionRange: ' + selectionStart + ' -> ' + selectionEnd);
  27386. if (currentIsFocused) {
  27387. // No need to focus, only need to change the selection range
  27388. this.setIgnoreSelectionChangeTime('setSelectionRange');
  27389. textArea.setSelectionRange(selectionStart, selectionEnd);
  27390. if (browser.isFirefox && window.parent !== window) {
  27391. textArea.focus();
  27392. }
  27393. return;
  27394. }
  27395. // If the focus is outside the textarea, browsers will try really hard to reveal the textarea.
  27396. // Here, we try to undo the browser's desperate reveal.
  27397. try {
  27398. var scrollState = dom.saveParentsScrollTop(textArea);
  27399. this.setIgnoreSelectionChangeTime('setSelectionRange');
  27400. textArea.focus();
  27401. textArea.setSelectionRange(selectionStart, selectionEnd);
  27402. dom.restoreParentsScrollTop(textArea, scrollState);
  27403. }
  27404. catch (e) {
  27405. // Sometimes IE throws when setting selection (e.g. textarea is off-DOM)
  27406. }
  27407. };
  27408. return TextAreaWrapper;
  27409. }(lifecycle_1.Disposable));
  27410. });
  27411. /*---------------------------------------------------------------------------------------------
  27412. * Copyright (c) Microsoft Corporation. All rights reserved.
  27413. * Licensed under the MIT License. See License.txt in the project root for license information.
  27414. *--------------------------------------------------------------------------------------------*/
  27415. define(__m[80/*vs/editor/common/commands/replaceCommand*/], __M([0/*require*/,1/*exports*/,22/*vs/editor/common/core/selection*/]), function (require, exports, selection_1) {
  27416. "use strict";
  27417. Object.defineProperty(exports, "__esModule", { value: true });
  27418. var ReplaceCommand = /** @class */ (function () {
  27419. function ReplaceCommand(range, text, insertsAutoWhitespace) {
  27420. if (insertsAutoWhitespace === void 0) { insertsAutoWhitespace = false; }
  27421. this._range = range;
  27422. this._text = text;
  27423. this.insertsAutoWhitespace = insertsAutoWhitespace;
  27424. }
  27425. ReplaceCommand.prototype.getEditOperations = function (model, builder) {
  27426. builder.addTrackedEditOperation(this._range, this._text);
  27427. };
  27428. ReplaceCommand.prototype.computeCursorState = function (model, helper) {
  27429. var inverseEditOperations = helper.getInverseEditOperations();
  27430. var srcRange = inverseEditOperations[0].range;
  27431. return new selection_1.Selection(srcRange.endLineNumber, srcRange.endColumn, srcRange.endLineNumber, srcRange.endColumn);
  27432. };
  27433. return ReplaceCommand;
  27434. }());
  27435. exports.ReplaceCommand = ReplaceCommand;
  27436. var ReplaceCommandThatSelectsText = /** @class */ (function () {
  27437. function ReplaceCommandThatSelectsText(range, text) {
  27438. this._range = range;
  27439. this._text = text;
  27440. }
  27441. ReplaceCommandThatSelectsText.prototype.getEditOperations = function (model, builder) {
  27442. builder.addTrackedEditOperation(this._range, this._text);
  27443. };
  27444. ReplaceCommandThatSelectsText.prototype.computeCursorState = function (model, helper) {
  27445. var inverseEditOperations = helper.getInverseEditOperations();
  27446. var srcRange = inverseEditOperations[0].range;
  27447. return new selection_1.Selection(srcRange.startLineNumber, srcRange.startColumn, srcRange.endLineNumber, srcRange.endColumn);
  27448. };
  27449. return ReplaceCommandThatSelectsText;
  27450. }());
  27451. exports.ReplaceCommandThatSelectsText = ReplaceCommandThatSelectsText;
  27452. var ReplaceCommandWithoutChangingPosition = /** @class */ (function () {
  27453. function ReplaceCommandWithoutChangingPosition(range, text, insertsAutoWhitespace) {
  27454. if (insertsAutoWhitespace === void 0) { insertsAutoWhitespace = false; }
  27455. this._range = range;
  27456. this._text = text;
  27457. this.insertsAutoWhitespace = insertsAutoWhitespace;
  27458. }
  27459. ReplaceCommandWithoutChangingPosition.prototype.getEditOperations = function (model, builder) {
  27460. builder.addTrackedEditOperation(this._range, this._text);
  27461. };
  27462. ReplaceCommandWithoutChangingPosition.prototype.computeCursorState = function (model, helper) {
  27463. var inverseEditOperations = helper.getInverseEditOperations();
  27464. var srcRange = inverseEditOperations[0].range;
  27465. return new selection_1.Selection(srcRange.startLineNumber, srcRange.startColumn, srcRange.startLineNumber, srcRange.startColumn);
  27466. };
  27467. return ReplaceCommandWithoutChangingPosition;
  27468. }());
  27469. exports.ReplaceCommandWithoutChangingPosition = ReplaceCommandWithoutChangingPosition;
  27470. var ReplaceCommandWithOffsetCursorState = /** @class */ (function () {
  27471. function ReplaceCommandWithOffsetCursorState(range, text, lineNumberDeltaOffset, columnDeltaOffset, insertsAutoWhitespace) {
  27472. if (insertsAutoWhitespace === void 0) { insertsAutoWhitespace = false; }
  27473. this._range = range;
  27474. this._text = text;
  27475. this._columnDeltaOffset = columnDeltaOffset;
  27476. this._lineNumberDeltaOffset = lineNumberDeltaOffset;
  27477. this.insertsAutoWhitespace = insertsAutoWhitespace;
  27478. }
  27479. ReplaceCommandWithOffsetCursorState.prototype.getEditOperations = function (model, builder) {
  27480. builder.addTrackedEditOperation(this._range, this._text);
  27481. };
  27482. ReplaceCommandWithOffsetCursorState.prototype.computeCursorState = function (model, helper) {
  27483. var inverseEditOperations = helper.getInverseEditOperations();
  27484. var srcRange = inverseEditOperations[0].range;
  27485. return new selection_1.Selection(srcRange.endLineNumber + this._lineNumberDeltaOffset, srcRange.endColumn + this._columnDeltaOffset, srcRange.endLineNumber + this._lineNumberDeltaOffset, srcRange.endColumn + this._columnDeltaOffset);
  27486. };
  27487. return ReplaceCommandWithOffsetCursorState;
  27488. }());
  27489. exports.ReplaceCommandWithOffsetCursorState = ReplaceCommandWithOffsetCursorState;
  27490. var ReplaceCommandThatPreservesSelection = /** @class */ (function () {
  27491. function ReplaceCommandThatPreservesSelection(editRange, text, initialSelection, forceMoveMarkers) {
  27492. if (forceMoveMarkers === void 0) { forceMoveMarkers = false; }
  27493. this._range = editRange;
  27494. this._text = text;
  27495. this._initialSelection = initialSelection;
  27496. this._forceMoveMarkers = forceMoveMarkers;
  27497. this._selectionId = null;
  27498. }
  27499. ReplaceCommandThatPreservesSelection.prototype.getEditOperations = function (model, builder) {
  27500. builder.addTrackedEditOperation(this._range, this._text, this._forceMoveMarkers);
  27501. this._selectionId = builder.trackSelection(this._initialSelection);
  27502. };
  27503. ReplaceCommandThatPreservesSelection.prototype.computeCursorState = function (model, helper) {
  27504. return helper.getTrackedSelection(this._selectionId);
  27505. };
  27506. return ReplaceCommandThatPreservesSelection;
  27507. }());
  27508. exports.ReplaceCommandThatPreservesSelection = ReplaceCommandThatPreservesSelection;
  27509. });
  27510. /*---------------------------------------------------------------------------------------------
  27511. * Copyright (c) Microsoft Corporation. All rights reserved.
  27512. * Licensed under the MIT License. See License.txt in the project root for license information.
  27513. *--------------------------------------------------------------------------------------------*/
  27514. define(__m[340/*vs/editor/common/commands/surroundSelectionCommand*/], __M([0/*require*/,1/*exports*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/]), function (require, exports, range_1, selection_1) {
  27515. "use strict";
  27516. Object.defineProperty(exports, "__esModule", { value: true });
  27517. var SurroundSelectionCommand = /** @class */ (function () {
  27518. function SurroundSelectionCommand(range, charBeforeSelection, charAfterSelection) {
  27519. this._range = range;
  27520. this._charBeforeSelection = charBeforeSelection;
  27521. this._charAfterSelection = charAfterSelection;
  27522. }
  27523. SurroundSelectionCommand.prototype.getEditOperations = function (model, builder) {
  27524. builder.addTrackedEditOperation(new range_1.Range(this._range.startLineNumber, this._range.startColumn, this._range.startLineNumber, this._range.startColumn), this._charBeforeSelection);
  27525. builder.addTrackedEditOperation(new range_1.Range(this._range.endLineNumber, this._range.endColumn, this._range.endLineNumber, this._range.endColumn), this._charAfterSelection);
  27526. };
  27527. SurroundSelectionCommand.prototype.computeCursorState = function (model, helper) {
  27528. var inverseEditOperations = helper.getInverseEditOperations();
  27529. var firstOperationRange = inverseEditOperations[0].range;
  27530. var secondOperationRange = inverseEditOperations[1].range;
  27531. return new selection_1.Selection(firstOperationRange.endLineNumber, firstOperationRange.endColumn, secondOperationRange.endLineNumber, secondOperationRange.endColumn - this._charAfterSelection.length);
  27532. };
  27533. return SurroundSelectionCommand;
  27534. }());
  27535. exports.SurroundSelectionCommand = SurroundSelectionCommand;
  27536. });
  27537. /*---------------------------------------------------------------------------------------------
  27538. * Copyright (c) Microsoft Corporation. All rights reserved.
  27539. * Licensed under the MIT License. See License.txt in the project root for license information.
  27540. *--------------------------------------------------------------------------------------------*/
  27541. define(__m[106/*vs/editor/common/core/stringBuilder*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/]), function (require, exports, strings) {
  27542. "use strict";
  27543. Object.defineProperty(exports, "__esModule", { value: true });
  27544. if (typeof TextDecoder !== 'undefined') {
  27545. exports.createStringBuilder = function (capacity) { return new StringBuilder(capacity); };
  27546. }
  27547. else {
  27548. exports.createStringBuilder = function (capacity) { return new CompatStringBuilder(); };
  27549. }
  27550. var StringBuilder = /** @class */ (function () {
  27551. function StringBuilder(capacity) {
  27552. this._decoder = new TextDecoder('UTF-16LE');
  27553. this._capacity = capacity | 0;
  27554. this._buffer = new Uint16Array(this._capacity);
  27555. this._completedStrings = null;
  27556. this._bufferLength = 0;
  27557. }
  27558. StringBuilder.prototype.reset = function () {
  27559. this._completedStrings = null;
  27560. this._bufferLength = 0;
  27561. };
  27562. StringBuilder.prototype.build = function () {
  27563. if (this._completedStrings !== null) {
  27564. this._flushBuffer();
  27565. return this._completedStrings.join('');
  27566. }
  27567. return this._buildBuffer();
  27568. };
  27569. StringBuilder.prototype._buildBuffer = function () {
  27570. if (this._bufferLength === 0) {
  27571. return '';
  27572. }
  27573. var view = new Uint16Array(this._buffer.buffer, 0, this._bufferLength);
  27574. return this._decoder.decode(view);
  27575. };
  27576. StringBuilder.prototype._flushBuffer = function () {
  27577. var bufferString = this._buildBuffer();
  27578. this._bufferLength = 0;
  27579. if (this._completedStrings === null) {
  27580. this._completedStrings = [bufferString];
  27581. }
  27582. else {
  27583. this._completedStrings[this._completedStrings.length] = bufferString;
  27584. }
  27585. };
  27586. StringBuilder.prototype.write1 = function (charCode) {
  27587. var remainingSpace = this._capacity - this._bufferLength;
  27588. if (remainingSpace <= 1) {
  27589. if (remainingSpace === 0 || strings.isHighSurrogate(charCode)) {
  27590. this._flushBuffer();
  27591. }
  27592. }
  27593. this._buffer[this._bufferLength++] = charCode;
  27594. };
  27595. StringBuilder.prototype.appendASCII = function (charCode) {
  27596. if (this._bufferLength === this._capacity) {
  27597. // buffer is full
  27598. this._flushBuffer();
  27599. }
  27600. this._buffer[this._bufferLength++] = charCode;
  27601. };
  27602. StringBuilder.prototype.appendASCIIString = function (str) {
  27603. var strLen = str.length;
  27604. if (this._bufferLength + strLen >= this._capacity) {
  27605. // This string does not fit in the remaining buffer space
  27606. this._flushBuffer();
  27607. this._completedStrings[this._completedStrings.length] = str;
  27608. return;
  27609. }
  27610. for (var i = 0; i < strLen; i++) {
  27611. this._buffer[this._bufferLength++] = str.charCodeAt(i);
  27612. }
  27613. };
  27614. return StringBuilder;
  27615. }());
  27616. var CompatStringBuilder = /** @class */ (function () {
  27617. function CompatStringBuilder() {
  27618. this._pieces = [];
  27619. this._piecesLen = 0;
  27620. }
  27621. CompatStringBuilder.prototype.reset = function () {
  27622. this._pieces = [];
  27623. this._piecesLen = 0;
  27624. };
  27625. CompatStringBuilder.prototype.build = function () {
  27626. return this._pieces.join('');
  27627. };
  27628. CompatStringBuilder.prototype.write1 = function (charCode) {
  27629. this._pieces[this._piecesLen++] = String.fromCharCode(charCode);
  27630. };
  27631. CompatStringBuilder.prototype.appendASCII = function (charCode) {
  27632. this._pieces[this._piecesLen++] = String.fromCharCode(charCode);
  27633. };
  27634. CompatStringBuilder.prototype.appendASCIIString = function (str) {
  27635. this._pieces[this._piecesLen++] = str;
  27636. };
  27637. return CompatStringBuilder;
  27638. }());
  27639. });
  27640. /*---------------------------------------------------------------------------------------------
  27641. * Copyright (c) Microsoft Corporation. All rights reserved.
  27642. * Licensed under the MIT License. See License.txt in the project root for license information.
  27643. *--------------------------------------------------------------------------------------------*/
  27644. define(__m[143/*vs/editor/browser/view/viewLayer*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,106/*vs/editor/common/core/stringBuilder*/]), function (require, exports, fastDomNode_1, stringBuilder_1) {
  27645. "use strict";
  27646. Object.defineProperty(exports, "__esModule", { value: true });
  27647. var RenderedLinesCollection = /** @class */ (function () {
  27648. function RenderedLinesCollection(createLine) {
  27649. this._createLine = createLine;
  27650. this._set(1, []);
  27651. }
  27652. RenderedLinesCollection.prototype.flush = function () {
  27653. this._set(1, []);
  27654. };
  27655. RenderedLinesCollection.prototype._set = function (rendLineNumberStart, lines) {
  27656. this._lines = lines;
  27657. this._rendLineNumberStart = rendLineNumberStart;
  27658. };
  27659. RenderedLinesCollection.prototype._get = function () {
  27660. return {
  27661. rendLineNumberStart: this._rendLineNumberStart,
  27662. lines: this._lines
  27663. };
  27664. };
  27665. /**
  27666. * @returns Inclusive line number that is inside this collection
  27667. */
  27668. RenderedLinesCollection.prototype.getStartLineNumber = function () {
  27669. return this._rendLineNumberStart;
  27670. };
  27671. /**
  27672. * @returns Inclusive line number that is inside this collection
  27673. */
  27674. RenderedLinesCollection.prototype.getEndLineNumber = function () {
  27675. return this._rendLineNumberStart + this._lines.length - 1;
  27676. };
  27677. RenderedLinesCollection.prototype.getCount = function () {
  27678. return this._lines.length;
  27679. };
  27680. RenderedLinesCollection.prototype.getLine = function (lineNumber) {
  27681. var lineIndex = lineNumber - this._rendLineNumberStart;
  27682. if (lineIndex < 0 || lineIndex >= this._lines.length) {
  27683. throw new Error('Illegal value for lineNumber');
  27684. }
  27685. return this._lines[lineIndex];
  27686. };
  27687. /**
  27688. * @returns Lines that were removed from this collection
  27689. */
  27690. RenderedLinesCollection.prototype.onLinesDeleted = function (deleteFromLineNumber, deleteToLineNumber) {
  27691. if (this.getCount() === 0) {
  27692. // no lines
  27693. return null;
  27694. }
  27695. var startLineNumber = this.getStartLineNumber();
  27696. var endLineNumber = this.getEndLineNumber();
  27697. if (deleteToLineNumber < startLineNumber) {
  27698. // deleting above the viewport
  27699. var deleteCnt = deleteToLineNumber - deleteFromLineNumber + 1;
  27700. this._rendLineNumberStart -= deleteCnt;
  27701. return null;
  27702. }
  27703. if (deleteFromLineNumber > endLineNumber) {
  27704. // deleted below the viewport
  27705. return null;
  27706. }
  27707. // Record what needs to be deleted
  27708. var deleteStartIndex = 0;
  27709. var deleteCount = 0;
  27710. for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
  27711. var lineIndex = lineNumber - this._rendLineNumberStart;
  27712. if (deleteFromLineNumber <= lineNumber && lineNumber <= deleteToLineNumber) {
  27713. // this is a line to be deleted
  27714. if (deleteCount === 0) {
  27715. // this is the first line to be deleted
  27716. deleteStartIndex = lineIndex;
  27717. deleteCount = 1;
  27718. }
  27719. else {
  27720. deleteCount++;
  27721. }
  27722. }
  27723. }
  27724. // Adjust this._rendLineNumberStart for lines deleted above
  27725. if (deleteFromLineNumber < startLineNumber) {
  27726. // Something was deleted above
  27727. var deleteAboveCount = 0;
  27728. if (deleteToLineNumber < startLineNumber) {
  27729. // the entire deleted lines are above
  27730. deleteAboveCount = deleteToLineNumber - deleteFromLineNumber + 1;
  27731. }
  27732. else {
  27733. deleteAboveCount = startLineNumber - deleteFromLineNumber;
  27734. }
  27735. this._rendLineNumberStart -= deleteAboveCount;
  27736. }
  27737. var deleted = this._lines.splice(deleteStartIndex, deleteCount);
  27738. return deleted;
  27739. };
  27740. RenderedLinesCollection.prototype.onLinesChanged = function (changeFromLineNumber, changeToLineNumber) {
  27741. if (this.getCount() === 0) {
  27742. // no lines
  27743. return false;
  27744. }
  27745. var startLineNumber = this.getStartLineNumber();
  27746. var endLineNumber = this.getEndLineNumber();
  27747. var someoneNotified = false;
  27748. for (var changedLineNumber = changeFromLineNumber; changedLineNumber <= changeToLineNumber; changedLineNumber++) {
  27749. if (changedLineNumber >= startLineNumber && changedLineNumber <= endLineNumber) {
  27750. // Notify the line
  27751. this._lines[changedLineNumber - this._rendLineNumberStart].onContentChanged();
  27752. someoneNotified = true;
  27753. }
  27754. }
  27755. return someoneNotified;
  27756. };
  27757. RenderedLinesCollection.prototype.onLinesInserted = function (insertFromLineNumber, insertToLineNumber) {
  27758. if (this.getCount() === 0) {
  27759. // no lines
  27760. return null;
  27761. }
  27762. var insertCnt = insertToLineNumber - insertFromLineNumber + 1;
  27763. var startLineNumber = this.getStartLineNumber();
  27764. var endLineNumber = this.getEndLineNumber();
  27765. if (insertFromLineNumber <= startLineNumber) {
  27766. // inserting above the viewport
  27767. this._rendLineNumberStart += insertCnt;
  27768. return null;
  27769. }
  27770. if (insertFromLineNumber > endLineNumber) {
  27771. // inserting below the viewport
  27772. return null;
  27773. }
  27774. if (insertCnt + insertFromLineNumber > endLineNumber) {
  27775. // insert inside the viewport in such a way that all remaining lines are pushed outside
  27776. var deleted = this._lines.splice(insertFromLineNumber - this._rendLineNumberStart, endLineNumber - insertFromLineNumber + 1);
  27777. return deleted;
  27778. }
  27779. // insert inside the viewport, push out some lines, but not all remaining lines
  27780. var newLines = [];
  27781. for (var i = 0; i < insertCnt; i++) {
  27782. newLines[i] = this._createLine();
  27783. }
  27784. var insertIndex = insertFromLineNumber - this._rendLineNumberStart;
  27785. var beforeLines = this._lines.slice(0, insertIndex);
  27786. var afterLines = this._lines.slice(insertIndex, this._lines.length - insertCnt);
  27787. var deletedLines = this._lines.slice(this._lines.length - insertCnt, this._lines.length);
  27788. this._lines = beforeLines.concat(newLines).concat(afterLines);
  27789. return deletedLines;
  27790. };
  27791. RenderedLinesCollection.prototype.onTokensChanged = function (ranges) {
  27792. if (this.getCount() === 0) {
  27793. // no lines
  27794. return false;
  27795. }
  27796. var startLineNumber = this.getStartLineNumber();
  27797. var endLineNumber = this.getEndLineNumber();
  27798. var notifiedSomeone = false;
  27799. for (var i = 0, len = ranges.length; i < len; i++) {
  27800. var rng = ranges[i];
  27801. if (rng.toLineNumber < startLineNumber || rng.fromLineNumber > endLineNumber) {
  27802. // range outside viewport
  27803. continue;
  27804. }
  27805. var from = Math.max(startLineNumber, rng.fromLineNumber);
  27806. var to = Math.min(endLineNumber, rng.toLineNumber);
  27807. for (var lineNumber = from; lineNumber <= to; lineNumber++) {
  27808. var lineIndex = lineNumber - this._rendLineNumberStart;
  27809. this._lines[lineIndex].onTokensChanged();
  27810. notifiedSomeone = true;
  27811. }
  27812. }
  27813. return notifiedSomeone;
  27814. };
  27815. return RenderedLinesCollection;
  27816. }());
  27817. exports.RenderedLinesCollection = RenderedLinesCollection;
  27818. var VisibleLinesCollection = /** @class */ (function () {
  27819. function VisibleLinesCollection(host) {
  27820. var _this = this;
  27821. this._host = host;
  27822. this.domNode = this._createDomNode();
  27823. this._linesCollection = new RenderedLinesCollection(function () { return _this._host.createVisibleLine(); });
  27824. }
  27825. VisibleLinesCollection.prototype._createDomNode = function () {
  27826. var domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  27827. domNode.setClassName('view-layer');
  27828. domNode.setPosition('absolute');
  27829. domNode.domNode.setAttribute('role', 'presentation');
  27830. domNode.domNode.setAttribute('aria-hidden', 'true');
  27831. return domNode;
  27832. };
  27833. // ---- begin view event handlers
  27834. VisibleLinesCollection.prototype.onConfigurationChanged = function (e) {
  27835. if (e.hasChanged(107 /* layoutInfo */)) {
  27836. return true;
  27837. }
  27838. return false;
  27839. };
  27840. VisibleLinesCollection.prototype.onFlushed = function (e) {
  27841. this._linesCollection.flush();
  27842. // No need to clear the dom node because a full .innerHTML will occur in ViewLayerRenderer._render
  27843. return true;
  27844. };
  27845. VisibleLinesCollection.prototype.onLinesChanged = function (e) {
  27846. return this._linesCollection.onLinesChanged(e.fromLineNumber, e.toLineNumber);
  27847. };
  27848. VisibleLinesCollection.prototype.onLinesDeleted = function (e) {
  27849. var deleted = this._linesCollection.onLinesDeleted(e.fromLineNumber, e.toLineNumber);
  27850. if (deleted) {
  27851. // Remove from DOM
  27852. for (var i = 0, len = deleted.length; i < len; i++) {
  27853. var lineDomNode = deleted[i].getDomNode();
  27854. if (lineDomNode) {
  27855. this.domNode.domNode.removeChild(lineDomNode);
  27856. }
  27857. }
  27858. }
  27859. return true;
  27860. };
  27861. VisibleLinesCollection.prototype.onLinesInserted = function (e) {
  27862. var deleted = this._linesCollection.onLinesInserted(e.fromLineNumber, e.toLineNumber);
  27863. if (deleted) {
  27864. // Remove from DOM
  27865. for (var i = 0, len = deleted.length; i < len; i++) {
  27866. var lineDomNode = deleted[i].getDomNode();
  27867. if (lineDomNode) {
  27868. this.domNode.domNode.removeChild(lineDomNode);
  27869. }
  27870. }
  27871. }
  27872. return true;
  27873. };
  27874. VisibleLinesCollection.prototype.onScrollChanged = function (e) {
  27875. return e.scrollTopChanged;
  27876. };
  27877. VisibleLinesCollection.prototype.onTokensChanged = function (e) {
  27878. return this._linesCollection.onTokensChanged(e.ranges);
  27879. };
  27880. VisibleLinesCollection.prototype.onZonesChanged = function (e) {
  27881. return true;
  27882. };
  27883. // ---- end view event handlers
  27884. VisibleLinesCollection.prototype.getStartLineNumber = function () {
  27885. return this._linesCollection.getStartLineNumber();
  27886. };
  27887. VisibleLinesCollection.prototype.getEndLineNumber = function () {
  27888. return this._linesCollection.getEndLineNumber();
  27889. };
  27890. VisibleLinesCollection.prototype.getVisibleLine = function (lineNumber) {
  27891. return this._linesCollection.getLine(lineNumber);
  27892. };
  27893. VisibleLinesCollection.prototype.renderLines = function (viewportData) {
  27894. var inp = this._linesCollection._get();
  27895. var renderer = new ViewLayerRenderer(this.domNode.domNode, this._host, viewportData);
  27896. var ctx = {
  27897. rendLineNumberStart: inp.rendLineNumberStart,
  27898. lines: inp.lines,
  27899. linesLength: inp.lines.length
  27900. };
  27901. // Decide if this render will do a single update (single large .innerHTML) or many updates (inserting/removing dom nodes)
  27902. var resCtx = renderer.render(ctx, viewportData.startLineNumber, viewportData.endLineNumber, viewportData.relativeVerticalOffset);
  27903. this._linesCollection._set(resCtx.rendLineNumberStart, resCtx.lines);
  27904. };
  27905. return VisibleLinesCollection;
  27906. }());
  27907. exports.VisibleLinesCollection = VisibleLinesCollection;
  27908. var ViewLayerRenderer = /** @class */ (function () {
  27909. function ViewLayerRenderer(domNode, host, viewportData) {
  27910. this.domNode = domNode;
  27911. this.host = host;
  27912. this.viewportData = viewportData;
  27913. }
  27914. ViewLayerRenderer.prototype.render = function (inContext, startLineNumber, stopLineNumber, deltaTop) {
  27915. var ctx = {
  27916. rendLineNumberStart: inContext.rendLineNumberStart,
  27917. lines: inContext.lines.slice(0),
  27918. linesLength: inContext.linesLength
  27919. };
  27920. if ((ctx.rendLineNumberStart + ctx.linesLength - 1 < startLineNumber) || (stopLineNumber < ctx.rendLineNumberStart)) {
  27921. // There is no overlap whatsoever
  27922. ctx.rendLineNumberStart = startLineNumber;
  27923. ctx.linesLength = stopLineNumber - startLineNumber + 1;
  27924. ctx.lines = [];
  27925. for (var x = startLineNumber; x <= stopLineNumber; x++) {
  27926. ctx.lines[x - startLineNumber] = this.host.createVisibleLine();
  27927. }
  27928. this._finishRendering(ctx, true, deltaTop);
  27929. return ctx;
  27930. }
  27931. // Update lines which will remain untouched
  27932. this._renderUntouchedLines(ctx, Math.max(startLineNumber - ctx.rendLineNumberStart, 0), Math.min(stopLineNumber - ctx.rendLineNumberStart, ctx.linesLength - 1), deltaTop, startLineNumber);
  27933. if (ctx.rendLineNumberStart > startLineNumber) {
  27934. // Insert lines before
  27935. var fromLineNumber = startLineNumber;
  27936. var toLineNumber = Math.min(stopLineNumber, ctx.rendLineNumberStart - 1);
  27937. if (fromLineNumber <= toLineNumber) {
  27938. this._insertLinesBefore(ctx, fromLineNumber, toLineNumber, deltaTop, startLineNumber);
  27939. ctx.linesLength += toLineNumber - fromLineNumber + 1;
  27940. }
  27941. }
  27942. else if (ctx.rendLineNumberStart < startLineNumber) {
  27943. // Remove lines before
  27944. var removeCnt = Math.min(ctx.linesLength, startLineNumber - ctx.rendLineNumberStart);
  27945. if (removeCnt > 0) {
  27946. this._removeLinesBefore(ctx, removeCnt);
  27947. ctx.linesLength -= removeCnt;
  27948. }
  27949. }
  27950. ctx.rendLineNumberStart = startLineNumber;
  27951. if (ctx.rendLineNumberStart + ctx.linesLength - 1 < stopLineNumber) {
  27952. // Insert lines after
  27953. var fromLineNumber = ctx.rendLineNumberStart + ctx.linesLength;
  27954. var toLineNumber = stopLineNumber;
  27955. if (fromLineNumber <= toLineNumber) {
  27956. this._insertLinesAfter(ctx, fromLineNumber, toLineNumber, deltaTop, startLineNumber);
  27957. ctx.linesLength += toLineNumber - fromLineNumber + 1;
  27958. }
  27959. }
  27960. else if (ctx.rendLineNumberStart + ctx.linesLength - 1 > stopLineNumber) {
  27961. // Remove lines after
  27962. var fromLineNumber = Math.max(0, stopLineNumber - ctx.rendLineNumberStart + 1);
  27963. var toLineNumber = ctx.linesLength - 1;
  27964. var removeCnt = toLineNumber - fromLineNumber + 1;
  27965. if (removeCnt > 0) {
  27966. this._removeLinesAfter(ctx, removeCnt);
  27967. ctx.linesLength -= removeCnt;
  27968. }
  27969. }
  27970. this._finishRendering(ctx, false, deltaTop);
  27971. return ctx;
  27972. };
  27973. ViewLayerRenderer.prototype._renderUntouchedLines = function (ctx, startIndex, endIndex, deltaTop, deltaLN) {
  27974. var rendLineNumberStart = ctx.rendLineNumberStart;
  27975. var lines = ctx.lines;
  27976. for (var i = startIndex; i <= endIndex; i++) {
  27977. var lineNumber = rendLineNumberStart + i;
  27978. lines[i].layoutLine(lineNumber, deltaTop[lineNumber - deltaLN]);
  27979. }
  27980. };
  27981. ViewLayerRenderer.prototype._insertLinesBefore = function (ctx, fromLineNumber, toLineNumber, deltaTop, deltaLN) {
  27982. var newLines = [];
  27983. var newLinesLen = 0;
  27984. for (var lineNumber = fromLineNumber; lineNumber <= toLineNumber; lineNumber++) {
  27985. newLines[newLinesLen++] = this.host.createVisibleLine();
  27986. }
  27987. ctx.lines = newLines.concat(ctx.lines);
  27988. };
  27989. ViewLayerRenderer.prototype._removeLinesBefore = function (ctx, removeCount) {
  27990. for (var i = 0; i < removeCount; i++) {
  27991. var lineDomNode = ctx.lines[i].getDomNode();
  27992. if (lineDomNode) {
  27993. this.domNode.removeChild(lineDomNode);
  27994. }
  27995. }
  27996. ctx.lines.splice(0, removeCount);
  27997. };
  27998. ViewLayerRenderer.prototype._insertLinesAfter = function (ctx, fromLineNumber, toLineNumber, deltaTop, deltaLN) {
  27999. var newLines = [];
  28000. var newLinesLen = 0;
  28001. for (var lineNumber = fromLineNumber; lineNumber <= toLineNumber; lineNumber++) {
  28002. newLines[newLinesLen++] = this.host.createVisibleLine();
  28003. }
  28004. ctx.lines = ctx.lines.concat(newLines);
  28005. };
  28006. ViewLayerRenderer.prototype._removeLinesAfter = function (ctx, removeCount) {
  28007. var removeIndex = ctx.linesLength - removeCount;
  28008. for (var i = 0; i < removeCount; i++) {
  28009. var lineDomNode = ctx.lines[removeIndex + i].getDomNode();
  28010. if (lineDomNode) {
  28011. this.domNode.removeChild(lineDomNode);
  28012. }
  28013. }
  28014. ctx.lines.splice(removeIndex, removeCount);
  28015. };
  28016. ViewLayerRenderer.prototype._finishRenderingNewLines = function (ctx, domNodeIsEmpty, newLinesHTML, wasNew) {
  28017. var lastChild = this.domNode.lastChild;
  28018. if (domNodeIsEmpty || !lastChild) {
  28019. this.domNode.innerHTML = newLinesHTML;
  28020. }
  28021. else {
  28022. lastChild.insertAdjacentHTML('afterend', newLinesHTML);
  28023. }
  28024. var currChild = this.domNode.lastChild;
  28025. for (var i = ctx.linesLength - 1; i >= 0; i--) {
  28026. var line = ctx.lines[i];
  28027. if (wasNew[i]) {
  28028. line.setDomNode(currChild);
  28029. currChild = currChild.previousSibling;
  28030. }
  28031. }
  28032. };
  28033. ViewLayerRenderer.prototype._finishRenderingInvalidLines = function (ctx, invalidLinesHTML, wasInvalid) {
  28034. var hugeDomNode = document.createElement('div');
  28035. hugeDomNode.innerHTML = invalidLinesHTML;
  28036. for (var i = 0; i < ctx.linesLength; i++) {
  28037. var line = ctx.lines[i];
  28038. if (wasInvalid[i]) {
  28039. var source = hugeDomNode.firstChild;
  28040. var lineDomNode = line.getDomNode();
  28041. lineDomNode.parentNode.replaceChild(source, lineDomNode);
  28042. line.setDomNode(source);
  28043. }
  28044. }
  28045. };
  28046. ViewLayerRenderer.prototype._finishRendering = function (ctx, domNodeIsEmpty, deltaTop) {
  28047. var sb = ViewLayerRenderer._sb;
  28048. var linesLength = ctx.linesLength;
  28049. var lines = ctx.lines;
  28050. var rendLineNumberStart = ctx.rendLineNumberStart;
  28051. var wasNew = [];
  28052. {
  28053. sb.reset();
  28054. var hadNewLine = false;
  28055. for (var i = 0; i < linesLength; i++) {
  28056. var line = lines[i];
  28057. wasNew[i] = false;
  28058. var lineDomNode = line.getDomNode();
  28059. if (lineDomNode) {
  28060. // line is not new
  28061. continue;
  28062. }
  28063. var renderResult = line.renderLine(i + rendLineNumberStart, deltaTop[i], this.viewportData, sb);
  28064. if (!renderResult) {
  28065. // line does not need rendering
  28066. continue;
  28067. }
  28068. wasNew[i] = true;
  28069. hadNewLine = true;
  28070. }
  28071. if (hadNewLine) {
  28072. this._finishRenderingNewLines(ctx, domNodeIsEmpty, sb.build(), wasNew);
  28073. }
  28074. }
  28075. {
  28076. sb.reset();
  28077. var hadInvalidLine = false;
  28078. var wasInvalid = [];
  28079. for (var i = 0; i < linesLength; i++) {
  28080. var line = lines[i];
  28081. wasInvalid[i] = false;
  28082. if (wasNew[i]) {
  28083. // line was new
  28084. continue;
  28085. }
  28086. var renderResult = line.renderLine(i + rendLineNumberStart, deltaTop[i], this.viewportData, sb);
  28087. if (!renderResult) {
  28088. // line does not need rendering
  28089. continue;
  28090. }
  28091. wasInvalid[i] = true;
  28092. hadInvalidLine = true;
  28093. }
  28094. if (hadInvalidLine) {
  28095. this._finishRenderingInvalidLines(ctx, sb.build(), wasInvalid);
  28096. }
  28097. }
  28098. };
  28099. ViewLayerRenderer._sb = stringBuilder_1.createStringBuilder(100000);
  28100. return ViewLayerRenderer;
  28101. }());
  28102. });
  28103. /*---------------------------------------------------------------------------------------------
  28104. * Copyright (c) Microsoft Corporation. All rights reserved.
  28105. * Licensed under the MIT License. See License.txt in the project root for license information.
  28106. *--------------------------------------------------------------------------------------------*/
  28107. define(__m[107/*vs/editor/common/core/token*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  28108. "use strict";
  28109. Object.defineProperty(exports, "__esModule", { value: true });
  28110. var Token = /** @class */ (function () {
  28111. function Token(offset, type, language) {
  28112. this.offset = offset | 0; // @perf
  28113. this.type = type;
  28114. this.language = language;
  28115. }
  28116. Token.prototype.toString = function () {
  28117. return '(' + this.offset + ', ' + this.type + ')';
  28118. };
  28119. return Token;
  28120. }());
  28121. exports.Token = Token;
  28122. var TokenizationResult = /** @class */ (function () {
  28123. function TokenizationResult(tokens, endState) {
  28124. this.tokens = tokens;
  28125. this.endState = endState;
  28126. }
  28127. return TokenizationResult;
  28128. }());
  28129. exports.TokenizationResult = TokenizationResult;
  28130. var TokenizationResult2 = /** @class */ (function () {
  28131. function TokenizationResult2(tokens, endState) {
  28132. this.tokens = tokens;
  28133. this.endState = endState;
  28134. }
  28135. return TokenizationResult2;
  28136. }());
  28137. exports.TokenizationResult2 = TokenizationResult2;
  28138. });
  28139. /*---------------------------------------------------------------------------------------------
  28140. * Copyright (c) Microsoft Corporation. All rights reserved.
  28141. * Licensed under the MIT License. See License.txt in the project root for license information.
  28142. *--------------------------------------------------------------------------------------------*/
  28143. define(__m[341/*vs/editor/common/diff/diffComputer*/], __M([0/*require*/,1/*exports*/,126/*vs/base/common/diff/diff*/,5/*vs/base/common/strings*/]), function (require, exports, diff_1, strings) {
  28144. "use strict";
  28145. Object.defineProperty(exports, "__esModule", { value: true });
  28146. var MINIMUM_MATCHING_CHARACTER_LENGTH = 3;
  28147. function computeDiff(originalSequence, modifiedSequence, continueProcessingPredicate, pretty) {
  28148. var diffAlgo = new diff_1.LcsDiff(originalSequence, modifiedSequence, continueProcessingPredicate);
  28149. return diffAlgo.ComputeDiff(pretty);
  28150. }
  28151. var LineSequence = /** @class */ (function () {
  28152. function LineSequence(lines) {
  28153. var startColumns = [];
  28154. var endColumns = [];
  28155. for (var i = 0, length_1 = lines.length; i < length_1; i++) {
  28156. startColumns[i] = getFirstNonBlankColumn(lines[i], 1);
  28157. endColumns[i] = getLastNonBlankColumn(lines[i], 1);
  28158. }
  28159. this.lines = lines;
  28160. this._startColumns = startColumns;
  28161. this._endColumns = endColumns;
  28162. }
  28163. LineSequence.prototype.getElements = function () {
  28164. var elements = [];
  28165. for (var i = 0, len = this.lines.length; i < len; i++) {
  28166. elements[i] = this.lines[i].substring(this._startColumns[i] - 1, this._endColumns[i] - 1);
  28167. }
  28168. return elements;
  28169. };
  28170. LineSequence.prototype.getStartLineNumber = function (i) {
  28171. return i + 1;
  28172. };
  28173. LineSequence.prototype.getEndLineNumber = function (i) {
  28174. return i + 1;
  28175. };
  28176. LineSequence.prototype.createCharSequence = function (shouldIgnoreTrimWhitespace, startIndex, endIndex) {
  28177. var charCodes = [];
  28178. var lineNumbers = [];
  28179. var columns = [];
  28180. var len = 0;
  28181. for (var index = startIndex; index <= endIndex; index++) {
  28182. var lineContent = this.lines[index];
  28183. var startColumn = (shouldIgnoreTrimWhitespace ? this._startColumns[index] : 1);
  28184. var endColumn = (shouldIgnoreTrimWhitespace ? this._endColumns[index] : lineContent.length + 1);
  28185. for (var col = startColumn; col < endColumn; col++) {
  28186. charCodes[len] = lineContent.charCodeAt(col - 1);
  28187. lineNumbers[len] = index + 1;
  28188. columns[len] = col;
  28189. len++;
  28190. }
  28191. }
  28192. return new CharSequence(charCodes, lineNumbers, columns);
  28193. };
  28194. return LineSequence;
  28195. }());
  28196. var CharSequence = /** @class */ (function () {
  28197. function CharSequence(charCodes, lineNumbers, columns) {
  28198. this._charCodes = charCodes;
  28199. this._lineNumbers = lineNumbers;
  28200. this._columns = columns;
  28201. }
  28202. CharSequence.prototype.getElements = function () {
  28203. return this._charCodes;
  28204. };
  28205. CharSequence.prototype.getStartLineNumber = function (i) {
  28206. return this._lineNumbers[i];
  28207. };
  28208. CharSequence.prototype.getStartColumn = function (i) {
  28209. return this._columns[i];
  28210. };
  28211. CharSequence.prototype.getEndLineNumber = function (i) {
  28212. return this._lineNumbers[i];
  28213. };
  28214. CharSequence.prototype.getEndColumn = function (i) {
  28215. return this._columns[i] + 1;
  28216. };
  28217. return CharSequence;
  28218. }());
  28219. var CharChange = /** @class */ (function () {
  28220. function CharChange(originalStartLineNumber, originalStartColumn, originalEndLineNumber, originalEndColumn, modifiedStartLineNumber, modifiedStartColumn, modifiedEndLineNumber, modifiedEndColumn) {
  28221. this.originalStartLineNumber = originalStartLineNumber;
  28222. this.originalStartColumn = originalStartColumn;
  28223. this.originalEndLineNumber = originalEndLineNumber;
  28224. this.originalEndColumn = originalEndColumn;
  28225. this.modifiedStartLineNumber = modifiedStartLineNumber;
  28226. this.modifiedStartColumn = modifiedStartColumn;
  28227. this.modifiedEndLineNumber = modifiedEndLineNumber;
  28228. this.modifiedEndColumn = modifiedEndColumn;
  28229. }
  28230. CharChange.createFromDiffChange = function (diffChange, originalCharSequence, modifiedCharSequence) {
  28231. var originalStartLineNumber;
  28232. var originalStartColumn;
  28233. var originalEndLineNumber;
  28234. var originalEndColumn;
  28235. var modifiedStartLineNumber;
  28236. var modifiedStartColumn;
  28237. var modifiedEndLineNumber;
  28238. var modifiedEndColumn;
  28239. if (diffChange.originalLength === 0) {
  28240. originalStartLineNumber = 0;
  28241. originalStartColumn = 0;
  28242. originalEndLineNumber = 0;
  28243. originalEndColumn = 0;
  28244. }
  28245. else {
  28246. originalStartLineNumber = originalCharSequence.getStartLineNumber(diffChange.originalStart);
  28247. originalStartColumn = originalCharSequence.getStartColumn(diffChange.originalStart);
  28248. originalEndLineNumber = originalCharSequence.getEndLineNumber(diffChange.originalStart + diffChange.originalLength - 1);
  28249. originalEndColumn = originalCharSequence.getEndColumn(diffChange.originalStart + diffChange.originalLength - 1);
  28250. }
  28251. if (diffChange.modifiedLength === 0) {
  28252. modifiedStartLineNumber = 0;
  28253. modifiedStartColumn = 0;
  28254. modifiedEndLineNumber = 0;
  28255. modifiedEndColumn = 0;
  28256. }
  28257. else {
  28258. modifiedStartLineNumber = modifiedCharSequence.getStartLineNumber(diffChange.modifiedStart);
  28259. modifiedStartColumn = modifiedCharSequence.getStartColumn(diffChange.modifiedStart);
  28260. modifiedEndLineNumber = modifiedCharSequence.getEndLineNumber(diffChange.modifiedStart + diffChange.modifiedLength - 1);
  28261. modifiedEndColumn = modifiedCharSequence.getEndColumn(diffChange.modifiedStart + diffChange.modifiedLength - 1);
  28262. }
  28263. return new CharChange(originalStartLineNumber, originalStartColumn, originalEndLineNumber, originalEndColumn, modifiedStartLineNumber, modifiedStartColumn, modifiedEndLineNumber, modifiedEndColumn);
  28264. };
  28265. return CharChange;
  28266. }());
  28267. function postProcessCharChanges(rawChanges) {
  28268. if (rawChanges.length <= 1) {
  28269. return rawChanges;
  28270. }
  28271. var result = [rawChanges[0]];
  28272. var prevChange = result[0];
  28273. for (var i = 1, len = rawChanges.length; i < len; i++) {
  28274. var currChange = rawChanges[i];
  28275. var originalMatchingLength = currChange.originalStart - (prevChange.originalStart + prevChange.originalLength);
  28276. var modifiedMatchingLength = currChange.modifiedStart - (prevChange.modifiedStart + prevChange.modifiedLength);
  28277. // Both of the above should be equal, but the continueProcessingPredicate may prevent this from being true
  28278. var matchingLength = Math.min(originalMatchingLength, modifiedMatchingLength);
  28279. if (matchingLength < MINIMUM_MATCHING_CHARACTER_LENGTH) {
  28280. // Merge the current change into the previous one
  28281. prevChange.originalLength = (currChange.originalStart + currChange.originalLength) - prevChange.originalStart;
  28282. prevChange.modifiedLength = (currChange.modifiedStart + currChange.modifiedLength) - prevChange.modifiedStart;
  28283. }
  28284. else {
  28285. // Add the current change
  28286. result.push(currChange);
  28287. prevChange = currChange;
  28288. }
  28289. }
  28290. return result;
  28291. }
  28292. var LineChange = /** @class */ (function () {
  28293. function LineChange(originalStartLineNumber, originalEndLineNumber, modifiedStartLineNumber, modifiedEndLineNumber, charChanges) {
  28294. this.originalStartLineNumber = originalStartLineNumber;
  28295. this.originalEndLineNumber = originalEndLineNumber;
  28296. this.modifiedStartLineNumber = modifiedStartLineNumber;
  28297. this.modifiedEndLineNumber = modifiedEndLineNumber;
  28298. this.charChanges = charChanges;
  28299. }
  28300. LineChange.createFromDiffResult = function (shouldIgnoreTrimWhitespace, diffChange, originalLineSequence, modifiedLineSequence, continueCharDiff, shouldComputeCharChanges, shouldPostProcessCharChanges) {
  28301. var originalStartLineNumber;
  28302. var originalEndLineNumber;
  28303. var modifiedStartLineNumber;
  28304. var modifiedEndLineNumber;
  28305. var charChanges = undefined;
  28306. if (diffChange.originalLength === 0) {
  28307. originalStartLineNumber = originalLineSequence.getStartLineNumber(diffChange.originalStart) - 1;
  28308. originalEndLineNumber = 0;
  28309. }
  28310. else {
  28311. originalStartLineNumber = originalLineSequence.getStartLineNumber(diffChange.originalStart);
  28312. originalEndLineNumber = originalLineSequence.getEndLineNumber(diffChange.originalStart + diffChange.originalLength - 1);
  28313. }
  28314. if (diffChange.modifiedLength === 0) {
  28315. modifiedStartLineNumber = modifiedLineSequence.getStartLineNumber(diffChange.modifiedStart) - 1;
  28316. modifiedEndLineNumber = 0;
  28317. }
  28318. else {
  28319. modifiedStartLineNumber = modifiedLineSequence.getStartLineNumber(diffChange.modifiedStart);
  28320. modifiedEndLineNumber = modifiedLineSequence.getEndLineNumber(diffChange.modifiedStart + diffChange.modifiedLength - 1);
  28321. }
  28322. if (shouldComputeCharChanges && diffChange.originalLength > 0 && diffChange.originalLength < 20 && diffChange.modifiedLength > 0 && diffChange.modifiedLength < 20 && continueCharDiff()) {
  28323. // Compute character changes for diff chunks of at most 20 lines...
  28324. var originalCharSequence = originalLineSequence.createCharSequence(shouldIgnoreTrimWhitespace, diffChange.originalStart, diffChange.originalStart + diffChange.originalLength - 1);
  28325. var modifiedCharSequence = modifiedLineSequence.createCharSequence(shouldIgnoreTrimWhitespace, diffChange.modifiedStart, diffChange.modifiedStart + diffChange.modifiedLength - 1);
  28326. var rawChanges = computeDiff(originalCharSequence, modifiedCharSequence, continueCharDiff, true).changes;
  28327. if (shouldPostProcessCharChanges) {
  28328. rawChanges = postProcessCharChanges(rawChanges);
  28329. }
  28330. charChanges = [];
  28331. for (var i = 0, length_2 = rawChanges.length; i < length_2; i++) {
  28332. charChanges.push(CharChange.createFromDiffChange(rawChanges[i], originalCharSequence, modifiedCharSequence));
  28333. }
  28334. }
  28335. return new LineChange(originalStartLineNumber, originalEndLineNumber, modifiedStartLineNumber, modifiedEndLineNumber, charChanges);
  28336. };
  28337. return LineChange;
  28338. }());
  28339. var DiffComputer = /** @class */ (function () {
  28340. function DiffComputer(originalLines, modifiedLines, opts) {
  28341. this.shouldComputeCharChanges = opts.shouldComputeCharChanges;
  28342. this.shouldPostProcessCharChanges = opts.shouldPostProcessCharChanges;
  28343. this.shouldIgnoreTrimWhitespace = opts.shouldIgnoreTrimWhitespace;
  28344. this.shouldMakePrettyDiff = opts.shouldMakePrettyDiff;
  28345. this.originalLines = originalLines;
  28346. this.modifiedLines = modifiedLines;
  28347. this.original = new LineSequence(originalLines);
  28348. this.modified = new LineSequence(modifiedLines);
  28349. this.continueLineDiff = createContinueProcessingPredicate(opts.maxComputationTime);
  28350. this.continueCharDiff = createContinueProcessingPredicate(opts.maxComputationTime === 0 ? 0 : Math.min(opts.maxComputationTime, 5000)); // never run after 5s for character changes...
  28351. }
  28352. DiffComputer.prototype.computeDiff = function () {
  28353. if (this.original.lines.length === 1 && this.original.lines[0].length === 0) {
  28354. // empty original => fast path
  28355. return {
  28356. quitEarly: false,
  28357. changes: [{
  28358. originalStartLineNumber: 1,
  28359. originalEndLineNumber: 1,
  28360. modifiedStartLineNumber: 1,
  28361. modifiedEndLineNumber: this.modified.lines.length,
  28362. charChanges: [{
  28363. modifiedEndColumn: 0,
  28364. modifiedEndLineNumber: 0,
  28365. modifiedStartColumn: 0,
  28366. modifiedStartLineNumber: 0,
  28367. originalEndColumn: 0,
  28368. originalEndLineNumber: 0,
  28369. originalStartColumn: 0,
  28370. originalStartLineNumber: 0
  28371. }]
  28372. }]
  28373. };
  28374. }
  28375. if (this.modified.lines.length === 1 && this.modified.lines[0].length === 0) {
  28376. // empty modified => fast path
  28377. return {
  28378. quitEarly: false,
  28379. changes: [{
  28380. originalStartLineNumber: 1,
  28381. originalEndLineNumber: this.original.lines.length,
  28382. modifiedStartLineNumber: 1,
  28383. modifiedEndLineNumber: 1,
  28384. charChanges: [{
  28385. modifiedEndColumn: 0,
  28386. modifiedEndLineNumber: 0,
  28387. modifiedStartColumn: 0,
  28388. modifiedStartLineNumber: 0,
  28389. originalEndColumn: 0,
  28390. originalEndLineNumber: 0,
  28391. originalStartColumn: 0,
  28392. originalStartLineNumber: 0
  28393. }]
  28394. }]
  28395. };
  28396. }
  28397. var diffResult = computeDiff(this.original, this.modified, this.continueLineDiff, this.shouldMakePrettyDiff);
  28398. var rawChanges = diffResult.changes;
  28399. var quitEarly = diffResult.quitEarly;
  28400. // The diff is always computed with ignoring trim whitespace
  28401. // This ensures we get the prettiest diff
  28402. if (this.shouldIgnoreTrimWhitespace) {
  28403. var lineChanges = [];
  28404. for (var i = 0, length_3 = rawChanges.length; i < length_3; i++) {
  28405. lineChanges.push(LineChange.createFromDiffResult(this.shouldIgnoreTrimWhitespace, rawChanges[i], this.original, this.modified, this.continueCharDiff, this.shouldComputeCharChanges, this.shouldPostProcessCharChanges));
  28406. }
  28407. return {
  28408. quitEarly: quitEarly,
  28409. changes: lineChanges
  28410. };
  28411. }
  28412. // Need to post-process and introduce changes where the trim whitespace is different
  28413. // Note that we are looping starting at -1 to also cover the lines before the first change
  28414. var result = [];
  28415. var originalLineIndex = 0;
  28416. var modifiedLineIndex = 0;
  28417. for (var i = -1 /* !!!! */, len = rawChanges.length; i < len; i++) {
  28418. var nextChange = (i + 1 < len ? rawChanges[i + 1] : null);
  28419. var originalStop = (nextChange ? nextChange.originalStart : this.originalLines.length);
  28420. var modifiedStop = (nextChange ? nextChange.modifiedStart : this.modifiedLines.length);
  28421. while (originalLineIndex < originalStop && modifiedLineIndex < modifiedStop) {
  28422. var originalLine = this.originalLines[originalLineIndex];
  28423. var modifiedLine = this.modifiedLines[modifiedLineIndex];
  28424. if (originalLine !== modifiedLine) {
  28425. // These lines differ only in trim whitespace
  28426. // Check the leading whitespace
  28427. {
  28428. var originalStartColumn = getFirstNonBlankColumn(originalLine, 1);
  28429. var modifiedStartColumn = getFirstNonBlankColumn(modifiedLine, 1);
  28430. while (originalStartColumn > 1 && modifiedStartColumn > 1) {
  28431. var originalChar = originalLine.charCodeAt(originalStartColumn - 2);
  28432. var modifiedChar = modifiedLine.charCodeAt(modifiedStartColumn - 2);
  28433. if (originalChar !== modifiedChar) {
  28434. break;
  28435. }
  28436. originalStartColumn--;
  28437. modifiedStartColumn--;
  28438. }
  28439. if (originalStartColumn > 1 || modifiedStartColumn > 1) {
  28440. this._pushTrimWhitespaceCharChange(result, originalLineIndex + 1, 1, originalStartColumn, modifiedLineIndex + 1, 1, modifiedStartColumn);
  28441. }
  28442. }
  28443. // Check the trailing whitespace
  28444. {
  28445. var originalEndColumn = getLastNonBlankColumn(originalLine, 1);
  28446. var modifiedEndColumn = getLastNonBlankColumn(modifiedLine, 1);
  28447. var originalMaxColumn = originalLine.length + 1;
  28448. var modifiedMaxColumn = modifiedLine.length + 1;
  28449. while (originalEndColumn < originalMaxColumn && modifiedEndColumn < modifiedMaxColumn) {
  28450. var originalChar = originalLine.charCodeAt(originalEndColumn - 1);
  28451. var modifiedChar = originalLine.charCodeAt(modifiedEndColumn - 1);
  28452. if (originalChar !== modifiedChar) {
  28453. break;
  28454. }
  28455. originalEndColumn++;
  28456. modifiedEndColumn++;
  28457. }
  28458. if (originalEndColumn < originalMaxColumn || modifiedEndColumn < modifiedMaxColumn) {
  28459. this._pushTrimWhitespaceCharChange(result, originalLineIndex + 1, originalEndColumn, originalMaxColumn, modifiedLineIndex + 1, modifiedEndColumn, modifiedMaxColumn);
  28460. }
  28461. }
  28462. }
  28463. originalLineIndex++;
  28464. modifiedLineIndex++;
  28465. }
  28466. if (nextChange) {
  28467. // Emit the actual change
  28468. result.push(LineChange.createFromDiffResult(this.shouldIgnoreTrimWhitespace, nextChange, this.original, this.modified, this.continueCharDiff, this.shouldComputeCharChanges, this.shouldPostProcessCharChanges));
  28469. originalLineIndex += nextChange.originalLength;
  28470. modifiedLineIndex += nextChange.modifiedLength;
  28471. }
  28472. }
  28473. return {
  28474. quitEarly: quitEarly,
  28475. changes: result
  28476. };
  28477. };
  28478. DiffComputer.prototype._pushTrimWhitespaceCharChange = function (result, originalLineNumber, originalStartColumn, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedEndColumn) {
  28479. if (this._mergeTrimWhitespaceCharChange(result, originalLineNumber, originalStartColumn, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedEndColumn)) {
  28480. // Merged into previous
  28481. return;
  28482. }
  28483. var charChanges = undefined;
  28484. if (this.shouldComputeCharChanges) {
  28485. charChanges = [new CharChange(originalLineNumber, originalStartColumn, originalLineNumber, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedLineNumber, modifiedEndColumn)];
  28486. }
  28487. result.push(new LineChange(originalLineNumber, originalLineNumber, modifiedLineNumber, modifiedLineNumber, charChanges));
  28488. };
  28489. DiffComputer.prototype._mergeTrimWhitespaceCharChange = function (result, originalLineNumber, originalStartColumn, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedEndColumn) {
  28490. var len = result.length;
  28491. if (len === 0) {
  28492. return false;
  28493. }
  28494. var prevChange = result[len - 1];
  28495. if (prevChange.originalEndLineNumber === 0 || prevChange.modifiedEndLineNumber === 0) {
  28496. // Don't merge with inserts/deletes
  28497. return false;
  28498. }
  28499. if (prevChange.originalEndLineNumber + 1 === originalLineNumber && prevChange.modifiedEndLineNumber + 1 === modifiedLineNumber) {
  28500. prevChange.originalEndLineNumber = originalLineNumber;
  28501. prevChange.modifiedEndLineNumber = modifiedLineNumber;
  28502. if (this.shouldComputeCharChanges && prevChange.charChanges) {
  28503. prevChange.charChanges.push(new CharChange(originalLineNumber, originalStartColumn, originalLineNumber, originalEndColumn, modifiedLineNumber, modifiedStartColumn, modifiedLineNumber, modifiedEndColumn));
  28504. }
  28505. return true;
  28506. }
  28507. return false;
  28508. };
  28509. return DiffComputer;
  28510. }());
  28511. exports.DiffComputer = DiffComputer;
  28512. function getFirstNonBlankColumn(txt, defaultValue) {
  28513. var r = strings.firstNonWhitespaceIndex(txt);
  28514. if (r === -1) {
  28515. return defaultValue;
  28516. }
  28517. return r + 1;
  28518. }
  28519. function getLastNonBlankColumn(txt, defaultValue) {
  28520. var r = strings.lastNonWhitespaceIndex(txt);
  28521. if (r === -1) {
  28522. return defaultValue;
  28523. }
  28524. return r + 2;
  28525. }
  28526. function createContinueProcessingPredicate(maximumRuntime) {
  28527. if (maximumRuntime === 0) {
  28528. return function () { return true; };
  28529. }
  28530. var startTime = Date.now();
  28531. return function () {
  28532. return Date.now() - startTime < maximumRuntime;
  28533. };
  28534. }
  28535. });
  28536. /*---------------------------------------------------------------------------------------------
  28537. * Copyright (c) Microsoft Corporation. All rights reserved.
  28538. * Licensed under the MIT License. See License.txt in the project root for license information.
  28539. *--------------------------------------------------------------------------------------------*/
  28540. define(__m[190/*vs/editor/common/editorAction*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  28541. "use strict";
  28542. Object.defineProperty(exports, "__esModule", { value: true });
  28543. var InternalEditorAction = /** @class */ (function () {
  28544. function InternalEditorAction(id, label, alias, precondition, run, contextKeyService) {
  28545. this.id = id;
  28546. this.label = label;
  28547. this.alias = alias;
  28548. this._precondition = precondition;
  28549. this._run = run;
  28550. this._contextKeyService = contextKeyService;
  28551. }
  28552. InternalEditorAction.prototype.isSupported = function () {
  28553. return this._contextKeyService.contextMatchesRules(this._precondition);
  28554. };
  28555. InternalEditorAction.prototype.run = function () {
  28556. if (!this.isSupported()) {
  28557. return Promise.resolve(undefined);
  28558. }
  28559. var r = this._run();
  28560. return r ? r : Promise.resolve(undefined);
  28561. };
  28562. return InternalEditorAction;
  28563. }());
  28564. exports.InternalEditorAction = InternalEditorAction;
  28565. });
  28566. define(__m[68/*vs/editor/common/editorCommon*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  28567. "use strict";
  28568. Object.defineProperty(exports, "__esModule", { value: true });
  28569. /**
  28570. * @internal
  28571. */
  28572. function isThemeColor(o) {
  28573. return o && typeof o.id === 'string';
  28574. }
  28575. exports.isThemeColor = isThemeColor;
  28576. /**
  28577. * The type of the `IEditor`.
  28578. */
  28579. exports.EditorType = {
  28580. ICodeEditor: 'vs.editor.ICodeEditor',
  28581. IDiffEditor: 'vs.editor.IDiffEditor'
  28582. };
  28583. /**
  28584. * Built-in commands.
  28585. * @internal
  28586. */
  28587. exports.Handler = {
  28588. ExecuteCommand: 'executeCommand',
  28589. ExecuteCommands: 'executeCommands',
  28590. Type: 'type',
  28591. ReplacePreviousChar: 'replacePreviousChar',
  28592. CompositionStart: 'compositionStart',
  28593. CompositionEnd: 'compositionEnd',
  28594. Paste: 'paste',
  28595. Cut: 'cut',
  28596. Undo: 'undo',
  28597. Redo: 'redo',
  28598. };
  28599. });
  28600. /*---------------------------------------------------------------------------------------------
  28601. * Copyright (c) Microsoft Corporation. All rights reserved.
  28602. * Licensed under the MIT License. See License.txt in the project root for license information.
  28603. *--------------------------------------------------------------------------------------------*/
  28604. define(__m[108/*vs/editor/browser/editorBrowser*/], __M([0/*require*/,1/*exports*/,68/*vs/editor/common/editorCommon*/]), function (require, exports, editorCommon) {
  28605. "use strict";
  28606. Object.defineProperty(exports, "__esModule", { value: true });
  28607. /**
  28608. *@internal
  28609. */
  28610. function isCodeEditor(thing) {
  28611. if (thing && typeof thing.getEditorType === 'function') {
  28612. return thing.getEditorType() === editorCommon.EditorType.ICodeEditor;
  28613. }
  28614. else {
  28615. return false;
  28616. }
  28617. }
  28618. exports.isCodeEditor = isCodeEditor;
  28619. });
  28620. /*---------------------------------------------------------------------------------------------
  28621. * Copyright (c) Microsoft Corporation. All rights reserved.
  28622. * Licensed under the MIT License. See License.txt in the project root for license information.
  28623. *--------------------------------------------------------------------------------------------*/
  28624. define(__m[48/*vs/editor/common/model*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  28625. "use strict";
  28626. Object.defineProperty(exports, "__esModule", { value: true });
  28627. /**
  28628. * Vertical Lane in the overview ruler of the editor.
  28629. */
  28630. var OverviewRulerLane;
  28631. (function (OverviewRulerLane) {
  28632. OverviewRulerLane[OverviewRulerLane["Left"] = 1] = "Left";
  28633. OverviewRulerLane[OverviewRulerLane["Center"] = 2] = "Center";
  28634. OverviewRulerLane[OverviewRulerLane["Right"] = 4] = "Right";
  28635. OverviewRulerLane[OverviewRulerLane["Full"] = 7] = "Full";
  28636. })(OverviewRulerLane = exports.OverviewRulerLane || (exports.OverviewRulerLane = {}));
  28637. /**
  28638. * Position in the minimap to render the decoration.
  28639. */
  28640. var MinimapPosition;
  28641. (function (MinimapPosition) {
  28642. MinimapPosition[MinimapPosition["Inline"] = 1] = "Inline";
  28643. MinimapPosition[MinimapPosition["Gutter"] = 2] = "Gutter";
  28644. })(MinimapPosition = exports.MinimapPosition || (exports.MinimapPosition = {}));
  28645. var TextModelResolvedOptions = /** @class */ (function () {
  28646. /**
  28647. * @internal
  28648. */
  28649. function TextModelResolvedOptions(src) {
  28650. this.tabSize = Math.max(1, src.tabSize | 0);
  28651. this.indentSize = src.tabSize | 0;
  28652. this.insertSpaces = Boolean(src.insertSpaces);
  28653. this.defaultEOL = src.defaultEOL | 0;
  28654. this.trimAutoWhitespace = Boolean(src.trimAutoWhitespace);
  28655. }
  28656. /**
  28657. * @internal
  28658. */
  28659. TextModelResolvedOptions.prototype.equals = function (other) {
  28660. return (this.tabSize === other.tabSize
  28661. && this.indentSize === other.indentSize
  28662. && this.insertSpaces === other.insertSpaces
  28663. && this.defaultEOL === other.defaultEOL
  28664. && this.trimAutoWhitespace === other.trimAutoWhitespace);
  28665. };
  28666. /**
  28667. * @internal
  28668. */
  28669. TextModelResolvedOptions.prototype.createChangeEvent = function (newOpts) {
  28670. return {
  28671. tabSize: this.tabSize !== newOpts.tabSize,
  28672. indentSize: this.indentSize !== newOpts.indentSize,
  28673. insertSpaces: this.insertSpaces !== newOpts.insertSpaces,
  28674. trimAutoWhitespace: this.trimAutoWhitespace !== newOpts.trimAutoWhitespace,
  28675. };
  28676. };
  28677. return TextModelResolvedOptions;
  28678. }());
  28679. exports.TextModelResolvedOptions = TextModelResolvedOptions;
  28680. var FindMatch = /** @class */ (function () {
  28681. /**
  28682. * @internal
  28683. */
  28684. function FindMatch(range, matches) {
  28685. this.range = range;
  28686. this.matches = matches;
  28687. }
  28688. return FindMatch;
  28689. }());
  28690. exports.FindMatch = FindMatch;
  28691. /**
  28692. * @internal
  28693. */
  28694. var ApplyEditsResult = /** @class */ (function () {
  28695. function ApplyEditsResult(reverseEdits, changes, trimAutoWhitespaceLineNumbers) {
  28696. this.reverseEdits = reverseEdits;
  28697. this.changes = changes;
  28698. this.trimAutoWhitespaceLineNumbers = trimAutoWhitespaceLineNumbers;
  28699. }
  28700. return ApplyEditsResult;
  28701. }());
  28702. exports.ApplyEditsResult = ApplyEditsResult;
  28703. });
  28704. /*---------------------------------------------------------------------------------------------
  28705. * Copyright (c) Microsoft Corporation. All rights reserved.
  28706. * Licensed under the MIT License. See License.txt in the project root for license information.
  28707. *--------------------------------------------------------------------------------------------*/
  28708. define(__m[342/*vs/editor/common/model/editStack*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/]), function (require, exports, errors_1) {
  28709. "use strict";
  28710. Object.defineProperty(exports, "__esModule", { value: true });
  28711. var EditStackElement = /** @class */ (function () {
  28712. function EditStackElement(beforeVersionId, beforeCursorState) {
  28713. this.beforeVersionId = beforeVersionId;
  28714. this.beforeCursorState = beforeCursorState;
  28715. this.afterCursorState = null;
  28716. this.afterVersionId = -1;
  28717. this.editOperations = [];
  28718. }
  28719. EditStackElement.prototype.undo = function (model) {
  28720. // Apply all operations in reverse order
  28721. for (var i = this.editOperations.length - 1; i >= 0; i--) {
  28722. this.editOperations[i] = {
  28723. operations: model.applyEdits(this.editOperations[i].operations)
  28724. };
  28725. }
  28726. };
  28727. EditStackElement.prototype.redo = function (model) {
  28728. // Apply all operations
  28729. for (var i = 0; i < this.editOperations.length; i++) {
  28730. this.editOperations[i] = {
  28731. operations: model.applyEdits(this.editOperations[i].operations)
  28732. };
  28733. }
  28734. };
  28735. return EditStackElement;
  28736. }());
  28737. function getModelEOL(model) {
  28738. var eol = model.getEOL();
  28739. if (eol === '\n') {
  28740. return 0 /* LF */;
  28741. }
  28742. else {
  28743. return 1 /* CRLF */;
  28744. }
  28745. }
  28746. var EOLStackElement = /** @class */ (function () {
  28747. function EOLStackElement(beforeVersionId, setEOL) {
  28748. this.beforeVersionId = beforeVersionId;
  28749. this.beforeCursorState = null;
  28750. this.afterCursorState = null;
  28751. this.afterVersionId = -1;
  28752. this.eol = setEOL;
  28753. }
  28754. EOLStackElement.prototype.undo = function (model) {
  28755. var redoEOL = getModelEOL(model);
  28756. model.setEOL(this.eol);
  28757. this.eol = redoEOL;
  28758. };
  28759. EOLStackElement.prototype.redo = function (model) {
  28760. var undoEOL = getModelEOL(model);
  28761. model.setEOL(this.eol);
  28762. this.eol = undoEOL;
  28763. };
  28764. return EOLStackElement;
  28765. }());
  28766. var EditStack = /** @class */ (function () {
  28767. function EditStack(model) {
  28768. this.model = model;
  28769. this.currentOpenStackElement = null;
  28770. this.past = [];
  28771. this.future = [];
  28772. }
  28773. EditStack.prototype.pushStackElement = function () {
  28774. if (this.currentOpenStackElement !== null) {
  28775. this.past.push(this.currentOpenStackElement);
  28776. this.currentOpenStackElement = null;
  28777. }
  28778. };
  28779. EditStack.prototype.clear = function () {
  28780. this.currentOpenStackElement = null;
  28781. this.past = [];
  28782. this.future = [];
  28783. };
  28784. EditStack.prototype.pushEOL = function (eol) {
  28785. // No support for parallel universes :(
  28786. this.future = [];
  28787. if (this.currentOpenStackElement) {
  28788. this.pushStackElement();
  28789. }
  28790. var prevEOL = getModelEOL(this.model);
  28791. var stackElement = new EOLStackElement(this.model.getAlternativeVersionId(), prevEOL);
  28792. this.model.setEOL(eol);
  28793. stackElement.afterVersionId = this.model.getVersionId();
  28794. this.currentOpenStackElement = stackElement;
  28795. this.pushStackElement();
  28796. };
  28797. EditStack.prototype.pushEditOperation = function (beforeCursorState, editOperations, cursorStateComputer) {
  28798. // No support for parallel universes :(
  28799. this.future = [];
  28800. var stackElement = null;
  28801. if (this.currentOpenStackElement) {
  28802. if (this.currentOpenStackElement instanceof EditStackElement) {
  28803. stackElement = this.currentOpenStackElement;
  28804. }
  28805. else {
  28806. this.pushStackElement();
  28807. }
  28808. }
  28809. if (!this.currentOpenStackElement) {
  28810. stackElement = new EditStackElement(this.model.getAlternativeVersionId(), beforeCursorState);
  28811. this.currentOpenStackElement = stackElement;
  28812. }
  28813. var inverseEditOperation = {
  28814. operations: this.model.applyEdits(editOperations)
  28815. };
  28816. stackElement.editOperations.push(inverseEditOperation);
  28817. stackElement.afterCursorState = EditStack._computeCursorState(cursorStateComputer, inverseEditOperation.operations);
  28818. stackElement.afterVersionId = this.model.getVersionId();
  28819. return stackElement.afterCursorState;
  28820. };
  28821. EditStack._computeCursorState = function (cursorStateComputer, inverseEditOperations) {
  28822. try {
  28823. return cursorStateComputer ? cursorStateComputer(inverseEditOperations) : null;
  28824. }
  28825. catch (e) {
  28826. errors_1.onUnexpectedError(e);
  28827. return null;
  28828. }
  28829. };
  28830. EditStack.prototype.undo = function () {
  28831. this.pushStackElement();
  28832. if (this.past.length > 0) {
  28833. var pastStackElement = this.past.pop();
  28834. try {
  28835. pastStackElement.undo(this.model);
  28836. }
  28837. catch (e) {
  28838. errors_1.onUnexpectedError(e);
  28839. this.clear();
  28840. return null;
  28841. }
  28842. this.future.push(pastStackElement);
  28843. return {
  28844. selections: pastStackElement.beforeCursorState,
  28845. recordedVersionId: pastStackElement.beforeVersionId
  28846. };
  28847. }
  28848. return null;
  28849. };
  28850. EditStack.prototype.canUndo = function () {
  28851. return (this.past.length > 0) || this.currentOpenStackElement !== null;
  28852. };
  28853. EditStack.prototype.redo = function () {
  28854. if (this.future.length > 0) {
  28855. var futureStackElement = this.future.pop();
  28856. try {
  28857. futureStackElement.redo(this.model);
  28858. }
  28859. catch (e) {
  28860. errors_1.onUnexpectedError(e);
  28861. this.clear();
  28862. return null;
  28863. }
  28864. this.past.push(futureStackElement);
  28865. return {
  28866. selections: futureStackElement.afterCursorState,
  28867. recordedVersionId: futureStackElement.afterVersionId
  28868. };
  28869. }
  28870. return null;
  28871. };
  28872. EditStack.prototype.canRedo = function () {
  28873. return (this.future.length > 0);
  28874. };
  28875. return EditStack;
  28876. }());
  28877. exports.EditStack = EditStack;
  28878. });
  28879. /*---------------------------------------------------------------------------------------------
  28880. * Copyright (c) Microsoft Corporation. All rights reserved.
  28881. * Licensed under the MIT License. See License.txt in the project root for license information.
  28882. *--------------------------------------------------------------------------------------------*/
  28883. define(__m[343/*vs/editor/common/model/indentationGuesser*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  28884. "use strict";
  28885. Object.defineProperty(exports, "__esModule", { value: true });
  28886. var SpacesDiffResult = /** @class */ (function () {
  28887. function SpacesDiffResult() {
  28888. this.spacesDiff = 0;
  28889. this.looksLikeAlignment = false;
  28890. }
  28891. return SpacesDiffResult;
  28892. }());
  28893. /**
  28894. * Compute the diff in spaces between two line's indentation.
  28895. */
  28896. function spacesDiff(a, aLength, b, bLength, result) {
  28897. result.spacesDiff = 0;
  28898. result.looksLikeAlignment = false;
  28899. // This can go both ways (e.g.):
  28900. // - a: "\t"
  28901. // - b: "\t "
  28902. // => This should count 1 tab and 4 spaces
  28903. var i;
  28904. for (i = 0; i < aLength && i < bLength; i++) {
  28905. var aCharCode = a.charCodeAt(i);
  28906. var bCharCode = b.charCodeAt(i);
  28907. if (aCharCode !== bCharCode) {
  28908. break;
  28909. }
  28910. }
  28911. var aSpacesCnt = 0, aTabsCount = 0;
  28912. for (var j = i; j < aLength; j++) {
  28913. var aCharCode = a.charCodeAt(j);
  28914. if (aCharCode === 32 /* Space */) {
  28915. aSpacesCnt++;
  28916. }
  28917. else {
  28918. aTabsCount++;
  28919. }
  28920. }
  28921. var bSpacesCnt = 0, bTabsCount = 0;
  28922. for (var j = i; j < bLength; j++) {
  28923. var bCharCode = b.charCodeAt(j);
  28924. if (bCharCode === 32 /* Space */) {
  28925. bSpacesCnt++;
  28926. }
  28927. else {
  28928. bTabsCount++;
  28929. }
  28930. }
  28931. if (aSpacesCnt > 0 && aTabsCount > 0) {
  28932. return;
  28933. }
  28934. if (bSpacesCnt > 0 && bTabsCount > 0) {
  28935. return;
  28936. }
  28937. var tabsDiff = Math.abs(aTabsCount - bTabsCount);
  28938. var spacesDiff = Math.abs(aSpacesCnt - bSpacesCnt);
  28939. if (tabsDiff === 0) {
  28940. // check if the indentation difference might be caused by alignment reasons
  28941. // sometime folks like to align their code, but this should not be used as a hint
  28942. result.spacesDiff = spacesDiff;
  28943. if (spacesDiff > 0 && 0 <= bSpacesCnt - 1 && bSpacesCnt - 1 < a.length && bSpacesCnt < b.length) {
  28944. if (b.charCodeAt(bSpacesCnt) !== 32 /* Space */ && a.charCodeAt(bSpacesCnt - 1) === 32 /* Space */) {
  28945. if (a.charCodeAt(a.length - 1) === 44 /* Comma */) {
  28946. // This looks like an alignment desire: e.g.
  28947. // const a = b + c,
  28948. // d = b - c;
  28949. result.looksLikeAlignment = true;
  28950. }
  28951. }
  28952. }
  28953. return;
  28954. }
  28955. if (spacesDiff % tabsDiff === 0) {
  28956. result.spacesDiff = spacesDiff / tabsDiff;
  28957. return;
  28958. }
  28959. }
  28960. function guessIndentation(source, defaultTabSize, defaultInsertSpaces) {
  28961. // Look at most at the first 10k lines
  28962. var linesCount = Math.min(source.getLineCount(), 10000);
  28963. var linesIndentedWithTabsCount = 0; // number of lines that contain at least one tab in indentation
  28964. var linesIndentedWithSpacesCount = 0; // number of lines that contain only spaces in indentation
  28965. var previousLineText = ''; // content of latest line that contained non-whitespace chars
  28966. var previousLineIndentation = 0; // index at which latest line contained the first non-whitespace char
  28967. var ALLOWED_TAB_SIZE_GUESSES = [2, 4, 6, 8, 3, 5, 7]; // prefer even guesses for `tabSize`, limit to [2, 8].
  28968. var MAX_ALLOWED_TAB_SIZE_GUESS = 8; // max(ALLOWED_TAB_SIZE_GUESSES) = 8
  28969. var spacesDiffCount = [0, 0, 0, 0, 0, 0, 0, 0, 0]; // `tabSize` scores
  28970. var tmp = new SpacesDiffResult();
  28971. for (var lineNumber = 1; lineNumber <= linesCount; lineNumber++) {
  28972. var currentLineLength = source.getLineLength(lineNumber);
  28973. var currentLineText = source.getLineContent(lineNumber);
  28974. // if the text buffer is chunk based, so long lines are cons-string, v8 will flattern the string when we check charCode.
  28975. // checking charCode on chunks directly is cheaper.
  28976. var useCurrentLineText = (currentLineLength <= 65536);
  28977. var currentLineHasContent = false; // does `currentLineText` contain non-whitespace chars
  28978. var currentLineIndentation = 0; // index at which `currentLineText` contains the first non-whitespace char
  28979. var currentLineSpacesCount = 0; // count of spaces found in `currentLineText` indentation
  28980. var currentLineTabsCount = 0; // count of tabs found in `currentLineText` indentation
  28981. for (var j = 0, lenJ = currentLineLength; j < lenJ; j++) {
  28982. var charCode = (useCurrentLineText ? currentLineText.charCodeAt(j) : source.getLineCharCode(lineNumber, j));
  28983. if (charCode === 9 /* Tab */) {
  28984. currentLineTabsCount++;
  28985. }
  28986. else if (charCode === 32 /* Space */) {
  28987. currentLineSpacesCount++;
  28988. }
  28989. else {
  28990. // Hit non whitespace character on this line
  28991. currentLineHasContent = true;
  28992. currentLineIndentation = j;
  28993. break;
  28994. }
  28995. }
  28996. // Ignore empty or only whitespace lines
  28997. if (!currentLineHasContent) {
  28998. continue;
  28999. }
  29000. if (currentLineTabsCount > 0) {
  29001. linesIndentedWithTabsCount++;
  29002. }
  29003. else if (currentLineSpacesCount > 1) {
  29004. linesIndentedWithSpacesCount++;
  29005. }
  29006. spacesDiff(previousLineText, previousLineIndentation, currentLineText, currentLineIndentation, tmp);
  29007. if (tmp.looksLikeAlignment) {
  29008. // if defaultInsertSpaces === true && the spaces count == tabSize, we may want to count it as valid indentation
  29009. //
  29010. // - item1
  29011. // - item2
  29012. //
  29013. // otherwise skip this line entirely
  29014. //
  29015. // const a = 1,
  29016. // b = 2;
  29017. if (!(defaultInsertSpaces && defaultTabSize === tmp.spacesDiff)) {
  29018. continue;
  29019. }
  29020. }
  29021. var currentSpacesDiff = tmp.spacesDiff;
  29022. if (currentSpacesDiff <= MAX_ALLOWED_TAB_SIZE_GUESS) {
  29023. spacesDiffCount[currentSpacesDiff]++;
  29024. }
  29025. previousLineText = currentLineText;
  29026. previousLineIndentation = currentLineIndentation;
  29027. }
  29028. var insertSpaces = defaultInsertSpaces;
  29029. if (linesIndentedWithTabsCount !== linesIndentedWithSpacesCount) {
  29030. insertSpaces = (linesIndentedWithTabsCount < linesIndentedWithSpacesCount);
  29031. }
  29032. var tabSize = defaultTabSize;
  29033. // Guess tabSize only if inserting spaces...
  29034. if (insertSpaces) {
  29035. var tabSizeScore_1 = (insertSpaces ? 0 : 0.1 * linesCount);
  29036. // console.log("score threshold: " + tabSizeScore);
  29037. ALLOWED_TAB_SIZE_GUESSES.forEach(function (possibleTabSize) {
  29038. var possibleTabSizeScore = spacesDiffCount[possibleTabSize];
  29039. if (possibleTabSizeScore > tabSizeScore_1) {
  29040. tabSizeScore_1 = possibleTabSizeScore;
  29041. tabSize = possibleTabSize;
  29042. }
  29043. });
  29044. // Let a tabSize of 2 win even if it is not the maximum
  29045. // (only in case 4 was guessed)
  29046. if (tabSize === 4 && spacesDiffCount[4] > 0 && spacesDiffCount[2] > 0 && spacesDiffCount[2] >= spacesDiffCount[4] / 2) {
  29047. tabSize = 2;
  29048. }
  29049. }
  29050. // console.log('--------------------------');
  29051. // console.log('linesIndentedWithTabsCount: ' + linesIndentedWithTabsCount + ', linesIndentedWithSpacesCount: ' + linesIndentedWithSpacesCount);
  29052. // console.log('spacesDiffCount: ' + spacesDiffCount);
  29053. // console.log('tabSize: ' + tabSize + ', tabSizeScore: ' + tabSizeScore);
  29054. return {
  29055. insertSpaces: insertSpaces,
  29056. tabSize: tabSize
  29057. };
  29058. }
  29059. exports.guessIndentation = guessIndentation;
  29060. });
  29061. /*---------------------------------------------------------------------------------------------
  29062. * Copyright (c) Microsoft Corporation. All rights reserved.
  29063. * Licensed under the MIT License. See License.txt in the project root for license information.
  29064. *--------------------------------------------------------------------------------------------*/
  29065. define(__m[344/*vs/editor/common/model/intervalTree*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  29066. "use strict";
  29067. Object.defineProperty(exports, "__esModule", { value: true });
  29068. function getNodeColor(node) {
  29069. return ((node.metadata & 1 /* ColorMask */) >>> 0 /* ColorOffset */);
  29070. }
  29071. exports.getNodeColor = getNodeColor;
  29072. function setNodeColor(node, color) {
  29073. node.metadata = ((node.metadata & 254 /* ColorMaskInverse */) | (color << 0 /* ColorOffset */));
  29074. }
  29075. function getNodeIsVisited(node) {
  29076. return ((node.metadata & 2 /* IsVisitedMask */) >>> 1 /* IsVisitedOffset */) === 1;
  29077. }
  29078. function setNodeIsVisited(node, value) {
  29079. node.metadata = ((node.metadata & 253 /* IsVisitedMaskInverse */) | ((value ? 1 : 0) << 1 /* IsVisitedOffset */));
  29080. }
  29081. function getNodeIsForValidation(node) {
  29082. return ((node.metadata & 4 /* IsForValidationMask */) >>> 2 /* IsForValidationOffset */) === 1;
  29083. }
  29084. function setNodeIsForValidation(node, value) {
  29085. node.metadata = ((node.metadata & 251 /* IsForValidationMaskInverse */) | ((value ? 1 : 0) << 2 /* IsForValidationOffset */));
  29086. }
  29087. function getNodeIsInOverviewRuler(node) {
  29088. return ((node.metadata & 8 /* IsInOverviewRulerMask */) >>> 3 /* IsInOverviewRulerOffset */) === 1;
  29089. }
  29090. exports.getNodeIsInOverviewRuler = getNodeIsInOverviewRuler;
  29091. function setNodeIsInOverviewRuler(node, value) {
  29092. node.metadata = ((node.metadata & 247 /* IsInOverviewRulerMaskInverse */) | ((value ? 1 : 0) << 3 /* IsInOverviewRulerOffset */));
  29093. }
  29094. function getNodeStickiness(node) {
  29095. return ((node.metadata & 48 /* StickinessMask */) >>> 4 /* StickinessOffset */);
  29096. }
  29097. function _setNodeStickiness(node, stickiness) {
  29098. node.metadata = ((node.metadata & 207 /* StickinessMaskInverse */) | (stickiness << 4 /* StickinessOffset */));
  29099. }
  29100. function getCollapseOnReplaceEdit(node) {
  29101. return ((node.metadata & 64 /* CollapseOnReplaceEditMask */) >>> 6 /* CollapseOnReplaceEditOffset */) === 1;
  29102. }
  29103. function setCollapseOnReplaceEdit(node, value) {
  29104. node.metadata = ((node.metadata & 191 /* CollapseOnReplaceEditMaskInverse */) | ((value ? 1 : 0) << 6 /* CollapseOnReplaceEditOffset */));
  29105. }
  29106. var IntervalNode = /** @class */ (function () {
  29107. function IntervalNode(id, start, end) {
  29108. this.metadata = 0;
  29109. this.parent = this;
  29110. this.left = this;
  29111. this.right = this;
  29112. setNodeColor(this, 1 /* Red */);
  29113. this.start = start;
  29114. this.end = end;
  29115. // FORCE_OVERFLOWING_TEST: this.delta = start;
  29116. this.delta = 0;
  29117. this.maxEnd = end;
  29118. this.id = id;
  29119. this.ownerId = 0;
  29120. this.options = null;
  29121. setNodeIsForValidation(this, false);
  29122. _setNodeStickiness(this, 1 /* NeverGrowsWhenTypingAtEdges */);
  29123. setNodeIsInOverviewRuler(this, false);
  29124. setCollapseOnReplaceEdit(this, false);
  29125. this.cachedVersionId = 0;
  29126. this.cachedAbsoluteStart = start;
  29127. this.cachedAbsoluteEnd = end;
  29128. this.range = null;
  29129. setNodeIsVisited(this, false);
  29130. }
  29131. IntervalNode.prototype.reset = function (versionId, start, end, range) {
  29132. this.start = start;
  29133. this.end = end;
  29134. this.maxEnd = end;
  29135. this.cachedVersionId = versionId;
  29136. this.cachedAbsoluteStart = start;
  29137. this.cachedAbsoluteEnd = end;
  29138. this.range = range;
  29139. };
  29140. IntervalNode.prototype.setOptions = function (options) {
  29141. this.options = options;
  29142. var className = this.options.className;
  29143. setNodeIsForValidation(this, (className === "squiggly-error" /* EditorErrorDecoration */
  29144. || className === "squiggly-warning" /* EditorWarningDecoration */
  29145. || className === "squiggly-info" /* EditorInfoDecoration */));
  29146. _setNodeStickiness(this, this.options.stickiness);
  29147. setNodeIsInOverviewRuler(this, (this.options.overviewRuler && this.options.overviewRuler.color) ? true : false);
  29148. setCollapseOnReplaceEdit(this, this.options.collapseOnReplaceEdit);
  29149. };
  29150. IntervalNode.prototype.setCachedOffsets = function (absoluteStart, absoluteEnd, cachedVersionId) {
  29151. if (this.cachedVersionId !== cachedVersionId) {
  29152. this.range = null;
  29153. }
  29154. this.cachedVersionId = cachedVersionId;
  29155. this.cachedAbsoluteStart = absoluteStart;
  29156. this.cachedAbsoluteEnd = absoluteEnd;
  29157. };
  29158. IntervalNode.prototype.detach = function () {
  29159. this.parent = null;
  29160. this.left = null;
  29161. this.right = null;
  29162. };
  29163. return IntervalNode;
  29164. }());
  29165. exports.IntervalNode = IntervalNode;
  29166. exports.SENTINEL = new IntervalNode(null, 0, 0);
  29167. exports.SENTINEL.parent = exports.SENTINEL;
  29168. exports.SENTINEL.left = exports.SENTINEL;
  29169. exports.SENTINEL.right = exports.SENTINEL;
  29170. setNodeColor(exports.SENTINEL, 0 /* Black */);
  29171. var IntervalTree = /** @class */ (function () {
  29172. function IntervalTree() {
  29173. this.root = exports.SENTINEL;
  29174. this.requestNormalizeDelta = false;
  29175. }
  29176. IntervalTree.prototype.intervalSearch = function (start, end, filterOwnerId, filterOutValidation, cachedVersionId) {
  29177. if (this.root === exports.SENTINEL) {
  29178. return [];
  29179. }
  29180. return intervalSearch(this, start, end, filterOwnerId, filterOutValidation, cachedVersionId);
  29181. };
  29182. IntervalTree.prototype.search = function (filterOwnerId, filterOutValidation, cachedVersionId) {
  29183. if (this.root === exports.SENTINEL) {
  29184. return [];
  29185. }
  29186. return search(this, filterOwnerId, filterOutValidation, cachedVersionId);
  29187. };
  29188. /**
  29189. * Will not set `cachedAbsoluteStart` nor `cachedAbsoluteEnd` on the returned nodes!
  29190. */
  29191. IntervalTree.prototype.collectNodesFromOwner = function (ownerId) {
  29192. return collectNodesFromOwner(this, ownerId);
  29193. };
  29194. /**
  29195. * Will not set `cachedAbsoluteStart` nor `cachedAbsoluteEnd` on the returned nodes!
  29196. */
  29197. IntervalTree.prototype.collectNodesPostOrder = function () {
  29198. return collectNodesPostOrder(this);
  29199. };
  29200. IntervalTree.prototype.insert = function (node) {
  29201. rbTreeInsert(this, node);
  29202. this._normalizeDeltaIfNecessary();
  29203. };
  29204. IntervalTree.prototype.delete = function (node) {
  29205. rbTreeDelete(this, node);
  29206. this._normalizeDeltaIfNecessary();
  29207. };
  29208. IntervalTree.prototype.resolveNode = function (node, cachedVersionId) {
  29209. var initialNode = node;
  29210. var delta = 0;
  29211. while (node !== this.root) {
  29212. if (node === node.parent.right) {
  29213. delta += node.parent.delta;
  29214. }
  29215. node = node.parent;
  29216. }
  29217. var nodeStart = initialNode.start + delta;
  29218. var nodeEnd = initialNode.end + delta;
  29219. initialNode.setCachedOffsets(nodeStart, nodeEnd, cachedVersionId);
  29220. };
  29221. IntervalTree.prototype.acceptReplace = function (offset, length, textLength, forceMoveMarkers) {
  29222. // Our strategy is to remove all directly impacted nodes, and then add them back to the tree.
  29223. // (1) collect all nodes that are intersecting this edit as nodes of interest
  29224. var nodesOfInterest = searchForEditing(this, offset, offset + length);
  29225. // (2) remove all nodes that are intersecting this edit
  29226. for (var i = 0, len = nodesOfInterest.length; i < len; i++) {
  29227. var node = nodesOfInterest[i];
  29228. rbTreeDelete(this, node);
  29229. }
  29230. this._normalizeDeltaIfNecessary();
  29231. // (3) edit all tree nodes except the nodes of interest
  29232. noOverlapReplace(this, offset, offset + length, textLength);
  29233. this._normalizeDeltaIfNecessary();
  29234. // (4) edit the nodes of interest and insert them back in the tree
  29235. for (var i = 0, len = nodesOfInterest.length; i < len; i++) {
  29236. var node = nodesOfInterest[i];
  29237. node.start = node.cachedAbsoluteStart;
  29238. node.end = node.cachedAbsoluteEnd;
  29239. nodeAcceptEdit(node, offset, (offset + length), textLength, forceMoveMarkers);
  29240. node.maxEnd = node.end;
  29241. rbTreeInsert(this, node);
  29242. }
  29243. this._normalizeDeltaIfNecessary();
  29244. };
  29245. IntervalTree.prototype._normalizeDeltaIfNecessary = function () {
  29246. if (!this.requestNormalizeDelta) {
  29247. return;
  29248. }
  29249. this.requestNormalizeDelta = false;
  29250. normalizeDelta(this);
  29251. };
  29252. return IntervalTree;
  29253. }());
  29254. exports.IntervalTree = IntervalTree;
  29255. //#region Delta Normalization
  29256. function normalizeDelta(T) {
  29257. var node = T.root;
  29258. var delta = 0;
  29259. while (node !== exports.SENTINEL) {
  29260. if (node.left !== exports.SENTINEL && !getNodeIsVisited(node.left)) {
  29261. // go left
  29262. node = node.left;
  29263. continue;
  29264. }
  29265. if (node.right !== exports.SENTINEL && !getNodeIsVisited(node.right)) {
  29266. // go right
  29267. delta += node.delta;
  29268. node = node.right;
  29269. continue;
  29270. }
  29271. // handle current node
  29272. node.start = delta + node.start;
  29273. node.end = delta + node.end;
  29274. node.delta = 0;
  29275. recomputeMaxEnd(node);
  29276. setNodeIsVisited(node, true);
  29277. // going up from this node
  29278. setNodeIsVisited(node.left, false);
  29279. setNodeIsVisited(node.right, false);
  29280. if (node === node.parent.right) {
  29281. delta -= node.parent.delta;
  29282. }
  29283. node = node.parent;
  29284. }
  29285. setNodeIsVisited(T.root, false);
  29286. }
  29287. function adjustMarkerBeforeColumn(markerOffset, markerStickToPreviousCharacter, checkOffset, moveSemantics) {
  29288. if (markerOffset < checkOffset) {
  29289. return true;
  29290. }
  29291. if (markerOffset > checkOffset) {
  29292. return false;
  29293. }
  29294. if (moveSemantics === 1 /* ForceMove */) {
  29295. return false;
  29296. }
  29297. if (moveSemantics === 2 /* ForceStay */) {
  29298. return true;
  29299. }
  29300. return markerStickToPreviousCharacter;
  29301. }
  29302. /**
  29303. * This is a lot more complicated than strictly necessary to maintain the same behaviour
  29304. * as when decorations were implemented using two markers.
  29305. */
  29306. function nodeAcceptEdit(node, start, end, textLength, forceMoveMarkers) {
  29307. var nodeStickiness = getNodeStickiness(node);
  29308. var startStickToPreviousCharacter = (nodeStickiness === 0 /* AlwaysGrowsWhenTypingAtEdges */
  29309. || nodeStickiness === 2 /* GrowsOnlyWhenTypingBefore */);
  29310. var endStickToPreviousCharacter = (nodeStickiness === 1 /* NeverGrowsWhenTypingAtEdges */
  29311. || nodeStickiness === 2 /* GrowsOnlyWhenTypingBefore */);
  29312. var deletingCnt = (end - start);
  29313. var insertingCnt = textLength;
  29314. var commonLength = Math.min(deletingCnt, insertingCnt);
  29315. var nodeStart = node.start;
  29316. var startDone = false;
  29317. var nodeEnd = node.end;
  29318. var endDone = false;
  29319. if (start <= nodeStart && nodeEnd <= end && getCollapseOnReplaceEdit(node)) {
  29320. // This edit encompasses the entire decoration range
  29321. // and the decoration has asked to become collapsed
  29322. node.start = start;
  29323. startDone = true;
  29324. node.end = start;
  29325. endDone = true;
  29326. }
  29327. {
  29328. var moveSemantics = forceMoveMarkers ? 1 /* ForceMove */ : (deletingCnt > 0 ? 2 /* ForceStay */ : 0 /* MarkerDefined */);
  29329. if (!startDone && adjustMarkerBeforeColumn(nodeStart, startStickToPreviousCharacter, start, moveSemantics)) {
  29330. startDone = true;
  29331. }
  29332. if (!endDone && adjustMarkerBeforeColumn(nodeEnd, endStickToPreviousCharacter, start, moveSemantics)) {
  29333. endDone = true;
  29334. }
  29335. }
  29336. if (commonLength > 0 && !forceMoveMarkers) {
  29337. var moveSemantics = (deletingCnt > insertingCnt ? 2 /* ForceStay */ : 0 /* MarkerDefined */);
  29338. if (!startDone && adjustMarkerBeforeColumn(nodeStart, startStickToPreviousCharacter, start + commonLength, moveSemantics)) {
  29339. startDone = true;
  29340. }
  29341. if (!endDone && adjustMarkerBeforeColumn(nodeEnd, endStickToPreviousCharacter, start + commonLength, moveSemantics)) {
  29342. endDone = true;
  29343. }
  29344. }
  29345. {
  29346. var moveSemantics = forceMoveMarkers ? 1 /* ForceMove */ : 0 /* MarkerDefined */;
  29347. if (!startDone && adjustMarkerBeforeColumn(nodeStart, startStickToPreviousCharacter, end, moveSemantics)) {
  29348. node.start = start + insertingCnt;
  29349. startDone = true;
  29350. }
  29351. if (!endDone && adjustMarkerBeforeColumn(nodeEnd, endStickToPreviousCharacter, end, moveSemantics)) {
  29352. node.end = start + insertingCnt;
  29353. endDone = true;
  29354. }
  29355. }
  29356. // Finish
  29357. var deltaColumn = (insertingCnt - deletingCnt);
  29358. if (!startDone) {
  29359. node.start = Math.max(0, nodeStart + deltaColumn);
  29360. }
  29361. if (!endDone) {
  29362. node.end = Math.max(0, nodeEnd + deltaColumn);
  29363. }
  29364. if (node.start > node.end) {
  29365. node.end = node.start;
  29366. }
  29367. }
  29368. exports.nodeAcceptEdit = nodeAcceptEdit;
  29369. function searchForEditing(T, start, end) {
  29370. // https://en.wikipedia.org/wiki/Interval_tree#Augmented_tree
  29371. // Now, it is known that two intervals A and B overlap only when both
  29372. // A.low <= B.high and A.high >= B.low. When searching the trees for
  29373. // nodes overlapping with a given interval, you can immediately skip:
  29374. // a) all nodes to the right of nodes whose low value is past the end of the given interval.
  29375. // b) all nodes that have their maximum 'high' value below the start of the given interval.
  29376. var node = T.root;
  29377. var delta = 0;
  29378. var nodeMaxEnd = 0;
  29379. var nodeStart = 0;
  29380. var nodeEnd = 0;
  29381. var result = [];
  29382. var resultLen = 0;
  29383. while (node !== exports.SENTINEL) {
  29384. if (getNodeIsVisited(node)) {
  29385. // going up from this node
  29386. setNodeIsVisited(node.left, false);
  29387. setNodeIsVisited(node.right, false);
  29388. if (node === node.parent.right) {
  29389. delta -= node.parent.delta;
  29390. }
  29391. node = node.parent;
  29392. continue;
  29393. }
  29394. if (!getNodeIsVisited(node.left)) {
  29395. // first time seeing this node
  29396. nodeMaxEnd = delta + node.maxEnd;
  29397. if (nodeMaxEnd < start) {
  29398. // cover case b) from above
  29399. // there is no need to search this node or its children
  29400. setNodeIsVisited(node, true);
  29401. continue;
  29402. }
  29403. if (node.left !== exports.SENTINEL) {
  29404. // go left
  29405. node = node.left;
  29406. continue;
  29407. }
  29408. }
  29409. // handle current node
  29410. nodeStart = delta + node.start;
  29411. if (nodeStart > end) {
  29412. // cover case a) from above
  29413. // there is no need to search this node or its right subtree
  29414. setNodeIsVisited(node, true);
  29415. continue;
  29416. }
  29417. nodeEnd = delta + node.end;
  29418. if (nodeEnd >= start) {
  29419. node.setCachedOffsets(nodeStart, nodeEnd, 0);
  29420. result[resultLen++] = node;
  29421. }
  29422. setNodeIsVisited(node, true);
  29423. if (node.right !== exports.SENTINEL && !getNodeIsVisited(node.right)) {
  29424. // go right
  29425. delta += node.delta;
  29426. node = node.right;
  29427. continue;
  29428. }
  29429. }
  29430. setNodeIsVisited(T.root, false);
  29431. return result;
  29432. }
  29433. function noOverlapReplace(T, start, end, textLength) {
  29434. // https://en.wikipedia.org/wiki/Interval_tree#Augmented_tree
  29435. // Now, it is known that two intervals A and B overlap only when both
  29436. // A.low <= B.high and A.high >= B.low. When searching the trees for
  29437. // nodes overlapping with a given interval, you can immediately skip:
  29438. // a) all nodes to the right of nodes whose low value is past the end of the given interval.
  29439. // b) all nodes that have their maximum 'high' value below the start of the given interval.
  29440. var node = T.root;
  29441. var delta = 0;
  29442. var nodeMaxEnd = 0;
  29443. var nodeStart = 0;
  29444. var editDelta = (textLength - (end - start));
  29445. while (node !== exports.SENTINEL) {
  29446. if (getNodeIsVisited(node)) {
  29447. // going up from this node
  29448. setNodeIsVisited(node.left, false);
  29449. setNodeIsVisited(node.right, false);
  29450. if (node === node.parent.right) {
  29451. delta -= node.parent.delta;
  29452. }
  29453. recomputeMaxEnd(node);
  29454. node = node.parent;
  29455. continue;
  29456. }
  29457. if (!getNodeIsVisited(node.left)) {
  29458. // first time seeing this node
  29459. nodeMaxEnd = delta + node.maxEnd;
  29460. if (nodeMaxEnd < start) {
  29461. // cover case b) from above
  29462. // there is no need to search this node or its children
  29463. setNodeIsVisited(node, true);
  29464. continue;
  29465. }
  29466. if (node.left !== exports.SENTINEL) {
  29467. // go left
  29468. node = node.left;
  29469. continue;
  29470. }
  29471. }
  29472. // handle current node
  29473. nodeStart = delta + node.start;
  29474. if (nodeStart > end) {
  29475. node.start += editDelta;
  29476. node.end += editDelta;
  29477. node.delta += editDelta;
  29478. if (node.delta < -1073741824 /* MIN_SAFE_DELTA */ || node.delta > 1073741824 /* MAX_SAFE_DELTA */) {
  29479. T.requestNormalizeDelta = true;
  29480. }
  29481. // cover case a) from above
  29482. // there is no need to search this node or its right subtree
  29483. setNodeIsVisited(node, true);
  29484. continue;
  29485. }
  29486. setNodeIsVisited(node, true);
  29487. if (node.right !== exports.SENTINEL && !getNodeIsVisited(node.right)) {
  29488. // go right
  29489. delta += node.delta;
  29490. node = node.right;
  29491. continue;
  29492. }
  29493. }
  29494. setNodeIsVisited(T.root, false);
  29495. }
  29496. //#endregion
  29497. //#region Searching
  29498. function collectNodesFromOwner(T, ownerId) {
  29499. var node = T.root;
  29500. var result = [];
  29501. var resultLen = 0;
  29502. while (node !== exports.SENTINEL) {
  29503. if (getNodeIsVisited(node)) {
  29504. // going up from this node
  29505. setNodeIsVisited(node.left, false);
  29506. setNodeIsVisited(node.right, false);
  29507. node = node.parent;
  29508. continue;
  29509. }
  29510. if (node.left !== exports.SENTINEL && !getNodeIsVisited(node.left)) {
  29511. // go left
  29512. node = node.left;
  29513. continue;
  29514. }
  29515. // handle current node
  29516. if (node.ownerId === ownerId) {
  29517. result[resultLen++] = node;
  29518. }
  29519. setNodeIsVisited(node, true);
  29520. if (node.right !== exports.SENTINEL && !getNodeIsVisited(node.right)) {
  29521. // go right
  29522. node = node.right;
  29523. continue;
  29524. }
  29525. }
  29526. setNodeIsVisited(T.root, false);
  29527. return result;
  29528. }
  29529. function collectNodesPostOrder(T) {
  29530. var node = T.root;
  29531. var result = [];
  29532. var resultLen = 0;
  29533. while (node !== exports.SENTINEL) {
  29534. if (getNodeIsVisited(node)) {
  29535. // going up from this node
  29536. setNodeIsVisited(node.left, false);
  29537. setNodeIsVisited(node.right, false);
  29538. node = node.parent;
  29539. continue;
  29540. }
  29541. if (node.left !== exports.SENTINEL && !getNodeIsVisited(node.left)) {
  29542. // go left
  29543. node = node.left;
  29544. continue;
  29545. }
  29546. if (node.right !== exports.SENTINEL && !getNodeIsVisited(node.right)) {
  29547. // go right
  29548. node = node.right;
  29549. continue;
  29550. }
  29551. // handle current node
  29552. result[resultLen++] = node;
  29553. setNodeIsVisited(node, true);
  29554. }
  29555. setNodeIsVisited(T.root, false);
  29556. return result;
  29557. }
  29558. function search(T, filterOwnerId, filterOutValidation, cachedVersionId) {
  29559. var node = T.root;
  29560. var delta = 0;
  29561. var nodeStart = 0;
  29562. var nodeEnd = 0;
  29563. var result = [];
  29564. var resultLen = 0;
  29565. while (node !== exports.SENTINEL) {
  29566. if (getNodeIsVisited(node)) {
  29567. // going up from this node
  29568. setNodeIsVisited(node.left, false);
  29569. setNodeIsVisited(node.right, false);
  29570. if (node === node.parent.right) {
  29571. delta -= node.parent.delta;
  29572. }
  29573. node = node.parent;
  29574. continue;
  29575. }
  29576. if (node.left !== exports.SENTINEL && !getNodeIsVisited(node.left)) {
  29577. // go left
  29578. node = node.left;
  29579. continue;
  29580. }
  29581. // handle current node
  29582. nodeStart = delta + node.start;
  29583. nodeEnd = delta + node.end;
  29584. node.setCachedOffsets(nodeStart, nodeEnd, cachedVersionId);
  29585. var include = true;
  29586. if (filterOwnerId && node.ownerId && node.ownerId !== filterOwnerId) {
  29587. include = false;
  29588. }
  29589. if (filterOutValidation && getNodeIsForValidation(node)) {
  29590. include = false;
  29591. }
  29592. if (include) {
  29593. result[resultLen++] = node;
  29594. }
  29595. setNodeIsVisited(node, true);
  29596. if (node.right !== exports.SENTINEL && !getNodeIsVisited(node.right)) {
  29597. // go right
  29598. delta += node.delta;
  29599. node = node.right;
  29600. continue;
  29601. }
  29602. }
  29603. setNodeIsVisited(T.root, false);
  29604. return result;
  29605. }
  29606. function intervalSearch(T, intervalStart, intervalEnd, filterOwnerId, filterOutValidation, cachedVersionId) {
  29607. // https://en.wikipedia.org/wiki/Interval_tree#Augmented_tree
  29608. // Now, it is known that two intervals A and B overlap only when both
  29609. // A.low <= B.high and A.high >= B.low. When searching the trees for
  29610. // nodes overlapping with a given interval, you can immediately skip:
  29611. // a) all nodes to the right of nodes whose low value is past the end of the given interval.
  29612. // b) all nodes that have their maximum 'high' value below the start of the given interval.
  29613. var node = T.root;
  29614. var delta = 0;
  29615. var nodeMaxEnd = 0;
  29616. var nodeStart = 0;
  29617. var nodeEnd = 0;
  29618. var result = [];
  29619. var resultLen = 0;
  29620. while (node !== exports.SENTINEL) {
  29621. if (getNodeIsVisited(node)) {
  29622. // going up from this node
  29623. setNodeIsVisited(node.left, false);
  29624. setNodeIsVisited(node.right, false);
  29625. if (node === node.parent.right) {
  29626. delta -= node.parent.delta;
  29627. }
  29628. node = node.parent;
  29629. continue;
  29630. }
  29631. if (!getNodeIsVisited(node.left)) {
  29632. // first time seeing this node
  29633. nodeMaxEnd = delta + node.maxEnd;
  29634. if (nodeMaxEnd < intervalStart) {
  29635. // cover case b) from above
  29636. // there is no need to search this node or its children
  29637. setNodeIsVisited(node, true);
  29638. continue;
  29639. }
  29640. if (node.left !== exports.SENTINEL) {
  29641. // go left
  29642. node = node.left;
  29643. continue;
  29644. }
  29645. }
  29646. // handle current node
  29647. nodeStart = delta + node.start;
  29648. if (nodeStart > intervalEnd) {
  29649. // cover case a) from above
  29650. // there is no need to search this node or its right subtree
  29651. setNodeIsVisited(node, true);
  29652. continue;
  29653. }
  29654. nodeEnd = delta + node.end;
  29655. if (nodeEnd >= intervalStart) {
  29656. // There is overlap
  29657. node.setCachedOffsets(nodeStart, nodeEnd, cachedVersionId);
  29658. var include = true;
  29659. if (filterOwnerId && node.ownerId && node.ownerId !== filterOwnerId) {
  29660. include = false;
  29661. }
  29662. if (filterOutValidation && getNodeIsForValidation(node)) {
  29663. include = false;
  29664. }
  29665. if (include) {
  29666. result[resultLen++] = node;
  29667. }
  29668. }
  29669. setNodeIsVisited(node, true);
  29670. if (node.right !== exports.SENTINEL && !getNodeIsVisited(node.right)) {
  29671. // go right
  29672. delta += node.delta;
  29673. node = node.right;
  29674. continue;
  29675. }
  29676. }
  29677. setNodeIsVisited(T.root, false);
  29678. return result;
  29679. }
  29680. //#endregion
  29681. //#region Insertion
  29682. function rbTreeInsert(T, newNode) {
  29683. if (T.root === exports.SENTINEL) {
  29684. newNode.parent = exports.SENTINEL;
  29685. newNode.left = exports.SENTINEL;
  29686. newNode.right = exports.SENTINEL;
  29687. setNodeColor(newNode, 0 /* Black */);
  29688. T.root = newNode;
  29689. return T.root;
  29690. }
  29691. treeInsert(T, newNode);
  29692. recomputeMaxEndWalkToRoot(newNode.parent);
  29693. // repair tree
  29694. var x = newNode;
  29695. while (x !== T.root && getNodeColor(x.parent) === 1 /* Red */) {
  29696. if (x.parent === x.parent.parent.left) {
  29697. var y = x.parent.parent.right;
  29698. if (getNodeColor(y) === 1 /* Red */) {
  29699. setNodeColor(x.parent, 0 /* Black */);
  29700. setNodeColor(y, 0 /* Black */);
  29701. setNodeColor(x.parent.parent, 1 /* Red */);
  29702. x = x.parent.parent;
  29703. }
  29704. else {
  29705. if (x === x.parent.right) {
  29706. x = x.parent;
  29707. leftRotate(T, x);
  29708. }
  29709. setNodeColor(x.parent, 0 /* Black */);
  29710. setNodeColor(x.parent.parent, 1 /* Red */);
  29711. rightRotate(T, x.parent.parent);
  29712. }
  29713. }
  29714. else {
  29715. var y = x.parent.parent.left;
  29716. if (getNodeColor(y) === 1 /* Red */) {
  29717. setNodeColor(x.parent, 0 /* Black */);
  29718. setNodeColor(y, 0 /* Black */);
  29719. setNodeColor(x.parent.parent, 1 /* Red */);
  29720. x = x.parent.parent;
  29721. }
  29722. else {
  29723. if (x === x.parent.left) {
  29724. x = x.parent;
  29725. rightRotate(T, x);
  29726. }
  29727. setNodeColor(x.parent, 0 /* Black */);
  29728. setNodeColor(x.parent.parent, 1 /* Red */);
  29729. leftRotate(T, x.parent.parent);
  29730. }
  29731. }
  29732. }
  29733. setNodeColor(T.root, 0 /* Black */);
  29734. return newNode;
  29735. }
  29736. function treeInsert(T, z) {
  29737. var delta = 0;
  29738. var x = T.root;
  29739. var zAbsoluteStart = z.start;
  29740. var zAbsoluteEnd = z.end;
  29741. while (true) {
  29742. var cmp = intervalCompare(zAbsoluteStart, zAbsoluteEnd, x.start + delta, x.end + delta);
  29743. if (cmp < 0) {
  29744. // this node should be inserted to the left
  29745. // => it is not affected by the node's delta
  29746. if (x.left === exports.SENTINEL) {
  29747. z.start -= delta;
  29748. z.end -= delta;
  29749. z.maxEnd -= delta;
  29750. x.left = z;
  29751. break;
  29752. }
  29753. else {
  29754. x = x.left;
  29755. }
  29756. }
  29757. else {
  29758. // this node should be inserted to the right
  29759. // => it is not affected by the node's delta
  29760. if (x.right === exports.SENTINEL) {
  29761. z.start -= (delta + x.delta);
  29762. z.end -= (delta + x.delta);
  29763. z.maxEnd -= (delta + x.delta);
  29764. x.right = z;
  29765. break;
  29766. }
  29767. else {
  29768. delta += x.delta;
  29769. x = x.right;
  29770. }
  29771. }
  29772. }
  29773. z.parent = x;
  29774. z.left = exports.SENTINEL;
  29775. z.right = exports.SENTINEL;
  29776. setNodeColor(z, 1 /* Red */);
  29777. }
  29778. //#endregion
  29779. //#region Deletion
  29780. function rbTreeDelete(T, z) {
  29781. var x;
  29782. var y;
  29783. // RB-DELETE except we don't swap z and y in case c)
  29784. // i.e. we always delete what's pointed at by z.
  29785. if (z.left === exports.SENTINEL) {
  29786. x = z.right;
  29787. y = z;
  29788. // x's delta is no longer influenced by z's delta
  29789. x.delta += z.delta;
  29790. if (x.delta < -1073741824 /* MIN_SAFE_DELTA */ || x.delta > 1073741824 /* MAX_SAFE_DELTA */) {
  29791. T.requestNormalizeDelta = true;
  29792. }
  29793. x.start += z.delta;
  29794. x.end += z.delta;
  29795. }
  29796. else if (z.right === exports.SENTINEL) {
  29797. x = z.left;
  29798. y = z;
  29799. }
  29800. else {
  29801. y = leftest(z.right);
  29802. x = y.right;
  29803. // y's delta is no longer influenced by z's delta,
  29804. // but we don't want to walk the entire right-hand-side subtree of x.
  29805. // we therefore maintain z's delta in y, and adjust only x
  29806. x.start += y.delta;
  29807. x.end += y.delta;
  29808. x.delta += y.delta;
  29809. if (x.delta < -1073741824 /* MIN_SAFE_DELTA */ || x.delta > 1073741824 /* MAX_SAFE_DELTA */) {
  29810. T.requestNormalizeDelta = true;
  29811. }
  29812. y.start += z.delta;
  29813. y.end += z.delta;
  29814. y.delta = z.delta;
  29815. if (y.delta < -1073741824 /* MIN_SAFE_DELTA */ || y.delta > 1073741824 /* MAX_SAFE_DELTA */) {
  29816. T.requestNormalizeDelta = true;
  29817. }
  29818. }
  29819. if (y === T.root) {
  29820. T.root = x;
  29821. setNodeColor(x, 0 /* Black */);
  29822. z.detach();
  29823. resetSentinel();
  29824. recomputeMaxEnd(x);
  29825. T.root.parent = exports.SENTINEL;
  29826. return;
  29827. }
  29828. var yWasRed = (getNodeColor(y) === 1 /* Red */);
  29829. if (y === y.parent.left) {
  29830. y.parent.left = x;
  29831. }
  29832. else {
  29833. y.parent.right = x;
  29834. }
  29835. if (y === z) {
  29836. x.parent = y.parent;
  29837. }
  29838. else {
  29839. if (y.parent === z) {
  29840. x.parent = y;
  29841. }
  29842. else {
  29843. x.parent = y.parent;
  29844. }
  29845. y.left = z.left;
  29846. y.right = z.right;
  29847. y.parent = z.parent;
  29848. setNodeColor(y, getNodeColor(z));
  29849. if (z === T.root) {
  29850. T.root = y;
  29851. }
  29852. else {
  29853. if (z === z.parent.left) {
  29854. z.parent.left = y;
  29855. }
  29856. else {
  29857. z.parent.right = y;
  29858. }
  29859. }
  29860. if (y.left !== exports.SENTINEL) {
  29861. y.left.parent = y;
  29862. }
  29863. if (y.right !== exports.SENTINEL) {
  29864. y.right.parent = y;
  29865. }
  29866. }
  29867. z.detach();
  29868. if (yWasRed) {
  29869. recomputeMaxEndWalkToRoot(x.parent);
  29870. if (y !== z) {
  29871. recomputeMaxEndWalkToRoot(y);
  29872. recomputeMaxEndWalkToRoot(y.parent);
  29873. }
  29874. resetSentinel();
  29875. return;
  29876. }
  29877. recomputeMaxEndWalkToRoot(x);
  29878. recomputeMaxEndWalkToRoot(x.parent);
  29879. if (y !== z) {
  29880. recomputeMaxEndWalkToRoot(y);
  29881. recomputeMaxEndWalkToRoot(y.parent);
  29882. }
  29883. // RB-DELETE-FIXUP
  29884. var w;
  29885. while (x !== T.root && getNodeColor(x) === 0 /* Black */) {
  29886. if (x === x.parent.left) {
  29887. w = x.parent.right;
  29888. if (getNodeColor(w) === 1 /* Red */) {
  29889. setNodeColor(w, 0 /* Black */);
  29890. setNodeColor(x.parent, 1 /* Red */);
  29891. leftRotate(T, x.parent);
  29892. w = x.parent.right;
  29893. }
  29894. if (getNodeColor(w.left) === 0 /* Black */ && getNodeColor(w.right) === 0 /* Black */) {
  29895. setNodeColor(w, 1 /* Red */);
  29896. x = x.parent;
  29897. }
  29898. else {
  29899. if (getNodeColor(w.right) === 0 /* Black */) {
  29900. setNodeColor(w.left, 0 /* Black */);
  29901. setNodeColor(w, 1 /* Red */);
  29902. rightRotate(T, w);
  29903. w = x.parent.right;
  29904. }
  29905. setNodeColor(w, getNodeColor(x.parent));
  29906. setNodeColor(x.parent, 0 /* Black */);
  29907. setNodeColor(w.right, 0 /* Black */);
  29908. leftRotate(T, x.parent);
  29909. x = T.root;
  29910. }
  29911. }
  29912. else {
  29913. w = x.parent.left;
  29914. if (getNodeColor(w) === 1 /* Red */) {
  29915. setNodeColor(w, 0 /* Black */);
  29916. setNodeColor(x.parent, 1 /* Red */);
  29917. rightRotate(T, x.parent);
  29918. w = x.parent.left;
  29919. }
  29920. if (getNodeColor(w.left) === 0 /* Black */ && getNodeColor(w.right) === 0 /* Black */) {
  29921. setNodeColor(w, 1 /* Red */);
  29922. x = x.parent;
  29923. }
  29924. else {
  29925. if (getNodeColor(w.left) === 0 /* Black */) {
  29926. setNodeColor(w.right, 0 /* Black */);
  29927. setNodeColor(w, 1 /* Red */);
  29928. leftRotate(T, w);
  29929. w = x.parent.left;
  29930. }
  29931. setNodeColor(w, getNodeColor(x.parent));
  29932. setNodeColor(x.parent, 0 /* Black */);
  29933. setNodeColor(w.left, 0 /* Black */);
  29934. rightRotate(T, x.parent);
  29935. x = T.root;
  29936. }
  29937. }
  29938. }
  29939. setNodeColor(x, 0 /* Black */);
  29940. resetSentinel();
  29941. }
  29942. function leftest(node) {
  29943. while (node.left !== exports.SENTINEL) {
  29944. node = node.left;
  29945. }
  29946. return node;
  29947. }
  29948. function resetSentinel() {
  29949. exports.SENTINEL.parent = exports.SENTINEL;
  29950. exports.SENTINEL.delta = 0; // optional
  29951. exports.SENTINEL.start = 0; // optional
  29952. exports.SENTINEL.end = 0; // optional
  29953. }
  29954. //#endregion
  29955. //#region Rotations
  29956. function leftRotate(T, x) {
  29957. var y = x.right; // set y.
  29958. y.delta += x.delta; // y's delta is no longer influenced by x's delta
  29959. if (y.delta < -1073741824 /* MIN_SAFE_DELTA */ || y.delta > 1073741824 /* MAX_SAFE_DELTA */) {
  29960. T.requestNormalizeDelta = true;
  29961. }
  29962. y.start += x.delta;
  29963. y.end += x.delta;
  29964. x.right = y.left; // turn y's left subtree into x's right subtree.
  29965. if (y.left !== exports.SENTINEL) {
  29966. y.left.parent = x;
  29967. }
  29968. y.parent = x.parent; // link x's parent to y.
  29969. if (x.parent === exports.SENTINEL) {
  29970. T.root = y;
  29971. }
  29972. else if (x === x.parent.left) {
  29973. x.parent.left = y;
  29974. }
  29975. else {
  29976. x.parent.right = y;
  29977. }
  29978. y.left = x; // put x on y's left.
  29979. x.parent = y;
  29980. recomputeMaxEnd(x);
  29981. recomputeMaxEnd(y);
  29982. }
  29983. function rightRotate(T, y) {
  29984. var x = y.left;
  29985. y.delta -= x.delta;
  29986. if (y.delta < -1073741824 /* MIN_SAFE_DELTA */ || y.delta > 1073741824 /* MAX_SAFE_DELTA */) {
  29987. T.requestNormalizeDelta = true;
  29988. }
  29989. y.start -= x.delta;
  29990. y.end -= x.delta;
  29991. y.left = x.right;
  29992. if (x.right !== exports.SENTINEL) {
  29993. x.right.parent = y;
  29994. }
  29995. x.parent = y.parent;
  29996. if (y.parent === exports.SENTINEL) {
  29997. T.root = x;
  29998. }
  29999. else if (y === y.parent.right) {
  30000. y.parent.right = x;
  30001. }
  30002. else {
  30003. y.parent.left = x;
  30004. }
  30005. x.right = y;
  30006. y.parent = x;
  30007. recomputeMaxEnd(y);
  30008. recomputeMaxEnd(x);
  30009. }
  30010. //#endregion
  30011. //#region max end computation
  30012. function computeMaxEnd(node) {
  30013. var maxEnd = node.end;
  30014. if (node.left !== exports.SENTINEL) {
  30015. var leftMaxEnd = node.left.maxEnd;
  30016. if (leftMaxEnd > maxEnd) {
  30017. maxEnd = leftMaxEnd;
  30018. }
  30019. }
  30020. if (node.right !== exports.SENTINEL) {
  30021. var rightMaxEnd = node.right.maxEnd + node.delta;
  30022. if (rightMaxEnd > maxEnd) {
  30023. maxEnd = rightMaxEnd;
  30024. }
  30025. }
  30026. return maxEnd;
  30027. }
  30028. function recomputeMaxEnd(node) {
  30029. node.maxEnd = computeMaxEnd(node);
  30030. }
  30031. exports.recomputeMaxEnd = recomputeMaxEnd;
  30032. function recomputeMaxEndWalkToRoot(node) {
  30033. while (node !== exports.SENTINEL) {
  30034. var maxEnd = computeMaxEnd(node);
  30035. if (node.maxEnd === maxEnd) {
  30036. // no need to go further
  30037. return;
  30038. }
  30039. node.maxEnd = maxEnd;
  30040. node = node.parent;
  30041. }
  30042. }
  30043. //#endregion
  30044. //#region utils
  30045. function intervalCompare(aStart, aEnd, bStart, bEnd) {
  30046. if (aStart === bStart) {
  30047. return aEnd - bEnd;
  30048. }
  30049. return aStart - bStart;
  30050. }
  30051. exports.intervalCompare = intervalCompare;
  30052. });
  30053. //#endregion
  30054. /*---------------------------------------------------------------------------------------------
  30055. * Copyright (c) Microsoft Corporation. All rights reserved.
  30056. * Licensed under the MIT License. See License.txt in the project root for license information.
  30057. *--------------------------------------------------------------------------------------------*/
  30058. define(__m[345/*vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  30059. "use strict";
  30060. Object.defineProperty(exports, "__esModule", { value: true });
  30061. var TreeNode = /** @class */ (function () {
  30062. function TreeNode(piece, color) {
  30063. this.piece = piece;
  30064. this.color = color;
  30065. this.size_left = 0;
  30066. this.lf_left = 0;
  30067. this.parent = this;
  30068. this.left = this;
  30069. this.right = this;
  30070. }
  30071. TreeNode.prototype.next = function () {
  30072. if (this.right !== exports.SENTINEL) {
  30073. return leftest(this.right);
  30074. }
  30075. var node = this;
  30076. while (node.parent !== exports.SENTINEL) {
  30077. if (node.parent.left === node) {
  30078. break;
  30079. }
  30080. node = node.parent;
  30081. }
  30082. if (node.parent === exports.SENTINEL) {
  30083. return exports.SENTINEL;
  30084. }
  30085. else {
  30086. return node.parent;
  30087. }
  30088. };
  30089. TreeNode.prototype.prev = function () {
  30090. if (this.left !== exports.SENTINEL) {
  30091. return righttest(this.left);
  30092. }
  30093. var node = this;
  30094. while (node.parent !== exports.SENTINEL) {
  30095. if (node.parent.right === node) {
  30096. break;
  30097. }
  30098. node = node.parent;
  30099. }
  30100. if (node.parent === exports.SENTINEL) {
  30101. return exports.SENTINEL;
  30102. }
  30103. else {
  30104. return node.parent;
  30105. }
  30106. };
  30107. TreeNode.prototype.detach = function () {
  30108. this.parent = null;
  30109. this.left = null;
  30110. this.right = null;
  30111. };
  30112. return TreeNode;
  30113. }());
  30114. exports.TreeNode = TreeNode;
  30115. exports.SENTINEL = new TreeNode(null, 0 /* Black */);
  30116. exports.SENTINEL.parent = exports.SENTINEL;
  30117. exports.SENTINEL.left = exports.SENTINEL;
  30118. exports.SENTINEL.right = exports.SENTINEL;
  30119. exports.SENTINEL.color = 0 /* Black */;
  30120. function leftest(node) {
  30121. while (node.left !== exports.SENTINEL) {
  30122. node = node.left;
  30123. }
  30124. return node;
  30125. }
  30126. exports.leftest = leftest;
  30127. function righttest(node) {
  30128. while (node.right !== exports.SENTINEL) {
  30129. node = node.right;
  30130. }
  30131. return node;
  30132. }
  30133. exports.righttest = righttest;
  30134. function calculateSize(node) {
  30135. if (node === exports.SENTINEL) {
  30136. return 0;
  30137. }
  30138. return node.size_left + node.piece.length + calculateSize(node.right);
  30139. }
  30140. exports.calculateSize = calculateSize;
  30141. function calculateLF(node) {
  30142. if (node === exports.SENTINEL) {
  30143. return 0;
  30144. }
  30145. return node.lf_left + node.piece.lineFeedCnt + calculateLF(node.right);
  30146. }
  30147. exports.calculateLF = calculateLF;
  30148. function resetSentinel() {
  30149. exports.SENTINEL.parent = exports.SENTINEL;
  30150. }
  30151. exports.resetSentinel = resetSentinel;
  30152. function leftRotate(tree, x) {
  30153. var y = x.right;
  30154. // fix size_left
  30155. y.size_left += x.size_left + (x.piece ? x.piece.length : 0);
  30156. y.lf_left += x.lf_left + (x.piece ? x.piece.lineFeedCnt : 0);
  30157. x.right = y.left;
  30158. if (y.left !== exports.SENTINEL) {
  30159. y.left.parent = x;
  30160. }
  30161. y.parent = x.parent;
  30162. if (x.parent === exports.SENTINEL) {
  30163. tree.root = y;
  30164. }
  30165. else if (x.parent.left === x) {
  30166. x.parent.left = y;
  30167. }
  30168. else {
  30169. x.parent.right = y;
  30170. }
  30171. y.left = x;
  30172. x.parent = y;
  30173. }
  30174. exports.leftRotate = leftRotate;
  30175. function rightRotate(tree, y) {
  30176. var x = y.left;
  30177. y.left = x.right;
  30178. if (x.right !== exports.SENTINEL) {
  30179. x.right.parent = y;
  30180. }
  30181. x.parent = y.parent;
  30182. // fix size_left
  30183. y.size_left -= x.size_left + (x.piece ? x.piece.length : 0);
  30184. y.lf_left -= x.lf_left + (x.piece ? x.piece.lineFeedCnt : 0);
  30185. if (y.parent === exports.SENTINEL) {
  30186. tree.root = x;
  30187. }
  30188. else if (y === y.parent.right) {
  30189. y.parent.right = x;
  30190. }
  30191. else {
  30192. y.parent.left = x;
  30193. }
  30194. x.right = y;
  30195. y.parent = x;
  30196. }
  30197. exports.rightRotate = rightRotate;
  30198. function rbDelete(tree, z) {
  30199. var x;
  30200. var y;
  30201. if (z.left === exports.SENTINEL) {
  30202. y = z;
  30203. x = y.right;
  30204. }
  30205. else if (z.right === exports.SENTINEL) {
  30206. y = z;
  30207. x = y.left;
  30208. }
  30209. else {
  30210. y = leftest(z.right);
  30211. x = y.right;
  30212. }
  30213. if (y === tree.root) {
  30214. tree.root = x;
  30215. // if x is null, we are removing the only node
  30216. x.color = 0 /* Black */;
  30217. z.detach();
  30218. resetSentinel();
  30219. tree.root.parent = exports.SENTINEL;
  30220. return;
  30221. }
  30222. var yWasRed = (y.color === 1 /* Red */);
  30223. if (y === y.parent.left) {
  30224. y.parent.left = x;
  30225. }
  30226. else {
  30227. y.parent.right = x;
  30228. }
  30229. if (y === z) {
  30230. x.parent = y.parent;
  30231. recomputeTreeMetadata(tree, x);
  30232. }
  30233. else {
  30234. if (y.parent === z) {
  30235. x.parent = y;
  30236. }
  30237. else {
  30238. x.parent = y.parent;
  30239. }
  30240. // as we make changes to x's hierarchy, update size_left of subtree first
  30241. recomputeTreeMetadata(tree, x);
  30242. y.left = z.left;
  30243. y.right = z.right;
  30244. y.parent = z.parent;
  30245. y.color = z.color;
  30246. if (z === tree.root) {
  30247. tree.root = y;
  30248. }
  30249. else {
  30250. if (z === z.parent.left) {
  30251. z.parent.left = y;
  30252. }
  30253. else {
  30254. z.parent.right = y;
  30255. }
  30256. }
  30257. if (y.left !== exports.SENTINEL) {
  30258. y.left.parent = y;
  30259. }
  30260. if (y.right !== exports.SENTINEL) {
  30261. y.right.parent = y;
  30262. }
  30263. // update metadata
  30264. // we replace z with y, so in this sub tree, the length change is z.item.length
  30265. y.size_left = z.size_left;
  30266. y.lf_left = z.lf_left;
  30267. recomputeTreeMetadata(tree, y);
  30268. }
  30269. z.detach();
  30270. if (x.parent.left === x) {
  30271. var newSizeLeft = calculateSize(x);
  30272. var newLFLeft = calculateLF(x);
  30273. if (newSizeLeft !== x.parent.size_left || newLFLeft !== x.parent.lf_left) {
  30274. var delta = newSizeLeft - x.parent.size_left;
  30275. var lf_delta = newLFLeft - x.parent.lf_left;
  30276. x.parent.size_left = newSizeLeft;
  30277. x.parent.lf_left = newLFLeft;
  30278. updateTreeMetadata(tree, x.parent, delta, lf_delta);
  30279. }
  30280. }
  30281. recomputeTreeMetadata(tree, x.parent);
  30282. if (yWasRed) {
  30283. resetSentinel();
  30284. return;
  30285. }
  30286. // RB-DELETE-FIXUP
  30287. var w;
  30288. while (x !== tree.root && x.color === 0 /* Black */) {
  30289. if (x === x.parent.left) {
  30290. w = x.parent.right;
  30291. if (w.color === 1 /* Red */) {
  30292. w.color = 0 /* Black */;
  30293. x.parent.color = 1 /* Red */;
  30294. leftRotate(tree, x.parent);
  30295. w = x.parent.right;
  30296. }
  30297. if (w.left.color === 0 /* Black */ && w.right.color === 0 /* Black */) {
  30298. w.color = 1 /* Red */;
  30299. x = x.parent;
  30300. }
  30301. else {
  30302. if (w.right.color === 0 /* Black */) {
  30303. w.left.color = 0 /* Black */;
  30304. w.color = 1 /* Red */;
  30305. rightRotate(tree, w);
  30306. w = x.parent.right;
  30307. }
  30308. w.color = x.parent.color;
  30309. x.parent.color = 0 /* Black */;
  30310. w.right.color = 0 /* Black */;
  30311. leftRotate(tree, x.parent);
  30312. x = tree.root;
  30313. }
  30314. }
  30315. else {
  30316. w = x.parent.left;
  30317. if (w.color === 1 /* Red */) {
  30318. w.color = 0 /* Black */;
  30319. x.parent.color = 1 /* Red */;
  30320. rightRotate(tree, x.parent);
  30321. w = x.parent.left;
  30322. }
  30323. if (w.left.color === 0 /* Black */ && w.right.color === 0 /* Black */) {
  30324. w.color = 1 /* Red */;
  30325. x = x.parent;
  30326. }
  30327. else {
  30328. if (w.left.color === 0 /* Black */) {
  30329. w.right.color = 0 /* Black */;
  30330. w.color = 1 /* Red */;
  30331. leftRotate(tree, w);
  30332. w = x.parent.left;
  30333. }
  30334. w.color = x.parent.color;
  30335. x.parent.color = 0 /* Black */;
  30336. w.left.color = 0 /* Black */;
  30337. rightRotate(tree, x.parent);
  30338. x = tree.root;
  30339. }
  30340. }
  30341. }
  30342. x.color = 0 /* Black */;
  30343. resetSentinel();
  30344. }
  30345. exports.rbDelete = rbDelete;
  30346. function fixInsert(tree, x) {
  30347. recomputeTreeMetadata(tree, x);
  30348. while (x !== tree.root && x.parent.color === 1 /* Red */) {
  30349. if (x.parent === x.parent.parent.left) {
  30350. var y = x.parent.parent.right;
  30351. if (y.color === 1 /* Red */) {
  30352. x.parent.color = 0 /* Black */;
  30353. y.color = 0 /* Black */;
  30354. x.parent.parent.color = 1 /* Red */;
  30355. x = x.parent.parent;
  30356. }
  30357. else {
  30358. if (x === x.parent.right) {
  30359. x = x.parent;
  30360. leftRotate(tree, x);
  30361. }
  30362. x.parent.color = 0 /* Black */;
  30363. x.parent.parent.color = 1 /* Red */;
  30364. rightRotate(tree, x.parent.parent);
  30365. }
  30366. }
  30367. else {
  30368. var y = x.parent.parent.left;
  30369. if (y.color === 1 /* Red */) {
  30370. x.parent.color = 0 /* Black */;
  30371. y.color = 0 /* Black */;
  30372. x.parent.parent.color = 1 /* Red */;
  30373. x = x.parent.parent;
  30374. }
  30375. else {
  30376. if (x === x.parent.left) {
  30377. x = x.parent;
  30378. rightRotate(tree, x);
  30379. }
  30380. x.parent.color = 0 /* Black */;
  30381. x.parent.parent.color = 1 /* Red */;
  30382. leftRotate(tree, x.parent.parent);
  30383. }
  30384. }
  30385. }
  30386. tree.root.color = 0 /* Black */;
  30387. }
  30388. exports.fixInsert = fixInsert;
  30389. function updateTreeMetadata(tree, x, delta, lineFeedCntDelta) {
  30390. // node length change or line feed count change
  30391. while (x !== tree.root && x !== exports.SENTINEL) {
  30392. if (x.parent.left === x) {
  30393. x.parent.size_left += delta;
  30394. x.parent.lf_left += lineFeedCntDelta;
  30395. }
  30396. x = x.parent;
  30397. }
  30398. }
  30399. exports.updateTreeMetadata = updateTreeMetadata;
  30400. function recomputeTreeMetadata(tree, x) {
  30401. var delta = 0;
  30402. var lf_delta = 0;
  30403. if (x === tree.root) {
  30404. return;
  30405. }
  30406. if (delta === 0) {
  30407. // go upwards till the node whose left subtree is changed.
  30408. while (x !== tree.root && x === x.parent.right) {
  30409. x = x.parent;
  30410. }
  30411. if (x === tree.root) {
  30412. // well, it means we add a node to the end (inorder)
  30413. return;
  30414. }
  30415. // x is the node whose right subtree is changed.
  30416. x = x.parent;
  30417. delta = calculateSize(x.left) - x.size_left;
  30418. lf_delta = calculateLF(x.left) - x.lf_left;
  30419. x.size_left += delta;
  30420. x.lf_left += lf_delta;
  30421. }
  30422. // go upwards till root. O(logN)
  30423. while (x !== tree.root && (delta !== 0 || lf_delta !== 0)) {
  30424. if (x.parent.left === x) {
  30425. x.parent.size_left += delta;
  30426. x.parent.lf_left += lf_delta;
  30427. }
  30428. x = x.parent;
  30429. }
  30430. }
  30431. exports.recomputeTreeMetadata = recomputeTreeMetadata;
  30432. });
  30433. /*---------------------------------------------------------------------------------------------
  30434. * Copyright (c) Microsoft Corporation. All rights reserved.
  30435. * Licensed under the MIT License. See License.txt in the project root for license information.
  30436. *--------------------------------------------------------------------------------------------*/
  30437. define(__m[346/*vs/editor/common/model/textModelEvents*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  30438. "use strict";
  30439. Object.defineProperty(exports, "__esModule", { value: true });
  30440. /**
  30441. * An event describing that a model has been reset to a new value.
  30442. * @internal
  30443. */
  30444. var ModelRawFlush = /** @class */ (function () {
  30445. function ModelRawFlush() {
  30446. this.changeType = 1 /* Flush */;
  30447. }
  30448. return ModelRawFlush;
  30449. }());
  30450. exports.ModelRawFlush = ModelRawFlush;
  30451. /**
  30452. * An event describing that a line has changed in a model.
  30453. * @internal
  30454. */
  30455. var ModelRawLineChanged = /** @class */ (function () {
  30456. function ModelRawLineChanged(lineNumber, detail) {
  30457. this.changeType = 2 /* LineChanged */;
  30458. this.lineNumber = lineNumber;
  30459. this.detail = detail;
  30460. }
  30461. return ModelRawLineChanged;
  30462. }());
  30463. exports.ModelRawLineChanged = ModelRawLineChanged;
  30464. /**
  30465. * An event describing that line(s) have been deleted in a model.
  30466. * @internal
  30467. */
  30468. var ModelRawLinesDeleted = /** @class */ (function () {
  30469. function ModelRawLinesDeleted(fromLineNumber, toLineNumber) {
  30470. this.changeType = 3 /* LinesDeleted */;
  30471. this.fromLineNumber = fromLineNumber;
  30472. this.toLineNumber = toLineNumber;
  30473. }
  30474. return ModelRawLinesDeleted;
  30475. }());
  30476. exports.ModelRawLinesDeleted = ModelRawLinesDeleted;
  30477. /**
  30478. * An event describing that line(s) have been inserted in a model.
  30479. * @internal
  30480. */
  30481. var ModelRawLinesInserted = /** @class */ (function () {
  30482. function ModelRawLinesInserted(fromLineNumber, toLineNumber, detail) {
  30483. this.changeType = 4 /* LinesInserted */;
  30484. this.fromLineNumber = fromLineNumber;
  30485. this.toLineNumber = toLineNumber;
  30486. this.detail = detail;
  30487. }
  30488. return ModelRawLinesInserted;
  30489. }());
  30490. exports.ModelRawLinesInserted = ModelRawLinesInserted;
  30491. /**
  30492. * An event describing that a model has had its EOL changed.
  30493. * @internal
  30494. */
  30495. var ModelRawEOLChanged = /** @class */ (function () {
  30496. function ModelRawEOLChanged() {
  30497. this.changeType = 5 /* EOLChanged */;
  30498. }
  30499. return ModelRawEOLChanged;
  30500. }());
  30501. exports.ModelRawEOLChanged = ModelRawEOLChanged;
  30502. /**
  30503. * An event describing a change in the text of a model.
  30504. * @internal
  30505. */
  30506. var ModelRawContentChangedEvent = /** @class */ (function () {
  30507. function ModelRawContentChangedEvent(changes, versionId, isUndoing, isRedoing) {
  30508. this.changes = changes;
  30509. this.versionId = versionId;
  30510. this.isUndoing = isUndoing;
  30511. this.isRedoing = isRedoing;
  30512. }
  30513. ModelRawContentChangedEvent.prototype.containsEvent = function (type) {
  30514. for (var i = 0, len = this.changes.length; i < len; i++) {
  30515. var change = this.changes[i];
  30516. if (change.changeType === type) {
  30517. return true;
  30518. }
  30519. }
  30520. return false;
  30521. };
  30522. ModelRawContentChangedEvent.merge = function (a, b) {
  30523. var changes = [].concat(a.changes).concat(b.changes);
  30524. var versionId = b.versionId;
  30525. var isUndoing = (a.isUndoing || b.isUndoing);
  30526. var isRedoing = (a.isRedoing || b.isRedoing);
  30527. return new ModelRawContentChangedEvent(changes, versionId, isUndoing, isRedoing);
  30528. };
  30529. return ModelRawContentChangedEvent;
  30530. }());
  30531. exports.ModelRawContentChangedEvent = ModelRawContentChangedEvent;
  30532. /**
  30533. * @internal
  30534. */
  30535. var InternalModelContentChangeEvent = /** @class */ (function () {
  30536. function InternalModelContentChangeEvent(rawContentChangedEvent, contentChangedEvent) {
  30537. this.rawContentChangedEvent = rawContentChangedEvent;
  30538. this.contentChangedEvent = contentChangedEvent;
  30539. }
  30540. InternalModelContentChangeEvent.prototype.merge = function (other) {
  30541. var rawContentChangedEvent = ModelRawContentChangedEvent.merge(this.rawContentChangedEvent, other.rawContentChangedEvent);
  30542. var contentChangedEvent = InternalModelContentChangeEvent._mergeChangeEvents(this.contentChangedEvent, other.contentChangedEvent);
  30543. return new InternalModelContentChangeEvent(rawContentChangedEvent, contentChangedEvent);
  30544. };
  30545. InternalModelContentChangeEvent._mergeChangeEvents = function (a, b) {
  30546. var changes = [].concat(a.changes).concat(b.changes);
  30547. var eol = b.eol;
  30548. var versionId = b.versionId;
  30549. var isUndoing = (a.isUndoing || b.isUndoing);
  30550. var isRedoing = (a.isRedoing || b.isRedoing);
  30551. var isFlush = (a.isFlush || b.isFlush);
  30552. return {
  30553. changes: changes,
  30554. eol: eol,
  30555. versionId: versionId,
  30556. isUndoing: isUndoing,
  30557. isRedoing: isRedoing,
  30558. isFlush: isFlush
  30559. };
  30560. };
  30561. return InternalModelContentChangeEvent;
  30562. }());
  30563. exports.InternalModelContentChangeEvent = InternalModelContentChangeEvent;
  30564. });
  30565. /*---------------------------------------------------------------------------------------------
  30566. * Copyright (c) Microsoft Corporation. All rights reserved.
  30567. * Licensed under the MIT License. See License.txt in the project root for license information.
  30568. *--------------------------------------------------------------------------------------------*/
  30569. define(__m[144/*vs/editor/common/model/textModelSearch*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,89/*vs/editor/common/controller/wordCharacterClassifier*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,48/*vs/editor/common/model*/]), function (require, exports, strings, wordCharacterClassifier_1, position_1, range_1, model_1) {
  30570. "use strict";
  30571. Object.defineProperty(exports, "__esModule", { value: true });
  30572. var LIMIT_FIND_COUNT = 999;
  30573. var SearchParams = /** @class */ (function () {
  30574. function SearchParams(searchString, isRegex, matchCase, wordSeparators) {
  30575. this.searchString = searchString;
  30576. this.isRegex = isRegex;
  30577. this.matchCase = matchCase;
  30578. this.wordSeparators = wordSeparators;
  30579. }
  30580. SearchParams.prototype.parseSearchRequest = function () {
  30581. if (this.searchString === '') {
  30582. return null;
  30583. }
  30584. // Try to create a RegExp out of the params
  30585. var multiline;
  30586. if (this.isRegex) {
  30587. multiline = isMultilineRegexSource(this.searchString);
  30588. }
  30589. else {
  30590. multiline = (this.searchString.indexOf('\n') >= 0);
  30591. }
  30592. var regex = null;
  30593. try {
  30594. regex = strings.createRegExp(this.searchString, this.isRegex, {
  30595. matchCase: this.matchCase,
  30596. wholeWord: false,
  30597. multiline: multiline,
  30598. global: true,
  30599. unicode: true
  30600. });
  30601. }
  30602. catch (err) {
  30603. return null;
  30604. }
  30605. if (!regex) {
  30606. return null;
  30607. }
  30608. var canUseSimpleSearch = (!this.isRegex && !multiline);
  30609. if (canUseSimpleSearch && this.searchString.toLowerCase() !== this.searchString.toUpperCase()) {
  30610. // casing might make a difference
  30611. canUseSimpleSearch = this.matchCase;
  30612. }
  30613. return new SearchData(regex, this.wordSeparators ? wordCharacterClassifier_1.getMapForWordSeparators(this.wordSeparators) : null, canUseSimpleSearch ? this.searchString : null);
  30614. };
  30615. return SearchParams;
  30616. }());
  30617. exports.SearchParams = SearchParams;
  30618. function isMultilineRegexSource(searchString) {
  30619. if (!searchString || searchString.length === 0) {
  30620. return false;
  30621. }
  30622. for (var i = 0, len = searchString.length; i < len; i++) {
  30623. var chCode = searchString.charCodeAt(i);
  30624. if (chCode === 92 /* Backslash */) {
  30625. // move to next char
  30626. i++;
  30627. if (i >= len) {
  30628. // string ends with a \
  30629. break;
  30630. }
  30631. var nextChCode = searchString.charCodeAt(i);
  30632. if (nextChCode === 110 /* n */ || nextChCode === 114 /* r */ || nextChCode === 87 /* W */ || nextChCode === 119 /* w */) {
  30633. return true;
  30634. }
  30635. }
  30636. }
  30637. return false;
  30638. }
  30639. exports.isMultilineRegexSource = isMultilineRegexSource;
  30640. var SearchData = /** @class */ (function () {
  30641. function SearchData(regex, wordSeparators, simpleSearch) {
  30642. this.regex = regex;
  30643. this.wordSeparators = wordSeparators;
  30644. this.simpleSearch = simpleSearch;
  30645. }
  30646. return SearchData;
  30647. }());
  30648. exports.SearchData = SearchData;
  30649. function createFindMatch(range, rawMatches, captureMatches) {
  30650. if (!captureMatches) {
  30651. return new model_1.FindMatch(range, null);
  30652. }
  30653. var matches = [];
  30654. for (var i = 0, len = rawMatches.length; i < len; i++) {
  30655. matches[i] = rawMatches[i];
  30656. }
  30657. return new model_1.FindMatch(range, matches);
  30658. }
  30659. exports.createFindMatch = createFindMatch;
  30660. var LineFeedCounter = /** @class */ (function () {
  30661. function LineFeedCounter(text) {
  30662. var lineFeedsOffsets = [];
  30663. var lineFeedsOffsetsLen = 0;
  30664. for (var i = 0, textLen = text.length; i < textLen; i++) {
  30665. if (text.charCodeAt(i) === 10 /* LineFeed */) {
  30666. lineFeedsOffsets[lineFeedsOffsetsLen++] = i;
  30667. }
  30668. }
  30669. this._lineFeedsOffsets = lineFeedsOffsets;
  30670. }
  30671. LineFeedCounter.prototype.findLineFeedCountBeforeOffset = function (offset) {
  30672. var lineFeedsOffsets = this._lineFeedsOffsets;
  30673. var min = 0;
  30674. var max = lineFeedsOffsets.length - 1;
  30675. if (max === -1) {
  30676. // no line feeds
  30677. return 0;
  30678. }
  30679. if (offset <= lineFeedsOffsets[0]) {
  30680. // before first line feed
  30681. return 0;
  30682. }
  30683. while (min < max) {
  30684. var mid = min + ((max - min) / 2 >> 0);
  30685. if (lineFeedsOffsets[mid] >= offset) {
  30686. max = mid - 1;
  30687. }
  30688. else {
  30689. if (lineFeedsOffsets[mid + 1] >= offset) {
  30690. // bingo!
  30691. min = mid;
  30692. max = mid;
  30693. }
  30694. else {
  30695. min = mid + 1;
  30696. }
  30697. }
  30698. }
  30699. return min + 1;
  30700. };
  30701. return LineFeedCounter;
  30702. }());
  30703. var TextModelSearch = /** @class */ (function () {
  30704. function TextModelSearch() {
  30705. }
  30706. TextModelSearch.findMatches = function (model, searchParams, searchRange, captureMatches, limitResultCount) {
  30707. var searchData = searchParams.parseSearchRequest();
  30708. if (!searchData) {
  30709. return [];
  30710. }
  30711. if (searchData.regex.multiline) {
  30712. return this._doFindMatchesMultiline(model, searchRange, new Searcher(searchData.wordSeparators, searchData.regex), captureMatches, limitResultCount);
  30713. }
  30714. return this._doFindMatchesLineByLine(model, searchRange, searchData, captureMatches, limitResultCount);
  30715. };
  30716. /**
  30717. * Multiline search always executes on the lines concatenated with \n.
  30718. * We must therefore compensate for the count of \n in case the model is CRLF
  30719. */
  30720. TextModelSearch._getMultilineMatchRange = function (model, deltaOffset, text, lfCounter, matchIndex, match0) {
  30721. var startOffset;
  30722. var lineFeedCountBeforeMatch = 0;
  30723. if (lfCounter) {
  30724. lineFeedCountBeforeMatch = lfCounter.findLineFeedCountBeforeOffset(matchIndex);
  30725. startOffset = deltaOffset + matchIndex + lineFeedCountBeforeMatch /* add as many \r as there were \n */;
  30726. }
  30727. else {
  30728. startOffset = deltaOffset + matchIndex;
  30729. }
  30730. var endOffset;
  30731. if (lfCounter) {
  30732. var lineFeedCountBeforeEndOfMatch = lfCounter.findLineFeedCountBeforeOffset(matchIndex + match0.length);
  30733. var lineFeedCountInMatch = lineFeedCountBeforeEndOfMatch - lineFeedCountBeforeMatch;
  30734. endOffset = startOffset + match0.length + lineFeedCountInMatch /* add as many \r as there were \n */;
  30735. }
  30736. else {
  30737. endOffset = startOffset + match0.length;
  30738. }
  30739. var startPosition = model.getPositionAt(startOffset);
  30740. var endPosition = model.getPositionAt(endOffset);
  30741. return new range_1.Range(startPosition.lineNumber, startPosition.column, endPosition.lineNumber, endPosition.column);
  30742. };
  30743. TextModelSearch._doFindMatchesMultiline = function (model, searchRange, searcher, captureMatches, limitResultCount) {
  30744. var deltaOffset = model.getOffsetAt(searchRange.getStartPosition());
  30745. // We always execute multiline search over the lines joined with \n
  30746. // This makes it that \n will match the EOL for both CRLF and LF models
  30747. // We compensate for offset errors in `_getMultilineMatchRange`
  30748. var text = model.getValueInRange(searchRange, 1 /* LF */);
  30749. var lfCounter = (model.getEOL() === '\r\n' ? new LineFeedCounter(text) : null);
  30750. var result = [];
  30751. var counter = 0;
  30752. var m;
  30753. searcher.reset(0);
  30754. while ((m = searcher.next(text))) {
  30755. result[counter++] = createFindMatch(this._getMultilineMatchRange(model, deltaOffset, text, lfCounter, m.index, m[0]), m, captureMatches);
  30756. if (counter >= limitResultCount) {
  30757. return result;
  30758. }
  30759. }
  30760. return result;
  30761. };
  30762. TextModelSearch._doFindMatchesLineByLine = function (model, searchRange, searchData, captureMatches, limitResultCount) {
  30763. var result = [];
  30764. var resultLen = 0;
  30765. // Early case for a search range that starts & stops on the same line number
  30766. if (searchRange.startLineNumber === searchRange.endLineNumber) {
  30767. var text_1 = model.getLineContent(searchRange.startLineNumber).substring(searchRange.startColumn - 1, searchRange.endColumn - 1);
  30768. resultLen = this._findMatchesInLine(searchData, text_1, searchRange.startLineNumber, searchRange.startColumn - 1, resultLen, result, captureMatches, limitResultCount);
  30769. return result;
  30770. }
  30771. // Collect results from first line
  30772. var text = model.getLineContent(searchRange.startLineNumber).substring(searchRange.startColumn - 1);
  30773. resultLen = this._findMatchesInLine(searchData, text, searchRange.startLineNumber, searchRange.startColumn - 1, resultLen, result, captureMatches, limitResultCount);
  30774. // Collect results from middle lines
  30775. for (var lineNumber = searchRange.startLineNumber + 1; lineNumber < searchRange.endLineNumber && resultLen < limitResultCount; lineNumber++) {
  30776. resultLen = this._findMatchesInLine(searchData, model.getLineContent(lineNumber), lineNumber, 0, resultLen, result, captureMatches, limitResultCount);
  30777. }
  30778. // Collect results from last line
  30779. if (resultLen < limitResultCount) {
  30780. var text_2 = model.getLineContent(searchRange.endLineNumber).substring(0, searchRange.endColumn - 1);
  30781. resultLen = this._findMatchesInLine(searchData, text_2, searchRange.endLineNumber, 0, resultLen, result, captureMatches, limitResultCount);
  30782. }
  30783. return result;
  30784. };
  30785. TextModelSearch._findMatchesInLine = function (searchData, text, lineNumber, deltaOffset, resultLen, result, captureMatches, limitResultCount) {
  30786. var wordSeparators = searchData.wordSeparators;
  30787. if (!captureMatches && searchData.simpleSearch) {
  30788. var searchString = searchData.simpleSearch;
  30789. var searchStringLen = searchString.length;
  30790. var textLength = text.length;
  30791. var lastMatchIndex = -searchStringLen;
  30792. while ((lastMatchIndex = text.indexOf(searchString, lastMatchIndex + searchStringLen)) !== -1) {
  30793. if (!wordSeparators || isValidMatch(wordSeparators, text, textLength, lastMatchIndex, searchStringLen)) {
  30794. result[resultLen++] = new model_1.FindMatch(new range_1.Range(lineNumber, lastMatchIndex + 1 + deltaOffset, lineNumber, lastMatchIndex + 1 + searchStringLen + deltaOffset), null);
  30795. if (resultLen >= limitResultCount) {
  30796. return resultLen;
  30797. }
  30798. }
  30799. }
  30800. return resultLen;
  30801. }
  30802. var searcher = new Searcher(searchData.wordSeparators, searchData.regex);
  30803. var m;
  30804. // Reset regex to search from the beginning
  30805. searcher.reset(0);
  30806. do {
  30807. m = searcher.next(text);
  30808. if (m) {
  30809. result[resultLen++] = createFindMatch(new range_1.Range(lineNumber, m.index + 1 + deltaOffset, lineNumber, m.index + 1 + m[0].length + deltaOffset), m, captureMatches);
  30810. if (resultLen >= limitResultCount) {
  30811. return resultLen;
  30812. }
  30813. }
  30814. } while (m);
  30815. return resultLen;
  30816. };
  30817. TextModelSearch.findNextMatch = function (model, searchParams, searchStart, captureMatches) {
  30818. var searchData = searchParams.parseSearchRequest();
  30819. if (!searchData) {
  30820. return null;
  30821. }
  30822. var searcher = new Searcher(searchData.wordSeparators, searchData.regex);
  30823. if (searchData.regex.multiline) {
  30824. return this._doFindNextMatchMultiline(model, searchStart, searcher, captureMatches);
  30825. }
  30826. return this._doFindNextMatchLineByLine(model, searchStart, searcher, captureMatches);
  30827. };
  30828. TextModelSearch._doFindNextMatchMultiline = function (model, searchStart, searcher, captureMatches) {
  30829. var searchTextStart = new position_1.Position(searchStart.lineNumber, 1);
  30830. var deltaOffset = model.getOffsetAt(searchTextStart);
  30831. var lineCount = model.getLineCount();
  30832. // We always execute multiline search over the lines joined with \n
  30833. // This makes it that \n will match the EOL for both CRLF and LF models
  30834. // We compensate for offset errors in `_getMultilineMatchRange`
  30835. var text = model.getValueInRange(new range_1.Range(searchTextStart.lineNumber, searchTextStart.column, lineCount, model.getLineMaxColumn(lineCount)), 1 /* LF */);
  30836. var lfCounter = (model.getEOL() === '\r\n' ? new LineFeedCounter(text) : null);
  30837. searcher.reset(searchStart.column - 1);
  30838. var m = searcher.next(text);
  30839. if (m) {
  30840. return createFindMatch(this._getMultilineMatchRange(model, deltaOffset, text, lfCounter, m.index, m[0]), m, captureMatches);
  30841. }
  30842. if (searchStart.lineNumber !== 1 || searchStart.column !== 1) {
  30843. // Try again from the top
  30844. return this._doFindNextMatchMultiline(model, new position_1.Position(1, 1), searcher, captureMatches);
  30845. }
  30846. return null;
  30847. };
  30848. TextModelSearch._doFindNextMatchLineByLine = function (model, searchStart, searcher, captureMatches) {
  30849. var lineCount = model.getLineCount();
  30850. var startLineNumber = searchStart.lineNumber;
  30851. // Look in first line
  30852. var text = model.getLineContent(startLineNumber);
  30853. var r = this._findFirstMatchInLine(searcher, text, startLineNumber, searchStart.column, captureMatches);
  30854. if (r) {
  30855. return r;
  30856. }
  30857. for (var i = 1; i <= lineCount; i++) {
  30858. var lineIndex = (startLineNumber + i - 1) % lineCount;
  30859. var text_3 = model.getLineContent(lineIndex + 1);
  30860. var r_1 = this._findFirstMatchInLine(searcher, text_3, lineIndex + 1, 1, captureMatches);
  30861. if (r_1) {
  30862. return r_1;
  30863. }
  30864. }
  30865. return null;
  30866. };
  30867. TextModelSearch._findFirstMatchInLine = function (searcher, text, lineNumber, fromColumn, captureMatches) {
  30868. // Set regex to search from column
  30869. searcher.reset(fromColumn - 1);
  30870. var m = searcher.next(text);
  30871. if (m) {
  30872. return createFindMatch(new range_1.Range(lineNumber, m.index + 1, lineNumber, m.index + 1 + m[0].length), m, captureMatches);
  30873. }
  30874. return null;
  30875. };
  30876. TextModelSearch.findPreviousMatch = function (model, searchParams, searchStart, captureMatches) {
  30877. var searchData = searchParams.parseSearchRequest();
  30878. if (!searchData) {
  30879. return null;
  30880. }
  30881. var searcher = new Searcher(searchData.wordSeparators, searchData.regex);
  30882. if (searchData.regex.multiline) {
  30883. return this._doFindPreviousMatchMultiline(model, searchStart, searcher, captureMatches);
  30884. }
  30885. return this._doFindPreviousMatchLineByLine(model, searchStart, searcher, captureMatches);
  30886. };
  30887. TextModelSearch._doFindPreviousMatchMultiline = function (model, searchStart, searcher, captureMatches) {
  30888. var matches = this._doFindMatchesMultiline(model, new range_1.Range(1, 1, searchStart.lineNumber, searchStart.column), searcher, captureMatches, 10 * LIMIT_FIND_COUNT);
  30889. if (matches.length > 0) {
  30890. return matches[matches.length - 1];
  30891. }
  30892. var lineCount = model.getLineCount();
  30893. if (searchStart.lineNumber !== lineCount || searchStart.column !== model.getLineMaxColumn(lineCount)) {
  30894. // Try again with all content
  30895. return this._doFindPreviousMatchMultiline(model, new position_1.Position(lineCount, model.getLineMaxColumn(lineCount)), searcher, captureMatches);
  30896. }
  30897. return null;
  30898. };
  30899. TextModelSearch._doFindPreviousMatchLineByLine = function (model, searchStart, searcher, captureMatches) {
  30900. var lineCount = model.getLineCount();
  30901. var startLineNumber = searchStart.lineNumber;
  30902. // Look in first line
  30903. var text = model.getLineContent(startLineNumber).substring(0, searchStart.column - 1);
  30904. var r = this._findLastMatchInLine(searcher, text, startLineNumber, captureMatches);
  30905. if (r) {
  30906. return r;
  30907. }
  30908. for (var i = 1; i <= lineCount; i++) {
  30909. var lineIndex = (lineCount + startLineNumber - i - 1) % lineCount;
  30910. var text_4 = model.getLineContent(lineIndex + 1);
  30911. var r_2 = this._findLastMatchInLine(searcher, text_4, lineIndex + 1, captureMatches);
  30912. if (r_2) {
  30913. return r_2;
  30914. }
  30915. }
  30916. return null;
  30917. };
  30918. TextModelSearch._findLastMatchInLine = function (searcher, text, lineNumber, captureMatches) {
  30919. var bestResult = null;
  30920. var m;
  30921. searcher.reset(0);
  30922. while ((m = searcher.next(text))) {
  30923. bestResult = createFindMatch(new range_1.Range(lineNumber, m.index + 1, lineNumber, m.index + 1 + m[0].length), m, captureMatches);
  30924. }
  30925. return bestResult;
  30926. };
  30927. return TextModelSearch;
  30928. }());
  30929. exports.TextModelSearch = TextModelSearch;
  30930. function leftIsWordBounday(wordSeparators, text, textLength, matchStartIndex, matchLength) {
  30931. if (matchStartIndex === 0) {
  30932. // Match starts at start of string
  30933. return true;
  30934. }
  30935. var charBefore = text.charCodeAt(matchStartIndex - 1);
  30936. if (wordSeparators.get(charBefore) !== 0 /* Regular */) {
  30937. // The character before the match is a word separator
  30938. return true;
  30939. }
  30940. if (charBefore === 13 /* CarriageReturn */ || charBefore === 10 /* LineFeed */) {
  30941. // The character before the match is line break or carriage return.
  30942. return true;
  30943. }
  30944. if (matchLength > 0) {
  30945. var firstCharInMatch = text.charCodeAt(matchStartIndex);
  30946. if (wordSeparators.get(firstCharInMatch) !== 0 /* Regular */) {
  30947. // The first character inside the match is a word separator
  30948. return true;
  30949. }
  30950. }
  30951. return false;
  30952. }
  30953. function rightIsWordBounday(wordSeparators, text, textLength, matchStartIndex, matchLength) {
  30954. if (matchStartIndex + matchLength === textLength) {
  30955. // Match ends at end of string
  30956. return true;
  30957. }
  30958. var charAfter = text.charCodeAt(matchStartIndex + matchLength);
  30959. if (wordSeparators.get(charAfter) !== 0 /* Regular */) {
  30960. // The character after the match is a word separator
  30961. return true;
  30962. }
  30963. if (charAfter === 13 /* CarriageReturn */ || charAfter === 10 /* LineFeed */) {
  30964. // The character after the match is line break or carriage return.
  30965. return true;
  30966. }
  30967. if (matchLength > 0) {
  30968. var lastCharInMatch = text.charCodeAt(matchStartIndex + matchLength - 1);
  30969. if (wordSeparators.get(lastCharInMatch) !== 0 /* Regular */) {
  30970. // The last character in the match is a word separator
  30971. return true;
  30972. }
  30973. }
  30974. return false;
  30975. }
  30976. function isValidMatch(wordSeparators, text, textLength, matchStartIndex, matchLength) {
  30977. return (leftIsWordBounday(wordSeparators, text, textLength, matchStartIndex, matchLength)
  30978. && rightIsWordBounday(wordSeparators, text, textLength, matchStartIndex, matchLength));
  30979. }
  30980. exports.isValidMatch = isValidMatch;
  30981. var Searcher = /** @class */ (function () {
  30982. function Searcher(wordSeparators, searchRegex) {
  30983. this._wordSeparators = wordSeparators;
  30984. this._searchRegex = searchRegex;
  30985. this._prevMatchStartIndex = -1;
  30986. this._prevMatchLength = 0;
  30987. }
  30988. Searcher.prototype.reset = function (lastIndex) {
  30989. this._searchRegex.lastIndex = lastIndex;
  30990. this._prevMatchStartIndex = -1;
  30991. this._prevMatchLength = 0;
  30992. };
  30993. Searcher.prototype.next = function (text) {
  30994. var textLength = text.length;
  30995. var m;
  30996. do {
  30997. if (this._prevMatchStartIndex + this._prevMatchLength === textLength) {
  30998. // Reached the end of the line
  30999. return null;
  31000. }
  31001. m = this._searchRegex.exec(text);
  31002. if (!m) {
  31003. return null;
  31004. }
  31005. var matchStartIndex = m.index;
  31006. var matchLength = m[0].length;
  31007. if (matchStartIndex === this._prevMatchStartIndex && matchLength === this._prevMatchLength) {
  31008. if (matchLength === 0) {
  31009. // the search result is an empty string and won't advance `regex.lastIndex`, so `regex.exec` will stuck here
  31010. // we attempt to recover from that by advancing by one
  31011. this._searchRegex.lastIndex += 1;
  31012. continue;
  31013. }
  31014. // Exit early if the regex matches the same range twice
  31015. return null;
  31016. }
  31017. this._prevMatchStartIndex = matchStartIndex;
  31018. this._prevMatchLength = matchLength;
  31019. if (!this._wordSeparators || isValidMatch(this._wordSeparators, text, textLength, matchStartIndex, matchLength)) {
  31020. return m;
  31021. }
  31022. } while (m);
  31023. return null;
  31024. };
  31025. return Searcher;
  31026. }());
  31027. exports.Searcher = Searcher;
  31028. });
  31029. /*---------------------------------------------------------------------------------------------
  31030. * Copyright (c) Microsoft Corporation. All rights reserved.
  31031. * Licensed under the MIT License. See License.txt in the project root for license information.
  31032. *--------------------------------------------------------------------------------------------*/
  31033. define(__m[191/*vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase*/], __M([0/*require*/,1/*exports*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,48/*vs/editor/common/model*/,345/*vs/editor/common/model/pieceTreeTextBuffer/rbTreeBase*/,144/*vs/editor/common/model/textModelSearch*/]), function (require, exports, position_1, range_1, model_1, rbTreeBase_1, textModelSearch_1) {
  31034. "use strict";
  31035. Object.defineProperty(exports, "__esModule", { value: true });
  31036. // const lfRegex = new RegExp(/\r\n|\r|\n/g);
  31037. exports.AverageBufferSize = 65535;
  31038. function createUintArray(arr) {
  31039. var r;
  31040. if (arr[arr.length - 1] < 65536) {
  31041. r = new Uint16Array(arr.length);
  31042. }
  31043. else {
  31044. r = new Uint32Array(arr.length);
  31045. }
  31046. r.set(arr, 0);
  31047. return r;
  31048. }
  31049. exports.createUintArray = createUintArray;
  31050. var LineStarts = /** @class */ (function () {
  31051. function LineStarts(lineStarts, cr, lf, crlf, isBasicASCII) {
  31052. this.lineStarts = lineStarts;
  31053. this.cr = cr;
  31054. this.lf = lf;
  31055. this.crlf = crlf;
  31056. this.isBasicASCII = isBasicASCII;
  31057. }
  31058. return LineStarts;
  31059. }());
  31060. exports.LineStarts = LineStarts;
  31061. function createLineStartsFast(str, readonly) {
  31062. if (readonly === void 0) { readonly = true; }
  31063. var r = [0], rLength = 1;
  31064. for (var i = 0, len = str.length; i < len; i++) {
  31065. var chr = str.charCodeAt(i);
  31066. if (chr === 13 /* CarriageReturn */) {
  31067. if (i + 1 < len && str.charCodeAt(i + 1) === 10 /* LineFeed */) {
  31068. // \r\n... case
  31069. r[rLength++] = i + 2;
  31070. i++; // skip \n
  31071. }
  31072. else {
  31073. // \r... case
  31074. r[rLength++] = i + 1;
  31075. }
  31076. }
  31077. else if (chr === 10 /* LineFeed */) {
  31078. r[rLength++] = i + 1;
  31079. }
  31080. }
  31081. if (readonly) {
  31082. return createUintArray(r);
  31083. }
  31084. else {
  31085. return r;
  31086. }
  31087. }
  31088. exports.createLineStartsFast = createLineStartsFast;
  31089. function createLineStarts(r, str) {
  31090. r.length = 0;
  31091. r[0] = 0;
  31092. var rLength = 1;
  31093. var cr = 0, lf = 0, crlf = 0;
  31094. var isBasicASCII = true;
  31095. for (var i = 0, len = str.length; i < len; i++) {
  31096. var chr = str.charCodeAt(i);
  31097. if (chr === 13 /* CarriageReturn */) {
  31098. if (i + 1 < len && str.charCodeAt(i + 1) === 10 /* LineFeed */) {
  31099. // \r\n... case
  31100. crlf++;
  31101. r[rLength++] = i + 2;
  31102. i++; // skip \n
  31103. }
  31104. else {
  31105. cr++;
  31106. // \r... case
  31107. r[rLength++] = i + 1;
  31108. }
  31109. }
  31110. else if (chr === 10 /* LineFeed */) {
  31111. lf++;
  31112. r[rLength++] = i + 1;
  31113. }
  31114. else {
  31115. if (isBasicASCII) {
  31116. if (chr !== 9 /* Tab */ && (chr < 32 || chr > 126)) {
  31117. isBasicASCII = false;
  31118. }
  31119. }
  31120. }
  31121. }
  31122. var result = new LineStarts(createUintArray(r), cr, lf, crlf, isBasicASCII);
  31123. r.length = 0;
  31124. return result;
  31125. }
  31126. exports.createLineStarts = createLineStarts;
  31127. var Piece = /** @class */ (function () {
  31128. function Piece(bufferIndex, start, end, lineFeedCnt, length) {
  31129. this.bufferIndex = bufferIndex;
  31130. this.start = start;
  31131. this.end = end;
  31132. this.lineFeedCnt = lineFeedCnt;
  31133. this.length = length;
  31134. }
  31135. return Piece;
  31136. }());
  31137. exports.Piece = Piece;
  31138. var StringBuffer = /** @class */ (function () {
  31139. function StringBuffer(buffer, lineStarts) {
  31140. this.buffer = buffer;
  31141. this.lineStarts = lineStarts;
  31142. }
  31143. return StringBuffer;
  31144. }());
  31145. exports.StringBuffer = StringBuffer;
  31146. var PieceTreeSearchCache = /** @class */ (function () {
  31147. function PieceTreeSearchCache(limit) {
  31148. this._limit = limit;
  31149. this._cache = [];
  31150. }
  31151. PieceTreeSearchCache.prototype.get = function (offset) {
  31152. for (var i = this._cache.length - 1; i >= 0; i--) {
  31153. var nodePos = this._cache[i];
  31154. if (nodePos.nodeStartOffset <= offset && nodePos.nodeStartOffset + nodePos.node.piece.length >= offset) {
  31155. return nodePos;
  31156. }
  31157. }
  31158. return null;
  31159. };
  31160. PieceTreeSearchCache.prototype.get2 = function (lineNumber) {
  31161. for (var i = this._cache.length - 1; i >= 0; i--) {
  31162. var nodePos = this._cache[i];
  31163. if (nodePos.nodeStartLineNumber && nodePos.nodeStartLineNumber < lineNumber && nodePos.nodeStartLineNumber + nodePos.node.piece.lineFeedCnt >= lineNumber) {
  31164. return nodePos;
  31165. }
  31166. }
  31167. return null;
  31168. };
  31169. PieceTreeSearchCache.prototype.set = function (nodePosition) {
  31170. if (this._cache.length >= this._limit) {
  31171. this._cache.shift();
  31172. }
  31173. this._cache.push(nodePosition);
  31174. };
  31175. PieceTreeSearchCache.prototype.valdiate = function (offset) {
  31176. var hasInvalidVal = false;
  31177. var tmp = this._cache;
  31178. for (var i = 0; i < tmp.length; i++) {
  31179. var nodePos = tmp[i];
  31180. if (nodePos.node.parent === null || nodePos.nodeStartOffset >= offset) {
  31181. tmp[i] = null;
  31182. hasInvalidVal = true;
  31183. continue;
  31184. }
  31185. }
  31186. if (hasInvalidVal) {
  31187. var newArr = [];
  31188. for (var _i = 0, tmp_1 = tmp; _i < tmp_1.length; _i++) {
  31189. var entry = tmp_1[_i];
  31190. if (entry !== null) {
  31191. newArr.push(entry);
  31192. }
  31193. }
  31194. this._cache = newArr;
  31195. }
  31196. };
  31197. return PieceTreeSearchCache;
  31198. }());
  31199. var PieceTreeBase = /** @class */ (function () {
  31200. function PieceTreeBase(chunks, eol, eolNormalized) {
  31201. this.create(chunks, eol, eolNormalized);
  31202. }
  31203. PieceTreeBase.prototype.create = function (chunks, eol, eolNormalized) {
  31204. this._buffers = [
  31205. new StringBuffer('', [0])
  31206. ];
  31207. this._lastChangeBufferPos = { line: 0, column: 0 };
  31208. this.root = rbTreeBase_1.SENTINEL;
  31209. this._lineCnt = 1;
  31210. this._length = 0;
  31211. this._EOL = eol;
  31212. this._EOLLength = eol.length;
  31213. this._EOLNormalized = eolNormalized;
  31214. var lastNode = null;
  31215. for (var i = 0, len = chunks.length; i < len; i++) {
  31216. if (chunks[i].buffer.length > 0) {
  31217. if (!chunks[i].lineStarts) {
  31218. chunks[i].lineStarts = createLineStartsFast(chunks[i].buffer);
  31219. }
  31220. var piece = new Piece(i + 1, { line: 0, column: 0 }, { line: chunks[i].lineStarts.length - 1, column: chunks[i].buffer.length - chunks[i].lineStarts[chunks[i].lineStarts.length - 1] }, chunks[i].lineStarts.length - 1, chunks[i].buffer.length);
  31221. this._buffers.push(chunks[i]);
  31222. lastNode = this.rbInsertRight(lastNode, piece);
  31223. }
  31224. }
  31225. this._searchCache = new PieceTreeSearchCache(1);
  31226. this._lastVisitedLine = { lineNumber: 0, value: '' };
  31227. this.computeBufferMetadata();
  31228. };
  31229. PieceTreeBase.prototype.normalizeEOL = function (eol) {
  31230. var _this = this;
  31231. var averageBufferSize = exports.AverageBufferSize;
  31232. var min = averageBufferSize - Math.floor(averageBufferSize / 3);
  31233. var max = min * 2;
  31234. var tempChunk = '';
  31235. var tempChunkLen = 0;
  31236. var chunks = [];
  31237. this.iterate(this.root, function (node) {
  31238. var str = _this.getNodeContent(node);
  31239. var len = str.length;
  31240. if (tempChunkLen <= min || tempChunkLen + len < max) {
  31241. tempChunk += str;
  31242. tempChunkLen += len;
  31243. return true;
  31244. }
  31245. // flush anyways
  31246. var text = tempChunk.replace(/\r\n|\r|\n/g, eol);
  31247. chunks.push(new StringBuffer(text, createLineStartsFast(text)));
  31248. tempChunk = str;
  31249. tempChunkLen = len;
  31250. return true;
  31251. });
  31252. if (tempChunkLen > 0) {
  31253. var text = tempChunk.replace(/\r\n|\r|\n/g, eol);
  31254. chunks.push(new StringBuffer(text, createLineStartsFast(text)));
  31255. }
  31256. this.create(chunks, eol, true);
  31257. };
  31258. // #region Buffer API
  31259. PieceTreeBase.prototype.getEOL = function () {
  31260. return this._EOL;
  31261. };
  31262. PieceTreeBase.prototype.setEOL = function (newEOL) {
  31263. this._EOL = newEOL;
  31264. this._EOLLength = this._EOL.length;
  31265. this.normalizeEOL(newEOL);
  31266. };
  31267. PieceTreeBase.prototype.getOffsetAt = function (lineNumber, column) {
  31268. var leftLen = 0; // inorder
  31269. var x = this.root;
  31270. while (x !== rbTreeBase_1.SENTINEL) {
  31271. if (x.left !== rbTreeBase_1.SENTINEL && x.lf_left + 1 >= lineNumber) {
  31272. x = x.left;
  31273. }
  31274. else if (x.lf_left + x.piece.lineFeedCnt + 1 >= lineNumber) {
  31275. leftLen += x.size_left;
  31276. // lineNumber >= 2
  31277. var accumualtedValInCurrentIndex = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
  31278. return leftLen += accumualtedValInCurrentIndex + column - 1;
  31279. }
  31280. else {
  31281. lineNumber -= x.lf_left + x.piece.lineFeedCnt;
  31282. leftLen += x.size_left + x.piece.length;
  31283. x = x.right;
  31284. }
  31285. }
  31286. return leftLen;
  31287. };
  31288. PieceTreeBase.prototype.getPositionAt = function (offset) {
  31289. offset = Math.floor(offset);
  31290. offset = Math.max(0, offset);
  31291. var x = this.root;
  31292. var lfCnt = 0;
  31293. var originalOffset = offset;
  31294. while (x !== rbTreeBase_1.SENTINEL) {
  31295. if (x.size_left !== 0 && x.size_left >= offset) {
  31296. x = x.left;
  31297. }
  31298. else if (x.size_left + x.piece.length >= offset) {
  31299. var out = this.getIndexOf(x, offset - x.size_left);
  31300. lfCnt += x.lf_left + out.index;
  31301. if (out.index === 0) {
  31302. var lineStartOffset = this.getOffsetAt(lfCnt + 1, 1);
  31303. var column = originalOffset - lineStartOffset;
  31304. return new position_1.Position(lfCnt + 1, column + 1);
  31305. }
  31306. return new position_1.Position(lfCnt + 1, out.remainder + 1);
  31307. }
  31308. else {
  31309. offset -= x.size_left + x.piece.length;
  31310. lfCnt += x.lf_left + x.piece.lineFeedCnt;
  31311. if (x.right === rbTreeBase_1.SENTINEL) {
  31312. // last node
  31313. var lineStartOffset = this.getOffsetAt(lfCnt + 1, 1);
  31314. var column = originalOffset - offset - lineStartOffset;
  31315. return new position_1.Position(lfCnt + 1, column + 1);
  31316. }
  31317. else {
  31318. x = x.right;
  31319. }
  31320. }
  31321. }
  31322. return new position_1.Position(1, 1);
  31323. };
  31324. PieceTreeBase.prototype.getValueInRange = function (range, eol) {
  31325. if (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn) {
  31326. return '';
  31327. }
  31328. var startPosition = this.nodeAt2(range.startLineNumber, range.startColumn);
  31329. var endPosition = this.nodeAt2(range.endLineNumber, range.endColumn);
  31330. var value = this.getValueInRange2(startPosition, endPosition);
  31331. if (eol) {
  31332. if (eol !== this._EOL || !this._EOLNormalized) {
  31333. return value.replace(/\r\n|\r|\n/g, eol);
  31334. }
  31335. if (eol === this.getEOL() && this._EOLNormalized) {
  31336. if (eol === '\r\n') {
  31337. }
  31338. return value;
  31339. }
  31340. return value.replace(/\r\n|\r|\n/g, eol);
  31341. }
  31342. return value;
  31343. };
  31344. PieceTreeBase.prototype.getValueInRange2 = function (startPosition, endPosition) {
  31345. if (startPosition.node === endPosition.node) {
  31346. var node = startPosition.node;
  31347. var buffer_1 = this._buffers[node.piece.bufferIndex].buffer;
  31348. var startOffset_1 = this.offsetInBuffer(node.piece.bufferIndex, node.piece.start);
  31349. return buffer_1.substring(startOffset_1 + startPosition.remainder, startOffset_1 + endPosition.remainder);
  31350. }
  31351. var x = startPosition.node;
  31352. var buffer = this._buffers[x.piece.bufferIndex].buffer;
  31353. var startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
  31354. var ret = buffer.substring(startOffset + startPosition.remainder, startOffset + x.piece.length);
  31355. x = x.next();
  31356. while (x !== rbTreeBase_1.SENTINEL) {
  31357. var buffer_2 = this._buffers[x.piece.bufferIndex].buffer;
  31358. var startOffset_2 = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
  31359. if (x === endPosition.node) {
  31360. ret += buffer_2.substring(startOffset_2, startOffset_2 + endPosition.remainder);
  31361. break;
  31362. }
  31363. else {
  31364. ret += buffer_2.substr(startOffset_2, x.piece.length);
  31365. }
  31366. x = x.next();
  31367. }
  31368. return ret;
  31369. };
  31370. PieceTreeBase.prototype.getLinesContent = function () {
  31371. var _this = this;
  31372. var lines = [];
  31373. var linesLength = 0;
  31374. var currentLine = '';
  31375. var danglingCR = false;
  31376. this.iterate(this.root, function (node) {
  31377. if (node === rbTreeBase_1.SENTINEL) {
  31378. return true;
  31379. }
  31380. var piece = node.piece;
  31381. var pieceLength = piece.length;
  31382. if (pieceLength === 0) {
  31383. return true;
  31384. }
  31385. var buffer = _this._buffers[piece.bufferIndex].buffer;
  31386. var lineStarts = _this._buffers[piece.bufferIndex].lineStarts;
  31387. var pieceStartLine = piece.start.line;
  31388. var pieceEndLine = piece.end.line;
  31389. var pieceStartOffset = lineStarts[pieceStartLine] + piece.start.column;
  31390. if (danglingCR) {
  31391. if (buffer.charCodeAt(pieceStartOffset) === 10 /* LineFeed */) {
  31392. // pretend the \n was in the previous piece..
  31393. pieceStartOffset++;
  31394. pieceLength--;
  31395. }
  31396. lines[linesLength++] = currentLine;
  31397. currentLine = '';
  31398. danglingCR = false;
  31399. if (pieceLength === 0) {
  31400. return true;
  31401. }
  31402. }
  31403. if (pieceStartLine === pieceEndLine) {
  31404. // this piece has no new lines
  31405. if (!_this._EOLNormalized && buffer.charCodeAt(pieceStartOffset + pieceLength - 1) === 13 /* CarriageReturn */) {
  31406. danglingCR = true;
  31407. currentLine += buffer.substr(pieceStartOffset, pieceLength - 1);
  31408. }
  31409. else {
  31410. currentLine += buffer.substr(pieceStartOffset, pieceLength);
  31411. }
  31412. return true;
  31413. }
  31414. // add the text before the first line start in this piece
  31415. currentLine += (_this._EOLNormalized
  31416. ? buffer.substring(pieceStartOffset, Math.max(pieceStartOffset, lineStarts[pieceStartLine + 1] - _this._EOLLength))
  31417. : buffer.substring(pieceStartOffset, lineStarts[pieceStartLine + 1]).replace(/(\r\n|\r|\n)$/, ''));
  31418. lines[linesLength++] = currentLine;
  31419. for (var line = pieceStartLine + 1; line < pieceEndLine; line++) {
  31420. currentLine = (_this._EOLNormalized
  31421. ? buffer.substring(lineStarts[line], lineStarts[line + 1] - _this._EOLLength)
  31422. : buffer.substring(lineStarts[line], lineStarts[line + 1]).replace(/(\r\n|\r|\n)$/, ''));
  31423. lines[linesLength++] = currentLine;
  31424. }
  31425. if (!_this._EOLNormalized && buffer.charCodeAt(lineStarts[pieceEndLine] + piece.end.column - 1) === 13 /* CarriageReturn */) {
  31426. danglingCR = true;
  31427. if (piece.end.column === 0) {
  31428. // The last line ended with a \r, let's undo the push, it will be pushed by next iteration
  31429. linesLength--;
  31430. }
  31431. else {
  31432. currentLine = buffer.substr(lineStarts[pieceEndLine], piece.end.column - 1);
  31433. }
  31434. }
  31435. else {
  31436. currentLine = buffer.substr(lineStarts[pieceEndLine], piece.end.column);
  31437. }
  31438. return true;
  31439. });
  31440. if (danglingCR) {
  31441. lines[linesLength++] = currentLine;
  31442. currentLine = '';
  31443. }
  31444. lines[linesLength++] = currentLine;
  31445. return lines;
  31446. };
  31447. PieceTreeBase.prototype.getLength = function () {
  31448. return this._length;
  31449. };
  31450. PieceTreeBase.prototype.getLineCount = function () {
  31451. return this._lineCnt;
  31452. };
  31453. PieceTreeBase.prototype.getLineContent = function (lineNumber) {
  31454. if (this._lastVisitedLine.lineNumber === lineNumber) {
  31455. return this._lastVisitedLine.value;
  31456. }
  31457. this._lastVisitedLine.lineNumber = lineNumber;
  31458. if (lineNumber === this._lineCnt) {
  31459. this._lastVisitedLine.value = this.getLineRawContent(lineNumber);
  31460. }
  31461. else if (this._EOLNormalized) {
  31462. this._lastVisitedLine.value = this.getLineRawContent(lineNumber, this._EOLLength);
  31463. }
  31464. else {
  31465. this._lastVisitedLine.value = this.getLineRawContent(lineNumber).replace(/(\r\n|\r|\n)$/, '');
  31466. }
  31467. return this._lastVisitedLine.value;
  31468. };
  31469. PieceTreeBase.prototype.getLineCharCode = function (lineNumber, index) {
  31470. var nodePos = this.nodeAt2(lineNumber, index + 1);
  31471. if (nodePos.remainder === nodePos.node.piece.length) {
  31472. // the char we want to fetch is at the head of next node.
  31473. var matchingNode = nodePos.node.next();
  31474. if (!matchingNode) {
  31475. return 0;
  31476. }
  31477. var buffer = this._buffers[matchingNode.piece.bufferIndex];
  31478. var startOffset = this.offsetInBuffer(matchingNode.piece.bufferIndex, matchingNode.piece.start);
  31479. return buffer.buffer.charCodeAt(startOffset);
  31480. }
  31481. else {
  31482. var buffer = this._buffers[nodePos.node.piece.bufferIndex];
  31483. var startOffset = this.offsetInBuffer(nodePos.node.piece.bufferIndex, nodePos.node.piece.start);
  31484. var targetOffset = startOffset + nodePos.remainder;
  31485. return buffer.buffer.charCodeAt(targetOffset);
  31486. }
  31487. };
  31488. PieceTreeBase.prototype.getLineLength = function (lineNumber) {
  31489. if (lineNumber === this.getLineCount()) {
  31490. var startOffset = this.getOffsetAt(lineNumber, 1);
  31491. return this.getLength() - startOffset;
  31492. }
  31493. return this.getOffsetAt(lineNumber + 1, 1) - this.getOffsetAt(lineNumber, 1) - this._EOLLength;
  31494. };
  31495. PieceTreeBase.prototype.findMatchesInNode = function (node, searcher, startLineNumber, startColumn, startCursor, endCursor, searchData, captureMatches, limitResultCount, resultLen, result) {
  31496. var buffer = this._buffers[node.piece.bufferIndex];
  31497. var startOffsetInBuffer = this.offsetInBuffer(node.piece.bufferIndex, node.piece.start);
  31498. var start = this.offsetInBuffer(node.piece.bufferIndex, startCursor);
  31499. var end = this.offsetInBuffer(node.piece.bufferIndex, endCursor);
  31500. var m;
  31501. // Reset regex to search from the beginning
  31502. var ret = { line: 0, column: 0 };
  31503. var searchText;
  31504. var offsetInBuffer;
  31505. if (searcher._wordSeparators) {
  31506. searchText = buffer.buffer.substring(start, end);
  31507. offsetInBuffer = function (offset) { return offset + start; };
  31508. searcher.reset(-1);
  31509. }
  31510. else {
  31511. searchText = buffer.buffer;
  31512. offsetInBuffer = function (offset) { return offset; };
  31513. searcher.reset(start);
  31514. }
  31515. do {
  31516. m = searcher.next(searchText);
  31517. if (m) {
  31518. if (offsetInBuffer(m.index) >= end) {
  31519. return resultLen;
  31520. }
  31521. this.positionInBuffer(node, offsetInBuffer(m.index) - startOffsetInBuffer, ret);
  31522. var lineFeedCnt = this.getLineFeedCnt(node.piece.bufferIndex, startCursor, ret);
  31523. var retStartColumn = ret.line === startCursor.line ? ret.column - startCursor.column + startColumn : ret.column + 1;
  31524. var retEndColumn = retStartColumn + m[0].length;
  31525. result[resultLen++] = textModelSearch_1.createFindMatch(new range_1.Range(startLineNumber + lineFeedCnt, retStartColumn, startLineNumber + lineFeedCnt, retEndColumn), m, captureMatches);
  31526. if (offsetInBuffer(m.index) + m[0].length >= end) {
  31527. return resultLen;
  31528. }
  31529. if (resultLen >= limitResultCount) {
  31530. return resultLen;
  31531. }
  31532. }
  31533. } while (m);
  31534. return resultLen;
  31535. };
  31536. PieceTreeBase.prototype.findMatchesLineByLine = function (searchRange, searchData, captureMatches, limitResultCount) {
  31537. var result = [];
  31538. var resultLen = 0;
  31539. var searcher = new textModelSearch_1.Searcher(searchData.wordSeparators, searchData.regex);
  31540. var startPosition = this.nodeAt2(searchRange.startLineNumber, searchRange.startColumn);
  31541. if (startPosition === null) {
  31542. return [];
  31543. }
  31544. var endPosition = this.nodeAt2(searchRange.endLineNumber, searchRange.endColumn);
  31545. if (endPosition === null) {
  31546. return [];
  31547. }
  31548. var start = this.positionInBuffer(startPosition.node, startPosition.remainder);
  31549. var end = this.positionInBuffer(endPosition.node, endPosition.remainder);
  31550. if (startPosition.node === endPosition.node) {
  31551. this.findMatchesInNode(startPosition.node, searcher, searchRange.startLineNumber, searchRange.startColumn, start, end, searchData, captureMatches, limitResultCount, resultLen, result);
  31552. return result;
  31553. }
  31554. var startLineNumber = searchRange.startLineNumber;
  31555. var currentNode = startPosition.node;
  31556. while (currentNode !== endPosition.node) {
  31557. var lineBreakCnt = this.getLineFeedCnt(currentNode.piece.bufferIndex, start, currentNode.piece.end);
  31558. if (lineBreakCnt >= 1) {
  31559. // last line break position
  31560. var lineStarts = this._buffers[currentNode.piece.bufferIndex].lineStarts;
  31561. var startOffsetInBuffer = this.offsetInBuffer(currentNode.piece.bufferIndex, currentNode.piece.start);
  31562. var nextLineStartOffset = lineStarts[start.line + lineBreakCnt];
  31563. var startColumn_1 = startLineNumber === searchRange.startLineNumber ? searchRange.startColumn : 1;
  31564. resultLen = this.findMatchesInNode(currentNode, searcher, startLineNumber, startColumn_1, start, this.positionInBuffer(currentNode, nextLineStartOffset - startOffsetInBuffer), searchData, captureMatches, limitResultCount, resultLen, result);
  31565. if (resultLen >= limitResultCount) {
  31566. return result;
  31567. }
  31568. startLineNumber += lineBreakCnt;
  31569. }
  31570. var startColumn_2 = startLineNumber === searchRange.startLineNumber ? searchRange.startColumn - 1 : 0;
  31571. // search for the remaining content
  31572. if (startLineNumber === searchRange.endLineNumber) {
  31573. var text = this.getLineContent(startLineNumber).substring(startColumn_2, searchRange.endColumn - 1);
  31574. resultLen = this._findMatchesInLine(searchData, searcher, text, searchRange.endLineNumber, startColumn_2, resultLen, result, captureMatches, limitResultCount);
  31575. return result;
  31576. }
  31577. resultLen = this._findMatchesInLine(searchData, searcher, this.getLineContent(startLineNumber).substr(startColumn_2), startLineNumber, startColumn_2, resultLen, result, captureMatches, limitResultCount);
  31578. if (resultLen >= limitResultCount) {
  31579. return result;
  31580. }
  31581. startLineNumber++;
  31582. startPosition = this.nodeAt2(startLineNumber, 1);
  31583. currentNode = startPosition.node;
  31584. start = this.positionInBuffer(startPosition.node, startPosition.remainder);
  31585. }
  31586. if (startLineNumber === searchRange.endLineNumber) {
  31587. var startColumn_3 = startLineNumber === searchRange.startLineNumber ? searchRange.startColumn - 1 : 0;
  31588. var text = this.getLineContent(startLineNumber).substring(startColumn_3, searchRange.endColumn - 1);
  31589. resultLen = this._findMatchesInLine(searchData, searcher, text, searchRange.endLineNumber, startColumn_3, resultLen, result, captureMatches, limitResultCount);
  31590. return result;
  31591. }
  31592. var startColumn = startLineNumber === searchRange.startLineNumber ? searchRange.startColumn : 1;
  31593. resultLen = this.findMatchesInNode(endPosition.node, searcher, startLineNumber, startColumn, start, end, searchData, captureMatches, limitResultCount, resultLen, result);
  31594. return result;
  31595. };
  31596. PieceTreeBase.prototype._findMatchesInLine = function (searchData, searcher, text, lineNumber, deltaOffset, resultLen, result, captureMatches, limitResultCount) {
  31597. var wordSeparators = searchData.wordSeparators;
  31598. if (!captureMatches && searchData.simpleSearch) {
  31599. var searchString = searchData.simpleSearch;
  31600. var searchStringLen = searchString.length;
  31601. var textLength = text.length;
  31602. var lastMatchIndex = -searchStringLen;
  31603. while ((lastMatchIndex = text.indexOf(searchString, lastMatchIndex + searchStringLen)) !== -1) {
  31604. if (!wordSeparators || textModelSearch_1.isValidMatch(wordSeparators, text, textLength, lastMatchIndex, searchStringLen)) {
  31605. result[resultLen++] = new model_1.FindMatch(new range_1.Range(lineNumber, lastMatchIndex + 1 + deltaOffset, lineNumber, lastMatchIndex + 1 + searchStringLen + deltaOffset), null);
  31606. if (resultLen >= limitResultCount) {
  31607. return resultLen;
  31608. }
  31609. }
  31610. }
  31611. return resultLen;
  31612. }
  31613. var m;
  31614. // Reset regex to search from the beginning
  31615. searcher.reset(0);
  31616. do {
  31617. m = searcher.next(text);
  31618. if (m) {
  31619. result[resultLen++] = textModelSearch_1.createFindMatch(new range_1.Range(lineNumber, m.index + 1 + deltaOffset, lineNumber, m.index + 1 + m[0].length + deltaOffset), m, captureMatches);
  31620. if (resultLen >= limitResultCount) {
  31621. return resultLen;
  31622. }
  31623. }
  31624. } while (m);
  31625. return resultLen;
  31626. };
  31627. // #endregion
  31628. // #region Piece Table
  31629. PieceTreeBase.prototype.insert = function (offset, value, eolNormalized) {
  31630. if (eolNormalized === void 0) { eolNormalized = false; }
  31631. this._EOLNormalized = this._EOLNormalized && eolNormalized;
  31632. this._lastVisitedLine.lineNumber = 0;
  31633. this._lastVisitedLine.value = '';
  31634. if (this.root !== rbTreeBase_1.SENTINEL) {
  31635. var _a = this.nodeAt(offset), node = _a.node, remainder = _a.remainder, nodeStartOffset = _a.nodeStartOffset;
  31636. var piece = node.piece;
  31637. var bufferIndex = piece.bufferIndex;
  31638. var insertPosInBuffer = this.positionInBuffer(node, remainder);
  31639. if (node.piece.bufferIndex === 0 &&
  31640. piece.end.line === this._lastChangeBufferPos.line &&
  31641. piece.end.column === this._lastChangeBufferPos.column &&
  31642. (nodeStartOffset + piece.length === offset) &&
  31643. value.length < exports.AverageBufferSize) {
  31644. // changed buffer
  31645. this.appendToNode(node, value);
  31646. this.computeBufferMetadata();
  31647. return;
  31648. }
  31649. if (nodeStartOffset === offset) {
  31650. this.insertContentToNodeLeft(value, node);
  31651. this._searchCache.valdiate(offset);
  31652. }
  31653. else if (nodeStartOffset + node.piece.length > offset) {
  31654. // we are inserting into the middle of a node.
  31655. var nodesToDel = [];
  31656. var newRightPiece = new Piece(piece.bufferIndex, insertPosInBuffer, piece.end, this.getLineFeedCnt(piece.bufferIndex, insertPosInBuffer, piece.end), this.offsetInBuffer(bufferIndex, piece.end) - this.offsetInBuffer(bufferIndex, insertPosInBuffer));
  31657. if (this.shouldCheckCRLF() && this.endWithCR(value)) {
  31658. var headOfRight = this.nodeCharCodeAt(node, remainder);
  31659. if (headOfRight === 10 /** \n */) {
  31660. var newStart = { line: newRightPiece.start.line + 1, column: 0 };
  31661. newRightPiece = new Piece(newRightPiece.bufferIndex, newStart, newRightPiece.end, this.getLineFeedCnt(newRightPiece.bufferIndex, newStart, newRightPiece.end), newRightPiece.length - 1);
  31662. value += '\n';
  31663. }
  31664. }
  31665. // reuse node for content before insertion point.
  31666. if (this.shouldCheckCRLF() && this.startWithLF(value)) {
  31667. var tailOfLeft = this.nodeCharCodeAt(node, remainder - 1);
  31668. if (tailOfLeft === 13 /** \r */) {
  31669. var previousPos = this.positionInBuffer(node, remainder - 1);
  31670. this.deleteNodeTail(node, previousPos);
  31671. value = '\r' + value;
  31672. if (node.piece.length === 0) {
  31673. nodesToDel.push(node);
  31674. }
  31675. }
  31676. else {
  31677. this.deleteNodeTail(node, insertPosInBuffer);
  31678. }
  31679. }
  31680. else {
  31681. this.deleteNodeTail(node, insertPosInBuffer);
  31682. }
  31683. var newPieces = this.createNewPieces(value);
  31684. if (newRightPiece.length > 0) {
  31685. this.rbInsertRight(node, newRightPiece);
  31686. }
  31687. var tmpNode = node;
  31688. for (var k = 0; k < newPieces.length; k++) {
  31689. tmpNode = this.rbInsertRight(tmpNode, newPieces[k]);
  31690. }
  31691. this.deleteNodes(nodesToDel);
  31692. }
  31693. else {
  31694. this.insertContentToNodeRight(value, node);
  31695. }
  31696. }
  31697. else {
  31698. // insert new node
  31699. var pieces = this.createNewPieces(value);
  31700. var node = this.rbInsertLeft(null, pieces[0]);
  31701. for (var k = 1; k < pieces.length; k++) {
  31702. node = this.rbInsertRight(node, pieces[k]);
  31703. }
  31704. }
  31705. // todo, this is too brutal. Total line feed count should be updated the same way as lf_left.
  31706. this.computeBufferMetadata();
  31707. };
  31708. PieceTreeBase.prototype.delete = function (offset, cnt) {
  31709. this._lastVisitedLine.lineNumber = 0;
  31710. this._lastVisitedLine.value = '';
  31711. if (cnt <= 0 || this.root === rbTreeBase_1.SENTINEL) {
  31712. return;
  31713. }
  31714. var startPosition = this.nodeAt(offset);
  31715. var endPosition = this.nodeAt(offset + cnt);
  31716. var startNode = startPosition.node;
  31717. var endNode = endPosition.node;
  31718. if (startNode === endNode) {
  31719. var startSplitPosInBuffer_1 = this.positionInBuffer(startNode, startPosition.remainder);
  31720. var endSplitPosInBuffer_1 = this.positionInBuffer(startNode, endPosition.remainder);
  31721. if (startPosition.nodeStartOffset === offset) {
  31722. if (cnt === startNode.piece.length) { // delete node
  31723. var next = startNode.next();
  31724. rbTreeBase_1.rbDelete(this, startNode);
  31725. this.validateCRLFWithPrevNode(next);
  31726. this.computeBufferMetadata();
  31727. return;
  31728. }
  31729. this.deleteNodeHead(startNode, endSplitPosInBuffer_1);
  31730. this._searchCache.valdiate(offset);
  31731. this.validateCRLFWithPrevNode(startNode);
  31732. this.computeBufferMetadata();
  31733. return;
  31734. }
  31735. if (startPosition.nodeStartOffset + startNode.piece.length === offset + cnt) {
  31736. this.deleteNodeTail(startNode, startSplitPosInBuffer_1);
  31737. this.validateCRLFWithNextNode(startNode);
  31738. this.computeBufferMetadata();
  31739. return;
  31740. }
  31741. // delete content in the middle, this node will be splitted to nodes
  31742. this.shrinkNode(startNode, startSplitPosInBuffer_1, endSplitPosInBuffer_1);
  31743. this.computeBufferMetadata();
  31744. return;
  31745. }
  31746. var nodesToDel = [];
  31747. var startSplitPosInBuffer = this.positionInBuffer(startNode, startPosition.remainder);
  31748. this.deleteNodeTail(startNode, startSplitPosInBuffer);
  31749. this._searchCache.valdiate(offset);
  31750. if (startNode.piece.length === 0) {
  31751. nodesToDel.push(startNode);
  31752. }
  31753. // update last touched node
  31754. var endSplitPosInBuffer = this.positionInBuffer(endNode, endPosition.remainder);
  31755. this.deleteNodeHead(endNode, endSplitPosInBuffer);
  31756. if (endNode.piece.length === 0) {
  31757. nodesToDel.push(endNode);
  31758. }
  31759. // delete nodes in between
  31760. var secondNode = startNode.next();
  31761. for (var node = secondNode; node !== rbTreeBase_1.SENTINEL && node !== endNode; node = node.next()) {
  31762. nodesToDel.push(node);
  31763. }
  31764. var prev = startNode.piece.length === 0 ? startNode.prev() : startNode;
  31765. this.deleteNodes(nodesToDel);
  31766. this.validateCRLFWithNextNode(prev);
  31767. this.computeBufferMetadata();
  31768. };
  31769. PieceTreeBase.prototype.insertContentToNodeLeft = function (value, node) {
  31770. // we are inserting content to the beginning of node
  31771. var nodesToDel = [];
  31772. if (this.shouldCheckCRLF() && this.endWithCR(value) && this.startWithLF(node)) {
  31773. // move `\n` to new node.
  31774. var piece = node.piece;
  31775. var newStart = { line: piece.start.line + 1, column: 0 };
  31776. var nPiece = new Piece(piece.bufferIndex, newStart, piece.end, this.getLineFeedCnt(piece.bufferIndex, newStart, piece.end), piece.length - 1);
  31777. node.piece = nPiece;
  31778. value += '\n';
  31779. rbTreeBase_1.updateTreeMetadata(this, node, -1, -1);
  31780. if (node.piece.length === 0) {
  31781. nodesToDel.push(node);
  31782. }
  31783. }
  31784. var newPieces = this.createNewPieces(value);
  31785. var newNode = this.rbInsertLeft(node, newPieces[newPieces.length - 1]);
  31786. for (var k = newPieces.length - 2; k >= 0; k--) {
  31787. newNode = this.rbInsertLeft(newNode, newPieces[k]);
  31788. }
  31789. this.validateCRLFWithPrevNode(newNode);
  31790. this.deleteNodes(nodesToDel);
  31791. };
  31792. PieceTreeBase.prototype.insertContentToNodeRight = function (value, node) {
  31793. // we are inserting to the right of this node.
  31794. if (this.adjustCarriageReturnFromNext(value, node)) {
  31795. // move \n to the new node.
  31796. value += '\n';
  31797. }
  31798. var newPieces = this.createNewPieces(value);
  31799. var newNode = this.rbInsertRight(node, newPieces[0]);
  31800. var tmpNode = newNode;
  31801. for (var k = 1; k < newPieces.length; k++) {
  31802. tmpNode = this.rbInsertRight(tmpNode, newPieces[k]);
  31803. }
  31804. this.validateCRLFWithPrevNode(newNode);
  31805. };
  31806. PieceTreeBase.prototype.positionInBuffer = function (node, remainder, ret) {
  31807. var piece = node.piece;
  31808. var bufferIndex = node.piece.bufferIndex;
  31809. var lineStarts = this._buffers[bufferIndex].lineStarts;
  31810. var startOffset = lineStarts[piece.start.line] + piece.start.column;
  31811. var offset = startOffset + remainder;
  31812. // binary search offset between startOffset and endOffset
  31813. var low = piece.start.line;
  31814. var high = piece.end.line;
  31815. var mid = 0;
  31816. var midStop = 0;
  31817. var midStart = 0;
  31818. while (low <= high) {
  31819. mid = low + ((high - low) / 2) | 0;
  31820. midStart = lineStarts[mid];
  31821. if (mid === high) {
  31822. break;
  31823. }
  31824. midStop = lineStarts[mid + 1];
  31825. if (offset < midStart) {
  31826. high = mid - 1;
  31827. }
  31828. else if (offset >= midStop) {
  31829. low = mid + 1;
  31830. }
  31831. else {
  31832. break;
  31833. }
  31834. }
  31835. if (ret) {
  31836. ret.line = mid;
  31837. ret.column = offset - midStart;
  31838. return null;
  31839. }
  31840. return {
  31841. line: mid,
  31842. column: offset - midStart
  31843. };
  31844. };
  31845. PieceTreeBase.prototype.getLineFeedCnt = function (bufferIndex, start, end) {
  31846. // we don't need to worry about start: abc\r|\n, or abc|\r, or abc|\n, or abc|\r\n doesn't change the fact that, there is one line break after start.
  31847. // now let's take care of end: abc\r|\n, if end is in between \r and \n, we need to add line feed count by 1
  31848. if (end.column === 0) {
  31849. return end.line - start.line;
  31850. }
  31851. var lineStarts = this._buffers[bufferIndex].lineStarts;
  31852. if (end.line === lineStarts.length - 1) { // it means, there is no \n after end, otherwise, there will be one more lineStart.
  31853. return end.line - start.line;
  31854. }
  31855. var nextLineStartOffset = lineStarts[end.line + 1];
  31856. var endOffset = lineStarts[end.line] + end.column;
  31857. if (nextLineStartOffset > endOffset + 1) { // there are more than 1 character after end, which means it can't be \n
  31858. return end.line - start.line;
  31859. }
  31860. // endOffset + 1 === nextLineStartOffset
  31861. // character at endOffset is \n, so we check the character before first
  31862. // if character at endOffset is \r, end.column is 0 and we can't get here.
  31863. var previousCharOffset = endOffset - 1; // end.column > 0 so it's okay.
  31864. var buffer = this._buffers[bufferIndex].buffer;
  31865. if (buffer.charCodeAt(previousCharOffset) === 13) {
  31866. return end.line - start.line + 1;
  31867. }
  31868. else {
  31869. return end.line - start.line;
  31870. }
  31871. };
  31872. PieceTreeBase.prototype.offsetInBuffer = function (bufferIndex, cursor) {
  31873. var lineStarts = this._buffers[bufferIndex].lineStarts;
  31874. return lineStarts[cursor.line] + cursor.column;
  31875. };
  31876. PieceTreeBase.prototype.deleteNodes = function (nodes) {
  31877. for (var i = 0; i < nodes.length; i++) {
  31878. rbTreeBase_1.rbDelete(this, nodes[i]);
  31879. }
  31880. };
  31881. PieceTreeBase.prototype.createNewPieces = function (text) {
  31882. if (text.length > exports.AverageBufferSize) {
  31883. // the content is large, operations like substring, charCode becomes slow
  31884. // so here we split it into smaller chunks, just like what we did for CR/LF normalization
  31885. var newPieces = [];
  31886. while (text.length > exports.AverageBufferSize) {
  31887. var lastChar = text.charCodeAt(exports.AverageBufferSize - 1);
  31888. var splitText = void 0;
  31889. if (lastChar === 13 /* CarriageReturn */ || (lastChar >= 0xD800 && lastChar <= 0xDBFF)) {
  31890. // last character is \r or a high surrogate => keep it back
  31891. splitText = text.substring(0, exports.AverageBufferSize - 1);
  31892. text = text.substring(exports.AverageBufferSize - 1);
  31893. }
  31894. else {
  31895. splitText = text.substring(0, exports.AverageBufferSize);
  31896. text = text.substring(exports.AverageBufferSize);
  31897. }
  31898. var lineStarts_1 = createLineStartsFast(splitText);
  31899. newPieces.push(new Piece(this._buffers.length, /* buffer index */ { line: 0, column: 0 }, { line: lineStarts_1.length - 1, column: splitText.length - lineStarts_1[lineStarts_1.length - 1] }, lineStarts_1.length - 1, splitText.length));
  31900. this._buffers.push(new StringBuffer(splitText, lineStarts_1));
  31901. }
  31902. var lineStarts_2 = createLineStartsFast(text);
  31903. newPieces.push(new Piece(this._buffers.length, /* buffer index */ { line: 0, column: 0 }, { line: lineStarts_2.length - 1, column: text.length - lineStarts_2[lineStarts_2.length - 1] }, lineStarts_2.length - 1, text.length));
  31904. this._buffers.push(new StringBuffer(text, lineStarts_2));
  31905. return newPieces;
  31906. }
  31907. var startOffset = this._buffers[0].buffer.length;
  31908. var lineStarts = createLineStartsFast(text, false);
  31909. var start = this._lastChangeBufferPos;
  31910. if (this._buffers[0].lineStarts[this._buffers[0].lineStarts.length - 1] === startOffset
  31911. && startOffset !== 0
  31912. && this.startWithLF(text)
  31913. && this.endWithCR(this._buffers[0].buffer) // todo, we can check this._lastChangeBufferPos's column as it's the last one
  31914. ) {
  31915. this._lastChangeBufferPos = { line: this._lastChangeBufferPos.line, column: this._lastChangeBufferPos.column + 1 };
  31916. start = this._lastChangeBufferPos;
  31917. for (var i = 0; i < lineStarts.length; i++) {
  31918. lineStarts[i] += startOffset + 1;
  31919. }
  31920. this._buffers[0].lineStarts = this._buffers[0].lineStarts.concat(lineStarts.slice(1));
  31921. this._buffers[0].buffer += '_' + text;
  31922. startOffset += 1;
  31923. }
  31924. else {
  31925. if (startOffset !== 0) {
  31926. for (var i = 0; i < lineStarts.length; i++) {
  31927. lineStarts[i] += startOffset;
  31928. }
  31929. }
  31930. this._buffers[0].lineStarts = this._buffers[0].lineStarts.concat(lineStarts.slice(1));
  31931. this._buffers[0].buffer += text;
  31932. }
  31933. var endOffset = this._buffers[0].buffer.length;
  31934. var endIndex = this._buffers[0].lineStarts.length - 1;
  31935. var endColumn = endOffset - this._buffers[0].lineStarts[endIndex];
  31936. var endPos = { line: endIndex, column: endColumn };
  31937. var newPiece = new Piece(0, /** todo@peng */ start, endPos, this.getLineFeedCnt(0, start, endPos), endOffset - startOffset);
  31938. this._lastChangeBufferPos = endPos;
  31939. return [newPiece];
  31940. };
  31941. PieceTreeBase.prototype.getLineRawContent = function (lineNumber, endOffset) {
  31942. if (endOffset === void 0) { endOffset = 0; }
  31943. var x = this.root;
  31944. var ret = '';
  31945. var cache = this._searchCache.get2(lineNumber);
  31946. if (cache) {
  31947. x = cache.node;
  31948. var prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - cache.nodeStartLineNumber - 1);
  31949. var buffer = this._buffers[x.piece.bufferIndex].buffer;
  31950. var startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
  31951. if (cache.nodeStartLineNumber + x.piece.lineFeedCnt === lineNumber) {
  31952. ret = buffer.substring(startOffset + prevAccumualtedValue, startOffset + x.piece.length);
  31953. }
  31954. else {
  31955. var accumualtedValue = this.getAccumulatedValue(x, lineNumber - cache.nodeStartLineNumber);
  31956. return buffer.substring(startOffset + prevAccumualtedValue, startOffset + accumualtedValue - endOffset);
  31957. }
  31958. }
  31959. else {
  31960. var nodeStartOffset = 0;
  31961. var originalLineNumber = lineNumber;
  31962. while (x !== rbTreeBase_1.SENTINEL) {
  31963. if (x.left !== rbTreeBase_1.SENTINEL && x.lf_left >= lineNumber - 1) {
  31964. x = x.left;
  31965. }
  31966. else if (x.lf_left + x.piece.lineFeedCnt > lineNumber - 1) {
  31967. var prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
  31968. var accumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 1);
  31969. var buffer = this._buffers[x.piece.bufferIndex].buffer;
  31970. var startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
  31971. nodeStartOffset += x.size_left;
  31972. this._searchCache.set({
  31973. node: x,
  31974. nodeStartOffset: nodeStartOffset,
  31975. nodeStartLineNumber: originalLineNumber - (lineNumber - 1 - x.lf_left)
  31976. });
  31977. return buffer.substring(startOffset + prevAccumualtedValue, startOffset + accumualtedValue - endOffset);
  31978. }
  31979. else if (x.lf_left + x.piece.lineFeedCnt === lineNumber - 1) {
  31980. var prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
  31981. var buffer = this._buffers[x.piece.bufferIndex].buffer;
  31982. var startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
  31983. ret = buffer.substring(startOffset + prevAccumualtedValue, startOffset + x.piece.length);
  31984. break;
  31985. }
  31986. else {
  31987. lineNumber -= x.lf_left + x.piece.lineFeedCnt;
  31988. nodeStartOffset += x.size_left + x.piece.length;
  31989. x = x.right;
  31990. }
  31991. }
  31992. }
  31993. // search in order, to find the node contains end column
  31994. x = x.next();
  31995. while (x !== rbTreeBase_1.SENTINEL) {
  31996. var buffer = this._buffers[x.piece.bufferIndex].buffer;
  31997. if (x.piece.lineFeedCnt > 0) {
  31998. var accumualtedValue = this.getAccumulatedValue(x, 0);
  31999. var startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
  32000. ret += buffer.substring(startOffset, startOffset + accumualtedValue - endOffset);
  32001. return ret;
  32002. }
  32003. else {
  32004. var startOffset = this.offsetInBuffer(x.piece.bufferIndex, x.piece.start);
  32005. ret += buffer.substr(startOffset, x.piece.length);
  32006. }
  32007. x = x.next();
  32008. }
  32009. return ret;
  32010. };
  32011. PieceTreeBase.prototype.computeBufferMetadata = function () {
  32012. var x = this.root;
  32013. var lfCnt = 1;
  32014. var len = 0;
  32015. while (x !== rbTreeBase_1.SENTINEL) {
  32016. lfCnt += x.lf_left + x.piece.lineFeedCnt;
  32017. len += x.size_left + x.piece.length;
  32018. x = x.right;
  32019. }
  32020. this._lineCnt = lfCnt;
  32021. this._length = len;
  32022. this._searchCache.valdiate(this._length);
  32023. };
  32024. // #region node operations
  32025. PieceTreeBase.prototype.getIndexOf = function (node, accumulatedValue) {
  32026. var piece = node.piece;
  32027. var pos = this.positionInBuffer(node, accumulatedValue);
  32028. var lineCnt = pos.line - piece.start.line;
  32029. if (this.offsetInBuffer(piece.bufferIndex, piece.end) - this.offsetInBuffer(piece.bufferIndex, piece.start) === accumulatedValue) {
  32030. // we are checking the end of this node, so a CRLF check is necessary.
  32031. var realLineCnt = this.getLineFeedCnt(node.piece.bufferIndex, piece.start, pos);
  32032. if (realLineCnt !== lineCnt) {
  32033. // aha yes, CRLF
  32034. return { index: realLineCnt, remainder: 0 };
  32035. }
  32036. }
  32037. return { index: lineCnt, remainder: pos.column };
  32038. };
  32039. PieceTreeBase.prototype.getAccumulatedValue = function (node, index) {
  32040. if (index < 0) {
  32041. return 0;
  32042. }
  32043. var piece = node.piece;
  32044. var lineStarts = this._buffers[piece.bufferIndex].lineStarts;
  32045. var expectedLineStartIndex = piece.start.line + index + 1;
  32046. if (expectedLineStartIndex > piece.end.line) {
  32047. return lineStarts[piece.end.line] + piece.end.column - lineStarts[piece.start.line] - piece.start.column;
  32048. }
  32049. else {
  32050. return lineStarts[expectedLineStartIndex] - lineStarts[piece.start.line] - piece.start.column;
  32051. }
  32052. };
  32053. PieceTreeBase.prototype.deleteNodeTail = function (node, pos) {
  32054. var piece = node.piece;
  32055. var originalLFCnt = piece.lineFeedCnt;
  32056. var originalEndOffset = this.offsetInBuffer(piece.bufferIndex, piece.end);
  32057. var newEnd = pos;
  32058. var newEndOffset = this.offsetInBuffer(piece.bufferIndex, newEnd);
  32059. var newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, piece.start, newEnd);
  32060. var lf_delta = newLineFeedCnt - originalLFCnt;
  32061. var size_delta = newEndOffset - originalEndOffset;
  32062. var newLength = piece.length + size_delta;
  32063. node.piece = new Piece(piece.bufferIndex, piece.start, newEnd, newLineFeedCnt, newLength);
  32064. rbTreeBase_1.updateTreeMetadata(this, node, size_delta, lf_delta);
  32065. };
  32066. PieceTreeBase.prototype.deleteNodeHead = function (node, pos) {
  32067. var piece = node.piece;
  32068. var originalLFCnt = piece.lineFeedCnt;
  32069. var originalStartOffset = this.offsetInBuffer(piece.bufferIndex, piece.start);
  32070. var newStart = pos;
  32071. var newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, newStart, piece.end);
  32072. var newStartOffset = this.offsetInBuffer(piece.bufferIndex, newStart);
  32073. var lf_delta = newLineFeedCnt - originalLFCnt;
  32074. var size_delta = originalStartOffset - newStartOffset;
  32075. var newLength = piece.length + size_delta;
  32076. node.piece = new Piece(piece.bufferIndex, newStart, piece.end, newLineFeedCnt, newLength);
  32077. rbTreeBase_1.updateTreeMetadata(this, node, size_delta, lf_delta);
  32078. };
  32079. PieceTreeBase.prototype.shrinkNode = function (node, start, end) {
  32080. var piece = node.piece;
  32081. var originalStartPos = piece.start;
  32082. var originalEndPos = piece.end;
  32083. // old piece, originalStartPos, start
  32084. var oldLength = piece.length;
  32085. var oldLFCnt = piece.lineFeedCnt;
  32086. var newEnd = start;
  32087. var newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, piece.start, newEnd);
  32088. var newLength = this.offsetInBuffer(piece.bufferIndex, start) - this.offsetInBuffer(piece.bufferIndex, originalStartPos);
  32089. node.piece = new Piece(piece.bufferIndex, piece.start, newEnd, newLineFeedCnt, newLength);
  32090. rbTreeBase_1.updateTreeMetadata(this, node, newLength - oldLength, newLineFeedCnt - oldLFCnt);
  32091. // new right piece, end, originalEndPos
  32092. var newPiece = new Piece(piece.bufferIndex, end, originalEndPos, this.getLineFeedCnt(piece.bufferIndex, end, originalEndPos), this.offsetInBuffer(piece.bufferIndex, originalEndPos) - this.offsetInBuffer(piece.bufferIndex, end));
  32093. var newNode = this.rbInsertRight(node, newPiece);
  32094. this.validateCRLFWithPrevNode(newNode);
  32095. };
  32096. PieceTreeBase.prototype.appendToNode = function (node, value) {
  32097. if (this.adjustCarriageReturnFromNext(value, node)) {
  32098. value += '\n';
  32099. }
  32100. var hitCRLF = this.shouldCheckCRLF() && this.startWithLF(value) && this.endWithCR(node);
  32101. var startOffset = this._buffers[0].buffer.length;
  32102. this._buffers[0].buffer += value;
  32103. var lineStarts = createLineStartsFast(value, false);
  32104. for (var i = 0; i < lineStarts.length; i++) {
  32105. lineStarts[i] += startOffset;
  32106. }
  32107. if (hitCRLF) {
  32108. var prevStartOffset = this._buffers[0].lineStarts[this._buffers[0].lineStarts.length - 2];
  32109. this._buffers[0].lineStarts.pop();
  32110. // _lastChangeBufferPos is already wrong
  32111. this._lastChangeBufferPos = { line: this._lastChangeBufferPos.line - 1, column: startOffset - prevStartOffset };
  32112. }
  32113. this._buffers[0].lineStarts = this._buffers[0].lineStarts.concat(lineStarts.slice(1));
  32114. var endIndex = this._buffers[0].lineStarts.length - 1;
  32115. var endColumn = this._buffers[0].buffer.length - this._buffers[0].lineStarts[endIndex];
  32116. var newEnd = { line: endIndex, column: endColumn };
  32117. var newLength = node.piece.length + value.length;
  32118. var oldLineFeedCnt = node.piece.lineFeedCnt;
  32119. var newLineFeedCnt = this.getLineFeedCnt(0, node.piece.start, newEnd);
  32120. var lf_delta = newLineFeedCnt - oldLineFeedCnt;
  32121. node.piece = new Piece(node.piece.bufferIndex, node.piece.start, newEnd, newLineFeedCnt, newLength);
  32122. this._lastChangeBufferPos = newEnd;
  32123. rbTreeBase_1.updateTreeMetadata(this, node, value.length, lf_delta);
  32124. };
  32125. PieceTreeBase.prototype.nodeAt = function (offset) {
  32126. var x = this.root;
  32127. var cache = this._searchCache.get(offset);
  32128. if (cache) {
  32129. return {
  32130. node: cache.node,
  32131. nodeStartOffset: cache.nodeStartOffset,
  32132. remainder: offset - cache.nodeStartOffset
  32133. };
  32134. }
  32135. var nodeStartOffset = 0;
  32136. while (x !== rbTreeBase_1.SENTINEL) {
  32137. if (x.size_left > offset) {
  32138. x = x.left;
  32139. }
  32140. else if (x.size_left + x.piece.length >= offset) {
  32141. nodeStartOffset += x.size_left;
  32142. var ret = {
  32143. node: x,
  32144. remainder: offset - x.size_left,
  32145. nodeStartOffset: nodeStartOffset
  32146. };
  32147. this._searchCache.set(ret);
  32148. return ret;
  32149. }
  32150. else {
  32151. offset -= x.size_left + x.piece.length;
  32152. nodeStartOffset += x.size_left + x.piece.length;
  32153. x = x.right;
  32154. }
  32155. }
  32156. return null;
  32157. };
  32158. PieceTreeBase.prototype.nodeAt2 = function (lineNumber, column) {
  32159. var x = this.root;
  32160. var nodeStartOffset = 0;
  32161. while (x !== rbTreeBase_1.SENTINEL) {
  32162. if (x.left !== rbTreeBase_1.SENTINEL && x.lf_left >= lineNumber - 1) {
  32163. x = x.left;
  32164. }
  32165. else if (x.lf_left + x.piece.lineFeedCnt > lineNumber - 1) {
  32166. var prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
  32167. var accumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 1);
  32168. nodeStartOffset += x.size_left;
  32169. return {
  32170. node: x,
  32171. remainder: Math.min(prevAccumualtedValue + column - 1, accumualtedValue),
  32172. nodeStartOffset: nodeStartOffset
  32173. };
  32174. }
  32175. else if (x.lf_left + x.piece.lineFeedCnt === lineNumber - 1) {
  32176. var prevAccumualtedValue = this.getAccumulatedValue(x, lineNumber - x.lf_left - 2);
  32177. if (prevAccumualtedValue + column - 1 <= x.piece.length) {
  32178. return {
  32179. node: x,
  32180. remainder: prevAccumualtedValue + column - 1,
  32181. nodeStartOffset: nodeStartOffset
  32182. };
  32183. }
  32184. else {
  32185. column -= x.piece.length - prevAccumualtedValue;
  32186. break;
  32187. }
  32188. }
  32189. else {
  32190. lineNumber -= x.lf_left + x.piece.lineFeedCnt;
  32191. nodeStartOffset += x.size_left + x.piece.length;
  32192. x = x.right;
  32193. }
  32194. }
  32195. // search in order, to find the node contains position.column
  32196. x = x.next();
  32197. while (x !== rbTreeBase_1.SENTINEL) {
  32198. if (x.piece.lineFeedCnt > 0) {
  32199. var accumualtedValue = this.getAccumulatedValue(x, 0);
  32200. var nodeStartOffset_1 = this.offsetOfNode(x);
  32201. return {
  32202. node: x,
  32203. remainder: Math.min(column - 1, accumualtedValue),
  32204. nodeStartOffset: nodeStartOffset_1
  32205. };
  32206. }
  32207. else {
  32208. if (x.piece.length >= column - 1) {
  32209. var nodeStartOffset_2 = this.offsetOfNode(x);
  32210. return {
  32211. node: x,
  32212. remainder: column - 1,
  32213. nodeStartOffset: nodeStartOffset_2
  32214. };
  32215. }
  32216. else {
  32217. column -= x.piece.length;
  32218. }
  32219. }
  32220. x = x.next();
  32221. }
  32222. return null;
  32223. };
  32224. PieceTreeBase.prototype.nodeCharCodeAt = function (node, offset) {
  32225. if (node.piece.lineFeedCnt < 1) {
  32226. return -1;
  32227. }
  32228. var buffer = this._buffers[node.piece.bufferIndex];
  32229. var newOffset = this.offsetInBuffer(node.piece.bufferIndex, node.piece.start) + offset;
  32230. return buffer.buffer.charCodeAt(newOffset);
  32231. };
  32232. PieceTreeBase.prototype.offsetOfNode = function (node) {
  32233. if (!node) {
  32234. return 0;
  32235. }
  32236. var pos = node.size_left;
  32237. while (node !== this.root) {
  32238. if (node.parent.right === node) {
  32239. pos += node.parent.size_left + node.parent.piece.length;
  32240. }
  32241. node = node.parent;
  32242. }
  32243. return pos;
  32244. };
  32245. // #endregion
  32246. // #region CRLF
  32247. PieceTreeBase.prototype.shouldCheckCRLF = function () {
  32248. return !(this._EOLNormalized && this._EOL === '\n');
  32249. };
  32250. PieceTreeBase.prototype.startWithLF = function (val) {
  32251. if (typeof val === 'string') {
  32252. return val.charCodeAt(0) === 10;
  32253. }
  32254. if (val === rbTreeBase_1.SENTINEL || val.piece.lineFeedCnt === 0) {
  32255. return false;
  32256. }
  32257. var piece = val.piece;
  32258. var lineStarts = this._buffers[piece.bufferIndex].lineStarts;
  32259. var line = piece.start.line;
  32260. var startOffset = lineStarts[line] + piece.start.column;
  32261. if (line === lineStarts.length - 1) {
  32262. // last line, so there is no line feed at the end of this line
  32263. return false;
  32264. }
  32265. var nextLineOffset = lineStarts[line + 1];
  32266. if (nextLineOffset > startOffset + 1) {
  32267. return false;
  32268. }
  32269. return this._buffers[piece.bufferIndex].buffer.charCodeAt(startOffset) === 10;
  32270. };
  32271. PieceTreeBase.prototype.endWithCR = function (val) {
  32272. if (typeof val === 'string') {
  32273. return val.charCodeAt(val.length - 1) === 13;
  32274. }
  32275. if (val === rbTreeBase_1.SENTINEL || val.piece.lineFeedCnt === 0) {
  32276. return false;
  32277. }
  32278. return this.nodeCharCodeAt(val, val.piece.length - 1) === 13;
  32279. };
  32280. PieceTreeBase.prototype.validateCRLFWithPrevNode = function (nextNode) {
  32281. if (this.shouldCheckCRLF() && this.startWithLF(nextNode)) {
  32282. var node = nextNode.prev();
  32283. if (this.endWithCR(node)) {
  32284. this.fixCRLF(node, nextNode);
  32285. }
  32286. }
  32287. };
  32288. PieceTreeBase.prototype.validateCRLFWithNextNode = function (node) {
  32289. if (this.shouldCheckCRLF() && this.endWithCR(node)) {
  32290. var nextNode = node.next();
  32291. if (this.startWithLF(nextNode)) {
  32292. this.fixCRLF(node, nextNode);
  32293. }
  32294. }
  32295. };
  32296. PieceTreeBase.prototype.fixCRLF = function (prev, next) {
  32297. var nodesToDel = [];
  32298. // update node
  32299. var lineStarts = this._buffers[prev.piece.bufferIndex].lineStarts;
  32300. var newEnd;
  32301. if (prev.piece.end.column === 0) {
  32302. // it means, last line ends with \r, not \r\n
  32303. newEnd = { line: prev.piece.end.line - 1, column: lineStarts[prev.piece.end.line] - lineStarts[prev.piece.end.line - 1] - 1 };
  32304. }
  32305. else {
  32306. // \r\n
  32307. newEnd = { line: prev.piece.end.line, column: prev.piece.end.column - 1 };
  32308. }
  32309. var prevNewLength = prev.piece.length - 1;
  32310. var prevNewLFCnt = prev.piece.lineFeedCnt - 1;
  32311. prev.piece = new Piece(prev.piece.bufferIndex, prev.piece.start, newEnd, prevNewLFCnt, prevNewLength);
  32312. rbTreeBase_1.updateTreeMetadata(this, prev, -1, -1);
  32313. if (prev.piece.length === 0) {
  32314. nodesToDel.push(prev);
  32315. }
  32316. // update nextNode
  32317. var newStart = { line: next.piece.start.line + 1, column: 0 };
  32318. var newLength = next.piece.length - 1;
  32319. var newLineFeedCnt = this.getLineFeedCnt(next.piece.bufferIndex, newStart, next.piece.end);
  32320. next.piece = new Piece(next.piece.bufferIndex, newStart, next.piece.end, newLineFeedCnt, newLength);
  32321. rbTreeBase_1.updateTreeMetadata(this, next, -1, -1);
  32322. if (next.piece.length === 0) {
  32323. nodesToDel.push(next);
  32324. }
  32325. // create new piece which contains \r\n
  32326. var pieces = this.createNewPieces('\r\n');
  32327. this.rbInsertRight(prev, pieces[0]);
  32328. // delete empty nodes
  32329. for (var i = 0; i < nodesToDel.length; i++) {
  32330. rbTreeBase_1.rbDelete(this, nodesToDel[i]);
  32331. }
  32332. };
  32333. PieceTreeBase.prototype.adjustCarriageReturnFromNext = function (value, node) {
  32334. if (this.shouldCheckCRLF() && this.endWithCR(value)) {
  32335. var nextNode = node.next();
  32336. if (this.startWithLF(nextNode)) {
  32337. // move `\n` forward
  32338. value += '\n';
  32339. if (nextNode.piece.length === 1) {
  32340. rbTreeBase_1.rbDelete(this, nextNode);
  32341. }
  32342. else {
  32343. var piece = nextNode.piece;
  32344. var newStart = { line: piece.start.line + 1, column: 0 };
  32345. var newLength = piece.length - 1;
  32346. var newLineFeedCnt = this.getLineFeedCnt(piece.bufferIndex, newStart, piece.end);
  32347. nextNode.piece = new Piece(piece.bufferIndex, newStart, piece.end, newLineFeedCnt, newLength);
  32348. rbTreeBase_1.updateTreeMetadata(this, nextNode, -1, -1);
  32349. }
  32350. return true;
  32351. }
  32352. }
  32353. return false;
  32354. };
  32355. // #endregion
  32356. // #endregion
  32357. // #region Tree operations
  32358. PieceTreeBase.prototype.iterate = function (node, callback) {
  32359. if (node === rbTreeBase_1.SENTINEL) {
  32360. return callback(rbTreeBase_1.SENTINEL);
  32361. }
  32362. var leftRet = this.iterate(node.left, callback);
  32363. if (!leftRet) {
  32364. return leftRet;
  32365. }
  32366. return callback(node) && this.iterate(node.right, callback);
  32367. };
  32368. PieceTreeBase.prototype.getNodeContent = function (node) {
  32369. if (node === rbTreeBase_1.SENTINEL) {
  32370. return '';
  32371. }
  32372. var buffer = this._buffers[node.piece.bufferIndex];
  32373. var currentContent;
  32374. var piece = node.piece;
  32375. var startOffset = this.offsetInBuffer(piece.bufferIndex, piece.start);
  32376. var endOffset = this.offsetInBuffer(piece.bufferIndex, piece.end);
  32377. currentContent = buffer.buffer.substring(startOffset, endOffset);
  32378. return currentContent;
  32379. };
  32380. /**
  32381. * node node
  32382. * / \ / \
  32383. * a b <---- a b
  32384. * /
  32385. * z
  32386. */
  32387. PieceTreeBase.prototype.rbInsertRight = function (node, p) {
  32388. var z = new rbTreeBase_1.TreeNode(p, 1 /* Red */);
  32389. z.left = rbTreeBase_1.SENTINEL;
  32390. z.right = rbTreeBase_1.SENTINEL;
  32391. z.parent = rbTreeBase_1.SENTINEL;
  32392. z.size_left = 0;
  32393. z.lf_left = 0;
  32394. var x = this.root;
  32395. if (x === rbTreeBase_1.SENTINEL) {
  32396. this.root = z;
  32397. z.color = 0 /* Black */;
  32398. }
  32399. else if (node.right === rbTreeBase_1.SENTINEL) {
  32400. node.right = z;
  32401. z.parent = node;
  32402. }
  32403. else {
  32404. var nextNode = rbTreeBase_1.leftest(node.right);
  32405. nextNode.left = z;
  32406. z.parent = nextNode;
  32407. }
  32408. rbTreeBase_1.fixInsert(this, z);
  32409. return z;
  32410. };
  32411. /**
  32412. * node node
  32413. * / \ / \
  32414. * a b ----> a b
  32415. * \
  32416. * z
  32417. */
  32418. PieceTreeBase.prototype.rbInsertLeft = function (node, p) {
  32419. var z = new rbTreeBase_1.TreeNode(p, 1 /* Red */);
  32420. z.left = rbTreeBase_1.SENTINEL;
  32421. z.right = rbTreeBase_1.SENTINEL;
  32422. z.parent = rbTreeBase_1.SENTINEL;
  32423. z.size_left = 0;
  32424. z.lf_left = 0;
  32425. if (this.root === rbTreeBase_1.SENTINEL) {
  32426. this.root = z;
  32427. z.color = 0 /* Black */;
  32428. }
  32429. else if (node.left === rbTreeBase_1.SENTINEL) {
  32430. node.left = z;
  32431. z.parent = node;
  32432. }
  32433. else {
  32434. var prevNode = rbTreeBase_1.righttest(node.left); // a
  32435. prevNode.right = z;
  32436. z.parent = prevNode;
  32437. }
  32438. rbTreeBase_1.fixInsert(this, z);
  32439. return z;
  32440. };
  32441. return PieceTreeBase;
  32442. }());
  32443. exports.PieceTreeBase = PieceTreeBase;
  32444. });
  32445. /*---------------------------------------------------------------------------------------------
  32446. * Copyright (c) Microsoft Corporation. All rights reserved.
  32447. * Licensed under the MIT License. See License.txt in the project root for license information.
  32448. *--------------------------------------------------------------------------------------------*/
  32449. define(__m[347/*vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,3/*vs/editor/common/core/range*/,48/*vs/editor/common/model*/,191/*vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase*/]), function (require, exports, strings, range_1, model_1, pieceTreeBase_1) {
  32450. "use strict";
  32451. Object.defineProperty(exports, "__esModule", { value: true });
  32452. var PieceTreeTextBuffer = /** @class */ (function () {
  32453. function PieceTreeTextBuffer(chunks, BOM, eol, containsRTL, isBasicASCII, eolNormalized) {
  32454. this._BOM = BOM;
  32455. this._mightContainNonBasicASCII = !isBasicASCII;
  32456. this._mightContainRTL = containsRTL;
  32457. this._pieceTree = new pieceTreeBase_1.PieceTreeBase(chunks, eol, eolNormalized);
  32458. }
  32459. PieceTreeTextBuffer.prototype.mightContainRTL = function () {
  32460. return this._mightContainRTL;
  32461. };
  32462. PieceTreeTextBuffer.prototype.mightContainNonBasicASCII = function () {
  32463. return this._mightContainNonBasicASCII;
  32464. };
  32465. PieceTreeTextBuffer.prototype.getBOM = function () {
  32466. return this._BOM;
  32467. };
  32468. PieceTreeTextBuffer.prototype.getEOL = function () {
  32469. return this._pieceTree.getEOL();
  32470. };
  32471. PieceTreeTextBuffer.prototype.getOffsetAt = function (lineNumber, column) {
  32472. return this._pieceTree.getOffsetAt(lineNumber, column);
  32473. };
  32474. PieceTreeTextBuffer.prototype.getPositionAt = function (offset) {
  32475. return this._pieceTree.getPositionAt(offset);
  32476. };
  32477. PieceTreeTextBuffer.prototype.getRangeAt = function (start, length) {
  32478. var end = start + length;
  32479. var startPosition = this.getPositionAt(start);
  32480. var endPosition = this.getPositionAt(end);
  32481. return new range_1.Range(startPosition.lineNumber, startPosition.column, endPosition.lineNumber, endPosition.column);
  32482. };
  32483. PieceTreeTextBuffer.prototype.getValueInRange = function (range, eol) {
  32484. if (eol === void 0) { eol = 0 /* TextDefined */; }
  32485. if (range.isEmpty()) {
  32486. return '';
  32487. }
  32488. var lineEnding = this._getEndOfLine(eol);
  32489. return this._pieceTree.getValueInRange(range, lineEnding);
  32490. };
  32491. PieceTreeTextBuffer.prototype.getValueLengthInRange = function (range, eol) {
  32492. if (eol === void 0) { eol = 0 /* TextDefined */; }
  32493. if (range.isEmpty()) {
  32494. return 0;
  32495. }
  32496. if (range.startLineNumber === range.endLineNumber) {
  32497. return (range.endColumn - range.startColumn);
  32498. }
  32499. var startOffset = this.getOffsetAt(range.startLineNumber, range.startColumn);
  32500. var endOffset = this.getOffsetAt(range.endLineNumber, range.endColumn);
  32501. return endOffset - startOffset;
  32502. };
  32503. PieceTreeTextBuffer.prototype.getCharacterCountInRange = function (range, eol) {
  32504. if (eol === void 0) { eol = 0 /* TextDefined */; }
  32505. if (this._mightContainNonBasicASCII) {
  32506. // we must count by iterating
  32507. var result = 0;
  32508. var fromLineNumber = range.startLineNumber;
  32509. var toLineNumber = range.endLineNumber;
  32510. for (var lineNumber = fromLineNumber; lineNumber <= toLineNumber; lineNumber++) {
  32511. var lineContent = this.getLineContent(lineNumber);
  32512. var fromOffset = (lineNumber === fromLineNumber ? range.startColumn - 1 : 0);
  32513. var toOffset = (lineNumber === toLineNumber ? range.endColumn - 1 : lineContent.length);
  32514. for (var offset = fromOffset; offset < toOffset; offset++) {
  32515. if (strings.isHighSurrogate(lineContent.charCodeAt(offset))) {
  32516. result = result + 1;
  32517. offset = offset + 1;
  32518. }
  32519. else {
  32520. result = result + 1;
  32521. }
  32522. }
  32523. }
  32524. result += this._getEndOfLine(eol).length * (toLineNumber - fromLineNumber);
  32525. return result;
  32526. }
  32527. return this.getValueLengthInRange(range, eol);
  32528. };
  32529. PieceTreeTextBuffer.prototype.getLength = function () {
  32530. return this._pieceTree.getLength();
  32531. };
  32532. PieceTreeTextBuffer.prototype.getLineCount = function () {
  32533. return this._pieceTree.getLineCount();
  32534. };
  32535. PieceTreeTextBuffer.prototype.getLinesContent = function () {
  32536. return this._pieceTree.getLinesContent();
  32537. };
  32538. PieceTreeTextBuffer.prototype.getLineContent = function (lineNumber) {
  32539. return this._pieceTree.getLineContent(lineNumber);
  32540. };
  32541. PieceTreeTextBuffer.prototype.getLineCharCode = function (lineNumber, index) {
  32542. return this._pieceTree.getLineCharCode(lineNumber, index);
  32543. };
  32544. PieceTreeTextBuffer.prototype.getLineLength = function (lineNumber) {
  32545. return this._pieceTree.getLineLength(lineNumber);
  32546. };
  32547. PieceTreeTextBuffer.prototype.getLineFirstNonWhitespaceColumn = function (lineNumber) {
  32548. var result = strings.firstNonWhitespaceIndex(this.getLineContent(lineNumber));
  32549. if (result === -1) {
  32550. return 0;
  32551. }
  32552. return result + 1;
  32553. };
  32554. PieceTreeTextBuffer.prototype.getLineLastNonWhitespaceColumn = function (lineNumber) {
  32555. var result = strings.lastNonWhitespaceIndex(this.getLineContent(lineNumber));
  32556. if (result === -1) {
  32557. return 0;
  32558. }
  32559. return result + 2;
  32560. };
  32561. PieceTreeTextBuffer.prototype._getEndOfLine = function (eol) {
  32562. switch (eol) {
  32563. case 1 /* LF */:
  32564. return '\n';
  32565. case 2 /* CRLF */:
  32566. return '\r\n';
  32567. case 0 /* TextDefined */:
  32568. return this.getEOL();
  32569. }
  32570. throw new Error('Unknown EOL preference');
  32571. };
  32572. PieceTreeTextBuffer.prototype.setEOL = function (newEOL) {
  32573. this._pieceTree.setEOL(newEOL);
  32574. };
  32575. PieceTreeTextBuffer.prototype.applyEdits = function (rawOperations, recordTrimAutoWhitespace) {
  32576. var mightContainRTL = this._mightContainRTL;
  32577. var mightContainNonBasicASCII = this._mightContainNonBasicASCII;
  32578. var canReduceOperations = true;
  32579. var operations = [];
  32580. for (var i = 0; i < rawOperations.length; i++) {
  32581. var op = rawOperations[i];
  32582. if (canReduceOperations && op._isTracked) {
  32583. canReduceOperations = false;
  32584. }
  32585. var validatedRange = op.range;
  32586. if (!mightContainRTL && op.text) {
  32587. // check if the new inserted text contains RTL
  32588. mightContainRTL = strings.containsRTL(op.text);
  32589. }
  32590. if (!mightContainNonBasicASCII && op.text) {
  32591. mightContainNonBasicASCII = !strings.isBasicASCII(op.text);
  32592. }
  32593. operations[i] = {
  32594. sortIndex: i,
  32595. identifier: op.identifier || null,
  32596. range: validatedRange,
  32597. rangeOffset: this.getOffsetAt(validatedRange.startLineNumber, validatedRange.startColumn),
  32598. rangeLength: this.getValueLengthInRange(validatedRange),
  32599. lines: op.text ? op.text.split(/\r\n|\r|\n/) : null,
  32600. forceMoveMarkers: Boolean(op.forceMoveMarkers),
  32601. isAutoWhitespaceEdit: op.isAutoWhitespaceEdit || false
  32602. };
  32603. }
  32604. // Sort operations ascending
  32605. operations.sort(PieceTreeTextBuffer._sortOpsAscending);
  32606. var hasTouchingRanges = false;
  32607. for (var i = 0, count = operations.length - 1; i < count; i++) {
  32608. var rangeEnd = operations[i].range.getEndPosition();
  32609. var nextRangeStart = operations[i + 1].range.getStartPosition();
  32610. if (nextRangeStart.isBeforeOrEqual(rangeEnd)) {
  32611. if (nextRangeStart.isBefore(rangeEnd)) {
  32612. // overlapping ranges
  32613. throw new Error('Overlapping ranges are not allowed!');
  32614. }
  32615. hasTouchingRanges = true;
  32616. }
  32617. }
  32618. if (canReduceOperations) {
  32619. operations = this._reduceOperations(operations);
  32620. }
  32621. // Delta encode operations
  32622. var reverseRanges = PieceTreeTextBuffer._getInverseEditRanges(operations);
  32623. var newTrimAutoWhitespaceCandidates = [];
  32624. for (var i = 0; i < operations.length; i++) {
  32625. var op = operations[i];
  32626. var reverseRange = reverseRanges[i];
  32627. if (recordTrimAutoWhitespace && op.isAutoWhitespaceEdit && op.range.isEmpty()) {
  32628. // Record already the future line numbers that might be auto whitespace removal candidates on next edit
  32629. for (var lineNumber = reverseRange.startLineNumber; lineNumber <= reverseRange.endLineNumber; lineNumber++) {
  32630. var currentLineContent = '';
  32631. if (lineNumber === reverseRange.startLineNumber) {
  32632. currentLineContent = this.getLineContent(op.range.startLineNumber);
  32633. if (strings.firstNonWhitespaceIndex(currentLineContent) !== -1) {
  32634. continue;
  32635. }
  32636. }
  32637. newTrimAutoWhitespaceCandidates.push({ lineNumber: lineNumber, oldContent: currentLineContent });
  32638. }
  32639. }
  32640. }
  32641. var reverseOperations = [];
  32642. for (var i = 0; i < operations.length; i++) {
  32643. var op = operations[i];
  32644. var reverseRange = reverseRanges[i];
  32645. reverseOperations[i] = {
  32646. sortIndex: op.sortIndex,
  32647. identifier: op.identifier,
  32648. range: reverseRange,
  32649. text: this.getValueInRange(op.range),
  32650. forceMoveMarkers: op.forceMoveMarkers
  32651. };
  32652. }
  32653. // Can only sort reverse operations when the order is not significant
  32654. if (!hasTouchingRanges) {
  32655. reverseOperations.sort(function (a, b) { return a.sortIndex - b.sortIndex; });
  32656. }
  32657. this._mightContainRTL = mightContainRTL;
  32658. this._mightContainNonBasicASCII = mightContainNonBasicASCII;
  32659. var contentChanges = this._doApplyEdits(operations);
  32660. var trimAutoWhitespaceLineNumbers = null;
  32661. if (recordTrimAutoWhitespace && newTrimAutoWhitespaceCandidates.length > 0) {
  32662. // sort line numbers auto whitespace removal candidates for next edit descending
  32663. newTrimAutoWhitespaceCandidates.sort(function (a, b) { return b.lineNumber - a.lineNumber; });
  32664. trimAutoWhitespaceLineNumbers = [];
  32665. for (var i = 0, len = newTrimAutoWhitespaceCandidates.length; i < len; i++) {
  32666. var lineNumber = newTrimAutoWhitespaceCandidates[i].lineNumber;
  32667. if (i > 0 && newTrimAutoWhitespaceCandidates[i - 1].lineNumber === lineNumber) {
  32668. // Do not have the same line number twice
  32669. continue;
  32670. }
  32671. var prevContent = newTrimAutoWhitespaceCandidates[i].oldContent;
  32672. var lineContent = this.getLineContent(lineNumber);
  32673. if (lineContent.length === 0 || lineContent === prevContent || strings.firstNonWhitespaceIndex(lineContent) !== -1) {
  32674. continue;
  32675. }
  32676. trimAutoWhitespaceLineNumbers.push(lineNumber);
  32677. }
  32678. }
  32679. return new model_1.ApplyEditsResult(reverseOperations, contentChanges, trimAutoWhitespaceLineNumbers);
  32680. };
  32681. /**
  32682. * Transform operations such that they represent the same logic edit,
  32683. * but that they also do not cause OOM crashes.
  32684. */
  32685. PieceTreeTextBuffer.prototype._reduceOperations = function (operations) {
  32686. if (operations.length < 1000) {
  32687. // We know from empirical testing that a thousand edits work fine regardless of their shape.
  32688. return operations;
  32689. }
  32690. // At one point, due to how events are emitted and how each operation is handled,
  32691. // some operations can trigger a high amount of temporary string allocations,
  32692. // that will immediately get edited again.
  32693. // e.g. a formatter inserting ridiculous ammounts of \n on a model with a single line
  32694. // Therefore, the strategy is to collapse all the operations into a huge single edit operation
  32695. return [this._toSingleEditOperation(operations)];
  32696. };
  32697. PieceTreeTextBuffer.prototype._toSingleEditOperation = function (operations) {
  32698. var forceMoveMarkers = false, firstEditRange = operations[0].range, lastEditRange = operations[operations.length - 1].range, entireEditRange = new range_1.Range(firstEditRange.startLineNumber, firstEditRange.startColumn, lastEditRange.endLineNumber, lastEditRange.endColumn), lastEndLineNumber = firstEditRange.startLineNumber, lastEndColumn = firstEditRange.startColumn, result = [];
  32699. for (var i = 0, len = operations.length; i < len; i++) {
  32700. var operation = operations[i], range = operation.range;
  32701. forceMoveMarkers = forceMoveMarkers || operation.forceMoveMarkers;
  32702. // (1) -- Push old text
  32703. for (var lineNumber = lastEndLineNumber; lineNumber < range.startLineNumber; lineNumber++) {
  32704. if (lineNumber === lastEndLineNumber) {
  32705. result.push(this.getLineContent(lineNumber).substring(lastEndColumn - 1));
  32706. }
  32707. else {
  32708. result.push('\n');
  32709. result.push(this.getLineContent(lineNumber));
  32710. }
  32711. }
  32712. if (range.startLineNumber === lastEndLineNumber) {
  32713. result.push(this.getLineContent(range.startLineNumber).substring(lastEndColumn - 1, range.startColumn - 1));
  32714. }
  32715. else {
  32716. result.push('\n');
  32717. result.push(this.getLineContent(range.startLineNumber).substring(0, range.startColumn - 1));
  32718. }
  32719. // (2) -- Push new text
  32720. if (operation.lines) {
  32721. for (var j = 0, lenJ = operation.lines.length; j < lenJ; j++) {
  32722. if (j !== 0) {
  32723. result.push('\n');
  32724. }
  32725. result.push(operation.lines[j]);
  32726. }
  32727. }
  32728. lastEndLineNumber = operation.range.endLineNumber;
  32729. lastEndColumn = operation.range.endColumn;
  32730. }
  32731. return {
  32732. sortIndex: 0,
  32733. identifier: operations[0].identifier,
  32734. range: entireEditRange,
  32735. rangeOffset: this.getOffsetAt(entireEditRange.startLineNumber, entireEditRange.startColumn),
  32736. rangeLength: this.getValueLengthInRange(entireEditRange, 0 /* TextDefined */),
  32737. lines: result.join('').split('\n'),
  32738. forceMoveMarkers: forceMoveMarkers,
  32739. isAutoWhitespaceEdit: false
  32740. };
  32741. };
  32742. PieceTreeTextBuffer.prototype._doApplyEdits = function (operations) {
  32743. operations.sort(PieceTreeTextBuffer._sortOpsDescending);
  32744. var contentChanges = [];
  32745. // operations are from bottom to top
  32746. for (var i = 0; i < operations.length; i++) {
  32747. var op = operations[i];
  32748. var startLineNumber = op.range.startLineNumber;
  32749. var startColumn = op.range.startColumn;
  32750. var endLineNumber = op.range.endLineNumber;
  32751. var endColumn = op.range.endColumn;
  32752. if (startLineNumber === endLineNumber && startColumn === endColumn && (!op.lines || op.lines.length === 0)) {
  32753. // no-op
  32754. continue;
  32755. }
  32756. var deletingLinesCnt = endLineNumber - startLineNumber;
  32757. var insertingLinesCnt = (op.lines ? op.lines.length - 1 : 0);
  32758. var editingLinesCnt = Math.min(deletingLinesCnt, insertingLinesCnt);
  32759. var text = (op.lines ? op.lines.join(this.getEOL()) : '');
  32760. if (text) {
  32761. // replacement
  32762. this._pieceTree.delete(op.rangeOffset, op.rangeLength);
  32763. this._pieceTree.insert(op.rangeOffset, text, true);
  32764. }
  32765. else {
  32766. // deletion
  32767. this._pieceTree.delete(op.rangeOffset, op.rangeLength);
  32768. }
  32769. if (editingLinesCnt < insertingLinesCnt) {
  32770. var newLinesContent = [];
  32771. for (var j = editingLinesCnt + 1; j <= insertingLinesCnt; j++) {
  32772. newLinesContent.push(op.lines[j]);
  32773. }
  32774. newLinesContent[newLinesContent.length - 1] = this.getLineContent(startLineNumber + insertingLinesCnt - 1);
  32775. }
  32776. var contentChangeRange = new range_1.Range(startLineNumber, startColumn, endLineNumber, endColumn);
  32777. contentChanges.push({
  32778. range: contentChangeRange,
  32779. rangeLength: op.rangeLength,
  32780. text: text,
  32781. rangeOffset: op.rangeOffset,
  32782. forceMoveMarkers: op.forceMoveMarkers
  32783. });
  32784. }
  32785. return contentChanges;
  32786. };
  32787. PieceTreeTextBuffer.prototype.findMatchesLineByLine = function (searchRange, searchData, captureMatches, limitResultCount) {
  32788. return this._pieceTree.findMatchesLineByLine(searchRange, searchData, captureMatches, limitResultCount);
  32789. };
  32790. /**
  32791. * Assumes `operations` are validated and sorted ascending
  32792. */
  32793. PieceTreeTextBuffer._getInverseEditRanges = function (operations) {
  32794. var result = [];
  32795. var prevOpEndLineNumber = 0;
  32796. var prevOpEndColumn = 0;
  32797. var prevOp = null;
  32798. for (var i = 0, len = operations.length; i < len; i++) {
  32799. var op = operations[i];
  32800. var startLineNumber = void 0;
  32801. var startColumn = void 0;
  32802. if (prevOp) {
  32803. if (prevOp.range.endLineNumber === op.range.startLineNumber) {
  32804. startLineNumber = prevOpEndLineNumber;
  32805. startColumn = prevOpEndColumn + (op.range.startColumn - prevOp.range.endColumn);
  32806. }
  32807. else {
  32808. startLineNumber = prevOpEndLineNumber + (op.range.startLineNumber - prevOp.range.endLineNumber);
  32809. startColumn = op.range.startColumn;
  32810. }
  32811. }
  32812. else {
  32813. startLineNumber = op.range.startLineNumber;
  32814. startColumn = op.range.startColumn;
  32815. }
  32816. var resultRange = void 0;
  32817. if (op.lines && op.lines.length > 0) {
  32818. // the operation inserts something
  32819. var lineCount = op.lines.length;
  32820. var firstLine = op.lines[0];
  32821. var lastLine = op.lines[lineCount - 1];
  32822. if (lineCount === 1) {
  32823. // single line insert
  32824. resultRange = new range_1.Range(startLineNumber, startColumn, startLineNumber, startColumn + firstLine.length);
  32825. }
  32826. else {
  32827. // multi line insert
  32828. resultRange = new range_1.Range(startLineNumber, startColumn, startLineNumber + lineCount - 1, lastLine.length + 1);
  32829. }
  32830. }
  32831. else {
  32832. // There is nothing to insert
  32833. resultRange = new range_1.Range(startLineNumber, startColumn, startLineNumber, startColumn);
  32834. }
  32835. prevOpEndLineNumber = resultRange.endLineNumber;
  32836. prevOpEndColumn = resultRange.endColumn;
  32837. result.push(resultRange);
  32838. prevOp = op;
  32839. }
  32840. return result;
  32841. };
  32842. PieceTreeTextBuffer._sortOpsAscending = function (a, b) {
  32843. var r = range_1.Range.compareRangesUsingEnds(a.range, b.range);
  32844. if (r === 0) {
  32845. return a.sortIndex - b.sortIndex;
  32846. }
  32847. return r;
  32848. };
  32849. PieceTreeTextBuffer._sortOpsDescending = function (a, b) {
  32850. var r = range_1.Range.compareRangesUsingEnds(a.range, b.range);
  32851. if (r === 0) {
  32852. return b.sortIndex - a.sortIndex;
  32853. }
  32854. return -r;
  32855. };
  32856. return PieceTreeTextBuffer;
  32857. }());
  32858. exports.PieceTreeTextBuffer = PieceTreeTextBuffer;
  32859. });
  32860. /*---------------------------------------------------------------------------------------------
  32861. * Copyright (c) Microsoft Corporation. All rights reserved.
  32862. * Licensed under the MIT License. See License.txt in the project root for license information.
  32863. *--------------------------------------------------------------------------------------------*/
  32864. define(__m[348/*vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,191/*vs/editor/common/model/pieceTreeTextBuffer/pieceTreeBase*/,347/*vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBuffer*/]), function (require, exports, strings, pieceTreeBase_1, pieceTreeTextBuffer_1) {
  32865. "use strict";
  32866. Object.defineProperty(exports, "__esModule", { value: true });
  32867. var PieceTreeTextBufferFactory = /** @class */ (function () {
  32868. function PieceTreeTextBufferFactory(_chunks, _bom, _cr, _lf, _crlf, _containsRTL, _isBasicASCII, _normalizeEOL) {
  32869. this._chunks = _chunks;
  32870. this._bom = _bom;
  32871. this._cr = _cr;
  32872. this._lf = _lf;
  32873. this._crlf = _crlf;
  32874. this._containsRTL = _containsRTL;
  32875. this._isBasicASCII = _isBasicASCII;
  32876. this._normalizeEOL = _normalizeEOL;
  32877. }
  32878. PieceTreeTextBufferFactory.prototype._getEOL = function (defaultEOL) {
  32879. var totalEOLCount = this._cr + this._lf + this._crlf;
  32880. var totalCRCount = this._cr + this._crlf;
  32881. if (totalEOLCount === 0) {
  32882. // This is an empty file or a file with precisely one line
  32883. return (defaultEOL === 1 /* LF */ ? '\n' : '\r\n');
  32884. }
  32885. if (totalCRCount > totalEOLCount / 2) {
  32886. // More than half of the file contains \r\n ending lines
  32887. return '\r\n';
  32888. }
  32889. // At least one line more ends in \n
  32890. return '\n';
  32891. };
  32892. PieceTreeTextBufferFactory.prototype.create = function (defaultEOL) {
  32893. var eol = this._getEOL(defaultEOL);
  32894. var chunks = this._chunks;
  32895. if (this._normalizeEOL &&
  32896. ((eol === '\r\n' && (this._cr > 0 || this._lf > 0))
  32897. || (eol === '\n' && (this._cr > 0 || this._crlf > 0)))) {
  32898. // Normalize pieces
  32899. for (var i = 0, len = chunks.length; i < len; i++) {
  32900. var str = chunks[i].buffer.replace(/\r\n|\r|\n/g, eol);
  32901. var newLineStart = pieceTreeBase_1.createLineStartsFast(str);
  32902. chunks[i] = new pieceTreeBase_1.StringBuffer(str, newLineStart);
  32903. }
  32904. }
  32905. return new pieceTreeTextBuffer_1.PieceTreeTextBuffer(chunks, this._bom, eol, this._containsRTL, this._isBasicASCII, this._normalizeEOL);
  32906. };
  32907. return PieceTreeTextBufferFactory;
  32908. }());
  32909. exports.PieceTreeTextBufferFactory = PieceTreeTextBufferFactory;
  32910. var PieceTreeTextBufferBuilder = /** @class */ (function () {
  32911. function PieceTreeTextBufferBuilder() {
  32912. this.chunks = [];
  32913. this.BOM = '';
  32914. this._hasPreviousChar = false;
  32915. this._previousChar = 0;
  32916. this._tmpLineStarts = [];
  32917. this.cr = 0;
  32918. this.lf = 0;
  32919. this.crlf = 0;
  32920. this.containsRTL = false;
  32921. this.isBasicASCII = true;
  32922. }
  32923. PieceTreeTextBufferBuilder.prototype.acceptChunk = function (chunk) {
  32924. if (chunk.length === 0) {
  32925. return;
  32926. }
  32927. if (this.chunks.length === 0) {
  32928. if (strings.startsWithUTF8BOM(chunk)) {
  32929. this.BOM = strings.UTF8_BOM_CHARACTER;
  32930. chunk = chunk.substr(1);
  32931. }
  32932. }
  32933. var lastChar = chunk.charCodeAt(chunk.length - 1);
  32934. if (lastChar === 13 /* CarriageReturn */ || (lastChar >= 0xD800 && lastChar <= 0xDBFF)) {
  32935. // last character is \r or a high surrogate => keep it back
  32936. this._acceptChunk1(chunk.substr(0, chunk.length - 1), false);
  32937. this._hasPreviousChar = true;
  32938. this._previousChar = lastChar;
  32939. }
  32940. else {
  32941. this._acceptChunk1(chunk, false);
  32942. this._hasPreviousChar = false;
  32943. this._previousChar = lastChar;
  32944. }
  32945. };
  32946. PieceTreeTextBufferBuilder.prototype._acceptChunk1 = function (chunk, allowEmptyStrings) {
  32947. if (!allowEmptyStrings && chunk.length === 0) {
  32948. // Nothing to do
  32949. return;
  32950. }
  32951. if (this._hasPreviousChar) {
  32952. this._acceptChunk2(String.fromCharCode(this._previousChar) + chunk);
  32953. }
  32954. else {
  32955. this._acceptChunk2(chunk);
  32956. }
  32957. };
  32958. PieceTreeTextBufferBuilder.prototype._acceptChunk2 = function (chunk) {
  32959. var lineStarts = pieceTreeBase_1.createLineStarts(this._tmpLineStarts, chunk);
  32960. this.chunks.push(new pieceTreeBase_1.StringBuffer(chunk, lineStarts.lineStarts));
  32961. this.cr += lineStarts.cr;
  32962. this.lf += lineStarts.lf;
  32963. this.crlf += lineStarts.crlf;
  32964. if (this.isBasicASCII) {
  32965. this.isBasicASCII = lineStarts.isBasicASCII;
  32966. }
  32967. if (!this.isBasicASCII && !this.containsRTL) {
  32968. // No need to check if is basic ASCII
  32969. this.containsRTL = strings.containsRTL(chunk);
  32970. }
  32971. };
  32972. PieceTreeTextBufferBuilder.prototype.finish = function (normalizeEOL) {
  32973. if (normalizeEOL === void 0) { normalizeEOL = true; }
  32974. this._finish();
  32975. return new PieceTreeTextBufferFactory(this.chunks, this.BOM, this.cr, this.lf, this.crlf, this.containsRTL, this.isBasicASCII, normalizeEOL);
  32976. };
  32977. PieceTreeTextBufferBuilder.prototype._finish = function () {
  32978. if (this.chunks.length === 0) {
  32979. this._acceptChunk1('', true);
  32980. }
  32981. if (this._hasPreviousChar) {
  32982. this._hasPreviousChar = false;
  32983. // recreate last chunk
  32984. var lastChunk = this.chunks[this.chunks.length - 1];
  32985. lastChunk.buffer += String.fromCharCode(this._previousChar);
  32986. var newLineStarts = pieceTreeBase_1.createLineStartsFast(lastChunk.buffer);
  32987. lastChunk.lineStarts = newLineStarts;
  32988. if (this._previousChar === 13 /* CarriageReturn */) {
  32989. this.cr++;
  32990. }
  32991. }
  32992. };
  32993. return PieceTreeTextBufferBuilder;
  32994. }());
  32995. exports.PieceTreeTextBufferBuilder = PieceTreeTextBufferBuilder;
  32996. });
  32997. /*---------------------------------------------------------------------------------------------
  32998. * Copyright (c) Microsoft Corporation. All rights reserved.
  32999. * Licensed under the MIT License. See License.txt in the project root for license information.
  33000. *--------------------------------------------------------------------------------------------*/
  33001. define(__m[109/*vs/editor/common/model/wordHelper*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  33002. "use strict";
  33003. Object.defineProperty(exports, "__esModule", { value: true });
  33004. exports.USUAL_WORD_SEPARATORS = '`~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?';
  33005. /**
  33006. * Create a word definition regular expression based on default word separators.
  33007. * Optionally provide allowed separators that should be included in words.
  33008. *
  33009. * The default would look like this:
  33010. * /(-?\d*\.\d\w*)|([^\`\~\!\@\#\$\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
  33011. */
  33012. function createWordRegExp(allowInWords) {
  33013. if (allowInWords === void 0) { allowInWords = ''; }
  33014. var source = '(-?\\d*\\.\\d\\w*)|([^';
  33015. for (var _i = 0, USUAL_WORD_SEPARATORS_1 = exports.USUAL_WORD_SEPARATORS; _i < USUAL_WORD_SEPARATORS_1.length; _i++) {
  33016. var sep = USUAL_WORD_SEPARATORS_1[_i];
  33017. if (allowInWords.indexOf(sep) >= 0) {
  33018. continue;
  33019. }
  33020. source += '\\' + sep;
  33021. }
  33022. source += '\\s]+)';
  33023. return new RegExp(source, 'g');
  33024. }
  33025. // catches numbers (including floating numbers) in the first group, and alphanum in the second
  33026. exports.DEFAULT_WORD_REGEXP = createWordRegExp();
  33027. function ensureValidWordDefinition(wordDefinition) {
  33028. var result = exports.DEFAULT_WORD_REGEXP;
  33029. if (wordDefinition && (wordDefinition instanceof RegExp)) {
  33030. if (!wordDefinition.global) {
  33031. var flags = 'g';
  33032. if (wordDefinition.ignoreCase) {
  33033. flags += 'i';
  33034. }
  33035. if (wordDefinition.multiline) {
  33036. flags += 'm';
  33037. }
  33038. if (wordDefinition.unicode) {
  33039. flags += 'u';
  33040. }
  33041. result = new RegExp(wordDefinition.source, flags);
  33042. }
  33043. else {
  33044. result = wordDefinition;
  33045. }
  33046. }
  33047. result.lastIndex = 0;
  33048. return result;
  33049. }
  33050. exports.ensureValidWordDefinition = ensureValidWordDefinition;
  33051. function getWordAtPosFast(column, wordDefinition, text, textOffset) {
  33052. // find whitespace enclosed text around column and match from there
  33053. var pos = column - 1 - textOffset;
  33054. var start = text.lastIndexOf(' ', pos - 1) + 1;
  33055. wordDefinition.lastIndex = start;
  33056. var match;
  33057. while (match = wordDefinition.exec(text)) {
  33058. var matchIndex = match.index || 0;
  33059. if (matchIndex <= pos && wordDefinition.lastIndex >= pos) {
  33060. return {
  33061. word: match[0],
  33062. startColumn: textOffset + 1 + matchIndex,
  33063. endColumn: textOffset + 1 + wordDefinition.lastIndex
  33064. };
  33065. }
  33066. }
  33067. return null;
  33068. }
  33069. function getWordAtPosSlow(column, wordDefinition, text, textOffset) {
  33070. // matches all words starting at the beginning
  33071. // of the input until it finds a match that encloses
  33072. // the desired column. slow but correct
  33073. var pos = column - 1 - textOffset;
  33074. wordDefinition.lastIndex = 0;
  33075. var match;
  33076. while (match = wordDefinition.exec(text)) {
  33077. var matchIndex = match.index || 0;
  33078. if (matchIndex > pos) {
  33079. // |nW -> matched only after the pos
  33080. return null;
  33081. }
  33082. else if (wordDefinition.lastIndex >= pos) {
  33083. // W|W -> match encloses pos
  33084. return {
  33085. word: match[0],
  33086. startColumn: textOffset + 1 + matchIndex,
  33087. endColumn: textOffset + 1 + wordDefinition.lastIndex
  33088. };
  33089. }
  33090. }
  33091. return null;
  33092. }
  33093. function getWordAtText(column, wordDefinition, text, textOffset) {
  33094. // if `words` can contain whitespace character we have to use the slow variant
  33095. // otherwise we use the fast variant of finding a word
  33096. wordDefinition.lastIndex = 0;
  33097. var match = wordDefinition.exec(text);
  33098. if (!match) {
  33099. return null;
  33100. }
  33101. // todo@joh the `match` could already be the (first) word
  33102. var ret = match[0].indexOf(' ') >= 0
  33103. // did match a word which contains a space character -> use slow word find
  33104. ? getWordAtPosSlow(column, wordDefinition, text, textOffset)
  33105. // sane word definition -> use fast word find
  33106. : getWordAtPosFast(column, wordDefinition, text, textOffset);
  33107. // both (getWordAtPosFast and getWordAtPosSlow) leave the wordDefinition-RegExp
  33108. // in an undefined state and to not confuse other users of the wordDefinition
  33109. // we reset the lastIndex
  33110. wordDefinition.lastIndex = 0;
  33111. return ret;
  33112. }
  33113. exports.getWordAtText = getWordAtText;
  33114. });
  33115. /*---------------------------------------------------------------------------------------------
  33116. * Copyright (c) Microsoft Corporation. All rights reserved.
  33117. * Licensed under the MIT License. See License.txt in the project root for license information.
  33118. *--------------------------------------------------------------------------------------------*/
  33119. define(__m[349/*vs/editor/common/modes/abstractMode*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  33120. "use strict";
  33121. Object.defineProperty(exports, "__esModule", { value: true });
  33122. var FrankensteinMode = /** @class */ (function () {
  33123. function FrankensteinMode(languageIdentifier) {
  33124. this._languageIdentifier = languageIdentifier;
  33125. }
  33126. FrankensteinMode.prototype.getId = function () {
  33127. return this._languageIdentifier.language;
  33128. };
  33129. return FrankensteinMode;
  33130. }());
  33131. exports.FrankensteinMode = FrankensteinMode;
  33132. });
  33133. /*---------------------------------------------------------------------------------------------
  33134. * Copyright (c) Microsoft Corporation. All rights reserved.
  33135. * Licensed under the MIT License. See License.txt in the project root for license information.
  33136. *--------------------------------------------------------------------------------------------*/
  33137. define(__m[90/*vs/editor/common/modes/languageConfiguration*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  33138. "use strict";
  33139. Object.defineProperty(exports, "__esModule", { value: true });
  33140. /**
  33141. * Describes what to do with the indentation when pressing Enter.
  33142. */
  33143. var IndentAction;
  33144. (function (IndentAction) {
  33145. /**
  33146. * Insert new line and copy the previous line's indentation.
  33147. */
  33148. IndentAction[IndentAction["None"] = 0] = "None";
  33149. /**
  33150. * Insert new line and indent once (relative to the previous line's indentation).
  33151. */
  33152. IndentAction[IndentAction["Indent"] = 1] = "Indent";
  33153. /**
  33154. * Insert two new lines:
  33155. * - the first one indented which will hold the cursor
  33156. * - the second one at the same indentation level
  33157. */
  33158. IndentAction[IndentAction["IndentOutdent"] = 2] = "IndentOutdent";
  33159. /**
  33160. * Insert new line and outdent once (relative to the previous line's indentation).
  33161. */
  33162. IndentAction[IndentAction["Outdent"] = 3] = "Outdent";
  33163. })(IndentAction = exports.IndentAction || (exports.IndentAction = {}));
  33164. /**
  33165. * @internal
  33166. */
  33167. var StandardAutoClosingPairConditional = /** @class */ (function () {
  33168. function StandardAutoClosingPairConditional(source) {
  33169. this.open = source.open;
  33170. this.close = source.close;
  33171. // initially allowed in all tokens
  33172. this._standardTokenMask = 0;
  33173. if (Array.isArray(source.notIn)) {
  33174. for (var i = 0, len = source.notIn.length; i < len; i++) {
  33175. var notIn = source.notIn[i];
  33176. switch (notIn) {
  33177. case 'string':
  33178. this._standardTokenMask |= 2 /* String */;
  33179. break;
  33180. case 'comment':
  33181. this._standardTokenMask |= 1 /* Comment */;
  33182. break;
  33183. case 'regex':
  33184. this._standardTokenMask |= 4 /* RegEx */;
  33185. break;
  33186. }
  33187. }
  33188. }
  33189. }
  33190. StandardAutoClosingPairConditional.prototype.isOK = function (standardToken) {
  33191. return (this._standardTokenMask & standardToken) === 0;
  33192. };
  33193. return StandardAutoClosingPairConditional;
  33194. }());
  33195. exports.StandardAutoClosingPairConditional = StandardAutoClosingPairConditional;
  33196. });
  33197. /*---------------------------------------------------------------------------------------------
  33198. * Copyright (c) Microsoft Corporation. All rights reserved.
  33199. * Licensed under the MIT License. See License.txt in the project root for license information.
  33200. *--------------------------------------------------------------------------------------------*/
  33201. define(__m[350/*vs/editor/common/modes/languageSelector*/], __M([0/*require*/,1/*exports*/,178/*vs/base/common/glob*/]), function (require, exports, glob_1) {
  33202. "use strict";
  33203. Object.defineProperty(exports, "__esModule", { value: true });
  33204. function score(selector, candidateUri, candidateLanguage, candidateIsSynchronized) {
  33205. if (Array.isArray(selector)) {
  33206. // array -> take max individual value
  33207. var ret = 0;
  33208. for (var _i = 0, selector_1 = selector; _i < selector_1.length; _i++) {
  33209. var filter = selector_1[_i];
  33210. var value = score(filter, candidateUri, candidateLanguage, candidateIsSynchronized);
  33211. if (value === 10) {
  33212. return value; // already at the highest
  33213. }
  33214. if (value > ret) {
  33215. ret = value;
  33216. }
  33217. }
  33218. return ret;
  33219. }
  33220. else if (typeof selector === 'string') {
  33221. if (!candidateIsSynchronized) {
  33222. return 0;
  33223. }
  33224. // short-hand notion, desugars to
  33225. // 'fooLang' -> { language: 'fooLang'}
  33226. // '*' -> { language: '*' }
  33227. if (selector === '*') {
  33228. return 5;
  33229. }
  33230. else if (selector === candidateLanguage) {
  33231. return 10;
  33232. }
  33233. else {
  33234. return 0;
  33235. }
  33236. }
  33237. else if (selector) {
  33238. // filter -> select accordingly, use defaults for scheme
  33239. var language = selector.language, pattern = selector.pattern, scheme = selector.scheme, hasAccessToAllModels = selector.hasAccessToAllModels;
  33240. if (!candidateIsSynchronized && !hasAccessToAllModels) {
  33241. return 0;
  33242. }
  33243. var ret = 0;
  33244. if (scheme) {
  33245. if (scheme === candidateUri.scheme) {
  33246. ret = 10;
  33247. }
  33248. else if (scheme === '*') {
  33249. ret = 5;
  33250. }
  33251. else {
  33252. return 0;
  33253. }
  33254. }
  33255. if (language) {
  33256. if (language === candidateLanguage) {
  33257. ret = 10;
  33258. }
  33259. else if (language === '*') {
  33260. ret = Math.max(ret, 5);
  33261. }
  33262. else {
  33263. return 0;
  33264. }
  33265. }
  33266. if (pattern) {
  33267. if (pattern === candidateUri.fsPath || glob_1.match(pattern, candidateUri.fsPath)) {
  33268. ret = 10;
  33269. }
  33270. else {
  33271. return 0;
  33272. }
  33273. }
  33274. return ret;
  33275. }
  33276. else {
  33277. return 0;
  33278. }
  33279. }
  33280. exports.score = score;
  33281. });
  33282. /*---------------------------------------------------------------------------------------------
  33283. * Copyright (c) Microsoft Corporation. All rights reserved.
  33284. * Licensed under the MIT License. See License.txt in the project root for license information.
  33285. *--------------------------------------------------------------------------------------------*/
  33286. define(__m[351/*vs/editor/common/modes/linkComputer*/], __M([0/*require*/,1/*exports*/,79/*vs/editor/common/core/characterClassifier*/]), function (require, exports, characterClassifier_1) {
  33287. "use strict";
  33288. Object.defineProperty(exports, "__esModule", { value: true });
  33289. var Uint8Matrix = /** @class */ (function () {
  33290. function Uint8Matrix(rows, cols, defaultValue) {
  33291. var data = new Uint8Array(rows * cols);
  33292. for (var i = 0, len = rows * cols; i < len; i++) {
  33293. data[i] = defaultValue;
  33294. }
  33295. this._data = data;
  33296. this.rows = rows;
  33297. this.cols = cols;
  33298. }
  33299. Uint8Matrix.prototype.get = function (row, col) {
  33300. return this._data[row * this.cols + col];
  33301. };
  33302. Uint8Matrix.prototype.set = function (row, col, value) {
  33303. this._data[row * this.cols + col] = value;
  33304. };
  33305. return Uint8Matrix;
  33306. }());
  33307. exports.Uint8Matrix = Uint8Matrix;
  33308. var StateMachine = /** @class */ (function () {
  33309. function StateMachine(edges) {
  33310. var maxCharCode = 0;
  33311. var maxState = 0 /* Invalid */;
  33312. for (var i = 0, len = edges.length; i < len; i++) {
  33313. var _a = edges[i], from = _a[0], chCode = _a[1], to = _a[2];
  33314. if (chCode > maxCharCode) {
  33315. maxCharCode = chCode;
  33316. }
  33317. if (from > maxState) {
  33318. maxState = from;
  33319. }
  33320. if (to > maxState) {
  33321. maxState = to;
  33322. }
  33323. }
  33324. maxCharCode++;
  33325. maxState++;
  33326. var states = new Uint8Matrix(maxState, maxCharCode, 0 /* Invalid */);
  33327. for (var i = 0, len = edges.length; i < len; i++) {
  33328. var _b = edges[i], from = _b[0], chCode = _b[1], to = _b[2];
  33329. states.set(from, chCode, to);
  33330. }
  33331. this._states = states;
  33332. this._maxCharCode = maxCharCode;
  33333. }
  33334. StateMachine.prototype.nextState = function (currentState, chCode) {
  33335. if (chCode < 0 || chCode >= this._maxCharCode) {
  33336. return 0 /* Invalid */;
  33337. }
  33338. return this._states.get(currentState, chCode);
  33339. };
  33340. return StateMachine;
  33341. }());
  33342. exports.StateMachine = StateMachine;
  33343. // State machine for http:// or https:// or file://
  33344. var _stateMachine = null;
  33345. function getStateMachine() {
  33346. if (_stateMachine === null) {
  33347. _stateMachine = new StateMachine([
  33348. [1 /* Start */, 104 /* h */, 2 /* H */],
  33349. [1 /* Start */, 72 /* H */, 2 /* H */],
  33350. [1 /* Start */, 102 /* f */, 6 /* F */],
  33351. [1 /* Start */, 70 /* F */, 6 /* F */],
  33352. [2 /* H */, 116 /* t */, 3 /* HT */],
  33353. [2 /* H */, 84 /* T */, 3 /* HT */],
  33354. [3 /* HT */, 116 /* t */, 4 /* HTT */],
  33355. [3 /* HT */, 84 /* T */, 4 /* HTT */],
  33356. [4 /* HTT */, 112 /* p */, 5 /* HTTP */],
  33357. [4 /* HTT */, 80 /* P */, 5 /* HTTP */],
  33358. [5 /* HTTP */, 115 /* s */, 9 /* BeforeColon */],
  33359. [5 /* HTTP */, 83 /* S */, 9 /* BeforeColon */],
  33360. [5 /* HTTP */, 58 /* Colon */, 10 /* AfterColon */],
  33361. [6 /* F */, 105 /* i */, 7 /* FI */],
  33362. [6 /* F */, 73 /* I */, 7 /* FI */],
  33363. [7 /* FI */, 108 /* l */, 8 /* FIL */],
  33364. [7 /* FI */, 76 /* L */, 8 /* FIL */],
  33365. [8 /* FIL */, 101 /* e */, 9 /* BeforeColon */],
  33366. [8 /* FIL */, 69 /* E */, 9 /* BeforeColon */],
  33367. [9 /* BeforeColon */, 58 /* Colon */, 10 /* AfterColon */],
  33368. [10 /* AfterColon */, 47 /* Slash */, 11 /* AlmostThere */],
  33369. [11 /* AlmostThere */, 47 /* Slash */, 12 /* End */],
  33370. ]);
  33371. }
  33372. return _stateMachine;
  33373. }
  33374. var _classifier = null;
  33375. function getClassifier() {
  33376. if (_classifier === null) {
  33377. _classifier = new characterClassifier_1.CharacterClassifier(0 /* None */);
  33378. var FORCE_TERMINATION_CHARACTERS = ' \t<>\'\"、。。、,.:;?!@#$%&*‘“〈《「『【〔([{「」}])〕】』」》〉”’`~…';
  33379. for (var i = 0; i < FORCE_TERMINATION_CHARACTERS.length; i++) {
  33380. _classifier.set(FORCE_TERMINATION_CHARACTERS.charCodeAt(i), 1 /* ForceTermination */);
  33381. }
  33382. var CANNOT_END_WITH_CHARACTERS = '.,;';
  33383. for (var i = 0; i < CANNOT_END_WITH_CHARACTERS.length; i++) {
  33384. _classifier.set(CANNOT_END_WITH_CHARACTERS.charCodeAt(i), 2 /* CannotEndIn */);
  33385. }
  33386. }
  33387. return _classifier;
  33388. }
  33389. var LinkComputer = /** @class */ (function () {
  33390. function LinkComputer() {
  33391. }
  33392. LinkComputer._createLink = function (classifier, line, lineNumber, linkBeginIndex, linkEndIndex) {
  33393. // Do not allow to end link in certain characters...
  33394. var lastIncludedCharIndex = linkEndIndex - 1;
  33395. do {
  33396. var chCode = line.charCodeAt(lastIncludedCharIndex);
  33397. var chClass = classifier.get(chCode);
  33398. if (chClass !== 2 /* CannotEndIn */) {
  33399. break;
  33400. }
  33401. lastIncludedCharIndex--;
  33402. } while (lastIncludedCharIndex > linkBeginIndex);
  33403. // Handle links enclosed in parens, square brackets and curlys.
  33404. if (linkBeginIndex > 0) {
  33405. var charCodeBeforeLink = line.charCodeAt(linkBeginIndex - 1);
  33406. var lastCharCodeInLink = line.charCodeAt(lastIncludedCharIndex);
  33407. if ((charCodeBeforeLink === 40 /* OpenParen */ && lastCharCodeInLink === 41 /* CloseParen */)
  33408. || (charCodeBeforeLink === 91 /* OpenSquareBracket */ && lastCharCodeInLink === 93 /* CloseSquareBracket */)
  33409. || (charCodeBeforeLink === 123 /* OpenCurlyBrace */ && lastCharCodeInLink === 125 /* CloseCurlyBrace */)) {
  33410. // Do not end in ) if ( is before the link start
  33411. // Do not end in ] if [ is before the link start
  33412. // Do not end in } if { is before the link start
  33413. lastIncludedCharIndex--;
  33414. }
  33415. }
  33416. return {
  33417. range: {
  33418. startLineNumber: lineNumber,
  33419. startColumn: linkBeginIndex + 1,
  33420. endLineNumber: lineNumber,
  33421. endColumn: lastIncludedCharIndex + 2
  33422. },
  33423. url: line.substring(linkBeginIndex, lastIncludedCharIndex + 1)
  33424. };
  33425. };
  33426. LinkComputer.computeLinks = function (model, stateMachine) {
  33427. if (stateMachine === void 0) { stateMachine = getStateMachine(); }
  33428. var classifier = getClassifier();
  33429. var result = [];
  33430. for (var i = 1, lineCount = model.getLineCount(); i <= lineCount; i++) {
  33431. var line = model.getLineContent(i);
  33432. var len = line.length;
  33433. var j = 0;
  33434. var linkBeginIndex = 0;
  33435. var linkBeginChCode = 0;
  33436. var state = 1 /* Start */;
  33437. var hasOpenParens = false;
  33438. var hasOpenSquareBracket = false;
  33439. var hasOpenCurlyBracket = false;
  33440. while (j < len) {
  33441. var resetStateMachine = false;
  33442. var chCode = line.charCodeAt(j);
  33443. if (state === 13 /* Accept */) {
  33444. var chClass = void 0;
  33445. switch (chCode) {
  33446. case 40 /* OpenParen */:
  33447. hasOpenParens = true;
  33448. chClass = 0 /* None */;
  33449. break;
  33450. case 41 /* CloseParen */:
  33451. chClass = (hasOpenParens ? 0 /* None */ : 1 /* ForceTermination */);
  33452. break;
  33453. case 91 /* OpenSquareBracket */:
  33454. hasOpenSquareBracket = true;
  33455. chClass = 0 /* None */;
  33456. break;
  33457. case 93 /* CloseSquareBracket */:
  33458. chClass = (hasOpenSquareBracket ? 0 /* None */ : 1 /* ForceTermination */);
  33459. break;
  33460. case 123 /* OpenCurlyBrace */:
  33461. hasOpenCurlyBracket = true;
  33462. chClass = 0 /* None */;
  33463. break;
  33464. case 125 /* CloseCurlyBrace */:
  33465. chClass = (hasOpenCurlyBracket ? 0 /* None */ : 1 /* ForceTermination */);
  33466. break;
  33467. /* The following three rules make it that ' or " or ` are allowed inside links if the link began with a different one */
  33468. case 39 /* SingleQuote */:
  33469. chClass = (linkBeginChCode === 34 /* DoubleQuote */ || linkBeginChCode === 96 /* BackTick */) ? 0 /* None */ : 1 /* ForceTermination */;
  33470. break;
  33471. case 34 /* DoubleQuote */:
  33472. chClass = (linkBeginChCode === 39 /* SingleQuote */ || linkBeginChCode === 96 /* BackTick */) ? 0 /* None */ : 1 /* ForceTermination */;
  33473. break;
  33474. case 96 /* BackTick */:
  33475. chClass = (linkBeginChCode === 39 /* SingleQuote */ || linkBeginChCode === 34 /* DoubleQuote */) ? 0 /* None */ : 1 /* ForceTermination */;
  33476. break;
  33477. case 42 /* Asterisk */:
  33478. // `*` terminates a link if the link began with `*`
  33479. chClass = (linkBeginChCode === 42 /* Asterisk */) ? 1 /* ForceTermination */ : 0 /* None */;
  33480. break;
  33481. case 124 /* Pipe */:
  33482. // `|` terminates a link if the link began with `|`
  33483. chClass = (linkBeginChCode === 124 /* Pipe */) ? 1 /* ForceTermination */ : 0 /* None */;
  33484. break;
  33485. default:
  33486. chClass = classifier.get(chCode);
  33487. }
  33488. // Check if character terminates link
  33489. if (chClass === 1 /* ForceTermination */) {
  33490. result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, j));
  33491. resetStateMachine = true;
  33492. }
  33493. }
  33494. else if (state === 12 /* End */) {
  33495. var chClass = void 0;
  33496. if (chCode === 91 /* OpenSquareBracket */) {
  33497. // Allow for the authority part to contain ipv6 addresses which contain [ and ]
  33498. hasOpenSquareBracket = true;
  33499. chClass = 0 /* None */;
  33500. }
  33501. else {
  33502. chClass = classifier.get(chCode);
  33503. }
  33504. // Check if character terminates link
  33505. if (chClass === 1 /* ForceTermination */) {
  33506. resetStateMachine = true;
  33507. }
  33508. else {
  33509. state = 13 /* Accept */;
  33510. }
  33511. }
  33512. else {
  33513. state = stateMachine.nextState(state, chCode);
  33514. if (state === 0 /* Invalid */) {
  33515. resetStateMachine = true;
  33516. }
  33517. }
  33518. if (resetStateMachine) {
  33519. state = 1 /* Start */;
  33520. hasOpenParens = false;
  33521. hasOpenSquareBracket = false;
  33522. hasOpenCurlyBracket = false;
  33523. // Record where the link started
  33524. linkBeginIndex = j + 1;
  33525. linkBeginChCode = chCode;
  33526. }
  33527. j++;
  33528. }
  33529. if (state === 13 /* Accept */) {
  33530. result.push(LinkComputer._createLink(classifier, line, i, linkBeginIndex, len));
  33531. }
  33532. }
  33533. return result;
  33534. };
  33535. return LinkComputer;
  33536. }());
  33537. exports.LinkComputer = LinkComputer;
  33538. /**
  33539. * Returns an array of all links contains in the provided
  33540. * document. *Note* that this operation is computational
  33541. * expensive and should not run in the UI thread.
  33542. */
  33543. function computeLinks(model) {
  33544. if (!model || typeof model.getLineCount !== 'function' || typeof model.getLineContent !== 'function') {
  33545. // Unknown caller!
  33546. return [];
  33547. }
  33548. return LinkComputer.computeLinks(model);
  33549. }
  33550. exports.computeLinks = computeLinks;
  33551. });
  33552. /*---------------------------------------------------------------------------------------------
  33553. * Copyright (c) Microsoft Corporation. All rights reserved.
  33554. * Licensed under the MIT License. See License.txt in the project root for license information.
  33555. *--------------------------------------------------------------------------------------------*/
  33556. define(__m[145/*vs/editor/common/modes/supports*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  33557. "use strict";
  33558. Object.defineProperty(exports, "__esModule", { value: true });
  33559. function createScopedLineTokens(context, offset) {
  33560. var tokenCount = context.getCount();
  33561. var tokenIndex = context.findTokenIndexAtOffset(offset);
  33562. var desiredLanguageId = context.getLanguageId(tokenIndex);
  33563. var lastTokenIndex = tokenIndex;
  33564. while (lastTokenIndex + 1 < tokenCount && context.getLanguageId(lastTokenIndex + 1) === desiredLanguageId) {
  33565. lastTokenIndex++;
  33566. }
  33567. var firstTokenIndex = tokenIndex;
  33568. while (firstTokenIndex > 0 && context.getLanguageId(firstTokenIndex - 1) === desiredLanguageId) {
  33569. firstTokenIndex--;
  33570. }
  33571. return new ScopedLineTokens(context, desiredLanguageId, firstTokenIndex, lastTokenIndex + 1, context.getStartOffset(firstTokenIndex), context.getEndOffset(lastTokenIndex));
  33572. }
  33573. exports.createScopedLineTokens = createScopedLineTokens;
  33574. var ScopedLineTokens = /** @class */ (function () {
  33575. function ScopedLineTokens(actual, languageId, firstTokenIndex, lastTokenIndex, firstCharOffset, lastCharOffset) {
  33576. this._actual = actual;
  33577. this.languageId = languageId;
  33578. this._firstTokenIndex = firstTokenIndex;
  33579. this._lastTokenIndex = lastTokenIndex;
  33580. this.firstCharOffset = firstCharOffset;
  33581. this._lastCharOffset = lastCharOffset;
  33582. }
  33583. ScopedLineTokens.prototype.getLineContent = function () {
  33584. var actualLineContent = this._actual.getLineContent();
  33585. return actualLineContent.substring(this.firstCharOffset, this._lastCharOffset);
  33586. };
  33587. ScopedLineTokens.prototype.getActualLineContentBefore = function (offset) {
  33588. var actualLineContent = this._actual.getLineContent();
  33589. return actualLineContent.substring(0, this.firstCharOffset + offset);
  33590. };
  33591. ScopedLineTokens.prototype.getTokenCount = function () {
  33592. return this._lastTokenIndex - this._firstTokenIndex;
  33593. };
  33594. ScopedLineTokens.prototype.findTokenIndexAtOffset = function (offset) {
  33595. return this._actual.findTokenIndexAtOffset(offset + this.firstCharOffset) - this._firstTokenIndex;
  33596. };
  33597. ScopedLineTokens.prototype.getStandardTokenType = function (tokenIndex) {
  33598. return this._actual.getStandardTokenType(tokenIndex + this._firstTokenIndex);
  33599. };
  33600. return ScopedLineTokens;
  33601. }());
  33602. exports.ScopedLineTokens = ScopedLineTokens;
  33603. function ignoreBracketsInToken(standardTokenType) {
  33604. return (standardTokenType & 7 /* value */) !== 0;
  33605. }
  33606. exports.ignoreBracketsInToken = ignoreBracketsInToken;
  33607. });
  33608. /*---------------------------------------------------------------------------------------------
  33609. * Copyright (c) Microsoft Corporation. All rights reserved.
  33610. * Licensed under the MIT License. See License.txt in the project root for license information.
  33611. *--------------------------------------------------------------------------------------------*/
  33612. define(__m[352/*vs/editor/common/modes/supports/characterPair*/], __M([0/*require*/,1/*exports*/,90/*vs/editor/common/modes/languageConfiguration*/]), function (require, exports, languageConfiguration_1) {
  33613. "use strict";
  33614. Object.defineProperty(exports, "__esModule", { value: true });
  33615. var CharacterPairSupport = /** @class */ (function () {
  33616. function CharacterPairSupport(config) {
  33617. if (config.autoClosingPairs) {
  33618. this._autoClosingPairs = config.autoClosingPairs.map(function (el) { return new languageConfiguration_1.StandardAutoClosingPairConditional(el); });
  33619. }
  33620. else if (config.brackets) {
  33621. this._autoClosingPairs = config.brackets.map(function (b) { return new languageConfiguration_1.StandardAutoClosingPairConditional({ open: b[0], close: b[1] }); });
  33622. }
  33623. else {
  33624. this._autoClosingPairs = [];
  33625. }
  33626. if (config.__electricCharacterSupport && config.__electricCharacterSupport.docComment) {
  33627. var docComment = config.__electricCharacterSupport.docComment;
  33628. // IDocComment is legacy, only partially supported
  33629. this._autoClosingPairs.push(new languageConfiguration_1.StandardAutoClosingPairConditional({ open: docComment.open, close: docComment.close || '' }));
  33630. }
  33631. this._autoCloseBefore = typeof config.autoCloseBefore === 'string' ? config.autoCloseBefore : CharacterPairSupport.DEFAULT_AUTOCLOSE_BEFORE_LANGUAGE_DEFINED;
  33632. this._surroundingPairs = config.surroundingPairs || this._autoClosingPairs;
  33633. }
  33634. CharacterPairSupport.prototype.getAutoClosingPairs = function () {
  33635. return this._autoClosingPairs;
  33636. };
  33637. CharacterPairSupport.prototype.getAutoCloseBeforeSet = function () {
  33638. return this._autoCloseBefore;
  33639. };
  33640. CharacterPairSupport.shouldAutoClosePair = function (autoClosingPair, context, column) {
  33641. // Always complete on empty line
  33642. if (context.getTokenCount() === 0) {
  33643. return true;
  33644. }
  33645. var tokenIndex = context.findTokenIndexAtOffset(column - 2);
  33646. var standardTokenType = context.getStandardTokenType(tokenIndex);
  33647. return autoClosingPair.isOK(standardTokenType);
  33648. };
  33649. CharacterPairSupport.prototype.getSurroundingPairs = function () {
  33650. return this._surroundingPairs;
  33651. };
  33652. CharacterPairSupport.DEFAULT_AUTOCLOSE_BEFORE_LANGUAGE_DEFINED = ';:.,=}])> \n\t';
  33653. return CharacterPairSupport;
  33654. }());
  33655. exports.CharacterPairSupport = CharacterPairSupport;
  33656. });
  33657. /*---------------------------------------------------------------------------------------------
  33658. * Copyright (c) Microsoft Corporation. All rights reserved.
  33659. * Licensed under the MIT License. See License.txt in the project root for license information.
  33660. *--------------------------------------------------------------------------------------------*/
  33661. define(__m[353/*vs/editor/common/modes/supports/indentRules*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  33662. "use strict";
  33663. Object.defineProperty(exports, "__esModule", { value: true });
  33664. var IndentRulesSupport = /** @class */ (function () {
  33665. function IndentRulesSupport(indentationRules) {
  33666. this._indentationRules = indentationRules;
  33667. }
  33668. IndentRulesSupport.prototype.shouldIncrease = function (text) {
  33669. if (this._indentationRules) {
  33670. if (this._indentationRules.increaseIndentPattern && this._indentationRules.increaseIndentPattern.test(text)) {
  33671. return true;
  33672. }
  33673. // if (this._indentationRules.indentNextLinePattern && this._indentationRules.indentNextLinePattern.test(text)) {
  33674. // return true;
  33675. // }
  33676. }
  33677. return false;
  33678. };
  33679. IndentRulesSupport.prototype.shouldDecrease = function (text) {
  33680. if (this._indentationRules && this._indentationRules.decreaseIndentPattern && this._indentationRules.decreaseIndentPattern.test(text)) {
  33681. return true;
  33682. }
  33683. return false;
  33684. };
  33685. IndentRulesSupport.prototype.shouldIndentNextLine = function (text) {
  33686. if (this._indentationRules && this._indentationRules.indentNextLinePattern && this._indentationRules.indentNextLinePattern.test(text)) {
  33687. return true;
  33688. }
  33689. return false;
  33690. };
  33691. IndentRulesSupport.prototype.shouldIgnore = function (text) {
  33692. // the text matches `unIndentedLinePattern`
  33693. if (this._indentationRules && this._indentationRules.unIndentedLinePattern && this._indentationRules.unIndentedLinePattern.test(text)) {
  33694. return true;
  33695. }
  33696. return false;
  33697. };
  33698. IndentRulesSupport.prototype.getIndentMetadata = function (text) {
  33699. var ret = 0;
  33700. if (this.shouldIncrease(text)) {
  33701. ret += 1 /* INCREASE_MASK */;
  33702. }
  33703. if (this.shouldDecrease(text)) {
  33704. ret += 2 /* DECREASE_MASK */;
  33705. }
  33706. if (this.shouldIndentNextLine(text)) {
  33707. ret += 4 /* INDENT_NEXTLINE_MASK */;
  33708. }
  33709. if (this.shouldIgnore(text)) {
  33710. ret += 8 /* UNINDENT_MASK */;
  33711. }
  33712. return ret;
  33713. };
  33714. return IndentRulesSupport;
  33715. }());
  33716. exports.IndentRulesSupport = IndentRulesSupport;
  33717. });
  33718. /*---------------------------------------------------------------------------------------------
  33719. * Copyright (c) Microsoft Corporation. All rights reserved.
  33720. * Licensed under the MIT License. See License.txt in the project root for license information.
  33721. *--------------------------------------------------------------------------------------------*/
  33722. define(__m[354/*vs/editor/common/modes/supports/inplaceReplaceSupport*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  33723. "use strict";
  33724. Object.defineProperty(exports, "__esModule", { value: true });
  33725. var BasicInplaceReplace = /** @class */ (function () {
  33726. function BasicInplaceReplace() {
  33727. this._defaultValueSet = [
  33728. ['true', 'false'],
  33729. ['True', 'False'],
  33730. ['Private', 'Public', 'Friend', 'ReadOnly', 'Partial', 'Protected', 'WriteOnly'],
  33731. ['public', 'protected', 'private'],
  33732. ];
  33733. }
  33734. BasicInplaceReplace.prototype.navigateValueSet = function (range1, text1, range2, text2, up) {
  33735. if (range1 && text1) {
  33736. var result = this.doNavigateValueSet(text1, up);
  33737. if (result) {
  33738. return {
  33739. range: range1,
  33740. value: result
  33741. };
  33742. }
  33743. }
  33744. if (range2 && text2) {
  33745. var result = this.doNavigateValueSet(text2, up);
  33746. if (result) {
  33747. return {
  33748. range: range2,
  33749. value: result
  33750. };
  33751. }
  33752. }
  33753. return null;
  33754. };
  33755. BasicInplaceReplace.prototype.doNavigateValueSet = function (text, up) {
  33756. var numberResult = this.numberReplace(text, up);
  33757. if (numberResult !== null) {
  33758. return numberResult;
  33759. }
  33760. return this.textReplace(text, up);
  33761. };
  33762. BasicInplaceReplace.prototype.numberReplace = function (value, up) {
  33763. var precision = Math.pow(10, value.length - (value.lastIndexOf('.') + 1));
  33764. var n1 = Number(value);
  33765. var n2 = parseFloat(value);
  33766. if (!isNaN(n1) && !isNaN(n2) && n1 === n2) {
  33767. if (n1 === 0 && !up) {
  33768. return null; // don't do negative
  33769. // } else if(n1 === 9 && up) {
  33770. // return null; // don't insert 10 into a number
  33771. }
  33772. else {
  33773. n1 = Math.floor(n1 * precision);
  33774. n1 += up ? precision : -precision;
  33775. return String(n1 / precision);
  33776. }
  33777. }
  33778. return null;
  33779. };
  33780. BasicInplaceReplace.prototype.textReplace = function (value, up) {
  33781. return this.valueSetsReplace(this._defaultValueSet, value, up);
  33782. };
  33783. BasicInplaceReplace.prototype.valueSetsReplace = function (valueSets, value, up) {
  33784. var result = null;
  33785. for (var i = 0, len = valueSets.length; result === null && i < len; i++) {
  33786. result = this.valueSetReplace(valueSets[i], value, up);
  33787. }
  33788. return result;
  33789. };
  33790. BasicInplaceReplace.prototype.valueSetReplace = function (valueSet, value, up) {
  33791. var idx = valueSet.indexOf(value);
  33792. if (idx >= 0) {
  33793. idx += up ? +1 : -1;
  33794. if (idx < 0) {
  33795. idx = valueSet.length - 1;
  33796. }
  33797. else {
  33798. idx %= valueSet.length;
  33799. }
  33800. return valueSet[idx];
  33801. }
  33802. return null;
  33803. };
  33804. BasicInplaceReplace.INSTANCE = new BasicInplaceReplace();
  33805. return BasicInplaceReplace;
  33806. }());
  33807. exports.BasicInplaceReplace = BasicInplaceReplace;
  33808. });
  33809. /*---------------------------------------------------------------------------------------------
  33810. * Copyright (c) Microsoft Corporation. All rights reserved.
  33811. * Licensed under the MIT License. See License.txt in the project root for license information.
  33812. *--------------------------------------------------------------------------------------------*/
  33813. define(__m[355/*vs/editor/common/modes/supports/onEnter*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,5/*vs/base/common/strings*/,90/*vs/editor/common/modes/languageConfiguration*/]), function (require, exports, errors_1, strings, languageConfiguration_1) {
  33814. "use strict";
  33815. Object.defineProperty(exports, "__esModule", { value: true });
  33816. var OnEnterSupport = /** @class */ (function () {
  33817. function OnEnterSupport(opts) {
  33818. var _this = this;
  33819. opts = opts || {};
  33820. opts.brackets = opts.brackets || [
  33821. ['(', ')'],
  33822. ['{', '}'],
  33823. ['[', ']']
  33824. ];
  33825. this._brackets = [];
  33826. opts.brackets.forEach(function (bracket) {
  33827. var openRegExp = OnEnterSupport._createOpenBracketRegExp(bracket[0]);
  33828. var closeRegExp = OnEnterSupport._createCloseBracketRegExp(bracket[1]);
  33829. if (openRegExp && closeRegExp) {
  33830. _this._brackets.push({
  33831. open: bracket[0],
  33832. openRegExp: openRegExp,
  33833. close: bracket[1],
  33834. closeRegExp: closeRegExp,
  33835. });
  33836. }
  33837. });
  33838. this._regExpRules = opts.onEnterRules || [];
  33839. }
  33840. OnEnterSupport.prototype.onEnter = function (autoIndent, oneLineAboveText, beforeEnterText, afterEnterText) {
  33841. // (1): `regExpRules`
  33842. if (autoIndent >= 3 /* Advanced */) {
  33843. for (var i = 0, len = this._regExpRules.length; i < len; i++) {
  33844. var rule = this._regExpRules[i];
  33845. var regResult = [{
  33846. reg: rule.beforeText,
  33847. text: beforeEnterText
  33848. }, {
  33849. reg: rule.afterText,
  33850. text: afterEnterText
  33851. }, {
  33852. reg: rule.oneLineAboveText,
  33853. text: oneLineAboveText
  33854. }].every(function (obj) {
  33855. return obj.reg ? obj.reg.test(obj.text) : true;
  33856. });
  33857. if (regResult) {
  33858. return rule.action;
  33859. }
  33860. }
  33861. }
  33862. // (2): Special indent-outdent
  33863. if (autoIndent >= 2 /* Brackets */) {
  33864. if (beforeEnterText.length > 0 && afterEnterText.length > 0) {
  33865. for (var i = 0, len = this._brackets.length; i < len; i++) {
  33866. var bracket = this._brackets[i];
  33867. if (bracket.openRegExp.test(beforeEnterText) && bracket.closeRegExp.test(afterEnterText)) {
  33868. return { indentAction: languageConfiguration_1.IndentAction.IndentOutdent };
  33869. }
  33870. }
  33871. }
  33872. }
  33873. // (4): Open bracket based logic
  33874. if (autoIndent >= 2 /* Brackets */) {
  33875. if (beforeEnterText.length > 0) {
  33876. for (var i = 0, len = this._brackets.length; i < len; i++) {
  33877. var bracket = this._brackets[i];
  33878. if (bracket.openRegExp.test(beforeEnterText)) {
  33879. return { indentAction: languageConfiguration_1.IndentAction.Indent };
  33880. }
  33881. }
  33882. }
  33883. }
  33884. return null;
  33885. };
  33886. OnEnterSupport._createOpenBracketRegExp = function (bracket) {
  33887. var str = strings.escapeRegExpCharacters(bracket);
  33888. if (!/\B/.test(str.charAt(0))) {
  33889. str = '\\b' + str;
  33890. }
  33891. str += '\\s*$';
  33892. return OnEnterSupport._safeRegExp(str);
  33893. };
  33894. OnEnterSupport._createCloseBracketRegExp = function (bracket) {
  33895. var str = strings.escapeRegExpCharacters(bracket);
  33896. if (!/\B/.test(str.charAt(str.length - 1))) {
  33897. str = str + '\\b';
  33898. }
  33899. str = '^\\s*' + str;
  33900. return OnEnterSupport._safeRegExp(str);
  33901. };
  33902. OnEnterSupport._safeRegExp = function (def) {
  33903. try {
  33904. return new RegExp(def);
  33905. }
  33906. catch (err) {
  33907. errors_1.onUnexpectedError(err);
  33908. return null;
  33909. }
  33910. };
  33911. return OnEnterSupport;
  33912. }());
  33913. exports.OnEnterSupport = OnEnterSupport;
  33914. });
  33915. /*---------------------------------------------------------------------------------------------
  33916. * Copyright (c) Microsoft Corporation. All rights reserved.
  33917. * Licensed under the MIT License. See License.txt in the project root for license information.
  33918. *--------------------------------------------------------------------------------------------*/
  33919. define(__m[146/*vs/editor/common/modes/supports/richEditBrackets*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,3/*vs/editor/common/core/range*/]), function (require, exports, strings, range_1) {
  33920. "use strict";
  33921. Object.defineProperty(exports, "__esModule", { value: true });
  33922. var RichEditBracket = /** @class */ (function () {
  33923. function RichEditBracket(languageIdentifier, index, open, close, forwardRegex, reversedRegex) {
  33924. this.languageIdentifier = languageIdentifier;
  33925. this.index = index;
  33926. this.open = open;
  33927. this.close = close;
  33928. this.forwardRegex = forwardRegex;
  33929. this.reversedRegex = reversedRegex;
  33930. this._openSet = RichEditBracket._toSet(this.open);
  33931. this._closeSet = RichEditBracket._toSet(this.close);
  33932. }
  33933. RichEditBracket.prototype.isOpen = function (text) {
  33934. return this._openSet.has(text);
  33935. };
  33936. RichEditBracket.prototype.isClose = function (text) {
  33937. return this._closeSet.has(text);
  33938. };
  33939. RichEditBracket._toSet = function (arr) {
  33940. var result = new Set();
  33941. for (var _i = 0, arr_1 = arr; _i < arr_1.length; _i++) {
  33942. var element = arr_1[_i];
  33943. result.add(element);
  33944. }
  33945. return result;
  33946. };
  33947. return RichEditBracket;
  33948. }());
  33949. exports.RichEditBracket = RichEditBracket;
  33950. function groupFuzzyBrackets(brackets) {
  33951. var N = brackets.length;
  33952. brackets = brackets.map(function (b) { return [b[0].toLowerCase(), b[1].toLowerCase()]; });
  33953. var group = [];
  33954. for (var i = 0; i < N; i++) {
  33955. group[i] = i;
  33956. }
  33957. var areOverlapping = function (a, b) {
  33958. var aOpen = a[0], aClose = a[1];
  33959. var bOpen = b[0], bClose = b[1];
  33960. return (aOpen === bOpen || aOpen === bClose || aClose === bOpen || aClose === bClose);
  33961. };
  33962. var mergeGroups = function (g1, g2) {
  33963. var newG = Math.min(g1, g2);
  33964. var oldG = Math.max(g1, g2);
  33965. for (var i = 0; i < N; i++) {
  33966. if (group[i] === oldG) {
  33967. group[i] = newG;
  33968. }
  33969. }
  33970. };
  33971. // group together brackets that have the same open or the same close sequence
  33972. for (var i = 0; i < N; i++) {
  33973. var a = brackets[i];
  33974. for (var j = i + 1; j < N; j++) {
  33975. var b = brackets[j];
  33976. if (areOverlapping(a, b)) {
  33977. mergeGroups(group[i], group[j]);
  33978. }
  33979. }
  33980. }
  33981. var result = [];
  33982. for (var g = 0; g < N; g++) {
  33983. var currentOpen = [];
  33984. var currentClose = [];
  33985. for (var i = 0; i < N; i++) {
  33986. if (group[i] === g) {
  33987. var _a = brackets[i], open_1 = _a[0], close_1 = _a[1];
  33988. currentOpen.push(open_1);
  33989. currentClose.push(close_1);
  33990. }
  33991. }
  33992. if (currentOpen.length > 0) {
  33993. result.push({
  33994. open: currentOpen,
  33995. close: currentClose
  33996. });
  33997. }
  33998. }
  33999. return result;
  34000. }
  34001. var RichEditBrackets = /** @class */ (function () {
  34002. function RichEditBrackets(languageIdentifier, _brackets) {
  34003. var brackets = groupFuzzyBrackets(_brackets);
  34004. this.brackets = brackets.map(function (b, index) {
  34005. return new RichEditBracket(languageIdentifier, index, b.open, b.close, getRegexForBracketPair(b.open, b.close, brackets, index), getReversedRegexForBracketPair(b.open, b.close, brackets, index));
  34006. });
  34007. this.forwardRegex = getRegexForBrackets(this.brackets);
  34008. this.reversedRegex = getReversedRegexForBrackets(this.brackets);
  34009. this.textIsBracket = {};
  34010. this.textIsOpenBracket = {};
  34011. this.maxBracketLength = 0;
  34012. for (var _i = 0, _a = this.brackets; _i < _a.length; _i++) {
  34013. var bracket = _a[_i];
  34014. for (var _b = 0, _c = bracket.open; _b < _c.length; _b++) {
  34015. var open_2 = _c[_b];
  34016. this.textIsBracket[open_2] = bracket;
  34017. this.textIsOpenBracket[open_2] = true;
  34018. this.maxBracketLength = Math.max(this.maxBracketLength, open_2.length);
  34019. }
  34020. for (var _d = 0, _e = bracket.close; _d < _e.length; _d++) {
  34021. var close_2 = _e[_d];
  34022. this.textIsBracket[close_2] = bracket;
  34023. this.textIsOpenBracket[close_2] = false;
  34024. this.maxBracketLength = Math.max(this.maxBracketLength, close_2.length);
  34025. }
  34026. }
  34027. }
  34028. return RichEditBrackets;
  34029. }());
  34030. exports.RichEditBrackets = RichEditBrackets;
  34031. function collectSuperstrings(str, brackets, currentIndex, dest) {
  34032. for (var i = 0, len = brackets.length; i < len; i++) {
  34033. if (i === currentIndex) {
  34034. continue;
  34035. }
  34036. var bracket = brackets[i];
  34037. for (var _i = 0, _a = bracket.open; _i < _a.length; _i++) {
  34038. var open_3 = _a[_i];
  34039. if (open_3.indexOf(str) >= 0) {
  34040. dest.push(open_3);
  34041. }
  34042. }
  34043. for (var _b = 0, _c = bracket.close; _b < _c.length; _b++) {
  34044. var close_3 = _c[_b];
  34045. if (close_3.indexOf(str) >= 0) {
  34046. dest.push(close_3);
  34047. }
  34048. }
  34049. }
  34050. }
  34051. function lengthcmp(a, b) {
  34052. return a.length - b.length;
  34053. }
  34054. function unique(arr) {
  34055. if (arr.length <= 1) {
  34056. return arr;
  34057. }
  34058. var result = [];
  34059. var seen = new Set();
  34060. for (var _i = 0, arr_2 = arr; _i < arr_2.length; _i++) {
  34061. var element = arr_2[_i];
  34062. if (seen.has(element)) {
  34063. continue;
  34064. }
  34065. result.push(element);
  34066. seen.add(element);
  34067. }
  34068. return result;
  34069. }
  34070. function getRegexForBracketPair(open, close, brackets, currentIndex) {
  34071. // search in all brackets for other brackets that are a superstring of these brackets
  34072. var pieces = [];
  34073. pieces = pieces.concat(open);
  34074. pieces = pieces.concat(close);
  34075. for (var i = 0, len = pieces.length; i < len; i++) {
  34076. collectSuperstrings(pieces[i], brackets, currentIndex, pieces);
  34077. }
  34078. pieces = unique(pieces);
  34079. pieces.sort(lengthcmp);
  34080. pieces.reverse();
  34081. return createBracketOrRegExp(pieces);
  34082. }
  34083. function getReversedRegexForBracketPair(open, close, brackets, currentIndex) {
  34084. // search in all brackets for other brackets that are a superstring of these brackets
  34085. var pieces = [];
  34086. pieces = pieces.concat(open);
  34087. pieces = pieces.concat(close);
  34088. for (var i = 0, len = pieces.length; i < len; i++) {
  34089. collectSuperstrings(pieces[i], brackets, currentIndex, pieces);
  34090. }
  34091. pieces = unique(pieces);
  34092. pieces.sort(lengthcmp);
  34093. pieces.reverse();
  34094. return createBracketOrRegExp(pieces.map(toReversedString));
  34095. }
  34096. function getRegexForBrackets(brackets) {
  34097. var pieces = [];
  34098. for (var _i = 0, brackets_1 = brackets; _i < brackets_1.length; _i++) {
  34099. var bracket = brackets_1[_i];
  34100. for (var _a = 0, _b = bracket.open; _a < _b.length; _a++) {
  34101. var open_4 = _b[_a];
  34102. pieces.push(open_4);
  34103. }
  34104. for (var _c = 0, _d = bracket.close; _c < _d.length; _c++) {
  34105. var close_4 = _d[_c];
  34106. pieces.push(close_4);
  34107. }
  34108. }
  34109. pieces = unique(pieces);
  34110. return createBracketOrRegExp(pieces);
  34111. }
  34112. function getReversedRegexForBrackets(brackets) {
  34113. var pieces = [];
  34114. for (var _i = 0, brackets_2 = brackets; _i < brackets_2.length; _i++) {
  34115. var bracket = brackets_2[_i];
  34116. for (var _a = 0, _b = bracket.open; _a < _b.length; _a++) {
  34117. var open_5 = _b[_a];
  34118. pieces.push(open_5);
  34119. }
  34120. for (var _c = 0, _d = bracket.close; _c < _d.length; _c++) {
  34121. var close_5 = _d[_c];
  34122. pieces.push(close_5);
  34123. }
  34124. }
  34125. pieces = unique(pieces);
  34126. return createBracketOrRegExp(pieces.map(toReversedString));
  34127. }
  34128. function prepareBracketForRegExp(str) {
  34129. // This bracket pair uses letters like e.g. "begin" - "end"
  34130. var insertWordBoundaries = (/^[\w ]+$/.test(str));
  34131. str = strings.escapeRegExpCharacters(str);
  34132. return (insertWordBoundaries ? "\\b" + str + "\\b" : str);
  34133. }
  34134. function createBracketOrRegExp(pieces) {
  34135. var regexStr = "(" + pieces.map(prepareBracketForRegExp).join(')|(') + ")";
  34136. return strings.createRegExp(regexStr, true);
  34137. }
  34138. var toReversedString = (function () {
  34139. function reverse(str) {
  34140. var reversedStr = '';
  34141. for (var i = str.length - 1; i >= 0; i--) {
  34142. reversedStr += str.charAt(i);
  34143. }
  34144. return reversedStr;
  34145. }
  34146. var lastInput = null;
  34147. var lastOutput = null;
  34148. return function toReversedString(str) {
  34149. if (lastInput !== str) {
  34150. lastInput = str;
  34151. lastOutput = reverse(lastInput);
  34152. }
  34153. return lastOutput;
  34154. };
  34155. })();
  34156. var BracketsUtils = /** @class */ (function () {
  34157. function BracketsUtils() {
  34158. }
  34159. BracketsUtils._findPrevBracketInText = function (reversedBracketRegex, lineNumber, reversedText, offset) {
  34160. var m = reversedText.match(reversedBracketRegex);
  34161. if (!m) {
  34162. return null;
  34163. }
  34164. var matchOffset = reversedText.length - (m.index || 0);
  34165. var matchLength = m[0].length;
  34166. var absoluteMatchOffset = offset + matchOffset;
  34167. return new range_1.Range(lineNumber, absoluteMatchOffset - matchLength + 1, lineNumber, absoluteMatchOffset + 1);
  34168. };
  34169. BracketsUtils.findPrevBracketInRange = function (reversedBracketRegex, lineNumber, lineText, startOffset, endOffset) {
  34170. // Because JS does not support backwards regex search, we search forwards in a reversed string with a reversed regex ;)
  34171. var reversedLineText = toReversedString(lineText);
  34172. var reversedSubstr = reversedLineText.substring(lineText.length - endOffset, lineText.length - startOffset);
  34173. return this._findPrevBracketInText(reversedBracketRegex, lineNumber, reversedSubstr, startOffset);
  34174. };
  34175. BracketsUtils.findNextBracketInText = function (bracketRegex, lineNumber, text, offset) {
  34176. var m = text.match(bracketRegex);
  34177. if (!m) {
  34178. return null;
  34179. }
  34180. var matchOffset = m.index || 0;
  34181. var matchLength = m[0].length;
  34182. if (matchLength === 0) {
  34183. return null;
  34184. }
  34185. var absoluteMatchOffset = offset + matchOffset;
  34186. return new range_1.Range(lineNumber, absoluteMatchOffset + 1, lineNumber, absoluteMatchOffset + 1 + matchLength);
  34187. };
  34188. BracketsUtils.findNextBracketInRange = function (bracketRegex, lineNumber, lineText, startOffset, endOffset) {
  34189. var substr = lineText.substring(startOffset, endOffset);
  34190. return this.findNextBracketInText(bracketRegex, lineNumber, substr, startOffset);
  34191. };
  34192. return BracketsUtils;
  34193. }());
  34194. exports.BracketsUtils = BracketsUtils;
  34195. });
  34196. /*---------------------------------------------------------------------------------------------
  34197. * Copyright (c) Microsoft Corporation. All rights reserved.
  34198. * Licensed under the MIT License. See License.txt in the project root for license information.
  34199. *--------------------------------------------------------------------------------------------*/
  34200. define(__m[356/*vs/editor/common/modes/supports/electricCharacter*/], __M([0/*require*/,1/*exports*/,145/*vs/editor/common/modes/supports*/,146/*vs/editor/common/modes/supports/richEditBrackets*/]), function (require, exports, supports_1, richEditBrackets_1) {
  34201. "use strict";
  34202. Object.defineProperty(exports, "__esModule", { value: true });
  34203. var BracketElectricCharacterSupport = /** @class */ (function () {
  34204. function BracketElectricCharacterSupport(richEditBrackets) {
  34205. this._richEditBrackets = richEditBrackets;
  34206. }
  34207. BracketElectricCharacterSupport.prototype.getElectricCharacters = function () {
  34208. var result = [];
  34209. if (this._richEditBrackets) {
  34210. for (var _i = 0, _a = this._richEditBrackets.brackets; _i < _a.length; _i++) {
  34211. var bracket = _a[_i];
  34212. for (var _b = 0, _c = bracket.close; _b < _c.length; _b++) {
  34213. var close_1 = _c[_b];
  34214. var lastChar = close_1.charAt(close_1.length - 1);
  34215. result.push(lastChar);
  34216. }
  34217. }
  34218. }
  34219. // Filter duplicate entries
  34220. result = result.filter(function (item, pos, array) {
  34221. return array.indexOf(item) === pos;
  34222. });
  34223. return result;
  34224. };
  34225. BracketElectricCharacterSupport.prototype.onElectricCharacter = function (character, context, column) {
  34226. if (!this._richEditBrackets || this._richEditBrackets.brackets.length === 0) {
  34227. return null;
  34228. }
  34229. var tokenIndex = context.findTokenIndexAtOffset(column - 1);
  34230. if (supports_1.ignoreBracketsInToken(context.getStandardTokenType(tokenIndex))) {
  34231. return null;
  34232. }
  34233. var reversedBracketRegex = this._richEditBrackets.reversedRegex;
  34234. var text = context.getLineContent().substring(0, column - 1) + character;
  34235. var r = richEditBrackets_1.BracketsUtils.findPrevBracketInRange(reversedBracketRegex, 1, text, 0, text.length);
  34236. if (!r) {
  34237. return null;
  34238. }
  34239. var bracketText = text.substring(r.startColumn - 1, r.endColumn - 1).toLowerCase();
  34240. var isOpen = this._richEditBrackets.textIsOpenBracket[bracketText];
  34241. if (isOpen) {
  34242. return null;
  34243. }
  34244. var textBeforeBracket = context.getActualLineContentBefore(r.startColumn - 1);
  34245. if (!/^\s*$/.test(textBeforeBracket)) {
  34246. // There is other text on the line before the bracket
  34247. return null;
  34248. }
  34249. return {
  34250. matchOpenBracket: bracketText
  34251. };
  34252. };
  34253. return BracketElectricCharacterSupport;
  34254. }());
  34255. exports.BracketElectricCharacterSupport = BracketElectricCharacterSupport;
  34256. });
  34257. /*---------------------------------------------------------------------------------------------
  34258. * Copyright (c) Microsoft Corporation. All rights reserved.
  34259. * Licensed under the MIT License. See License.txt in the project root for license information.
  34260. *--------------------------------------------------------------------------------------------*/
  34261. define(__m[41/*vs/editor/common/modes/languageConfigurationRegistry*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,5/*vs/base/common/strings*/,109/*vs/editor/common/model/wordHelper*/,90/*vs/editor/common/modes/languageConfiguration*/,145/*vs/editor/common/modes/supports*/,352/*vs/editor/common/modes/supports/characterPair*/,356/*vs/editor/common/modes/supports/electricCharacter*/,353/*vs/editor/common/modes/supports/indentRules*/,355/*vs/editor/common/modes/supports/onEnter*/,146/*vs/editor/common/modes/supports/richEditBrackets*/]), function (require, exports, event_1, lifecycle_1, strings, wordHelper_1, languageConfiguration_1, supports_1, characterPair_1, electricCharacter_1, indentRules_1, onEnter_1, richEditBrackets_1) {
  34262. "use strict";
  34263. Object.defineProperty(exports, "__esModule", { value: true });
  34264. var RichEditSupport = /** @class */ (function () {
  34265. function RichEditSupport(languageIdentifier, previous, rawConf) {
  34266. this._languageIdentifier = languageIdentifier;
  34267. this._brackets = null;
  34268. this._electricCharacter = null;
  34269. var prev = null;
  34270. if (previous) {
  34271. prev = previous._conf;
  34272. }
  34273. this._conf = RichEditSupport._mergeConf(prev, rawConf);
  34274. this._onEnterSupport = (this._conf.brackets || this._conf.indentationRules || this._conf.onEnterRules ? new onEnter_1.OnEnterSupport(this._conf) : null);
  34275. this.comments = RichEditSupport._handleComments(this._conf);
  34276. this.characterPair = new characterPair_1.CharacterPairSupport(this._conf);
  34277. this.wordDefinition = this._conf.wordPattern || wordHelper_1.DEFAULT_WORD_REGEXP;
  34278. this.indentationRules = this._conf.indentationRules;
  34279. if (this._conf.indentationRules) {
  34280. this.indentRulesSupport = new indentRules_1.IndentRulesSupport(this._conf.indentationRules);
  34281. }
  34282. else {
  34283. this.indentRulesSupport = null;
  34284. }
  34285. this.foldingRules = this._conf.folding || {};
  34286. }
  34287. Object.defineProperty(RichEditSupport.prototype, "brackets", {
  34288. get: function () {
  34289. if (!this._brackets && this._conf.brackets) {
  34290. this._brackets = new richEditBrackets_1.RichEditBrackets(this._languageIdentifier, this._conf.brackets);
  34291. }
  34292. return this._brackets;
  34293. },
  34294. enumerable: true,
  34295. configurable: true
  34296. });
  34297. Object.defineProperty(RichEditSupport.prototype, "electricCharacter", {
  34298. get: function () {
  34299. if (!this._electricCharacter) {
  34300. this._electricCharacter = new electricCharacter_1.BracketElectricCharacterSupport(this.brackets);
  34301. }
  34302. return this._electricCharacter;
  34303. },
  34304. enumerable: true,
  34305. configurable: true
  34306. });
  34307. RichEditSupport.prototype.onEnter = function (autoIndent, oneLineAboveText, beforeEnterText, afterEnterText) {
  34308. if (!this._onEnterSupport) {
  34309. return null;
  34310. }
  34311. return this._onEnterSupport.onEnter(autoIndent, oneLineAboveText, beforeEnterText, afterEnterText);
  34312. };
  34313. RichEditSupport._mergeConf = function (prev, current) {
  34314. return {
  34315. comments: (prev ? current.comments || prev.comments : current.comments),
  34316. brackets: (prev ? current.brackets || prev.brackets : current.brackets),
  34317. wordPattern: (prev ? current.wordPattern || prev.wordPattern : current.wordPattern),
  34318. indentationRules: (prev ? current.indentationRules || prev.indentationRules : current.indentationRules),
  34319. onEnterRules: (prev ? current.onEnterRules || prev.onEnterRules : current.onEnterRules),
  34320. autoClosingPairs: (prev ? current.autoClosingPairs || prev.autoClosingPairs : current.autoClosingPairs),
  34321. surroundingPairs: (prev ? current.surroundingPairs || prev.surroundingPairs : current.surroundingPairs),
  34322. autoCloseBefore: (prev ? current.autoCloseBefore || prev.autoCloseBefore : current.autoCloseBefore),
  34323. folding: (prev ? current.folding || prev.folding : current.folding),
  34324. __electricCharacterSupport: (prev ? current.__electricCharacterSupport || prev.__electricCharacterSupport : current.__electricCharacterSupport),
  34325. };
  34326. };
  34327. RichEditSupport._handleComments = function (conf) {
  34328. var commentRule = conf.comments;
  34329. if (!commentRule) {
  34330. return null;
  34331. }
  34332. // comment configuration
  34333. var comments = {};
  34334. if (commentRule.lineComment) {
  34335. comments.lineCommentToken = commentRule.lineComment;
  34336. }
  34337. if (commentRule.blockComment) {
  34338. var _a = commentRule.blockComment, blockStart = _a[0], blockEnd = _a[1];
  34339. comments.blockCommentStartToken = blockStart;
  34340. comments.blockCommentEndToken = blockEnd;
  34341. }
  34342. return comments;
  34343. };
  34344. return RichEditSupport;
  34345. }());
  34346. exports.RichEditSupport = RichEditSupport;
  34347. var LanguageConfigurationChangeEvent = /** @class */ (function () {
  34348. function LanguageConfigurationChangeEvent(languageIdentifier) {
  34349. this.languageIdentifier = languageIdentifier;
  34350. }
  34351. return LanguageConfigurationChangeEvent;
  34352. }());
  34353. exports.LanguageConfigurationChangeEvent = LanguageConfigurationChangeEvent;
  34354. var LanguageConfigurationRegistryImpl = /** @class */ (function () {
  34355. function LanguageConfigurationRegistryImpl() {
  34356. this._entries = new Map();
  34357. this._onDidChange = new event_1.Emitter();
  34358. this.onDidChange = this._onDidChange.event;
  34359. }
  34360. LanguageConfigurationRegistryImpl.prototype.register = function (languageIdentifier, configuration) {
  34361. var _this = this;
  34362. var previous = this._getRichEditSupport(languageIdentifier.id);
  34363. var current = new RichEditSupport(languageIdentifier, previous, configuration);
  34364. this._entries.set(languageIdentifier.id, current);
  34365. this._onDidChange.fire(new LanguageConfigurationChangeEvent(languageIdentifier));
  34366. return lifecycle_1.toDisposable(function () {
  34367. if (_this._entries.get(languageIdentifier.id) === current) {
  34368. _this._entries.set(languageIdentifier.id, previous);
  34369. _this._onDidChange.fire(new LanguageConfigurationChangeEvent(languageIdentifier));
  34370. }
  34371. });
  34372. };
  34373. LanguageConfigurationRegistryImpl.prototype._getRichEditSupport = function (languageId) {
  34374. return this._entries.get(languageId);
  34375. };
  34376. // begin electricCharacter
  34377. LanguageConfigurationRegistryImpl.prototype._getElectricCharacterSupport = function (languageId) {
  34378. var value = this._getRichEditSupport(languageId);
  34379. if (!value) {
  34380. return null;
  34381. }
  34382. return value.electricCharacter || null;
  34383. };
  34384. LanguageConfigurationRegistryImpl.prototype.getElectricCharacters = function (languageId) {
  34385. var electricCharacterSupport = this._getElectricCharacterSupport(languageId);
  34386. if (!electricCharacterSupport) {
  34387. return [];
  34388. }
  34389. return electricCharacterSupport.getElectricCharacters();
  34390. };
  34391. /**
  34392. * Should return opening bracket type to match indentation with
  34393. */
  34394. LanguageConfigurationRegistryImpl.prototype.onElectricCharacter = function (character, context, column) {
  34395. var scopedLineTokens = supports_1.createScopedLineTokens(context, column - 1);
  34396. var electricCharacterSupport = this._getElectricCharacterSupport(scopedLineTokens.languageId);
  34397. if (!electricCharacterSupport) {
  34398. return null;
  34399. }
  34400. return electricCharacterSupport.onElectricCharacter(character, scopedLineTokens, column - scopedLineTokens.firstCharOffset);
  34401. };
  34402. // end electricCharacter
  34403. LanguageConfigurationRegistryImpl.prototype.getComments = function (languageId) {
  34404. var value = this._getRichEditSupport(languageId);
  34405. if (!value) {
  34406. return null;
  34407. }
  34408. return value.comments || null;
  34409. };
  34410. // begin characterPair
  34411. LanguageConfigurationRegistryImpl.prototype._getCharacterPairSupport = function (languageId) {
  34412. var value = this._getRichEditSupport(languageId);
  34413. if (!value) {
  34414. return null;
  34415. }
  34416. return value.characterPair || null;
  34417. };
  34418. LanguageConfigurationRegistryImpl.prototype.getAutoClosingPairs = function (languageId) {
  34419. var characterPairSupport = this._getCharacterPairSupport(languageId);
  34420. if (!characterPairSupport) {
  34421. return [];
  34422. }
  34423. return characterPairSupport.getAutoClosingPairs();
  34424. };
  34425. LanguageConfigurationRegistryImpl.prototype.getAutoCloseBeforeSet = function (languageId) {
  34426. var characterPairSupport = this._getCharacterPairSupport(languageId);
  34427. if (!characterPairSupport) {
  34428. return characterPair_1.CharacterPairSupport.DEFAULT_AUTOCLOSE_BEFORE_LANGUAGE_DEFINED;
  34429. }
  34430. return characterPairSupport.getAutoCloseBeforeSet();
  34431. };
  34432. LanguageConfigurationRegistryImpl.prototype.getSurroundingPairs = function (languageId) {
  34433. var characterPairSupport = this._getCharacterPairSupport(languageId);
  34434. if (!characterPairSupport) {
  34435. return [];
  34436. }
  34437. return characterPairSupport.getSurroundingPairs();
  34438. };
  34439. LanguageConfigurationRegistryImpl.prototype.shouldAutoClosePair = function (autoClosingPair, context, column) {
  34440. var scopedLineTokens = supports_1.createScopedLineTokens(context, column - 1);
  34441. return characterPair_1.CharacterPairSupport.shouldAutoClosePair(autoClosingPair, scopedLineTokens, column - scopedLineTokens.firstCharOffset);
  34442. };
  34443. // end characterPair
  34444. LanguageConfigurationRegistryImpl.prototype.getWordDefinition = function (languageId) {
  34445. var value = this._getRichEditSupport(languageId);
  34446. if (!value) {
  34447. return wordHelper_1.ensureValidWordDefinition(null);
  34448. }
  34449. return wordHelper_1.ensureValidWordDefinition(value.wordDefinition || null);
  34450. };
  34451. LanguageConfigurationRegistryImpl.prototype.getFoldingRules = function (languageId) {
  34452. var value = this._getRichEditSupport(languageId);
  34453. if (!value) {
  34454. return {};
  34455. }
  34456. return value.foldingRules;
  34457. };
  34458. // begin Indent Rules
  34459. LanguageConfigurationRegistryImpl.prototype.getIndentRulesSupport = function (languageId) {
  34460. var value = this._getRichEditSupport(languageId);
  34461. if (!value) {
  34462. return null;
  34463. }
  34464. return value.indentRulesSupport || null;
  34465. };
  34466. /**
  34467. * Get nearest preceiding line which doesn't match unIndentPattern or contains all whitespace.
  34468. * Result:
  34469. * -1: run into the boundary of embedded languages
  34470. * 0: every line above are invalid
  34471. * else: nearest preceding line of the same language
  34472. */
  34473. LanguageConfigurationRegistryImpl.prototype.getPrecedingValidLine = function (model, lineNumber, indentRulesSupport) {
  34474. var languageID = model.getLanguageIdAtPosition(lineNumber, 0);
  34475. if (lineNumber > 1) {
  34476. var lastLineNumber = void 0;
  34477. var resultLineNumber = -1;
  34478. for (lastLineNumber = lineNumber - 1; lastLineNumber >= 1; lastLineNumber--) {
  34479. if (model.getLanguageIdAtPosition(lastLineNumber, 0) !== languageID) {
  34480. return resultLineNumber;
  34481. }
  34482. var text = model.getLineContent(lastLineNumber);
  34483. if (indentRulesSupport.shouldIgnore(text) || /^\s+$/.test(text) || text === '') {
  34484. resultLineNumber = lastLineNumber;
  34485. continue;
  34486. }
  34487. return lastLineNumber;
  34488. }
  34489. }
  34490. return -1;
  34491. };
  34492. /**
  34493. * Get inherited indentation from above lines.
  34494. * 1. Find the nearest preceding line which doesn't match unIndentedLinePattern.
  34495. * 2. If this line matches indentNextLinePattern or increaseIndentPattern, it means that the indent level of `lineNumber` should be 1 greater than this line.
  34496. * 3. If this line doesn't match any indent rules
  34497. * a. check whether the line above it matches indentNextLinePattern
  34498. * b. If not, the indent level of this line is the result
  34499. * c. If so, it means the indent of this line is *temporary*, go upward utill we find a line whose indent is not temporary (the same workflow a -> b -> c).
  34500. * 4. Otherwise, we fail to get an inherited indent from aboves. Return null and we should not touch the indent of `lineNumber`
  34501. *
  34502. * This function only return the inherited indent based on above lines, it doesn't check whether current line should decrease or not.
  34503. */
  34504. LanguageConfigurationRegistryImpl.prototype.getInheritIndentForLine = function (autoIndent, model, lineNumber, honorIntentialIndent) {
  34505. if (honorIntentialIndent === void 0) { honorIntentialIndent = true; }
  34506. if (autoIndent < 4 /* Full */) {
  34507. return null;
  34508. }
  34509. var indentRulesSupport = this.getIndentRulesSupport(model.getLanguageIdentifier().id);
  34510. if (!indentRulesSupport) {
  34511. return null;
  34512. }
  34513. if (lineNumber <= 1) {
  34514. return {
  34515. indentation: '',
  34516. action: null
  34517. };
  34518. }
  34519. var precedingUnIgnoredLine = this.getPrecedingValidLine(model, lineNumber, indentRulesSupport);
  34520. if (precedingUnIgnoredLine < 0) {
  34521. return null;
  34522. }
  34523. else if (precedingUnIgnoredLine < 1) {
  34524. return {
  34525. indentation: '',
  34526. action: null
  34527. };
  34528. }
  34529. var precedingUnIgnoredLineContent = model.getLineContent(precedingUnIgnoredLine);
  34530. if (indentRulesSupport.shouldIncrease(precedingUnIgnoredLineContent) || indentRulesSupport.shouldIndentNextLine(precedingUnIgnoredLineContent)) {
  34531. return {
  34532. indentation: strings.getLeadingWhitespace(precedingUnIgnoredLineContent),
  34533. action: languageConfiguration_1.IndentAction.Indent,
  34534. line: precedingUnIgnoredLine
  34535. };
  34536. }
  34537. else if (indentRulesSupport.shouldDecrease(precedingUnIgnoredLineContent)) {
  34538. return {
  34539. indentation: strings.getLeadingWhitespace(precedingUnIgnoredLineContent),
  34540. action: null,
  34541. line: precedingUnIgnoredLine
  34542. };
  34543. }
  34544. else {
  34545. // precedingUnIgnoredLine can not be ignored.
  34546. // it doesn't increase indent of following lines
  34547. // it doesn't increase just next line
  34548. // so current line is not affect by precedingUnIgnoredLine
  34549. // and then we should get a correct inheritted indentation from above lines
  34550. if (precedingUnIgnoredLine === 1) {
  34551. return {
  34552. indentation: strings.getLeadingWhitespace(model.getLineContent(precedingUnIgnoredLine)),
  34553. action: null,
  34554. line: precedingUnIgnoredLine
  34555. };
  34556. }
  34557. var previousLine = precedingUnIgnoredLine - 1;
  34558. var previousLineIndentMetadata = indentRulesSupport.getIndentMetadata(model.getLineContent(previousLine));
  34559. if (!(previousLineIndentMetadata & (1 /* INCREASE_MASK */ | 2 /* DECREASE_MASK */)) &&
  34560. (previousLineIndentMetadata & 4 /* INDENT_NEXTLINE_MASK */)) {
  34561. var stopLine = 0;
  34562. for (var i = previousLine - 1; i > 0; i--) {
  34563. if (indentRulesSupport.shouldIndentNextLine(model.getLineContent(i))) {
  34564. continue;
  34565. }
  34566. stopLine = i;
  34567. break;
  34568. }
  34569. return {
  34570. indentation: strings.getLeadingWhitespace(model.getLineContent(stopLine + 1)),
  34571. action: null,
  34572. line: stopLine + 1
  34573. };
  34574. }
  34575. if (honorIntentialIndent) {
  34576. return {
  34577. indentation: strings.getLeadingWhitespace(model.getLineContent(precedingUnIgnoredLine)),
  34578. action: null,
  34579. line: precedingUnIgnoredLine
  34580. };
  34581. }
  34582. else {
  34583. // search from precedingUnIgnoredLine until we find one whose indent is not temporary
  34584. for (var i = precedingUnIgnoredLine; i > 0; i--) {
  34585. var lineContent = model.getLineContent(i);
  34586. if (indentRulesSupport.shouldIncrease(lineContent)) {
  34587. return {
  34588. indentation: strings.getLeadingWhitespace(lineContent),
  34589. action: languageConfiguration_1.IndentAction.Indent,
  34590. line: i
  34591. };
  34592. }
  34593. else if (indentRulesSupport.shouldIndentNextLine(lineContent)) {
  34594. var stopLine = 0;
  34595. for (var j = i - 1; j > 0; j--) {
  34596. if (indentRulesSupport.shouldIndentNextLine(model.getLineContent(i))) {
  34597. continue;
  34598. }
  34599. stopLine = j;
  34600. break;
  34601. }
  34602. return {
  34603. indentation: strings.getLeadingWhitespace(model.getLineContent(stopLine + 1)),
  34604. action: null,
  34605. line: stopLine + 1
  34606. };
  34607. }
  34608. else if (indentRulesSupport.shouldDecrease(lineContent)) {
  34609. return {
  34610. indentation: strings.getLeadingWhitespace(lineContent),
  34611. action: null,
  34612. line: i
  34613. };
  34614. }
  34615. }
  34616. return {
  34617. indentation: strings.getLeadingWhitespace(model.getLineContent(1)),
  34618. action: null,
  34619. line: 1
  34620. };
  34621. }
  34622. }
  34623. };
  34624. LanguageConfigurationRegistryImpl.prototype.getGoodIndentForLine = function (autoIndent, virtualModel, languageId, lineNumber, indentConverter) {
  34625. if (autoIndent < 4 /* Full */) {
  34626. return null;
  34627. }
  34628. var richEditSupport = this._getRichEditSupport(languageId);
  34629. if (!richEditSupport) {
  34630. return null;
  34631. }
  34632. var indentRulesSupport = this.getIndentRulesSupport(languageId);
  34633. if (!indentRulesSupport) {
  34634. return null;
  34635. }
  34636. var indent = this.getInheritIndentForLine(autoIndent, virtualModel, lineNumber);
  34637. var lineContent = virtualModel.getLineContent(lineNumber);
  34638. if (indent) {
  34639. var inheritLine = indent.line;
  34640. if (inheritLine !== undefined) {
  34641. var enterResult = richEditSupport.onEnter(autoIndent, '', virtualModel.getLineContent(inheritLine), '');
  34642. if (enterResult) {
  34643. var indentation = strings.getLeadingWhitespace(virtualModel.getLineContent(inheritLine));
  34644. if (enterResult.removeText) {
  34645. indentation = indentation.substring(0, indentation.length - enterResult.removeText);
  34646. }
  34647. if ((enterResult.indentAction === languageConfiguration_1.IndentAction.Indent) ||
  34648. (enterResult.indentAction === languageConfiguration_1.IndentAction.IndentOutdent)) {
  34649. indentation = indentConverter.shiftIndent(indentation);
  34650. }
  34651. else if (enterResult.indentAction === languageConfiguration_1.IndentAction.Outdent) {
  34652. indentation = indentConverter.unshiftIndent(indentation);
  34653. }
  34654. if (indentRulesSupport.shouldDecrease(lineContent)) {
  34655. indentation = indentConverter.unshiftIndent(indentation);
  34656. }
  34657. if (enterResult.appendText) {
  34658. indentation += enterResult.appendText;
  34659. }
  34660. return strings.getLeadingWhitespace(indentation);
  34661. }
  34662. }
  34663. if (indentRulesSupport.shouldDecrease(lineContent)) {
  34664. if (indent.action === languageConfiguration_1.IndentAction.Indent) {
  34665. return indent.indentation;
  34666. }
  34667. else {
  34668. return indentConverter.unshiftIndent(indent.indentation);
  34669. }
  34670. }
  34671. else {
  34672. if (indent.action === languageConfiguration_1.IndentAction.Indent) {
  34673. return indentConverter.shiftIndent(indent.indentation);
  34674. }
  34675. else {
  34676. return indent.indentation;
  34677. }
  34678. }
  34679. }
  34680. return null;
  34681. };
  34682. LanguageConfigurationRegistryImpl.prototype.getIndentForEnter = function (autoIndent, model, range, indentConverter) {
  34683. if (autoIndent < 4 /* Full */) {
  34684. return null;
  34685. }
  34686. model.forceTokenization(range.startLineNumber);
  34687. var lineTokens = model.getLineTokens(range.startLineNumber);
  34688. var scopedLineTokens = supports_1.createScopedLineTokens(lineTokens, range.startColumn - 1);
  34689. var scopedLineText = scopedLineTokens.getLineContent();
  34690. var embeddedLanguage = false;
  34691. var beforeEnterText;
  34692. if (scopedLineTokens.firstCharOffset > 0 && lineTokens.getLanguageId(0) !== scopedLineTokens.languageId) {
  34693. // we are in the embeded language content
  34694. embeddedLanguage = true; // if embeddedLanguage is true, then we don't touch the indentation of current line
  34695. beforeEnterText = scopedLineText.substr(0, range.startColumn - 1 - scopedLineTokens.firstCharOffset);
  34696. }
  34697. else {
  34698. beforeEnterText = lineTokens.getLineContent().substring(0, range.startColumn - 1);
  34699. }
  34700. var afterEnterText;
  34701. if (range.isEmpty()) {
  34702. afterEnterText = scopedLineText.substr(range.startColumn - 1 - scopedLineTokens.firstCharOffset);
  34703. }
  34704. else {
  34705. var endScopedLineTokens = this.getScopedLineTokens(model, range.endLineNumber, range.endColumn);
  34706. afterEnterText = endScopedLineTokens.getLineContent().substr(range.endColumn - 1 - scopedLineTokens.firstCharOffset);
  34707. }
  34708. var indentRulesSupport = this.getIndentRulesSupport(scopedLineTokens.languageId);
  34709. if (!indentRulesSupport) {
  34710. return null;
  34711. }
  34712. var beforeEnterResult = beforeEnterText;
  34713. var beforeEnterIndent = strings.getLeadingWhitespace(beforeEnterText);
  34714. var virtualModel = {
  34715. getLineTokens: function (lineNumber) {
  34716. return model.getLineTokens(lineNumber);
  34717. },
  34718. getLanguageIdentifier: function () {
  34719. return model.getLanguageIdentifier();
  34720. },
  34721. getLanguageIdAtPosition: function (lineNumber, column) {
  34722. return model.getLanguageIdAtPosition(lineNumber, column);
  34723. },
  34724. getLineContent: function (lineNumber) {
  34725. if (lineNumber === range.startLineNumber) {
  34726. return beforeEnterResult;
  34727. }
  34728. else {
  34729. return model.getLineContent(lineNumber);
  34730. }
  34731. }
  34732. };
  34733. var currentLineIndent = strings.getLeadingWhitespace(lineTokens.getLineContent());
  34734. var afterEnterAction = this.getInheritIndentForLine(autoIndent, virtualModel, range.startLineNumber + 1);
  34735. if (!afterEnterAction) {
  34736. var beforeEnter = embeddedLanguage ? currentLineIndent : beforeEnterIndent;
  34737. return {
  34738. beforeEnter: beforeEnter,
  34739. afterEnter: beforeEnter
  34740. };
  34741. }
  34742. var afterEnterIndent = embeddedLanguage ? currentLineIndent : afterEnterAction.indentation;
  34743. if (afterEnterAction.action === languageConfiguration_1.IndentAction.Indent) {
  34744. afterEnterIndent = indentConverter.shiftIndent(afterEnterIndent);
  34745. }
  34746. if (indentRulesSupport.shouldDecrease(afterEnterText)) {
  34747. afterEnterIndent = indentConverter.unshiftIndent(afterEnterIndent);
  34748. }
  34749. return {
  34750. beforeEnter: embeddedLanguage ? currentLineIndent : beforeEnterIndent,
  34751. afterEnter: afterEnterIndent
  34752. };
  34753. };
  34754. /**
  34755. * We should always allow intentional indentation. It means, if users change the indentation of `lineNumber` and the content of
  34756. * this line doesn't match decreaseIndentPattern, we should not adjust the indentation.
  34757. */
  34758. LanguageConfigurationRegistryImpl.prototype.getIndentActionForType = function (autoIndent, model, range, ch, indentConverter) {
  34759. if (autoIndent < 4 /* Full */) {
  34760. return null;
  34761. }
  34762. var scopedLineTokens = this.getScopedLineTokens(model, range.startLineNumber, range.startColumn);
  34763. var indentRulesSupport = this.getIndentRulesSupport(scopedLineTokens.languageId);
  34764. if (!indentRulesSupport) {
  34765. return null;
  34766. }
  34767. var scopedLineText = scopedLineTokens.getLineContent();
  34768. var beforeTypeText = scopedLineText.substr(0, range.startColumn - 1 - scopedLineTokens.firstCharOffset);
  34769. // selection support
  34770. var afterTypeText;
  34771. if (range.isEmpty()) {
  34772. afterTypeText = scopedLineText.substr(range.startColumn - 1 - scopedLineTokens.firstCharOffset);
  34773. }
  34774. else {
  34775. var endScopedLineTokens = this.getScopedLineTokens(model, range.endLineNumber, range.endColumn);
  34776. afterTypeText = endScopedLineTokens.getLineContent().substr(range.endColumn - 1 - scopedLineTokens.firstCharOffset);
  34777. }
  34778. // If previous content already matches decreaseIndentPattern, it means indentation of this line should already be adjusted
  34779. // Users might change the indentation by purpose and we should honor that instead of readjusting.
  34780. if (!indentRulesSupport.shouldDecrease(beforeTypeText + afterTypeText) && indentRulesSupport.shouldDecrease(beforeTypeText + ch + afterTypeText)) {
  34781. // after typing `ch`, the content matches decreaseIndentPattern, we should adjust the indent to a good manner.
  34782. // 1. Get inherited indent action
  34783. var r = this.getInheritIndentForLine(autoIndent, model, range.startLineNumber, false);
  34784. if (!r) {
  34785. return null;
  34786. }
  34787. var indentation = r.indentation;
  34788. if (r.action !== languageConfiguration_1.IndentAction.Indent) {
  34789. indentation = indentConverter.unshiftIndent(indentation);
  34790. }
  34791. return indentation;
  34792. }
  34793. return null;
  34794. };
  34795. LanguageConfigurationRegistryImpl.prototype.getIndentMetadata = function (model, lineNumber) {
  34796. var indentRulesSupport = this.getIndentRulesSupport(model.getLanguageIdentifier().id);
  34797. if (!indentRulesSupport) {
  34798. return null;
  34799. }
  34800. if (lineNumber < 1 || lineNumber > model.getLineCount()) {
  34801. return null;
  34802. }
  34803. return indentRulesSupport.getIndentMetadata(model.getLineContent(lineNumber));
  34804. };
  34805. // end Indent Rules
  34806. // begin onEnter
  34807. LanguageConfigurationRegistryImpl.prototype.getEnterAction = function (autoIndent, model, range) {
  34808. var scopedLineTokens = this.getScopedLineTokens(model, range.startLineNumber, range.startColumn);
  34809. var richEditSupport = this._getRichEditSupport(scopedLineTokens.languageId);
  34810. if (!richEditSupport) {
  34811. return null;
  34812. }
  34813. var scopedLineText = scopedLineTokens.getLineContent();
  34814. var beforeEnterText = scopedLineText.substr(0, range.startColumn - 1 - scopedLineTokens.firstCharOffset);
  34815. // selection support
  34816. var afterEnterText;
  34817. if (range.isEmpty()) {
  34818. afterEnterText = scopedLineText.substr(range.startColumn - 1 - scopedLineTokens.firstCharOffset);
  34819. }
  34820. else {
  34821. var endScopedLineTokens = this.getScopedLineTokens(model, range.endLineNumber, range.endColumn);
  34822. afterEnterText = endScopedLineTokens.getLineContent().substr(range.endColumn - 1 - scopedLineTokens.firstCharOffset);
  34823. }
  34824. var oneLineAboveText = '';
  34825. if (range.startLineNumber > 1 && scopedLineTokens.firstCharOffset === 0) {
  34826. // This is not the first line and the entire line belongs to this mode
  34827. var oneLineAboveScopedLineTokens = this.getScopedLineTokens(model, range.startLineNumber - 1);
  34828. if (oneLineAboveScopedLineTokens.languageId === scopedLineTokens.languageId) {
  34829. // The line above ends with text belonging to the same mode
  34830. oneLineAboveText = oneLineAboveScopedLineTokens.getLineContent();
  34831. }
  34832. }
  34833. var enterResult = richEditSupport.onEnter(autoIndent, oneLineAboveText, beforeEnterText, afterEnterText);
  34834. if (!enterResult) {
  34835. return null;
  34836. }
  34837. var indentAction = enterResult.indentAction;
  34838. var appendText = enterResult.appendText;
  34839. var removeText = enterResult.removeText || 0;
  34840. // Here we add `\t` to appendText first because enterAction is leveraging appendText and removeText to change indentation.
  34841. if (!appendText) {
  34842. if ((indentAction === languageConfiguration_1.IndentAction.Indent) ||
  34843. (indentAction === languageConfiguration_1.IndentAction.IndentOutdent)) {
  34844. appendText = '\t';
  34845. }
  34846. else {
  34847. appendText = '';
  34848. }
  34849. }
  34850. var indentation = this.getIndentationAtPosition(model, range.startLineNumber, range.startColumn);
  34851. if (removeText) {
  34852. indentation = indentation.substring(0, indentation.length - removeText);
  34853. }
  34854. return {
  34855. indentAction: indentAction,
  34856. appendText: appendText,
  34857. removeText: removeText,
  34858. indentation: indentation
  34859. };
  34860. };
  34861. LanguageConfigurationRegistryImpl.prototype.getIndentationAtPosition = function (model, lineNumber, column) {
  34862. var lineText = model.getLineContent(lineNumber);
  34863. var indentation = strings.getLeadingWhitespace(lineText);
  34864. if (indentation.length > column - 1) {
  34865. indentation = indentation.substring(0, column - 1);
  34866. }
  34867. return indentation;
  34868. };
  34869. LanguageConfigurationRegistryImpl.prototype.getScopedLineTokens = function (model, lineNumber, columnNumber) {
  34870. model.forceTokenization(lineNumber);
  34871. var lineTokens = model.getLineTokens(lineNumber);
  34872. var column = (typeof columnNumber === 'undefined' ? model.getLineMaxColumn(lineNumber) - 1 : columnNumber - 1);
  34873. return supports_1.createScopedLineTokens(lineTokens, column);
  34874. };
  34875. // end onEnter
  34876. LanguageConfigurationRegistryImpl.prototype.getBracketsSupport = function (languageId) {
  34877. var value = this._getRichEditSupport(languageId);
  34878. if (!value) {
  34879. return null;
  34880. }
  34881. return value.brackets || null;
  34882. };
  34883. return LanguageConfigurationRegistryImpl;
  34884. }());
  34885. exports.LanguageConfigurationRegistryImpl = LanguageConfigurationRegistryImpl;
  34886. exports.LanguageConfigurationRegistry = new LanguageConfigurationRegistryImpl();
  34887. });
  34888. /*---------------------------------------------------------------------------------------------
  34889. * Copyright (c) Microsoft Corporation. All rights reserved.
  34890. * Licensed under the MIT License. See License.txt in the project root for license information.
  34891. *--------------------------------------------------------------------------------------------*/
  34892. define(__m[357/*vs/editor/common/modes/supports/tokenization*/], __M([0/*require*/,1/*exports*/,27/*vs/base/common/color*/]), function (require, exports, color_1) {
  34893. "use strict";
  34894. Object.defineProperty(exports, "__esModule", { value: true });
  34895. var ParsedTokenThemeRule = /** @class */ (function () {
  34896. function ParsedTokenThemeRule(token, index, fontStyle, foreground, background) {
  34897. this.token = token;
  34898. this.index = index;
  34899. this.fontStyle = fontStyle;
  34900. this.foreground = foreground;
  34901. this.background = background;
  34902. }
  34903. return ParsedTokenThemeRule;
  34904. }());
  34905. exports.ParsedTokenThemeRule = ParsedTokenThemeRule;
  34906. /**
  34907. * Parse a raw theme into rules.
  34908. */
  34909. function parseTokenTheme(source) {
  34910. if (!source || !Array.isArray(source)) {
  34911. return [];
  34912. }
  34913. var result = [], resultLen = 0;
  34914. for (var i = 0, len = source.length; i < len; i++) {
  34915. var entry = source[i];
  34916. var fontStyle = -1 /* NotSet */;
  34917. if (typeof entry.fontStyle === 'string') {
  34918. fontStyle = 0 /* None */;
  34919. var segments = entry.fontStyle.split(' ');
  34920. for (var j = 0, lenJ = segments.length; j < lenJ; j++) {
  34921. var segment = segments[j];
  34922. switch (segment) {
  34923. case 'italic':
  34924. fontStyle = fontStyle | 1 /* Italic */;
  34925. break;
  34926. case 'bold':
  34927. fontStyle = fontStyle | 2 /* Bold */;
  34928. break;
  34929. case 'underline':
  34930. fontStyle = fontStyle | 4 /* Underline */;
  34931. break;
  34932. }
  34933. }
  34934. }
  34935. var foreground = null;
  34936. if (typeof entry.foreground === 'string') {
  34937. foreground = entry.foreground;
  34938. }
  34939. var background = null;
  34940. if (typeof entry.background === 'string') {
  34941. background = entry.background;
  34942. }
  34943. result[resultLen++] = new ParsedTokenThemeRule(entry.token || '', i, fontStyle, foreground, background);
  34944. }
  34945. return result;
  34946. }
  34947. exports.parseTokenTheme = parseTokenTheme;
  34948. /**
  34949. * Resolve rules (i.e. inheritance).
  34950. */
  34951. function resolveParsedTokenThemeRules(parsedThemeRules, customTokenColors) {
  34952. // Sort rules lexicographically, and then by index if necessary
  34953. parsedThemeRules.sort(function (a, b) {
  34954. var r = strcmp(a.token, b.token);
  34955. if (r !== 0) {
  34956. return r;
  34957. }
  34958. return a.index - b.index;
  34959. });
  34960. // Determine defaults
  34961. var defaultFontStyle = 0 /* None */;
  34962. var defaultForeground = '000000';
  34963. var defaultBackground = 'ffffff';
  34964. while (parsedThemeRules.length >= 1 && parsedThemeRules[0].token === '') {
  34965. var incomingDefaults = parsedThemeRules.shift();
  34966. if (incomingDefaults.fontStyle !== -1 /* NotSet */) {
  34967. defaultFontStyle = incomingDefaults.fontStyle;
  34968. }
  34969. if (incomingDefaults.foreground !== null) {
  34970. defaultForeground = incomingDefaults.foreground;
  34971. }
  34972. if (incomingDefaults.background !== null) {
  34973. defaultBackground = incomingDefaults.background;
  34974. }
  34975. }
  34976. var colorMap = new ColorMap();
  34977. // start with token colors from custom token themes
  34978. for (var _i = 0, customTokenColors_1 = customTokenColors; _i < customTokenColors_1.length; _i++) {
  34979. var color = customTokenColors_1[_i];
  34980. colorMap.getId(color);
  34981. }
  34982. var foregroundColorId = colorMap.getId(defaultForeground);
  34983. var backgroundColorId = colorMap.getId(defaultBackground);
  34984. var defaults = new ThemeTrieElementRule(defaultFontStyle, foregroundColorId, backgroundColorId);
  34985. var root = new ThemeTrieElement(defaults);
  34986. for (var i = 0, len = parsedThemeRules.length; i < len; i++) {
  34987. var rule = parsedThemeRules[i];
  34988. root.insert(rule.token, rule.fontStyle, colorMap.getId(rule.foreground), colorMap.getId(rule.background));
  34989. }
  34990. return new TokenTheme(colorMap, root);
  34991. }
  34992. var colorRegExp = /^#?([0-9A-Fa-f]{6})([0-9A-Fa-f]{2})?$/;
  34993. var ColorMap = /** @class */ (function () {
  34994. function ColorMap() {
  34995. this._lastColorId = 0;
  34996. this._id2color = [];
  34997. this._color2id = new Map();
  34998. }
  34999. ColorMap.prototype.getId = function (color) {
  35000. if (color === null) {
  35001. return 0;
  35002. }
  35003. var match = color.match(colorRegExp);
  35004. if (!match) {
  35005. throw new Error('Illegal value for token color: ' + color);
  35006. }
  35007. color = match[1].toUpperCase();
  35008. var value = this._color2id.get(color);
  35009. if (value) {
  35010. return value;
  35011. }
  35012. value = ++this._lastColorId;
  35013. this._color2id.set(color, value);
  35014. this._id2color[value] = color_1.Color.fromHex('#' + color);
  35015. return value;
  35016. };
  35017. ColorMap.prototype.getColorMap = function () {
  35018. return this._id2color.slice(0);
  35019. };
  35020. return ColorMap;
  35021. }());
  35022. exports.ColorMap = ColorMap;
  35023. var TokenTheme = /** @class */ (function () {
  35024. function TokenTheme(colorMap, root) {
  35025. this._colorMap = colorMap;
  35026. this._root = root;
  35027. this._cache = new Map();
  35028. }
  35029. TokenTheme.createFromRawTokenTheme = function (source, customTokenColors) {
  35030. return this.createFromParsedTokenTheme(parseTokenTheme(source), customTokenColors);
  35031. };
  35032. TokenTheme.createFromParsedTokenTheme = function (source, customTokenColors) {
  35033. return resolveParsedTokenThemeRules(source, customTokenColors);
  35034. };
  35035. TokenTheme.prototype.getColorMap = function () {
  35036. return this._colorMap.getColorMap();
  35037. };
  35038. TokenTheme.prototype._match = function (token) {
  35039. return this._root.match(token);
  35040. };
  35041. TokenTheme.prototype.match = function (languageId, token) {
  35042. // The cache contains the metadata without the language bits set.
  35043. var result = this._cache.get(token);
  35044. if (typeof result === 'undefined') {
  35045. var rule = this._match(token);
  35046. var standardToken = toStandardTokenType(token);
  35047. result = (rule.metadata
  35048. | (standardToken << 8 /* TOKEN_TYPE_OFFSET */)) >>> 0;
  35049. this._cache.set(token, result);
  35050. }
  35051. return (result
  35052. | (languageId << 0 /* LANGUAGEID_OFFSET */)) >>> 0;
  35053. };
  35054. return TokenTheme;
  35055. }());
  35056. exports.TokenTheme = TokenTheme;
  35057. var STANDARD_TOKEN_TYPE_REGEXP = /\b(comment|string|regex|regexp)\b/;
  35058. function toStandardTokenType(tokenType) {
  35059. var m = tokenType.match(STANDARD_TOKEN_TYPE_REGEXP);
  35060. if (!m) {
  35061. return 0 /* Other */;
  35062. }
  35063. switch (m[1]) {
  35064. case 'comment':
  35065. return 1 /* Comment */;
  35066. case 'string':
  35067. return 2 /* String */;
  35068. case 'regex':
  35069. return 4 /* RegEx */;
  35070. case 'regexp':
  35071. return 4 /* RegEx */;
  35072. }
  35073. throw new Error('Unexpected match for standard token type!');
  35074. }
  35075. exports.toStandardTokenType = toStandardTokenType;
  35076. function strcmp(a, b) {
  35077. if (a < b) {
  35078. return -1;
  35079. }
  35080. if (a > b) {
  35081. return 1;
  35082. }
  35083. return 0;
  35084. }
  35085. exports.strcmp = strcmp;
  35086. var ThemeTrieElementRule = /** @class */ (function () {
  35087. function ThemeTrieElementRule(fontStyle, foreground, background) {
  35088. this._fontStyle = fontStyle;
  35089. this._foreground = foreground;
  35090. this._background = background;
  35091. this.metadata = ((this._fontStyle << 11 /* FONT_STYLE_OFFSET */)
  35092. | (this._foreground << 14 /* FOREGROUND_OFFSET */)
  35093. | (this._background << 23 /* BACKGROUND_OFFSET */)) >>> 0;
  35094. }
  35095. ThemeTrieElementRule.prototype.clone = function () {
  35096. return new ThemeTrieElementRule(this._fontStyle, this._foreground, this._background);
  35097. };
  35098. ThemeTrieElementRule.prototype.acceptOverwrite = function (fontStyle, foreground, background) {
  35099. if (fontStyle !== -1 /* NotSet */) {
  35100. this._fontStyle = fontStyle;
  35101. }
  35102. if (foreground !== 0 /* None */) {
  35103. this._foreground = foreground;
  35104. }
  35105. if (background !== 0 /* None */) {
  35106. this._background = background;
  35107. }
  35108. this.metadata = ((this._fontStyle << 11 /* FONT_STYLE_OFFSET */)
  35109. | (this._foreground << 14 /* FOREGROUND_OFFSET */)
  35110. | (this._background << 23 /* BACKGROUND_OFFSET */)) >>> 0;
  35111. };
  35112. return ThemeTrieElementRule;
  35113. }());
  35114. exports.ThemeTrieElementRule = ThemeTrieElementRule;
  35115. var ThemeTrieElement = /** @class */ (function () {
  35116. function ThemeTrieElement(mainRule) {
  35117. this._mainRule = mainRule;
  35118. this._children = new Map();
  35119. }
  35120. ThemeTrieElement.prototype.match = function (token) {
  35121. if (token === '') {
  35122. return this._mainRule;
  35123. }
  35124. var dotIndex = token.indexOf('.');
  35125. var head;
  35126. var tail;
  35127. if (dotIndex === -1) {
  35128. head = token;
  35129. tail = '';
  35130. }
  35131. else {
  35132. head = token.substring(0, dotIndex);
  35133. tail = token.substring(dotIndex + 1);
  35134. }
  35135. var child = this._children.get(head);
  35136. if (typeof child !== 'undefined') {
  35137. return child.match(tail);
  35138. }
  35139. return this._mainRule;
  35140. };
  35141. ThemeTrieElement.prototype.insert = function (token, fontStyle, foreground, background) {
  35142. if (token === '') {
  35143. // Merge into the main rule
  35144. this._mainRule.acceptOverwrite(fontStyle, foreground, background);
  35145. return;
  35146. }
  35147. var dotIndex = token.indexOf('.');
  35148. var head;
  35149. var tail;
  35150. if (dotIndex === -1) {
  35151. head = token;
  35152. tail = '';
  35153. }
  35154. else {
  35155. head = token.substring(0, dotIndex);
  35156. tail = token.substring(dotIndex + 1);
  35157. }
  35158. var child = this._children.get(head);
  35159. if (typeof child === 'undefined') {
  35160. child = new ThemeTrieElement(this._mainRule.clone());
  35161. this._children.set(head, child);
  35162. }
  35163. child.insert(tail, fontStyle, foreground, background);
  35164. };
  35165. return ThemeTrieElement;
  35166. }());
  35167. exports.ThemeTrieElement = ThemeTrieElement;
  35168. function generateTokensCSSForColorMap(colorMap) {
  35169. var rules = [];
  35170. for (var i = 1, len = colorMap.length; i < len; i++) {
  35171. var color = colorMap[i];
  35172. rules[i] = ".mtk" + i + " { color: " + color + "; }";
  35173. }
  35174. rules.push('.mtki { font-style: italic; }');
  35175. rules.push('.mtkb { font-weight: bold; }');
  35176. rules.push('.mtku { text-decoration: underline; text-underline-position: under; }');
  35177. return rules.join('\n');
  35178. }
  35179. exports.generateTokensCSSForColorMap = generateTokensCSSForColorMap;
  35180. });
  35181. /*---------------------------------------------------------------------------------------------
  35182. * Copyright (c) Microsoft Corporation. All rights reserved.
  35183. * Licensed under the MIT License. See License.txt in the project root for license information.
  35184. *--------------------------------------------------------------------------------------------*/
  35185. define(__m[358/*vs/editor/common/modes/tokenizationRegistry*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,21/*vs/base/common/types*/,38/*vs/base/common/map*/]), function (require, exports, event_1, lifecycle_1, types_1, map_1) {
  35186. "use strict";
  35187. Object.defineProperty(exports, "__esModule", { value: true });
  35188. var TokenizationRegistryImpl = /** @class */ (function () {
  35189. function TokenizationRegistryImpl() {
  35190. this._map = new Map();
  35191. this._promises = new Map();
  35192. this._onDidChange = new event_1.Emitter();
  35193. this.onDidChange = this._onDidChange.event;
  35194. this._colorMap = null;
  35195. }
  35196. TokenizationRegistryImpl.prototype.fire = function (languages) {
  35197. this._onDidChange.fire({
  35198. changedLanguages: languages,
  35199. changedColorMap: false
  35200. });
  35201. };
  35202. TokenizationRegistryImpl.prototype.register = function (language, support) {
  35203. var _this = this;
  35204. this._map.set(language, support);
  35205. this.fire([language]);
  35206. return lifecycle_1.toDisposable(function () {
  35207. if (_this._map.get(language) !== support) {
  35208. return;
  35209. }
  35210. _this._map.delete(language);
  35211. _this.fire([language]);
  35212. });
  35213. };
  35214. TokenizationRegistryImpl.prototype.registerPromise = function (language, supportPromise) {
  35215. var _this = this;
  35216. var registration = null;
  35217. var isDisposed = false;
  35218. this._promises.set(language, supportPromise.then(function (support) {
  35219. _this._promises.delete(language);
  35220. if (isDisposed || !support) {
  35221. return;
  35222. }
  35223. registration = _this.register(language, support);
  35224. }));
  35225. return lifecycle_1.toDisposable(function () {
  35226. isDisposed = true;
  35227. if (registration) {
  35228. registration.dispose();
  35229. }
  35230. });
  35231. };
  35232. TokenizationRegistryImpl.prototype.getPromise = function (language) {
  35233. var _this = this;
  35234. var support = this.get(language);
  35235. if (support) {
  35236. return Promise.resolve(support);
  35237. }
  35238. var promise = this._promises.get(language);
  35239. if (promise) {
  35240. return promise.then(function (_) { return _this.get(language); });
  35241. }
  35242. return null;
  35243. };
  35244. TokenizationRegistryImpl.prototype.get = function (language) {
  35245. return types_1.withUndefinedAsNull(this._map.get(language));
  35246. };
  35247. TokenizationRegistryImpl.prototype.setColorMap = function (colorMap) {
  35248. this._colorMap = colorMap;
  35249. this._onDidChange.fire({
  35250. changedLanguages: map_1.keys(this._map),
  35251. changedColorMap: true
  35252. });
  35253. };
  35254. TokenizationRegistryImpl.prototype.getColorMap = function () {
  35255. return this._colorMap;
  35256. };
  35257. TokenizationRegistryImpl.prototype.getDefaultBackground = function () {
  35258. if (this._colorMap && this._colorMap.length > 2 /* DefaultBackground */) {
  35259. return this._colorMap[2 /* DefaultBackground */];
  35260. }
  35261. return null;
  35262. };
  35263. return TokenizationRegistryImpl;
  35264. }());
  35265. exports.TokenizationRegistryImpl = TokenizationRegistryImpl;
  35266. });
  35267. /*!
  35268. Copyright (c) 2014 Taylor Hakes
  35269. Copyright (c) 2014 Forbes Lindesay
  35270. */
  35271. (function (global, factory) {
  35272. typeof exports === 'object' && typeof module !== 'undefined' ? factory() :
  35273. typeof define === 'function' && define.amd ? define("vs/editor/common/standalone/promise-polyfill/polyfill", factory) :
  35274. (factory());
  35275. }(this, (function () {
  35276. 'use strict';
  35277. /**
  35278. * @this {Promise}
  35279. */
  35280. function finallyConstructor(callback) {
  35281. var constructor = this.constructor;
  35282. return this.then(
  35283. function (value) {
  35284. return constructor.resolve(callback()).then(function () {
  35285. return value;
  35286. });
  35287. },
  35288. function (reason) {
  35289. return constructor.resolve(callback()).then(function () {
  35290. return constructor.reject(reason);
  35291. });
  35292. }
  35293. );
  35294. }
  35295. // Store setTimeout reference so promise-polyfill will be unaffected by
  35296. // other code modifying setTimeout (like sinon.useFakeTimers())
  35297. var setTimeoutFunc = setTimeout;
  35298. function noop() { }
  35299. // Polyfill for Function.prototype.bind
  35300. function bind(fn, thisArg) {
  35301. return function () {
  35302. fn.apply(thisArg, arguments);
  35303. };
  35304. }
  35305. /**
  35306. * @constructor
  35307. * @param {Function} fn
  35308. */
  35309. function Promise(fn) {
  35310. if (!(this instanceof Promise))
  35311. throw new TypeError('Promises must be constructed via new');
  35312. if (typeof fn !== 'function') throw new TypeError('not a function');
  35313. /** @type {!number} */
  35314. this._state = 0;
  35315. /** @type {!boolean} */
  35316. this._handled = false;
  35317. /** @type {Promise|undefined} */
  35318. this._value = undefined;
  35319. /** @type {!Array<!Function>} */
  35320. this._deferreds = [];
  35321. doResolve(fn, this);
  35322. }
  35323. function handle(self, deferred) {
  35324. while (self._state === 3) {
  35325. self = self._value;
  35326. }
  35327. if (self._state === 0) {
  35328. self._deferreds.push(deferred);
  35329. return;
  35330. }
  35331. self._handled = true;
  35332. Promise._immediateFn(function () {
  35333. var cb = self._state === 1 ? deferred.onFulfilled : deferred.onRejected;
  35334. if (cb === null) {
  35335. (self._state === 1 ? resolve : reject)(deferred.promise, self._value);
  35336. return;
  35337. }
  35338. var ret;
  35339. try {
  35340. ret = cb(self._value);
  35341. } catch (e) {
  35342. reject(deferred.promise, e);
  35343. return;
  35344. }
  35345. resolve(deferred.promise, ret);
  35346. });
  35347. }
  35348. function resolve(self, newValue) {
  35349. try {
  35350. // Promise Resolution Procedure: https://github.com/promises-aplus/promises-spec#the-promise-resolution-procedure
  35351. if (newValue === self)
  35352. throw new TypeError('A promise cannot be resolved with itself.');
  35353. if (
  35354. newValue &&
  35355. (typeof newValue === 'object' || typeof newValue === 'function')
  35356. ) {
  35357. var then = newValue.then;
  35358. if (newValue instanceof Promise) {
  35359. self._state = 3;
  35360. self._value = newValue;
  35361. finale(self);
  35362. return;
  35363. } else if (typeof then === 'function') {
  35364. doResolve(bind(then, newValue), self);
  35365. return;
  35366. }
  35367. }
  35368. self._state = 1;
  35369. self._value = newValue;
  35370. finale(self);
  35371. } catch (e) {
  35372. reject(self, e);
  35373. }
  35374. }
  35375. function reject(self, newValue) {
  35376. self._state = 2;
  35377. self._value = newValue;
  35378. finale(self);
  35379. }
  35380. function finale(self) {
  35381. if (self._state === 2 && self._deferreds.length === 0) {
  35382. Promise._immediateFn(function () {
  35383. if (!self._handled) {
  35384. Promise._unhandledRejectionFn(self._value);
  35385. }
  35386. });
  35387. }
  35388. for (var i = 0, len = self._deferreds.length; i < len; i++) {
  35389. handle(self, self._deferreds[i]);
  35390. }
  35391. self._deferreds = null;
  35392. }
  35393. /**
  35394. * @constructor
  35395. */
  35396. function Handler(onFulfilled, onRejected, promise) {
  35397. this.onFulfilled = typeof onFulfilled === 'function' ? onFulfilled : null;
  35398. this.onRejected = typeof onRejected === 'function' ? onRejected : null;
  35399. this.promise = promise;
  35400. }
  35401. /**
  35402. * Take a potentially misbehaving resolver function and make sure
  35403. * onFulfilled and onRejected are only called once.
  35404. *
  35405. * Makes no guarantees about asynchrony.
  35406. */
  35407. function doResolve(fn, self) {
  35408. var done = false;
  35409. try {
  35410. fn(
  35411. function (value) {
  35412. if (done) return;
  35413. done = true;
  35414. resolve(self, value);
  35415. },
  35416. function (reason) {
  35417. if (done) return;
  35418. done = true;
  35419. reject(self, reason);
  35420. }
  35421. );
  35422. } catch (ex) {
  35423. if (done) return;
  35424. done = true;
  35425. reject(self, ex);
  35426. }
  35427. }
  35428. Promise.prototype['catch'] = function (onRejected) {
  35429. return this.then(null, onRejected);
  35430. };
  35431. Promise.prototype.then = function (onFulfilled, onRejected) {
  35432. // @ts-ignore
  35433. var prom = new this.constructor(noop);
  35434. handle(this, new Handler(onFulfilled, onRejected, prom));
  35435. return prom;
  35436. };
  35437. Promise.prototype['finally'] = finallyConstructor;
  35438. Promise.all = function (arr) {
  35439. return new Promise(function (resolve, reject) {
  35440. if (!arr || typeof arr.length === 'undefined')
  35441. throw new TypeError('Promise.all accepts an array');
  35442. var args = Array.prototype.slice.call(arr);
  35443. if (args.length === 0) return resolve([]);
  35444. var remaining = args.length;
  35445. function res(i, val) {
  35446. try {
  35447. if (val && (typeof val === 'object' || typeof val === 'function')) {
  35448. var then = val.then;
  35449. if (typeof then === 'function') {
  35450. then.call(
  35451. val,
  35452. function (val) {
  35453. res(i, val);
  35454. },
  35455. reject
  35456. );
  35457. return;
  35458. }
  35459. }
  35460. args[i] = val;
  35461. if (--remaining === 0) {
  35462. resolve(args);
  35463. }
  35464. } catch (ex) {
  35465. reject(ex);
  35466. }
  35467. }
  35468. for (var i = 0; i < args.length; i++) {
  35469. res(i, args[i]);
  35470. }
  35471. });
  35472. };
  35473. Promise.resolve = function (value) {
  35474. if (value && typeof value === 'object' && value.constructor === Promise) {
  35475. return value;
  35476. }
  35477. return new Promise(function (resolve) {
  35478. resolve(value);
  35479. });
  35480. };
  35481. Promise.reject = function (value) {
  35482. return new Promise(function (resolve, reject) {
  35483. reject(value);
  35484. });
  35485. };
  35486. Promise.race = function (values) {
  35487. return new Promise(function (resolve, reject) {
  35488. for (var i = 0, len = values.length; i < len; i++) {
  35489. values[i].then(resolve, reject);
  35490. }
  35491. });
  35492. };
  35493. // Use polyfill for setImmediate for performance gains
  35494. Promise._immediateFn =
  35495. (typeof setImmediate === 'function' &&
  35496. function (fn) {
  35497. setImmediate(fn);
  35498. }) ||
  35499. function (fn) {
  35500. setTimeoutFunc(fn, 0);
  35501. };
  35502. Promise._unhandledRejectionFn = function _unhandledRejectionFn(err) {
  35503. if (typeof console !== 'undefined' && console) {
  35504. console.warn('Possible Unhandled Promise Rejection:', err); // eslint-disable-line no-console
  35505. }
  35506. };
  35507. /** @suppress {undefinedVars} */
  35508. var globalNS = (function () {
  35509. // the only reliable means to get the global object is
  35510. // `Function('return this')()`
  35511. // However, this causes CSP violations in Chrome apps.
  35512. if (typeof self !== 'undefined') {
  35513. return self;
  35514. }
  35515. if (typeof window !== 'undefined') {
  35516. return window;
  35517. }
  35518. if (typeof global !== 'undefined') {
  35519. return global;
  35520. }
  35521. throw new Error('unable to locate global object');
  35522. })();
  35523. if (!('Promise' in globalNS)) {
  35524. globalNS['Promise'] = Promise;
  35525. } else if (!globalNS.Promise.prototype['finally']) {
  35526. globalNS.Promise.prototype['finally'] = finallyConstructor;
  35527. }
  35528. })));
  35529. /*---------------------------------------------------------------------------------------------
  35530. * Copyright (c) Microsoft Corporation. All rights reserved.
  35531. * Licensed under the MIT License. See License.txt in the project root for license information.
  35532. *--------------------------------------------------------------------------------------------*/
  35533. define(__m[147/*vs/editor/common/standalone/standaloneEnums*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  35534. "use strict";
  35535. Object.defineProperty(exports, "__esModule", { value: true });
  35536. // THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY.
  35537. var AccessibilitySupport;
  35538. (function (AccessibilitySupport) {
  35539. /**
  35540. * This should be the browser case where it is not known if a screen reader is attached or no.
  35541. */
  35542. AccessibilitySupport[AccessibilitySupport["Unknown"] = 0] = "Unknown";
  35543. AccessibilitySupport[AccessibilitySupport["Disabled"] = 1] = "Disabled";
  35544. AccessibilitySupport[AccessibilitySupport["Enabled"] = 2] = "Enabled";
  35545. })(AccessibilitySupport = exports.AccessibilitySupport || (exports.AccessibilitySupport = {}));
  35546. var CompletionItemInsertTextRule;
  35547. (function (CompletionItemInsertTextRule) {
  35548. /**
  35549. * Adjust whitespace/indentation of multiline insert texts to
  35550. * match the current line indentation.
  35551. */
  35552. CompletionItemInsertTextRule[CompletionItemInsertTextRule["KeepWhitespace"] = 1] = "KeepWhitespace";
  35553. /**
  35554. * `insertText` is a snippet.
  35555. */
  35556. CompletionItemInsertTextRule[CompletionItemInsertTextRule["InsertAsSnippet"] = 4] = "InsertAsSnippet";
  35557. })(CompletionItemInsertTextRule = exports.CompletionItemInsertTextRule || (exports.CompletionItemInsertTextRule = {}));
  35558. var CompletionItemKind;
  35559. (function (CompletionItemKind) {
  35560. CompletionItemKind[CompletionItemKind["Method"] = 0] = "Method";
  35561. CompletionItemKind[CompletionItemKind["Function"] = 1] = "Function";
  35562. CompletionItemKind[CompletionItemKind["Constructor"] = 2] = "Constructor";
  35563. CompletionItemKind[CompletionItemKind["Field"] = 3] = "Field";
  35564. CompletionItemKind[CompletionItemKind["Variable"] = 4] = "Variable";
  35565. CompletionItemKind[CompletionItemKind["Class"] = 5] = "Class";
  35566. CompletionItemKind[CompletionItemKind["Struct"] = 6] = "Struct";
  35567. CompletionItemKind[CompletionItemKind["Interface"] = 7] = "Interface";
  35568. CompletionItemKind[CompletionItemKind["Module"] = 8] = "Module";
  35569. CompletionItemKind[CompletionItemKind["Property"] = 9] = "Property";
  35570. CompletionItemKind[CompletionItemKind["Event"] = 10] = "Event";
  35571. CompletionItemKind[CompletionItemKind["Operator"] = 11] = "Operator";
  35572. CompletionItemKind[CompletionItemKind["Unit"] = 12] = "Unit";
  35573. CompletionItemKind[CompletionItemKind["Value"] = 13] = "Value";
  35574. CompletionItemKind[CompletionItemKind["Constant"] = 14] = "Constant";
  35575. CompletionItemKind[CompletionItemKind["Enum"] = 15] = "Enum";
  35576. CompletionItemKind[CompletionItemKind["EnumMember"] = 16] = "EnumMember";
  35577. CompletionItemKind[CompletionItemKind["Keyword"] = 17] = "Keyword";
  35578. CompletionItemKind[CompletionItemKind["Text"] = 18] = "Text";
  35579. CompletionItemKind[CompletionItemKind["Color"] = 19] = "Color";
  35580. CompletionItemKind[CompletionItemKind["File"] = 20] = "File";
  35581. CompletionItemKind[CompletionItemKind["Reference"] = 21] = "Reference";
  35582. CompletionItemKind[CompletionItemKind["Customcolor"] = 22] = "Customcolor";
  35583. CompletionItemKind[CompletionItemKind["Folder"] = 23] = "Folder";
  35584. CompletionItemKind[CompletionItemKind["TypeParameter"] = 24] = "TypeParameter";
  35585. CompletionItemKind[CompletionItemKind["Snippet"] = 25] = "Snippet";
  35586. })(CompletionItemKind = exports.CompletionItemKind || (exports.CompletionItemKind = {}));
  35587. var CompletionItemTag;
  35588. (function (CompletionItemTag) {
  35589. CompletionItemTag[CompletionItemTag["Deprecated"] = 1] = "Deprecated";
  35590. })(CompletionItemTag = exports.CompletionItemTag || (exports.CompletionItemTag = {}));
  35591. /**
  35592. * How a suggest provider was triggered.
  35593. */
  35594. var CompletionTriggerKind;
  35595. (function (CompletionTriggerKind) {
  35596. CompletionTriggerKind[CompletionTriggerKind["Invoke"] = 0] = "Invoke";
  35597. CompletionTriggerKind[CompletionTriggerKind["TriggerCharacter"] = 1] = "TriggerCharacter";
  35598. CompletionTriggerKind[CompletionTriggerKind["TriggerForIncompleteCompletions"] = 2] = "TriggerForIncompleteCompletions";
  35599. })(CompletionTriggerKind = exports.CompletionTriggerKind || (exports.CompletionTriggerKind = {}));
  35600. /**
  35601. * A positioning preference for rendering content widgets.
  35602. */
  35603. var ContentWidgetPositionPreference;
  35604. (function (ContentWidgetPositionPreference) {
  35605. /**
  35606. * Place the content widget exactly at a position
  35607. */
  35608. ContentWidgetPositionPreference[ContentWidgetPositionPreference["EXACT"] = 0] = "EXACT";
  35609. /**
  35610. * Place the content widget above a position
  35611. */
  35612. ContentWidgetPositionPreference[ContentWidgetPositionPreference["ABOVE"] = 1] = "ABOVE";
  35613. /**
  35614. * Place the content widget below a position
  35615. */
  35616. ContentWidgetPositionPreference[ContentWidgetPositionPreference["BELOW"] = 2] = "BELOW";
  35617. })(ContentWidgetPositionPreference = exports.ContentWidgetPositionPreference || (exports.ContentWidgetPositionPreference = {}));
  35618. /**
  35619. * Describes the reason the cursor has changed its position.
  35620. */
  35621. var CursorChangeReason;
  35622. (function (CursorChangeReason) {
  35623. /**
  35624. * Unknown or not set.
  35625. */
  35626. CursorChangeReason[CursorChangeReason["NotSet"] = 0] = "NotSet";
  35627. /**
  35628. * A `model.setValue()` was called.
  35629. */
  35630. CursorChangeReason[CursorChangeReason["ContentFlush"] = 1] = "ContentFlush";
  35631. /**
  35632. * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers.
  35633. */
  35634. CursorChangeReason[CursorChangeReason["RecoverFromMarkers"] = 2] = "RecoverFromMarkers";
  35635. /**
  35636. * There was an explicit user gesture.
  35637. */
  35638. CursorChangeReason[CursorChangeReason["Explicit"] = 3] = "Explicit";
  35639. /**
  35640. * There was a Paste.
  35641. */
  35642. CursorChangeReason[CursorChangeReason["Paste"] = 4] = "Paste";
  35643. /**
  35644. * There was an Undo.
  35645. */
  35646. CursorChangeReason[CursorChangeReason["Undo"] = 5] = "Undo";
  35647. /**
  35648. * There was a Redo.
  35649. */
  35650. CursorChangeReason[CursorChangeReason["Redo"] = 6] = "Redo";
  35651. })(CursorChangeReason = exports.CursorChangeReason || (exports.CursorChangeReason = {}));
  35652. /**
  35653. * The default end of line to use when instantiating models.
  35654. */
  35655. var DefaultEndOfLine;
  35656. (function (DefaultEndOfLine) {
  35657. /**
  35658. * Use line feed (\n) as the end of line character.
  35659. */
  35660. DefaultEndOfLine[DefaultEndOfLine["LF"] = 1] = "LF";
  35661. /**
  35662. * Use carriage return and line feed (\r\n) as the end of line character.
  35663. */
  35664. DefaultEndOfLine[DefaultEndOfLine["CRLF"] = 2] = "CRLF";
  35665. })(DefaultEndOfLine = exports.DefaultEndOfLine || (exports.DefaultEndOfLine = {}));
  35666. /**
  35667. * A document highlight kind.
  35668. */
  35669. var DocumentHighlightKind;
  35670. (function (DocumentHighlightKind) {
  35671. /**
  35672. * A textual occurrence.
  35673. */
  35674. DocumentHighlightKind[DocumentHighlightKind["Text"] = 0] = "Text";
  35675. /**
  35676. * Read-access of a symbol, like reading a variable.
  35677. */
  35678. DocumentHighlightKind[DocumentHighlightKind["Read"] = 1] = "Read";
  35679. /**
  35680. * Write-access of a symbol, like writing to a variable.
  35681. */
  35682. DocumentHighlightKind[DocumentHighlightKind["Write"] = 2] = "Write";
  35683. })(DocumentHighlightKind = exports.DocumentHighlightKind || (exports.DocumentHighlightKind = {}));
  35684. /**
  35685. * Configuration options for auto indentation in the editor
  35686. */
  35687. var EditorAutoIndentStrategy;
  35688. (function (EditorAutoIndentStrategy) {
  35689. EditorAutoIndentStrategy[EditorAutoIndentStrategy["None"] = 0] = "None";
  35690. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Keep"] = 1] = "Keep";
  35691. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Brackets"] = 2] = "Brackets";
  35692. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Advanced"] = 3] = "Advanced";
  35693. EditorAutoIndentStrategy[EditorAutoIndentStrategy["Full"] = 4] = "Full";
  35694. })(EditorAutoIndentStrategy = exports.EditorAutoIndentStrategy || (exports.EditorAutoIndentStrategy = {}));
  35695. var EditorOption;
  35696. (function (EditorOption) {
  35697. EditorOption[EditorOption["acceptSuggestionOnCommitCharacter"] = 0] = "acceptSuggestionOnCommitCharacter";
  35698. EditorOption[EditorOption["acceptSuggestionOnEnter"] = 1] = "acceptSuggestionOnEnter";
  35699. EditorOption[EditorOption["accessibilitySupport"] = 2] = "accessibilitySupport";
  35700. EditorOption[EditorOption["accessibilityPageSize"] = 3] = "accessibilityPageSize";
  35701. EditorOption[EditorOption["ariaLabel"] = 4] = "ariaLabel";
  35702. EditorOption[EditorOption["autoClosingBrackets"] = 5] = "autoClosingBrackets";
  35703. EditorOption[EditorOption["autoClosingOvertype"] = 6] = "autoClosingOvertype";
  35704. EditorOption[EditorOption["autoClosingQuotes"] = 7] = "autoClosingQuotes";
  35705. EditorOption[EditorOption["autoIndent"] = 8] = "autoIndent";
  35706. EditorOption[EditorOption["automaticLayout"] = 9] = "automaticLayout";
  35707. EditorOption[EditorOption["autoSurround"] = 10] = "autoSurround";
  35708. EditorOption[EditorOption["codeLens"] = 11] = "codeLens";
  35709. EditorOption[EditorOption["colorDecorators"] = 12] = "colorDecorators";
  35710. EditorOption[EditorOption["comments"] = 13] = "comments";
  35711. EditorOption[EditorOption["contextmenu"] = 14] = "contextmenu";
  35712. EditorOption[EditorOption["copyWithSyntaxHighlighting"] = 15] = "copyWithSyntaxHighlighting";
  35713. EditorOption[EditorOption["cursorBlinking"] = 16] = "cursorBlinking";
  35714. EditorOption[EditorOption["cursorSmoothCaretAnimation"] = 17] = "cursorSmoothCaretAnimation";
  35715. EditorOption[EditorOption["cursorStyle"] = 18] = "cursorStyle";
  35716. EditorOption[EditorOption["cursorSurroundingLines"] = 19] = "cursorSurroundingLines";
  35717. EditorOption[EditorOption["cursorSurroundingLinesStyle"] = 20] = "cursorSurroundingLinesStyle";
  35718. EditorOption[EditorOption["cursorWidth"] = 21] = "cursorWidth";
  35719. EditorOption[EditorOption["disableLayerHinting"] = 22] = "disableLayerHinting";
  35720. EditorOption[EditorOption["disableMonospaceOptimizations"] = 23] = "disableMonospaceOptimizations";
  35721. EditorOption[EditorOption["dragAndDrop"] = 24] = "dragAndDrop";
  35722. EditorOption[EditorOption["emptySelectionClipboard"] = 25] = "emptySelectionClipboard";
  35723. EditorOption[EditorOption["extraEditorClassName"] = 26] = "extraEditorClassName";
  35724. EditorOption[EditorOption["fastScrollSensitivity"] = 27] = "fastScrollSensitivity";
  35725. EditorOption[EditorOption["find"] = 28] = "find";
  35726. EditorOption[EditorOption["fixedOverflowWidgets"] = 29] = "fixedOverflowWidgets";
  35727. EditorOption[EditorOption["folding"] = 30] = "folding";
  35728. EditorOption[EditorOption["foldingStrategy"] = 31] = "foldingStrategy";
  35729. EditorOption[EditorOption["foldingHighlight"] = 32] = "foldingHighlight";
  35730. EditorOption[EditorOption["fontFamily"] = 33] = "fontFamily";
  35731. EditorOption[EditorOption["fontInfo"] = 34] = "fontInfo";
  35732. EditorOption[EditorOption["fontLigatures"] = 35] = "fontLigatures";
  35733. EditorOption[EditorOption["fontSize"] = 36] = "fontSize";
  35734. EditorOption[EditorOption["fontWeight"] = 37] = "fontWeight";
  35735. EditorOption[EditorOption["formatOnPaste"] = 38] = "formatOnPaste";
  35736. EditorOption[EditorOption["formatOnType"] = 39] = "formatOnType";
  35737. EditorOption[EditorOption["glyphMargin"] = 40] = "glyphMargin";
  35738. EditorOption[EditorOption["gotoLocation"] = 41] = "gotoLocation";
  35739. EditorOption[EditorOption["hideCursorInOverviewRuler"] = 42] = "hideCursorInOverviewRuler";
  35740. EditorOption[EditorOption["highlightActiveIndentGuide"] = 43] = "highlightActiveIndentGuide";
  35741. EditorOption[EditorOption["hover"] = 44] = "hover";
  35742. EditorOption[EditorOption["inDiffEditor"] = 45] = "inDiffEditor";
  35743. EditorOption[EditorOption["letterSpacing"] = 46] = "letterSpacing";
  35744. EditorOption[EditorOption["lightbulb"] = 47] = "lightbulb";
  35745. EditorOption[EditorOption["lineDecorationsWidth"] = 48] = "lineDecorationsWidth";
  35746. EditorOption[EditorOption["lineHeight"] = 49] = "lineHeight";
  35747. EditorOption[EditorOption["lineNumbers"] = 50] = "lineNumbers";
  35748. EditorOption[EditorOption["lineNumbersMinChars"] = 51] = "lineNumbersMinChars";
  35749. EditorOption[EditorOption["links"] = 52] = "links";
  35750. EditorOption[EditorOption["matchBrackets"] = 53] = "matchBrackets";
  35751. EditorOption[EditorOption["minimap"] = 54] = "minimap";
  35752. EditorOption[EditorOption["mouseStyle"] = 55] = "mouseStyle";
  35753. EditorOption[EditorOption["mouseWheelScrollSensitivity"] = 56] = "mouseWheelScrollSensitivity";
  35754. EditorOption[EditorOption["mouseWheelZoom"] = 57] = "mouseWheelZoom";
  35755. EditorOption[EditorOption["multiCursorMergeOverlapping"] = 58] = "multiCursorMergeOverlapping";
  35756. EditorOption[EditorOption["multiCursorModifier"] = 59] = "multiCursorModifier";
  35757. EditorOption[EditorOption["multiCursorPaste"] = 60] = "multiCursorPaste";
  35758. EditorOption[EditorOption["occurrencesHighlight"] = 61] = "occurrencesHighlight";
  35759. EditorOption[EditorOption["overviewRulerBorder"] = 62] = "overviewRulerBorder";
  35760. EditorOption[EditorOption["overviewRulerLanes"] = 63] = "overviewRulerLanes";
  35761. EditorOption[EditorOption["parameterHints"] = 64] = "parameterHints";
  35762. EditorOption[EditorOption["peekWidgetDefaultFocus"] = 65] = "peekWidgetDefaultFocus";
  35763. EditorOption[EditorOption["quickSuggestions"] = 66] = "quickSuggestions";
  35764. EditorOption[EditorOption["quickSuggestionsDelay"] = 67] = "quickSuggestionsDelay";
  35765. EditorOption[EditorOption["readOnly"] = 68] = "readOnly";
  35766. EditorOption[EditorOption["renderControlCharacters"] = 69] = "renderControlCharacters";
  35767. EditorOption[EditorOption["renderIndentGuides"] = 70] = "renderIndentGuides";
  35768. EditorOption[EditorOption["renderFinalNewline"] = 71] = "renderFinalNewline";
  35769. EditorOption[EditorOption["renderLineHighlight"] = 72] = "renderLineHighlight";
  35770. EditorOption[EditorOption["renderValidationDecorations"] = 73] = "renderValidationDecorations";
  35771. EditorOption[EditorOption["renderWhitespace"] = 74] = "renderWhitespace";
  35772. EditorOption[EditorOption["revealHorizontalRightPadding"] = 75] = "revealHorizontalRightPadding";
  35773. EditorOption[EditorOption["roundedSelection"] = 76] = "roundedSelection";
  35774. EditorOption[EditorOption["rulers"] = 77] = "rulers";
  35775. EditorOption[EditorOption["scrollbar"] = 78] = "scrollbar";
  35776. EditorOption[EditorOption["scrollBeyondLastColumn"] = 79] = "scrollBeyondLastColumn";
  35777. EditorOption[EditorOption["scrollBeyondLastLine"] = 80] = "scrollBeyondLastLine";
  35778. EditorOption[EditorOption["selectionClipboard"] = 81] = "selectionClipboard";
  35779. EditorOption[EditorOption["selectionHighlight"] = 82] = "selectionHighlight";
  35780. EditorOption[EditorOption["selectOnLineNumbers"] = 83] = "selectOnLineNumbers";
  35781. EditorOption[EditorOption["showFoldingControls"] = 84] = "showFoldingControls";
  35782. EditorOption[EditorOption["showUnused"] = 85] = "showUnused";
  35783. EditorOption[EditorOption["snippetSuggestions"] = 86] = "snippetSuggestions";
  35784. EditorOption[EditorOption["smoothScrolling"] = 87] = "smoothScrolling";
  35785. EditorOption[EditorOption["stopRenderingLineAfter"] = 88] = "stopRenderingLineAfter";
  35786. EditorOption[EditorOption["suggest"] = 89] = "suggest";
  35787. EditorOption[EditorOption["suggestFontSize"] = 90] = "suggestFontSize";
  35788. EditorOption[EditorOption["suggestLineHeight"] = 91] = "suggestLineHeight";
  35789. EditorOption[EditorOption["suggestOnTriggerCharacters"] = 92] = "suggestOnTriggerCharacters";
  35790. EditorOption[EditorOption["suggestSelection"] = 93] = "suggestSelection";
  35791. EditorOption[EditorOption["tabCompletion"] = 94] = "tabCompletion";
  35792. EditorOption[EditorOption["useTabStops"] = 95] = "useTabStops";
  35793. EditorOption[EditorOption["wordSeparators"] = 96] = "wordSeparators";
  35794. EditorOption[EditorOption["wordWrap"] = 97] = "wordWrap";
  35795. EditorOption[EditorOption["wordWrapBreakAfterCharacters"] = 98] = "wordWrapBreakAfterCharacters";
  35796. EditorOption[EditorOption["wordWrapBreakBeforeCharacters"] = 99] = "wordWrapBreakBeforeCharacters";
  35797. EditorOption[EditorOption["wordWrapColumn"] = 100] = "wordWrapColumn";
  35798. EditorOption[EditorOption["wordWrapMinified"] = 101] = "wordWrapMinified";
  35799. EditorOption[EditorOption["wrappingIndent"] = 102] = "wrappingIndent";
  35800. EditorOption[EditorOption["wrappingStrategy"] = 103] = "wrappingStrategy";
  35801. EditorOption[EditorOption["editorClassName"] = 104] = "editorClassName";
  35802. EditorOption[EditorOption["pixelRatio"] = 105] = "pixelRatio";
  35803. EditorOption[EditorOption["tabFocusMode"] = 106] = "tabFocusMode";
  35804. EditorOption[EditorOption["layoutInfo"] = 107] = "layoutInfo";
  35805. EditorOption[EditorOption["wrappingInfo"] = 108] = "wrappingInfo";
  35806. })(EditorOption = exports.EditorOption || (exports.EditorOption = {}));
  35807. /**
  35808. * End of line character preference.
  35809. */
  35810. var EndOfLinePreference;
  35811. (function (EndOfLinePreference) {
  35812. /**
  35813. * Use the end of line character identified in the text buffer.
  35814. */
  35815. EndOfLinePreference[EndOfLinePreference["TextDefined"] = 0] = "TextDefined";
  35816. /**
  35817. * Use line feed (\n) as the end of line character.
  35818. */
  35819. EndOfLinePreference[EndOfLinePreference["LF"] = 1] = "LF";
  35820. /**
  35821. * Use carriage return and line feed (\r\n) as the end of line character.
  35822. */
  35823. EndOfLinePreference[EndOfLinePreference["CRLF"] = 2] = "CRLF";
  35824. })(EndOfLinePreference = exports.EndOfLinePreference || (exports.EndOfLinePreference = {}));
  35825. /**
  35826. * End of line character preference.
  35827. */
  35828. var EndOfLineSequence;
  35829. (function (EndOfLineSequence) {
  35830. /**
  35831. * Use line feed (\n) as the end of line character.
  35832. */
  35833. EndOfLineSequence[EndOfLineSequence["LF"] = 0] = "LF";
  35834. /**
  35835. * Use carriage return and line feed (\r\n) as the end of line character.
  35836. */
  35837. EndOfLineSequence[EndOfLineSequence["CRLF"] = 1] = "CRLF";
  35838. })(EndOfLineSequence = exports.EndOfLineSequence || (exports.EndOfLineSequence = {}));
  35839. /**
  35840. * Describes what to do with the indentation when pressing Enter.
  35841. */
  35842. var IndentAction;
  35843. (function (IndentAction) {
  35844. /**
  35845. * Insert new line and copy the previous line's indentation.
  35846. */
  35847. IndentAction[IndentAction["None"] = 0] = "None";
  35848. /**
  35849. * Insert new line and indent once (relative to the previous line's indentation).
  35850. */
  35851. IndentAction[IndentAction["Indent"] = 1] = "Indent";
  35852. /**
  35853. * Insert two new lines:
  35854. * - the first one indented which will hold the cursor
  35855. * - the second one at the same indentation level
  35856. */
  35857. IndentAction[IndentAction["IndentOutdent"] = 2] = "IndentOutdent";
  35858. /**
  35859. * Insert new line and outdent once (relative to the previous line's indentation).
  35860. */
  35861. IndentAction[IndentAction["Outdent"] = 3] = "Outdent";
  35862. })(IndentAction = exports.IndentAction || (exports.IndentAction = {}));
  35863. /**
  35864. * Virtual Key Codes, the value does not hold any inherent meaning.
  35865. * Inspired somewhat from https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
  35866. * But these are "more general", as they should work across browsers & OS`s.
  35867. */
  35868. var KeyCode;
  35869. (function (KeyCode) {
  35870. /**
  35871. * Placed first to cover the 0 value of the enum.
  35872. */
  35873. KeyCode[KeyCode["Unknown"] = 0] = "Unknown";
  35874. KeyCode[KeyCode["Backspace"] = 1] = "Backspace";
  35875. KeyCode[KeyCode["Tab"] = 2] = "Tab";
  35876. KeyCode[KeyCode["Enter"] = 3] = "Enter";
  35877. KeyCode[KeyCode["Shift"] = 4] = "Shift";
  35878. KeyCode[KeyCode["Ctrl"] = 5] = "Ctrl";
  35879. KeyCode[KeyCode["Alt"] = 6] = "Alt";
  35880. KeyCode[KeyCode["PauseBreak"] = 7] = "PauseBreak";
  35881. KeyCode[KeyCode["CapsLock"] = 8] = "CapsLock";
  35882. KeyCode[KeyCode["Escape"] = 9] = "Escape";
  35883. KeyCode[KeyCode["Space"] = 10] = "Space";
  35884. KeyCode[KeyCode["PageUp"] = 11] = "PageUp";
  35885. KeyCode[KeyCode["PageDown"] = 12] = "PageDown";
  35886. KeyCode[KeyCode["End"] = 13] = "End";
  35887. KeyCode[KeyCode["Home"] = 14] = "Home";
  35888. KeyCode[KeyCode["LeftArrow"] = 15] = "LeftArrow";
  35889. KeyCode[KeyCode["UpArrow"] = 16] = "UpArrow";
  35890. KeyCode[KeyCode["RightArrow"] = 17] = "RightArrow";
  35891. KeyCode[KeyCode["DownArrow"] = 18] = "DownArrow";
  35892. KeyCode[KeyCode["Insert"] = 19] = "Insert";
  35893. KeyCode[KeyCode["Delete"] = 20] = "Delete";
  35894. KeyCode[KeyCode["KEY_0"] = 21] = "KEY_0";
  35895. KeyCode[KeyCode["KEY_1"] = 22] = "KEY_1";
  35896. KeyCode[KeyCode["KEY_2"] = 23] = "KEY_2";
  35897. KeyCode[KeyCode["KEY_3"] = 24] = "KEY_3";
  35898. KeyCode[KeyCode["KEY_4"] = 25] = "KEY_4";
  35899. KeyCode[KeyCode["KEY_5"] = 26] = "KEY_5";
  35900. KeyCode[KeyCode["KEY_6"] = 27] = "KEY_6";
  35901. KeyCode[KeyCode["KEY_7"] = 28] = "KEY_7";
  35902. KeyCode[KeyCode["KEY_8"] = 29] = "KEY_8";
  35903. KeyCode[KeyCode["KEY_9"] = 30] = "KEY_9";
  35904. KeyCode[KeyCode["KEY_A"] = 31] = "KEY_A";
  35905. KeyCode[KeyCode["KEY_B"] = 32] = "KEY_B";
  35906. KeyCode[KeyCode["KEY_C"] = 33] = "KEY_C";
  35907. KeyCode[KeyCode["KEY_D"] = 34] = "KEY_D";
  35908. KeyCode[KeyCode["KEY_E"] = 35] = "KEY_E";
  35909. KeyCode[KeyCode["KEY_F"] = 36] = "KEY_F";
  35910. KeyCode[KeyCode["KEY_G"] = 37] = "KEY_G";
  35911. KeyCode[KeyCode["KEY_H"] = 38] = "KEY_H";
  35912. KeyCode[KeyCode["KEY_I"] = 39] = "KEY_I";
  35913. KeyCode[KeyCode["KEY_J"] = 40] = "KEY_J";
  35914. KeyCode[KeyCode["KEY_K"] = 41] = "KEY_K";
  35915. KeyCode[KeyCode["KEY_L"] = 42] = "KEY_L";
  35916. KeyCode[KeyCode["KEY_M"] = 43] = "KEY_M";
  35917. KeyCode[KeyCode["KEY_N"] = 44] = "KEY_N";
  35918. KeyCode[KeyCode["KEY_O"] = 45] = "KEY_O";
  35919. KeyCode[KeyCode["KEY_P"] = 46] = "KEY_P";
  35920. KeyCode[KeyCode["KEY_Q"] = 47] = "KEY_Q";
  35921. KeyCode[KeyCode["KEY_R"] = 48] = "KEY_R";
  35922. KeyCode[KeyCode["KEY_S"] = 49] = "KEY_S";
  35923. KeyCode[KeyCode["KEY_T"] = 50] = "KEY_T";
  35924. KeyCode[KeyCode["KEY_U"] = 51] = "KEY_U";
  35925. KeyCode[KeyCode["KEY_V"] = 52] = "KEY_V";
  35926. KeyCode[KeyCode["KEY_W"] = 53] = "KEY_W";
  35927. KeyCode[KeyCode["KEY_X"] = 54] = "KEY_X";
  35928. KeyCode[KeyCode["KEY_Y"] = 55] = "KEY_Y";
  35929. KeyCode[KeyCode["KEY_Z"] = 56] = "KEY_Z";
  35930. KeyCode[KeyCode["Meta"] = 57] = "Meta";
  35931. KeyCode[KeyCode["ContextMenu"] = 58] = "ContextMenu";
  35932. KeyCode[KeyCode["F1"] = 59] = "F1";
  35933. KeyCode[KeyCode["F2"] = 60] = "F2";
  35934. KeyCode[KeyCode["F3"] = 61] = "F3";
  35935. KeyCode[KeyCode["F4"] = 62] = "F4";
  35936. KeyCode[KeyCode["F5"] = 63] = "F5";
  35937. KeyCode[KeyCode["F6"] = 64] = "F6";
  35938. KeyCode[KeyCode["F7"] = 65] = "F7";
  35939. KeyCode[KeyCode["F8"] = 66] = "F8";
  35940. KeyCode[KeyCode["F9"] = 67] = "F9";
  35941. KeyCode[KeyCode["F10"] = 68] = "F10";
  35942. KeyCode[KeyCode["F11"] = 69] = "F11";
  35943. KeyCode[KeyCode["F12"] = 70] = "F12";
  35944. KeyCode[KeyCode["F13"] = 71] = "F13";
  35945. KeyCode[KeyCode["F14"] = 72] = "F14";
  35946. KeyCode[KeyCode["F15"] = 73] = "F15";
  35947. KeyCode[KeyCode["F16"] = 74] = "F16";
  35948. KeyCode[KeyCode["F17"] = 75] = "F17";
  35949. KeyCode[KeyCode["F18"] = 76] = "F18";
  35950. KeyCode[KeyCode["F19"] = 77] = "F19";
  35951. KeyCode[KeyCode["NumLock"] = 78] = "NumLock";
  35952. KeyCode[KeyCode["ScrollLock"] = 79] = "ScrollLock";
  35953. /**
  35954. * Used for miscellaneous characters; it can vary by keyboard.
  35955. * For the US standard keyboard, the ';:' key
  35956. */
  35957. KeyCode[KeyCode["US_SEMICOLON"] = 80] = "US_SEMICOLON";
  35958. /**
  35959. * For any country/region, the '+' key
  35960. * For the US standard keyboard, the '=+' key
  35961. */
  35962. KeyCode[KeyCode["US_EQUAL"] = 81] = "US_EQUAL";
  35963. /**
  35964. * For any country/region, the ',' key
  35965. * For the US standard keyboard, the ',<' key
  35966. */
  35967. KeyCode[KeyCode["US_COMMA"] = 82] = "US_COMMA";
  35968. /**
  35969. * For any country/region, the '-' key
  35970. * For the US standard keyboard, the '-_' key
  35971. */
  35972. KeyCode[KeyCode["US_MINUS"] = 83] = "US_MINUS";
  35973. /**
  35974. * For any country/region, the '.' key
  35975. * For the US standard keyboard, the '.>' key
  35976. */
  35977. KeyCode[KeyCode["US_DOT"] = 84] = "US_DOT";
  35978. /**
  35979. * Used for miscellaneous characters; it can vary by keyboard.
  35980. * For the US standard keyboard, the '/?' key
  35981. */
  35982. KeyCode[KeyCode["US_SLASH"] = 85] = "US_SLASH";
  35983. /**
  35984. * Used for miscellaneous characters; it can vary by keyboard.
  35985. * For the US standard keyboard, the '`~' key
  35986. */
  35987. KeyCode[KeyCode["US_BACKTICK"] = 86] = "US_BACKTICK";
  35988. /**
  35989. * Used for miscellaneous characters; it can vary by keyboard.
  35990. * For the US standard keyboard, the '[{' key
  35991. */
  35992. KeyCode[KeyCode["US_OPEN_SQUARE_BRACKET"] = 87] = "US_OPEN_SQUARE_BRACKET";
  35993. /**
  35994. * Used for miscellaneous characters; it can vary by keyboard.
  35995. * For the US standard keyboard, the '\|' key
  35996. */
  35997. KeyCode[KeyCode["US_BACKSLASH"] = 88] = "US_BACKSLASH";
  35998. /**
  35999. * Used for miscellaneous characters; it can vary by keyboard.
  36000. * For the US standard keyboard, the ']}' key
  36001. */
  36002. KeyCode[KeyCode["US_CLOSE_SQUARE_BRACKET"] = 89] = "US_CLOSE_SQUARE_BRACKET";
  36003. /**
  36004. * Used for miscellaneous characters; it can vary by keyboard.
  36005. * For the US standard keyboard, the ''"' key
  36006. */
  36007. KeyCode[KeyCode["US_QUOTE"] = 90] = "US_QUOTE";
  36008. /**
  36009. * Used for miscellaneous characters; it can vary by keyboard.
  36010. */
  36011. KeyCode[KeyCode["OEM_8"] = 91] = "OEM_8";
  36012. /**
  36013. * Either the angle bracket key or the backslash key on the RT 102-key keyboard.
  36014. */
  36015. KeyCode[KeyCode["OEM_102"] = 92] = "OEM_102";
  36016. KeyCode[KeyCode["NUMPAD_0"] = 93] = "NUMPAD_0";
  36017. KeyCode[KeyCode["NUMPAD_1"] = 94] = "NUMPAD_1";
  36018. KeyCode[KeyCode["NUMPAD_2"] = 95] = "NUMPAD_2";
  36019. KeyCode[KeyCode["NUMPAD_3"] = 96] = "NUMPAD_3";
  36020. KeyCode[KeyCode["NUMPAD_4"] = 97] = "NUMPAD_4";
  36021. KeyCode[KeyCode["NUMPAD_5"] = 98] = "NUMPAD_5";
  36022. KeyCode[KeyCode["NUMPAD_6"] = 99] = "NUMPAD_6";
  36023. KeyCode[KeyCode["NUMPAD_7"] = 100] = "NUMPAD_7";
  36024. KeyCode[KeyCode["NUMPAD_8"] = 101] = "NUMPAD_8";
  36025. KeyCode[KeyCode["NUMPAD_9"] = 102] = "NUMPAD_9";
  36026. KeyCode[KeyCode["NUMPAD_MULTIPLY"] = 103] = "NUMPAD_MULTIPLY";
  36027. KeyCode[KeyCode["NUMPAD_ADD"] = 104] = "NUMPAD_ADD";
  36028. KeyCode[KeyCode["NUMPAD_SEPARATOR"] = 105] = "NUMPAD_SEPARATOR";
  36029. KeyCode[KeyCode["NUMPAD_SUBTRACT"] = 106] = "NUMPAD_SUBTRACT";
  36030. KeyCode[KeyCode["NUMPAD_DECIMAL"] = 107] = "NUMPAD_DECIMAL";
  36031. KeyCode[KeyCode["NUMPAD_DIVIDE"] = 108] = "NUMPAD_DIVIDE";
  36032. /**
  36033. * Cover all key codes when IME is processing input.
  36034. */
  36035. KeyCode[KeyCode["KEY_IN_COMPOSITION"] = 109] = "KEY_IN_COMPOSITION";
  36036. KeyCode[KeyCode["ABNT_C1"] = 110] = "ABNT_C1";
  36037. KeyCode[KeyCode["ABNT_C2"] = 111] = "ABNT_C2";
  36038. /**
  36039. * Placed last to cover the length of the enum.
  36040. * Please do not depend on this value!
  36041. */
  36042. KeyCode[KeyCode["MAX_VALUE"] = 112] = "MAX_VALUE";
  36043. })(KeyCode = exports.KeyCode || (exports.KeyCode = {}));
  36044. var MarkerSeverity;
  36045. (function (MarkerSeverity) {
  36046. MarkerSeverity[MarkerSeverity["Hint"] = 1] = "Hint";
  36047. MarkerSeverity[MarkerSeverity["Info"] = 2] = "Info";
  36048. MarkerSeverity[MarkerSeverity["Warning"] = 4] = "Warning";
  36049. MarkerSeverity[MarkerSeverity["Error"] = 8] = "Error";
  36050. })(MarkerSeverity = exports.MarkerSeverity || (exports.MarkerSeverity = {}));
  36051. var MarkerTag;
  36052. (function (MarkerTag) {
  36053. MarkerTag[MarkerTag["Unnecessary"] = 1] = "Unnecessary";
  36054. MarkerTag[MarkerTag["Deprecated"] = 2] = "Deprecated";
  36055. })(MarkerTag = exports.MarkerTag || (exports.MarkerTag = {}));
  36056. /**
  36057. * Position in the minimap to render the decoration.
  36058. */
  36059. var MinimapPosition;
  36060. (function (MinimapPosition) {
  36061. MinimapPosition[MinimapPosition["Inline"] = 1] = "Inline";
  36062. MinimapPosition[MinimapPosition["Gutter"] = 2] = "Gutter";
  36063. })(MinimapPosition = exports.MinimapPosition || (exports.MinimapPosition = {}));
  36064. /**
  36065. * Type of hit element with the mouse in the editor.
  36066. */
  36067. var MouseTargetType;
  36068. (function (MouseTargetType) {
  36069. /**
  36070. * Mouse is on top of an unknown element.
  36071. */
  36072. MouseTargetType[MouseTargetType["UNKNOWN"] = 0] = "UNKNOWN";
  36073. /**
  36074. * Mouse is on top of the textarea used for input.
  36075. */
  36076. MouseTargetType[MouseTargetType["TEXTAREA"] = 1] = "TEXTAREA";
  36077. /**
  36078. * Mouse is on top of the glyph margin
  36079. */
  36080. MouseTargetType[MouseTargetType["GUTTER_GLYPH_MARGIN"] = 2] = "GUTTER_GLYPH_MARGIN";
  36081. /**
  36082. * Mouse is on top of the line numbers
  36083. */
  36084. MouseTargetType[MouseTargetType["GUTTER_LINE_NUMBERS"] = 3] = "GUTTER_LINE_NUMBERS";
  36085. /**
  36086. * Mouse is on top of the line decorations
  36087. */
  36088. MouseTargetType[MouseTargetType["GUTTER_LINE_DECORATIONS"] = 4] = "GUTTER_LINE_DECORATIONS";
  36089. /**
  36090. * Mouse is on top of the whitespace left in the gutter by a view zone.
  36091. */
  36092. MouseTargetType[MouseTargetType["GUTTER_VIEW_ZONE"] = 5] = "GUTTER_VIEW_ZONE";
  36093. /**
  36094. * Mouse is on top of text in the content.
  36095. */
  36096. MouseTargetType[MouseTargetType["CONTENT_TEXT"] = 6] = "CONTENT_TEXT";
  36097. /**
  36098. * Mouse is on top of empty space in the content (e.g. after line text or below last line)
  36099. */
  36100. MouseTargetType[MouseTargetType["CONTENT_EMPTY"] = 7] = "CONTENT_EMPTY";
  36101. /**
  36102. * Mouse is on top of a view zone in the content.
  36103. */
  36104. MouseTargetType[MouseTargetType["CONTENT_VIEW_ZONE"] = 8] = "CONTENT_VIEW_ZONE";
  36105. /**
  36106. * Mouse is on top of a content widget.
  36107. */
  36108. MouseTargetType[MouseTargetType["CONTENT_WIDGET"] = 9] = "CONTENT_WIDGET";
  36109. /**
  36110. * Mouse is on top of the decorations overview ruler.
  36111. */
  36112. MouseTargetType[MouseTargetType["OVERVIEW_RULER"] = 10] = "OVERVIEW_RULER";
  36113. /**
  36114. * Mouse is on top of a scrollbar.
  36115. */
  36116. MouseTargetType[MouseTargetType["SCROLLBAR"] = 11] = "SCROLLBAR";
  36117. /**
  36118. * Mouse is on top of an overlay widget.
  36119. */
  36120. MouseTargetType[MouseTargetType["OVERLAY_WIDGET"] = 12] = "OVERLAY_WIDGET";
  36121. /**
  36122. * Mouse is outside of the editor.
  36123. */
  36124. MouseTargetType[MouseTargetType["OUTSIDE_EDITOR"] = 13] = "OUTSIDE_EDITOR";
  36125. })(MouseTargetType = exports.MouseTargetType || (exports.MouseTargetType = {}));
  36126. /**
  36127. * A positioning preference for rendering overlay widgets.
  36128. */
  36129. var OverlayWidgetPositionPreference;
  36130. (function (OverlayWidgetPositionPreference) {
  36131. /**
  36132. * Position the overlay widget in the top right corner
  36133. */
  36134. OverlayWidgetPositionPreference[OverlayWidgetPositionPreference["TOP_RIGHT_CORNER"] = 0] = "TOP_RIGHT_CORNER";
  36135. /**
  36136. * Position the overlay widget in the bottom right corner
  36137. */
  36138. OverlayWidgetPositionPreference[OverlayWidgetPositionPreference["BOTTOM_RIGHT_CORNER"] = 1] = "BOTTOM_RIGHT_CORNER";
  36139. /**
  36140. * Position the overlay widget in the top center
  36141. */
  36142. OverlayWidgetPositionPreference[OverlayWidgetPositionPreference["TOP_CENTER"] = 2] = "TOP_CENTER";
  36143. })(OverlayWidgetPositionPreference = exports.OverlayWidgetPositionPreference || (exports.OverlayWidgetPositionPreference = {}));
  36144. /**
  36145. * Vertical Lane in the overview ruler of the editor.
  36146. */
  36147. var OverviewRulerLane;
  36148. (function (OverviewRulerLane) {
  36149. OverviewRulerLane[OverviewRulerLane["Left"] = 1] = "Left";
  36150. OverviewRulerLane[OverviewRulerLane["Center"] = 2] = "Center";
  36151. OverviewRulerLane[OverviewRulerLane["Right"] = 4] = "Right";
  36152. OverviewRulerLane[OverviewRulerLane["Full"] = 7] = "Full";
  36153. })(OverviewRulerLane = exports.OverviewRulerLane || (exports.OverviewRulerLane = {}));
  36154. var RenderLineNumbersType;
  36155. (function (RenderLineNumbersType) {
  36156. RenderLineNumbersType[RenderLineNumbersType["Off"] = 0] = "Off";
  36157. RenderLineNumbersType[RenderLineNumbersType["On"] = 1] = "On";
  36158. RenderLineNumbersType[RenderLineNumbersType["Relative"] = 2] = "Relative";
  36159. RenderLineNumbersType[RenderLineNumbersType["Interval"] = 3] = "Interval";
  36160. RenderLineNumbersType[RenderLineNumbersType["Custom"] = 4] = "Custom";
  36161. })(RenderLineNumbersType = exports.RenderLineNumbersType || (exports.RenderLineNumbersType = {}));
  36162. var RenderMinimap;
  36163. (function (RenderMinimap) {
  36164. RenderMinimap[RenderMinimap["None"] = 0] = "None";
  36165. RenderMinimap[RenderMinimap["Text"] = 1] = "Text";
  36166. RenderMinimap[RenderMinimap["Blocks"] = 2] = "Blocks";
  36167. })(RenderMinimap = exports.RenderMinimap || (exports.RenderMinimap = {}));
  36168. var ScrollType;
  36169. (function (ScrollType) {
  36170. ScrollType[ScrollType["Smooth"] = 0] = "Smooth";
  36171. ScrollType[ScrollType["Immediate"] = 1] = "Immediate";
  36172. })(ScrollType = exports.ScrollType || (exports.ScrollType = {}));
  36173. var ScrollbarVisibility;
  36174. (function (ScrollbarVisibility) {
  36175. ScrollbarVisibility[ScrollbarVisibility["Auto"] = 1] = "Auto";
  36176. ScrollbarVisibility[ScrollbarVisibility["Hidden"] = 2] = "Hidden";
  36177. ScrollbarVisibility[ScrollbarVisibility["Visible"] = 3] = "Visible";
  36178. })(ScrollbarVisibility = exports.ScrollbarVisibility || (exports.ScrollbarVisibility = {}));
  36179. /**
  36180. * The direction of a selection.
  36181. */
  36182. var SelectionDirection;
  36183. (function (SelectionDirection) {
  36184. /**
  36185. * The selection starts above where it ends.
  36186. */
  36187. SelectionDirection[SelectionDirection["LTR"] = 0] = "LTR";
  36188. /**
  36189. * The selection starts below where it ends.
  36190. */
  36191. SelectionDirection[SelectionDirection["RTL"] = 1] = "RTL";
  36192. })(SelectionDirection = exports.SelectionDirection || (exports.SelectionDirection = {}));
  36193. var SignatureHelpTriggerKind;
  36194. (function (SignatureHelpTriggerKind) {
  36195. SignatureHelpTriggerKind[SignatureHelpTriggerKind["Invoke"] = 1] = "Invoke";
  36196. SignatureHelpTriggerKind[SignatureHelpTriggerKind["TriggerCharacter"] = 2] = "TriggerCharacter";
  36197. SignatureHelpTriggerKind[SignatureHelpTriggerKind["ContentChange"] = 3] = "ContentChange";
  36198. })(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
  36199. /**
  36200. * A symbol kind.
  36201. */
  36202. var SymbolKind;
  36203. (function (SymbolKind) {
  36204. SymbolKind[SymbolKind["File"] = 0] = "File";
  36205. SymbolKind[SymbolKind["Module"] = 1] = "Module";
  36206. SymbolKind[SymbolKind["Namespace"] = 2] = "Namespace";
  36207. SymbolKind[SymbolKind["Package"] = 3] = "Package";
  36208. SymbolKind[SymbolKind["Class"] = 4] = "Class";
  36209. SymbolKind[SymbolKind["Method"] = 5] = "Method";
  36210. SymbolKind[SymbolKind["Property"] = 6] = "Property";
  36211. SymbolKind[SymbolKind["Field"] = 7] = "Field";
  36212. SymbolKind[SymbolKind["Constructor"] = 8] = "Constructor";
  36213. SymbolKind[SymbolKind["Enum"] = 9] = "Enum";
  36214. SymbolKind[SymbolKind["Interface"] = 10] = "Interface";
  36215. SymbolKind[SymbolKind["Function"] = 11] = "Function";
  36216. SymbolKind[SymbolKind["Variable"] = 12] = "Variable";
  36217. SymbolKind[SymbolKind["Constant"] = 13] = "Constant";
  36218. SymbolKind[SymbolKind["String"] = 14] = "String";
  36219. SymbolKind[SymbolKind["Number"] = 15] = "Number";
  36220. SymbolKind[SymbolKind["Boolean"] = 16] = "Boolean";
  36221. SymbolKind[SymbolKind["Array"] = 17] = "Array";
  36222. SymbolKind[SymbolKind["Object"] = 18] = "Object";
  36223. SymbolKind[SymbolKind["Key"] = 19] = "Key";
  36224. SymbolKind[SymbolKind["Null"] = 20] = "Null";
  36225. SymbolKind[SymbolKind["EnumMember"] = 21] = "EnumMember";
  36226. SymbolKind[SymbolKind["Struct"] = 22] = "Struct";
  36227. SymbolKind[SymbolKind["Event"] = 23] = "Event";
  36228. SymbolKind[SymbolKind["Operator"] = 24] = "Operator";
  36229. SymbolKind[SymbolKind["TypeParameter"] = 25] = "TypeParameter";
  36230. })(SymbolKind = exports.SymbolKind || (exports.SymbolKind = {}));
  36231. var SymbolTag;
  36232. (function (SymbolTag) {
  36233. SymbolTag[SymbolTag["Deprecated"] = 1] = "Deprecated";
  36234. })(SymbolTag = exports.SymbolTag || (exports.SymbolTag = {}));
  36235. /**
  36236. * The kind of animation in which the editor's cursor should be rendered.
  36237. */
  36238. var TextEditorCursorBlinkingStyle;
  36239. (function (TextEditorCursorBlinkingStyle) {
  36240. /**
  36241. * Hidden
  36242. */
  36243. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Hidden"] = 0] = "Hidden";
  36244. /**
  36245. * Blinking
  36246. */
  36247. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Blink"] = 1] = "Blink";
  36248. /**
  36249. * Blinking with smooth fading
  36250. */
  36251. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Smooth"] = 2] = "Smooth";
  36252. /**
  36253. * Blinking with prolonged filled state and smooth fading
  36254. */
  36255. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Phase"] = 3] = "Phase";
  36256. /**
  36257. * Expand collapse animation on the y axis
  36258. */
  36259. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Expand"] = 4] = "Expand";
  36260. /**
  36261. * No-Blinking
  36262. */
  36263. TextEditorCursorBlinkingStyle[TextEditorCursorBlinkingStyle["Solid"] = 5] = "Solid";
  36264. })(TextEditorCursorBlinkingStyle = exports.TextEditorCursorBlinkingStyle || (exports.TextEditorCursorBlinkingStyle = {}));
  36265. /**
  36266. * The style in which the editor's cursor should be rendered.
  36267. */
  36268. var TextEditorCursorStyle;
  36269. (function (TextEditorCursorStyle) {
  36270. /**
  36271. * As a vertical line (sitting between two characters).
  36272. */
  36273. TextEditorCursorStyle[TextEditorCursorStyle["Line"] = 1] = "Line";
  36274. /**
  36275. * As a block (sitting on top of a character).
  36276. */
  36277. TextEditorCursorStyle[TextEditorCursorStyle["Block"] = 2] = "Block";
  36278. /**
  36279. * As a horizontal line (sitting under a character).
  36280. */
  36281. TextEditorCursorStyle[TextEditorCursorStyle["Underline"] = 3] = "Underline";
  36282. /**
  36283. * As a thin vertical line (sitting between two characters).
  36284. */
  36285. TextEditorCursorStyle[TextEditorCursorStyle["LineThin"] = 4] = "LineThin";
  36286. /**
  36287. * As an outlined block (sitting on top of a character).
  36288. */
  36289. TextEditorCursorStyle[TextEditorCursorStyle["BlockOutline"] = 5] = "BlockOutline";
  36290. /**
  36291. * As a thin horizontal line (sitting under a character).
  36292. */
  36293. TextEditorCursorStyle[TextEditorCursorStyle["UnderlineThin"] = 6] = "UnderlineThin";
  36294. })(TextEditorCursorStyle = exports.TextEditorCursorStyle || (exports.TextEditorCursorStyle = {}));
  36295. /**
  36296. * Describes the behavior of decorations when typing/editing near their edges.
  36297. * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior`
  36298. */
  36299. var TrackedRangeStickiness;
  36300. (function (TrackedRangeStickiness) {
  36301. TrackedRangeStickiness[TrackedRangeStickiness["AlwaysGrowsWhenTypingAtEdges"] = 0] = "AlwaysGrowsWhenTypingAtEdges";
  36302. TrackedRangeStickiness[TrackedRangeStickiness["NeverGrowsWhenTypingAtEdges"] = 1] = "NeverGrowsWhenTypingAtEdges";
  36303. TrackedRangeStickiness[TrackedRangeStickiness["GrowsOnlyWhenTypingBefore"] = 2] = "GrowsOnlyWhenTypingBefore";
  36304. TrackedRangeStickiness[TrackedRangeStickiness["GrowsOnlyWhenTypingAfter"] = 3] = "GrowsOnlyWhenTypingAfter";
  36305. })(TrackedRangeStickiness = exports.TrackedRangeStickiness || (exports.TrackedRangeStickiness = {}));
  36306. /**
  36307. * Describes how to indent wrapped lines.
  36308. */
  36309. var WrappingIndent;
  36310. (function (WrappingIndent) {
  36311. /**
  36312. * No indentation => wrapped lines begin at column 1.
  36313. */
  36314. WrappingIndent[WrappingIndent["None"] = 0] = "None";
  36315. /**
  36316. * Same => wrapped lines get the same indentation as the parent.
  36317. */
  36318. WrappingIndent[WrappingIndent["Same"] = 1] = "Same";
  36319. /**
  36320. * Indent => wrapped lines get +1 indentation toward the parent.
  36321. */
  36322. WrappingIndent[WrappingIndent["Indent"] = 2] = "Indent";
  36323. /**
  36324. * DeepIndent => wrapped lines get +2 indentation toward the parent.
  36325. */
  36326. WrappingIndent[WrappingIndent["DeepIndent"] = 3] = "DeepIndent";
  36327. })(WrappingIndent = exports.WrappingIndent || (exports.WrappingIndent = {}));
  36328. });
  36329. /*---------------------------------------------------------------------------------------------
  36330. * Copyright (c) Microsoft Corporation. All rights reserved.
  36331. * Licensed under the MIT License. See License.txt in the project root for license information.
  36332. *--------------------------------------------------------------------------------------------*/
  36333. define(__m[192/*vs/editor/common/standalone/standaloneBase*/], __M([0/*require*/,1/*exports*/,26/*vs/base/common/cancellation*/,4/*vs/base/common/event*/,36/*vs/base/common/keyCodes*/,25/*vs/base/common/uri*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,107/*vs/editor/common/core/token*/,147/*vs/editor/common/standalone/standaloneEnums*/,614/*vs/editor/common/standalone/promise-polyfill/polyfill*/]), function (require, exports, cancellation_1, event_1, keyCodes_1, uri_1, position_1, range_1, selection_1, token_1, standaloneEnums) {
  36334. "use strict";
  36335. Object.defineProperty(exports, "__esModule", { value: true });
  36336. var KeyMod = /** @class */ (function () {
  36337. function KeyMod() {
  36338. }
  36339. KeyMod.chord = function (firstPart, secondPart) {
  36340. return keyCodes_1.KeyChord(firstPart, secondPart);
  36341. };
  36342. KeyMod.CtrlCmd = 2048 /* CtrlCmd */;
  36343. KeyMod.Shift = 1024 /* Shift */;
  36344. KeyMod.Alt = 512 /* Alt */;
  36345. KeyMod.WinCtrl = 256 /* WinCtrl */;
  36346. return KeyMod;
  36347. }());
  36348. exports.KeyMod = KeyMod;
  36349. function createMonacoBaseAPI() {
  36350. return {
  36351. editor: undefined,
  36352. languages: undefined,
  36353. CancellationTokenSource: cancellation_1.CancellationTokenSource,
  36354. Emitter: event_1.Emitter,
  36355. KeyCode: standaloneEnums.KeyCode,
  36356. KeyMod: KeyMod,
  36357. Position: position_1.Position,
  36358. Range: range_1.Range,
  36359. Selection: selection_1.Selection,
  36360. SelectionDirection: standaloneEnums.SelectionDirection,
  36361. MarkerSeverity: standaloneEnums.MarkerSeverity,
  36362. MarkerTag: standaloneEnums.MarkerTag,
  36363. Uri: uri_1.URI,
  36364. Token: token_1.Token
  36365. };
  36366. }
  36367. exports.createMonacoBaseAPI = createMonacoBaseAPI;
  36368. });
  36369. /*---------------------------------------------------------------------------------------------
  36370. * Copyright (c) Microsoft Corporation. All rights reserved.
  36371. * Licensed under the MIT License. See License.txt in the project root for license information.
  36372. *--------------------------------------------------------------------------------------------*/
  36373. define(__m[193/*vs/editor/common/view/overviewZoneManager*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  36374. "use strict";
  36375. Object.defineProperty(exports, "__esModule", { value: true });
  36376. var ColorZone = /** @class */ (function () {
  36377. function ColorZone(from, to, colorId) {
  36378. this.from = from | 0;
  36379. this.to = to | 0;
  36380. this.colorId = colorId | 0;
  36381. }
  36382. ColorZone.compare = function (a, b) {
  36383. if (a.colorId === b.colorId) {
  36384. if (a.from === b.from) {
  36385. return a.to - b.to;
  36386. }
  36387. return a.from - b.from;
  36388. }
  36389. return a.colorId - b.colorId;
  36390. };
  36391. return ColorZone;
  36392. }());
  36393. exports.ColorZone = ColorZone;
  36394. /**
  36395. * A zone in the overview ruler
  36396. */
  36397. var OverviewRulerZone = /** @class */ (function () {
  36398. function OverviewRulerZone(startLineNumber, endLineNumber, color) {
  36399. this.startLineNumber = startLineNumber;
  36400. this.endLineNumber = endLineNumber;
  36401. this.color = color;
  36402. this._colorZone = null;
  36403. }
  36404. OverviewRulerZone.compare = function (a, b) {
  36405. if (a.color === b.color) {
  36406. if (a.startLineNumber === b.startLineNumber) {
  36407. return a.endLineNumber - b.endLineNumber;
  36408. }
  36409. return a.startLineNumber - b.startLineNumber;
  36410. }
  36411. return a.color < b.color ? -1 : 1;
  36412. };
  36413. OverviewRulerZone.prototype.setColorZone = function (colorZone) {
  36414. this._colorZone = colorZone;
  36415. };
  36416. OverviewRulerZone.prototype.getColorZones = function () {
  36417. return this._colorZone;
  36418. };
  36419. return OverviewRulerZone;
  36420. }());
  36421. exports.OverviewRulerZone = OverviewRulerZone;
  36422. var OverviewZoneManager = /** @class */ (function () {
  36423. function OverviewZoneManager(getVerticalOffsetForLine) {
  36424. this._getVerticalOffsetForLine = getVerticalOffsetForLine;
  36425. this._zones = [];
  36426. this._colorZonesInvalid = false;
  36427. this._lineHeight = 0;
  36428. this._domWidth = 0;
  36429. this._domHeight = 0;
  36430. this._outerHeight = 0;
  36431. this._pixelRatio = 1;
  36432. this._lastAssignedId = 0;
  36433. this._color2Id = Object.create(null);
  36434. this._id2Color = [];
  36435. }
  36436. OverviewZoneManager.prototype.getId2Color = function () {
  36437. return this._id2Color;
  36438. };
  36439. OverviewZoneManager.prototype.setZones = function (newZones) {
  36440. this._zones = newZones;
  36441. this._zones.sort(OverviewRulerZone.compare);
  36442. };
  36443. OverviewZoneManager.prototype.setLineHeight = function (lineHeight) {
  36444. if (this._lineHeight === lineHeight) {
  36445. return false;
  36446. }
  36447. this._lineHeight = lineHeight;
  36448. this._colorZonesInvalid = true;
  36449. return true;
  36450. };
  36451. OverviewZoneManager.prototype.setPixelRatio = function (pixelRatio) {
  36452. this._pixelRatio = pixelRatio;
  36453. this._colorZonesInvalid = true;
  36454. };
  36455. OverviewZoneManager.prototype.getDOMWidth = function () {
  36456. return this._domWidth;
  36457. };
  36458. OverviewZoneManager.prototype.getCanvasWidth = function () {
  36459. return this._domWidth * this._pixelRatio;
  36460. };
  36461. OverviewZoneManager.prototype.setDOMWidth = function (width) {
  36462. if (this._domWidth === width) {
  36463. return false;
  36464. }
  36465. this._domWidth = width;
  36466. this._colorZonesInvalid = true;
  36467. return true;
  36468. };
  36469. OverviewZoneManager.prototype.getDOMHeight = function () {
  36470. return this._domHeight;
  36471. };
  36472. OverviewZoneManager.prototype.getCanvasHeight = function () {
  36473. return this._domHeight * this._pixelRatio;
  36474. };
  36475. OverviewZoneManager.prototype.setDOMHeight = function (height) {
  36476. if (this._domHeight === height) {
  36477. return false;
  36478. }
  36479. this._domHeight = height;
  36480. this._colorZonesInvalid = true;
  36481. return true;
  36482. };
  36483. OverviewZoneManager.prototype.getOuterHeight = function () {
  36484. return this._outerHeight;
  36485. };
  36486. OverviewZoneManager.prototype.setOuterHeight = function (outerHeight) {
  36487. if (this._outerHeight === outerHeight) {
  36488. return false;
  36489. }
  36490. this._outerHeight = outerHeight;
  36491. this._colorZonesInvalid = true;
  36492. return true;
  36493. };
  36494. OverviewZoneManager.prototype.resolveColorZones = function () {
  36495. var colorZonesInvalid = this._colorZonesInvalid;
  36496. var lineHeight = Math.floor(this._lineHeight); // @perf
  36497. var totalHeight = Math.floor(this.getCanvasHeight()); // @perf
  36498. var outerHeight = Math.floor(this._outerHeight); // @perf
  36499. var heightRatio = totalHeight / outerHeight;
  36500. var halfMinimumHeight = Math.floor(4 /* MINIMUM_HEIGHT */ * this._pixelRatio / 2);
  36501. var allColorZones = [];
  36502. for (var i = 0, len = this._zones.length; i < len; i++) {
  36503. var zone = this._zones[i];
  36504. if (!colorZonesInvalid) {
  36505. var colorZone_1 = zone.getColorZones();
  36506. if (colorZone_1) {
  36507. allColorZones.push(colorZone_1);
  36508. continue;
  36509. }
  36510. }
  36511. var y1 = Math.floor(heightRatio * (this._getVerticalOffsetForLine(zone.startLineNumber)));
  36512. var y2 = Math.floor(heightRatio * (this._getVerticalOffsetForLine(zone.endLineNumber) + lineHeight));
  36513. var ycenter = Math.floor((y1 + y2) / 2);
  36514. var halfHeight = (y2 - ycenter);
  36515. if (halfHeight < halfMinimumHeight) {
  36516. halfHeight = halfMinimumHeight;
  36517. }
  36518. if (ycenter - halfHeight < 0) {
  36519. ycenter = halfHeight;
  36520. }
  36521. if (ycenter + halfHeight > totalHeight) {
  36522. ycenter = totalHeight - halfHeight;
  36523. }
  36524. var color = zone.color;
  36525. var colorId = this._color2Id[color];
  36526. if (!colorId) {
  36527. colorId = (++this._lastAssignedId);
  36528. this._color2Id[color] = colorId;
  36529. this._id2Color[colorId] = color;
  36530. }
  36531. var colorZone = new ColorZone(ycenter - halfHeight, ycenter + halfHeight, colorId);
  36532. zone.setColorZone(colorZone);
  36533. allColorZones.push(colorZone);
  36534. }
  36535. this._colorZonesInvalid = false;
  36536. allColorZones.sort(ColorZone.compare);
  36537. return allColorZones;
  36538. };
  36539. return OverviewZoneManager;
  36540. }());
  36541. exports.OverviewZoneManager = OverviewZoneManager;
  36542. });
  36543. /*---------------------------------------------------------------------------------------------
  36544. * Copyright (c) Microsoft Corporation. All rights reserved.
  36545. * Licensed under the MIT License. See License.txt in the project root for license information.
  36546. *--------------------------------------------------------------------------------------------*/
  36547. define(__m[91/*vs/editor/common/view/renderingContext*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  36548. "use strict";
  36549. Object.defineProperty(exports, "__esModule", { value: true });
  36550. var RestrictedRenderingContext = /** @class */ (function () {
  36551. function RestrictedRenderingContext(viewLayout, viewportData) {
  36552. this._viewLayout = viewLayout;
  36553. this.viewportData = viewportData;
  36554. this.scrollWidth = this._viewLayout.getScrollWidth();
  36555. this.scrollHeight = this._viewLayout.getScrollHeight();
  36556. this.visibleRange = this.viewportData.visibleRange;
  36557. this.bigNumbersDelta = this.viewportData.bigNumbersDelta;
  36558. var vInfo = this._viewLayout.getCurrentViewport();
  36559. this.scrollTop = vInfo.top;
  36560. this.scrollLeft = vInfo.left;
  36561. this.viewportWidth = vInfo.width;
  36562. this.viewportHeight = vInfo.height;
  36563. }
  36564. RestrictedRenderingContext.prototype.getScrolledTopFromAbsoluteTop = function (absoluteTop) {
  36565. return absoluteTop - this.scrollTop;
  36566. };
  36567. RestrictedRenderingContext.prototype.getVerticalOffsetForLineNumber = function (lineNumber) {
  36568. return this._viewLayout.getVerticalOffsetForLineNumber(lineNumber);
  36569. };
  36570. RestrictedRenderingContext.prototype.getDecorationsInViewport = function () {
  36571. return this.viewportData.getDecorationsInViewport();
  36572. };
  36573. return RestrictedRenderingContext;
  36574. }());
  36575. exports.RestrictedRenderingContext = RestrictedRenderingContext;
  36576. var RenderingContext = /** @class */ (function (_super) {
  36577. __extends(RenderingContext, _super);
  36578. function RenderingContext(viewLayout, viewportData, viewLines) {
  36579. var _this = _super.call(this, viewLayout, viewportData) || this;
  36580. _this._viewLines = viewLines;
  36581. return _this;
  36582. }
  36583. RenderingContext.prototype.linesVisibleRangesForRange = function (range, includeNewLines) {
  36584. return this._viewLines.linesVisibleRangesForRange(range, includeNewLines);
  36585. };
  36586. RenderingContext.prototype.visibleRangeForPosition = function (position) {
  36587. return this._viewLines.visibleRangeForPosition(position);
  36588. };
  36589. return RenderingContext;
  36590. }(RestrictedRenderingContext));
  36591. exports.RenderingContext = RenderingContext;
  36592. var LineVisibleRanges = /** @class */ (function () {
  36593. function LineVisibleRanges(outsideRenderedLine, lineNumber, ranges) {
  36594. this.outsideRenderedLine = outsideRenderedLine;
  36595. this.lineNumber = lineNumber;
  36596. this.ranges = ranges;
  36597. }
  36598. return LineVisibleRanges;
  36599. }());
  36600. exports.LineVisibleRanges = LineVisibleRanges;
  36601. var HorizontalRange = /** @class */ (function () {
  36602. function HorizontalRange(left, width) {
  36603. this.left = Math.round(left);
  36604. this.width = Math.round(width);
  36605. }
  36606. HorizontalRange.prototype.toString = function () {
  36607. return "[" + this.left + "," + this.width + "]";
  36608. };
  36609. return HorizontalRange;
  36610. }());
  36611. exports.HorizontalRange = HorizontalRange;
  36612. var HorizontalPosition = /** @class */ (function () {
  36613. function HorizontalPosition(outsideRenderedLine, left) {
  36614. this.outsideRenderedLine = outsideRenderedLine;
  36615. this.left = Math.round(left);
  36616. }
  36617. return HorizontalPosition;
  36618. }());
  36619. exports.HorizontalPosition = HorizontalPosition;
  36620. var VisibleRanges = /** @class */ (function () {
  36621. function VisibleRanges(outsideRenderedLine, ranges) {
  36622. this.outsideRenderedLine = outsideRenderedLine;
  36623. this.ranges = ranges;
  36624. }
  36625. return VisibleRanges;
  36626. }());
  36627. exports.VisibleRanges = VisibleRanges;
  36628. });
  36629. /*---------------------------------------------------------------------------------------------
  36630. * Copyright (c) Microsoft Corporation. All rights reserved.
  36631. * Licensed under the MIT License. See License.txt in the project root for license information.
  36632. *--------------------------------------------------------------------------------------------*/
  36633. define(__m[359/*vs/editor/browser/viewParts/lines/rangeUtil*/], __M([0/*require*/,1/*exports*/,91/*vs/editor/common/view/renderingContext*/]), function (require, exports, renderingContext_1) {
  36634. "use strict";
  36635. Object.defineProperty(exports, "__esModule", { value: true });
  36636. var FloatHorizontalRange = /** @class */ (function () {
  36637. function FloatHorizontalRange(left, width) {
  36638. this.left = left;
  36639. this.width = width;
  36640. }
  36641. FloatHorizontalRange.prototype.toString = function () {
  36642. return "[" + this.left + "," + this.width + "]";
  36643. };
  36644. FloatHorizontalRange.compare = function (a, b) {
  36645. return a.left - b.left;
  36646. };
  36647. return FloatHorizontalRange;
  36648. }());
  36649. var RangeUtil = /** @class */ (function () {
  36650. function RangeUtil() {
  36651. }
  36652. RangeUtil._createRange = function () {
  36653. if (!this._handyReadyRange) {
  36654. this._handyReadyRange = document.createRange();
  36655. }
  36656. return this._handyReadyRange;
  36657. };
  36658. RangeUtil._detachRange = function (range, endNode) {
  36659. // Move range out of the span node, IE doesn't like having many ranges in
  36660. // the same spot and will act badly for lines containing dashes ('-')
  36661. range.selectNodeContents(endNode);
  36662. };
  36663. RangeUtil._readClientRects = function (startElement, startOffset, endElement, endOffset, endNode) {
  36664. var range = this._createRange();
  36665. try {
  36666. range.setStart(startElement, startOffset);
  36667. range.setEnd(endElement, endOffset);
  36668. return range.getClientRects();
  36669. }
  36670. catch (e) {
  36671. // This is life ...
  36672. return null;
  36673. }
  36674. finally {
  36675. this._detachRange(range, endNode);
  36676. }
  36677. };
  36678. RangeUtil._mergeAdjacentRanges = function (ranges) {
  36679. if (ranges.length === 1) {
  36680. // There is nothing to merge
  36681. return [new renderingContext_1.HorizontalRange(ranges[0].left, ranges[0].width)];
  36682. }
  36683. ranges.sort(FloatHorizontalRange.compare);
  36684. var result = [], resultLen = 0;
  36685. var prevLeft = ranges[0].left;
  36686. var prevWidth = ranges[0].width;
  36687. for (var i = 1, len = ranges.length; i < len; i++) {
  36688. var range = ranges[i];
  36689. var myLeft = range.left;
  36690. var myWidth = range.width;
  36691. if (prevLeft + prevWidth + 0.9 /* account for browser's rounding errors*/ >= myLeft) {
  36692. prevWidth = Math.max(prevWidth, myLeft + myWidth - prevLeft);
  36693. }
  36694. else {
  36695. result[resultLen++] = new renderingContext_1.HorizontalRange(prevLeft, prevWidth);
  36696. prevLeft = myLeft;
  36697. prevWidth = myWidth;
  36698. }
  36699. }
  36700. result[resultLen++] = new renderingContext_1.HorizontalRange(prevLeft, prevWidth);
  36701. return result;
  36702. };
  36703. RangeUtil._createHorizontalRangesFromClientRects = function (clientRects, clientRectDeltaLeft) {
  36704. if (!clientRects || clientRects.length === 0) {
  36705. return null;
  36706. }
  36707. // We go through FloatHorizontalRange because it has been observed in bi-di text
  36708. // that the clientRects are not coming in sorted from the browser
  36709. var result = [];
  36710. for (var i = 0, len = clientRects.length; i < len; i++) {
  36711. var clientRect = clientRects[i];
  36712. result[i] = new FloatHorizontalRange(Math.max(0, clientRect.left - clientRectDeltaLeft), clientRect.width);
  36713. }
  36714. return this._mergeAdjacentRanges(result);
  36715. };
  36716. RangeUtil.readHorizontalRanges = function (domNode, startChildIndex, startOffset, endChildIndex, endOffset, clientRectDeltaLeft, endNode) {
  36717. // Panic check
  36718. var min = 0;
  36719. var max = domNode.children.length - 1;
  36720. if (min > max) {
  36721. return null;
  36722. }
  36723. startChildIndex = Math.min(max, Math.max(min, startChildIndex));
  36724. endChildIndex = Math.min(max, Math.max(min, endChildIndex));
  36725. // If crossing over to a span only to select offset 0, then use the previous span's maximum offset
  36726. // Chrome is buggy and doesn't handle 0 offsets well sometimes.
  36727. if (startChildIndex !== endChildIndex) {
  36728. if (endChildIndex > 0 && endOffset === 0) {
  36729. endChildIndex--;
  36730. endOffset = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  36731. }
  36732. }
  36733. var startElement = domNode.children[startChildIndex].firstChild;
  36734. var endElement = domNode.children[endChildIndex].firstChild;
  36735. if (!startElement || !endElement) {
  36736. // When having an empty <span> (without any text content), try to move to the previous <span>
  36737. if (!startElement && startOffset === 0 && startChildIndex > 0) {
  36738. startElement = domNode.children[startChildIndex - 1].firstChild;
  36739. startOffset = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  36740. }
  36741. if (!endElement && endOffset === 0 && endChildIndex > 0) {
  36742. endElement = domNode.children[endChildIndex - 1].firstChild;
  36743. endOffset = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  36744. }
  36745. }
  36746. if (!startElement || !endElement) {
  36747. return null;
  36748. }
  36749. startOffset = Math.min(startElement.textContent.length, Math.max(0, startOffset));
  36750. endOffset = Math.min(endElement.textContent.length, Math.max(0, endOffset));
  36751. var clientRects = this._readClientRects(startElement, startOffset, endElement, endOffset, endNode);
  36752. return this._createHorizontalRangesFromClientRects(clientRects, clientRectDeltaLeft);
  36753. };
  36754. return RangeUtil;
  36755. }());
  36756. exports.RangeUtil = RangeUtil;
  36757. });
  36758. /*---------------------------------------------------------------------------------------------
  36759. * Copyright (c) Microsoft Corporation. All rights reserved.
  36760. * Licensed under the MIT License. See License.txt in the project root for license information.
  36761. *--------------------------------------------------------------------------------------------*/
  36762. define(__m[360/*vs/editor/common/view/viewContext*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  36763. "use strict";
  36764. Object.defineProperty(exports, "__esModule", { value: true });
  36765. var ViewContext = /** @class */ (function () {
  36766. function ViewContext(configuration, theme, model, privateViewEventBus) {
  36767. this.configuration = configuration;
  36768. this.theme = theme;
  36769. this.model = model;
  36770. this.viewLayout = model.viewLayout;
  36771. this.privateViewEventBus = privateViewEventBus;
  36772. }
  36773. ViewContext.prototype.addEventHandler = function (eventHandler) {
  36774. this.privateViewEventBus.addEventHandler(eventHandler);
  36775. };
  36776. ViewContext.prototype.removeEventHandler = function (eventHandler) {
  36777. this.privateViewEventBus.removeEventHandler(eventHandler);
  36778. };
  36779. return ViewContext;
  36780. }());
  36781. exports.ViewContext = ViewContext;
  36782. });
  36783. /*---------------------------------------------------------------------------------------------
  36784. * Copyright (c) Microsoft Corporation. All rights reserved.
  36785. * Licensed under the MIT License. See License.txt in the project root for license information.
  36786. *--------------------------------------------------------------------------------------------*/
  36787. define(__m[361/*vs/editor/common/view/viewEventDispatcher*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  36788. "use strict";
  36789. Object.defineProperty(exports, "__esModule", { value: true });
  36790. var ViewEventDispatcher = /** @class */ (function () {
  36791. function ViewEventDispatcher(eventHandlerGateKeeper) {
  36792. this._eventHandlerGateKeeper = eventHandlerGateKeeper;
  36793. this._eventHandlers = [];
  36794. this._eventQueue = null;
  36795. this._isConsumingQueue = false;
  36796. }
  36797. ViewEventDispatcher.prototype.addEventHandler = function (eventHandler) {
  36798. for (var i = 0, len = this._eventHandlers.length; i < len; i++) {
  36799. if (this._eventHandlers[i] === eventHandler) {
  36800. console.warn('Detected duplicate listener in ViewEventDispatcher', eventHandler);
  36801. }
  36802. }
  36803. this._eventHandlers.push(eventHandler);
  36804. };
  36805. ViewEventDispatcher.prototype.removeEventHandler = function (eventHandler) {
  36806. for (var i = 0; i < this._eventHandlers.length; i++) {
  36807. if (this._eventHandlers[i] === eventHandler) {
  36808. this._eventHandlers.splice(i, 1);
  36809. break;
  36810. }
  36811. }
  36812. };
  36813. ViewEventDispatcher.prototype.emit = function (event) {
  36814. if (this._eventQueue) {
  36815. this._eventQueue.push(event);
  36816. }
  36817. else {
  36818. this._eventQueue = [event];
  36819. }
  36820. if (!this._isConsumingQueue) {
  36821. this.consumeQueue();
  36822. }
  36823. };
  36824. ViewEventDispatcher.prototype.emitMany = function (events) {
  36825. if (this._eventQueue) {
  36826. this._eventQueue = this._eventQueue.concat(events);
  36827. }
  36828. else {
  36829. this._eventQueue = events;
  36830. }
  36831. if (!this._isConsumingQueue) {
  36832. this.consumeQueue();
  36833. }
  36834. };
  36835. ViewEventDispatcher.prototype.consumeQueue = function () {
  36836. var _this = this;
  36837. this._eventHandlerGateKeeper(function () {
  36838. try {
  36839. _this._isConsumingQueue = true;
  36840. _this._doConsumeQueue();
  36841. }
  36842. finally {
  36843. _this._isConsumingQueue = false;
  36844. }
  36845. });
  36846. };
  36847. ViewEventDispatcher.prototype._doConsumeQueue = function () {
  36848. while (this._eventQueue) {
  36849. // Empty event queue, as events might come in while sending these off
  36850. var events = this._eventQueue;
  36851. this._eventQueue = null;
  36852. // Use a clone of the event handlers list, as they might remove themselves
  36853. var eventHandlers = this._eventHandlers.slice(0);
  36854. for (var i = 0, len = eventHandlers.length; i < len; i++) {
  36855. eventHandlers[i].handleEvents(events);
  36856. }
  36857. }
  36858. };
  36859. return ViewEventDispatcher;
  36860. }());
  36861. exports.ViewEventDispatcher = ViewEventDispatcher;
  36862. });
  36863. /*---------------------------------------------------------------------------------------------
  36864. * Copyright (c) Microsoft Corporation. All rights reserved.
  36865. * Licensed under the MIT License. See License.txt in the project root for license information.
  36866. *--------------------------------------------------------------------------------------------*/
  36867. define(__m[81/*vs/editor/common/view/viewEvents*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,2/*vs/base/common/lifecycle*/]), function (require, exports, errors, lifecycle_1) {
  36868. "use strict";
  36869. Object.defineProperty(exports, "__esModule", { value: true });
  36870. var ViewConfigurationChangedEvent = /** @class */ (function () {
  36871. function ViewConfigurationChangedEvent(source) {
  36872. this.type = 1 /* ViewConfigurationChanged */;
  36873. this._source = source;
  36874. }
  36875. ViewConfigurationChangedEvent.prototype.hasChanged = function (id) {
  36876. return this._source.hasChanged(id);
  36877. };
  36878. return ViewConfigurationChangedEvent;
  36879. }());
  36880. exports.ViewConfigurationChangedEvent = ViewConfigurationChangedEvent;
  36881. var ViewContentSizeChangedEvent = /** @class */ (function () {
  36882. function ViewContentSizeChangedEvent(source) {
  36883. this.type = 2 /* ViewContentSizeChanged */;
  36884. this.contentWidth = source.contentWidth;
  36885. this.contentHeight = source.contentHeight;
  36886. this.contentWidthChanged = source.contentWidthChanged;
  36887. this.contentHeightChanged = source.contentHeightChanged;
  36888. }
  36889. return ViewContentSizeChangedEvent;
  36890. }());
  36891. exports.ViewContentSizeChangedEvent = ViewContentSizeChangedEvent;
  36892. var ViewCursorStateChangedEvent = /** @class */ (function () {
  36893. function ViewCursorStateChangedEvent(selections, modelSelections) {
  36894. this.type = 3 /* ViewCursorStateChanged */;
  36895. this.selections = selections;
  36896. this.modelSelections = modelSelections;
  36897. }
  36898. return ViewCursorStateChangedEvent;
  36899. }());
  36900. exports.ViewCursorStateChangedEvent = ViewCursorStateChangedEvent;
  36901. var ViewDecorationsChangedEvent = /** @class */ (function () {
  36902. function ViewDecorationsChangedEvent() {
  36903. this.type = 4 /* ViewDecorationsChanged */;
  36904. // Nothing to do
  36905. }
  36906. return ViewDecorationsChangedEvent;
  36907. }());
  36908. exports.ViewDecorationsChangedEvent = ViewDecorationsChangedEvent;
  36909. var ViewFlushedEvent = /** @class */ (function () {
  36910. function ViewFlushedEvent() {
  36911. this.type = 5 /* ViewFlushed */;
  36912. // Nothing to do
  36913. }
  36914. return ViewFlushedEvent;
  36915. }());
  36916. exports.ViewFlushedEvent = ViewFlushedEvent;
  36917. var ViewFocusChangedEvent = /** @class */ (function () {
  36918. function ViewFocusChangedEvent(isFocused) {
  36919. this.type = 6 /* ViewFocusChanged */;
  36920. this.isFocused = isFocused;
  36921. }
  36922. return ViewFocusChangedEvent;
  36923. }());
  36924. exports.ViewFocusChangedEvent = ViewFocusChangedEvent;
  36925. var ViewLanguageConfigurationEvent = /** @class */ (function () {
  36926. function ViewLanguageConfigurationEvent() {
  36927. this.type = 7 /* ViewLanguageConfigurationChanged */;
  36928. }
  36929. return ViewLanguageConfigurationEvent;
  36930. }());
  36931. exports.ViewLanguageConfigurationEvent = ViewLanguageConfigurationEvent;
  36932. var ViewLineMappingChangedEvent = /** @class */ (function () {
  36933. function ViewLineMappingChangedEvent() {
  36934. this.type = 8 /* ViewLineMappingChanged */;
  36935. // Nothing to do
  36936. }
  36937. return ViewLineMappingChangedEvent;
  36938. }());
  36939. exports.ViewLineMappingChangedEvent = ViewLineMappingChangedEvent;
  36940. var ViewLinesChangedEvent = /** @class */ (function () {
  36941. function ViewLinesChangedEvent(fromLineNumber, toLineNumber) {
  36942. this.type = 9 /* ViewLinesChanged */;
  36943. this.fromLineNumber = fromLineNumber;
  36944. this.toLineNumber = toLineNumber;
  36945. }
  36946. return ViewLinesChangedEvent;
  36947. }());
  36948. exports.ViewLinesChangedEvent = ViewLinesChangedEvent;
  36949. var ViewLinesDeletedEvent = /** @class */ (function () {
  36950. function ViewLinesDeletedEvent(fromLineNumber, toLineNumber) {
  36951. this.type = 10 /* ViewLinesDeleted */;
  36952. this.fromLineNumber = fromLineNumber;
  36953. this.toLineNumber = toLineNumber;
  36954. }
  36955. return ViewLinesDeletedEvent;
  36956. }());
  36957. exports.ViewLinesDeletedEvent = ViewLinesDeletedEvent;
  36958. var ViewLinesInsertedEvent = /** @class */ (function () {
  36959. function ViewLinesInsertedEvent(fromLineNumber, toLineNumber) {
  36960. this.type = 11 /* ViewLinesInserted */;
  36961. this.fromLineNumber = fromLineNumber;
  36962. this.toLineNumber = toLineNumber;
  36963. }
  36964. return ViewLinesInsertedEvent;
  36965. }());
  36966. exports.ViewLinesInsertedEvent = ViewLinesInsertedEvent;
  36967. var ViewRevealRangeRequestEvent = /** @class */ (function () {
  36968. function ViewRevealRangeRequestEvent(source, range, verticalType, revealHorizontal, scrollType) {
  36969. this.type = 12 /* ViewRevealRangeRequest */;
  36970. this.source = source;
  36971. this.range = range;
  36972. this.verticalType = verticalType;
  36973. this.revealHorizontal = revealHorizontal;
  36974. this.scrollType = scrollType;
  36975. }
  36976. return ViewRevealRangeRequestEvent;
  36977. }());
  36978. exports.ViewRevealRangeRequestEvent = ViewRevealRangeRequestEvent;
  36979. var ViewScrollChangedEvent = /** @class */ (function () {
  36980. function ViewScrollChangedEvent(source) {
  36981. this.type = 13 /* ViewScrollChanged */;
  36982. this.scrollWidth = source.scrollWidth;
  36983. this.scrollLeft = source.scrollLeft;
  36984. this.scrollHeight = source.scrollHeight;
  36985. this.scrollTop = source.scrollTop;
  36986. this.scrollWidthChanged = source.scrollWidthChanged;
  36987. this.scrollLeftChanged = source.scrollLeftChanged;
  36988. this.scrollHeightChanged = source.scrollHeightChanged;
  36989. this.scrollTopChanged = source.scrollTopChanged;
  36990. }
  36991. return ViewScrollChangedEvent;
  36992. }());
  36993. exports.ViewScrollChangedEvent = ViewScrollChangedEvent;
  36994. var ViewThemeChangedEvent = /** @class */ (function () {
  36995. function ViewThemeChangedEvent() {
  36996. this.type = 14 /* ViewThemeChanged */;
  36997. }
  36998. return ViewThemeChangedEvent;
  36999. }());
  37000. exports.ViewThemeChangedEvent = ViewThemeChangedEvent;
  37001. var ViewTokensChangedEvent = /** @class */ (function () {
  37002. function ViewTokensChangedEvent(ranges) {
  37003. this.type = 15 /* ViewTokensChanged */;
  37004. this.ranges = ranges;
  37005. }
  37006. return ViewTokensChangedEvent;
  37007. }());
  37008. exports.ViewTokensChangedEvent = ViewTokensChangedEvent;
  37009. var ViewTokensColorsChangedEvent = /** @class */ (function () {
  37010. function ViewTokensColorsChangedEvent() {
  37011. this.type = 16 /* ViewTokensColorsChanged */;
  37012. // Nothing to do
  37013. }
  37014. return ViewTokensColorsChangedEvent;
  37015. }());
  37016. exports.ViewTokensColorsChangedEvent = ViewTokensColorsChangedEvent;
  37017. var ViewZonesChangedEvent = /** @class */ (function () {
  37018. function ViewZonesChangedEvent() {
  37019. this.type = 17 /* ViewZonesChanged */;
  37020. // Nothing to do
  37021. }
  37022. return ViewZonesChangedEvent;
  37023. }());
  37024. exports.ViewZonesChangedEvent = ViewZonesChangedEvent;
  37025. var ViewEventEmitter = /** @class */ (function (_super) {
  37026. __extends(ViewEventEmitter, _super);
  37027. function ViewEventEmitter() {
  37028. var _this = _super.call(this) || this;
  37029. _this._listeners = [];
  37030. _this._collector = null;
  37031. _this._collectorCnt = 0;
  37032. return _this;
  37033. }
  37034. ViewEventEmitter.prototype.dispose = function () {
  37035. this._listeners = [];
  37036. _super.prototype.dispose.call(this);
  37037. };
  37038. ViewEventEmitter.prototype._beginEmit = function () {
  37039. this._collectorCnt++;
  37040. if (this._collectorCnt === 1) {
  37041. this._collector = new ViewEventsCollector();
  37042. }
  37043. return this._collector;
  37044. };
  37045. ViewEventEmitter.prototype._endEmit = function () {
  37046. this._collectorCnt--;
  37047. if (this._collectorCnt === 0) {
  37048. var events = this._collector.finalize();
  37049. this._collector = null;
  37050. if (events.length > 0) {
  37051. this._emit(events);
  37052. }
  37053. }
  37054. };
  37055. ViewEventEmitter.prototype._emit = function (events) {
  37056. var listeners = this._listeners.slice(0);
  37057. for (var i = 0, len = listeners.length; i < len; i++) {
  37058. safeInvokeListener(listeners[i], events);
  37059. }
  37060. };
  37061. ViewEventEmitter.prototype.addEventListener = function (listener) {
  37062. var _this = this;
  37063. this._listeners.push(listener);
  37064. return lifecycle_1.toDisposable(function () {
  37065. var listeners = _this._listeners;
  37066. for (var i = 0, len = listeners.length; i < len; i++) {
  37067. if (listeners[i] === listener) {
  37068. listeners.splice(i, 1);
  37069. break;
  37070. }
  37071. }
  37072. });
  37073. };
  37074. return ViewEventEmitter;
  37075. }(lifecycle_1.Disposable));
  37076. exports.ViewEventEmitter = ViewEventEmitter;
  37077. var ViewEventsCollector = /** @class */ (function () {
  37078. function ViewEventsCollector() {
  37079. this._eventsLen = 0;
  37080. this._events = [];
  37081. this._eventsLen = 0;
  37082. }
  37083. ViewEventsCollector.prototype.emit = function (event) {
  37084. this._events[this._eventsLen++] = event;
  37085. };
  37086. ViewEventsCollector.prototype.finalize = function () {
  37087. var result = this._events;
  37088. this._events = [];
  37089. return result;
  37090. };
  37091. return ViewEventsCollector;
  37092. }());
  37093. exports.ViewEventsCollector = ViewEventsCollector;
  37094. function safeInvokeListener(listener, events) {
  37095. try {
  37096. listener(events);
  37097. }
  37098. catch (e) {
  37099. errors.onUnexpectedError(e);
  37100. }
  37101. }
  37102. });
  37103. /*---------------------------------------------------------------------------------------------
  37104. * Copyright (c) Microsoft Corporation. All rights reserved.
  37105. * Licensed under the MIT License. See License.txt in the project root for license information.
  37106. *--------------------------------------------------------------------------------------------*/
  37107. define(__m[148/*vs/editor/common/viewLayout/lineDecorations*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/]), function (require, exports, strings) {
  37108. "use strict";
  37109. Object.defineProperty(exports, "__esModule", { value: true });
  37110. var LineDecoration = /** @class */ (function () {
  37111. function LineDecoration(startColumn, endColumn, className, type) {
  37112. this.startColumn = startColumn;
  37113. this.endColumn = endColumn;
  37114. this.className = className;
  37115. this.type = type;
  37116. }
  37117. LineDecoration._equals = function (a, b) {
  37118. return (a.startColumn === b.startColumn
  37119. && a.endColumn === b.endColumn
  37120. && a.className === b.className
  37121. && a.type === b.type);
  37122. };
  37123. LineDecoration.equalsArr = function (a, b) {
  37124. var aLen = a.length;
  37125. var bLen = b.length;
  37126. if (aLen !== bLen) {
  37127. return false;
  37128. }
  37129. for (var i = 0; i < aLen; i++) {
  37130. if (!LineDecoration._equals(a[i], b[i])) {
  37131. return false;
  37132. }
  37133. }
  37134. return true;
  37135. };
  37136. LineDecoration.filter = function (lineDecorations, lineNumber, minLineColumn, maxLineColumn) {
  37137. if (lineDecorations.length === 0) {
  37138. return [];
  37139. }
  37140. var result = [], resultLen = 0;
  37141. for (var i = 0, len = lineDecorations.length; i < len; i++) {
  37142. var d = lineDecorations[i];
  37143. var range = d.range;
  37144. if (range.endLineNumber < lineNumber || range.startLineNumber > lineNumber) {
  37145. // Ignore decorations that sit outside this line
  37146. continue;
  37147. }
  37148. if (range.isEmpty() && (d.type === 0 /* Regular */ || d.type === 3 /* RegularAffectingLetterSpacing */)) {
  37149. // Ignore empty range decorations
  37150. continue;
  37151. }
  37152. var startColumn = (range.startLineNumber === lineNumber ? range.startColumn : minLineColumn);
  37153. var endColumn = (range.endLineNumber === lineNumber ? range.endColumn : maxLineColumn);
  37154. result[resultLen++] = new LineDecoration(startColumn, endColumn, d.inlineClassName, d.type);
  37155. }
  37156. return result;
  37157. };
  37158. LineDecoration.compare = function (a, b) {
  37159. if (a.startColumn === b.startColumn) {
  37160. if (a.endColumn === b.endColumn) {
  37161. if (a.className < b.className) {
  37162. return -1;
  37163. }
  37164. if (a.className > b.className) {
  37165. return 1;
  37166. }
  37167. return 0;
  37168. }
  37169. return a.endColumn - b.endColumn;
  37170. }
  37171. return a.startColumn - b.startColumn;
  37172. };
  37173. return LineDecoration;
  37174. }());
  37175. exports.LineDecoration = LineDecoration;
  37176. var DecorationSegment = /** @class */ (function () {
  37177. function DecorationSegment(startOffset, endOffset, className) {
  37178. this.startOffset = startOffset;
  37179. this.endOffset = endOffset;
  37180. this.className = className;
  37181. }
  37182. return DecorationSegment;
  37183. }());
  37184. exports.DecorationSegment = DecorationSegment;
  37185. var Stack = /** @class */ (function () {
  37186. function Stack() {
  37187. this.stopOffsets = [];
  37188. this.classNames = [];
  37189. this.count = 0;
  37190. }
  37191. Stack.prototype.consumeLowerThan = function (maxStopOffset, nextStartOffset, result) {
  37192. while (this.count > 0 && this.stopOffsets[0] < maxStopOffset) {
  37193. var i = 0;
  37194. // Take all equal stopping offsets
  37195. while (i + 1 < this.count && this.stopOffsets[i] === this.stopOffsets[i + 1]) {
  37196. i++;
  37197. }
  37198. // Basically we are consuming the first i + 1 elements of the stack
  37199. result.push(new DecorationSegment(nextStartOffset, this.stopOffsets[i], this.classNames.join(' ')));
  37200. nextStartOffset = this.stopOffsets[i] + 1;
  37201. // Consume them
  37202. this.stopOffsets.splice(0, i + 1);
  37203. this.classNames.splice(0, i + 1);
  37204. this.count -= (i + 1);
  37205. }
  37206. if (this.count > 0 && nextStartOffset < maxStopOffset) {
  37207. result.push(new DecorationSegment(nextStartOffset, maxStopOffset - 1, this.classNames.join(' ')));
  37208. nextStartOffset = maxStopOffset;
  37209. }
  37210. return nextStartOffset;
  37211. };
  37212. Stack.prototype.insert = function (stopOffset, className) {
  37213. if (this.count === 0 || this.stopOffsets[this.count - 1] <= stopOffset) {
  37214. // Insert at the end
  37215. this.stopOffsets.push(stopOffset);
  37216. this.classNames.push(className);
  37217. }
  37218. else {
  37219. // Find the insertion position for `stopOffset`
  37220. for (var i = 0; i < this.count; i++) {
  37221. if (this.stopOffsets[i] >= stopOffset) {
  37222. this.stopOffsets.splice(i, 0, stopOffset);
  37223. this.classNames.splice(i, 0, className);
  37224. break;
  37225. }
  37226. }
  37227. }
  37228. this.count++;
  37229. return;
  37230. };
  37231. return Stack;
  37232. }());
  37233. var LineDecorationsNormalizer = /** @class */ (function () {
  37234. function LineDecorationsNormalizer() {
  37235. }
  37236. /**
  37237. * Normalize line decorations. Overlapping decorations will generate multiple segments
  37238. */
  37239. LineDecorationsNormalizer.normalize = function (lineContent, lineDecorations) {
  37240. if (lineDecorations.length === 0) {
  37241. return [];
  37242. }
  37243. var result = [];
  37244. var stack = new Stack();
  37245. var nextStartOffset = 0;
  37246. for (var i = 0, len = lineDecorations.length; i < len; i++) {
  37247. var d = lineDecorations[i];
  37248. var startColumn = d.startColumn;
  37249. var endColumn = d.endColumn;
  37250. var className = d.className;
  37251. // If the position would end up in the middle of a high-low surrogate pair, we move it to before the pair
  37252. if (startColumn > 1) {
  37253. var charCodeBefore = lineContent.charCodeAt(startColumn - 2);
  37254. if (strings.isHighSurrogate(charCodeBefore)) {
  37255. startColumn--;
  37256. }
  37257. }
  37258. if (endColumn > 1) {
  37259. var charCodeBefore = lineContent.charCodeAt(endColumn - 2);
  37260. if (strings.isHighSurrogate(charCodeBefore)) {
  37261. endColumn--;
  37262. }
  37263. }
  37264. var currentStartOffset = startColumn - 1;
  37265. var currentEndOffset = endColumn - 2;
  37266. nextStartOffset = stack.consumeLowerThan(currentStartOffset, nextStartOffset, result);
  37267. if (stack.count === 0) {
  37268. nextStartOffset = currentStartOffset;
  37269. }
  37270. stack.insert(currentEndOffset, className);
  37271. }
  37272. stack.consumeLowerThan(1073741824 /* MAX_SAFE_SMALL_INTEGER */, nextStartOffset, result);
  37273. return result;
  37274. };
  37275. return LineDecorationsNormalizer;
  37276. }());
  37277. exports.LineDecorationsNormalizer = LineDecorationsNormalizer;
  37278. });
  37279. /*---------------------------------------------------------------------------------------------
  37280. * Copyright (c) Microsoft Corporation. All rights reserved.
  37281. * Licensed under the MIT License. See License.txt in the project root for license information.
  37282. *--------------------------------------------------------------------------------------------*/
  37283. define(__m[362/*vs/editor/common/viewLayout/linesLayout*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/]), function (require, exports, strings) {
  37284. "use strict";
  37285. Object.defineProperty(exports, "__esModule", { value: true });
  37286. var PendingChanges = /** @class */ (function () {
  37287. function PendingChanges() {
  37288. this._hasPending = false;
  37289. this._inserts = [];
  37290. this._changes = [];
  37291. this._removes = [];
  37292. }
  37293. PendingChanges.prototype.insert = function (x) {
  37294. this._hasPending = true;
  37295. this._inserts.push(x);
  37296. };
  37297. PendingChanges.prototype.change = function (x) {
  37298. this._hasPending = true;
  37299. this._changes.push(x);
  37300. };
  37301. PendingChanges.prototype.remove = function (x) {
  37302. this._hasPending = true;
  37303. this._removes.push(x);
  37304. };
  37305. PendingChanges.prototype.mustCommit = function () {
  37306. return this._hasPending;
  37307. };
  37308. PendingChanges.prototype.commit = function (linesLayout) {
  37309. if (!this._hasPending) {
  37310. return;
  37311. }
  37312. var inserts = this._inserts;
  37313. var changes = this._changes;
  37314. var removes = this._removes;
  37315. this._hasPending = false;
  37316. this._inserts = [];
  37317. this._changes = [];
  37318. this._removes = [];
  37319. linesLayout._commitPendingChanges(inserts, changes, removes);
  37320. };
  37321. return PendingChanges;
  37322. }());
  37323. var EditorWhitespace = /** @class */ (function () {
  37324. function EditorWhitespace(id, afterLineNumber, ordinal, height, minWidth) {
  37325. this.id = id;
  37326. this.afterLineNumber = afterLineNumber;
  37327. this.ordinal = ordinal;
  37328. this.height = height;
  37329. this.minWidth = minWidth;
  37330. this.prefixSum = 0;
  37331. }
  37332. return EditorWhitespace;
  37333. }());
  37334. exports.EditorWhitespace = EditorWhitespace;
  37335. /**
  37336. * Layouting of objects that take vertical space (by having a height) and push down other objects.
  37337. *
  37338. * These objects are basically either text (lines) or spaces between those lines (whitespaces).
  37339. * This provides commodity operations for working with lines that contain whitespace that pushes lines lower (vertically).
  37340. */
  37341. var LinesLayout = /** @class */ (function () {
  37342. function LinesLayout(lineCount, lineHeight) {
  37343. this._instanceId = strings.singleLetterHash(++LinesLayout.INSTANCE_COUNT);
  37344. this._pendingChanges = new PendingChanges();
  37345. this._lastWhitespaceId = 0;
  37346. this._arr = [];
  37347. this._prefixSumValidIndex = -1;
  37348. this._minWidth = -1; /* marker for not being computed */
  37349. this._lineCount = lineCount;
  37350. this._lineHeight = lineHeight;
  37351. }
  37352. /**
  37353. * Find the insertion index for a new value inside a sorted array of values.
  37354. * If the value is already present in the sorted array, the insertion index will be after the already existing value.
  37355. */
  37356. LinesLayout.findInsertionIndex = function (arr, afterLineNumber, ordinal) {
  37357. var low = 0;
  37358. var high = arr.length;
  37359. while (low < high) {
  37360. var mid = ((low + high) >>> 1);
  37361. if (afterLineNumber === arr[mid].afterLineNumber) {
  37362. if (ordinal < arr[mid].ordinal) {
  37363. high = mid;
  37364. }
  37365. else {
  37366. low = mid + 1;
  37367. }
  37368. }
  37369. else if (afterLineNumber < arr[mid].afterLineNumber) {
  37370. high = mid;
  37371. }
  37372. else {
  37373. low = mid + 1;
  37374. }
  37375. }
  37376. return low;
  37377. };
  37378. /**
  37379. * Change the height of a line in pixels.
  37380. */
  37381. LinesLayout.prototype.setLineHeight = function (lineHeight) {
  37382. this._checkPendingChanges();
  37383. this._lineHeight = lineHeight;
  37384. };
  37385. /**
  37386. * Set the number of lines.
  37387. *
  37388. * @param lineCount New number of lines.
  37389. */
  37390. LinesLayout.prototype.onFlushed = function (lineCount) {
  37391. this._checkPendingChanges();
  37392. this._lineCount = lineCount;
  37393. };
  37394. LinesLayout.prototype.changeWhitespace = function (callback) {
  37395. var _this = this;
  37396. try {
  37397. var accessor = {
  37398. insertWhitespace: function (afterLineNumber, ordinal, heightInPx, minWidth) {
  37399. afterLineNumber = afterLineNumber | 0;
  37400. ordinal = ordinal | 0;
  37401. heightInPx = heightInPx | 0;
  37402. minWidth = minWidth | 0;
  37403. var id = _this._instanceId + (++_this._lastWhitespaceId);
  37404. _this._pendingChanges.insert(new EditorWhitespace(id, afterLineNumber, ordinal, heightInPx, minWidth));
  37405. return id;
  37406. },
  37407. changeOneWhitespace: function (id, newAfterLineNumber, newHeight) {
  37408. newAfterLineNumber = newAfterLineNumber | 0;
  37409. newHeight = newHeight | 0;
  37410. _this._pendingChanges.change({ id: id, newAfterLineNumber: newAfterLineNumber, newHeight: newHeight });
  37411. },
  37412. removeWhitespace: function (id) {
  37413. _this._pendingChanges.remove({ id: id });
  37414. }
  37415. };
  37416. return callback(accessor);
  37417. }
  37418. finally {
  37419. this._pendingChanges.commit(this);
  37420. }
  37421. };
  37422. LinesLayout.prototype._commitPendingChanges = function (inserts, changes, removes) {
  37423. if (inserts.length > 0 || removes.length > 0) {
  37424. this._minWidth = -1; /* marker for not being computed */
  37425. }
  37426. if (inserts.length + changes.length + removes.length <= 1) {
  37427. // when only one thing happened, handle it "delicately"
  37428. for (var _i = 0, inserts_1 = inserts; _i < inserts_1.length; _i++) {
  37429. var insert = inserts_1[_i];
  37430. this._insertWhitespace(insert);
  37431. }
  37432. for (var _a = 0, changes_1 = changes; _a < changes_1.length; _a++) {
  37433. var change = changes_1[_a];
  37434. this._changeOneWhitespace(change.id, change.newAfterLineNumber, change.newHeight);
  37435. }
  37436. for (var _b = 0, removes_1 = removes; _b < removes_1.length; _b++) {
  37437. var remove = removes_1[_b];
  37438. var index = this._findWhitespaceIndex(remove.id);
  37439. if (index === -1) {
  37440. continue;
  37441. }
  37442. this._removeWhitespace(index);
  37443. }
  37444. return;
  37445. }
  37446. // simply rebuild the entire datastructure
  37447. var toRemove = new Set();
  37448. for (var _c = 0, removes_2 = removes; _c < removes_2.length; _c++) {
  37449. var remove = removes_2[_c];
  37450. toRemove.add(remove.id);
  37451. }
  37452. var toChange = new Map();
  37453. for (var _d = 0, changes_2 = changes; _d < changes_2.length; _d++) {
  37454. var change = changes_2[_d];
  37455. toChange.set(change.id, change);
  37456. }
  37457. var applyRemoveAndChange = function (whitespaces) {
  37458. var result = [];
  37459. for (var _i = 0, whitespaces_1 = whitespaces; _i < whitespaces_1.length; _i++) {
  37460. var whitespace = whitespaces_1[_i];
  37461. if (toRemove.has(whitespace.id)) {
  37462. continue;
  37463. }
  37464. if (toChange.has(whitespace.id)) {
  37465. var change = toChange.get(whitespace.id);
  37466. whitespace.afterLineNumber = change.newAfterLineNumber;
  37467. whitespace.height = change.newHeight;
  37468. }
  37469. result.push(whitespace);
  37470. }
  37471. return result;
  37472. };
  37473. var result = applyRemoveAndChange(this._arr).concat(applyRemoveAndChange(inserts));
  37474. result.sort(function (a, b) {
  37475. if (a.afterLineNumber === b.afterLineNumber) {
  37476. return a.ordinal - b.ordinal;
  37477. }
  37478. return a.afterLineNumber - b.afterLineNumber;
  37479. });
  37480. this._arr = result;
  37481. this._prefixSumValidIndex = -1;
  37482. };
  37483. LinesLayout.prototype._checkPendingChanges = function () {
  37484. if (this._pendingChanges.mustCommit()) {
  37485. this._pendingChanges.commit(this);
  37486. }
  37487. };
  37488. LinesLayout.prototype._insertWhitespace = function (whitespace) {
  37489. var insertIndex = LinesLayout.findInsertionIndex(this._arr, whitespace.afterLineNumber, whitespace.ordinal);
  37490. this._arr.splice(insertIndex, 0, whitespace);
  37491. this._prefixSumValidIndex = Math.min(this._prefixSumValidIndex, insertIndex - 1);
  37492. };
  37493. LinesLayout.prototype._findWhitespaceIndex = function (id) {
  37494. var arr = this._arr;
  37495. for (var i = 0, len = arr.length; i < len; i++) {
  37496. if (arr[i].id === id) {
  37497. return i;
  37498. }
  37499. }
  37500. return -1;
  37501. };
  37502. LinesLayout.prototype._changeOneWhitespace = function (id, newAfterLineNumber, newHeight) {
  37503. var index = this._findWhitespaceIndex(id);
  37504. if (index === -1) {
  37505. return;
  37506. }
  37507. if (this._arr[index].height !== newHeight) {
  37508. this._arr[index].height = newHeight;
  37509. this._prefixSumValidIndex = Math.min(this._prefixSumValidIndex, index - 1);
  37510. }
  37511. if (this._arr[index].afterLineNumber !== newAfterLineNumber) {
  37512. // `afterLineNumber` changed for this whitespace
  37513. // Record old whitespace
  37514. var whitespace = this._arr[index];
  37515. // Since changing `afterLineNumber` can trigger a reordering, we're gonna remove this whitespace
  37516. this._removeWhitespace(index);
  37517. whitespace.afterLineNumber = newAfterLineNumber;
  37518. // And add it again
  37519. this._insertWhitespace(whitespace);
  37520. }
  37521. };
  37522. LinesLayout.prototype._removeWhitespace = function (removeIndex) {
  37523. this._arr.splice(removeIndex, 1);
  37524. this._prefixSumValidIndex = Math.min(this._prefixSumValidIndex, removeIndex - 1);
  37525. };
  37526. /**
  37527. * Notify the layouter that lines have been deleted (a continuous zone of lines).
  37528. *
  37529. * @param fromLineNumber The line number at which the deletion started, inclusive
  37530. * @param toLineNumber The line number at which the deletion ended, inclusive
  37531. */
  37532. LinesLayout.prototype.onLinesDeleted = function (fromLineNumber, toLineNumber) {
  37533. this._checkPendingChanges();
  37534. fromLineNumber = fromLineNumber | 0;
  37535. toLineNumber = toLineNumber | 0;
  37536. this._lineCount -= (toLineNumber - fromLineNumber + 1);
  37537. for (var i = 0, len = this._arr.length; i < len; i++) {
  37538. var afterLineNumber = this._arr[i].afterLineNumber;
  37539. if (fromLineNumber <= afterLineNumber && afterLineNumber <= toLineNumber) {
  37540. // The line this whitespace was after has been deleted
  37541. // => move whitespace to before first deleted line
  37542. this._arr[i].afterLineNumber = fromLineNumber - 1;
  37543. }
  37544. else if (afterLineNumber > toLineNumber) {
  37545. // The line this whitespace was after has been moved up
  37546. // => move whitespace up
  37547. this._arr[i].afterLineNumber -= (toLineNumber - fromLineNumber + 1);
  37548. }
  37549. }
  37550. };
  37551. /**
  37552. * Notify the layouter that lines have been inserted (a continuous zone of lines).
  37553. *
  37554. * @param fromLineNumber The line number at which the insertion started, inclusive
  37555. * @param toLineNumber The line number at which the insertion ended, inclusive.
  37556. */
  37557. LinesLayout.prototype.onLinesInserted = function (fromLineNumber, toLineNumber) {
  37558. this._checkPendingChanges();
  37559. fromLineNumber = fromLineNumber | 0;
  37560. toLineNumber = toLineNumber | 0;
  37561. this._lineCount += (toLineNumber - fromLineNumber + 1);
  37562. for (var i = 0, len = this._arr.length; i < len; i++) {
  37563. var afterLineNumber = this._arr[i].afterLineNumber;
  37564. if (fromLineNumber <= afterLineNumber) {
  37565. this._arr[i].afterLineNumber += (toLineNumber - fromLineNumber + 1);
  37566. }
  37567. }
  37568. };
  37569. /**
  37570. * Get the sum of all the whitespaces.
  37571. */
  37572. LinesLayout.prototype.getWhitespacesTotalHeight = function () {
  37573. this._checkPendingChanges();
  37574. if (this._arr.length === 0) {
  37575. return 0;
  37576. }
  37577. return this.getWhitespacesAccumulatedHeight(this._arr.length - 1);
  37578. };
  37579. /**
  37580. * Return the sum of the heights of the whitespaces at [0..index].
  37581. * This includes the whitespace at `index`.
  37582. *
  37583. * @param index The index of the whitespace.
  37584. * @return The sum of the heights of all whitespaces before the one at `index`, including the one at `index`.
  37585. */
  37586. LinesLayout.prototype.getWhitespacesAccumulatedHeight = function (index) {
  37587. this._checkPendingChanges();
  37588. index = index | 0;
  37589. var startIndex = Math.max(0, this._prefixSumValidIndex + 1);
  37590. if (startIndex === 0) {
  37591. this._arr[0].prefixSum = this._arr[0].height;
  37592. startIndex++;
  37593. }
  37594. for (var i = startIndex; i <= index; i++) {
  37595. this._arr[i].prefixSum = this._arr[i - 1].prefixSum + this._arr[i].height;
  37596. }
  37597. this._prefixSumValidIndex = Math.max(this._prefixSumValidIndex, index);
  37598. return this._arr[index].prefixSum;
  37599. };
  37600. /**
  37601. * Get the sum of heights for all objects.
  37602. *
  37603. * @return The sum of heights for all objects.
  37604. */
  37605. LinesLayout.prototype.getLinesTotalHeight = function () {
  37606. this._checkPendingChanges();
  37607. var linesHeight = this._lineHeight * this._lineCount;
  37608. var whitespacesHeight = this.getWhitespacesTotalHeight();
  37609. return linesHeight + whitespacesHeight;
  37610. };
  37611. /**
  37612. * Returns the accumulated height of whitespaces before the given line number.
  37613. *
  37614. * @param lineNumber The line number
  37615. */
  37616. LinesLayout.prototype.getWhitespaceAccumulatedHeightBeforeLineNumber = function (lineNumber) {
  37617. this._checkPendingChanges();
  37618. lineNumber = lineNumber | 0;
  37619. var lastWhitespaceBeforeLineNumber = this._findLastWhitespaceBeforeLineNumber(lineNumber);
  37620. if (lastWhitespaceBeforeLineNumber === -1) {
  37621. return 0;
  37622. }
  37623. return this.getWhitespacesAccumulatedHeight(lastWhitespaceBeforeLineNumber);
  37624. };
  37625. LinesLayout.prototype._findLastWhitespaceBeforeLineNumber = function (lineNumber) {
  37626. lineNumber = lineNumber | 0;
  37627. // Find the whitespace before line number
  37628. var arr = this._arr;
  37629. var low = 0;
  37630. var high = arr.length - 1;
  37631. while (low <= high) {
  37632. var delta = (high - low) | 0;
  37633. var halfDelta = (delta / 2) | 0;
  37634. var mid = (low + halfDelta) | 0;
  37635. if (arr[mid].afterLineNumber < lineNumber) {
  37636. if (mid + 1 >= arr.length || arr[mid + 1].afterLineNumber >= lineNumber) {
  37637. return mid;
  37638. }
  37639. else {
  37640. low = (mid + 1) | 0;
  37641. }
  37642. }
  37643. else {
  37644. high = (mid - 1) | 0;
  37645. }
  37646. }
  37647. return -1;
  37648. };
  37649. LinesLayout.prototype._findFirstWhitespaceAfterLineNumber = function (lineNumber) {
  37650. lineNumber = lineNumber | 0;
  37651. var lastWhitespaceBeforeLineNumber = this._findLastWhitespaceBeforeLineNumber(lineNumber);
  37652. var firstWhitespaceAfterLineNumber = lastWhitespaceBeforeLineNumber + 1;
  37653. if (firstWhitespaceAfterLineNumber < this._arr.length) {
  37654. return firstWhitespaceAfterLineNumber;
  37655. }
  37656. return -1;
  37657. };
  37658. /**
  37659. * Find the index of the first whitespace which has `afterLineNumber` >= `lineNumber`.
  37660. * @return The index of the first whitespace with `afterLineNumber` >= `lineNumber` or -1 if no whitespace is found.
  37661. */
  37662. LinesLayout.prototype.getFirstWhitespaceIndexAfterLineNumber = function (lineNumber) {
  37663. this._checkPendingChanges();
  37664. lineNumber = lineNumber | 0;
  37665. return this._findFirstWhitespaceAfterLineNumber(lineNumber);
  37666. };
  37667. /**
  37668. * Get the vertical offset (the sum of heights for all objects above) a certain line number.
  37669. *
  37670. * @param lineNumber The line number
  37671. * @return The sum of heights for all objects above `lineNumber`.
  37672. */
  37673. LinesLayout.prototype.getVerticalOffsetForLineNumber = function (lineNumber) {
  37674. this._checkPendingChanges();
  37675. lineNumber = lineNumber | 0;
  37676. var previousLinesHeight;
  37677. if (lineNumber > 1) {
  37678. previousLinesHeight = this._lineHeight * (lineNumber - 1);
  37679. }
  37680. else {
  37681. previousLinesHeight = 0;
  37682. }
  37683. var previousWhitespacesHeight = this.getWhitespaceAccumulatedHeightBeforeLineNumber(lineNumber);
  37684. return previousLinesHeight + previousWhitespacesHeight;
  37685. };
  37686. /**
  37687. * The maximum min width for all whitespaces.
  37688. */
  37689. LinesLayout.prototype.getWhitespaceMinWidth = function () {
  37690. this._checkPendingChanges();
  37691. if (this._minWidth === -1) {
  37692. var minWidth = 0;
  37693. for (var i = 0, len = this._arr.length; i < len; i++) {
  37694. minWidth = Math.max(minWidth, this._arr[i].minWidth);
  37695. }
  37696. this._minWidth = minWidth;
  37697. }
  37698. return this._minWidth;
  37699. };
  37700. /**
  37701. * Check if `verticalOffset` is below all lines.
  37702. */
  37703. LinesLayout.prototype.isAfterLines = function (verticalOffset) {
  37704. this._checkPendingChanges();
  37705. var totalHeight = this.getLinesTotalHeight();
  37706. return verticalOffset > totalHeight;
  37707. };
  37708. /**
  37709. * Find the first line number that is at or after vertical offset `verticalOffset`.
  37710. * i.e. if getVerticalOffsetForLine(line) is x and getVerticalOffsetForLine(line + 1) is y, then
  37711. * getLineNumberAtOrAfterVerticalOffset(i) = line, x <= i < y.
  37712. *
  37713. * @param verticalOffset The vertical offset to search at.
  37714. * @return The line number at or after vertical offset `verticalOffset`.
  37715. */
  37716. LinesLayout.prototype.getLineNumberAtOrAfterVerticalOffset = function (verticalOffset) {
  37717. this._checkPendingChanges();
  37718. verticalOffset = verticalOffset | 0;
  37719. if (verticalOffset < 0) {
  37720. return 1;
  37721. }
  37722. var linesCount = this._lineCount | 0;
  37723. var lineHeight = this._lineHeight;
  37724. var minLineNumber = 1;
  37725. var maxLineNumber = linesCount;
  37726. while (minLineNumber < maxLineNumber) {
  37727. var midLineNumber = ((minLineNumber + maxLineNumber) / 2) | 0;
  37728. var midLineNumberVerticalOffset = this.getVerticalOffsetForLineNumber(midLineNumber) | 0;
  37729. if (verticalOffset >= midLineNumberVerticalOffset + lineHeight) {
  37730. // vertical offset is after mid line number
  37731. minLineNumber = midLineNumber + 1;
  37732. }
  37733. else if (verticalOffset >= midLineNumberVerticalOffset) {
  37734. // Hit
  37735. return midLineNumber;
  37736. }
  37737. else {
  37738. // vertical offset is before mid line number, but mid line number could still be what we're searching for
  37739. maxLineNumber = midLineNumber;
  37740. }
  37741. }
  37742. if (minLineNumber > linesCount) {
  37743. return linesCount;
  37744. }
  37745. return minLineNumber;
  37746. };
  37747. /**
  37748. * Get all the lines and their relative vertical offsets that are positioned between `verticalOffset1` and `verticalOffset2`.
  37749. *
  37750. * @param verticalOffset1 The beginning of the viewport.
  37751. * @param verticalOffset2 The end of the viewport.
  37752. * @return A structure describing the lines positioned between `verticalOffset1` and `verticalOffset2`.
  37753. */
  37754. LinesLayout.prototype.getLinesViewportData = function (verticalOffset1, verticalOffset2) {
  37755. this._checkPendingChanges();
  37756. verticalOffset1 = verticalOffset1 | 0;
  37757. verticalOffset2 = verticalOffset2 | 0;
  37758. var lineHeight = this._lineHeight;
  37759. // Find first line number
  37760. // We don't live in a perfect world, so the line number might start before or after verticalOffset1
  37761. var startLineNumber = this.getLineNumberAtOrAfterVerticalOffset(verticalOffset1) | 0;
  37762. var startLineNumberVerticalOffset = this.getVerticalOffsetForLineNumber(startLineNumber) | 0;
  37763. var endLineNumber = this._lineCount | 0;
  37764. // Also keep track of what whitespace we've got
  37765. var whitespaceIndex = this.getFirstWhitespaceIndexAfterLineNumber(startLineNumber) | 0;
  37766. var whitespaceCount = this.getWhitespacesCount() | 0;
  37767. var currentWhitespaceHeight;
  37768. var currentWhitespaceAfterLineNumber;
  37769. if (whitespaceIndex === -1) {
  37770. whitespaceIndex = whitespaceCount;
  37771. currentWhitespaceAfterLineNumber = endLineNumber + 1;
  37772. currentWhitespaceHeight = 0;
  37773. }
  37774. else {
  37775. currentWhitespaceAfterLineNumber = this.getAfterLineNumberForWhitespaceIndex(whitespaceIndex) | 0;
  37776. currentWhitespaceHeight = this.getHeightForWhitespaceIndex(whitespaceIndex) | 0;
  37777. }
  37778. var currentVerticalOffset = startLineNumberVerticalOffset;
  37779. var currentLineRelativeOffset = currentVerticalOffset;
  37780. // IE (all versions) cannot handle units above about 1,533,908 px, so every 500k pixels bring numbers down
  37781. var STEP_SIZE = 500000;
  37782. var bigNumbersDelta = 0;
  37783. if (startLineNumberVerticalOffset >= STEP_SIZE) {
  37784. // Compute a delta that guarantees that lines are positioned at `lineHeight` increments
  37785. bigNumbersDelta = Math.floor(startLineNumberVerticalOffset / STEP_SIZE) * STEP_SIZE;
  37786. bigNumbersDelta = Math.floor(bigNumbersDelta / lineHeight) * lineHeight;
  37787. currentLineRelativeOffset -= bigNumbersDelta;
  37788. }
  37789. var linesOffsets = [];
  37790. var verticalCenter = verticalOffset1 + (verticalOffset2 - verticalOffset1) / 2;
  37791. var centeredLineNumber = -1;
  37792. // Figure out how far the lines go
  37793. for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
  37794. if (centeredLineNumber === -1) {
  37795. var currentLineTop = currentVerticalOffset;
  37796. var currentLineBottom = currentVerticalOffset + lineHeight;
  37797. if ((currentLineTop <= verticalCenter && verticalCenter < currentLineBottom) || currentLineTop > verticalCenter) {
  37798. centeredLineNumber = lineNumber;
  37799. }
  37800. }
  37801. // Count current line height in the vertical offsets
  37802. currentVerticalOffset += lineHeight;
  37803. linesOffsets[lineNumber - startLineNumber] = currentLineRelativeOffset;
  37804. // Next line starts immediately after this one
  37805. currentLineRelativeOffset += lineHeight;
  37806. while (currentWhitespaceAfterLineNumber === lineNumber) {
  37807. // Push down next line with the height of the current whitespace
  37808. currentLineRelativeOffset += currentWhitespaceHeight;
  37809. // Count current whitespace in the vertical offsets
  37810. currentVerticalOffset += currentWhitespaceHeight;
  37811. whitespaceIndex++;
  37812. if (whitespaceIndex >= whitespaceCount) {
  37813. currentWhitespaceAfterLineNumber = endLineNumber + 1;
  37814. }
  37815. else {
  37816. currentWhitespaceAfterLineNumber = this.getAfterLineNumberForWhitespaceIndex(whitespaceIndex) | 0;
  37817. currentWhitespaceHeight = this.getHeightForWhitespaceIndex(whitespaceIndex) | 0;
  37818. }
  37819. }
  37820. if (currentVerticalOffset >= verticalOffset2) {
  37821. // We have covered the entire viewport area, time to stop
  37822. endLineNumber = lineNumber;
  37823. break;
  37824. }
  37825. }
  37826. if (centeredLineNumber === -1) {
  37827. centeredLineNumber = endLineNumber;
  37828. }
  37829. var endLineNumberVerticalOffset = this.getVerticalOffsetForLineNumber(endLineNumber) | 0;
  37830. var completelyVisibleStartLineNumber = startLineNumber;
  37831. var completelyVisibleEndLineNumber = endLineNumber;
  37832. if (completelyVisibleStartLineNumber < completelyVisibleEndLineNumber) {
  37833. if (startLineNumberVerticalOffset < verticalOffset1) {
  37834. completelyVisibleStartLineNumber++;
  37835. }
  37836. }
  37837. if (completelyVisibleStartLineNumber < completelyVisibleEndLineNumber) {
  37838. if (endLineNumberVerticalOffset + lineHeight > verticalOffset2) {
  37839. completelyVisibleEndLineNumber--;
  37840. }
  37841. }
  37842. return {
  37843. bigNumbersDelta: bigNumbersDelta,
  37844. startLineNumber: startLineNumber,
  37845. endLineNumber: endLineNumber,
  37846. relativeVerticalOffset: linesOffsets,
  37847. centeredLineNumber: centeredLineNumber,
  37848. completelyVisibleStartLineNumber: completelyVisibleStartLineNumber,
  37849. completelyVisibleEndLineNumber: completelyVisibleEndLineNumber
  37850. };
  37851. };
  37852. LinesLayout.prototype.getVerticalOffsetForWhitespaceIndex = function (whitespaceIndex) {
  37853. this._checkPendingChanges();
  37854. whitespaceIndex = whitespaceIndex | 0;
  37855. var afterLineNumber = this.getAfterLineNumberForWhitespaceIndex(whitespaceIndex);
  37856. var previousLinesHeight;
  37857. if (afterLineNumber >= 1) {
  37858. previousLinesHeight = this._lineHeight * afterLineNumber;
  37859. }
  37860. else {
  37861. previousLinesHeight = 0;
  37862. }
  37863. var previousWhitespacesHeight;
  37864. if (whitespaceIndex > 0) {
  37865. previousWhitespacesHeight = this.getWhitespacesAccumulatedHeight(whitespaceIndex - 1);
  37866. }
  37867. else {
  37868. previousWhitespacesHeight = 0;
  37869. }
  37870. return previousLinesHeight + previousWhitespacesHeight;
  37871. };
  37872. LinesLayout.prototype.getWhitespaceIndexAtOrAfterVerticallOffset = function (verticalOffset) {
  37873. this._checkPendingChanges();
  37874. verticalOffset = verticalOffset | 0;
  37875. var minWhitespaceIndex = 0;
  37876. var maxWhitespaceIndex = this.getWhitespacesCount() - 1;
  37877. if (maxWhitespaceIndex < 0) {
  37878. return -1;
  37879. }
  37880. // Special case: nothing to be found
  37881. var maxWhitespaceVerticalOffset = this.getVerticalOffsetForWhitespaceIndex(maxWhitespaceIndex);
  37882. var maxWhitespaceHeight = this.getHeightForWhitespaceIndex(maxWhitespaceIndex);
  37883. if (verticalOffset >= maxWhitespaceVerticalOffset + maxWhitespaceHeight) {
  37884. return -1;
  37885. }
  37886. while (minWhitespaceIndex < maxWhitespaceIndex) {
  37887. var midWhitespaceIndex = Math.floor((minWhitespaceIndex + maxWhitespaceIndex) / 2);
  37888. var midWhitespaceVerticalOffset = this.getVerticalOffsetForWhitespaceIndex(midWhitespaceIndex);
  37889. var midWhitespaceHeight = this.getHeightForWhitespaceIndex(midWhitespaceIndex);
  37890. if (verticalOffset >= midWhitespaceVerticalOffset + midWhitespaceHeight) {
  37891. // vertical offset is after whitespace
  37892. minWhitespaceIndex = midWhitespaceIndex + 1;
  37893. }
  37894. else if (verticalOffset >= midWhitespaceVerticalOffset) {
  37895. // Hit
  37896. return midWhitespaceIndex;
  37897. }
  37898. else {
  37899. // vertical offset is before whitespace, but midWhitespaceIndex might still be what we're searching for
  37900. maxWhitespaceIndex = midWhitespaceIndex;
  37901. }
  37902. }
  37903. return minWhitespaceIndex;
  37904. };
  37905. /**
  37906. * Get exactly the whitespace that is layouted at `verticalOffset`.
  37907. *
  37908. * @param verticalOffset The vertical offset.
  37909. * @return Precisely the whitespace that is layouted at `verticaloffset` or null.
  37910. */
  37911. LinesLayout.prototype.getWhitespaceAtVerticalOffset = function (verticalOffset) {
  37912. this._checkPendingChanges();
  37913. verticalOffset = verticalOffset | 0;
  37914. var candidateIndex = this.getWhitespaceIndexAtOrAfterVerticallOffset(verticalOffset);
  37915. if (candidateIndex < 0) {
  37916. return null;
  37917. }
  37918. if (candidateIndex >= this.getWhitespacesCount()) {
  37919. return null;
  37920. }
  37921. var candidateTop = this.getVerticalOffsetForWhitespaceIndex(candidateIndex);
  37922. if (candidateTop > verticalOffset) {
  37923. return null;
  37924. }
  37925. var candidateHeight = this.getHeightForWhitespaceIndex(candidateIndex);
  37926. var candidateId = this.getIdForWhitespaceIndex(candidateIndex);
  37927. var candidateAfterLineNumber = this.getAfterLineNumberForWhitespaceIndex(candidateIndex);
  37928. return {
  37929. id: candidateId,
  37930. afterLineNumber: candidateAfterLineNumber,
  37931. verticalOffset: candidateTop,
  37932. height: candidateHeight
  37933. };
  37934. };
  37935. /**
  37936. * Get a list of whitespaces that are positioned between `verticalOffset1` and `verticalOffset2`.
  37937. *
  37938. * @param verticalOffset1 The beginning of the viewport.
  37939. * @param verticalOffset2 The end of the viewport.
  37940. * @return An array with all the whitespaces in the viewport. If no whitespace is in viewport, the array is empty.
  37941. */
  37942. LinesLayout.prototype.getWhitespaceViewportData = function (verticalOffset1, verticalOffset2) {
  37943. this._checkPendingChanges();
  37944. verticalOffset1 = verticalOffset1 | 0;
  37945. verticalOffset2 = verticalOffset2 | 0;
  37946. var startIndex = this.getWhitespaceIndexAtOrAfterVerticallOffset(verticalOffset1);
  37947. var endIndex = this.getWhitespacesCount() - 1;
  37948. if (startIndex < 0) {
  37949. return [];
  37950. }
  37951. var result = [];
  37952. for (var i = startIndex; i <= endIndex; i++) {
  37953. var top_1 = this.getVerticalOffsetForWhitespaceIndex(i);
  37954. var height = this.getHeightForWhitespaceIndex(i);
  37955. if (top_1 >= verticalOffset2) {
  37956. break;
  37957. }
  37958. result.push({
  37959. id: this.getIdForWhitespaceIndex(i),
  37960. afterLineNumber: this.getAfterLineNumberForWhitespaceIndex(i),
  37961. verticalOffset: top_1,
  37962. height: height
  37963. });
  37964. }
  37965. return result;
  37966. };
  37967. /**
  37968. * Get all whitespaces.
  37969. */
  37970. LinesLayout.prototype.getWhitespaces = function () {
  37971. this._checkPendingChanges();
  37972. return this._arr.slice(0);
  37973. };
  37974. /**
  37975. * The number of whitespaces.
  37976. */
  37977. LinesLayout.prototype.getWhitespacesCount = function () {
  37978. this._checkPendingChanges();
  37979. return this._arr.length;
  37980. };
  37981. /**
  37982. * Get the `id` for whitespace at index `index`.
  37983. *
  37984. * @param index The index of the whitespace.
  37985. * @return `id` of whitespace at `index`.
  37986. */
  37987. LinesLayout.prototype.getIdForWhitespaceIndex = function (index) {
  37988. this._checkPendingChanges();
  37989. index = index | 0;
  37990. return this._arr[index].id;
  37991. };
  37992. /**
  37993. * Get the `afterLineNumber` for whitespace at index `index`.
  37994. *
  37995. * @param index The index of the whitespace.
  37996. * @return `afterLineNumber` of whitespace at `index`.
  37997. */
  37998. LinesLayout.prototype.getAfterLineNumberForWhitespaceIndex = function (index) {
  37999. this._checkPendingChanges();
  38000. index = index | 0;
  38001. return this._arr[index].afterLineNumber;
  38002. };
  38003. /**
  38004. * Get the `height` for whitespace at index `index`.
  38005. *
  38006. * @param index The index of the whitespace.
  38007. * @return `height` of whitespace at `index`.
  38008. */
  38009. LinesLayout.prototype.getHeightForWhitespaceIndex = function (index) {
  38010. this._checkPendingChanges();
  38011. index = index | 0;
  38012. return this._arr[index].height;
  38013. };
  38014. LinesLayout.INSTANCE_COUNT = 0;
  38015. return LinesLayout;
  38016. }());
  38017. exports.LinesLayout = LinesLayout;
  38018. });
  38019. /*---------------------------------------------------------------------------------------------
  38020. * Copyright (c) Microsoft Corporation. All rights reserved.
  38021. * Licensed under the MIT License. See License.txt in the project root for license information.
  38022. *--------------------------------------------------------------------------------------------*/
  38023. define(__m[110/*vs/editor/common/viewLayout/viewLineRenderer*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,106/*vs/editor/common/core/stringBuilder*/,148/*vs/editor/common/viewLayout/lineDecorations*/]), function (require, exports, strings, stringBuilder_1, lineDecorations_1) {
  38024. "use strict";
  38025. Object.defineProperty(exports, "__esModule", { value: true });
  38026. var LinePart = /** @class */ (function () {
  38027. function LinePart(endIndex, type) {
  38028. this.endIndex = endIndex;
  38029. this.type = type;
  38030. }
  38031. return LinePart;
  38032. }());
  38033. var LineRange = /** @class */ (function () {
  38034. function LineRange(startIndex, endIndex) {
  38035. this.startOffset = startIndex;
  38036. this.endOffset = endIndex;
  38037. }
  38038. LineRange.prototype.equals = function (otherLineRange) {
  38039. return this.startOffset === otherLineRange.startOffset
  38040. && this.endOffset === otherLineRange.endOffset;
  38041. };
  38042. return LineRange;
  38043. }());
  38044. exports.LineRange = LineRange;
  38045. var RenderLineInput = /** @class */ (function () {
  38046. function RenderLineInput(useMonospaceOptimizations, canUseHalfwidthRightwardsArrow, lineContent, continuesWithWrappedLine, isBasicASCII, containsRTL, fauxIndentLength, lineTokens, lineDecorations, tabSize, startVisibleColumn, spaceWidth, middotWidth, stopRenderingLineAfter, renderWhitespace, renderControlCharacters, fontLigatures, selectionsOnLine) {
  38047. this.useMonospaceOptimizations = useMonospaceOptimizations;
  38048. this.canUseHalfwidthRightwardsArrow = canUseHalfwidthRightwardsArrow;
  38049. this.lineContent = lineContent;
  38050. this.continuesWithWrappedLine = continuesWithWrappedLine;
  38051. this.isBasicASCII = isBasicASCII;
  38052. this.containsRTL = containsRTL;
  38053. this.fauxIndentLength = fauxIndentLength;
  38054. this.lineTokens = lineTokens;
  38055. this.lineDecorations = lineDecorations;
  38056. this.tabSize = tabSize;
  38057. this.startVisibleColumn = startVisibleColumn;
  38058. this.spaceWidth = spaceWidth;
  38059. this.middotWidth = middotWidth;
  38060. this.stopRenderingLineAfter = stopRenderingLineAfter;
  38061. this.renderWhitespace = (renderWhitespace === 'all'
  38062. ? 3 /* All */
  38063. : renderWhitespace === 'boundary'
  38064. ? 1 /* Boundary */
  38065. : renderWhitespace === 'selection'
  38066. ? 2 /* Selection */
  38067. : 0 /* None */);
  38068. this.renderControlCharacters = renderControlCharacters;
  38069. this.fontLigatures = fontLigatures;
  38070. this.selectionsOnLine = selectionsOnLine && selectionsOnLine.sort(function (a, b) { return a.startOffset < b.startOffset ? -1 : 1; });
  38071. }
  38072. RenderLineInput.prototype.sameSelection = function (otherSelections) {
  38073. if (this.selectionsOnLine === null) {
  38074. return otherSelections === null;
  38075. }
  38076. if (otherSelections === null) {
  38077. return false;
  38078. }
  38079. if (otherSelections.length !== this.selectionsOnLine.length) {
  38080. return false;
  38081. }
  38082. for (var i = 0; i < this.selectionsOnLine.length; i++) {
  38083. if (!this.selectionsOnLine[i].equals(otherSelections[i])) {
  38084. return false;
  38085. }
  38086. }
  38087. return true;
  38088. };
  38089. RenderLineInput.prototype.equals = function (other) {
  38090. return (this.useMonospaceOptimizations === other.useMonospaceOptimizations
  38091. && this.canUseHalfwidthRightwardsArrow === other.canUseHalfwidthRightwardsArrow
  38092. && this.lineContent === other.lineContent
  38093. && this.continuesWithWrappedLine === other.continuesWithWrappedLine
  38094. && this.isBasicASCII === other.isBasicASCII
  38095. && this.containsRTL === other.containsRTL
  38096. && this.fauxIndentLength === other.fauxIndentLength
  38097. && this.tabSize === other.tabSize
  38098. && this.startVisibleColumn === other.startVisibleColumn
  38099. && this.spaceWidth === other.spaceWidth
  38100. && this.stopRenderingLineAfter === other.stopRenderingLineAfter
  38101. && this.renderWhitespace === other.renderWhitespace
  38102. && this.renderControlCharacters === other.renderControlCharacters
  38103. && this.fontLigatures === other.fontLigatures
  38104. && lineDecorations_1.LineDecoration.equalsArr(this.lineDecorations, other.lineDecorations)
  38105. && this.lineTokens.equals(other.lineTokens)
  38106. && this.sameSelection(other.selectionsOnLine));
  38107. };
  38108. return RenderLineInput;
  38109. }());
  38110. exports.RenderLineInput = RenderLineInput;
  38111. /**
  38112. * Provides a both direction mapping between a line's character and its rendered position.
  38113. */
  38114. var CharacterMapping = /** @class */ (function () {
  38115. function CharacterMapping(length, partCount) {
  38116. this.length = length;
  38117. this._data = new Uint32Array(this.length);
  38118. this._absoluteOffsets = new Uint32Array(this.length);
  38119. }
  38120. CharacterMapping.getPartIndex = function (partData) {
  38121. return (partData & 4294901760 /* PART_INDEX_MASK */) >>> 16 /* PART_INDEX_OFFSET */;
  38122. };
  38123. CharacterMapping.getCharIndex = function (partData) {
  38124. return (partData & 65535 /* CHAR_INDEX_MASK */) >>> 0 /* CHAR_INDEX_OFFSET */;
  38125. };
  38126. CharacterMapping.prototype.setPartData = function (charOffset, partIndex, charIndex, partAbsoluteOffset) {
  38127. var partData = ((partIndex << 16 /* PART_INDEX_OFFSET */)
  38128. | (charIndex << 0 /* CHAR_INDEX_OFFSET */)) >>> 0;
  38129. this._data[charOffset] = partData;
  38130. this._absoluteOffsets[charOffset] = partAbsoluteOffset + charIndex;
  38131. };
  38132. CharacterMapping.prototype.getAbsoluteOffsets = function () {
  38133. return this._absoluteOffsets;
  38134. };
  38135. CharacterMapping.prototype.charOffsetToPartData = function (charOffset) {
  38136. if (this.length === 0) {
  38137. return 0;
  38138. }
  38139. if (charOffset < 0) {
  38140. return this._data[0];
  38141. }
  38142. if (charOffset >= this.length) {
  38143. return this._data[this.length - 1];
  38144. }
  38145. return this._data[charOffset];
  38146. };
  38147. CharacterMapping.prototype.partDataToCharOffset = function (partIndex, partLength, charIndex) {
  38148. if (this.length === 0) {
  38149. return 0;
  38150. }
  38151. var searchEntry = ((partIndex << 16 /* PART_INDEX_OFFSET */)
  38152. | (charIndex << 0 /* CHAR_INDEX_OFFSET */)) >>> 0;
  38153. var min = 0;
  38154. var max = this.length - 1;
  38155. while (min + 1 < max) {
  38156. var mid = ((min + max) >>> 1);
  38157. var midEntry = this._data[mid];
  38158. if (midEntry === searchEntry) {
  38159. return mid;
  38160. }
  38161. else if (midEntry > searchEntry) {
  38162. max = mid;
  38163. }
  38164. else {
  38165. min = mid;
  38166. }
  38167. }
  38168. if (min === max) {
  38169. return min;
  38170. }
  38171. var minEntry = this._data[min];
  38172. var maxEntry = this._data[max];
  38173. if (minEntry === searchEntry) {
  38174. return min;
  38175. }
  38176. if (maxEntry === searchEntry) {
  38177. return max;
  38178. }
  38179. var minPartIndex = CharacterMapping.getPartIndex(minEntry);
  38180. var minCharIndex = CharacterMapping.getCharIndex(minEntry);
  38181. var maxPartIndex = CharacterMapping.getPartIndex(maxEntry);
  38182. var maxCharIndex;
  38183. if (minPartIndex !== maxPartIndex) {
  38184. // sitting between parts
  38185. maxCharIndex = partLength;
  38186. }
  38187. else {
  38188. maxCharIndex = CharacterMapping.getCharIndex(maxEntry);
  38189. }
  38190. var minEntryDistance = charIndex - minCharIndex;
  38191. var maxEntryDistance = maxCharIndex - charIndex;
  38192. if (minEntryDistance <= maxEntryDistance) {
  38193. return min;
  38194. }
  38195. return max;
  38196. };
  38197. return CharacterMapping;
  38198. }());
  38199. exports.CharacterMapping = CharacterMapping;
  38200. var RenderLineOutput = /** @class */ (function () {
  38201. function RenderLineOutput(characterMapping, containsRTL, containsForeignElements) {
  38202. this.characterMapping = characterMapping;
  38203. this.containsRTL = containsRTL;
  38204. this.containsForeignElements = containsForeignElements;
  38205. }
  38206. return RenderLineOutput;
  38207. }());
  38208. exports.RenderLineOutput = RenderLineOutput;
  38209. function renderViewLine(input, sb) {
  38210. if (input.lineContent.length === 0) {
  38211. var containsForeignElements = 0 /* None */;
  38212. // This is basically for IE's hit test to work
  38213. var content = '<span><span>\u00a0</span></span>';
  38214. if (input.lineDecorations.length > 0) {
  38215. // This line is empty, but it contains inline decorations
  38216. var beforeClassNames = [];
  38217. var afterClassNames = [];
  38218. for (var i = 0, len = input.lineDecorations.length; i < len; i++) {
  38219. var lineDecoration = input.lineDecorations[i];
  38220. if (lineDecoration.type === 1 /* Before */) {
  38221. beforeClassNames.push(input.lineDecorations[i].className);
  38222. containsForeignElements |= 1 /* Before */;
  38223. }
  38224. if (lineDecoration.type === 2 /* After */) {
  38225. afterClassNames.push(input.lineDecorations[i].className);
  38226. containsForeignElements |= 2 /* After */;
  38227. }
  38228. }
  38229. if (containsForeignElements !== 0 /* None */) {
  38230. var beforeSpan = (beforeClassNames.length > 0 ? "<span class=\"" + beforeClassNames.join(' ') + "\"></span>" : "");
  38231. var afterSpan = (afterClassNames.length > 0 ? "<span class=\"" + afterClassNames.join(' ') + "\"></span>" : "");
  38232. content = "<span>" + beforeSpan + afterSpan + "</span>";
  38233. }
  38234. }
  38235. sb.appendASCIIString(content);
  38236. return new RenderLineOutput(new CharacterMapping(0, 0), false, containsForeignElements);
  38237. }
  38238. return _renderLine(resolveRenderLineInput(input), sb);
  38239. }
  38240. exports.renderViewLine = renderViewLine;
  38241. var RenderLineOutput2 = /** @class */ (function () {
  38242. function RenderLineOutput2(characterMapping, html, containsRTL, containsForeignElements) {
  38243. this.characterMapping = characterMapping;
  38244. this.html = html;
  38245. this.containsRTL = containsRTL;
  38246. this.containsForeignElements = containsForeignElements;
  38247. }
  38248. return RenderLineOutput2;
  38249. }());
  38250. exports.RenderLineOutput2 = RenderLineOutput2;
  38251. function renderViewLine2(input) {
  38252. var sb = stringBuilder_1.createStringBuilder(10000);
  38253. var out = renderViewLine(input, sb);
  38254. return new RenderLineOutput2(out.characterMapping, sb.build(), out.containsRTL, out.containsForeignElements);
  38255. }
  38256. exports.renderViewLine2 = renderViewLine2;
  38257. var ResolvedRenderLineInput = /** @class */ (function () {
  38258. function ResolvedRenderLineInput(fontIsMonospace, canUseHalfwidthRightwardsArrow, lineContent, len, isOverflowing, parts, containsForeignElements, fauxIndentLength, tabSize, startVisibleColumn, containsRTL, spaceWidth, middotWidth, renderWhitespace, renderControlCharacters) {
  38259. this.fontIsMonospace = fontIsMonospace;
  38260. this.canUseHalfwidthRightwardsArrow = canUseHalfwidthRightwardsArrow;
  38261. this.lineContent = lineContent;
  38262. this.len = len;
  38263. this.isOverflowing = isOverflowing;
  38264. this.parts = parts;
  38265. this.containsForeignElements = containsForeignElements;
  38266. this.fauxIndentLength = fauxIndentLength;
  38267. this.tabSize = tabSize;
  38268. this.startVisibleColumn = startVisibleColumn;
  38269. this.containsRTL = containsRTL;
  38270. this.spaceWidth = spaceWidth;
  38271. this.middotWidth = middotWidth;
  38272. this.renderWhitespace = renderWhitespace;
  38273. this.renderControlCharacters = renderControlCharacters;
  38274. //
  38275. }
  38276. return ResolvedRenderLineInput;
  38277. }());
  38278. function resolveRenderLineInput(input) {
  38279. var useMonospaceOptimizations = input.useMonospaceOptimizations;
  38280. var lineContent = input.lineContent;
  38281. var isOverflowing;
  38282. var len;
  38283. if (input.stopRenderingLineAfter !== -1 && input.stopRenderingLineAfter < lineContent.length) {
  38284. isOverflowing = true;
  38285. len = input.stopRenderingLineAfter;
  38286. }
  38287. else {
  38288. isOverflowing = false;
  38289. len = lineContent.length;
  38290. }
  38291. var tokens = transformAndRemoveOverflowing(input.lineTokens, input.fauxIndentLength, len);
  38292. if (input.renderWhitespace === 3 /* All */ || input.renderWhitespace === 1 /* Boundary */ || (input.renderWhitespace === 2 /* Selection */ && !!input.selectionsOnLine)) {
  38293. tokens = _applyRenderWhitespace(lineContent, len, input.continuesWithWrappedLine, tokens, input.fauxIndentLength, input.tabSize, input.startVisibleColumn, useMonospaceOptimizations, input.selectionsOnLine, input.renderWhitespace === 1 /* Boundary */);
  38294. }
  38295. var containsForeignElements = 0 /* None */;
  38296. if (input.lineDecorations.length > 0) {
  38297. for (var i = 0, len_1 = input.lineDecorations.length; i < len_1; i++) {
  38298. var lineDecoration = input.lineDecorations[i];
  38299. if (lineDecoration.type === 3 /* RegularAffectingLetterSpacing */) {
  38300. // Pretend there are foreign elements... although not 100% accurate.
  38301. containsForeignElements |= 1 /* Before */;
  38302. }
  38303. else if (lineDecoration.type === 1 /* Before */) {
  38304. containsForeignElements |= 1 /* Before */;
  38305. }
  38306. else if (lineDecoration.type === 2 /* After */) {
  38307. containsForeignElements |= 2 /* After */;
  38308. }
  38309. }
  38310. tokens = _applyInlineDecorations(lineContent, len, tokens, input.lineDecorations);
  38311. }
  38312. if (!input.containsRTL) {
  38313. // We can never split RTL text, as it ruins the rendering
  38314. tokens = splitLargeTokens(lineContent, tokens, !input.isBasicASCII || input.fontLigatures);
  38315. }
  38316. return new ResolvedRenderLineInput(useMonospaceOptimizations, input.canUseHalfwidthRightwardsArrow, lineContent, len, isOverflowing, tokens, containsForeignElements, input.fauxIndentLength, input.tabSize, input.startVisibleColumn, input.containsRTL, input.spaceWidth, input.middotWidth, input.renderWhitespace, input.renderControlCharacters);
  38317. }
  38318. /**
  38319. * In the rendering phase, characters are always looped until token.endIndex.
  38320. * Ensure that all tokens end before `len` and the last one ends precisely at `len`.
  38321. */
  38322. function transformAndRemoveOverflowing(tokens, fauxIndentLength, len) {
  38323. var result = [], resultLen = 0;
  38324. // The faux indent part of the line should have no token type
  38325. if (fauxIndentLength > 0) {
  38326. result[resultLen++] = new LinePart(fauxIndentLength, '');
  38327. }
  38328. for (var tokenIndex = 0, tokensLen = tokens.getCount(); tokenIndex < tokensLen; tokenIndex++) {
  38329. var endIndex = tokens.getEndOffset(tokenIndex);
  38330. if (endIndex <= fauxIndentLength) {
  38331. // The faux indent part of the line should have no token type
  38332. continue;
  38333. }
  38334. var type = tokens.getClassName(tokenIndex);
  38335. if (endIndex >= len) {
  38336. result[resultLen++] = new LinePart(len, type);
  38337. break;
  38338. }
  38339. result[resultLen++] = new LinePart(endIndex, type);
  38340. }
  38341. return result;
  38342. }
  38343. /**
  38344. * See https://github.com/Microsoft/vscode/issues/6885.
  38345. * It appears that having very large spans causes very slow reading of character positions.
  38346. * So here we try to avoid that.
  38347. */
  38348. function splitLargeTokens(lineContent, tokens, onlyAtSpaces) {
  38349. var lastTokenEndIndex = 0;
  38350. var result = [], resultLen = 0;
  38351. if (onlyAtSpaces) {
  38352. // Split only at spaces => we need to walk each character
  38353. for (var i = 0, len = tokens.length; i < len; i++) {
  38354. var token = tokens[i];
  38355. var tokenEndIndex = token.endIndex;
  38356. if (lastTokenEndIndex + 50 /* LongToken */ < tokenEndIndex) {
  38357. var tokenType = token.type;
  38358. var lastSpaceOffset = -1;
  38359. var currTokenStart = lastTokenEndIndex;
  38360. for (var j = lastTokenEndIndex; j < tokenEndIndex; j++) {
  38361. if (lineContent.charCodeAt(j) === 32 /* Space */) {
  38362. lastSpaceOffset = j;
  38363. }
  38364. if (lastSpaceOffset !== -1 && j - currTokenStart >= 50 /* LongToken */) {
  38365. // Split at `lastSpaceOffset` + 1
  38366. result[resultLen++] = new LinePart(lastSpaceOffset + 1, tokenType);
  38367. currTokenStart = lastSpaceOffset + 1;
  38368. lastSpaceOffset = -1;
  38369. }
  38370. }
  38371. if (currTokenStart !== tokenEndIndex) {
  38372. result[resultLen++] = new LinePart(tokenEndIndex, tokenType);
  38373. }
  38374. }
  38375. else {
  38376. result[resultLen++] = token;
  38377. }
  38378. lastTokenEndIndex = tokenEndIndex;
  38379. }
  38380. }
  38381. else {
  38382. // Split anywhere => we don't need to walk each character
  38383. for (var i = 0, len = tokens.length; i < len; i++) {
  38384. var token = tokens[i];
  38385. var tokenEndIndex = token.endIndex;
  38386. var diff = (tokenEndIndex - lastTokenEndIndex);
  38387. if (diff > 50 /* LongToken */) {
  38388. var tokenType = token.type;
  38389. var piecesCount = Math.ceil(diff / 50 /* LongToken */);
  38390. for (var j = 1; j < piecesCount; j++) {
  38391. var pieceEndIndex = lastTokenEndIndex + (j * 50 /* LongToken */);
  38392. result[resultLen++] = new LinePart(pieceEndIndex, tokenType);
  38393. }
  38394. result[resultLen++] = new LinePart(tokenEndIndex, tokenType);
  38395. }
  38396. else {
  38397. result[resultLen++] = token;
  38398. }
  38399. lastTokenEndIndex = tokenEndIndex;
  38400. }
  38401. }
  38402. return result;
  38403. }
  38404. /**
  38405. * Whitespace is rendered by "replacing" tokens with a special-purpose `vs-whitespace` type that is later recognized in the rendering phase.
  38406. * Moreover, a token is created for every visual indent because on some fonts the glyphs used for rendering whitespace (&rarr; or &middot;) do not have the same width as &nbsp;.
  38407. * The rendering phase will generate `style="width:..."` for these tokens.
  38408. */
  38409. function _applyRenderWhitespace(lineContent, len, continuesWithWrappedLine, tokens, fauxIndentLength, tabSize, startVisibleColumn, useMonospaceOptimizations, selections, onlyBoundary) {
  38410. var result = [], resultLen = 0;
  38411. var tokenIndex = 0;
  38412. var tokenType = tokens[tokenIndex].type;
  38413. var tokenEndIndex = tokens[tokenIndex].endIndex;
  38414. var tokensLength = tokens.length;
  38415. var firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
  38416. var lastNonWhitespaceIndex;
  38417. if (firstNonWhitespaceIndex === -1) {
  38418. // The entire line is whitespace
  38419. firstNonWhitespaceIndex = len;
  38420. lastNonWhitespaceIndex = len;
  38421. }
  38422. else {
  38423. lastNonWhitespaceIndex = strings.lastNonWhitespaceIndex(lineContent);
  38424. }
  38425. var wasInWhitespace = false;
  38426. var currentSelectionIndex = 0;
  38427. var currentSelection = selections && selections[currentSelectionIndex];
  38428. var tmpIndent = startVisibleColumn % tabSize;
  38429. for (var charIndex = fauxIndentLength; charIndex < len; charIndex++) {
  38430. var chCode = lineContent.charCodeAt(charIndex);
  38431. if (currentSelection && charIndex >= currentSelection.endOffset) {
  38432. currentSelectionIndex++;
  38433. currentSelection = selections && selections[currentSelectionIndex];
  38434. }
  38435. var isInWhitespace = void 0;
  38436. if (charIndex < firstNonWhitespaceIndex || charIndex > lastNonWhitespaceIndex) {
  38437. // in leading or trailing whitespace
  38438. isInWhitespace = true;
  38439. }
  38440. else if (chCode === 9 /* Tab */) {
  38441. // a tab character is rendered both in all and boundary cases
  38442. isInWhitespace = true;
  38443. }
  38444. else if (chCode === 32 /* Space */) {
  38445. // hit a space character
  38446. if (onlyBoundary) {
  38447. // rendering only boundary whitespace
  38448. if (wasInWhitespace) {
  38449. isInWhitespace = true;
  38450. }
  38451. else {
  38452. var nextChCode = (charIndex + 1 < len ? lineContent.charCodeAt(charIndex + 1) : 0 /* Null */);
  38453. isInWhitespace = (nextChCode === 32 /* Space */ || nextChCode === 9 /* Tab */);
  38454. }
  38455. }
  38456. else {
  38457. isInWhitespace = true;
  38458. }
  38459. }
  38460. else {
  38461. isInWhitespace = false;
  38462. }
  38463. // If rendering whitespace on selection, check that the charIndex falls within a selection
  38464. if (isInWhitespace && selections) {
  38465. isInWhitespace = !!currentSelection && currentSelection.startOffset <= charIndex && currentSelection.endOffset > charIndex;
  38466. }
  38467. if (wasInWhitespace) {
  38468. // was in whitespace token
  38469. if (!isInWhitespace || (!useMonospaceOptimizations && tmpIndent >= tabSize)) {
  38470. // leaving whitespace token or entering a new indent
  38471. result[resultLen++] = new LinePart(charIndex, 'vs-whitespace');
  38472. tmpIndent = tmpIndent % tabSize;
  38473. }
  38474. }
  38475. else {
  38476. // was in regular token
  38477. if (charIndex === tokenEndIndex || (isInWhitespace && charIndex > fauxIndentLength)) {
  38478. result[resultLen++] = new LinePart(charIndex, tokenType);
  38479. tmpIndent = tmpIndent % tabSize;
  38480. }
  38481. }
  38482. if (chCode === 9 /* Tab */) {
  38483. tmpIndent = tabSize;
  38484. }
  38485. else if (strings.isFullWidthCharacter(chCode)) {
  38486. tmpIndent += 2;
  38487. }
  38488. else {
  38489. tmpIndent++;
  38490. }
  38491. wasInWhitespace = isInWhitespace;
  38492. if (charIndex === tokenEndIndex) {
  38493. tokenIndex++;
  38494. if (tokenIndex < tokensLength) {
  38495. tokenType = tokens[tokenIndex].type;
  38496. tokenEndIndex = tokens[tokenIndex].endIndex;
  38497. }
  38498. }
  38499. }
  38500. var generateWhitespace = false;
  38501. if (wasInWhitespace) {
  38502. // was in whitespace token
  38503. if (continuesWithWrappedLine && onlyBoundary) {
  38504. var lastCharCode = (len > 0 ? lineContent.charCodeAt(len - 1) : 0 /* Null */);
  38505. var prevCharCode = (len > 1 ? lineContent.charCodeAt(len - 2) : 0 /* Null */);
  38506. var isSingleTrailingSpace = (lastCharCode === 32 /* Space */ && (prevCharCode !== 32 /* Space */ && prevCharCode !== 9 /* Tab */));
  38507. if (!isSingleTrailingSpace) {
  38508. generateWhitespace = true;
  38509. }
  38510. }
  38511. else {
  38512. generateWhitespace = true;
  38513. }
  38514. }
  38515. result[resultLen++] = new LinePart(len, generateWhitespace ? 'vs-whitespace' : tokenType);
  38516. return result;
  38517. }
  38518. /**
  38519. * Inline decorations are "merged" on top of tokens.
  38520. * Special care must be taken when multiple inline decorations are at play and they overlap.
  38521. */
  38522. function _applyInlineDecorations(lineContent, len, tokens, _lineDecorations) {
  38523. _lineDecorations.sort(lineDecorations_1.LineDecoration.compare);
  38524. var lineDecorations = lineDecorations_1.LineDecorationsNormalizer.normalize(lineContent, _lineDecorations);
  38525. var lineDecorationsLen = lineDecorations.length;
  38526. var lineDecorationIndex = 0;
  38527. var result = [], resultLen = 0, lastResultEndIndex = 0;
  38528. for (var tokenIndex = 0, len_2 = tokens.length; tokenIndex < len_2; tokenIndex++) {
  38529. var token = tokens[tokenIndex];
  38530. var tokenEndIndex = token.endIndex;
  38531. var tokenType = token.type;
  38532. while (lineDecorationIndex < lineDecorationsLen && lineDecorations[lineDecorationIndex].startOffset < tokenEndIndex) {
  38533. var lineDecoration = lineDecorations[lineDecorationIndex];
  38534. if (lineDecoration.startOffset > lastResultEndIndex) {
  38535. lastResultEndIndex = lineDecoration.startOffset;
  38536. result[resultLen++] = new LinePart(lastResultEndIndex, tokenType);
  38537. }
  38538. if (lineDecoration.endOffset + 1 <= tokenEndIndex) {
  38539. // This line decoration ends before this token ends
  38540. lastResultEndIndex = lineDecoration.endOffset + 1;
  38541. result[resultLen++] = new LinePart(lastResultEndIndex, tokenType + ' ' + lineDecoration.className);
  38542. lineDecorationIndex++;
  38543. }
  38544. else {
  38545. // This line decoration continues on to the next token
  38546. lastResultEndIndex = tokenEndIndex;
  38547. result[resultLen++] = new LinePart(lastResultEndIndex, tokenType + ' ' + lineDecoration.className);
  38548. break;
  38549. }
  38550. }
  38551. if (tokenEndIndex > lastResultEndIndex) {
  38552. lastResultEndIndex = tokenEndIndex;
  38553. result[resultLen++] = new LinePart(lastResultEndIndex, tokenType);
  38554. }
  38555. }
  38556. var lastTokenEndIndex = tokens[tokens.length - 1].endIndex;
  38557. if (lineDecorationIndex < lineDecorationsLen && lineDecorations[lineDecorationIndex].startOffset === lastTokenEndIndex) {
  38558. var classNames = [];
  38559. while (lineDecorationIndex < lineDecorationsLen && lineDecorations[lineDecorationIndex].startOffset === lastTokenEndIndex) {
  38560. classNames.push(lineDecorations[lineDecorationIndex].className);
  38561. lineDecorationIndex++;
  38562. }
  38563. result[resultLen++] = new LinePart(lastResultEndIndex, classNames.join(' '));
  38564. }
  38565. return result;
  38566. }
  38567. /**
  38568. * This function is on purpose not split up into multiple functions to allow runtime type inference (i.e. performance reasons).
  38569. * Notice how all the needed data is fully resolved and passed in (i.e. no other calls).
  38570. */
  38571. function _renderLine(input, sb) {
  38572. var fontIsMonospace = input.fontIsMonospace;
  38573. var canUseHalfwidthRightwardsArrow = input.canUseHalfwidthRightwardsArrow;
  38574. var containsForeignElements = input.containsForeignElements;
  38575. var lineContent = input.lineContent;
  38576. var len = input.len;
  38577. var isOverflowing = input.isOverflowing;
  38578. var parts = input.parts;
  38579. var fauxIndentLength = input.fauxIndentLength;
  38580. var tabSize = input.tabSize;
  38581. var startVisibleColumn = input.startVisibleColumn;
  38582. var containsRTL = input.containsRTL;
  38583. var spaceWidth = input.spaceWidth;
  38584. var middotWidth = input.middotWidth;
  38585. var renderWhitespace = input.renderWhitespace;
  38586. var renderControlCharacters = input.renderControlCharacters;
  38587. // use U+2E31 - WORD SEPARATOR MIDDLE DOT or U+00B7 - MIDDLE DOT
  38588. var spaceRenderWhitespaceCharacter = (middotWidth > spaceWidth ? 0x2E31 : 0xB7);
  38589. var characterMapping = new CharacterMapping(len + 1, parts.length);
  38590. var charIndex = 0;
  38591. var visibleColumn = startVisibleColumn;
  38592. var charOffsetInPart = 0;
  38593. var prevPartContentCnt = 0;
  38594. var partAbsoluteOffset = 0;
  38595. sb.appendASCIIString('<span>');
  38596. for (var partIndex = 0, tokensLen = parts.length; partIndex < tokensLen; partIndex++) {
  38597. partAbsoluteOffset += prevPartContentCnt;
  38598. var part = parts[partIndex];
  38599. var partEndIndex = part.endIndex;
  38600. var partType = part.type;
  38601. var partRendersWhitespace = (renderWhitespace !== 0 /* None */ && (partType.indexOf('vs-whitespace') >= 0));
  38602. charOffsetInPart = 0;
  38603. sb.appendASCIIString('<span class="');
  38604. sb.appendASCIIString(partType);
  38605. sb.appendASCII(34 /* DoubleQuote */);
  38606. if (partRendersWhitespace) {
  38607. var partContentCnt = 0;
  38608. {
  38609. var _charIndex = charIndex;
  38610. var _visibleColumn = visibleColumn;
  38611. for (; _charIndex < partEndIndex; _charIndex++) {
  38612. var charCode = lineContent.charCodeAt(_charIndex);
  38613. var charWidth = (charCode === 9 /* Tab */ ? (tabSize - (_visibleColumn % tabSize)) : 1) | 0;
  38614. partContentCnt += charWidth;
  38615. if (_charIndex >= fauxIndentLength) {
  38616. _visibleColumn += charWidth;
  38617. }
  38618. }
  38619. }
  38620. if (!fontIsMonospace) {
  38621. var partIsOnlyWhitespace = (partType === 'vs-whitespace');
  38622. if (partIsOnlyWhitespace || !containsForeignElements) {
  38623. sb.appendASCIIString(' style="display:inline-block;width:');
  38624. sb.appendASCIIString(String(spaceWidth * partContentCnt));
  38625. sb.appendASCIIString('px"');
  38626. }
  38627. }
  38628. sb.appendASCII(62 /* GreaterThan */);
  38629. for (; charIndex < partEndIndex; charIndex++) {
  38630. characterMapping.setPartData(charIndex, partIndex, charOffsetInPart, partAbsoluteOffset);
  38631. var charCode = lineContent.charCodeAt(charIndex);
  38632. var charWidth = void 0;
  38633. if (charCode === 9 /* Tab */) {
  38634. charWidth = (tabSize - (visibleColumn % tabSize)) | 0;
  38635. if (!canUseHalfwidthRightwardsArrow || charWidth > 1) {
  38636. sb.write1(0x2192); // RIGHTWARDS ARROW
  38637. }
  38638. else {
  38639. sb.write1(0xFFEB); // HALFWIDTH RIGHTWARDS ARROW
  38640. }
  38641. for (var space = 2; space <= charWidth; space++) {
  38642. sb.write1(0xA0); // &nbsp;
  38643. }
  38644. }
  38645. else { // must be CharCode.Space
  38646. charWidth = 1;
  38647. sb.write1(spaceRenderWhitespaceCharacter); // &middot; or word separator middle dot
  38648. }
  38649. charOffsetInPart += charWidth;
  38650. if (charIndex >= fauxIndentLength) {
  38651. visibleColumn += charWidth;
  38652. }
  38653. }
  38654. prevPartContentCnt = partContentCnt;
  38655. }
  38656. else {
  38657. var partContentCnt = 0;
  38658. if (containsRTL) {
  38659. sb.appendASCIIString(' dir="ltr"');
  38660. }
  38661. sb.appendASCII(62 /* GreaterThan */);
  38662. for (; charIndex < partEndIndex; charIndex++) {
  38663. characterMapping.setPartData(charIndex, partIndex, charOffsetInPart, partAbsoluteOffset);
  38664. var charCode = lineContent.charCodeAt(charIndex);
  38665. var producedCharacters = 1;
  38666. var charWidth = 1;
  38667. switch (charCode) {
  38668. case 9 /* Tab */:
  38669. producedCharacters = (tabSize - (visibleColumn % tabSize));
  38670. charWidth = producedCharacters;
  38671. for (var space = 1; space <= producedCharacters; space++) {
  38672. sb.write1(0xA0); // &nbsp;
  38673. }
  38674. break;
  38675. case 32 /* Space */:
  38676. sb.write1(0xA0); // &nbsp;
  38677. break;
  38678. case 60 /* LessThan */:
  38679. sb.appendASCIIString('&lt;');
  38680. break;
  38681. case 62 /* GreaterThan */:
  38682. sb.appendASCIIString('&gt;');
  38683. break;
  38684. case 38 /* Ampersand */:
  38685. sb.appendASCIIString('&amp;');
  38686. break;
  38687. case 0 /* Null */:
  38688. sb.appendASCIIString('&#00;');
  38689. break;
  38690. case 65279 /* UTF8_BOM */:
  38691. case 8232 /* LINE_SEPARATOR_2028 */:
  38692. sb.write1(0xFFFD);
  38693. break;
  38694. default:
  38695. if (strings.isFullWidthCharacter(charCode)) {
  38696. charWidth++;
  38697. }
  38698. if (renderControlCharacters && charCode < 32) {
  38699. sb.write1(9216 + charCode);
  38700. }
  38701. else {
  38702. sb.write1(charCode);
  38703. }
  38704. }
  38705. charOffsetInPart += producedCharacters;
  38706. partContentCnt += producedCharacters;
  38707. if (charIndex >= fauxIndentLength) {
  38708. visibleColumn += charWidth;
  38709. }
  38710. }
  38711. prevPartContentCnt = partContentCnt;
  38712. }
  38713. sb.appendASCIIString('</span>');
  38714. }
  38715. // When getting client rects for the last character, we will position the
  38716. // text range at the end of the span, insteaf of at the beginning of next span
  38717. characterMapping.setPartData(len, parts.length - 1, charOffsetInPart, partAbsoluteOffset);
  38718. if (isOverflowing) {
  38719. sb.appendASCIIString('<span>&hellip;</span>');
  38720. }
  38721. sb.appendASCIIString('</span>');
  38722. return new RenderLineOutput(characterMapping, containsRTL, containsForeignElements);
  38723. }
  38724. });
  38725. /*---------------------------------------------------------------------------------------------
  38726. * Copyright (c) Microsoft Corporation. All rights reserved.
  38727. * Licensed under the MIT License. See License.txt in the project root for license information.
  38728. *--------------------------------------------------------------------------------------------*/
  38729. define(__m[363/*vs/editor/common/viewLayout/viewLinesViewportData*/], __M([0/*require*/,1/*exports*/,3/*vs/editor/common/core/range*/]), function (require, exports, range_1) {
  38730. "use strict";
  38731. Object.defineProperty(exports, "__esModule", { value: true });
  38732. /**
  38733. * Contains all data needed to render at a specific viewport.
  38734. */
  38735. var ViewportData = /** @class */ (function () {
  38736. function ViewportData(selections, partialData, whitespaceViewportData, model) {
  38737. this.selections = selections;
  38738. this.startLineNumber = partialData.startLineNumber | 0;
  38739. this.endLineNumber = partialData.endLineNumber | 0;
  38740. this.relativeVerticalOffset = partialData.relativeVerticalOffset;
  38741. this.bigNumbersDelta = partialData.bigNumbersDelta | 0;
  38742. this.whitespaceViewportData = whitespaceViewportData;
  38743. this._model = model;
  38744. this.visibleRange = new range_1.Range(partialData.startLineNumber, this._model.getLineMinColumn(partialData.startLineNumber), partialData.endLineNumber, this._model.getLineMaxColumn(partialData.endLineNumber));
  38745. }
  38746. ViewportData.prototype.getViewLineRenderingData = function (lineNumber) {
  38747. return this._model.getViewLineRenderingData(this.visibleRange, lineNumber);
  38748. };
  38749. ViewportData.prototype.getDecorationsInViewport = function () {
  38750. return this._model.getDecorationsInViewport(this.visibleRange);
  38751. };
  38752. return ViewportData;
  38753. }());
  38754. exports.ViewportData = ViewportData;
  38755. });
  38756. /*---------------------------------------------------------------------------------------------
  38757. * Copyright (c) Microsoft Corporation. All rights reserved.
  38758. * Licensed under the MIT License. See License.txt in the project root for license information.
  38759. *--------------------------------------------------------------------------------------------*/
  38760. define(__m[194/*vs/editor/common/viewModel/prefixSumComputer*/], __M([0/*require*/,1/*exports*/,179/*vs/base/common/uint*/]), function (require, exports, uint_1) {
  38761. "use strict";
  38762. Object.defineProperty(exports, "__esModule", { value: true });
  38763. var PrefixSumIndexOfResult = /** @class */ (function () {
  38764. function PrefixSumIndexOfResult(index, remainder) {
  38765. this.index = index;
  38766. this.remainder = remainder;
  38767. }
  38768. return PrefixSumIndexOfResult;
  38769. }());
  38770. exports.PrefixSumIndexOfResult = PrefixSumIndexOfResult;
  38771. var PrefixSumComputer = /** @class */ (function () {
  38772. function PrefixSumComputer(values) {
  38773. this.values = values;
  38774. this.prefixSum = new Uint32Array(values.length);
  38775. this.prefixSumValidIndex = new Int32Array(1);
  38776. this.prefixSumValidIndex[0] = -1;
  38777. }
  38778. PrefixSumComputer.prototype.insertValues = function (insertIndex, insertValues) {
  38779. insertIndex = uint_1.toUint32(insertIndex);
  38780. var oldValues = this.values;
  38781. var oldPrefixSum = this.prefixSum;
  38782. var insertValuesLen = insertValues.length;
  38783. if (insertValuesLen === 0) {
  38784. return false;
  38785. }
  38786. this.values = new Uint32Array(oldValues.length + insertValuesLen);
  38787. this.values.set(oldValues.subarray(0, insertIndex), 0);
  38788. this.values.set(oldValues.subarray(insertIndex), insertIndex + insertValuesLen);
  38789. this.values.set(insertValues, insertIndex);
  38790. if (insertIndex - 1 < this.prefixSumValidIndex[0]) {
  38791. this.prefixSumValidIndex[0] = insertIndex - 1;
  38792. }
  38793. this.prefixSum = new Uint32Array(this.values.length);
  38794. if (this.prefixSumValidIndex[0] >= 0) {
  38795. this.prefixSum.set(oldPrefixSum.subarray(0, this.prefixSumValidIndex[0] + 1));
  38796. }
  38797. return true;
  38798. };
  38799. PrefixSumComputer.prototype.changeValue = function (index, value) {
  38800. index = uint_1.toUint32(index);
  38801. value = uint_1.toUint32(value);
  38802. if (this.values[index] === value) {
  38803. return false;
  38804. }
  38805. this.values[index] = value;
  38806. if (index - 1 < this.prefixSumValidIndex[0]) {
  38807. this.prefixSumValidIndex[0] = index - 1;
  38808. }
  38809. return true;
  38810. };
  38811. PrefixSumComputer.prototype.removeValues = function (startIndex, cnt) {
  38812. startIndex = uint_1.toUint32(startIndex);
  38813. cnt = uint_1.toUint32(cnt);
  38814. var oldValues = this.values;
  38815. var oldPrefixSum = this.prefixSum;
  38816. if (startIndex >= oldValues.length) {
  38817. return false;
  38818. }
  38819. var maxCnt = oldValues.length - startIndex;
  38820. if (cnt >= maxCnt) {
  38821. cnt = maxCnt;
  38822. }
  38823. if (cnt === 0) {
  38824. return false;
  38825. }
  38826. this.values = new Uint32Array(oldValues.length - cnt);
  38827. this.values.set(oldValues.subarray(0, startIndex), 0);
  38828. this.values.set(oldValues.subarray(startIndex + cnt), startIndex);
  38829. this.prefixSum = new Uint32Array(this.values.length);
  38830. if (startIndex - 1 < this.prefixSumValidIndex[0]) {
  38831. this.prefixSumValidIndex[0] = startIndex - 1;
  38832. }
  38833. if (this.prefixSumValidIndex[0] >= 0) {
  38834. this.prefixSum.set(oldPrefixSum.subarray(0, this.prefixSumValidIndex[0] + 1));
  38835. }
  38836. return true;
  38837. };
  38838. PrefixSumComputer.prototype.getTotalValue = function () {
  38839. if (this.values.length === 0) {
  38840. return 0;
  38841. }
  38842. return this._getAccumulatedValue(this.values.length - 1);
  38843. };
  38844. PrefixSumComputer.prototype.getAccumulatedValue = function (index) {
  38845. if (index < 0) {
  38846. return 0;
  38847. }
  38848. index = uint_1.toUint32(index);
  38849. return this._getAccumulatedValue(index);
  38850. };
  38851. PrefixSumComputer.prototype._getAccumulatedValue = function (index) {
  38852. if (index <= this.prefixSumValidIndex[0]) {
  38853. return this.prefixSum[index];
  38854. }
  38855. var startIndex = this.prefixSumValidIndex[0] + 1;
  38856. if (startIndex === 0) {
  38857. this.prefixSum[0] = this.values[0];
  38858. startIndex++;
  38859. }
  38860. if (index >= this.values.length) {
  38861. index = this.values.length - 1;
  38862. }
  38863. for (var i = startIndex; i <= index; i++) {
  38864. this.prefixSum[i] = this.prefixSum[i - 1] + this.values[i];
  38865. }
  38866. this.prefixSumValidIndex[0] = Math.max(this.prefixSumValidIndex[0], index);
  38867. return this.prefixSum[index];
  38868. };
  38869. PrefixSumComputer.prototype.getIndexOf = function (accumulatedValue) {
  38870. accumulatedValue = Math.floor(accumulatedValue); //@perf
  38871. // Compute all sums (to get a fully valid prefixSum)
  38872. this.getTotalValue();
  38873. var low = 0;
  38874. var high = this.values.length - 1;
  38875. var mid = 0;
  38876. var midStop = 0;
  38877. var midStart = 0;
  38878. while (low <= high) {
  38879. mid = low + ((high - low) / 2) | 0;
  38880. midStop = this.prefixSum[mid];
  38881. midStart = midStop - this.values[mid];
  38882. if (accumulatedValue < midStart) {
  38883. high = mid - 1;
  38884. }
  38885. else if (accumulatedValue >= midStop) {
  38886. low = mid + 1;
  38887. }
  38888. else {
  38889. break;
  38890. }
  38891. }
  38892. return new PrefixSumIndexOfResult(mid, accumulatedValue - midStart);
  38893. };
  38894. return PrefixSumComputer;
  38895. }());
  38896. exports.PrefixSumComputer = PrefixSumComputer;
  38897. });
  38898. /*---------------------------------------------------------------------------------------------
  38899. * Copyright (c) Microsoft Corporation. All rights reserved.
  38900. * Licensed under the MIT License. See License.txt in the project root for license information.
  38901. *--------------------------------------------------------------------------------------------*/
  38902. define(__m[364/*vs/editor/common/model/mirrorTextModel*/], __M([0/*require*/,1/*exports*/,13/*vs/editor/common/core/position*/,194/*vs/editor/common/viewModel/prefixSumComputer*/]), function (require, exports, position_1, prefixSumComputer_1) {
  38903. "use strict";
  38904. Object.defineProperty(exports, "__esModule", { value: true });
  38905. var MirrorTextModel = /** @class */ (function () {
  38906. function MirrorTextModel(uri, lines, eol, versionId) {
  38907. this._uri = uri;
  38908. this._lines = lines;
  38909. this._eol = eol;
  38910. this._versionId = versionId;
  38911. this._lineStarts = null;
  38912. }
  38913. MirrorTextModel.prototype.dispose = function () {
  38914. this._lines.length = 0;
  38915. };
  38916. MirrorTextModel.prototype.getText = function () {
  38917. return this._lines.join(this._eol);
  38918. };
  38919. MirrorTextModel.prototype.onEvents = function (e) {
  38920. if (e.eol && e.eol !== this._eol) {
  38921. this._eol = e.eol;
  38922. this._lineStarts = null;
  38923. }
  38924. // Update my lines
  38925. var changes = e.changes;
  38926. for (var _i = 0, changes_1 = changes; _i < changes_1.length; _i++) {
  38927. var change = changes_1[_i];
  38928. this._acceptDeleteRange(change.range);
  38929. this._acceptInsertText(new position_1.Position(change.range.startLineNumber, change.range.startColumn), change.text);
  38930. }
  38931. this._versionId = e.versionId;
  38932. };
  38933. MirrorTextModel.prototype._ensureLineStarts = function () {
  38934. if (!this._lineStarts) {
  38935. var eolLength = this._eol.length;
  38936. var linesLength = this._lines.length;
  38937. var lineStartValues = new Uint32Array(linesLength);
  38938. for (var i = 0; i < linesLength; i++) {
  38939. lineStartValues[i] = this._lines[i].length + eolLength;
  38940. }
  38941. this._lineStarts = new prefixSumComputer_1.PrefixSumComputer(lineStartValues);
  38942. }
  38943. };
  38944. /**
  38945. * All changes to a line's text go through this method
  38946. */
  38947. MirrorTextModel.prototype._setLineText = function (lineIndex, newValue) {
  38948. this._lines[lineIndex] = newValue;
  38949. if (this._lineStarts) {
  38950. // update prefix sum
  38951. this._lineStarts.changeValue(lineIndex, this._lines[lineIndex].length + this._eol.length);
  38952. }
  38953. };
  38954. MirrorTextModel.prototype._acceptDeleteRange = function (range) {
  38955. if (range.startLineNumber === range.endLineNumber) {
  38956. if (range.startColumn === range.endColumn) {
  38957. // Nothing to delete
  38958. return;
  38959. }
  38960. // Delete text on the affected line
  38961. this._setLineText(range.startLineNumber - 1, this._lines[range.startLineNumber - 1].substring(0, range.startColumn - 1)
  38962. + this._lines[range.startLineNumber - 1].substring(range.endColumn - 1));
  38963. return;
  38964. }
  38965. // Take remaining text on last line and append it to remaining text on first line
  38966. this._setLineText(range.startLineNumber - 1, this._lines[range.startLineNumber - 1].substring(0, range.startColumn - 1)
  38967. + this._lines[range.endLineNumber - 1].substring(range.endColumn - 1));
  38968. // Delete middle lines
  38969. this._lines.splice(range.startLineNumber, range.endLineNumber - range.startLineNumber);
  38970. if (this._lineStarts) {
  38971. // update prefix sum
  38972. this._lineStarts.removeValues(range.startLineNumber, range.endLineNumber - range.startLineNumber);
  38973. }
  38974. };
  38975. MirrorTextModel.prototype._acceptInsertText = function (position, insertText) {
  38976. if (insertText.length === 0) {
  38977. // Nothing to insert
  38978. return;
  38979. }
  38980. var insertLines = insertText.split(/\r\n|\r|\n/);
  38981. if (insertLines.length === 1) {
  38982. // Inserting text on one line
  38983. this._setLineText(position.lineNumber - 1, this._lines[position.lineNumber - 1].substring(0, position.column - 1)
  38984. + insertLines[0]
  38985. + this._lines[position.lineNumber - 1].substring(position.column - 1));
  38986. return;
  38987. }
  38988. // Append overflowing text from first line to the end of text to insert
  38989. insertLines[insertLines.length - 1] += this._lines[position.lineNumber - 1].substring(position.column - 1);
  38990. // Delete overflowing text from first line and insert text on first line
  38991. this._setLineText(position.lineNumber - 1, this._lines[position.lineNumber - 1].substring(0, position.column - 1)
  38992. + insertLines[0]);
  38993. // Insert new lines & store lengths
  38994. var newLengths = new Uint32Array(insertLines.length - 1);
  38995. for (var i = 1; i < insertLines.length; i++) {
  38996. this._lines.splice(position.lineNumber + i - 1, 0, insertLines[i]);
  38997. newLengths[i - 1] = insertLines[i].length + this._eol.length;
  38998. }
  38999. if (this._lineStarts) {
  39000. // update prefix sum
  39001. this._lineStarts.insertValues(position.lineNumber, newLengths);
  39002. }
  39003. };
  39004. return MirrorTextModel;
  39005. }());
  39006. exports.MirrorTextModel = MirrorTextModel;
  39007. });
  39008. /*---------------------------------------------------------------------------------------------
  39009. * Copyright (c) Microsoft Corporation. All rights reserved.
  39010. * Licensed under the MIT License. See License.txt in the project root for license information.
  39011. *--------------------------------------------------------------------------------------------*/
  39012. define(__m[365/*vs/editor/common/services/editorSimpleWorker*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,126/*vs/base/common/diff/diff*/,54/*vs/base/common/iterator*/,16/*vs/base/common/platform*/,25/*vs/base/common/uri*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,341/*vs/editor/common/diff/diffComputer*/,364/*vs/editor/common/model/mirrorTextModel*/,109/*vs/editor/common/model/wordHelper*/,351/*vs/editor/common/modes/linkComputer*/,354/*vs/editor/common/modes/supports/inplaceReplaceSupport*/,192/*vs/editor/common/standalone/standaloneBase*/,21/*vs/base/common/types*/]), function (require, exports, arrays_1, diff_1, iterator_1, platform_1, uri_1, position_1, range_1, diffComputer_1, mirrorTextModel_1, wordHelper_1, linkComputer_1, inplaceReplaceSupport_1, standaloneBase_1, types) {
  39013. "use strict";
  39014. Object.defineProperty(exports, "__esModule", { value: true });
  39015. /**
  39016. * @internal
  39017. */
  39018. var MirrorModel = /** @class */ (function (_super) {
  39019. __extends(MirrorModel, _super);
  39020. function MirrorModel() {
  39021. return _super !== null && _super.apply(this, arguments) || this;
  39022. }
  39023. Object.defineProperty(MirrorModel.prototype, "uri", {
  39024. get: function () {
  39025. return this._uri;
  39026. },
  39027. enumerable: true,
  39028. configurable: true
  39029. });
  39030. Object.defineProperty(MirrorModel.prototype, "version", {
  39031. get: function () {
  39032. return this._versionId;
  39033. },
  39034. enumerable: true,
  39035. configurable: true
  39036. });
  39037. Object.defineProperty(MirrorModel.prototype, "eol", {
  39038. get: function () {
  39039. return this._eol;
  39040. },
  39041. enumerable: true,
  39042. configurable: true
  39043. });
  39044. MirrorModel.prototype.getValue = function () {
  39045. return this.getText();
  39046. };
  39047. MirrorModel.prototype.getLinesContent = function () {
  39048. return this._lines.slice(0);
  39049. };
  39050. MirrorModel.prototype.getLineCount = function () {
  39051. return this._lines.length;
  39052. };
  39053. MirrorModel.prototype.getLineContent = function (lineNumber) {
  39054. return this._lines[lineNumber - 1];
  39055. };
  39056. MirrorModel.prototype.getWordAtPosition = function (position, wordDefinition) {
  39057. var wordAtText = wordHelper_1.getWordAtText(position.column, wordHelper_1.ensureValidWordDefinition(wordDefinition), this._lines[position.lineNumber - 1], 0);
  39058. if (wordAtText) {
  39059. return new range_1.Range(position.lineNumber, wordAtText.startColumn, position.lineNumber, wordAtText.endColumn);
  39060. }
  39061. return null;
  39062. };
  39063. MirrorModel.prototype.createWordIterator = function (wordDefinition) {
  39064. var _this = this;
  39065. var obj;
  39066. var lineNumber = 0;
  39067. var lineText;
  39068. var wordRangesIdx = 0;
  39069. var wordRanges = [];
  39070. var next = function () {
  39071. if (wordRangesIdx < wordRanges.length) {
  39072. var value = lineText.substring(wordRanges[wordRangesIdx].start, wordRanges[wordRangesIdx].end);
  39073. wordRangesIdx += 1;
  39074. if (!obj) {
  39075. obj = { done: false, value: value };
  39076. }
  39077. else {
  39078. obj.value = value;
  39079. }
  39080. return obj;
  39081. }
  39082. else if (lineNumber >= _this._lines.length) {
  39083. return iterator_1.FIN;
  39084. }
  39085. else {
  39086. lineText = _this._lines[lineNumber];
  39087. wordRanges = _this._wordenize(lineText, wordDefinition);
  39088. wordRangesIdx = 0;
  39089. lineNumber += 1;
  39090. return next();
  39091. }
  39092. };
  39093. return { next: next };
  39094. };
  39095. MirrorModel.prototype.getLineWords = function (lineNumber, wordDefinition) {
  39096. var content = this._lines[lineNumber - 1];
  39097. var ranges = this._wordenize(content, wordDefinition);
  39098. var words = [];
  39099. for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) {
  39100. var range = ranges_1[_i];
  39101. words.push({
  39102. word: content.substring(range.start, range.end),
  39103. startColumn: range.start + 1,
  39104. endColumn: range.end + 1
  39105. });
  39106. }
  39107. return words;
  39108. };
  39109. MirrorModel.prototype._wordenize = function (content, wordDefinition) {
  39110. var result = [];
  39111. var match;
  39112. wordDefinition.lastIndex = 0; // reset lastIndex just to be sure
  39113. while (match = wordDefinition.exec(content)) {
  39114. if (match[0].length === 0) {
  39115. // it did match the empty string
  39116. break;
  39117. }
  39118. result.push({ start: match.index, end: match.index + match[0].length });
  39119. }
  39120. return result;
  39121. };
  39122. MirrorModel.prototype.getValueInRange = function (range) {
  39123. range = this._validateRange(range);
  39124. if (range.startLineNumber === range.endLineNumber) {
  39125. return this._lines[range.startLineNumber - 1].substring(range.startColumn - 1, range.endColumn - 1);
  39126. }
  39127. var lineEnding = this._eol;
  39128. var startLineIndex = range.startLineNumber - 1;
  39129. var endLineIndex = range.endLineNumber - 1;
  39130. var resultLines = [];
  39131. resultLines.push(this._lines[startLineIndex].substring(range.startColumn - 1));
  39132. for (var i = startLineIndex + 1; i < endLineIndex; i++) {
  39133. resultLines.push(this._lines[i]);
  39134. }
  39135. resultLines.push(this._lines[endLineIndex].substring(0, range.endColumn - 1));
  39136. return resultLines.join(lineEnding);
  39137. };
  39138. MirrorModel.prototype.offsetAt = function (position) {
  39139. position = this._validatePosition(position);
  39140. this._ensureLineStarts();
  39141. return this._lineStarts.getAccumulatedValue(position.lineNumber - 2) + (position.column - 1);
  39142. };
  39143. MirrorModel.prototype.positionAt = function (offset) {
  39144. offset = Math.floor(offset);
  39145. offset = Math.max(0, offset);
  39146. this._ensureLineStarts();
  39147. var out = this._lineStarts.getIndexOf(offset);
  39148. var lineLength = this._lines[out.index].length;
  39149. // Ensure we return a valid position
  39150. return {
  39151. lineNumber: 1 + out.index,
  39152. column: 1 + Math.min(out.remainder, lineLength)
  39153. };
  39154. };
  39155. MirrorModel.prototype._validateRange = function (range) {
  39156. var start = this._validatePosition({ lineNumber: range.startLineNumber, column: range.startColumn });
  39157. var end = this._validatePosition({ lineNumber: range.endLineNumber, column: range.endColumn });
  39158. if (start.lineNumber !== range.startLineNumber
  39159. || start.column !== range.startColumn
  39160. || end.lineNumber !== range.endLineNumber
  39161. || end.column !== range.endColumn) {
  39162. return {
  39163. startLineNumber: start.lineNumber,
  39164. startColumn: start.column,
  39165. endLineNumber: end.lineNumber,
  39166. endColumn: end.column
  39167. };
  39168. }
  39169. return range;
  39170. };
  39171. MirrorModel.prototype._validatePosition = function (position) {
  39172. if (!position_1.Position.isIPosition(position)) {
  39173. throw new Error('bad position');
  39174. }
  39175. var lineNumber = position.lineNumber, column = position.column;
  39176. var hasChanged = false;
  39177. if (lineNumber < 1) {
  39178. lineNumber = 1;
  39179. column = 1;
  39180. hasChanged = true;
  39181. }
  39182. else if (lineNumber > this._lines.length) {
  39183. lineNumber = this._lines.length;
  39184. column = this._lines[lineNumber - 1].length + 1;
  39185. hasChanged = true;
  39186. }
  39187. else {
  39188. var maxCharacter = this._lines[lineNumber - 1].length + 1;
  39189. if (column < 1) {
  39190. column = 1;
  39191. hasChanged = true;
  39192. }
  39193. else if (column > maxCharacter) {
  39194. column = maxCharacter;
  39195. hasChanged = true;
  39196. }
  39197. }
  39198. if (!hasChanged) {
  39199. return position;
  39200. }
  39201. else {
  39202. return { lineNumber: lineNumber, column: column };
  39203. }
  39204. };
  39205. return MirrorModel;
  39206. }(mirrorTextModel_1.MirrorTextModel));
  39207. /**
  39208. * @internal
  39209. */
  39210. var EditorSimpleWorker = /** @class */ (function () {
  39211. function EditorSimpleWorker(host, foreignModuleFactory) {
  39212. this._host = host;
  39213. this._models = Object.create(null);
  39214. this._foreignModuleFactory = foreignModuleFactory;
  39215. this._foreignModule = null;
  39216. }
  39217. EditorSimpleWorker.prototype.dispose = function () {
  39218. this._models = Object.create(null);
  39219. };
  39220. EditorSimpleWorker.prototype._getModel = function (uri) {
  39221. return this._models[uri];
  39222. };
  39223. EditorSimpleWorker.prototype._getModels = function () {
  39224. var _this = this;
  39225. var all = [];
  39226. Object.keys(this._models).forEach(function (key) { return all.push(_this._models[key]); });
  39227. return all;
  39228. };
  39229. EditorSimpleWorker.prototype.acceptNewModel = function (data) {
  39230. this._models[data.url] = new MirrorModel(uri_1.URI.parse(data.url), data.lines, data.EOL, data.versionId);
  39231. };
  39232. EditorSimpleWorker.prototype.acceptModelChanged = function (strURL, e) {
  39233. if (!this._models[strURL]) {
  39234. return;
  39235. }
  39236. var model = this._models[strURL];
  39237. model.onEvents(e);
  39238. };
  39239. EditorSimpleWorker.prototype.acceptRemovedModel = function (strURL) {
  39240. if (!this._models[strURL]) {
  39241. return;
  39242. }
  39243. delete this._models[strURL];
  39244. };
  39245. // ---- BEGIN diff --------------------------------------------------------------------------
  39246. EditorSimpleWorker.prototype.computeDiff = function (originalUrl, modifiedUrl, ignoreTrimWhitespace, maxComputationTime) {
  39247. return __awaiter(this, void 0, void 0, function () {
  39248. var original, modified, originalLines, modifiedLines, diffComputer, diffResult, identical;
  39249. return __generator(this, function (_a) {
  39250. original = this._getModel(originalUrl);
  39251. modified = this._getModel(modifiedUrl);
  39252. if (!original || !modified) {
  39253. return [2 /*return*/, null];
  39254. }
  39255. originalLines = original.getLinesContent();
  39256. modifiedLines = modified.getLinesContent();
  39257. diffComputer = new diffComputer_1.DiffComputer(originalLines, modifiedLines, {
  39258. shouldComputeCharChanges: true,
  39259. shouldPostProcessCharChanges: true,
  39260. shouldIgnoreTrimWhitespace: ignoreTrimWhitespace,
  39261. shouldMakePrettyDiff: true,
  39262. maxComputationTime: maxComputationTime
  39263. });
  39264. diffResult = diffComputer.computeDiff();
  39265. identical = (diffResult.changes.length > 0 ? false : this._modelsAreIdentical(original, modified));
  39266. return [2 /*return*/, {
  39267. quitEarly: diffResult.quitEarly,
  39268. identical: identical,
  39269. changes: diffResult.changes
  39270. }];
  39271. });
  39272. });
  39273. };
  39274. EditorSimpleWorker.prototype._modelsAreIdentical = function (original, modified) {
  39275. var originalLineCount = original.getLineCount();
  39276. var modifiedLineCount = modified.getLineCount();
  39277. if (originalLineCount !== modifiedLineCount) {
  39278. return false;
  39279. }
  39280. for (var line = 1; line <= originalLineCount; line++) {
  39281. var originalLine = original.getLineContent(line);
  39282. var modifiedLine = modified.getLineContent(line);
  39283. if (originalLine !== modifiedLine) {
  39284. return false;
  39285. }
  39286. }
  39287. return true;
  39288. };
  39289. EditorSimpleWorker.prototype.computeMoreMinimalEdits = function (modelUrl, edits) {
  39290. return __awaiter(this, void 0, void 0, function () {
  39291. var model, result, lastEol, _i, edits_1, _a, range, text, eol, original, changes, editOffset, _b, changes_1, change, start, end, newEdit;
  39292. return __generator(this, function (_c) {
  39293. model = this._getModel(modelUrl);
  39294. if (!model) {
  39295. return [2 /*return*/, edits];
  39296. }
  39297. result = [];
  39298. lastEol = undefined;
  39299. edits = arrays_1.mergeSort(edits, function (a, b) {
  39300. if (a.range && b.range) {
  39301. return range_1.Range.compareRangesUsingStarts(a.range, b.range);
  39302. }
  39303. // eol only changes should go to the end
  39304. var aRng = a.range ? 0 : 1;
  39305. var bRng = b.range ? 0 : 1;
  39306. return aRng - bRng;
  39307. });
  39308. for (_i = 0, edits_1 = edits; _i < edits_1.length; _i++) {
  39309. _a = edits_1[_i], range = _a.range, text = _a.text, eol = _a.eol;
  39310. if (typeof eol === 'number') {
  39311. lastEol = eol;
  39312. }
  39313. if (range_1.Range.isEmpty(range) && !text) {
  39314. // empty change
  39315. continue;
  39316. }
  39317. original = model.getValueInRange(range);
  39318. text = text.replace(/\r\n|\n|\r/g, model.eol);
  39319. if (original === text) {
  39320. // noop
  39321. continue;
  39322. }
  39323. // make sure diff won't take too long
  39324. if (Math.max(text.length, original.length) > EditorSimpleWorker._diffLimit) {
  39325. result.push({ range: range, text: text });
  39326. continue;
  39327. }
  39328. changes = diff_1.stringDiff(original, text, false);
  39329. editOffset = model.offsetAt(range_1.Range.lift(range).getStartPosition());
  39330. for (_b = 0, changes_1 = changes; _b < changes_1.length; _b++) {
  39331. change = changes_1[_b];
  39332. start = model.positionAt(editOffset + change.originalStart);
  39333. end = model.positionAt(editOffset + change.originalStart + change.originalLength);
  39334. newEdit = {
  39335. text: text.substr(change.modifiedStart, change.modifiedLength),
  39336. range: { startLineNumber: start.lineNumber, startColumn: start.column, endLineNumber: end.lineNumber, endColumn: end.column }
  39337. };
  39338. if (model.getValueInRange(newEdit.range) !== newEdit.text) {
  39339. result.push(newEdit);
  39340. }
  39341. }
  39342. }
  39343. if (typeof lastEol === 'number') {
  39344. result.push({ eol: lastEol, text: '', range: { startLineNumber: 0, startColumn: 0, endLineNumber: 0, endColumn: 0 } });
  39345. }
  39346. return [2 /*return*/, result];
  39347. });
  39348. });
  39349. };
  39350. // ---- END minimal edits ---------------------------------------------------------------
  39351. EditorSimpleWorker.prototype.computeLinks = function (modelUrl) {
  39352. return __awaiter(this, void 0, void 0, function () {
  39353. var model;
  39354. return __generator(this, function (_a) {
  39355. model = this._getModel(modelUrl);
  39356. if (!model) {
  39357. return [2 /*return*/, null];
  39358. }
  39359. return [2 /*return*/, linkComputer_1.computeLinks(model)];
  39360. });
  39361. });
  39362. };
  39363. EditorSimpleWorker.prototype.textualSuggest = function (modelUrl, position, wordDef, wordDefFlags) {
  39364. return __awaiter(this, void 0, void 0, function () {
  39365. var model, words, seen, wordDefRegExp, wordAt, iter, e, word;
  39366. return __generator(this, function (_a) {
  39367. model = this._getModel(modelUrl);
  39368. if (!model) {
  39369. return [2 /*return*/, null];
  39370. }
  39371. words = [];
  39372. seen = new Set();
  39373. wordDefRegExp = new RegExp(wordDef, wordDefFlags);
  39374. wordAt = model.getWordAtPosition(position, wordDefRegExp);
  39375. if (wordAt) {
  39376. seen.add(model.getValueInRange(wordAt));
  39377. }
  39378. for (iter = model.createWordIterator(wordDefRegExp), e = iter.next(); !e.done && seen.size <= EditorSimpleWorker._suggestionsLimit; e = iter.next()) {
  39379. word = e.value;
  39380. if (seen.has(word)) {
  39381. continue;
  39382. }
  39383. seen.add(word);
  39384. if (!isNaN(Number(word))) {
  39385. continue;
  39386. }
  39387. words.push(word);
  39388. }
  39389. return [2 /*return*/, words];
  39390. });
  39391. });
  39392. };
  39393. // ---- END suggest --------------------------------------------------------------------------
  39394. //#region -- word ranges --
  39395. EditorSimpleWorker.prototype.computeWordRanges = function (modelUrl, range, wordDef, wordDefFlags) {
  39396. return __awaiter(this, void 0, void 0, function () {
  39397. var model, wordDefRegExp, result, line, words, _i, words_1, word, array;
  39398. return __generator(this, function (_a) {
  39399. model = this._getModel(modelUrl);
  39400. if (!model) {
  39401. return [2 /*return*/, Object.create(null)];
  39402. }
  39403. wordDefRegExp = new RegExp(wordDef, wordDefFlags);
  39404. result = Object.create(null);
  39405. for (line = range.startLineNumber; line < range.endLineNumber; line++) {
  39406. words = model.getLineWords(line, wordDefRegExp);
  39407. for (_i = 0, words_1 = words; _i < words_1.length; _i++) {
  39408. word = words_1[_i];
  39409. if (!isNaN(Number(word.word))) {
  39410. continue;
  39411. }
  39412. array = result[word.word];
  39413. if (!array) {
  39414. array = [];
  39415. result[word.word] = array;
  39416. }
  39417. array.push({
  39418. startLineNumber: line,
  39419. startColumn: word.startColumn,
  39420. endLineNumber: line,
  39421. endColumn: word.endColumn
  39422. });
  39423. }
  39424. }
  39425. return [2 /*return*/, result];
  39426. });
  39427. });
  39428. };
  39429. //#endregion
  39430. EditorSimpleWorker.prototype.navigateValueSet = function (modelUrl, range, up, wordDef, wordDefFlags) {
  39431. return __awaiter(this, void 0, void 0, function () {
  39432. var model, wordDefRegExp, selectionText, wordRange, word, result;
  39433. return __generator(this, function (_a) {
  39434. model = this._getModel(modelUrl);
  39435. if (!model) {
  39436. return [2 /*return*/, null];
  39437. }
  39438. wordDefRegExp = new RegExp(wordDef, wordDefFlags);
  39439. if (range.startColumn === range.endColumn) {
  39440. range = {
  39441. startLineNumber: range.startLineNumber,
  39442. startColumn: range.startColumn,
  39443. endLineNumber: range.endLineNumber,
  39444. endColumn: range.endColumn + 1
  39445. };
  39446. }
  39447. selectionText = model.getValueInRange(range);
  39448. wordRange = model.getWordAtPosition({ lineNumber: range.startLineNumber, column: range.startColumn }, wordDefRegExp);
  39449. if (!wordRange) {
  39450. return [2 /*return*/, null];
  39451. }
  39452. word = model.getValueInRange(wordRange);
  39453. result = inplaceReplaceSupport_1.BasicInplaceReplace.INSTANCE.navigateValueSet(range, selectionText, wordRange, word, up);
  39454. return [2 /*return*/, result];
  39455. });
  39456. });
  39457. };
  39458. // ---- BEGIN foreign module support --------------------------------------------------------------------------
  39459. EditorSimpleWorker.prototype.loadForeignModule = function (moduleId, createData, foreignHostMethods) {
  39460. var _this = this;
  39461. var proxyMethodRequest = function (method, args) {
  39462. return _this._host.fhr(method, args);
  39463. };
  39464. var foreignHost = types.createProxyObject(foreignHostMethods, proxyMethodRequest);
  39465. var ctx = {
  39466. host: foreignHost,
  39467. getMirrorModels: function () {
  39468. return _this._getModels();
  39469. }
  39470. };
  39471. if (this._foreignModuleFactory) {
  39472. this._foreignModule = this._foreignModuleFactory(ctx, createData);
  39473. // static foreing module
  39474. return Promise.resolve(types.getAllMethodNames(this._foreignModule));
  39475. }
  39476. // ESM-comment-begin
  39477. return new Promise(function (resolve, reject) {
  39478. require([moduleId], function (foreignModule) {
  39479. _this._foreignModule = foreignModule.create(ctx, createData);
  39480. resolve(types.getAllMethodNames(_this._foreignModule));
  39481. }, reject);
  39482. });
  39483. // ESM-comment-end
  39484. // ESM-uncomment-begin
  39485. // return Promise.reject(new Error(`Unexpected usage`));
  39486. // ESM-uncomment-end
  39487. };
  39488. // foreign method request
  39489. EditorSimpleWorker.prototype.fmr = function (method, args) {
  39490. if (!this._foreignModule || typeof this._foreignModule[method] !== 'function') {
  39491. return Promise.reject(new Error('Missing requestHandler or method: ' + method));
  39492. }
  39493. try {
  39494. return Promise.resolve(this._foreignModule[method].apply(this._foreignModule, args));
  39495. }
  39496. catch (e) {
  39497. return Promise.reject(e);
  39498. }
  39499. };
  39500. // ---- END diff --------------------------------------------------------------------------
  39501. // ---- BEGIN minimal edits ---------------------------------------------------------------
  39502. EditorSimpleWorker._diffLimit = 100000;
  39503. // ---- BEGIN suggest --------------------------------------------------------------------------
  39504. EditorSimpleWorker._suggestionsLimit = 10000;
  39505. return EditorSimpleWorker;
  39506. }());
  39507. exports.EditorSimpleWorker = EditorSimpleWorker;
  39508. /**
  39509. * Called on the worker side
  39510. * @internal
  39511. */
  39512. function create(host) {
  39513. return new EditorSimpleWorker(host, null);
  39514. }
  39515. exports.create = create;
  39516. if (typeof importScripts === 'function') {
  39517. // Running in a web worker
  39518. platform_1.globals.monaco = standaloneBase_1.createMonacoBaseAPI();
  39519. }
  39520. });
  39521. /*---------------------------------------------------------------------------------------------
  39522. * Copyright (c) Microsoft Corporation. All rights reserved.
  39523. * Licensed under the MIT License. See License.txt in the project root for license information.
  39524. *--------------------------------------------------------------------------------------------*/
  39525. define(__m[92/*vs/editor/common/viewModel/viewEventHandler*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/]), function (require, exports, lifecycle_1) {
  39526. "use strict";
  39527. Object.defineProperty(exports, "__esModule", { value: true });
  39528. var ViewEventHandler = /** @class */ (function (_super) {
  39529. __extends(ViewEventHandler, _super);
  39530. function ViewEventHandler() {
  39531. var _this = _super.call(this) || this;
  39532. _this._shouldRender = true;
  39533. return _this;
  39534. }
  39535. ViewEventHandler.prototype.shouldRender = function () {
  39536. return this._shouldRender;
  39537. };
  39538. ViewEventHandler.prototype.forceShouldRender = function () {
  39539. this._shouldRender = true;
  39540. };
  39541. ViewEventHandler.prototype.setShouldRender = function () {
  39542. this._shouldRender = true;
  39543. };
  39544. ViewEventHandler.prototype.onDidRender = function () {
  39545. this._shouldRender = false;
  39546. };
  39547. // --- begin event handlers
  39548. ViewEventHandler.prototype.onConfigurationChanged = function (e) {
  39549. return false;
  39550. };
  39551. ViewEventHandler.prototype.onContentSizeChanged = function (e) {
  39552. return false;
  39553. };
  39554. ViewEventHandler.prototype.onCursorStateChanged = function (e) {
  39555. return false;
  39556. };
  39557. ViewEventHandler.prototype.onDecorationsChanged = function (e) {
  39558. return false;
  39559. };
  39560. ViewEventHandler.prototype.onFlushed = function (e) {
  39561. return false;
  39562. };
  39563. ViewEventHandler.prototype.onFocusChanged = function (e) {
  39564. return false;
  39565. };
  39566. ViewEventHandler.prototype.onLanguageConfigurationChanged = function (e) {
  39567. return false;
  39568. };
  39569. ViewEventHandler.prototype.onLineMappingChanged = function (e) {
  39570. return false;
  39571. };
  39572. ViewEventHandler.prototype.onLinesChanged = function (e) {
  39573. return false;
  39574. };
  39575. ViewEventHandler.prototype.onLinesDeleted = function (e) {
  39576. return false;
  39577. };
  39578. ViewEventHandler.prototype.onLinesInserted = function (e) {
  39579. return false;
  39580. };
  39581. ViewEventHandler.prototype.onRevealRangeRequest = function (e) {
  39582. return false;
  39583. };
  39584. ViewEventHandler.prototype.onScrollChanged = function (e) {
  39585. return false;
  39586. };
  39587. ViewEventHandler.prototype.onThemeChanged = function (e) {
  39588. return false;
  39589. };
  39590. ViewEventHandler.prototype.onTokensChanged = function (e) {
  39591. return false;
  39592. };
  39593. ViewEventHandler.prototype.onTokensColorsChanged = function (e) {
  39594. return false;
  39595. };
  39596. ViewEventHandler.prototype.onZonesChanged = function (e) {
  39597. return false;
  39598. };
  39599. // --- end event handlers
  39600. ViewEventHandler.prototype.handleEvents = function (events) {
  39601. var shouldRender = false;
  39602. for (var i = 0, len = events.length; i < len; i++) {
  39603. var e = events[i];
  39604. switch (e.type) {
  39605. case 1 /* ViewConfigurationChanged */:
  39606. if (this.onConfigurationChanged(e)) {
  39607. shouldRender = true;
  39608. }
  39609. break;
  39610. case 2 /* ViewContentSizeChanged */:
  39611. if (this.onContentSizeChanged(e)) {
  39612. shouldRender = true;
  39613. }
  39614. break;
  39615. case 3 /* ViewCursorStateChanged */:
  39616. if (this.onCursorStateChanged(e)) {
  39617. shouldRender = true;
  39618. }
  39619. break;
  39620. case 4 /* ViewDecorationsChanged */:
  39621. if (this.onDecorationsChanged(e)) {
  39622. shouldRender = true;
  39623. }
  39624. break;
  39625. case 5 /* ViewFlushed */:
  39626. if (this.onFlushed(e)) {
  39627. shouldRender = true;
  39628. }
  39629. break;
  39630. case 6 /* ViewFocusChanged */:
  39631. if (this.onFocusChanged(e)) {
  39632. shouldRender = true;
  39633. }
  39634. break;
  39635. case 7 /* ViewLanguageConfigurationChanged */:
  39636. if (this.onLanguageConfigurationChanged(e)) {
  39637. shouldRender = true;
  39638. }
  39639. break;
  39640. case 8 /* ViewLineMappingChanged */:
  39641. if (this.onLineMappingChanged(e)) {
  39642. shouldRender = true;
  39643. }
  39644. break;
  39645. case 9 /* ViewLinesChanged */:
  39646. if (this.onLinesChanged(e)) {
  39647. shouldRender = true;
  39648. }
  39649. break;
  39650. case 10 /* ViewLinesDeleted */:
  39651. if (this.onLinesDeleted(e)) {
  39652. shouldRender = true;
  39653. }
  39654. break;
  39655. case 11 /* ViewLinesInserted */:
  39656. if (this.onLinesInserted(e)) {
  39657. shouldRender = true;
  39658. }
  39659. break;
  39660. case 12 /* ViewRevealRangeRequest */:
  39661. if (this.onRevealRangeRequest(e)) {
  39662. shouldRender = true;
  39663. }
  39664. break;
  39665. case 13 /* ViewScrollChanged */:
  39666. if (this.onScrollChanged(e)) {
  39667. shouldRender = true;
  39668. }
  39669. break;
  39670. case 15 /* ViewTokensChanged */:
  39671. if (this.onTokensChanged(e)) {
  39672. shouldRender = true;
  39673. }
  39674. break;
  39675. case 14 /* ViewThemeChanged */:
  39676. if (this.onThemeChanged(e)) {
  39677. shouldRender = true;
  39678. }
  39679. break;
  39680. case 16 /* ViewTokensColorsChanged */:
  39681. if (this.onTokensColorsChanged(e)) {
  39682. shouldRender = true;
  39683. }
  39684. break;
  39685. case 17 /* ViewZonesChanged */:
  39686. if (this.onZonesChanged(e)) {
  39687. shouldRender = true;
  39688. }
  39689. break;
  39690. default:
  39691. console.info('View received unknown event: ');
  39692. console.info(e);
  39693. }
  39694. }
  39695. if (shouldRender) {
  39696. this._shouldRender = true;
  39697. }
  39698. };
  39699. return ViewEventHandler;
  39700. }(lifecycle_1.Disposable));
  39701. exports.ViewEventHandler = ViewEventHandler;
  39702. });
  39703. /*---------------------------------------------------------------------------------------------
  39704. * Copyright (c) Microsoft Corporation. All rights reserved.
  39705. * Licensed under the MIT License. See License.txt in the project root for license information.
  39706. *--------------------------------------------------------------------------------------------*/
  39707. define(__m[82/*vs/editor/browser/view/dynamicViewOverlay*/], __M([0/*require*/,1/*exports*/,92/*vs/editor/common/viewModel/viewEventHandler*/]), function (require, exports, viewEventHandler_1) {
  39708. "use strict";
  39709. Object.defineProperty(exports, "__esModule", { value: true });
  39710. var DynamicViewOverlay = /** @class */ (function (_super) {
  39711. __extends(DynamicViewOverlay, _super);
  39712. function DynamicViewOverlay() {
  39713. return _super !== null && _super.apply(this, arguments) || this;
  39714. }
  39715. return DynamicViewOverlay;
  39716. }(viewEventHandler_1.ViewEventHandler));
  39717. exports.DynamicViewOverlay = DynamicViewOverlay;
  39718. });
  39719. /*---------------------------------------------------------------------------------------------
  39720. * Copyright (c) Microsoft Corporation. All rights reserved.
  39721. * Licensed under the MIT License. See License.txt in the project root for license information.
  39722. *--------------------------------------------------------------------------------------------*/
  39723. define(__m[37/*vs/editor/browser/view/viewPart*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,92/*vs/editor/common/viewModel/viewEventHandler*/]), function (require, exports, fastDomNode_1, viewEventHandler_1) {
  39724. "use strict";
  39725. Object.defineProperty(exports, "__esModule", { value: true });
  39726. var ViewPart = /** @class */ (function (_super) {
  39727. __extends(ViewPart, _super);
  39728. function ViewPart(context) {
  39729. var _this = _super.call(this) || this;
  39730. _this._context = context;
  39731. _this._context.addEventHandler(_this);
  39732. return _this;
  39733. }
  39734. ViewPart.prototype.dispose = function () {
  39735. this._context.removeEventHandler(this);
  39736. _super.prototype.dispose.call(this);
  39737. };
  39738. return ViewPart;
  39739. }(viewEventHandler_1.ViewEventHandler));
  39740. exports.ViewPart = ViewPart;
  39741. var PartFingerprints = /** @class */ (function () {
  39742. function PartFingerprints() {
  39743. }
  39744. PartFingerprints.write = function (target, partId) {
  39745. if (target instanceof fastDomNode_1.FastDomNode) {
  39746. target.setAttribute('data-mprt', String(partId));
  39747. }
  39748. else {
  39749. target.setAttribute('data-mprt', String(partId));
  39750. }
  39751. };
  39752. PartFingerprints.read = function (target) {
  39753. var r = target.getAttribute('data-mprt');
  39754. if (r === null) {
  39755. return 0 /* None */;
  39756. }
  39757. return parseInt(r, 10);
  39758. };
  39759. PartFingerprints.collect = function (child, stopAt) {
  39760. var result = [], resultLen = 0;
  39761. while (child && child !== document.body) {
  39762. if (child === stopAt) {
  39763. break;
  39764. }
  39765. if (child.nodeType === child.ELEMENT_NODE) {
  39766. result[resultLen++] = this.read(child);
  39767. }
  39768. child = child.parentElement;
  39769. }
  39770. var r = new Uint8Array(resultLen);
  39771. for (var i = 0; i < resultLen; i++) {
  39772. r[i] = result[resultLen - i - 1];
  39773. }
  39774. return r;
  39775. };
  39776. return PartFingerprints;
  39777. }());
  39778. exports.PartFingerprints = PartFingerprints;
  39779. });
  39780. /*---------------------------------------------------------------------------------------------
  39781. * Copyright (c) Microsoft Corporation. All rights reserved.
  39782. * Licensed under the MIT License. See License.txt in the project root for license information.
  39783. *--------------------------------------------------------------------------------------------*/
  39784. define(__m[366/*vs/editor/browser/viewParts/contentWidgets/contentWidgets*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,28/*vs/base/browser/fastDomNode*/,37/*vs/editor/browser/view/viewPart*/]), function (require, exports, dom, fastDomNode_1, viewPart_1) {
  39785. "use strict";
  39786. Object.defineProperty(exports, "__esModule", { value: true });
  39787. var Coordinate = /** @class */ (function () {
  39788. function Coordinate(top, left) {
  39789. this.top = top;
  39790. this.left = left;
  39791. }
  39792. return Coordinate;
  39793. }());
  39794. var ViewContentWidgets = /** @class */ (function (_super) {
  39795. __extends(ViewContentWidgets, _super);
  39796. function ViewContentWidgets(context, viewDomNode) {
  39797. var _this = _super.call(this, context) || this;
  39798. _this._viewDomNode = viewDomNode;
  39799. _this._widgets = {};
  39800. _this.domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  39801. viewPart_1.PartFingerprints.write(_this.domNode, 1 /* ContentWidgets */);
  39802. _this.domNode.setClassName('contentWidgets');
  39803. _this.domNode.setPosition('absolute');
  39804. _this.domNode.setTop(0);
  39805. _this.overflowingContentWidgetsDomNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  39806. viewPart_1.PartFingerprints.write(_this.overflowingContentWidgetsDomNode, 2 /* OverflowingContentWidgets */);
  39807. _this.overflowingContentWidgetsDomNode.setClassName('overflowingContentWidgets');
  39808. return _this;
  39809. }
  39810. ViewContentWidgets.prototype.dispose = function () {
  39811. _super.prototype.dispose.call(this);
  39812. this._widgets = {};
  39813. };
  39814. // --- begin event handlers
  39815. ViewContentWidgets.prototype.onConfigurationChanged = function (e) {
  39816. var keys = Object.keys(this._widgets);
  39817. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  39818. var widgetId = keys_1[_i];
  39819. this._widgets[widgetId].onConfigurationChanged(e);
  39820. }
  39821. return true;
  39822. };
  39823. ViewContentWidgets.prototype.onDecorationsChanged = function (e) {
  39824. // true for inline decorations that can end up relayouting text
  39825. return true;
  39826. };
  39827. ViewContentWidgets.prototype.onFlushed = function (e) {
  39828. return true;
  39829. };
  39830. ViewContentWidgets.prototype.onLineMappingChanged = function (e) {
  39831. var keys = Object.keys(this._widgets);
  39832. for (var _i = 0, keys_2 = keys; _i < keys_2.length; _i++) {
  39833. var widgetId = keys_2[_i];
  39834. this._widgets[widgetId].onLineMappingChanged(e);
  39835. }
  39836. return true;
  39837. };
  39838. ViewContentWidgets.prototype.onLinesChanged = function (e) {
  39839. return true;
  39840. };
  39841. ViewContentWidgets.prototype.onLinesDeleted = function (e) {
  39842. return true;
  39843. };
  39844. ViewContentWidgets.prototype.onLinesInserted = function (e) {
  39845. return true;
  39846. };
  39847. ViewContentWidgets.prototype.onScrollChanged = function (e) {
  39848. return true;
  39849. };
  39850. ViewContentWidgets.prototype.onZonesChanged = function (e) {
  39851. return true;
  39852. };
  39853. // ---- end view event handlers
  39854. ViewContentWidgets.prototype.addWidget = function (_widget) {
  39855. var myWidget = new Widget(this._context, this._viewDomNode, _widget);
  39856. this._widgets[myWidget.id] = myWidget;
  39857. if (myWidget.allowEditorOverflow) {
  39858. this.overflowingContentWidgetsDomNode.appendChild(myWidget.domNode);
  39859. }
  39860. else {
  39861. this.domNode.appendChild(myWidget.domNode);
  39862. }
  39863. this.setShouldRender();
  39864. };
  39865. ViewContentWidgets.prototype.setWidgetPosition = function (widget, range, preference) {
  39866. var myWidget = this._widgets[widget.getId()];
  39867. myWidget.setPosition(range, preference);
  39868. this.setShouldRender();
  39869. };
  39870. ViewContentWidgets.prototype.removeWidget = function (widget) {
  39871. var widgetId = widget.getId();
  39872. if (this._widgets.hasOwnProperty(widgetId)) {
  39873. var myWidget = this._widgets[widgetId];
  39874. delete this._widgets[widgetId];
  39875. var domNode = myWidget.domNode.domNode;
  39876. domNode.parentNode.removeChild(domNode);
  39877. domNode.removeAttribute('monaco-visible-content-widget');
  39878. this.setShouldRender();
  39879. }
  39880. };
  39881. ViewContentWidgets.prototype.shouldSuppressMouseDownOnWidget = function (widgetId) {
  39882. if (this._widgets.hasOwnProperty(widgetId)) {
  39883. return this._widgets[widgetId].suppressMouseDown;
  39884. }
  39885. return false;
  39886. };
  39887. ViewContentWidgets.prototype.onBeforeRender = function (viewportData) {
  39888. var keys = Object.keys(this._widgets);
  39889. for (var _i = 0, keys_3 = keys; _i < keys_3.length; _i++) {
  39890. var widgetId = keys_3[_i];
  39891. this._widgets[widgetId].onBeforeRender(viewportData);
  39892. }
  39893. };
  39894. ViewContentWidgets.prototype.prepareRender = function (ctx) {
  39895. var keys = Object.keys(this._widgets);
  39896. for (var _i = 0, keys_4 = keys; _i < keys_4.length; _i++) {
  39897. var widgetId = keys_4[_i];
  39898. this._widgets[widgetId].prepareRender(ctx);
  39899. }
  39900. };
  39901. ViewContentWidgets.prototype.render = function (ctx) {
  39902. var keys = Object.keys(this._widgets);
  39903. for (var _i = 0, keys_5 = keys; _i < keys_5.length; _i++) {
  39904. var widgetId = keys_5[_i];
  39905. this._widgets[widgetId].render(ctx);
  39906. }
  39907. };
  39908. return ViewContentWidgets;
  39909. }(viewPart_1.ViewPart));
  39910. exports.ViewContentWidgets = ViewContentWidgets;
  39911. var Widget = /** @class */ (function () {
  39912. function Widget(context, viewDomNode, actual) {
  39913. this._context = context;
  39914. this._viewDomNode = viewDomNode;
  39915. this._actual = actual;
  39916. this.domNode = fastDomNode_1.createFastDomNode(this._actual.getDomNode());
  39917. this.id = this._actual.getId();
  39918. this.allowEditorOverflow = this._actual.allowEditorOverflow || false;
  39919. this.suppressMouseDown = this._actual.suppressMouseDown || false;
  39920. var options = this._context.configuration.options;
  39921. var layoutInfo = options.get(107 /* layoutInfo */);
  39922. this._fixedOverflowWidgets = options.get(29 /* fixedOverflowWidgets */);
  39923. this._contentWidth = layoutInfo.contentWidth;
  39924. this._contentLeft = layoutInfo.contentLeft;
  39925. this._lineHeight = options.get(49 /* lineHeight */);
  39926. this._range = null;
  39927. this._viewRange = null;
  39928. this._preference = [];
  39929. this._cachedDomNodeClientWidth = -1;
  39930. this._cachedDomNodeClientHeight = -1;
  39931. this._maxWidth = this._getMaxWidth();
  39932. this._isVisible = false;
  39933. this._renderData = null;
  39934. this.domNode.setPosition((this._fixedOverflowWidgets && this.allowEditorOverflow) ? 'fixed' : 'absolute');
  39935. this.domNode.setVisibility('hidden');
  39936. this.domNode.setAttribute('widgetId', this.id);
  39937. this.domNode.setMaxWidth(this._maxWidth);
  39938. }
  39939. Widget.prototype.onConfigurationChanged = function (e) {
  39940. var options = this._context.configuration.options;
  39941. this._lineHeight = options.get(49 /* lineHeight */);
  39942. if (e.hasChanged(107 /* layoutInfo */)) {
  39943. var layoutInfo = options.get(107 /* layoutInfo */);
  39944. this._contentLeft = layoutInfo.contentLeft;
  39945. this._contentWidth = layoutInfo.contentWidth;
  39946. this._maxWidth = this._getMaxWidth();
  39947. }
  39948. };
  39949. Widget.prototype.onLineMappingChanged = function (e) {
  39950. this._setPosition(this._range);
  39951. };
  39952. Widget.prototype._setPosition = function (range) {
  39953. this._range = range;
  39954. this._viewRange = null;
  39955. if (this._range) {
  39956. // Do not trust that widgets give a valid position
  39957. var validModelRange = this._context.model.validateModelRange(this._range);
  39958. if (this._context.model.coordinatesConverter.modelPositionIsVisible(validModelRange.getStartPosition()) || this._context.model.coordinatesConverter.modelPositionIsVisible(validModelRange.getEndPosition())) {
  39959. this._viewRange = this._context.model.coordinatesConverter.convertModelRangeToViewRange(validModelRange);
  39960. }
  39961. }
  39962. };
  39963. Widget.prototype._getMaxWidth = function () {
  39964. return (this.allowEditorOverflow
  39965. ? window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth
  39966. : this._contentWidth);
  39967. };
  39968. Widget.prototype.setPosition = function (range, preference) {
  39969. this._setPosition(range);
  39970. this._preference = preference;
  39971. this._cachedDomNodeClientWidth = -1;
  39972. this._cachedDomNodeClientHeight = -1;
  39973. };
  39974. Widget.prototype._layoutBoxInViewport = function (topLeft, bottomLeft, width, height, ctx) {
  39975. // Our visible box is split horizontally by the current line => 2 boxes
  39976. // a) the box above the line
  39977. var aboveLineTop = topLeft.top;
  39978. var heightAboveLine = aboveLineTop;
  39979. // b) the box under the line
  39980. var underLineTop = bottomLeft.top + this._lineHeight;
  39981. var heightUnderLine = ctx.viewportHeight - underLineTop;
  39982. var aboveTop = aboveLineTop - height;
  39983. var fitsAbove = (heightAboveLine >= height);
  39984. var belowTop = underLineTop;
  39985. var fitsBelow = (heightUnderLine >= height);
  39986. // And its left
  39987. var actualAboveLeft = topLeft.left;
  39988. var actualBelowLeft = bottomLeft.left;
  39989. if (actualAboveLeft + width > ctx.scrollLeft + ctx.viewportWidth) {
  39990. actualAboveLeft = ctx.scrollLeft + ctx.viewportWidth - width;
  39991. }
  39992. if (actualBelowLeft + width > ctx.scrollLeft + ctx.viewportWidth) {
  39993. actualBelowLeft = ctx.scrollLeft + ctx.viewportWidth - width;
  39994. }
  39995. if (actualAboveLeft < ctx.scrollLeft) {
  39996. actualAboveLeft = ctx.scrollLeft;
  39997. }
  39998. if (actualBelowLeft < ctx.scrollLeft) {
  39999. actualBelowLeft = ctx.scrollLeft;
  40000. }
  40001. return {
  40002. fitsAbove: fitsAbove,
  40003. aboveTop: aboveTop,
  40004. aboveLeft: actualAboveLeft,
  40005. fitsBelow: fitsBelow,
  40006. belowTop: belowTop,
  40007. belowLeft: actualBelowLeft,
  40008. };
  40009. };
  40010. Widget.prototype._layoutHorizontalSegmentInPage = function (windowSize, domNodePosition, left, width) {
  40011. // Initially, the limits are defined as the dom node limits
  40012. var MIN_LIMIT = Math.max(0, domNodePosition.left - width);
  40013. var MAX_LIMIT = Math.min(domNodePosition.left + domNodePosition.width + width, windowSize.width);
  40014. var absoluteLeft = domNodePosition.left + left - dom.StandardWindow.scrollX;
  40015. if (absoluteLeft + width > MAX_LIMIT) {
  40016. var delta = absoluteLeft - (MAX_LIMIT - width);
  40017. absoluteLeft -= delta;
  40018. left -= delta;
  40019. }
  40020. if (absoluteLeft < MIN_LIMIT) {
  40021. var delta = absoluteLeft - MIN_LIMIT;
  40022. absoluteLeft -= delta;
  40023. left -= delta;
  40024. }
  40025. return [left, absoluteLeft];
  40026. };
  40027. Widget.prototype._layoutBoxInPage = function (topLeft, bottomLeft, width, height, ctx) {
  40028. var aboveTop = topLeft.top - height;
  40029. var belowTop = bottomLeft.top + this._lineHeight;
  40030. var domNodePosition = dom.getDomNodePagePosition(this._viewDomNode.domNode);
  40031. var absoluteAboveTop = domNodePosition.top + aboveTop - dom.StandardWindow.scrollY;
  40032. var absoluteBelowTop = domNodePosition.top + belowTop - dom.StandardWindow.scrollY;
  40033. var windowSize = dom.getClientArea(document.body);
  40034. var _a = this._layoutHorizontalSegmentInPage(windowSize, domNodePosition, topLeft.left - ctx.scrollLeft + this._contentLeft, width), aboveLeft = _a[0], absoluteAboveLeft = _a[1];
  40035. var _b = this._layoutHorizontalSegmentInPage(windowSize, domNodePosition, bottomLeft.left - ctx.scrollLeft + this._contentLeft, width), belowLeft = _b[0], absoluteBelowLeft = _b[1];
  40036. // Leave some clearance to the top/bottom
  40037. var TOP_PADDING = 22;
  40038. var BOTTOM_PADDING = 22;
  40039. var fitsAbove = (absoluteAboveTop >= TOP_PADDING);
  40040. var fitsBelow = (absoluteBelowTop + height <= windowSize.height - BOTTOM_PADDING);
  40041. if (this._fixedOverflowWidgets) {
  40042. return {
  40043. fitsAbove: fitsAbove,
  40044. aboveTop: Math.max(absoluteAboveTop, TOP_PADDING),
  40045. aboveLeft: absoluteAboveLeft,
  40046. fitsBelow: fitsBelow,
  40047. belowTop: absoluteBelowTop,
  40048. belowLeft: absoluteBelowLeft
  40049. };
  40050. }
  40051. return {
  40052. fitsAbove: fitsAbove,
  40053. aboveTop: Math.max(aboveTop, TOP_PADDING),
  40054. aboveLeft: aboveLeft,
  40055. fitsBelow: fitsBelow,
  40056. belowTop: belowTop,
  40057. belowLeft: belowLeft
  40058. };
  40059. };
  40060. Widget.prototype._prepareRenderWidgetAtExactPositionOverflowing = function (topLeft) {
  40061. return new Coordinate(topLeft.top, topLeft.left + this._contentLeft);
  40062. };
  40063. /**
  40064. * Compute `this._topLeft`
  40065. */
  40066. Widget.prototype._getTopAndBottomLeft = function (ctx) {
  40067. if (!this._viewRange) {
  40068. return [null, null];
  40069. }
  40070. var visibleRangesForRange = ctx.linesVisibleRangesForRange(this._viewRange, false);
  40071. if (!visibleRangesForRange || visibleRangesForRange.length === 0) {
  40072. return [null, null];
  40073. }
  40074. var firstLine = visibleRangesForRange[0];
  40075. var lastLine = visibleRangesForRange[0];
  40076. for (var _i = 0, visibleRangesForRange_1 = visibleRangesForRange; _i < visibleRangesForRange_1.length; _i++) {
  40077. var visibleRangesForLine = visibleRangesForRange_1[_i];
  40078. if (visibleRangesForLine.lineNumber < firstLine.lineNumber) {
  40079. firstLine = visibleRangesForLine;
  40080. }
  40081. if (visibleRangesForLine.lineNumber > lastLine.lineNumber) {
  40082. lastLine = visibleRangesForLine;
  40083. }
  40084. }
  40085. var firstLineMinLeft = 1073741824 /* MAX_SAFE_SMALL_INTEGER */; //firstLine.Constants.MAX_SAFE_SMALL_INTEGER;
  40086. for (var _a = 0, _b = firstLine.ranges; _a < _b.length; _a++) {
  40087. var visibleRange = _b[_a];
  40088. if (visibleRange.left < firstLineMinLeft) {
  40089. firstLineMinLeft = visibleRange.left;
  40090. }
  40091. }
  40092. var lastLineMinLeft = 1073741824 /* MAX_SAFE_SMALL_INTEGER */; //lastLine.Constants.MAX_SAFE_SMALL_INTEGER;
  40093. for (var _c = 0, _d = lastLine.ranges; _c < _d.length; _c++) {
  40094. var visibleRange = _d[_c];
  40095. if (visibleRange.left < lastLineMinLeft) {
  40096. lastLineMinLeft = visibleRange.left;
  40097. }
  40098. }
  40099. var topForPosition = ctx.getVerticalOffsetForLineNumber(firstLine.lineNumber) - ctx.scrollTop;
  40100. var topLeft = new Coordinate(topForPosition, firstLineMinLeft);
  40101. var topForBottomLine = ctx.getVerticalOffsetForLineNumber(lastLine.lineNumber) - ctx.scrollTop;
  40102. var bottomLeft = new Coordinate(topForBottomLine, lastLineMinLeft);
  40103. return [topLeft, bottomLeft];
  40104. };
  40105. Widget.prototype._prepareRenderWidget = function (ctx) {
  40106. var _a = this._getTopAndBottomLeft(ctx), topLeft = _a[0], bottomLeft = _a[1];
  40107. if (!topLeft || !bottomLeft) {
  40108. return null;
  40109. }
  40110. if (this._cachedDomNodeClientWidth === -1 || this._cachedDomNodeClientHeight === -1) {
  40111. var domNode = this.domNode.domNode;
  40112. this._cachedDomNodeClientWidth = domNode.clientWidth;
  40113. this._cachedDomNodeClientHeight = domNode.clientHeight;
  40114. }
  40115. var placement;
  40116. if (this.allowEditorOverflow) {
  40117. placement = this._layoutBoxInPage(topLeft, bottomLeft, this._cachedDomNodeClientWidth, this._cachedDomNodeClientHeight, ctx);
  40118. }
  40119. else {
  40120. placement = this._layoutBoxInViewport(topLeft, bottomLeft, this._cachedDomNodeClientWidth, this._cachedDomNodeClientHeight, ctx);
  40121. }
  40122. // Do two passes, first for perfect fit, second picks first option
  40123. if (this._preference) {
  40124. for (var pass = 1; pass <= 2; pass++) {
  40125. for (var _i = 0, _b = this._preference; _i < _b.length; _i++) {
  40126. var pref = _b[_i];
  40127. // placement
  40128. if (pref === 1 /* ABOVE */) {
  40129. if (!placement) {
  40130. // Widget outside of viewport
  40131. return null;
  40132. }
  40133. if (pass === 2 || placement.fitsAbove) {
  40134. return new Coordinate(placement.aboveTop, placement.aboveLeft);
  40135. }
  40136. }
  40137. else if (pref === 2 /* BELOW */) {
  40138. if (!placement) {
  40139. // Widget outside of viewport
  40140. return null;
  40141. }
  40142. if (pass === 2 || placement.fitsBelow) {
  40143. return new Coordinate(placement.belowTop, placement.belowLeft);
  40144. }
  40145. }
  40146. else {
  40147. if (this.allowEditorOverflow) {
  40148. return this._prepareRenderWidgetAtExactPositionOverflowing(topLeft);
  40149. }
  40150. else {
  40151. return topLeft;
  40152. }
  40153. }
  40154. }
  40155. }
  40156. }
  40157. return null;
  40158. };
  40159. /**
  40160. * On this first pass, we ensure that the content widget (if it is in the viewport) has the max width set correctly.
  40161. */
  40162. Widget.prototype.onBeforeRender = function (viewportData) {
  40163. if (!this._viewRange || !this._preference) {
  40164. return;
  40165. }
  40166. if (this._viewRange.endLineNumber < viewportData.startLineNumber || this._viewRange.startLineNumber > viewportData.endLineNumber) {
  40167. // Outside of viewport
  40168. return;
  40169. }
  40170. this.domNode.setMaxWidth(this._maxWidth);
  40171. };
  40172. Widget.prototype.prepareRender = function (ctx) {
  40173. this._renderData = this._prepareRenderWidget(ctx);
  40174. };
  40175. Widget.prototype.render = function (ctx) {
  40176. if (!this._renderData) {
  40177. // This widget should be invisible
  40178. if (this._isVisible) {
  40179. this.domNode.removeAttribute('monaco-visible-content-widget');
  40180. this._isVisible = false;
  40181. this.domNode.setVisibility('hidden');
  40182. }
  40183. return;
  40184. }
  40185. // This widget should be visible
  40186. if (this.allowEditorOverflow) {
  40187. this.domNode.setTop(this._renderData.top);
  40188. this.domNode.setLeft(this._renderData.left);
  40189. }
  40190. else {
  40191. this.domNode.setTop(this._renderData.top + ctx.scrollTop - ctx.bigNumbersDelta);
  40192. this.domNode.setLeft(this._renderData.left);
  40193. }
  40194. if (!this._isVisible) {
  40195. this.domNode.setVisibility('inherit');
  40196. this.domNode.setAttribute('monaco-visible-content-widget', 'true');
  40197. this._isVisible = true;
  40198. }
  40199. };
  40200. return Widget;
  40201. }());
  40202. });
  40203. /*---------------------------------------------------------------------------------------------
  40204. * Copyright (c) Microsoft Corporation. All rights reserved.
  40205. * Licensed under the MIT License. See License.txt in the project root for license information.
  40206. *--------------------------------------------------------------------------------------------*/
  40207. define(__m[367/*vs/editor/browser/viewParts/decorations/decorations*/], __M([0/*require*/,1/*exports*/,82/*vs/editor/browser/view/dynamicViewOverlay*/,3/*vs/editor/common/core/range*/,91/*vs/editor/common/view/renderingContext*/,286/*vs/css!vs/editor/browser/viewParts/decorations/decorations*/]), function (require, exports, dynamicViewOverlay_1, range_1, renderingContext_1) {
  40208. "use strict";
  40209. Object.defineProperty(exports, "__esModule", { value: true });
  40210. var DecorationsOverlay = /** @class */ (function (_super) {
  40211. __extends(DecorationsOverlay, _super);
  40212. function DecorationsOverlay(context) {
  40213. var _this = _super.call(this) || this;
  40214. _this._context = context;
  40215. var options = _this._context.configuration.options;
  40216. _this._lineHeight = options.get(49 /* lineHeight */);
  40217. _this._typicalHalfwidthCharacterWidth = options.get(34 /* fontInfo */).typicalHalfwidthCharacterWidth;
  40218. _this._renderResult = null;
  40219. _this._context.addEventHandler(_this);
  40220. return _this;
  40221. }
  40222. DecorationsOverlay.prototype.dispose = function () {
  40223. this._context.removeEventHandler(this);
  40224. this._renderResult = null;
  40225. _super.prototype.dispose.call(this);
  40226. };
  40227. // --- begin event handlers
  40228. DecorationsOverlay.prototype.onConfigurationChanged = function (e) {
  40229. var options = this._context.configuration.options;
  40230. this._lineHeight = options.get(49 /* lineHeight */);
  40231. this._typicalHalfwidthCharacterWidth = options.get(34 /* fontInfo */).typicalHalfwidthCharacterWidth;
  40232. return true;
  40233. };
  40234. DecorationsOverlay.prototype.onDecorationsChanged = function (e) {
  40235. return true;
  40236. };
  40237. DecorationsOverlay.prototype.onFlushed = function (e) {
  40238. return true;
  40239. };
  40240. DecorationsOverlay.prototype.onLinesChanged = function (e) {
  40241. return true;
  40242. };
  40243. DecorationsOverlay.prototype.onLinesDeleted = function (e) {
  40244. return true;
  40245. };
  40246. DecorationsOverlay.prototype.onLinesInserted = function (e) {
  40247. return true;
  40248. };
  40249. DecorationsOverlay.prototype.onScrollChanged = function (e) {
  40250. return e.scrollTopChanged || e.scrollWidthChanged;
  40251. };
  40252. DecorationsOverlay.prototype.onZonesChanged = function (e) {
  40253. return true;
  40254. };
  40255. // --- end event handlers
  40256. DecorationsOverlay.prototype.prepareRender = function (ctx) {
  40257. var _decorations = ctx.getDecorationsInViewport();
  40258. // Keep only decorations with `className`
  40259. var decorations = [], decorationsLen = 0;
  40260. for (var i = 0, len = _decorations.length; i < len; i++) {
  40261. var d = _decorations[i];
  40262. if (d.options.className) {
  40263. decorations[decorationsLen++] = d;
  40264. }
  40265. }
  40266. // Sort decorations for consistent render output
  40267. decorations = decorations.sort(function (a, b) {
  40268. if (a.options.zIndex < b.options.zIndex) {
  40269. return -1;
  40270. }
  40271. if (a.options.zIndex > b.options.zIndex) {
  40272. return 1;
  40273. }
  40274. var aClassName = a.options.className;
  40275. var bClassName = b.options.className;
  40276. if (aClassName < bClassName) {
  40277. return -1;
  40278. }
  40279. if (aClassName > bClassName) {
  40280. return 1;
  40281. }
  40282. return range_1.Range.compareRangesUsingStarts(a.range, b.range);
  40283. });
  40284. var visibleStartLineNumber = ctx.visibleRange.startLineNumber;
  40285. var visibleEndLineNumber = ctx.visibleRange.endLineNumber;
  40286. var output = [];
  40287. for (var lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
  40288. var lineIndex = lineNumber - visibleStartLineNumber;
  40289. output[lineIndex] = '';
  40290. }
  40291. // Render first whole line decorations and then regular decorations
  40292. this._renderWholeLineDecorations(ctx, decorations, output);
  40293. this._renderNormalDecorations(ctx, decorations, output);
  40294. this._renderResult = output;
  40295. };
  40296. DecorationsOverlay.prototype._renderWholeLineDecorations = function (ctx, decorations, output) {
  40297. var lineHeight = String(this._lineHeight);
  40298. var visibleStartLineNumber = ctx.visibleRange.startLineNumber;
  40299. var visibleEndLineNumber = ctx.visibleRange.endLineNumber;
  40300. for (var i = 0, lenI = decorations.length; i < lenI; i++) {
  40301. var d = decorations[i];
  40302. if (!d.options.isWholeLine) {
  40303. continue;
  40304. }
  40305. var decorationOutput = ('<div class="cdr '
  40306. + d.options.className
  40307. + '" style="left:0;width:100%;height:'
  40308. + lineHeight
  40309. + 'px;"></div>');
  40310. var startLineNumber = Math.max(d.range.startLineNumber, visibleStartLineNumber);
  40311. var endLineNumber = Math.min(d.range.endLineNumber, visibleEndLineNumber);
  40312. for (var j = startLineNumber; j <= endLineNumber; j++) {
  40313. var lineIndex = j - visibleStartLineNumber;
  40314. output[lineIndex] += decorationOutput;
  40315. }
  40316. }
  40317. };
  40318. DecorationsOverlay.prototype._renderNormalDecorations = function (ctx, decorations, output) {
  40319. var lineHeight = String(this._lineHeight);
  40320. var visibleStartLineNumber = ctx.visibleRange.startLineNumber;
  40321. var prevClassName = null;
  40322. var prevShowIfCollapsed = false;
  40323. var prevRange = null;
  40324. for (var i = 0, lenI = decorations.length; i < lenI; i++) {
  40325. var d = decorations[i];
  40326. if (d.options.isWholeLine) {
  40327. continue;
  40328. }
  40329. var className = d.options.className;
  40330. var showIfCollapsed = Boolean(d.options.showIfCollapsed);
  40331. var range = d.range;
  40332. if (showIfCollapsed && range.endColumn === 1 && range.endLineNumber !== range.startLineNumber) {
  40333. range = new range_1.Range(range.startLineNumber, range.startColumn, range.endLineNumber - 1, this._context.model.getLineMaxColumn(range.endLineNumber - 1));
  40334. }
  40335. if (prevClassName === className && prevShowIfCollapsed === showIfCollapsed && range_1.Range.areIntersectingOrTouching(prevRange, range)) {
  40336. // merge into previous decoration
  40337. prevRange = range_1.Range.plusRange(prevRange, range);
  40338. continue;
  40339. }
  40340. // flush previous decoration
  40341. if (prevClassName !== null) {
  40342. this._renderNormalDecoration(ctx, prevRange, prevClassName, prevShowIfCollapsed, lineHeight, visibleStartLineNumber, output);
  40343. }
  40344. prevClassName = className;
  40345. prevShowIfCollapsed = showIfCollapsed;
  40346. prevRange = range;
  40347. }
  40348. if (prevClassName !== null) {
  40349. this._renderNormalDecoration(ctx, prevRange, prevClassName, prevShowIfCollapsed, lineHeight, visibleStartLineNumber, output);
  40350. }
  40351. };
  40352. DecorationsOverlay.prototype._renderNormalDecoration = function (ctx, range, className, showIfCollapsed, lineHeight, visibleStartLineNumber, output) {
  40353. var linesVisibleRanges = ctx.linesVisibleRangesForRange(range, /*TODO@Alex*/ className === 'findMatch');
  40354. if (!linesVisibleRanges) {
  40355. return;
  40356. }
  40357. for (var j = 0, lenJ = linesVisibleRanges.length; j < lenJ; j++) {
  40358. var lineVisibleRanges = linesVisibleRanges[j];
  40359. if (lineVisibleRanges.outsideRenderedLine) {
  40360. continue;
  40361. }
  40362. var lineIndex = lineVisibleRanges.lineNumber - visibleStartLineNumber;
  40363. if (showIfCollapsed && lineVisibleRanges.ranges.length === 1) {
  40364. var singleVisibleRange = lineVisibleRanges.ranges[0];
  40365. if (singleVisibleRange.width === 0) {
  40366. // collapsed range case => make the decoration visible by faking its width
  40367. lineVisibleRanges.ranges[0] = new renderingContext_1.HorizontalRange(singleVisibleRange.left, this._typicalHalfwidthCharacterWidth);
  40368. }
  40369. }
  40370. for (var k = 0, lenK = lineVisibleRanges.ranges.length; k < lenK; k++) {
  40371. var visibleRange = lineVisibleRanges.ranges[k];
  40372. var decorationOutput = ('<div class="cdr '
  40373. + className
  40374. + '" style="left:'
  40375. + String(visibleRange.left)
  40376. + 'px;width:'
  40377. + String(visibleRange.width)
  40378. + 'px;height:'
  40379. + lineHeight
  40380. + 'px;"></div>');
  40381. output[lineIndex] += decorationOutput;
  40382. }
  40383. }
  40384. };
  40385. DecorationsOverlay.prototype.render = function (startLineNumber, lineNumber) {
  40386. if (!this._renderResult) {
  40387. return '';
  40388. }
  40389. var lineIndex = lineNumber - startLineNumber;
  40390. if (lineIndex < 0 || lineIndex >= this._renderResult.length) {
  40391. return '';
  40392. }
  40393. return this._renderResult[lineIndex];
  40394. };
  40395. return DecorationsOverlay;
  40396. }(dynamicViewOverlay_1.DynamicViewOverlay));
  40397. exports.DecorationsOverlay = DecorationsOverlay;
  40398. });
  40399. /*---------------------------------------------------------------------------------------------
  40400. * Copyright (c) Microsoft Corporation. All rights reserved.
  40401. * Licensed under the MIT License. See License.txt in the project root for license information.
  40402. *--------------------------------------------------------------------------------------------*/
  40403. define(__m[149/*vs/editor/browser/viewParts/glyphMargin/glyphMargin*/], __M([0/*require*/,1/*exports*/,82/*vs/editor/browser/view/dynamicViewOverlay*/,287/*vs/css!vs/editor/browser/viewParts/glyphMargin/glyphMargin*/]), function (require, exports, dynamicViewOverlay_1) {
  40404. "use strict";
  40405. Object.defineProperty(exports, "__esModule", { value: true });
  40406. var DecorationToRender = /** @class */ (function () {
  40407. function DecorationToRender(startLineNumber, endLineNumber, className) {
  40408. this.startLineNumber = +startLineNumber;
  40409. this.endLineNumber = +endLineNumber;
  40410. this.className = String(className);
  40411. }
  40412. return DecorationToRender;
  40413. }());
  40414. exports.DecorationToRender = DecorationToRender;
  40415. var DedupOverlay = /** @class */ (function (_super) {
  40416. __extends(DedupOverlay, _super);
  40417. function DedupOverlay() {
  40418. return _super !== null && _super.apply(this, arguments) || this;
  40419. }
  40420. DedupOverlay.prototype._render = function (visibleStartLineNumber, visibleEndLineNumber, decorations) {
  40421. var output = [];
  40422. for (var lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
  40423. var lineIndex = lineNumber - visibleStartLineNumber;
  40424. output[lineIndex] = [];
  40425. }
  40426. if (decorations.length === 0) {
  40427. return output;
  40428. }
  40429. decorations.sort(function (a, b) {
  40430. if (a.className === b.className) {
  40431. if (a.startLineNumber === b.startLineNumber) {
  40432. return a.endLineNumber - b.endLineNumber;
  40433. }
  40434. return a.startLineNumber - b.startLineNumber;
  40435. }
  40436. return (a.className < b.className ? -1 : 1);
  40437. });
  40438. var prevClassName = null;
  40439. var prevEndLineIndex = 0;
  40440. for (var i = 0, len = decorations.length; i < len; i++) {
  40441. var d = decorations[i];
  40442. var className = d.className;
  40443. var startLineIndex = Math.max(d.startLineNumber, visibleStartLineNumber) - visibleStartLineNumber;
  40444. var endLineIndex = Math.min(d.endLineNumber, visibleEndLineNumber) - visibleStartLineNumber;
  40445. if (prevClassName === className) {
  40446. startLineIndex = Math.max(prevEndLineIndex + 1, startLineIndex);
  40447. prevEndLineIndex = Math.max(prevEndLineIndex, endLineIndex);
  40448. }
  40449. else {
  40450. prevClassName = className;
  40451. prevEndLineIndex = endLineIndex;
  40452. }
  40453. for (var i_1 = startLineIndex; i_1 <= prevEndLineIndex; i_1++) {
  40454. output[i_1].push(prevClassName);
  40455. }
  40456. }
  40457. return output;
  40458. };
  40459. return DedupOverlay;
  40460. }(dynamicViewOverlay_1.DynamicViewOverlay));
  40461. exports.DedupOverlay = DedupOverlay;
  40462. var GlyphMarginOverlay = /** @class */ (function (_super) {
  40463. __extends(GlyphMarginOverlay, _super);
  40464. function GlyphMarginOverlay(context) {
  40465. var _this = _super.call(this) || this;
  40466. _this._context = context;
  40467. var options = _this._context.configuration.options;
  40468. var layoutInfo = options.get(107 /* layoutInfo */);
  40469. _this._lineHeight = options.get(49 /* lineHeight */);
  40470. _this._glyphMargin = options.get(40 /* glyphMargin */);
  40471. _this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
  40472. _this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
  40473. _this._renderResult = null;
  40474. _this._context.addEventHandler(_this);
  40475. return _this;
  40476. }
  40477. GlyphMarginOverlay.prototype.dispose = function () {
  40478. this._context.removeEventHandler(this);
  40479. this._renderResult = null;
  40480. _super.prototype.dispose.call(this);
  40481. };
  40482. // --- begin event handlers
  40483. GlyphMarginOverlay.prototype.onConfigurationChanged = function (e) {
  40484. var options = this._context.configuration.options;
  40485. var layoutInfo = options.get(107 /* layoutInfo */);
  40486. this._lineHeight = options.get(49 /* lineHeight */);
  40487. this._glyphMargin = options.get(40 /* glyphMargin */);
  40488. this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
  40489. this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
  40490. return true;
  40491. };
  40492. GlyphMarginOverlay.prototype.onDecorationsChanged = function (e) {
  40493. return true;
  40494. };
  40495. GlyphMarginOverlay.prototype.onFlushed = function (e) {
  40496. return true;
  40497. };
  40498. GlyphMarginOverlay.prototype.onLinesChanged = function (e) {
  40499. return true;
  40500. };
  40501. GlyphMarginOverlay.prototype.onLinesDeleted = function (e) {
  40502. return true;
  40503. };
  40504. GlyphMarginOverlay.prototype.onLinesInserted = function (e) {
  40505. return true;
  40506. };
  40507. GlyphMarginOverlay.prototype.onScrollChanged = function (e) {
  40508. return e.scrollTopChanged;
  40509. };
  40510. GlyphMarginOverlay.prototype.onZonesChanged = function (e) {
  40511. return true;
  40512. };
  40513. // --- end event handlers
  40514. GlyphMarginOverlay.prototype._getDecorations = function (ctx) {
  40515. var decorations = ctx.getDecorationsInViewport();
  40516. var r = [], rLen = 0;
  40517. for (var i = 0, len = decorations.length; i < len; i++) {
  40518. var d = decorations[i];
  40519. var glyphMarginClassName = d.options.glyphMarginClassName;
  40520. if (glyphMarginClassName) {
  40521. r[rLen++] = new DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, glyphMarginClassName);
  40522. }
  40523. }
  40524. return r;
  40525. };
  40526. GlyphMarginOverlay.prototype.prepareRender = function (ctx) {
  40527. if (!this._glyphMargin) {
  40528. this._renderResult = null;
  40529. return;
  40530. }
  40531. var visibleStartLineNumber = ctx.visibleRange.startLineNumber;
  40532. var visibleEndLineNumber = ctx.visibleRange.endLineNumber;
  40533. var toRender = this._render(visibleStartLineNumber, visibleEndLineNumber, this._getDecorations(ctx));
  40534. var lineHeight = this._lineHeight.toString();
  40535. var left = this._glyphMarginLeft.toString();
  40536. var width = this._glyphMarginWidth.toString();
  40537. var common = '" style="left:' + left + 'px;width:' + width + 'px' + ';height:' + lineHeight + 'px;"></div>';
  40538. var output = [];
  40539. for (var lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
  40540. var lineIndex = lineNumber - visibleStartLineNumber;
  40541. var classNames = toRender[lineIndex];
  40542. if (classNames.length === 0) {
  40543. output[lineIndex] = '';
  40544. }
  40545. else {
  40546. output[lineIndex] = ('<div class="cgmr codicon '
  40547. + classNames.join(' ')
  40548. + common);
  40549. }
  40550. }
  40551. this._renderResult = output;
  40552. };
  40553. GlyphMarginOverlay.prototype.render = function (startLineNumber, lineNumber) {
  40554. if (!this._renderResult) {
  40555. return '';
  40556. }
  40557. var lineIndex = lineNumber - startLineNumber;
  40558. if (lineIndex < 0 || lineIndex >= this._renderResult.length) {
  40559. return '';
  40560. }
  40561. return this._renderResult[lineIndex];
  40562. };
  40563. return GlyphMarginOverlay;
  40564. }(DedupOverlay));
  40565. exports.GlyphMarginOverlay = GlyphMarginOverlay;
  40566. });
  40567. /*---------------------------------------------------------------------------------------------
  40568. * Copyright (c) Microsoft Corporation. All rights reserved.
  40569. * Licensed under the MIT License. See License.txt in the project root for license information.
  40570. *--------------------------------------------------------------------------------------------*/
  40571. define(__m[368/*vs/editor/browser/viewParts/linesDecorations/linesDecorations*/], __M([0/*require*/,1/*exports*/,149/*vs/editor/browser/viewParts/glyphMargin/glyphMargin*/,291/*vs/css!vs/editor/browser/viewParts/linesDecorations/linesDecorations*/]), function (require, exports, glyphMargin_1) {
  40572. "use strict";
  40573. Object.defineProperty(exports, "__esModule", { value: true });
  40574. var LinesDecorationsOverlay = /** @class */ (function (_super) {
  40575. __extends(LinesDecorationsOverlay, _super);
  40576. function LinesDecorationsOverlay(context) {
  40577. var _this = _super.call(this) || this;
  40578. _this._context = context;
  40579. var options = _this._context.configuration.options;
  40580. var layoutInfo = options.get(107 /* layoutInfo */);
  40581. _this._decorationsLeft = layoutInfo.decorationsLeft;
  40582. _this._decorationsWidth = layoutInfo.decorationsWidth;
  40583. _this._renderResult = null;
  40584. _this._context.addEventHandler(_this);
  40585. return _this;
  40586. }
  40587. LinesDecorationsOverlay.prototype.dispose = function () {
  40588. this._context.removeEventHandler(this);
  40589. this._renderResult = null;
  40590. _super.prototype.dispose.call(this);
  40591. };
  40592. // --- begin event handlers
  40593. LinesDecorationsOverlay.prototype.onConfigurationChanged = function (e) {
  40594. var options = this._context.configuration.options;
  40595. var layoutInfo = options.get(107 /* layoutInfo */);
  40596. this._decorationsLeft = layoutInfo.decorationsLeft;
  40597. this._decorationsWidth = layoutInfo.decorationsWidth;
  40598. return true;
  40599. };
  40600. LinesDecorationsOverlay.prototype.onDecorationsChanged = function (e) {
  40601. return true;
  40602. };
  40603. LinesDecorationsOverlay.prototype.onFlushed = function (e) {
  40604. return true;
  40605. };
  40606. LinesDecorationsOverlay.prototype.onLinesChanged = function (e) {
  40607. return true;
  40608. };
  40609. LinesDecorationsOverlay.prototype.onLinesDeleted = function (e) {
  40610. return true;
  40611. };
  40612. LinesDecorationsOverlay.prototype.onLinesInserted = function (e) {
  40613. return true;
  40614. };
  40615. LinesDecorationsOverlay.prototype.onScrollChanged = function (e) {
  40616. return e.scrollTopChanged;
  40617. };
  40618. LinesDecorationsOverlay.prototype.onZonesChanged = function (e) {
  40619. return true;
  40620. };
  40621. // --- end event handlers
  40622. LinesDecorationsOverlay.prototype._getDecorations = function (ctx) {
  40623. var decorations = ctx.getDecorationsInViewport();
  40624. var r = [], rLen = 0;
  40625. for (var i = 0, len = decorations.length; i < len; i++) {
  40626. var d = decorations[i];
  40627. var linesDecorationsClassName = d.options.linesDecorationsClassName;
  40628. if (linesDecorationsClassName) {
  40629. r[rLen++] = new glyphMargin_1.DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, linesDecorationsClassName);
  40630. }
  40631. }
  40632. return r;
  40633. };
  40634. LinesDecorationsOverlay.prototype.prepareRender = function (ctx) {
  40635. var visibleStartLineNumber = ctx.visibleRange.startLineNumber;
  40636. var visibleEndLineNumber = ctx.visibleRange.endLineNumber;
  40637. var toRender = this._render(visibleStartLineNumber, visibleEndLineNumber, this._getDecorations(ctx));
  40638. var left = this._decorationsLeft.toString();
  40639. var width = this._decorationsWidth.toString();
  40640. var common = '" style="left:' + left + 'px;width:' + width + 'px;"></div>';
  40641. var output = [];
  40642. for (var lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
  40643. var lineIndex = lineNumber - visibleStartLineNumber;
  40644. var classNames = toRender[lineIndex];
  40645. var lineOutput = '';
  40646. for (var i = 0, len = classNames.length; i < len; i++) {
  40647. lineOutput += '<div class="cldr ' + classNames[i] + common;
  40648. }
  40649. output[lineIndex] = lineOutput;
  40650. }
  40651. this._renderResult = output;
  40652. };
  40653. LinesDecorationsOverlay.prototype.render = function (startLineNumber, lineNumber) {
  40654. if (!this._renderResult) {
  40655. return '';
  40656. }
  40657. return this._renderResult[lineNumber - startLineNumber];
  40658. };
  40659. return LinesDecorationsOverlay;
  40660. }(glyphMargin_1.DedupOverlay));
  40661. exports.LinesDecorationsOverlay = LinesDecorationsOverlay;
  40662. });
  40663. /*---------------------------------------------------------------------------------------------
  40664. * Copyright (c) Microsoft Corporation. All rights reserved.
  40665. * Licensed under the MIT License. See License.txt in the project root for license information.
  40666. *--------------------------------------------------------------------------------------------*/
  40667. define(__m[195/*vs/editor/browser/viewParts/margin/margin*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,37/*vs/editor/browser/view/viewPart*/]), function (require, exports, fastDomNode_1, viewPart_1) {
  40668. "use strict";
  40669. Object.defineProperty(exports, "__esModule", { value: true });
  40670. var Margin = /** @class */ (function (_super) {
  40671. __extends(Margin, _super);
  40672. function Margin(context) {
  40673. var _this = _super.call(this, context) || this;
  40674. var options = _this._context.configuration.options;
  40675. var layoutInfo = options.get(107 /* layoutInfo */);
  40676. _this._canUseLayerHinting = !options.get(22 /* disableLayerHinting */);
  40677. _this._contentLeft = layoutInfo.contentLeft;
  40678. _this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
  40679. _this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
  40680. _this._domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  40681. _this._domNode.setClassName(Margin.OUTER_CLASS_NAME);
  40682. _this._domNode.setPosition('absolute');
  40683. _this._domNode.setAttribute('role', 'presentation');
  40684. _this._domNode.setAttribute('aria-hidden', 'true');
  40685. _this._glyphMarginBackgroundDomNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  40686. _this._glyphMarginBackgroundDomNode.setClassName(Margin.CLASS_NAME);
  40687. _this._domNode.appendChild(_this._glyphMarginBackgroundDomNode);
  40688. return _this;
  40689. }
  40690. Margin.prototype.dispose = function () {
  40691. _super.prototype.dispose.call(this);
  40692. };
  40693. Margin.prototype.getDomNode = function () {
  40694. return this._domNode;
  40695. };
  40696. // --- begin event handlers
  40697. Margin.prototype.onConfigurationChanged = function (e) {
  40698. var options = this._context.configuration.options;
  40699. var layoutInfo = options.get(107 /* layoutInfo */);
  40700. this._canUseLayerHinting = !options.get(22 /* disableLayerHinting */);
  40701. this._contentLeft = layoutInfo.contentLeft;
  40702. this._glyphMarginLeft = layoutInfo.glyphMarginLeft;
  40703. this._glyphMarginWidth = layoutInfo.glyphMarginWidth;
  40704. return true;
  40705. };
  40706. Margin.prototype.onScrollChanged = function (e) {
  40707. return _super.prototype.onScrollChanged.call(this, e) || e.scrollTopChanged;
  40708. };
  40709. // --- end event handlers
  40710. Margin.prototype.prepareRender = function (ctx) {
  40711. // Nothing to read
  40712. };
  40713. Margin.prototype.render = function (ctx) {
  40714. this._domNode.setLayerHinting(this._canUseLayerHinting);
  40715. this._domNode.setContain('strict');
  40716. var adjustedScrollTop = ctx.scrollTop - ctx.bigNumbersDelta;
  40717. this._domNode.setTop(-adjustedScrollTop);
  40718. var height = Math.min(ctx.scrollHeight, 1000000);
  40719. this._domNode.setHeight(height);
  40720. this._domNode.setWidth(this._contentLeft);
  40721. this._glyphMarginBackgroundDomNode.setLeft(this._glyphMarginLeft);
  40722. this._glyphMarginBackgroundDomNode.setWidth(this._glyphMarginWidth);
  40723. this._glyphMarginBackgroundDomNode.setHeight(height);
  40724. };
  40725. Margin.CLASS_NAME = 'glyph-margin';
  40726. Margin.OUTER_CLASS_NAME = 'margin';
  40727. return Margin;
  40728. }(viewPart_1.ViewPart));
  40729. exports.Margin = Margin;
  40730. });
  40731. /*---------------------------------------------------------------------------------------------
  40732. * Copyright (c) Microsoft Corporation. All rights reserved.
  40733. * Licensed under the MIT License. See License.txt in the project root for license information.
  40734. *--------------------------------------------------------------------------------------------*/
  40735. define(__m[369/*vs/editor/browser/viewParts/marginDecorations/marginDecorations*/], __M([0/*require*/,1/*exports*/,149/*vs/editor/browser/viewParts/glyphMargin/glyphMargin*/,292/*vs/css!vs/editor/browser/viewParts/marginDecorations/marginDecorations*/]), function (require, exports, glyphMargin_1) {
  40736. "use strict";
  40737. Object.defineProperty(exports, "__esModule", { value: true });
  40738. var MarginViewLineDecorationsOverlay = /** @class */ (function (_super) {
  40739. __extends(MarginViewLineDecorationsOverlay, _super);
  40740. function MarginViewLineDecorationsOverlay(context) {
  40741. var _this = _super.call(this) || this;
  40742. _this._context = context;
  40743. _this._renderResult = null;
  40744. _this._context.addEventHandler(_this);
  40745. return _this;
  40746. }
  40747. MarginViewLineDecorationsOverlay.prototype.dispose = function () {
  40748. this._context.removeEventHandler(this);
  40749. this._renderResult = null;
  40750. _super.prototype.dispose.call(this);
  40751. };
  40752. // --- begin event handlers
  40753. MarginViewLineDecorationsOverlay.prototype.onConfigurationChanged = function (e) {
  40754. return true;
  40755. };
  40756. MarginViewLineDecorationsOverlay.prototype.onDecorationsChanged = function (e) {
  40757. return true;
  40758. };
  40759. MarginViewLineDecorationsOverlay.prototype.onFlushed = function (e) {
  40760. return true;
  40761. };
  40762. MarginViewLineDecorationsOverlay.prototype.onLinesChanged = function (e) {
  40763. return true;
  40764. };
  40765. MarginViewLineDecorationsOverlay.prototype.onLinesDeleted = function (e) {
  40766. return true;
  40767. };
  40768. MarginViewLineDecorationsOverlay.prototype.onLinesInserted = function (e) {
  40769. return true;
  40770. };
  40771. MarginViewLineDecorationsOverlay.prototype.onScrollChanged = function (e) {
  40772. return e.scrollTopChanged;
  40773. };
  40774. MarginViewLineDecorationsOverlay.prototype.onZonesChanged = function (e) {
  40775. return true;
  40776. };
  40777. // --- end event handlers
  40778. MarginViewLineDecorationsOverlay.prototype._getDecorations = function (ctx) {
  40779. var decorations = ctx.getDecorationsInViewport();
  40780. var r = [], rLen = 0;
  40781. for (var i = 0, len = decorations.length; i < len; i++) {
  40782. var d = decorations[i];
  40783. var marginClassName = d.options.marginClassName;
  40784. if (marginClassName) {
  40785. r[rLen++] = new glyphMargin_1.DecorationToRender(d.range.startLineNumber, d.range.endLineNumber, marginClassName);
  40786. }
  40787. }
  40788. return r;
  40789. };
  40790. MarginViewLineDecorationsOverlay.prototype.prepareRender = function (ctx) {
  40791. var visibleStartLineNumber = ctx.visibleRange.startLineNumber;
  40792. var visibleEndLineNumber = ctx.visibleRange.endLineNumber;
  40793. var toRender = this._render(visibleStartLineNumber, visibleEndLineNumber, this._getDecorations(ctx));
  40794. var output = [];
  40795. for (var lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
  40796. var lineIndex = lineNumber - visibleStartLineNumber;
  40797. var classNames = toRender[lineIndex];
  40798. var lineOutput = '';
  40799. for (var i = 0, len = classNames.length; i < len; i++) {
  40800. lineOutput += '<div class="cmdr ' + classNames[i] + '" style=""></div>';
  40801. }
  40802. output[lineIndex] = lineOutput;
  40803. }
  40804. this._renderResult = output;
  40805. };
  40806. MarginViewLineDecorationsOverlay.prototype.render = function (startLineNumber, lineNumber) {
  40807. if (!this._renderResult) {
  40808. return '';
  40809. }
  40810. return this._renderResult[lineNumber - startLineNumber];
  40811. };
  40812. return MarginViewLineDecorationsOverlay;
  40813. }(glyphMargin_1.DedupOverlay));
  40814. exports.MarginViewLineDecorationsOverlay = MarginViewLineDecorationsOverlay;
  40815. });
  40816. /*---------------------------------------------------------------------------------------------
  40817. * Copyright (c) Microsoft Corporation. All rights reserved.
  40818. * Licensed under the MIT License. See License.txt in the project root for license information.
  40819. *--------------------------------------------------------------------------------------------*/
  40820. define(__m[370/*vs/editor/browser/viewParts/overlayWidgets/overlayWidgets*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,37/*vs/editor/browser/view/viewPart*/,294/*vs/css!vs/editor/browser/viewParts/overlayWidgets/overlayWidgets*/]), function (require, exports, fastDomNode_1, viewPart_1) {
  40821. "use strict";
  40822. Object.defineProperty(exports, "__esModule", { value: true });
  40823. var ViewOverlayWidgets = /** @class */ (function (_super) {
  40824. __extends(ViewOverlayWidgets, _super);
  40825. function ViewOverlayWidgets(context) {
  40826. var _this = _super.call(this, context) || this;
  40827. var options = _this._context.configuration.options;
  40828. var layoutInfo = options.get(107 /* layoutInfo */);
  40829. _this._widgets = {};
  40830. _this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth;
  40831. _this._minimapWidth = layoutInfo.minimapWidth;
  40832. _this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight;
  40833. _this._editorHeight = layoutInfo.height;
  40834. _this._editorWidth = layoutInfo.width;
  40835. _this._domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  40836. viewPart_1.PartFingerprints.write(_this._domNode, 4 /* OverlayWidgets */);
  40837. _this._domNode.setClassName('overlayWidgets');
  40838. return _this;
  40839. }
  40840. ViewOverlayWidgets.prototype.dispose = function () {
  40841. _super.prototype.dispose.call(this);
  40842. this._widgets = {};
  40843. };
  40844. ViewOverlayWidgets.prototype.getDomNode = function () {
  40845. return this._domNode;
  40846. };
  40847. // ---- begin view event handlers
  40848. ViewOverlayWidgets.prototype.onConfigurationChanged = function (e) {
  40849. var options = this._context.configuration.options;
  40850. var layoutInfo = options.get(107 /* layoutInfo */);
  40851. this._verticalScrollbarWidth = layoutInfo.verticalScrollbarWidth;
  40852. this._minimapWidth = layoutInfo.minimapWidth;
  40853. this._horizontalScrollbarHeight = layoutInfo.horizontalScrollbarHeight;
  40854. this._editorHeight = layoutInfo.height;
  40855. this._editorWidth = layoutInfo.width;
  40856. return true;
  40857. };
  40858. // ---- end view event handlers
  40859. ViewOverlayWidgets.prototype.addWidget = function (widget) {
  40860. var domNode = fastDomNode_1.createFastDomNode(widget.getDomNode());
  40861. this._widgets[widget.getId()] = {
  40862. widget: widget,
  40863. preference: null,
  40864. domNode: domNode
  40865. };
  40866. // This is sync because a widget wants to be in the dom
  40867. domNode.setPosition('absolute');
  40868. domNode.setAttribute('widgetId', widget.getId());
  40869. this._domNode.appendChild(domNode);
  40870. this.setShouldRender();
  40871. };
  40872. ViewOverlayWidgets.prototype.setWidgetPosition = function (widget, preference) {
  40873. var widgetData = this._widgets[widget.getId()];
  40874. if (widgetData.preference === preference) {
  40875. return false;
  40876. }
  40877. widgetData.preference = preference;
  40878. this.setShouldRender();
  40879. return true;
  40880. };
  40881. ViewOverlayWidgets.prototype.removeWidget = function (widget) {
  40882. var widgetId = widget.getId();
  40883. if (this._widgets.hasOwnProperty(widgetId)) {
  40884. var widgetData = this._widgets[widgetId];
  40885. var domNode = widgetData.domNode.domNode;
  40886. delete this._widgets[widgetId];
  40887. domNode.parentNode.removeChild(domNode);
  40888. this.setShouldRender();
  40889. }
  40890. };
  40891. ViewOverlayWidgets.prototype._renderWidget = function (widgetData) {
  40892. var domNode = widgetData.domNode;
  40893. if (widgetData.preference === null) {
  40894. domNode.unsetTop();
  40895. return;
  40896. }
  40897. if (widgetData.preference === 0 /* TOP_RIGHT_CORNER */) {
  40898. domNode.setTop(0);
  40899. domNode.setRight((2 * this._verticalScrollbarWidth) + this._minimapWidth);
  40900. }
  40901. else if (widgetData.preference === 1 /* BOTTOM_RIGHT_CORNER */) {
  40902. var widgetHeight = domNode.domNode.clientHeight;
  40903. domNode.setTop((this._editorHeight - widgetHeight - 2 * this._horizontalScrollbarHeight));
  40904. domNode.setRight((2 * this._verticalScrollbarWidth) + this._minimapWidth);
  40905. }
  40906. else if (widgetData.preference === 2 /* TOP_CENTER */) {
  40907. domNode.setTop(0);
  40908. domNode.domNode.style.right = '50%';
  40909. }
  40910. };
  40911. ViewOverlayWidgets.prototype.prepareRender = function (ctx) {
  40912. // Nothing to read
  40913. };
  40914. ViewOverlayWidgets.prototype.render = function (ctx) {
  40915. this._domNode.setWidth(this._editorWidth);
  40916. var keys = Object.keys(this._widgets);
  40917. for (var i = 0, len = keys.length; i < len; i++) {
  40918. var widgetId = keys[i];
  40919. this._renderWidget(this._widgets[widgetId]);
  40920. }
  40921. };
  40922. return ViewOverlayWidgets;
  40923. }(viewPart_1.ViewPart));
  40924. exports.ViewOverlayWidgets = ViewOverlayWidgets;
  40925. });
  40926. /*---------------------------------------------------------------------------------------------
  40927. * Copyright (c) Microsoft Corporation. All rights reserved.
  40928. * Licensed under the MIT License. See License.txt in the project root for license information.
  40929. *--------------------------------------------------------------------------------------------*/
  40930. define(__m[371/*vs/editor/browser/viewParts/overviewRuler/overviewRuler*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,193/*vs/editor/common/view/overviewZoneManager*/,92/*vs/editor/common/viewModel/viewEventHandler*/]), function (require, exports, fastDomNode_1, overviewZoneManager_1, viewEventHandler_1) {
  40931. "use strict";
  40932. Object.defineProperty(exports, "__esModule", { value: true });
  40933. var OverviewRuler = /** @class */ (function (_super) {
  40934. __extends(OverviewRuler, _super);
  40935. function OverviewRuler(context, cssClassName) {
  40936. var _this = _super.call(this) || this;
  40937. _this._context = context;
  40938. var options = _this._context.configuration.options;
  40939. _this._domNode = fastDomNode_1.createFastDomNode(document.createElement('canvas'));
  40940. _this._domNode.setClassName(cssClassName);
  40941. _this._domNode.setPosition('absolute');
  40942. _this._domNode.setLayerHinting(true);
  40943. _this._domNode.setContain('strict');
  40944. _this._zoneManager = new overviewZoneManager_1.OverviewZoneManager(function (lineNumber) { return _this._context.viewLayout.getVerticalOffsetForLineNumber(lineNumber); });
  40945. _this._zoneManager.setDOMWidth(0);
  40946. _this._zoneManager.setDOMHeight(0);
  40947. _this._zoneManager.setOuterHeight(_this._context.viewLayout.getScrollHeight());
  40948. _this._zoneManager.setLineHeight(options.get(49 /* lineHeight */));
  40949. _this._zoneManager.setPixelRatio(options.get(105 /* pixelRatio */));
  40950. _this._context.addEventHandler(_this);
  40951. return _this;
  40952. }
  40953. OverviewRuler.prototype.dispose = function () {
  40954. this._context.removeEventHandler(this);
  40955. _super.prototype.dispose.call(this);
  40956. };
  40957. // ---- begin view event handlers
  40958. OverviewRuler.prototype.onConfigurationChanged = function (e) {
  40959. var options = this._context.configuration.options;
  40960. if (e.hasChanged(49 /* lineHeight */)) {
  40961. this._zoneManager.setLineHeight(options.get(49 /* lineHeight */));
  40962. this._render();
  40963. }
  40964. if (e.hasChanged(105 /* pixelRatio */)) {
  40965. this._zoneManager.setPixelRatio(options.get(105 /* pixelRatio */));
  40966. this._domNode.setWidth(this._zoneManager.getDOMWidth());
  40967. this._domNode.setHeight(this._zoneManager.getDOMHeight());
  40968. this._domNode.domNode.width = this._zoneManager.getCanvasWidth();
  40969. this._domNode.domNode.height = this._zoneManager.getCanvasHeight();
  40970. this._render();
  40971. }
  40972. return true;
  40973. };
  40974. OverviewRuler.prototype.onFlushed = function (e) {
  40975. this._render();
  40976. return true;
  40977. };
  40978. OverviewRuler.prototype.onScrollChanged = function (e) {
  40979. if (e.scrollHeightChanged) {
  40980. this._zoneManager.setOuterHeight(e.scrollHeight);
  40981. this._render();
  40982. }
  40983. return true;
  40984. };
  40985. OverviewRuler.prototype.onZonesChanged = function (e) {
  40986. this._render();
  40987. return true;
  40988. };
  40989. // ---- end view event handlers
  40990. OverviewRuler.prototype.getDomNode = function () {
  40991. return this._domNode.domNode;
  40992. };
  40993. OverviewRuler.prototype.setLayout = function (position) {
  40994. this._domNode.setTop(position.top);
  40995. this._domNode.setRight(position.right);
  40996. var hasChanged = false;
  40997. hasChanged = this._zoneManager.setDOMWidth(position.width) || hasChanged;
  40998. hasChanged = this._zoneManager.setDOMHeight(position.height) || hasChanged;
  40999. if (hasChanged) {
  41000. this._domNode.setWidth(this._zoneManager.getDOMWidth());
  41001. this._domNode.setHeight(this._zoneManager.getDOMHeight());
  41002. this._domNode.domNode.width = this._zoneManager.getCanvasWidth();
  41003. this._domNode.domNode.height = this._zoneManager.getCanvasHeight();
  41004. this._render();
  41005. }
  41006. };
  41007. OverviewRuler.prototype.setZones = function (zones) {
  41008. this._zoneManager.setZones(zones);
  41009. this._render();
  41010. };
  41011. OverviewRuler.prototype._render = function () {
  41012. if (this._zoneManager.getOuterHeight() === 0) {
  41013. return false;
  41014. }
  41015. var width = this._zoneManager.getCanvasWidth();
  41016. var height = this._zoneManager.getCanvasHeight();
  41017. var colorZones = this._zoneManager.resolveColorZones();
  41018. var id2Color = this._zoneManager.getId2Color();
  41019. var ctx = this._domNode.domNode.getContext('2d');
  41020. ctx.clearRect(0, 0, width, height);
  41021. if (colorZones.length > 0) {
  41022. this._renderOneLane(ctx, colorZones, id2Color, width);
  41023. }
  41024. return true;
  41025. };
  41026. OverviewRuler.prototype._renderOneLane = function (ctx, colorZones, id2Color, width) {
  41027. var currentColorId = 0;
  41028. var currentFrom = 0;
  41029. var currentTo = 0;
  41030. for (var _i = 0, colorZones_1 = colorZones; _i < colorZones_1.length; _i++) {
  41031. var zone = colorZones_1[_i];
  41032. var zoneColorId = zone.colorId;
  41033. var zoneFrom = zone.from;
  41034. var zoneTo = zone.to;
  41035. if (zoneColorId !== currentColorId) {
  41036. ctx.fillRect(0, currentFrom, width, currentTo - currentFrom);
  41037. currentColorId = zoneColorId;
  41038. ctx.fillStyle = id2Color[currentColorId];
  41039. currentFrom = zoneFrom;
  41040. currentTo = zoneTo;
  41041. }
  41042. else {
  41043. if (currentTo >= zoneFrom) {
  41044. currentTo = Math.max(currentTo, zoneTo);
  41045. }
  41046. else {
  41047. ctx.fillRect(0, currentFrom, width, currentTo - currentFrom);
  41048. currentFrom = zoneFrom;
  41049. currentTo = zoneTo;
  41050. }
  41051. }
  41052. }
  41053. ctx.fillRect(0, currentFrom, width, currentTo - currentFrom);
  41054. };
  41055. return OverviewRuler;
  41056. }(viewEventHandler_1.ViewEventHandler));
  41057. exports.OverviewRuler = OverviewRuler;
  41058. });
  41059. /*---------------------------------------------------------------------------------------------
  41060. * Copyright (c) Microsoft Corporation. All rights reserved.
  41061. * Licensed under the MIT License. See License.txt in the project root for license information.
  41062. *--------------------------------------------------------------------------------------------*/
  41063. define(__m[372/*vs/editor/browser/viewParts/viewZones/viewZones*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,10/*vs/base/common/errors*/,37/*vs/editor/browser/view/viewPart*/,13/*vs/editor/common/core/position*/]), function (require, exports, fastDomNode_1, errors_1, viewPart_1, position_1) {
  41064. "use strict";
  41065. Object.defineProperty(exports, "__esModule", { value: true });
  41066. var invalidFunc = function () { throw new Error("Invalid change accessor"); };
  41067. var ViewZones = /** @class */ (function (_super) {
  41068. __extends(ViewZones, _super);
  41069. function ViewZones(context) {
  41070. var _this = _super.call(this, context) || this;
  41071. var options = _this._context.configuration.options;
  41072. var layoutInfo = options.get(107 /* layoutInfo */);
  41073. _this._lineHeight = options.get(49 /* lineHeight */);
  41074. _this._contentWidth = layoutInfo.contentWidth;
  41075. _this._contentLeft = layoutInfo.contentLeft;
  41076. _this.domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  41077. _this.domNode.setClassName('view-zones');
  41078. _this.domNode.setPosition('absolute');
  41079. _this.domNode.setAttribute('role', 'presentation');
  41080. _this.domNode.setAttribute('aria-hidden', 'true');
  41081. _this.marginDomNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  41082. _this.marginDomNode.setClassName('margin-view-zones');
  41083. _this.marginDomNode.setPosition('absolute');
  41084. _this.marginDomNode.setAttribute('role', 'presentation');
  41085. _this.marginDomNode.setAttribute('aria-hidden', 'true');
  41086. _this._zones = {};
  41087. return _this;
  41088. }
  41089. ViewZones.prototype.dispose = function () {
  41090. _super.prototype.dispose.call(this);
  41091. this._zones = {};
  41092. };
  41093. // ---- begin view event handlers
  41094. ViewZones.prototype._recomputeWhitespacesProps = function () {
  41095. var _this = this;
  41096. var whitespaces = this._context.viewLayout.getWhitespaces();
  41097. var oldWhitespaces = new Map();
  41098. for (var _i = 0, whitespaces_1 = whitespaces; _i < whitespaces_1.length; _i++) {
  41099. var whitespace = whitespaces_1[_i];
  41100. oldWhitespaces.set(whitespace.id, whitespace);
  41101. }
  41102. return this._context.viewLayout.changeWhitespace(function (whitespaceAccessor) {
  41103. var hadAChange = false;
  41104. var keys = Object.keys(_this._zones);
  41105. for (var i = 0, len = keys.length; i < len; i++) {
  41106. var id = keys[i];
  41107. var zone = _this._zones[id];
  41108. var props = _this._computeWhitespaceProps(zone.delegate);
  41109. var oldWhitespace = oldWhitespaces.get(id);
  41110. if (oldWhitespace && (oldWhitespace.afterLineNumber !== props.afterViewLineNumber || oldWhitespace.height !== props.heightInPx)) {
  41111. whitespaceAccessor.changeOneWhitespace(id, props.afterViewLineNumber, props.heightInPx);
  41112. _this._safeCallOnComputedHeight(zone.delegate, props.heightInPx);
  41113. hadAChange = true;
  41114. }
  41115. }
  41116. return hadAChange;
  41117. });
  41118. };
  41119. ViewZones.prototype.onConfigurationChanged = function (e) {
  41120. var options = this._context.configuration.options;
  41121. var layoutInfo = options.get(107 /* layoutInfo */);
  41122. this._lineHeight = options.get(49 /* lineHeight */);
  41123. this._contentWidth = layoutInfo.contentWidth;
  41124. this._contentLeft = layoutInfo.contentLeft;
  41125. if (e.hasChanged(49 /* lineHeight */)) {
  41126. this._recomputeWhitespacesProps();
  41127. }
  41128. return true;
  41129. };
  41130. ViewZones.prototype.onLineMappingChanged = function (e) {
  41131. var hadAChange = this._recomputeWhitespacesProps();
  41132. if (hadAChange) {
  41133. this._context.viewLayout.onHeightMaybeChanged();
  41134. }
  41135. return hadAChange;
  41136. };
  41137. ViewZones.prototype.onLinesDeleted = function (e) {
  41138. return true;
  41139. };
  41140. ViewZones.prototype.onScrollChanged = function (e) {
  41141. return e.scrollTopChanged || e.scrollWidthChanged;
  41142. };
  41143. ViewZones.prototype.onZonesChanged = function (e) {
  41144. return true;
  41145. };
  41146. ViewZones.prototype.onLinesInserted = function (e) {
  41147. return true;
  41148. };
  41149. // ---- end view event handlers
  41150. ViewZones.prototype._getZoneOrdinal = function (zone) {
  41151. if (typeof zone.afterColumn !== 'undefined') {
  41152. return zone.afterColumn;
  41153. }
  41154. return 10000;
  41155. };
  41156. ViewZones.prototype._computeWhitespaceProps = function (zone) {
  41157. if (zone.afterLineNumber === 0) {
  41158. return {
  41159. afterViewLineNumber: 0,
  41160. heightInPx: this._heightInPixels(zone),
  41161. minWidthInPx: this._minWidthInPixels(zone)
  41162. };
  41163. }
  41164. var zoneAfterModelPosition;
  41165. if (typeof zone.afterColumn !== 'undefined') {
  41166. zoneAfterModelPosition = this._context.model.validateModelPosition({
  41167. lineNumber: zone.afterLineNumber,
  41168. column: zone.afterColumn
  41169. });
  41170. }
  41171. else {
  41172. var validAfterLineNumber = this._context.model.validateModelPosition({
  41173. lineNumber: zone.afterLineNumber,
  41174. column: 1
  41175. }).lineNumber;
  41176. zoneAfterModelPosition = new position_1.Position(validAfterLineNumber, this._context.model.getModelLineMaxColumn(validAfterLineNumber));
  41177. }
  41178. var zoneBeforeModelPosition;
  41179. if (zoneAfterModelPosition.column === this._context.model.getModelLineMaxColumn(zoneAfterModelPosition.lineNumber)) {
  41180. zoneBeforeModelPosition = this._context.model.validateModelPosition({
  41181. lineNumber: zoneAfterModelPosition.lineNumber + 1,
  41182. column: 1
  41183. });
  41184. }
  41185. else {
  41186. zoneBeforeModelPosition = this._context.model.validateModelPosition({
  41187. lineNumber: zoneAfterModelPosition.lineNumber,
  41188. column: zoneAfterModelPosition.column + 1
  41189. });
  41190. }
  41191. var viewPosition = this._context.model.coordinatesConverter.convertModelPositionToViewPosition(zoneAfterModelPosition);
  41192. var isVisible = this._context.model.coordinatesConverter.modelPositionIsVisible(zoneBeforeModelPosition);
  41193. return {
  41194. afterViewLineNumber: viewPosition.lineNumber,
  41195. heightInPx: (isVisible ? this._heightInPixels(zone) : 0),
  41196. minWidthInPx: this._minWidthInPixels(zone)
  41197. };
  41198. };
  41199. ViewZones.prototype.changeViewZones = function (callback) {
  41200. var _this = this;
  41201. return this._context.viewLayout.changeWhitespace(function (whitespaceAccessor) {
  41202. var zonesHaveChanged = false;
  41203. var changeAccessor = {
  41204. addZone: function (zone) {
  41205. zonesHaveChanged = true;
  41206. return _this._addZone(whitespaceAccessor, zone);
  41207. },
  41208. removeZone: function (id) {
  41209. if (!id) {
  41210. return;
  41211. }
  41212. zonesHaveChanged = _this._removeZone(whitespaceAccessor, id) || zonesHaveChanged;
  41213. },
  41214. layoutZone: function (id) {
  41215. if (!id) {
  41216. return;
  41217. }
  41218. zonesHaveChanged = _this._layoutZone(whitespaceAccessor, id) || zonesHaveChanged;
  41219. }
  41220. };
  41221. safeInvoke1Arg(callback, changeAccessor);
  41222. // Invalidate changeAccessor
  41223. changeAccessor.addZone = invalidFunc;
  41224. changeAccessor.removeZone = invalidFunc;
  41225. changeAccessor.layoutZone = invalidFunc;
  41226. return zonesHaveChanged;
  41227. });
  41228. };
  41229. ViewZones.prototype._addZone = function (whitespaceAccessor, zone) {
  41230. var props = this._computeWhitespaceProps(zone);
  41231. var whitespaceId = whitespaceAccessor.insertWhitespace(props.afterViewLineNumber, this._getZoneOrdinal(zone), props.heightInPx, props.minWidthInPx);
  41232. var myZone = {
  41233. whitespaceId: whitespaceId,
  41234. delegate: zone,
  41235. isVisible: false,
  41236. domNode: fastDomNode_1.createFastDomNode(zone.domNode),
  41237. marginDomNode: zone.marginDomNode ? fastDomNode_1.createFastDomNode(zone.marginDomNode) : null
  41238. };
  41239. this._safeCallOnComputedHeight(myZone.delegate, props.heightInPx);
  41240. myZone.domNode.setPosition('absolute');
  41241. myZone.domNode.domNode.style.width = '100%';
  41242. myZone.domNode.setDisplay('none');
  41243. myZone.domNode.setAttribute('monaco-view-zone', myZone.whitespaceId);
  41244. this.domNode.appendChild(myZone.domNode);
  41245. if (myZone.marginDomNode) {
  41246. myZone.marginDomNode.setPosition('absolute');
  41247. myZone.marginDomNode.domNode.style.width = '100%';
  41248. myZone.marginDomNode.setDisplay('none');
  41249. myZone.marginDomNode.setAttribute('monaco-view-zone', myZone.whitespaceId);
  41250. this.marginDomNode.appendChild(myZone.marginDomNode);
  41251. }
  41252. this._zones[myZone.whitespaceId] = myZone;
  41253. this.setShouldRender();
  41254. return myZone.whitespaceId;
  41255. };
  41256. ViewZones.prototype._removeZone = function (whitespaceAccessor, id) {
  41257. if (this._zones.hasOwnProperty(id)) {
  41258. var zone = this._zones[id];
  41259. delete this._zones[id];
  41260. whitespaceAccessor.removeWhitespace(zone.whitespaceId);
  41261. zone.domNode.removeAttribute('monaco-visible-view-zone');
  41262. zone.domNode.removeAttribute('monaco-view-zone');
  41263. zone.domNode.domNode.parentNode.removeChild(zone.domNode.domNode);
  41264. if (zone.marginDomNode) {
  41265. zone.marginDomNode.removeAttribute('monaco-visible-view-zone');
  41266. zone.marginDomNode.removeAttribute('monaco-view-zone');
  41267. zone.marginDomNode.domNode.parentNode.removeChild(zone.marginDomNode.domNode);
  41268. }
  41269. this.setShouldRender();
  41270. return true;
  41271. }
  41272. return false;
  41273. };
  41274. ViewZones.prototype._layoutZone = function (whitespaceAccessor, id) {
  41275. if (this._zones.hasOwnProperty(id)) {
  41276. var zone = this._zones[id];
  41277. var props = this._computeWhitespaceProps(zone.delegate);
  41278. // const newOrdinal = this._getZoneOrdinal(zone.delegate);
  41279. whitespaceAccessor.changeOneWhitespace(zone.whitespaceId, props.afterViewLineNumber, props.heightInPx);
  41280. // TODO@Alex: change `newOrdinal` too
  41281. this._safeCallOnComputedHeight(zone.delegate, props.heightInPx);
  41282. this.setShouldRender();
  41283. return true;
  41284. }
  41285. return false;
  41286. };
  41287. ViewZones.prototype.shouldSuppressMouseDownOnViewZone = function (id) {
  41288. if (this._zones.hasOwnProperty(id)) {
  41289. var zone = this._zones[id];
  41290. return Boolean(zone.delegate.suppressMouseDown);
  41291. }
  41292. return false;
  41293. };
  41294. ViewZones.prototype._heightInPixels = function (zone) {
  41295. if (typeof zone.heightInPx === 'number') {
  41296. return zone.heightInPx;
  41297. }
  41298. if (typeof zone.heightInLines === 'number') {
  41299. return this._lineHeight * zone.heightInLines;
  41300. }
  41301. return this._lineHeight;
  41302. };
  41303. ViewZones.prototype._minWidthInPixels = function (zone) {
  41304. if (typeof zone.minWidthInPx === 'number') {
  41305. return zone.minWidthInPx;
  41306. }
  41307. return 0;
  41308. };
  41309. ViewZones.prototype._safeCallOnComputedHeight = function (zone, height) {
  41310. if (typeof zone.onComputedHeight === 'function') {
  41311. try {
  41312. zone.onComputedHeight(height);
  41313. }
  41314. catch (e) {
  41315. errors_1.onUnexpectedError(e);
  41316. }
  41317. }
  41318. };
  41319. ViewZones.prototype._safeCallOnDomNodeTop = function (zone, top) {
  41320. if (typeof zone.onDomNodeTop === 'function') {
  41321. try {
  41322. zone.onDomNodeTop(top);
  41323. }
  41324. catch (e) {
  41325. errors_1.onUnexpectedError(e);
  41326. }
  41327. }
  41328. };
  41329. ViewZones.prototype.prepareRender = function (ctx) {
  41330. // Nothing to read
  41331. };
  41332. ViewZones.prototype.render = function (ctx) {
  41333. var visibleWhitespaces = ctx.viewportData.whitespaceViewportData;
  41334. var visibleZones = {};
  41335. var hasVisibleZone = false;
  41336. for (var i = 0, len = visibleWhitespaces.length; i < len; i++) {
  41337. visibleZones[visibleWhitespaces[i].id] = visibleWhitespaces[i];
  41338. hasVisibleZone = true;
  41339. }
  41340. var keys = Object.keys(this._zones);
  41341. for (var i = 0, len = keys.length; i < len; i++) {
  41342. var id = keys[i];
  41343. var zone = this._zones[id];
  41344. var newTop = 0;
  41345. var newHeight = 0;
  41346. var newDisplay = 'none';
  41347. if (visibleZones.hasOwnProperty(id)) {
  41348. newTop = visibleZones[id].verticalOffset - ctx.bigNumbersDelta;
  41349. newHeight = visibleZones[id].height;
  41350. newDisplay = 'block';
  41351. // zone is visible
  41352. if (!zone.isVisible) {
  41353. zone.domNode.setAttribute('monaco-visible-view-zone', 'true');
  41354. zone.isVisible = true;
  41355. }
  41356. this._safeCallOnDomNodeTop(zone.delegate, ctx.getScrolledTopFromAbsoluteTop(visibleZones[id].verticalOffset));
  41357. }
  41358. else {
  41359. if (zone.isVisible) {
  41360. zone.domNode.removeAttribute('monaco-visible-view-zone');
  41361. zone.isVisible = false;
  41362. }
  41363. this._safeCallOnDomNodeTop(zone.delegate, ctx.getScrolledTopFromAbsoluteTop(-1000000));
  41364. }
  41365. zone.domNode.setTop(newTop);
  41366. zone.domNode.setHeight(newHeight);
  41367. zone.domNode.setDisplay(newDisplay);
  41368. if (zone.marginDomNode) {
  41369. zone.marginDomNode.setTop(newTop);
  41370. zone.marginDomNode.setHeight(newHeight);
  41371. zone.marginDomNode.setDisplay(newDisplay);
  41372. }
  41373. }
  41374. if (hasVisibleZone) {
  41375. this.domNode.setWidth(Math.max(ctx.scrollWidth, this._contentWidth));
  41376. this.marginDomNode.setWidth(this._contentLeft);
  41377. }
  41378. };
  41379. return ViewZones;
  41380. }(viewPart_1.ViewPart));
  41381. exports.ViewZones = ViewZones;
  41382. function safeInvoke1Arg(func, arg1) {
  41383. try {
  41384. return func(arg1);
  41385. }
  41386. catch (e) {
  41387. errors_1.onUnexpectedError(e);
  41388. }
  41389. }
  41390. });
  41391. /*---------------------------------------------------------------------------------------------
  41392. * Copyright (c) Microsoft Corporation. All rights reserved.
  41393. * Licensed under the MIT License. See License.txt in the project root for license information.
  41394. *--------------------------------------------------------------------------------------------*/
  41395. define(__m[69/*vs/editor/common/viewModel/viewModel*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/]), function (require, exports, strings) {
  41396. "use strict";
  41397. Object.defineProperty(exports, "__esModule", { value: true });
  41398. var Viewport = /** @class */ (function () {
  41399. function Viewport(top, left, width, height) {
  41400. this.top = top | 0;
  41401. this.left = left | 0;
  41402. this.width = width | 0;
  41403. this.height = height | 0;
  41404. }
  41405. return Viewport;
  41406. }());
  41407. exports.Viewport = Viewport;
  41408. var MinimapLinesRenderingData = /** @class */ (function () {
  41409. function MinimapLinesRenderingData(tabSize, data) {
  41410. this.tabSize = tabSize;
  41411. this.data = data;
  41412. }
  41413. return MinimapLinesRenderingData;
  41414. }());
  41415. exports.MinimapLinesRenderingData = MinimapLinesRenderingData;
  41416. var ViewLineData = /** @class */ (function () {
  41417. function ViewLineData(content, continuesWithWrappedLine, minColumn, maxColumn, startVisibleColumn, tokens) {
  41418. this.content = content;
  41419. this.continuesWithWrappedLine = continuesWithWrappedLine;
  41420. this.minColumn = minColumn;
  41421. this.maxColumn = maxColumn;
  41422. this.startVisibleColumn = startVisibleColumn;
  41423. this.tokens = tokens;
  41424. }
  41425. return ViewLineData;
  41426. }());
  41427. exports.ViewLineData = ViewLineData;
  41428. var ViewLineRenderingData = /** @class */ (function () {
  41429. function ViewLineRenderingData(minColumn, maxColumn, content, continuesWithWrappedLine, mightContainRTL, mightContainNonBasicASCII, tokens, inlineDecorations, tabSize, startVisibleColumn) {
  41430. this.minColumn = minColumn;
  41431. this.maxColumn = maxColumn;
  41432. this.content = content;
  41433. this.continuesWithWrappedLine = continuesWithWrappedLine;
  41434. this.isBasicASCII = ViewLineRenderingData.isBasicASCII(content, mightContainNonBasicASCII);
  41435. this.containsRTL = ViewLineRenderingData.containsRTL(content, this.isBasicASCII, mightContainRTL);
  41436. this.tokens = tokens;
  41437. this.inlineDecorations = inlineDecorations;
  41438. this.tabSize = tabSize;
  41439. this.startVisibleColumn = startVisibleColumn;
  41440. }
  41441. ViewLineRenderingData.isBasicASCII = function (lineContent, mightContainNonBasicASCII) {
  41442. if (mightContainNonBasicASCII) {
  41443. return strings.isBasicASCII(lineContent);
  41444. }
  41445. return true;
  41446. };
  41447. ViewLineRenderingData.containsRTL = function (lineContent, isBasicASCII, mightContainRTL) {
  41448. if (!isBasicASCII && mightContainRTL) {
  41449. return strings.containsRTL(lineContent);
  41450. }
  41451. return false;
  41452. };
  41453. return ViewLineRenderingData;
  41454. }());
  41455. exports.ViewLineRenderingData = ViewLineRenderingData;
  41456. var InlineDecoration = /** @class */ (function () {
  41457. function InlineDecoration(range, inlineClassName, type) {
  41458. this.range = range;
  41459. this.inlineClassName = inlineClassName;
  41460. this.type = type;
  41461. }
  41462. return InlineDecoration;
  41463. }());
  41464. exports.InlineDecoration = InlineDecoration;
  41465. var ViewModelDecoration = /** @class */ (function () {
  41466. function ViewModelDecoration(range, options) {
  41467. this.range = range;
  41468. this.options = options;
  41469. }
  41470. return ViewModelDecoration;
  41471. }());
  41472. exports.ViewModelDecoration = ViewModelDecoration;
  41473. });
  41474. /*---------------------------------------------------------------------------------------------
  41475. * Copyright (c) Microsoft Corporation. All rights reserved.
  41476. * Licensed under the MIT License. See License.txt in the project root for license information.
  41477. *--------------------------------------------------------------------------------------------*/
  41478. define(__m[373/*vs/editor/common/viewLayout/viewLayout*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,176/*vs/base/common/scrollable*/,362/*vs/editor/common/viewLayout/linesLayout*/,69/*vs/editor/common/viewModel/viewModel*/]), function (require, exports, event_1, lifecycle_1, scrollable_1, linesLayout_1, viewModel_1) {
  41479. "use strict";
  41480. Object.defineProperty(exports, "__esModule", { value: true });
  41481. var SMOOTH_SCROLLING_TIME = 125;
  41482. var EditorScrollDimensions = /** @class */ (function () {
  41483. function EditorScrollDimensions(width, contentWidth, height, contentHeight) {
  41484. width = width | 0;
  41485. contentWidth = contentWidth | 0;
  41486. height = height | 0;
  41487. contentHeight = contentHeight | 0;
  41488. if (width < 0) {
  41489. width = 0;
  41490. }
  41491. if (contentWidth < 0) {
  41492. contentWidth = 0;
  41493. }
  41494. if (height < 0) {
  41495. height = 0;
  41496. }
  41497. if (contentHeight < 0) {
  41498. contentHeight = 0;
  41499. }
  41500. this.width = width;
  41501. this.contentWidth = contentWidth;
  41502. this.scrollWidth = Math.max(width, contentWidth);
  41503. this.height = height;
  41504. this.contentHeight = contentHeight;
  41505. this.scrollHeight = Math.max(height, contentHeight);
  41506. }
  41507. EditorScrollDimensions.prototype.equals = function (other) {
  41508. return (this.width === other.width
  41509. && this.contentWidth === other.contentWidth
  41510. && this.height === other.height
  41511. && this.contentHeight === other.contentHeight);
  41512. };
  41513. return EditorScrollDimensions;
  41514. }());
  41515. var EditorScrollable = /** @class */ (function (_super) {
  41516. __extends(EditorScrollable, _super);
  41517. function EditorScrollable(smoothScrollDuration, scheduleAtNextAnimationFrame) {
  41518. var _this = _super.call(this) || this;
  41519. _this._onDidContentSizeChange = _this._register(new event_1.Emitter());
  41520. _this.onDidContentSizeChange = _this._onDidContentSizeChange.event;
  41521. _this._dimensions = new EditorScrollDimensions(0, 0, 0, 0);
  41522. _this._scrollable = _this._register(new scrollable_1.Scrollable(smoothScrollDuration, scheduleAtNextAnimationFrame));
  41523. _this.onDidScroll = _this._scrollable.onScroll;
  41524. return _this;
  41525. }
  41526. EditorScrollable.prototype.getScrollable = function () {
  41527. return this._scrollable;
  41528. };
  41529. EditorScrollable.prototype.setSmoothScrollDuration = function (smoothScrollDuration) {
  41530. this._scrollable.setSmoothScrollDuration(smoothScrollDuration);
  41531. };
  41532. EditorScrollable.prototype.validateScrollPosition = function (scrollPosition) {
  41533. return this._scrollable.validateScrollPosition(scrollPosition);
  41534. };
  41535. EditorScrollable.prototype.getScrollDimensions = function () {
  41536. return this._dimensions;
  41537. };
  41538. EditorScrollable.prototype.setScrollDimensions = function (dimensions) {
  41539. if (this._dimensions.equals(dimensions)) {
  41540. return;
  41541. }
  41542. var oldDimensions = this._dimensions;
  41543. this._dimensions = dimensions;
  41544. this._scrollable.setScrollDimensions({
  41545. width: dimensions.width,
  41546. scrollWidth: dimensions.scrollWidth,
  41547. height: dimensions.height,
  41548. scrollHeight: dimensions.scrollHeight
  41549. });
  41550. var contentWidthChanged = (oldDimensions.contentWidth !== dimensions.contentWidth);
  41551. var contentHeightChanged = (oldDimensions.contentHeight !== dimensions.contentHeight);
  41552. if (contentWidthChanged || contentHeightChanged) {
  41553. this._onDidContentSizeChange.fire({
  41554. contentWidth: dimensions.contentWidth,
  41555. contentHeight: dimensions.contentHeight,
  41556. contentWidthChanged: contentWidthChanged,
  41557. contentHeightChanged: contentHeightChanged
  41558. });
  41559. }
  41560. };
  41561. EditorScrollable.prototype.getFutureScrollPosition = function () {
  41562. return this._scrollable.getFutureScrollPosition();
  41563. };
  41564. EditorScrollable.prototype.getCurrentScrollPosition = function () {
  41565. return this._scrollable.getCurrentScrollPosition();
  41566. };
  41567. EditorScrollable.prototype.setScrollPositionNow = function (update) {
  41568. this._scrollable.setScrollPositionNow(update);
  41569. };
  41570. EditorScrollable.prototype.setScrollPositionSmooth = function (update) {
  41571. this._scrollable.setScrollPositionSmooth(update);
  41572. };
  41573. return EditorScrollable;
  41574. }(lifecycle_1.Disposable));
  41575. var ViewLayout = /** @class */ (function (_super) {
  41576. __extends(ViewLayout, _super);
  41577. function ViewLayout(configuration, lineCount, scheduleAtNextAnimationFrame) {
  41578. var _this = _super.call(this) || this;
  41579. _this._configuration = configuration;
  41580. var options = _this._configuration.options;
  41581. var layoutInfo = options.get(107 /* layoutInfo */);
  41582. _this._linesLayout = new linesLayout_1.LinesLayout(lineCount, options.get(49 /* lineHeight */));
  41583. _this._scrollable = _this._register(new EditorScrollable(0, scheduleAtNextAnimationFrame));
  41584. _this._configureSmoothScrollDuration();
  41585. _this._scrollable.setScrollDimensions(new EditorScrollDimensions(layoutInfo.contentWidth, 0, layoutInfo.height, 0));
  41586. _this.onDidScroll = _this._scrollable.onDidScroll;
  41587. _this.onDidContentSizeChange = _this._scrollable.onDidContentSizeChange;
  41588. _this._updateHeight();
  41589. return _this;
  41590. }
  41591. ViewLayout.prototype.dispose = function () {
  41592. _super.prototype.dispose.call(this);
  41593. };
  41594. ViewLayout.prototype.getScrollable = function () {
  41595. return this._scrollable.getScrollable();
  41596. };
  41597. ViewLayout.prototype.onHeightMaybeChanged = function () {
  41598. this._updateHeight();
  41599. };
  41600. ViewLayout.prototype._configureSmoothScrollDuration = function () {
  41601. this._scrollable.setSmoothScrollDuration(this._configuration.options.get(87 /* smoothScrolling */) ? SMOOTH_SCROLLING_TIME : 0);
  41602. };
  41603. // ---- begin view event handlers
  41604. ViewLayout.prototype.onConfigurationChanged = function (e) {
  41605. var options = this._configuration.options;
  41606. if (e.hasChanged(49 /* lineHeight */)) {
  41607. this._linesLayout.setLineHeight(options.get(49 /* lineHeight */));
  41608. }
  41609. if (e.hasChanged(107 /* layoutInfo */)) {
  41610. var layoutInfo = options.get(107 /* layoutInfo */);
  41611. var width = layoutInfo.contentWidth;
  41612. var height = layoutInfo.height;
  41613. var scrollDimensions = this._scrollable.getScrollDimensions();
  41614. var scrollWidth = scrollDimensions.scrollWidth;
  41615. this._scrollable.setScrollDimensions(new EditorScrollDimensions(width, scrollDimensions.contentWidth, height, this._getContentHeight(width, height, scrollWidth)));
  41616. }
  41617. else {
  41618. this._updateHeight();
  41619. }
  41620. if (e.hasChanged(87 /* smoothScrolling */)) {
  41621. this._configureSmoothScrollDuration();
  41622. }
  41623. };
  41624. ViewLayout.prototype.onFlushed = function (lineCount) {
  41625. this._linesLayout.onFlushed(lineCount);
  41626. };
  41627. ViewLayout.prototype.onLinesDeleted = function (fromLineNumber, toLineNumber) {
  41628. this._linesLayout.onLinesDeleted(fromLineNumber, toLineNumber);
  41629. };
  41630. ViewLayout.prototype.onLinesInserted = function (fromLineNumber, toLineNumber) {
  41631. this._linesLayout.onLinesInserted(fromLineNumber, toLineNumber);
  41632. };
  41633. // ---- end view event handlers
  41634. ViewLayout.prototype._getHorizontalScrollbarHeight = function (width, scrollWidth) {
  41635. var options = this._configuration.options;
  41636. var scrollbar = options.get(78 /* scrollbar */);
  41637. if (scrollbar.horizontal === 2 /* Hidden */) {
  41638. // horizontal scrollbar not visible
  41639. return 0;
  41640. }
  41641. if (width >= scrollWidth) {
  41642. // horizontal scrollbar not visible
  41643. return 0;
  41644. }
  41645. return scrollbar.horizontalScrollbarSize;
  41646. };
  41647. ViewLayout.prototype._getContentHeight = function (width, height, scrollWidth) {
  41648. var options = this._configuration.options;
  41649. var result = this._linesLayout.getLinesTotalHeight();
  41650. if (options.get(80 /* scrollBeyondLastLine */)) {
  41651. result += height - options.get(49 /* lineHeight */);
  41652. }
  41653. else {
  41654. result += this._getHorizontalScrollbarHeight(width, scrollWidth);
  41655. }
  41656. return result;
  41657. };
  41658. ViewLayout.prototype._updateHeight = function () {
  41659. var scrollDimensions = this._scrollable.getScrollDimensions();
  41660. var width = scrollDimensions.width;
  41661. var height = scrollDimensions.height;
  41662. var scrollWidth = scrollDimensions.scrollWidth;
  41663. this._scrollable.setScrollDimensions(new EditorScrollDimensions(width, scrollDimensions.contentWidth, height, this._getContentHeight(width, height, scrollWidth)));
  41664. };
  41665. // ---- Layouting logic
  41666. ViewLayout.prototype.getCurrentViewport = function () {
  41667. var scrollDimensions = this._scrollable.getScrollDimensions();
  41668. var currentScrollPosition = this._scrollable.getCurrentScrollPosition();
  41669. return new viewModel_1.Viewport(currentScrollPosition.scrollTop, currentScrollPosition.scrollLeft, scrollDimensions.width, scrollDimensions.height);
  41670. };
  41671. ViewLayout.prototype.getFutureViewport = function () {
  41672. var scrollDimensions = this._scrollable.getScrollDimensions();
  41673. var currentScrollPosition = this._scrollable.getFutureScrollPosition();
  41674. return new viewModel_1.Viewport(currentScrollPosition.scrollTop, currentScrollPosition.scrollLeft, scrollDimensions.width, scrollDimensions.height);
  41675. };
  41676. ViewLayout.prototype._computeContentWidth = function (maxLineWidth) {
  41677. var options = this._configuration.options;
  41678. var wrappingInfo = options.get(108 /* wrappingInfo */);
  41679. var fontInfo = options.get(34 /* fontInfo */);
  41680. if (wrappingInfo.isViewportWrapping) {
  41681. var layoutInfo = options.get(107 /* layoutInfo */);
  41682. var minimap = options.get(54 /* minimap */);
  41683. if (maxLineWidth > layoutInfo.contentWidth + fontInfo.typicalHalfwidthCharacterWidth) {
  41684. // This is a case where viewport wrapping is on, but the line extends above the viewport
  41685. if (minimap.enabled && minimap.side === 'right') {
  41686. // We need to accomodate the scrollbar width
  41687. return maxLineWidth + layoutInfo.verticalScrollbarWidth;
  41688. }
  41689. }
  41690. return maxLineWidth;
  41691. }
  41692. else {
  41693. var extraHorizontalSpace = options.get(79 /* scrollBeyondLastColumn */) * fontInfo.typicalHalfwidthCharacterWidth;
  41694. var whitespaceMinWidth = this._linesLayout.getWhitespaceMinWidth();
  41695. return Math.max(maxLineWidth + extraHorizontalSpace, whitespaceMinWidth);
  41696. }
  41697. };
  41698. ViewLayout.prototype.onMaxLineWidthChanged = function (maxLineWidth) {
  41699. var scrollDimensions = this._scrollable.getScrollDimensions();
  41700. // const newScrollWidth = ;
  41701. this._scrollable.setScrollDimensions(new EditorScrollDimensions(scrollDimensions.width, this._computeContentWidth(maxLineWidth), scrollDimensions.height, scrollDimensions.contentHeight));
  41702. // The height might depend on the fact that there is a horizontal scrollbar or not
  41703. this._updateHeight();
  41704. };
  41705. // ---- view state
  41706. ViewLayout.prototype.saveState = function () {
  41707. var currentScrollPosition = this._scrollable.getFutureScrollPosition();
  41708. var scrollTop = currentScrollPosition.scrollTop;
  41709. var firstLineNumberInViewport = this._linesLayout.getLineNumberAtOrAfterVerticalOffset(scrollTop);
  41710. var whitespaceAboveFirstLine = this._linesLayout.getWhitespaceAccumulatedHeightBeforeLineNumber(firstLineNumberInViewport);
  41711. return {
  41712. scrollTop: scrollTop,
  41713. scrollTopWithoutViewZones: scrollTop - whitespaceAboveFirstLine,
  41714. scrollLeft: currentScrollPosition.scrollLeft
  41715. };
  41716. };
  41717. // ---- IVerticalLayoutProvider
  41718. ViewLayout.prototype.changeWhitespace = function (callback) {
  41719. return this._linesLayout.changeWhitespace(callback);
  41720. };
  41721. ViewLayout.prototype.getVerticalOffsetForLineNumber = function (lineNumber) {
  41722. return this._linesLayout.getVerticalOffsetForLineNumber(lineNumber);
  41723. };
  41724. ViewLayout.prototype.isAfterLines = function (verticalOffset) {
  41725. return this._linesLayout.isAfterLines(verticalOffset);
  41726. };
  41727. ViewLayout.prototype.getLineNumberAtVerticalOffset = function (verticalOffset) {
  41728. return this._linesLayout.getLineNumberAtOrAfterVerticalOffset(verticalOffset);
  41729. };
  41730. ViewLayout.prototype.getWhitespaceAtVerticalOffset = function (verticalOffset) {
  41731. return this._linesLayout.getWhitespaceAtVerticalOffset(verticalOffset);
  41732. };
  41733. ViewLayout.prototype.getLinesViewportData = function () {
  41734. var visibleBox = this.getCurrentViewport();
  41735. return this._linesLayout.getLinesViewportData(visibleBox.top, visibleBox.top + visibleBox.height);
  41736. };
  41737. ViewLayout.prototype.getLinesViewportDataAtScrollTop = function (scrollTop) {
  41738. // do some minimal validations on scrollTop
  41739. var scrollDimensions = this._scrollable.getScrollDimensions();
  41740. if (scrollTop + scrollDimensions.height > scrollDimensions.scrollHeight) {
  41741. scrollTop = scrollDimensions.scrollHeight - scrollDimensions.height;
  41742. }
  41743. if (scrollTop < 0) {
  41744. scrollTop = 0;
  41745. }
  41746. return this._linesLayout.getLinesViewportData(scrollTop, scrollTop + scrollDimensions.height);
  41747. };
  41748. ViewLayout.prototype.getWhitespaceViewportData = function () {
  41749. var visibleBox = this.getCurrentViewport();
  41750. return this._linesLayout.getWhitespaceViewportData(visibleBox.top, visibleBox.top + visibleBox.height);
  41751. };
  41752. ViewLayout.prototype.getWhitespaces = function () {
  41753. return this._linesLayout.getWhitespaces();
  41754. };
  41755. // ---- IScrollingProvider
  41756. ViewLayout.prototype.getContentWidth = function () {
  41757. var scrollDimensions = this._scrollable.getScrollDimensions();
  41758. return scrollDimensions.contentWidth;
  41759. };
  41760. ViewLayout.prototype.getScrollWidth = function () {
  41761. var scrollDimensions = this._scrollable.getScrollDimensions();
  41762. return scrollDimensions.scrollWidth;
  41763. };
  41764. ViewLayout.prototype.getContentHeight = function () {
  41765. var scrollDimensions = this._scrollable.getScrollDimensions();
  41766. return scrollDimensions.contentHeight;
  41767. };
  41768. ViewLayout.prototype.getScrollHeight = function () {
  41769. var scrollDimensions = this._scrollable.getScrollDimensions();
  41770. return scrollDimensions.scrollHeight;
  41771. };
  41772. ViewLayout.prototype.getCurrentScrollLeft = function () {
  41773. var currentScrollPosition = this._scrollable.getCurrentScrollPosition();
  41774. return currentScrollPosition.scrollLeft;
  41775. };
  41776. ViewLayout.prototype.getCurrentScrollTop = function () {
  41777. var currentScrollPosition = this._scrollable.getCurrentScrollPosition();
  41778. return currentScrollPosition.scrollTop;
  41779. };
  41780. ViewLayout.prototype.validateScrollPosition = function (scrollPosition) {
  41781. return this._scrollable.validateScrollPosition(scrollPosition);
  41782. };
  41783. ViewLayout.prototype.setScrollPositionNow = function (position) {
  41784. this._scrollable.setScrollPositionNow(position);
  41785. };
  41786. ViewLayout.prototype.setScrollPositionSmooth = function (position) {
  41787. this._scrollable.setScrollPositionSmooth(position);
  41788. };
  41789. ViewLayout.prototype.deltaScrollNow = function (deltaScrollLeft, deltaScrollTop) {
  41790. var currentScrollPosition = this._scrollable.getCurrentScrollPosition();
  41791. this._scrollable.setScrollPositionNow({
  41792. scrollLeft: currentScrollPosition.scrollLeft + deltaScrollLeft,
  41793. scrollTop: currentScrollPosition.scrollTop + deltaScrollTop
  41794. });
  41795. };
  41796. return ViewLayout;
  41797. }(lifecycle_1.Disposable));
  41798. exports.ViewLayout = ViewLayout;
  41799. });
  41800. /*---------------------------------------------------------------------------------------------
  41801. * Copyright (c) Microsoft Corporation. All rights reserved.
  41802. * Licensed under the MIT License. See License.txt in the project root for license information.
  41803. *--------------------------------------------------------------------------------------------*/
  41804. define(__m[374/*vs/editor/contrib/caretOperations/moveCaretCommand*/], __M([0/*require*/,1/*exports*/,3/*vs/editor/common/core/range*/]), function (require, exports, range_1) {
  41805. "use strict";
  41806. Object.defineProperty(exports, "__esModule", { value: true });
  41807. var MoveCaretCommand = /** @class */ (function () {
  41808. function MoveCaretCommand(selection, isMovingLeft) {
  41809. this._selection = selection;
  41810. this._isMovingLeft = isMovingLeft;
  41811. this._cutStartIndex = -1;
  41812. this._cutEndIndex = -1;
  41813. this._moved = false;
  41814. this._selectionId = null;
  41815. }
  41816. MoveCaretCommand.prototype.getEditOperations = function (model, builder) {
  41817. var s = this._selection;
  41818. this._selectionId = builder.trackSelection(s);
  41819. if (s.startLineNumber !== s.endLineNumber) {
  41820. return;
  41821. }
  41822. if (this._isMovingLeft && s.startColumn === 0) {
  41823. return;
  41824. }
  41825. else if (!this._isMovingLeft && s.endColumn === model.getLineMaxColumn(s.startLineNumber)) {
  41826. return;
  41827. }
  41828. var lineNumber = s.selectionStartLineNumber;
  41829. var lineContent = model.getLineContent(lineNumber);
  41830. var left;
  41831. var middle;
  41832. var right;
  41833. if (this._isMovingLeft) {
  41834. left = lineContent.substring(0, s.startColumn - 2);
  41835. middle = lineContent.substring(s.startColumn - 1, s.endColumn - 1);
  41836. right = lineContent.substring(s.startColumn - 2, s.startColumn - 1) + lineContent.substring(s.endColumn - 1);
  41837. }
  41838. else {
  41839. left = lineContent.substring(0, s.startColumn - 1) + lineContent.substring(s.endColumn - 1, s.endColumn);
  41840. middle = lineContent.substring(s.startColumn - 1, s.endColumn - 1);
  41841. right = lineContent.substring(s.endColumn);
  41842. }
  41843. var newLineContent = left + middle + right;
  41844. builder.addEditOperation(new range_1.Range(lineNumber, 1, lineNumber, model.getLineMaxColumn(lineNumber)), null);
  41845. builder.addEditOperation(new range_1.Range(lineNumber, 1, lineNumber, 1), newLineContent);
  41846. this._cutStartIndex = s.startColumn + (this._isMovingLeft ? -1 : 1);
  41847. this._cutEndIndex = this._cutStartIndex + s.endColumn - s.startColumn;
  41848. this._moved = true;
  41849. };
  41850. MoveCaretCommand.prototype.computeCursorState = function (model, helper) {
  41851. var result = helper.getTrackedSelection(this._selectionId);
  41852. if (this._moved) {
  41853. result = result.setStartPosition(result.startLineNumber, this._cutStartIndex);
  41854. result = result.setEndPosition(result.startLineNumber, this._cutEndIndex);
  41855. }
  41856. return result;
  41857. };
  41858. return MoveCaretCommand;
  41859. }());
  41860. exports.MoveCaretCommand = MoveCaretCommand;
  41861. });
  41862. /*---------------------------------------------------------------------------------------------
  41863. * Copyright (c) Microsoft Corporation. All rights reserved.
  41864. * Licensed under the MIT License. See License.txt in the project root for license information.
  41865. *--------------------------------------------------------------------------------------------*/
  41866. define(__m[111/*vs/editor/contrib/codeAction/types*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/]), function (require, exports, strings_1) {
  41867. "use strict";
  41868. Object.defineProperty(exports, "__esModule", { value: true });
  41869. var CodeActionKind = /** @class */ (function () {
  41870. function CodeActionKind(value) {
  41871. this.value = value;
  41872. }
  41873. CodeActionKind.prototype.equals = function (other) {
  41874. return this.value === other.value;
  41875. };
  41876. CodeActionKind.prototype.contains = function (other) {
  41877. return this.equals(other) || this.value === '' || strings_1.startsWith(other.value, this.value + CodeActionKind.sep);
  41878. };
  41879. CodeActionKind.prototype.intersects = function (other) {
  41880. return this.contains(other) || other.contains(this);
  41881. };
  41882. CodeActionKind.prototype.append = function (part) {
  41883. return new CodeActionKind(this.value + CodeActionKind.sep + part);
  41884. };
  41885. CodeActionKind.sep = '.';
  41886. CodeActionKind.None = new CodeActionKind('@@none@@'); // Special code action that contains nothing
  41887. CodeActionKind.Empty = new CodeActionKind('');
  41888. CodeActionKind.QuickFix = new CodeActionKind('quickfix');
  41889. CodeActionKind.Refactor = new CodeActionKind('refactor');
  41890. CodeActionKind.Source = new CodeActionKind('source');
  41891. CodeActionKind.SourceOrganizeImports = CodeActionKind.Source.append('organizeImports');
  41892. CodeActionKind.SourceFixAll = CodeActionKind.Source.append('fixAll');
  41893. return CodeActionKind;
  41894. }());
  41895. exports.CodeActionKind = CodeActionKind;
  41896. function mayIncludeActionsOfKind(filter, providedKind) {
  41897. // A provided kind may be a subset or superset of our filtered kind.
  41898. if (filter.include && !filter.include.intersects(providedKind)) {
  41899. return false;
  41900. }
  41901. if (filter.excludes) {
  41902. if (filter.excludes.some(function (exclude) { return excludesAction(providedKind, exclude, filter.include); })) {
  41903. return false;
  41904. }
  41905. }
  41906. // Don't return source actions unless they are explicitly requested
  41907. if (!filter.includeSourceActions && CodeActionKind.Source.contains(providedKind)) {
  41908. return false;
  41909. }
  41910. return true;
  41911. }
  41912. exports.mayIncludeActionsOfKind = mayIncludeActionsOfKind;
  41913. function filtersAction(filter, action) {
  41914. var actionKind = action.kind ? new CodeActionKind(action.kind) : undefined;
  41915. // Filter out actions by kind
  41916. if (filter.include) {
  41917. if (!actionKind || !filter.include.contains(actionKind)) {
  41918. return false;
  41919. }
  41920. }
  41921. if (filter.excludes) {
  41922. if (actionKind && filter.excludes.some(function (exclude) { return excludesAction(actionKind, exclude, filter.include); })) {
  41923. return false;
  41924. }
  41925. }
  41926. // Don't return source actions unless they are explicitly requested
  41927. if (!filter.includeSourceActions) {
  41928. if (actionKind && CodeActionKind.Source.contains(actionKind)) {
  41929. return false;
  41930. }
  41931. }
  41932. if (filter.onlyIncludePreferredActions) {
  41933. if (!action.isPreferred) {
  41934. return false;
  41935. }
  41936. }
  41937. return true;
  41938. }
  41939. exports.filtersAction = filtersAction;
  41940. function excludesAction(providedKind, exclude, include) {
  41941. if (!exclude.contains(providedKind)) {
  41942. return false;
  41943. }
  41944. if (include && exclude.contains(include)) {
  41945. // The include is more specific, don't filter out
  41946. return false;
  41947. }
  41948. return true;
  41949. }
  41950. var CodeActionCommandArgs = /** @class */ (function () {
  41951. function CodeActionCommandArgs(kind, apply, preferred) {
  41952. this.kind = kind;
  41953. this.apply = apply;
  41954. this.preferred = preferred;
  41955. }
  41956. CodeActionCommandArgs.fromUser = function (arg, defaults) {
  41957. if (!arg || typeof arg !== 'object') {
  41958. return new CodeActionCommandArgs(defaults.kind, defaults.apply, false);
  41959. }
  41960. return new CodeActionCommandArgs(CodeActionCommandArgs.getKindFromUser(arg, defaults.kind), CodeActionCommandArgs.getApplyFromUser(arg, defaults.apply), CodeActionCommandArgs.getPreferredUser(arg));
  41961. };
  41962. CodeActionCommandArgs.getApplyFromUser = function (arg, defaultAutoApply) {
  41963. switch (typeof arg.apply === 'string' ? arg.apply.toLowerCase() : '') {
  41964. case 'first': return "first" /* First */;
  41965. case 'never': return "never" /* Never */;
  41966. case 'ifsingle': return "ifSingle" /* IfSingle */;
  41967. default: return defaultAutoApply;
  41968. }
  41969. };
  41970. CodeActionCommandArgs.getKindFromUser = function (arg, defaultKind) {
  41971. return typeof arg.kind === 'string'
  41972. ? new CodeActionKind(arg.kind)
  41973. : defaultKind;
  41974. };
  41975. CodeActionCommandArgs.getPreferredUser = function (arg) {
  41976. return typeof arg.preferred === 'boolean'
  41977. ? arg.preferred
  41978. : false;
  41979. };
  41980. return CodeActionCommandArgs;
  41981. }());
  41982. exports.CodeActionCommandArgs = CodeActionCommandArgs;
  41983. });
  41984. /*---------------------------------------------------------------------------------------------
  41985. * Copyright (c) Microsoft Corporation. All rights reserved.
  41986. * Licensed under the MIT License. See License.txt in the project root for license information.
  41987. *--------------------------------------------------------------------------------------------*/
  41988. define(__m[375/*vs/editor/contrib/colorPicker/colorPickerModel*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/]), function (require, exports, event_1) {
  41989. "use strict";
  41990. Object.defineProperty(exports, "__esModule", { value: true });
  41991. var ColorPickerModel = /** @class */ (function () {
  41992. function ColorPickerModel(color, availableColorPresentations, presentationIndex) {
  41993. this.presentationIndex = presentationIndex;
  41994. this._onColorFlushed = new event_1.Emitter();
  41995. this.onColorFlushed = this._onColorFlushed.event;
  41996. this._onDidChangeColor = new event_1.Emitter();
  41997. this.onDidChangeColor = this._onDidChangeColor.event;
  41998. this._onDidChangePresentation = new event_1.Emitter();
  41999. this.onDidChangePresentation = this._onDidChangePresentation.event;
  42000. this.originalColor = color;
  42001. this._color = color;
  42002. this._colorPresentations = availableColorPresentations;
  42003. }
  42004. Object.defineProperty(ColorPickerModel.prototype, "color", {
  42005. get: function () {
  42006. return this._color;
  42007. },
  42008. set: function (color) {
  42009. if (this._color.equals(color)) {
  42010. return;
  42011. }
  42012. this._color = color;
  42013. this._onDidChangeColor.fire(color);
  42014. },
  42015. enumerable: true,
  42016. configurable: true
  42017. });
  42018. Object.defineProperty(ColorPickerModel.prototype, "presentation", {
  42019. get: function () { return this.colorPresentations[this.presentationIndex]; },
  42020. enumerable: true,
  42021. configurable: true
  42022. });
  42023. Object.defineProperty(ColorPickerModel.prototype, "colorPresentations", {
  42024. get: function () {
  42025. return this._colorPresentations;
  42026. },
  42027. set: function (colorPresentations) {
  42028. this._colorPresentations = colorPresentations;
  42029. if (this.presentationIndex > colorPresentations.length - 1) {
  42030. this.presentationIndex = 0;
  42031. }
  42032. this._onDidChangePresentation.fire(this.presentation);
  42033. },
  42034. enumerable: true,
  42035. configurable: true
  42036. });
  42037. ColorPickerModel.prototype.selectNextColorPresentation = function () {
  42038. this.presentationIndex = (this.presentationIndex + 1) % this.colorPresentations.length;
  42039. this.flushColor();
  42040. this._onDidChangePresentation.fire(this.presentation);
  42041. };
  42042. ColorPickerModel.prototype.guessColorPresentation = function (color, originalText) {
  42043. for (var i = 0; i < this.colorPresentations.length; i++) {
  42044. if (originalText === this.colorPresentations[i].label) {
  42045. this.presentationIndex = i;
  42046. this._onDidChangePresentation.fire(this.presentation);
  42047. break;
  42048. }
  42049. }
  42050. };
  42051. ColorPickerModel.prototype.flushColor = function () {
  42052. this._onColorFlushed.fire(this._color);
  42053. };
  42054. return ColorPickerModel;
  42055. }());
  42056. exports.ColorPickerModel = ColorPickerModel;
  42057. });
  42058. /*---------------------------------------------------------------------------------------------
  42059. * Copyright (c) Microsoft Corporation. All rights reserved.
  42060. * Licensed under the MIT License. See License.txt in the project root for license information.
  42061. *--------------------------------------------------------------------------------------------*/
  42062. define(__m[196/*vs/editor/contrib/comment/blockCommentCommand*/], __M([0/*require*/,1/*exports*/,58/*vs/editor/common/core/editOperation*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/]), function (require, exports, editOperation_1, position_1, range_1, selection_1, languageConfigurationRegistry_1) {
  42063. "use strict";
  42064. Object.defineProperty(exports, "__esModule", { value: true });
  42065. var BlockCommentCommand = /** @class */ (function () {
  42066. function BlockCommentCommand(selection, insertSpace) {
  42067. this._selection = selection;
  42068. this._insertSpace = insertSpace;
  42069. this._usedEndToken = null;
  42070. }
  42071. BlockCommentCommand._haystackHasNeedleAtOffset = function (haystack, needle, offset) {
  42072. if (offset < 0) {
  42073. return false;
  42074. }
  42075. var needleLength = needle.length;
  42076. var haystackLength = haystack.length;
  42077. if (offset + needleLength > haystackLength) {
  42078. return false;
  42079. }
  42080. for (var i = 0; i < needleLength; i++) {
  42081. var codeA = haystack.charCodeAt(offset + i);
  42082. var codeB = needle.charCodeAt(i);
  42083. if (codeA === codeB) {
  42084. continue;
  42085. }
  42086. if (codeA >= 65 /* A */ && codeA <= 90 /* Z */ && codeA + 32 === codeB) {
  42087. // codeA is upper-case variant of codeB
  42088. continue;
  42089. }
  42090. if (codeB >= 65 /* A */ && codeB <= 90 /* Z */ && codeB + 32 === codeA) {
  42091. // codeB is upper-case variant of codeA
  42092. continue;
  42093. }
  42094. return false;
  42095. }
  42096. return true;
  42097. };
  42098. BlockCommentCommand.prototype._createOperationsForBlockComment = function (selection, startToken, endToken, insertSpace, model, builder) {
  42099. var startLineNumber = selection.startLineNumber;
  42100. var startColumn = selection.startColumn;
  42101. var endLineNumber = selection.endLineNumber;
  42102. var endColumn = selection.endColumn;
  42103. var startLineText = model.getLineContent(startLineNumber);
  42104. var endLineText = model.getLineContent(endLineNumber);
  42105. var startTokenIndex = startLineText.lastIndexOf(startToken, startColumn - 1 + startToken.length);
  42106. var endTokenIndex = endLineText.indexOf(endToken, endColumn - 1 - endToken.length);
  42107. if (startTokenIndex !== -1 && endTokenIndex !== -1) {
  42108. if (startLineNumber === endLineNumber) {
  42109. var lineBetweenTokens = startLineText.substring(startTokenIndex + startToken.length, endTokenIndex);
  42110. if (lineBetweenTokens.indexOf(endToken) >= 0) {
  42111. // force to add a block comment
  42112. startTokenIndex = -1;
  42113. endTokenIndex = -1;
  42114. }
  42115. }
  42116. else {
  42117. var startLineAfterStartToken = startLineText.substring(startTokenIndex + startToken.length);
  42118. var endLineBeforeEndToken = endLineText.substring(0, endTokenIndex);
  42119. if (startLineAfterStartToken.indexOf(endToken) >= 0 || endLineBeforeEndToken.indexOf(endToken) >= 0) {
  42120. // force to add a block comment
  42121. startTokenIndex = -1;
  42122. endTokenIndex = -1;
  42123. }
  42124. }
  42125. }
  42126. var ops;
  42127. if (startTokenIndex !== -1 && endTokenIndex !== -1) {
  42128. // Consider spaces as part of the comment tokens
  42129. if (insertSpace && startTokenIndex + startToken.length < startLineText.length && startLineText.charCodeAt(startTokenIndex + startToken.length) === 32 /* Space */) {
  42130. // Pretend the start token contains a trailing space
  42131. startToken = startToken + ' ';
  42132. }
  42133. if (insertSpace && endTokenIndex > 0 && endLineText.charCodeAt(endTokenIndex - 1) === 32 /* Space */) {
  42134. // Pretend the end token contains a leading space
  42135. endToken = ' ' + endToken;
  42136. endTokenIndex -= 1;
  42137. }
  42138. ops = BlockCommentCommand._createRemoveBlockCommentOperations(new range_1.Range(startLineNumber, startTokenIndex + startToken.length + 1, endLineNumber, endTokenIndex + 1), startToken, endToken);
  42139. }
  42140. else {
  42141. ops = BlockCommentCommand._createAddBlockCommentOperations(selection, startToken, endToken, this._insertSpace);
  42142. this._usedEndToken = ops.length === 1 ? endToken : null;
  42143. }
  42144. for (var _i = 0, ops_1 = ops; _i < ops_1.length; _i++) {
  42145. var op = ops_1[_i];
  42146. builder.addTrackedEditOperation(op.range, op.text);
  42147. }
  42148. };
  42149. BlockCommentCommand._createRemoveBlockCommentOperations = function (r, startToken, endToken) {
  42150. var res = [];
  42151. if (!range_1.Range.isEmpty(r)) {
  42152. // Remove block comment start
  42153. res.push(editOperation_1.EditOperation.delete(new range_1.Range(r.startLineNumber, r.startColumn - startToken.length, r.startLineNumber, r.startColumn)));
  42154. // Remove block comment end
  42155. res.push(editOperation_1.EditOperation.delete(new range_1.Range(r.endLineNumber, r.endColumn, r.endLineNumber, r.endColumn + endToken.length)));
  42156. }
  42157. else {
  42158. // Remove both continuously
  42159. res.push(editOperation_1.EditOperation.delete(new range_1.Range(r.startLineNumber, r.startColumn - startToken.length, r.endLineNumber, r.endColumn + endToken.length)));
  42160. }
  42161. return res;
  42162. };
  42163. BlockCommentCommand._createAddBlockCommentOperations = function (r, startToken, endToken, insertSpace) {
  42164. var res = [];
  42165. if (!range_1.Range.isEmpty(r)) {
  42166. // Insert block comment start
  42167. res.push(editOperation_1.EditOperation.insert(new position_1.Position(r.startLineNumber, r.startColumn), startToken + (insertSpace ? ' ' : '')));
  42168. // Insert block comment end
  42169. res.push(editOperation_1.EditOperation.insert(new position_1.Position(r.endLineNumber, r.endColumn), (insertSpace ? ' ' : '') + endToken));
  42170. }
  42171. else {
  42172. // Insert both continuously
  42173. res.push(editOperation_1.EditOperation.replace(new range_1.Range(r.startLineNumber, r.startColumn, r.endLineNumber, r.endColumn), startToken + ' ' + endToken));
  42174. }
  42175. return res;
  42176. };
  42177. BlockCommentCommand.prototype.getEditOperations = function (model, builder) {
  42178. var startLineNumber = this._selection.startLineNumber;
  42179. var startColumn = this._selection.startColumn;
  42180. model.tokenizeIfCheap(startLineNumber);
  42181. var languageId = model.getLanguageIdAtPosition(startLineNumber, startColumn);
  42182. var config = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getComments(languageId);
  42183. if (!config || !config.blockCommentStartToken || !config.blockCommentEndToken) {
  42184. // Mode does not support block comments
  42185. return;
  42186. }
  42187. this._createOperationsForBlockComment(this._selection, config.blockCommentStartToken, config.blockCommentEndToken, this._insertSpace, model, builder);
  42188. };
  42189. BlockCommentCommand.prototype.computeCursorState = function (model, helper) {
  42190. var inverseEditOperations = helper.getInverseEditOperations();
  42191. if (inverseEditOperations.length === 2) {
  42192. var startTokenEditOperation = inverseEditOperations[0];
  42193. var endTokenEditOperation = inverseEditOperations[1];
  42194. return new selection_1.Selection(startTokenEditOperation.range.endLineNumber, startTokenEditOperation.range.endColumn, endTokenEditOperation.range.startLineNumber, endTokenEditOperation.range.startColumn);
  42195. }
  42196. else {
  42197. var srcRange = inverseEditOperations[0].range;
  42198. var deltaColumn = this._usedEndToken ? -this._usedEndToken.length - 1 : 0; // minus 1 space before endToken
  42199. return new selection_1.Selection(srcRange.endLineNumber, srcRange.endColumn + deltaColumn, srcRange.endLineNumber, srcRange.endColumn + deltaColumn);
  42200. }
  42201. };
  42202. return BlockCommentCommand;
  42203. }());
  42204. exports.BlockCommentCommand = BlockCommentCommand;
  42205. });
  42206. /*---------------------------------------------------------------------------------------------
  42207. * Copyright (c) Microsoft Corporation. All rights reserved.
  42208. * Licensed under the MIT License. See License.txt in the project root for license information.
  42209. *--------------------------------------------------------------------------------------------*/
  42210. define(__m[376/*vs/editor/contrib/comment/lineCommentCommand*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,58/*vs/editor/common/core/editOperation*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/,196/*vs/editor/contrib/comment/blockCommentCommand*/]), function (require, exports, strings, editOperation_1, position_1, range_1, selection_1, languageConfigurationRegistry_1, blockCommentCommand_1) {
  42211. "use strict";
  42212. Object.defineProperty(exports, "__esModule", { value: true });
  42213. var LineCommentCommand = /** @class */ (function () {
  42214. function LineCommentCommand(selection, tabSize, type, insertSpace) {
  42215. this._selection = selection;
  42216. this._tabSize = tabSize;
  42217. this._type = type;
  42218. this._insertSpace = insertSpace;
  42219. this._selectionId = null;
  42220. this._deltaColumn = 0;
  42221. this._moveEndPositionDown = false;
  42222. }
  42223. /**
  42224. * Do an initial pass over the lines and gather info about the line comment string.
  42225. * Returns null if any of the lines doesn't support a line comment string.
  42226. */
  42227. LineCommentCommand._gatherPreflightCommentStrings = function (model, startLineNumber, endLineNumber) {
  42228. model.tokenizeIfCheap(startLineNumber);
  42229. var languageId = model.getLanguageIdAtPosition(startLineNumber, 1);
  42230. var config = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getComments(languageId);
  42231. var commentStr = (config ? config.lineCommentToken : null);
  42232. if (!commentStr) {
  42233. // Mode does not support line comments
  42234. return null;
  42235. }
  42236. var lines = [];
  42237. for (var i = 0, lineCount = endLineNumber - startLineNumber + 1; i < lineCount; i++) {
  42238. lines[i] = {
  42239. ignore: false,
  42240. commentStr: commentStr,
  42241. commentStrOffset: 0,
  42242. commentStrLength: commentStr.length
  42243. };
  42244. }
  42245. return lines;
  42246. };
  42247. /**
  42248. * Analyze lines and decide which lines are relevant and what the toggle should do.
  42249. * Also, build up several offsets and lengths useful in the generation of editor operations.
  42250. */
  42251. LineCommentCommand._analyzeLines = function (type, insertSpace, model, lines, startLineNumber) {
  42252. var onlyWhitespaceLines = true;
  42253. var shouldRemoveComments;
  42254. if (type === 0 /* Toggle */) {
  42255. shouldRemoveComments = true;
  42256. }
  42257. else if (type === 1 /* ForceAdd */) {
  42258. shouldRemoveComments = false;
  42259. }
  42260. else {
  42261. shouldRemoveComments = true;
  42262. }
  42263. for (var i = 0, lineCount = lines.length; i < lineCount; i++) {
  42264. var lineData = lines[i];
  42265. var lineNumber = startLineNumber + i;
  42266. var lineContent = model.getLineContent(lineNumber);
  42267. var lineContentStartOffset = strings.firstNonWhitespaceIndex(lineContent);
  42268. if (lineContentStartOffset === -1) {
  42269. // Empty or whitespace only line
  42270. if (type === 0 /* Toggle */) {
  42271. lineData.ignore = true;
  42272. }
  42273. else if (type === 1 /* ForceAdd */) {
  42274. lineData.ignore = true;
  42275. }
  42276. else {
  42277. lineData.ignore = true;
  42278. }
  42279. lineData.commentStrOffset = lineContent.length;
  42280. continue;
  42281. }
  42282. onlyWhitespaceLines = false;
  42283. lineData.ignore = false;
  42284. lineData.commentStrOffset = lineContentStartOffset;
  42285. if (shouldRemoveComments && !blockCommentCommand_1.BlockCommentCommand._haystackHasNeedleAtOffset(lineContent, lineData.commentStr, lineContentStartOffset)) {
  42286. if (type === 0 /* Toggle */) {
  42287. // Every line so far has been a line comment, but this one is not
  42288. shouldRemoveComments = false;
  42289. }
  42290. else if (type === 1 /* ForceAdd */) {
  42291. // Will not happen
  42292. }
  42293. else {
  42294. lineData.ignore = true;
  42295. }
  42296. }
  42297. if (shouldRemoveComments && insertSpace) {
  42298. // Remove a following space if present
  42299. var commentStrEndOffset = lineContentStartOffset + lineData.commentStrLength;
  42300. if (commentStrEndOffset < lineContent.length && lineContent.charCodeAt(commentStrEndOffset) === 32 /* Space */) {
  42301. lineData.commentStrLength += 1;
  42302. }
  42303. }
  42304. }
  42305. if (type === 0 /* Toggle */ && onlyWhitespaceLines) {
  42306. // For only whitespace lines, we insert comments
  42307. shouldRemoveComments = false;
  42308. // Also, no longer ignore them
  42309. for (var i = 0, lineCount = lines.length; i < lineCount; i++) {
  42310. lines[i].ignore = false;
  42311. }
  42312. }
  42313. return {
  42314. supported: true,
  42315. shouldRemoveComments: shouldRemoveComments,
  42316. lines: lines
  42317. };
  42318. };
  42319. /**
  42320. * Analyze all lines and decide exactly what to do => not supported | insert line comments | remove line comments
  42321. */
  42322. LineCommentCommand._gatherPreflightData = function (type, insertSpace, model, startLineNumber, endLineNumber) {
  42323. var lines = LineCommentCommand._gatherPreflightCommentStrings(model, startLineNumber, endLineNumber);
  42324. if (lines === null) {
  42325. return {
  42326. supported: false
  42327. };
  42328. }
  42329. return LineCommentCommand._analyzeLines(type, insertSpace, model, lines, startLineNumber);
  42330. };
  42331. /**
  42332. * Given a successful analysis, execute either insert line comments, either remove line comments
  42333. */
  42334. LineCommentCommand.prototype._executeLineComments = function (model, builder, data, s) {
  42335. var ops;
  42336. if (data.shouldRemoveComments) {
  42337. ops = LineCommentCommand._createRemoveLineCommentsOperations(data.lines, s.startLineNumber);
  42338. }
  42339. else {
  42340. LineCommentCommand._normalizeInsertionPoint(model, data.lines, s.startLineNumber, this._tabSize);
  42341. ops = this._createAddLineCommentsOperations(data.lines, s.startLineNumber);
  42342. }
  42343. var cursorPosition = new position_1.Position(s.positionLineNumber, s.positionColumn);
  42344. for (var i = 0, len = ops.length; i < len; i++) {
  42345. builder.addEditOperation(ops[i].range, ops[i].text);
  42346. if (ops[i].range.isEmpty() && ops[i].range.getStartPosition().equals(cursorPosition)) {
  42347. var lineContent = model.getLineContent(cursorPosition.lineNumber);
  42348. if (lineContent.length + 1 === cursorPosition.column) {
  42349. this._deltaColumn = (ops[i].text || '').length;
  42350. }
  42351. }
  42352. }
  42353. this._selectionId = builder.trackSelection(s);
  42354. };
  42355. LineCommentCommand.prototype._attemptRemoveBlockComment = function (model, s, startToken, endToken) {
  42356. var startLineNumber = s.startLineNumber;
  42357. var endLineNumber = s.endLineNumber;
  42358. var startTokenAllowedBeforeColumn = endToken.length + Math.max(model.getLineFirstNonWhitespaceColumn(s.startLineNumber), s.startColumn);
  42359. var startTokenIndex = model.getLineContent(startLineNumber).lastIndexOf(startToken, startTokenAllowedBeforeColumn - 1);
  42360. var endTokenIndex = model.getLineContent(endLineNumber).indexOf(endToken, s.endColumn - 1 - startToken.length);
  42361. if (startTokenIndex !== -1 && endTokenIndex === -1) {
  42362. endTokenIndex = model.getLineContent(startLineNumber).indexOf(endToken, startTokenIndex + startToken.length);
  42363. endLineNumber = startLineNumber;
  42364. }
  42365. if (startTokenIndex === -1 && endTokenIndex !== -1) {
  42366. startTokenIndex = model.getLineContent(endLineNumber).lastIndexOf(startToken, endTokenIndex);
  42367. startLineNumber = endLineNumber;
  42368. }
  42369. if (s.isEmpty() && (startTokenIndex === -1 || endTokenIndex === -1)) {
  42370. startTokenIndex = model.getLineContent(startLineNumber).indexOf(startToken);
  42371. if (startTokenIndex !== -1) {
  42372. endTokenIndex = model.getLineContent(startLineNumber).indexOf(endToken, startTokenIndex + startToken.length);
  42373. }
  42374. }
  42375. // We have to adjust to possible inner white space.
  42376. // For Space after startToken, add Space to startToken - range math will work out.
  42377. if (startTokenIndex !== -1 && model.getLineContent(startLineNumber).charCodeAt(startTokenIndex + startToken.length) === 32 /* Space */) {
  42378. startToken += ' ';
  42379. }
  42380. // For Space before endToken, add Space before endToken and shift index one left.
  42381. if (endTokenIndex !== -1 && model.getLineContent(endLineNumber).charCodeAt(endTokenIndex - 1) === 32 /* Space */) {
  42382. endToken = ' ' + endToken;
  42383. endTokenIndex -= 1;
  42384. }
  42385. if (startTokenIndex !== -1 && endTokenIndex !== -1) {
  42386. return blockCommentCommand_1.BlockCommentCommand._createRemoveBlockCommentOperations(new range_1.Range(startLineNumber, startTokenIndex + startToken.length + 1, endLineNumber, endTokenIndex + 1), startToken, endToken);
  42387. }
  42388. return null;
  42389. };
  42390. /**
  42391. * Given an unsuccessful analysis, delegate to the block comment command
  42392. */
  42393. LineCommentCommand.prototype._executeBlockComment = function (model, builder, s) {
  42394. model.tokenizeIfCheap(s.startLineNumber);
  42395. var languageId = model.getLanguageIdAtPosition(s.startLineNumber, 1);
  42396. var config = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getComments(languageId);
  42397. if (!config || !config.blockCommentStartToken || !config.blockCommentEndToken) {
  42398. // Mode does not support block comments
  42399. return;
  42400. }
  42401. var startToken = config.blockCommentStartToken;
  42402. var endToken = config.blockCommentEndToken;
  42403. var ops = this._attemptRemoveBlockComment(model, s, startToken, endToken);
  42404. if (!ops) {
  42405. if (s.isEmpty()) {
  42406. var lineContent = model.getLineContent(s.startLineNumber);
  42407. var firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
  42408. if (firstNonWhitespaceIndex === -1) {
  42409. // Line is empty or contains only whitespace
  42410. firstNonWhitespaceIndex = lineContent.length;
  42411. }
  42412. ops = blockCommentCommand_1.BlockCommentCommand._createAddBlockCommentOperations(new range_1.Range(s.startLineNumber, firstNonWhitespaceIndex + 1, s.startLineNumber, lineContent.length + 1), startToken, endToken, this._insertSpace);
  42413. }
  42414. else {
  42415. ops = blockCommentCommand_1.BlockCommentCommand._createAddBlockCommentOperations(new range_1.Range(s.startLineNumber, model.getLineFirstNonWhitespaceColumn(s.startLineNumber), s.endLineNumber, model.getLineMaxColumn(s.endLineNumber)), startToken, endToken, this._insertSpace);
  42416. }
  42417. if (ops.length === 1) {
  42418. // Leave cursor after token and Space
  42419. this._deltaColumn = startToken.length + 1;
  42420. }
  42421. }
  42422. this._selectionId = builder.trackSelection(s);
  42423. for (var _i = 0, ops_1 = ops; _i < ops_1.length; _i++) {
  42424. var op = ops_1[_i];
  42425. builder.addEditOperation(op.range, op.text);
  42426. }
  42427. };
  42428. LineCommentCommand.prototype.getEditOperations = function (model, builder) {
  42429. var s = this._selection;
  42430. this._moveEndPositionDown = false;
  42431. if (s.startLineNumber < s.endLineNumber && s.endColumn === 1) {
  42432. this._moveEndPositionDown = true;
  42433. s = s.setEndPosition(s.endLineNumber - 1, model.getLineMaxColumn(s.endLineNumber - 1));
  42434. }
  42435. var data = LineCommentCommand._gatherPreflightData(this._type, this._insertSpace, model, s.startLineNumber, s.endLineNumber);
  42436. if (data.supported) {
  42437. return this._executeLineComments(model, builder, data, s);
  42438. }
  42439. return this._executeBlockComment(model, builder, s);
  42440. };
  42441. LineCommentCommand.prototype.computeCursorState = function (model, helper) {
  42442. var result = helper.getTrackedSelection(this._selectionId);
  42443. if (this._moveEndPositionDown) {
  42444. result = result.setEndPosition(result.endLineNumber + 1, 1);
  42445. }
  42446. return new selection_1.Selection(result.selectionStartLineNumber, result.selectionStartColumn + this._deltaColumn, result.positionLineNumber, result.positionColumn + this._deltaColumn);
  42447. };
  42448. /**
  42449. * Generate edit operations in the remove line comment case
  42450. */
  42451. LineCommentCommand._createRemoveLineCommentsOperations = function (lines, startLineNumber) {
  42452. var res = [];
  42453. for (var i = 0, len = lines.length; i < len; i++) {
  42454. var lineData = lines[i];
  42455. if (lineData.ignore) {
  42456. continue;
  42457. }
  42458. res.push(editOperation_1.EditOperation.delete(new range_1.Range(startLineNumber + i, lineData.commentStrOffset + 1, startLineNumber + i, lineData.commentStrOffset + lineData.commentStrLength + 1)));
  42459. }
  42460. return res;
  42461. };
  42462. /**
  42463. * Generate edit operations in the add line comment case
  42464. */
  42465. LineCommentCommand.prototype._createAddLineCommentsOperations = function (lines, startLineNumber) {
  42466. var res = [];
  42467. var afterCommentStr = this._insertSpace ? ' ' : '';
  42468. for (var i = 0, len = lines.length; i < len; i++) {
  42469. var lineData = lines[i];
  42470. if (lineData.ignore) {
  42471. continue;
  42472. }
  42473. res.push(editOperation_1.EditOperation.insert(new position_1.Position(startLineNumber + i, lineData.commentStrOffset + 1), lineData.commentStr + afterCommentStr));
  42474. }
  42475. return res;
  42476. };
  42477. LineCommentCommand.nextVisibleColumn = function (currentVisibleColumn, tabSize, isTab, columnSize) {
  42478. if (isTab) {
  42479. return currentVisibleColumn + (tabSize - (currentVisibleColumn % tabSize));
  42480. }
  42481. return currentVisibleColumn + columnSize;
  42482. };
  42483. /**
  42484. * Adjust insertion points to have them vertically aligned in the add line comment case
  42485. */
  42486. LineCommentCommand._normalizeInsertionPoint = function (model, lines, startLineNumber, tabSize) {
  42487. var minVisibleColumn = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  42488. var j;
  42489. var lenJ;
  42490. for (var i = 0, len = lines.length; i < len; i++) {
  42491. if (lines[i].ignore) {
  42492. continue;
  42493. }
  42494. var lineContent = model.getLineContent(startLineNumber + i);
  42495. var currentVisibleColumn = 0;
  42496. for (var j_1 = 0, lenJ_1 = lines[i].commentStrOffset; currentVisibleColumn < minVisibleColumn && j_1 < lenJ_1; j_1++) {
  42497. currentVisibleColumn = LineCommentCommand.nextVisibleColumn(currentVisibleColumn, tabSize, lineContent.charCodeAt(j_1) === 9 /* Tab */, 1);
  42498. }
  42499. if (currentVisibleColumn < minVisibleColumn) {
  42500. minVisibleColumn = currentVisibleColumn;
  42501. }
  42502. }
  42503. minVisibleColumn = Math.floor(minVisibleColumn / tabSize) * tabSize;
  42504. for (var i = 0, len = lines.length; i < len; i++) {
  42505. if (lines[i].ignore) {
  42506. continue;
  42507. }
  42508. var lineContent = model.getLineContent(startLineNumber + i);
  42509. var currentVisibleColumn = 0;
  42510. for (j = 0, lenJ = lines[i].commentStrOffset; currentVisibleColumn < minVisibleColumn && j < lenJ; j++) {
  42511. currentVisibleColumn = LineCommentCommand.nextVisibleColumn(currentVisibleColumn, tabSize, lineContent.charCodeAt(j) === 9 /* Tab */, 1);
  42512. }
  42513. if (currentVisibleColumn > minVisibleColumn) {
  42514. lines[i].commentStrOffset = j - 1;
  42515. }
  42516. else {
  42517. lines[i].commentStrOffset = j;
  42518. }
  42519. }
  42520. };
  42521. return LineCommentCommand;
  42522. }());
  42523. exports.LineCommentCommand = LineCommentCommand;
  42524. });
  42525. /*---------------------------------------------------------------------------------------------
  42526. * Copyright (c) Microsoft Corporation. All rights reserved.
  42527. * Licensed under the MIT License. See License.txt in the project root for license information.
  42528. *--------------------------------------------------------------------------------------------*/
  42529. define(__m[377/*vs/editor/contrib/dnd/dragAndDropCommand*/], __M([0/*require*/,1/*exports*/,22/*vs/editor/common/core/selection*/,3/*vs/editor/common/core/range*/]), function (require, exports, selection_1, range_1) {
  42530. "use strict";
  42531. Object.defineProperty(exports, "__esModule", { value: true });
  42532. var DragAndDropCommand = /** @class */ (function () {
  42533. function DragAndDropCommand(selection, targetPosition, copy) {
  42534. this.selection = selection;
  42535. this.targetPosition = targetPosition;
  42536. this.copy = copy;
  42537. this.targetSelection = null;
  42538. }
  42539. DragAndDropCommand.prototype.getEditOperations = function (model, builder) {
  42540. var text = model.getValueInRange(this.selection);
  42541. if (!this.copy) {
  42542. builder.addEditOperation(this.selection, null);
  42543. }
  42544. builder.addEditOperation(new range_1.Range(this.targetPosition.lineNumber, this.targetPosition.column, this.targetPosition.lineNumber, this.targetPosition.column), text);
  42545. if (this.selection.containsPosition(this.targetPosition) && !(this.copy && (this.selection.getEndPosition().equals(this.targetPosition) || this.selection.getStartPosition().equals(this.targetPosition)) // we allow users to paste content beside the selection
  42546. )) {
  42547. this.targetSelection = this.selection;
  42548. return;
  42549. }
  42550. if (this.copy) {
  42551. this.targetSelection = new selection_1.Selection(this.targetPosition.lineNumber, this.targetPosition.column, this.selection.endLineNumber - this.selection.startLineNumber + this.targetPosition.lineNumber, this.selection.startLineNumber === this.selection.endLineNumber ?
  42552. this.targetPosition.column + this.selection.endColumn - this.selection.startColumn :
  42553. this.selection.endColumn);
  42554. return;
  42555. }
  42556. if (this.targetPosition.lineNumber > this.selection.endLineNumber) {
  42557. // Drag the selection downwards
  42558. this.targetSelection = new selection_1.Selection(this.targetPosition.lineNumber - this.selection.endLineNumber + this.selection.startLineNumber, this.targetPosition.column, this.targetPosition.lineNumber, this.selection.startLineNumber === this.selection.endLineNumber ?
  42559. this.targetPosition.column + this.selection.endColumn - this.selection.startColumn :
  42560. this.selection.endColumn);
  42561. return;
  42562. }
  42563. if (this.targetPosition.lineNumber < this.selection.endLineNumber) {
  42564. // Drag the selection upwards
  42565. this.targetSelection = new selection_1.Selection(this.targetPosition.lineNumber, this.targetPosition.column, this.targetPosition.lineNumber + this.selection.endLineNumber - this.selection.startLineNumber, this.selection.startLineNumber === this.selection.endLineNumber ?
  42566. this.targetPosition.column + this.selection.endColumn - this.selection.startColumn :
  42567. this.selection.endColumn);
  42568. return;
  42569. }
  42570. // The target position is at the same line as the selection's end position.
  42571. if (this.selection.endColumn <= this.targetPosition.column) {
  42572. // The target position is after the selection's end position
  42573. this.targetSelection = new selection_1.Selection(this.targetPosition.lineNumber - this.selection.endLineNumber + this.selection.startLineNumber, this.selection.startLineNumber === this.selection.endLineNumber ?
  42574. this.targetPosition.column - this.selection.endColumn + this.selection.startColumn :
  42575. this.targetPosition.column - this.selection.endColumn + this.selection.startColumn, this.targetPosition.lineNumber, this.selection.startLineNumber === this.selection.endLineNumber ?
  42576. this.targetPosition.column :
  42577. this.selection.endColumn);
  42578. }
  42579. else {
  42580. // The target position is before the selection's end position. Since the selection doesn't contain the target position, the selection is one-line and target position is before this selection.
  42581. this.targetSelection = new selection_1.Selection(this.targetPosition.lineNumber - this.selection.endLineNumber + this.selection.startLineNumber, this.targetPosition.column, this.targetPosition.lineNumber, this.targetPosition.column + this.selection.endColumn - this.selection.startColumn);
  42582. }
  42583. };
  42584. DragAndDropCommand.prototype.computeCursorState = function (model, helper) {
  42585. return this.targetSelection;
  42586. };
  42587. return DragAndDropCommand;
  42588. }());
  42589. exports.DragAndDropCommand = DragAndDropCommand;
  42590. });
  42591. /*---------------------------------------------------------------------------------------------
  42592. * Copyright (c) Microsoft Corporation. All rights reserved.
  42593. * Licensed under the MIT License. See License.txt in the project root for license information.
  42594. *--------------------------------------------------------------------------------------------*/
  42595. define(__m[378/*vs/editor/contrib/find/findState*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,3/*vs/editor/common/core/range*/]), function (require, exports, event_1, lifecycle_1, range_1) {
  42596. "use strict";
  42597. Object.defineProperty(exports, "__esModule", { value: true });
  42598. function effectiveOptionValue(override, value) {
  42599. if (override === 1 /* True */) {
  42600. return true;
  42601. }
  42602. if (override === 2 /* False */) {
  42603. return false;
  42604. }
  42605. return value;
  42606. }
  42607. var FindReplaceState = /** @class */ (function (_super) {
  42608. __extends(FindReplaceState, _super);
  42609. function FindReplaceState() {
  42610. var _this = _super.call(this) || this;
  42611. _this._onFindReplaceStateChange = _this._register(new event_1.Emitter());
  42612. _this.onFindReplaceStateChange = _this._onFindReplaceStateChange.event;
  42613. _this._searchString = '';
  42614. _this._replaceString = '';
  42615. _this._isRevealed = false;
  42616. _this._isReplaceRevealed = false;
  42617. _this._isRegex = false;
  42618. _this._isRegexOverride = 0 /* NotSet */;
  42619. _this._wholeWord = false;
  42620. _this._wholeWordOverride = 0 /* NotSet */;
  42621. _this._matchCase = false;
  42622. _this._matchCaseOverride = 0 /* NotSet */;
  42623. _this._preserveCase = false;
  42624. _this._preserveCaseOverride = 0 /* NotSet */;
  42625. _this._searchScope = null;
  42626. _this._matchesPosition = 0;
  42627. _this._matchesCount = 0;
  42628. _this._currentMatch = null;
  42629. return _this;
  42630. }
  42631. Object.defineProperty(FindReplaceState.prototype, "searchString", {
  42632. get: function () { return this._searchString; },
  42633. enumerable: true,
  42634. configurable: true
  42635. });
  42636. Object.defineProperty(FindReplaceState.prototype, "replaceString", {
  42637. get: function () { return this._replaceString; },
  42638. enumerable: true,
  42639. configurable: true
  42640. });
  42641. Object.defineProperty(FindReplaceState.prototype, "isRevealed", {
  42642. get: function () { return this._isRevealed; },
  42643. enumerable: true,
  42644. configurable: true
  42645. });
  42646. Object.defineProperty(FindReplaceState.prototype, "isReplaceRevealed", {
  42647. get: function () { return this._isReplaceRevealed; },
  42648. enumerable: true,
  42649. configurable: true
  42650. });
  42651. Object.defineProperty(FindReplaceState.prototype, "isRegex", {
  42652. get: function () { return effectiveOptionValue(this._isRegexOverride, this._isRegex); },
  42653. enumerable: true,
  42654. configurable: true
  42655. });
  42656. Object.defineProperty(FindReplaceState.prototype, "wholeWord", {
  42657. get: function () { return effectiveOptionValue(this._wholeWordOverride, this._wholeWord); },
  42658. enumerable: true,
  42659. configurable: true
  42660. });
  42661. Object.defineProperty(FindReplaceState.prototype, "matchCase", {
  42662. get: function () { return effectiveOptionValue(this._matchCaseOverride, this._matchCase); },
  42663. enumerable: true,
  42664. configurable: true
  42665. });
  42666. Object.defineProperty(FindReplaceState.prototype, "preserveCase", {
  42667. get: function () { return effectiveOptionValue(this._preserveCaseOverride, this._preserveCase); },
  42668. enumerable: true,
  42669. configurable: true
  42670. });
  42671. Object.defineProperty(FindReplaceState.prototype, "actualIsRegex", {
  42672. get: function () { return this._isRegex; },
  42673. enumerable: true,
  42674. configurable: true
  42675. });
  42676. Object.defineProperty(FindReplaceState.prototype, "actualWholeWord", {
  42677. get: function () { return this._wholeWord; },
  42678. enumerable: true,
  42679. configurable: true
  42680. });
  42681. Object.defineProperty(FindReplaceState.prototype, "actualMatchCase", {
  42682. get: function () { return this._matchCase; },
  42683. enumerable: true,
  42684. configurable: true
  42685. });
  42686. Object.defineProperty(FindReplaceState.prototype, "actualPreserveCase", {
  42687. get: function () { return this._preserveCase; },
  42688. enumerable: true,
  42689. configurable: true
  42690. });
  42691. Object.defineProperty(FindReplaceState.prototype, "searchScope", {
  42692. get: function () { return this._searchScope; },
  42693. enumerable: true,
  42694. configurable: true
  42695. });
  42696. Object.defineProperty(FindReplaceState.prototype, "matchesPosition", {
  42697. get: function () { return this._matchesPosition; },
  42698. enumerable: true,
  42699. configurable: true
  42700. });
  42701. Object.defineProperty(FindReplaceState.prototype, "matchesCount", {
  42702. get: function () { return this._matchesCount; },
  42703. enumerable: true,
  42704. configurable: true
  42705. });
  42706. Object.defineProperty(FindReplaceState.prototype, "currentMatch", {
  42707. get: function () { return this._currentMatch; },
  42708. enumerable: true,
  42709. configurable: true
  42710. });
  42711. FindReplaceState.prototype.changeMatchInfo = function (matchesPosition, matchesCount, currentMatch) {
  42712. var changeEvent = {
  42713. moveCursor: false,
  42714. updateHistory: false,
  42715. searchString: false,
  42716. replaceString: false,
  42717. isRevealed: false,
  42718. isReplaceRevealed: false,
  42719. isRegex: false,
  42720. wholeWord: false,
  42721. matchCase: false,
  42722. preserveCase: false,
  42723. searchScope: false,
  42724. matchesPosition: false,
  42725. matchesCount: false,
  42726. currentMatch: false
  42727. };
  42728. var somethingChanged = false;
  42729. if (matchesCount === 0) {
  42730. matchesPosition = 0;
  42731. }
  42732. if (matchesPosition > matchesCount) {
  42733. matchesPosition = matchesCount;
  42734. }
  42735. if (this._matchesPosition !== matchesPosition) {
  42736. this._matchesPosition = matchesPosition;
  42737. changeEvent.matchesPosition = true;
  42738. somethingChanged = true;
  42739. }
  42740. if (this._matchesCount !== matchesCount) {
  42741. this._matchesCount = matchesCount;
  42742. changeEvent.matchesCount = true;
  42743. somethingChanged = true;
  42744. }
  42745. if (typeof currentMatch !== 'undefined') {
  42746. if (!range_1.Range.equalsRange(this._currentMatch, currentMatch)) {
  42747. this._currentMatch = currentMatch;
  42748. changeEvent.currentMatch = true;
  42749. somethingChanged = true;
  42750. }
  42751. }
  42752. if (somethingChanged) {
  42753. this._onFindReplaceStateChange.fire(changeEvent);
  42754. }
  42755. };
  42756. FindReplaceState.prototype.change = function (newState, moveCursor, updateHistory) {
  42757. if (updateHistory === void 0) { updateHistory = true; }
  42758. var changeEvent = {
  42759. moveCursor: moveCursor,
  42760. updateHistory: updateHistory,
  42761. searchString: false,
  42762. replaceString: false,
  42763. isRevealed: false,
  42764. isReplaceRevealed: false,
  42765. isRegex: false,
  42766. wholeWord: false,
  42767. matchCase: false,
  42768. preserveCase: false,
  42769. searchScope: false,
  42770. matchesPosition: false,
  42771. matchesCount: false,
  42772. currentMatch: false
  42773. };
  42774. var somethingChanged = false;
  42775. var oldEffectiveIsRegex = this.isRegex;
  42776. var oldEffectiveWholeWords = this.wholeWord;
  42777. var oldEffectiveMatchCase = this.matchCase;
  42778. var oldEffectivePreserveCase = this.preserveCase;
  42779. if (typeof newState.searchString !== 'undefined') {
  42780. if (this._searchString !== newState.searchString) {
  42781. this._searchString = newState.searchString;
  42782. changeEvent.searchString = true;
  42783. somethingChanged = true;
  42784. }
  42785. }
  42786. if (typeof newState.replaceString !== 'undefined') {
  42787. if (this._replaceString !== newState.replaceString) {
  42788. this._replaceString = newState.replaceString;
  42789. changeEvent.replaceString = true;
  42790. somethingChanged = true;
  42791. }
  42792. }
  42793. if (typeof newState.isRevealed !== 'undefined') {
  42794. if (this._isRevealed !== newState.isRevealed) {
  42795. this._isRevealed = newState.isRevealed;
  42796. changeEvent.isRevealed = true;
  42797. somethingChanged = true;
  42798. }
  42799. }
  42800. if (typeof newState.isReplaceRevealed !== 'undefined') {
  42801. if (this._isReplaceRevealed !== newState.isReplaceRevealed) {
  42802. this._isReplaceRevealed = newState.isReplaceRevealed;
  42803. changeEvent.isReplaceRevealed = true;
  42804. somethingChanged = true;
  42805. }
  42806. }
  42807. if (typeof newState.isRegex !== 'undefined') {
  42808. this._isRegex = newState.isRegex;
  42809. }
  42810. if (typeof newState.wholeWord !== 'undefined') {
  42811. this._wholeWord = newState.wholeWord;
  42812. }
  42813. if (typeof newState.matchCase !== 'undefined') {
  42814. this._matchCase = newState.matchCase;
  42815. }
  42816. if (typeof newState.preserveCase !== 'undefined') {
  42817. this._preserveCase = newState.preserveCase;
  42818. }
  42819. if (typeof newState.searchScope !== 'undefined') {
  42820. if (!range_1.Range.equalsRange(this._searchScope, newState.searchScope)) {
  42821. this._searchScope = newState.searchScope;
  42822. changeEvent.searchScope = true;
  42823. somethingChanged = true;
  42824. }
  42825. }
  42826. // Overrides get set when they explicitly come in and get reset anytime something else changes
  42827. this._isRegexOverride = (typeof newState.isRegexOverride !== 'undefined' ? newState.isRegexOverride : 0 /* NotSet */);
  42828. this._wholeWordOverride = (typeof newState.wholeWordOverride !== 'undefined' ? newState.wholeWordOverride : 0 /* NotSet */);
  42829. this._matchCaseOverride = (typeof newState.matchCaseOverride !== 'undefined' ? newState.matchCaseOverride : 0 /* NotSet */);
  42830. this._preserveCaseOverride = (typeof newState.preserveCaseOverride !== 'undefined' ? newState.preserveCaseOverride : 0 /* NotSet */);
  42831. if (oldEffectiveIsRegex !== this.isRegex) {
  42832. somethingChanged = true;
  42833. changeEvent.isRegex = true;
  42834. }
  42835. if (oldEffectiveWholeWords !== this.wholeWord) {
  42836. somethingChanged = true;
  42837. changeEvent.wholeWord = true;
  42838. }
  42839. if (oldEffectiveMatchCase !== this.matchCase) {
  42840. somethingChanged = true;
  42841. changeEvent.matchCase = true;
  42842. }
  42843. if (oldEffectivePreserveCase !== this.preserveCase) {
  42844. somethingChanged = true;
  42845. changeEvent.preserveCase = true;
  42846. }
  42847. if (somethingChanged) {
  42848. this._onFindReplaceStateChange.fire(changeEvent);
  42849. }
  42850. };
  42851. return FindReplaceState;
  42852. }(lifecycle_1.Disposable));
  42853. exports.FindReplaceState = FindReplaceState;
  42854. });
  42855. /*---------------------------------------------------------------------------------------------
  42856. * Copyright (c) Microsoft Corporation. All rights reserved.
  42857. * Licensed under the MIT License. See License.txt in the project root for license information.
  42858. *--------------------------------------------------------------------------------------------*/
  42859. define(__m[379/*vs/editor/contrib/find/replaceAllCommand*/], __M([0/*require*/,1/*exports*/,3/*vs/editor/common/core/range*/]), function (require, exports, range_1) {
  42860. "use strict";
  42861. Object.defineProperty(exports, "__esModule", { value: true });
  42862. var ReplaceAllCommand = /** @class */ (function () {
  42863. function ReplaceAllCommand(editorSelection, ranges, replaceStrings) {
  42864. this._editorSelection = editorSelection;
  42865. this._ranges = ranges;
  42866. this._replaceStrings = replaceStrings;
  42867. this._trackedEditorSelectionId = null;
  42868. }
  42869. ReplaceAllCommand.prototype.getEditOperations = function (model, builder) {
  42870. if (this._ranges.length > 0) {
  42871. // Collect all edit operations
  42872. var ops = [];
  42873. for (var i = 0; i < this._ranges.length; i++) {
  42874. ops.push({
  42875. range: this._ranges[i],
  42876. text: this._replaceStrings[i]
  42877. });
  42878. }
  42879. // Sort them in ascending order by range starts
  42880. ops.sort(function (o1, o2) {
  42881. return range_1.Range.compareRangesUsingStarts(o1.range, o2.range);
  42882. });
  42883. // Merge operations that touch each other
  42884. var resultOps = [];
  42885. var previousOp = ops[0];
  42886. for (var i = 1; i < ops.length; i++) {
  42887. if (previousOp.range.endLineNumber === ops[i].range.startLineNumber && previousOp.range.endColumn === ops[i].range.startColumn) {
  42888. // These operations are one after another and can be merged
  42889. previousOp.range = previousOp.range.plusRange(ops[i].range);
  42890. previousOp.text = previousOp.text + ops[i].text;
  42891. }
  42892. else {
  42893. resultOps.push(previousOp);
  42894. previousOp = ops[i];
  42895. }
  42896. }
  42897. resultOps.push(previousOp);
  42898. for (var _i = 0, resultOps_1 = resultOps; _i < resultOps_1.length; _i++) {
  42899. var op = resultOps_1[_i];
  42900. builder.addEditOperation(op.range, op.text);
  42901. }
  42902. }
  42903. this._trackedEditorSelectionId = builder.trackSelection(this._editorSelection);
  42904. };
  42905. ReplaceAllCommand.prototype.computeCursorState = function (model, helper) {
  42906. return helper.getTrackedSelection(this._trackedEditorSelectionId);
  42907. };
  42908. return ReplaceAllCommand;
  42909. }());
  42910. exports.ReplaceAllCommand = ReplaceAllCommand;
  42911. });
  42912. /*---------------------------------------------------------------------------------------------
  42913. * Copyright (c) Microsoft Corporation. All rights reserved.
  42914. * Licensed under the MIT License. See License.txt in the project root for license information.
  42915. *--------------------------------------------------------------------------------------------*/
  42916. define(__m[380/*vs/editor/contrib/find/replacePattern*/], __M([0/*require*/,1/*exports*/,247/*vs/base/common/search*/]), function (require, exports, search_1) {
  42917. "use strict";
  42918. Object.defineProperty(exports, "__esModule", { value: true });
  42919. /**
  42920. * Assigned when the replace pattern is entirely static.
  42921. */
  42922. var StaticValueReplacePattern = /** @class */ (function () {
  42923. function StaticValueReplacePattern(staticValue) {
  42924. this.staticValue = staticValue;
  42925. this.kind = 0 /* StaticValue */;
  42926. }
  42927. return StaticValueReplacePattern;
  42928. }());
  42929. /**
  42930. * Assigned when the replace pattern has replacemend patterns.
  42931. */
  42932. var DynamicPiecesReplacePattern = /** @class */ (function () {
  42933. function DynamicPiecesReplacePattern(pieces) {
  42934. this.pieces = pieces;
  42935. this.kind = 1 /* DynamicPieces */;
  42936. }
  42937. return DynamicPiecesReplacePattern;
  42938. }());
  42939. var ReplacePattern = /** @class */ (function () {
  42940. function ReplacePattern(pieces) {
  42941. if (!pieces || pieces.length === 0) {
  42942. this._state = new StaticValueReplacePattern('');
  42943. }
  42944. else if (pieces.length === 1 && pieces[0].staticValue !== null) {
  42945. this._state = new StaticValueReplacePattern(pieces[0].staticValue);
  42946. }
  42947. else {
  42948. this._state = new DynamicPiecesReplacePattern(pieces);
  42949. }
  42950. }
  42951. ReplacePattern.fromStaticValue = function (value) {
  42952. return new ReplacePattern([ReplacePiece.staticValue(value)]);
  42953. };
  42954. Object.defineProperty(ReplacePattern.prototype, "hasReplacementPatterns", {
  42955. get: function () {
  42956. return (this._state.kind === 1 /* DynamicPieces */);
  42957. },
  42958. enumerable: true,
  42959. configurable: true
  42960. });
  42961. ReplacePattern.prototype.buildReplaceString = function (matches, preserveCase) {
  42962. if (this._state.kind === 0 /* StaticValue */) {
  42963. if (preserveCase) {
  42964. return search_1.buildReplaceStringWithCasePreserved(matches, this._state.staticValue);
  42965. }
  42966. else {
  42967. return this._state.staticValue;
  42968. }
  42969. }
  42970. var result = '';
  42971. for (var i = 0, len = this._state.pieces.length; i < len; i++) {
  42972. var piece = this._state.pieces[i];
  42973. if (piece.staticValue !== null) {
  42974. // static value ReplacePiece
  42975. result += piece.staticValue;
  42976. continue;
  42977. }
  42978. // match index ReplacePiece
  42979. result += ReplacePattern._substitute(piece.matchIndex, matches);
  42980. }
  42981. return result;
  42982. };
  42983. ReplacePattern._substitute = function (matchIndex, matches) {
  42984. if (matches === null) {
  42985. return '';
  42986. }
  42987. if (matchIndex === 0) {
  42988. return matches[0];
  42989. }
  42990. var remainder = '';
  42991. while (matchIndex > 0) {
  42992. if (matchIndex < matches.length) {
  42993. // A match can be undefined
  42994. var match = (matches[matchIndex] || '');
  42995. return match + remainder;
  42996. }
  42997. remainder = String(matchIndex % 10) + remainder;
  42998. matchIndex = Math.floor(matchIndex / 10);
  42999. }
  43000. return '$' + remainder;
  43001. };
  43002. return ReplacePattern;
  43003. }());
  43004. exports.ReplacePattern = ReplacePattern;
  43005. /**
  43006. * A replace piece can either be a static string or an index to a specific match.
  43007. */
  43008. var ReplacePiece = /** @class */ (function () {
  43009. function ReplacePiece(staticValue, matchIndex) {
  43010. this.staticValue = staticValue;
  43011. this.matchIndex = matchIndex;
  43012. }
  43013. ReplacePiece.staticValue = function (value) {
  43014. return new ReplacePiece(value, -1);
  43015. };
  43016. ReplacePiece.matchIndex = function (index) {
  43017. return new ReplacePiece(null, index);
  43018. };
  43019. return ReplacePiece;
  43020. }());
  43021. exports.ReplacePiece = ReplacePiece;
  43022. var ReplacePieceBuilder = /** @class */ (function () {
  43023. function ReplacePieceBuilder(source) {
  43024. this._source = source;
  43025. this._lastCharIndex = 0;
  43026. this._result = [];
  43027. this._resultLen = 0;
  43028. this._currentStaticPiece = '';
  43029. }
  43030. ReplacePieceBuilder.prototype.emitUnchanged = function (toCharIndex) {
  43031. this._emitStatic(this._source.substring(this._lastCharIndex, toCharIndex));
  43032. this._lastCharIndex = toCharIndex;
  43033. };
  43034. ReplacePieceBuilder.prototype.emitStatic = function (value, toCharIndex) {
  43035. this._emitStatic(value);
  43036. this._lastCharIndex = toCharIndex;
  43037. };
  43038. ReplacePieceBuilder.prototype._emitStatic = function (value) {
  43039. if (value.length === 0) {
  43040. return;
  43041. }
  43042. this._currentStaticPiece += value;
  43043. };
  43044. ReplacePieceBuilder.prototype.emitMatchIndex = function (index, toCharIndex) {
  43045. if (this._currentStaticPiece.length !== 0) {
  43046. this._result[this._resultLen++] = ReplacePiece.staticValue(this._currentStaticPiece);
  43047. this._currentStaticPiece = '';
  43048. }
  43049. this._result[this._resultLen++] = ReplacePiece.matchIndex(index);
  43050. this._lastCharIndex = toCharIndex;
  43051. };
  43052. ReplacePieceBuilder.prototype.finalize = function () {
  43053. this.emitUnchanged(this._source.length);
  43054. if (this._currentStaticPiece.length !== 0) {
  43055. this._result[this._resultLen++] = ReplacePiece.staticValue(this._currentStaticPiece);
  43056. this._currentStaticPiece = '';
  43057. }
  43058. return new ReplacePattern(this._result);
  43059. };
  43060. return ReplacePieceBuilder;
  43061. }());
  43062. /**
  43063. * \n => inserts a LF
  43064. * \t => inserts a TAB
  43065. * \\ => inserts a "\".
  43066. * $$ => inserts a "$".
  43067. * $& and $0 => inserts the matched substring.
  43068. * $n => Where n is a non-negative integer lesser than 100, inserts the nth parenthesized submatch string
  43069. * everything else stays untouched
  43070. *
  43071. * Also see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace#Specifying_a_string_as_a_parameter
  43072. */
  43073. function parseReplaceString(replaceString) {
  43074. if (!replaceString || replaceString.length === 0) {
  43075. return new ReplacePattern(null);
  43076. }
  43077. var result = new ReplacePieceBuilder(replaceString);
  43078. for (var i = 0, len = replaceString.length; i < len; i++) {
  43079. var chCode = replaceString.charCodeAt(i);
  43080. if (chCode === 92 /* Backslash */) {
  43081. // move to next char
  43082. i++;
  43083. if (i >= len) {
  43084. // string ends with a \
  43085. break;
  43086. }
  43087. var nextChCode = replaceString.charCodeAt(i);
  43088. // let replaceWithCharacter: string | null = null;
  43089. switch (nextChCode) {
  43090. case 92 /* Backslash */:
  43091. // \\ => inserts a "\"
  43092. result.emitUnchanged(i - 1);
  43093. result.emitStatic('\\', i + 1);
  43094. break;
  43095. case 110 /* n */:
  43096. // \n => inserts a LF
  43097. result.emitUnchanged(i - 1);
  43098. result.emitStatic('\n', i + 1);
  43099. break;
  43100. case 116 /* t */:
  43101. // \t => inserts a TAB
  43102. result.emitUnchanged(i - 1);
  43103. result.emitStatic('\t', i + 1);
  43104. break;
  43105. }
  43106. continue;
  43107. }
  43108. if (chCode === 36 /* DollarSign */) {
  43109. // move to next char
  43110. i++;
  43111. if (i >= len) {
  43112. // string ends with a $
  43113. break;
  43114. }
  43115. var nextChCode = replaceString.charCodeAt(i);
  43116. if (nextChCode === 36 /* DollarSign */) {
  43117. // $$ => inserts a "$"
  43118. result.emitUnchanged(i - 1);
  43119. result.emitStatic('$', i + 1);
  43120. continue;
  43121. }
  43122. if (nextChCode === 48 /* Digit0 */ || nextChCode === 38 /* Ampersand */) {
  43123. // $& and $0 => inserts the matched substring.
  43124. result.emitUnchanged(i - 1);
  43125. result.emitMatchIndex(0, i + 1);
  43126. continue;
  43127. }
  43128. if (49 /* Digit1 */ <= nextChCode && nextChCode <= 57 /* Digit9 */) {
  43129. // $n
  43130. var matchIndex = nextChCode - 48 /* Digit0 */;
  43131. // peek next char to probe for $nn
  43132. if (i + 1 < len) {
  43133. var nextNextChCode = replaceString.charCodeAt(i + 1);
  43134. if (48 /* Digit0 */ <= nextNextChCode && nextNextChCode <= 57 /* Digit9 */) {
  43135. // $nn
  43136. // move to next char
  43137. i++;
  43138. matchIndex = matchIndex * 10 + (nextNextChCode - 48 /* Digit0 */);
  43139. result.emitUnchanged(i - 2);
  43140. result.emitMatchIndex(matchIndex, i + 1);
  43141. continue;
  43142. }
  43143. }
  43144. result.emitUnchanged(i - 1);
  43145. result.emitMatchIndex(matchIndex, i + 1);
  43146. continue;
  43147. }
  43148. }
  43149. }
  43150. return result.finalize();
  43151. }
  43152. exports.parseReplaceString = parseReplaceString;
  43153. });
  43154. /*---------------------------------------------------------------------------------------------
  43155. * Copyright (c) Microsoft Corporation. All rights reserved.
  43156. * Licensed under the MIT License. See License.txt in the project root for license information.
  43157. *--------------------------------------------------------------------------------------------*/
  43158. define(__m[150/*vs/editor/contrib/folding/foldingRanges*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  43159. "use strict";
  43160. Object.defineProperty(exports, "__esModule", { value: true });
  43161. exports.MAX_FOLDING_REGIONS = 0xFFFF;
  43162. exports.MAX_LINE_NUMBER = 0xFFFFFF;
  43163. var MASK_INDENT = 0xFF000000;
  43164. var FoldingRegions = /** @class */ (function () {
  43165. function FoldingRegions(startIndexes, endIndexes, types) {
  43166. if (startIndexes.length !== endIndexes.length || startIndexes.length > exports.MAX_FOLDING_REGIONS) {
  43167. throw new Error('invalid startIndexes or endIndexes size');
  43168. }
  43169. this._startIndexes = startIndexes;
  43170. this._endIndexes = endIndexes;
  43171. this._collapseStates = new Uint32Array(Math.ceil(startIndexes.length / 32));
  43172. this._types = types;
  43173. this._parentsComputed = false;
  43174. }
  43175. FoldingRegions.prototype.ensureParentIndices = function () {
  43176. var _this = this;
  43177. if (!this._parentsComputed) {
  43178. this._parentsComputed = true;
  43179. var parentIndexes_1 = [];
  43180. var isInsideLast = function (startLineNumber, endLineNumber) {
  43181. var index = parentIndexes_1[parentIndexes_1.length - 1];
  43182. return _this.getStartLineNumber(index) <= startLineNumber && _this.getEndLineNumber(index) >= endLineNumber;
  43183. };
  43184. for (var i = 0, len = this._startIndexes.length; i < len; i++) {
  43185. var startLineNumber = this._startIndexes[i];
  43186. var endLineNumber = this._endIndexes[i];
  43187. if (startLineNumber > exports.MAX_LINE_NUMBER || endLineNumber > exports.MAX_LINE_NUMBER) {
  43188. throw new Error('startLineNumber or endLineNumber must not exceed ' + exports.MAX_LINE_NUMBER);
  43189. }
  43190. while (parentIndexes_1.length > 0 && !isInsideLast(startLineNumber, endLineNumber)) {
  43191. parentIndexes_1.pop();
  43192. }
  43193. var parentIndex = parentIndexes_1.length > 0 ? parentIndexes_1[parentIndexes_1.length - 1] : -1;
  43194. parentIndexes_1.push(i);
  43195. this._startIndexes[i] = startLineNumber + ((parentIndex & 0xFF) << 24);
  43196. this._endIndexes[i] = endLineNumber + ((parentIndex & 0xFF00) << 16);
  43197. }
  43198. }
  43199. };
  43200. Object.defineProperty(FoldingRegions.prototype, "length", {
  43201. get: function () {
  43202. return this._startIndexes.length;
  43203. },
  43204. enumerable: true,
  43205. configurable: true
  43206. });
  43207. FoldingRegions.prototype.getStartLineNumber = function (index) {
  43208. return this._startIndexes[index] & exports.MAX_LINE_NUMBER;
  43209. };
  43210. FoldingRegions.prototype.getEndLineNumber = function (index) {
  43211. return this._endIndexes[index] & exports.MAX_LINE_NUMBER;
  43212. };
  43213. FoldingRegions.prototype.getType = function (index) {
  43214. return this._types ? this._types[index] : undefined;
  43215. };
  43216. FoldingRegions.prototype.hasTypes = function () {
  43217. return !!this._types;
  43218. };
  43219. FoldingRegions.prototype.isCollapsed = function (index) {
  43220. var arrayIndex = (index / 32) | 0;
  43221. var bit = index % 32;
  43222. return (this._collapseStates[arrayIndex] & (1 << bit)) !== 0;
  43223. };
  43224. FoldingRegions.prototype.setCollapsed = function (index, newState) {
  43225. var arrayIndex = (index / 32) | 0;
  43226. var bit = index % 32;
  43227. var value = this._collapseStates[arrayIndex];
  43228. if (newState) {
  43229. this._collapseStates[arrayIndex] = value | (1 << bit);
  43230. }
  43231. else {
  43232. this._collapseStates[arrayIndex] = value & ~(1 << bit);
  43233. }
  43234. };
  43235. FoldingRegions.prototype.toRegion = function (index) {
  43236. return new FoldingRegion(this, index);
  43237. };
  43238. FoldingRegions.prototype.getParentIndex = function (index) {
  43239. this.ensureParentIndices();
  43240. var parent = ((this._startIndexes[index] & MASK_INDENT) >>> 24) + ((this._endIndexes[index] & MASK_INDENT) >>> 16);
  43241. if (parent === exports.MAX_FOLDING_REGIONS) {
  43242. return -1;
  43243. }
  43244. return parent;
  43245. };
  43246. FoldingRegions.prototype.contains = function (index, line) {
  43247. return this.getStartLineNumber(index) <= line && this.getEndLineNumber(index) >= line;
  43248. };
  43249. FoldingRegions.prototype.findIndex = function (line) {
  43250. var low = 0, high = this._startIndexes.length;
  43251. if (high === 0) {
  43252. return -1; // no children
  43253. }
  43254. while (low < high) {
  43255. var mid = Math.floor((low + high) / 2);
  43256. if (line < this.getStartLineNumber(mid)) {
  43257. high = mid;
  43258. }
  43259. else {
  43260. low = mid + 1;
  43261. }
  43262. }
  43263. return low - 1;
  43264. };
  43265. FoldingRegions.prototype.findRange = function (line) {
  43266. var index = this.findIndex(line);
  43267. if (index >= 0) {
  43268. var endLineNumber = this.getEndLineNumber(index);
  43269. if (endLineNumber >= line) {
  43270. return index;
  43271. }
  43272. index = this.getParentIndex(index);
  43273. while (index !== -1) {
  43274. if (this.contains(index, line)) {
  43275. return index;
  43276. }
  43277. index = this.getParentIndex(index);
  43278. }
  43279. }
  43280. return -1;
  43281. };
  43282. FoldingRegions.prototype.toString = function () {
  43283. var res = [];
  43284. for (var i = 0; i < this.length; i++) {
  43285. res[i] = "[" + (this.isCollapsed(i) ? '+' : '-') + "] " + this.getStartLineNumber(i) + "/" + this.getEndLineNumber(i);
  43286. }
  43287. return res.join(', ');
  43288. };
  43289. return FoldingRegions;
  43290. }());
  43291. exports.FoldingRegions = FoldingRegions;
  43292. var FoldingRegion = /** @class */ (function () {
  43293. function FoldingRegion(ranges, index) {
  43294. this.ranges = ranges;
  43295. this.index = index;
  43296. }
  43297. Object.defineProperty(FoldingRegion.prototype, "startLineNumber", {
  43298. get: function () {
  43299. return this.ranges.getStartLineNumber(this.index);
  43300. },
  43301. enumerable: true,
  43302. configurable: true
  43303. });
  43304. Object.defineProperty(FoldingRegion.prototype, "endLineNumber", {
  43305. get: function () {
  43306. return this.ranges.getEndLineNumber(this.index);
  43307. },
  43308. enumerable: true,
  43309. configurable: true
  43310. });
  43311. Object.defineProperty(FoldingRegion.prototype, "regionIndex", {
  43312. get: function () {
  43313. return this.index;
  43314. },
  43315. enumerable: true,
  43316. configurable: true
  43317. });
  43318. Object.defineProperty(FoldingRegion.prototype, "parentIndex", {
  43319. get: function () {
  43320. return this.ranges.getParentIndex(this.index);
  43321. },
  43322. enumerable: true,
  43323. configurable: true
  43324. });
  43325. Object.defineProperty(FoldingRegion.prototype, "isCollapsed", {
  43326. get: function () {
  43327. return this.ranges.isCollapsed(this.index);
  43328. },
  43329. enumerable: true,
  43330. configurable: true
  43331. });
  43332. FoldingRegion.prototype.containedBy = function (range) {
  43333. return range.startLineNumber <= this.startLineNumber && range.endLineNumber >= this.endLineNumber;
  43334. };
  43335. FoldingRegion.prototype.containsLine = function (lineNumber) {
  43336. return this.startLineNumber <= lineNumber && lineNumber <= this.endLineNumber;
  43337. };
  43338. return FoldingRegion;
  43339. }());
  43340. exports.FoldingRegion = FoldingRegion;
  43341. });
  43342. /*---------------------------------------------------------------------------------------------
  43343. * Copyright (c) Microsoft Corporation. All rights reserved.
  43344. * Licensed under the MIT License. See License.txt in the project root for license information.
  43345. *--------------------------------------------------------------------------------------------*/
  43346. define(__m[381/*vs/editor/contrib/folding/foldingModel*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,150/*vs/editor/contrib/folding/foldingRanges*/]), function (require, exports, event_1, foldingRanges_1) {
  43347. "use strict";
  43348. Object.defineProperty(exports, "__esModule", { value: true });
  43349. var FoldingModel = /** @class */ (function () {
  43350. function FoldingModel(textModel, decorationProvider) {
  43351. this._updateEventEmitter = new event_1.Emitter();
  43352. this.onDidChange = this._updateEventEmitter.event;
  43353. this._textModel = textModel;
  43354. this._decorationProvider = decorationProvider;
  43355. this._regions = new foldingRanges_1.FoldingRegions(new Uint32Array(0), new Uint32Array(0));
  43356. this._editorDecorationIds = [];
  43357. this._isInitialized = false;
  43358. }
  43359. Object.defineProperty(FoldingModel.prototype, "regions", {
  43360. get: function () { return this._regions; },
  43361. enumerable: true,
  43362. configurable: true
  43363. });
  43364. Object.defineProperty(FoldingModel.prototype, "textModel", {
  43365. get: function () { return this._textModel; },
  43366. enumerable: true,
  43367. configurable: true
  43368. });
  43369. Object.defineProperty(FoldingModel.prototype, "isInitialized", {
  43370. get: function () { return this._isInitialized; },
  43371. enumerable: true,
  43372. configurable: true
  43373. });
  43374. FoldingModel.prototype.toggleCollapseState = function (regions) {
  43375. var _this = this;
  43376. if (!regions.length) {
  43377. return;
  43378. }
  43379. var processed = {};
  43380. this._decorationProvider.changeDecorations(function (accessor) {
  43381. for (var _i = 0, regions_1 = regions; _i < regions_1.length; _i++) {
  43382. var region = regions_1[_i];
  43383. var index = region.regionIndex;
  43384. var editorDecorationId = _this._editorDecorationIds[index];
  43385. if (editorDecorationId && !processed[editorDecorationId]) {
  43386. processed[editorDecorationId] = true;
  43387. var newCollapseState = !_this._regions.isCollapsed(index);
  43388. _this._regions.setCollapsed(index, newCollapseState);
  43389. accessor.changeDecorationOptions(editorDecorationId, _this._decorationProvider.getDecorationOption(newCollapseState));
  43390. }
  43391. }
  43392. });
  43393. this._updateEventEmitter.fire({ model: this, collapseStateChanged: regions });
  43394. };
  43395. FoldingModel.prototype.update = function (newRegions, blockedLineNumers) {
  43396. var _this = this;
  43397. if (blockedLineNumers === void 0) { blockedLineNumers = []; }
  43398. var newEditorDecorations = [];
  43399. var isBlocked = function (startLineNumber, endLineNumber) {
  43400. for (var _i = 0, blockedLineNumers_1 = blockedLineNumers; _i < blockedLineNumers_1.length; _i++) {
  43401. var blockedLineNumber = blockedLineNumers_1[_i];
  43402. if (startLineNumber < blockedLineNumber && blockedLineNumber <= endLineNumber) { // first line is visible
  43403. return true;
  43404. }
  43405. }
  43406. return false;
  43407. };
  43408. var initRange = function (index, isCollapsed) {
  43409. var startLineNumber = newRegions.getStartLineNumber(index);
  43410. if (isCollapsed && isBlocked(startLineNumber, newRegions.getEndLineNumber(index))) {
  43411. isCollapsed = false;
  43412. }
  43413. newRegions.setCollapsed(index, isCollapsed);
  43414. var maxColumn = _this._textModel.getLineMaxColumn(startLineNumber);
  43415. var decorationRange = {
  43416. startLineNumber: startLineNumber,
  43417. startColumn: maxColumn,
  43418. endLineNumber: startLineNumber,
  43419. endColumn: maxColumn
  43420. };
  43421. newEditorDecorations.push({ range: decorationRange, options: _this._decorationProvider.getDecorationOption(isCollapsed) });
  43422. };
  43423. var i = 0;
  43424. var nextCollapsed = function () {
  43425. while (i < _this._regions.length) {
  43426. var isCollapsed = _this._regions.isCollapsed(i);
  43427. i++;
  43428. if (isCollapsed) {
  43429. return i - 1;
  43430. }
  43431. }
  43432. return -1;
  43433. };
  43434. var k = 0;
  43435. var collapsedIndex = nextCollapsed();
  43436. while (collapsedIndex !== -1 && k < newRegions.length) {
  43437. // get the latest range
  43438. var decRange = this._textModel.getDecorationRange(this._editorDecorationIds[collapsedIndex]);
  43439. if (decRange) {
  43440. var collapsedStartLineNumber = decRange.startLineNumber;
  43441. if (this._textModel.getLineMaxColumn(collapsedStartLineNumber) === decRange.startColumn) { // test that the decoration is still at the end otherwise it got deleted
  43442. while (k < newRegions.length) {
  43443. var startLineNumber = newRegions.getStartLineNumber(k);
  43444. if (collapsedStartLineNumber >= startLineNumber) {
  43445. initRange(k, collapsedStartLineNumber === startLineNumber);
  43446. k++;
  43447. }
  43448. else {
  43449. break;
  43450. }
  43451. }
  43452. }
  43453. }
  43454. collapsedIndex = nextCollapsed();
  43455. }
  43456. while (k < newRegions.length) {
  43457. initRange(k, false);
  43458. k++;
  43459. }
  43460. this._editorDecorationIds = this._decorationProvider.deltaDecorations(this._editorDecorationIds, newEditorDecorations);
  43461. this._regions = newRegions;
  43462. this._isInitialized = true;
  43463. this._updateEventEmitter.fire({ model: this });
  43464. };
  43465. /**
  43466. * Collapse state memento, for persistence only
  43467. */
  43468. FoldingModel.prototype.getMemento = function () {
  43469. var collapsedRanges = [];
  43470. for (var i = 0; i < this._regions.length; i++) {
  43471. if (this._regions.isCollapsed(i)) {
  43472. var range = this._textModel.getDecorationRange(this._editorDecorationIds[i]);
  43473. if (range) {
  43474. var startLineNumber = range.startLineNumber;
  43475. var endLineNumber = range.endLineNumber + this._regions.getEndLineNumber(i) - this._regions.getStartLineNumber(i);
  43476. collapsedRanges.push({ startLineNumber: startLineNumber, endLineNumber: endLineNumber });
  43477. }
  43478. }
  43479. }
  43480. if (collapsedRanges.length > 0) {
  43481. return collapsedRanges;
  43482. }
  43483. return undefined;
  43484. };
  43485. /**
  43486. * Apply persisted state, for persistence only
  43487. */
  43488. FoldingModel.prototype.applyMemento = function (state) {
  43489. if (!Array.isArray(state)) {
  43490. return;
  43491. }
  43492. var toToogle = [];
  43493. for (var _i = 0, state_1 = state; _i < state_1.length; _i++) {
  43494. var range = state_1[_i];
  43495. var region = this.getRegionAtLine(range.startLineNumber);
  43496. if (region && !region.isCollapsed) {
  43497. toToogle.push(region);
  43498. }
  43499. }
  43500. this.toggleCollapseState(toToogle);
  43501. };
  43502. FoldingModel.prototype.dispose = function () {
  43503. this._decorationProvider.deltaDecorations(this._editorDecorationIds, []);
  43504. };
  43505. FoldingModel.prototype.getAllRegionsAtLine = function (lineNumber, filter) {
  43506. var result = [];
  43507. if (this._regions) {
  43508. var index = this._regions.findRange(lineNumber);
  43509. var level = 1;
  43510. while (index >= 0) {
  43511. var current = this._regions.toRegion(index);
  43512. if (!filter || filter(current, level)) {
  43513. result.push(current);
  43514. }
  43515. level++;
  43516. index = current.parentIndex;
  43517. }
  43518. }
  43519. return result;
  43520. };
  43521. FoldingModel.prototype.getRegionAtLine = function (lineNumber) {
  43522. if (this._regions) {
  43523. var index = this._regions.findRange(lineNumber);
  43524. if (index >= 0) {
  43525. return this._regions.toRegion(index);
  43526. }
  43527. }
  43528. return null;
  43529. };
  43530. FoldingModel.prototype.getRegionsInside = function (region, filter) {
  43531. var result = [];
  43532. var index = region ? region.regionIndex + 1 : 0;
  43533. var endLineNumber = region ? region.endLineNumber : Number.MAX_VALUE;
  43534. if (filter && filter.length === 2) {
  43535. var levelStack = [];
  43536. for (var i = index, len = this._regions.length; i < len; i++) {
  43537. var current = this._regions.toRegion(i);
  43538. if (this._regions.getStartLineNumber(i) < endLineNumber) {
  43539. while (levelStack.length > 0 && !current.containedBy(levelStack[levelStack.length - 1])) {
  43540. levelStack.pop();
  43541. }
  43542. levelStack.push(current);
  43543. if (filter(current, levelStack.length)) {
  43544. result.push(current);
  43545. }
  43546. }
  43547. else {
  43548. break;
  43549. }
  43550. }
  43551. }
  43552. else {
  43553. for (var i = index, len = this._regions.length; i < len; i++) {
  43554. var current = this._regions.toRegion(i);
  43555. if (this._regions.getStartLineNumber(i) < endLineNumber) {
  43556. if (!filter || filter(current)) {
  43557. result.push(current);
  43558. }
  43559. }
  43560. else {
  43561. break;
  43562. }
  43563. }
  43564. }
  43565. return result;
  43566. };
  43567. return FoldingModel;
  43568. }());
  43569. exports.FoldingModel = FoldingModel;
  43570. /**
  43571. * Collapse or expand the regions at the given locations
  43572. * @param levels The number of levels. Use 1 to only impact the regions at the location, use Number.MAX_VALUE for all levels.
  43573. * @param lineNumbers the location of the regions to collapse or expand, or if not set, all regions in the model.
  43574. */
  43575. function toggleCollapseState(foldingModel, levels, lineNumbers) {
  43576. var toToggle = [];
  43577. var _loop_1 = function (lineNumber) {
  43578. var region = foldingModel.getRegionAtLine(lineNumber);
  43579. if (region) {
  43580. var doCollapse_1 = !region.isCollapsed;
  43581. toToggle.push(region);
  43582. if (levels > 1) {
  43583. var regionsInside = foldingModel.getRegionsInside(region, function (r, level) { return r.isCollapsed !== doCollapse_1 && level < levels; });
  43584. toToggle.push.apply(toToggle, regionsInside);
  43585. }
  43586. }
  43587. };
  43588. for (var _i = 0, lineNumbers_1 = lineNumbers; _i < lineNumbers_1.length; _i++) {
  43589. var lineNumber = lineNumbers_1[_i];
  43590. _loop_1(lineNumber);
  43591. }
  43592. foldingModel.toggleCollapseState(toToggle);
  43593. }
  43594. exports.toggleCollapseState = toggleCollapseState;
  43595. /**
  43596. * Collapse or expand the regions at the given locations including all children.
  43597. * @param doCollapse Wheter to collase or expand
  43598. * @param levels The number of levels. Use 1 to only impact the regions at the location, use Number.MAX_VALUE for all levels.
  43599. * @param lineNumbers the location of the regions to collapse or expand, or if not set, all regions in the model.
  43600. */
  43601. function setCollapseStateLevelsDown(foldingModel, doCollapse, levels, lineNumbers) {
  43602. if (levels === void 0) { levels = Number.MAX_VALUE; }
  43603. var toToggle = [];
  43604. if (lineNumbers && lineNumbers.length > 0) {
  43605. for (var _i = 0, lineNumbers_2 = lineNumbers; _i < lineNumbers_2.length; _i++) {
  43606. var lineNumber = lineNumbers_2[_i];
  43607. var region = foldingModel.getRegionAtLine(lineNumber);
  43608. if (region) {
  43609. if (region.isCollapsed !== doCollapse) {
  43610. toToggle.push(region);
  43611. }
  43612. if (levels > 1) {
  43613. var regionsInside = foldingModel.getRegionsInside(region, function (r, level) { return r.isCollapsed !== doCollapse && level < levels; });
  43614. toToggle.push.apply(toToggle, regionsInside);
  43615. }
  43616. }
  43617. }
  43618. }
  43619. else {
  43620. var regionsInside = foldingModel.getRegionsInside(null, function (r, level) { return r.isCollapsed !== doCollapse && level < levels; });
  43621. toToggle.push.apply(toToggle, regionsInside);
  43622. }
  43623. foldingModel.toggleCollapseState(toToggle);
  43624. }
  43625. exports.setCollapseStateLevelsDown = setCollapseStateLevelsDown;
  43626. /**
  43627. * Collapse or expand the regions at the given locations including all parents.
  43628. * @param doCollapse Wheter to collase or expand
  43629. * @param levels The number of levels. Use 1 to only impact the regions at the location, use Number.MAX_VALUE for all levels.
  43630. * @param lineNumbers the location of the regions to collapse or expand.
  43631. */
  43632. function setCollapseStateLevelsUp(foldingModel, doCollapse, levels, lineNumbers) {
  43633. var toToggle = [];
  43634. for (var _i = 0, lineNumbers_3 = lineNumbers; _i < lineNumbers_3.length; _i++) {
  43635. var lineNumber = lineNumbers_3[_i];
  43636. var regions = foldingModel.getAllRegionsAtLine(lineNumber, function (region, level) { return region.isCollapsed !== doCollapse && level <= levels; });
  43637. toToggle.push.apply(toToggle, regions);
  43638. }
  43639. foldingModel.toggleCollapseState(toToggle);
  43640. }
  43641. exports.setCollapseStateLevelsUp = setCollapseStateLevelsUp;
  43642. /**
  43643. * Collapse or expand a region at the given locations. If the inner most region is already collapsed/expanded, uses the first parent instead.
  43644. * @param doCollapse Wheter to collase or expand
  43645. * @param lineNumbers the location of the regions to collapse or expand.
  43646. */
  43647. function setCollapseStateUp(foldingModel, doCollapse, lineNumbers) {
  43648. var toToggle = [];
  43649. for (var _i = 0, lineNumbers_4 = lineNumbers; _i < lineNumbers_4.length; _i++) {
  43650. var lineNumber = lineNumbers_4[_i];
  43651. var regions = foldingModel.getAllRegionsAtLine(lineNumber, function (region) { return region.isCollapsed !== doCollapse; });
  43652. if (regions.length > 0) {
  43653. toToggle.push(regions[0]);
  43654. }
  43655. }
  43656. foldingModel.toggleCollapseState(toToggle);
  43657. }
  43658. exports.setCollapseStateUp = setCollapseStateUp;
  43659. /**
  43660. * Folds or unfolds all regions that have a given level, except if they contain one of the blocked lines.
  43661. * @param foldLevel level. Level == 1 is the top level
  43662. * @param doCollapse Wheter to collase or expand
  43663. */
  43664. function setCollapseStateAtLevel(foldingModel, foldLevel, doCollapse, blockedLineNumbers) {
  43665. var filter = function (region, level) { return level === foldLevel && region.isCollapsed !== doCollapse && !blockedLineNumbers.some(function (line) { return region.containsLine(line); }); };
  43666. var toToggle = foldingModel.getRegionsInside(null, filter);
  43667. foldingModel.toggleCollapseState(toToggle);
  43668. }
  43669. exports.setCollapseStateAtLevel = setCollapseStateAtLevel;
  43670. /**
  43671. * Folds all regions for which the lines start with a given regex
  43672. * @param foldingModel the folding model
  43673. */
  43674. function setCollapseStateForMatchingLines(foldingModel, regExp, doCollapse) {
  43675. var editorModel = foldingModel.textModel;
  43676. var regions = foldingModel.regions;
  43677. var toToggle = [];
  43678. for (var i = regions.length - 1; i >= 0; i--) {
  43679. if (doCollapse !== regions.isCollapsed(i)) {
  43680. var startLineNumber = regions.getStartLineNumber(i);
  43681. if (regExp.test(editorModel.getLineContent(startLineNumber))) {
  43682. toToggle.push(regions.toRegion(i));
  43683. }
  43684. }
  43685. }
  43686. foldingModel.toggleCollapseState(toToggle);
  43687. }
  43688. exports.setCollapseStateForMatchingLines = setCollapseStateForMatchingLines;
  43689. /**
  43690. * Folds all regions of the given type
  43691. * @param foldingModel the folding model
  43692. */
  43693. function setCollapseStateForType(foldingModel, type, doCollapse) {
  43694. var regions = foldingModel.regions;
  43695. var toToggle = [];
  43696. for (var i = regions.length - 1; i >= 0; i--) {
  43697. if (doCollapse !== regions.isCollapsed(i) && type === regions.getType(i)) {
  43698. toToggle.push(regions.toRegion(i));
  43699. }
  43700. }
  43701. foldingModel.toggleCollapseState(toToggle);
  43702. }
  43703. exports.setCollapseStateForType = setCollapseStateForType;
  43704. });
  43705. /*---------------------------------------------------------------------------------------------
  43706. * Copyright (c) Microsoft Corporation. All rights reserved.
  43707. * Licensed under the MIT License. See License.txt in the project root for license information.
  43708. *--------------------------------------------------------------------------------------------*/
  43709. define(__m[382/*vs/editor/contrib/folding/hiddenRangeModel*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,3/*vs/editor/common/core/range*/,19/*vs/base/common/arrays*/]), function (require, exports, event_1, range_1, arrays_1) {
  43710. "use strict";
  43711. Object.defineProperty(exports, "__esModule", { value: true });
  43712. var HiddenRangeModel = /** @class */ (function () {
  43713. function HiddenRangeModel(model) {
  43714. var _this = this;
  43715. this._updateEventEmitter = new event_1.Emitter();
  43716. this._foldingModel = model;
  43717. this._foldingModelListener = model.onDidChange(function (_) { return _this.updateHiddenRanges(); });
  43718. this._hiddenRanges = [];
  43719. if (model.regions.length) {
  43720. this.updateHiddenRanges();
  43721. }
  43722. }
  43723. Object.defineProperty(HiddenRangeModel.prototype, "onDidChange", {
  43724. get: function () { return this._updateEventEmitter.event; },
  43725. enumerable: true,
  43726. configurable: true
  43727. });
  43728. Object.defineProperty(HiddenRangeModel.prototype, "hiddenRanges", {
  43729. get: function () { return this._hiddenRanges; },
  43730. enumerable: true,
  43731. configurable: true
  43732. });
  43733. HiddenRangeModel.prototype.updateHiddenRanges = function () {
  43734. var updateHiddenAreas = false;
  43735. var newHiddenAreas = [];
  43736. var i = 0; // index into hidden
  43737. var k = 0;
  43738. var lastCollapsedStart = Number.MAX_VALUE;
  43739. var lastCollapsedEnd = -1;
  43740. var ranges = this._foldingModel.regions;
  43741. for (; i < ranges.length; i++) {
  43742. if (!ranges.isCollapsed(i)) {
  43743. continue;
  43744. }
  43745. var startLineNumber = ranges.getStartLineNumber(i) + 1; // the first line is not hidden
  43746. var endLineNumber = ranges.getEndLineNumber(i);
  43747. if (lastCollapsedStart <= startLineNumber && endLineNumber <= lastCollapsedEnd) {
  43748. // ignore ranges contained in collapsed regions
  43749. continue;
  43750. }
  43751. if (!updateHiddenAreas && k < this._hiddenRanges.length && this._hiddenRanges[k].startLineNumber === startLineNumber && this._hiddenRanges[k].endLineNumber === endLineNumber) {
  43752. // reuse the old ranges
  43753. newHiddenAreas.push(this._hiddenRanges[k]);
  43754. k++;
  43755. }
  43756. else {
  43757. updateHiddenAreas = true;
  43758. newHiddenAreas.push(new range_1.Range(startLineNumber, 1, endLineNumber, 1));
  43759. }
  43760. lastCollapsedStart = startLineNumber;
  43761. lastCollapsedEnd = endLineNumber;
  43762. }
  43763. if (updateHiddenAreas || k < this._hiddenRanges.length) {
  43764. this.applyHiddenRanges(newHiddenAreas);
  43765. }
  43766. };
  43767. HiddenRangeModel.prototype.applyMemento = function (state) {
  43768. if (!Array.isArray(state) || state.length === 0) {
  43769. return false;
  43770. }
  43771. var hiddenRanges = [];
  43772. for (var _i = 0, state_1 = state; _i < state_1.length; _i++) {
  43773. var r = state_1[_i];
  43774. if (!r.startLineNumber || !r.endLineNumber) {
  43775. return false;
  43776. }
  43777. hiddenRanges.push(new range_1.Range(r.startLineNumber + 1, 1, r.endLineNumber, 1));
  43778. }
  43779. this.applyHiddenRanges(hiddenRanges);
  43780. return true;
  43781. };
  43782. /**
  43783. * Collapse state memento, for persistence only, only used if folding model is not yet initialized
  43784. */
  43785. HiddenRangeModel.prototype.getMemento = function () {
  43786. return this._hiddenRanges.map(function (r) { return ({ startLineNumber: r.startLineNumber - 1, endLineNumber: r.endLineNumber }); });
  43787. };
  43788. HiddenRangeModel.prototype.applyHiddenRanges = function (newHiddenAreas) {
  43789. this._hiddenRanges = newHiddenAreas;
  43790. this._updateEventEmitter.fire(newHiddenAreas);
  43791. };
  43792. HiddenRangeModel.prototype.hasRanges = function () {
  43793. return this._hiddenRanges.length > 0;
  43794. };
  43795. HiddenRangeModel.prototype.isHidden = function (line) {
  43796. return findRange(this._hiddenRanges, line) !== null;
  43797. };
  43798. HiddenRangeModel.prototype.adjustSelections = function (selections) {
  43799. var _this = this;
  43800. var hasChanges = false;
  43801. var editorModel = this._foldingModel.textModel;
  43802. var lastRange = null;
  43803. var adjustLine = function (line) {
  43804. if (!lastRange || !isInside(line, lastRange)) {
  43805. lastRange = findRange(_this._hiddenRanges, line);
  43806. }
  43807. if (lastRange) {
  43808. return lastRange.startLineNumber - 1;
  43809. }
  43810. return null;
  43811. };
  43812. for (var i = 0, len = selections.length; i < len; i++) {
  43813. var selection = selections[i];
  43814. var adjustedStartLine = adjustLine(selection.startLineNumber);
  43815. if (adjustedStartLine) {
  43816. selection = selection.setStartPosition(adjustedStartLine, editorModel.getLineMaxColumn(adjustedStartLine));
  43817. hasChanges = true;
  43818. }
  43819. var adjustedEndLine = adjustLine(selection.endLineNumber);
  43820. if (adjustedEndLine) {
  43821. selection = selection.setEndPosition(adjustedEndLine, editorModel.getLineMaxColumn(adjustedEndLine));
  43822. hasChanges = true;
  43823. }
  43824. selections[i] = selection;
  43825. }
  43826. return hasChanges;
  43827. };
  43828. HiddenRangeModel.prototype.dispose = function () {
  43829. if (this.hiddenRanges.length > 0) {
  43830. this._hiddenRanges = [];
  43831. this._updateEventEmitter.fire(this._hiddenRanges);
  43832. }
  43833. if (this._foldingModelListener) {
  43834. this._foldingModelListener.dispose();
  43835. this._foldingModelListener = null;
  43836. }
  43837. };
  43838. return HiddenRangeModel;
  43839. }());
  43840. exports.HiddenRangeModel = HiddenRangeModel;
  43841. function isInside(line, range) {
  43842. return line >= range.startLineNumber && line <= range.endLineNumber;
  43843. }
  43844. function findRange(ranges, line) {
  43845. var i = arrays_1.findFirstInSorted(ranges, function (r) { return line < r.startLineNumber; }) - 1;
  43846. if (i >= 0 && ranges[i].endLineNumber >= line) {
  43847. return ranges[i];
  43848. }
  43849. return null;
  43850. }
  43851. });
  43852. /*---------------------------------------------------------------------------------------------
  43853. * Copyright (c) Microsoft Corporation. All rights reserved.
  43854. * Licensed under the MIT License. See License.txt in the project root for license information.
  43855. *--------------------------------------------------------------------------------------------*/
  43856. define(__m[197/*vs/editor/contrib/folding/syntaxRangeProvider*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,150/*vs/editor/contrib/folding/foldingRanges*/]), function (require, exports, errors_1, foldingRanges_1) {
  43857. "use strict";
  43858. Object.defineProperty(exports, "__esModule", { value: true });
  43859. var MAX_FOLDING_REGIONS = 5000;
  43860. var foldingContext = {};
  43861. exports.ID_SYNTAX_PROVIDER = 'syntax';
  43862. var SyntaxRangeProvider = /** @class */ (function () {
  43863. function SyntaxRangeProvider(editorModel, providers, limit) {
  43864. if (limit === void 0) { limit = MAX_FOLDING_REGIONS; }
  43865. this.editorModel = editorModel;
  43866. this.providers = providers;
  43867. this.limit = limit;
  43868. this.id = exports.ID_SYNTAX_PROVIDER;
  43869. }
  43870. SyntaxRangeProvider.prototype.compute = function (cancellationToken) {
  43871. var _this = this;
  43872. return collectSyntaxRanges(this.providers, this.editorModel, cancellationToken).then(function (ranges) {
  43873. if (ranges) {
  43874. var res = sanitizeRanges(ranges, _this.limit);
  43875. return res;
  43876. }
  43877. return null;
  43878. });
  43879. };
  43880. SyntaxRangeProvider.prototype.dispose = function () {
  43881. };
  43882. return SyntaxRangeProvider;
  43883. }());
  43884. exports.SyntaxRangeProvider = SyntaxRangeProvider;
  43885. function collectSyntaxRanges(providers, model, cancellationToken) {
  43886. var rangeData = null;
  43887. var promises = providers.map(function (provider, i) {
  43888. return Promise.resolve(provider.provideFoldingRanges(model, foldingContext, cancellationToken)).then(function (ranges) {
  43889. if (cancellationToken.isCancellationRequested) {
  43890. return;
  43891. }
  43892. if (Array.isArray(ranges)) {
  43893. if (!Array.isArray(rangeData)) {
  43894. rangeData = [];
  43895. }
  43896. var nLines = model.getLineCount();
  43897. for (var _i = 0, ranges_1 = ranges; _i < ranges_1.length; _i++) {
  43898. var r = ranges_1[_i];
  43899. if (r.start > 0 && r.end > r.start && r.end <= nLines) {
  43900. rangeData.push({ start: r.start, end: r.end, rank: i, kind: r.kind });
  43901. }
  43902. }
  43903. }
  43904. }, errors_1.onUnexpectedExternalError);
  43905. });
  43906. return Promise.all(promises).then(function (_) {
  43907. return rangeData;
  43908. });
  43909. }
  43910. var RangesCollector = /** @class */ (function () {
  43911. function RangesCollector(foldingRangesLimit) {
  43912. this._startIndexes = [];
  43913. this._endIndexes = [];
  43914. this._nestingLevels = [];
  43915. this._nestingLevelCounts = [];
  43916. this._types = [];
  43917. this._length = 0;
  43918. this._foldingRangesLimit = foldingRangesLimit;
  43919. }
  43920. RangesCollector.prototype.add = function (startLineNumber, endLineNumber, type, nestingLevel) {
  43921. if (startLineNumber > foldingRanges_1.MAX_LINE_NUMBER || endLineNumber > foldingRanges_1.MAX_LINE_NUMBER) {
  43922. return;
  43923. }
  43924. var index = this._length;
  43925. this._startIndexes[index] = startLineNumber;
  43926. this._endIndexes[index] = endLineNumber;
  43927. this._nestingLevels[index] = nestingLevel;
  43928. this._types[index] = type;
  43929. this._length++;
  43930. if (nestingLevel < 30) {
  43931. this._nestingLevelCounts[nestingLevel] = (this._nestingLevelCounts[nestingLevel] || 0) + 1;
  43932. }
  43933. };
  43934. RangesCollector.prototype.toIndentRanges = function () {
  43935. if (this._length <= this._foldingRangesLimit) {
  43936. var startIndexes = new Uint32Array(this._length);
  43937. var endIndexes = new Uint32Array(this._length);
  43938. for (var i = 0; i < this._length; i++) {
  43939. startIndexes[i] = this._startIndexes[i];
  43940. endIndexes[i] = this._endIndexes[i];
  43941. }
  43942. return new foldingRanges_1.FoldingRegions(startIndexes, endIndexes, this._types);
  43943. }
  43944. else {
  43945. var entries = 0;
  43946. var maxLevel = this._nestingLevelCounts.length;
  43947. for (var i = 0; i < this._nestingLevelCounts.length; i++) {
  43948. var n = this._nestingLevelCounts[i];
  43949. if (n) {
  43950. if (n + entries > this._foldingRangesLimit) {
  43951. maxLevel = i;
  43952. break;
  43953. }
  43954. entries += n;
  43955. }
  43956. }
  43957. var startIndexes = new Uint32Array(this._foldingRangesLimit);
  43958. var endIndexes = new Uint32Array(this._foldingRangesLimit);
  43959. var types = [];
  43960. for (var i = 0, k = 0; i < this._length; i++) {
  43961. var level = this._nestingLevels[i];
  43962. if (level < maxLevel || (level === maxLevel && entries++ < this._foldingRangesLimit)) {
  43963. startIndexes[k] = this._startIndexes[i];
  43964. endIndexes[k] = this._endIndexes[i];
  43965. types[k] = this._types[i];
  43966. k++;
  43967. }
  43968. }
  43969. return new foldingRanges_1.FoldingRegions(startIndexes, endIndexes, types);
  43970. }
  43971. };
  43972. return RangesCollector;
  43973. }());
  43974. exports.RangesCollector = RangesCollector;
  43975. function sanitizeRanges(rangeData, limit) {
  43976. var sorted = rangeData.sort(function (d1, d2) {
  43977. var diff = d1.start - d2.start;
  43978. if (diff === 0) {
  43979. diff = d1.rank - d2.rank;
  43980. }
  43981. return diff;
  43982. });
  43983. var collector = new RangesCollector(limit);
  43984. var top = undefined;
  43985. var previous = [];
  43986. for (var _i = 0, sorted_1 = sorted; _i < sorted_1.length; _i++) {
  43987. var entry = sorted_1[_i];
  43988. if (!top) {
  43989. top = entry;
  43990. collector.add(entry.start, entry.end, entry.kind && entry.kind.value, previous.length);
  43991. }
  43992. else {
  43993. if (entry.start > top.start) {
  43994. if (entry.end <= top.end) {
  43995. previous.push(top);
  43996. top = entry;
  43997. collector.add(entry.start, entry.end, entry.kind && entry.kind.value, previous.length);
  43998. }
  43999. else {
  44000. if (entry.start > top.end) {
  44001. do {
  44002. top = previous.pop();
  44003. } while (top && entry.start > top.end);
  44004. if (top) {
  44005. previous.push(top);
  44006. }
  44007. top = entry;
  44008. }
  44009. collector.add(entry.start, entry.end, entry.kind && entry.kind.value, previous.length);
  44010. }
  44011. }
  44012. }
  44013. }
  44014. return collector.toIndentRanges();
  44015. }
  44016. exports.sanitizeRanges = sanitizeRanges;
  44017. });
  44018. /*---------------------------------------------------------------------------------------------
  44019. * Copyright (c) Microsoft Corporation. All rights reserved.
  44020. * Licensed under the MIT License. See License.txt in the project root for license information.
  44021. *--------------------------------------------------------------------------------------------*/
  44022. define(__m[383/*vs/editor/contrib/folding/intializingRangeProvider*/], __M([0/*require*/,1/*exports*/,197/*vs/editor/contrib/folding/syntaxRangeProvider*/]), function (require, exports, syntaxRangeProvider_1) {
  44023. "use strict";
  44024. Object.defineProperty(exports, "__esModule", { value: true });
  44025. exports.ID_INIT_PROVIDER = 'init';
  44026. var InitializingRangeProvider = /** @class */ (function () {
  44027. function InitializingRangeProvider(editorModel, initialRanges, onTimeout, timeoutTime) {
  44028. this.editorModel = editorModel;
  44029. this.id = exports.ID_INIT_PROVIDER;
  44030. if (initialRanges.length) {
  44031. var toDecorationRange = function (range) {
  44032. return {
  44033. range: {
  44034. startLineNumber: range.startLineNumber,
  44035. startColumn: 0,
  44036. endLineNumber: range.endLineNumber,
  44037. endColumn: editorModel.getLineLength(range.endLineNumber)
  44038. },
  44039. options: {
  44040. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */
  44041. }
  44042. };
  44043. };
  44044. this.decorationIds = editorModel.deltaDecorations([], initialRanges.map(toDecorationRange));
  44045. this.timeout = setTimeout(onTimeout, timeoutTime);
  44046. }
  44047. }
  44048. InitializingRangeProvider.prototype.dispose = function () {
  44049. if (this.decorationIds) {
  44050. this.editorModel.deltaDecorations(this.decorationIds, []);
  44051. this.decorationIds = undefined;
  44052. }
  44053. if (typeof this.timeout === 'number') {
  44054. clearTimeout(this.timeout);
  44055. this.timeout = undefined;
  44056. }
  44057. };
  44058. InitializingRangeProvider.prototype.compute = function (cancelationToken) {
  44059. var foldingRangeData = [];
  44060. if (this.decorationIds) {
  44061. for (var _i = 0, _a = this.decorationIds; _i < _a.length; _i++) {
  44062. var id = _a[_i];
  44063. var range = this.editorModel.getDecorationRange(id);
  44064. if (range) {
  44065. foldingRangeData.push({ start: range.startLineNumber, end: range.endLineNumber, rank: 1 });
  44066. }
  44067. }
  44068. }
  44069. return Promise.resolve(syntaxRangeProvider_1.sanitizeRanges(foldingRangeData, Number.MAX_VALUE));
  44070. };
  44071. return InitializingRangeProvider;
  44072. }());
  44073. exports.InitializingRangeProvider = InitializingRangeProvider;
  44074. });
  44075. /*---------------------------------------------------------------------------------------------
  44076. * Copyright (c) Microsoft Corporation. All rights reserved.
  44077. * Licensed under the MIT License. See License.txt in the project root for license information.
  44078. *--------------------------------------------------------------------------------------------*/
  44079. define(__m[198/*vs/editor/contrib/format/formattingEdit*/], __M([0/*require*/,1/*exports*/,58/*vs/editor/common/core/editOperation*/,3/*vs/editor/common/core/range*/]), function (require, exports, editOperation_1, range_1) {
  44080. "use strict";
  44081. Object.defineProperty(exports, "__esModule", { value: true });
  44082. var FormattingEdit = /** @class */ (function () {
  44083. function FormattingEdit() {
  44084. }
  44085. FormattingEdit._handleEolEdits = function (editor, edits) {
  44086. var newEol = undefined;
  44087. var singleEdits = [];
  44088. for (var _i = 0, edits_1 = edits; _i < edits_1.length; _i++) {
  44089. var edit = edits_1[_i];
  44090. if (typeof edit.eol === 'number') {
  44091. newEol = edit.eol;
  44092. }
  44093. if (edit.range && typeof edit.text === 'string') {
  44094. singleEdits.push(edit);
  44095. }
  44096. }
  44097. if (typeof newEol === 'number') {
  44098. if (editor.hasModel()) {
  44099. editor.getModel().pushEOL(newEol);
  44100. }
  44101. }
  44102. return singleEdits;
  44103. };
  44104. FormattingEdit._isFullModelReplaceEdit = function (editor, edit) {
  44105. if (!editor.hasModel()) {
  44106. return false;
  44107. }
  44108. var model = editor.getModel();
  44109. var editRange = model.validateRange(edit.range);
  44110. var fullModelRange = model.getFullModelRange();
  44111. return fullModelRange.equalsRange(editRange);
  44112. };
  44113. FormattingEdit.execute = function (editor, _edits) {
  44114. editor.pushUndoStop();
  44115. var edits = FormattingEdit._handleEolEdits(editor, _edits);
  44116. if (edits.length === 1 && FormattingEdit._isFullModelReplaceEdit(editor, edits[0])) {
  44117. // We use replace semantics and hope that markers stay put...
  44118. editor.executeEdits('formatEditsCommand', edits.map(function (edit) { return editOperation_1.EditOperation.replace(range_1.Range.lift(edit.range), edit.text); }));
  44119. }
  44120. else {
  44121. editor.executeEdits('formatEditsCommand', edits.map(function (edit) { return editOperation_1.EditOperation.replaceMove(range_1.Range.lift(edit.range), edit.text); }));
  44122. }
  44123. editor.pushUndoStop();
  44124. };
  44125. return FormattingEdit;
  44126. }());
  44127. exports.FormattingEdit = FormattingEdit;
  44128. });
  44129. /*---------------------------------------------------------------------------------------------
  44130. * Copyright (c) Microsoft Corporation. All rights reserved.
  44131. * Licensed under the MIT License. See License.txt in the project root for license information.
  44132. *--------------------------------------------------------------------------------------------*/
  44133. define(__m[199/*vs/editor/contrib/gotoSymbol/link/clickLinkGesture*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,2/*vs/base/common/lifecycle*/,4/*vs/base/common/event*/,16/*vs/base/common/platform*/]), function (require, exports, browser, lifecycle_1, event_1, platform) {
  44134. "use strict";
  44135. Object.defineProperty(exports, "__esModule", { value: true });
  44136. function hasModifier(e, modifier) {
  44137. return !!e[modifier];
  44138. }
  44139. /**
  44140. * An event that encapsulates the various trigger modifiers logic needed for go to definition.
  44141. */
  44142. var ClickLinkMouseEvent = /** @class */ (function () {
  44143. function ClickLinkMouseEvent(source, opts) {
  44144. this.target = source.target;
  44145. this.hasTriggerModifier = hasModifier(source.event, opts.triggerModifier);
  44146. this.hasSideBySideModifier = hasModifier(source.event, opts.triggerSideBySideModifier);
  44147. this.isNoneOrSingleMouseDown = (browser.isIE || source.event.detail <= 1); // IE does not support event.detail properly
  44148. }
  44149. return ClickLinkMouseEvent;
  44150. }());
  44151. exports.ClickLinkMouseEvent = ClickLinkMouseEvent;
  44152. /**
  44153. * An event that encapsulates the various trigger modifiers logic needed for go to definition.
  44154. */
  44155. var ClickLinkKeyboardEvent = /** @class */ (function () {
  44156. function ClickLinkKeyboardEvent(source, opts) {
  44157. this.keyCodeIsTriggerKey = (source.keyCode === opts.triggerKey);
  44158. this.keyCodeIsSideBySideKey = (source.keyCode === opts.triggerSideBySideKey);
  44159. this.hasTriggerModifier = hasModifier(source, opts.triggerModifier);
  44160. }
  44161. return ClickLinkKeyboardEvent;
  44162. }());
  44163. exports.ClickLinkKeyboardEvent = ClickLinkKeyboardEvent;
  44164. var ClickLinkOptions = /** @class */ (function () {
  44165. function ClickLinkOptions(triggerKey, triggerModifier, triggerSideBySideKey, triggerSideBySideModifier) {
  44166. this.triggerKey = triggerKey;
  44167. this.triggerModifier = triggerModifier;
  44168. this.triggerSideBySideKey = triggerSideBySideKey;
  44169. this.triggerSideBySideModifier = triggerSideBySideModifier;
  44170. }
  44171. ClickLinkOptions.prototype.equals = function (other) {
  44172. return (this.triggerKey === other.triggerKey
  44173. && this.triggerModifier === other.triggerModifier
  44174. && this.triggerSideBySideKey === other.triggerSideBySideKey
  44175. && this.triggerSideBySideModifier === other.triggerSideBySideModifier);
  44176. };
  44177. return ClickLinkOptions;
  44178. }());
  44179. exports.ClickLinkOptions = ClickLinkOptions;
  44180. function createOptions(multiCursorModifier) {
  44181. if (multiCursorModifier === 'altKey') {
  44182. if (platform.isMacintosh) {
  44183. return new ClickLinkOptions(57 /* Meta */, 'metaKey', 6 /* Alt */, 'altKey');
  44184. }
  44185. return new ClickLinkOptions(5 /* Ctrl */, 'ctrlKey', 6 /* Alt */, 'altKey');
  44186. }
  44187. if (platform.isMacintosh) {
  44188. return new ClickLinkOptions(6 /* Alt */, 'altKey', 57 /* Meta */, 'metaKey');
  44189. }
  44190. return new ClickLinkOptions(6 /* Alt */, 'altKey', 5 /* Ctrl */, 'ctrlKey');
  44191. }
  44192. var ClickLinkGesture = /** @class */ (function (_super) {
  44193. __extends(ClickLinkGesture, _super);
  44194. function ClickLinkGesture(editor) {
  44195. var _this = _super.call(this) || this;
  44196. _this._onMouseMoveOrRelevantKeyDown = _this._register(new event_1.Emitter());
  44197. _this.onMouseMoveOrRelevantKeyDown = _this._onMouseMoveOrRelevantKeyDown.event;
  44198. _this._onExecute = _this._register(new event_1.Emitter());
  44199. _this.onExecute = _this._onExecute.event;
  44200. _this._onCancel = _this._register(new event_1.Emitter());
  44201. _this.onCancel = _this._onCancel.event;
  44202. _this._editor = editor;
  44203. _this._opts = createOptions(_this._editor.getOption(59 /* multiCursorModifier */));
  44204. _this.lastMouseMoveEvent = null;
  44205. _this.hasTriggerKeyOnMouseDown = false;
  44206. _this._register(_this._editor.onDidChangeConfiguration(function (e) {
  44207. if (e.hasChanged(59 /* multiCursorModifier */)) {
  44208. var newOpts = createOptions(_this._editor.getOption(59 /* multiCursorModifier */));
  44209. if (_this._opts.equals(newOpts)) {
  44210. return;
  44211. }
  44212. _this._opts = newOpts;
  44213. _this.lastMouseMoveEvent = null;
  44214. _this.hasTriggerKeyOnMouseDown = false;
  44215. _this._onCancel.fire();
  44216. }
  44217. }));
  44218. _this._register(_this._editor.onMouseMove(function (e) { return _this.onEditorMouseMove(new ClickLinkMouseEvent(e, _this._opts)); }));
  44219. _this._register(_this._editor.onMouseDown(function (e) { return _this.onEditorMouseDown(new ClickLinkMouseEvent(e, _this._opts)); }));
  44220. _this._register(_this._editor.onMouseUp(function (e) { return _this.onEditorMouseUp(new ClickLinkMouseEvent(e, _this._opts)); }));
  44221. _this._register(_this._editor.onKeyDown(function (e) { return _this.onEditorKeyDown(new ClickLinkKeyboardEvent(e, _this._opts)); }));
  44222. _this._register(_this._editor.onKeyUp(function (e) { return _this.onEditorKeyUp(new ClickLinkKeyboardEvent(e, _this._opts)); }));
  44223. _this._register(_this._editor.onMouseDrag(function () { return _this.resetHandler(); }));
  44224. _this._register(_this._editor.onDidChangeCursorSelection(function (e) { return _this.onDidChangeCursorSelection(e); }));
  44225. _this._register(_this._editor.onDidChangeModel(function (e) { return _this.resetHandler(); }));
  44226. _this._register(_this._editor.onDidChangeModelContent(function () { return _this.resetHandler(); }));
  44227. _this._register(_this._editor.onDidScrollChange(function (e) {
  44228. if (e.scrollTopChanged || e.scrollLeftChanged) {
  44229. _this.resetHandler();
  44230. }
  44231. }));
  44232. return _this;
  44233. }
  44234. ClickLinkGesture.prototype.onDidChangeCursorSelection = function (e) {
  44235. if (e.selection && e.selection.startColumn !== e.selection.endColumn) {
  44236. this.resetHandler(); // immediately stop this feature if the user starts to select (https://github.com/Microsoft/vscode/issues/7827)
  44237. }
  44238. };
  44239. ClickLinkGesture.prototype.onEditorMouseMove = function (mouseEvent) {
  44240. this.lastMouseMoveEvent = mouseEvent;
  44241. this._onMouseMoveOrRelevantKeyDown.fire([mouseEvent, null]);
  44242. };
  44243. ClickLinkGesture.prototype.onEditorMouseDown = function (mouseEvent) {
  44244. // We need to record if we had the trigger key on mouse down because someone might select something in the editor
  44245. // holding the mouse down and then while mouse is down start to press Ctrl/Cmd to start a copy operation and then
  44246. // release the mouse button without wanting to do the navigation.
  44247. // With this flag we prevent goto definition if the mouse was down before the trigger key was pressed.
  44248. this.hasTriggerKeyOnMouseDown = mouseEvent.hasTriggerModifier;
  44249. };
  44250. ClickLinkGesture.prototype.onEditorMouseUp = function (mouseEvent) {
  44251. if (this.hasTriggerKeyOnMouseDown) {
  44252. this._onExecute.fire(mouseEvent);
  44253. }
  44254. };
  44255. ClickLinkGesture.prototype.onEditorKeyDown = function (e) {
  44256. if (this.lastMouseMoveEvent
  44257. && (e.keyCodeIsTriggerKey // User just pressed Ctrl/Cmd (normal goto definition)
  44258. || (e.keyCodeIsSideBySideKey && e.hasTriggerModifier) // User pressed Ctrl/Cmd+Alt (goto definition to the side)
  44259. )) {
  44260. this._onMouseMoveOrRelevantKeyDown.fire([this.lastMouseMoveEvent, e]);
  44261. }
  44262. else if (e.hasTriggerModifier) {
  44263. this._onCancel.fire(); // remove decorations if user holds another key with ctrl/cmd to prevent accident goto declaration
  44264. }
  44265. };
  44266. ClickLinkGesture.prototype.onEditorKeyUp = function (e) {
  44267. if (e.keyCodeIsTriggerKey) {
  44268. this._onCancel.fire();
  44269. }
  44270. };
  44271. ClickLinkGesture.prototype.resetHandler = function () {
  44272. this.lastMouseMoveEvent = null;
  44273. this.hasTriggerKeyOnMouseDown = false;
  44274. this._onCancel.fire();
  44275. };
  44276. return ClickLinkGesture;
  44277. }(lifecycle_1.Disposable));
  44278. exports.ClickLinkGesture = ClickLinkGesture;
  44279. });
  44280. /*---------------------------------------------------------------------------------------------
  44281. * Copyright (c) Microsoft Corporation. All rights reserved.
  44282. * Licensed under the MIT License. See License.txt in the project root for license information.
  44283. *--------------------------------------------------------------------------------------------*/
  44284. define(__m[200/*vs/editor/contrib/hover/hoverOperation*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,10/*vs/base/common/errors*/]), function (require, exports, async_1, errors_1) {
  44285. "use strict";
  44286. Object.defineProperty(exports, "__esModule", { value: true });
  44287. var HoverOperation = /** @class */ (function () {
  44288. function HoverOperation(computer, success, error, progress, hoverTime) {
  44289. var _this = this;
  44290. this._computer = computer;
  44291. this._state = 0 /* IDLE */;
  44292. this._hoverTime = hoverTime;
  44293. this._firstWaitScheduler = new async_1.RunOnceScheduler(function () { return _this._triggerAsyncComputation(); }, 0);
  44294. this._secondWaitScheduler = new async_1.RunOnceScheduler(function () { return _this._triggerSyncComputation(); }, 0);
  44295. this._loadingMessageScheduler = new async_1.RunOnceScheduler(function () { return _this._showLoadingMessage(); }, 0);
  44296. this._asyncComputationPromise = null;
  44297. this._asyncComputationPromiseDone = false;
  44298. this._completeCallback = success;
  44299. this._errorCallback = error;
  44300. this._progressCallback = progress;
  44301. }
  44302. HoverOperation.prototype.setHoverTime = function (hoverTime) {
  44303. this._hoverTime = hoverTime;
  44304. };
  44305. HoverOperation.prototype._firstWaitTime = function () {
  44306. return this._hoverTime / 2;
  44307. };
  44308. HoverOperation.prototype._secondWaitTime = function () {
  44309. return this._hoverTime / 2;
  44310. };
  44311. HoverOperation.prototype._loadingMessageTime = function () {
  44312. return 3 * this._hoverTime;
  44313. };
  44314. HoverOperation.prototype._triggerAsyncComputation = function () {
  44315. var _this = this;
  44316. this._state = 2 /* SECOND_WAIT */;
  44317. this._secondWaitScheduler.schedule(this._secondWaitTime());
  44318. if (this._computer.computeAsync) {
  44319. this._asyncComputationPromiseDone = false;
  44320. this._asyncComputationPromise = async_1.createCancelablePromise(function (token) { return _this._computer.computeAsync(token); });
  44321. this._asyncComputationPromise.then(function (asyncResult) {
  44322. _this._asyncComputationPromiseDone = true;
  44323. _this._withAsyncResult(asyncResult);
  44324. }, function (e) { return _this._onError(e); });
  44325. }
  44326. else {
  44327. this._asyncComputationPromiseDone = true;
  44328. }
  44329. };
  44330. HoverOperation.prototype._triggerSyncComputation = function () {
  44331. if (this._computer.computeSync) {
  44332. this._computer.onResult(this._computer.computeSync(), true);
  44333. }
  44334. if (this._asyncComputationPromiseDone) {
  44335. this._state = 0 /* IDLE */;
  44336. this._onComplete(this._computer.getResult());
  44337. }
  44338. else {
  44339. this._state = 3 /* WAITING_FOR_ASYNC_COMPUTATION */;
  44340. this._onProgress(this._computer.getResult());
  44341. }
  44342. };
  44343. HoverOperation.prototype._showLoadingMessage = function () {
  44344. if (this._state === 3 /* WAITING_FOR_ASYNC_COMPUTATION */) {
  44345. this._onProgress(this._computer.getResultWithLoadingMessage());
  44346. }
  44347. };
  44348. HoverOperation.prototype._withAsyncResult = function (asyncResult) {
  44349. if (asyncResult) {
  44350. this._computer.onResult(asyncResult, false);
  44351. }
  44352. if (this._state === 3 /* WAITING_FOR_ASYNC_COMPUTATION */) {
  44353. this._state = 0 /* IDLE */;
  44354. this._onComplete(this._computer.getResult());
  44355. }
  44356. };
  44357. HoverOperation.prototype._onComplete = function (value) {
  44358. if (this._completeCallback) {
  44359. this._completeCallback(value);
  44360. }
  44361. };
  44362. HoverOperation.prototype._onError = function (error) {
  44363. if (this._errorCallback) {
  44364. this._errorCallback(error);
  44365. }
  44366. else {
  44367. errors_1.onUnexpectedError(error);
  44368. }
  44369. };
  44370. HoverOperation.prototype._onProgress = function (value) {
  44371. if (this._progressCallback) {
  44372. this._progressCallback(value);
  44373. }
  44374. };
  44375. HoverOperation.prototype.start = function (mode) {
  44376. if (mode === 0 /* Delayed */) {
  44377. if (this._state === 0 /* IDLE */) {
  44378. this._state = 1 /* FIRST_WAIT */;
  44379. this._firstWaitScheduler.schedule(this._firstWaitTime());
  44380. this._loadingMessageScheduler.schedule(this._loadingMessageTime());
  44381. }
  44382. }
  44383. else {
  44384. switch (this._state) {
  44385. case 0 /* IDLE */:
  44386. this._triggerAsyncComputation();
  44387. this._secondWaitScheduler.cancel();
  44388. this._triggerSyncComputation();
  44389. break;
  44390. case 2 /* SECOND_WAIT */:
  44391. this._secondWaitScheduler.cancel();
  44392. this._triggerSyncComputation();
  44393. break;
  44394. }
  44395. }
  44396. };
  44397. HoverOperation.prototype.cancel = function () {
  44398. this._loadingMessageScheduler.cancel();
  44399. if (this._state === 1 /* FIRST_WAIT */) {
  44400. this._firstWaitScheduler.cancel();
  44401. }
  44402. if (this._state === 2 /* SECOND_WAIT */) {
  44403. this._secondWaitScheduler.cancel();
  44404. if (this._asyncComputationPromise) {
  44405. this._asyncComputationPromise.cancel();
  44406. this._asyncComputationPromise = null;
  44407. }
  44408. }
  44409. if (this._state === 3 /* WAITING_FOR_ASYNC_COMPUTATION */) {
  44410. if (this._asyncComputationPromise) {
  44411. this._asyncComputationPromise.cancel();
  44412. this._asyncComputationPromise = null;
  44413. }
  44414. }
  44415. this._state = 0 /* IDLE */;
  44416. };
  44417. return HoverOperation;
  44418. }());
  44419. exports.HoverOperation = HoverOperation;
  44420. });
  44421. /*---------------------------------------------------------------------------------------------
  44422. * Copyright (c) Microsoft Corporation. All rights reserved.
  44423. * Licensed under the MIT License. See License.txt in the project root for license information.
  44424. *--------------------------------------------------------------------------------------------*/
  44425. var __spreadArrays = (this && this.__spreadArrays) || function () {
  44426. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  44427. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  44428. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  44429. r[k] = a[j];
  44430. return r;
  44431. };
  44432. define(__m[201/*vs/editor/contrib/hover/hoverWidgets*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,53/*vs/base/browser/ui/scrollbar/scrollableElement*/,47/*vs/base/browser/ui/widget*/]), function (require, exports, dom_1, scrollableElement_1, widget_1) {
  44433. "use strict";
  44434. Object.defineProperty(exports, "__esModule", { value: true });
  44435. var ContentHoverWidget = /** @class */ (function (_super) {
  44436. __extends(ContentHoverWidget, _super);
  44437. function ContentHoverWidget(id, editor) {
  44438. var _this = _super.call(this) || this;
  44439. // Editor.IContentWidget.allowEditorOverflow
  44440. _this.allowEditorOverflow = true;
  44441. _this._id = id;
  44442. _this._editor = editor;
  44443. _this._isVisible = false;
  44444. _this._stoleFocus = false;
  44445. _this._containerDomNode = document.createElement('div');
  44446. _this._containerDomNode.className = 'monaco-editor-hover hidden';
  44447. _this._containerDomNode.tabIndex = 0;
  44448. _this._domNode = document.createElement('div');
  44449. _this._domNode.className = 'monaco-editor-hover-content';
  44450. _this.scrollbar = new scrollableElement_1.DomScrollableElement(_this._domNode, {});
  44451. _this._register(_this.scrollbar);
  44452. _this._containerDomNode.appendChild(_this.scrollbar.getDomNode());
  44453. _this.onkeydown(_this._containerDomNode, function (e) {
  44454. if (e.equals(9 /* Escape */)) {
  44455. _this.hide();
  44456. }
  44457. });
  44458. _this._register(_this._editor.onDidChangeConfiguration(function (e) {
  44459. if (e.hasChanged(34 /* fontInfo */)) {
  44460. _this.updateFont();
  44461. }
  44462. }));
  44463. _this._editor.onDidLayoutChange(function (e) { return _this.layout(); });
  44464. _this.layout();
  44465. _this._editor.addContentWidget(_this);
  44466. _this._showAtPosition = null;
  44467. _this._showAtRange = null;
  44468. _this._stoleFocus = false;
  44469. return _this;
  44470. }
  44471. Object.defineProperty(ContentHoverWidget.prototype, "isVisible", {
  44472. get: function () {
  44473. return this._isVisible;
  44474. },
  44475. set: function (value) {
  44476. this._isVisible = value;
  44477. dom_1.toggleClass(this._containerDomNode, 'hidden', !this._isVisible);
  44478. },
  44479. enumerable: true,
  44480. configurable: true
  44481. });
  44482. ContentHoverWidget.prototype.getId = function () {
  44483. return this._id;
  44484. };
  44485. ContentHoverWidget.prototype.getDomNode = function () {
  44486. return this._containerDomNode;
  44487. };
  44488. ContentHoverWidget.prototype.showAt = function (position, range, focus) {
  44489. // Position has changed
  44490. this._showAtPosition = position;
  44491. this._showAtRange = range;
  44492. this.isVisible = true;
  44493. this._editor.layoutContentWidget(this);
  44494. // Simply force a synchronous render on the editor
  44495. // such that the widget does not really render with left = '0px'
  44496. this._editor.render();
  44497. this._stoleFocus = focus;
  44498. if (focus) {
  44499. this._containerDomNode.focus();
  44500. }
  44501. };
  44502. ContentHoverWidget.prototype.hide = function () {
  44503. if (!this.isVisible) {
  44504. return;
  44505. }
  44506. this.isVisible = false;
  44507. this._editor.layoutContentWidget(this);
  44508. if (this._stoleFocus) {
  44509. this._editor.focus();
  44510. }
  44511. };
  44512. ContentHoverWidget.prototype.getPosition = function () {
  44513. if (this.isVisible) {
  44514. return {
  44515. position: this._showAtPosition,
  44516. range: this._showAtRange,
  44517. preference: [
  44518. 1 /* ABOVE */,
  44519. 2 /* BELOW */
  44520. ]
  44521. };
  44522. }
  44523. return null;
  44524. };
  44525. ContentHoverWidget.prototype.dispose = function () {
  44526. this._editor.removeContentWidget(this);
  44527. _super.prototype.dispose.call(this);
  44528. };
  44529. ContentHoverWidget.prototype.updateFont = function () {
  44530. var _this = this;
  44531. var codeClasses = Array.prototype.slice.call(this._domNode.getElementsByClassName('code'));
  44532. codeClasses.forEach(function (node) { return _this._editor.applyFontInfo(node); });
  44533. };
  44534. ContentHoverWidget.prototype.updateContents = function (node) {
  44535. this._domNode.textContent = '';
  44536. this._domNode.appendChild(node);
  44537. this.updateFont();
  44538. this._editor.layoutContentWidget(this);
  44539. this.onContentsChange();
  44540. };
  44541. ContentHoverWidget.prototype.onContentsChange = function () {
  44542. this.scrollbar.scanDomNode();
  44543. };
  44544. ContentHoverWidget.prototype.layout = function () {
  44545. var height = Math.max(this._editor.getLayoutInfo().height / 4, 250);
  44546. var _a = this._editor.getOption(34 /* fontInfo */), fontSize = _a.fontSize, lineHeight = _a.lineHeight;
  44547. this._domNode.style.fontSize = fontSize + "px";
  44548. this._domNode.style.lineHeight = lineHeight + "px";
  44549. this._domNode.style.maxHeight = height + "px";
  44550. this._domNode.style.maxWidth = Math.max(this._editor.getLayoutInfo().width * 0.66, 500) + "px";
  44551. };
  44552. return ContentHoverWidget;
  44553. }(widget_1.Widget));
  44554. exports.ContentHoverWidget = ContentHoverWidget;
  44555. var GlyphHoverWidget = /** @class */ (function (_super) {
  44556. __extends(GlyphHoverWidget, _super);
  44557. function GlyphHoverWidget(id, editor) {
  44558. var _this = _super.call(this) || this;
  44559. _this._id = id;
  44560. _this._editor = editor;
  44561. _this._isVisible = false;
  44562. _this._domNode = document.createElement('div');
  44563. _this._domNode.className = 'monaco-editor-hover hidden';
  44564. _this._domNode.setAttribute('aria-hidden', 'true');
  44565. _this._domNode.setAttribute('role', 'presentation');
  44566. _this._showAtLineNumber = -1;
  44567. _this._register(_this._editor.onDidChangeConfiguration(function (e) {
  44568. if (e.hasChanged(34 /* fontInfo */)) {
  44569. _this.updateFont();
  44570. }
  44571. }));
  44572. _this._editor.addOverlayWidget(_this);
  44573. return _this;
  44574. }
  44575. Object.defineProperty(GlyphHoverWidget.prototype, "isVisible", {
  44576. get: function () {
  44577. return this._isVisible;
  44578. },
  44579. set: function (value) {
  44580. this._isVisible = value;
  44581. dom_1.toggleClass(this._domNode, 'hidden', !this._isVisible);
  44582. },
  44583. enumerable: true,
  44584. configurable: true
  44585. });
  44586. GlyphHoverWidget.prototype.getId = function () {
  44587. return this._id;
  44588. };
  44589. GlyphHoverWidget.prototype.getDomNode = function () {
  44590. return this._domNode;
  44591. };
  44592. GlyphHoverWidget.prototype.showAt = function (lineNumber) {
  44593. this._showAtLineNumber = lineNumber;
  44594. if (!this.isVisible) {
  44595. this.isVisible = true;
  44596. }
  44597. var editorLayout = this._editor.getLayoutInfo();
  44598. var topForLineNumber = this._editor.getTopForLineNumber(this._showAtLineNumber);
  44599. var editorScrollTop = this._editor.getScrollTop();
  44600. var lineHeight = this._editor.getOption(49 /* lineHeight */);
  44601. var nodeHeight = this._domNode.clientHeight;
  44602. var top = topForLineNumber - editorScrollTop - ((nodeHeight - lineHeight) / 2);
  44603. this._domNode.style.left = editorLayout.glyphMarginLeft + editorLayout.glyphMarginWidth + "px";
  44604. this._domNode.style.top = Math.max(Math.round(top), 0) + "px";
  44605. };
  44606. GlyphHoverWidget.prototype.hide = function () {
  44607. if (!this.isVisible) {
  44608. return;
  44609. }
  44610. this.isVisible = false;
  44611. };
  44612. GlyphHoverWidget.prototype.getPosition = function () {
  44613. return null;
  44614. };
  44615. GlyphHoverWidget.prototype.dispose = function () {
  44616. this._editor.removeOverlayWidget(this);
  44617. _super.prototype.dispose.call(this);
  44618. };
  44619. GlyphHoverWidget.prototype.updateFont = function () {
  44620. var _this = this;
  44621. var codeTags = Array.prototype.slice.call(this._domNode.getElementsByTagName('code'));
  44622. var codeClasses = Array.prototype.slice.call(this._domNode.getElementsByClassName('code'));
  44623. __spreadArrays(codeTags, codeClasses).forEach(function (node) { return _this._editor.applyFontInfo(node); });
  44624. };
  44625. GlyphHoverWidget.prototype.updateContents = function (node) {
  44626. this._domNode.textContent = '';
  44627. this._domNode.appendChild(node);
  44628. this.updateFont();
  44629. };
  44630. return GlyphHoverWidget;
  44631. }(widget_1.Widget));
  44632. exports.GlyphHoverWidget = GlyphHoverWidget;
  44633. });
  44634. /*---------------------------------------------------------------------------------------------
  44635. * Copyright (c) Microsoft Corporation. All rights reserved.
  44636. * Licensed under the MIT License. See License.txt in the project root for license information.
  44637. *--------------------------------------------------------------------------------------------*/
  44638. define(__m[384/*vs/editor/contrib/inPlaceReplace/inPlaceReplaceCommand*/], __M([0/*require*/,1/*exports*/,22/*vs/editor/common/core/selection*/]), function (require, exports, selection_1) {
  44639. "use strict";
  44640. Object.defineProperty(exports, "__esModule", { value: true });
  44641. var InPlaceReplaceCommand = /** @class */ (function () {
  44642. function InPlaceReplaceCommand(editRange, originalSelection, text) {
  44643. this._editRange = editRange;
  44644. this._originalSelection = originalSelection;
  44645. this._text = text;
  44646. }
  44647. InPlaceReplaceCommand.prototype.getEditOperations = function (model, builder) {
  44648. builder.addTrackedEditOperation(this._editRange, this._text);
  44649. };
  44650. InPlaceReplaceCommand.prototype.computeCursorState = function (model, helper) {
  44651. var inverseEditOperations = helper.getInverseEditOperations();
  44652. var srcRange = inverseEditOperations[0].range;
  44653. if (!this._originalSelection.isEmpty()) {
  44654. // Preserve selection and extends to typed text
  44655. return new selection_1.Selection(srcRange.endLineNumber, srcRange.endColumn - this._text.length, srcRange.endLineNumber, srcRange.endColumn);
  44656. }
  44657. return new selection_1.Selection(srcRange.endLineNumber, Math.min(this._originalSelection.positionColumn, srcRange.endColumn), srcRange.endLineNumber, Math.min(this._originalSelection.positionColumn, srcRange.endColumn));
  44658. };
  44659. return InPlaceReplaceCommand;
  44660. }());
  44661. exports.InPlaceReplaceCommand = InPlaceReplaceCommand;
  44662. });
  44663. /*---------------------------------------------------------------------------------------------
  44664. * Copyright (c) Microsoft Corporation. All rights reserved.
  44665. * Licensed under the MIT License. See License.txt in the project root for license information.
  44666. *--------------------------------------------------------------------------------------------*/
  44667. define(__m[385/*vs/editor/contrib/indentation/indentUtils*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  44668. "use strict";
  44669. Object.defineProperty(exports, "__esModule", { value: true });
  44670. function getSpaceCnt(str, tabSize) {
  44671. var spacesCnt = 0;
  44672. for (var i = 0; i < str.length; i++) {
  44673. if (str.charAt(i) === '\t') {
  44674. spacesCnt += tabSize;
  44675. }
  44676. else {
  44677. spacesCnt++;
  44678. }
  44679. }
  44680. return spacesCnt;
  44681. }
  44682. exports.getSpaceCnt = getSpaceCnt;
  44683. function generateIndent(spacesCnt, tabSize, insertSpaces) {
  44684. spacesCnt = spacesCnt < 0 ? 0 : spacesCnt;
  44685. var result = '';
  44686. if (!insertSpaces) {
  44687. var tabsCnt = Math.floor(spacesCnt / tabSize);
  44688. spacesCnt = spacesCnt % tabSize;
  44689. for (var i = 0; i < tabsCnt; i++) {
  44690. result += '\t';
  44691. }
  44692. }
  44693. for (var i = 0; i < spacesCnt; i++) {
  44694. result += ' ';
  44695. }
  44696. return result;
  44697. }
  44698. exports.generateIndent = generateIndent;
  44699. });
  44700. /*---------------------------------------------------------------------------------------------
  44701. * Copyright (c) Microsoft Corporation. All rights reserved.
  44702. * Licensed under the MIT License. See License.txt in the project root for license information.
  44703. *--------------------------------------------------------------------------------------------*/
  44704. define(__m[386/*vs/editor/contrib/linesOperations/copyLinesCommand*/], __M([0/*require*/,1/*exports*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/]), function (require, exports, range_1, selection_1) {
  44705. "use strict";
  44706. Object.defineProperty(exports, "__esModule", { value: true });
  44707. var CopyLinesCommand = /** @class */ (function () {
  44708. function CopyLinesCommand(selection, isCopyingDown) {
  44709. this._selection = selection;
  44710. this._isCopyingDown = isCopyingDown;
  44711. this._selectionDirection = 0 /* LTR */;
  44712. this._selectionId = null;
  44713. this._startLineNumberDelta = 0;
  44714. this._endLineNumberDelta = 0;
  44715. }
  44716. CopyLinesCommand.prototype.getEditOperations = function (model, builder) {
  44717. var s = this._selection;
  44718. this._startLineNumberDelta = 0;
  44719. this._endLineNumberDelta = 0;
  44720. if (s.startLineNumber < s.endLineNumber && s.endColumn === 1) {
  44721. this._endLineNumberDelta = 1;
  44722. s = s.setEndPosition(s.endLineNumber - 1, model.getLineMaxColumn(s.endLineNumber - 1));
  44723. }
  44724. var sourceLines = [];
  44725. for (var i = s.startLineNumber; i <= s.endLineNumber; i++) {
  44726. sourceLines.push(model.getLineContent(i));
  44727. }
  44728. var sourceText = sourceLines.join('\n');
  44729. if (sourceText === '') {
  44730. // Duplicating empty line
  44731. if (this._isCopyingDown) {
  44732. this._startLineNumberDelta++;
  44733. this._endLineNumberDelta++;
  44734. }
  44735. }
  44736. if (!this._isCopyingDown) {
  44737. builder.addEditOperation(new range_1.Range(s.endLineNumber, model.getLineMaxColumn(s.endLineNumber), s.endLineNumber, model.getLineMaxColumn(s.endLineNumber)), '\n' + sourceText);
  44738. }
  44739. else {
  44740. builder.addEditOperation(new range_1.Range(s.startLineNumber, 1, s.startLineNumber, 1), sourceText + '\n');
  44741. }
  44742. this._selectionId = builder.trackSelection(s);
  44743. this._selectionDirection = this._selection.getDirection();
  44744. };
  44745. CopyLinesCommand.prototype.computeCursorState = function (model, helper) {
  44746. var result = helper.getTrackedSelection(this._selectionId);
  44747. if (this._startLineNumberDelta !== 0 || this._endLineNumberDelta !== 0) {
  44748. var startLineNumber = result.startLineNumber;
  44749. var startColumn = result.startColumn;
  44750. var endLineNumber = result.endLineNumber;
  44751. var endColumn = result.endColumn;
  44752. if (this._startLineNumberDelta !== 0) {
  44753. startLineNumber = startLineNumber + this._startLineNumberDelta;
  44754. startColumn = 1;
  44755. }
  44756. if (this._endLineNumberDelta !== 0) {
  44757. endLineNumber = endLineNumber + this._endLineNumberDelta;
  44758. endColumn = 1;
  44759. }
  44760. result = selection_1.Selection.createWithDirection(startLineNumber, startColumn, endLineNumber, endColumn, this._selectionDirection);
  44761. }
  44762. return result;
  44763. };
  44764. return CopyLinesCommand;
  44765. }());
  44766. exports.CopyLinesCommand = CopyLinesCommand;
  44767. });
  44768. /*---------------------------------------------------------------------------------------------
  44769. * Copyright (c) Microsoft Corporation. All rights reserved.
  44770. * Licensed under the MIT License. See License.txt in the project root for license information.
  44771. *--------------------------------------------------------------------------------------------*/
  44772. define(__m[387/*vs/editor/contrib/linesOperations/sortLinesCommand*/], __M([0/*require*/,1/*exports*/,58/*vs/editor/common/core/editOperation*/,3/*vs/editor/common/core/range*/]), function (require, exports, editOperation_1, range_1) {
  44773. "use strict";
  44774. Object.defineProperty(exports, "__esModule", { value: true });
  44775. var SortLinesCommand = /** @class */ (function () {
  44776. function SortLinesCommand(selection, descending) {
  44777. this.selection = selection;
  44778. this.descending = descending;
  44779. this.selectionId = null;
  44780. }
  44781. SortLinesCommand.getCollator = function () {
  44782. if (!SortLinesCommand._COLLATOR) {
  44783. SortLinesCommand._COLLATOR = new Intl.Collator();
  44784. }
  44785. return SortLinesCommand._COLLATOR;
  44786. };
  44787. SortLinesCommand.prototype.getEditOperations = function (model, builder) {
  44788. var op = sortLines(model, this.selection, this.descending);
  44789. if (op) {
  44790. builder.addEditOperation(op.range, op.text);
  44791. }
  44792. this.selectionId = builder.trackSelection(this.selection);
  44793. };
  44794. SortLinesCommand.prototype.computeCursorState = function (model, helper) {
  44795. return helper.getTrackedSelection(this.selectionId);
  44796. };
  44797. SortLinesCommand.canRun = function (model, selection, descending) {
  44798. if (model === null) {
  44799. return false;
  44800. }
  44801. var data = getSortData(model, selection, descending);
  44802. if (!data) {
  44803. return false;
  44804. }
  44805. for (var i = 0, len = data.before.length; i < len; i++) {
  44806. if (data.before[i] !== data.after[i]) {
  44807. return true;
  44808. }
  44809. }
  44810. return false;
  44811. };
  44812. SortLinesCommand._COLLATOR = null;
  44813. return SortLinesCommand;
  44814. }());
  44815. exports.SortLinesCommand = SortLinesCommand;
  44816. function getSortData(model, selection, descending) {
  44817. var startLineNumber = selection.startLineNumber;
  44818. var endLineNumber = selection.endLineNumber;
  44819. if (selection.endColumn === 1) {
  44820. endLineNumber--;
  44821. }
  44822. // Nothing to sort if user didn't select anything.
  44823. if (startLineNumber >= endLineNumber) {
  44824. return null;
  44825. }
  44826. var linesToSort = [];
  44827. // Get the contents of the selection to be sorted.
  44828. for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
  44829. linesToSort.push(model.getLineContent(lineNumber));
  44830. }
  44831. var sorted = linesToSort.slice(0);
  44832. sorted.sort(SortLinesCommand.getCollator().compare);
  44833. // If descending, reverse the order.
  44834. if (descending === true) {
  44835. sorted = sorted.reverse();
  44836. }
  44837. return {
  44838. startLineNumber: startLineNumber,
  44839. endLineNumber: endLineNumber,
  44840. before: linesToSort,
  44841. after: sorted
  44842. };
  44843. }
  44844. /**
  44845. * Generate commands for sorting lines on a model.
  44846. */
  44847. function sortLines(model, selection, descending) {
  44848. var data = getSortData(model, selection, descending);
  44849. if (!data) {
  44850. return null;
  44851. }
  44852. return editOperation_1.EditOperation.replace(new range_1.Range(data.startLineNumber, 1, data.endLineNumber, model.getLineMaxColumn(data.endLineNumber)), data.after.join('\n'));
  44853. }
  44854. });
  44855. /*---------------------------------------------------------------------------------------------
  44856. * Copyright (c) Microsoft Corporation. All rights reserved.
  44857. * Licensed under the MIT License. See License.txt in the project root for license information.
  44858. *--------------------------------------------------------------------------------------------*/
  44859. define(__m[202/*vs/editor/contrib/smartSelect/bracketSelections*/], __M([0/*require*/,1/*exports*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,76/*vs/base/common/linkedList*/]), function (require, exports, position_1, range_1, linkedList_1) {
  44860. "use strict";
  44861. Object.defineProperty(exports, "__esModule", { value: true });
  44862. var BracketSelectionRangeProvider = /** @class */ (function () {
  44863. function BracketSelectionRangeProvider() {
  44864. }
  44865. BracketSelectionRangeProvider.prototype.provideSelectionRanges = function (model, positions) {
  44866. return __awaiter(this, void 0, void 0, function () {
  44867. var result, _loop_1, _i, positions_1, position;
  44868. return __generator(this, function (_a) {
  44869. switch (_a.label) {
  44870. case 0:
  44871. result = [];
  44872. _loop_1 = function (position) {
  44873. var bucket, ranges;
  44874. return __generator(this, function (_a) {
  44875. switch (_a.label) {
  44876. case 0:
  44877. bucket = [];
  44878. result.push(bucket);
  44879. ranges = new Map();
  44880. return [4 /*yield*/, new Promise(function (resolve) { return BracketSelectionRangeProvider._bracketsRightYield(resolve, 0, model, position, ranges); })];
  44881. case 1:
  44882. _a.sent();
  44883. return [4 /*yield*/, new Promise(function (resolve) { return BracketSelectionRangeProvider._bracketsLeftYield(resolve, 0, model, position, ranges, bucket); })];
  44884. case 2:
  44885. _a.sent();
  44886. return [2 /*return*/];
  44887. }
  44888. });
  44889. };
  44890. _i = 0, positions_1 = positions;
  44891. _a.label = 1;
  44892. case 1:
  44893. if (!(_i < positions_1.length)) return [3 /*break*/, 4];
  44894. position = positions_1[_i];
  44895. return [5 /*yield**/, _loop_1(position)];
  44896. case 2:
  44897. _a.sent();
  44898. _a.label = 3;
  44899. case 3:
  44900. _i++;
  44901. return [3 /*break*/, 1];
  44902. case 4: return [2 /*return*/, result];
  44903. }
  44904. });
  44905. });
  44906. };
  44907. BracketSelectionRangeProvider._bracketsRightYield = function (resolve, round, model, pos, ranges) {
  44908. var counts = new Map();
  44909. var t1 = Date.now();
  44910. while (true) {
  44911. if (round >= BracketSelectionRangeProvider._maxRounds) {
  44912. resolve();
  44913. break;
  44914. }
  44915. if (!pos) {
  44916. resolve();
  44917. break;
  44918. }
  44919. var bracket = model.findNextBracket(pos);
  44920. if (!bracket) {
  44921. resolve();
  44922. break;
  44923. }
  44924. var d = Date.now() - t1;
  44925. if (d > BracketSelectionRangeProvider._maxDuration) {
  44926. setTimeout(function () { return BracketSelectionRangeProvider._bracketsRightYield(resolve, round + 1, model, pos, ranges); });
  44927. break;
  44928. }
  44929. var key = bracket.close[0];
  44930. if (bracket.isOpen) {
  44931. // wait for closing
  44932. var val = counts.has(key) ? counts.get(key) : 0;
  44933. counts.set(key, val + 1);
  44934. }
  44935. else {
  44936. // process closing
  44937. var val = counts.has(key) ? counts.get(key) : 0;
  44938. val -= 1;
  44939. counts.set(key, Math.max(0, val));
  44940. if (val < 0) {
  44941. var list = ranges.get(key);
  44942. if (!list) {
  44943. list = new linkedList_1.LinkedList();
  44944. ranges.set(key, list);
  44945. }
  44946. list.push(bracket.range);
  44947. }
  44948. }
  44949. pos = bracket.range.getEndPosition();
  44950. }
  44951. };
  44952. BracketSelectionRangeProvider._bracketsLeftYield = function (resolve, round, model, pos, ranges, bucket) {
  44953. var counts = new Map();
  44954. var t1 = Date.now();
  44955. while (true) {
  44956. if (round >= BracketSelectionRangeProvider._maxRounds && ranges.size === 0) {
  44957. resolve();
  44958. break;
  44959. }
  44960. if (!pos) {
  44961. resolve();
  44962. break;
  44963. }
  44964. var bracket = model.findPrevBracket(pos);
  44965. if (!bracket) {
  44966. resolve();
  44967. break;
  44968. }
  44969. var d = Date.now() - t1;
  44970. if (d > BracketSelectionRangeProvider._maxDuration) {
  44971. setTimeout(function () { return BracketSelectionRangeProvider._bracketsLeftYield(resolve, round + 1, model, pos, ranges, bucket); });
  44972. break;
  44973. }
  44974. var key = bracket.close[0];
  44975. if (!bracket.isOpen) {
  44976. // wait for opening
  44977. var val = counts.has(key) ? counts.get(key) : 0;
  44978. counts.set(key, val + 1);
  44979. }
  44980. else {
  44981. // opening
  44982. var val = counts.has(key) ? counts.get(key) : 0;
  44983. val -= 1;
  44984. counts.set(key, Math.max(0, val));
  44985. if (val < 0) {
  44986. var list = ranges.get(key);
  44987. if (list) {
  44988. var closing = list.shift();
  44989. if (list.size === 0) {
  44990. ranges.delete(key);
  44991. }
  44992. var innerBracket = range_1.Range.fromPositions(bracket.range.getEndPosition(), closing.getStartPosition());
  44993. var outerBracket = range_1.Range.fromPositions(bracket.range.getStartPosition(), closing.getEndPosition());
  44994. bucket.push({ range: innerBracket });
  44995. bucket.push({ range: outerBracket });
  44996. BracketSelectionRangeProvider._addBracketLeading(model, outerBracket, bucket);
  44997. }
  44998. }
  44999. }
  45000. pos = bracket.range.getStartPosition();
  45001. }
  45002. };
  45003. BracketSelectionRangeProvider._addBracketLeading = function (model, bracket, bucket) {
  45004. if (bracket.startLineNumber === bracket.endLineNumber) {
  45005. return;
  45006. }
  45007. // xxxxxxxx {
  45008. //
  45009. // }
  45010. var startLine = bracket.startLineNumber;
  45011. var column = model.getLineFirstNonWhitespaceColumn(startLine);
  45012. if (column !== 0 && column !== bracket.startColumn) {
  45013. bucket.push({ range: range_1.Range.fromPositions(new position_1.Position(startLine, column), bracket.getEndPosition()) });
  45014. bucket.push({ range: range_1.Range.fromPositions(new position_1.Position(startLine, 1), bracket.getEndPosition()) });
  45015. }
  45016. // xxxxxxxx
  45017. // {
  45018. //
  45019. // }
  45020. var aboveLine = startLine - 1;
  45021. if (aboveLine > 0) {
  45022. var column_1 = model.getLineFirstNonWhitespaceColumn(aboveLine);
  45023. if (column_1 === bracket.startColumn && column_1 !== model.getLineLastNonWhitespaceColumn(aboveLine)) {
  45024. bucket.push({ range: range_1.Range.fromPositions(new position_1.Position(aboveLine, column_1), bracket.getEndPosition()) });
  45025. bucket.push({ range: range_1.Range.fromPositions(new position_1.Position(aboveLine, 1), bracket.getEndPosition()) });
  45026. }
  45027. }
  45028. };
  45029. BracketSelectionRangeProvider._maxDuration = 30;
  45030. BracketSelectionRangeProvider._maxRounds = 2;
  45031. return BracketSelectionRangeProvider;
  45032. }());
  45033. exports.BracketSelectionRangeProvider = BracketSelectionRangeProvider;
  45034. });
  45035. /*---------------------------------------------------------------------------------------------
  45036. * Copyright (c) Microsoft Corporation. All rights reserved.
  45037. * Licensed under the MIT License. See License.txt in the project root for license information.
  45038. *--------------------------------------------------------------------------------------------*/
  45039. define(__m[388/*vs/editor/contrib/smartSelect/wordSelections*/], __M([0/*require*/,1/*exports*/,3/*vs/editor/common/core/range*/,5/*vs/base/common/strings*/]), function (require, exports, range_1, strings_1) {
  45040. "use strict";
  45041. Object.defineProperty(exports, "__esModule", { value: true });
  45042. var WordSelectionRangeProvider = /** @class */ (function () {
  45043. function WordSelectionRangeProvider() {
  45044. }
  45045. WordSelectionRangeProvider.prototype.provideSelectionRanges = function (model, positions) {
  45046. var result = [];
  45047. for (var _i = 0, positions_1 = positions; _i < positions_1.length; _i++) {
  45048. var position = positions_1[_i];
  45049. var bucket = [];
  45050. result.push(bucket);
  45051. this._addInWordRanges(bucket, model, position);
  45052. this._addWordRanges(bucket, model, position);
  45053. this._addWhitespaceLine(bucket, model, position);
  45054. bucket.push({ range: model.getFullModelRange() });
  45055. }
  45056. return result;
  45057. };
  45058. WordSelectionRangeProvider.prototype._addInWordRanges = function (bucket, model, pos) {
  45059. var obj = model.getWordAtPosition(pos);
  45060. if (!obj) {
  45061. return;
  45062. }
  45063. var word = obj.word, startColumn = obj.startColumn;
  45064. var offset = pos.column - startColumn;
  45065. var start = offset;
  45066. var end = offset;
  45067. var lastCh = 0;
  45068. // LEFT anchor (start)
  45069. for (; start >= 0; start--) {
  45070. var ch = word.charCodeAt(start);
  45071. if (ch === 95 /* Underline */ || ch === 45 /* Dash */) {
  45072. // foo-bar OR foo_bar
  45073. break;
  45074. }
  45075. else if (strings_1.isLowerAsciiLetter(ch) && strings_1.isUpperAsciiLetter(lastCh)) {
  45076. // fooBar
  45077. break;
  45078. }
  45079. lastCh = ch;
  45080. }
  45081. start += 1;
  45082. // RIGHT anchor (end)
  45083. for (; end < word.length; end++) {
  45084. var ch = word.charCodeAt(end);
  45085. if (strings_1.isUpperAsciiLetter(ch) && strings_1.isLowerAsciiLetter(lastCh)) {
  45086. // fooBar
  45087. break;
  45088. }
  45089. else if (ch === 95 /* Underline */ || ch === 45 /* Dash */) {
  45090. // foo-bar OR foo_bar
  45091. break;
  45092. }
  45093. lastCh = ch;
  45094. }
  45095. if (start < end) {
  45096. bucket.push({ range: new range_1.Range(pos.lineNumber, startColumn + start, pos.lineNumber, startColumn + end) });
  45097. }
  45098. };
  45099. WordSelectionRangeProvider.prototype._addWordRanges = function (bucket, model, pos) {
  45100. var word = model.getWordAtPosition(pos);
  45101. if (word) {
  45102. bucket.push({ range: new range_1.Range(pos.lineNumber, word.startColumn, pos.lineNumber, word.endColumn) });
  45103. }
  45104. };
  45105. WordSelectionRangeProvider.prototype._addWhitespaceLine = function (bucket, model, pos) {
  45106. if (model.getLineLength(pos.lineNumber) > 0
  45107. && model.getLineFirstNonWhitespaceColumn(pos.lineNumber) === 0
  45108. && model.getLineLastNonWhitespaceColumn(pos.lineNumber) === 0) {
  45109. bucket.push({ range: new range_1.Range(pos.lineNumber, 1, pos.lineNumber, model.getLineMaxColumn(pos.lineNumber)) });
  45110. }
  45111. };
  45112. return WordSelectionRangeProvider;
  45113. }());
  45114. exports.WordSelectionRangeProvider = WordSelectionRangeProvider;
  45115. });
  45116. /*---------------------------------------------------------------------------------------------
  45117. * Copyright (c) Microsoft Corporation. All rights reserved.
  45118. * Licensed under the MIT License. See License.txt in the project root for license information.
  45119. *--------------------------------------------------------------------------------------------*/
  45120. var __spreadArrays = (this && this.__spreadArrays) || function () {
  45121. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  45122. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  45123. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  45124. r[k] = a[j];
  45125. return r;
  45126. };
  45127. define(__m[151/*vs/editor/contrib/snippet/snippetParser*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  45128. "use strict";
  45129. var _a;
  45130. Object.defineProperty(exports, "__esModule", { value: true });
  45131. var Scanner = /** @class */ (function () {
  45132. function Scanner() {
  45133. this.value = '';
  45134. this.pos = 0;
  45135. }
  45136. Scanner.isDigitCharacter = function (ch) {
  45137. return ch >= 48 /* Digit0 */ && ch <= 57 /* Digit9 */;
  45138. };
  45139. Scanner.isVariableCharacter = function (ch) {
  45140. return ch === 95 /* Underline */
  45141. || (ch >= 97 /* a */ && ch <= 122 /* z */)
  45142. || (ch >= 65 /* A */ && ch <= 90 /* Z */);
  45143. };
  45144. Scanner.prototype.text = function (value) {
  45145. this.value = value;
  45146. this.pos = 0;
  45147. };
  45148. Scanner.prototype.tokenText = function (token) {
  45149. return this.value.substr(token.pos, token.len);
  45150. };
  45151. Scanner.prototype.next = function () {
  45152. if (this.pos >= this.value.length) {
  45153. return { type: 14 /* EOF */, pos: this.pos, len: 0 };
  45154. }
  45155. var pos = this.pos;
  45156. var len = 0;
  45157. var ch = this.value.charCodeAt(pos);
  45158. var type;
  45159. // static types
  45160. type = Scanner._table[ch];
  45161. if (typeof type === 'number') {
  45162. this.pos += 1;
  45163. return { type: type, pos: pos, len: 1 };
  45164. }
  45165. // number
  45166. if (Scanner.isDigitCharacter(ch)) {
  45167. type = 8 /* Int */;
  45168. do {
  45169. len += 1;
  45170. ch = this.value.charCodeAt(pos + len);
  45171. } while (Scanner.isDigitCharacter(ch));
  45172. this.pos += len;
  45173. return { type: type, pos: pos, len: len };
  45174. }
  45175. // variable name
  45176. if (Scanner.isVariableCharacter(ch)) {
  45177. type = 9 /* VariableName */;
  45178. do {
  45179. ch = this.value.charCodeAt(pos + (++len));
  45180. } while (Scanner.isVariableCharacter(ch) || Scanner.isDigitCharacter(ch));
  45181. this.pos += len;
  45182. return { type: type, pos: pos, len: len };
  45183. }
  45184. // format
  45185. type = 10 /* Format */;
  45186. do {
  45187. len += 1;
  45188. ch = this.value.charCodeAt(pos + len);
  45189. } while (!isNaN(ch)
  45190. && typeof Scanner._table[ch] === 'undefined' // not static token
  45191. && !Scanner.isDigitCharacter(ch) // not number
  45192. && !Scanner.isVariableCharacter(ch) // not variable
  45193. );
  45194. this.pos += len;
  45195. return { type: type, pos: pos, len: len };
  45196. };
  45197. Scanner._table = (_a = {},
  45198. _a[36 /* DollarSign */] = 0 /* Dollar */,
  45199. _a[58 /* Colon */] = 1 /* Colon */,
  45200. _a[44 /* Comma */] = 2 /* Comma */,
  45201. _a[123 /* OpenCurlyBrace */] = 3 /* CurlyOpen */,
  45202. _a[125 /* CloseCurlyBrace */] = 4 /* CurlyClose */,
  45203. _a[92 /* Backslash */] = 5 /* Backslash */,
  45204. _a[47 /* Slash */] = 6 /* Forwardslash */,
  45205. _a[124 /* Pipe */] = 7 /* Pipe */,
  45206. _a[43 /* Plus */] = 11 /* Plus */,
  45207. _a[45 /* Dash */] = 12 /* Dash */,
  45208. _a[63 /* QuestionMark */] = 13 /* QuestionMark */,
  45209. _a);
  45210. return Scanner;
  45211. }());
  45212. exports.Scanner = Scanner;
  45213. var Marker = /** @class */ (function () {
  45214. function Marker() {
  45215. this._children = [];
  45216. }
  45217. Marker.prototype.appendChild = function (child) {
  45218. if (child instanceof Text && this._children[this._children.length - 1] instanceof Text) {
  45219. // this and previous child are text -> merge them
  45220. this._children[this._children.length - 1].value += child.value;
  45221. }
  45222. else {
  45223. // normal adoption of child
  45224. child.parent = this;
  45225. this._children.push(child);
  45226. }
  45227. return this;
  45228. };
  45229. Marker.prototype.replace = function (child, others) {
  45230. var parent = child.parent;
  45231. var idx = parent.children.indexOf(child);
  45232. var newChildren = parent.children.slice(0);
  45233. newChildren.splice.apply(newChildren, __spreadArrays([idx, 1], others));
  45234. parent._children = newChildren;
  45235. (function _fixParent(children, parent) {
  45236. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  45237. var child_1 = children_1[_i];
  45238. child_1.parent = parent;
  45239. _fixParent(child_1.children, child_1);
  45240. }
  45241. })(others, parent);
  45242. };
  45243. Object.defineProperty(Marker.prototype, "children", {
  45244. get: function () {
  45245. return this._children;
  45246. },
  45247. enumerable: true,
  45248. configurable: true
  45249. });
  45250. Object.defineProperty(Marker.prototype, "snippet", {
  45251. get: function () {
  45252. var candidate = this;
  45253. while (true) {
  45254. if (!candidate) {
  45255. return undefined;
  45256. }
  45257. if (candidate instanceof TextmateSnippet) {
  45258. return candidate;
  45259. }
  45260. candidate = candidate.parent;
  45261. }
  45262. },
  45263. enumerable: true,
  45264. configurable: true
  45265. });
  45266. Marker.prototype.toString = function () {
  45267. return this.children.reduce(function (prev, cur) { return prev + cur.toString(); }, '');
  45268. };
  45269. Marker.prototype.len = function () {
  45270. return 0;
  45271. };
  45272. return Marker;
  45273. }());
  45274. exports.Marker = Marker;
  45275. var Text = /** @class */ (function (_super) {
  45276. __extends(Text, _super);
  45277. function Text(value) {
  45278. var _this_1 = _super.call(this) || this;
  45279. _this_1.value = value;
  45280. return _this_1;
  45281. }
  45282. Text.prototype.toString = function () {
  45283. return this.value;
  45284. };
  45285. Text.prototype.len = function () {
  45286. return this.value.length;
  45287. };
  45288. Text.prototype.clone = function () {
  45289. return new Text(this.value);
  45290. };
  45291. return Text;
  45292. }(Marker));
  45293. exports.Text = Text;
  45294. var TransformableMarker = /** @class */ (function (_super) {
  45295. __extends(TransformableMarker, _super);
  45296. function TransformableMarker() {
  45297. return _super !== null && _super.apply(this, arguments) || this;
  45298. }
  45299. return TransformableMarker;
  45300. }(Marker));
  45301. exports.TransformableMarker = TransformableMarker;
  45302. var Placeholder = /** @class */ (function (_super) {
  45303. __extends(Placeholder, _super);
  45304. function Placeholder(index) {
  45305. var _this_1 = _super.call(this) || this;
  45306. _this_1.index = index;
  45307. return _this_1;
  45308. }
  45309. Placeholder.compareByIndex = function (a, b) {
  45310. if (a.index === b.index) {
  45311. return 0;
  45312. }
  45313. else if (a.isFinalTabstop) {
  45314. return 1;
  45315. }
  45316. else if (b.isFinalTabstop) {
  45317. return -1;
  45318. }
  45319. else if (a.index < b.index) {
  45320. return -1;
  45321. }
  45322. else if (a.index > b.index) {
  45323. return 1;
  45324. }
  45325. else {
  45326. return 0;
  45327. }
  45328. };
  45329. Object.defineProperty(Placeholder.prototype, "isFinalTabstop", {
  45330. get: function () {
  45331. return this.index === 0;
  45332. },
  45333. enumerable: true,
  45334. configurable: true
  45335. });
  45336. Object.defineProperty(Placeholder.prototype, "choice", {
  45337. get: function () {
  45338. return this._children.length === 1 && this._children[0] instanceof Choice
  45339. ? this._children[0]
  45340. : undefined;
  45341. },
  45342. enumerable: true,
  45343. configurable: true
  45344. });
  45345. Placeholder.prototype.clone = function () {
  45346. var ret = new Placeholder(this.index);
  45347. if (this.transform) {
  45348. ret.transform = this.transform.clone();
  45349. }
  45350. ret._children = this.children.map(function (child) { return child.clone(); });
  45351. return ret;
  45352. };
  45353. return Placeholder;
  45354. }(TransformableMarker));
  45355. exports.Placeholder = Placeholder;
  45356. var Choice = /** @class */ (function (_super) {
  45357. __extends(Choice, _super);
  45358. function Choice() {
  45359. var _this_1 = _super !== null && _super.apply(this, arguments) || this;
  45360. _this_1.options = [];
  45361. return _this_1;
  45362. }
  45363. Choice.prototype.appendChild = function (marker) {
  45364. if (marker instanceof Text) {
  45365. marker.parent = this;
  45366. this.options.push(marker);
  45367. }
  45368. return this;
  45369. };
  45370. Choice.prototype.toString = function () {
  45371. return this.options[0].value;
  45372. };
  45373. Choice.prototype.len = function () {
  45374. return this.options[0].len();
  45375. };
  45376. Choice.prototype.clone = function () {
  45377. var ret = new Choice();
  45378. this.options.forEach(ret.appendChild, ret);
  45379. return ret;
  45380. };
  45381. return Choice;
  45382. }(Marker));
  45383. exports.Choice = Choice;
  45384. var Transform = /** @class */ (function (_super) {
  45385. __extends(Transform, _super);
  45386. function Transform() {
  45387. var _this_1 = _super !== null && _super.apply(this, arguments) || this;
  45388. _this_1.regexp = new RegExp('');
  45389. return _this_1;
  45390. }
  45391. Transform.prototype.resolve = function (value) {
  45392. var _this = this;
  45393. var didMatch = false;
  45394. var ret = value.replace(this.regexp, function () {
  45395. didMatch = true;
  45396. return _this._replace(Array.prototype.slice.call(arguments, 0, -2));
  45397. });
  45398. // when the regex didn't match and when the transform has
  45399. // else branches, then run those
  45400. if (!didMatch && this._children.some(function (child) { return child instanceof FormatString && Boolean(child.elseValue); })) {
  45401. ret = this._replace([]);
  45402. }
  45403. return ret;
  45404. };
  45405. Transform.prototype._replace = function (groups) {
  45406. var ret = '';
  45407. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  45408. var marker = _a[_i];
  45409. if (marker instanceof FormatString) {
  45410. var value = groups[marker.index] || '';
  45411. value = marker.resolve(value);
  45412. ret += value;
  45413. }
  45414. else {
  45415. ret += marker.toString();
  45416. }
  45417. }
  45418. return ret;
  45419. };
  45420. Transform.prototype.toString = function () {
  45421. return '';
  45422. };
  45423. Transform.prototype.clone = function () {
  45424. var ret = new Transform();
  45425. ret.regexp = new RegExp(this.regexp.source, '' + (this.regexp.ignoreCase ? 'i' : '') + (this.regexp.global ? 'g' : ''));
  45426. ret._children = this.children.map(function (child) { return child.clone(); });
  45427. return ret;
  45428. };
  45429. return Transform;
  45430. }(Marker));
  45431. exports.Transform = Transform;
  45432. var FormatString = /** @class */ (function (_super) {
  45433. __extends(FormatString, _super);
  45434. function FormatString(index, shorthandName, ifValue, elseValue) {
  45435. var _this_1 = _super.call(this) || this;
  45436. _this_1.index = index;
  45437. _this_1.shorthandName = shorthandName;
  45438. _this_1.ifValue = ifValue;
  45439. _this_1.elseValue = elseValue;
  45440. return _this_1;
  45441. }
  45442. FormatString.prototype.resolve = function (value) {
  45443. if (this.shorthandName === 'upcase') {
  45444. return !value ? '' : value.toLocaleUpperCase();
  45445. }
  45446. else if (this.shorthandName === 'downcase') {
  45447. return !value ? '' : value.toLocaleLowerCase();
  45448. }
  45449. else if (this.shorthandName === 'capitalize') {
  45450. return !value ? '' : (value[0].toLocaleUpperCase() + value.substr(1));
  45451. }
  45452. else if (this.shorthandName === 'pascalcase') {
  45453. return !value ? '' : this._toPascalCase(value);
  45454. }
  45455. else if (Boolean(value) && typeof this.ifValue === 'string') {
  45456. return this.ifValue;
  45457. }
  45458. else if (!Boolean(value) && typeof this.elseValue === 'string') {
  45459. return this.elseValue;
  45460. }
  45461. else {
  45462. return value || '';
  45463. }
  45464. };
  45465. FormatString.prototype._toPascalCase = function (value) {
  45466. var match = value.match(/[a-z]+/gi);
  45467. if (!match) {
  45468. return value;
  45469. }
  45470. return match.map(function (word) {
  45471. return word.charAt(0).toUpperCase()
  45472. + word.substr(1).toLowerCase();
  45473. })
  45474. .join('');
  45475. };
  45476. FormatString.prototype.clone = function () {
  45477. var ret = new FormatString(this.index, this.shorthandName, this.ifValue, this.elseValue);
  45478. return ret;
  45479. };
  45480. return FormatString;
  45481. }(Marker));
  45482. exports.FormatString = FormatString;
  45483. var Variable = /** @class */ (function (_super) {
  45484. __extends(Variable, _super);
  45485. function Variable(name) {
  45486. var _this_1 = _super.call(this) || this;
  45487. _this_1.name = name;
  45488. return _this_1;
  45489. }
  45490. Variable.prototype.resolve = function (resolver) {
  45491. var value = resolver.resolve(this);
  45492. if (this.transform) {
  45493. value = this.transform.resolve(value || '');
  45494. }
  45495. if (value !== undefined) {
  45496. this._children = [new Text(value)];
  45497. return true;
  45498. }
  45499. return false;
  45500. };
  45501. Variable.prototype.clone = function () {
  45502. var ret = new Variable(this.name);
  45503. if (this.transform) {
  45504. ret.transform = this.transform.clone();
  45505. }
  45506. ret._children = this.children.map(function (child) { return child.clone(); });
  45507. return ret;
  45508. };
  45509. return Variable;
  45510. }(TransformableMarker));
  45511. exports.Variable = Variable;
  45512. function walk(marker, visitor) {
  45513. var stack = __spreadArrays(marker);
  45514. while (stack.length > 0) {
  45515. var marker_1 = stack.shift();
  45516. var recurse = visitor(marker_1);
  45517. if (!recurse) {
  45518. break;
  45519. }
  45520. stack.unshift.apply(stack, marker_1.children);
  45521. }
  45522. }
  45523. var TextmateSnippet = /** @class */ (function (_super) {
  45524. __extends(TextmateSnippet, _super);
  45525. function TextmateSnippet() {
  45526. return _super !== null && _super.apply(this, arguments) || this;
  45527. }
  45528. Object.defineProperty(TextmateSnippet.prototype, "placeholderInfo", {
  45529. get: function () {
  45530. if (!this._placeholders) {
  45531. // fill in placeholders
  45532. var all_1 = [];
  45533. var last_1;
  45534. this.walk(function (candidate) {
  45535. if (candidate instanceof Placeholder) {
  45536. all_1.push(candidate);
  45537. last_1 = !last_1 || last_1.index < candidate.index ? candidate : last_1;
  45538. }
  45539. return true;
  45540. });
  45541. this._placeholders = { all: all_1, last: last_1 };
  45542. }
  45543. return this._placeholders;
  45544. },
  45545. enumerable: true,
  45546. configurable: true
  45547. });
  45548. Object.defineProperty(TextmateSnippet.prototype, "placeholders", {
  45549. get: function () {
  45550. var all = this.placeholderInfo.all;
  45551. return all;
  45552. },
  45553. enumerable: true,
  45554. configurable: true
  45555. });
  45556. TextmateSnippet.prototype.offset = function (marker) {
  45557. var pos = 0;
  45558. var found = false;
  45559. this.walk(function (candidate) {
  45560. if (candidate === marker) {
  45561. found = true;
  45562. return false;
  45563. }
  45564. pos += candidate.len();
  45565. return true;
  45566. });
  45567. if (!found) {
  45568. return -1;
  45569. }
  45570. return pos;
  45571. };
  45572. TextmateSnippet.prototype.fullLen = function (marker) {
  45573. var ret = 0;
  45574. walk([marker], function (marker) {
  45575. ret += marker.len();
  45576. return true;
  45577. });
  45578. return ret;
  45579. };
  45580. TextmateSnippet.prototype.enclosingPlaceholders = function (placeholder) {
  45581. var ret = [];
  45582. var parent = placeholder.parent;
  45583. while (parent) {
  45584. if (parent instanceof Placeholder) {
  45585. ret.push(parent);
  45586. }
  45587. parent = parent.parent;
  45588. }
  45589. return ret;
  45590. };
  45591. TextmateSnippet.prototype.resolveVariables = function (resolver) {
  45592. var _this_1 = this;
  45593. this.walk(function (candidate) {
  45594. if (candidate instanceof Variable) {
  45595. if (candidate.resolve(resolver)) {
  45596. _this_1._placeholders = undefined;
  45597. }
  45598. }
  45599. return true;
  45600. });
  45601. return this;
  45602. };
  45603. TextmateSnippet.prototype.appendChild = function (child) {
  45604. this._placeholders = undefined;
  45605. return _super.prototype.appendChild.call(this, child);
  45606. };
  45607. TextmateSnippet.prototype.replace = function (child, others) {
  45608. this._placeholders = undefined;
  45609. return _super.prototype.replace.call(this, child, others);
  45610. };
  45611. TextmateSnippet.prototype.clone = function () {
  45612. var ret = new TextmateSnippet();
  45613. this._children = this.children.map(function (child) { return child.clone(); });
  45614. return ret;
  45615. };
  45616. TextmateSnippet.prototype.walk = function (visitor) {
  45617. walk(this.children, visitor);
  45618. };
  45619. return TextmateSnippet;
  45620. }(Marker));
  45621. exports.TextmateSnippet = TextmateSnippet;
  45622. var SnippetParser = /** @class */ (function () {
  45623. function SnippetParser() {
  45624. this._scanner = new Scanner();
  45625. this._token = { type: 14 /* EOF */, pos: 0, len: 0 };
  45626. }
  45627. SnippetParser.escape = function (value) {
  45628. return value.replace(/\$|}|\\/g, '\\$&');
  45629. };
  45630. SnippetParser.prototype.parse = function (value, insertFinalTabstop, enforceFinalTabstop) {
  45631. this._scanner.text(value);
  45632. this._token = this._scanner.next();
  45633. var snippet = new TextmateSnippet();
  45634. while (this._parse(snippet)) {
  45635. // nothing
  45636. }
  45637. // fill in values for placeholders. the first placeholder of an index
  45638. // that has a value defines the value for all placeholders with that index
  45639. var placeholderDefaultValues = new Map();
  45640. var incompletePlaceholders = [];
  45641. var placeholderCount = 0;
  45642. snippet.walk(function (marker) {
  45643. if (marker instanceof Placeholder) {
  45644. placeholderCount += 1;
  45645. if (marker.isFinalTabstop) {
  45646. placeholderDefaultValues.set(0, undefined);
  45647. }
  45648. else if (!placeholderDefaultValues.has(marker.index) && marker.children.length > 0) {
  45649. placeholderDefaultValues.set(marker.index, marker.children);
  45650. }
  45651. else {
  45652. incompletePlaceholders.push(marker);
  45653. }
  45654. }
  45655. return true;
  45656. });
  45657. for (var _i = 0, incompletePlaceholders_1 = incompletePlaceholders; _i < incompletePlaceholders_1.length; _i++) {
  45658. var placeholder = incompletePlaceholders_1[_i];
  45659. var defaultValues = placeholderDefaultValues.get(placeholder.index);
  45660. if (defaultValues) {
  45661. var clone = new Placeholder(placeholder.index);
  45662. clone.transform = placeholder.transform;
  45663. for (var _a = 0, defaultValues_1 = defaultValues; _a < defaultValues_1.length; _a++) {
  45664. var child = defaultValues_1[_a];
  45665. clone.appendChild(child.clone());
  45666. }
  45667. snippet.replace(placeholder, [clone]);
  45668. }
  45669. }
  45670. if (!enforceFinalTabstop) {
  45671. enforceFinalTabstop = placeholderCount > 0 && insertFinalTabstop;
  45672. }
  45673. if (!placeholderDefaultValues.has(0) && enforceFinalTabstop) {
  45674. // the snippet uses placeholders but has no
  45675. // final tabstop defined -> insert at the end
  45676. snippet.appendChild(new Placeholder(0));
  45677. }
  45678. return snippet;
  45679. };
  45680. SnippetParser.prototype._accept = function (type, value) {
  45681. if (type === undefined || this._token.type === type) {
  45682. var ret = !value ? true : this._scanner.tokenText(this._token);
  45683. this._token = this._scanner.next();
  45684. return ret;
  45685. }
  45686. return false;
  45687. };
  45688. SnippetParser.prototype._backTo = function (token) {
  45689. this._scanner.pos = token.pos + token.len;
  45690. this._token = token;
  45691. return false;
  45692. };
  45693. SnippetParser.prototype._until = function (type) {
  45694. var start = this._token;
  45695. while (this._token.type !== type) {
  45696. if (this._token.type === 14 /* EOF */) {
  45697. return false;
  45698. }
  45699. else if (this._token.type === 5 /* Backslash */) {
  45700. var nextToken = this._scanner.next();
  45701. if (nextToken.type !== 0 /* Dollar */
  45702. && nextToken.type !== 4 /* CurlyClose */
  45703. && nextToken.type !== 5 /* Backslash */) {
  45704. return false;
  45705. }
  45706. }
  45707. this._token = this._scanner.next();
  45708. }
  45709. var value = this._scanner.value.substring(start.pos, this._token.pos).replace(/\\(\$|}|\\)/g, '$1');
  45710. this._token = this._scanner.next();
  45711. return value;
  45712. };
  45713. SnippetParser.prototype._parse = function (marker) {
  45714. return this._parseEscaped(marker)
  45715. || this._parseTabstopOrVariableName(marker)
  45716. || this._parseComplexPlaceholder(marker)
  45717. || this._parseComplexVariable(marker)
  45718. || this._parseAnything(marker);
  45719. };
  45720. // \$, \\, \} -> just text
  45721. SnippetParser.prototype._parseEscaped = function (marker) {
  45722. var value;
  45723. if (value = this._accept(5 /* Backslash */, true)) {
  45724. // saw a backslash, append escaped token or that backslash
  45725. value = this._accept(0 /* Dollar */, true)
  45726. || this._accept(4 /* CurlyClose */, true)
  45727. || this._accept(5 /* Backslash */, true)
  45728. || value;
  45729. marker.appendChild(new Text(value));
  45730. return true;
  45731. }
  45732. return false;
  45733. };
  45734. // $foo -> variable, $1 -> tabstop
  45735. SnippetParser.prototype._parseTabstopOrVariableName = function (parent) {
  45736. var value;
  45737. var token = this._token;
  45738. var match = this._accept(0 /* Dollar */)
  45739. && (value = this._accept(9 /* VariableName */, true) || this._accept(8 /* Int */, true));
  45740. if (!match) {
  45741. return this._backTo(token);
  45742. }
  45743. parent.appendChild(/^\d+$/.test(value)
  45744. ? new Placeholder(Number(value))
  45745. : new Variable(value));
  45746. return true;
  45747. };
  45748. // ${1:<children>}, ${1} -> placeholder
  45749. SnippetParser.prototype._parseComplexPlaceholder = function (parent) {
  45750. var index;
  45751. var token = this._token;
  45752. var match = this._accept(0 /* Dollar */)
  45753. && this._accept(3 /* CurlyOpen */)
  45754. && (index = this._accept(8 /* Int */, true));
  45755. if (!match) {
  45756. return this._backTo(token);
  45757. }
  45758. var placeholder = new Placeholder(Number(index));
  45759. if (this._accept(1 /* Colon */)) {
  45760. // ${1:<children>}
  45761. while (true) {
  45762. // ...} -> done
  45763. if (this._accept(4 /* CurlyClose */)) {
  45764. parent.appendChild(placeholder);
  45765. return true;
  45766. }
  45767. if (this._parse(placeholder)) {
  45768. continue;
  45769. }
  45770. // fallback
  45771. parent.appendChild(new Text('${' + index + ':'));
  45772. placeholder.children.forEach(parent.appendChild, parent);
  45773. return true;
  45774. }
  45775. }
  45776. else if (placeholder.index > 0 && this._accept(7 /* Pipe */)) {
  45777. // ${1|one,two,three|}
  45778. var choice = new Choice();
  45779. while (true) {
  45780. if (this._parseChoiceElement(choice)) {
  45781. if (this._accept(2 /* Comma */)) {
  45782. // opt, -> more
  45783. continue;
  45784. }
  45785. if (this._accept(7 /* Pipe */)) {
  45786. placeholder.appendChild(choice);
  45787. if (this._accept(4 /* CurlyClose */)) {
  45788. // ..|} -> done
  45789. parent.appendChild(placeholder);
  45790. return true;
  45791. }
  45792. }
  45793. }
  45794. this._backTo(token);
  45795. return false;
  45796. }
  45797. }
  45798. else if (this._accept(6 /* Forwardslash */)) {
  45799. // ${1/<regex>/<format>/<options>}
  45800. if (this._parseTransform(placeholder)) {
  45801. parent.appendChild(placeholder);
  45802. return true;
  45803. }
  45804. this._backTo(token);
  45805. return false;
  45806. }
  45807. else if (this._accept(4 /* CurlyClose */)) {
  45808. // ${1}
  45809. parent.appendChild(placeholder);
  45810. return true;
  45811. }
  45812. else {
  45813. // ${1 <- missing curly or colon
  45814. return this._backTo(token);
  45815. }
  45816. };
  45817. SnippetParser.prototype._parseChoiceElement = function (parent) {
  45818. var token = this._token;
  45819. var values = [];
  45820. while (true) {
  45821. if (this._token.type === 2 /* Comma */ || this._token.type === 7 /* Pipe */) {
  45822. break;
  45823. }
  45824. var value = void 0;
  45825. if (value = this._accept(5 /* Backslash */, true)) {
  45826. // \, \|, or \\
  45827. value = this._accept(2 /* Comma */, true)
  45828. || this._accept(7 /* Pipe */, true)
  45829. || this._accept(5 /* Backslash */, true)
  45830. || value;
  45831. }
  45832. else {
  45833. value = this._accept(undefined, true);
  45834. }
  45835. if (!value) {
  45836. // EOF
  45837. this._backTo(token);
  45838. return false;
  45839. }
  45840. values.push(value);
  45841. }
  45842. if (values.length === 0) {
  45843. this._backTo(token);
  45844. return false;
  45845. }
  45846. parent.appendChild(new Text(values.join('')));
  45847. return true;
  45848. };
  45849. // ${foo:<children>}, ${foo} -> variable
  45850. SnippetParser.prototype._parseComplexVariable = function (parent) {
  45851. var name;
  45852. var token = this._token;
  45853. var match = this._accept(0 /* Dollar */)
  45854. && this._accept(3 /* CurlyOpen */)
  45855. && (name = this._accept(9 /* VariableName */, true));
  45856. if (!match) {
  45857. return this._backTo(token);
  45858. }
  45859. var variable = new Variable(name);
  45860. if (this._accept(1 /* Colon */)) {
  45861. // ${foo:<children>}
  45862. while (true) {
  45863. // ...} -> done
  45864. if (this._accept(4 /* CurlyClose */)) {
  45865. parent.appendChild(variable);
  45866. return true;
  45867. }
  45868. if (this._parse(variable)) {
  45869. continue;
  45870. }
  45871. // fallback
  45872. parent.appendChild(new Text('${' + name + ':'));
  45873. variable.children.forEach(parent.appendChild, parent);
  45874. return true;
  45875. }
  45876. }
  45877. else if (this._accept(6 /* Forwardslash */)) {
  45878. // ${foo/<regex>/<format>/<options>}
  45879. if (this._parseTransform(variable)) {
  45880. parent.appendChild(variable);
  45881. return true;
  45882. }
  45883. this._backTo(token);
  45884. return false;
  45885. }
  45886. else if (this._accept(4 /* CurlyClose */)) {
  45887. // ${foo}
  45888. parent.appendChild(variable);
  45889. return true;
  45890. }
  45891. else {
  45892. // ${foo <- missing curly or colon
  45893. return this._backTo(token);
  45894. }
  45895. };
  45896. SnippetParser.prototype._parseTransform = function (parent) {
  45897. // ...<regex>/<format>/<options>}
  45898. var transform = new Transform();
  45899. var regexValue = '';
  45900. var regexOptions = '';
  45901. // (1) /regex
  45902. while (true) {
  45903. if (this._accept(6 /* Forwardslash */)) {
  45904. break;
  45905. }
  45906. var escaped = void 0;
  45907. if (escaped = this._accept(5 /* Backslash */, true)) {
  45908. escaped = this._accept(6 /* Forwardslash */, true) || escaped;
  45909. regexValue += escaped;
  45910. continue;
  45911. }
  45912. if (this._token.type !== 14 /* EOF */) {
  45913. regexValue += this._accept(undefined, true);
  45914. continue;
  45915. }
  45916. return false;
  45917. }
  45918. // (2) /format
  45919. while (true) {
  45920. if (this._accept(6 /* Forwardslash */)) {
  45921. break;
  45922. }
  45923. var escaped = void 0;
  45924. if (escaped = this._accept(5 /* Backslash */, true)) {
  45925. escaped = this._accept(5 /* Backslash */, true) || this._accept(6 /* Forwardslash */, true) || escaped;
  45926. transform.appendChild(new Text(escaped));
  45927. continue;
  45928. }
  45929. if (this._parseFormatString(transform) || this._parseAnything(transform)) {
  45930. continue;
  45931. }
  45932. return false;
  45933. }
  45934. // (3) /option
  45935. while (true) {
  45936. if (this._accept(4 /* CurlyClose */)) {
  45937. break;
  45938. }
  45939. if (this._token.type !== 14 /* EOF */) {
  45940. regexOptions += this._accept(undefined, true);
  45941. continue;
  45942. }
  45943. return false;
  45944. }
  45945. try {
  45946. transform.regexp = new RegExp(regexValue, regexOptions);
  45947. }
  45948. catch (e) {
  45949. // invalid regexp
  45950. return false;
  45951. }
  45952. parent.transform = transform;
  45953. return true;
  45954. };
  45955. SnippetParser.prototype._parseFormatString = function (parent) {
  45956. var token = this._token;
  45957. if (!this._accept(0 /* Dollar */)) {
  45958. return false;
  45959. }
  45960. var complex = false;
  45961. if (this._accept(3 /* CurlyOpen */)) {
  45962. complex = true;
  45963. }
  45964. var index = this._accept(8 /* Int */, true);
  45965. if (!index) {
  45966. this._backTo(token);
  45967. return false;
  45968. }
  45969. else if (!complex) {
  45970. // $1
  45971. parent.appendChild(new FormatString(Number(index)));
  45972. return true;
  45973. }
  45974. else if (this._accept(4 /* CurlyClose */)) {
  45975. // ${1}
  45976. parent.appendChild(new FormatString(Number(index)));
  45977. return true;
  45978. }
  45979. else if (!this._accept(1 /* Colon */)) {
  45980. this._backTo(token);
  45981. return false;
  45982. }
  45983. if (this._accept(6 /* Forwardslash */)) {
  45984. // ${1:/upcase}
  45985. var shorthand = this._accept(9 /* VariableName */, true);
  45986. if (!shorthand || !this._accept(4 /* CurlyClose */)) {
  45987. this._backTo(token);
  45988. return false;
  45989. }
  45990. else {
  45991. parent.appendChild(new FormatString(Number(index), shorthand));
  45992. return true;
  45993. }
  45994. }
  45995. else if (this._accept(11 /* Plus */)) {
  45996. // ${1:+<if>}
  45997. var ifValue = this._until(4 /* CurlyClose */);
  45998. if (ifValue) {
  45999. parent.appendChild(new FormatString(Number(index), undefined, ifValue, undefined));
  46000. return true;
  46001. }
  46002. }
  46003. else if (this._accept(12 /* Dash */)) {
  46004. // ${2:-<else>}
  46005. var elseValue = this._until(4 /* CurlyClose */);
  46006. if (elseValue) {
  46007. parent.appendChild(new FormatString(Number(index), undefined, undefined, elseValue));
  46008. return true;
  46009. }
  46010. }
  46011. else if (this._accept(13 /* QuestionMark */)) {
  46012. // ${2:?<if>:<else>}
  46013. var ifValue = this._until(1 /* Colon */);
  46014. if (ifValue) {
  46015. var elseValue = this._until(4 /* CurlyClose */);
  46016. if (elseValue) {
  46017. parent.appendChild(new FormatString(Number(index), undefined, ifValue, elseValue));
  46018. return true;
  46019. }
  46020. }
  46021. }
  46022. else {
  46023. // ${1:<else>}
  46024. var elseValue = this._until(4 /* CurlyClose */);
  46025. if (elseValue) {
  46026. parent.appendChild(new FormatString(Number(index), undefined, undefined, elseValue));
  46027. return true;
  46028. }
  46029. }
  46030. this._backTo(token);
  46031. return false;
  46032. };
  46033. SnippetParser.prototype._parseAnything = function (marker) {
  46034. if (this._token.type !== 14 /* EOF */) {
  46035. marker.appendChild(new Text(this._scanner.tokenText(this._token)));
  46036. this._accept(undefined);
  46037. return true;
  46038. }
  46039. return false;
  46040. };
  46041. return SnippetParser;
  46042. }());
  46043. exports.SnippetParser = SnippetParser;
  46044. });
  46045. /*---------------------------------------------------------------------------------------------
  46046. * Copyright (c) Microsoft Corporation. All rights reserved.
  46047. * Licensed under the MIT License. See License.txt in the project root for license information.
  46048. *--------------------------------------------------------------------------------------------*/
  46049. define(__m[389/*vs/editor/contrib/suggest/completionModel*/], __M([0/*require*/,1/*exports*/,61/*vs/base/common/filters*/,5/*vs/base/common/strings*/]), function (require, exports, filters_1, strings_1) {
  46050. "use strict";
  46051. Object.defineProperty(exports, "__esModule", { value: true });
  46052. var LineContext = /** @class */ (function () {
  46053. function LineContext(leadingLineContent, characterCountDelta) {
  46054. this.leadingLineContent = leadingLineContent;
  46055. this.characterCountDelta = characterCountDelta;
  46056. }
  46057. return LineContext;
  46058. }());
  46059. exports.LineContext = LineContext;
  46060. var CompletionModel = /** @class */ (function () {
  46061. function CompletionModel(items, column, lineContext, wordDistance, options, snippetSuggestions) {
  46062. this._snippetCompareFn = CompletionModel._compareCompletionItems;
  46063. this._items = items;
  46064. this._column = column;
  46065. this._wordDistance = wordDistance;
  46066. this._options = options;
  46067. this._refilterKind = 1 /* All */;
  46068. this._lineContext = lineContext;
  46069. if (snippetSuggestions === 'top') {
  46070. this._snippetCompareFn = CompletionModel._compareCompletionItemsSnippetsUp;
  46071. }
  46072. else if (snippetSuggestions === 'bottom') {
  46073. this._snippetCompareFn = CompletionModel._compareCompletionItemsSnippetsDown;
  46074. }
  46075. }
  46076. Object.defineProperty(CompletionModel.prototype, "lineContext", {
  46077. get: function () {
  46078. return this._lineContext;
  46079. },
  46080. set: function (value) {
  46081. if (this._lineContext.leadingLineContent !== value.leadingLineContent
  46082. || this._lineContext.characterCountDelta !== value.characterCountDelta) {
  46083. this._refilterKind = this._lineContext.characterCountDelta < value.characterCountDelta && this._filteredItems ? 2 /* Incr */ : 1 /* All */;
  46084. this._lineContext = value;
  46085. }
  46086. },
  46087. enumerable: true,
  46088. configurable: true
  46089. });
  46090. Object.defineProperty(CompletionModel.prototype, "items", {
  46091. get: function () {
  46092. this._ensureCachedState();
  46093. return this._filteredItems;
  46094. },
  46095. enumerable: true,
  46096. configurable: true
  46097. });
  46098. Object.defineProperty(CompletionModel.prototype, "incomplete", {
  46099. get: function () {
  46100. this._ensureCachedState();
  46101. return this._isIncomplete;
  46102. },
  46103. enumerable: true,
  46104. configurable: true
  46105. });
  46106. CompletionModel.prototype.adopt = function (except) {
  46107. var res = new Array();
  46108. for (var i = 0; i < this._items.length;) {
  46109. if (!except.has(this._items[i].provider)) {
  46110. res.push(this._items[i]);
  46111. // unordered removed
  46112. this._items[i] = this._items[this._items.length - 1];
  46113. this._items.pop();
  46114. }
  46115. else {
  46116. // continue with next item
  46117. i++;
  46118. }
  46119. }
  46120. this._refilterKind = 1 /* All */;
  46121. return res;
  46122. };
  46123. Object.defineProperty(CompletionModel.prototype, "stats", {
  46124. get: function () {
  46125. this._ensureCachedState();
  46126. return this._stats;
  46127. },
  46128. enumerable: true,
  46129. configurable: true
  46130. });
  46131. CompletionModel.prototype._ensureCachedState = function () {
  46132. if (this._refilterKind !== 0 /* Nothing */) {
  46133. this._createCachedState();
  46134. }
  46135. };
  46136. CompletionModel.prototype._createCachedState = function () {
  46137. this._isIncomplete = new Set();
  46138. this._stats = { suggestionCount: 0, snippetCount: 0, textCount: 0 };
  46139. var _a = this._lineContext, leadingLineContent = _a.leadingLineContent, characterCountDelta = _a.characterCountDelta;
  46140. var word = '';
  46141. var wordLow = '';
  46142. // incrementally filter less
  46143. var source = this._refilterKind === 1 /* All */ ? this._items : this._filteredItems;
  46144. var target = [];
  46145. // picks a score function based on the number of
  46146. // items that we have to score/filter and based on the
  46147. // user-configuration
  46148. var scoreFn = (!this._options.filterGraceful || source.length > 2000) ? filters_1.fuzzyScore : filters_1.fuzzyScoreGracefulAggressive;
  46149. for (var i = 0; i < source.length; i++) {
  46150. var item = source[i];
  46151. // collect those supports that signaled having
  46152. // an incomplete result
  46153. if (item.container.incomplete) {
  46154. this._isIncomplete.add(item.provider);
  46155. }
  46156. // 'word' is that remainder of the current line that we
  46157. // filter and score against. In theory each suggestion uses a
  46158. // different word, but in practice not - that's why we cache
  46159. var overwriteBefore = item.position.column - item.editStart.column;
  46160. var wordLen = overwriteBefore + characterCountDelta - (item.position.column - this._column);
  46161. if (word.length !== wordLen) {
  46162. word = wordLen === 0 ? '' : leadingLineContent.slice(-wordLen);
  46163. wordLow = word.toLowerCase();
  46164. }
  46165. // remember the word against which this item was
  46166. // scored
  46167. item.word = word;
  46168. if (wordLen === 0) {
  46169. // when there is nothing to score against, don't
  46170. // event try to do. Use a const rank and rely on
  46171. // the fallback-sort using the initial sort order.
  46172. // use a score of `-100` because that is out of the
  46173. // bound of values `fuzzyScore` will return
  46174. item.score = filters_1.FuzzyScore.Default;
  46175. }
  46176. else {
  46177. // skip word characters that are whitespace until
  46178. // we have hit the replace range (overwriteBefore)
  46179. var wordPos = 0;
  46180. while (wordPos < overwriteBefore) {
  46181. var ch = word.charCodeAt(wordPos);
  46182. if (ch === 32 /* Space */ || ch === 9 /* Tab */) {
  46183. wordPos += 1;
  46184. }
  46185. else {
  46186. break;
  46187. }
  46188. }
  46189. var textLabel = typeof item.completion.label === 'string' ? item.completion.label : item.completion.label.name;
  46190. if (wordPos >= wordLen) {
  46191. // the wordPos at which scoring starts is the whole word
  46192. // and therefore the same rules as not having a word apply
  46193. item.score = filters_1.FuzzyScore.Default;
  46194. }
  46195. else if (typeof item.completion.filterText === 'string') {
  46196. // when there is a `filterText` it must match the `word`.
  46197. // if it matches we check with the label to compute highlights
  46198. // and if that doesn't yield a result we have no highlights,
  46199. // despite having the match
  46200. var match = scoreFn(word, wordLow, wordPos, item.completion.filterText, item.filterTextLow, 0, false);
  46201. if (!match) {
  46202. continue; // NO match
  46203. }
  46204. if (strings_1.compareIgnoreCase(item.completion.filterText, textLabel) === 0) {
  46205. // filterText and label are actually the same -> use good highlights
  46206. item.score = match;
  46207. }
  46208. else {
  46209. // re-run the scorer on the label in the hope of a result BUT use the rank
  46210. // of the filterText-match
  46211. item.score = filters_1.anyScore(word, wordLow, wordPos, textLabel, item.labelLow, 0);
  46212. item.score[0] = match[0]; // use score from filterText
  46213. }
  46214. }
  46215. else {
  46216. // by default match `word` against the `label`
  46217. var match = scoreFn(word, wordLow, wordPos, textLabel, item.labelLow, 0, false);
  46218. if (!match) {
  46219. continue; // NO match
  46220. }
  46221. item.score = match;
  46222. }
  46223. }
  46224. item.idx = i;
  46225. item.distance = this._wordDistance.distance(item.position, item.completion);
  46226. target.push(item);
  46227. // update stats
  46228. this._stats.suggestionCount++;
  46229. switch (item.completion.kind) {
  46230. case 25 /* Snippet */:
  46231. this._stats.snippetCount++;
  46232. break;
  46233. case 18 /* Text */:
  46234. this._stats.textCount++;
  46235. break;
  46236. }
  46237. }
  46238. this._filteredItems = target.sort(this._snippetCompareFn);
  46239. this._refilterKind = 0 /* Nothing */;
  46240. };
  46241. CompletionModel._compareCompletionItems = function (a, b) {
  46242. if (a.score[0] > b.score[0]) {
  46243. return -1;
  46244. }
  46245. else if (a.score[0] < b.score[0]) {
  46246. return 1;
  46247. }
  46248. else if (a.distance < b.distance) {
  46249. return -1;
  46250. }
  46251. else if (a.distance > b.distance) {
  46252. return 1;
  46253. }
  46254. else if (a.idx < b.idx) {
  46255. return -1;
  46256. }
  46257. else if (a.idx > b.idx) {
  46258. return 1;
  46259. }
  46260. else {
  46261. return 0;
  46262. }
  46263. };
  46264. CompletionModel._compareCompletionItemsSnippetsDown = function (a, b) {
  46265. if (a.completion.kind !== b.completion.kind) {
  46266. if (a.completion.kind === 25 /* Snippet */) {
  46267. return 1;
  46268. }
  46269. else if (b.completion.kind === 25 /* Snippet */) {
  46270. return -1;
  46271. }
  46272. }
  46273. return CompletionModel._compareCompletionItems(a, b);
  46274. };
  46275. CompletionModel._compareCompletionItemsSnippetsUp = function (a, b) {
  46276. if (a.completion.kind !== b.completion.kind) {
  46277. if (a.completion.kind === 25 /* Snippet */) {
  46278. return -1;
  46279. }
  46280. else if (b.completion.kind === 25 /* Snippet */) {
  46281. return 1;
  46282. }
  46283. }
  46284. return CompletionModel._compareCompletionItems(a, b);
  46285. };
  46286. return CompletionModel;
  46287. }());
  46288. exports.CompletionModel = CompletionModel;
  46289. });
  46290. /*---------------------------------------------------------------------------------------------
  46291. * Copyright (c) Microsoft Corporation. All rights reserved.
  46292. * Licensed under the MIT License. See License.txt in the project root for license information.
  46293. *--------------------------------------------------------------------------------------------*/
  46294. define(__m[390/*vs/editor/contrib/suggest/suggestCommitCharacters*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,2/*vs/base/common/lifecycle*/,79/*vs/editor/common/core/characterClassifier*/]), function (require, exports, arrays_1, lifecycle_1, characterClassifier_1) {
  46295. "use strict";
  46296. Object.defineProperty(exports, "__esModule", { value: true });
  46297. var CommitCharacterController = /** @class */ (function () {
  46298. function CommitCharacterController(editor, widget, accept) {
  46299. var _this = this;
  46300. this._disposables = new lifecycle_1.DisposableStore();
  46301. this._disposables.add(widget.onDidShow(function () { return _this._onItem(widget.getFocusedItem()); }));
  46302. this._disposables.add(widget.onDidFocus(this._onItem, this));
  46303. this._disposables.add(widget.onDidHide(this.reset, this));
  46304. this._disposables.add(editor.onWillType(function (text) {
  46305. if (_this._active && !widget.isFrozen()) {
  46306. var ch = text.charCodeAt(text.length - 1);
  46307. if (_this._active.acceptCharacters.has(ch) && editor.getOption(0 /* acceptSuggestionOnCommitCharacter */)) {
  46308. accept(_this._active.item);
  46309. }
  46310. }
  46311. }));
  46312. }
  46313. CommitCharacterController.prototype._onItem = function (selected) {
  46314. if (!selected || !arrays_1.isNonEmptyArray(selected.item.completion.commitCharacters)) {
  46315. // no item or no commit characters
  46316. this.reset();
  46317. return;
  46318. }
  46319. if (this._active && this._active.item.item === selected.item) {
  46320. // still the same item
  46321. return;
  46322. }
  46323. // keep item and its commit characters
  46324. var acceptCharacters = new characterClassifier_1.CharacterSet();
  46325. for (var _i = 0, _a = selected.item.completion.commitCharacters; _i < _a.length; _i++) {
  46326. var ch = _a[_i];
  46327. if (ch.length > 0) {
  46328. acceptCharacters.add(ch.charCodeAt(0));
  46329. }
  46330. }
  46331. this._active = { acceptCharacters: acceptCharacters, item: selected };
  46332. };
  46333. CommitCharacterController.prototype.reset = function () {
  46334. this._active = undefined;
  46335. };
  46336. CommitCharacterController.prototype.dispose = function () {
  46337. this._disposables.dispose();
  46338. };
  46339. return CommitCharacterController;
  46340. }());
  46341. exports.CommitCharacterController = CommitCharacterController;
  46342. });
  46343. /*---------------------------------------------------------------------------------------------
  46344. * Copyright (c) Microsoft Corporation. All rights reserved.
  46345. * Licensed under the MIT License. See License.txt in the project root for license information.
  46346. *--------------------------------------------------------------------------------------------*/
  46347. define(__m[391/*vs/editor/contrib/suggest/suggestRangeHighlighter*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,3/*vs/editor/common/core/range*/,4/*vs/base/common/event*/,52/*vs/base/browser/event*/]), function (require, exports, lifecycle_1, range_1, event_1, event_2) {
  46348. "use strict";
  46349. Object.defineProperty(exports, "__esModule", { value: true });
  46350. var SuggestRangeHighlighter = /** @class */ (function () {
  46351. function SuggestRangeHighlighter(_controller) {
  46352. var _this = this;
  46353. this._controller = _controller;
  46354. this._disposables = new lifecycle_1.DisposableStore();
  46355. this._decorations = [];
  46356. this._disposables.add(_controller.model.onDidSuggest(function (e) {
  46357. if (!e.shy) {
  46358. var widget = _this._controller.widget.getValue();
  46359. var focused = widget.getFocusedItem();
  46360. if (focused) {
  46361. _this._highlight(focused.item);
  46362. }
  46363. if (!_this._widgetListener) {
  46364. _this._widgetListener = widget.onDidFocus(function (e) { return _this._highlight(e.item); });
  46365. }
  46366. }
  46367. }));
  46368. this._disposables.add(_controller.model.onDidCancel(function () {
  46369. _this._reset();
  46370. }));
  46371. }
  46372. SuggestRangeHighlighter.prototype.dispose = function () {
  46373. this._reset();
  46374. this._disposables.dispose();
  46375. lifecycle_1.dispose(this._widgetListener);
  46376. lifecycle_1.dispose(this._shiftKeyListener);
  46377. };
  46378. SuggestRangeHighlighter.prototype._reset = function () {
  46379. this._decorations = this._controller.editor.deltaDecorations(this._decorations, []);
  46380. if (this._shiftKeyListener) {
  46381. this._shiftKeyListener.dispose();
  46382. this._shiftKeyListener = undefined;
  46383. }
  46384. };
  46385. SuggestRangeHighlighter.prototype._highlight = function (item) {
  46386. var _this = this;
  46387. var _a;
  46388. this._currentItem = item;
  46389. var opts = this._controller.editor.getOption(89 /* suggest */);
  46390. var newDeco = [];
  46391. if (opts.insertHighlight) {
  46392. if (!this._shiftKeyListener) {
  46393. this._shiftKeyListener = shiftKey.event(function () { return _this._highlight(_this._currentItem); });
  46394. }
  46395. var info = this._controller.getOverwriteInfo(item, shiftKey.isPressed);
  46396. var position = this._controller.editor.getPosition();
  46397. if (opts.insertMode === 'insert' && info.overwriteAfter > 0) {
  46398. // wants inserts but got replace-mode -> highlight AFTER range
  46399. newDeco = [{
  46400. range: new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column + info.overwriteAfter),
  46401. options: { inlineClassName: 'suggest-insert-unexpected' }
  46402. }];
  46403. }
  46404. else if (opts.insertMode === 'replace' && info.overwriteAfter === 0) {
  46405. // want replace but likely got insert -> highlight AFTER range
  46406. var wordInfo = (_a = this._controller.editor.getModel()) === null || _a === void 0 ? void 0 : _a.getWordAtPosition(position);
  46407. if (wordInfo && wordInfo.endColumn > position.column) {
  46408. newDeco = [{
  46409. range: new range_1.Range(position.lineNumber, position.column, position.lineNumber, wordInfo.endColumn),
  46410. options: { inlineClassName: 'suggest-insert-unexpected' }
  46411. }];
  46412. }
  46413. }
  46414. }
  46415. // update editor decorations
  46416. this._decorations = this._controller.editor.deltaDecorations(this._decorations, newDeco);
  46417. };
  46418. return SuggestRangeHighlighter;
  46419. }());
  46420. exports.SuggestRangeHighlighter = SuggestRangeHighlighter;
  46421. var shiftKey = new /** @class */ (function (_super) {
  46422. __extends(ShiftKey, _super);
  46423. function ShiftKey() {
  46424. var _this = _super.call(this) || this;
  46425. _this._subscriptions = new lifecycle_1.DisposableStore();
  46426. _this._isPressed = false;
  46427. _this._subscriptions.add(event_2.domEvent(document.body, 'keydown')(function (e) { return _this.isPressed = e.shiftKey; }));
  46428. _this._subscriptions.add(event_2.domEvent(document.body, 'keyup')(function () { return _this.isPressed = false; }));
  46429. _this._subscriptions.add(event_2.domEvent(document.body, 'mouseleave')(function () { return _this.isPressed = false; }));
  46430. _this._subscriptions.add(event_2.domEvent(document.body, 'blur')(function () { return _this.isPressed = false; }));
  46431. return _this;
  46432. }
  46433. Object.defineProperty(ShiftKey.prototype, "isPressed", {
  46434. get: function () {
  46435. return this._isPressed;
  46436. },
  46437. set: function (value) {
  46438. if (this._isPressed !== value) {
  46439. this._isPressed = value;
  46440. this.fire(value);
  46441. }
  46442. },
  46443. enumerable: true,
  46444. configurable: true
  46445. });
  46446. ShiftKey.prototype.dispose = function () {
  46447. this._subscriptions.dispose();
  46448. _super.prototype.dispose.call(this);
  46449. };
  46450. return ShiftKey;
  46451. }(event_1.Emitter));
  46452. });
  46453. /*---------------------------------------------------------------------------------------------
  46454. * Copyright (c) Microsoft Corporation. All rights reserved.
  46455. * Licensed under the MIT License. See License.txt in the project root for license information.
  46456. *--------------------------------------------------------------------------------------------*/
  46457. define(__m[392/*vs/editor/contrib/suggest/wordDistance*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,3/*vs/editor/common/core/range*/,202/*vs/editor/contrib/smartSelect/bracketSelections*/]), function (require, exports, arrays_1, range_1, bracketSelections_1) {
  46458. "use strict";
  46459. Object.defineProperty(exports, "__esModule", { value: true });
  46460. var WordDistance = /** @class */ (function () {
  46461. function WordDistance() {
  46462. }
  46463. WordDistance.create = function (service, editor) {
  46464. return __awaiter(this, void 0, void 0, function () {
  46465. var model, position, ranges, wordRanges;
  46466. return __generator(this, function (_a) {
  46467. switch (_a.label) {
  46468. case 0:
  46469. if (!editor.getOption(89 /* suggest */).localityBonus) {
  46470. return [2 /*return*/, WordDistance.None];
  46471. }
  46472. if (!editor.hasModel()) {
  46473. return [2 /*return*/, WordDistance.None];
  46474. }
  46475. model = editor.getModel();
  46476. position = editor.getPosition();
  46477. if (!service.canComputeWordRanges(model.uri)) {
  46478. return [2 /*return*/, WordDistance.None];
  46479. }
  46480. return [4 /*yield*/, new bracketSelections_1.BracketSelectionRangeProvider().provideSelectionRanges(model, [position])];
  46481. case 1:
  46482. ranges = _a.sent();
  46483. if (!ranges || ranges.length === 0 || ranges[0].length === 0) {
  46484. return [2 /*return*/, WordDistance.None];
  46485. }
  46486. return [4 /*yield*/, service.computeWordRanges(model.uri, ranges[0][0].range)];
  46487. case 2:
  46488. wordRanges = _a.sent();
  46489. return [2 /*return*/, new /** @class */ (function (_super) {
  46490. __extends(class_1, _super);
  46491. function class_1() {
  46492. return _super !== null && _super.apply(this, arguments) || this;
  46493. }
  46494. class_1.prototype.distance = function (anchor, suggestion) {
  46495. if (!wordRanges || !position.equals(editor.getPosition())) {
  46496. return 0;
  46497. }
  46498. if (suggestion.kind === 17 /* Keyword */) {
  46499. return 2 << 20;
  46500. }
  46501. var word = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;
  46502. var wordLines = wordRanges[word];
  46503. if (arrays_1.isFalsyOrEmpty(wordLines)) {
  46504. return 2 << 20;
  46505. }
  46506. var idx = arrays_1.binarySearch(wordLines, range_1.Range.fromPositions(anchor), range_1.Range.compareRangesUsingStarts);
  46507. var bestWordRange = idx >= 0 ? wordLines[idx] : wordLines[Math.max(0, ~idx - 1)];
  46508. var blockDistance = ranges.length;
  46509. for (var _i = 0, _a = ranges[0]; _i < _a.length; _i++) {
  46510. var range = _a[_i];
  46511. if (!range_1.Range.containsRange(range.range, bestWordRange)) {
  46512. break;
  46513. }
  46514. blockDistance -= 1;
  46515. }
  46516. return blockDistance;
  46517. };
  46518. return class_1;
  46519. }(WordDistance))];
  46520. }
  46521. });
  46522. });
  46523. };
  46524. WordDistance.None = new /** @class */ (function (_super) {
  46525. __extends(class_2, _super);
  46526. function class_2() {
  46527. return _super !== null && _super.apply(this, arguments) || this;
  46528. }
  46529. class_2.prototype.distance = function () { return 0; };
  46530. return class_2;
  46531. }(WordDistance));
  46532. return WordDistance;
  46533. }());
  46534. exports.WordDistance = WordDistance;
  46535. });
  46536. /*---------------------------------------------------------------------------------------------
  46537. * Copyright (c) Microsoft Corporation. All rights reserved.
  46538. * Licensed under the MIT License. See License.txt in the project root for license information.
  46539. *--------------------------------------------------------------------------------------------*/
  46540. define(__m[203/*vs/editor/standalone/common/monarch/monarchCommon*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  46541. "use strict";
  46542. Object.defineProperty(exports, "__esModule", { value: true });
  46543. function isFuzzyActionArr(what) {
  46544. return (Array.isArray(what));
  46545. }
  46546. exports.isFuzzyActionArr = isFuzzyActionArr;
  46547. function isFuzzyAction(what) {
  46548. return !isFuzzyActionArr(what);
  46549. }
  46550. exports.isFuzzyAction = isFuzzyAction;
  46551. function isString(what) {
  46552. return (typeof what === 'string');
  46553. }
  46554. exports.isString = isString;
  46555. function isIAction(what) {
  46556. return !isString(what);
  46557. }
  46558. exports.isIAction = isIAction;
  46559. // Small helper functions
  46560. /**
  46561. * Is a string null, undefined, or empty?
  46562. */
  46563. function empty(s) {
  46564. return (s ? false : true);
  46565. }
  46566. exports.empty = empty;
  46567. /**
  46568. * Puts a string to lower case if 'ignoreCase' is set.
  46569. */
  46570. function fixCase(lexer, str) {
  46571. return (lexer.ignoreCase && str ? str.toLowerCase() : str);
  46572. }
  46573. exports.fixCase = fixCase;
  46574. /**
  46575. * Ensures there are no bad characters in a CSS token class.
  46576. */
  46577. function sanitize(s) {
  46578. return s.replace(/[&<>'"_]/g, '-'); // used on all output token CSS classes
  46579. }
  46580. exports.sanitize = sanitize;
  46581. // Logging
  46582. /**
  46583. * Logs a message.
  46584. */
  46585. function log(lexer, msg) {
  46586. console.log(lexer.languageId + ": " + msg);
  46587. }
  46588. exports.log = log;
  46589. // Throwing errors
  46590. function createError(lexer, msg) {
  46591. return new Error(lexer.languageId + ": " + msg);
  46592. }
  46593. exports.createError = createError;
  46594. // Helper functions for rule finding and substitution
  46595. /**
  46596. * substituteMatches is used on lexer strings and can substitutes predefined patterns:
  46597. * $$ => $
  46598. * $# => id
  46599. * $n => matched entry n
  46600. * @attr => contents of lexer[attr]
  46601. *
  46602. * See documentation for more info
  46603. */
  46604. function substituteMatches(lexer, str, id, matches, state) {
  46605. var re = /\$((\$)|(#)|(\d\d?)|[sS](\d\d?)|@(\w+))/g;
  46606. var stateMatches = null;
  46607. return str.replace(re, function (full, sub, dollar, hash, n, s, attr, ofs, total) {
  46608. if (!empty(dollar)) {
  46609. return '$'; // $$
  46610. }
  46611. if (!empty(hash)) {
  46612. return fixCase(lexer, id); // default $#
  46613. }
  46614. if (!empty(n) && n < matches.length) {
  46615. return fixCase(lexer, matches[n]); // $n
  46616. }
  46617. if (!empty(attr) && lexer && typeof (lexer[attr]) === 'string') {
  46618. return lexer[attr]; //@attribute
  46619. }
  46620. if (stateMatches === null) { // split state on demand
  46621. stateMatches = state.split('.');
  46622. stateMatches.unshift(state);
  46623. }
  46624. if (!empty(s) && s < stateMatches.length) {
  46625. return fixCase(lexer, stateMatches[s]); //$Sn
  46626. }
  46627. return '';
  46628. });
  46629. }
  46630. exports.substituteMatches = substituteMatches;
  46631. /**
  46632. * Find the tokenizer rules for a specific state (i.e. next action)
  46633. */
  46634. function findRules(lexer, inState) {
  46635. var state = inState;
  46636. while (state && state.length > 0) {
  46637. var rules = lexer.tokenizer[state];
  46638. if (rules) {
  46639. return rules;
  46640. }
  46641. var idx = state.lastIndexOf('.');
  46642. if (idx < 0) {
  46643. state = null; // no further parent
  46644. }
  46645. else {
  46646. state = state.substr(0, idx);
  46647. }
  46648. }
  46649. return null;
  46650. }
  46651. exports.findRules = findRules;
  46652. /**
  46653. * Is a certain state defined? In contrast to 'findRules' this works on a ILexerMin.
  46654. * This is used during compilation where we may know the defined states
  46655. * but not yet whether the corresponding rules are correct.
  46656. */
  46657. function stateExists(lexer, inState) {
  46658. var state = inState;
  46659. while (state && state.length > 0) {
  46660. var exist = lexer.stateNames[state];
  46661. if (exist) {
  46662. return true;
  46663. }
  46664. var idx = state.lastIndexOf('.');
  46665. if (idx < 0) {
  46666. state = null; // no further parent
  46667. }
  46668. else {
  46669. state = state.substr(0, idx);
  46670. }
  46671. }
  46672. return false;
  46673. }
  46674. exports.stateExists = stateExists;
  46675. });
  46676. /*---------------------------------------------------------------------------------------------
  46677. * Copyright (c) Microsoft Corporation. All rights reserved.
  46678. * Licensed under the MIT License. See License.txt in the project root for license information.
  46679. *--------------------------------------------------------------------------------------------*/
  46680. define(__m[393/*vs/editor/standalone/common/monarch/monarchCompile*/], __M([0/*require*/,1/*exports*/,203/*vs/editor/standalone/common/monarch/monarchCommon*/]), function (require, exports, monarchCommon) {
  46681. "use strict";
  46682. Object.defineProperty(exports, "__esModule", { value: true });
  46683. /*
  46684. * Type helpers
  46685. *
  46686. * Note: this is just for sanity checks on the JSON description which is
  46687. * helpful for the programmer. No checks are done anymore once the lexer is
  46688. * already 'compiled and checked'.
  46689. *
  46690. */
  46691. function isArrayOf(elemType, obj) {
  46692. if (!obj) {
  46693. return false;
  46694. }
  46695. if (!(Array.isArray(obj))) {
  46696. return false;
  46697. }
  46698. for (var _i = 0, obj_1 = obj; _i < obj_1.length; _i++) {
  46699. var el = obj_1[_i];
  46700. if (!(elemType(el))) {
  46701. return false;
  46702. }
  46703. }
  46704. return true;
  46705. }
  46706. function bool(prop, defValue) {
  46707. if (typeof prop === 'boolean') {
  46708. return prop;
  46709. }
  46710. return defValue;
  46711. }
  46712. function string(prop, defValue) {
  46713. if (typeof (prop) === 'string') {
  46714. return prop;
  46715. }
  46716. return defValue;
  46717. }
  46718. function arrayToHash(array) {
  46719. var result = {};
  46720. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  46721. var e = array_1[_i];
  46722. result[e] = true;
  46723. }
  46724. return result;
  46725. }
  46726. function createKeywordMatcher(arr, caseInsensitive) {
  46727. if (caseInsensitive === void 0) { caseInsensitive = false; }
  46728. if (caseInsensitive) {
  46729. arr = arr.map(function (x) { return x.toLowerCase(); });
  46730. }
  46731. var hash = arrayToHash(arr);
  46732. if (caseInsensitive) {
  46733. return function (word) {
  46734. return hash[word.toLowerCase()] !== undefined && hash.hasOwnProperty(word.toLowerCase());
  46735. };
  46736. }
  46737. else {
  46738. return function (word) {
  46739. return hash[word] !== undefined && hash.hasOwnProperty(word);
  46740. };
  46741. }
  46742. }
  46743. // Lexer helpers
  46744. /**
  46745. * Compiles a regular expression string, adding the 'i' flag if 'ignoreCase' is set.
  46746. * Also replaces @\w+ or sequences with the content of the specified attribute
  46747. */
  46748. function compileRegExp(lexer, str) {
  46749. var n = 0;
  46750. while (str.indexOf('@') >= 0 && n < 5) { // at most 5 expansions
  46751. n++;
  46752. str = str.replace(/@(\w+)/g, function (s, attr) {
  46753. var sub = '';
  46754. if (typeof (lexer[attr]) === 'string') {
  46755. sub = lexer[attr];
  46756. }
  46757. else if (lexer[attr] && lexer[attr] instanceof RegExp) {
  46758. sub = lexer[attr].source;
  46759. }
  46760. else {
  46761. if (lexer[attr] === undefined) {
  46762. throw monarchCommon.createError(lexer, 'language definition does not contain attribute \'' + attr + '\', used at: ' + str);
  46763. }
  46764. else {
  46765. throw monarchCommon.createError(lexer, 'attribute reference \'' + attr + '\' must be a string, used at: ' + str);
  46766. }
  46767. }
  46768. return (monarchCommon.empty(sub) ? '' : '(?:' + sub + ')');
  46769. });
  46770. }
  46771. return new RegExp(str, (lexer.ignoreCase ? 'i' : ''));
  46772. }
  46773. /**
  46774. * Compiles guard functions for case matches.
  46775. * This compiles 'cases' attributes into efficient match functions.
  46776. *
  46777. */
  46778. function selectScrutinee(id, matches, state, num) {
  46779. if (num < 0) {
  46780. return id;
  46781. }
  46782. if (num < matches.length) {
  46783. return matches[num];
  46784. }
  46785. if (num >= 100) {
  46786. num = num - 100;
  46787. var parts = state.split('.');
  46788. parts.unshift(state);
  46789. if (num < parts.length) {
  46790. return parts[num];
  46791. }
  46792. }
  46793. return null;
  46794. }
  46795. function createGuard(lexer, ruleName, tkey, val) {
  46796. // get the scrutinee and pattern
  46797. var scrut = -1; // -1: $!, 0-99: $n, 100+n: $Sn
  46798. var oppat = tkey;
  46799. var matches = tkey.match(/^\$(([sS]?)(\d\d?)|#)(.*)$/);
  46800. if (matches) {
  46801. if (matches[3]) { // if digits
  46802. scrut = parseInt(matches[3]);
  46803. if (matches[2]) {
  46804. scrut = scrut + 100; // if [sS] present
  46805. }
  46806. }
  46807. oppat = matches[4];
  46808. }
  46809. // get operator
  46810. var op = '~';
  46811. var pat = oppat;
  46812. if (!oppat || oppat.length === 0) {
  46813. op = '!=';
  46814. pat = '';
  46815. }
  46816. else if (/^\w*$/.test(pat)) { // just a word
  46817. op = '==';
  46818. }
  46819. else {
  46820. matches = oppat.match(/^(@|!@|~|!~|==|!=)(.*)$/);
  46821. if (matches) {
  46822. op = matches[1];
  46823. pat = matches[2];
  46824. }
  46825. }
  46826. // set the tester function
  46827. var tester;
  46828. // special case a regexp that matches just words
  46829. if ((op === '~' || op === '!~') && /^(\w|\|)*$/.test(pat)) {
  46830. var inWords_1 = createKeywordMatcher(pat.split('|'), lexer.ignoreCase);
  46831. tester = function (s) { return (op === '~' ? inWords_1(s) : !inWords_1(s)); };
  46832. }
  46833. else if (op === '@' || op === '!@') {
  46834. var words = lexer[pat];
  46835. if (!words) {
  46836. throw monarchCommon.createError(lexer, 'the @ match target \'' + pat + '\' is not defined, in rule: ' + ruleName);
  46837. }
  46838. if (!(isArrayOf(function (elem) { return (typeof (elem) === 'string'); }, words))) {
  46839. throw monarchCommon.createError(lexer, 'the @ match target \'' + pat + '\' must be an array of strings, in rule: ' + ruleName);
  46840. }
  46841. var inWords_2 = createKeywordMatcher(words, lexer.ignoreCase);
  46842. tester = function (s) { return (op === '@' ? inWords_2(s) : !inWords_2(s)); };
  46843. }
  46844. else if (op === '~' || op === '!~') {
  46845. if (pat.indexOf('$') < 0) {
  46846. // precompile regular expression
  46847. var re_1 = compileRegExp(lexer, '^' + pat + '$');
  46848. tester = function (s) { return (op === '~' ? re_1.test(s) : !re_1.test(s)); };
  46849. }
  46850. else {
  46851. tester = function (s, id, matches, state) {
  46852. var re = compileRegExp(lexer, '^' + monarchCommon.substituteMatches(lexer, pat, id, matches, state) + '$');
  46853. return re.test(s);
  46854. };
  46855. }
  46856. }
  46857. else { // if (op==='==' || op==='!=') {
  46858. if (pat.indexOf('$') < 0) {
  46859. var patx_1 = monarchCommon.fixCase(lexer, pat);
  46860. tester = function (s) { return (op === '==' ? s === patx_1 : s !== patx_1); };
  46861. }
  46862. else {
  46863. var patx_2 = monarchCommon.fixCase(lexer, pat);
  46864. tester = function (s, id, matches, state, eos) {
  46865. var patexp = monarchCommon.substituteMatches(lexer, patx_2, id, matches, state);
  46866. return (op === '==' ? s === patexp : s !== patexp);
  46867. };
  46868. }
  46869. }
  46870. // return the branch object
  46871. if (scrut === -1) {
  46872. return {
  46873. name: tkey, value: val, test: function (id, matches, state, eos) {
  46874. return tester(id, id, matches, state, eos);
  46875. }
  46876. };
  46877. }
  46878. else {
  46879. return {
  46880. name: tkey, value: val, test: function (id, matches, state, eos) {
  46881. var scrutinee = selectScrutinee(id, matches, state, scrut);
  46882. return tester(!scrutinee ? '' : scrutinee, id, matches, state, eos);
  46883. }
  46884. };
  46885. }
  46886. }
  46887. /**
  46888. * Compiles an action: i.e. optimize regular expressions and case matches
  46889. * and do many sanity checks.
  46890. *
  46891. * This is called only during compilation but if the lexer definition
  46892. * contains user functions as actions (which is usually not allowed), then this
  46893. * may be called during lexing. It is important therefore to compile common cases efficiently
  46894. */
  46895. function compileAction(lexer, ruleName, action) {
  46896. if (!action) {
  46897. return { token: '' };
  46898. }
  46899. else if (typeof (action) === 'string') {
  46900. return action; // { token: action };
  46901. }
  46902. else if (action.token || action.token === '') {
  46903. if (typeof (action.token) !== 'string') {
  46904. throw monarchCommon.createError(lexer, 'a \'token\' attribute must be of type string, in rule: ' + ruleName);
  46905. }
  46906. else {
  46907. // only copy specific typed fields (only happens once during compile Lexer)
  46908. var newAction = { token: action.token };
  46909. if (action.token.indexOf('$') >= 0) {
  46910. newAction.tokenSubst = true;
  46911. }
  46912. if (typeof (action.bracket) === 'string') {
  46913. if (action.bracket === '@open') {
  46914. newAction.bracket = 1 /* Open */;
  46915. }
  46916. else if (action.bracket === '@close') {
  46917. newAction.bracket = -1 /* Close */;
  46918. }
  46919. else {
  46920. throw monarchCommon.createError(lexer, 'a \'bracket\' attribute must be either \'@open\' or \'@close\', in rule: ' + ruleName);
  46921. }
  46922. }
  46923. if (action.next) {
  46924. if (typeof (action.next) !== 'string') {
  46925. throw monarchCommon.createError(lexer, 'the next state must be a string value in rule: ' + ruleName);
  46926. }
  46927. else {
  46928. var next = action.next;
  46929. if (!/^(@pop|@push|@popall)$/.test(next)) {
  46930. if (next[0] === '@') {
  46931. next = next.substr(1); // peel off starting @ sign
  46932. }
  46933. if (next.indexOf('$') < 0) { // no dollar substitution, we can check if the state exists
  46934. if (!monarchCommon.stateExists(lexer, monarchCommon.substituteMatches(lexer, next, '', [], ''))) {
  46935. throw monarchCommon.createError(lexer, 'the next state \'' + action.next + '\' is not defined in rule: ' + ruleName);
  46936. }
  46937. }
  46938. }
  46939. newAction.next = next;
  46940. }
  46941. }
  46942. if (typeof (action.goBack) === 'number') {
  46943. newAction.goBack = action.goBack;
  46944. }
  46945. if (typeof (action.switchTo) === 'string') {
  46946. newAction.switchTo = action.switchTo;
  46947. }
  46948. if (typeof (action.log) === 'string') {
  46949. newAction.log = action.log;
  46950. }
  46951. if (typeof (action.nextEmbedded) === 'string') {
  46952. newAction.nextEmbedded = action.nextEmbedded;
  46953. lexer.usesEmbedded = true;
  46954. }
  46955. return newAction;
  46956. }
  46957. }
  46958. else if (Array.isArray(action)) {
  46959. var results = [];
  46960. for (var i = 0, len = action.length; i < len; i++) {
  46961. results[i] = compileAction(lexer, ruleName, action[i]);
  46962. }
  46963. return { group: results };
  46964. }
  46965. else if (action.cases) {
  46966. // build an array of test cases
  46967. var cases_1 = [];
  46968. // for each case, push a test function and result value
  46969. for (var tkey in action.cases) {
  46970. if (action.cases.hasOwnProperty(tkey)) {
  46971. var val = compileAction(lexer, ruleName, action.cases[tkey]);
  46972. // what kind of case
  46973. if (tkey === '@default' || tkey === '@' || tkey === '') {
  46974. cases_1.push({ test: undefined, value: val, name: tkey });
  46975. }
  46976. else if (tkey === '@eos') {
  46977. cases_1.push({ test: function (id, matches, state, eos) { return eos; }, value: val, name: tkey });
  46978. }
  46979. else {
  46980. cases_1.push(createGuard(lexer, ruleName, tkey, val)); // call separate function to avoid local variable capture
  46981. }
  46982. }
  46983. }
  46984. // create a matching function
  46985. var def_1 = lexer.defaultToken;
  46986. return {
  46987. test: function (id, matches, state, eos) {
  46988. for (var _i = 0, cases_2 = cases_1; _i < cases_2.length; _i++) {
  46989. var _case = cases_2[_i];
  46990. var didmatch = (!_case.test || _case.test(id, matches, state, eos));
  46991. if (didmatch) {
  46992. return _case.value;
  46993. }
  46994. }
  46995. return def_1;
  46996. }
  46997. };
  46998. }
  46999. else {
  47000. throw monarchCommon.createError(lexer, 'an action must be a string, an object with a \'token\' or \'cases\' attribute, or an array of actions; in rule: ' + ruleName);
  47001. }
  47002. }
  47003. /**
  47004. * Helper class for creating matching rules
  47005. */
  47006. var Rule = /** @class */ (function () {
  47007. function Rule(name) {
  47008. this.regex = new RegExp('');
  47009. this.action = { token: '' };
  47010. this.matchOnlyAtLineStart = false;
  47011. this.name = '';
  47012. this.name = name;
  47013. }
  47014. Rule.prototype.setRegex = function (lexer, re) {
  47015. var sregex;
  47016. if (typeof (re) === 'string') {
  47017. sregex = re;
  47018. }
  47019. else if (re instanceof RegExp) {
  47020. sregex = re.source;
  47021. }
  47022. else {
  47023. throw monarchCommon.createError(lexer, 'rules must start with a match string or regular expression: ' + this.name);
  47024. }
  47025. this.matchOnlyAtLineStart = (sregex.length > 0 && sregex[0] === '^');
  47026. this.name = this.name + ': ' + sregex;
  47027. this.regex = compileRegExp(lexer, '^(?:' + (this.matchOnlyAtLineStart ? sregex.substr(1) : sregex) + ')');
  47028. };
  47029. Rule.prototype.setAction = function (lexer, act) {
  47030. this.action = compileAction(lexer, this.name, act);
  47031. };
  47032. return Rule;
  47033. }());
  47034. /**
  47035. * Compiles a json description function into json where all regular expressions,
  47036. * case matches etc, are compiled and all include rules are expanded.
  47037. * We also compile the bracket definitions, supply defaults, and do many sanity checks.
  47038. * If the 'jsonStrict' parameter is 'false', we allow at certain locations
  47039. * regular expression objects and functions that get called during lexing.
  47040. * (Currently we have no samples that need this so perhaps we should always have
  47041. * jsonStrict to true).
  47042. */
  47043. function compile(languageId, json) {
  47044. if (!json || typeof (json) !== 'object') {
  47045. throw new Error('Monarch: expecting a language definition object');
  47046. }
  47047. // Create our lexer
  47048. var lexer = {};
  47049. lexer.languageId = languageId;
  47050. lexer.noThrow = false; // raise exceptions during compilation
  47051. lexer.maxStack = 100;
  47052. // Set standard fields: be defensive about types
  47053. lexer.start = (typeof json.start === 'string' ? json.start : null);
  47054. lexer.ignoreCase = bool(json.ignoreCase, false);
  47055. lexer.tokenPostfix = string(json.tokenPostfix, '.' + lexer.languageId);
  47056. lexer.defaultToken = string(json.defaultToken, 'source');
  47057. lexer.usesEmbedded = false; // becomes true if we find a nextEmbedded action
  47058. // For calling compileAction later on
  47059. var lexerMin = json;
  47060. lexerMin.languageId = languageId;
  47061. lexerMin.ignoreCase = lexer.ignoreCase;
  47062. lexerMin.noThrow = lexer.noThrow;
  47063. lexerMin.usesEmbedded = lexer.usesEmbedded;
  47064. lexerMin.stateNames = json.tokenizer;
  47065. lexerMin.defaultToken = lexer.defaultToken;
  47066. // Compile an array of rules into newrules where RegExp objects are created.
  47067. function addRules(state, newrules, rules) {
  47068. for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) {
  47069. var rule = rules_1[_i];
  47070. var include = rule.include;
  47071. if (include) {
  47072. if (typeof (include) !== 'string') {
  47073. throw monarchCommon.createError(lexer, 'an \'include\' attribute must be a string at: ' + state);
  47074. }
  47075. if (include[0] === '@') {
  47076. include = include.substr(1); // peel off starting @
  47077. }
  47078. if (!json.tokenizer[include]) {
  47079. throw monarchCommon.createError(lexer, 'include target \'' + include + '\' is not defined at: ' + state);
  47080. }
  47081. addRules(state + '.' + include, newrules, json.tokenizer[include]);
  47082. }
  47083. else {
  47084. var newrule = new Rule(state);
  47085. // Set up new rule attributes
  47086. if (Array.isArray(rule) && rule.length >= 1 && rule.length <= 3) {
  47087. newrule.setRegex(lexerMin, rule[0]);
  47088. if (rule.length >= 3) {
  47089. if (typeof (rule[1]) === 'string') {
  47090. newrule.setAction(lexerMin, { token: rule[1], next: rule[2] });
  47091. }
  47092. else if (typeof (rule[1]) === 'object') {
  47093. var rule1 = rule[1];
  47094. rule1.next = rule[2];
  47095. newrule.setAction(lexerMin, rule1);
  47096. }
  47097. else {
  47098. throw monarchCommon.createError(lexer, 'a next state as the last element of a rule can only be given if the action is either an object or a string, at: ' + state);
  47099. }
  47100. }
  47101. else {
  47102. newrule.setAction(lexerMin, rule[1]);
  47103. }
  47104. }
  47105. else {
  47106. if (!rule.regex) {
  47107. throw monarchCommon.createError(lexer, 'a rule must either be an array, or an object with a \'regex\' or \'include\' field at: ' + state);
  47108. }
  47109. if (rule.name) {
  47110. if (typeof rule.name === 'string') {
  47111. newrule.name = rule.name;
  47112. }
  47113. }
  47114. if (rule.matchOnlyAtStart) {
  47115. newrule.matchOnlyAtLineStart = bool(rule.matchOnlyAtLineStart, false);
  47116. }
  47117. newrule.setRegex(lexerMin, rule.regex);
  47118. newrule.setAction(lexerMin, rule.action);
  47119. }
  47120. newrules.push(newrule);
  47121. }
  47122. }
  47123. }
  47124. // compile the tokenizer rules
  47125. if (!json.tokenizer || typeof (json.tokenizer) !== 'object') {
  47126. throw monarchCommon.createError(lexer, 'a language definition must define the \'tokenizer\' attribute as an object');
  47127. }
  47128. lexer.tokenizer = [];
  47129. for (var key in json.tokenizer) {
  47130. if (json.tokenizer.hasOwnProperty(key)) {
  47131. if (!lexer.start) {
  47132. lexer.start = key;
  47133. }
  47134. var rules = json.tokenizer[key];
  47135. lexer.tokenizer[key] = new Array();
  47136. addRules('tokenizer.' + key, lexer.tokenizer[key], rules);
  47137. }
  47138. }
  47139. lexer.usesEmbedded = lexerMin.usesEmbedded; // can be set during compileAction
  47140. // Set simple brackets
  47141. if (json.brackets) {
  47142. if (!(Array.isArray(json.brackets))) {
  47143. throw monarchCommon.createError(lexer, 'the \'brackets\' attribute must be defined as an array');
  47144. }
  47145. }
  47146. else {
  47147. json.brackets = [
  47148. { open: '{', close: '}', token: 'delimiter.curly' },
  47149. { open: '[', close: ']', token: 'delimiter.square' },
  47150. { open: '(', close: ')', token: 'delimiter.parenthesis' },
  47151. { open: '<', close: '>', token: 'delimiter.angle' }
  47152. ];
  47153. }
  47154. var brackets = [];
  47155. for (var _i = 0, _a = json.brackets; _i < _a.length; _i++) {
  47156. var el = _a[_i];
  47157. var desc = el;
  47158. if (desc && Array.isArray(desc) && desc.length === 3) {
  47159. desc = { token: desc[2], open: desc[0], close: desc[1] };
  47160. }
  47161. if (desc.open === desc.close) {
  47162. throw monarchCommon.createError(lexer, 'open and close brackets in a \'brackets\' attribute must be different: ' + desc.open +
  47163. '\n hint: use the \'bracket\' attribute if matching on equal brackets is required.');
  47164. }
  47165. if (typeof desc.open === 'string' && typeof desc.token === 'string' && typeof desc.close === 'string') {
  47166. brackets.push({
  47167. token: desc.token + lexer.tokenPostfix,
  47168. open: monarchCommon.fixCase(lexer, desc.open),
  47169. close: monarchCommon.fixCase(lexer, desc.close)
  47170. });
  47171. }
  47172. else {
  47173. throw monarchCommon.createError(lexer, 'every element in the \'brackets\' array must be a \'{open,close,token}\' object or array');
  47174. }
  47175. }
  47176. lexer.brackets = brackets;
  47177. // Disable throw so the syntax highlighter goes, no matter what
  47178. lexer.noThrow = true;
  47179. return lexer;
  47180. }
  47181. exports.compile = compile;
  47182. });
  47183. define(__m[394/*vs/nls!vs/base/browser/ui/actionbar/actionbar*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/browser/ui/actionbar/actionbar", data); });
  47184. /*---------------------------------------------------------------------------------------------
  47185. * Copyright (c) Microsoft Corporation. All rights reserved.
  47186. * Licensed under the MIT License. See License.txt in the project root for license information.
  47187. *--------------------------------------------------------------------------------------------*/
  47188. define(__m[70/*vs/base/browser/ui/actionbar/actionbar*/], __M([0/*require*/,1/*exports*/,16/*vs/base/common/platform*/,394/*vs/nls!vs/base/browser/ui/actionbar/actionbar*/,2/*vs/base/common/lifecycle*/,55/*vs/base/common/actions*/,6/*vs/base/browser/dom*/,21/*vs/base/common/types*/,57/*vs/base/browser/touch*/,56/*vs/base/browser/keyboardEvent*/,4/*vs/base/common/event*/,98/*vs/base/browser/dnd*/,24/*vs/base/browser/browser*/,259/*vs/css!vs/base/browser/ui/actionbar/actionbar*/]), function (require, exports, platform, nls, lifecycle_1, actions_1, DOM, types, touch_1, keyboardEvent_1, event_1, dnd_1, browser_1) {
  47189. "use strict";
  47190. Object.defineProperty(exports, "__esModule", { value: true });
  47191. var BaseActionViewItem = /** @class */ (function (_super) {
  47192. __extends(BaseActionViewItem, _super);
  47193. function BaseActionViewItem(context, action, options) {
  47194. var _this = _super.call(this) || this;
  47195. _this.options = options;
  47196. _this._context = context || _this;
  47197. _this._action = action;
  47198. if (action instanceof actions_1.Action) {
  47199. _this._register(action.onDidChange(function (event) {
  47200. if (!_this.element) {
  47201. // we have not been rendered yet, so there
  47202. // is no point in updating the UI
  47203. return;
  47204. }
  47205. _this.handleActionChangeEvent(event);
  47206. }));
  47207. }
  47208. return _this;
  47209. }
  47210. BaseActionViewItem.prototype.handleActionChangeEvent = function (event) {
  47211. if (event.enabled !== undefined) {
  47212. this.updateEnabled();
  47213. }
  47214. if (event.checked !== undefined) {
  47215. this.updateChecked();
  47216. }
  47217. if (event.class !== undefined) {
  47218. this.updateClass();
  47219. }
  47220. if (event.label !== undefined) {
  47221. this.updateLabel();
  47222. this.updateTooltip();
  47223. }
  47224. if (event.tooltip !== undefined) {
  47225. this.updateTooltip();
  47226. }
  47227. };
  47228. Object.defineProperty(BaseActionViewItem.prototype, "actionRunner", {
  47229. get: function () {
  47230. if (!this._actionRunner) {
  47231. this._actionRunner = this._register(new actions_1.ActionRunner());
  47232. }
  47233. return this._actionRunner;
  47234. },
  47235. set: function (actionRunner) {
  47236. this._actionRunner = actionRunner;
  47237. },
  47238. enumerable: true,
  47239. configurable: true
  47240. });
  47241. BaseActionViewItem.prototype.getAction = function () {
  47242. return this._action;
  47243. };
  47244. BaseActionViewItem.prototype.isEnabled = function () {
  47245. return this._action.enabled;
  47246. };
  47247. BaseActionViewItem.prototype.setActionContext = function (newContext) {
  47248. this._context = newContext;
  47249. };
  47250. BaseActionViewItem.prototype.render = function (container) {
  47251. var _this = this;
  47252. var element = this.element = container;
  47253. this._register(touch_1.Gesture.addTarget(container));
  47254. var enableDragging = this.options && this.options.draggable;
  47255. if (enableDragging) {
  47256. container.draggable = true;
  47257. if (browser_1.isFirefox) {
  47258. // Firefox: requires to set a text data transfer to get going
  47259. this._register(DOM.addDisposableListener(container, DOM.EventType.DRAG_START, function (e) { var _a; return (_a = e.dataTransfer) === null || _a === void 0 ? void 0 : _a.setData(dnd_1.DataTransfers.TEXT, _this._action.label); }));
  47260. }
  47261. }
  47262. this._register(DOM.addDisposableListener(element, touch_1.EventType.Tap, function (e) { return _this.onClick(e); }));
  47263. this._register(DOM.addDisposableListener(element, DOM.EventType.MOUSE_DOWN, function (e) {
  47264. if (!enableDragging) {
  47265. DOM.EventHelper.stop(e, true); // do not run when dragging is on because that would disable it
  47266. }
  47267. if (_this._action.enabled && e.button === 0) {
  47268. DOM.addClass(element, 'active');
  47269. }
  47270. }));
  47271. this._register(DOM.addDisposableListener(element, DOM.EventType.CLICK, function (e) {
  47272. DOM.EventHelper.stop(e, true);
  47273. // See https://developer.mozilla.org/en-US/Add-ons/WebExtensions/Interact_with_the_clipboard
  47274. // > Writing to the clipboard
  47275. // > You can use the "cut" and "copy" commands without any special
  47276. // permission if you are using them in a short-lived event handler
  47277. // for a user action (for example, a click handler).
  47278. // => to get the Copy and Paste context menu actions working on Firefox,
  47279. // there should be no timeout here
  47280. if (_this.options && _this.options.isMenu) {
  47281. _this.onClick(e);
  47282. }
  47283. else {
  47284. platform.setImmediate(function () { return _this.onClick(e); });
  47285. }
  47286. }));
  47287. this._register(DOM.addDisposableListener(element, DOM.EventType.DBLCLICK, function (e) {
  47288. DOM.EventHelper.stop(e, true);
  47289. }));
  47290. [DOM.EventType.MOUSE_UP, DOM.EventType.MOUSE_OUT].forEach(function (event) {
  47291. _this._register(DOM.addDisposableListener(element, event, function (e) {
  47292. DOM.EventHelper.stop(e);
  47293. DOM.removeClass(element, 'active');
  47294. }));
  47295. });
  47296. };
  47297. BaseActionViewItem.prototype.onClick = function (event) {
  47298. DOM.EventHelper.stop(event, true);
  47299. var context;
  47300. if (types.isUndefinedOrNull(this._context)) {
  47301. context = event;
  47302. }
  47303. else {
  47304. context = this._context;
  47305. if (types.isObject(context)) {
  47306. context.event = event;
  47307. }
  47308. }
  47309. this.actionRunner.run(this._action, context);
  47310. };
  47311. BaseActionViewItem.prototype.focus = function () {
  47312. if (this.element) {
  47313. this.element.focus();
  47314. DOM.addClass(this.element, 'focused');
  47315. }
  47316. };
  47317. BaseActionViewItem.prototype.blur = function () {
  47318. if (this.element) {
  47319. this.element.blur();
  47320. DOM.removeClass(this.element, 'focused');
  47321. }
  47322. };
  47323. BaseActionViewItem.prototype.updateEnabled = function () {
  47324. // implement in subclass
  47325. };
  47326. BaseActionViewItem.prototype.updateLabel = function () {
  47327. // implement in subclass
  47328. };
  47329. BaseActionViewItem.prototype.updateTooltip = function () {
  47330. // implement in subclass
  47331. };
  47332. BaseActionViewItem.prototype.updateClass = function () {
  47333. // implement in subclass
  47334. };
  47335. BaseActionViewItem.prototype.updateChecked = function () {
  47336. // implement in subclass
  47337. };
  47338. BaseActionViewItem.prototype.dispose = function () {
  47339. if (this.element) {
  47340. DOM.removeNode(this.element);
  47341. this.element = undefined;
  47342. }
  47343. _super.prototype.dispose.call(this);
  47344. };
  47345. return BaseActionViewItem;
  47346. }(lifecycle_1.Disposable));
  47347. exports.BaseActionViewItem = BaseActionViewItem;
  47348. var Separator = /** @class */ (function (_super) {
  47349. __extends(Separator, _super);
  47350. function Separator(label) {
  47351. var _this = _super.call(this, Separator.ID, label, label ? 'separator text' : 'separator') || this;
  47352. _this.checked = false;
  47353. _this.enabled = false;
  47354. return _this;
  47355. }
  47356. Separator.ID = 'vs.actions.separator';
  47357. return Separator;
  47358. }(actions_1.Action));
  47359. exports.Separator = Separator;
  47360. var ActionViewItem = /** @class */ (function (_super) {
  47361. __extends(ActionViewItem, _super);
  47362. function ActionViewItem(context, action, options) {
  47363. if (options === void 0) { options = {}; }
  47364. var _this = _super.call(this, context, action, options) || this;
  47365. _this.options = options;
  47366. _this.options.icon = options.icon !== undefined ? options.icon : false;
  47367. _this.options.label = options.label !== undefined ? options.label : true;
  47368. _this.cssClass = '';
  47369. return _this;
  47370. }
  47371. ActionViewItem.prototype.render = function (container) {
  47372. _super.prototype.render.call(this, container);
  47373. if (this.element) {
  47374. this.label = DOM.append(this.element, DOM.$('a.action-label'));
  47375. }
  47376. if (this.label) {
  47377. if (this._action.id === Separator.ID) {
  47378. this.label.setAttribute('role', 'presentation'); // A separator is a presentation item
  47379. }
  47380. else {
  47381. if (this.options.isMenu) {
  47382. this.label.setAttribute('role', 'menuitem');
  47383. }
  47384. else {
  47385. this.label.setAttribute('role', 'button');
  47386. }
  47387. }
  47388. }
  47389. if (this.options.label && this.options.keybinding && this.element) {
  47390. DOM.append(this.element, DOM.$('span.keybinding')).textContent = this.options.keybinding;
  47391. }
  47392. this.updateClass();
  47393. this.updateLabel();
  47394. this.updateTooltip();
  47395. this.updateEnabled();
  47396. this.updateChecked();
  47397. };
  47398. ActionViewItem.prototype.focus = function () {
  47399. _super.prototype.focus.call(this);
  47400. if (this.label) {
  47401. this.label.focus();
  47402. }
  47403. };
  47404. ActionViewItem.prototype.updateLabel = function () {
  47405. if (this.options.label && this.label) {
  47406. this.label.textContent = this.getAction().label;
  47407. }
  47408. };
  47409. ActionViewItem.prototype.updateTooltip = function () {
  47410. var title = null;
  47411. if (this.getAction().tooltip) {
  47412. title = this.getAction().tooltip;
  47413. }
  47414. else if (!this.options.label && this.getAction().label && this.options.icon) {
  47415. title = this.getAction().label;
  47416. if (this.options.keybinding) {
  47417. title = nls.localize(0, null, title, this.options.keybinding);
  47418. }
  47419. }
  47420. if (title && this.label) {
  47421. this.label.title = title;
  47422. }
  47423. };
  47424. ActionViewItem.prototype.updateClass = function () {
  47425. if (this.cssClass && this.label) {
  47426. DOM.removeClasses(this.label, this.cssClass);
  47427. }
  47428. if (this.options.icon) {
  47429. this.cssClass = this.getAction().class;
  47430. if (this.label) {
  47431. DOM.addClass(this.label, 'codicon');
  47432. if (this.cssClass) {
  47433. DOM.addClasses(this.label, this.cssClass);
  47434. }
  47435. }
  47436. this.updateEnabled();
  47437. }
  47438. else {
  47439. if (this.label) {
  47440. DOM.removeClass(this.label, 'codicon');
  47441. }
  47442. }
  47443. };
  47444. ActionViewItem.prototype.updateEnabled = function () {
  47445. if (this.getAction().enabled) {
  47446. if (this.label) {
  47447. this.label.removeAttribute('aria-disabled');
  47448. DOM.removeClass(this.label, 'disabled');
  47449. this.label.tabIndex = 0;
  47450. }
  47451. if (this.element) {
  47452. DOM.removeClass(this.element, 'disabled');
  47453. }
  47454. }
  47455. else {
  47456. if (this.label) {
  47457. this.label.setAttribute('aria-disabled', 'true');
  47458. DOM.addClass(this.label, 'disabled');
  47459. DOM.removeTabIndexAndUpdateFocus(this.label);
  47460. }
  47461. if (this.element) {
  47462. DOM.addClass(this.element, 'disabled');
  47463. }
  47464. }
  47465. };
  47466. ActionViewItem.prototype.updateChecked = function () {
  47467. if (this.label) {
  47468. if (this.getAction().checked) {
  47469. DOM.addClass(this.label, 'checked');
  47470. }
  47471. else {
  47472. DOM.removeClass(this.label, 'checked');
  47473. }
  47474. }
  47475. };
  47476. return ActionViewItem;
  47477. }(BaseActionViewItem));
  47478. exports.ActionViewItem = ActionViewItem;
  47479. var defaultOptions = {
  47480. orientation: 0 /* HORIZONTAL */,
  47481. context: null,
  47482. triggerKeys: {
  47483. keys: [3 /* Enter */, 10 /* Space */],
  47484. keyDown: false
  47485. }
  47486. };
  47487. var ActionBar = /** @class */ (function (_super) {
  47488. __extends(ActionBar, _super);
  47489. function ActionBar(container, options) {
  47490. if (options === void 0) { options = defaultOptions; }
  47491. var _this = _super.call(this) || this;
  47492. _this._onDidBlur = _this._register(new event_1.Emitter());
  47493. _this.onDidBlur = _this._onDidBlur.event;
  47494. _this._onDidCancel = _this._register(new event_1.Emitter());
  47495. _this.onDidCancel = _this._onDidCancel.event;
  47496. _this._onDidRun = _this._register(new event_1.Emitter());
  47497. _this.onDidRun = _this._onDidRun.event;
  47498. _this._onDidBeforeRun = _this._register(new event_1.Emitter());
  47499. _this.onDidBeforeRun = _this._onDidBeforeRun.event;
  47500. _this.options = options;
  47501. _this._context = options.context;
  47502. if (!_this.options.triggerKeys) {
  47503. _this.options.triggerKeys = defaultOptions.triggerKeys;
  47504. }
  47505. if (_this.options.actionRunner) {
  47506. _this._actionRunner = _this.options.actionRunner;
  47507. }
  47508. else {
  47509. _this._actionRunner = new actions_1.ActionRunner();
  47510. _this._register(_this._actionRunner);
  47511. }
  47512. _this._register(_this._actionRunner.onDidRun(function (e) { return _this._onDidRun.fire(e); }));
  47513. _this._register(_this._actionRunner.onDidBeforeRun(function (e) { return _this._onDidBeforeRun.fire(e); }));
  47514. _this.viewItems = [];
  47515. _this.focusedItem = undefined;
  47516. _this.domNode = document.createElement('div');
  47517. _this.domNode.className = 'monaco-action-bar';
  47518. if (options.animated !== false) {
  47519. DOM.addClass(_this.domNode, 'animated');
  47520. }
  47521. var previousKey;
  47522. var nextKey;
  47523. switch (_this.options.orientation) {
  47524. case 0 /* HORIZONTAL */:
  47525. previousKey = 15 /* LeftArrow */;
  47526. nextKey = 17 /* RightArrow */;
  47527. break;
  47528. case 1 /* HORIZONTAL_REVERSE */:
  47529. previousKey = 17 /* RightArrow */;
  47530. nextKey = 15 /* LeftArrow */;
  47531. _this.domNode.className += ' reverse';
  47532. break;
  47533. case 2 /* VERTICAL */:
  47534. previousKey = 16 /* UpArrow */;
  47535. nextKey = 18 /* DownArrow */;
  47536. _this.domNode.className += ' vertical';
  47537. break;
  47538. case 3 /* VERTICAL_REVERSE */:
  47539. previousKey = 18 /* DownArrow */;
  47540. nextKey = 16 /* UpArrow */;
  47541. _this.domNode.className += ' vertical reverse';
  47542. break;
  47543. }
  47544. _this._register(DOM.addDisposableListener(_this.domNode, DOM.EventType.KEY_DOWN, function (e) {
  47545. var event = new keyboardEvent_1.StandardKeyboardEvent(e);
  47546. var eventHandled = true;
  47547. if (event.equals(previousKey)) {
  47548. _this.focusPrevious();
  47549. }
  47550. else if (event.equals(nextKey)) {
  47551. _this.focusNext();
  47552. }
  47553. else if (event.equals(9 /* Escape */)) {
  47554. _this.cancel();
  47555. }
  47556. else if (_this.isTriggerKeyEvent(event)) {
  47557. // Staying out of the else branch even if not triggered
  47558. if (_this.options.triggerKeys && _this.options.triggerKeys.keyDown) {
  47559. _this.doTrigger(event);
  47560. }
  47561. }
  47562. else {
  47563. eventHandled = false;
  47564. }
  47565. if (eventHandled) {
  47566. event.preventDefault();
  47567. event.stopPropagation();
  47568. }
  47569. }));
  47570. _this._register(DOM.addDisposableListener(_this.domNode, DOM.EventType.KEY_UP, function (e) {
  47571. var event = new keyboardEvent_1.StandardKeyboardEvent(e);
  47572. // Run action on Enter/Space
  47573. if (_this.isTriggerKeyEvent(event)) {
  47574. if (_this.options.triggerKeys && !_this.options.triggerKeys.keyDown) {
  47575. _this.doTrigger(event);
  47576. }
  47577. event.preventDefault();
  47578. event.stopPropagation();
  47579. }
  47580. // Recompute focused item
  47581. else if (event.equals(2 /* Tab */) || event.equals(1024 /* Shift */ | 2 /* Tab */)) {
  47582. _this.updateFocusedItem();
  47583. }
  47584. }));
  47585. _this.focusTracker = _this._register(DOM.trackFocus(_this.domNode));
  47586. _this._register(_this.focusTracker.onDidBlur(function () {
  47587. if (document.activeElement === _this.domNode || !DOM.isAncestor(document.activeElement, _this.domNode)) {
  47588. _this._onDidBlur.fire();
  47589. _this.focusedItem = undefined;
  47590. }
  47591. }));
  47592. _this._register(_this.focusTracker.onDidFocus(function () { return _this.updateFocusedItem(); }));
  47593. _this.actionsList = document.createElement('ul');
  47594. _this.actionsList.className = 'actions-container';
  47595. _this.actionsList.setAttribute('role', 'toolbar');
  47596. if (_this.options.ariaLabel) {
  47597. _this.actionsList.setAttribute('aria-label', _this.options.ariaLabel);
  47598. }
  47599. _this.domNode.appendChild(_this.actionsList);
  47600. container.appendChild(_this.domNode);
  47601. return _this;
  47602. }
  47603. ActionBar.prototype.isTriggerKeyEvent = function (event) {
  47604. var ret = false;
  47605. if (this.options.triggerKeys) {
  47606. this.options.triggerKeys.keys.forEach(function (keyCode) {
  47607. ret = ret || event.equals(keyCode);
  47608. });
  47609. }
  47610. return ret;
  47611. };
  47612. ActionBar.prototype.updateFocusedItem = function () {
  47613. for (var i = 0; i < this.actionsList.children.length; i++) {
  47614. var elem = this.actionsList.children[i];
  47615. if (DOM.isAncestor(document.activeElement, elem)) {
  47616. this.focusedItem = i;
  47617. break;
  47618. }
  47619. }
  47620. };
  47621. Object.defineProperty(ActionBar.prototype, "context", {
  47622. get: function () {
  47623. return this._context;
  47624. },
  47625. set: function (context) {
  47626. this._context = context;
  47627. this.viewItems.forEach(function (i) { return i.setActionContext(context); });
  47628. },
  47629. enumerable: true,
  47630. configurable: true
  47631. });
  47632. ActionBar.prototype.getContainer = function () {
  47633. return this.domNode;
  47634. };
  47635. ActionBar.prototype.push = function (arg, options) {
  47636. var _this = this;
  47637. if (options === void 0) { options = {}; }
  47638. var actions = Array.isArray(arg) ? arg : [arg];
  47639. var index = types.isNumber(options.index) ? options.index : null;
  47640. actions.forEach(function (action) {
  47641. var actionViewItemElement = document.createElement('li');
  47642. actionViewItemElement.className = 'action-item';
  47643. actionViewItemElement.setAttribute('role', 'presentation');
  47644. // Prevent native context menu on actions
  47645. _this._register(DOM.addDisposableListener(actionViewItemElement, DOM.EventType.CONTEXT_MENU, function (e) {
  47646. e.preventDefault();
  47647. e.stopPropagation();
  47648. }));
  47649. var item;
  47650. if (_this.options.actionViewItemProvider) {
  47651. item = _this.options.actionViewItemProvider(action);
  47652. }
  47653. if (!item) {
  47654. item = new ActionViewItem(_this.context, action, options);
  47655. }
  47656. item.actionRunner = _this._actionRunner;
  47657. item.setActionContext(_this.context);
  47658. item.render(actionViewItemElement);
  47659. if (index === null || index < 0 || index >= _this.actionsList.children.length) {
  47660. _this.actionsList.appendChild(actionViewItemElement);
  47661. _this.viewItems.push(item);
  47662. }
  47663. else {
  47664. _this.actionsList.insertBefore(actionViewItemElement, _this.actionsList.children[index]);
  47665. _this.viewItems.splice(index, 0, item);
  47666. index++;
  47667. }
  47668. });
  47669. };
  47670. ActionBar.prototype.clear = function () {
  47671. this.viewItems = lifecycle_1.dispose(this.viewItems);
  47672. DOM.clearNode(this.actionsList);
  47673. };
  47674. ActionBar.prototype.isEmpty = function () {
  47675. return this.viewItems.length === 0;
  47676. };
  47677. ActionBar.prototype.focus = function (arg) {
  47678. var selectFirst = false;
  47679. var index = undefined;
  47680. if (arg === undefined) {
  47681. selectFirst = true;
  47682. }
  47683. else if (typeof arg === 'number') {
  47684. index = arg;
  47685. }
  47686. else if (typeof arg === 'boolean') {
  47687. selectFirst = arg;
  47688. }
  47689. if (selectFirst && typeof this.focusedItem === 'undefined') {
  47690. // Focus the first enabled item
  47691. this.focusedItem = this.viewItems.length - 1;
  47692. this.focusNext();
  47693. }
  47694. else {
  47695. if (index !== undefined) {
  47696. this.focusedItem = index;
  47697. }
  47698. this.updateFocus();
  47699. }
  47700. };
  47701. ActionBar.prototype.focusNext = function () {
  47702. if (typeof this.focusedItem === 'undefined') {
  47703. this.focusedItem = this.viewItems.length - 1;
  47704. }
  47705. var startIndex = this.focusedItem;
  47706. var item;
  47707. do {
  47708. this.focusedItem = (this.focusedItem + 1) % this.viewItems.length;
  47709. item = this.viewItems[this.focusedItem];
  47710. } while (this.focusedItem !== startIndex && !item.isEnabled());
  47711. if (this.focusedItem === startIndex && !item.isEnabled()) {
  47712. this.focusedItem = undefined;
  47713. }
  47714. this.updateFocus();
  47715. };
  47716. ActionBar.prototype.focusPrevious = function () {
  47717. if (typeof this.focusedItem === 'undefined') {
  47718. this.focusedItem = 0;
  47719. }
  47720. var startIndex = this.focusedItem;
  47721. var item;
  47722. do {
  47723. this.focusedItem = this.focusedItem - 1;
  47724. if (this.focusedItem < 0) {
  47725. this.focusedItem = this.viewItems.length - 1;
  47726. }
  47727. item = this.viewItems[this.focusedItem];
  47728. } while (this.focusedItem !== startIndex && !item.isEnabled());
  47729. if (this.focusedItem === startIndex && !item.isEnabled()) {
  47730. this.focusedItem = undefined;
  47731. }
  47732. this.updateFocus(true);
  47733. };
  47734. ActionBar.prototype.updateFocus = function (fromRight, preventScroll) {
  47735. if (typeof this.focusedItem === 'undefined') {
  47736. this.actionsList.focus({ preventScroll: preventScroll });
  47737. }
  47738. for (var i = 0; i < this.viewItems.length; i++) {
  47739. var item = this.viewItems[i];
  47740. var actionViewItem = item;
  47741. if (i === this.focusedItem) {
  47742. if (types.isFunction(actionViewItem.isEnabled)) {
  47743. if (actionViewItem.isEnabled() && types.isFunction(actionViewItem.focus)) {
  47744. actionViewItem.focus(fromRight);
  47745. }
  47746. else {
  47747. this.actionsList.focus({ preventScroll: preventScroll });
  47748. }
  47749. }
  47750. }
  47751. else {
  47752. if (types.isFunction(actionViewItem.blur)) {
  47753. actionViewItem.blur();
  47754. }
  47755. }
  47756. }
  47757. };
  47758. ActionBar.prototype.doTrigger = function (event) {
  47759. if (typeof this.focusedItem === 'undefined') {
  47760. return; //nothing to focus
  47761. }
  47762. // trigger action
  47763. var actionViewItem = this.viewItems[this.focusedItem];
  47764. if (actionViewItem instanceof BaseActionViewItem) {
  47765. var context = (actionViewItem._context === null || actionViewItem._context === undefined) ? event : actionViewItem._context;
  47766. this.run(actionViewItem._action, context);
  47767. }
  47768. };
  47769. ActionBar.prototype.cancel = function () {
  47770. if (document.activeElement instanceof HTMLElement) {
  47771. document.activeElement.blur(); // remove focus from focused action
  47772. }
  47773. this._onDidCancel.fire();
  47774. };
  47775. ActionBar.prototype.run = function (action, context) {
  47776. return this._actionRunner.run(action, context);
  47777. };
  47778. ActionBar.prototype.dispose = function () {
  47779. lifecycle_1.dispose(this.viewItems);
  47780. this.viewItems = [];
  47781. DOM.removeNode(this.getContainer());
  47782. _super.prototype.dispose.call(this);
  47783. };
  47784. return ActionBar;
  47785. }(lifecycle_1.Disposable));
  47786. exports.ActionBar = ActionBar;
  47787. });
  47788. define(__m[395/*vs/nls!vs/base/browser/ui/aria/aria*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/browser/ui/aria/aria", data); });
  47789. /*---------------------------------------------------------------------------------------------
  47790. * Copyright (c) Microsoft Corporation. All rights reserved.
  47791. * Licensed under the MIT License. See License.txt in the project root for license information.
  47792. *--------------------------------------------------------------------------------------------*/
  47793. define(__m[50/*vs/base/browser/ui/aria/aria*/], __M([0/*require*/,1/*exports*/,395/*vs/nls!vs/base/browser/ui/aria/aria*/,16/*vs/base/common/platform*/,6/*vs/base/browser/dom*/,260/*vs/css!vs/base/browser/ui/aria/aria*/]), function (require, exports, nls, platform_1, dom) {
  47794. "use strict";
  47795. Object.defineProperty(exports, "__esModule", { value: true });
  47796. var ariaContainer;
  47797. var alertContainer;
  47798. var statusContainer;
  47799. function setARIAContainer(parent) {
  47800. ariaContainer = document.createElement('div');
  47801. ariaContainer.className = 'monaco-aria-container';
  47802. alertContainer = document.createElement('div');
  47803. alertContainer.className = 'monaco-alert';
  47804. alertContainer.setAttribute('role', 'alert');
  47805. alertContainer.setAttribute('aria-atomic', 'true');
  47806. ariaContainer.appendChild(alertContainer);
  47807. statusContainer = document.createElement('div');
  47808. statusContainer.className = 'monaco-status';
  47809. statusContainer.setAttribute('role', 'status');
  47810. statusContainer.setAttribute('aria-atomic', 'true');
  47811. ariaContainer.appendChild(statusContainer);
  47812. parent.appendChild(ariaContainer);
  47813. }
  47814. exports.setARIAContainer = setARIAContainer;
  47815. /**
  47816. * Given the provided message, will make sure that it is read as alert to screen readers.
  47817. */
  47818. function alert(msg, disableRepeat) {
  47819. insertMessage(alertContainer, msg, disableRepeat);
  47820. }
  47821. exports.alert = alert;
  47822. /**
  47823. * Given the provided message, will make sure that it is read as status to screen readers.
  47824. */
  47825. function status(msg, disableRepeat) {
  47826. if (platform_1.isMacintosh) {
  47827. alert(msg, disableRepeat); // VoiceOver does not seem to support status role
  47828. }
  47829. else {
  47830. insertMessage(statusContainer, msg, disableRepeat);
  47831. }
  47832. }
  47833. exports.status = status;
  47834. var repeatedTimes = 0;
  47835. var prevText = undefined;
  47836. function insertMessage(target, msg, disableRepeat) {
  47837. if (!ariaContainer) {
  47838. return;
  47839. }
  47840. // If the same message should be inserted that is already present, a screen reader would
  47841. // not announce this message because it matches the previous one. As a workaround, we
  47842. // alter the message with the number of occurences unless this is explicitly disabled
  47843. // via the disableRepeat flag.
  47844. if (!disableRepeat) {
  47845. if (prevText === msg) {
  47846. repeatedTimes++;
  47847. }
  47848. else {
  47849. prevText = msg;
  47850. repeatedTimes = 0;
  47851. }
  47852. switch (repeatedTimes) {
  47853. case 0: break;
  47854. case 1:
  47855. msg = nls.localize(0, null, msg);
  47856. break;
  47857. default:
  47858. msg = nls.localize(1, null, msg, repeatedTimes);
  47859. break;
  47860. }
  47861. }
  47862. dom.clearNode(target);
  47863. target.textContent = msg;
  47864. // See https://www.paciellogroup.com/blog/2012/06/html5-accessibility-chops-aria-rolealert-browser-support/
  47865. target.style.visibility = 'hidden';
  47866. target.style.visibility = 'visible';
  47867. }
  47868. });
  47869. define(__m[396/*vs/nls!vs/base/browser/ui/findinput/findInput*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/browser/ui/findinput/findInput", data); });
  47870. define(__m[397/*vs/nls!vs/base/browser/ui/findinput/findInputCheckboxes*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/browser/ui/findinput/findInputCheckboxes", data); });
  47871. /*---------------------------------------------------------------------------------------------
  47872. * Copyright (c) Microsoft Corporation. All rights reserved.
  47873. * Licensed under the MIT License. See License.txt in the project root for license information.
  47874. *--------------------------------------------------------------------------------------------*/
  47875. define(__m[204/*vs/base/browser/ui/findinput/findInputCheckboxes*/], __M([0/*require*/,1/*exports*/,138/*vs/base/browser/ui/checkbox/checkbox*/,397/*vs/nls!vs/base/browser/ui/findinput/findInputCheckboxes*/]), function (require, exports, checkbox_1, nls) {
  47876. "use strict";
  47877. Object.defineProperty(exports, "__esModule", { value: true });
  47878. var NLS_CASE_SENSITIVE_CHECKBOX_LABEL = nls.localize(0, null);
  47879. var NLS_WHOLE_WORD_CHECKBOX_LABEL = nls.localize(1, null);
  47880. var NLS_REGEX_CHECKBOX_LABEL = nls.localize(2, null);
  47881. var CaseSensitiveCheckbox = /** @class */ (function (_super) {
  47882. __extends(CaseSensitiveCheckbox, _super);
  47883. function CaseSensitiveCheckbox(opts) {
  47884. return _super.call(this, {
  47885. actionClassName: 'codicon-case-sensitive',
  47886. title: NLS_CASE_SENSITIVE_CHECKBOX_LABEL + opts.appendTitle,
  47887. isChecked: opts.isChecked,
  47888. inputActiveOptionBorder: opts.inputActiveOptionBorder,
  47889. inputActiveOptionBackground: opts.inputActiveOptionBackground
  47890. }) || this;
  47891. }
  47892. return CaseSensitiveCheckbox;
  47893. }(checkbox_1.Checkbox));
  47894. exports.CaseSensitiveCheckbox = CaseSensitiveCheckbox;
  47895. var WholeWordsCheckbox = /** @class */ (function (_super) {
  47896. __extends(WholeWordsCheckbox, _super);
  47897. function WholeWordsCheckbox(opts) {
  47898. return _super.call(this, {
  47899. actionClassName: 'codicon-whole-word',
  47900. title: NLS_WHOLE_WORD_CHECKBOX_LABEL + opts.appendTitle,
  47901. isChecked: opts.isChecked,
  47902. inputActiveOptionBorder: opts.inputActiveOptionBorder,
  47903. inputActiveOptionBackground: opts.inputActiveOptionBackground
  47904. }) || this;
  47905. }
  47906. return WholeWordsCheckbox;
  47907. }(checkbox_1.Checkbox));
  47908. exports.WholeWordsCheckbox = WholeWordsCheckbox;
  47909. var RegexCheckbox = /** @class */ (function (_super) {
  47910. __extends(RegexCheckbox, _super);
  47911. function RegexCheckbox(opts) {
  47912. return _super.call(this, {
  47913. actionClassName: 'codicon-regex',
  47914. title: NLS_REGEX_CHECKBOX_LABEL + opts.appendTitle,
  47915. isChecked: opts.isChecked,
  47916. inputActiveOptionBorder: opts.inputActiveOptionBorder,
  47917. inputActiveOptionBackground: opts.inputActiveOptionBackground
  47918. }) || this;
  47919. }
  47920. return RegexCheckbox;
  47921. }(checkbox_1.Checkbox));
  47922. exports.RegexCheckbox = RegexCheckbox;
  47923. });
  47924. define(__m[398/*vs/nls!vs/base/browser/ui/findinput/replaceInput*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/browser/ui/findinput/replaceInput", data); });
  47925. define(__m[399/*vs/nls!vs/base/browser/ui/inputbox/inputBox*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/browser/ui/inputbox/inputBox", data); });
  47926. /*---------------------------------------------------------------------------------------------
  47927. * Copyright (c) Microsoft Corporation. All rights reserved.
  47928. * Licensed under the MIT License. See License.txt in the project root for license information.
  47929. *--------------------------------------------------------------------------------------------*/
  47930. define(__m[152/*vs/base/browser/ui/inputbox/inputBox*/], __M([0/*require*/,1/*exports*/,399/*vs/nls!vs/base/browser/ui/inputbox/inputBox*/,24/*vs/base/browser/browser*/,6/*vs/base/browser/dom*/,134/*vs/base/browser/formattedTextRenderer*/,50/*vs/base/browser/ui/aria/aria*/,70/*vs/base/browser/ui/actionbar/actionbar*/,4/*vs/base/common/event*/,47/*vs/base/browser/ui/widget*/,27/*vs/base/common/color*/,31/*vs/base/common/objects*/,242/*vs/base/common/history*/,53/*vs/base/browser/ui/scrollbar/scrollableElement*/,52/*vs/base/browser/event*/,269/*vs/css!vs/base/browser/ui/inputbox/inputBox*/]), function (require, exports, nls, Bal, dom, formattedTextRenderer_1, aria, actionbar_1, event_1, widget_1, color_1, objects_1, history_1, scrollableElement_1, event_2) {
  47931. "use strict";
  47932. Object.defineProperty(exports, "__esModule", { value: true });
  47933. var $ = dom.$;
  47934. var defaultOpts = {
  47935. inputBackground: color_1.Color.fromHex('#3C3C3C'),
  47936. inputForeground: color_1.Color.fromHex('#CCCCCC'),
  47937. inputValidationInfoBorder: color_1.Color.fromHex('#55AAFF'),
  47938. inputValidationInfoBackground: color_1.Color.fromHex('#063B49'),
  47939. inputValidationWarningBorder: color_1.Color.fromHex('#B89500'),
  47940. inputValidationWarningBackground: color_1.Color.fromHex('#352A05'),
  47941. inputValidationErrorBorder: color_1.Color.fromHex('#BE1100'),
  47942. inputValidationErrorBackground: color_1.Color.fromHex('#5A1D1D')
  47943. };
  47944. var InputBox = /** @class */ (function (_super) {
  47945. __extends(InputBox, _super);
  47946. function InputBox(container, contextViewProvider, options) {
  47947. var _this = _super.call(this) || this;
  47948. _this.state = 'idle';
  47949. _this.maxHeight = Number.POSITIVE_INFINITY;
  47950. _this._onDidChange = _this._register(new event_1.Emitter());
  47951. _this.onDidChange = _this._onDidChange.event;
  47952. _this._onDidHeightChange = _this._register(new event_1.Emitter());
  47953. _this.onDidHeightChange = _this._onDidHeightChange.event;
  47954. _this.contextViewProvider = contextViewProvider;
  47955. _this.options = options || Object.create(null);
  47956. objects_1.mixin(_this.options, defaultOpts, false);
  47957. _this.message = null;
  47958. _this.placeholder = _this.options.placeholder || '';
  47959. _this.ariaLabel = _this.options.ariaLabel || '';
  47960. _this.inputBackground = _this.options.inputBackground;
  47961. _this.inputForeground = _this.options.inputForeground;
  47962. _this.inputBorder = _this.options.inputBorder;
  47963. _this.inputValidationInfoBorder = _this.options.inputValidationInfoBorder;
  47964. _this.inputValidationInfoBackground = _this.options.inputValidationInfoBackground;
  47965. _this.inputValidationInfoForeground = _this.options.inputValidationInfoForeground;
  47966. _this.inputValidationWarningBorder = _this.options.inputValidationWarningBorder;
  47967. _this.inputValidationWarningBackground = _this.options.inputValidationWarningBackground;
  47968. _this.inputValidationWarningForeground = _this.options.inputValidationWarningForeground;
  47969. _this.inputValidationErrorBorder = _this.options.inputValidationErrorBorder;
  47970. _this.inputValidationErrorBackground = _this.options.inputValidationErrorBackground;
  47971. _this.inputValidationErrorForeground = _this.options.inputValidationErrorForeground;
  47972. if (_this.options.validationOptions) {
  47973. _this.validation = _this.options.validationOptions.validation;
  47974. }
  47975. _this.element = dom.append(container, $('.monaco-inputbox.idle'));
  47976. var tagName = _this.options.flexibleHeight ? 'textarea' : 'input';
  47977. var wrapper = dom.append(_this.element, $('.wrapper'));
  47978. _this.input = dom.append(wrapper, $(tagName + '.input.empty'));
  47979. _this.input.setAttribute('autocorrect', 'off');
  47980. _this.input.setAttribute('autocapitalize', 'off');
  47981. _this.input.setAttribute('spellcheck', 'false');
  47982. _this.onfocus(_this.input, function () { return dom.addClass(_this.element, 'synthetic-focus'); });
  47983. _this.onblur(_this.input, function () { return dom.removeClass(_this.element, 'synthetic-focus'); });
  47984. if (_this.options.flexibleHeight) {
  47985. _this.maxHeight = typeof _this.options.flexibleMaxHeight === 'number' ? _this.options.flexibleMaxHeight : Number.POSITIVE_INFINITY;
  47986. _this.mirror = dom.append(wrapper, $('div.mirror'));
  47987. _this.mirror.innerHTML = '&#160;';
  47988. _this.scrollableElement = new scrollableElement_1.ScrollableElement(_this.element, { vertical: 1 /* Auto */ });
  47989. if (_this.options.flexibleWidth) {
  47990. _this.input.setAttribute('wrap', 'off');
  47991. _this.mirror.style.whiteSpace = 'pre';
  47992. _this.mirror.style.wordWrap = 'initial';
  47993. }
  47994. dom.append(container, _this.scrollableElement.getDomNode());
  47995. _this._register(_this.scrollableElement);
  47996. // from ScrollableElement to DOM
  47997. _this._register(_this.scrollableElement.onScroll(function (e) { return _this.input.scrollTop = e.scrollTop; }));
  47998. var onSelectionChange = event_1.Event.filter(event_2.domEvent(document, 'selectionchange'), function () {
  47999. var selection = document.getSelection();
  48000. return (selection === null || selection === void 0 ? void 0 : selection.anchorNode) === wrapper;
  48001. });
  48002. // from DOM to ScrollableElement
  48003. _this._register(onSelectionChange(_this.updateScrollDimensions, _this));
  48004. _this._register(_this.onDidHeightChange(_this.updateScrollDimensions, _this));
  48005. }
  48006. else {
  48007. _this.input.type = _this.options.type || 'text';
  48008. _this.input.setAttribute('wrap', 'off');
  48009. }
  48010. if (_this.ariaLabel) {
  48011. _this.input.setAttribute('aria-label', _this.ariaLabel);
  48012. }
  48013. if (_this.placeholder) {
  48014. _this.setPlaceHolder(_this.placeholder);
  48015. }
  48016. _this.oninput(_this.input, function () { return _this.onValueChange(); });
  48017. _this.onblur(_this.input, function () { return _this.onBlur(); });
  48018. _this.onfocus(_this.input, function () { return _this.onFocus(); });
  48019. // Add placeholder shim for IE because IE decides to hide the placeholder on focus (we dont want that!)
  48020. if (_this.placeholder && Bal.isIE) {
  48021. _this.onclick(_this.input, function (e) {
  48022. dom.EventHelper.stop(e, true);
  48023. _this.input.focus();
  48024. });
  48025. }
  48026. _this.ignoreGesture(_this.input);
  48027. setTimeout(function () { return _this.updateMirror(); }, 0);
  48028. // Support actions
  48029. if (_this.options.actions) {
  48030. _this.actionbar = _this._register(new actionbar_1.ActionBar(_this.element));
  48031. _this.actionbar.push(_this.options.actions, { icon: true, label: false });
  48032. }
  48033. _this.applyStyles();
  48034. return _this;
  48035. }
  48036. InputBox.prototype.onBlur = function () {
  48037. this._hideMessage();
  48038. };
  48039. InputBox.prototype.onFocus = function () {
  48040. this._showMessage();
  48041. };
  48042. InputBox.prototype.setPlaceHolder = function (placeHolder) {
  48043. this.placeholder = placeHolder;
  48044. this.input.setAttribute('placeholder', placeHolder);
  48045. this.input.title = placeHolder;
  48046. };
  48047. InputBox.prototype.setAriaLabel = function (label) {
  48048. this.ariaLabel = label;
  48049. if (label) {
  48050. this.input.setAttribute('aria-label', this.ariaLabel);
  48051. }
  48052. else {
  48053. this.input.removeAttribute('aria-label');
  48054. }
  48055. };
  48056. Object.defineProperty(InputBox.prototype, "inputElement", {
  48057. get: function () {
  48058. return this.input;
  48059. },
  48060. enumerable: true,
  48061. configurable: true
  48062. });
  48063. Object.defineProperty(InputBox.prototype, "value", {
  48064. get: function () {
  48065. return this.input.value;
  48066. },
  48067. set: function (newValue) {
  48068. if (this.input.value !== newValue) {
  48069. this.input.value = newValue;
  48070. this.onValueChange();
  48071. }
  48072. },
  48073. enumerable: true,
  48074. configurable: true
  48075. });
  48076. Object.defineProperty(InputBox.prototype, "height", {
  48077. get: function () {
  48078. return typeof this.cachedHeight === 'number' ? this.cachedHeight : dom.getTotalHeight(this.element);
  48079. },
  48080. enumerable: true,
  48081. configurable: true
  48082. });
  48083. InputBox.prototype.focus = function () {
  48084. this.input.focus();
  48085. };
  48086. InputBox.prototype.blur = function () {
  48087. this.input.blur();
  48088. };
  48089. InputBox.prototype.hasFocus = function () {
  48090. return document.activeElement === this.input;
  48091. };
  48092. InputBox.prototype.select = function (range) {
  48093. if (range === void 0) { range = null; }
  48094. this.input.select();
  48095. if (range) {
  48096. this.input.setSelectionRange(range.start, range.end);
  48097. }
  48098. };
  48099. InputBox.prototype.enable = function () {
  48100. this.input.removeAttribute('disabled');
  48101. };
  48102. InputBox.prototype.disable = function () {
  48103. this.blur();
  48104. this.input.disabled = true;
  48105. this._hideMessage();
  48106. };
  48107. Object.defineProperty(InputBox.prototype, "width", {
  48108. get: function () {
  48109. return dom.getTotalWidth(this.input);
  48110. },
  48111. set: function (width) {
  48112. if (this.options.flexibleHeight && this.options.flexibleWidth) {
  48113. // textarea with horizontal scrolling
  48114. var horizontalPadding = 0;
  48115. if (this.mirror) {
  48116. var paddingLeft = parseFloat(this.mirror.style.paddingLeft || '') || 0;
  48117. var paddingRight = parseFloat(this.mirror.style.paddingRight || '') || 0;
  48118. horizontalPadding = paddingLeft + paddingRight;
  48119. }
  48120. this.input.style.width = (width - horizontalPadding) + 'px';
  48121. }
  48122. else {
  48123. this.input.style.width = width + 'px';
  48124. }
  48125. if (this.mirror) {
  48126. this.mirror.style.width = width + 'px';
  48127. }
  48128. },
  48129. enumerable: true,
  48130. configurable: true
  48131. });
  48132. Object.defineProperty(InputBox.prototype, "paddingRight", {
  48133. set: function (paddingRight) {
  48134. if (this.options.flexibleHeight && this.options.flexibleWidth) {
  48135. this.input.style.width = "calc(100% - " + paddingRight + "px)";
  48136. }
  48137. else {
  48138. this.input.style.paddingRight = paddingRight + 'px';
  48139. }
  48140. if (this.mirror) {
  48141. this.mirror.style.paddingRight = paddingRight + 'px';
  48142. }
  48143. },
  48144. enumerable: true,
  48145. configurable: true
  48146. });
  48147. InputBox.prototype.updateScrollDimensions = function () {
  48148. if (typeof this.cachedContentHeight !== 'number' || typeof this.cachedHeight !== 'number' || !this.scrollableElement) {
  48149. return;
  48150. }
  48151. var scrollHeight = this.cachedContentHeight;
  48152. var height = this.cachedHeight;
  48153. var scrollTop = this.input.scrollTop;
  48154. this.scrollableElement.setScrollDimensions({ scrollHeight: scrollHeight, height: height });
  48155. this.scrollableElement.setScrollPosition({ scrollTop: scrollTop });
  48156. };
  48157. InputBox.prototype.showMessage = function (message, force) {
  48158. this.message = message;
  48159. dom.removeClass(this.element, 'idle');
  48160. dom.removeClass(this.element, 'info');
  48161. dom.removeClass(this.element, 'warning');
  48162. dom.removeClass(this.element, 'error');
  48163. dom.addClass(this.element, this.classForType(message.type));
  48164. var styles = this.stylesForType(this.message.type);
  48165. this.element.style.border = styles.border ? "1px solid " + styles.border : '';
  48166. // ARIA Support
  48167. var alertText;
  48168. if (message.type === 3 /* ERROR */) {
  48169. alertText = nls.localize(0, null, message.content);
  48170. }
  48171. else if (message.type === 2 /* WARNING */) {
  48172. alertText = nls.localize(1, null, message.content);
  48173. }
  48174. else {
  48175. alertText = nls.localize(2, null, message.content);
  48176. }
  48177. aria.alert(alertText);
  48178. if (this.hasFocus() || force) {
  48179. this._showMessage();
  48180. }
  48181. };
  48182. InputBox.prototype.hideMessage = function () {
  48183. this.message = null;
  48184. dom.removeClass(this.element, 'info');
  48185. dom.removeClass(this.element, 'warning');
  48186. dom.removeClass(this.element, 'error');
  48187. dom.addClass(this.element, 'idle');
  48188. this._hideMessage();
  48189. this.applyStyles();
  48190. };
  48191. InputBox.prototype.validate = function () {
  48192. var errorMsg = null;
  48193. if (this.validation) {
  48194. errorMsg = this.validation(this.value);
  48195. if (errorMsg) {
  48196. this.inputElement.setAttribute('aria-invalid', 'true');
  48197. this.showMessage(errorMsg);
  48198. }
  48199. else if (this.inputElement.hasAttribute('aria-invalid')) {
  48200. this.inputElement.removeAttribute('aria-invalid');
  48201. this.hideMessage();
  48202. }
  48203. }
  48204. return !errorMsg;
  48205. };
  48206. InputBox.prototype.stylesForType = function (type) {
  48207. switch (type) {
  48208. case 1 /* INFO */: return { border: this.inputValidationInfoBorder, background: this.inputValidationInfoBackground, foreground: this.inputValidationInfoForeground };
  48209. case 2 /* WARNING */: return { border: this.inputValidationWarningBorder, background: this.inputValidationWarningBackground, foreground: this.inputValidationWarningForeground };
  48210. default: return { border: this.inputValidationErrorBorder, background: this.inputValidationErrorBackground, foreground: this.inputValidationErrorForeground };
  48211. }
  48212. };
  48213. InputBox.prototype.classForType = function (type) {
  48214. switch (type) {
  48215. case 1 /* INFO */: return 'info';
  48216. case 2 /* WARNING */: return 'warning';
  48217. default: return 'error';
  48218. }
  48219. };
  48220. InputBox.prototype._showMessage = function () {
  48221. var _this = this;
  48222. if (!this.contextViewProvider || !this.message) {
  48223. return;
  48224. }
  48225. var div;
  48226. var layout = function () { return div.style.width = dom.getTotalWidth(_this.element) + 'px'; };
  48227. this.contextViewProvider.showContextView({
  48228. getAnchor: function () { return _this.element; },
  48229. anchorAlignment: 1 /* RIGHT */,
  48230. render: function (container) {
  48231. if (!_this.message) {
  48232. return null;
  48233. }
  48234. div = dom.append(container, $('.monaco-inputbox-container'));
  48235. layout();
  48236. var renderOptions = {
  48237. inline: true,
  48238. className: 'monaco-inputbox-message'
  48239. };
  48240. var spanElement = (_this.message.formatContent
  48241. ? formattedTextRenderer_1.renderFormattedText(_this.message.content, renderOptions)
  48242. : formattedTextRenderer_1.renderText(_this.message.content, renderOptions));
  48243. dom.addClass(spanElement, _this.classForType(_this.message.type));
  48244. var styles = _this.stylesForType(_this.message.type);
  48245. spanElement.style.backgroundColor = styles.background ? styles.background.toString() : '';
  48246. spanElement.style.color = styles.foreground ? styles.foreground.toString() : '';
  48247. spanElement.style.border = styles.border ? "1px solid " + styles.border : '';
  48248. dom.append(div, spanElement);
  48249. return null;
  48250. },
  48251. onHide: function () {
  48252. _this.state = 'closed';
  48253. },
  48254. layout: layout
  48255. });
  48256. this.state = 'open';
  48257. };
  48258. InputBox.prototype._hideMessage = function () {
  48259. if (!this.contextViewProvider) {
  48260. return;
  48261. }
  48262. if (this.state === 'open') {
  48263. this.contextViewProvider.hideContextView();
  48264. }
  48265. this.state = 'idle';
  48266. };
  48267. InputBox.prototype.onValueChange = function () {
  48268. this._onDidChange.fire(this.value);
  48269. this.validate();
  48270. this.updateMirror();
  48271. dom.toggleClass(this.input, 'empty', !this.value);
  48272. if (this.state === 'open' && this.contextViewProvider) {
  48273. this.contextViewProvider.layout();
  48274. }
  48275. };
  48276. InputBox.prototype.updateMirror = function () {
  48277. if (!this.mirror) {
  48278. return;
  48279. }
  48280. var value = this.value;
  48281. var lastCharCode = value.charCodeAt(value.length - 1);
  48282. var suffix = lastCharCode === 10 ? ' ' : '';
  48283. var mirrorTextContent = value + suffix;
  48284. if (mirrorTextContent) {
  48285. this.mirror.textContent = value + suffix;
  48286. }
  48287. else {
  48288. this.mirror.innerHTML = '&#160;';
  48289. }
  48290. this.layout();
  48291. };
  48292. InputBox.prototype.style = function (styles) {
  48293. this.inputBackground = styles.inputBackground;
  48294. this.inputForeground = styles.inputForeground;
  48295. this.inputBorder = styles.inputBorder;
  48296. this.inputValidationInfoBackground = styles.inputValidationInfoBackground;
  48297. this.inputValidationInfoForeground = styles.inputValidationInfoForeground;
  48298. this.inputValidationInfoBorder = styles.inputValidationInfoBorder;
  48299. this.inputValidationWarningBackground = styles.inputValidationWarningBackground;
  48300. this.inputValidationWarningForeground = styles.inputValidationWarningForeground;
  48301. this.inputValidationWarningBorder = styles.inputValidationWarningBorder;
  48302. this.inputValidationErrorBackground = styles.inputValidationErrorBackground;
  48303. this.inputValidationErrorForeground = styles.inputValidationErrorForeground;
  48304. this.inputValidationErrorBorder = styles.inputValidationErrorBorder;
  48305. this.applyStyles();
  48306. };
  48307. InputBox.prototype.applyStyles = function () {
  48308. var background = this.inputBackground ? this.inputBackground.toString() : '';
  48309. var foreground = this.inputForeground ? this.inputForeground.toString() : '';
  48310. var border = this.inputBorder ? this.inputBorder.toString() : '';
  48311. this.element.style.backgroundColor = background;
  48312. this.element.style.color = foreground;
  48313. this.input.style.backgroundColor = background;
  48314. this.input.style.color = foreground;
  48315. this.element.style.borderWidth = border ? '1px' : '';
  48316. this.element.style.borderStyle = border ? 'solid' : '';
  48317. this.element.style.borderColor = border;
  48318. };
  48319. InputBox.prototype.layout = function () {
  48320. if (!this.mirror) {
  48321. return;
  48322. }
  48323. var previousHeight = this.cachedContentHeight;
  48324. this.cachedContentHeight = dom.getTotalHeight(this.mirror);
  48325. if (previousHeight !== this.cachedContentHeight) {
  48326. this.cachedHeight = Math.min(this.cachedContentHeight, this.maxHeight);
  48327. this.input.style.height = this.cachedHeight + 'px';
  48328. this._onDidHeightChange.fire(this.cachedContentHeight);
  48329. }
  48330. };
  48331. InputBox.prototype.insertAtCursor = function (text) {
  48332. var inputElement = this.inputElement;
  48333. var start = inputElement.selectionStart;
  48334. var end = inputElement.selectionEnd;
  48335. var content = inputElement.value;
  48336. if (start !== null && end !== null) {
  48337. this.value = content.substr(0, start) + text + content.substr(end);
  48338. inputElement.setSelectionRange(start + 1, start + 1);
  48339. this.layout();
  48340. }
  48341. };
  48342. InputBox.prototype.dispose = function () {
  48343. this._hideMessage();
  48344. this.message = null;
  48345. if (this.actionbar) {
  48346. this.actionbar.dispose();
  48347. }
  48348. _super.prototype.dispose.call(this);
  48349. };
  48350. return InputBox;
  48351. }(widget_1.Widget));
  48352. exports.InputBox = InputBox;
  48353. var HistoryInputBox = /** @class */ (function (_super) {
  48354. __extends(HistoryInputBox, _super);
  48355. function HistoryInputBox(container, contextViewProvider, options) {
  48356. var _this = _super.call(this, container, contextViewProvider, options) || this;
  48357. _this.history = new history_1.HistoryNavigator(options.history, 100);
  48358. return _this;
  48359. }
  48360. HistoryInputBox.prototype.addToHistory = function () {
  48361. if (this.value && this.value !== this.getCurrentValue()) {
  48362. this.history.add(this.value);
  48363. }
  48364. };
  48365. HistoryInputBox.prototype.showNextValue = function () {
  48366. if (!this.history.has(this.value)) {
  48367. this.addToHistory();
  48368. }
  48369. var next = this.getNextValue();
  48370. if (next) {
  48371. next = next === this.value ? this.getNextValue() : next;
  48372. }
  48373. if (next) {
  48374. this.value = next;
  48375. aria.status(this.value);
  48376. }
  48377. };
  48378. HistoryInputBox.prototype.showPreviousValue = function () {
  48379. if (!this.history.has(this.value)) {
  48380. this.addToHistory();
  48381. }
  48382. var previous = this.getPreviousValue();
  48383. if (previous) {
  48384. previous = previous === this.value ? this.getPreviousValue() : previous;
  48385. }
  48386. if (previous) {
  48387. this.value = previous;
  48388. aria.status(this.value);
  48389. }
  48390. };
  48391. HistoryInputBox.prototype.getCurrentValue = function () {
  48392. var currentValue = this.history.current();
  48393. if (!currentValue) {
  48394. currentValue = this.history.last();
  48395. this.history.next();
  48396. }
  48397. return currentValue;
  48398. };
  48399. HistoryInputBox.prototype.getPreviousValue = function () {
  48400. return this.history.previous() || this.history.first();
  48401. };
  48402. HistoryInputBox.prototype.getNextValue = function () {
  48403. return this.history.next() || this.history.last();
  48404. };
  48405. return HistoryInputBox;
  48406. }(InputBox));
  48407. exports.HistoryInputBox = HistoryInputBox;
  48408. });
  48409. /*---------------------------------------------------------------------------------------------
  48410. * Copyright (c) Microsoft Corporation. All rights reserved.
  48411. * Licensed under the MIT License. See License.txt in the project root for license information.
  48412. *--------------------------------------------------------------------------------------------*/
  48413. define(__m[400/*vs/base/browser/ui/findinput/findInput*/], __M([0/*require*/,1/*exports*/,396/*vs/nls!vs/base/browser/ui/findinput/findInput*/,6/*vs/base/browser/dom*/,152/*vs/base/browser/ui/inputbox/inputBox*/,47/*vs/base/browser/ui/widget*/,4/*vs/base/common/event*/,204/*vs/base/browser/ui/findinput/findInputCheckboxes*/,184/*vs/css!vs/base/browser/ui/findinput/findInput*/]), function (require, exports, nls, dom, inputBox_1, widget_1, event_1, findInputCheckboxes_1) {
  48414. "use strict";
  48415. Object.defineProperty(exports, "__esModule", { value: true });
  48416. var NLS_DEFAULT_LABEL = nls.localize(0, null);
  48417. var FindInput = /** @class */ (function (_super) {
  48418. __extends(FindInput, _super);
  48419. function FindInput(parent, contextViewProvider, _showOptionButtons, options) {
  48420. var _this = _super.call(this) || this;
  48421. _this._showOptionButtons = _showOptionButtons;
  48422. _this.fixFocusOnOptionClickEnabled = true;
  48423. _this._onDidOptionChange = _this._register(new event_1.Emitter());
  48424. _this.onDidOptionChange = _this._onDidOptionChange.event;
  48425. _this._onKeyDown = _this._register(new event_1.Emitter());
  48426. _this.onKeyDown = _this._onKeyDown.event;
  48427. _this._onMouseDown = _this._register(new event_1.Emitter());
  48428. _this.onMouseDown = _this._onMouseDown.event;
  48429. _this._onInput = _this._register(new event_1.Emitter());
  48430. _this._onKeyUp = _this._register(new event_1.Emitter());
  48431. _this._onCaseSensitiveKeyDown = _this._register(new event_1.Emitter());
  48432. _this.onCaseSensitiveKeyDown = _this._onCaseSensitiveKeyDown.event;
  48433. _this._onRegexKeyDown = _this._register(new event_1.Emitter());
  48434. _this.onRegexKeyDown = _this._onRegexKeyDown.event;
  48435. _this._lastHighlightFindOptions = 0;
  48436. _this.contextViewProvider = contextViewProvider;
  48437. _this.placeholder = options.placeholder || '';
  48438. _this.validation = options.validation;
  48439. _this.label = options.label || NLS_DEFAULT_LABEL;
  48440. _this.inputActiveOptionBorder = options.inputActiveOptionBorder;
  48441. _this.inputActiveOptionBackground = options.inputActiveOptionBackground;
  48442. _this.inputBackground = options.inputBackground;
  48443. _this.inputForeground = options.inputForeground;
  48444. _this.inputBorder = options.inputBorder;
  48445. _this.inputValidationInfoBorder = options.inputValidationInfoBorder;
  48446. _this.inputValidationInfoBackground = options.inputValidationInfoBackground;
  48447. _this.inputValidationInfoForeground = options.inputValidationInfoForeground;
  48448. _this.inputValidationWarningBorder = options.inputValidationWarningBorder;
  48449. _this.inputValidationWarningBackground = options.inputValidationWarningBackground;
  48450. _this.inputValidationWarningForeground = options.inputValidationWarningForeground;
  48451. _this.inputValidationErrorBorder = options.inputValidationErrorBorder;
  48452. _this.inputValidationErrorBackground = options.inputValidationErrorBackground;
  48453. _this.inputValidationErrorForeground = options.inputValidationErrorForeground;
  48454. var appendCaseSensitiveLabel = options.appendCaseSensitiveLabel || '';
  48455. var appendWholeWordsLabel = options.appendWholeWordsLabel || '';
  48456. var appendRegexLabel = options.appendRegexLabel || '';
  48457. var history = options.history || [];
  48458. var flexibleHeight = !!options.flexibleHeight;
  48459. var flexibleWidth = !!options.flexibleWidth;
  48460. var flexibleMaxHeight = options.flexibleMaxHeight;
  48461. _this.domNode = document.createElement('div');
  48462. dom.addClass(_this.domNode, 'monaco-findInput');
  48463. _this.inputBox = _this._register(new inputBox_1.HistoryInputBox(_this.domNode, _this.contextViewProvider, {
  48464. placeholder: _this.placeholder || '',
  48465. ariaLabel: _this.label || '',
  48466. validationOptions: {
  48467. validation: _this.validation
  48468. },
  48469. inputBackground: _this.inputBackground,
  48470. inputForeground: _this.inputForeground,
  48471. inputBorder: _this.inputBorder,
  48472. inputValidationInfoBackground: _this.inputValidationInfoBackground,
  48473. inputValidationInfoForeground: _this.inputValidationInfoForeground,
  48474. inputValidationInfoBorder: _this.inputValidationInfoBorder,
  48475. inputValidationWarningBackground: _this.inputValidationWarningBackground,
  48476. inputValidationWarningForeground: _this.inputValidationWarningForeground,
  48477. inputValidationWarningBorder: _this.inputValidationWarningBorder,
  48478. inputValidationErrorBackground: _this.inputValidationErrorBackground,
  48479. inputValidationErrorForeground: _this.inputValidationErrorForeground,
  48480. inputValidationErrorBorder: _this.inputValidationErrorBorder,
  48481. history: history,
  48482. flexibleHeight: flexibleHeight,
  48483. flexibleWidth: flexibleWidth,
  48484. flexibleMaxHeight: flexibleMaxHeight
  48485. }));
  48486. _this.regex = _this._register(new findInputCheckboxes_1.RegexCheckbox({
  48487. appendTitle: appendRegexLabel,
  48488. isChecked: false,
  48489. inputActiveOptionBorder: _this.inputActiveOptionBorder,
  48490. inputActiveOptionBackground: _this.inputActiveOptionBackground
  48491. }));
  48492. _this._register(_this.regex.onChange(function (viaKeyboard) {
  48493. _this._onDidOptionChange.fire(viaKeyboard);
  48494. if (!viaKeyboard && _this.fixFocusOnOptionClickEnabled) {
  48495. _this.inputBox.focus();
  48496. }
  48497. _this.validate();
  48498. }));
  48499. _this._register(_this.regex.onKeyDown(function (e) {
  48500. _this._onRegexKeyDown.fire(e);
  48501. }));
  48502. _this.wholeWords = _this._register(new findInputCheckboxes_1.WholeWordsCheckbox({
  48503. appendTitle: appendWholeWordsLabel,
  48504. isChecked: false,
  48505. inputActiveOptionBorder: _this.inputActiveOptionBorder,
  48506. inputActiveOptionBackground: _this.inputActiveOptionBackground
  48507. }));
  48508. _this._register(_this.wholeWords.onChange(function (viaKeyboard) {
  48509. _this._onDidOptionChange.fire(viaKeyboard);
  48510. if (!viaKeyboard && _this.fixFocusOnOptionClickEnabled) {
  48511. _this.inputBox.focus();
  48512. }
  48513. _this.validate();
  48514. }));
  48515. _this.caseSensitive = _this._register(new findInputCheckboxes_1.CaseSensitiveCheckbox({
  48516. appendTitle: appendCaseSensitiveLabel,
  48517. isChecked: false,
  48518. inputActiveOptionBorder: _this.inputActiveOptionBorder,
  48519. inputActiveOptionBackground: _this.inputActiveOptionBackground
  48520. }));
  48521. _this._register(_this.caseSensitive.onChange(function (viaKeyboard) {
  48522. _this._onDidOptionChange.fire(viaKeyboard);
  48523. if (!viaKeyboard && _this.fixFocusOnOptionClickEnabled) {
  48524. _this.inputBox.focus();
  48525. }
  48526. _this.validate();
  48527. }));
  48528. _this._register(_this.caseSensitive.onKeyDown(function (e) {
  48529. _this._onCaseSensitiveKeyDown.fire(e);
  48530. }));
  48531. if (_this._showOptionButtons) {
  48532. _this.inputBox.paddingRight = _this.caseSensitive.width() + _this.wholeWords.width() + _this.regex.width();
  48533. }
  48534. // Arrow-Key support to navigate between options
  48535. var indexes = [_this.caseSensitive.domNode, _this.wholeWords.domNode, _this.regex.domNode];
  48536. _this.onkeydown(_this.domNode, function (event) {
  48537. if (event.equals(15 /* LeftArrow */) || event.equals(17 /* RightArrow */) || event.equals(9 /* Escape */)) {
  48538. var index = indexes.indexOf(document.activeElement);
  48539. if (index >= 0) {
  48540. var newIndex = -1;
  48541. if (event.equals(17 /* RightArrow */)) {
  48542. newIndex = (index + 1) % indexes.length;
  48543. }
  48544. else if (event.equals(15 /* LeftArrow */)) {
  48545. if (index === 0) {
  48546. newIndex = indexes.length - 1;
  48547. }
  48548. else {
  48549. newIndex = index - 1;
  48550. }
  48551. }
  48552. if (event.equals(9 /* Escape */)) {
  48553. indexes[index].blur();
  48554. }
  48555. else if (newIndex >= 0) {
  48556. indexes[newIndex].focus();
  48557. }
  48558. dom.EventHelper.stop(event, true);
  48559. }
  48560. }
  48561. });
  48562. var controls = document.createElement('div');
  48563. controls.className = 'controls';
  48564. controls.style.display = _this._showOptionButtons ? 'block' : 'none';
  48565. controls.appendChild(_this.caseSensitive.domNode);
  48566. controls.appendChild(_this.wholeWords.domNode);
  48567. controls.appendChild(_this.regex.domNode);
  48568. _this.domNode.appendChild(controls);
  48569. if (parent) {
  48570. parent.appendChild(_this.domNode);
  48571. }
  48572. _this.onkeydown(_this.inputBox.inputElement, function (e) { return _this._onKeyDown.fire(e); });
  48573. _this.onkeyup(_this.inputBox.inputElement, function (e) { return _this._onKeyUp.fire(e); });
  48574. _this.oninput(_this.inputBox.inputElement, function (e) { return _this._onInput.fire(); });
  48575. _this.onmousedown(_this.inputBox.inputElement, function (e) { return _this._onMouseDown.fire(e); });
  48576. return _this;
  48577. }
  48578. FindInput.prototype.enable = function () {
  48579. dom.removeClass(this.domNode, 'disabled');
  48580. this.inputBox.enable();
  48581. this.regex.enable();
  48582. this.wholeWords.enable();
  48583. this.caseSensitive.enable();
  48584. };
  48585. FindInput.prototype.disable = function () {
  48586. dom.addClass(this.domNode, 'disabled');
  48587. this.inputBox.disable();
  48588. this.regex.disable();
  48589. this.wholeWords.disable();
  48590. this.caseSensitive.disable();
  48591. };
  48592. FindInput.prototype.setFocusInputOnOptionClick = function (value) {
  48593. this.fixFocusOnOptionClickEnabled = value;
  48594. };
  48595. FindInput.prototype.setEnabled = function (enabled) {
  48596. if (enabled) {
  48597. this.enable();
  48598. }
  48599. else {
  48600. this.disable();
  48601. }
  48602. };
  48603. FindInput.prototype.getValue = function () {
  48604. return this.inputBox.value;
  48605. };
  48606. FindInput.prototype.setValue = function (value) {
  48607. if (this.inputBox.value !== value) {
  48608. this.inputBox.value = value;
  48609. }
  48610. };
  48611. FindInput.prototype.style = function (styles) {
  48612. this.inputActiveOptionBorder = styles.inputActiveOptionBorder;
  48613. this.inputActiveOptionBackground = styles.inputActiveOptionBackground;
  48614. this.inputBackground = styles.inputBackground;
  48615. this.inputForeground = styles.inputForeground;
  48616. this.inputBorder = styles.inputBorder;
  48617. this.inputValidationInfoBackground = styles.inputValidationInfoBackground;
  48618. this.inputValidationInfoForeground = styles.inputValidationInfoForeground;
  48619. this.inputValidationInfoBorder = styles.inputValidationInfoBorder;
  48620. this.inputValidationWarningBackground = styles.inputValidationWarningBackground;
  48621. this.inputValidationWarningForeground = styles.inputValidationWarningForeground;
  48622. this.inputValidationWarningBorder = styles.inputValidationWarningBorder;
  48623. this.inputValidationErrorBackground = styles.inputValidationErrorBackground;
  48624. this.inputValidationErrorForeground = styles.inputValidationErrorForeground;
  48625. this.inputValidationErrorBorder = styles.inputValidationErrorBorder;
  48626. this.applyStyles();
  48627. };
  48628. FindInput.prototype.applyStyles = function () {
  48629. if (this.domNode) {
  48630. var checkBoxStyles = {
  48631. inputActiveOptionBorder: this.inputActiveOptionBorder,
  48632. inputActiveOptionBackground: this.inputActiveOptionBackground,
  48633. };
  48634. this.regex.style(checkBoxStyles);
  48635. this.wholeWords.style(checkBoxStyles);
  48636. this.caseSensitive.style(checkBoxStyles);
  48637. var inputBoxStyles = {
  48638. inputBackground: this.inputBackground,
  48639. inputForeground: this.inputForeground,
  48640. inputBorder: this.inputBorder,
  48641. inputValidationInfoBackground: this.inputValidationInfoBackground,
  48642. inputValidationInfoForeground: this.inputValidationInfoForeground,
  48643. inputValidationInfoBorder: this.inputValidationInfoBorder,
  48644. inputValidationWarningBackground: this.inputValidationWarningBackground,
  48645. inputValidationWarningForeground: this.inputValidationWarningForeground,
  48646. inputValidationWarningBorder: this.inputValidationWarningBorder,
  48647. inputValidationErrorBackground: this.inputValidationErrorBackground,
  48648. inputValidationErrorForeground: this.inputValidationErrorForeground,
  48649. inputValidationErrorBorder: this.inputValidationErrorBorder
  48650. };
  48651. this.inputBox.style(inputBoxStyles);
  48652. }
  48653. };
  48654. FindInput.prototype.select = function () {
  48655. this.inputBox.select();
  48656. };
  48657. FindInput.prototype.focus = function () {
  48658. this.inputBox.focus();
  48659. };
  48660. FindInput.prototype.getCaseSensitive = function () {
  48661. return this.caseSensitive.checked;
  48662. };
  48663. FindInput.prototype.setCaseSensitive = function (value) {
  48664. this.caseSensitive.checked = value;
  48665. };
  48666. FindInput.prototype.getWholeWords = function () {
  48667. return this.wholeWords.checked;
  48668. };
  48669. FindInput.prototype.setWholeWords = function (value) {
  48670. this.wholeWords.checked = value;
  48671. };
  48672. FindInput.prototype.getRegex = function () {
  48673. return this.regex.checked;
  48674. };
  48675. FindInput.prototype.setRegex = function (value) {
  48676. this.regex.checked = value;
  48677. this.validate();
  48678. };
  48679. FindInput.prototype.focusOnCaseSensitive = function () {
  48680. this.caseSensitive.focus();
  48681. };
  48682. FindInput.prototype.highlightFindOptions = function () {
  48683. dom.removeClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
  48684. this._lastHighlightFindOptions = 1 - this._lastHighlightFindOptions;
  48685. dom.addClass(this.domNode, 'highlight-' + (this._lastHighlightFindOptions));
  48686. };
  48687. FindInput.prototype.validate = function () {
  48688. this.inputBox.validate();
  48689. };
  48690. FindInput.prototype.clearMessage = function () {
  48691. this.inputBox.hideMessage();
  48692. };
  48693. return FindInput;
  48694. }(widget_1.Widget));
  48695. exports.FindInput = FindInput;
  48696. });
  48697. /*---------------------------------------------------------------------------------------------
  48698. * Copyright (c) Microsoft Corporation. All rights reserved.
  48699. * Licensed under the MIT License. See License.txt in the project root for license information.
  48700. *--------------------------------------------------------------------------------------------*/
  48701. define(__m[401/*vs/base/browser/ui/findinput/replaceInput*/], __M([0/*require*/,1/*exports*/,398/*vs/nls!vs/base/browser/ui/findinput/replaceInput*/,6/*vs/base/browser/dom*/,152/*vs/base/browser/ui/inputbox/inputBox*/,47/*vs/base/browser/ui/widget*/,4/*vs/base/common/event*/,138/*vs/base/browser/ui/checkbox/checkbox*/,184/*vs/css!vs/base/browser/ui/findinput/findInput*/]), function (require, exports, nls, dom, inputBox_1, widget_1, event_1, checkbox_1) {
  48702. "use strict";
  48703. Object.defineProperty(exports, "__esModule", { value: true });
  48704. var NLS_DEFAULT_LABEL = nls.localize(0, null);
  48705. var NLS_PRESERVE_CASE_LABEL = nls.localize(1, null);
  48706. var PreserveCaseCheckbox = /** @class */ (function (_super) {
  48707. __extends(PreserveCaseCheckbox, _super);
  48708. function PreserveCaseCheckbox(opts) {
  48709. return _super.call(this, {
  48710. // TODO: does this need its own icon?
  48711. actionClassName: 'codicon-preserve-case',
  48712. title: NLS_PRESERVE_CASE_LABEL + opts.appendTitle,
  48713. isChecked: opts.isChecked,
  48714. inputActiveOptionBorder: opts.inputActiveOptionBorder,
  48715. inputActiveOptionBackground: opts.inputActiveOptionBackground
  48716. }) || this;
  48717. }
  48718. return PreserveCaseCheckbox;
  48719. }(checkbox_1.Checkbox));
  48720. exports.PreserveCaseCheckbox = PreserveCaseCheckbox;
  48721. var ReplaceInput = /** @class */ (function (_super) {
  48722. __extends(ReplaceInput, _super);
  48723. function ReplaceInput(parent, contextViewProvider, _showOptionButtons, options) {
  48724. var _this = _super.call(this) || this;
  48725. _this._showOptionButtons = _showOptionButtons;
  48726. _this.fixFocusOnOptionClickEnabled = true;
  48727. _this.cachedOptionsWidth = 0;
  48728. _this._onDidOptionChange = _this._register(new event_1.Emitter());
  48729. _this.onDidOptionChange = _this._onDidOptionChange.event;
  48730. _this._onKeyDown = _this._register(new event_1.Emitter());
  48731. _this.onKeyDown = _this._onKeyDown.event;
  48732. _this._onMouseDown = _this._register(new event_1.Emitter());
  48733. _this._onInput = _this._register(new event_1.Emitter());
  48734. _this._onKeyUp = _this._register(new event_1.Emitter());
  48735. _this._onPreserveCaseKeyDown = _this._register(new event_1.Emitter());
  48736. _this.onPreserveCaseKeyDown = _this._onPreserveCaseKeyDown.event;
  48737. _this.contextViewProvider = contextViewProvider;
  48738. _this.placeholder = options.placeholder || '';
  48739. _this.validation = options.validation;
  48740. _this.label = options.label || NLS_DEFAULT_LABEL;
  48741. _this.inputActiveOptionBorder = options.inputActiveOptionBorder;
  48742. _this.inputActiveOptionBackground = options.inputActiveOptionBackground;
  48743. _this.inputBackground = options.inputBackground;
  48744. _this.inputForeground = options.inputForeground;
  48745. _this.inputBorder = options.inputBorder;
  48746. _this.inputValidationInfoBorder = options.inputValidationInfoBorder;
  48747. _this.inputValidationInfoBackground = options.inputValidationInfoBackground;
  48748. _this.inputValidationInfoForeground = options.inputValidationInfoForeground;
  48749. _this.inputValidationWarningBorder = options.inputValidationWarningBorder;
  48750. _this.inputValidationWarningBackground = options.inputValidationWarningBackground;
  48751. _this.inputValidationWarningForeground = options.inputValidationWarningForeground;
  48752. _this.inputValidationErrorBorder = options.inputValidationErrorBorder;
  48753. _this.inputValidationErrorBackground = options.inputValidationErrorBackground;
  48754. _this.inputValidationErrorForeground = options.inputValidationErrorForeground;
  48755. var history = options.history || [];
  48756. var flexibleHeight = !!options.flexibleHeight;
  48757. var flexibleWidth = !!options.flexibleWidth;
  48758. var flexibleMaxHeight = options.flexibleMaxHeight;
  48759. _this.domNode = document.createElement('div');
  48760. dom.addClass(_this.domNode, 'monaco-findInput');
  48761. _this.inputBox = _this._register(new inputBox_1.HistoryInputBox(_this.domNode, _this.contextViewProvider, {
  48762. ariaLabel: _this.label || '',
  48763. placeholder: _this.placeholder || '',
  48764. validationOptions: {
  48765. validation: _this.validation
  48766. },
  48767. inputBackground: _this.inputBackground,
  48768. inputForeground: _this.inputForeground,
  48769. inputBorder: _this.inputBorder,
  48770. inputValidationInfoBackground: _this.inputValidationInfoBackground,
  48771. inputValidationInfoForeground: _this.inputValidationInfoForeground,
  48772. inputValidationInfoBorder: _this.inputValidationInfoBorder,
  48773. inputValidationWarningBackground: _this.inputValidationWarningBackground,
  48774. inputValidationWarningForeground: _this.inputValidationWarningForeground,
  48775. inputValidationWarningBorder: _this.inputValidationWarningBorder,
  48776. inputValidationErrorBackground: _this.inputValidationErrorBackground,
  48777. inputValidationErrorForeground: _this.inputValidationErrorForeground,
  48778. inputValidationErrorBorder: _this.inputValidationErrorBorder,
  48779. history: history,
  48780. flexibleHeight: flexibleHeight,
  48781. flexibleWidth: flexibleWidth,
  48782. flexibleMaxHeight: flexibleMaxHeight
  48783. }));
  48784. _this.preserveCase = _this._register(new PreserveCaseCheckbox({
  48785. appendTitle: '',
  48786. isChecked: false,
  48787. inputActiveOptionBorder: _this.inputActiveOptionBorder,
  48788. inputActiveOptionBackground: _this.inputActiveOptionBackground,
  48789. }));
  48790. _this._register(_this.preserveCase.onChange(function (viaKeyboard) {
  48791. _this._onDidOptionChange.fire(viaKeyboard);
  48792. if (!viaKeyboard && _this.fixFocusOnOptionClickEnabled) {
  48793. _this.inputBox.focus();
  48794. }
  48795. _this.validate();
  48796. }));
  48797. _this._register(_this.preserveCase.onKeyDown(function (e) {
  48798. _this._onPreserveCaseKeyDown.fire(e);
  48799. }));
  48800. if (_this._showOptionButtons) {
  48801. _this.cachedOptionsWidth = _this.preserveCase.width();
  48802. }
  48803. else {
  48804. _this.cachedOptionsWidth = 0;
  48805. }
  48806. // Arrow-Key support to navigate between options
  48807. var indexes = [_this.preserveCase.domNode];
  48808. _this.onkeydown(_this.domNode, function (event) {
  48809. if (event.equals(15 /* LeftArrow */) || event.equals(17 /* RightArrow */) || event.equals(9 /* Escape */)) {
  48810. var index = indexes.indexOf(document.activeElement);
  48811. if (index >= 0) {
  48812. var newIndex = -1;
  48813. if (event.equals(17 /* RightArrow */)) {
  48814. newIndex = (index + 1) % indexes.length;
  48815. }
  48816. else if (event.equals(15 /* LeftArrow */)) {
  48817. if (index === 0) {
  48818. newIndex = indexes.length - 1;
  48819. }
  48820. else {
  48821. newIndex = index - 1;
  48822. }
  48823. }
  48824. if (event.equals(9 /* Escape */)) {
  48825. indexes[index].blur();
  48826. }
  48827. else if (newIndex >= 0) {
  48828. indexes[newIndex].focus();
  48829. }
  48830. dom.EventHelper.stop(event, true);
  48831. }
  48832. }
  48833. });
  48834. var controls = document.createElement('div');
  48835. controls.className = 'controls';
  48836. controls.style.display = _this._showOptionButtons ? 'block' : 'none';
  48837. controls.appendChild(_this.preserveCase.domNode);
  48838. _this.domNode.appendChild(controls);
  48839. if (parent) {
  48840. parent.appendChild(_this.domNode);
  48841. }
  48842. _this.onkeydown(_this.inputBox.inputElement, function (e) { return _this._onKeyDown.fire(e); });
  48843. _this.onkeyup(_this.inputBox.inputElement, function (e) { return _this._onKeyUp.fire(e); });
  48844. _this.oninput(_this.inputBox.inputElement, function (e) { return _this._onInput.fire(); });
  48845. _this.onmousedown(_this.inputBox.inputElement, function (e) { return _this._onMouseDown.fire(e); });
  48846. return _this;
  48847. }
  48848. ReplaceInput.prototype.enable = function () {
  48849. dom.removeClass(this.domNode, 'disabled');
  48850. this.inputBox.enable();
  48851. this.preserveCase.enable();
  48852. };
  48853. ReplaceInput.prototype.disable = function () {
  48854. dom.addClass(this.domNode, 'disabled');
  48855. this.inputBox.disable();
  48856. this.preserveCase.disable();
  48857. };
  48858. ReplaceInput.prototype.setEnabled = function (enabled) {
  48859. if (enabled) {
  48860. this.enable();
  48861. }
  48862. else {
  48863. this.disable();
  48864. }
  48865. };
  48866. ReplaceInput.prototype.style = function (styles) {
  48867. this.inputActiveOptionBorder = styles.inputActiveOptionBorder;
  48868. this.inputActiveOptionBackground = styles.inputActiveOptionBackground;
  48869. this.inputBackground = styles.inputBackground;
  48870. this.inputForeground = styles.inputForeground;
  48871. this.inputBorder = styles.inputBorder;
  48872. this.inputValidationInfoBackground = styles.inputValidationInfoBackground;
  48873. this.inputValidationInfoForeground = styles.inputValidationInfoForeground;
  48874. this.inputValidationInfoBorder = styles.inputValidationInfoBorder;
  48875. this.inputValidationWarningBackground = styles.inputValidationWarningBackground;
  48876. this.inputValidationWarningForeground = styles.inputValidationWarningForeground;
  48877. this.inputValidationWarningBorder = styles.inputValidationWarningBorder;
  48878. this.inputValidationErrorBackground = styles.inputValidationErrorBackground;
  48879. this.inputValidationErrorForeground = styles.inputValidationErrorForeground;
  48880. this.inputValidationErrorBorder = styles.inputValidationErrorBorder;
  48881. this.applyStyles();
  48882. };
  48883. ReplaceInput.prototype.applyStyles = function () {
  48884. if (this.domNode) {
  48885. var checkBoxStyles = {
  48886. inputActiveOptionBorder: this.inputActiveOptionBorder,
  48887. inputActiveOptionBackground: this.inputActiveOptionBackground,
  48888. };
  48889. this.preserveCase.style(checkBoxStyles);
  48890. var inputBoxStyles = {
  48891. inputBackground: this.inputBackground,
  48892. inputForeground: this.inputForeground,
  48893. inputBorder: this.inputBorder,
  48894. inputValidationInfoBackground: this.inputValidationInfoBackground,
  48895. inputValidationInfoForeground: this.inputValidationInfoForeground,
  48896. inputValidationInfoBorder: this.inputValidationInfoBorder,
  48897. inputValidationWarningBackground: this.inputValidationWarningBackground,
  48898. inputValidationWarningForeground: this.inputValidationWarningForeground,
  48899. inputValidationWarningBorder: this.inputValidationWarningBorder,
  48900. inputValidationErrorBackground: this.inputValidationErrorBackground,
  48901. inputValidationErrorForeground: this.inputValidationErrorForeground,
  48902. inputValidationErrorBorder: this.inputValidationErrorBorder
  48903. };
  48904. this.inputBox.style(inputBoxStyles);
  48905. }
  48906. };
  48907. ReplaceInput.prototype.select = function () {
  48908. this.inputBox.select();
  48909. };
  48910. ReplaceInput.prototype.focus = function () {
  48911. this.inputBox.focus();
  48912. };
  48913. ReplaceInput.prototype.getPreserveCase = function () {
  48914. return this.preserveCase.checked;
  48915. };
  48916. ReplaceInput.prototype.setPreserveCase = function (value) {
  48917. this.preserveCase.checked = value;
  48918. };
  48919. ReplaceInput.prototype.focusOnPreserve = function () {
  48920. this.preserveCase.focus();
  48921. };
  48922. ReplaceInput.prototype.validate = function () {
  48923. if (this.inputBox) {
  48924. this.inputBox.validate();
  48925. }
  48926. };
  48927. Object.defineProperty(ReplaceInput.prototype, "width", {
  48928. set: function (newWidth) {
  48929. this.inputBox.paddingRight = this.cachedOptionsWidth;
  48930. this.inputBox.width = newWidth;
  48931. this.domNode.style.width = newWidth + 'px';
  48932. },
  48933. enumerable: true,
  48934. configurable: true
  48935. });
  48936. ReplaceInput.prototype.dispose = function () {
  48937. _super.prototype.dispose.call(this);
  48938. };
  48939. return ReplaceInput;
  48940. }(widget_1.Widget));
  48941. exports.ReplaceInput = ReplaceInput;
  48942. });
  48943. define(__m[402/*vs/nls!vs/base/browser/ui/keybindingLabel/keybindingLabel*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/browser/ui/keybindingLabel/keybindingLabel", data); });
  48944. define(__m[403/*vs/nls!vs/base/browser/ui/list/listWidget*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/browser/ui/list/listWidget", data); });
  48945. /*---------------------------------------------------------------------------------------------
  48946. * Copyright (c) Microsoft Corporation. All rights reserved.
  48947. * Licensed under the MIT License. See License.txt in the project root for license information.
  48948. *--------------------------------------------------------------------------------------------*/
  48949. var __spreadArrays = (this && this.__spreadArrays) || function () {
  48950. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  48951. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  48952. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  48953. r[k] = a[j];
  48954. return r;
  48955. };
  48956. define(__m[153/*vs/base/browser/ui/list/listWidget*/], __M([0/*require*/,1/*exports*/,403/*vs/nls!vs/base/browser/ui/list/listWidget*/,2/*vs/base/common/lifecycle*/,21/*vs/base/common/types*/,19/*vs/base/common/arrays*/,101/*vs/base/common/decorators*/,6/*vs/base/browser/dom*/,16/*vs/base/common/platform*/,57/*vs/base/browser/touch*/,56/*vs/base/browser/keyboardEvent*/,4/*vs/base/common/event*/,52/*vs/base/browser/event*/,239/*vs/base/browser/ui/list/list*/,140/*vs/base/browser/ui/list/listView*/,27/*vs/base/common/color*/,31/*vs/base/common/objects*/,240/*vs/base/browser/ui/list/splice*/,131/*vs/base/common/numbers*/,61/*vs/base/common/filters*/,271/*vs/css!vs/base/browser/ui/list/list*/]), function (require, exports, nls_1, lifecycle_1, types_1, arrays_1, decorators_1, DOM, platform, touch_1, keyboardEvent_1, event_1, event_2, list_1, listView_1, color_1, objects_1, splice_1, numbers_1, filters_1) {
  48957. "use strict";
  48958. Object.defineProperty(exports, "__esModule", { value: true });
  48959. var TraitRenderer = /** @class */ (function () {
  48960. function TraitRenderer(trait) {
  48961. this.trait = trait;
  48962. this.renderedElements = [];
  48963. }
  48964. Object.defineProperty(TraitRenderer.prototype, "templateId", {
  48965. get: function () {
  48966. return "template:" + this.trait.trait;
  48967. },
  48968. enumerable: true,
  48969. configurable: true
  48970. });
  48971. TraitRenderer.prototype.renderTemplate = function (container) {
  48972. return container;
  48973. };
  48974. TraitRenderer.prototype.renderElement = function (element, index, templateData) {
  48975. var renderedElementIndex = arrays_1.firstIndex(this.renderedElements, function (el) { return el.templateData === templateData; });
  48976. if (renderedElementIndex >= 0) {
  48977. var rendered = this.renderedElements[renderedElementIndex];
  48978. this.trait.unrender(templateData);
  48979. rendered.index = index;
  48980. }
  48981. else {
  48982. var rendered = { index: index, templateData: templateData };
  48983. this.renderedElements.push(rendered);
  48984. }
  48985. this.trait.renderIndex(index, templateData);
  48986. };
  48987. TraitRenderer.prototype.splice = function (start, deleteCount, insertCount) {
  48988. var rendered = [];
  48989. for (var _i = 0, _a = this.renderedElements; _i < _a.length; _i++) {
  48990. var renderedElement = _a[_i];
  48991. if (renderedElement.index < start) {
  48992. rendered.push(renderedElement);
  48993. }
  48994. else if (renderedElement.index >= start + deleteCount) {
  48995. rendered.push({
  48996. index: renderedElement.index + insertCount - deleteCount,
  48997. templateData: renderedElement.templateData
  48998. });
  48999. }
  49000. }
  49001. this.renderedElements = rendered;
  49002. };
  49003. TraitRenderer.prototype.renderIndexes = function (indexes) {
  49004. for (var _i = 0, _a = this.renderedElements; _i < _a.length; _i++) {
  49005. var _b = _a[_i], index = _b.index, templateData = _b.templateData;
  49006. if (indexes.indexOf(index) > -1) {
  49007. this.trait.renderIndex(index, templateData);
  49008. }
  49009. }
  49010. };
  49011. TraitRenderer.prototype.disposeTemplate = function (templateData) {
  49012. var index = arrays_1.firstIndex(this.renderedElements, function (el) { return el.templateData === templateData; });
  49013. if (index < 0) {
  49014. return;
  49015. }
  49016. this.renderedElements.splice(index, 1);
  49017. };
  49018. return TraitRenderer;
  49019. }());
  49020. var Trait = /** @class */ (function () {
  49021. function Trait(_trait) {
  49022. this._trait = _trait;
  49023. this.indexes = [];
  49024. this.sortedIndexes = [];
  49025. this._onChange = new event_1.Emitter();
  49026. this.onChange = this._onChange.event;
  49027. }
  49028. Object.defineProperty(Trait.prototype, "trait", {
  49029. get: function () { return this._trait; },
  49030. enumerable: true,
  49031. configurable: true
  49032. });
  49033. Object.defineProperty(Trait.prototype, "renderer", {
  49034. get: function () {
  49035. return new TraitRenderer(this);
  49036. },
  49037. enumerable: true,
  49038. configurable: true
  49039. });
  49040. Trait.prototype.splice = function (start, deleteCount, elements) {
  49041. var diff = elements.length - deleteCount;
  49042. var end = start + deleteCount;
  49043. var indexes = __spreadArrays(this.sortedIndexes.filter(function (i) { return i < start; }), elements.map(function (hasTrait, i) { return hasTrait ? i + start : -1; }).filter(function (i) { return i !== -1; }), this.sortedIndexes.filter(function (i) { return i >= end; }).map(function (i) { return i + diff; }));
  49044. this.renderer.splice(start, deleteCount, elements.length);
  49045. this._set(indexes, indexes);
  49046. };
  49047. Trait.prototype.renderIndex = function (index, container) {
  49048. DOM.toggleClass(container, this._trait, this.contains(index));
  49049. };
  49050. Trait.prototype.unrender = function (container) {
  49051. DOM.removeClass(container, this._trait);
  49052. };
  49053. /**
  49054. * Sets the indexes which should have this trait.
  49055. *
  49056. * @param indexes Indexes which should have this trait.
  49057. * @return The old indexes which had this trait.
  49058. */
  49059. Trait.prototype.set = function (indexes, browserEvent) {
  49060. return this._set(indexes, __spreadArrays(indexes).sort(numericSort), browserEvent);
  49061. };
  49062. Trait.prototype._set = function (indexes, sortedIndexes, browserEvent) {
  49063. var result = this.indexes;
  49064. var sortedResult = this.sortedIndexes;
  49065. this.indexes = indexes;
  49066. this.sortedIndexes = sortedIndexes;
  49067. var toRender = disjunction(sortedResult, indexes);
  49068. this.renderer.renderIndexes(toRender);
  49069. this._onChange.fire({ indexes: indexes, browserEvent: browserEvent });
  49070. return result;
  49071. };
  49072. Trait.prototype.get = function () {
  49073. return this.indexes;
  49074. };
  49075. Trait.prototype.contains = function (index) {
  49076. return arrays_1.binarySearch(this.sortedIndexes, index, numericSort) >= 0;
  49077. };
  49078. Trait.prototype.dispose = function () {
  49079. lifecycle_1.dispose(this._onChange);
  49080. };
  49081. __decorate([
  49082. decorators_1.memoize
  49083. ], Trait.prototype, "renderer", null);
  49084. return Trait;
  49085. }());
  49086. var FocusTrait = /** @class */ (function (_super) {
  49087. __extends(FocusTrait, _super);
  49088. function FocusTrait() {
  49089. return _super.call(this, 'focused') || this;
  49090. }
  49091. FocusTrait.prototype.renderIndex = function (index, container) {
  49092. _super.prototype.renderIndex.call(this, index, container);
  49093. if (this.contains(index)) {
  49094. container.setAttribute('aria-selected', 'true');
  49095. }
  49096. else {
  49097. container.removeAttribute('aria-selected');
  49098. }
  49099. };
  49100. return FocusTrait;
  49101. }(Trait));
  49102. /**
  49103. * The TraitSpliceable is used as a util class to be able
  49104. * to preserve traits across splice calls, given an identity
  49105. * provider.
  49106. */
  49107. var TraitSpliceable = /** @class */ (function () {
  49108. function TraitSpliceable(trait, view, identityProvider) {
  49109. this.trait = trait;
  49110. this.view = view;
  49111. this.identityProvider = identityProvider;
  49112. }
  49113. TraitSpliceable.prototype.splice = function (start, deleteCount, elements) {
  49114. var _this = this;
  49115. if (!this.identityProvider) {
  49116. return this.trait.splice(start, deleteCount, elements.map(function () { return false; }));
  49117. }
  49118. var pastElementsWithTrait = this.trait.get().map(function (i) { return _this.identityProvider.getId(_this.view.element(i)).toString(); });
  49119. var elementsWithTrait = elements.map(function (e) { return pastElementsWithTrait.indexOf(_this.identityProvider.getId(e).toString()) > -1; });
  49120. this.trait.splice(start, deleteCount, elementsWithTrait);
  49121. };
  49122. return TraitSpliceable;
  49123. }());
  49124. function isInputElement(e) {
  49125. return e.tagName === 'INPUT' || e.tagName === 'TEXTAREA';
  49126. }
  49127. var KeyboardController = /** @class */ (function () {
  49128. function KeyboardController(list, view, options) {
  49129. this.list = list;
  49130. this.view = view;
  49131. this.disposables = new lifecycle_1.DisposableStore();
  49132. var multipleSelectionSupport = options.multipleSelectionSupport !== false;
  49133. this.openController = options.openController || DefaultOpenController;
  49134. var onKeyDown = event_1.Event.chain(event_2.domEvent(view.domNode, 'keydown'))
  49135. .filter(function (e) { return !isInputElement(e.target); })
  49136. .map(function (e) { return new keyboardEvent_1.StandardKeyboardEvent(e); });
  49137. onKeyDown.filter(function (e) { return e.keyCode === 3 /* Enter */; }).on(this.onEnter, this, this.disposables);
  49138. onKeyDown.filter(function (e) { return e.keyCode === 16 /* UpArrow */; }).on(this.onUpArrow, this, this.disposables);
  49139. onKeyDown.filter(function (e) { return e.keyCode === 18 /* DownArrow */; }).on(this.onDownArrow, this, this.disposables);
  49140. onKeyDown.filter(function (e) { return e.keyCode === 11 /* PageUp */; }).on(this.onPageUpArrow, this, this.disposables);
  49141. onKeyDown.filter(function (e) { return e.keyCode === 12 /* PageDown */; }).on(this.onPageDownArrow, this, this.disposables);
  49142. onKeyDown.filter(function (e) { return e.keyCode === 9 /* Escape */; }).on(this.onEscape, this, this.disposables);
  49143. if (multipleSelectionSupport) {
  49144. onKeyDown.filter(function (e) { return (platform.isMacintosh ? e.metaKey : e.ctrlKey) && e.keyCode === 31 /* KEY_A */; }).on(this.onCtrlA, this, this.disposables);
  49145. }
  49146. }
  49147. KeyboardController.prototype.onEnter = function (e) {
  49148. e.preventDefault();
  49149. e.stopPropagation();
  49150. this.list.setSelection(this.list.getFocus(), e.browserEvent);
  49151. if (this.openController.shouldOpen(e.browserEvent)) {
  49152. this.list.open(this.list.getFocus(), e.browserEvent);
  49153. }
  49154. };
  49155. KeyboardController.prototype.onUpArrow = function (e) {
  49156. e.preventDefault();
  49157. e.stopPropagation();
  49158. this.list.focusPrevious(1, false, e.browserEvent);
  49159. this.list.reveal(this.list.getFocus()[0]);
  49160. this.view.domNode.focus();
  49161. };
  49162. KeyboardController.prototype.onDownArrow = function (e) {
  49163. e.preventDefault();
  49164. e.stopPropagation();
  49165. this.list.focusNext(1, false, e.browserEvent);
  49166. this.list.reveal(this.list.getFocus()[0]);
  49167. this.view.domNode.focus();
  49168. };
  49169. KeyboardController.prototype.onPageUpArrow = function (e) {
  49170. e.preventDefault();
  49171. e.stopPropagation();
  49172. this.list.focusPreviousPage(e.browserEvent);
  49173. this.list.reveal(this.list.getFocus()[0]);
  49174. this.view.domNode.focus();
  49175. };
  49176. KeyboardController.prototype.onPageDownArrow = function (e) {
  49177. e.preventDefault();
  49178. e.stopPropagation();
  49179. this.list.focusNextPage(e.browserEvent);
  49180. this.list.reveal(this.list.getFocus()[0]);
  49181. this.view.domNode.focus();
  49182. };
  49183. KeyboardController.prototype.onCtrlA = function (e) {
  49184. e.preventDefault();
  49185. e.stopPropagation();
  49186. this.list.setSelection(arrays_1.range(this.list.length), e.browserEvent);
  49187. this.view.domNode.focus();
  49188. };
  49189. KeyboardController.prototype.onEscape = function (e) {
  49190. e.preventDefault();
  49191. e.stopPropagation();
  49192. this.list.setSelection([], e.browserEvent);
  49193. this.view.domNode.focus();
  49194. };
  49195. KeyboardController.prototype.dispose = function () {
  49196. this.disposables.dispose();
  49197. };
  49198. return KeyboardController;
  49199. }());
  49200. var TypeLabelControllerState;
  49201. (function (TypeLabelControllerState) {
  49202. TypeLabelControllerState[TypeLabelControllerState["Idle"] = 0] = "Idle";
  49203. TypeLabelControllerState[TypeLabelControllerState["Typing"] = 1] = "Typing";
  49204. })(TypeLabelControllerState || (TypeLabelControllerState = {}));
  49205. exports.DefaultKeyboardNavigationDelegate = new /** @class */ (function () {
  49206. function class_1() {
  49207. }
  49208. class_1.prototype.mightProducePrintableCharacter = function (event) {
  49209. if (event.ctrlKey || event.metaKey || event.altKey) {
  49210. return false;
  49211. }
  49212. return (event.keyCode >= 31 /* KEY_A */ && event.keyCode <= 56 /* KEY_Z */)
  49213. || (event.keyCode >= 21 /* KEY_0 */ && event.keyCode <= 30 /* KEY_9 */)
  49214. || (event.keyCode >= 93 /* NUMPAD_0 */ && event.keyCode <= 102 /* NUMPAD_9 */)
  49215. || (event.keyCode >= 80 /* US_SEMICOLON */ && event.keyCode <= 90 /* US_QUOTE */);
  49216. };
  49217. return class_1;
  49218. }());
  49219. var TypeLabelController = /** @class */ (function () {
  49220. function TypeLabelController(list, view, keyboardNavigationLabelProvider, delegate) {
  49221. this.list = list;
  49222. this.view = view;
  49223. this.keyboardNavigationLabelProvider = keyboardNavigationLabelProvider;
  49224. this.delegate = delegate;
  49225. this.enabled = false;
  49226. this.state = TypeLabelControllerState.Idle;
  49227. this.automaticKeyboardNavigation = true;
  49228. this.triggered = false;
  49229. this.enabledDisposables = new lifecycle_1.DisposableStore();
  49230. this.disposables = new lifecycle_1.DisposableStore();
  49231. this.updateOptions(list.options);
  49232. }
  49233. TypeLabelController.prototype.updateOptions = function (options) {
  49234. var enableKeyboardNavigation = typeof options.enableKeyboardNavigation === 'undefined' ? true : !!options.enableKeyboardNavigation;
  49235. if (enableKeyboardNavigation) {
  49236. this.enable();
  49237. }
  49238. else {
  49239. this.disable();
  49240. }
  49241. if (typeof options.automaticKeyboardNavigation !== 'undefined') {
  49242. this.automaticKeyboardNavigation = options.automaticKeyboardNavigation;
  49243. }
  49244. };
  49245. TypeLabelController.prototype.enable = function () {
  49246. var _this = this;
  49247. if (this.enabled) {
  49248. return;
  49249. }
  49250. var onChar = event_1.Event.chain(event_2.domEvent(this.view.domNode, 'keydown'))
  49251. .filter(function (e) { return !isInputElement(e.target); })
  49252. .filter(function () { return _this.automaticKeyboardNavigation || _this.triggered; })
  49253. .map(function (event) { return new keyboardEvent_1.StandardKeyboardEvent(event); })
  49254. .filter(function (e) { return _this.delegate.mightProducePrintableCharacter(e); })
  49255. .forEach(function (e) { e.stopPropagation(); e.preventDefault(); })
  49256. .map(function (event) { return event.browserEvent.key; })
  49257. .event;
  49258. var onClear = event_1.Event.debounce(onChar, function () { return null; }, 800);
  49259. var onInput = event_1.Event.reduce(event_1.Event.any(onChar, onClear), function (r, i) { return i === null ? null : ((r || '') + i); });
  49260. onInput(this.onInput, this, this.enabledDisposables);
  49261. this.enabled = true;
  49262. this.triggered = false;
  49263. };
  49264. TypeLabelController.prototype.disable = function () {
  49265. if (!this.enabled) {
  49266. return;
  49267. }
  49268. this.enabledDisposables.clear();
  49269. this.enabled = false;
  49270. this.triggered = false;
  49271. };
  49272. TypeLabelController.prototype.onInput = function (word) {
  49273. if (!word) {
  49274. this.state = TypeLabelControllerState.Idle;
  49275. this.triggered = false;
  49276. return;
  49277. }
  49278. var focus = this.list.getFocus();
  49279. var start = focus.length > 0 ? focus[0] : 0;
  49280. var delta = this.state === TypeLabelControllerState.Idle ? 1 : 0;
  49281. this.state = TypeLabelControllerState.Typing;
  49282. for (var i = 0; i < this.list.length; i++) {
  49283. var index = (start + i + delta) % this.list.length;
  49284. var label = this.keyboardNavigationLabelProvider.getKeyboardNavigationLabel(this.view.element(index));
  49285. var labelStr = label && label.toString();
  49286. if (typeof labelStr === 'undefined' || filters_1.matchesPrefix(word, labelStr)) {
  49287. this.list.setFocus([index]);
  49288. this.list.reveal(index);
  49289. return;
  49290. }
  49291. }
  49292. };
  49293. TypeLabelController.prototype.dispose = function () {
  49294. this.disable();
  49295. this.enabledDisposables.dispose();
  49296. this.disposables.dispose();
  49297. };
  49298. return TypeLabelController;
  49299. }());
  49300. var DOMFocusController = /** @class */ (function () {
  49301. function DOMFocusController(list, view) {
  49302. this.list = list;
  49303. this.view = view;
  49304. this.disposables = new lifecycle_1.DisposableStore();
  49305. var onKeyDown = event_1.Event.chain(event_2.domEvent(view.domNode, 'keydown'))
  49306. .filter(function (e) { return !isInputElement(e.target); })
  49307. .map(function (e) { return new keyboardEvent_1.StandardKeyboardEvent(e); });
  49308. onKeyDown.filter(function (e) { return e.keyCode === 2 /* Tab */ && !e.ctrlKey && !e.metaKey && !e.shiftKey && !e.altKey; })
  49309. .on(this.onTab, this, this.disposables);
  49310. }
  49311. DOMFocusController.prototype.onTab = function (e) {
  49312. if (e.target !== this.view.domNode) {
  49313. return;
  49314. }
  49315. var focus = this.list.getFocus();
  49316. if (focus.length === 0) {
  49317. return;
  49318. }
  49319. var focusedDomElement = this.view.domElement(focus[0]);
  49320. if (!focusedDomElement) {
  49321. return;
  49322. }
  49323. var tabIndexElement = focusedDomElement.querySelector('[tabIndex]');
  49324. if (!tabIndexElement || !(tabIndexElement instanceof HTMLElement) || tabIndexElement.tabIndex === -1) {
  49325. return;
  49326. }
  49327. var style = window.getComputedStyle(tabIndexElement);
  49328. if (style.visibility === 'hidden' || style.display === 'none') {
  49329. return;
  49330. }
  49331. e.preventDefault();
  49332. e.stopPropagation();
  49333. tabIndexElement.focus();
  49334. };
  49335. DOMFocusController.prototype.dispose = function () {
  49336. this.disposables.dispose();
  49337. };
  49338. return DOMFocusController;
  49339. }());
  49340. function isSelectionSingleChangeEvent(event) {
  49341. return platform.isMacintosh ? event.browserEvent.metaKey : event.browserEvent.ctrlKey;
  49342. }
  49343. exports.isSelectionSingleChangeEvent = isSelectionSingleChangeEvent;
  49344. function isSelectionRangeChangeEvent(event) {
  49345. return event.browserEvent.shiftKey;
  49346. }
  49347. exports.isSelectionRangeChangeEvent = isSelectionRangeChangeEvent;
  49348. function isMouseRightClick(event) {
  49349. return event instanceof MouseEvent && event.button === 2;
  49350. }
  49351. var DefaultMultipleSelectionController = {
  49352. isSelectionSingleChangeEvent: isSelectionSingleChangeEvent,
  49353. isSelectionRangeChangeEvent: isSelectionRangeChangeEvent
  49354. };
  49355. var DefaultOpenController = {
  49356. shouldOpen: function (event) {
  49357. if (event instanceof MouseEvent) {
  49358. return !isMouseRightClick(event);
  49359. }
  49360. return true;
  49361. }
  49362. };
  49363. var MouseController = /** @class */ (function () {
  49364. function MouseController(list) {
  49365. this.list = list;
  49366. this.disposables = new lifecycle_1.DisposableStore();
  49367. this.multipleSelectionSupport = !(list.options.multipleSelectionSupport === false);
  49368. if (this.multipleSelectionSupport) {
  49369. this.multipleSelectionController = list.options.multipleSelectionController || DefaultMultipleSelectionController;
  49370. }
  49371. this.openController = list.options.openController || DefaultOpenController;
  49372. this.mouseSupport = typeof list.options.mouseSupport === 'undefined' || !!list.options.mouseSupport;
  49373. if (this.mouseSupport) {
  49374. list.onMouseDown(this.onMouseDown, this, this.disposables);
  49375. list.onContextMenu(this.onContextMenu, this, this.disposables);
  49376. list.onMouseDblClick(this.onDoubleClick, this, this.disposables);
  49377. list.onTouchStart(this.onMouseDown, this, this.disposables);
  49378. this.disposables.add(touch_1.Gesture.addTarget(list.getHTMLElement()));
  49379. }
  49380. list.onMouseClick(this.onPointer, this, this.disposables);
  49381. list.onMouseMiddleClick(this.onPointer, this, this.disposables);
  49382. list.onTap(this.onPointer, this, this.disposables);
  49383. }
  49384. MouseController.prototype.isSelectionSingleChangeEvent = function (event) {
  49385. if (this.multipleSelectionController) {
  49386. return this.multipleSelectionController.isSelectionSingleChangeEvent(event);
  49387. }
  49388. return platform.isMacintosh ? event.browserEvent.metaKey : event.browserEvent.ctrlKey;
  49389. };
  49390. MouseController.prototype.isSelectionRangeChangeEvent = function (event) {
  49391. if (this.multipleSelectionController) {
  49392. return this.multipleSelectionController.isSelectionRangeChangeEvent(event);
  49393. }
  49394. return event.browserEvent.shiftKey;
  49395. };
  49396. MouseController.prototype.isSelectionChangeEvent = function (event) {
  49397. return this.isSelectionSingleChangeEvent(event) || this.isSelectionRangeChangeEvent(event);
  49398. };
  49399. MouseController.prototype.onMouseDown = function (e) {
  49400. if (document.activeElement !== e.browserEvent.target) {
  49401. this.list.domFocus();
  49402. }
  49403. };
  49404. MouseController.prototype.onContextMenu = function (e) {
  49405. var focus = typeof e.index === 'undefined' ? [] : [e.index];
  49406. this.list.setFocus(focus, e.browserEvent);
  49407. };
  49408. MouseController.prototype.onPointer = function (e) {
  49409. if (!this.mouseSupport) {
  49410. return;
  49411. }
  49412. if (isInputElement(e.browserEvent.target)) {
  49413. return;
  49414. }
  49415. var reference = this.list.getFocus()[0];
  49416. var selection = this.list.getSelection();
  49417. reference = reference === undefined ? selection[0] : reference;
  49418. var focus = e.index;
  49419. if (typeof focus === 'undefined') {
  49420. this.list.setFocus([], e.browserEvent);
  49421. this.list.setSelection([], e.browserEvent);
  49422. return;
  49423. }
  49424. if (this.multipleSelectionSupport && this.isSelectionRangeChangeEvent(e)) {
  49425. return this.changeSelection(e, reference);
  49426. }
  49427. if (this.multipleSelectionSupport && this.isSelectionChangeEvent(e)) {
  49428. return this.changeSelection(e, reference);
  49429. }
  49430. this.list.setFocus([focus], e.browserEvent);
  49431. if (!isMouseRightClick(e.browserEvent)) {
  49432. this.list.setSelection([focus], e.browserEvent);
  49433. if (this.openController.shouldOpen(e.browserEvent)) {
  49434. this.list.open([focus], e.browserEvent);
  49435. }
  49436. }
  49437. };
  49438. MouseController.prototype.onDoubleClick = function (e) {
  49439. if (isInputElement(e.browserEvent.target)) {
  49440. return;
  49441. }
  49442. if (this.multipleSelectionSupport && this.isSelectionChangeEvent(e)) {
  49443. return;
  49444. }
  49445. var focus = this.list.getFocus();
  49446. this.list.setSelection(focus, e.browserEvent);
  49447. this.list.pin(focus);
  49448. };
  49449. MouseController.prototype.changeSelection = function (e, reference) {
  49450. var focus = e.index;
  49451. if (this.isSelectionRangeChangeEvent(e) && reference !== undefined) {
  49452. var min = Math.min(reference, focus);
  49453. var max = Math.max(reference, focus);
  49454. var rangeSelection = arrays_1.range(min, max + 1);
  49455. var selection = this.list.getSelection();
  49456. var contiguousRange = getContiguousRangeContaining(disjunction(selection, [reference]), reference);
  49457. if (contiguousRange.length === 0) {
  49458. return;
  49459. }
  49460. var newSelection = disjunction(rangeSelection, relativeComplement(selection, contiguousRange));
  49461. this.list.setSelection(newSelection, e.browserEvent);
  49462. }
  49463. else if (this.isSelectionSingleChangeEvent(e)) {
  49464. var selection = this.list.getSelection();
  49465. var newSelection = selection.filter(function (i) { return i !== focus; });
  49466. this.list.setFocus([focus]);
  49467. if (selection.length === newSelection.length) {
  49468. this.list.setSelection(__spreadArrays(newSelection, [focus]), e.browserEvent);
  49469. }
  49470. else {
  49471. this.list.setSelection(newSelection, e.browserEvent);
  49472. }
  49473. }
  49474. };
  49475. MouseController.prototype.dispose = function () {
  49476. this.disposables.dispose();
  49477. };
  49478. return MouseController;
  49479. }());
  49480. exports.MouseController = MouseController;
  49481. var DefaultStyleController = /** @class */ (function () {
  49482. function DefaultStyleController(styleElement, selectorSuffix) {
  49483. this.styleElement = styleElement;
  49484. this.selectorSuffix = selectorSuffix;
  49485. }
  49486. DefaultStyleController.prototype.style = function (styles) {
  49487. var suffix = this.selectorSuffix && "." + this.selectorSuffix;
  49488. var content = [];
  49489. if (styles.listBackground) {
  49490. if (styles.listBackground.isOpaque()) {
  49491. content.push(".monaco-list" + suffix + " .monaco-list-rows { background: " + styles.listBackground + "; }");
  49492. }
  49493. else if (!platform.isMacintosh) { // subpixel AA doesn't exist in macOS
  49494. console.warn("List with id '" + this.selectorSuffix + "' was styled with a non-opaque background color. This will break sub-pixel antialiasing.");
  49495. }
  49496. }
  49497. if (styles.listFocusBackground) {
  49498. content.push(".monaco-list" + suffix + ":focus .monaco-list-row.focused { background-color: " + styles.listFocusBackground + "; }");
  49499. content.push(".monaco-list" + suffix + ":focus .monaco-list-row.focused:hover { background-color: " + styles.listFocusBackground + "; }"); // overwrite :hover style in this case!
  49500. }
  49501. if (styles.listFocusForeground) {
  49502. content.push(".monaco-list" + suffix + ":focus .monaco-list-row.focused { color: " + styles.listFocusForeground + "; }");
  49503. }
  49504. if (styles.listActiveSelectionBackground) {
  49505. content.push(".monaco-list" + suffix + ":focus .monaco-list-row.selected { background-color: " + styles.listActiveSelectionBackground + "; }");
  49506. content.push(".monaco-list" + suffix + ":focus .monaco-list-row.selected:hover { background-color: " + styles.listActiveSelectionBackground + "; }"); // overwrite :hover style in this case!
  49507. }
  49508. if (styles.listActiveSelectionForeground) {
  49509. content.push(".monaco-list" + suffix + ":focus .monaco-list-row.selected { color: " + styles.listActiveSelectionForeground + "; }");
  49510. }
  49511. if (styles.listFocusAndSelectionBackground) {
  49512. content.push("\n\t\t\t\t.monaco-drag-image,\n\t\t\t\t.monaco-list" + suffix + ":focus .monaco-list-row.selected.focused { background-color: " + styles.listFocusAndSelectionBackground + "; }\n\t\t\t");
  49513. }
  49514. if (styles.listFocusAndSelectionForeground) {
  49515. content.push("\n\t\t\t\t.monaco-drag-image,\n\t\t\t\t.monaco-list" + suffix + ":focus .monaco-list-row.selected.focused { color: " + styles.listFocusAndSelectionForeground + "; }\n\t\t\t");
  49516. }
  49517. if (styles.listInactiveFocusBackground) {
  49518. content.push(".monaco-list" + suffix + " .monaco-list-row.focused { background-color: " + styles.listInactiveFocusBackground + "; }");
  49519. content.push(".monaco-list" + suffix + " .monaco-list-row.focused:hover { background-color: " + styles.listInactiveFocusBackground + "; }"); // overwrite :hover style in this case!
  49520. }
  49521. if (styles.listInactiveSelectionBackground) {
  49522. content.push(".monaco-list" + suffix + " .monaco-list-row.selected { background-color: " + styles.listInactiveSelectionBackground + "; }");
  49523. content.push(".monaco-list" + suffix + " .monaco-list-row.selected:hover { background-color: " + styles.listInactiveSelectionBackground + "; }"); // overwrite :hover style in this case!
  49524. }
  49525. if (styles.listInactiveSelectionForeground) {
  49526. content.push(".monaco-list" + suffix + " .monaco-list-row.selected { color: " + styles.listInactiveSelectionForeground + "; }");
  49527. }
  49528. if (styles.listHoverBackground) {
  49529. content.push(".monaco-list" + suffix + ":not(.drop-target) .monaco-list-row:hover:not(.selected):not(.focused) { background-color: " + styles.listHoverBackground + "; }");
  49530. }
  49531. if (styles.listHoverForeground) {
  49532. content.push(".monaco-list" + suffix + " .monaco-list-row:hover:not(.selected):not(.focused) { color: " + styles.listHoverForeground + "; }");
  49533. }
  49534. if (styles.listSelectionOutline) {
  49535. content.push(".monaco-list" + suffix + " .monaco-list-row.selected { outline: 1px dotted " + styles.listSelectionOutline + "; outline-offset: -1px; }");
  49536. }
  49537. if (styles.listFocusOutline) {
  49538. content.push("\n\t\t\t\t.monaco-drag-image,\n\t\t\t\t.monaco-list" + suffix + ":focus .monaco-list-row.focused { outline: 1px solid " + styles.listFocusOutline + "; outline-offset: -1px; }\n\t\t\t");
  49539. }
  49540. if (styles.listInactiveFocusOutline) {
  49541. content.push(".monaco-list" + suffix + " .monaco-list-row.focused { outline: 1px dotted " + styles.listInactiveFocusOutline + "; outline-offset: -1px; }");
  49542. }
  49543. if (styles.listHoverOutline) {
  49544. content.push(".monaco-list" + suffix + " .monaco-list-row:hover { outline: 1px dashed " + styles.listHoverOutline + "; outline-offset: -1px; }");
  49545. }
  49546. if (styles.listDropBackground) {
  49547. content.push("\n\t\t\t\t.monaco-list" + suffix + ".drop-target,\n\t\t\t\t.monaco-list" + suffix + " .monaco-list-rows.drop-target,\n\t\t\t\t.monaco-list" + suffix + " .monaco-list-row.drop-target { background-color: " + styles.listDropBackground + " !important; color: inherit !important; }\n\t\t\t");
  49548. }
  49549. if (styles.listFilterWidgetBackground) {
  49550. content.push(".monaco-list-type-filter { background-color: " + styles.listFilterWidgetBackground + " }");
  49551. }
  49552. if (styles.listFilterWidgetOutline) {
  49553. content.push(".monaco-list-type-filter { border: 1px solid " + styles.listFilterWidgetOutline + "; }");
  49554. }
  49555. if (styles.listFilterWidgetNoMatchesOutline) {
  49556. content.push(".monaco-list-type-filter.no-matches { border: 1px solid " + styles.listFilterWidgetNoMatchesOutline + "; }");
  49557. }
  49558. if (styles.listMatchesShadow) {
  49559. content.push(".monaco-list-type-filter { box-shadow: 1px 1px 1px " + styles.listMatchesShadow + "; }");
  49560. }
  49561. var newStyles = content.join('\n');
  49562. if (newStyles !== this.styleElement.innerHTML) {
  49563. this.styleElement.innerHTML = newStyles;
  49564. }
  49565. };
  49566. return DefaultStyleController;
  49567. }());
  49568. exports.DefaultStyleController = DefaultStyleController;
  49569. var defaultStyles = {
  49570. listFocusBackground: color_1.Color.fromHex('#7FB0D0'),
  49571. listActiveSelectionBackground: color_1.Color.fromHex('#0E639C'),
  49572. listActiveSelectionForeground: color_1.Color.fromHex('#FFFFFF'),
  49573. listFocusAndSelectionBackground: color_1.Color.fromHex('#094771'),
  49574. listFocusAndSelectionForeground: color_1.Color.fromHex('#FFFFFF'),
  49575. listInactiveSelectionBackground: color_1.Color.fromHex('#3F3F46'),
  49576. listHoverBackground: color_1.Color.fromHex('#2A2D2E'),
  49577. listDropBackground: color_1.Color.fromHex('#383B3D'),
  49578. treeIndentGuidesStroke: color_1.Color.fromHex('#a9a9a9')
  49579. };
  49580. var DefaultOptions = {
  49581. keyboardSupport: true,
  49582. mouseSupport: true,
  49583. multipleSelectionSupport: true,
  49584. dnd: {
  49585. getDragURI: function () { return null; },
  49586. onDragStart: function () { },
  49587. onDragOver: function () { return false; },
  49588. drop: function () { }
  49589. },
  49590. ariaRootRole: list_1.ListAriaRootRole.TREE
  49591. };
  49592. // TODO@Joao: move these utils into a SortedArray class
  49593. function getContiguousRangeContaining(range, value) {
  49594. var index = range.indexOf(value);
  49595. if (index === -1) {
  49596. return [];
  49597. }
  49598. var result = [];
  49599. var i = index - 1;
  49600. while (i >= 0 && range[i] === value - (index - i)) {
  49601. result.push(range[i--]);
  49602. }
  49603. result.reverse();
  49604. i = index;
  49605. while (i < range.length && range[i] === value + (i - index)) {
  49606. result.push(range[i++]);
  49607. }
  49608. return result;
  49609. }
  49610. /**
  49611. * Given two sorted collections of numbers, returns the intersection
  49612. * between them (OR).
  49613. */
  49614. function disjunction(one, other) {
  49615. var result = [];
  49616. var i = 0, j = 0;
  49617. while (i < one.length || j < other.length) {
  49618. if (i >= one.length) {
  49619. result.push(other[j++]);
  49620. }
  49621. else if (j >= other.length) {
  49622. result.push(one[i++]);
  49623. }
  49624. else if (one[i] === other[j]) {
  49625. result.push(one[i]);
  49626. i++;
  49627. j++;
  49628. continue;
  49629. }
  49630. else if (one[i] < other[j]) {
  49631. result.push(one[i++]);
  49632. }
  49633. else {
  49634. result.push(other[j++]);
  49635. }
  49636. }
  49637. return result;
  49638. }
  49639. /**
  49640. * Given two sorted collections of numbers, returns the relative
  49641. * complement between them (XOR).
  49642. */
  49643. function relativeComplement(one, other) {
  49644. var result = [];
  49645. var i = 0, j = 0;
  49646. while (i < one.length || j < other.length) {
  49647. if (i >= one.length) {
  49648. result.push(other[j++]);
  49649. }
  49650. else if (j >= other.length) {
  49651. result.push(one[i++]);
  49652. }
  49653. else if (one[i] === other[j]) {
  49654. i++;
  49655. j++;
  49656. continue;
  49657. }
  49658. else if (one[i] < other[j]) {
  49659. result.push(one[i++]);
  49660. }
  49661. else {
  49662. j++;
  49663. }
  49664. }
  49665. return result;
  49666. }
  49667. var numericSort = function (a, b) { return a - b; };
  49668. var PipelineRenderer = /** @class */ (function () {
  49669. function PipelineRenderer(_templateId, renderers) {
  49670. this._templateId = _templateId;
  49671. this.renderers = renderers;
  49672. }
  49673. Object.defineProperty(PipelineRenderer.prototype, "templateId", {
  49674. get: function () {
  49675. return this._templateId;
  49676. },
  49677. enumerable: true,
  49678. configurable: true
  49679. });
  49680. PipelineRenderer.prototype.renderTemplate = function (container) {
  49681. return this.renderers.map(function (r) { return r.renderTemplate(container); });
  49682. };
  49683. PipelineRenderer.prototype.renderElement = function (element, index, templateData, height) {
  49684. var i = 0;
  49685. for (var _i = 0, _a = this.renderers; _i < _a.length; _i++) {
  49686. var renderer = _a[_i];
  49687. renderer.renderElement(element, index, templateData[i++], height);
  49688. }
  49689. };
  49690. PipelineRenderer.prototype.disposeElement = function (element, index, templateData, height) {
  49691. var i = 0;
  49692. for (var _i = 0, _a = this.renderers; _i < _a.length; _i++) {
  49693. var renderer = _a[_i];
  49694. if (renderer.disposeElement) {
  49695. renderer.disposeElement(element, index, templateData[i], height);
  49696. }
  49697. i += 1;
  49698. }
  49699. };
  49700. PipelineRenderer.prototype.disposeTemplate = function (templateData) {
  49701. var i = 0;
  49702. for (var _i = 0, _a = this.renderers; _i < _a.length; _i++) {
  49703. var renderer = _a[_i];
  49704. renderer.disposeTemplate(templateData[i++]);
  49705. }
  49706. };
  49707. return PipelineRenderer;
  49708. }());
  49709. var AccessibiltyRenderer = /** @class */ (function () {
  49710. function AccessibiltyRenderer(accessibilityProvider) {
  49711. this.accessibilityProvider = accessibilityProvider;
  49712. this.templateId = 'a18n';
  49713. }
  49714. AccessibiltyRenderer.prototype.renderTemplate = function (container) {
  49715. return container;
  49716. };
  49717. AccessibiltyRenderer.prototype.renderElement = function (element, index, container) {
  49718. var ariaLabel = this.accessibilityProvider.getAriaLabel(element);
  49719. if (ariaLabel) {
  49720. container.setAttribute('aria-label', ariaLabel);
  49721. }
  49722. else {
  49723. container.removeAttribute('aria-label');
  49724. }
  49725. var ariaLevel = this.accessibilityProvider.getAriaLevel && this.accessibilityProvider.getAriaLevel(element);
  49726. if (typeof ariaLevel === 'number') {
  49727. container.setAttribute('aria-level', "" + ariaLevel);
  49728. }
  49729. else {
  49730. container.removeAttribute('aria-level');
  49731. }
  49732. };
  49733. AccessibiltyRenderer.prototype.disposeTemplate = function (templateData) {
  49734. // noop
  49735. };
  49736. return AccessibiltyRenderer;
  49737. }());
  49738. var ListViewDragAndDrop = /** @class */ (function () {
  49739. function ListViewDragAndDrop(list, dnd) {
  49740. this.list = list;
  49741. this.dnd = dnd;
  49742. }
  49743. ListViewDragAndDrop.prototype.getDragElements = function (element) {
  49744. var selection = this.list.getSelectedElements();
  49745. var elements = selection.indexOf(element) > -1 ? selection : [element];
  49746. return elements;
  49747. };
  49748. ListViewDragAndDrop.prototype.getDragURI = function (element) {
  49749. return this.dnd.getDragURI(element);
  49750. };
  49751. ListViewDragAndDrop.prototype.getDragLabel = function (elements, originalEvent) {
  49752. if (this.dnd.getDragLabel) {
  49753. return this.dnd.getDragLabel(elements, originalEvent);
  49754. }
  49755. return undefined;
  49756. };
  49757. ListViewDragAndDrop.prototype.onDragStart = function (data, originalEvent) {
  49758. if (this.dnd.onDragStart) {
  49759. this.dnd.onDragStart(data, originalEvent);
  49760. }
  49761. };
  49762. ListViewDragAndDrop.prototype.onDragOver = function (data, targetElement, targetIndex, originalEvent) {
  49763. return this.dnd.onDragOver(data, targetElement, targetIndex, originalEvent);
  49764. };
  49765. ListViewDragAndDrop.prototype.onDragEnd = function (originalEvent) {
  49766. if (this.dnd.onDragEnd) {
  49767. this.dnd.onDragEnd(originalEvent);
  49768. }
  49769. };
  49770. ListViewDragAndDrop.prototype.drop = function (data, targetElement, targetIndex, originalEvent) {
  49771. this.dnd.drop(data, targetElement, targetIndex, originalEvent);
  49772. };
  49773. return ListViewDragAndDrop;
  49774. }());
  49775. var List = /** @class */ (function () {
  49776. function List(user, container, virtualDelegate, renderers, _options) {
  49777. if (_options === void 0) { _options = DefaultOptions; }
  49778. this.user = user;
  49779. this._options = _options;
  49780. this.eventBufferer = new event_1.EventBufferer();
  49781. this.disposables = new lifecycle_1.DisposableStore();
  49782. this._onDidOpen = new event_1.Emitter();
  49783. this.onDidOpen = this._onDidOpen.event;
  49784. this._onDidPin = new event_1.Emitter();
  49785. this.didJustPressContextMenuKey = false;
  49786. this._onDidDispose = new event_1.Emitter();
  49787. this.onDidDispose = this._onDidDispose.event;
  49788. this.focus = new FocusTrait();
  49789. this.selection = new Trait('selected');
  49790. objects_1.mixin(_options, defaultStyles, false);
  49791. var baseRenderers = [this.focus.renderer, this.selection.renderer];
  49792. this.accessibilityProvider = _options.accessibilityProvider;
  49793. if (this.accessibilityProvider) {
  49794. baseRenderers.push(new AccessibiltyRenderer(this.accessibilityProvider));
  49795. if (this.accessibilityProvider.onDidChangeActiveDescendant) {
  49796. this.accessibilityProvider.onDidChangeActiveDescendant(this.onDidChangeActiveDescendant, this, this.disposables);
  49797. }
  49798. }
  49799. renderers = renderers.map(function (r) { return new PipelineRenderer(r.templateId, __spreadArrays(baseRenderers, [r])); });
  49800. var viewOptions = __assign(__assign({}, _options), { dnd: _options.dnd && new ListViewDragAndDrop(this, _options.dnd) });
  49801. this.view = new listView_1.ListView(container, virtualDelegate, renderers, viewOptions);
  49802. if (typeof _options.ariaRole !== 'string') {
  49803. this.view.domNode.setAttribute('role', list_1.ListAriaRootRole.TREE);
  49804. }
  49805. else {
  49806. this.view.domNode.setAttribute('role', _options.ariaRole);
  49807. }
  49808. if (_options.styleController) {
  49809. this.styleController = _options.styleController(this.view.domId);
  49810. }
  49811. else {
  49812. var styleElement = DOM.createStyleSheet(this.view.domNode);
  49813. this.styleController = new DefaultStyleController(styleElement, this.view.domId);
  49814. }
  49815. this.spliceable = new splice_1.CombinedSpliceable([
  49816. new TraitSpliceable(this.focus, this.view, _options.identityProvider),
  49817. new TraitSpliceable(this.selection, this.view, _options.identityProvider),
  49818. this.view
  49819. ]);
  49820. this.disposables.add(this.focus);
  49821. this.disposables.add(this.selection);
  49822. this.disposables.add(this.view);
  49823. this.disposables.add(this._onDidDispose);
  49824. this.onDidFocus = event_1.Event.map(event_2.domEvent(this.view.domNode, 'focus', true), function () { return null; });
  49825. this.onDidBlur = event_1.Event.map(event_2.domEvent(this.view.domNode, 'blur', true), function () { return null; });
  49826. this.disposables.add(new DOMFocusController(this, this.view));
  49827. if (typeof _options.keyboardSupport !== 'boolean' || _options.keyboardSupport) {
  49828. var controller = new KeyboardController(this, this.view, _options);
  49829. this.disposables.add(controller);
  49830. }
  49831. if (_options.keyboardNavigationLabelProvider) {
  49832. var delegate = _options.keyboardNavigationDelegate || exports.DefaultKeyboardNavigationDelegate;
  49833. this.typeLabelController = new TypeLabelController(this, this.view, _options.keyboardNavigationLabelProvider, delegate);
  49834. this.disposables.add(this.typeLabelController);
  49835. }
  49836. this.disposables.add(this.createMouseController(_options));
  49837. this.onFocusChange(this._onFocusChange, this, this.disposables);
  49838. this.onSelectionChange(this._onSelectionChange, this, this.disposables);
  49839. if (_options.ariaLabel) {
  49840. this.view.domNode.setAttribute('aria-label', nls_1.localize(0, null, _options.ariaLabel));
  49841. }
  49842. }
  49843. Object.defineProperty(List.prototype, "onFocusChange", {
  49844. get: function () {
  49845. var _this = this;
  49846. return event_1.Event.map(this.eventBufferer.wrapEvent(this.focus.onChange), function (e) { return _this.toListEvent(e); });
  49847. },
  49848. enumerable: true,
  49849. configurable: true
  49850. });
  49851. Object.defineProperty(List.prototype, "onSelectionChange", {
  49852. get: function () {
  49853. var _this = this;
  49854. return event_1.Event.map(this.eventBufferer.wrapEvent(this.selection.onChange), function (e) { return _this.toListEvent(e); });
  49855. },
  49856. enumerable: true,
  49857. configurable: true
  49858. });
  49859. Object.defineProperty(List.prototype, "domId", {
  49860. get: function () { return this.view.domId; },
  49861. enumerable: true,
  49862. configurable: true
  49863. });
  49864. Object.defineProperty(List.prototype, "onMouseClick", {
  49865. get: function () { return this.view.onMouseClick; },
  49866. enumerable: true,
  49867. configurable: true
  49868. });
  49869. Object.defineProperty(List.prototype, "onMouseDblClick", {
  49870. get: function () { return this.view.onMouseDblClick; },
  49871. enumerable: true,
  49872. configurable: true
  49873. });
  49874. Object.defineProperty(List.prototype, "onMouseMiddleClick", {
  49875. get: function () { return this.view.onMouseMiddleClick; },
  49876. enumerable: true,
  49877. configurable: true
  49878. });
  49879. Object.defineProperty(List.prototype, "onMouseDown", {
  49880. get: function () { return this.view.onMouseDown; },
  49881. enumerable: true,
  49882. configurable: true
  49883. });
  49884. Object.defineProperty(List.prototype, "onTouchStart", {
  49885. get: function () { return this.view.onTouchStart; },
  49886. enumerable: true,
  49887. configurable: true
  49888. });
  49889. Object.defineProperty(List.prototype, "onTap", {
  49890. get: function () { return this.view.onTap; },
  49891. enumerable: true,
  49892. configurable: true
  49893. });
  49894. Object.defineProperty(List.prototype, "onContextMenu", {
  49895. get: function () {
  49896. var _this = this;
  49897. var fromKeydown = event_1.Event.chain(event_2.domEvent(this.view.domNode, 'keydown'))
  49898. .map(function (e) { return new keyboardEvent_1.StandardKeyboardEvent(e); })
  49899. .filter(function (e) { return _this.didJustPressContextMenuKey = e.keyCode === 58 /* ContextMenu */ || (e.shiftKey && e.keyCode === 68 /* F10 */); })
  49900. .filter(function (e) { e.preventDefault(); e.stopPropagation(); return false; })
  49901. .event;
  49902. var fromKeyup = event_1.Event.chain(event_2.domEvent(this.view.domNode, 'keyup'))
  49903. .filter(function () {
  49904. var didJustPressContextMenuKey = _this.didJustPressContextMenuKey;
  49905. _this.didJustPressContextMenuKey = false;
  49906. return didJustPressContextMenuKey;
  49907. })
  49908. .filter(function () { return _this.getFocus().length > 0 && !!_this.view.domElement(_this.getFocus()[0]); })
  49909. .map(function (browserEvent) {
  49910. var index = _this.getFocus()[0];
  49911. var element = _this.view.element(index);
  49912. var anchor = _this.view.domElement(index);
  49913. return { index: index, element: element, anchor: anchor, browserEvent: browserEvent };
  49914. })
  49915. .event;
  49916. var fromMouse = event_1.Event.chain(this.view.onContextMenu)
  49917. .filter(function () { return !_this.didJustPressContextMenuKey; })
  49918. .map(function (_a) {
  49919. var element = _a.element, index = _a.index, browserEvent = _a.browserEvent;
  49920. return ({ element: element, index: index, anchor: { x: browserEvent.clientX + 1, y: browserEvent.clientY }, browserEvent: browserEvent });
  49921. })
  49922. .event;
  49923. return event_1.Event.any(fromKeydown, fromKeyup, fromMouse);
  49924. },
  49925. enumerable: true,
  49926. configurable: true
  49927. });
  49928. Object.defineProperty(List.prototype, "onKeyDown", {
  49929. get: function () { return event_2.domEvent(this.view.domNode, 'keydown'); },
  49930. enumerable: true,
  49931. configurable: true
  49932. });
  49933. List.prototype.createMouseController = function (options) {
  49934. return new MouseController(this);
  49935. };
  49936. List.prototype.updateOptions = function (optionsUpdate) {
  49937. if (optionsUpdate === void 0) { optionsUpdate = {}; }
  49938. this._options = __assign(__assign({}, this._options), optionsUpdate);
  49939. if (this.typeLabelController) {
  49940. this.typeLabelController.updateOptions(this._options);
  49941. }
  49942. };
  49943. Object.defineProperty(List.prototype, "options", {
  49944. get: function () {
  49945. return this._options;
  49946. },
  49947. enumerable: true,
  49948. configurable: true
  49949. });
  49950. List.prototype.splice = function (start, deleteCount, elements) {
  49951. var _this = this;
  49952. if (elements === void 0) { elements = []; }
  49953. if (start < 0 || start > this.view.length) {
  49954. throw new list_1.ListError(this.user, "Invalid start index: " + start);
  49955. }
  49956. if (deleteCount < 0) {
  49957. throw new list_1.ListError(this.user, "Invalid delete count: " + deleteCount);
  49958. }
  49959. if (deleteCount === 0 && elements.length === 0) {
  49960. return;
  49961. }
  49962. this.eventBufferer.bufferEvents(function () { return _this.spliceable.splice(start, deleteCount, elements); });
  49963. };
  49964. List.prototype.rerender = function () {
  49965. this.view.rerender();
  49966. };
  49967. List.prototype.element = function (index) {
  49968. return this.view.element(index);
  49969. };
  49970. Object.defineProperty(List.prototype, "length", {
  49971. get: function () {
  49972. return this.view.length;
  49973. },
  49974. enumerable: true,
  49975. configurable: true
  49976. });
  49977. Object.defineProperty(List.prototype, "contentHeight", {
  49978. get: function () {
  49979. return this.view.contentHeight;
  49980. },
  49981. enumerable: true,
  49982. configurable: true
  49983. });
  49984. Object.defineProperty(List.prototype, "scrollTop", {
  49985. get: function () {
  49986. return this.view.getScrollTop();
  49987. },
  49988. set: function (scrollTop) {
  49989. this.view.setScrollTop(scrollTop);
  49990. },
  49991. enumerable: true,
  49992. configurable: true
  49993. });
  49994. List.prototype.domFocus = function () {
  49995. this.view.domNode.focus();
  49996. };
  49997. List.prototype.layout = function (height, width) {
  49998. this.view.layout(height, width);
  49999. };
  50000. List.prototype.setSelection = function (indexes, browserEvent) {
  50001. for (var _i = 0, indexes_1 = indexes; _i < indexes_1.length; _i++) {
  50002. var index = indexes_1[_i];
  50003. if (index < 0 || index >= this.length) {
  50004. throw new list_1.ListError(this.user, "Invalid index " + index);
  50005. }
  50006. }
  50007. this.selection.set(indexes, browserEvent);
  50008. };
  50009. List.prototype.getSelection = function () {
  50010. return this.selection.get();
  50011. };
  50012. List.prototype.getSelectedElements = function () {
  50013. var _this = this;
  50014. return this.getSelection().map(function (i) { return _this.view.element(i); });
  50015. };
  50016. List.prototype.setFocus = function (indexes, browserEvent) {
  50017. for (var _i = 0, indexes_2 = indexes; _i < indexes_2.length; _i++) {
  50018. var index = indexes_2[_i];
  50019. if (index < 0 || index >= this.length) {
  50020. throw new list_1.ListError(this.user, "Invalid index " + index);
  50021. }
  50022. }
  50023. this.focus.set(indexes, browserEvent);
  50024. };
  50025. List.prototype.focusNext = function (n, loop, browserEvent, filter) {
  50026. if (n === void 0) { n = 1; }
  50027. if (loop === void 0) { loop = false; }
  50028. if (this.length === 0) {
  50029. return;
  50030. }
  50031. var focus = this.focus.get();
  50032. var index = this.findNextIndex(focus.length > 0 ? focus[0] + n : 0, loop, filter);
  50033. if (index > -1) {
  50034. this.setFocus([index], browserEvent);
  50035. }
  50036. };
  50037. List.prototype.focusPrevious = function (n, loop, browserEvent, filter) {
  50038. if (n === void 0) { n = 1; }
  50039. if (loop === void 0) { loop = false; }
  50040. if (this.length === 0) {
  50041. return;
  50042. }
  50043. var focus = this.focus.get();
  50044. var index = this.findPreviousIndex(focus.length > 0 ? focus[0] - n : 0, loop, filter);
  50045. if (index > -1) {
  50046. this.setFocus([index], browserEvent);
  50047. }
  50048. };
  50049. List.prototype.focusNextPage = function (browserEvent, filter) {
  50050. var _this = this;
  50051. var lastPageIndex = this.view.indexAt(this.view.getScrollTop() + this.view.renderHeight);
  50052. lastPageIndex = lastPageIndex === 0 ? 0 : lastPageIndex - 1;
  50053. var lastPageElement = this.view.element(lastPageIndex);
  50054. var currentlyFocusedElement = this.getFocusedElements()[0];
  50055. if (currentlyFocusedElement !== lastPageElement) {
  50056. var lastGoodPageIndex = this.findPreviousIndex(lastPageIndex, false, filter);
  50057. if (lastGoodPageIndex > -1 && currentlyFocusedElement !== this.view.element(lastGoodPageIndex)) {
  50058. this.setFocus([lastGoodPageIndex], browserEvent);
  50059. }
  50060. else {
  50061. this.setFocus([lastPageIndex], browserEvent);
  50062. }
  50063. }
  50064. else {
  50065. var previousScrollTop = this.view.getScrollTop();
  50066. this.view.setScrollTop(previousScrollTop + this.view.renderHeight - this.view.elementHeight(lastPageIndex));
  50067. if (this.view.getScrollTop() !== previousScrollTop) {
  50068. // Let the scroll event listener run
  50069. setTimeout(function () { return _this.focusNextPage(browserEvent, filter); }, 0);
  50070. }
  50071. }
  50072. };
  50073. List.prototype.focusPreviousPage = function (browserEvent, filter) {
  50074. var _this = this;
  50075. var firstPageIndex;
  50076. var scrollTop = this.view.getScrollTop();
  50077. if (scrollTop === 0) {
  50078. firstPageIndex = this.view.indexAt(scrollTop);
  50079. }
  50080. else {
  50081. firstPageIndex = this.view.indexAfter(scrollTop - 1);
  50082. }
  50083. var firstPageElement = this.view.element(firstPageIndex);
  50084. var currentlyFocusedElement = this.getFocusedElements()[0];
  50085. if (currentlyFocusedElement !== firstPageElement) {
  50086. var firstGoodPageIndex = this.findNextIndex(firstPageIndex, false, filter);
  50087. if (firstGoodPageIndex > -1 && currentlyFocusedElement !== this.view.element(firstGoodPageIndex)) {
  50088. this.setFocus([firstGoodPageIndex], browserEvent);
  50089. }
  50090. else {
  50091. this.setFocus([firstPageIndex], browserEvent);
  50092. }
  50093. }
  50094. else {
  50095. var previousScrollTop = scrollTop;
  50096. this.view.setScrollTop(scrollTop - this.view.renderHeight);
  50097. if (this.view.getScrollTop() !== previousScrollTop) {
  50098. // Let the scroll event listener run
  50099. setTimeout(function () { return _this.focusPreviousPage(browserEvent, filter); }, 0);
  50100. }
  50101. }
  50102. };
  50103. List.prototype.focusLast = function (browserEvent, filter) {
  50104. if (this.length === 0) {
  50105. return;
  50106. }
  50107. var index = this.findPreviousIndex(this.length - 1, false, filter);
  50108. if (index > -1) {
  50109. this.setFocus([index], browserEvent);
  50110. }
  50111. };
  50112. List.prototype.focusFirst = function (browserEvent, filter) {
  50113. if (this.length === 0) {
  50114. return;
  50115. }
  50116. var index = this.findNextIndex(0, false, filter);
  50117. if (index > -1) {
  50118. this.setFocus([index], browserEvent);
  50119. }
  50120. };
  50121. List.prototype.findNextIndex = function (index, loop, filter) {
  50122. if (loop === void 0) { loop = false; }
  50123. for (var i = 0; i < this.length; i++) {
  50124. if (index >= this.length && !loop) {
  50125. return -1;
  50126. }
  50127. index = index % this.length;
  50128. if (!filter || filter(this.element(index))) {
  50129. return index;
  50130. }
  50131. index++;
  50132. }
  50133. return -1;
  50134. };
  50135. List.prototype.findPreviousIndex = function (index, loop, filter) {
  50136. if (loop === void 0) { loop = false; }
  50137. for (var i = 0; i < this.length; i++) {
  50138. if (index < 0 && !loop) {
  50139. return -1;
  50140. }
  50141. index = (this.length + (index % this.length)) % this.length;
  50142. if (!filter || filter(this.element(index))) {
  50143. return index;
  50144. }
  50145. index--;
  50146. }
  50147. return -1;
  50148. };
  50149. List.prototype.getFocus = function () {
  50150. return this.focus.get();
  50151. };
  50152. List.prototype.getFocusedElements = function () {
  50153. var _this = this;
  50154. return this.getFocus().map(function (i) { return _this.view.element(i); });
  50155. };
  50156. List.prototype.reveal = function (index, relativeTop) {
  50157. if (index < 0 || index >= this.length) {
  50158. throw new list_1.ListError(this.user, "Invalid index " + index);
  50159. }
  50160. var scrollTop = this.view.getScrollTop();
  50161. var elementTop = this.view.elementTop(index);
  50162. var elementHeight = this.view.elementHeight(index);
  50163. if (types_1.isNumber(relativeTop)) {
  50164. // y = mx + b
  50165. var m = elementHeight - this.view.renderHeight;
  50166. this.view.setScrollTop(m * numbers_1.clamp(relativeTop, 0, 1) + elementTop);
  50167. }
  50168. else {
  50169. var viewItemBottom = elementTop + elementHeight;
  50170. var wrapperBottom = scrollTop + this.view.renderHeight;
  50171. if (elementTop < scrollTop && viewItemBottom >= wrapperBottom) {
  50172. // The element is already overflowing the viewport, no-op
  50173. }
  50174. else if (elementTop < scrollTop) {
  50175. this.view.setScrollTop(elementTop);
  50176. }
  50177. else if (viewItemBottom >= wrapperBottom) {
  50178. this.view.setScrollTop(viewItemBottom - this.view.renderHeight);
  50179. }
  50180. }
  50181. };
  50182. /**
  50183. * Returns the relative position of an element rendered in the list.
  50184. * Returns `null` if the element isn't *entirely* in the visible viewport.
  50185. */
  50186. List.prototype.getRelativeTop = function (index) {
  50187. if (index < 0 || index >= this.length) {
  50188. throw new list_1.ListError(this.user, "Invalid index " + index);
  50189. }
  50190. var scrollTop = this.view.getScrollTop();
  50191. var elementTop = this.view.elementTop(index);
  50192. var elementHeight = this.view.elementHeight(index);
  50193. if (elementTop < scrollTop || elementTop + elementHeight > scrollTop + this.view.renderHeight) {
  50194. return null;
  50195. }
  50196. // y = mx + b
  50197. var m = elementHeight - this.view.renderHeight;
  50198. return Math.abs((scrollTop - elementTop) / m);
  50199. };
  50200. List.prototype.getHTMLElement = function () {
  50201. return this.view.domNode;
  50202. };
  50203. List.prototype.open = function (indexes, browserEvent) {
  50204. var _this = this;
  50205. for (var _i = 0, indexes_3 = indexes; _i < indexes_3.length; _i++) {
  50206. var index = indexes_3[_i];
  50207. if (index < 0 || index >= this.length) {
  50208. throw new list_1.ListError(this.user, "Invalid index " + index);
  50209. }
  50210. }
  50211. this._onDidOpen.fire({ indexes: indexes, elements: indexes.map(function (i) { return _this.view.element(i); }), browserEvent: browserEvent });
  50212. };
  50213. List.prototype.pin = function (indexes, browserEvent) {
  50214. var _this = this;
  50215. for (var _i = 0, indexes_4 = indexes; _i < indexes_4.length; _i++) {
  50216. var index = indexes_4[_i];
  50217. if (index < 0 || index >= this.length) {
  50218. throw new list_1.ListError(this.user, "Invalid index " + index);
  50219. }
  50220. }
  50221. this._onDidPin.fire({ indexes: indexes, elements: indexes.map(function (i) { return _this.view.element(i); }), browserEvent: browserEvent });
  50222. };
  50223. List.prototype.style = function (styles) {
  50224. this.styleController.style(styles);
  50225. };
  50226. List.prototype.toListEvent = function (_a) {
  50227. var _this = this;
  50228. var indexes = _a.indexes, browserEvent = _a.browserEvent;
  50229. return { indexes: indexes, elements: indexes.map(function (i) { return _this.view.element(i); }), browserEvent: browserEvent };
  50230. };
  50231. List.prototype._onFocusChange = function () {
  50232. var focus = this.focus.get();
  50233. DOM.toggleClass(this.view.domNode, 'element-focused', focus.length > 0);
  50234. this.onDidChangeActiveDescendant();
  50235. };
  50236. List.prototype.onDidChangeActiveDescendant = function () {
  50237. var _a;
  50238. var focus = this.focus.get();
  50239. if (focus.length > 0) {
  50240. var id = void 0;
  50241. if ((_a = this.accessibilityProvider) === null || _a === void 0 ? void 0 : _a.getActiveDescendantId) {
  50242. id = this.accessibilityProvider.getActiveDescendantId(this.view.element(focus[0]));
  50243. }
  50244. this.view.domNode.setAttribute('aria-activedescendant', id || this.view.getElementDomId(focus[0]));
  50245. }
  50246. else {
  50247. this.view.domNode.removeAttribute('aria-activedescendant');
  50248. }
  50249. };
  50250. List.prototype._onSelectionChange = function () {
  50251. var selection = this.selection.get();
  50252. DOM.toggleClass(this.view.domNode, 'selection-none', selection.length === 0);
  50253. DOM.toggleClass(this.view.domNode, 'selection-single', selection.length === 1);
  50254. DOM.toggleClass(this.view.domNode, 'selection-multiple', selection.length > 1);
  50255. };
  50256. List.prototype.dispose = function () {
  50257. this._onDidDispose.fire();
  50258. this.disposables.dispose();
  50259. this._onDidOpen.dispose();
  50260. this._onDidPin.dispose();
  50261. this._onDidDispose.dispose();
  50262. };
  50263. __decorate([
  50264. decorators_1.memoize
  50265. ], List.prototype, "onFocusChange", null);
  50266. __decorate([
  50267. decorators_1.memoize
  50268. ], List.prototype, "onSelectionChange", null);
  50269. __decorate([
  50270. decorators_1.memoize
  50271. ], List.prototype, "onContextMenu", null);
  50272. return List;
  50273. }());
  50274. exports.List = List;
  50275. });
  50276. define(__m[404/*vs/nls!vs/base/browser/ui/menu/menu*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/browser/ui/menu/menu", data); });
  50277. /*---------------------------------------------------------------------------------------------
  50278. * Copyright (c) Microsoft Corporation. All rights reserved.
  50279. * Licensed under the MIT License. See License.txt in the project root for license information.
  50280. *--------------------------------------------------------------------------------------------*/
  50281. var __spreadArrays = (this && this.__spreadArrays) || function () {
  50282. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  50283. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  50284. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  50285. r[k] = a[j];
  50286. return r;
  50287. };
  50288. define(__m[205/*vs/base/browser/ui/menu/menu*/], __M([0/*require*/,1/*exports*/,404/*vs/nls!vs/base/browser/ui/menu/menu*/,5/*vs/base/common/strings*/,55/*vs/base/common/actions*/,70/*vs/base/browser/ui/actionbar/actionbar*/,6/*vs/base/browser/dom*/,56/*vs/base/browser/keyboardEvent*/,15/*vs/base/common/async*/,2/*vs/base/common/lifecycle*/,53/*vs/base/browser/ui/scrollbar/scrollableElement*/,16/*vs/base/common/platform*/,272/*vs/css!vs/base/browser/ui/menu/menu*/]), function (require, exports, nls, strings, actions_1, actionbar_1, dom_1, keyboardEvent_1, async_1, lifecycle_1, scrollableElement_1, platform_1) {
  50289. "use strict";
  50290. Object.defineProperty(exports, "__esModule", { value: true });
  50291. exports.MENU_MNEMONIC_REGEX = /\(&([^\s&])\)|(^|[^&])&([^\s&])/;
  50292. exports.MENU_ESCAPED_MNEMONIC_REGEX = /(&amp;)?(&amp;)([^\s&])/g;
  50293. var Direction;
  50294. (function (Direction) {
  50295. Direction[Direction["Right"] = 0] = "Right";
  50296. Direction[Direction["Left"] = 1] = "Left";
  50297. })(Direction = exports.Direction || (exports.Direction = {}));
  50298. var SubmenuAction = /** @class */ (function (_super) {
  50299. __extends(SubmenuAction, _super);
  50300. function SubmenuAction(label, entries, cssClass) {
  50301. var _this = _super.call(this, !!cssClass ? cssClass : 'submenu', label, '', true) || this;
  50302. _this.entries = entries;
  50303. return _this;
  50304. }
  50305. return SubmenuAction;
  50306. }(actions_1.Action));
  50307. exports.SubmenuAction = SubmenuAction;
  50308. var Menu = /** @class */ (function (_super) {
  50309. __extends(Menu, _super);
  50310. function Menu(container, actions, options) {
  50311. if (options === void 0) { options = {}; }
  50312. var _this = this;
  50313. dom_1.addClass(container, 'monaco-menu-container');
  50314. container.setAttribute('role', 'presentation');
  50315. var menuElement = document.createElement('div');
  50316. dom_1.addClass(menuElement, 'monaco-menu');
  50317. menuElement.setAttribute('role', 'presentation');
  50318. _this = _super.call(this, menuElement, {
  50319. orientation: 2 /* VERTICAL */,
  50320. actionViewItemProvider: function (action) { return _this.doGetActionViewItem(action, options, parentData); },
  50321. context: options.context,
  50322. actionRunner: options.actionRunner,
  50323. ariaLabel: options.ariaLabel,
  50324. triggerKeys: { keys: __spreadArrays([3 /* Enter */], (platform_1.isMacintosh ? [10 /* Space */] : [])), keyDown: true }
  50325. }) || this;
  50326. _this.menuElement = menuElement;
  50327. _this.actionsList.setAttribute('role', 'menu');
  50328. _this.actionsList.tabIndex = 0;
  50329. _this.menuDisposables = _this._register(new lifecycle_1.DisposableStore());
  50330. dom_1.addDisposableListener(menuElement, dom_1.EventType.KEY_DOWN, function (e) {
  50331. var event = new keyboardEvent_1.StandardKeyboardEvent(e);
  50332. // Stop tab navigation of menus
  50333. if (event.equals(2 /* Tab */)) {
  50334. e.preventDefault();
  50335. }
  50336. });
  50337. if (options.enableMnemonics) {
  50338. _this.menuDisposables.add(dom_1.addDisposableListener(menuElement, dom_1.EventType.KEY_DOWN, function (e) {
  50339. var key = e.key.toLocaleLowerCase();
  50340. if (_this.mnemonics.has(key)) {
  50341. dom_1.EventHelper.stop(e, true);
  50342. var actions_2 = _this.mnemonics.get(key);
  50343. if (actions_2.length === 1) {
  50344. if (actions_2[0] instanceof SubmenuMenuActionViewItem && actions_2[0].container) {
  50345. _this.focusItemByElement(actions_2[0].container);
  50346. }
  50347. actions_2[0].onClick(e);
  50348. }
  50349. if (actions_2.length > 1) {
  50350. var action = actions_2.shift();
  50351. if (action && action.container) {
  50352. _this.focusItemByElement(action.container);
  50353. actions_2.push(action);
  50354. }
  50355. _this.mnemonics.set(key, actions_2);
  50356. }
  50357. }
  50358. }));
  50359. }
  50360. if (platform_1.isLinux) {
  50361. _this._register(dom_1.addDisposableListener(menuElement, dom_1.EventType.KEY_DOWN, function (e) {
  50362. var event = new keyboardEvent_1.StandardKeyboardEvent(e);
  50363. if (event.equals(14 /* Home */) || event.equals(11 /* PageUp */)) {
  50364. _this.focusedItem = _this.viewItems.length - 1;
  50365. _this.focusNext();
  50366. dom_1.EventHelper.stop(e, true);
  50367. }
  50368. else if (event.equals(13 /* End */) || event.equals(12 /* PageDown */)) {
  50369. _this.focusedItem = 0;
  50370. _this.focusPrevious();
  50371. dom_1.EventHelper.stop(e, true);
  50372. }
  50373. }));
  50374. }
  50375. _this._register(dom_1.addDisposableListener(_this.domNode, dom_1.EventType.MOUSE_OUT, function (e) {
  50376. var relatedTarget = e.relatedTarget;
  50377. if (!dom_1.isAncestor(relatedTarget, _this.domNode)) {
  50378. _this.focusedItem = undefined;
  50379. _this.updateFocus();
  50380. e.stopPropagation();
  50381. }
  50382. }));
  50383. _this._register(dom_1.addDisposableListener(_this.actionsList, dom_1.EventType.MOUSE_OVER, function (e) {
  50384. var target = e.target;
  50385. if (!target || !dom_1.isAncestor(target, _this.actionsList) || target === _this.actionsList) {
  50386. return;
  50387. }
  50388. while (target.parentElement !== _this.actionsList && target.parentElement !== null) {
  50389. target = target.parentElement;
  50390. }
  50391. if (dom_1.hasClass(target, 'action-item')) {
  50392. var lastFocusedItem = _this.focusedItem;
  50393. _this.setFocusedItem(target);
  50394. if (lastFocusedItem !== _this.focusedItem) {
  50395. _this.updateFocus();
  50396. }
  50397. }
  50398. }));
  50399. var parentData = {
  50400. parent: _this
  50401. };
  50402. _this.mnemonics = new Map();
  50403. // Scroll Logic
  50404. _this.scrollableElement = _this._register(new scrollableElement_1.DomScrollableElement(menuElement, {
  50405. alwaysConsumeMouseWheel: true,
  50406. horizontal: 2 /* Hidden */,
  50407. vertical: 3 /* Visible */,
  50408. verticalScrollbarSize: 7,
  50409. handleMouseWheel: true,
  50410. useShadows: true
  50411. }));
  50412. var scrollElement = _this.scrollableElement.getDomNode();
  50413. scrollElement.style.position = '';
  50414. _this._register(dom_1.addDisposableListener(scrollElement, dom_1.EventType.MOUSE_UP, function (e) {
  50415. // Absorb clicks in menu dead space https://github.com/Microsoft/vscode/issues/63575
  50416. // We do this on the scroll element so the scroll bar doesn't dismiss the menu either
  50417. e.preventDefault();
  50418. }));
  50419. menuElement.style.maxHeight = Math.max(10, window.innerHeight - container.getBoundingClientRect().top - 30) + "px";
  50420. _this.push(actions, { icon: true, label: true, isMenu: true });
  50421. container.appendChild(_this.scrollableElement.getDomNode());
  50422. _this.scrollableElement.scanDomNode();
  50423. _this.viewItems.filter(function (item) { return !(item instanceof MenuSeparatorActionViewItem); }).forEach(function (item, index, array) {
  50424. item.updatePositionInSet(index + 1, array.length);
  50425. });
  50426. return _this;
  50427. }
  50428. Menu.prototype.style = function (style) {
  50429. var container = this.getContainer();
  50430. var fgColor = style.foregroundColor ? "" + style.foregroundColor : '';
  50431. var bgColor = style.backgroundColor ? "" + style.backgroundColor : '';
  50432. var border = style.borderColor ? "1px solid " + style.borderColor : '';
  50433. var shadow = style.shadowColor ? "0 2px 4px " + style.shadowColor : '';
  50434. container.style.border = border;
  50435. this.domNode.style.color = fgColor;
  50436. this.domNode.style.backgroundColor = bgColor;
  50437. container.style.boxShadow = shadow;
  50438. if (this.viewItems) {
  50439. this.viewItems.forEach(function (item) {
  50440. if (item instanceof BaseMenuActionViewItem || item instanceof MenuSeparatorActionViewItem) {
  50441. item.style(style);
  50442. }
  50443. });
  50444. }
  50445. };
  50446. Menu.prototype.getContainer = function () {
  50447. return this.scrollableElement.getDomNode();
  50448. };
  50449. Object.defineProperty(Menu.prototype, "onScroll", {
  50450. get: function () {
  50451. return this.scrollableElement.onScroll;
  50452. },
  50453. enumerable: true,
  50454. configurable: true
  50455. });
  50456. Object.defineProperty(Menu.prototype, "scrollOffset", {
  50457. get: function () {
  50458. return this.menuElement.scrollTop;
  50459. },
  50460. enumerable: true,
  50461. configurable: true
  50462. });
  50463. Menu.prototype.focusItemByElement = function (element) {
  50464. var lastFocusedItem = this.focusedItem;
  50465. this.setFocusedItem(element);
  50466. if (lastFocusedItem !== this.focusedItem) {
  50467. this.updateFocus();
  50468. }
  50469. };
  50470. Menu.prototype.setFocusedItem = function (element) {
  50471. for (var i = 0; i < this.actionsList.children.length; i++) {
  50472. var elem = this.actionsList.children[i];
  50473. if (element === elem) {
  50474. this.focusedItem = i;
  50475. break;
  50476. }
  50477. }
  50478. };
  50479. Menu.prototype.updateFocus = function (fromRight) {
  50480. _super.prototype.updateFocus.call(this, fromRight, true);
  50481. if (typeof this.focusedItem !== 'undefined') {
  50482. // Workaround for #80047 caused by an issue in chromium
  50483. // https://bugs.chromium.org/p/chromium/issues/detail?id=414283
  50484. // When that's fixed, just call this.scrollableElement.scanDomNode()
  50485. this.scrollableElement.setScrollPosition({
  50486. scrollTop: Math.round(this.menuElement.scrollTop)
  50487. });
  50488. }
  50489. };
  50490. Menu.prototype.doGetActionViewItem = function (action, options, parentData) {
  50491. if (action instanceof actionbar_1.Separator) {
  50492. return new MenuSeparatorActionViewItem(options.context, action, { icon: true });
  50493. }
  50494. else if (action instanceof SubmenuAction) {
  50495. var menuActionViewItem = new SubmenuMenuActionViewItem(action, action.entries, parentData, options);
  50496. if (options.enableMnemonics) {
  50497. var mnemonic = menuActionViewItem.getMnemonic();
  50498. if (mnemonic && menuActionViewItem.isEnabled()) {
  50499. var actionViewItems = [];
  50500. if (this.mnemonics.has(mnemonic)) {
  50501. actionViewItems = this.mnemonics.get(mnemonic);
  50502. }
  50503. actionViewItems.push(menuActionViewItem);
  50504. this.mnemonics.set(mnemonic, actionViewItems);
  50505. }
  50506. }
  50507. return menuActionViewItem;
  50508. }
  50509. else {
  50510. var menuItemOptions = { enableMnemonics: options.enableMnemonics };
  50511. if (options.getKeyBinding) {
  50512. var keybinding = options.getKeyBinding(action);
  50513. if (keybinding) {
  50514. var keybindingLabel = keybinding.getLabel();
  50515. if (keybindingLabel) {
  50516. menuItemOptions.keybinding = keybindingLabel;
  50517. }
  50518. }
  50519. }
  50520. var menuActionViewItem = new BaseMenuActionViewItem(options.context, action, menuItemOptions);
  50521. if (options.enableMnemonics) {
  50522. var mnemonic = menuActionViewItem.getMnemonic();
  50523. if (mnemonic && menuActionViewItem.isEnabled()) {
  50524. var actionViewItems = [];
  50525. if (this.mnemonics.has(mnemonic)) {
  50526. actionViewItems = this.mnemonics.get(mnemonic);
  50527. }
  50528. actionViewItems.push(menuActionViewItem);
  50529. this.mnemonics.set(mnemonic, actionViewItems);
  50530. }
  50531. }
  50532. return menuActionViewItem;
  50533. }
  50534. };
  50535. return Menu;
  50536. }(actionbar_1.ActionBar));
  50537. exports.Menu = Menu;
  50538. var BaseMenuActionViewItem = /** @class */ (function (_super) {
  50539. __extends(BaseMenuActionViewItem, _super);
  50540. function BaseMenuActionViewItem(ctx, action, options) {
  50541. if (options === void 0) { options = {}; }
  50542. var _this = this;
  50543. options.isMenu = true;
  50544. _this = _super.call(this, action, action, options) || this;
  50545. _this.options = options;
  50546. _this.options.icon = options.icon !== undefined ? options.icon : false;
  50547. _this.options.label = options.label !== undefined ? options.label : true;
  50548. _this.cssClass = '';
  50549. // Set mnemonic
  50550. if (_this.options.label && options.enableMnemonics) {
  50551. var label = _this.getAction().label;
  50552. if (label) {
  50553. var matches = exports.MENU_MNEMONIC_REGEX.exec(label);
  50554. if (matches) {
  50555. _this.mnemonic = (!!matches[1] ? matches[1] : matches[3]).toLocaleLowerCase();
  50556. }
  50557. }
  50558. }
  50559. // Add mouse up listener later to avoid accidental clicks
  50560. _this.runOnceToEnableMouseUp = new async_1.RunOnceScheduler(function () {
  50561. if (!_this.element) {
  50562. return;
  50563. }
  50564. _this._register(dom_1.addDisposableListener(_this.element, dom_1.EventType.MOUSE_UP, function (e) {
  50565. if (e.defaultPrevented) {
  50566. return;
  50567. }
  50568. dom_1.EventHelper.stop(e, true);
  50569. _this.onClick(e);
  50570. }));
  50571. }, 100);
  50572. _this._register(_this.runOnceToEnableMouseUp);
  50573. return _this;
  50574. }
  50575. BaseMenuActionViewItem.prototype.render = function (container) {
  50576. _super.prototype.render.call(this, container);
  50577. if (!this.element) {
  50578. return;
  50579. }
  50580. this.container = container;
  50581. this.item = dom_1.append(this.element, dom_1.$('a.action-menu-item'));
  50582. if (this._action.id === actionbar_1.Separator.ID) {
  50583. // A separator is a presentation item
  50584. this.item.setAttribute('role', 'presentation');
  50585. }
  50586. else {
  50587. this.item.setAttribute('role', 'menuitem');
  50588. if (this.mnemonic) {
  50589. this.item.setAttribute('aria-keyshortcuts', "" + this.mnemonic);
  50590. }
  50591. }
  50592. this.check = dom_1.append(this.item, dom_1.$('span.menu-item-check.codicon.codicon-check'));
  50593. this.check.setAttribute('role', 'none');
  50594. this.label = dom_1.append(this.item, dom_1.$('span.action-label'));
  50595. if (this.options.label && this.options.keybinding) {
  50596. dom_1.append(this.item, dom_1.$('span.keybinding')).textContent = this.options.keybinding;
  50597. }
  50598. // Adds mouse up listener to actually run the action
  50599. this.runOnceToEnableMouseUp.schedule();
  50600. this.updateClass();
  50601. this.updateLabel();
  50602. this.updateTooltip();
  50603. this.updateEnabled();
  50604. this.updateChecked();
  50605. };
  50606. BaseMenuActionViewItem.prototype.blur = function () {
  50607. _super.prototype.blur.call(this);
  50608. this.applyStyle();
  50609. };
  50610. BaseMenuActionViewItem.prototype.focus = function () {
  50611. _super.prototype.focus.call(this);
  50612. if (this.item) {
  50613. this.item.focus();
  50614. }
  50615. this.applyStyle();
  50616. };
  50617. BaseMenuActionViewItem.prototype.updatePositionInSet = function (pos, setSize) {
  50618. if (this.item) {
  50619. this.item.setAttribute('aria-posinset', "" + pos);
  50620. this.item.setAttribute('aria-setsize', "" + setSize);
  50621. }
  50622. };
  50623. BaseMenuActionViewItem.prototype.updateLabel = function () {
  50624. if (this.options.label) {
  50625. var label = this.getAction().label;
  50626. if (label) {
  50627. var cleanLabel = cleanMnemonic(label);
  50628. if (!this.options.enableMnemonics) {
  50629. label = cleanLabel;
  50630. }
  50631. if (this.label) {
  50632. this.label.setAttribute('aria-label', cleanLabel.replace(/&&/g, '&'));
  50633. }
  50634. var matches = exports.MENU_MNEMONIC_REGEX.exec(label);
  50635. if (matches) {
  50636. label = strings.escape(label);
  50637. // This is global, reset it
  50638. exports.MENU_ESCAPED_MNEMONIC_REGEX.lastIndex = 0;
  50639. var escMatch = exports.MENU_ESCAPED_MNEMONIC_REGEX.exec(label);
  50640. // We can't use negative lookbehind so if we match our negative and skip
  50641. while (escMatch && escMatch[1]) {
  50642. escMatch = exports.MENU_ESCAPED_MNEMONIC_REGEX.exec(label);
  50643. }
  50644. if (escMatch) {
  50645. label = label.substr(0, escMatch.index) + "<u aria-hidden=\"true\">" + escMatch[3] + "</u>" + label.substr(escMatch.index + escMatch[0].length);
  50646. }
  50647. label = label.replace(/&amp;&amp;/g, '&amp;');
  50648. if (this.item) {
  50649. this.item.setAttribute('aria-keyshortcuts', (!!matches[1] ? matches[1] : matches[3]).toLocaleLowerCase());
  50650. }
  50651. }
  50652. else {
  50653. label = label.replace(/&&/g, '&');
  50654. }
  50655. }
  50656. if (this.label) {
  50657. this.label.innerHTML = label.trim();
  50658. }
  50659. }
  50660. };
  50661. BaseMenuActionViewItem.prototype.updateTooltip = function () {
  50662. var title = null;
  50663. if (this.getAction().tooltip) {
  50664. title = this.getAction().tooltip;
  50665. }
  50666. else if (!this.options.label && this.getAction().label && this.options.icon) {
  50667. title = this.getAction().label;
  50668. if (this.options.keybinding) {
  50669. title = nls.localize(0, null, title, this.options.keybinding);
  50670. }
  50671. }
  50672. if (title && this.item) {
  50673. this.item.title = title;
  50674. }
  50675. };
  50676. BaseMenuActionViewItem.prototype.updateClass = function () {
  50677. if (this.cssClass && this.item) {
  50678. dom_1.removeClasses(this.item, this.cssClass);
  50679. }
  50680. if (this.options.icon && this.label) {
  50681. this.cssClass = this.getAction().class || '';
  50682. dom_1.addClass(this.label, 'icon');
  50683. if (this.cssClass) {
  50684. dom_1.addClasses(this.label, this.cssClass);
  50685. }
  50686. this.updateEnabled();
  50687. }
  50688. else if (this.label) {
  50689. dom_1.removeClass(this.label, 'icon');
  50690. }
  50691. };
  50692. BaseMenuActionViewItem.prototype.updateEnabled = function () {
  50693. if (this.getAction().enabled) {
  50694. if (this.element) {
  50695. dom_1.removeClass(this.element, 'disabled');
  50696. }
  50697. if (this.item) {
  50698. dom_1.removeClass(this.item, 'disabled');
  50699. this.item.tabIndex = 0;
  50700. }
  50701. }
  50702. else {
  50703. if (this.element) {
  50704. dom_1.addClass(this.element, 'disabled');
  50705. }
  50706. if (this.item) {
  50707. dom_1.addClass(this.item, 'disabled');
  50708. dom_1.removeTabIndexAndUpdateFocus(this.item);
  50709. }
  50710. }
  50711. };
  50712. BaseMenuActionViewItem.prototype.updateChecked = function () {
  50713. if (!this.item) {
  50714. return;
  50715. }
  50716. if (this.getAction().checked) {
  50717. dom_1.addClass(this.item, 'checked');
  50718. this.item.setAttribute('role', 'menuitemcheckbox');
  50719. this.item.setAttribute('aria-checked', 'true');
  50720. }
  50721. else {
  50722. dom_1.removeClass(this.item, 'checked');
  50723. this.item.setAttribute('role', 'menuitem');
  50724. this.item.setAttribute('aria-checked', 'false');
  50725. }
  50726. };
  50727. BaseMenuActionViewItem.prototype.getMnemonic = function () {
  50728. return this.mnemonic;
  50729. };
  50730. BaseMenuActionViewItem.prototype.applyStyle = function () {
  50731. if (!this.menuStyle) {
  50732. return;
  50733. }
  50734. var isSelected = this.element && dom_1.hasClass(this.element, 'focused');
  50735. var fgColor = isSelected && this.menuStyle.selectionForegroundColor ? this.menuStyle.selectionForegroundColor : this.menuStyle.foregroundColor;
  50736. var bgColor = isSelected && this.menuStyle.selectionBackgroundColor ? this.menuStyle.selectionBackgroundColor : undefined;
  50737. var border = isSelected && this.menuStyle.selectionBorderColor ? "thin solid " + this.menuStyle.selectionBorderColor : '';
  50738. if (this.item) {
  50739. this.item.style.color = fgColor ? fgColor.toString() : '';
  50740. this.item.style.backgroundColor = bgColor ? bgColor.toString() : '';
  50741. }
  50742. if (this.check) {
  50743. this.check.style.color = fgColor ? fgColor.toString() : '';
  50744. }
  50745. if (this.container) {
  50746. this.container.style.border = border;
  50747. }
  50748. };
  50749. BaseMenuActionViewItem.prototype.style = function (style) {
  50750. this.menuStyle = style;
  50751. this.applyStyle();
  50752. };
  50753. return BaseMenuActionViewItem;
  50754. }(actionbar_1.BaseActionViewItem));
  50755. var SubmenuMenuActionViewItem = /** @class */ (function (_super) {
  50756. __extends(SubmenuMenuActionViewItem, _super);
  50757. function SubmenuMenuActionViewItem(action, submenuActions, parentData, submenuOptions) {
  50758. var _this = _super.call(this, action, action, submenuOptions) || this;
  50759. _this.submenuActions = submenuActions;
  50760. _this.parentData = parentData;
  50761. _this.submenuOptions = submenuOptions;
  50762. _this.mysubmenu = null;
  50763. _this.submenuDisposables = _this._register(new lifecycle_1.DisposableStore());
  50764. _this.mouseOver = false;
  50765. _this.expandDirection = submenuOptions && submenuOptions.expandDirection !== undefined ? submenuOptions.expandDirection : Direction.Right;
  50766. _this.showScheduler = new async_1.RunOnceScheduler(function () {
  50767. if (_this.mouseOver) {
  50768. _this.cleanupExistingSubmenu(false);
  50769. _this.createSubmenu(false);
  50770. }
  50771. }, 250);
  50772. _this.hideScheduler = new async_1.RunOnceScheduler(function () {
  50773. if (_this.element && (!dom_1.isAncestor(document.activeElement, _this.element) && _this.parentData.submenu === _this.mysubmenu)) {
  50774. _this.parentData.parent.focus(false);
  50775. _this.cleanupExistingSubmenu(true);
  50776. }
  50777. }, 750);
  50778. return _this;
  50779. }
  50780. SubmenuMenuActionViewItem.prototype.render = function (container) {
  50781. var _this = this;
  50782. _super.prototype.render.call(this, container);
  50783. if (!this.element) {
  50784. return;
  50785. }
  50786. if (this.item) {
  50787. dom_1.addClass(this.item, 'monaco-submenu-item');
  50788. this.item.setAttribute('aria-haspopup', 'true');
  50789. this.updateAriaExpanded('false');
  50790. this.submenuIndicator = dom_1.append(this.item, dom_1.$('span.submenu-indicator.codicon.codicon-chevron-right'));
  50791. this.submenuIndicator.setAttribute('aria-hidden', 'true');
  50792. }
  50793. this._register(dom_1.addDisposableListener(this.element, dom_1.EventType.KEY_UP, function (e) {
  50794. var event = new keyboardEvent_1.StandardKeyboardEvent(e);
  50795. if (event.equals(17 /* RightArrow */) || event.equals(3 /* Enter */)) {
  50796. dom_1.EventHelper.stop(e, true);
  50797. _this.createSubmenu(true);
  50798. }
  50799. }));
  50800. this._register(dom_1.addDisposableListener(this.element, dom_1.EventType.KEY_DOWN, function (e) {
  50801. var event = new keyboardEvent_1.StandardKeyboardEvent(e);
  50802. if (document.activeElement === _this.item) {
  50803. if (event.equals(17 /* RightArrow */) || event.equals(3 /* Enter */)) {
  50804. dom_1.EventHelper.stop(e, true);
  50805. }
  50806. }
  50807. }));
  50808. this._register(dom_1.addDisposableListener(this.element, dom_1.EventType.MOUSE_OVER, function (e) {
  50809. if (!_this.mouseOver) {
  50810. _this.mouseOver = true;
  50811. _this.showScheduler.schedule();
  50812. }
  50813. }));
  50814. this._register(dom_1.addDisposableListener(this.element, dom_1.EventType.MOUSE_LEAVE, function (e) {
  50815. _this.mouseOver = false;
  50816. }));
  50817. this._register(dom_1.addDisposableListener(this.element, dom_1.EventType.FOCUS_OUT, function (e) {
  50818. if (_this.element && !dom_1.isAncestor(document.activeElement, _this.element)) {
  50819. _this.hideScheduler.schedule();
  50820. }
  50821. }));
  50822. this._register(this.parentData.parent.onScroll(function () {
  50823. _this.parentData.parent.focus(false);
  50824. _this.cleanupExistingSubmenu(false);
  50825. }));
  50826. };
  50827. SubmenuMenuActionViewItem.prototype.onClick = function (e) {
  50828. // stop clicking from trying to run an action
  50829. dom_1.EventHelper.stop(e, true);
  50830. this.cleanupExistingSubmenu(false);
  50831. this.createSubmenu(true);
  50832. };
  50833. SubmenuMenuActionViewItem.prototype.cleanupExistingSubmenu = function (force) {
  50834. if (this.parentData.submenu && (force || (this.parentData.submenu !== this.mysubmenu))) {
  50835. this.parentData.submenu.dispose();
  50836. this.parentData.submenu = undefined;
  50837. this.updateAriaExpanded('false');
  50838. if (this.submenuContainer) {
  50839. this.submenuDisposables.clear();
  50840. this.submenuContainer = undefined;
  50841. }
  50842. }
  50843. };
  50844. SubmenuMenuActionViewItem.prototype.createSubmenu = function (selectFirstItem) {
  50845. var _this = this;
  50846. if (selectFirstItem === void 0) { selectFirstItem = true; }
  50847. if (!this.element) {
  50848. return;
  50849. }
  50850. if (!this.parentData.submenu) {
  50851. this.updateAriaExpanded('true');
  50852. this.submenuContainer = dom_1.append(this.element, dom_1.$('div.monaco-submenu'));
  50853. dom_1.addClasses(this.submenuContainer, 'menubar-menu-items-holder', 'context-view');
  50854. // Set the top value of the menu container before construction
  50855. // This allows the menu constructor to calculate the proper max height
  50856. var computedStyles = getComputedStyle(this.parentData.parent.domNode);
  50857. var paddingTop = parseFloat(computedStyles.paddingTop || '0') || 0;
  50858. this.submenuContainer.style.top = this.element.offsetTop - this.parentData.parent.scrollOffset - paddingTop + "px";
  50859. this.parentData.submenu = new Menu(this.submenuContainer, this.submenuActions, this.submenuOptions);
  50860. if (this.menuStyle) {
  50861. this.parentData.submenu.style(this.menuStyle);
  50862. }
  50863. var boundingRect = this.element.getBoundingClientRect();
  50864. var childBoundingRect = this.submenuContainer.getBoundingClientRect();
  50865. if (this.expandDirection === Direction.Right) {
  50866. if (window.innerWidth <= boundingRect.right + childBoundingRect.width) {
  50867. this.submenuContainer.style.left = '10px';
  50868. this.submenuContainer.style.top = this.element.offsetTop - this.parentData.parent.scrollOffset + boundingRect.height + "px";
  50869. }
  50870. else {
  50871. this.submenuContainer.style.left = this.element.offsetWidth + "px";
  50872. this.submenuContainer.style.top = this.element.offsetTop - this.parentData.parent.scrollOffset - paddingTop + "px";
  50873. }
  50874. }
  50875. else if (this.expandDirection === Direction.Left) {
  50876. this.submenuContainer.style.right = this.element.offsetWidth + "px";
  50877. this.submenuContainer.style.left = 'auto';
  50878. this.submenuContainer.style.top = this.element.offsetTop - this.parentData.parent.scrollOffset - paddingTop + "px";
  50879. }
  50880. this.submenuDisposables.add(dom_1.addDisposableListener(this.submenuContainer, dom_1.EventType.KEY_UP, function (e) {
  50881. var event = new keyboardEvent_1.StandardKeyboardEvent(e);
  50882. if (event.equals(15 /* LeftArrow */)) {
  50883. dom_1.EventHelper.stop(e, true);
  50884. _this.parentData.parent.focus();
  50885. _this.cleanupExistingSubmenu(true);
  50886. }
  50887. }));
  50888. this.submenuDisposables.add(dom_1.addDisposableListener(this.submenuContainer, dom_1.EventType.KEY_DOWN, function (e) {
  50889. var event = new keyboardEvent_1.StandardKeyboardEvent(e);
  50890. if (event.equals(15 /* LeftArrow */)) {
  50891. dom_1.EventHelper.stop(e, true);
  50892. }
  50893. }));
  50894. this.submenuDisposables.add(this.parentData.submenu.onDidCancel(function () {
  50895. _this.parentData.parent.focus();
  50896. _this.cleanupExistingSubmenu(true);
  50897. }));
  50898. this.parentData.submenu.focus(selectFirstItem);
  50899. this.mysubmenu = this.parentData.submenu;
  50900. }
  50901. else {
  50902. this.parentData.submenu.focus(false);
  50903. }
  50904. };
  50905. SubmenuMenuActionViewItem.prototype.updateAriaExpanded = function (value) {
  50906. var _a;
  50907. if (this.item) {
  50908. (_a = this.item) === null || _a === void 0 ? void 0 : _a.setAttribute('aria-expanded', value);
  50909. }
  50910. };
  50911. SubmenuMenuActionViewItem.prototype.applyStyle = function () {
  50912. _super.prototype.applyStyle.call(this);
  50913. if (!this.menuStyle) {
  50914. return;
  50915. }
  50916. var isSelected = this.element && dom_1.hasClass(this.element, 'focused');
  50917. var fgColor = isSelected && this.menuStyle.selectionForegroundColor ? this.menuStyle.selectionForegroundColor : this.menuStyle.foregroundColor;
  50918. if (this.submenuIndicator) {
  50919. this.submenuIndicator.style.color = fgColor ? "" + fgColor : '';
  50920. }
  50921. if (this.parentData.submenu) {
  50922. this.parentData.submenu.style(this.menuStyle);
  50923. }
  50924. };
  50925. SubmenuMenuActionViewItem.prototype.dispose = function () {
  50926. _super.prototype.dispose.call(this);
  50927. this.hideScheduler.dispose();
  50928. if (this.mysubmenu) {
  50929. this.mysubmenu.dispose();
  50930. this.mysubmenu = null;
  50931. }
  50932. if (this.submenuContainer) {
  50933. this.submenuContainer = undefined;
  50934. }
  50935. };
  50936. return SubmenuMenuActionViewItem;
  50937. }(BaseMenuActionViewItem));
  50938. var MenuSeparatorActionViewItem = /** @class */ (function (_super) {
  50939. __extends(MenuSeparatorActionViewItem, _super);
  50940. function MenuSeparatorActionViewItem() {
  50941. return _super !== null && _super.apply(this, arguments) || this;
  50942. }
  50943. MenuSeparatorActionViewItem.prototype.style = function (style) {
  50944. if (this.label) {
  50945. this.label.style.borderBottomColor = style.separatorColor ? "" + style.separatorColor : '';
  50946. }
  50947. };
  50948. return MenuSeparatorActionViewItem;
  50949. }(actionbar_1.ActionViewItem));
  50950. function cleanMnemonic(label) {
  50951. var regex = exports.MENU_MNEMONIC_REGEX;
  50952. var matches = regex.exec(label);
  50953. if (!matches) {
  50954. return label;
  50955. }
  50956. var mnemonicInText = !matches[1];
  50957. return label.replace(regex, mnemonicInText ? '$2$3' : '').trim();
  50958. }
  50959. exports.cleanMnemonic = cleanMnemonic;
  50960. });
  50961. /*---------------------------------------------------------------------------------------------
  50962. * Copyright (c) Microsoft Corporation. All rights reserved.
  50963. * Licensed under the MIT License. See License.txt in the project root for license information.
  50964. *--------------------------------------------------------------------------------------------*/
  50965. define(__m[405/*vs/base/browser/contextmenu*/], __M([0/*require*/,1/*exports*/,205/*vs/base/browser/ui/menu/menu*/]), function (require, exports, menu_1) {
  50966. "use strict";
  50967. Object.defineProperty(exports, "__esModule", { value: true });
  50968. var ContextSubMenu = /** @class */ (function (_super) {
  50969. __extends(ContextSubMenu, _super);
  50970. function ContextSubMenu(label, entries) {
  50971. var _this = _super.call(this, label, entries, 'contextsubmenu') || this;
  50972. _this.entries = entries;
  50973. return _this;
  50974. }
  50975. return ContextSubMenu;
  50976. }(menu_1.SubmenuAction));
  50977. exports.ContextSubMenu = ContextSubMenu;
  50978. });
  50979. define(__m[406/*vs/nls!vs/base/browser/ui/tree/abstractTree*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/browser/ui/tree/abstractTree", data); });
  50980. /*---------------------------------------------------------------------------------------------
  50981. * Copyright (c) Microsoft Corporation. All rights reserved.
  50982. * Licensed under the MIT License. See License.txt in the project root for license information.
  50983. *--------------------------------------------------------------------------------------------*/
  50984. var __spreadArrays = (this && this.__spreadArrays) || function () {
  50985. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  50986. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  50987. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  50988. r[k] = a[j];
  50989. return r;
  50990. };
  50991. define(__m[154/*vs/base/browser/ui/tree/abstractTree*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,153/*vs/base/browser/ui/list/listWidget*/,6/*vs/base/browser/dom*/,4/*vs/base/common/event*/,56/*vs/base/browser/keyboardEvent*/,98/*vs/base/browser/dnd*/,19/*vs/base/common/arrays*/,140/*vs/base/browser/ui/list/listView*/,52/*vs/base/browser/event*/,61/*vs/base/common/filters*/,129/*vs/base/browser/ui/tree/indexTreeModel*/,406/*vs/nls!vs/base/browser/ui/tree/abstractTree*/,15/*vs/base/common/async*/,16/*vs/base/common/platform*/,38/*vs/base/common/map*/,131/*vs/base/common/numbers*/,87/*vs/base/common/collections*/,280/*vs/css!vs/base/browser/ui/tree/media/tree*/]), function (require, exports, lifecycle_1, listWidget_1, dom_1, event_1, keyboardEvent_1, dnd_1, arrays_1, listView_1, event_2, filters_1, indexTreeModel_1, nls_1, async_1, platform_1, map_1, numbers_1, collections_1) {
  50992. "use strict";
  50993. Object.defineProperty(exports, "__esModule", { value: true });
  50994. var TreeElementsDragAndDropData = /** @class */ (function (_super) {
  50995. __extends(TreeElementsDragAndDropData, _super);
  50996. function TreeElementsDragAndDropData(data) {
  50997. var _this = _super.call(this, data.elements.map(function (node) { return node.element; })) || this;
  50998. _this.data = data;
  50999. return _this;
  51000. }
  51001. return TreeElementsDragAndDropData;
  51002. }(listView_1.ElementsDragAndDropData));
  51003. function asTreeDragAndDropData(data) {
  51004. if (data instanceof listView_1.ElementsDragAndDropData) {
  51005. return new TreeElementsDragAndDropData(data);
  51006. }
  51007. return data;
  51008. }
  51009. var TreeNodeListDragAndDrop = /** @class */ (function () {
  51010. function TreeNodeListDragAndDrop(modelProvider, dnd) {
  51011. this.modelProvider = modelProvider;
  51012. this.dnd = dnd;
  51013. this.autoExpandDisposable = lifecycle_1.Disposable.None;
  51014. }
  51015. TreeNodeListDragAndDrop.prototype.getDragURI = function (node) {
  51016. return this.dnd.getDragURI(node.element);
  51017. };
  51018. TreeNodeListDragAndDrop.prototype.getDragLabel = function (nodes, originalEvent) {
  51019. if (this.dnd.getDragLabel) {
  51020. return this.dnd.getDragLabel(nodes.map(function (node) { return node.element; }), originalEvent);
  51021. }
  51022. return undefined;
  51023. };
  51024. TreeNodeListDragAndDrop.prototype.onDragStart = function (data, originalEvent) {
  51025. if (this.dnd.onDragStart) {
  51026. this.dnd.onDragStart(asTreeDragAndDropData(data), originalEvent);
  51027. }
  51028. };
  51029. TreeNodeListDragAndDrop.prototype.onDragOver = function (data, targetNode, targetIndex, originalEvent, raw) {
  51030. var _this = this;
  51031. if (raw === void 0) { raw = true; }
  51032. var result = this.dnd.onDragOver(asTreeDragAndDropData(data), targetNode && targetNode.element, targetIndex, originalEvent);
  51033. var didChangeAutoExpandNode = this.autoExpandNode !== targetNode;
  51034. if (didChangeAutoExpandNode) {
  51035. this.autoExpandDisposable.dispose();
  51036. this.autoExpandNode = targetNode;
  51037. }
  51038. if (typeof targetNode === 'undefined') {
  51039. return result;
  51040. }
  51041. if (didChangeAutoExpandNode && typeof result !== 'boolean' && result.autoExpand) {
  51042. this.autoExpandDisposable = async_1.disposableTimeout(function () {
  51043. var model = _this.modelProvider();
  51044. var ref = model.getNodeLocation(targetNode);
  51045. if (model.isCollapsed(ref)) {
  51046. model.setCollapsed(ref, false);
  51047. }
  51048. _this.autoExpandNode = undefined;
  51049. }, 500);
  51050. }
  51051. if (typeof result === 'boolean' || !result.accept || typeof result.bubble === 'undefined' || result.feedback) {
  51052. if (!raw) {
  51053. var accept = typeof result === 'boolean' ? result : result.accept;
  51054. var effect = typeof result === 'boolean' ? undefined : result.effect;
  51055. return { accept: accept, effect: effect, feedback: [targetIndex] };
  51056. }
  51057. return result;
  51058. }
  51059. if (result.bubble === 1 /* Up */) {
  51060. var model_1 = this.modelProvider();
  51061. var ref_1 = model_1.getNodeLocation(targetNode);
  51062. var parentRef = model_1.getParentNodeLocation(ref_1);
  51063. var parentNode = model_1.getNode(parentRef);
  51064. var parentIndex = parentRef && model_1.getListIndex(parentRef);
  51065. return this.onDragOver(data, parentNode, parentIndex, originalEvent, false);
  51066. }
  51067. var model = this.modelProvider();
  51068. var ref = model.getNodeLocation(targetNode);
  51069. var start = model.getListIndex(ref);
  51070. var length = model.getListRenderCount(ref);
  51071. return __assign(__assign({}, result), { feedback: arrays_1.range(start, start + length) });
  51072. };
  51073. TreeNodeListDragAndDrop.prototype.drop = function (data, targetNode, targetIndex, originalEvent) {
  51074. this.autoExpandDisposable.dispose();
  51075. this.autoExpandNode = undefined;
  51076. this.dnd.drop(asTreeDragAndDropData(data), targetNode && targetNode.element, targetIndex, originalEvent);
  51077. };
  51078. TreeNodeListDragAndDrop.prototype.onDragEnd = function (originalEvent) {
  51079. if (this.dnd.onDragEnd) {
  51080. this.dnd.onDragEnd(originalEvent);
  51081. }
  51082. };
  51083. return TreeNodeListDragAndDrop;
  51084. }());
  51085. function asListOptions(modelProvider, options) {
  51086. return options && __assign(__assign({}, options), { identityProvider: options.identityProvider && {
  51087. getId: function (el) {
  51088. return options.identityProvider.getId(el.element);
  51089. }
  51090. }, dnd: options.dnd && new TreeNodeListDragAndDrop(modelProvider, options.dnd), multipleSelectionController: options.multipleSelectionController && {
  51091. isSelectionSingleChangeEvent: function (e) {
  51092. return options.multipleSelectionController.isSelectionSingleChangeEvent(__assign(__assign({}, e), { element: e.element }));
  51093. },
  51094. isSelectionRangeChangeEvent: function (e) {
  51095. return options.multipleSelectionController.isSelectionRangeChangeEvent(__assign(__assign({}, e), { element: e.element }));
  51096. }
  51097. }, accessibilityProvider: options.accessibilityProvider && __assign(__assign({}, options.accessibilityProvider), { getAriaLabel: function (e) {
  51098. return options.accessibilityProvider.getAriaLabel(e.element);
  51099. },
  51100. getAriaLevel: function (node) {
  51101. return node.depth;
  51102. }, getActiveDescendantId: options.accessibilityProvider.getActiveDescendantId && (function (node) {
  51103. return options.accessibilityProvider.getActiveDescendantId(node.element);
  51104. }) }), keyboardNavigationLabelProvider: options.keyboardNavigationLabelProvider && __assign(__assign({}, options.keyboardNavigationLabelProvider), { getKeyboardNavigationLabel: function (node) {
  51105. return options.keyboardNavigationLabelProvider.getKeyboardNavigationLabel(node.element);
  51106. } }), enableKeyboardNavigation: options.simpleKeyboardNavigation, ariaProvider: {
  51107. getSetSize: function (node) {
  51108. var model = modelProvider();
  51109. var ref = model.getNodeLocation(node);
  51110. var parentRef = model.getParentNodeLocation(ref);
  51111. var parentNode = model.getNode(parentRef);
  51112. return parentNode.visibleChildrenCount;
  51113. },
  51114. getPosInSet: function (node) {
  51115. return node.visibleChildIndex + 1;
  51116. },
  51117. isChecked: options.ariaProvider && options.ariaProvider.isChecked ? function (node) {
  51118. return options.ariaProvider.isChecked(node.element);
  51119. } : undefined,
  51120. getRole: options.ariaProvider && options.ariaProvider.getRole ? function (node) {
  51121. return options.ariaProvider.getRole(node.element);
  51122. } : undefined
  51123. } });
  51124. }
  51125. var ComposedTreeDelegate = /** @class */ (function () {
  51126. function ComposedTreeDelegate(delegate) {
  51127. this.delegate = delegate;
  51128. }
  51129. ComposedTreeDelegate.prototype.getHeight = function (element) {
  51130. return this.delegate.getHeight(element.element);
  51131. };
  51132. ComposedTreeDelegate.prototype.getTemplateId = function (element) {
  51133. return this.delegate.getTemplateId(element.element);
  51134. };
  51135. ComposedTreeDelegate.prototype.hasDynamicHeight = function (element) {
  51136. return !!this.delegate.hasDynamicHeight && this.delegate.hasDynamicHeight(element.element);
  51137. };
  51138. ComposedTreeDelegate.prototype.setDynamicHeight = function (element, height) {
  51139. if (this.delegate.setDynamicHeight) {
  51140. this.delegate.setDynamicHeight(element.element, height);
  51141. }
  51142. };
  51143. return ComposedTreeDelegate;
  51144. }());
  51145. exports.ComposedTreeDelegate = ComposedTreeDelegate;
  51146. var RenderIndentGuides;
  51147. (function (RenderIndentGuides) {
  51148. RenderIndentGuides["None"] = "none";
  51149. RenderIndentGuides["OnHover"] = "onHover";
  51150. RenderIndentGuides["Always"] = "always";
  51151. })(RenderIndentGuides = exports.RenderIndentGuides || (exports.RenderIndentGuides = {}));
  51152. var EventCollection = /** @class */ (function () {
  51153. function EventCollection(onDidChange, _elements) {
  51154. var _this = this;
  51155. if (_elements === void 0) { _elements = []; }
  51156. this._elements = _elements;
  51157. this.onDidChange = event_1.Event.forEach(onDidChange, function (elements) { return _this._elements = elements; });
  51158. }
  51159. Object.defineProperty(EventCollection.prototype, "elements", {
  51160. get: function () {
  51161. return this._elements;
  51162. },
  51163. enumerable: true,
  51164. configurable: true
  51165. });
  51166. return EventCollection;
  51167. }());
  51168. var TreeRenderer = /** @class */ (function () {
  51169. function TreeRenderer(renderer, modelProvider, onDidChangeCollapseState, activeNodes, options) {
  51170. if (options === void 0) { options = {}; }
  51171. this.renderer = renderer;
  51172. this.modelProvider = modelProvider;
  51173. this.activeNodes = activeNodes;
  51174. this.renderedElements = new Map();
  51175. this.renderedNodes = new Map();
  51176. this.indent = TreeRenderer.DefaultIndent;
  51177. this.hideTwistiesOfChildlessElements = false;
  51178. this.shouldRenderIndentGuides = false;
  51179. this.renderedIndentGuides = new collections_1.SetMap();
  51180. this.activeIndentNodes = new Set();
  51181. this.indentGuidesDisposable = lifecycle_1.Disposable.None;
  51182. this.disposables = new lifecycle_1.DisposableStore();
  51183. this.templateId = renderer.templateId;
  51184. this.updateOptions(options);
  51185. event_1.Event.map(onDidChangeCollapseState, function (e) { return e.node; })(this.onDidChangeNodeTwistieState, this, this.disposables);
  51186. if (renderer.onDidChangeTwistieState) {
  51187. renderer.onDidChangeTwistieState(this.onDidChangeTwistieState, this, this.disposables);
  51188. }
  51189. }
  51190. TreeRenderer.prototype.updateOptions = function (options) {
  51191. if (options === void 0) { options = {}; }
  51192. if (typeof options.indent !== 'undefined') {
  51193. this.indent = numbers_1.clamp(options.indent, 0, 40);
  51194. }
  51195. if (typeof options.renderIndentGuides !== 'undefined') {
  51196. var shouldRenderIndentGuides = options.renderIndentGuides !== RenderIndentGuides.None;
  51197. if (shouldRenderIndentGuides !== this.shouldRenderIndentGuides) {
  51198. this.shouldRenderIndentGuides = shouldRenderIndentGuides;
  51199. this.indentGuidesDisposable.dispose();
  51200. if (shouldRenderIndentGuides) {
  51201. var disposables = new lifecycle_1.DisposableStore();
  51202. this.activeNodes.onDidChange(this._onDidChangeActiveNodes, this, disposables);
  51203. this.indentGuidesDisposable = disposables;
  51204. this._onDidChangeActiveNodes(this.activeNodes.elements);
  51205. }
  51206. }
  51207. }
  51208. if (typeof options.hideTwistiesOfChildlessElements !== 'undefined') {
  51209. this.hideTwistiesOfChildlessElements = options.hideTwistiesOfChildlessElements;
  51210. }
  51211. };
  51212. TreeRenderer.prototype.renderTemplate = function (container) {
  51213. var el = dom_1.append(container, dom_1.$('.monaco-tl-row'));
  51214. var indent = dom_1.append(el, dom_1.$('.monaco-tl-indent'));
  51215. var twistie = dom_1.append(el, dom_1.$('.monaco-tl-twistie'));
  51216. var contents = dom_1.append(el, dom_1.$('.monaco-tl-contents'));
  51217. var templateData = this.renderer.renderTemplate(contents);
  51218. return { container: container, indent: indent, twistie: twistie, indentGuidesDisposable: lifecycle_1.Disposable.None, templateData: templateData };
  51219. };
  51220. TreeRenderer.prototype.renderElement = function (node, index, templateData, height) {
  51221. if (typeof height === 'number') {
  51222. this.renderedNodes.set(node, { templateData: templateData, height: height });
  51223. this.renderedElements.set(node.element, node);
  51224. }
  51225. var indent = TreeRenderer.DefaultIndent + (node.depth - 1) * this.indent;
  51226. templateData.twistie.style.paddingLeft = indent + "px";
  51227. templateData.indent.style.width = indent + this.indent - 16 + "px";
  51228. this.renderTwistie(node, templateData);
  51229. if (typeof height === 'number') {
  51230. this.renderIndentGuides(node, templateData);
  51231. }
  51232. this.renderer.renderElement(node, index, templateData.templateData, height);
  51233. };
  51234. TreeRenderer.prototype.disposeElement = function (node, index, templateData, height) {
  51235. templateData.indentGuidesDisposable.dispose();
  51236. if (this.renderer.disposeElement) {
  51237. this.renderer.disposeElement(node, index, templateData.templateData, height);
  51238. }
  51239. if (typeof height === 'number') {
  51240. this.renderedNodes.delete(node);
  51241. this.renderedElements.delete(node.element);
  51242. }
  51243. };
  51244. TreeRenderer.prototype.disposeTemplate = function (templateData) {
  51245. this.renderer.disposeTemplate(templateData.templateData);
  51246. };
  51247. TreeRenderer.prototype.onDidChangeTwistieState = function (element) {
  51248. var node = this.renderedElements.get(element);
  51249. if (!node) {
  51250. return;
  51251. }
  51252. this.onDidChangeNodeTwistieState(node);
  51253. };
  51254. TreeRenderer.prototype.onDidChangeNodeTwistieState = function (node) {
  51255. var data = this.renderedNodes.get(node);
  51256. if (!data) {
  51257. return;
  51258. }
  51259. this.renderTwistie(node, data.templateData);
  51260. this._onDidChangeActiveNodes(this.activeNodes.elements);
  51261. this.renderIndentGuides(node, data.templateData);
  51262. };
  51263. TreeRenderer.prototype.renderTwistie = function (node, templateData) {
  51264. if (this.renderer.renderTwistie) {
  51265. this.renderer.renderTwistie(node.element, templateData.twistie);
  51266. }
  51267. if (node.collapsible && (!this.hideTwistiesOfChildlessElements || node.visibleChildrenCount > 0)) {
  51268. dom_1.addClasses(templateData.twistie, 'codicon', 'codicon-chevron-down', 'collapsible');
  51269. dom_1.toggleClass(templateData.twistie, 'collapsed', node.collapsed);
  51270. }
  51271. else {
  51272. dom_1.removeClasses(templateData.twistie, 'codicon', 'codicon-chevron-down', 'collapsible', 'collapsed');
  51273. }
  51274. if (node.collapsible) {
  51275. templateData.container.setAttribute('aria-expanded', String(!node.collapsed));
  51276. }
  51277. else {
  51278. templateData.container.removeAttribute('aria-expanded');
  51279. }
  51280. };
  51281. TreeRenderer.prototype.renderIndentGuides = function (target, templateData) {
  51282. var _this = this;
  51283. dom_1.clearNode(templateData.indent);
  51284. templateData.indentGuidesDisposable.dispose();
  51285. if (!this.shouldRenderIndentGuides) {
  51286. return;
  51287. }
  51288. var disposableStore = new lifecycle_1.DisposableStore();
  51289. var model = this.modelProvider();
  51290. var node = target;
  51291. var _loop_1 = function () {
  51292. var ref = model.getNodeLocation(node);
  51293. var parentRef = model.getParentNodeLocation(ref);
  51294. if (!parentRef) {
  51295. return "break";
  51296. }
  51297. var parent_1 = model.getNode(parentRef);
  51298. var guide = dom_1.$('.indent-guide', { style: "width: " + this_1.indent + "px" });
  51299. if (this_1.activeIndentNodes.has(parent_1)) {
  51300. dom_1.addClass(guide, 'active');
  51301. }
  51302. if (templateData.indent.childElementCount === 0) {
  51303. templateData.indent.appendChild(guide);
  51304. }
  51305. else {
  51306. templateData.indent.insertBefore(guide, templateData.indent.firstElementChild);
  51307. }
  51308. this_1.renderedIndentGuides.add(parent_1, guide);
  51309. disposableStore.add(lifecycle_1.toDisposable(function () { return _this.renderedIndentGuides.delete(parent_1, guide); }));
  51310. node = parent_1;
  51311. };
  51312. var this_1 = this;
  51313. while (true) {
  51314. var state_1 = _loop_1();
  51315. if (state_1 === "break")
  51316. break;
  51317. }
  51318. templateData.indentGuidesDisposable = disposableStore;
  51319. };
  51320. TreeRenderer.prototype._onDidChangeActiveNodes = function (nodes) {
  51321. var _this = this;
  51322. if (!this.shouldRenderIndentGuides) {
  51323. return;
  51324. }
  51325. var set = new Set();
  51326. var model = this.modelProvider();
  51327. nodes.forEach(function (node) {
  51328. var ref = model.getNodeLocation(node);
  51329. try {
  51330. var parentRef = model.getParentNodeLocation(ref);
  51331. if (node.collapsible && node.children.length > 0 && !node.collapsed) {
  51332. set.add(node);
  51333. }
  51334. else if (parentRef) {
  51335. set.add(model.getNode(parentRef));
  51336. }
  51337. }
  51338. catch (_a) {
  51339. // noop
  51340. }
  51341. });
  51342. this.activeIndentNodes.forEach(function (node) {
  51343. if (!set.has(node)) {
  51344. _this.renderedIndentGuides.forEach(node, function (line) { return dom_1.removeClass(line, 'active'); });
  51345. }
  51346. });
  51347. set.forEach(function (node) {
  51348. if (!_this.activeIndentNodes.has(node)) {
  51349. _this.renderedIndentGuides.forEach(node, function (line) { return dom_1.addClass(line, 'active'); });
  51350. }
  51351. });
  51352. this.activeIndentNodes = set;
  51353. };
  51354. TreeRenderer.prototype.dispose = function () {
  51355. this.renderedNodes.clear();
  51356. this.renderedElements.clear();
  51357. this.indentGuidesDisposable.dispose();
  51358. lifecycle_1.dispose(this.disposables);
  51359. };
  51360. TreeRenderer.DefaultIndent = 8;
  51361. return TreeRenderer;
  51362. }());
  51363. var TypeFilter = /** @class */ (function () {
  51364. function TypeFilter(tree, keyboardNavigationLabelProvider, _filter) {
  51365. this.tree = tree;
  51366. this.keyboardNavigationLabelProvider = keyboardNavigationLabelProvider;
  51367. this._filter = _filter;
  51368. this._totalCount = 0;
  51369. this._matchCount = 0;
  51370. this._pattern = '';
  51371. this._lowercasePattern = '';
  51372. this.disposables = new lifecycle_1.DisposableStore();
  51373. tree.onWillRefilter(this.reset, this, this.disposables);
  51374. }
  51375. Object.defineProperty(TypeFilter.prototype, "totalCount", {
  51376. get: function () { return this._totalCount; },
  51377. enumerable: true,
  51378. configurable: true
  51379. });
  51380. Object.defineProperty(TypeFilter.prototype, "matchCount", {
  51381. get: function () { return this._matchCount; },
  51382. enumerable: true,
  51383. configurable: true
  51384. });
  51385. Object.defineProperty(TypeFilter.prototype, "pattern", {
  51386. set: function (pattern) {
  51387. this._pattern = pattern;
  51388. this._lowercasePattern = pattern.toLowerCase();
  51389. },
  51390. enumerable: true,
  51391. configurable: true
  51392. });
  51393. TypeFilter.prototype.filter = function (element, parentVisibility) {
  51394. if (this._filter) {
  51395. var result = this._filter.filter(element, parentVisibility);
  51396. if (this.tree.options.simpleKeyboardNavigation) {
  51397. return result;
  51398. }
  51399. var visibility = void 0;
  51400. if (typeof result === 'boolean') {
  51401. visibility = result ? 1 /* Visible */ : 0 /* Hidden */;
  51402. }
  51403. else if (indexTreeModel_1.isFilterResult(result)) {
  51404. visibility = indexTreeModel_1.getVisibleState(result.visibility);
  51405. }
  51406. else {
  51407. visibility = result;
  51408. }
  51409. if (visibility === 0 /* Hidden */) {
  51410. return false;
  51411. }
  51412. }
  51413. this._totalCount++;
  51414. if (this.tree.options.simpleKeyboardNavigation || !this._pattern) {
  51415. this._matchCount++;
  51416. return { data: filters_1.FuzzyScore.Default, visibility: true };
  51417. }
  51418. var label = this.keyboardNavigationLabelProvider.getKeyboardNavigationLabel(element);
  51419. var labelStr = label && label.toString();
  51420. if (typeof labelStr === 'undefined') {
  51421. return { data: filters_1.FuzzyScore.Default, visibility: true };
  51422. }
  51423. var score = filters_1.fuzzyScore(this._pattern, this._lowercasePattern, 0, labelStr, labelStr.toLowerCase(), 0, true);
  51424. if (!score) {
  51425. if (this.tree.options.filterOnType) {
  51426. return 2 /* Recurse */;
  51427. }
  51428. else {
  51429. return { data: filters_1.FuzzyScore.Default, visibility: true };
  51430. }
  51431. // DEMO: smarter filter ?
  51432. // return parentVisibility === TreeVisibility.Visible ? true : TreeVisibility.Recurse;
  51433. }
  51434. this._matchCount++;
  51435. return { data: score, visibility: true };
  51436. };
  51437. TypeFilter.prototype.reset = function () {
  51438. this._totalCount = 0;
  51439. this._matchCount = 0;
  51440. };
  51441. TypeFilter.prototype.dispose = function () {
  51442. lifecycle_1.dispose(this.disposables);
  51443. };
  51444. return TypeFilter;
  51445. }());
  51446. var TypeFilterController = /** @class */ (function () {
  51447. function TypeFilterController(tree, model, view, filter, keyboardNavigationDelegate) {
  51448. this.tree = tree;
  51449. this.view = view;
  51450. this.filter = filter;
  51451. this.keyboardNavigationDelegate = keyboardNavigationDelegate;
  51452. this._enabled = false;
  51453. this._pattern = '';
  51454. this._empty = false;
  51455. this._onDidChangeEmptyState = new event_1.Emitter();
  51456. this.positionClassName = 'ne';
  51457. this.automaticKeyboardNavigation = true;
  51458. this.triggered = false;
  51459. this._onDidChangePattern = new event_1.Emitter();
  51460. this.enabledDisposables = new lifecycle_1.DisposableStore();
  51461. this.disposables = new lifecycle_1.DisposableStore();
  51462. this.domNode = dom_1.$(".monaco-list-type-filter." + this.positionClassName);
  51463. this.domNode.draggable = true;
  51464. event_2.domEvent(this.domNode, 'dragstart')(this.onDragStart, this, this.disposables);
  51465. this.messageDomNode = dom_1.append(view.getHTMLElement(), dom_1.$(".monaco-list-type-filter-message"));
  51466. this.labelDomNode = dom_1.append(this.domNode, dom_1.$('span.label'));
  51467. var controls = dom_1.append(this.domNode, dom_1.$('.controls'));
  51468. this._filterOnType = !!tree.options.filterOnType;
  51469. this.filterOnTypeDomNode = dom_1.append(controls, dom_1.$('input.filter.codicon.codicon-list-selection'));
  51470. this.filterOnTypeDomNode.type = 'checkbox';
  51471. this.filterOnTypeDomNode.checked = this._filterOnType;
  51472. this.filterOnTypeDomNode.tabIndex = -1;
  51473. this.updateFilterOnTypeTitle();
  51474. event_2.domEvent(this.filterOnTypeDomNode, 'input')(this.onDidChangeFilterOnType, this, this.disposables);
  51475. this.clearDomNode = dom_1.append(controls, dom_1.$('button.clear.codicon.codicon-close'));
  51476. this.clearDomNode.tabIndex = -1;
  51477. this.clearDomNode.title = nls_1.localize(0, null);
  51478. this.keyboardNavigationEventFilter = tree.options.keyboardNavigationEventFilter;
  51479. model.onDidSplice(this.onDidSpliceModel, this, this.disposables);
  51480. this.updateOptions(tree.options);
  51481. }
  51482. Object.defineProperty(TypeFilterController.prototype, "enabled", {
  51483. get: function () { return this._enabled; },
  51484. enumerable: true,
  51485. configurable: true
  51486. });
  51487. Object.defineProperty(TypeFilterController.prototype, "pattern", {
  51488. get: function () { return this._pattern; },
  51489. enumerable: true,
  51490. configurable: true
  51491. });
  51492. Object.defineProperty(TypeFilterController.prototype, "filterOnType", {
  51493. get: function () { return this._filterOnType; },
  51494. enumerable: true,
  51495. configurable: true
  51496. });
  51497. TypeFilterController.prototype.updateOptions = function (options) {
  51498. if (options.simpleKeyboardNavigation) {
  51499. this.disable();
  51500. }
  51501. else {
  51502. this.enable();
  51503. }
  51504. if (typeof options.filterOnType !== 'undefined') {
  51505. this._filterOnType = !!options.filterOnType;
  51506. this.filterOnTypeDomNode.checked = this._filterOnType;
  51507. }
  51508. if (typeof options.automaticKeyboardNavigation !== 'undefined') {
  51509. this.automaticKeyboardNavigation = options.automaticKeyboardNavigation;
  51510. }
  51511. this.tree.refilter();
  51512. this.render();
  51513. if (!this.automaticKeyboardNavigation) {
  51514. this.onEventOrInput('');
  51515. }
  51516. };
  51517. TypeFilterController.prototype.enable = function () {
  51518. var _this = this;
  51519. if (this._enabled) {
  51520. return;
  51521. }
  51522. var onKeyDown = event_1.Event.chain(event_2.domEvent(this.view.getHTMLElement(), 'keydown'))
  51523. .filter(function (e) { return !isInputElement(e.target) || e.target === _this.filterOnTypeDomNode; })
  51524. .filter(function (e) { return e.key !== 'Dead' && !/^Media/.test(e.key); })
  51525. .map(function (e) { return new keyboardEvent_1.StandardKeyboardEvent(e); })
  51526. .filter(this.keyboardNavigationEventFilter || (function () { return true; }))
  51527. .filter(function () { return _this.automaticKeyboardNavigation || _this.triggered; })
  51528. .filter(function (e) { return _this.keyboardNavigationDelegate.mightProducePrintableCharacter(e) || ((_this.pattern.length > 0 || _this.triggered) && ((e.keyCode === 9 /* Escape */ || e.keyCode === 1 /* Backspace */) && !e.altKey && !e.ctrlKey && !e.metaKey) || (e.keyCode === 1 /* Backspace */ && (platform_1.isMacintosh ? (e.altKey && !e.metaKey) : e.ctrlKey) && !e.shiftKey)); })
  51529. .forEach(function (e) { e.stopPropagation(); e.preventDefault(); })
  51530. .event;
  51531. var onClear = event_2.domEvent(this.clearDomNode, 'click');
  51532. event_1.Event.chain(event_1.Event.any(onKeyDown, onClear))
  51533. .event(this.onEventOrInput, this, this.enabledDisposables);
  51534. this.filter.pattern = '';
  51535. this.tree.refilter();
  51536. this.render();
  51537. this._enabled = true;
  51538. this.triggered = false;
  51539. };
  51540. TypeFilterController.prototype.disable = function () {
  51541. if (!this._enabled) {
  51542. return;
  51543. }
  51544. this.domNode.remove();
  51545. this.enabledDisposables.clear();
  51546. this.tree.refilter();
  51547. this.render();
  51548. this._enabled = false;
  51549. this.triggered = false;
  51550. };
  51551. TypeFilterController.prototype.onEventOrInput = function (e) {
  51552. if (typeof e === 'string') {
  51553. this.onInput(e);
  51554. }
  51555. else if (e instanceof MouseEvent || e.keyCode === 9 /* Escape */ || (e.keyCode === 1 /* Backspace */ && (platform_1.isMacintosh ? e.altKey : e.ctrlKey))) {
  51556. this.onInput('');
  51557. }
  51558. else if (e.keyCode === 1 /* Backspace */) {
  51559. this.onInput(this.pattern.length === 0 ? '' : this.pattern.substr(0, this.pattern.length - 1));
  51560. }
  51561. else {
  51562. this.onInput(this.pattern + e.browserEvent.key);
  51563. }
  51564. };
  51565. TypeFilterController.prototype.onInput = function (pattern) {
  51566. var container = this.view.getHTMLElement();
  51567. if (pattern && !this.domNode.parentElement) {
  51568. container.append(this.domNode);
  51569. }
  51570. else if (!pattern && this.domNode.parentElement) {
  51571. this.domNode.remove();
  51572. this.tree.domFocus();
  51573. }
  51574. this._pattern = pattern;
  51575. this._onDidChangePattern.fire(pattern);
  51576. this.filter.pattern = pattern;
  51577. this.tree.refilter();
  51578. if (pattern) {
  51579. this.tree.focusNext(0, true, undefined, function (node) { return !filters_1.FuzzyScore.isDefault(node.filterData); });
  51580. }
  51581. var focus = this.tree.getFocus();
  51582. if (focus.length > 0) {
  51583. var element = focus[0];
  51584. if (this.tree.getRelativeTop(element) === null) {
  51585. this.tree.reveal(element, 0.5);
  51586. }
  51587. }
  51588. this.render();
  51589. if (!pattern) {
  51590. this.triggered = false;
  51591. }
  51592. };
  51593. TypeFilterController.prototype.onDragStart = function () {
  51594. var _this = this;
  51595. var container = this.view.getHTMLElement();
  51596. var left = dom_1.getDomNodePagePosition(container).left;
  51597. var containerWidth = container.clientWidth;
  51598. var midContainerWidth = containerWidth / 2;
  51599. var width = this.domNode.clientWidth;
  51600. var disposables = new lifecycle_1.DisposableStore();
  51601. var positionClassName = this.positionClassName;
  51602. var updatePosition = function () {
  51603. switch (positionClassName) {
  51604. case 'nw':
  51605. _this.domNode.style.top = "4px";
  51606. _this.domNode.style.left = "4px";
  51607. break;
  51608. case 'ne':
  51609. _this.domNode.style.top = "4px";
  51610. _this.domNode.style.left = containerWidth - width - 6 + "px";
  51611. break;
  51612. }
  51613. };
  51614. var onDragOver = function (event) {
  51615. event.preventDefault(); // needed so that the drop event fires (https://stackoverflow.com/questions/21339924/drop-event-not-firing-in-chrome)
  51616. var x = event.screenX - left;
  51617. if (event.dataTransfer) {
  51618. event.dataTransfer.dropEffect = 'none';
  51619. }
  51620. if (x < midContainerWidth) {
  51621. positionClassName = 'nw';
  51622. }
  51623. else {
  51624. positionClassName = 'ne';
  51625. }
  51626. updatePosition();
  51627. };
  51628. var onDragEnd = function () {
  51629. _this.positionClassName = positionClassName;
  51630. _this.domNode.className = "monaco-list-type-filter " + _this.positionClassName;
  51631. _this.domNode.style.top = '';
  51632. _this.domNode.style.left = '';
  51633. lifecycle_1.dispose(disposables);
  51634. };
  51635. updatePosition();
  51636. dom_1.removeClass(this.domNode, positionClassName);
  51637. dom_1.addClass(this.domNode, 'dragging');
  51638. disposables.add(lifecycle_1.toDisposable(function () { return dom_1.removeClass(_this.domNode, 'dragging'); }));
  51639. event_2.domEvent(document, 'dragover')(onDragOver, null, disposables);
  51640. event_2.domEvent(this.domNode, 'dragend')(onDragEnd, null, disposables);
  51641. dnd_1.StaticDND.CurrentDragAndDropData = new dnd_1.DragAndDropData('vscode-ui');
  51642. disposables.add(lifecycle_1.toDisposable(function () { return dnd_1.StaticDND.CurrentDragAndDropData = undefined; }));
  51643. };
  51644. TypeFilterController.prototype.onDidSpliceModel = function () {
  51645. if (!this._enabled || this.pattern.length === 0) {
  51646. return;
  51647. }
  51648. this.tree.refilter();
  51649. this.render();
  51650. };
  51651. TypeFilterController.prototype.onDidChangeFilterOnType = function () {
  51652. this.tree.updateOptions({ filterOnType: this.filterOnTypeDomNode.checked });
  51653. this.tree.refilter();
  51654. this.tree.domFocus();
  51655. this.render();
  51656. this.updateFilterOnTypeTitle();
  51657. };
  51658. TypeFilterController.prototype.updateFilterOnTypeTitle = function () {
  51659. if (this.filterOnType) {
  51660. this.filterOnTypeDomNode.title = nls_1.localize(1, null);
  51661. }
  51662. else {
  51663. this.filterOnTypeDomNode.title = nls_1.localize(2, null);
  51664. }
  51665. };
  51666. TypeFilterController.prototype.render = function () {
  51667. var noMatches = this.filter.totalCount > 0 && this.filter.matchCount === 0;
  51668. if (this.pattern && this.tree.options.filterOnType && noMatches) {
  51669. this.messageDomNode.textContent = nls_1.localize(3, null);
  51670. this._empty = true;
  51671. }
  51672. else {
  51673. this.messageDomNode.innerHTML = '';
  51674. this._empty = false;
  51675. }
  51676. dom_1.toggleClass(this.domNode, 'no-matches', noMatches);
  51677. this.domNode.title = nls_1.localize(4, null, this.filter.matchCount, this.filter.totalCount);
  51678. this.labelDomNode.textContent = this.pattern.length > 16 ? '…' + this.pattern.substr(this.pattern.length - 16) : this.pattern;
  51679. this._onDidChangeEmptyState.fire(this._empty);
  51680. };
  51681. TypeFilterController.prototype.shouldAllowFocus = function (node) {
  51682. if (!this.enabled || !this.pattern || this.filterOnType) {
  51683. return true;
  51684. }
  51685. if (this.filter.totalCount > 0 && this.filter.matchCount <= 1) {
  51686. return true;
  51687. }
  51688. return !filters_1.FuzzyScore.isDefault(node.filterData);
  51689. };
  51690. TypeFilterController.prototype.dispose = function () {
  51691. if (this._enabled) {
  51692. this.domNode.remove();
  51693. this.enabledDisposables.dispose();
  51694. this._enabled = false;
  51695. this.triggered = false;
  51696. }
  51697. this._onDidChangePattern.dispose();
  51698. lifecycle_1.dispose(this.disposables);
  51699. };
  51700. return TypeFilterController;
  51701. }());
  51702. function isInputElement(e) {
  51703. return e.tagName === 'INPUT' || e.tagName === 'TEXTAREA';
  51704. }
  51705. function asTreeEvent(event) {
  51706. return {
  51707. elements: event.elements.map(function (node) { return node.element; }),
  51708. browserEvent: event.browserEvent
  51709. };
  51710. }
  51711. function dfs(node, fn) {
  51712. fn(node);
  51713. node.children.forEach(function (child) { return dfs(child, fn); });
  51714. }
  51715. /**
  51716. * The trait concept needs to exist at the tree level, because collapsed
  51717. * tree nodes will not be known by the list.
  51718. */
  51719. var Trait = /** @class */ (function () {
  51720. function Trait(identityProvider) {
  51721. this.identityProvider = identityProvider;
  51722. this.nodes = [];
  51723. this._onDidChange = new event_1.Emitter();
  51724. this.onDidChange = this._onDidChange.event;
  51725. }
  51726. Object.defineProperty(Trait.prototype, "nodeSet", {
  51727. get: function () {
  51728. if (!this._nodeSet) {
  51729. this._nodeSet = this.createNodeSet();
  51730. }
  51731. return this._nodeSet;
  51732. },
  51733. enumerable: true,
  51734. configurable: true
  51735. });
  51736. Trait.prototype.set = function (nodes, browserEvent) {
  51737. if (arrays_1.equals(this.nodes, nodes)) {
  51738. return;
  51739. }
  51740. this._set(nodes, false, browserEvent);
  51741. };
  51742. Trait.prototype._set = function (nodes, silent, browserEvent) {
  51743. this.nodes = __spreadArrays(nodes);
  51744. this.elements = undefined;
  51745. this._nodeSet = undefined;
  51746. if (!silent) {
  51747. var that_1 = this;
  51748. this._onDidChange.fire({ get elements() { return that_1.get(); }, browserEvent: browserEvent });
  51749. }
  51750. };
  51751. Trait.prototype.get = function () {
  51752. if (!this.elements) {
  51753. this.elements = this.nodes.map(function (node) { return node.element; });
  51754. }
  51755. return __spreadArrays(this.elements);
  51756. };
  51757. Trait.prototype.getNodes = function () {
  51758. return this.nodes;
  51759. };
  51760. Trait.prototype.has = function (node) {
  51761. return this.nodeSet.has(node);
  51762. };
  51763. Trait.prototype.onDidModelSplice = function (_a) {
  51764. var _this = this;
  51765. var insertedNodes = _a.insertedNodes, deletedNodes = _a.deletedNodes;
  51766. if (!this.identityProvider) {
  51767. var set_1 = this.createNodeSet();
  51768. var visit_1 = function (node) { return set_1.delete(node); };
  51769. deletedNodes.forEach(function (node) { return dfs(node, visit_1); });
  51770. this.set(map_1.values(set_1));
  51771. return;
  51772. }
  51773. var deletedNodesIdSet = new Set();
  51774. var deletedNodesVisitor = function (node) { return deletedNodesIdSet.add(_this.identityProvider.getId(node.element).toString()); };
  51775. deletedNodes.forEach(function (node) { return dfs(node, deletedNodesVisitor); });
  51776. var insertedNodesMap = new Map();
  51777. var insertedNodesVisitor = function (node) { return insertedNodesMap.set(_this.identityProvider.getId(node.element).toString(), node); };
  51778. insertedNodes.forEach(function (node) { return dfs(node, insertedNodesVisitor); });
  51779. var nodes = [];
  51780. for (var _i = 0, _b = this.nodes; _i < _b.length; _i++) {
  51781. var node = _b[_i];
  51782. var id = this.identityProvider.getId(node.element).toString();
  51783. var wasDeleted = deletedNodesIdSet.has(id);
  51784. if (!wasDeleted) {
  51785. nodes.push(node);
  51786. }
  51787. else {
  51788. var insertedNode = insertedNodesMap.get(id);
  51789. if (insertedNode) {
  51790. nodes.push(insertedNode);
  51791. }
  51792. }
  51793. }
  51794. this._set(nodes, true);
  51795. };
  51796. Trait.prototype.createNodeSet = function () {
  51797. var set = new Set();
  51798. for (var _i = 0, _a = this.nodes; _i < _a.length; _i++) {
  51799. var node = _a[_i];
  51800. set.add(node);
  51801. }
  51802. return set;
  51803. };
  51804. return Trait;
  51805. }());
  51806. var TreeNodeListMouseController = /** @class */ (function (_super) {
  51807. __extends(TreeNodeListMouseController, _super);
  51808. function TreeNodeListMouseController(list, tree) {
  51809. var _this = _super.call(this, list) || this;
  51810. _this.tree = tree;
  51811. return _this;
  51812. }
  51813. TreeNodeListMouseController.prototype.onPointer = function (e) {
  51814. if (isInputElement(e.browserEvent.target)) {
  51815. return;
  51816. }
  51817. var node = e.element;
  51818. if (!node) {
  51819. return _super.prototype.onPointer.call(this, e);
  51820. }
  51821. if (this.isSelectionRangeChangeEvent(e) || this.isSelectionSingleChangeEvent(e)) {
  51822. return _super.prototype.onPointer.call(this, e);
  51823. }
  51824. var onTwistie = dom_1.hasClass(e.browserEvent.target, 'monaco-tl-twistie');
  51825. if (!this.tree.openOnSingleClick && e.browserEvent.detail !== 2 && !onTwistie) {
  51826. return _super.prototype.onPointer.call(this, e);
  51827. }
  51828. var expandOnlyOnTwistieClick = false;
  51829. if (typeof this.tree.expandOnlyOnTwistieClick === 'function') {
  51830. expandOnlyOnTwistieClick = this.tree.expandOnlyOnTwistieClick(node.element);
  51831. }
  51832. else {
  51833. expandOnlyOnTwistieClick = !!this.tree.expandOnlyOnTwistieClick;
  51834. }
  51835. if (expandOnlyOnTwistieClick && !onTwistie) {
  51836. return _super.prototype.onPointer.call(this, e);
  51837. }
  51838. if (node.collapsible) {
  51839. var model = this.tree.model; // internal
  51840. var location_1 = model.getNodeLocation(node);
  51841. var recursive = e.browserEvent.altKey;
  51842. model.setCollapsed(location_1, undefined, recursive);
  51843. if (expandOnlyOnTwistieClick && onTwistie) {
  51844. return;
  51845. }
  51846. }
  51847. _super.prototype.onPointer.call(this, e);
  51848. };
  51849. TreeNodeListMouseController.prototype.onDoubleClick = function (e) {
  51850. var onTwistie = dom_1.hasClass(e.browserEvent.target, 'monaco-tl-twistie');
  51851. if (onTwistie) {
  51852. return;
  51853. }
  51854. _super.prototype.onDoubleClick.call(this, e);
  51855. };
  51856. return TreeNodeListMouseController;
  51857. }(listWidget_1.MouseController));
  51858. /**
  51859. * We use this List subclass to restore selection and focus as nodes
  51860. * get rendered in the list, possibly due to a node expand() call.
  51861. */
  51862. var TreeNodeList = /** @class */ (function (_super) {
  51863. __extends(TreeNodeList, _super);
  51864. function TreeNodeList(user, container, virtualDelegate, renderers, focusTrait, selectionTrait, options) {
  51865. var _this = _super.call(this, user, container, virtualDelegate, renderers, options) || this;
  51866. _this.focusTrait = focusTrait;
  51867. _this.selectionTrait = selectionTrait;
  51868. return _this;
  51869. }
  51870. TreeNodeList.prototype.createMouseController = function (options) {
  51871. return new TreeNodeListMouseController(this, options.tree);
  51872. };
  51873. TreeNodeList.prototype.splice = function (start, deleteCount, elements) {
  51874. var _this = this;
  51875. if (elements === void 0) { elements = []; }
  51876. _super.prototype.splice.call(this, start, deleteCount, elements);
  51877. if (elements.length === 0) {
  51878. return;
  51879. }
  51880. var additionalFocus = [];
  51881. var additionalSelection = [];
  51882. elements.forEach(function (node, index) {
  51883. if (_this.focusTrait.has(node)) {
  51884. additionalFocus.push(start + index);
  51885. }
  51886. if (_this.selectionTrait.has(node)) {
  51887. additionalSelection.push(start + index);
  51888. }
  51889. });
  51890. if (additionalFocus.length > 0) {
  51891. _super.prototype.setFocus.call(this, arrays_1.distinctES6(__spreadArrays(_super.prototype.getFocus.call(this), additionalFocus)));
  51892. }
  51893. if (additionalSelection.length > 0) {
  51894. _super.prototype.setSelection.call(this, arrays_1.distinctES6(__spreadArrays(_super.prototype.getSelection.call(this), additionalSelection)));
  51895. }
  51896. };
  51897. TreeNodeList.prototype.setFocus = function (indexes, browserEvent, fromAPI) {
  51898. var _this = this;
  51899. if (fromAPI === void 0) { fromAPI = false; }
  51900. _super.prototype.setFocus.call(this, indexes, browserEvent);
  51901. if (!fromAPI) {
  51902. this.focusTrait.set(indexes.map(function (i) { return _this.element(i); }), browserEvent);
  51903. }
  51904. };
  51905. TreeNodeList.prototype.setSelection = function (indexes, browserEvent, fromAPI) {
  51906. var _this = this;
  51907. if (fromAPI === void 0) { fromAPI = false; }
  51908. _super.prototype.setSelection.call(this, indexes, browserEvent);
  51909. if (!fromAPI) {
  51910. this.selectionTrait.set(indexes.map(function (i) { return _this.element(i); }), browserEvent);
  51911. }
  51912. };
  51913. return TreeNodeList;
  51914. }(listWidget_1.List));
  51915. var AbstractTree = /** @class */ (function () {
  51916. function AbstractTree(user, container, delegate, renderers, _options) {
  51917. var _this = this;
  51918. if (_options === void 0) { _options = {}; }
  51919. this._options = _options;
  51920. this.eventBufferer = new event_1.EventBufferer();
  51921. this.disposables = new lifecycle_1.DisposableStore();
  51922. this._onWillRefilter = new event_1.Emitter();
  51923. this.onWillRefilter = this._onWillRefilter.event;
  51924. this._onDidUpdateOptions = new event_1.Emitter();
  51925. var treeDelegate = new ComposedTreeDelegate(delegate);
  51926. var onDidChangeCollapseStateRelay = new event_1.Relay();
  51927. var onDidChangeActiveNodes = new event_1.Relay();
  51928. var activeNodes = new EventCollection(onDidChangeActiveNodes.event);
  51929. this.renderers = renderers.map(function (r) { return new TreeRenderer(r, function () { return _this.model; }, onDidChangeCollapseStateRelay.event, activeNodes, _options); });
  51930. for (var _i = 0, _a = this.renderers; _i < _a.length; _i++) {
  51931. var r = _a[_i];
  51932. this.disposables.add(r);
  51933. }
  51934. var filter;
  51935. if (_options.keyboardNavigationLabelProvider) {
  51936. filter = new TypeFilter(this, _options.keyboardNavigationLabelProvider, _options.filter);
  51937. _options = __assign(__assign({}, _options), { filter: filter }); // TODO need typescript help here
  51938. this.disposables.add(filter);
  51939. }
  51940. this.focus = new Trait(_options.identityProvider);
  51941. this.selection = new Trait(_options.identityProvider);
  51942. this.view = new TreeNodeList(user, container, treeDelegate, this.renderers, this.focus, this.selection, __assign(__assign({}, asListOptions(function () { return _this.model; }, _options)), { tree: this }));
  51943. this.model = this.createModel(user, this.view, _options);
  51944. onDidChangeCollapseStateRelay.input = this.model.onDidChangeCollapseState;
  51945. var onDidModelSplice = event_1.Event.forEach(this.model.onDidSplice, function (e) {
  51946. _this.eventBufferer.bufferEvents(function () {
  51947. _this.focus.onDidModelSplice(e);
  51948. _this.selection.onDidModelSplice(e);
  51949. });
  51950. });
  51951. // Make sure the `forEach` always runs
  51952. onDidModelSplice(function () { return null; }, null, this.disposables);
  51953. // Active nodes can change when the model changes or when focus or selection change.
  51954. // We debounce it with 0 delay since these events may fire in the same stack and we only
  51955. // want to run this once. It also doesn't matter if it runs on the next tick since it's only
  51956. // a nice to have UI feature.
  51957. onDidChangeActiveNodes.input = event_1.Event.chain(event_1.Event.any(onDidModelSplice, this.focus.onDidChange, this.selection.onDidChange))
  51958. .debounce(function () { return null; }, 0)
  51959. .map(function () {
  51960. var set = new Set();
  51961. for (var _i = 0, _a = _this.focus.getNodes(); _i < _a.length; _i++) {
  51962. var node = _a[_i];
  51963. set.add(node);
  51964. }
  51965. for (var _b = 0, _c = _this.selection.getNodes(); _b < _c.length; _b++) {
  51966. var node = _c[_b];
  51967. set.add(node);
  51968. }
  51969. return arrays_1.fromSet(set);
  51970. }).event;
  51971. if (_options.keyboardSupport !== false) {
  51972. var onKeyDown = event_1.Event.chain(this.view.onKeyDown)
  51973. .filter(function (e) { return !isInputElement(e.target); })
  51974. .map(function (e) { return new keyboardEvent_1.StandardKeyboardEvent(e); });
  51975. onKeyDown.filter(function (e) { return e.keyCode === 15 /* LeftArrow */; }).on(this.onLeftArrow, this, this.disposables);
  51976. onKeyDown.filter(function (e) { return e.keyCode === 17 /* RightArrow */; }).on(this.onRightArrow, this, this.disposables);
  51977. onKeyDown.filter(function (e) { return e.keyCode === 10 /* Space */; }).on(this.onSpace, this, this.disposables);
  51978. }
  51979. if (_options.keyboardNavigationLabelProvider) {
  51980. var delegate_1 = _options.keyboardNavigationDelegate || listWidget_1.DefaultKeyboardNavigationDelegate;
  51981. this.typeFilterController = new TypeFilterController(this, this.model, this.view, filter, delegate_1);
  51982. this.focusNavigationFilter = function (node) { return _this.typeFilterController.shouldAllowFocus(node); };
  51983. this.disposables.add(this.typeFilterController);
  51984. }
  51985. this.styleElement = dom_1.createStyleSheet(this.view.getHTMLElement());
  51986. dom_1.toggleClass(this.getHTMLElement(), 'always', this._options.renderIndentGuides === RenderIndentGuides.Always);
  51987. }
  51988. Object.defineProperty(AbstractTree.prototype, "onDidChangeFocus", {
  51989. get: function () { return this.eventBufferer.wrapEvent(this.focus.onDidChange); },
  51990. enumerable: true,
  51991. configurable: true
  51992. });
  51993. Object.defineProperty(AbstractTree.prototype, "onDidChangeSelection", {
  51994. get: function () { return this.eventBufferer.wrapEvent(this.selection.onDidChange); },
  51995. enumerable: true,
  51996. configurable: true
  51997. });
  51998. Object.defineProperty(AbstractTree.prototype, "onDidOpen", {
  51999. get: function () { return event_1.Event.map(this.view.onDidOpen, asTreeEvent); },
  52000. enumerable: true,
  52001. configurable: true
  52002. });
  52003. Object.defineProperty(AbstractTree.prototype, "onDidFocus", {
  52004. get: function () { return this.view.onDidFocus; },
  52005. enumerable: true,
  52006. configurable: true
  52007. });
  52008. Object.defineProperty(AbstractTree.prototype, "onDidChangeCollapseState", {
  52009. get: function () { return this.model.onDidChangeCollapseState; },
  52010. enumerable: true,
  52011. configurable: true
  52012. });
  52013. Object.defineProperty(AbstractTree.prototype, "openOnSingleClick", {
  52014. get: function () { return typeof this._options.openOnSingleClick === 'undefined' ? true : this._options.openOnSingleClick; },
  52015. enumerable: true,
  52016. configurable: true
  52017. });
  52018. Object.defineProperty(AbstractTree.prototype, "expandOnlyOnTwistieClick", {
  52019. get: function () { return typeof this._options.expandOnlyOnTwistieClick === 'undefined' ? false : this._options.expandOnlyOnTwistieClick; },
  52020. enumerable: true,
  52021. configurable: true
  52022. });
  52023. Object.defineProperty(AbstractTree.prototype, "onDidDispose", {
  52024. get: function () { return this.view.onDidDispose; },
  52025. enumerable: true,
  52026. configurable: true
  52027. });
  52028. AbstractTree.prototype.updateOptions = function (optionsUpdate) {
  52029. if (optionsUpdate === void 0) { optionsUpdate = {}; }
  52030. this._options = __assign(__assign({}, this._options), optionsUpdate);
  52031. for (var _i = 0, _a = this.renderers; _i < _a.length; _i++) {
  52032. var renderer = _a[_i];
  52033. renderer.updateOptions(optionsUpdate);
  52034. }
  52035. this.view.updateOptions({
  52036. enableKeyboardNavigation: this._options.simpleKeyboardNavigation,
  52037. automaticKeyboardNavigation: this._options.automaticKeyboardNavigation
  52038. });
  52039. if (this.typeFilterController) {
  52040. this.typeFilterController.updateOptions(this._options);
  52041. }
  52042. this._onDidUpdateOptions.fire(this._options);
  52043. dom_1.toggleClass(this.getHTMLElement(), 'always', this._options.renderIndentGuides === RenderIndentGuides.Always);
  52044. };
  52045. Object.defineProperty(AbstractTree.prototype, "options", {
  52046. get: function () {
  52047. return this._options;
  52048. },
  52049. enumerable: true,
  52050. configurable: true
  52051. });
  52052. // Widget
  52053. AbstractTree.prototype.getHTMLElement = function () {
  52054. return this.view.getHTMLElement();
  52055. };
  52056. Object.defineProperty(AbstractTree.prototype, "scrollTop", {
  52057. get: function () {
  52058. return this.view.scrollTop;
  52059. },
  52060. set: function (scrollTop) {
  52061. this.view.scrollTop = scrollTop;
  52062. },
  52063. enumerable: true,
  52064. configurable: true
  52065. });
  52066. AbstractTree.prototype.domFocus = function () {
  52067. this.view.domFocus();
  52068. };
  52069. AbstractTree.prototype.layout = function (height, width) {
  52070. this.view.layout(height, width);
  52071. };
  52072. AbstractTree.prototype.style = function (styles) {
  52073. var suffix = "." + this.view.domId;
  52074. var content = [];
  52075. if (styles.treeIndentGuidesStroke) {
  52076. content.push(".monaco-list" + suffix + ":hover .monaco-tl-indent > .indent-guide, .monaco-list" + suffix + ".always .monaco-tl-indent > .indent-guide { border-color: " + styles.treeIndentGuidesStroke.transparent(0.4) + "; }");
  52077. content.push(".monaco-list" + suffix + " .monaco-tl-indent > .indent-guide.active { border-color: " + styles.treeIndentGuidesStroke + "; }");
  52078. }
  52079. var newStyles = content.join('\n');
  52080. if (newStyles !== this.styleElement.innerHTML) {
  52081. this.styleElement.innerHTML = newStyles;
  52082. }
  52083. this.view.style(styles);
  52084. };
  52085. AbstractTree.prototype.collapse = function (location, recursive) {
  52086. if (recursive === void 0) { recursive = false; }
  52087. return this.model.setCollapsed(location, true, recursive);
  52088. };
  52089. AbstractTree.prototype.expand = function (location, recursive) {
  52090. if (recursive === void 0) { recursive = false; }
  52091. return this.model.setCollapsed(location, false, recursive);
  52092. };
  52093. AbstractTree.prototype.isCollapsible = function (location) {
  52094. return this.model.isCollapsible(location);
  52095. };
  52096. AbstractTree.prototype.setCollapsible = function (location, collapsible) {
  52097. return this.model.setCollapsible(location, collapsible);
  52098. };
  52099. AbstractTree.prototype.isCollapsed = function (location) {
  52100. return this.model.isCollapsed(location);
  52101. };
  52102. AbstractTree.prototype.refilter = function () {
  52103. this._onWillRefilter.fire(undefined);
  52104. this.model.refilter();
  52105. };
  52106. AbstractTree.prototype.setSelection = function (elements, browserEvent) {
  52107. var _this = this;
  52108. var nodes = elements.map(function (e) { return _this.model.getNode(e); });
  52109. this.selection.set(nodes, browserEvent);
  52110. var indexes = elements.map(function (e) { return _this.model.getListIndex(e); }).filter(function (i) { return i > -1; });
  52111. this.view.setSelection(indexes, browserEvent, true);
  52112. };
  52113. AbstractTree.prototype.getSelection = function () {
  52114. return this.selection.get();
  52115. };
  52116. AbstractTree.prototype.setFocus = function (elements, browserEvent) {
  52117. var _this = this;
  52118. var nodes = elements.map(function (e) { return _this.model.getNode(e); });
  52119. this.focus.set(nodes, browserEvent);
  52120. var indexes = elements.map(function (e) { return _this.model.getListIndex(e); }).filter(function (i) { return i > -1; });
  52121. this.view.setFocus(indexes, browserEvent, true);
  52122. };
  52123. AbstractTree.prototype.focusNext = function (n, loop, browserEvent, filter) {
  52124. if (n === void 0) { n = 1; }
  52125. if (loop === void 0) { loop = false; }
  52126. if (filter === void 0) { filter = this.focusNavigationFilter; }
  52127. this.view.focusNext(n, loop, browserEvent, filter);
  52128. };
  52129. AbstractTree.prototype.getFocus = function () {
  52130. return this.focus.get();
  52131. };
  52132. AbstractTree.prototype.reveal = function (location, relativeTop) {
  52133. this.model.expandTo(location);
  52134. var index = this.model.getListIndex(location);
  52135. if (index === -1) {
  52136. return;
  52137. }
  52138. this.view.reveal(index, relativeTop);
  52139. };
  52140. /**
  52141. * Returns the relative position of an element rendered in the list.
  52142. * Returns `null` if the element isn't *entirely* in the visible viewport.
  52143. */
  52144. AbstractTree.prototype.getRelativeTop = function (location) {
  52145. var index = this.model.getListIndex(location);
  52146. if (index === -1) {
  52147. return null;
  52148. }
  52149. return this.view.getRelativeTop(index);
  52150. };
  52151. // List
  52152. AbstractTree.prototype.onLeftArrow = function (e) {
  52153. e.preventDefault();
  52154. e.stopPropagation();
  52155. var nodes = this.view.getFocusedElements();
  52156. if (nodes.length === 0) {
  52157. return;
  52158. }
  52159. var node = nodes[0];
  52160. var location = this.model.getNodeLocation(node);
  52161. var didChange = this.model.setCollapsed(location, true);
  52162. if (!didChange) {
  52163. var parentLocation = this.model.getParentNodeLocation(location);
  52164. if (!parentLocation) {
  52165. return;
  52166. }
  52167. var parentListIndex = this.model.getListIndex(parentLocation);
  52168. this.view.reveal(parentListIndex);
  52169. this.view.setFocus([parentListIndex]);
  52170. }
  52171. };
  52172. AbstractTree.prototype.onRightArrow = function (e) {
  52173. e.preventDefault();
  52174. e.stopPropagation();
  52175. var nodes = this.view.getFocusedElements();
  52176. if (nodes.length === 0) {
  52177. return;
  52178. }
  52179. var node = nodes[0];
  52180. var location = this.model.getNodeLocation(node);
  52181. var didChange = this.model.setCollapsed(location, false);
  52182. if (!didChange) {
  52183. if (!node.children.some(function (child) { return child.visible; })) {
  52184. return;
  52185. }
  52186. var focusedIndex = this.view.getFocus()[0];
  52187. var firstChildIndex = focusedIndex + 1;
  52188. this.view.reveal(firstChildIndex);
  52189. this.view.setFocus([firstChildIndex]);
  52190. }
  52191. };
  52192. AbstractTree.prototype.onSpace = function (e) {
  52193. e.preventDefault();
  52194. e.stopPropagation();
  52195. var nodes = this.view.getFocusedElements();
  52196. if (nodes.length === 0) {
  52197. return;
  52198. }
  52199. var node = nodes[0];
  52200. var location = this.model.getNodeLocation(node);
  52201. var recursive = e.browserEvent.altKey;
  52202. this.model.setCollapsed(location, undefined, recursive);
  52203. };
  52204. AbstractTree.prototype.dispose = function () {
  52205. lifecycle_1.dispose(this.disposables);
  52206. this.view.dispose();
  52207. };
  52208. return AbstractTree;
  52209. }());
  52210. exports.AbstractTree = AbstractTree;
  52211. });
  52212. /*---------------------------------------------------------------------------------------------
  52213. * Copyright (c) Microsoft Corporation. All rights reserved.
  52214. * Licensed under the MIT License. See License.txt in the project root for license information.
  52215. *--------------------------------------------------------------------------------------------*/
  52216. define(__m[407/*vs/base/browser/ui/tree/dataTree*/], __M([0/*require*/,1/*exports*/,154/*vs/base/browser/ui/tree/abstractTree*/,130/*vs/base/browser/ui/tree/objectTreeModel*/]), function (require, exports, abstractTree_1, objectTreeModel_1) {
  52217. "use strict";
  52218. Object.defineProperty(exports, "__esModule", { value: true });
  52219. var DataTree = /** @class */ (function (_super) {
  52220. __extends(DataTree, _super);
  52221. function DataTree(user, container, delegate, renderers, dataSource, options) {
  52222. if (options === void 0) { options = {}; }
  52223. var _this = _super.call(this, user, container, delegate, renderers, options) || this;
  52224. _this.user = user;
  52225. _this.dataSource = dataSource;
  52226. _this.identityProvider = options.identityProvider;
  52227. return _this;
  52228. }
  52229. DataTree.prototype.createModel = function (user, view, options) {
  52230. return new objectTreeModel_1.ObjectTreeModel(user, view, options);
  52231. };
  52232. return DataTree;
  52233. }(abstractTree_1.AbstractTree));
  52234. exports.DataTree = DataTree;
  52235. });
  52236. /*---------------------------------------------------------------------------------------------
  52237. * Copyright (c) Microsoft Corporation. All rights reserved.
  52238. * Licensed under the MIT License. See License.txt in the project root for license information.
  52239. *--------------------------------------------------------------------------------------------*/
  52240. define(__m[206/*vs/base/browser/ui/tree/objectTree*/], __M([0/*require*/,1/*exports*/,154/*vs/base/browser/ui/tree/abstractTree*/,130/*vs/base/browser/ui/tree/objectTreeModel*/,243/*vs/base/browser/ui/tree/compressedObjectTreeModel*/,101/*vs/base/common/decorators*/]), function (require, exports, abstractTree_1, objectTreeModel_1, compressedObjectTreeModel_1, decorators_1) {
  52241. "use strict";
  52242. Object.defineProperty(exports, "__esModule", { value: true });
  52243. var ObjectTree = /** @class */ (function (_super) {
  52244. __extends(ObjectTree, _super);
  52245. function ObjectTree(user, container, delegate, renderers, options) {
  52246. if (options === void 0) { options = {}; }
  52247. return _super.call(this, user, container, delegate, renderers, options) || this;
  52248. }
  52249. Object.defineProperty(ObjectTree.prototype, "onDidChangeCollapseState", {
  52250. get: function () { return this.model.onDidChangeCollapseState; },
  52251. enumerable: true,
  52252. configurable: true
  52253. });
  52254. ObjectTree.prototype.setChildren = function (element, children) {
  52255. this.model.setChildren(element, children);
  52256. };
  52257. ObjectTree.prototype.rerender = function (element) {
  52258. if (element === undefined) {
  52259. this.view.rerender();
  52260. return;
  52261. }
  52262. this.model.rerender(element);
  52263. };
  52264. ObjectTree.prototype.hasElement = function (element) {
  52265. return this.model.has(element);
  52266. };
  52267. ObjectTree.prototype.createModel = function (user, view, options) {
  52268. return new objectTreeModel_1.ObjectTreeModel(user, view, options);
  52269. };
  52270. return ObjectTree;
  52271. }(abstractTree_1.AbstractTree));
  52272. exports.ObjectTree = ObjectTree;
  52273. var CompressibleRenderer = /** @class */ (function () {
  52274. function CompressibleRenderer(_compressedTreeNodeProvider, renderer) {
  52275. this._compressedTreeNodeProvider = _compressedTreeNodeProvider;
  52276. this.renderer = renderer;
  52277. this.templateId = renderer.templateId;
  52278. if (renderer.onDidChangeTwistieState) {
  52279. this.onDidChangeTwistieState = renderer.onDidChangeTwistieState;
  52280. }
  52281. }
  52282. Object.defineProperty(CompressibleRenderer.prototype, "compressedTreeNodeProvider", {
  52283. get: function () {
  52284. return this._compressedTreeNodeProvider();
  52285. },
  52286. enumerable: true,
  52287. configurable: true
  52288. });
  52289. CompressibleRenderer.prototype.renderTemplate = function (container) {
  52290. var data = this.renderer.renderTemplate(container);
  52291. return { compressedTreeNode: undefined, data: data };
  52292. };
  52293. CompressibleRenderer.prototype.renderElement = function (node, index, templateData, height) {
  52294. var compressedTreeNode = this.compressedTreeNodeProvider.getCompressedTreeNode(node.element);
  52295. if (compressedTreeNode.element.elements.length === 1) {
  52296. templateData.compressedTreeNode = undefined;
  52297. this.renderer.renderElement(node, index, templateData.data, height);
  52298. }
  52299. else {
  52300. templateData.compressedTreeNode = compressedTreeNode;
  52301. this.renderer.renderCompressedElements(compressedTreeNode, index, templateData.data, height);
  52302. }
  52303. };
  52304. CompressibleRenderer.prototype.disposeElement = function (node, index, templateData, height) {
  52305. if (templateData.compressedTreeNode) {
  52306. if (this.renderer.disposeCompressedElements) {
  52307. this.renderer.disposeCompressedElements(templateData.compressedTreeNode, index, templateData.data, height);
  52308. }
  52309. }
  52310. else {
  52311. if (this.renderer.disposeElement) {
  52312. this.renderer.disposeElement(node, index, templateData.data, height);
  52313. }
  52314. }
  52315. };
  52316. CompressibleRenderer.prototype.disposeTemplate = function (templateData) {
  52317. this.renderer.disposeTemplate(templateData.data);
  52318. };
  52319. CompressibleRenderer.prototype.renderTwistie = function (element, twistieElement) {
  52320. if (this.renderer.renderTwistie) {
  52321. this.renderer.renderTwistie(element, twistieElement);
  52322. }
  52323. };
  52324. __decorate([
  52325. decorators_1.memoize
  52326. ], CompressibleRenderer.prototype, "compressedTreeNodeProvider", null);
  52327. return CompressibleRenderer;
  52328. }());
  52329. function asObjectTreeOptions(compressedTreeNodeProvider, options) {
  52330. return options && __assign(__assign({}, options), { keyboardNavigationLabelProvider: options.keyboardNavigationLabelProvider && {
  52331. getKeyboardNavigationLabel: function (e) {
  52332. var compressedTreeNode;
  52333. try {
  52334. compressedTreeNode = compressedTreeNodeProvider().getCompressedTreeNode(e);
  52335. }
  52336. catch (_a) {
  52337. return options.keyboardNavigationLabelProvider.getKeyboardNavigationLabel(e);
  52338. }
  52339. if (compressedTreeNode.element.elements.length === 1) {
  52340. return options.keyboardNavigationLabelProvider.getKeyboardNavigationLabel(e);
  52341. }
  52342. else {
  52343. return options.keyboardNavigationLabelProvider.getCompressedNodeKeyboardNavigationLabel(compressedTreeNode.element.elements);
  52344. }
  52345. }
  52346. } });
  52347. }
  52348. var CompressibleObjectTree = /** @class */ (function (_super) {
  52349. __extends(CompressibleObjectTree, _super);
  52350. function CompressibleObjectTree(user, container, delegate, renderers, options) {
  52351. if (options === void 0) { options = {}; }
  52352. var _this = this;
  52353. var compressedTreeNodeProvider = function () { return _this; };
  52354. var compressibleRenderers = renderers.map(function (r) { return new CompressibleRenderer(compressedTreeNodeProvider, r); });
  52355. _this = _super.call(this, user, container, delegate, compressibleRenderers, asObjectTreeOptions(compressedTreeNodeProvider, options)) || this;
  52356. return _this;
  52357. }
  52358. CompressibleObjectTree.prototype.setChildren = function (element, children) {
  52359. this.model.setChildren(element, children);
  52360. };
  52361. CompressibleObjectTree.prototype.createModel = function (user, view, options) {
  52362. return new compressedObjectTreeModel_1.CompressibleObjectTreeModel(user, view, options);
  52363. };
  52364. CompressibleObjectTree.prototype.updateOptions = function (optionsUpdate) {
  52365. if (optionsUpdate === void 0) { optionsUpdate = {}; }
  52366. _super.prototype.updateOptions.call(this, optionsUpdate);
  52367. if (typeof optionsUpdate.compressionEnabled !== 'undefined') {
  52368. this.model.setCompressionEnabled(optionsUpdate.compressionEnabled);
  52369. }
  52370. };
  52371. CompressibleObjectTree.prototype.getCompressedTreeNode = function (element) {
  52372. if (element === void 0) { element = null; }
  52373. return this.model.getCompressedTreeNode(element);
  52374. };
  52375. return CompressibleObjectTree;
  52376. }(ObjectTree));
  52377. exports.CompressibleObjectTree = CompressibleObjectTree;
  52378. });
  52379. /*---------------------------------------------------------------------------------------------
  52380. * Copyright (c) Microsoft Corporation. All rights reserved.
  52381. * Licensed under the MIT License. See License.txt in the project root for license information.
  52382. *--------------------------------------------------------------------------------------------*/
  52383. var __spreadArrays = (this && this.__spreadArrays) || function () {
  52384. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  52385. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  52386. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  52387. r[k] = a[j];
  52388. return r;
  52389. };
  52390. define(__m[408/*vs/base/browser/ui/tree/asyncDataTree*/], __M([0/*require*/,1/*exports*/,154/*vs/base/browser/ui/tree/abstractTree*/,206/*vs/base/browser/ui/tree/objectTree*/,99/*vs/base/browser/ui/tree/tree*/,2/*vs/base/common/lifecycle*/,4/*vs/base/common/event*/,15/*vs/base/common/async*/,54/*vs/base/common/iterator*/,140/*vs/base/browser/ui/list/listView*/,10/*vs/base/common/errors*/,6/*vs/base/browser/dom*/,38/*vs/base/common/map*/,129/*vs/base/browser/ui/tree/indexTreeModel*/]), function (require, exports, abstractTree_1, objectTree_1, tree_1, lifecycle_1, event_1, async_1, iterator_1, listView_1, errors_1, dom_1, map_1, indexTreeModel_1) {
  52391. "use strict";
  52392. Object.defineProperty(exports, "__esModule", { value: true });
  52393. function createAsyncDataTreeNode(props) {
  52394. return __assign(__assign({}, props), { children: [], refreshPromise: undefined, stale: true, slow: false, collapsedByDefault: undefined });
  52395. }
  52396. function isAncestor(ancestor, descendant) {
  52397. if (!descendant.parent) {
  52398. return false;
  52399. }
  52400. else if (descendant.parent === ancestor) {
  52401. return true;
  52402. }
  52403. else {
  52404. return isAncestor(ancestor, descendant.parent);
  52405. }
  52406. }
  52407. function intersects(node, other) {
  52408. return node === other || isAncestor(node, other) || isAncestor(other, node);
  52409. }
  52410. var AsyncDataTreeNodeWrapper = /** @class */ (function () {
  52411. function AsyncDataTreeNodeWrapper(node) {
  52412. this.node = node;
  52413. }
  52414. Object.defineProperty(AsyncDataTreeNodeWrapper.prototype, "element", {
  52415. get: function () { return this.node.element.element; },
  52416. enumerable: true,
  52417. configurable: true
  52418. });
  52419. Object.defineProperty(AsyncDataTreeNodeWrapper.prototype, "children", {
  52420. get: function () { return this.node.children.map(function (node) { return new AsyncDataTreeNodeWrapper(node); }); },
  52421. enumerable: true,
  52422. configurable: true
  52423. });
  52424. Object.defineProperty(AsyncDataTreeNodeWrapper.prototype, "depth", {
  52425. get: function () { return this.node.depth; },
  52426. enumerable: true,
  52427. configurable: true
  52428. });
  52429. Object.defineProperty(AsyncDataTreeNodeWrapper.prototype, "visibleChildrenCount", {
  52430. get: function () { return this.node.visibleChildrenCount; },
  52431. enumerable: true,
  52432. configurable: true
  52433. });
  52434. Object.defineProperty(AsyncDataTreeNodeWrapper.prototype, "visibleChildIndex", {
  52435. get: function () { return this.node.visibleChildIndex; },
  52436. enumerable: true,
  52437. configurable: true
  52438. });
  52439. Object.defineProperty(AsyncDataTreeNodeWrapper.prototype, "collapsible", {
  52440. get: function () { return this.node.collapsible; },
  52441. enumerable: true,
  52442. configurable: true
  52443. });
  52444. Object.defineProperty(AsyncDataTreeNodeWrapper.prototype, "collapsed", {
  52445. get: function () { return this.node.collapsed; },
  52446. enumerable: true,
  52447. configurable: true
  52448. });
  52449. Object.defineProperty(AsyncDataTreeNodeWrapper.prototype, "visible", {
  52450. get: function () { return this.node.visible; },
  52451. enumerable: true,
  52452. configurable: true
  52453. });
  52454. Object.defineProperty(AsyncDataTreeNodeWrapper.prototype, "filterData", {
  52455. get: function () { return this.node.filterData; },
  52456. enumerable: true,
  52457. configurable: true
  52458. });
  52459. return AsyncDataTreeNodeWrapper;
  52460. }());
  52461. var AsyncDataTreeRenderer = /** @class */ (function () {
  52462. function AsyncDataTreeRenderer(renderer, nodeMapper, onDidChangeTwistieState) {
  52463. this.renderer = renderer;
  52464. this.nodeMapper = nodeMapper;
  52465. this.onDidChangeTwistieState = onDidChangeTwistieState;
  52466. this.renderedNodes = new Map();
  52467. this.templateId = renderer.templateId;
  52468. }
  52469. AsyncDataTreeRenderer.prototype.renderTemplate = function (container) {
  52470. var templateData = this.renderer.renderTemplate(container);
  52471. return { templateData: templateData };
  52472. };
  52473. AsyncDataTreeRenderer.prototype.renderElement = function (node, index, templateData, height) {
  52474. this.renderer.renderElement(this.nodeMapper.map(node), index, templateData.templateData, height);
  52475. };
  52476. AsyncDataTreeRenderer.prototype.renderTwistie = function (element, twistieElement) {
  52477. dom_1.toggleClass(twistieElement, 'codicon-loading', element.slow);
  52478. return false;
  52479. };
  52480. AsyncDataTreeRenderer.prototype.disposeElement = function (node, index, templateData, height) {
  52481. if (this.renderer.disposeElement) {
  52482. this.renderer.disposeElement(this.nodeMapper.map(node), index, templateData.templateData, height);
  52483. }
  52484. };
  52485. AsyncDataTreeRenderer.prototype.disposeTemplate = function (templateData) {
  52486. this.renderer.disposeTemplate(templateData.templateData);
  52487. };
  52488. AsyncDataTreeRenderer.prototype.dispose = function () {
  52489. this.renderedNodes.clear();
  52490. };
  52491. return AsyncDataTreeRenderer;
  52492. }());
  52493. function asTreeEvent(e) {
  52494. return {
  52495. browserEvent: e.browserEvent,
  52496. elements: e.elements.map(function (e) { return e.element; })
  52497. };
  52498. }
  52499. var AsyncDataTreeElementsDragAndDropData = /** @class */ (function (_super) {
  52500. __extends(AsyncDataTreeElementsDragAndDropData, _super);
  52501. function AsyncDataTreeElementsDragAndDropData(data) {
  52502. var _this = _super.call(this, data.elements.map(function (node) { return node.element; })) || this;
  52503. _this.data = data;
  52504. return _this;
  52505. }
  52506. return AsyncDataTreeElementsDragAndDropData;
  52507. }(listView_1.ElementsDragAndDropData));
  52508. function asAsyncDataTreeDragAndDropData(data) {
  52509. if (data instanceof listView_1.ElementsDragAndDropData) {
  52510. return new AsyncDataTreeElementsDragAndDropData(data);
  52511. }
  52512. return data;
  52513. }
  52514. var AsyncDataTreeNodeListDragAndDrop = /** @class */ (function () {
  52515. function AsyncDataTreeNodeListDragAndDrop(dnd) {
  52516. this.dnd = dnd;
  52517. }
  52518. AsyncDataTreeNodeListDragAndDrop.prototype.getDragURI = function (node) {
  52519. return this.dnd.getDragURI(node.element);
  52520. };
  52521. AsyncDataTreeNodeListDragAndDrop.prototype.getDragLabel = function (nodes, originalEvent) {
  52522. if (this.dnd.getDragLabel) {
  52523. return this.dnd.getDragLabel(nodes.map(function (node) { return node.element; }), originalEvent);
  52524. }
  52525. return undefined;
  52526. };
  52527. AsyncDataTreeNodeListDragAndDrop.prototype.onDragStart = function (data, originalEvent) {
  52528. if (this.dnd.onDragStart) {
  52529. this.dnd.onDragStart(asAsyncDataTreeDragAndDropData(data), originalEvent);
  52530. }
  52531. };
  52532. AsyncDataTreeNodeListDragAndDrop.prototype.onDragOver = function (data, targetNode, targetIndex, originalEvent, raw) {
  52533. if (raw === void 0) { raw = true; }
  52534. return this.dnd.onDragOver(asAsyncDataTreeDragAndDropData(data), targetNode && targetNode.element, targetIndex, originalEvent);
  52535. };
  52536. AsyncDataTreeNodeListDragAndDrop.prototype.drop = function (data, targetNode, targetIndex, originalEvent) {
  52537. this.dnd.drop(asAsyncDataTreeDragAndDropData(data), targetNode && targetNode.element, targetIndex, originalEvent);
  52538. };
  52539. AsyncDataTreeNodeListDragAndDrop.prototype.onDragEnd = function (originalEvent) {
  52540. if (this.dnd.onDragEnd) {
  52541. this.dnd.onDragEnd(originalEvent);
  52542. }
  52543. };
  52544. return AsyncDataTreeNodeListDragAndDrop;
  52545. }());
  52546. function asObjectTreeOptions(options) {
  52547. return options && __assign(__assign({}, options), { collapseByDefault: true, identityProvider: options.identityProvider && {
  52548. getId: function (el) {
  52549. return options.identityProvider.getId(el.element);
  52550. }
  52551. }, dnd: options.dnd && new AsyncDataTreeNodeListDragAndDrop(options.dnd), multipleSelectionController: options.multipleSelectionController && {
  52552. isSelectionSingleChangeEvent: function (e) {
  52553. return options.multipleSelectionController.isSelectionSingleChangeEvent(__assign(__assign({}, e), { element: e.element }));
  52554. },
  52555. isSelectionRangeChangeEvent: function (e) {
  52556. return options.multipleSelectionController.isSelectionRangeChangeEvent(__assign(__assign({}, e), { element: e.element }));
  52557. }
  52558. }, accessibilityProvider: options.accessibilityProvider && __assign(__assign({}, options.accessibilityProvider), { getAriaLabel: function (e) {
  52559. return options.accessibilityProvider.getAriaLabel(e.element);
  52560. }, getAriaLevel: options.accessibilityProvider.getAriaLevel && (function (node) {
  52561. return options.accessibilityProvider.getAriaLevel(node.element);
  52562. }), getActiveDescendantId: options.accessibilityProvider.getActiveDescendantId && (function (node) {
  52563. return options.accessibilityProvider.getActiveDescendantId(node.element);
  52564. }) }), filter: options.filter && {
  52565. filter: function (e, parentVisibility) {
  52566. return options.filter.filter(e.element, parentVisibility);
  52567. }
  52568. }, keyboardNavigationLabelProvider: options.keyboardNavigationLabelProvider && __assign(__assign({}, options.keyboardNavigationLabelProvider), { getKeyboardNavigationLabel: function (e) {
  52569. return options.keyboardNavigationLabelProvider.getKeyboardNavigationLabel(e.element);
  52570. } }), sorter: undefined, expandOnlyOnTwistieClick: typeof options.expandOnlyOnTwistieClick === 'undefined' ? undefined : (typeof options.expandOnlyOnTwistieClick !== 'function' ? options.expandOnlyOnTwistieClick : (function (e) { return options.expandOnlyOnTwistieClick(e.element); })), ariaProvider: options.ariaProvider && {
  52571. getPosInSet: function (el, index) {
  52572. return options.ariaProvider.getPosInSet(el.element, index);
  52573. },
  52574. getSetSize: function (el, index, listLength) {
  52575. return options.ariaProvider.getSetSize(el.element, index, listLength);
  52576. },
  52577. getRole: options.ariaProvider.getRole ? function (el) {
  52578. return options.ariaProvider.getRole(el.element);
  52579. } : undefined,
  52580. isChecked: options.ariaProvider.isChecked ? function (e) {
  52581. var _a;
  52582. return ((_a = options.ariaProvider) === null || _a === void 0 ? void 0 : _a.isChecked)(e.element);
  52583. } : undefined
  52584. }, additionalScrollHeight: options.additionalScrollHeight });
  52585. }
  52586. function dfs(node, fn) {
  52587. fn(node);
  52588. node.children.forEach(function (child) { return dfs(child, fn); });
  52589. }
  52590. var AsyncDataTree = /** @class */ (function () {
  52591. function AsyncDataTree(user, container, delegate, renderers, dataSource, options) {
  52592. if (options === void 0) { options = {}; }
  52593. this.user = user;
  52594. this.dataSource = dataSource;
  52595. this.nodes = new Map();
  52596. this.subTreeRefreshPromises = new Map();
  52597. this.refreshPromises = new Map();
  52598. this._onDidRender = new event_1.Emitter();
  52599. this._onDidChangeNodeSlowState = new event_1.Emitter();
  52600. this.nodeMapper = new tree_1.WeakMapper(function (node) { return new AsyncDataTreeNodeWrapper(node); });
  52601. this.disposables = new lifecycle_1.DisposableStore();
  52602. this.identityProvider = options.identityProvider;
  52603. this.autoExpandSingleChildren = typeof options.autoExpandSingleChildren === 'undefined' ? false : options.autoExpandSingleChildren;
  52604. this.sorter = options.sorter;
  52605. this.collapseByDefault = options.collapseByDefault;
  52606. this.tree = this.createTree(user, container, delegate, renderers, options);
  52607. this.root = createAsyncDataTreeNode({
  52608. element: undefined,
  52609. parent: null,
  52610. hasChildren: true
  52611. });
  52612. if (this.identityProvider) {
  52613. this.root = __assign(__assign({}, this.root), { id: null });
  52614. }
  52615. this.nodes.set(null, this.root);
  52616. this.tree.onDidChangeCollapseState(this._onDidChangeCollapseState, this, this.disposables);
  52617. }
  52618. Object.defineProperty(AsyncDataTree.prototype, "onDidChangeFocus", {
  52619. get: function () { return event_1.Event.map(this.tree.onDidChangeFocus, asTreeEvent); },
  52620. enumerable: true,
  52621. configurable: true
  52622. });
  52623. Object.defineProperty(AsyncDataTree.prototype, "onDidChangeSelection", {
  52624. get: function () { return event_1.Event.map(this.tree.onDidChangeSelection, asTreeEvent); },
  52625. enumerable: true,
  52626. configurable: true
  52627. });
  52628. Object.defineProperty(AsyncDataTree.prototype, "onDidOpen", {
  52629. get: function () { return event_1.Event.map(this.tree.onDidOpen, asTreeEvent); },
  52630. enumerable: true,
  52631. configurable: true
  52632. });
  52633. Object.defineProperty(AsyncDataTree.prototype, "onDidFocus", {
  52634. get: function () { return this.tree.onDidFocus; },
  52635. enumerable: true,
  52636. configurable: true
  52637. });
  52638. Object.defineProperty(AsyncDataTree.prototype, "onDidDispose", {
  52639. get: function () { return this.tree.onDidDispose; },
  52640. enumerable: true,
  52641. configurable: true
  52642. });
  52643. AsyncDataTree.prototype.createTree = function (user, container, delegate, renderers, options) {
  52644. var _this = this;
  52645. var objectTreeDelegate = new abstractTree_1.ComposedTreeDelegate(delegate);
  52646. var objectTreeRenderers = renderers.map(function (r) { return new AsyncDataTreeRenderer(r, _this.nodeMapper, _this._onDidChangeNodeSlowState.event); });
  52647. var objectTreeOptions = asObjectTreeOptions(options) || {};
  52648. return new objectTree_1.ObjectTree(user, container, objectTreeDelegate, objectTreeRenderers, objectTreeOptions);
  52649. };
  52650. AsyncDataTree.prototype.updateOptions = function (options) {
  52651. if (options === void 0) { options = {}; }
  52652. this.tree.updateOptions(options);
  52653. };
  52654. // Widget
  52655. AsyncDataTree.prototype.getHTMLElement = function () {
  52656. return this.tree.getHTMLElement();
  52657. };
  52658. Object.defineProperty(AsyncDataTree.prototype, "scrollTop", {
  52659. get: function () {
  52660. return this.tree.scrollTop;
  52661. },
  52662. set: function (scrollTop) {
  52663. this.tree.scrollTop = scrollTop;
  52664. },
  52665. enumerable: true,
  52666. configurable: true
  52667. });
  52668. AsyncDataTree.prototype.domFocus = function () {
  52669. this.tree.domFocus();
  52670. };
  52671. AsyncDataTree.prototype.layout = function (height, width) {
  52672. this.tree.layout(height, width);
  52673. };
  52674. AsyncDataTree.prototype.style = function (styles) {
  52675. this.tree.style(styles);
  52676. };
  52677. // Model
  52678. AsyncDataTree.prototype.getInput = function () {
  52679. return this.root.element;
  52680. };
  52681. AsyncDataTree.prototype.setInput = function (input, viewState) {
  52682. return __awaiter(this, void 0, void 0, function () {
  52683. var viewStateContext;
  52684. return __generator(this, function (_a) {
  52685. switch (_a.label) {
  52686. case 0:
  52687. this.refreshPromises.forEach(function (promise) { return promise.cancel(); });
  52688. this.refreshPromises.clear();
  52689. this.root.element = input;
  52690. viewStateContext = viewState && { viewState: viewState, focus: [], selection: [] };
  52691. return [4 /*yield*/, this._updateChildren(input, true, false, viewStateContext)];
  52692. case 1:
  52693. _a.sent();
  52694. if (viewStateContext) {
  52695. this.tree.setFocus(viewStateContext.focus);
  52696. this.tree.setSelection(viewStateContext.selection);
  52697. }
  52698. if (viewState && typeof viewState.scrollTop === 'number') {
  52699. this.scrollTop = viewState.scrollTop;
  52700. }
  52701. return [2 /*return*/];
  52702. }
  52703. });
  52704. });
  52705. };
  52706. AsyncDataTree.prototype._updateChildren = function (element, recursive, rerender, viewStateContext) {
  52707. if (element === void 0) { element = this.root.element; }
  52708. if (recursive === void 0) { recursive = true; }
  52709. if (rerender === void 0) { rerender = false; }
  52710. return __awaiter(this, void 0, void 0, function () {
  52711. var node;
  52712. return __generator(this, function (_a) {
  52713. switch (_a.label) {
  52714. case 0:
  52715. if (typeof this.root.element === 'undefined') {
  52716. throw new tree_1.TreeError(this.user, 'Tree input not set');
  52717. }
  52718. if (!this.root.refreshPromise) return [3 /*break*/, 3];
  52719. return [4 /*yield*/, this.root.refreshPromise];
  52720. case 1:
  52721. _a.sent();
  52722. return [4 /*yield*/, event_1.Event.toPromise(this._onDidRender.event)];
  52723. case 2:
  52724. _a.sent();
  52725. _a.label = 3;
  52726. case 3:
  52727. node = this.getDataNode(element);
  52728. return [4 /*yield*/, this.refreshAndRenderNode(node, recursive, viewStateContext)];
  52729. case 4:
  52730. _a.sent();
  52731. if (rerender) {
  52732. try {
  52733. this.tree.rerender(node);
  52734. }
  52735. catch (_b) {
  52736. // missing nodes are fine, this could've resulted from
  52737. // parallel refresh calls, removing `node` altogether
  52738. }
  52739. }
  52740. return [2 /*return*/];
  52741. }
  52742. });
  52743. });
  52744. };
  52745. // View
  52746. AsyncDataTree.prototype.rerender = function (element) {
  52747. if (element === undefined || element === this.root.element) {
  52748. this.tree.rerender();
  52749. return;
  52750. }
  52751. var node = this.getDataNode(element);
  52752. this.tree.rerender(node);
  52753. };
  52754. AsyncDataTree.prototype.collapse = function (element, recursive) {
  52755. if (recursive === void 0) { recursive = false; }
  52756. var node = this.getDataNode(element);
  52757. return this.tree.collapse(node === this.root ? null : node, recursive);
  52758. };
  52759. AsyncDataTree.prototype.expand = function (element, recursive) {
  52760. if (recursive === void 0) { recursive = false; }
  52761. return __awaiter(this, void 0, void 0, function () {
  52762. var node, result;
  52763. return __generator(this, function (_a) {
  52764. switch (_a.label) {
  52765. case 0:
  52766. if (typeof this.root.element === 'undefined') {
  52767. throw new tree_1.TreeError(this.user, 'Tree input not set');
  52768. }
  52769. if (!this.root.refreshPromise) return [3 /*break*/, 3];
  52770. return [4 /*yield*/, this.root.refreshPromise];
  52771. case 1:
  52772. _a.sent();
  52773. return [4 /*yield*/, event_1.Event.toPromise(this._onDidRender.event)];
  52774. case 2:
  52775. _a.sent();
  52776. _a.label = 3;
  52777. case 3:
  52778. node = this.getDataNode(element);
  52779. if (this.tree.hasElement(node) && !this.tree.isCollapsible(node)) {
  52780. return [2 /*return*/, false];
  52781. }
  52782. if (!node.refreshPromise) return [3 /*break*/, 6];
  52783. return [4 /*yield*/, this.root.refreshPromise];
  52784. case 4:
  52785. _a.sent();
  52786. return [4 /*yield*/, event_1.Event.toPromise(this._onDidRender.event)];
  52787. case 5:
  52788. _a.sent();
  52789. _a.label = 6;
  52790. case 6:
  52791. if (node !== this.root && !node.refreshPromise && !this.tree.isCollapsed(node)) {
  52792. return [2 /*return*/, false];
  52793. }
  52794. result = this.tree.expand(node === this.root ? null : node, recursive);
  52795. if (!node.refreshPromise) return [3 /*break*/, 9];
  52796. return [4 /*yield*/, this.root.refreshPromise];
  52797. case 7:
  52798. _a.sent();
  52799. return [4 /*yield*/, event_1.Event.toPromise(this._onDidRender.event)];
  52800. case 8:
  52801. _a.sent();
  52802. _a.label = 9;
  52803. case 9: return [2 /*return*/, result];
  52804. }
  52805. });
  52806. });
  52807. };
  52808. AsyncDataTree.prototype.setSelection = function (elements, browserEvent) {
  52809. var _this = this;
  52810. var nodes = elements.map(function (e) { return _this.getDataNode(e); });
  52811. this.tree.setSelection(nodes, browserEvent);
  52812. };
  52813. AsyncDataTree.prototype.getSelection = function () {
  52814. var nodes = this.tree.getSelection();
  52815. return nodes.map(function (n) { return n.element; });
  52816. };
  52817. AsyncDataTree.prototype.setFocus = function (elements, browserEvent) {
  52818. var _this = this;
  52819. var nodes = elements.map(function (e) { return _this.getDataNode(e); });
  52820. this.tree.setFocus(nodes, browserEvent);
  52821. };
  52822. AsyncDataTree.prototype.getFocus = function () {
  52823. var nodes = this.tree.getFocus();
  52824. return nodes.map(function (n) { return n.element; });
  52825. };
  52826. AsyncDataTree.prototype.reveal = function (element, relativeTop) {
  52827. this.tree.reveal(this.getDataNode(element), relativeTop);
  52828. };
  52829. // Implementation
  52830. AsyncDataTree.prototype.getDataNode = function (element) {
  52831. var node = this.nodes.get((element === this.root.element ? null : element));
  52832. if (!node) {
  52833. throw new tree_1.TreeError(this.user, "Data tree node not found: " + element);
  52834. }
  52835. return node;
  52836. };
  52837. AsyncDataTree.prototype.refreshAndRenderNode = function (node, recursive, viewStateContext) {
  52838. return __awaiter(this, void 0, void 0, function () {
  52839. return __generator(this, function (_a) {
  52840. switch (_a.label) {
  52841. case 0: return [4 /*yield*/, this.refreshNode(node, recursive, viewStateContext)];
  52842. case 1:
  52843. _a.sent();
  52844. this.render(node, viewStateContext);
  52845. return [2 /*return*/];
  52846. }
  52847. });
  52848. });
  52849. };
  52850. AsyncDataTree.prototype.refreshNode = function (node, recursive, viewStateContext) {
  52851. return __awaiter(this, void 0, void 0, function () {
  52852. var result;
  52853. var _this = this;
  52854. return __generator(this, function (_a) {
  52855. this.subTreeRefreshPromises.forEach(function (refreshPromise, refreshNode) {
  52856. if (!result && intersects(refreshNode, node)) {
  52857. result = refreshPromise.then(function () { return _this.refreshNode(node, recursive, viewStateContext); });
  52858. }
  52859. });
  52860. if (result) {
  52861. return [2 /*return*/, result];
  52862. }
  52863. return [2 /*return*/, this.doRefreshSubTree(node, recursive, viewStateContext)];
  52864. });
  52865. });
  52866. };
  52867. AsyncDataTree.prototype.doRefreshSubTree = function (node, recursive, viewStateContext) {
  52868. return __awaiter(this, void 0, void 0, function () {
  52869. var done, childrenToRefresh;
  52870. var _this = this;
  52871. return __generator(this, function (_a) {
  52872. switch (_a.label) {
  52873. case 0:
  52874. node.refreshPromise = new Promise(function (c) { return done = c; });
  52875. this.subTreeRefreshPromises.set(node, node.refreshPromise);
  52876. node.refreshPromise.finally(function () {
  52877. node.refreshPromise = undefined;
  52878. _this.subTreeRefreshPromises.delete(node);
  52879. });
  52880. _a.label = 1;
  52881. case 1:
  52882. _a.trys.push([1, , 4, 5]);
  52883. return [4 /*yield*/, this.doRefreshNode(node, recursive, viewStateContext)];
  52884. case 2:
  52885. childrenToRefresh = _a.sent();
  52886. node.stale = false;
  52887. return [4 /*yield*/, Promise.all(childrenToRefresh.map(function (child) { return _this.doRefreshSubTree(child, recursive, viewStateContext); }))];
  52888. case 3:
  52889. _a.sent();
  52890. return [3 /*break*/, 5];
  52891. case 4:
  52892. done();
  52893. return [7 /*endfinally*/];
  52894. case 5: return [2 /*return*/];
  52895. }
  52896. });
  52897. });
  52898. };
  52899. AsyncDataTree.prototype.doRefreshNode = function (node, recursive, viewStateContext) {
  52900. return __awaiter(this, void 0, void 0, function () {
  52901. var childrenPromise, slowTimeout_1, children, err_1;
  52902. var _this = this;
  52903. return __generator(this, function (_a) {
  52904. switch (_a.label) {
  52905. case 0:
  52906. node.hasChildren = !!this.dataSource.hasChildren(node.element);
  52907. if (!node.hasChildren) {
  52908. childrenPromise = Promise.resolve([]);
  52909. }
  52910. else {
  52911. slowTimeout_1 = async_1.timeout(800);
  52912. slowTimeout_1.then(function () {
  52913. node.slow = true;
  52914. _this._onDidChangeNodeSlowState.fire(node);
  52915. }, function (_) { return null; });
  52916. childrenPromise = this.doGetChildren(node)
  52917. .finally(function () { return slowTimeout_1.cancel(); });
  52918. }
  52919. _a.label = 1;
  52920. case 1:
  52921. _a.trys.push([1, 3, 4, 5]);
  52922. return [4 /*yield*/, childrenPromise];
  52923. case 2:
  52924. children = _a.sent();
  52925. return [2 /*return*/, this.setChildren(node, children, recursive, viewStateContext)];
  52926. case 3:
  52927. err_1 = _a.sent();
  52928. if (node !== this.root) {
  52929. this.tree.collapse(node === this.root ? null : node);
  52930. }
  52931. if (errors_1.isPromiseCanceledError(err_1)) {
  52932. return [2 /*return*/, []];
  52933. }
  52934. throw err_1;
  52935. case 4:
  52936. if (node.slow) {
  52937. node.slow = false;
  52938. this._onDidChangeNodeSlowState.fire(node);
  52939. }
  52940. return [7 /*endfinally*/];
  52941. case 5: return [2 /*return*/];
  52942. }
  52943. });
  52944. });
  52945. };
  52946. AsyncDataTree.prototype.doGetChildren = function (node) {
  52947. var _this = this;
  52948. var result = this.refreshPromises.get(node);
  52949. if (result) {
  52950. return result;
  52951. }
  52952. result = async_1.createCancelablePromise(function () { return __awaiter(_this, void 0, void 0, function () {
  52953. var children;
  52954. return __generator(this, function (_a) {
  52955. switch (_a.label) {
  52956. case 0: return [4 /*yield*/, this.dataSource.getChildren(node.element)];
  52957. case 1:
  52958. children = _a.sent();
  52959. return [2 /*return*/, this.processChildren(children)];
  52960. }
  52961. });
  52962. }); });
  52963. this.refreshPromises.set(node, result);
  52964. return result.finally(function () { return _this.refreshPromises.delete(node); });
  52965. };
  52966. AsyncDataTree.prototype._onDidChangeCollapseState = function (_a) {
  52967. var node = _a.node, deep = _a.deep;
  52968. if (!node.collapsed && node.element.stale) {
  52969. if (deep) {
  52970. this.collapse(node.element.element);
  52971. }
  52972. else {
  52973. this.refreshAndRenderNode(node.element, false)
  52974. .catch(errors_1.onUnexpectedError);
  52975. }
  52976. }
  52977. };
  52978. AsyncDataTree.prototype.setChildren = function (node, childrenElements, recursive, viewStateContext) {
  52979. var _a;
  52980. var _this = this;
  52981. // perf: if the node was and still is a leaf, avoid all this hassle
  52982. if (node.children.length === 0 && childrenElements.length === 0) {
  52983. return [];
  52984. }
  52985. var nodesToForget = new Map();
  52986. var childrenTreeNodesById = new Map();
  52987. for (var _i = 0, _b = node.children; _i < _b.length; _i++) {
  52988. var child = _b[_i];
  52989. nodesToForget.set(child.element, child);
  52990. if (this.identityProvider) {
  52991. var collapsed = this.tree.isCollapsed(child);
  52992. childrenTreeNodesById.set(child.id, { node: child, collapsed: collapsed });
  52993. }
  52994. }
  52995. var childrenToRefresh = [];
  52996. var children = childrenElements.map(function (element) {
  52997. var hasChildren = !!_this.dataSource.hasChildren(element);
  52998. if (!_this.identityProvider) {
  52999. var asyncDataTreeNode = createAsyncDataTreeNode({ element: element, parent: node, hasChildren: hasChildren });
  53000. if (hasChildren && _this.collapseByDefault && !_this.collapseByDefault(element)) {
  53001. asyncDataTreeNode.collapsedByDefault = false;
  53002. childrenToRefresh.push(asyncDataTreeNode);
  53003. }
  53004. return asyncDataTreeNode;
  53005. }
  53006. var id = _this.identityProvider.getId(element).toString();
  53007. var result = childrenTreeNodesById.get(id);
  53008. if (result) {
  53009. var asyncDataTreeNode = result.node;
  53010. nodesToForget.delete(asyncDataTreeNode.element);
  53011. _this.nodes.delete(asyncDataTreeNode.element);
  53012. _this.nodes.set(element, asyncDataTreeNode);
  53013. asyncDataTreeNode.element = element;
  53014. asyncDataTreeNode.hasChildren = hasChildren;
  53015. if (recursive) {
  53016. if (result.collapsed) {
  53017. asyncDataTreeNode.children.forEach(function (node) { return dfs(node, function (node) { return _this.nodes.delete(node.element); }); });
  53018. asyncDataTreeNode.children.splice(0, asyncDataTreeNode.children.length);
  53019. asyncDataTreeNode.stale = true;
  53020. }
  53021. else {
  53022. childrenToRefresh.push(asyncDataTreeNode);
  53023. }
  53024. }
  53025. else if (hasChildren && _this.collapseByDefault && !_this.collapseByDefault(element)) {
  53026. asyncDataTreeNode.collapsedByDefault = false;
  53027. childrenToRefresh.push(asyncDataTreeNode);
  53028. }
  53029. return asyncDataTreeNode;
  53030. }
  53031. var childAsyncDataTreeNode = createAsyncDataTreeNode({ element: element, parent: node, id: id, hasChildren: hasChildren });
  53032. if (viewStateContext && viewStateContext.viewState.focus && viewStateContext.viewState.focus.indexOf(id) > -1) {
  53033. viewStateContext.focus.push(childAsyncDataTreeNode);
  53034. }
  53035. if (viewStateContext && viewStateContext.viewState.selection && viewStateContext.viewState.selection.indexOf(id) > -1) {
  53036. viewStateContext.selection.push(childAsyncDataTreeNode);
  53037. }
  53038. if (viewStateContext && viewStateContext.viewState.expanded && viewStateContext.viewState.expanded.indexOf(id) > -1) {
  53039. childrenToRefresh.push(childAsyncDataTreeNode);
  53040. }
  53041. else if (hasChildren && _this.collapseByDefault && !_this.collapseByDefault(element)) {
  53042. childAsyncDataTreeNode.collapsedByDefault = false;
  53043. childrenToRefresh.push(childAsyncDataTreeNode);
  53044. }
  53045. return childAsyncDataTreeNode;
  53046. });
  53047. for (var _c = 0, _d = map_1.values(nodesToForget); _c < _d.length; _c++) {
  53048. var node_1 = _d[_c];
  53049. dfs(node_1, function (node) { return _this.nodes.delete(node.element); });
  53050. }
  53051. for (var _e = 0, children_1 = children; _e < children_1.length; _e++) {
  53052. var child = children_1[_e];
  53053. this.nodes.set(child.element, child);
  53054. }
  53055. (_a = node.children).splice.apply(_a, __spreadArrays([0, node.children.length], children));
  53056. // TODO@joao this doesn't take filter into account
  53057. if (node !== this.root && this.autoExpandSingleChildren && children.length === 1 && childrenToRefresh.length === 0) {
  53058. children[0].collapsedByDefault = false;
  53059. childrenToRefresh.push(children[0]);
  53060. }
  53061. return childrenToRefresh;
  53062. };
  53063. AsyncDataTree.prototype.render = function (node, viewStateContext) {
  53064. var _this = this;
  53065. var children = node.children.map(function (node) { return _this.asTreeElement(node, viewStateContext); });
  53066. this.tree.setChildren(node === this.root ? null : node, children);
  53067. if (node !== this.root) {
  53068. this.tree.setCollapsible(node, node.hasChildren);
  53069. }
  53070. this._onDidRender.fire();
  53071. };
  53072. AsyncDataTree.prototype.asTreeElement = function (node, viewStateContext) {
  53073. var _this = this;
  53074. if (node.stale) {
  53075. return {
  53076. element: node,
  53077. collapsible: node.hasChildren,
  53078. collapsed: true
  53079. };
  53080. }
  53081. var collapsed;
  53082. if (viewStateContext && viewStateContext.viewState.expanded && node.id && viewStateContext.viewState.expanded.indexOf(node.id) > -1) {
  53083. collapsed = false;
  53084. }
  53085. else {
  53086. collapsed = node.collapsedByDefault;
  53087. }
  53088. node.collapsedByDefault = undefined;
  53089. return {
  53090. element: node,
  53091. children: node.hasChildren ? iterator_1.Iterator.map(iterator_1.Iterator.fromArray(node.children), function (child) { return _this.asTreeElement(child, viewStateContext); }) : [],
  53092. collapsible: node.hasChildren,
  53093. collapsed: collapsed
  53094. };
  53095. };
  53096. AsyncDataTree.prototype.processChildren = function (children) {
  53097. if (this.sorter) {
  53098. children.sort(this.sorter.compare.bind(this.sorter));
  53099. }
  53100. return children;
  53101. };
  53102. AsyncDataTree.prototype.dispose = function () {
  53103. this.disposables.dispose();
  53104. };
  53105. return AsyncDataTree;
  53106. }());
  53107. exports.AsyncDataTree = AsyncDataTree;
  53108. var CompressibleAsyncDataTreeNodeWrapper = /** @class */ (function () {
  53109. function CompressibleAsyncDataTreeNodeWrapper(node) {
  53110. this.node = node;
  53111. }
  53112. Object.defineProperty(CompressibleAsyncDataTreeNodeWrapper.prototype, "element", {
  53113. get: function () {
  53114. return {
  53115. elements: this.node.element.elements.map(function (e) { return e.element; }),
  53116. incompressible: this.node.element.incompressible
  53117. };
  53118. },
  53119. enumerable: true,
  53120. configurable: true
  53121. });
  53122. Object.defineProperty(CompressibleAsyncDataTreeNodeWrapper.prototype, "children", {
  53123. get: function () { return this.node.children.map(function (node) { return new CompressibleAsyncDataTreeNodeWrapper(node); }); },
  53124. enumerable: true,
  53125. configurable: true
  53126. });
  53127. Object.defineProperty(CompressibleAsyncDataTreeNodeWrapper.prototype, "depth", {
  53128. get: function () { return this.node.depth; },
  53129. enumerable: true,
  53130. configurable: true
  53131. });
  53132. Object.defineProperty(CompressibleAsyncDataTreeNodeWrapper.prototype, "visibleChildrenCount", {
  53133. get: function () { return this.node.visibleChildrenCount; },
  53134. enumerable: true,
  53135. configurable: true
  53136. });
  53137. Object.defineProperty(CompressibleAsyncDataTreeNodeWrapper.prototype, "visibleChildIndex", {
  53138. get: function () { return this.node.visibleChildIndex; },
  53139. enumerable: true,
  53140. configurable: true
  53141. });
  53142. Object.defineProperty(CompressibleAsyncDataTreeNodeWrapper.prototype, "collapsible", {
  53143. get: function () { return this.node.collapsible; },
  53144. enumerable: true,
  53145. configurable: true
  53146. });
  53147. Object.defineProperty(CompressibleAsyncDataTreeNodeWrapper.prototype, "collapsed", {
  53148. get: function () { return this.node.collapsed; },
  53149. enumerable: true,
  53150. configurable: true
  53151. });
  53152. Object.defineProperty(CompressibleAsyncDataTreeNodeWrapper.prototype, "visible", {
  53153. get: function () { return this.node.visible; },
  53154. enumerable: true,
  53155. configurable: true
  53156. });
  53157. Object.defineProperty(CompressibleAsyncDataTreeNodeWrapper.prototype, "filterData", {
  53158. get: function () { return this.node.filterData; },
  53159. enumerable: true,
  53160. configurable: true
  53161. });
  53162. return CompressibleAsyncDataTreeNodeWrapper;
  53163. }());
  53164. var CompressibleAsyncDataTreeRenderer = /** @class */ (function () {
  53165. function CompressibleAsyncDataTreeRenderer(renderer, nodeMapper, compressibleNodeMapperProvider, onDidChangeTwistieState) {
  53166. this.renderer = renderer;
  53167. this.nodeMapper = nodeMapper;
  53168. this.compressibleNodeMapperProvider = compressibleNodeMapperProvider;
  53169. this.onDidChangeTwistieState = onDidChangeTwistieState;
  53170. this.renderedNodes = new Map();
  53171. this.disposables = [];
  53172. this.templateId = renderer.templateId;
  53173. }
  53174. CompressibleAsyncDataTreeRenderer.prototype.renderTemplate = function (container) {
  53175. var templateData = this.renderer.renderTemplate(container);
  53176. return { templateData: templateData };
  53177. };
  53178. CompressibleAsyncDataTreeRenderer.prototype.renderElement = function (node, index, templateData, height) {
  53179. this.renderer.renderElement(this.nodeMapper.map(node), index, templateData.templateData, height);
  53180. };
  53181. CompressibleAsyncDataTreeRenderer.prototype.renderCompressedElements = function (node, index, templateData, height) {
  53182. this.renderer.renderCompressedElements(this.compressibleNodeMapperProvider().map(node), index, templateData.templateData, height);
  53183. };
  53184. CompressibleAsyncDataTreeRenderer.prototype.renderTwistie = function (element, twistieElement) {
  53185. dom_1.toggleClass(twistieElement, 'codicon-loading', element.slow);
  53186. return false;
  53187. };
  53188. CompressibleAsyncDataTreeRenderer.prototype.disposeElement = function (node, index, templateData, height) {
  53189. if (this.renderer.disposeElement) {
  53190. this.renderer.disposeElement(this.nodeMapper.map(node), index, templateData.templateData, height);
  53191. }
  53192. };
  53193. CompressibleAsyncDataTreeRenderer.prototype.disposeCompressedElements = function (node, index, templateData, height) {
  53194. if (this.renderer.disposeCompressedElements) {
  53195. this.renderer.disposeCompressedElements(this.compressibleNodeMapperProvider().map(node), index, templateData.templateData, height);
  53196. }
  53197. };
  53198. CompressibleAsyncDataTreeRenderer.prototype.disposeTemplate = function (templateData) {
  53199. this.renderer.disposeTemplate(templateData.templateData);
  53200. };
  53201. CompressibleAsyncDataTreeRenderer.prototype.dispose = function () {
  53202. this.renderedNodes.clear();
  53203. this.disposables = lifecycle_1.dispose(this.disposables);
  53204. };
  53205. return CompressibleAsyncDataTreeRenderer;
  53206. }());
  53207. function asCompressibleObjectTreeOptions(options) {
  53208. var objectTreeOptions = options && asObjectTreeOptions(options);
  53209. return objectTreeOptions && __assign(__assign({}, objectTreeOptions), { keyboardNavigationLabelProvider: objectTreeOptions.keyboardNavigationLabelProvider && __assign(__assign({}, objectTreeOptions.keyboardNavigationLabelProvider), { getCompressedNodeKeyboardNavigationLabel: function (els) {
  53210. return options.keyboardNavigationLabelProvider.getCompressedNodeKeyboardNavigationLabel(els.map(function (e) { return e.element; }));
  53211. } }) });
  53212. }
  53213. var CompressibleAsyncDataTree = /** @class */ (function (_super) {
  53214. __extends(CompressibleAsyncDataTree, _super);
  53215. function CompressibleAsyncDataTree(user, container, virtualDelegate, compressionDelegate, renderers, dataSource, options) {
  53216. if (options === void 0) { options = {}; }
  53217. var _this = _super.call(this, user, container, virtualDelegate, renderers, dataSource, options) || this;
  53218. _this.compressionDelegate = compressionDelegate;
  53219. _this.compressibleNodeMapper = new tree_1.WeakMapper(function (node) { return new CompressibleAsyncDataTreeNodeWrapper(node); });
  53220. _this.filter = options.filter;
  53221. return _this;
  53222. }
  53223. CompressibleAsyncDataTree.prototype.createTree = function (user, container, delegate, renderers, options) {
  53224. var _this = this;
  53225. var objectTreeDelegate = new abstractTree_1.ComposedTreeDelegate(delegate);
  53226. var objectTreeRenderers = renderers.map(function (r) { return new CompressibleAsyncDataTreeRenderer(r, _this.nodeMapper, function () { return _this.compressibleNodeMapper; }, _this._onDidChangeNodeSlowState.event); });
  53227. var objectTreeOptions = asCompressibleObjectTreeOptions(options) || {};
  53228. return new objectTree_1.CompressibleObjectTree(user, container, objectTreeDelegate, objectTreeRenderers, objectTreeOptions);
  53229. };
  53230. CompressibleAsyncDataTree.prototype.asTreeElement = function (node, viewStateContext) {
  53231. return __assign({ incompressible: this.compressionDelegate.isIncompressible(node.element) }, _super.prototype.asTreeElement.call(this, node, viewStateContext));
  53232. };
  53233. CompressibleAsyncDataTree.prototype.updateOptions = function (options) {
  53234. if (options === void 0) { options = {}; }
  53235. this.tree.updateOptions(options);
  53236. };
  53237. CompressibleAsyncDataTree.prototype.render = function (node, viewStateContext) {
  53238. var _this = this;
  53239. if (!this.identityProvider) {
  53240. return _super.prototype.render.call(this, node, viewStateContext);
  53241. }
  53242. // Preserve traits across compressions. Hacky but does the trick.
  53243. // This is hard to fix properly since it requires rewriting the traits
  53244. // across trees and lists. Let's just keep it this way for now.
  53245. var getId = function (element) { return _this.identityProvider.getId(element).toString(); };
  53246. var getUncompressedIds = function (nodes) {
  53247. var result = new Set();
  53248. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  53249. var node_2 = nodes_1[_i];
  53250. var compressedNode = _this.tree.getCompressedTreeNode(node_2 === _this.root ? null : node_2);
  53251. if (!compressedNode.element) {
  53252. continue;
  53253. }
  53254. for (var _a = 0, _b = compressedNode.element.elements; _a < _b.length; _a++) {
  53255. var node_3 = _b[_a];
  53256. result.add(getId(node_3.element));
  53257. }
  53258. }
  53259. return result;
  53260. };
  53261. var oldSelection = getUncompressedIds(this.tree.getSelection());
  53262. var oldFocus = getUncompressedIds(this.tree.getFocus());
  53263. _super.prototype.render.call(this, node, viewStateContext);
  53264. var selection = this.getSelection();
  53265. var didChangeSelection = false;
  53266. var focus = this.getFocus();
  53267. var didChangeFocus = false;
  53268. var visit = function (node) {
  53269. var compressedNode = node.element;
  53270. if (compressedNode) {
  53271. for (var i = 0; i < compressedNode.elements.length; i++) {
  53272. var id = getId(compressedNode.elements[i].element);
  53273. var element = compressedNode.elements[compressedNode.elements.length - 1].element;
  53274. // github.com/microsoft/vscode/issues/85938
  53275. if (oldSelection.has(id) && selection.indexOf(element) === -1) {
  53276. selection.push(element);
  53277. didChangeSelection = true;
  53278. }
  53279. if (oldFocus.has(id) && focus.indexOf(element) === -1) {
  53280. focus.push(element);
  53281. didChangeFocus = true;
  53282. }
  53283. }
  53284. }
  53285. node.children.forEach(visit);
  53286. };
  53287. visit(this.tree.getCompressedTreeNode(node === this.root ? null : node));
  53288. if (didChangeSelection) {
  53289. this.setSelection(selection);
  53290. }
  53291. if (didChangeFocus) {
  53292. this.setFocus(focus);
  53293. }
  53294. };
  53295. // For compressed async data trees, `TreeVisibility.Recurse` doesn't currently work
  53296. // and we have to filter everything beforehand
  53297. // Related to #85193 and #85835
  53298. CompressibleAsyncDataTree.prototype.processChildren = function (children) {
  53299. var _this = this;
  53300. if (this.filter) {
  53301. children = children.filter(function (e) {
  53302. var result = _this.filter.filter(e, 1 /* Visible */);
  53303. var visibility = getVisibility(result);
  53304. if (visibility === 2 /* Recurse */) {
  53305. throw new Error('Recursive tree visibility not supported in async data compressed trees');
  53306. }
  53307. return visibility === 1 /* Visible */;
  53308. });
  53309. }
  53310. return _super.prototype.processChildren.call(this, children);
  53311. };
  53312. return CompressibleAsyncDataTree;
  53313. }(AsyncDataTree));
  53314. exports.CompressibleAsyncDataTree = CompressibleAsyncDataTree;
  53315. function getVisibility(filterResult) {
  53316. if (typeof filterResult === 'boolean') {
  53317. return filterResult ? 1 /* Visible */ : 0 /* Hidden */;
  53318. }
  53319. else if (indexTreeModel_1.isFilterResult(filterResult)) {
  53320. return indexTreeModel_1.getVisibleState(filterResult.visibility);
  53321. }
  53322. else {
  53323. return indexTreeModel_1.getVisibleState(filterResult);
  53324. }
  53325. }
  53326. });
  53327. define(__m[409/*vs/nls!vs/base/common/keybindingLabels*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/common/keybindingLabels", data); });
  53328. /*---------------------------------------------------------------------------------------------
  53329. * Copyright (c) Microsoft Corporation. All rights reserved.
  53330. * Licensed under the MIT License. See License.txt in the project root for license information.
  53331. *--------------------------------------------------------------------------------------------*/
  53332. define(__m[207/*vs/base/common/keybindingLabels*/], __M([0/*require*/,1/*exports*/,409/*vs/nls!vs/base/common/keybindingLabels*/]), function (require, exports, nls) {
  53333. "use strict";
  53334. Object.defineProperty(exports, "__esModule", { value: true });
  53335. var ModifierLabelProvider = /** @class */ (function () {
  53336. function ModifierLabelProvider(mac, windows, linux) {
  53337. if (linux === void 0) { linux = windows; }
  53338. this.modifierLabels = [null]; // index 0 will never me accessed.
  53339. this.modifierLabels[2 /* Macintosh */] = mac;
  53340. this.modifierLabels[1 /* Windows */] = windows;
  53341. this.modifierLabels[3 /* Linux */] = linux;
  53342. }
  53343. ModifierLabelProvider.prototype.toLabel = function (OS, parts, keyLabelProvider) {
  53344. if (parts.length === 0) {
  53345. return null;
  53346. }
  53347. var result = [];
  53348. for (var i = 0, len = parts.length; i < len; i++) {
  53349. var part = parts[i];
  53350. var keyLabel = keyLabelProvider(part);
  53351. if (keyLabel === null) {
  53352. // this keybinding cannot be expressed...
  53353. return null;
  53354. }
  53355. result[i] = _simpleAsString(part, keyLabel, this.modifierLabels[OS]);
  53356. }
  53357. return result.join(' ');
  53358. };
  53359. return ModifierLabelProvider;
  53360. }());
  53361. exports.ModifierLabelProvider = ModifierLabelProvider;
  53362. /**
  53363. * A label provider that prints modifiers in a suitable format for displaying in the UI.
  53364. */
  53365. exports.UILabelProvider = new ModifierLabelProvider({
  53366. ctrlKey: '⌃',
  53367. shiftKey: '⇧',
  53368. altKey: '⌥',
  53369. metaKey: '⌘',
  53370. separator: '',
  53371. }, {
  53372. ctrlKey: nls.localize(0, null),
  53373. shiftKey: nls.localize(1, null),
  53374. altKey: nls.localize(2, null),
  53375. metaKey: nls.localize(3, null),
  53376. separator: '+',
  53377. }, {
  53378. ctrlKey: nls.localize(4, null),
  53379. shiftKey: nls.localize(5, null),
  53380. altKey: nls.localize(6, null),
  53381. metaKey: nls.localize(7, null),
  53382. separator: '+',
  53383. });
  53384. /**
  53385. * A label provider that prints modifiers in a suitable format for ARIA.
  53386. */
  53387. exports.AriaLabelProvider = new ModifierLabelProvider({
  53388. ctrlKey: nls.localize(8, null),
  53389. shiftKey: nls.localize(9, null),
  53390. altKey: nls.localize(10, null),
  53391. metaKey: nls.localize(11, null),
  53392. separator: '+',
  53393. }, {
  53394. ctrlKey: nls.localize(12, null),
  53395. shiftKey: nls.localize(13, null),
  53396. altKey: nls.localize(14, null),
  53397. metaKey: nls.localize(15, null),
  53398. separator: '+',
  53399. }, {
  53400. ctrlKey: nls.localize(16, null),
  53401. shiftKey: nls.localize(17, null),
  53402. altKey: nls.localize(18, null),
  53403. metaKey: nls.localize(19, null),
  53404. separator: '+',
  53405. });
  53406. function _simpleAsString(modifiers, key, labels) {
  53407. if (key === null) {
  53408. return '';
  53409. }
  53410. var result = [];
  53411. // translate modifier keys: Ctrl-Shift-Alt-Meta
  53412. if (modifiers.ctrlKey) {
  53413. result.push(labels.ctrlKey);
  53414. }
  53415. if (modifiers.shiftKey) {
  53416. result.push(labels.shiftKey);
  53417. }
  53418. if (modifiers.altKey) {
  53419. result.push(labels.altKey);
  53420. }
  53421. if (modifiers.metaKey) {
  53422. result.push(labels.metaKey);
  53423. }
  53424. // the actual key
  53425. result.push(key);
  53426. return result.join(labels.separator);
  53427. }
  53428. });
  53429. /*---------------------------------------------------------------------------------------------
  53430. * Copyright (c) Microsoft Corporation. All rights reserved.
  53431. * Licensed under the MIT License. See License.txt in the project root for license information.
  53432. *--------------------------------------------------------------------------------------------*/
  53433. define(__m[410/*vs/base/browser/ui/keybindingLabel/keybindingLabel*/], __M([0/*require*/,1/*exports*/,31/*vs/base/common/objects*/,207/*vs/base/common/keybindingLabels*/,6/*vs/base/browser/dom*/,402/*vs/nls!vs/base/browser/ui/keybindingLabel/keybindingLabel*/,270/*vs/css!vs/base/browser/ui/keybindingLabel/keybindingLabel*/]), function (require, exports, objects_1, keybindingLabels_1, dom, nls_1) {
  53434. "use strict";
  53435. Object.defineProperty(exports, "__esModule", { value: true });
  53436. var $ = dom.$;
  53437. var KeybindingLabel = /** @class */ (function () {
  53438. function KeybindingLabel(container, os, options) {
  53439. this.os = os;
  53440. this.options = options;
  53441. this.domNode = dom.append(container, $('.monaco-keybinding'));
  53442. this.didEverRender = false;
  53443. container.appendChild(this.domNode);
  53444. }
  53445. KeybindingLabel.prototype.set = function (keybinding, matches) {
  53446. if (this.didEverRender && this.keybinding === keybinding && KeybindingLabel.areSame(this.matches, matches)) {
  53447. return;
  53448. }
  53449. this.keybinding = keybinding;
  53450. this.matches = matches;
  53451. this.render();
  53452. };
  53453. KeybindingLabel.prototype.render = function () {
  53454. dom.clearNode(this.domNode);
  53455. if (this.keybinding) {
  53456. var _a = this.keybinding.getParts(), firstPart = _a[0], chordPart = _a[1];
  53457. if (firstPart) {
  53458. this.renderPart(this.domNode, firstPart, this.matches ? this.matches.firstPart : null);
  53459. }
  53460. if (chordPart) {
  53461. dom.append(this.domNode, $('span.monaco-keybinding-key-chord-separator', undefined, ' '));
  53462. this.renderPart(this.domNode, chordPart, this.matches ? this.matches.chordPart : null);
  53463. }
  53464. this.domNode.title = this.keybinding.getAriaLabel() || '';
  53465. }
  53466. else if (this.options && this.options.renderUnboundKeybindings) {
  53467. this.renderUnbound(this.domNode);
  53468. }
  53469. this.didEverRender = true;
  53470. };
  53471. KeybindingLabel.prototype.renderPart = function (parent, part, match) {
  53472. var modifierLabels = keybindingLabels_1.UILabelProvider.modifierLabels[this.os];
  53473. if (part.ctrlKey) {
  53474. this.renderKey(parent, modifierLabels.ctrlKey, Boolean(match === null || match === void 0 ? void 0 : match.ctrlKey), modifierLabels.separator);
  53475. }
  53476. if (part.shiftKey) {
  53477. this.renderKey(parent, modifierLabels.shiftKey, Boolean(match === null || match === void 0 ? void 0 : match.shiftKey), modifierLabels.separator);
  53478. }
  53479. if (part.altKey) {
  53480. this.renderKey(parent, modifierLabels.altKey, Boolean(match === null || match === void 0 ? void 0 : match.altKey), modifierLabels.separator);
  53481. }
  53482. if (part.metaKey) {
  53483. this.renderKey(parent, modifierLabels.metaKey, Boolean(match === null || match === void 0 ? void 0 : match.metaKey), modifierLabels.separator);
  53484. }
  53485. var keyLabel = part.keyLabel;
  53486. if (keyLabel) {
  53487. this.renderKey(parent, keyLabel, Boolean(match === null || match === void 0 ? void 0 : match.keyCode), '');
  53488. }
  53489. };
  53490. KeybindingLabel.prototype.renderKey = function (parent, label, highlight, separator) {
  53491. dom.append(parent, $('span.monaco-keybinding-key' + (highlight ? '.highlight' : ''), undefined, label));
  53492. if (separator) {
  53493. dom.append(parent, $('span.monaco-keybinding-key-separator', undefined, separator));
  53494. }
  53495. };
  53496. KeybindingLabel.prototype.renderUnbound = function (parent) {
  53497. dom.append(parent, $('span.monaco-keybinding-key', undefined, nls_1.localize(0, null)));
  53498. };
  53499. KeybindingLabel.areSame = function (a, b) {
  53500. if (a === b || (!a && !b)) {
  53501. return true;
  53502. }
  53503. return !!a && !!b && objects_1.equals(a.firstPart, b.firstPart) && objects_1.equals(a.chordPart, b.chordPart);
  53504. };
  53505. return KeybindingLabel;
  53506. }());
  53507. exports.KeybindingLabel = KeybindingLabel;
  53508. });
  53509. define(__m[411/*vs/nls!vs/base/common/severity*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/common/severity", data); });
  53510. /*---------------------------------------------------------------------------------------------
  53511. * Copyright (c) Microsoft Corporation. All rights reserved.
  53512. * Licensed under the MIT License. See License.txt in the project root for license information.
  53513. *--------------------------------------------------------------------------------------------*/
  53514. define(__m[112/*vs/base/common/severity*/], __M([0/*require*/,1/*exports*/,411/*vs/nls!vs/base/common/severity*/,5/*vs/base/common/strings*/]), function (require, exports, nls, strings) {
  53515. "use strict";
  53516. Object.defineProperty(exports, "__esModule", { value: true });
  53517. var Severity;
  53518. (function (Severity) {
  53519. Severity[Severity["Ignore"] = 0] = "Ignore";
  53520. Severity[Severity["Info"] = 1] = "Info";
  53521. Severity[Severity["Warning"] = 2] = "Warning";
  53522. Severity[Severity["Error"] = 3] = "Error";
  53523. })(Severity || (Severity = {}));
  53524. (function (Severity) {
  53525. var _error = 'error';
  53526. var _warning = 'warning';
  53527. var _warn = 'warn';
  53528. var _info = 'info';
  53529. var _displayStrings = Object.create(null);
  53530. _displayStrings[Severity.Error] = nls.localize(0, null);
  53531. _displayStrings[Severity.Warning] = nls.localize(1, null);
  53532. _displayStrings[Severity.Info] = nls.localize(2, null);
  53533. /**
  53534. * Parses 'error', 'warning', 'warn', 'info' in call casings
  53535. * and falls back to ignore.
  53536. */
  53537. function fromValue(value) {
  53538. if (!value) {
  53539. return Severity.Ignore;
  53540. }
  53541. if (strings.equalsIgnoreCase(_error, value)) {
  53542. return Severity.Error;
  53543. }
  53544. if (strings.equalsIgnoreCase(_warning, value) || strings.equalsIgnoreCase(_warn, value)) {
  53545. return Severity.Warning;
  53546. }
  53547. if (strings.equalsIgnoreCase(_info, value)) {
  53548. return Severity.Info;
  53549. }
  53550. return Severity.Ignore;
  53551. }
  53552. Severity.fromValue = fromValue;
  53553. })(Severity || (Severity = {}));
  53554. exports.default = Severity;
  53555. });
  53556. define(__m[412/*vs/nls!vs/base/parts/quickopen/browser/quickOpenModel*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/parts/quickopen/browser/quickOpenModel", data); });
  53557. /*---------------------------------------------------------------------------------------------
  53558. * Copyright (c) Microsoft Corporation. All rights reserved.
  53559. * Licensed under the MIT License. See License.txt in the project root for license information.
  53560. *--------------------------------------------------------------------------------------------*/
  53561. define(__m[155/*vs/base/parts/quickopen/browser/quickOpenModel*/], __M([0/*require*/,1/*exports*/,412/*vs/nls!vs/base/parts/quickopen/browser/quickOpenModel*/,21/*vs/base/common/types*/,139/*vs/base/browser/ui/iconLabel/iconLabel*/,70/*vs/base/browser/ui/actionbar/actionbar*/,133/*vs/base/browser/ui/highlightedlabel/highlightedLabel*/,6/*vs/base/browser/dom*/,410/*vs/base/browser/ui/keybindingLabel/keybindingLabel*/,16/*vs/base/common/platform*/,19/*vs/base/common/arrays*/]), function (require, exports, nls, types, iconLabel_1, actionbar_1, highlightedLabel_1, DOM, keybindingLabel_1, platform_1, arrays_1) {
  53562. "use strict";
  53563. Object.defineProperty(exports, "__esModule", { value: true });
  53564. var IDS = 0;
  53565. var QuickOpenEntry = /** @class */ (function () {
  53566. function QuickOpenEntry(highlights) {
  53567. if (highlights === void 0) { highlights = []; }
  53568. this.id = (IDS++).toString();
  53569. this.labelHighlights = highlights;
  53570. this.descriptionHighlights = [];
  53571. }
  53572. /**
  53573. * A unique identifier for the entry
  53574. */
  53575. QuickOpenEntry.prototype.getId = function () {
  53576. return this.id;
  53577. };
  53578. /**
  53579. * The label of the entry to identify it from others in the list
  53580. */
  53581. QuickOpenEntry.prototype.getLabel = function () {
  53582. return undefined;
  53583. };
  53584. /**
  53585. * The options for the label to use for this entry
  53586. */
  53587. QuickOpenEntry.prototype.getLabelOptions = function () {
  53588. return undefined;
  53589. };
  53590. /**
  53591. * The label of the entry to use when a screen reader wants to read about the entry
  53592. */
  53593. QuickOpenEntry.prototype.getAriaLabel = function () {
  53594. return arrays_1.coalesce([this.getLabel(), this.getDescription(), this.getDetail()])
  53595. .join(', ');
  53596. };
  53597. /**
  53598. * Detail information about the entry that is optional and can be shown below the label
  53599. */
  53600. QuickOpenEntry.prototype.getDetail = function () {
  53601. return undefined;
  53602. };
  53603. /**
  53604. * The icon of the entry to identify it from others in the list
  53605. */
  53606. QuickOpenEntry.prototype.getIcon = function () {
  53607. return undefined;
  53608. };
  53609. /**
  53610. * A secondary description that is optional and can be shown right to the label
  53611. */
  53612. QuickOpenEntry.prototype.getDescription = function () {
  53613. return undefined;
  53614. };
  53615. /**
  53616. * A tooltip to show when hovering over the entry.
  53617. */
  53618. QuickOpenEntry.prototype.getTooltip = function () {
  53619. return undefined;
  53620. };
  53621. /**
  53622. * A tooltip to show when hovering over the description portion of the entry.
  53623. */
  53624. QuickOpenEntry.prototype.getDescriptionTooltip = function () {
  53625. return undefined;
  53626. };
  53627. /**
  53628. * An optional keybinding to show for an entry.
  53629. */
  53630. QuickOpenEntry.prototype.getKeybinding = function () {
  53631. return undefined;
  53632. };
  53633. /**
  53634. * Allows to reuse the same model while filtering. Hidden entries will not show up in the viewer.
  53635. */
  53636. QuickOpenEntry.prototype.isHidden = function () {
  53637. return !!this.hidden;
  53638. };
  53639. /**
  53640. * Allows to set highlight ranges that should show up for the entry label and optionally description if set.
  53641. */
  53642. QuickOpenEntry.prototype.setHighlights = function (labelHighlights, descriptionHighlights, detailHighlights) {
  53643. this.labelHighlights = labelHighlights;
  53644. this.descriptionHighlights = descriptionHighlights;
  53645. this.detailHighlights = detailHighlights;
  53646. };
  53647. /**
  53648. * Allows to return highlight ranges that should show up for the entry label and description.
  53649. */
  53650. QuickOpenEntry.prototype.getHighlights = function () {
  53651. return [this.labelHighlights, this.descriptionHighlights, this.detailHighlights];
  53652. };
  53653. /**
  53654. * Called when the entry is selected for opening. Returns a boolean value indicating if an action was performed or not.
  53655. * The mode parameter gives an indication if the element is previewed (using arrow keys) or opened.
  53656. *
  53657. * The context parameter provides additional context information how the run was triggered.
  53658. */
  53659. QuickOpenEntry.prototype.run = function (mode, context) {
  53660. return false;
  53661. };
  53662. return QuickOpenEntry;
  53663. }());
  53664. exports.QuickOpenEntry = QuickOpenEntry;
  53665. var QuickOpenEntryGroup = /** @class */ (function (_super) {
  53666. __extends(QuickOpenEntryGroup, _super);
  53667. function QuickOpenEntryGroup(entry, groupLabel, withBorder) {
  53668. var _this = _super.call(this) || this;
  53669. _this.entry = entry;
  53670. _this.groupLabel = groupLabel;
  53671. _this.withBorder = withBorder;
  53672. return _this;
  53673. }
  53674. /**
  53675. * The label of the group or null if none.
  53676. */
  53677. QuickOpenEntryGroup.prototype.getGroupLabel = function () {
  53678. return this.groupLabel;
  53679. };
  53680. QuickOpenEntryGroup.prototype.setGroupLabel = function (groupLabel) {
  53681. this.groupLabel = groupLabel;
  53682. };
  53683. /**
  53684. * Whether to show a border on top of the group entry or not.
  53685. */
  53686. QuickOpenEntryGroup.prototype.showBorder = function () {
  53687. return !!this.withBorder;
  53688. };
  53689. QuickOpenEntryGroup.prototype.setShowBorder = function (showBorder) {
  53690. this.withBorder = showBorder;
  53691. };
  53692. QuickOpenEntryGroup.prototype.getLabel = function () {
  53693. return this.entry ? this.entry.getLabel() : _super.prototype.getLabel.call(this);
  53694. };
  53695. QuickOpenEntryGroup.prototype.getLabelOptions = function () {
  53696. return this.entry ? this.entry.getLabelOptions() : _super.prototype.getLabelOptions.call(this);
  53697. };
  53698. QuickOpenEntryGroup.prototype.getAriaLabel = function () {
  53699. return this.entry ? this.entry.getAriaLabel() : _super.prototype.getAriaLabel.call(this);
  53700. };
  53701. QuickOpenEntryGroup.prototype.getDetail = function () {
  53702. return this.entry ? this.entry.getDetail() : _super.prototype.getDetail.call(this);
  53703. };
  53704. QuickOpenEntryGroup.prototype.getIcon = function () {
  53705. return this.entry ? this.entry.getIcon() : _super.prototype.getIcon.call(this);
  53706. };
  53707. QuickOpenEntryGroup.prototype.getDescription = function () {
  53708. return this.entry ? this.entry.getDescription() : _super.prototype.getDescription.call(this);
  53709. };
  53710. QuickOpenEntryGroup.prototype.getHighlights = function () {
  53711. return this.entry ? this.entry.getHighlights() : _super.prototype.getHighlights.call(this);
  53712. };
  53713. QuickOpenEntryGroup.prototype.isHidden = function () {
  53714. return this.entry ? this.entry.isHidden() : _super.prototype.isHidden.call(this);
  53715. };
  53716. QuickOpenEntryGroup.prototype.setHighlights = function (labelHighlights, descriptionHighlights, detailHighlights) {
  53717. this.entry ? this.entry.setHighlights(labelHighlights, descriptionHighlights, detailHighlights) : _super.prototype.setHighlights.call(this, labelHighlights, descriptionHighlights, detailHighlights);
  53718. };
  53719. QuickOpenEntryGroup.prototype.run = function (mode, context) {
  53720. return this.entry ? this.entry.run(mode, context) : _super.prototype.run.call(this, mode, context);
  53721. };
  53722. return QuickOpenEntryGroup;
  53723. }(QuickOpenEntry));
  53724. exports.QuickOpenEntryGroup = QuickOpenEntryGroup;
  53725. var NoActionProvider = /** @class */ (function () {
  53726. function NoActionProvider() {
  53727. }
  53728. NoActionProvider.prototype.hasActions = function (tree, element) {
  53729. return false;
  53730. };
  53731. NoActionProvider.prototype.getActions = function (tree, element) {
  53732. return null;
  53733. };
  53734. return NoActionProvider;
  53735. }());
  53736. var templateEntry = 'quickOpenEntry';
  53737. var templateEntryGroup = 'quickOpenEntryGroup';
  53738. var Renderer = /** @class */ (function () {
  53739. function Renderer(actionProvider, actionRunner) {
  53740. if (actionProvider === void 0) { actionProvider = new NoActionProvider(); }
  53741. this.actionProvider = actionProvider;
  53742. this.actionRunner = actionRunner;
  53743. }
  53744. Renderer.prototype.getHeight = function (entry) {
  53745. if (entry.getDetail()) {
  53746. return 44;
  53747. }
  53748. return 22;
  53749. };
  53750. Renderer.prototype.getTemplateId = function (entry) {
  53751. if (entry instanceof QuickOpenEntryGroup) {
  53752. return templateEntryGroup;
  53753. }
  53754. return templateEntry;
  53755. };
  53756. Renderer.prototype.renderTemplate = function (templateId, container, styles) {
  53757. var entryContainer = document.createElement('div');
  53758. DOM.addClass(entryContainer, 'sub-content');
  53759. container.appendChild(entryContainer);
  53760. // Entry
  53761. var row1 = DOM.$('.quick-open-row');
  53762. var row2 = DOM.$('.quick-open-row');
  53763. var entry = DOM.$('.quick-open-entry', undefined, row1, row2);
  53764. entryContainer.appendChild(entry);
  53765. // Icon
  53766. var icon = document.createElement('span');
  53767. row1.appendChild(icon);
  53768. // Label
  53769. var label = new iconLabel_1.IconLabel(row1, { supportHighlights: true, supportDescriptionHighlights: true, supportCodicons: true });
  53770. // Keybinding
  53771. var keybindingContainer = document.createElement('span');
  53772. row1.appendChild(keybindingContainer);
  53773. DOM.addClass(keybindingContainer, 'quick-open-entry-keybinding');
  53774. var keybinding = new keybindingLabel_1.KeybindingLabel(keybindingContainer, platform_1.OS);
  53775. // Detail
  53776. var detailContainer = document.createElement('div');
  53777. row2.appendChild(detailContainer);
  53778. DOM.addClass(detailContainer, 'quick-open-entry-meta');
  53779. var detail = new highlightedLabel_1.HighlightedLabel(detailContainer, true);
  53780. // Entry Group
  53781. var group;
  53782. if (templateId === templateEntryGroup) {
  53783. group = document.createElement('div');
  53784. DOM.addClass(group, 'results-group');
  53785. container.appendChild(group);
  53786. }
  53787. // Actions
  53788. DOM.addClass(container, 'actions');
  53789. var actionBarContainer = document.createElement('div');
  53790. DOM.addClass(actionBarContainer, 'primary-action-bar');
  53791. container.appendChild(actionBarContainer);
  53792. var actionBar = new actionbar_1.ActionBar(actionBarContainer, {
  53793. actionRunner: this.actionRunner
  53794. });
  53795. return {
  53796. container: container,
  53797. entry: entry,
  53798. icon: icon,
  53799. label: label,
  53800. detail: detail,
  53801. keybinding: keybinding,
  53802. group: group,
  53803. actionBar: actionBar
  53804. };
  53805. };
  53806. Renderer.prototype.renderElement = function (entry, templateId, data, styles) {
  53807. // Action Bar
  53808. if (this.actionProvider.hasActions(null, entry)) {
  53809. DOM.addClass(data.container, 'has-actions');
  53810. }
  53811. else {
  53812. DOM.removeClass(data.container, 'has-actions');
  53813. }
  53814. data.actionBar.context = entry; // make sure the context is the current element
  53815. var actions = this.actionProvider.getActions(null, entry);
  53816. if (data.actionBar.isEmpty() && actions && actions.length > 0) {
  53817. data.actionBar.push(actions, { icon: true, label: false });
  53818. }
  53819. else if (!data.actionBar.isEmpty() && (!actions || actions.length === 0)) {
  53820. data.actionBar.clear();
  53821. }
  53822. // Entry group class
  53823. if (entry instanceof QuickOpenEntryGroup && entry.getGroupLabel()) {
  53824. DOM.addClass(data.container, 'has-group-label');
  53825. }
  53826. else {
  53827. DOM.removeClass(data.container, 'has-group-label');
  53828. }
  53829. // Entry group
  53830. if (entry instanceof QuickOpenEntryGroup) {
  53831. var group = entry;
  53832. var groupData = data;
  53833. // Border
  53834. if (group.showBorder()) {
  53835. DOM.addClass(groupData.container, 'results-group-separator');
  53836. if (styles.pickerGroupBorder) {
  53837. groupData.container.style.borderTopColor = styles.pickerGroupBorder.toString();
  53838. }
  53839. }
  53840. else {
  53841. DOM.removeClass(groupData.container, 'results-group-separator');
  53842. groupData.container.style.borderTopColor = '';
  53843. }
  53844. // Group Label
  53845. var groupLabel = group.getGroupLabel() || '';
  53846. if (groupData.group) {
  53847. groupData.group.textContent = groupLabel;
  53848. if (styles.pickerGroupForeground) {
  53849. groupData.group.style.color = styles.pickerGroupForeground.toString();
  53850. }
  53851. }
  53852. }
  53853. // Normal Entry
  53854. if (entry instanceof QuickOpenEntry) {
  53855. var _a = entry.getHighlights(), labelHighlights = _a[0], descriptionHighlights = _a[1], detailHighlights = _a[2];
  53856. // Icon
  53857. var iconClass = entry.getIcon() ? ('quick-open-entry-icon ' + entry.getIcon()) : '';
  53858. data.icon.className = iconClass;
  53859. // Label
  53860. var options = entry.getLabelOptions() || Object.create(null);
  53861. options.matches = labelHighlights || [];
  53862. options.title = entry.getTooltip();
  53863. options.descriptionTitle = entry.getDescriptionTooltip() || entry.getDescription(); // tooltip over description because it could overflow
  53864. options.descriptionMatches = descriptionHighlights || [];
  53865. data.label.setLabel(entry.getLabel() || '', entry.getDescription(), options);
  53866. // Meta
  53867. data.detail.set(entry.getDetail(), detailHighlights);
  53868. // Keybinding
  53869. data.keybinding.set(entry.getKeybinding());
  53870. }
  53871. };
  53872. Renderer.prototype.disposeTemplate = function (templateId, templateData) {
  53873. templateData.actionBar.dispose();
  53874. templateData.actionBar = null;
  53875. templateData.container = null;
  53876. templateData.entry = null;
  53877. templateData.keybinding = null;
  53878. templateData.detail = null;
  53879. templateData.group = null;
  53880. templateData.icon = null;
  53881. templateData.label.dispose();
  53882. templateData.label = null;
  53883. };
  53884. return Renderer;
  53885. }());
  53886. var QuickOpenModel = /** @class */ (function () {
  53887. function QuickOpenModel(entries, actionProvider) {
  53888. if (entries === void 0) { entries = []; }
  53889. if (actionProvider === void 0) { actionProvider = new NoActionProvider(); }
  53890. this._entries = entries;
  53891. this._dataSource = this;
  53892. this._renderer = new Renderer(actionProvider);
  53893. this._filter = this;
  53894. this._runner = this;
  53895. this._accessibilityProvider = this;
  53896. }
  53897. Object.defineProperty(QuickOpenModel.prototype, "entries", {
  53898. get: function () { return this._entries; },
  53899. set: function (entries) {
  53900. this._entries = entries;
  53901. },
  53902. enumerable: true,
  53903. configurable: true
  53904. });
  53905. Object.defineProperty(QuickOpenModel.prototype, "dataSource", {
  53906. get: function () { return this._dataSource; },
  53907. enumerable: true,
  53908. configurable: true
  53909. });
  53910. Object.defineProperty(QuickOpenModel.prototype, "renderer", {
  53911. get: function () { return this._renderer; },
  53912. enumerable: true,
  53913. configurable: true
  53914. });
  53915. Object.defineProperty(QuickOpenModel.prototype, "filter", {
  53916. get: function () { return this._filter; },
  53917. enumerable: true,
  53918. configurable: true
  53919. });
  53920. Object.defineProperty(QuickOpenModel.prototype, "runner", {
  53921. get: function () { return this._runner; },
  53922. enumerable: true,
  53923. configurable: true
  53924. });
  53925. Object.defineProperty(QuickOpenModel.prototype, "accessibilityProvider", {
  53926. get: function () { return this._accessibilityProvider; },
  53927. enumerable: true,
  53928. configurable: true
  53929. });
  53930. QuickOpenModel.prototype.getId = function (entry) {
  53931. return entry.getId();
  53932. };
  53933. QuickOpenModel.prototype.getLabel = function (entry) {
  53934. return types.withUndefinedAsNull(entry.getLabel());
  53935. };
  53936. QuickOpenModel.prototype.getAriaLabel = function (entry) {
  53937. var ariaLabel = entry.getAriaLabel();
  53938. if (ariaLabel) {
  53939. return nls.localize(0, null, entry.getAriaLabel());
  53940. }
  53941. return nls.localize(1, null);
  53942. };
  53943. QuickOpenModel.prototype.isVisible = function (entry) {
  53944. return !entry.isHidden();
  53945. };
  53946. QuickOpenModel.prototype.run = function (entry, mode, context) {
  53947. return entry.run(mode, context);
  53948. };
  53949. return QuickOpenModel;
  53950. }());
  53951. exports.QuickOpenModel = QuickOpenModel;
  53952. });
  53953. define(__m[413/*vs/nls!vs/base/parts/quickopen/browser/quickOpenWidget*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/base/parts/quickopen/browser/quickOpenWidget", data); });
  53954. /*---------------------------------------------------------------------------------------------
  53955. * Copyright (c) Microsoft Corporation. All rights reserved.
  53956. * Licensed under the MIT License. See License.txt in the project root for license information.
  53957. *--------------------------------------------------------------------------------------------*/
  53958. define(__m[414/*vs/base/parts/quickopen/browser/quickOpenWidget*/], __M([0/*require*/,1/*exports*/,413/*vs/nls!vs/base/parts/quickopen/browser/quickOpenWidget*/,16/*vs/base/common/platform*/,21/*vs/base/common/types*/,253/*vs/base/parts/quickopen/browser/quickOpenViewer*/,152/*vs/base/browser/ui/inputbox/inputBox*/,283/*vs/base/parts/tree/browser/treeImpl*/,274/*vs/base/browser/ui/progressbar/progressbar*/,56/*vs/base/browser/keyboardEvent*/,137/*vs/base/parts/tree/browser/treeDefaults*/,6/*vs/base/browser/dom*/,2/*vs/base/common/lifecycle*/,27/*vs/base/common/color*/,31/*vs/base/common/objects*/,45/*vs/base/browser/mouseEvent*/,281/*vs/css!vs/base/parts/quickopen/browser/quickopen*/]), function (require, exports, nls, platform, types, quickOpenViewer_1, inputBox_1, treeImpl_1, progressbar_1, keyboardEvent_1, treeDefaults_1, DOM, lifecycle_1, color_1, objects_1, mouseEvent_1) {
  53959. "use strict";
  53960. Object.defineProperty(exports, "__esModule", { value: true });
  53961. var QuickOpenController = /** @class */ (function (_super) {
  53962. __extends(QuickOpenController, _super);
  53963. function QuickOpenController() {
  53964. return _super !== null && _super.apply(this, arguments) || this;
  53965. }
  53966. QuickOpenController.prototype.onContextMenu = function (tree, element, event) {
  53967. if (platform.isMacintosh) {
  53968. return this.onLeftClick(tree, element, event); // https://github.com/Microsoft/vscode/issues/1011
  53969. }
  53970. return _super.prototype.onContextMenu.call(this, tree, element, event);
  53971. };
  53972. return QuickOpenController;
  53973. }(treeDefaults_1.DefaultController));
  53974. exports.QuickOpenController = QuickOpenController;
  53975. var defaultStyles = {
  53976. background: color_1.Color.fromHex('#1E1E1E'),
  53977. foreground: color_1.Color.fromHex('#CCCCCC'),
  53978. pickerGroupForeground: color_1.Color.fromHex('#0097FB'),
  53979. pickerGroupBorder: color_1.Color.fromHex('#3F3F46'),
  53980. widgetShadow: color_1.Color.fromHex('#000000'),
  53981. progressBarBackground: color_1.Color.fromHex('#0E70C0')
  53982. };
  53983. var DEFAULT_INPUT_ARIA_LABEL = nls.localize(0, null);
  53984. var QuickOpenWidget = /** @class */ (function (_super) {
  53985. __extends(QuickOpenWidget, _super);
  53986. function QuickOpenWidget(container, callbacks, options) {
  53987. var _this = _super.call(this) || this;
  53988. _this.isDisposed = false;
  53989. _this.container = container;
  53990. _this.callbacks = callbacks;
  53991. _this.options = options;
  53992. _this.styles = options || Object.create(null);
  53993. objects_1.mixin(_this.styles, defaultStyles, false);
  53994. _this.model = null;
  53995. return _this;
  53996. }
  53997. QuickOpenWidget.prototype.getModel = function () {
  53998. return this.model;
  53999. };
  54000. QuickOpenWidget.prototype.create = function () {
  54001. var _this = this;
  54002. // Container
  54003. this.element = document.createElement('div');
  54004. DOM.addClass(this.element, 'monaco-quick-open-widget');
  54005. this.container.appendChild(this.element);
  54006. this._register(DOM.addDisposableListener(this.element, DOM.EventType.CONTEXT_MENU, function (e) { return DOM.EventHelper.stop(e, true); })); // Do this to fix an issue on Mac where the menu goes into the way
  54007. this._register(DOM.addDisposableListener(this.element, DOM.EventType.FOCUS, function (e) { return _this.gainingFocus(); }, true));
  54008. this._register(DOM.addDisposableListener(this.element, DOM.EventType.BLUR, function (e) { return _this.loosingFocus(e); }, true));
  54009. this._register(DOM.addDisposableListener(this.element, DOM.EventType.KEY_DOWN, function (e) {
  54010. var keyboardEvent = new keyboardEvent_1.StandardKeyboardEvent(e);
  54011. if (keyboardEvent.keyCode === 9 /* Escape */) {
  54012. DOM.EventHelper.stop(e, true);
  54013. _this.hide(2 /* CANCELED */);
  54014. }
  54015. else if (keyboardEvent.keyCode === 2 /* Tab */ && !keyboardEvent.altKey && !keyboardEvent.ctrlKey && !keyboardEvent.metaKey) {
  54016. var stops = e.currentTarget.querySelectorAll('input, .monaco-tree, .monaco-tree-row.focused .action-label.icon');
  54017. if (keyboardEvent.shiftKey && keyboardEvent.target === stops[0]) {
  54018. DOM.EventHelper.stop(e, true);
  54019. stops[stops.length - 1].focus();
  54020. }
  54021. else if (!keyboardEvent.shiftKey && keyboardEvent.target === stops[stops.length - 1]) {
  54022. DOM.EventHelper.stop(e, true);
  54023. stops[0].focus();
  54024. }
  54025. }
  54026. }));
  54027. // Progress Bar
  54028. this.progressBar = this._register(new progressbar_1.ProgressBar(this.element, { progressBarBackground: this.styles.progressBarBackground }));
  54029. this.progressBar.hide();
  54030. // Input Field
  54031. this.inputContainer = document.createElement('div');
  54032. DOM.addClass(this.inputContainer, 'quick-open-input');
  54033. this.element.appendChild(this.inputContainer);
  54034. this.inputBox = this._register(new inputBox_1.InputBox(this.inputContainer, undefined, {
  54035. placeholder: this.options.inputPlaceHolder || '',
  54036. ariaLabel: DEFAULT_INPUT_ARIA_LABEL,
  54037. inputBackground: this.styles.inputBackground,
  54038. inputForeground: this.styles.inputForeground,
  54039. inputBorder: this.styles.inputBorder,
  54040. inputValidationInfoBackground: this.styles.inputValidationInfoBackground,
  54041. inputValidationInfoForeground: this.styles.inputValidationInfoForeground,
  54042. inputValidationInfoBorder: this.styles.inputValidationInfoBorder,
  54043. inputValidationWarningBackground: this.styles.inputValidationWarningBackground,
  54044. inputValidationWarningForeground: this.styles.inputValidationWarningForeground,
  54045. inputValidationWarningBorder: this.styles.inputValidationWarningBorder,
  54046. inputValidationErrorBackground: this.styles.inputValidationErrorBackground,
  54047. inputValidationErrorForeground: this.styles.inputValidationErrorForeground,
  54048. inputValidationErrorBorder: this.styles.inputValidationErrorBorder
  54049. }));
  54050. this.inputElement = this.inputBox.inputElement;
  54051. this.inputElement.setAttribute('role', 'combobox');
  54052. this.inputElement.setAttribute('aria-haspopup', 'false');
  54053. this.inputElement.setAttribute('aria-autocomplete', 'list');
  54054. this._register(DOM.addDisposableListener(this.inputBox.inputElement, DOM.EventType.INPUT, function (e) { return _this.onType(); }));
  54055. this._register(DOM.addDisposableListener(this.inputBox.inputElement, DOM.EventType.KEY_DOWN, function (e) {
  54056. var keyboardEvent = new keyboardEvent_1.StandardKeyboardEvent(e);
  54057. var shouldOpenInBackground = _this.shouldOpenInBackground(keyboardEvent);
  54058. // Do not handle Tab: It is used to navigate between elements without mouse
  54059. if (keyboardEvent.keyCode === 2 /* Tab */) {
  54060. return;
  54061. }
  54062. // Pass tree navigation keys to the tree but leave focus in input field
  54063. else if (keyboardEvent.keyCode === 18 /* DownArrow */ || keyboardEvent.keyCode === 16 /* UpArrow */ || keyboardEvent.keyCode === 12 /* PageDown */ || keyboardEvent.keyCode === 11 /* PageUp */) {
  54064. DOM.EventHelper.stop(e, true);
  54065. _this.navigateInTree(keyboardEvent.keyCode, keyboardEvent.shiftKey);
  54066. // Position cursor at the end of input to allow right arrow (open in background)
  54067. // to function immediately unless the user has made a selection
  54068. if (_this.inputBox.inputElement.selectionStart === _this.inputBox.inputElement.selectionEnd) {
  54069. _this.inputBox.inputElement.selectionStart = _this.inputBox.value.length;
  54070. }
  54071. }
  54072. // Select element on Enter or on Arrow-Right if we are at the end of the input
  54073. else if (keyboardEvent.keyCode === 3 /* Enter */ || shouldOpenInBackground) {
  54074. DOM.EventHelper.stop(e, true);
  54075. var focus_1 = _this.tree.getFocus();
  54076. if (focus_1) {
  54077. _this.elementSelected(focus_1, e, shouldOpenInBackground ? 2 /* OPEN_IN_BACKGROUND */ : 1 /* OPEN */);
  54078. }
  54079. }
  54080. }));
  54081. // Result count for screen readers
  54082. this.resultCount = document.createElement('div');
  54083. DOM.addClass(this.resultCount, 'quick-open-result-count');
  54084. this.resultCount.setAttribute('aria-live', 'polite');
  54085. this.resultCount.setAttribute('aria-atomic', 'true');
  54086. this.element.appendChild(this.resultCount);
  54087. // Tree
  54088. this.treeContainer = document.createElement('div');
  54089. DOM.addClass(this.treeContainer, 'quick-open-tree');
  54090. this.element.appendChild(this.treeContainer);
  54091. var createTree = this.options.treeCreator || (function (container, config, opts) { return new treeImpl_1.Tree(container, config, opts); });
  54092. this.tree = this._register(createTree(this.treeContainer, {
  54093. dataSource: new quickOpenViewer_1.DataSource(this),
  54094. controller: new QuickOpenController({ clickBehavior: 1 /* ON_MOUSE_UP */, keyboardSupport: this.options.keyboardSupport }),
  54095. renderer: (this.renderer = new quickOpenViewer_1.Renderer(this, this.styles)),
  54096. filter: new quickOpenViewer_1.Filter(this),
  54097. accessibilityProvider: new quickOpenViewer_1.AccessibilityProvider(this)
  54098. }, {
  54099. twistiePixels: 11,
  54100. indentPixels: 0,
  54101. alwaysFocused: true,
  54102. verticalScrollMode: 3 /* Visible */,
  54103. horizontalScrollMode: 2 /* Hidden */,
  54104. ariaLabel: nls.localize(1, null),
  54105. keyboardSupport: this.options.keyboardSupport,
  54106. preventRootFocus: false
  54107. }));
  54108. this.treeElement = this.tree.getHTMLElement();
  54109. // Handle Focus and Selection event
  54110. this._register(this.tree.onDidChangeFocus(function (event) {
  54111. _this.elementFocused(event.focus, event);
  54112. }));
  54113. this._register(this.tree.onDidChangeSelection(function (event) {
  54114. if (event.selection && event.selection.length > 0) {
  54115. var mouseEvent = event.payload && event.payload.originalEvent instanceof mouseEvent_1.StandardMouseEvent ? event.payload.originalEvent : undefined;
  54116. var shouldOpenInBackground = mouseEvent ? _this.shouldOpenInBackground(mouseEvent) : false;
  54117. _this.elementSelected(event.selection[0], event, shouldOpenInBackground ? 2 /* OPEN_IN_BACKGROUND */ : 1 /* OPEN */);
  54118. }
  54119. }));
  54120. this._register(DOM.addDisposableListener(this.treeContainer, DOM.EventType.KEY_DOWN, function (e) {
  54121. var keyboardEvent = new keyboardEvent_1.StandardKeyboardEvent(e);
  54122. // Only handle when in quick navigation mode
  54123. if (!_this.quickNavigateConfiguration) {
  54124. return;
  54125. }
  54126. // Support keyboard navigation in quick navigation mode
  54127. if (keyboardEvent.keyCode === 18 /* DownArrow */ || keyboardEvent.keyCode === 16 /* UpArrow */ || keyboardEvent.keyCode === 12 /* PageDown */ || keyboardEvent.keyCode === 11 /* PageUp */) {
  54128. DOM.EventHelper.stop(e, true);
  54129. _this.navigateInTree(keyboardEvent.keyCode);
  54130. }
  54131. // Support to open item with Enter still even in quick nav mode
  54132. else if (keyboardEvent.keyCode === 3 /* Enter */) {
  54133. DOM.EventHelper.stop(e, true);
  54134. var focus_2 = _this.tree.getFocus();
  54135. if (focus_2) {
  54136. _this.elementSelected(focus_2, e);
  54137. }
  54138. }
  54139. }));
  54140. this._register(DOM.addDisposableListener(this.treeContainer, DOM.EventType.KEY_UP, function (e) {
  54141. var keyboardEvent = new keyboardEvent_1.StandardKeyboardEvent(e);
  54142. var keyCode = keyboardEvent.keyCode;
  54143. // Only handle when in quick navigation mode
  54144. if (!_this.quickNavigateConfiguration) {
  54145. return;
  54146. }
  54147. // Select element when keys are pressed that signal it
  54148. var quickNavKeys = _this.quickNavigateConfiguration.keybindings;
  54149. var wasTriggerKeyPressed = quickNavKeys.some(function (k) {
  54150. var _a = k.getParts(), firstPart = _a[0], chordPart = _a[1];
  54151. if (chordPart) {
  54152. return false;
  54153. }
  54154. if (firstPart.shiftKey && keyCode === 4 /* Shift */) {
  54155. if (keyboardEvent.ctrlKey || keyboardEvent.altKey || keyboardEvent.metaKey) {
  54156. return false; // this is an optimistic check for the shift key being used to navigate back in quick open
  54157. }
  54158. return true;
  54159. }
  54160. if (firstPart.altKey && keyCode === 6 /* Alt */) {
  54161. return true;
  54162. }
  54163. if (firstPart.ctrlKey && keyCode === 5 /* Ctrl */) {
  54164. return true;
  54165. }
  54166. if (firstPart.metaKey && keyCode === 57 /* Meta */) {
  54167. return true;
  54168. }
  54169. return false;
  54170. });
  54171. if (wasTriggerKeyPressed) {
  54172. var focus_3 = _this.tree.getFocus();
  54173. if (focus_3) {
  54174. _this.elementSelected(focus_3, e);
  54175. }
  54176. }
  54177. }));
  54178. // Support layout
  54179. if (this.layoutDimensions) {
  54180. this.layout(this.layoutDimensions);
  54181. }
  54182. this.applyStyles();
  54183. // Allows focus to switch to next/previous entry after tab into an actionbar item
  54184. this._register(DOM.addDisposableListener(this.treeContainer, DOM.EventType.KEY_DOWN, function (e) {
  54185. var keyboardEvent = new keyboardEvent_1.StandardKeyboardEvent(e);
  54186. // Only handle when not in quick navigation mode
  54187. if (_this.quickNavigateConfiguration) {
  54188. return;
  54189. }
  54190. if (keyboardEvent.keyCode === 18 /* DownArrow */ || keyboardEvent.keyCode === 16 /* UpArrow */ || keyboardEvent.keyCode === 12 /* PageDown */ || keyboardEvent.keyCode === 11 /* PageUp */) {
  54191. DOM.EventHelper.stop(e, true);
  54192. _this.navigateInTree(keyboardEvent.keyCode, keyboardEvent.shiftKey);
  54193. _this.treeElement.focus();
  54194. }
  54195. }));
  54196. return this.element;
  54197. };
  54198. QuickOpenWidget.prototype.style = function (styles) {
  54199. this.styles = styles;
  54200. this.applyStyles();
  54201. };
  54202. QuickOpenWidget.prototype.applyStyles = function () {
  54203. if (this.element) {
  54204. var foreground = this.styles.foreground ? this.styles.foreground.toString() : '';
  54205. var background = this.styles.background ? this.styles.background.toString() : '';
  54206. var borderColor = this.styles.borderColor ? this.styles.borderColor.toString() : '';
  54207. var widgetShadow = this.styles.widgetShadow ? this.styles.widgetShadow.toString() : '';
  54208. this.element.style.color = foreground;
  54209. this.element.style.backgroundColor = background;
  54210. this.element.style.borderColor = borderColor;
  54211. this.element.style.borderWidth = borderColor ? '1px' : '';
  54212. this.element.style.borderStyle = borderColor ? 'solid' : '';
  54213. this.element.style.boxShadow = widgetShadow ? "0 5px 8px " + widgetShadow : '';
  54214. }
  54215. if (this.progressBar) {
  54216. this.progressBar.style({
  54217. progressBarBackground: this.styles.progressBarBackground
  54218. });
  54219. }
  54220. if (this.inputBox) {
  54221. this.inputBox.style({
  54222. inputBackground: this.styles.inputBackground,
  54223. inputForeground: this.styles.inputForeground,
  54224. inputBorder: this.styles.inputBorder,
  54225. inputValidationInfoBackground: this.styles.inputValidationInfoBackground,
  54226. inputValidationInfoForeground: this.styles.inputValidationInfoForeground,
  54227. inputValidationInfoBorder: this.styles.inputValidationInfoBorder,
  54228. inputValidationWarningBackground: this.styles.inputValidationWarningBackground,
  54229. inputValidationWarningForeground: this.styles.inputValidationWarningForeground,
  54230. inputValidationWarningBorder: this.styles.inputValidationWarningBorder,
  54231. inputValidationErrorBackground: this.styles.inputValidationErrorBackground,
  54232. inputValidationErrorForeground: this.styles.inputValidationErrorForeground,
  54233. inputValidationErrorBorder: this.styles.inputValidationErrorBorder
  54234. });
  54235. }
  54236. if (this.tree && !this.options.treeCreator) {
  54237. this.tree.style(this.styles);
  54238. }
  54239. if (this.renderer) {
  54240. this.renderer.updateStyles(this.styles);
  54241. }
  54242. };
  54243. QuickOpenWidget.prototype.shouldOpenInBackground = function (e) {
  54244. // Keyboard
  54245. if (e instanceof keyboardEvent_1.StandardKeyboardEvent) {
  54246. if (e.keyCode !== 17 /* RightArrow */) {
  54247. return false; // only for right arrow
  54248. }
  54249. if (e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) {
  54250. return false; // no modifiers allowed
  54251. }
  54252. // validate the cursor is at the end of the input and there is no selection,
  54253. // and if not prevent opening in the background such as the selection can be changed
  54254. var element = this.inputBox.inputElement;
  54255. return element.selectionEnd === this.inputBox.value.length && element.selectionStart === element.selectionEnd;
  54256. }
  54257. // Mouse
  54258. return e.middleButton;
  54259. };
  54260. QuickOpenWidget.prototype.onType = function () {
  54261. var value = this.inputBox.value;
  54262. // Adjust help text as needed if present
  54263. if (this.helpText) {
  54264. if (value) {
  54265. DOM.hide(this.helpText);
  54266. }
  54267. else {
  54268. DOM.show(this.helpText);
  54269. }
  54270. }
  54271. // Send to callbacks
  54272. this.callbacks.onType(value);
  54273. };
  54274. QuickOpenWidget.prototype.navigateInTree = function (keyCode, isShift) {
  54275. var model = this.tree.getInput();
  54276. var entries = model ? model.entries : [];
  54277. var oldFocus = this.tree.getFocus();
  54278. // Normal Navigation
  54279. switch (keyCode) {
  54280. case 18 /* DownArrow */:
  54281. this.tree.focusNext();
  54282. break;
  54283. case 16 /* UpArrow */:
  54284. this.tree.focusPrevious();
  54285. break;
  54286. case 12 /* PageDown */:
  54287. this.tree.focusNextPage();
  54288. break;
  54289. case 11 /* PageUp */:
  54290. this.tree.focusPreviousPage();
  54291. break;
  54292. case 2 /* Tab */:
  54293. if (isShift) {
  54294. this.tree.focusPrevious();
  54295. }
  54296. else {
  54297. this.tree.focusNext();
  54298. }
  54299. break;
  54300. }
  54301. var newFocus = this.tree.getFocus();
  54302. // Support cycle-through navigation if focus did not change
  54303. if (entries.length > 1 && oldFocus === newFocus) {
  54304. // Up from no entry or first entry goes down to last
  54305. if (keyCode === 16 /* UpArrow */ || (keyCode === 2 /* Tab */ && isShift)) {
  54306. this.tree.focusLast();
  54307. }
  54308. // Down from last entry goes to up to first
  54309. else if (keyCode === 18 /* DownArrow */ || keyCode === 2 /* Tab */ && !isShift) {
  54310. this.tree.focusFirst();
  54311. }
  54312. }
  54313. // Reveal
  54314. newFocus = this.tree.getFocus();
  54315. if (newFocus) {
  54316. this.tree.reveal(newFocus);
  54317. }
  54318. };
  54319. QuickOpenWidget.prototype.elementFocused = function (value, event) {
  54320. if (!value || !this.isVisible()) {
  54321. return;
  54322. }
  54323. // ARIA
  54324. var arivaActiveDescendant = this.treeElement.getAttribute('aria-activedescendant');
  54325. if (arivaActiveDescendant) {
  54326. this.inputElement.setAttribute('aria-activedescendant', arivaActiveDescendant);
  54327. }
  54328. else {
  54329. this.inputElement.removeAttribute('aria-activedescendant');
  54330. }
  54331. var context = { event: event, keymods: this.extractKeyMods(event), quickNavigateConfiguration: this.quickNavigateConfiguration };
  54332. this.model.runner.run(value, 0 /* PREVIEW */, context);
  54333. };
  54334. QuickOpenWidget.prototype.elementSelected = function (value, event, preferredMode) {
  54335. var hide = true;
  54336. // Trigger open of element on selection
  54337. if (this.isVisible()) {
  54338. var mode = preferredMode || 1 /* OPEN */;
  54339. var context = { event: event, keymods: this.extractKeyMods(event), quickNavigateConfiguration: this.quickNavigateConfiguration };
  54340. hide = this.model.runner.run(value, mode, context);
  54341. }
  54342. // Hide if command was run successfully
  54343. if (hide) {
  54344. this.hide(0 /* ELEMENT_SELECTED */);
  54345. }
  54346. };
  54347. QuickOpenWidget.prototype.extractKeyMods = function (event) {
  54348. return {
  54349. ctrlCmd: event && (event.ctrlKey || event.metaKey || (event.payload && event.payload.originalEvent && (event.payload.originalEvent.ctrlKey || event.payload.originalEvent.metaKey))),
  54350. alt: event && (event.altKey || (event.payload && event.payload.originalEvent && event.payload.originalEvent.altKey))
  54351. };
  54352. };
  54353. QuickOpenWidget.prototype.show = function (param, options) {
  54354. this.visible = true;
  54355. this.isLoosingFocus = false;
  54356. this.quickNavigateConfiguration = options ? options.quickNavigateConfiguration : undefined;
  54357. // Adjust UI for quick navigate mode
  54358. if (this.quickNavigateConfiguration) {
  54359. DOM.hide(this.inputContainer);
  54360. DOM.show(this.element);
  54361. this.tree.domFocus();
  54362. }
  54363. // Otherwise use normal UI
  54364. else {
  54365. DOM.show(this.inputContainer);
  54366. DOM.show(this.element);
  54367. this.inputBox.focus();
  54368. }
  54369. // Adjust Help text for IE
  54370. if (this.helpText) {
  54371. if (this.quickNavigateConfiguration || types.isString(param)) {
  54372. DOM.hide(this.helpText);
  54373. }
  54374. else {
  54375. DOM.show(this.helpText);
  54376. }
  54377. }
  54378. // Show based on param
  54379. if (types.isString(param)) {
  54380. this.doShowWithPrefix(param);
  54381. }
  54382. else {
  54383. if (options && options.value) {
  54384. this.restoreLastInput(options.value);
  54385. }
  54386. this.doShowWithInput(param, options && options.autoFocus ? options.autoFocus : {});
  54387. }
  54388. // Respect selectAll option
  54389. if (options && options.inputSelection && !this.quickNavigateConfiguration) {
  54390. this.inputBox.select(options.inputSelection);
  54391. }
  54392. if (this.callbacks.onShow) {
  54393. this.callbacks.onShow();
  54394. }
  54395. };
  54396. QuickOpenWidget.prototype.restoreLastInput = function (lastInput) {
  54397. this.inputBox.value = lastInput;
  54398. this.inputBox.select();
  54399. this.callbacks.onType(lastInput);
  54400. };
  54401. QuickOpenWidget.prototype.doShowWithPrefix = function (prefix) {
  54402. this.inputBox.value = prefix;
  54403. this.callbacks.onType(prefix);
  54404. };
  54405. QuickOpenWidget.prototype.doShowWithInput = function (input, autoFocus) {
  54406. this.setInput(input, autoFocus);
  54407. };
  54408. QuickOpenWidget.prototype.setInputAndLayout = function (input, autoFocus) {
  54409. var _this = this;
  54410. this.treeContainer.style.height = this.getHeight(input) + "px";
  54411. this.tree.setInput(null).then(function () {
  54412. _this.model = input;
  54413. // ARIA
  54414. _this.inputElement.setAttribute('aria-haspopup', String(input && input.entries && input.entries.length > 0));
  54415. return _this.tree.setInput(input);
  54416. }).then(function () {
  54417. // Indicate entries to tree
  54418. _this.tree.layout();
  54419. var entries = input ? input.entries.filter(function (e) { return _this.isElementVisible(input, e); }) : [];
  54420. _this.updateResultCount(entries.length);
  54421. // Handle auto focus
  54422. if (entries.length) {
  54423. _this.autoFocus(input, entries, autoFocus);
  54424. }
  54425. });
  54426. };
  54427. QuickOpenWidget.prototype.isElementVisible = function (input, e) {
  54428. if (!input.filter) {
  54429. return true;
  54430. }
  54431. return input.filter.isVisible(e);
  54432. };
  54433. QuickOpenWidget.prototype.autoFocus = function (input, entries, autoFocus) {
  54434. if (autoFocus === void 0) { autoFocus = {}; }
  54435. // First check for auto focus of prefix matches
  54436. if (autoFocus.autoFocusPrefixMatch) {
  54437. var caseSensitiveMatch = void 0;
  54438. var caseInsensitiveMatch = void 0;
  54439. var prefix = autoFocus.autoFocusPrefixMatch;
  54440. var lowerCasePrefix = prefix.toLowerCase();
  54441. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  54442. var entry = entries_1[_i];
  54443. var label = input.dataSource.getLabel(entry) || '';
  54444. if (!caseSensitiveMatch && label.indexOf(prefix) === 0) {
  54445. caseSensitiveMatch = entry;
  54446. }
  54447. else if (!caseInsensitiveMatch && label.toLowerCase().indexOf(lowerCasePrefix) === 0) {
  54448. caseInsensitiveMatch = entry;
  54449. }
  54450. if (caseSensitiveMatch && caseInsensitiveMatch) {
  54451. break;
  54452. }
  54453. }
  54454. var entryToFocus = caseSensitiveMatch || caseInsensitiveMatch;
  54455. if (entryToFocus) {
  54456. this.tree.setFocus(entryToFocus);
  54457. this.tree.reveal(entryToFocus, 0.5);
  54458. return;
  54459. }
  54460. }
  54461. // Second check for auto focus of first entry
  54462. if (autoFocus.autoFocusFirstEntry) {
  54463. this.tree.focusFirst();
  54464. this.tree.reveal(this.tree.getFocus());
  54465. }
  54466. // Third check for specific index option
  54467. else if (typeof autoFocus.autoFocusIndex === 'number') {
  54468. if (entries.length > autoFocus.autoFocusIndex) {
  54469. this.tree.focusNth(autoFocus.autoFocusIndex);
  54470. this.tree.reveal(this.tree.getFocus());
  54471. }
  54472. }
  54473. // Check for auto focus of second entry
  54474. else if (autoFocus.autoFocusSecondEntry) {
  54475. if (entries.length > 1) {
  54476. this.tree.focusNth(1);
  54477. }
  54478. }
  54479. // Finally check for auto focus of last entry
  54480. else if (autoFocus.autoFocusLastEntry) {
  54481. if (entries.length > 1) {
  54482. this.tree.focusLast();
  54483. this.tree.reveal(this.tree.getFocus());
  54484. }
  54485. }
  54486. };
  54487. QuickOpenWidget.prototype.getHeight = function (input) {
  54488. var _this = this;
  54489. var renderer = input.renderer;
  54490. if (!input) {
  54491. var itemHeight = renderer.getHeight(null);
  54492. return this.options.minItemsToShow ? this.options.minItemsToShow * itemHeight : 0;
  54493. }
  54494. var height = 0;
  54495. var preferredItemsHeight;
  54496. if (this.layoutDimensions && this.layoutDimensions.height) {
  54497. preferredItemsHeight = (this.layoutDimensions.height - 50 /* subtract height of input field (30px) and some spacing (drop shadow) to fit */) * 0.4 /* max 40% of screen */;
  54498. }
  54499. if (!preferredItemsHeight || preferredItemsHeight > QuickOpenWidget.MAX_ITEMS_HEIGHT) {
  54500. preferredItemsHeight = QuickOpenWidget.MAX_ITEMS_HEIGHT;
  54501. }
  54502. var entries = input.entries.filter(function (e) { return _this.isElementVisible(input, e); });
  54503. var maxEntries = this.options.maxItemsToShow || entries.length;
  54504. for (var i = 0; i < maxEntries && i < entries.length; i++) {
  54505. var entryHeight = renderer.getHeight(entries[i]);
  54506. if (height + entryHeight <= preferredItemsHeight) {
  54507. height += entryHeight;
  54508. }
  54509. else {
  54510. break;
  54511. }
  54512. }
  54513. return height;
  54514. };
  54515. QuickOpenWidget.prototype.updateResultCount = function (count) {
  54516. this.resultCount.textContent = nls.localize(2, null, count);
  54517. };
  54518. QuickOpenWidget.prototype.hide = function (reason) {
  54519. if (!this.isVisible()) {
  54520. return;
  54521. }
  54522. this.visible = false;
  54523. DOM.hide(this.element);
  54524. this.element.blur();
  54525. // Clear input field and clear tree
  54526. this.inputBox.value = '';
  54527. this.tree.setInput(null);
  54528. // ARIA
  54529. this.inputElement.setAttribute('aria-haspopup', 'false');
  54530. // Reset Tree Height
  54531. this.treeContainer.style.height = (this.options.minItemsToShow ? this.options.minItemsToShow * 22 : 0) + "px";
  54532. // Clear any running Progress
  54533. this.progressBar.stop().hide();
  54534. // Clear Focus
  54535. if (this.tree.isDOMFocused()) {
  54536. this.tree.domBlur();
  54537. }
  54538. else if (this.inputBox.hasFocus()) {
  54539. this.inputBox.blur();
  54540. }
  54541. // Callbacks
  54542. if (reason === 0 /* ELEMENT_SELECTED */) {
  54543. this.callbacks.onOk();
  54544. }
  54545. else {
  54546. this.callbacks.onCancel();
  54547. }
  54548. if (this.callbacks.onHide) {
  54549. this.callbacks.onHide(reason);
  54550. }
  54551. };
  54552. QuickOpenWidget.prototype.setInput = function (input, autoFocus, ariaLabel) {
  54553. if (!this.isVisible()) {
  54554. return;
  54555. }
  54556. // If the input changes, indicate this to the tree
  54557. if (!!this.getInput()) {
  54558. this.onInputChanging();
  54559. }
  54560. // Adapt tree height to entries and apply input
  54561. this.setInputAndLayout(input, autoFocus);
  54562. // Apply ARIA
  54563. if (this.inputBox) {
  54564. this.inputBox.setAriaLabel(ariaLabel || DEFAULT_INPUT_ARIA_LABEL);
  54565. }
  54566. };
  54567. QuickOpenWidget.prototype.onInputChanging = function () {
  54568. var _this = this;
  54569. if (this.inputChangingTimeoutHandle) {
  54570. clearTimeout(this.inputChangingTimeoutHandle);
  54571. this.inputChangingTimeoutHandle = null;
  54572. }
  54573. // when the input is changing in quick open, we indicate this as CSS class to the widget
  54574. // for a certain timeout. this helps reducing some hectic UI updates when input changes quickly
  54575. DOM.addClass(this.element, 'content-changing');
  54576. this.inputChangingTimeoutHandle = setTimeout(function () {
  54577. DOM.removeClass(_this.element, 'content-changing');
  54578. }, 500);
  54579. };
  54580. QuickOpenWidget.prototype.getInput = function () {
  54581. return this.tree.getInput();
  54582. };
  54583. QuickOpenWidget.prototype.isVisible = function () {
  54584. return this.visible;
  54585. };
  54586. QuickOpenWidget.prototype.layout = function (dimension) {
  54587. this.layoutDimensions = dimension;
  54588. // Apply to quick open width (height is dynamic by number of items to show)
  54589. var quickOpenWidth = Math.min(this.layoutDimensions.width * 0.62 /* golden cut */, QuickOpenWidget.MAX_WIDTH);
  54590. if (this.element) {
  54591. // quick open
  54592. this.element.style.width = quickOpenWidth + "px";
  54593. this.element.style.marginLeft = "-" + quickOpenWidth / 2 + "px";
  54594. // input field
  54595. this.inputContainer.style.width = quickOpenWidth - 12 + "px";
  54596. }
  54597. };
  54598. QuickOpenWidget.prototype.gainingFocus = function () {
  54599. this.isLoosingFocus = false;
  54600. };
  54601. QuickOpenWidget.prototype.loosingFocus = function (e) {
  54602. var _this = this;
  54603. if (!this.isVisible()) {
  54604. return;
  54605. }
  54606. var relatedTarget = e.relatedTarget;
  54607. if (!this.quickNavigateConfiguration && DOM.isAncestor(relatedTarget, this.element)) {
  54608. return; // user clicked somewhere into quick open widget, do not close thereby
  54609. }
  54610. this.isLoosingFocus = true;
  54611. setTimeout(function () {
  54612. if (!_this.isLoosingFocus || _this.isDisposed) {
  54613. return;
  54614. }
  54615. var veto = _this.callbacks.onFocusLost && _this.callbacks.onFocusLost();
  54616. if (!veto) {
  54617. _this.hide(1 /* FOCUS_LOST */);
  54618. }
  54619. }, 0);
  54620. };
  54621. QuickOpenWidget.prototype.dispose = function () {
  54622. _super.prototype.dispose.call(this);
  54623. this.isDisposed = true;
  54624. };
  54625. QuickOpenWidget.MAX_WIDTH = 600; // Max total width of quick open widget
  54626. QuickOpenWidget.MAX_ITEMS_HEIGHT = 20 * 22; // Max height of item list below input field
  54627. return QuickOpenWidget;
  54628. }(lifecycle_1.Disposable));
  54629. exports.QuickOpenWidget = QuickOpenWidget;
  54630. });
  54631. define(__m[415/*vs/nls!vs/editor/browser/controller/coreCommands*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/browser/controller/coreCommands", data); });
  54632. define(__m[416/*vs/nls!vs/editor/browser/controller/textAreaHandler*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/browser/controller/textAreaHandler", data); });
  54633. define(__m[417/*vs/nls!vs/editor/browser/widget/codeEditorWidget*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/browser/widget/codeEditorWidget", data); });
  54634. define(__m[418/*vs/nls!vs/editor/browser/widget/diffEditorWidget*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/browser/widget/diffEditorWidget", data); });
  54635. define(__m[419/*vs/nls!vs/editor/browser/widget/diffReview*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/browser/widget/diffReview", data); });
  54636. define(__m[420/*vs/nls!vs/editor/browser/widget/inlineDiffMargin*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/browser/widget/inlineDiffMargin", data); });
  54637. /*---------------------------------------------------------------------------------------------
  54638. * Copyright (c) Microsoft Corporation. All rights reserved.
  54639. * Licensed under the MIT License. See License.txt in the project root for license information.
  54640. *--------------------------------------------------------------------------------------------*/
  54641. define(__m[421/*vs/editor/browser/widget/inlineDiffMargin*/], __M([0/*require*/,1/*exports*/,420/*vs/nls!vs/editor/browser/widget/inlineDiffMargin*/,6/*vs/base/browser/dom*/,55/*vs/base/common/actions*/,2/*vs/base/common/lifecycle*/,3/*vs/editor/common/core/range*/]), function (require, exports, nls, dom, actions_1, lifecycle_1, range_1) {
  54642. "use strict";
  54643. Object.defineProperty(exports, "__esModule", { value: true });
  54644. var InlineDiffMargin = /** @class */ (function (_super) {
  54645. __extends(InlineDiffMargin, _super);
  54646. function InlineDiffMargin(_viewZoneId, _marginDomNode, editor, diff, _contextMenuService, _clipboardService) {
  54647. var _this = _super.call(this) || this;
  54648. _this._viewZoneId = _viewZoneId;
  54649. _this._marginDomNode = _marginDomNode;
  54650. _this.editor = editor;
  54651. _this.diff = diff;
  54652. _this._contextMenuService = _contextMenuService;
  54653. _this._clipboardService = _clipboardService;
  54654. _this._visibility = false;
  54655. // make sure the diff margin shows above overlay.
  54656. _this._marginDomNode.style.zIndex = '10';
  54657. _this._diffActions = document.createElement('div');
  54658. _this._diffActions.className = 'codicon codicon-lightbulb lightbulb-glyph';
  54659. _this._diffActions.style.position = 'absolute';
  54660. var lineHeight = editor.getOption(49 /* lineHeight */);
  54661. var lineFeed = editor.getModel().getEOL();
  54662. _this._diffActions.style.right = '0px';
  54663. _this._diffActions.style.visibility = 'hidden';
  54664. _this._diffActions.style.height = lineHeight + "px";
  54665. _this._diffActions.style.lineHeight = lineHeight + "px";
  54666. _this._marginDomNode.appendChild(_this._diffActions);
  54667. var actions = [];
  54668. // default action
  54669. actions.push(new actions_1.Action('diff.clipboard.copyDeletedContent', diff.originalEndLineNumber > diff.modifiedStartLineNumber
  54670. ? nls.localize(0, null)
  54671. : nls.localize(1, null), undefined, true, function () { return __awaiter(_this, void 0, void 0, function () {
  54672. return __generator(this, function (_a) {
  54673. switch (_a.label) {
  54674. case 0: return [4 /*yield*/, this._clipboardService.writeText(diff.originalContent.join(lineFeed) + lineFeed)];
  54675. case 1:
  54676. _a.sent();
  54677. return [2 /*return*/];
  54678. }
  54679. });
  54680. }); }));
  54681. var currentLineNumberOffset = 0;
  54682. var copyLineAction = undefined;
  54683. if (diff.originalEndLineNumber > diff.modifiedStartLineNumber) {
  54684. copyLineAction = new actions_1.Action('diff.clipboard.copyDeletedLineContent', nls.localize(2, null, diff.originalStartLineNumber), undefined, true, function () { return __awaiter(_this, void 0, void 0, function () {
  54685. return __generator(this, function (_a) {
  54686. switch (_a.label) {
  54687. case 0: return [4 /*yield*/, this._clipboardService.writeText(diff.originalContent[currentLineNumberOffset])];
  54688. case 1:
  54689. _a.sent();
  54690. return [2 /*return*/];
  54691. }
  54692. });
  54693. }); });
  54694. actions.push(copyLineAction);
  54695. }
  54696. var readOnly = editor.getOption(68 /* readOnly */);
  54697. if (!readOnly) {
  54698. actions.push(new actions_1.Action('diff.inline.revertChange', nls.localize(3, null), undefined, true, function () { return __awaiter(_this, void 0, void 0, function () {
  54699. var column, column;
  54700. return __generator(this, function (_a) {
  54701. if (diff.modifiedEndLineNumber === 0) {
  54702. column = editor.getModel().getLineMaxColumn(diff.modifiedStartLineNumber);
  54703. editor.executeEdits('diffEditor', [
  54704. {
  54705. range: new range_1.Range(diff.modifiedStartLineNumber, column, diff.modifiedStartLineNumber, column),
  54706. text: lineFeed + diff.originalContent.join(lineFeed)
  54707. }
  54708. ]);
  54709. }
  54710. else {
  54711. column = editor.getModel().getLineMaxColumn(diff.modifiedEndLineNumber);
  54712. editor.executeEdits('diffEditor', [
  54713. {
  54714. range: new range_1.Range(diff.modifiedStartLineNumber, 1, diff.modifiedEndLineNumber, column),
  54715. text: diff.originalContent.join(lineFeed)
  54716. }
  54717. ]);
  54718. }
  54719. return [2 /*return*/];
  54720. });
  54721. }); }));
  54722. }
  54723. var showContextMenu = function (x, y) {
  54724. _this._contextMenuService.showContextMenu({
  54725. getAnchor: function () {
  54726. return {
  54727. x: x,
  54728. y: y
  54729. };
  54730. },
  54731. getActions: function () {
  54732. if (copyLineAction) {
  54733. copyLineAction.label = nls.localize(4, null, diff.originalStartLineNumber + currentLineNumberOffset);
  54734. }
  54735. return actions;
  54736. },
  54737. autoSelectFirstItem: true
  54738. });
  54739. };
  54740. _this._register(dom.addStandardDisposableListener(_this._diffActions, 'mousedown', function (e) {
  54741. var _a = dom.getDomNodePagePosition(_this._diffActions), top = _a.top, height = _a.height;
  54742. var pad = Math.floor(lineHeight / 3);
  54743. e.preventDefault();
  54744. showContextMenu(e.posx, top + height + pad);
  54745. }));
  54746. _this._register(editor.onMouseMove(function (e) {
  54747. if (e.target.type === 8 /* CONTENT_VIEW_ZONE */ || e.target.type === 5 /* GUTTER_VIEW_ZONE */) {
  54748. var viewZoneId = e.target.detail.viewZoneId;
  54749. if (viewZoneId === _this._viewZoneId) {
  54750. _this.visibility = true;
  54751. currentLineNumberOffset = _this._updateLightBulbPosition(_this._marginDomNode, e.event.browserEvent.y, lineHeight);
  54752. }
  54753. else {
  54754. _this.visibility = false;
  54755. }
  54756. }
  54757. else {
  54758. _this.visibility = false;
  54759. }
  54760. }));
  54761. _this._register(editor.onMouseDown(function (e) {
  54762. if (!e.event.rightButton) {
  54763. return;
  54764. }
  54765. if (e.target.type === 8 /* CONTENT_VIEW_ZONE */ || e.target.type === 5 /* GUTTER_VIEW_ZONE */) {
  54766. var viewZoneId = e.target.detail.viewZoneId;
  54767. if (viewZoneId === _this._viewZoneId) {
  54768. e.event.preventDefault();
  54769. currentLineNumberOffset = _this._updateLightBulbPosition(_this._marginDomNode, e.event.browserEvent.y, lineHeight);
  54770. showContextMenu(e.event.posx, e.event.posy + lineHeight);
  54771. }
  54772. }
  54773. }));
  54774. return _this;
  54775. }
  54776. Object.defineProperty(InlineDiffMargin.prototype, "visibility", {
  54777. get: function () {
  54778. return this._visibility;
  54779. },
  54780. set: function (_visibility) {
  54781. if (this._visibility !== _visibility) {
  54782. this._visibility = _visibility;
  54783. if (_visibility) {
  54784. this._diffActions.style.visibility = 'visible';
  54785. }
  54786. else {
  54787. this._diffActions.style.visibility = 'hidden';
  54788. }
  54789. }
  54790. },
  54791. enumerable: true,
  54792. configurable: true
  54793. });
  54794. InlineDiffMargin.prototype._updateLightBulbPosition = function (marginDomNode, y, lineHeight) {
  54795. var top = dom.getDomNodePagePosition(marginDomNode).top;
  54796. var offset = y - top;
  54797. var lineNumberOffset = Math.floor(offset / lineHeight);
  54798. var newTop = lineNumberOffset * lineHeight;
  54799. this._diffActions.style.top = newTop + "px";
  54800. return lineNumberOffset;
  54801. };
  54802. return InlineDiffMargin;
  54803. }(lifecycle_1.Disposable));
  54804. exports.InlineDiffMargin = InlineDiffMargin;
  54805. });
  54806. define(__m[422/*vs/nls!vs/editor/common/config/commonEditorConfig*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/common/config/commonEditorConfig", data); });
  54807. define(__m[423/*vs/nls!vs/editor/common/config/editorOptions*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/common/config/editorOptions", data); });
  54808. /*---------------------------------------------------------------------------------------------
  54809. * Copyright (c) Microsoft Corporation. All rights reserved.
  54810. * Licensed under the MIT License. See License.txt in the project root for license information.
  54811. *--------------------------------------------------------------------------------------------*/
  54812. define(__m[33/*vs/editor/common/config/editorOptions*/], __M([0/*require*/,1/*exports*/,423/*vs/nls!vs/editor/common/config/editorOptions*/,16/*vs/base/common/platform*/,109/*vs/editor/common/model/wordHelper*/]), function (require, exports, nls, platform, wordHelper_1) {
  54813. "use strict";
  54814. Object.defineProperty(exports, "__esModule", { value: true });
  54815. /**
  54816. * @internal
  54817. * The width of the minimap gutter, in pixels.
  54818. */
  54819. exports.MINIMAP_GUTTER_WIDTH = 8;
  54820. //#endregion
  54821. /**
  54822. * An event describing that the configuration of the editor has changed.
  54823. */
  54824. var ConfigurationChangedEvent = /** @class */ (function () {
  54825. /**
  54826. * @internal
  54827. */
  54828. function ConfigurationChangedEvent(values) {
  54829. this._values = values;
  54830. }
  54831. ConfigurationChangedEvent.prototype.hasChanged = function (id) {
  54832. return this._values[id];
  54833. };
  54834. return ConfigurationChangedEvent;
  54835. }());
  54836. exports.ConfigurationChangedEvent = ConfigurationChangedEvent;
  54837. /**
  54838. * @internal
  54839. */
  54840. var ValidatedEditorOptions = /** @class */ (function () {
  54841. function ValidatedEditorOptions() {
  54842. this._values = [];
  54843. }
  54844. ValidatedEditorOptions.prototype._read = function (option) {
  54845. return this._values[option];
  54846. };
  54847. ValidatedEditorOptions.prototype.get = function (id) {
  54848. return this._values[id];
  54849. };
  54850. ValidatedEditorOptions.prototype._write = function (option, value) {
  54851. this._values[option] = value;
  54852. };
  54853. return ValidatedEditorOptions;
  54854. }());
  54855. exports.ValidatedEditorOptions = ValidatedEditorOptions;
  54856. /**
  54857. * @internal
  54858. */
  54859. var BaseEditorOption = /** @class */ (function () {
  54860. function BaseEditorOption(id, name, defaultValue, schema) {
  54861. this.id = id;
  54862. this.name = name;
  54863. this.defaultValue = defaultValue;
  54864. this.schema = schema;
  54865. }
  54866. BaseEditorOption.prototype.compute = function (env, options, value) {
  54867. return value;
  54868. };
  54869. return BaseEditorOption;
  54870. }());
  54871. /**
  54872. * @internal
  54873. */
  54874. var ComputedEditorOption = /** @class */ (function () {
  54875. function ComputedEditorOption(id, deps) {
  54876. if (deps === void 0) { deps = null; }
  54877. this.schema = undefined;
  54878. this.id = id;
  54879. this.name = '_never_';
  54880. this.defaultValue = undefined;
  54881. this.deps = deps;
  54882. }
  54883. ComputedEditorOption.prototype.validate = function (input) {
  54884. return this.defaultValue;
  54885. };
  54886. return ComputedEditorOption;
  54887. }());
  54888. var SimpleEditorOption = /** @class */ (function () {
  54889. function SimpleEditorOption(id, name, defaultValue, schema) {
  54890. this.id = id;
  54891. this.name = name;
  54892. this.defaultValue = defaultValue;
  54893. this.schema = schema;
  54894. }
  54895. SimpleEditorOption.prototype.validate = function (input) {
  54896. if (typeof input === 'undefined') {
  54897. return this.defaultValue;
  54898. }
  54899. return input;
  54900. };
  54901. SimpleEditorOption.prototype.compute = function (env, options, value) {
  54902. return value;
  54903. };
  54904. return SimpleEditorOption;
  54905. }());
  54906. var EditorBooleanOption = /** @class */ (function (_super) {
  54907. __extends(EditorBooleanOption, _super);
  54908. function EditorBooleanOption(id, name, defaultValue, schema) {
  54909. if (schema === void 0) { schema = undefined; }
  54910. var _this = this;
  54911. if (typeof schema !== 'undefined') {
  54912. schema.type = 'boolean';
  54913. schema.default = defaultValue;
  54914. }
  54915. _this = _super.call(this, id, name, defaultValue, schema) || this;
  54916. return _this;
  54917. }
  54918. EditorBooleanOption.boolean = function (value, defaultValue) {
  54919. if (typeof value === 'undefined') {
  54920. return defaultValue;
  54921. }
  54922. if (value === 'false') {
  54923. // treat the string 'false' as false
  54924. return false;
  54925. }
  54926. return Boolean(value);
  54927. };
  54928. EditorBooleanOption.prototype.validate = function (input) {
  54929. return EditorBooleanOption.boolean(input, this.defaultValue);
  54930. };
  54931. return EditorBooleanOption;
  54932. }(SimpleEditorOption));
  54933. var EditorIntOption = /** @class */ (function (_super) {
  54934. __extends(EditorIntOption, _super);
  54935. function EditorIntOption(id, name, defaultValue, minimum, maximum, schema) {
  54936. if (schema === void 0) { schema = undefined; }
  54937. var _this = this;
  54938. if (typeof schema !== 'undefined') {
  54939. schema.type = 'integer';
  54940. schema.default = defaultValue;
  54941. schema.minimum = minimum;
  54942. schema.maximum = maximum;
  54943. }
  54944. _this = _super.call(this, id, name, defaultValue, schema) || this;
  54945. _this.minimum = minimum;
  54946. _this.maximum = maximum;
  54947. return _this;
  54948. }
  54949. EditorIntOption.clampedInt = function (value, defaultValue, minimum, maximum) {
  54950. var r;
  54951. if (typeof value === 'undefined') {
  54952. r = defaultValue;
  54953. }
  54954. else {
  54955. r = parseInt(value, 10);
  54956. if (isNaN(r)) {
  54957. r = defaultValue;
  54958. }
  54959. }
  54960. r = Math.max(minimum, r);
  54961. r = Math.min(maximum, r);
  54962. return r | 0;
  54963. };
  54964. EditorIntOption.prototype.validate = function (input) {
  54965. return EditorIntOption.clampedInt(input, this.defaultValue, this.minimum, this.maximum);
  54966. };
  54967. return EditorIntOption;
  54968. }(SimpleEditorOption));
  54969. var EditorFloatOption = /** @class */ (function (_super) {
  54970. __extends(EditorFloatOption, _super);
  54971. function EditorFloatOption(id, name, defaultValue, validationFn, schema) {
  54972. var _this = this;
  54973. if (typeof schema !== 'undefined') {
  54974. schema.type = 'number';
  54975. schema.default = defaultValue;
  54976. }
  54977. _this = _super.call(this, id, name, defaultValue, schema) || this;
  54978. _this.validationFn = validationFn;
  54979. return _this;
  54980. }
  54981. EditorFloatOption.clamp = function (n, min, max) {
  54982. if (n < min) {
  54983. return min;
  54984. }
  54985. if (n > max) {
  54986. return max;
  54987. }
  54988. return n;
  54989. };
  54990. EditorFloatOption.float = function (value, defaultValue) {
  54991. if (typeof value === 'number') {
  54992. return value;
  54993. }
  54994. if (typeof value === 'undefined') {
  54995. return defaultValue;
  54996. }
  54997. var r = parseFloat(value);
  54998. return (isNaN(r) ? defaultValue : r);
  54999. };
  55000. EditorFloatOption.prototype.validate = function (input) {
  55001. return this.validationFn(EditorFloatOption.float(input, this.defaultValue));
  55002. };
  55003. return EditorFloatOption;
  55004. }(SimpleEditorOption));
  55005. var EditorStringOption = /** @class */ (function (_super) {
  55006. __extends(EditorStringOption, _super);
  55007. function EditorStringOption(id, name, defaultValue, schema) {
  55008. if (schema === void 0) { schema = undefined; }
  55009. var _this = this;
  55010. if (typeof schema !== 'undefined') {
  55011. schema.type = 'string';
  55012. schema.default = defaultValue;
  55013. }
  55014. _this = _super.call(this, id, name, defaultValue, schema) || this;
  55015. return _this;
  55016. }
  55017. EditorStringOption.string = function (value, defaultValue) {
  55018. if (typeof value !== 'string') {
  55019. return defaultValue;
  55020. }
  55021. return value;
  55022. };
  55023. EditorStringOption.prototype.validate = function (input) {
  55024. return EditorStringOption.string(input, this.defaultValue);
  55025. };
  55026. return EditorStringOption;
  55027. }(SimpleEditorOption));
  55028. var EditorStringEnumOption = /** @class */ (function (_super) {
  55029. __extends(EditorStringEnumOption, _super);
  55030. function EditorStringEnumOption(id, name, defaultValue, allowedValues, schema) {
  55031. if (schema === void 0) { schema = undefined; }
  55032. var _this = this;
  55033. if (typeof schema !== 'undefined') {
  55034. schema.type = 'string';
  55035. schema.enum = allowedValues;
  55036. schema.default = defaultValue;
  55037. }
  55038. _this = _super.call(this, id, name, defaultValue, schema) || this;
  55039. _this._allowedValues = allowedValues;
  55040. return _this;
  55041. }
  55042. EditorStringEnumOption.stringSet = function (value, defaultValue, allowedValues) {
  55043. if (typeof value !== 'string') {
  55044. return defaultValue;
  55045. }
  55046. if (allowedValues.indexOf(value) === -1) {
  55047. return defaultValue;
  55048. }
  55049. return value;
  55050. };
  55051. EditorStringEnumOption.prototype.validate = function (input) {
  55052. return EditorStringEnumOption.stringSet(input, this.defaultValue, this._allowedValues);
  55053. };
  55054. return EditorStringEnumOption;
  55055. }(SimpleEditorOption));
  55056. var EditorEnumOption = /** @class */ (function (_super) {
  55057. __extends(EditorEnumOption, _super);
  55058. function EditorEnumOption(id, name, defaultValue, defaultStringValue, allowedValues, convert, schema) {
  55059. if (schema === void 0) { schema = undefined; }
  55060. var _this = this;
  55061. if (typeof schema !== 'undefined') {
  55062. schema.type = 'string';
  55063. schema.enum = allowedValues;
  55064. schema.default = defaultStringValue;
  55065. }
  55066. _this = _super.call(this, id, name, defaultValue, schema) || this;
  55067. _this._allowedValues = allowedValues;
  55068. _this._convert = convert;
  55069. return _this;
  55070. }
  55071. EditorEnumOption.prototype.validate = function (input) {
  55072. if (typeof input !== 'string') {
  55073. return this.defaultValue;
  55074. }
  55075. if (this._allowedValues.indexOf(input) === -1) {
  55076. return this.defaultValue;
  55077. }
  55078. return this._convert(input);
  55079. };
  55080. return EditorEnumOption;
  55081. }(BaseEditorOption));
  55082. //#endregion
  55083. //#region autoIndent
  55084. function _autoIndentFromString(autoIndent) {
  55085. switch (autoIndent) {
  55086. case 'none': return 0 /* None */;
  55087. case 'keep': return 1 /* Keep */;
  55088. case 'brackets': return 2 /* Brackets */;
  55089. case 'advanced': return 3 /* Advanced */;
  55090. case 'full': return 4 /* Full */;
  55091. }
  55092. }
  55093. //#endregion
  55094. //#region accessibilitySupport
  55095. var EditorAccessibilitySupport = /** @class */ (function (_super) {
  55096. __extends(EditorAccessibilitySupport, _super);
  55097. function EditorAccessibilitySupport() {
  55098. return _super.call(this, 2 /* accessibilitySupport */, 'accessibilitySupport', 0 /* Unknown */, {
  55099. type: 'string',
  55100. enum: ['auto', 'on', 'off'],
  55101. enumDescriptions: [
  55102. nls.localize(0, null),
  55103. nls.localize(1, null),
  55104. nls.localize(2, null),
  55105. ],
  55106. default: 'auto',
  55107. description: nls.localize(3, null)
  55108. }) || this;
  55109. }
  55110. EditorAccessibilitySupport.prototype.validate = function (input) {
  55111. switch (input) {
  55112. case 'auto': return 0 /* Unknown */;
  55113. case 'off': return 1 /* Disabled */;
  55114. case 'on': return 2 /* Enabled */;
  55115. }
  55116. return this.defaultValue;
  55117. };
  55118. EditorAccessibilitySupport.prototype.compute = function (env, options, value) {
  55119. if (value === 0 /* Unknown */) {
  55120. // The editor reads the `accessibilitySupport` from the environment
  55121. return env.accessibilitySupport;
  55122. }
  55123. return value;
  55124. };
  55125. return EditorAccessibilitySupport;
  55126. }(BaseEditorOption));
  55127. var EditorComments = /** @class */ (function (_super) {
  55128. __extends(EditorComments, _super);
  55129. function EditorComments() {
  55130. var _this = this;
  55131. var defaults = {
  55132. insertSpace: true,
  55133. };
  55134. _this = _super.call(this, 13 /* comments */, 'comments', defaults, {
  55135. 'editor.comments.insertSpace': {
  55136. type: 'boolean',
  55137. default: defaults.insertSpace,
  55138. description: nls.localize(4, null)
  55139. },
  55140. }) || this;
  55141. return _this;
  55142. }
  55143. EditorComments.prototype.validate = function (_input) {
  55144. if (typeof _input !== 'object') {
  55145. return this.defaultValue;
  55146. }
  55147. var input = _input;
  55148. return {
  55149. insertSpace: EditorBooleanOption.boolean(input.insertSpace, this.defaultValue.insertSpace),
  55150. };
  55151. };
  55152. return EditorComments;
  55153. }(BaseEditorOption));
  55154. function _cursorBlinkingStyleFromString(cursorBlinkingStyle) {
  55155. switch (cursorBlinkingStyle) {
  55156. case 'blink': return 1 /* Blink */;
  55157. case 'smooth': return 2 /* Smooth */;
  55158. case 'phase': return 3 /* Phase */;
  55159. case 'expand': return 4 /* Expand */;
  55160. case 'solid': return 5 /* Solid */;
  55161. }
  55162. }
  55163. //#endregion
  55164. //#region cursorStyle
  55165. /**
  55166. * The style in which the editor's cursor should be rendered.
  55167. */
  55168. var TextEditorCursorStyle;
  55169. (function (TextEditorCursorStyle) {
  55170. /**
  55171. * As a vertical line (sitting between two characters).
  55172. */
  55173. TextEditorCursorStyle[TextEditorCursorStyle["Line"] = 1] = "Line";
  55174. /**
  55175. * As a block (sitting on top of a character).
  55176. */
  55177. TextEditorCursorStyle[TextEditorCursorStyle["Block"] = 2] = "Block";
  55178. /**
  55179. * As a horizontal line (sitting under a character).
  55180. */
  55181. TextEditorCursorStyle[TextEditorCursorStyle["Underline"] = 3] = "Underline";
  55182. /**
  55183. * As a thin vertical line (sitting between two characters).
  55184. */
  55185. TextEditorCursorStyle[TextEditorCursorStyle["LineThin"] = 4] = "LineThin";
  55186. /**
  55187. * As an outlined block (sitting on top of a character).
  55188. */
  55189. TextEditorCursorStyle[TextEditorCursorStyle["BlockOutline"] = 5] = "BlockOutline";
  55190. /**
  55191. * As a thin horizontal line (sitting under a character).
  55192. */
  55193. TextEditorCursorStyle[TextEditorCursorStyle["UnderlineThin"] = 6] = "UnderlineThin";
  55194. })(TextEditorCursorStyle = exports.TextEditorCursorStyle || (exports.TextEditorCursorStyle = {}));
  55195. function _cursorStyleFromString(cursorStyle) {
  55196. switch (cursorStyle) {
  55197. case 'line': return TextEditorCursorStyle.Line;
  55198. case 'block': return TextEditorCursorStyle.Block;
  55199. case 'underline': return TextEditorCursorStyle.Underline;
  55200. case 'line-thin': return TextEditorCursorStyle.LineThin;
  55201. case 'block-outline': return TextEditorCursorStyle.BlockOutline;
  55202. case 'underline-thin': return TextEditorCursorStyle.UnderlineThin;
  55203. }
  55204. }
  55205. //#endregion
  55206. //#region editorClassName
  55207. var EditorClassName = /** @class */ (function (_super) {
  55208. __extends(EditorClassName, _super);
  55209. function EditorClassName() {
  55210. return _super.call(this, 104 /* editorClassName */, [55 /* mouseStyle */, 26 /* extraEditorClassName */]) || this;
  55211. }
  55212. EditorClassName.prototype.compute = function (env, options, _) {
  55213. var className = 'monaco-editor';
  55214. if (options.get(26 /* extraEditorClassName */)) {
  55215. className += ' ' + options.get(26 /* extraEditorClassName */);
  55216. }
  55217. if (env.extraEditorClassName) {
  55218. className += ' ' + env.extraEditorClassName;
  55219. }
  55220. if (options.get(55 /* mouseStyle */) === 'default') {
  55221. className += ' mouse-default';
  55222. }
  55223. else if (options.get(55 /* mouseStyle */) === 'copy') {
  55224. className += ' mouse-copy';
  55225. }
  55226. if (options.get(85 /* showUnused */)) {
  55227. className += ' showUnused';
  55228. }
  55229. return className;
  55230. };
  55231. return EditorClassName;
  55232. }(ComputedEditorOption));
  55233. //#endregion
  55234. //#region emptySelectionClipboard
  55235. var EditorEmptySelectionClipboard = /** @class */ (function (_super) {
  55236. __extends(EditorEmptySelectionClipboard, _super);
  55237. function EditorEmptySelectionClipboard() {
  55238. return _super.call(this, 25 /* emptySelectionClipboard */, 'emptySelectionClipboard', true, { description: nls.localize(5, null) }) || this;
  55239. }
  55240. EditorEmptySelectionClipboard.prototype.compute = function (env, options, value) {
  55241. return value && env.emptySelectionClipboard;
  55242. };
  55243. return EditorEmptySelectionClipboard;
  55244. }(EditorBooleanOption));
  55245. var EditorFind = /** @class */ (function (_super) {
  55246. __extends(EditorFind, _super);
  55247. function EditorFind() {
  55248. var _this = this;
  55249. var defaults = {
  55250. seedSearchStringFromSelection: true,
  55251. autoFindInSelection: 'never',
  55252. globalFindClipboard: false,
  55253. addExtraSpaceOnTop: true
  55254. };
  55255. _this = _super.call(this, 28 /* find */, 'find', defaults, {
  55256. 'editor.find.seedSearchStringFromSelection': {
  55257. type: 'boolean',
  55258. default: defaults.seedSearchStringFromSelection,
  55259. description: nls.localize(6, null)
  55260. },
  55261. 'editor.find.autoFindInSelection': {
  55262. type: 'string',
  55263. enum: ['never', 'always', 'multiline'],
  55264. default: defaults.autoFindInSelection,
  55265. enumDescriptions: [
  55266. nls.localize(7, null),
  55267. nls.localize(8, null),
  55268. nls.localize(9, null)
  55269. ],
  55270. description: nls.localize(10, null)
  55271. },
  55272. 'editor.find.globalFindClipboard': {
  55273. type: 'boolean',
  55274. default: defaults.globalFindClipboard,
  55275. description: nls.localize(11, null),
  55276. included: platform.isMacintosh
  55277. },
  55278. 'editor.find.addExtraSpaceOnTop': {
  55279. type: 'boolean',
  55280. default: defaults.addExtraSpaceOnTop,
  55281. description: nls.localize(12, null)
  55282. }
  55283. }) || this;
  55284. return _this;
  55285. }
  55286. EditorFind.prototype.validate = function (_input) {
  55287. if (typeof _input !== 'object') {
  55288. return this.defaultValue;
  55289. }
  55290. var input = _input;
  55291. return {
  55292. seedSearchStringFromSelection: EditorBooleanOption.boolean(input.seedSearchStringFromSelection, this.defaultValue.seedSearchStringFromSelection),
  55293. autoFindInSelection: typeof _input.autoFindInSelection === 'boolean'
  55294. ? (_input.autoFindInSelection ? 'always' : 'never')
  55295. : EditorStringEnumOption.stringSet(input.autoFindInSelection, this.defaultValue.autoFindInSelection, ['never', 'always', 'multiline']),
  55296. globalFindClipboard: EditorBooleanOption.boolean(input.globalFindClipboard, this.defaultValue.globalFindClipboard),
  55297. addExtraSpaceOnTop: EditorBooleanOption.boolean(input.addExtraSpaceOnTop, this.defaultValue.addExtraSpaceOnTop)
  55298. };
  55299. };
  55300. return EditorFind;
  55301. }(BaseEditorOption));
  55302. //#endregion
  55303. //#region fontLigatures
  55304. /**
  55305. * @internal
  55306. */
  55307. var EditorFontLigatures = /** @class */ (function (_super) {
  55308. __extends(EditorFontLigatures, _super);
  55309. function EditorFontLigatures() {
  55310. return _super.call(this, 35 /* fontLigatures */, 'fontLigatures', EditorFontLigatures.OFF, {
  55311. anyOf: [
  55312. {
  55313. type: 'boolean',
  55314. description: nls.localize(13, null),
  55315. },
  55316. {
  55317. type: 'string',
  55318. description: nls.localize(14, null)
  55319. }
  55320. ],
  55321. description: nls.localize(15, null),
  55322. default: false
  55323. }) || this;
  55324. }
  55325. EditorFontLigatures.prototype.validate = function (input) {
  55326. if (typeof input === 'undefined') {
  55327. return this.defaultValue;
  55328. }
  55329. if (typeof input === 'string') {
  55330. if (input === 'false') {
  55331. return EditorFontLigatures.OFF;
  55332. }
  55333. if (input === 'true') {
  55334. return EditorFontLigatures.ON;
  55335. }
  55336. return input;
  55337. }
  55338. if (Boolean(input)) {
  55339. return EditorFontLigatures.ON;
  55340. }
  55341. return EditorFontLigatures.OFF;
  55342. };
  55343. EditorFontLigatures.OFF = '"liga" off, "calt" off';
  55344. EditorFontLigatures.ON = '"liga" on, "calt" on';
  55345. return EditorFontLigatures;
  55346. }(BaseEditorOption));
  55347. exports.EditorFontLigatures = EditorFontLigatures;
  55348. //#endregion
  55349. //#region fontInfo
  55350. var EditorFontInfo = /** @class */ (function (_super) {
  55351. __extends(EditorFontInfo, _super);
  55352. function EditorFontInfo() {
  55353. return _super.call(this, 34 /* fontInfo */) || this;
  55354. }
  55355. EditorFontInfo.prototype.compute = function (env, options, _) {
  55356. return env.fontInfo;
  55357. };
  55358. return EditorFontInfo;
  55359. }(ComputedEditorOption));
  55360. //#endregion
  55361. //#region fontSize
  55362. var EditorFontSize = /** @class */ (function (_super) {
  55363. __extends(EditorFontSize, _super);
  55364. function EditorFontSize() {
  55365. return _super.call(this, 36 /* fontSize */, 'fontSize', exports.EDITOR_FONT_DEFAULTS.fontSize, {
  55366. type: 'number',
  55367. minimum: 6,
  55368. maximum: 100,
  55369. default: exports.EDITOR_FONT_DEFAULTS.fontSize,
  55370. description: nls.localize(16, null)
  55371. }) || this;
  55372. }
  55373. EditorFontSize.prototype.validate = function (input) {
  55374. var r = EditorFloatOption.float(input, this.defaultValue);
  55375. if (r === 0) {
  55376. return exports.EDITOR_FONT_DEFAULTS.fontSize;
  55377. }
  55378. return EditorFloatOption.clamp(r, 6, 100);
  55379. };
  55380. EditorFontSize.prototype.compute = function (env, options, value) {
  55381. // The final fontSize respects the editor zoom level.
  55382. // So take the result from env.fontInfo
  55383. return env.fontInfo.fontSize;
  55384. };
  55385. return EditorFontSize;
  55386. }(SimpleEditorOption));
  55387. var EditorGoToLocation = /** @class */ (function (_super) {
  55388. __extends(EditorGoToLocation, _super);
  55389. function EditorGoToLocation() {
  55390. var _this = this;
  55391. var defaults = {
  55392. multiple: 'peek',
  55393. multipleDefinitions: 'peek',
  55394. multipleTypeDefinitions: 'peek',
  55395. multipleDeclarations: 'peek',
  55396. multipleImplementations: 'peek',
  55397. multipleReferences: 'peek',
  55398. alternativeDefinitionCommand: 'editor.action.goToReferences',
  55399. alternativeTypeDefinitionCommand: 'editor.action.goToReferences',
  55400. alternativeDeclarationCommand: 'editor.action.goToReferences',
  55401. alternativeImplementationCommand: '',
  55402. alternativeReferenceCommand: '',
  55403. };
  55404. var jsonSubset = {
  55405. type: 'string',
  55406. enum: ['peek', 'gotoAndPeek', 'goto'],
  55407. default: defaults.multiple,
  55408. enumDescriptions: [
  55409. nls.localize(17, null),
  55410. nls.localize(18, null),
  55411. nls.localize(19, null)
  55412. ]
  55413. };
  55414. _this = _super.call(this, 41 /* gotoLocation */, 'gotoLocation', defaults, {
  55415. 'editor.gotoLocation.multiple': {
  55416. deprecationMessage: nls.localize(20, null),
  55417. },
  55418. 'editor.gotoLocation.multipleDefinitions': __assign({ description: nls.localize(21, null) }, jsonSubset),
  55419. 'editor.gotoLocation.multipleTypeDefinitions': __assign({ description: nls.localize(22, null) }, jsonSubset),
  55420. 'editor.gotoLocation.multipleDeclarations': __assign({ description: nls.localize(23, null) }, jsonSubset),
  55421. 'editor.gotoLocation.multipleImplementations': __assign({ description: nls.localize(24, null) }, jsonSubset),
  55422. 'editor.gotoLocation.multipleReferences': __assign({ description: nls.localize(25, null) }, jsonSubset),
  55423. 'editor.gotoLocation.alternativeDefinitionCommand': {
  55424. type: 'string',
  55425. default: defaults.alternativeDefinitionCommand,
  55426. description: nls.localize(26, null)
  55427. },
  55428. 'editor.gotoLocation.alternativeTypeDefinitionCommand': {
  55429. type: 'string',
  55430. default: defaults.alternativeTypeDefinitionCommand,
  55431. description: nls.localize(27, null)
  55432. },
  55433. 'editor.gotoLocation.alternativeDeclarationCommand': {
  55434. type: 'string',
  55435. default: defaults.alternativeDeclarationCommand,
  55436. description: nls.localize(28, null)
  55437. },
  55438. 'editor.gotoLocation.alternativeImplementationCommand': {
  55439. type: 'string',
  55440. default: defaults.alternativeImplementationCommand,
  55441. description: nls.localize(29, null)
  55442. },
  55443. 'editor.gotoLocation.alternativeReferenceCommand': {
  55444. type: 'string',
  55445. default: defaults.alternativeReferenceCommand,
  55446. description: nls.localize(30, null)
  55447. },
  55448. }) || this;
  55449. return _this;
  55450. }
  55451. EditorGoToLocation.prototype.validate = function (_input) {
  55452. var _a, _b, _c, _d, _e;
  55453. if (typeof _input !== 'object') {
  55454. return this.defaultValue;
  55455. }
  55456. var input = _input;
  55457. return {
  55458. multiple: EditorStringEnumOption.stringSet(input.multiple, this.defaultValue.multiple, ['peek', 'gotoAndPeek', 'goto']),
  55459. multipleDefinitions: (_a = input.multipleDefinitions) !== null && _a !== void 0 ? _a : EditorStringEnumOption.stringSet(input.multipleDefinitions, 'peek', ['peek', 'gotoAndPeek', 'goto']),
  55460. multipleTypeDefinitions: (_b = input.multipleTypeDefinitions) !== null && _b !== void 0 ? _b : EditorStringEnumOption.stringSet(input.multipleTypeDefinitions, 'peek', ['peek', 'gotoAndPeek', 'goto']),
  55461. multipleDeclarations: (_c = input.multipleDeclarations) !== null && _c !== void 0 ? _c : EditorStringEnumOption.stringSet(input.multipleDeclarations, 'peek', ['peek', 'gotoAndPeek', 'goto']),
  55462. multipleImplementations: (_d = input.multipleImplementations) !== null && _d !== void 0 ? _d : EditorStringEnumOption.stringSet(input.multipleImplementations, 'peek', ['peek', 'gotoAndPeek', 'goto']),
  55463. multipleReferences: (_e = input.multipleReferences) !== null && _e !== void 0 ? _e : EditorStringEnumOption.stringSet(input.multipleReferences, 'peek', ['peek', 'gotoAndPeek', 'goto']),
  55464. alternativeDefinitionCommand: EditorStringOption.string(input.alternativeDefinitionCommand, this.defaultValue.alternativeDefinitionCommand),
  55465. alternativeTypeDefinitionCommand: EditorStringOption.string(input.alternativeTypeDefinitionCommand, this.defaultValue.alternativeTypeDefinitionCommand),
  55466. alternativeDeclarationCommand: EditorStringOption.string(input.alternativeDeclarationCommand, this.defaultValue.alternativeDeclarationCommand),
  55467. alternativeImplementationCommand: EditorStringOption.string(input.alternativeImplementationCommand, this.defaultValue.alternativeImplementationCommand),
  55468. alternativeReferenceCommand: EditorStringOption.string(input.alternativeReferenceCommand, this.defaultValue.alternativeReferenceCommand),
  55469. };
  55470. };
  55471. return EditorGoToLocation;
  55472. }(BaseEditorOption));
  55473. var EditorHover = /** @class */ (function (_super) {
  55474. __extends(EditorHover, _super);
  55475. function EditorHover() {
  55476. var _this = this;
  55477. var defaults = {
  55478. enabled: true,
  55479. delay: 300,
  55480. sticky: true
  55481. };
  55482. _this = _super.call(this, 44 /* hover */, 'hover', defaults, {
  55483. 'editor.hover.enabled': {
  55484. type: 'boolean',
  55485. default: defaults.enabled,
  55486. description: nls.localize(31, null)
  55487. },
  55488. 'editor.hover.delay': {
  55489. type: 'number',
  55490. default: defaults.delay,
  55491. description: nls.localize(32, null)
  55492. },
  55493. 'editor.hover.sticky': {
  55494. type: 'boolean',
  55495. default: defaults.sticky,
  55496. description: nls.localize(33, null)
  55497. },
  55498. }) || this;
  55499. return _this;
  55500. }
  55501. EditorHover.prototype.validate = function (_input) {
  55502. if (typeof _input !== 'object') {
  55503. return this.defaultValue;
  55504. }
  55505. var input = _input;
  55506. return {
  55507. enabled: EditorBooleanOption.boolean(input.enabled, this.defaultValue.enabled),
  55508. delay: EditorIntOption.clampedInt(input.delay, this.defaultValue.delay, 0, 10000),
  55509. sticky: EditorBooleanOption.boolean(input.sticky, this.defaultValue.sticky)
  55510. };
  55511. };
  55512. return EditorHover;
  55513. }(BaseEditorOption));
  55514. /**
  55515. * @internal
  55516. */
  55517. var EditorLayoutInfoComputer = /** @class */ (function (_super) {
  55518. __extends(EditorLayoutInfoComputer, _super);
  55519. function EditorLayoutInfoComputer() {
  55520. return _super.call(this, 107 /* layoutInfo */, [40 /* glyphMargin */, 48 /* lineDecorationsWidth */, 30 /* folding */, 54 /* minimap */, 78 /* scrollbar */, 50 /* lineNumbers */]) || this;
  55521. }
  55522. EditorLayoutInfoComputer.prototype.compute = function (env, options, _) {
  55523. return EditorLayoutInfoComputer.computeLayout(options, {
  55524. outerWidth: env.outerWidth,
  55525. outerHeight: env.outerHeight,
  55526. lineHeight: env.fontInfo.lineHeight,
  55527. lineNumbersDigitCount: env.lineNumbersDigitCount,
  55528. typicalHalfwidthCharacterWidth: env.fontInfo.typicalHalfwidthCharacterWidth,
  55529. maxDigitWidth: env.fontInfo.maxDigitWidth,
  55530. pixelRatio: env.pixelRatio
  55531. });
  55532. };
  55533. EditorLayoutInfoComputer.computeLayout = function (options, env) {
  55534. var outerWidth = env.outerWidth | 0;
  55535. var outerHeight = env.outerHeight | 0;
  55536. var lineHeight = env.lineHeight | 0;
  55537. var lineNumbersDigitCount = env.lineNumbersDigitCount | 0;
  55538. var typicalHalfwidthCharacterWidth = env.typicalHalfwidthCharacterWidth;
  55539. var maxDigitWidth = env.maxDigitWidth;
  55540. var pixelRatio = env.pixelRatio;
  55541. var showGlyphMargin = options.get(40 /* glyphMargin */);
  55542. var showLineNumbers = (options.get(50 /* lineNumbers */).renderType !== 0 /* Off */);
  55543. var lineNumbersMinChars = options.get(51 /* lineNumbersMinChars */) | 0;
  55544. var minimap = options.get(54 /* minimap */);
  55545. var minimapEnabled = minimap.enabled;
  55546. var minimapSide = minimap.side;
  55547. var minimapRenderCharacters = minimap.renderCharacters;
  55548. var minimapScale = (pixelRatio >= 2 ? Math.round(minimap.scale * 2) : minimap.scale);
  55549. var minimapMaxColumn = minimap.maxColumn | 0;
  55550. var scrollbar = options.get(78 /* scrollbar */);
  55551. var verticalScrollbarWidth = scrollbar.verticalScrollbarSize | 0;
  55552. var verticalScrollbarHasArrows = scrollbar.verticalHasArrows;
  55553. var scrollbarArrowSize = scrollbar.arrowSize | 0;
  55554. var horizontalScrollbarHeight = scrollbar.horizontalScrollbarSize | 0;
  55555. var rawLineDecorationsWidth = options.get(48 /* lineDecorationsWidth */);
  55556. var folding = options.get(30 /* folding */);
  55557. var lineDecorationsWidth;
  55558. if (typeof rawLineDecorationsWidth === 'string' && /^\d+(\.\d+)?ch$/.test(rawLineDecorationsWidth)) {
  55559. var multiple = parseFloat(rawLineDecorationsWidth.substr(0, rawLineDecorationsWidth.length - 2));
  55560. lineDecorationsWidth = EditorIntOption.clampedInt(multiple * typicalHalfwidthCharacterWidth, 0, 0, 1000);
  55561. }
  55562. else {
  55563. lineDecorationsWidth = EditorIntOption.clampedInt(rawLineDecorationsWidth, 0, 0, 1000);
  55564. }
  55565. if (folding) {
  55566. lineDecorationsWidth += 16;
  55567. }
  55568. var lineNumbersWidth = 0;
  55569. if (showLineNumbers) {
  55570. var digitCount = Math.max(lineNumbersDigitCount, lineNumbersMinChars);
  55571. lineNumbersWidth = Math.round(digitCount * maxDigitWidth);
  55572. }
  55573. var glyphMarginWidth = 0;
  55574. if (showGlyphMargin) {
  55575. glyphMarginWidth = lineHeight;
  55576. }
  55577. var glyphMarginLeft = 0;
  55578. var lineNumbersLeft = glyphMarginLeft + glyphMarginWidth;
  55579. var decorationsLeft = lineNumbersLeft + lineNumbersWidth;
  55580. var contentLeft = decorationsLeft + lineDecorationsWidth;
  55581. var remainingWidth = outerWidth - glyphMarginWidth - lineNumbersWidth - lineDecorationsWidth;
  55582. var renderMinimap;
  55583. var minimapLeft;
  55584. var minimapWidth;
  55585. var contentWidth;
  55586. if (!minimapEnabled) {
  55587. minimapLeft = 0;
  55588. minimapWidth = 0;
  55589. renderMinimap = 0 /* None */;
  55590. contentWidth = remainingWidth;
  55591. }
  55592. else {
  55593. // The minimapScale is also the pixel width of each character. Adjust
  55594. // for the pixel ratio of the screen.
  55595. var minimapCharWidth = minimapScale / pixelRatio;
  55596. renderMinimap = minimapRenderCharacters ? 1 /* Text */ : 2 /* Blocks */;
  55597. // Given:
  55598. // (leaving 2px for the cursor to have space after the last character)
  55599. // viewportColumn = (contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth
  55600. // minimapWidth = viewportColumn * minimapCharWidth
  55601. // contentWidth = remainingWidth - minimapWidth
  55602. // What are good values for contentWidth and minimapWidth ?
  55603. // minimapWidth = ((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth) * minimapCharWidth
  55604. // typicalHalfwidthCharacterWidth * minimapWidth = (contentWidth - verticalScrollbarWidth - 2) * minimapCharWidth
  55605. // typicalHalfwidthCharacterWidth * minimapWidth = (remainingWidth - minimapWidth - verticalScrollbarWidth - 2) * minimapCharWidth
  55606. // (typicalHalfwidthCharacterWidth + minimapCharWidth) * minimapWidth = (remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth
  55607. // minimapWidth = ((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth)
  55608. minimapWidth = Math.max(0, Math.floor(((remainingWidth - verticalScrollbarWidth - 2) * minimapCharWidth) / (typicalHalfwidthCharacterWidth + minimapCharWidth))) + exports.MINIMAP_GUTTER_WIDTH;
  55609. var minimapColumns = minimapWidth / minimapCharWidth;
  55610. if (minimapColumns > minimapMaxColumn) {
  55611. minimapWidth = Math.floor(minimapMaxColumn * minimapCharWidth);
  55612. }
  55613. contentWidth = remainingWidth - minimapWidth;
  55614. if (minimapSide === 'left') {
  55615. minimapLeft = 0;
  55616. glyphMarginLeft += minimapWidth;
  55617. lineNumbersLeft += minimapWidth;
  55618. decorationsLeft += minimapWidth;
  55619. contentLeft += minimapWidth;
  55620. }
  55621. else {
  55622. minimapLeft = outerWidth - minimapWidth - verticalScrollbarWidth;
  55623. }
  55624. }
  55625. // (leaving 2px for the cursor to have space after the last character)
  55626. var viewportColumn = Math.max(1, Math.floor((contentWidth - verticalScrollbarWidth - 2) / typicalHalfwidthCharacterWidth));
  55627. var verticalArrowSize = (verticalScrollbarHasArrows ? scrollbarArrowSize : 0);
  55628. return {
  55629. width: outerWidth,
  55630. height: outerHeight,
  55631. glyphMarginLeft: glyphMarginLeft,
  55632. glyphMarginWidth: glyphMarginWidth,
  55633. lineNumbersLeft: lineNumbersLeft,
  55634. lineNumbersWidth: lineNumbersWidth,
  55635. decorationsLeft: decorationsLeft,
  55636. decorationsWidth: lineDecorationsWidth,
  55637. contentLeft: contentLeft,
  55638. contentWidth: contentWidth,
  55639. renderMinimap: renderMinimap,
  55640. minimapLeft: minimapLeft,
  55641. minimapWidth: minimapWidth,
  55642. viewportColumn: viewportColumn,
  55643. verticalScrollbarWidth: verticalScrollbarWidth,
  55644. horizontalScrollbarHeight: horizontalScrollbarHeight,
  55645. overviewRuler: {
  55646. top: verticalArrowSize,
  55647. width: verticalScrollbarWidth,
  55648. height: (outerHeight - 2 * verticalArrowSize),
  55649. right: 0
  55650. }
  55651. };
  55652. };
  55653. return EditorLayoutInfoComputer;
  55654. }(ComputedEditorOption));
  55655. exports.EditorLayoutInfoComputer = EditorLayoutInfoComputer;
  55656. var EditorLightbulb = /** @class */ (function (_super) {
  55657. __extends(EditorLightbulb, _super);
  55658. function EditorLightbulb() {
  55659. var _this = this;
  55660. var defaults = { enabled: true };
  55661. _this = _super.call(this, 47 /* lightbulb */, 'lightbulb', defaults, {
  55662. 'editor.lightbulb.enabled': {
  55663. type: 'boolean',
  55664. default: defaults.enabled,
  55665. description: nls.localize(34, null)
  55666. },
  55667. }) || this;
  55668. return _this;
  55669. }
  55670. EditorLightbulb.prototype.validate = function (_input) {
  55671. if (typeof _input !== 'object') {
  55672. return this.defaultValue;
  55673. }
  55674. var input = _input;
  55675. return {
  55676. enabled: EditorBooleanOption.boolean(input.enabled, this.defaultValue.enabled)
  55677. };
  55678. };
  55679. return EditorLightbulb;
  55680. }(BaseEditorOption));
  55681. //#endregion
  55682. //#region lineHeight
  55683. var EditorLineHeight = /** @class */ (function (_super) {
  55684. __extends(EditorLineHeight, _super);
  55685. function EditorLineHeight() {
  55686. return _super.call(this, 49 /* lineHeight */, 'lineHeight', exports.EDITOR_FONT_DEFAULTS.lineHeight, 0, 150, { description: nls.localize(35, null) }) || this;
  55687. }
  55688. EditorLineHeight.prototype.compute = function (env, options, value) {
  55689. // The lineHeight is computed from the fontSize if it is 0.
  55690. // Moreover, the final lineHeight respects the editor zoom level.
  55691. // So take the result from env.fontInfo
  55692. return env.fontInfo.lineHeight;
  55693. };
  55694. return EditorLineHeight;
  55695. }(EditorIntOption));
  55696. var EditorMinimap = /** @class */ (function (_super) {
  55697. __extends(EditorMinimap, _super);
  55698. function EditorMinimap() {
  55699. var _this = this;
  55700. var defaults = {
  55701. enabled: true,
  55702. side: 'right',
  55703. showSlider: 'mouseover',
  55704. renderCharacters: true,
  55705. maxColumn: 120,
  55706. scale: 1,
  55707. };
  55708. _this = _super.call(this, 54 /* minimap */, 'minimap', defaults, {
  55709. 'editor.minimap.enabled': {
  55710. type: 'boolean',
  55711. default: defaults.enabled,
  55712. description: nls.localize(36, null)
  55713. },
  55714. 'editor.minimap.side': {
  55715. type: 'string',
  55716. enum: ['left', 'right'],
  55717. default: defaults.side,
  55718. description: nls.localize(37, null)
  55719. },
  55720. 'editor.minimap.showSlider': {
  55721. type: 'string',
  55722. enum: ['always', 'mouseover'],
  55723. default: defaults.showSlider,
  55724. description: nls.localize(38, null)
  55725. },
  55726. 'editor.minimap.scale': {
  55727. type: 'number',
  55728. default: defaults.scale,
  55729. minimum: 1,
  55730. maximum: 3,
  55731. description: nls.localize(39, null)
  55732. },
  55733. 'editor.minimap.renderCharacters': {
  55734. type: 'boolean',
  55735. default: defaults.renderCharacters,
  55736. description: nls.localize(40, null)
  55737. },
  55738. 'editor.minimap.maxColumn': {
  55739. type: 'number',
  55740. default: defaults.maxColumn,
  55741. description: nls.localize(41, null)
  55742. },
  55743. }) || this;
  55744. return _this;
  55745. }
  55746. EditorMinimap.prototype.validate = function (_input) {
  55747. if (typeof _input !== 'object') {
  55748. return this.defaultValue;
  55749. }
  55750. var input = _input;
  55751. return {
  55752. enabled: EditorBooleanOption.boolean(input.enabled, this.defaultValue.enabled),
  55753. side: EditorStringEnumOption.stringSet(input.side, this.defaultValue.side, ['right', 'left']),
  55754. showSlider: EditorStringEnumOption.stringSet(input.showSlider, this.defaultValue.showSlider, ['always', 'mouseover']),
  55755. renderCharacters: EditorBooleanOption.boolean(input.renderCharacters, this.defaultValue.renderCharacters),
  55756. scale: EditorIntOption.clampedInt(input.scale, 1, 1, 3),
  55757. maxColumn: EditorIntOption.clampedInt(input.maxColumn, this.defaultValue.maxColumn, 1, 10000),
  55758. };
  55759. };
  55760. return EditorMinimap;
  55761. }(BaseEditorOption));
  55762. //#endregion
  55763. //#region multiCursorModifier
  55764. function _multiCursorModifierFromString(multiCursorModifier) {
  55765. if (multiCursorModifier === 'ctrlCmd') {
  55766. return (platform.isMacintosh ? 'metaKey' : 'ctrlKey');
  55767. }
  55768. return 'altKey';
  55769. }
  55770. var EditorParameterHints = /** @class */ (function (_super) {
  55771. __extends(EditorParameterHints, _super);
  55772. function EditorParameterHints() {
  55773. var _this = this;
  55774. var defaults = {
  55775. enabled: true,
  55776. cycle: false
  55777. };
  55778. _this = _super.call(this, 64 /* parameterHints */, 'parameterHints', defaults, {
  55779. 'editor.parameterHints.enabled': {
  55780. type: 'boolean',
  55781. default: defaults.enabled,
  55782. description: nls.localize(42, null)
  55783. },
  55784. 'editor.parameterHints.cycle': {
  55785. type: 'boolean',
  55786. default: defaults.cycle,
  55787. description: nls.localize(43, null)
  55788. },
  55789. }) || this;
  55790. return _this;
  55791. }
  55792. EditorParameterHints.prototype.validate = function (_input) {
  55793. if (typeof _input !== 'object') {
  55794. return this.defaultValue;
  55795. }
  55796. var input = _input;
  55797. return {
  55798. enabled: EditorBooleanOption.boolean(input.enabled, this.defaultValue.enabled),
  55799. cycle: EditorBooleanOption.boolean(input.cycle, this.defaultValue.cycle)
  55800. };
  55801. };
  55802. return EditorParameterHints;
  55803. }(BaseEditorOption));
  55804. //#endregion
  55805. //#region pixelRatio
  55806. var EditorPixelRatio = /** @class */ (function (_super) {
  55807. __extends(EditorPixelRatio, _super);
  55808. function EditorPixelRatio() {
  55809. return _super.call(this, 105 /* pixelRatio */) || this;
  55810. }
  55811. EditorPixelRatio.prototype.compute = function (env, options, _) {
  55812. return env.pixelRatio;
  55813. };
  55814. return EditorPixelRatio;
  55815. }(ComputedEditorOption));
  55816. var EditorQuickSuggestions = /** @class */ (function (_super) {
  55817. __extends(EditorQuickSuggestions, _super);
  55818. function EditorQuickSuggestions() {
  55819. var _this = this;
  55820. var defaults = {
  55821. other: true,
  55822. comments: false,
  55823. strings: false
  55824. };
  55825. _this = _super.call(this, 66 /* quickSuggestions */, 'quickSuggestions', defaults, {
  55826. anyOf: [
  55827. {
  55828. type: 'boolean',
  55829. },
  55830. {
  55831. type: 'object',
  55832. properties: {
  55833. strings: {
  55834. type: 'boolean',
  55835. default: defaults.strings,
  55836. description: nls.localize(44, null)
  55837. },
  55838. comments: {
  55839. type: 'boolean',
  55840. default: defaults.comments,
  55841. description: nls.localize(45, null)
  55842. },
  55843. other: {
  55844. type: 'boolean',
  55845. default: defaults.other,
  55846. description: nls.localize(46, null)
  55847. },
  55848. }
  55849. }
  55850. ],
  55851. default: defaults,
  55852. description: nls.localize(47, null)
  55853. }) || this;
  55854. _this.defaultValue = defaults;
  55855. return _this;
  55856. }
  55857. EditorQuickSuggestions.prototype.validate = function (_input) {
  55858. if (typeof _input === 'boolean') {
  55859. return _input;
  55860. }
  55861. if (typeof _input === 'object') {
  55862. var input = _input;
  55863. var opts = {
  55864. other: EditorBooleanOption.boolean(input.other, this.defaultValue.other),
  55865. comments: EditorBooleanOption.boolean(input.comments, this.defaultValue.comments),
  55866. strings: EditorBooleanOption.boolean(input.strings, this.defaultValue.strings),
  55867. };
  55868. if (opts.other && opts.comments && opts.strings) {
  55869. return true; // all on
  55870. }
  55871. else if (!opts.other && !opts.comments && !opts.strings) {
  55872. return false; // all off
  55873. }
  55874. else {
  55875. return opts;
  55876. }
  55877. }
  55878. return this.defaultValue;
  55879. };
  55880. return EditorQuickSuggestions;
  55881. }(BaseEditorOption));
  55882. var EditorRenderLineNumbersOption = /** @class */ (function (_super) {
  55883. __extends(EditorRenderLineNumbersOption, _super);
  55884. function EditorRenderLineNumbersOption() {
  55885. return _super.call(this, 50 /* lineNumbers */, 'lineNumbers', { renderType: 1 /* On */, renderFn: null }, {
  55886. type: 'string',
  55887. enum: ['off', 'on', 'relative', 'interval'],
  55888. enumDescriptions: [
  55889. nls.localize(48, null),
  55890. nls.localize(49, null),
  55891. nls.localize(50, null),
  55892. nls.localize(51, null)
  55893. ],
  55894. default: 'on',
  55895. description: nls.localize(52, null)
  55896. }) || this;
  55897. }
  55898. EditorRenderLineNumbersOption.prototype.validate = function (lineNumbers) {
  55899. var renderType = this.defaultValue.renderType;
  55900. var renderFn = this.defaultValue.renderFn;
  55901. if (typeof lineNumbers !== 'undefined') {
  55902. if (typeof lineNumbers === 'function') {
  55903. renderType = 4 /* Custom */;
  55904. renderFn = lineNumbers;
  55905. }
  55906. else if (lineNumbers === 'interval') {
  55907. renderType = 3 /* Interval */;
  55908. }
  55909. else if (lineNumbers === 'relative') {
  55910. renderType = 2 /* Relative */;
  55911. }
  55912. else if (lineNumbers === 'on') {
  55913. renderType = 1 /* On */;
  55914. }
  55915. else {
  55916. renderType = 0 /* Off */;
  55917. }
  55918. }
  55919. return {
  55920. renderType: renderType,
  55921. renderFn: renderFn
  55922. };
  55923. };
  55924. return EditorRenderLineNumbersOption;
  55925. }(BaseEditorOption));
  55926. //#endregion
  55927. //#region renderValidationDecorations
  55928. /**
  55929. * @internal
  55930. */
  55931. function filterValidationDecorations(options) {
  55932. var renderValidationDecorations = options.get(73 /* renderValidationDecorations */);
  55933. if (renderValidationDecorations === 'editable') {
  55934. return options.get(68 /* readOnly */);
  55935. }
  55936. return renderValidationDecorations === 'on' ? false : true;
  55937. }
  55938. exports.filterValidationDecorations = filterValidationDecorations;
  55939. //#endregion
  55940. //#region rulers
  55941. var EditorRulers = /** @class */ (function (_super) {
  55942. __extends(EditorRulers, _super);
  55943. function EditorRulers() {
  55944. var _this = this;
  55945. var defaults = [];
  55946. _this = _super.call(this, 77 /* rulers */, 'rulers', defaults, {
  55947. type: 'array',
  55948. items: {
  55949. type: 'number'
  55950. },
  55951. default: defaults,
  55952. description: nls.localize(53, null)
  55953. }) || this;
  55954. return _this;
  55955. }
  55956. EditorRulers.prototype.validate = function (input) {
  55957. if (Array.isArray(input)) {
  55958. var rulers = [];
  55959. for (var _i = 0, input_1 = input; _i < input_1.length; _i++) {
  55960. var value = input_1[_i];
  55961. rulers.push(EditorIntOption.clampedInt(value, 0, 0, 10000));
  55962. }
  55963. rulers.sort(function (a, b) { return a - b; });
  55964. return rulers;
  55965. }
  55966. return this.defaultValue;
  55967. };
  55968. return EditorRulers;
  55969. }(SimpleEditorOption));
  55970. function _scrollbarVisibilityFromString(visibility, defaultValue) {
  55971. if (typeof visibility !== 'string') {
  55972. return defaultValue;
  55973. }
  55974. switch (visibility) {
  55975. case 'hidden': return 2 /* Hidden */;
  55976. case 'visible': return 3 /* Visible */;
  55977. default: return 1 /* Auto */;
  55978. }
  55979. }
  55980. var EditorScrollbar = /** @class */ (function (_super) {
  55981. __extends(EditorScrollbar, _super);
  55982. function EditorScrollbar() {
  55983. return _super.call(this, 78 /* scrollbar */, 'scrollbar', {
  55984. vertical: 1 /* Auto */,
  55985. horizontal: 1 /* Auto */,
  55986. arrowSize: 11,
  55987. useShadows: true,
  55988. verticalHasArrows: false,
  55989. horizontalHasArrows: false,
  55990. horizontalScrollbarSize: 10,
  55991. horizontalSliderSize: 10,
  55992. verticalScrollbarSize: 14,
  55993. verticalSliderSize: 14,
  55994. handleMouseWheel: true,
  55995. alwaysConsumeMouseWheel: true
  55996. }) || this;
  55997. }
  55998. EditorScrollbar.prototype.validate = function (_input) {
  55999. if (typeof _input !== 'object') {
  56000. return this.defaultValue;
  56001. }
  56002. var input = _input;
  56003. var horizontalScrollbarSize = EditorIntOption.clampedInt(input.horizontalScrollbarSize, this.defaultValue.horizontalScrollbarSize, 0, 1000);
  56004. var verticalScrollbarSize = EditorIntOption.clampedInt(input.verticalScrollbarSize, this.defaultValue.verticalScrollbarSize, 0, 1000);
  56005. return {
  56006. arrowSize: EditorIntOption.clampedInt(input.arrowSize, this.defaultValue.arrowSize, 0, 1000),
  56007. vertical: _scrollbarVisibilityFromString(input.vertical, this.defaultValue.vertical),
  56008. horizontal: _scrollbarVisibilityFromString(input.horizontal, this.defaultValue.horizontal),
  56009. useShadows: EditorBooleanOption.boolean(input.useShadows, this.defaultValue.useShadows),
  56010. verticalHasArrows: EditorBooleanOption.boolean(input.verticalHasArrows, this.defaultValue.verticalHasArrows),
  56011. horizontalHasArrows: EditorBooleanOption.boolean(input.horizontalHasArrows, this.defaultValue.horizontalHasArrows),
  56012. handleMouseWheel: EditorBooleanOption.boolean(input.handleMouseWheel, this.defaultValue.handleMouseWheel),
  56013. alwaysConsumeMouseWheel: EditorBooleanOption.boolean(input.alwaysConsumeMouseWheel, this.defaultValue.alwaysConsumeMouseWheel),
  56014. horizontalScrollbarSize: horizontalScrollbarSize,
  56015. horizontalSliderSize: EditorIntOption.clampedInt(input.horizontalSliderSize, horizontalScrollbarSize, 0, 1000),
  56016. verticalScrollbarSize: verticalScrollbarSize,
  56017. verticalSliderSize: EditorIntOption.clampedInt(input.verticalSliderSize, verticalScrollbarSize, 0, 1000),
  56018. };
  56019. };
  56020. return EditorScrollbar;
  56021. }(BaseEditorOption));
  56022. var EditorSuggest = /** @class */ (function (_super) {
  56023. __extends(EditorSuggest, _super);
  56024. function EditorSuggest() {
  56025. var _this = this;
  56026. var defaults = {
  56027. insertMode: 'insert',
  56028. insertHighlight: false,
  56029. filterGraceful: true,
  56030. snippetsPreventQuickSuggestions: true,
  56031. localityBonus: false,
  56032. shareSuggestSelections: false,
  56033. showIcons: true,
  56034. maxVisibleSuggestions: 12,
  56035. showMethods: true,
  56036. showFunctions: true,
  56037. showConstructors: true,
  56038. showFields: true,
  56039. showVariables: true,
  56040. showClasses: true,
  56041. showStructs: true,
  56042. showInterfaces: true,
  56043. showModules: true,
  56044. showProperties: true,
  56045. showEvents: true,
  56046. showOperators: true,
  56047. showUnits: true,
  56048. showValues: true,
  56049. showConstants: true,
  56050. showEnums: true,
  56051. showEnumMembers: true,
  56052. showKeywords: true,
  56053. showWords: true,
  56054. showColors: true,
  56055. showFiles: true,
  56056. showReferences: true,
  56057. showFolders: true,
  56058. showTypeParameters: true,
  56059. showSnippets: true,
  56060. hideStatusBar: true
  56061. };
  56062. _this = _super.call(this, 89 /* suggest */, 'suggest', defaults, {
  56063. 'editor.suggest.insertMode': {
  56064. type: 'string',
  56065. enum: ['insert', 'replace'],
  56066. enumDescriptions: [
  56067. nls.localize(54, null),
  56068. nls.localize(55, null),
  56069. ],
  56070. default: defaults.insertMode,
  56071. description: nls.localize(56, null)
  56072. },
  56073. 'editor.suggest.insertHighlight': {
  56074. type: 'boolean',
  56075. default: defaults.insertHighlight,
  56076. description: nls.localize(57, null)
  56077. },
  56078. 'editor.suggest.filterGraceful': {
  56079. type: 'boolean',
  56080. default: defaults.filterGraceful,
  56081. description: nls.localize(58, null)
  56082. },
  56083. 'editor.suggest.localityBonus': {
  56084. type: 'boolean',
  56085. default: defaults.localityBonus,
  56086. description: nls.localize(59, null)
  56087. },
  56088. 'editor.suggest.shareSuggestSelections': {
  56089. type: 'boolean',
  56090. default: defaults.shareSuggestSelections,
  56091. markdownDescription: nls.localize(60, null)
  56092. },
  56093. 'editor.suggest.snippetsPreventQuickSuggestions': {
  56094. type: 'boolean',
  56095. default: defaults.snippetsPreventQuickSuggestions,
  56096. description: nls.localize(61, null)
  56097. },
  56098. 'editor.suggest.showIcons': {
  56099. type: 'boolean',
  56100. default: defaults.showIcons,
  56101. description: nls.localize(62, null)
  56102. },
  56103. 'editor.suggest.maxVisibleSuggestions': {
  56104. type: 'number',
  56105. default: defaults.maxVisibleSuggestions,
  56106. minimum: 1,
  56107. maximum: 15,
  56108. description: nls.localize(63, null)
  56109. },
  56110. 'editor.suggest.filteredTypes': {
  56111. type: 'object',
  56112. deprecationMessage: nls.localize(64, null)
  56113. },
  56114. 'editor.suggest.showMethods': {
  56115. type: 'boolean',
  56116. default: true,
  56117. markdownDescription: nls.localize(65, null)
  56118. },
  56119. 'editor.suggest.showFunctions': {
  56120. type: 'boolean',
  56121. default: true,
  56122. markdownDescription: nls.localize(66, null)
  56123. },
  56124. 'editor.suggest.showConstructors': {
  56125. type: 'boolean',
  56126. default: true,
  56127. markdownDescription: nls.localize(67, null)
  56128. },
  56129. 'editor.suggest.showFields': {
  56130. type: 'boolean',
  56131. default: true,
  56132. markdownDescription: nls.localize(68, null)
  56133. },
  56134. 'editor.suggest.showVariables': {
  56135. type: 'boolean',
  56136. default: true,
  56137. markdownDescription: nls.localize(69, null)
  56138. },
  56139. 'editor.suggest.showClasses': {
  56140. type: 'boolean',
  56141. default: true,
  56142. markdownDescription: nls.localize(70, null)
  56143. },
  56144. 'editor.suggest.showStructs': {
  56145. type: 'boolean',
  56146. default: true,
  56147. markdownDescription: nls.localize(71, null)
  56148. },
  56149. 'editor.suggest.showInterfaces': {
  56150. type: 'boolean',
  56151. default: true,
  56152. markdownDescription: nls.localize(72, null)
  56153. },
  56154. 'editor.suggest.showModules': {
  56155. type: 'boolean',
  56156. default: true,
  56157. markdownDescription: nls.localize(73, null)
  56158. },
  56159. 'editor.suggest.showProperties': {
  56160. type: 'boolean',
  56161. default: true,
  56162. markdownDescription: nls.localize(74, null)
  56163. },
  56164. 'editor.suggest.showEvents': {
  56165. type: 'boolean',
  56166. default: true,
  56167. markdownDescription: nls.localize(75, null)
  56168. },
  56169. 'editor.suggest.showOperators': {
  56170. type: 'boolean',
  56171. default: true,
  56172. markdownDescription: nls.localize(76, null)
  56173. },
  56174. 'editor.suggest.showUnits': {
  56175. type: 'boolean',
  56176. default: true,
  56177. markdownDescription: nls.localize(77, null)
  56178. },
  56179. 'editor.suggest.showValues': {
  56180. type: 'boolean',
  56181. default: true,
  56182. markdownDescription: nls.localize(78, null)
  56183. },
  56184. 'editor.suggest.showConstants': {
  56185. type: 'boolean',
  56186. default: true,
  56187. markdownDescription: nls.localize(79, null)
  56188. },
  56189. 'editor.suggest.showEnums': {
  56190. type: 'boolean',
  56191. default: true,
  56192. markdownDescription: nls.localize(80, null)
  56193. },
  56194. 'editor.suggest.showEnumMembers': {
  56195. type: 'boolean',
  56196. default: true,
  56197. markdownDescription: nls.localize(81, null)
  56198. },
  56199. 'editor.suggest.showKeywords': {
  56200. type: 'boolean',
  56201. default: true,
  56202. markdownDescription: nls.localize(82, null)
  56203. },
  56204. 'editor.suggest.showWords': {
  56205. type: 'boolean',
  56206. default: true,
  56207. markdownDescription: nls.localize(83, null)
  56208. },
  56209. 'editor.suggest.showColors': {
  56210. type: 'boolean',
  56211. default: true,
  56212. markdownDescription: nls.localize(84, null)
  56213. },
  56214. 'editor.suggest.showFiles': {
  56215. type: 'boolean',
  56216. default: true,
  56217. markdownDescription: nls.localize(85, null)
  56218. },
  56219. 'editor.suggest.showReferences': {
  56220. type: 'boolean',
  56221. default: true,
  56222. markdownDescription: nls.localize(86, null)
  56223. },
  56224. 'editor.suggest.showCustomcolors': {
  56225. type: 'boolean',
  56226. default: true,
  56227. markdownDescription: nls.localize(87, null)
  56228. },
  56229. 'editor.suggest.showFolders': {
  56230. type: 'boolean',
  56231. default: true,
  56232. markdownDescription: nls.localize(88, null)
  56233. },
  56234. 'editor.suggest.showTypeParameters': {
  56235. type: 'boolean',
  56236. default: true,
  56237. markdownDescription: nls.localize(89, null)
  56238. },
  56239. 'editor.suggest.showSnippets': {
  56240. type: 'boolean',
  56241. default: true,
  56242. markdownDescription: nls.localize(90, null)
  56243. },
  56244. 'editor.suggest.hideStatusBar': {
  56245. type: 'boolean',
  56246. default: true,
  56247. markdownDescription: nls.localize(91, null)
  56248. }
  56249. }) || this;
  56250. return _this;
  56251. }
  56252. EditorSuggest.prototype.validate = function (_input) {
  56253. if (typeof _input !== 'object') {
  56254. return this.defaultValue;
  56255. }
  56256. var input = _input;
  56257. return {
  56258. insertMode: EditorStringEnumOption.stringSet(input.insertMode, this.defaultValue.insertMode, ['insert', 'replace']),
  56259. insertHighlight: EditorBooleanOption.boolean(input.insertHighlight, this.defaultValue.insertHighlight),
  56260. filterGraceful: EditorBooleanOption.boolean(input.filterGraceful, this.defaultValue.filterGraceful),
  56261. snippetsPreventQuickSuggestions: EditorBooleanOption.boolean(input.snippetsPreventQuickSuggestions, this.defaultValue.filterGraceful),
  56262. localityBonus: EditorBooleanOption.boolean(input.localityBonus, this.defaultValue.localityBonus),
  56263. shareSuggestSelections: EditorBooleanOption.boolean(input.shareSuggestSelections, this.defaultValue.shareSuggestSelections),
  56264. showIcons: EditorBooleanOption.boolean(input.showIcons, this.defaultValue.showIcons),
  56265. maxVisibleSuggestions: EditorIntOption.clampedInt(input.maxVisibleSuggestions, this.defaultValue.maxVisibleSuggestions, 1, 15),
  56266. showMethods: EditorBooleanOption.boolean(input.showMethods, this.defaultValue.showMethods),
  56267. showFunctions: EditorBooleanOption.boolean(input.showFunctions, this.defaultValue.showFunctions),
  56268. showConstructors: EditorBooleanOption.boolean(input.showConstructors, this.defaultValue.showConstructors),
  56269. showFields: EditorBooleanOption.boolean(input.showFields, this.defaultValue.showFields),
  56270. showVariables: EditorBooleanOption.boolean(input.showVariables, this.defaultValue.showVariables),
  56271. showClasses: EditorBooleanOption.boolean(input.showClasses, this.defaultValue.showClasses),
  56272. showStructs: EditorBooleanOption.boolean(input.showStructs, this.defaultValue.showStructs),
  56273. showInterfaces: EditorBooleanOption.boolean(input.showInterfaces, this.defaultValue.showInterfaces),
  56274. showModules: EditorBooleanOption.boolean(input.showModules, this.defaultValue.showModules),
  56275. showProperties: EditorBooleanOption.boolean(input.showProperties, this.defaultValue.showProperties),
  56276. showEvents: EditorBooleanOption.boolean(input.showEvents, this.defaultValue.showEvents),
  56277. showOperators: EditorBooleanOption.boolean(input.showOperators, this.defaultValue.showOperators),
  56278. showUnits: EditorBooleanOption.boolean(input.showUnits, this.defaultValue.showUnits),
  56279. showValues: EditorBooleanOption.boolean(input.showValues, this.defaultValue.showValues),
  56280. showConstants: EditorBooleanOption.boolean(input.showConstants, this.defaultValue.showConstants),
  56281. showEnums: EditorBooleanOption.boolean(input.showEnums, this.defaultValue.showEnums),
  56282. showEnumMembers: EditorBooleanOption.boolean(input.showEnumMembers, this.defaultValue.showEnumMembers),
  56283. showKeywords: EditorBooleanOption.boolean(input.showKeywords, this.defaultValue.showKeywords),
  56284. showWords: EditorBooleanOption.boolean(input.showWords, this.defaultValue.showWords),
  56285. showColors: EditorBooleanOption.boolean(input.showColors, this.defaultValue.showColors),
  56286. showFiles: EditorBooleanOption.boolean(input.showFiles, this.defaultValue.showFiles),
  56287. showReferences: EditorBooleanOption.boolean(input.showReferences, this.defaultValue.showReferences),
  56288. showFolders: EditorBooleanOption.boolean(input.showFolders, this.defaultValue.showFolders),
  56289. showTypeParameters: EditorBooleanOption.boolean(input.showTypeParameters, this.defaultValue.showTypeParameters),
  56290. showSnippets: EditorBooleanOption.boolean(input.showSnippets, this.defaultValue.showSnippets),
  56291. hideStatusBar: EditorBooleanOption.boolean(input.hideStatusBar, this.defaultValue.hideStatusBar),
  56292. };
  56293. };
  56294. return EditorSuggest;
  56295. }(BaseEditorOption));
  56296. //#endregion
  56297. //#region tabFocusMode
  56298. var EditorTabFocusMode = /** @class */ (function (_super) {
  56299. __extends(EditorTabFocusMode, _super);
  56300. function EditorTabFocusMode() {
  56301. return _super.call(this, 106 /* tabFocusMode */, [68 /* readOnly */]) || this;
  56302. }
  56303. EditorTabFocusMode.prototype.compute = function (env, options, _) {
  56304. var readOnly = options.get(68 /* readOnly */);
  56305. return (readOnly ? true : env.tabFocusMode);
  56306. };
  56307. return EditorTabFocusMode;
  56308. }(ComputedEditorOption));
  56309. function _wrappingIndentFromString(wrappingIndent) {
  56310. switch (wrappingIndent) {
  56311. case 'none': return 0 /* None */;
  56312. case 'same': return 1 /* Same */;
  56313. case 'indent': return 2 /* Indent */;
  56314. case 'deepIndent': return 3 /* DeepIndent */;
  56315. }
  56316. }
  56317. var EditorWrappingInfoComputer = /** @class */ (function (_super) {
  56318. __extends(EditorWrappingInfoComputer, _super);
  56319. function EditorWrappingInfoComputer() {
  56320. return _super.call(this, 108 /* wrappingInfo */, [97 /* wordWrap */, 100 /* wordWrapColumn */, 101 /* wordWrapMinified */, 107 /* layoutInfo */, 2 /* accessibilitySupport */]) || this;
  56321. }
  56322. EditorWrappingInfoComputer.prototype.compute = function (env, options, _) {
  56323. var wordWrap = options.get(97 /* wordWrap */);
  56324. var wordWrapColumn = options.get(100 /* wordWrapColumn */);
  56325. var wordWrapMinified = options.get(101 /* wordWrapMinified */);
  56326. var layoutInfo = options.get(107 /* layoutInfo */);
  56327. var accessibilitySupport = options.get(2 /* accessibilitySupport */);
  56328. var bareWrappingInfo = null;
  56329. {
  56330. if (accessibilitySupport === 2 /* Enabled */) {
  56331. // See https://github.com/Microsoft/vscode/issues/27766
  56332. // Never enable wrapping when a screen reader is attached
  56333. // because arrow down etc. will not move the cursor in the way
  56334. // a screen reader expects.
  56335. bareWrappingInfo = {
  56336. isWordWrapMinified: false,
  56337. isViewportWrapping: false,
  56338. wrappingColumn: -1
  56339. };
  56340. }
  56341. else if (wordWrapMinified && env.isDominatedByLongLines) {
  56342. // Force viewport width wrapping if model is dominated by long lines
  56343. bareWrappingInfo = {
  56344. isWordWrapMinified: true,
  56345. isViewportWrapping: true,
  56346. wrappingColumn: Math.max(1, layoutInfo.viewportColumn)
  56347. };
  56348. }
  56349. else if (wordWrap === 'on') {
  56350. bareWrappingInfo = {
  56351. isWordWrapMinified: false,
  56352. isViewportWrapping: true,
  56353. wrappingColumn: Math.max(1, layoutInfo.viewportColumn)
  56354. };
  56355. }
  56356. else if (wordWrap === 'bounded') {
  56357. bareWrappingInfo = {
  56358. isWordWrapMinified: false,
  56359. isViewportWrapping: true,
  56360. wrappingColumn: Math.min(Math.max(1, layoutInfo.viewportColumn), wordWrapColumn)
  56361. };
  56362. }
  56363. else if (wordWrap === 'wordWrapColumn') {
  56364. bareWrappingInfo = {
  56365. isWordWrapMinified: false,
  56366. isViewportWrapping: false,
  56367. wrappingColumn: wordWrapColumn
  56368. };
  56369. }
  56370. else {
  56371. bareWrappingInfo = {
  56372. isWordWrapMinified: false,
  56373. isViewportWrapping: false,
  56374. wrappingColumn: -1
  56375. };
  56376. }
  56377. }
  56378. return {
  56379. isDominatedByLongLines: env.isDominatedByLongLines,
  56380. isWordWrapMinified: bareWrappingInfo.isWordWrapMinified,
  56381. isViewportWrapping: bareWrappingInfo.isViewportWrapping,
  56382. wrappingColumn: bareWrappingInfo.wrappingColumn,
  56383. };
  56384. };
  56385. return EditorWrappingInfoComputer;
  56386. }(ComputedEditorOption));
  56387. //#endregion
  56388. var DEFAULT_WINDOWS_FONT_FAMILY = 'Consolas, \'Courier New\', monospace';
  56389. var DEFAULT_MAC_FONT_FAMILY = 'Menlo, Monaco, \'Courier New\', monospace';
  56390. var DEFAULT_LINUX_FONT_FAMILY = '\'Droid Sans Mono\', \'monospace\', monospace, \'Droid Sans Fallback\'';
  56391. /**
  56392. * @internal
  56393. */
  56394. exports.EDITOR_FONT_DEFAULTS = {
  56395. fontFamily: (platform.isMacintosh ? DEFAULT_MAC_FONT_FAMILY : (platform.isLinux ? DEFAULT_LINUX_FONT_FAMILY : DEFAULT_WINDOWS_FONT_FAMILY)),
  56396. fontWeight: 'normal',
  56397. fontSize: (platform.isMacintosh ? 12 : 14),
  56398. lineHeight: 0,
  56399. letterSpacing: 0,
  56400. };
  56401. /**
  56402. * @internal
  56403. */
  56404. exports.EDITOR_MODEL_DEFAULTS = {
  56405. tabSize: 4,
  56406. indentSize: 4,
  56407. insertSpaces: true,
  56408. detectIndentation: true,
  56409. trimAutoWhitespace: true,
  56410. largeFileOptimizations: true
  56411. };
  56412. /**
  56413. * @internal
  56414. */
  56415. exports.editorOptionsRegistry = [];
  56416. function register(option) {
  56417. exports.editorOptionsRegistry[option.id] = option;
  56418. return option;
  56419. }
  56420. /**
  56421. * WORKAROUND: TS emits "any" for complex editor options values (anything except string, bool, enum, etc. ends up being "any")
  56422. * @monacodtsreplace
  56423. * /accessibilitySupport, any/accessibilitySupport, AccessibilitySupport/
  56424. * /comments, any/comments, EditorCommentsOptions/
  56425. * /find, any/find, EditorFindOptions/
  56426. * /fontInfo, any/fontInfo, FontInfo/
  56427. * /gotoLocation, any/gotoLocation, GoToLocationOptions/
  56428. * /hover, any/hover, EditorHoverOptions/
  56429. * /lightbulb, any/lightbulb, EditorLightbulbOptions/
  56430. * /minimap, any/minimap, EditorMinimapOptions/
  56431. * /parameterHints, any/parameterHints, InternalParameterHintOptions/
  56432. * /quickSuggestions, any/quickSuggestions, ValidQuickSuggestionsOptions/
  56433. * /suggest, any/suggest, InternalSuggestOptions/
  56434. */
  56435. exports.EditorOptions = {
  56436. acceptSuggestionOnCommitCharacter: register(new EditorBooleanOption(0 /* acceptSuggestionOnCommitCharacter */, 'acceptSuggestionOnCommitCharacter', true, { markdownDescription: nls.localize(92, null) })),
  56437. acceptSuggestionOnEnter: register(new EditorStringEnumOption(1 /* acceptSuggestionOnEnter */, 'acceptSuggestionOnEnter', 'on', ['on', 'smart', 'off'], {
  56438. markdownEnumDescriptions: [
  56439. '',
  56440. nls.localize(93, null),
  56441. ''
  56442. ],
  56443. markdownDescription: nls.localize(94, null)
  56444. })),
  56445. accessibilitySupport: register(new EditorAccessibilitySupport()),
  56446. accessibilityPageSize: register(new EditorIntOption(3 /* accessibilityPageSize */, 'accessibilityPageSize', 10, 1, 1073741824 /* MAX_SAFE_SMALL_INTEGER */, { description: nls.localize(95, null) })),
  56447. ariaLabel: register(new EditorStringOption(4 /* ariaLabel */, 'ariaLabel', nls.localize(96, null))),
  56448. autoClosingBrackets: register(new EditorStringEnumOption(5 /* autoClosingBrackets */, 'autoClosingBrackets', 'languageDefined', ['always', 'languageDefined', 'beforeWhitespace', 'never'], {
  56449. enumDescriptions: [
  56450. '',
  56451. nls.localize(97, null),
  56452. nls.localize(98, null),
  56453. '',
  56454. ],
  56455. description: nls.localize(99, null)
  56456. })),
  56457. autoClosingOvertype: register(new EditorStringEnumOption(6 /* autoClosingOvertype */, 'autoClosingOvertype', 'auto', ['always', 'auto', 'never'], {
  56458. enumDescriptions: [
  56459. '',
  56460. nls.localize(100, null),
  56461. '',
  56462. ],
  56463. description: nls.localize(101, null)
  56464. })),
  56465. autoClosingQuotes: register(new EditorStringEnumOption(7 /* autoClosingQuotes */, 'autoClosingQuotes', 'languageDefined', ['always', 'languageDefined', 'beforeWhitespace', 'never'], {
  56466. enumDescriptions: [
  56467. '',
  56468. nls.localize(102, null),
  56469. nls.localize(103, null),
  56470. '',
  56471. ],
  56472. description: nls.localize(104, null)
  56473. })),
  56474. autoIndent: register(new EditorEnumOption(8 /* autoIndent */, 'autoIndent', 4 /* Full */, 'full', ['none', 'keep', 'brackets', 'advanced', 'full'], _autoIndentFromString, {
  56475. enumDescriptions: [
  56476. nls.localize(105, null),
  56477. nls.localize(106, null),
  56478. nls.localize(107, null),
  56479. nls.localize(108, null),
  56480. nls.localize(109, null),
  56481. ],
  56482. description: nls.localize(110, null)
  56483. })),
  56484. automaticLayout: register(new EditorBooleanOption(9 /* automaticLayout */, 'automaticLayout', false)),
  56485. autoSurround: register(new EditorStringEnumOption(10 /* autoSurround */, 'autoSurround', 'languageDefined', ['languageDefined', 'quotes', 'brackets', 'never'], {
  56486. enumDescriptions: [
  56487. nls.localize(111, null),
  56488. nls.localize(112, null),
  56489. nls.localize(113, null),
  56490. ''
  56491. ],
  56492. description: nls.localize(114, null)
  56493. })),
  56494. codeLens: register(new EditorBooleanOption(11 /* codeLens */, 'codeLens', true, { description: nls.localize(115, null) })),
  56495. colorDecorators: register(new EditorBooleanOption(12 /* colorDecorators */, 'colorDecorators', true, { description: nls.localize(116, null) })),
  56496. comments: register(new EditorComments()),
  56497. contextmenu: register(new EditorBooleanOption(14 /* contextmenu */, 'contextmenu', true)),
  56498. copyWithSyntaxHighlighting: register(new EditorBooleanOption(15 /* copyWithSyntaxHighlighting */, 'copyWithSyntaxHighlighting', true, { description: nls.localize(117, null) })),
  56499. cursorBlinking: register(new EditorEnumOption(16 /* cursorBlinking */, 'cursorBlinking', 1 /* Blink */, 'blink', ['blink', 'smooth', 'phase', 'expand', 'solid'], _cursorBlinkingStyleFromString, { description: nls.localize(118, null) })),
  56500. cursorSmoothCaretAnimation: register(new EditorBooleanOption(17 /* cursorSmoothCaretAnimation */, 'cursorSmoothCaretAnimation', false, { description: nls.localize(119, null) })),
  56501. cursorStyle: register(new EditorEnumOption(18 /* cursorStyle */, 'cursorStyle', TextEditorCursorStyle.Line, 'line', ['line', 'block', 'underline', 'line-thin', 'block-outline', 'underline-thin'], _cursorStyleFromString, { description: nls.localize(120, null) })),
  56502. cursorSurroundingLines: register(new EditorIntOption(19 /* cursorSurroundingLines */, 'cursorSurroundingLines', 0, 0, 1073741824 /* MAX_SAFE_SMALL_INTEGER */, { description: nls.localize(121, null) })),
  56503. cursorSurroundingLinesStyle: register(new EditorStringEnumOption(20 /* cursorSurroundingLinesStyle */, 'cursorSurroundingLinesStyle', 'default', ['default', 'all'], {
  56504. enumDescriptions: [
  56505. nls.localize(122, null),
  56506. nls.localize(123, null)
  56507. ],
  56508. description: nls.localize(124, null)
  56509. })),
  56510. cursorWidth: register(new EditorIntOption(21 /* cursorWidth */, 'cursorWidth', 0, 0, 1073741824 /* MAX_SAFE_SMALL_INTEGER */, { markdownDescription: nls.localize(125, null) })),
  56511. disableLayerHinting: register(new EditorBooleanOption(22 /* disableLayerHinting */, 'disableLayerHinting', false)),
  56512. disableMonospaceOptimizations: register(new EditorBooleanOption(23 /* disableMonospaceOptimizations */, 'disableMonospaceOptimizations', false)),
  56513. dragAndDrop: register(new EditorBooleanOption(24 /* dragAndDrop */, 'dragAndDrop', true, { description: nls.localize(126, null) })),
  56514. emptySelectionClipboard: register(new EditorEmptySelectionClipboard()),
  56515. extraEditorClassName: register(new EditorStringOption(26 /* extraEditorClassName */, 'extraEditorClassName', '')),
  56516. fastScrollSensitivity: register(new EditorFloatOption(27 /* fastScrollSensitivity */, 'fastScrollSensitivity', 5, function (x) { return (x <= 0 ? 5 : x); }, { markdownDescription: nls.localize(127, null) })),
  56517. find: register(new EditorFind()),
  56518. fixedOverflowWidgets: register(new EditorBooleanOption(29 /* fixedOverflowWidgets */, 'fixedOverflowWidgets', false)),
  56519. folding: register(new EditorBooleanOption(30 /* folding */, 'folding', true, { description: nls.localize(128, null) })),
  56520. foldingStrategy: register(new EditorStringEnumOption(31 /* foldingStrategy */, 'foldingStrategy', 'auto', ['auto', 'indentation'], { markdownDescription: nls.localize(129, null) })),
  56521. foldingHighlight: register(new EditorBooleanOption(32 /* foldingHighlight */, 'foldingHighlight', true, { description: nls.localize(130, null) })),
  56522. fontFamily: register(new EditorStringOption(33 /* fontFamily */, 'fontFamily', exports.EDITOR_FONT_DEFAULTS.fontFamily, { description: nls.localize(131, null) })),
  56523. fontInfo: register(new EditorFontInfo()),
  56524. fontLigatures2: register(new EditorFontLigatures()),
  56525. fontSize: register(new EditorFontSize()),
  56526. fontWeight: register(new EditorStringOption(37 /* fontWeight */, 'fontWeight', exports.EDITOR_FONT_DEFAULTS.fontWeight, {
  56527. enum: ['normal', 'bold', '100', '200', '300', '400', '500', '600', '700', '800', '900'],
  56528. description: nls.localize(132, null)
  56529. })),
  56530. formatOnPaste: register(new EditorBooleanOption(38 /* formatOnPaste */, 'formatOnPaste', false, { description: nls.localize(133, null) })),
  56531. formatOnType: register(new EditorBooleanOption(39 /* formatOnType */, 'formatOnType', false, { description: nls.localize(134, null) })),
  56532. glyphMargin: register(new EditorBooleanOption(40 /* glyphMargin */, 'glyphMargin', true, { description: nls.localize(135, null) })),
  56533. gotoLocation: register(new EditorGoToLocation()),
  56534. hideCursorInOverviewRuler: register(new EditorBooleanOption(42 /* hideCursorInOverviewRuler */, 'hideCursorInOverviewRuler', false, { description: nls.localize(136, null) })),
  56535. highlightActiveIndentGuide: register(new EditorBooleanOption(43 /* highlightActiveIndentGuide */, 'highlightActiveIndentGuide', true, { description: nls.localize(137, null) })),
  56536. hover: register(new EditorHover()),
  56537. inDiffEditor: register(new EditorBooleanOption(45 /* inDiffEditor */, 'inDiffEditor', false)),
  56538. letterSpacing: register(new EditorFloatOption(46 /* letterSpacing */, 'letterSpacing', exports.EDITOR_FONT_DEFAULTS.letterSpacing, function (x) { return EditorFloatOption.clamp(x, -5, 20); }, { description: nls.localize(138, null) })),
  56539. lightbulb: register(new EditorLightbulb()),
  56540. lineDecorationsWidth: register(new SimpleEditorOption(48 /* lineDecorationsWidth */, 'lineDecorationsWidth', 10)),
  56541. lineHeight: register(new EditorLineHeight()),
  56542. lineNumbers: register(new EditorRenderLineNumbersOption()),
  56543. lineNumbersMinChars: register(new EditorIntOption(51 /* lineNumbersMinChars */, 'lineNumbersMinChars', 5, 1, 300)),
  56544. links: register(new EditorBooleanOption(52 /* links */, 'links', true, { description: nls.localize(139, null) })),
  56545. matchBrackets: register(new EditorStringEnumOption(53 /* matchBrackets */, 'matchBrackets', 'always', ['always', 'near', 'never'], { description: nls.localize(140, null) })),
  56546. minimap: register(new EditorMinimap()),
  56547. mouseStyle: register(new EditorStringEnumOption(55 /* mouseStyle */, 'mouseStyle', 'text', ['text', 'default', 'copy'])),
  56548. mouseWheelScrollSensitivity: register(new EditorFloatOption(56 /* mouseWheelScrollSensitivity */, 'mouseWheelScrollSensitivity', 1, function (x) { return (x === 0 ? 1 : x); }, { markdownDescription: nls.localize(141, null) })),
  56549. mouseWheelZoom: register(new EditorBooleanOption(57 /* mouseWheelZoom */, 'mouseWheelZoom', false, { markdownDescription: nls.localize(142, null) })),
  56550. multiCursorMergeOverlapping: register(new EditorBooleanOption(58 /* multiCursorMergeOverlapping */, 'multiCursorMergeOverlapping', true, { description: nls.localize(143, null) })),
  56551. multiCursorModifier: register(new EditorEnumOption(59 /* multiCursorModifier */, 'multiCursorModifier', 'altKey', 'alt', ['ctrlCmd', 'alt'], _multiCursorModifierFromString, {
  56552. markdownEnumDescriptions: [
  56553. nls.localize(144, null),
  56554. nls.localize(145, null)
  56555. ],
  56556. markdownDescription: nls.localize(146, null)
  56557. })),
  56558. multiCursorPaste: register(new EditorStringEnumOption(60 /* multiCursorPaste */, 'multiCursorPaste', 'spread', ['spread', 'full'], {
  56559. markdownEnumDescriptions: [
  56560. nls.localize(147, null),
  56561. nls.localize(148, null)
  56562. ],
  56563. markdownDescription: nls.localize(149, null)
  56564. })),
  56565. occurrencesHighlight: register(new EditorBooleanOption(61 /* occurrencesHighlight */, 'occurrencesHighlight', true, { description: nls.localize(150, null) })),
  56566. overviewRulerBorder: register(new EditorBooleanOption(62 /* overviewRulerBorder */, 'overviewRulerBorder', true, { description: nls.localize(151, null) })),
  56567. overviewRulerLanes: register(new EditorIntOption(63 /* overviewRulerLanes */, 'overviewRulerLanes', 3, 0, 3)),
  56568. parameterHints: register(new EditorParameterHints()),
  56569. peekWidgetDefaultFocus: register(new EditorStringEnumOption(65 /* peekWidgetDefaultFocus */, 'peekWidgetDefaultFocus', 'tree', ['tree', 'editor'], {
  56570. enumDescriptions: [
  56571. nls.localize(152, null),
  56572. nls.localize(153, null)
  56573. ],
  56574. description: nls.localize(154, null)
  56575. })),
  56576. quickSuggestions: register(new EditorQuickSuggestions()),
  56577. quickSuggestionsDelay: register(new EditorIntOption(67 /* quickSuggestionsDelay */, 'quickSuggestionsDelay', 10, 0, 1073741824 /* MAX_SAFE_SMALL_INTEGER */, { description: nls.localize(155, null) })),
  56578. readOnly: register(new EditorBooleanOption(68 /* readOnly */, 'readOnly', false)),
  56579. renderControlCharacters: register(new EditorBooleanOption(69 /* renderControlCharacters */, 'renderControlCharacters', false, { description: nls.localize(156, null) })),
  56580. renderIndentGuides: register(new EditorBooleanOption(70 /* renderIndentGuides */, 'renderIndentGuides', true, { description: nls.localize(157, null) })),
  56581. renderFinalNewline: register(new EditorBooleanOption(71 /* renderFinalNewline */, 'renderFinalNewline', true, { description: nls.localize(158, null) })),
  56582. renderLineHighlight: register(new EditorStringEnumOption(72 /* renderLineHighlight */, 'renderLineHighlight', 'line', ['none', 'gutter', 'line', 'all'], {
  56583. enumDescriptions: [
  56584. '',
  56585. '',
  56586. '',
  56587. nls.localize(159, null),
  56588. ],
  56589. description: nls.localize(160, null)
  56590. })),
  56591. renderValidationDecorations: register(new EditorStringEnumOption(73 /* renderValidationDecorations */, 'renderValidationDecorations', 'editable', ['editable', 'on', 'off'])),
  56592. renderWhitespace: register(new EditorStringEnumOption(74 /* renderWhitespace */, 'renderWhitespace', 'none', ['none', 'boundary', 'selection', 'all'], {
  56593. enumDescriptions: [
  56594. '',
  56595. nls.localize(161, null),
  56596. nls.localize(162, null),
  56597. ''
  56598. ],
  56599. description: nls.localize(163, null)
  56600. })),
  56601. revealHorizontalRightPadding: register(new EditorIntOption(75 /* revealHorizontalRightPadding */, 'revealHorizontalRightPadding', 30, 0, 1000)),
  56602. roundedSelection: register(new EditorBooleanOption(76 /* roundedSelection */, 'roundedSelection', true, { description: nls.localize(164, null) })),
  56603. rulers: register(new EditorRulers()),
  56604. scrollbar: register(new EditorScrollbar()),
  56605. scrollBeyondLastColumn: register(new EditorIntOption(79 /* scrollBeyondLastColumn */, 'scrollBeyondLastColumn', 5, 0, 1073741824 /* MAX_SAFE_SMALL_INTEGER */, { description: nls.localize(165, null) })),
  56606. scrollBeyondLastLine: register(new EditorBooleanOption(80 /* scrollBeyondLastLine */, 'scrollBeyondLastLine', true, { description: nls.localize(166, null) })),
  56607. selectionClipboard: register(new EditorBooleanOption(81 /* selectionClipboard */, 'selectionClipboard', true, {
  56608. description: nls.localize(167, null),
  56609. included: platform.isLinux
  56610. })),
  56611. selectionHighlight: register(new EditorBooleanOption(82 /* selectionHighlight */, 'selectionHighlight', true, { description: nls.localize(168, null) })),
  56612. selectOnLineNumbers: register(new EditorBooleanOption(83 /* selectOnLineNumbers */, 'selectOnLineNumbers', true)),
  56613. showFoldingControls: register(new EditorStringEnumOption(84 /* showFoldingControls */, 'showFoldingControls', 'mouseover', ['always', 'mouseover'], { description: nls.localize(169, null) })),
  56614. showUnused: register(new EditorBooleanOption(85 /* showUnused */, 'showUnused', true, { description: nls.localize(170, null) })),
  56615. snippetSuggestions: register(new EditorStringEnumOption(86 /* snippetSuggestions */, 'snippetSuggestions', 'inline', ['top', 'bottom', 'inline', 'none'], {
  56616. enumDescriptions: [
  56617. nls.localize(171, null),
  56618. nls.localize(172, null),
  56619. nls.localize(173, null),
  56620. nls.localize(174, null),
  56621. ],
  56622. description: nls.localize(175, null)
  56623. })),
  56624. smoothScrolling: register(new EditorBooleanOption(87 /* smoothScrolling */, 'smoothScrolling', false, { description: nls.localize(176, null) })),
  56625. stopRenderingLineAfter: register(new EditorIntOption(88 /* stopRenderingLineAfter */, 'stopRenderingLineAfter', 10000, -1, 1073741824 /* MAX_SAFE_SMALL_INTEGER */)),
  56626. suggest: register(new EditorSuggest()),
  56627. suggestFontSize: register(new EditorIntOption(90 /* suggestFontSize */, 'suggestFontSize', 0, 0, 1000, { markdownDescription: nls.localize(177, null) })),
  56628. suggestLineHeight: register(new EditorIntOption(91 /* suggestLineHeight */, 'suggestLineHeight', 0, 0, 1000, { markdownDescription: nls.localize(178, null) })),
  56629. suggestOnTriggerCharacters: register(new EditorBooleanOption(92 /* suggestOnTriggerCharacters */, 'suggestOnTriggerCharacters', true, { description: nls.localize(179, null) })),
  56630. suggestSelection: register(new EditorStringEnumOption(93 /* suggestSelection */, 'suggestSelection', 'recentlyUsed', ['first', 'recentlyUsed', 'recentlyUsedByPrefix'], {
  56631. markdownEnumDescriptions: [
  56632. nls.localize(180, null),
  56633. nls.localize(181, null),
  56634. nls.localize(182, null),
  56635. ],
  56636. description: nls.localize(183, null)
  56637. })),
  56638. tabCompletion: register(new EditorStringEnumOption(94 /* tabCompletion */, 'tabCompletion', 'off', ['on', 'off', 'onlySnippets'], {
  56639. enumDescriptions: [
  56640. nls.localize(184, null),
  56641. nls.localize(185, null),
  56642. nls.localize(186, null),
  56643. ],
  56644. description: nls.localize(187, null)
  56645. })),
  56646. useTabStops: register(new EditorBooleanOption(95 /* useTabStops */, 'useTabStops', true, { description: nls.localize(188, null) })),
  56647. wordSeparators: register(new EditorStringOption(96 /* wordSeparators */, 'wordSeparators', wordHelper_1.USUAL_WORD_SEPARATORS, { description: nls.localize(189, null) })),
  56648. wordWrap: register(new EditorStringEnumOption(97 /* wordWrap */, 'wordWrap', 'off', ['off', 'on', 'wordWrapColumn', 'bounded'], {
  56649. markdownEnumDescriptions: [
  56650. nls.localize(190, null),
  56651. nls.localize(191, null),
  56652. nls.localize(192, null),
  56653. nls.localize(193, null),
  56654. ],
  56655. description: nls.localize(194, null)
  56656. })),
  56657. wordWrapBreakAfterCharacters: register(new EditorStringOption(98 /* wordWrapBreakAfterCharacters */, 'wordWrapBreakAfterCharacters', ' \t})]?|/&.,;¢°′″‰℃、。。、¢,.:;?!%・・ゝゞヽヾーァィゥェォッャュョヮヵヶぁぃぅぇぉっゃゅょゎゕゖㇰㇱㇲㇳㇴㇵㇶㇷㇸㇹㇺㇻㇼㇽㇾㇿ々〻ァィゥェォャュョッー”〉》」』】〕)]}」')),
  56658. wordWrapBreakBeforeCharacters: register(new EditorStringOption(99 /* wordWrapBreakBeforeCharacters */, 'wordWrapBreakBeforeCharacters', '([{‘“〈《「『【〔([{「£¥$£¥++')),
  56659. wordWrapColumn: register(new EditorIntOption(100 /* wordWrapColumn */, 'wordWrapColumn', 80, 1, 1073741824 /* MAX_SAFE_SMALL_INTEGER */, {
  56660. markdownDescription: nls.localize(195, null)
  56661. })),
  56662. wordWrapMinified: register(new EditorBooleanOption(101 /* wordWrapMinified */, 'wordWrapMinified', true)),
  56663. wrappingIndent: register(new EditorEnumOption(102 /* wrappingIndent */, 'wrappingIndent', 1 /* Same */, 'same', ['none', 'same', 'indent', 'deepIndent'], _wrappingIndentFromString, {
  56664. enumDescriptions: [
  56665. nls.localize(196, null),
  56666. nls.localize(197, null),
  56667. nls.localize(198, null),
  56668. nls.localize(199, null),
  56669. ],
  56670. description: nls.localize(200, null),
  56671. })),
  56672. wrappingStrategy: register(new EditorStringEnumOption(103 /* wrappingStrategy */, 'wrappingStrategy', 'simple', ['simple', 'advanced'], {
  56673. enumDescriptions: [
  56674. nls.localize(201, null),
  56675. nls.localize(202, null)
  56676. ],
  56677. description: nls.localize(203, null)
  56678. })),
  56679. // Leave these at the end (because they have dependencies!)
  56680. editorClassName: register(new EditorClassName()),
  56681. pixelRatio: register(new EditorPixelRatio()),
  56682. tabFocusMode: register(new EditorTabFocusMode()),
  56683. layoutInfo: register(new EditorLayoutInfoComputer()),
  56684. wrappingInfo: register(new EditorWrappingInfoComputer())
  56685. };
  56686. });
  56687. /*---------------------------------------------------------------------------------------------
  56688. * Copyright (c) Microsoft Corporation. All rights reserved.
  56689. * Licensed under the MIT License. See License.txt in the project root for license information.
  56690. *--------------------------------------------------------------------------------------------*/
  56691. define(__m[424/*vs/editor/common/viewModel/viewModelDecorations*/], __M([0/*require*/,1/*exports*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,69/*vs/editor/common/viewModel/viewModel*/,33/*vs/editor/common/config/editorOptions*/]), function (require, exports, position_1, range_1, viewModel_1, editorOptions_1) {
  56692. "use strict";
  56693. Object.defineProperty(exports, "__esModule", { value: true });
  56694. var ViewModelDecorations = /** @class */ (function () {
  56695. function ViewModelDecorations(editorId, model, configuration, linesCollection, coordinatesConverter) {
  56696. this.editorId = editorId;
  56697. this.model = model;
  56698. this.configuration = configuration;
  56699. this._linesCollection = linesCollection;
  56700. this._coordinatesConverter = coordinatesConverter;
  56701. this._decorationsCache = Object.create(null);
  56702. this._cachedModelDecorationsResolver = null;
  56703. this._cachedModelDecorationsResolverViewRange = null;
  56704. }
  56705. ViewModelDecorations.prototype._clearCachedModelDecorationsResolver = function () {
  56706. this._cachedModelDecorationsResolver = null;
  56707. this._cachedModelDecorationsResolverViewRange = null;
  56708. };
  56709. ViewModelDecorations.prototype.dispose = function () {
  56710. this._decorationsCache = Object.create(null);
  56711. this._clearCachedModelDecorationsResolver();
  56712. };
  56713. ViewModelDecorations.prototype.reset = function () {
  56714. this._decorationsCache = Object.create(null);
  56715. this._clearCachedModelDecorationsResolver();
  56716. };
  56717. ViewModelDecorations.prototype.onModelDecorationsChanged = function () {
  56718. this._decorationsCache = Object.create(null);
  56719. this._clearCachedModelDecorationsResolver();
  56720. };
  56721. ViewModelDecorations.prototype.onLineMappingChanged = function () {
  56722. this._decorationsCache = Object.create(null);
  56723. this._clearCachedModelDecorationsResolver();
  56724. };
  56725. ViewModelDecorations.prototype._getOrCreateViewModelDecoration = function (modelDecoration) {
  56726. var id = modelDecoration.id;
  56727. var r = this._decorationsCache[id];
  56728. if (!r) {
  56729. var modelRange = modelDecoration.range;
  56730. var options = modelDecoration.options;
  56731. var viewRange = void 0;
  56732. if (options.isWholeLine) {
  56733. var start = this._coordinatesConverter.convertModelPositionToViewPosition(new position_1.Position(modelRange.startLineNumber, 1));
  56734. var end = this._coordinatesConverter.convertModelPositionToViewPosition(new position_1.Position(modelRange.endLineNumber, this.model.getLineMaxColumn(modelRange.endLineNumber)));
  56735. viewRange = new range_1.Range(start.lineNumber, start.column, end.lineNumber, end.column);
  56736. }
  56737. else {
  56738. viewRange = this._coordinatesConverter.convertModelRangeToViewRange(modelRange);
  56739. }
  56740. r = new viewModel_1.ViewModelDecoration(viewRange, options);
  56741. this._decorationsCache[id] = r;
  56742. }
  56743. return r;
  56744. };
  56745. ViewModelDecorations.prototype.getDecorationsViewportData = function (viewRange) {
  56746. var cacheIsValid = (this._cachedModelDecorationsResolver !== null);
  56747. cacheIsValid = cacheIsValid && (viewRange.equalsRange(this._cachedModelDecorationsResolverViewRange));
  56748. if (!cacheIsValid) {
  56749. this._cachedModelDecorationsResolver = this._getDecorationsViewportData(viewRange);
  56750. this._cachedModelDecorationsResolverViewRange = viewRange;
  56751. }
  56752. return this._cachedModelDecorationsResolver;
  56753. };
  56754. ViewModelDecorations.prototype._getDecorationsViewportData = function (viewportRange) {
  56755. var modelDecorations = this._linesCollection.getDecorationsInRange(viewportRange, this.editorId, editorOptions_1.filterValidationDecorations(this.configuration.options));
  56756. var startLineNumber = viewportRange.startLineNumber;
  56757. var endLineNumber = viewportRange.endLineNumber;
  56758. var decorationsInViewport = [], decorationsInViewportLen = 0;
  56759. var inlineDecorations = [];
  56760. for (var j = startLineNumber; j <= endLineNumber; j++) {
  56761. inlineDecorations[j - startLineNumber] = [];
  56762. }
  56763. for (var i = 0, len = modelDecorations.length; i < len; i++) {
  56764. var modelDecoration = modelDecorations[i];
  56765. var decorationOptions = modelDecoration.options;
  56766. var viewModelDecoration = this._getOrCreateViewModelDecoration(modelDecoration);
  56767. var viewRange = viewModelDecoration.range;
  56768. decorationsInViewport[decorationsInViewportLen++] = viewModelDecoration;
  56769. if (decorationOptions.inlineClassName) {
  56770. var inlineDecoration = new viewModel_1.InlineDecoration(viewRange, decorationOptions.inlineClassName, decorationOptions.inlineClassNameAffectsLetterSpacing ? 3 /* RegularAffectingLetterSpacing */ : 0 /* Regular */);
  56771. var intersectedStartLineNumber = Math.max(startLineNumber, viewRange.startLineNumber);
  56772. var intersectedEndLineNumber = Math.min(endLineNumber, viewRange.endLineNumber);
  56773. for (var j = intersectedStartLineNumber; j <= intersectedEndLineNumber; j++) {
  56774. inlineDecorations[j - startLineNumber].push(inlineDecoration);
  56775. }
  56776. }
  56777. if (decorationOptions.beforeContentClassName) {
  56778. if (startLineNumber <= viewRange.startLineNumber && viewRange.startLineNumber <= endLineNumber) {
  56779. var inlineDecoration = new viewModel_1.InlineDecoration(new range_1.Range(viewRange.startLineNumber, viewRange.startColumn, viewRange.startLineNumber, viewRange.startColumn), decorationOptions.beforeContentClassName, 1 /* Before */);
  56780. inlineDecorations[viewRange.startLineNumber - startLineNumber].push(inlineDecoration);
  56781. }
  56782. }
  56783. if (decorationOptions.afterContentClassName) {
  56784. if (startLineNumber <= viewRange.endLineNumber && viewRange.endLineNumber <= endLineNumber) {
  56785. var inlineDecoration = new viewModel_1.InlineDecoration(new range_1.Range(viewRange.endLineNumber, viewRange.endColumn, viewRange.endLineNumber, viewRange.endColumn), decorationOptions.afterContentClassName, 2 /* After */);
  56786. inlineDecorations[viewRange.endLineNumber - startLineNumber].push(inlineDecoration);
  56787. }
  56788. }
  56789. }
  56790. return {
  56791. decorations: decorationsInViewport,
  56792. inlineDecorations: inlineDecorations
  56793. };
  56794. };
  56795. return ViewModelDecorations;
  56796. }());
  56797. exports.ViewModelDecorations = ViewModelDecorations;
  56798. });
  56799. define(__m[425/*vs/nls!vs/editor/common/modes/modesRegistry*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/common/modes/modesRegistry", data); });
  56800. define(__m[426/*vs/nls!vs/editor/common/standaloneStrings*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/common/standaloneStrings", data); });
  56801. /*---------------------------------------------------------------------------------------------
  56802. * Copyright (c) Microsoft Corporation. All rights reserved.
  56803. * Licensed under the MIT License. See License.txt in the project root for license information.
  56804. *--------------------------------------------------------------------------------------------*/
  56805. define(__m[59/*vs/editor/common/standaloneStrings*/], __M([0/*require*/,1/*exports*/,426/*vs/nls!vs/editor/common/standaloneStrings*/]), function (require, exports, nls) {
  56806. "use strict";
  56807. Object.defineProperty(exports, "__esModule", { value: true });
  56808. var AccessibilityHelpNLS;
  56809. (function (AccessibilityHelpNLS) {
  56810. AccessibilityHelpNLS.noSelection = nls.localize(0, null);
  56811. AccessibilityHelpNLS.singleSelectionRange = nls.localize(1, null);
  56812. AccessibilityHelpNLS.singleSelection = nls.localize(2, null);
  56813. AccessibilityHelpNLS.multiSelectionRange = nls.localize(3, null);
  56814. AccessibilityHelpNLS.multiSelection = nls.localize(4, null);
  56815. AccessibilityHelpNLS.emergencyConfOn = nls.localize(5, null);
  56816. AccessibilityHelpNLS.openingDocs = nls.localize(6, null);
  56817. AccessibilityHelpNLS.readonlyDiffEditor = nls.localize(7, null);
  56818. AccessibilityHelpNLS.editableDiffEditor = nls.localize(8, null);
  56819. AccessibilityHelpNLS.readonlyEditor = nls.localize(9, null);
  56820. AccessibilityHelpNLS.editableEditor = nls.localize(10, null);
  56821. AccessibilityHelpNLS.changeConfigToOnMac = nls.localize(11, null);
  56822. AccessibilityHelpNLS.changeConfigToOnWinLinux = nls.localize(12, null);
  56823. AccessibilityHelpNLS.auto_on = nls.localize(13, null);
  56824. AccessibilityHelpNLS.auto_off = nls.localize(14, null);
  56825. AccessibilityHelpNLS.tabFocusModeOnMsg = nls.localize(15, null);
  56826. AccessibilityHelpNLS.tabFocusModeOnMsgNoKb = nls.localize(16, null);
  56827. AccessibilityHelpNLS.tabFocusModeOffMsg = nls.localize(17, null);
  56828. AccessibilityHelpNLS.tabFocusModeOffMsgNoKb = nls.localize(18, null);
  56829. AccessibilityHelpNLS.openDocMac = nls.localize(19, null);
  56830. AccessibilityHelpNLS.openDocWinLinux = nls.localize(20, null);
  56831. AccessibilityHelpNLS.outroMsg = nls.localize(21, null);
  56832. AccessibilityHelpNLS.showAccessibilityHelpAction = nls.localize(22, null);
  56833. })(AccessibilityHelpNLS = exports.AccessibilityHelpNLS || (exports.AccessibilityHelpNLS = {}));
  56834. var InspectTokensNLS;
  56835. (function (InspectTokensNLS) {
  56836. InspectTokensNLS.inspectTokensAction = nls.localize(23, null);
  56837. })(InspectTokensNLS = exports.InspectTokensNLS || (exports.InspectTokensNLS = {}));
  56838. var GoToLineNLS;
  56839. (function (GoToLineNLS) {
  56840. GoToLineNLS.gotoLineLabelValidLineAndColumn = nls.localize(24, null);
  56841. GoToLineNLS.gotoLineLabelValidLine = nls.localize(25, null);
  56842. GoToLineNLS.gotoLineLabelEmptyWithLineLimit = nls.localize(26, null);
  56843. GoToLineNLS.gotoLineLabelEmptyWithLineAndColumnLimit = nls.localize(27, null);
  56844. GoToLineNLS.gotoLineAriaLabel = nls.localize(28, null);
  56845. GoToLineNLS.gotoLineActionInput = nls.localize(29, null);
  56846. GoToLineNLS.gotoLineActionLabel = nls.localize(30, null);
  56847. })(GoToLineNLS = exports.GoToLineNLS || (exports.GoToLineNLS = {}));
  56848. var QuickCommandNLS;
  56849. (function (QuickCommandNLS) {
  56850. QuickCommandNLS.ariaLabelEntryWithKey = nls.localize(31, null);
  56851. QuickCommandNLS.ariaLabelEntry = nls.localize(32, null);
  56852. QuickCommandNLS.quickCommandActionInput = nls.localize(33, null);
  56853. QuickCommandNLS.quickCommandActionLabel = nls.localize(34, null);
  56854. })(QuickCommandNLS = exports.QuickCommandNLS || (exports.QuickCommandNLS = {}));
  56855. var QuickOutlineNLS;
  56856. (function (QuickOutlineNLS) {
  56857. QuickOutlineNLS.entryAriaLabel = nls.localize(35, null);
  56858. QuickOutlineNLS.quickOutlineActionInput = nls.localize(36, null);
  56859. QuickOutlineNLS.quickOutlineActionLabel = nls.localize(37, null);
  56860. QuickOutlineNLS._symbols_ = nls.localize(38, null);
  56861. QuickOutlineNLS._modules_ = nls.localize(39, null);
  56862. QuickOutlineNLS._class_ = nls.localize(40, null);
  56863. QuickOutlineNLS._interface_ = nls.localize(41, null);
  56864. QuickOutlineNLS._method_ = nls.localize(42, null);
  56865. QuickOutlineNLS._function_ = nls.localize(43, null);
  56866. QuickOutlineNLS._property_ = nls.localize(44, null);
  56867. QuickOutlineNLS._variable_ = nls.localize(45, null);
  56868. QuickOutlineNLS._variable2_ = nls.localize(46, null);
  56869. QuickOutlineNLS._constructor_ = nls.localize(47, null);
  56870. QuickOutlineNLS._call_ = nls.localize(48, null);
  56871. })(QuickOutlineNLS = exports.QuickOutlineNLS || (exports.QuickOutlineNLS = {}));
  56872. var StandaloneCodeEditorNLS;
  56873. (function (StandaloneCodeEditorNLS) {
  56874. StandaloneCodeEditorNLS.editorViewAccessibleLabel = nls.localize(49, null);
  56875. StandaloneCodeEditorNLS.accessibilityHelpMessageIE = nls.localize(50, null);
  56876. StandaloneCodeEditorNLS.accessibilityHelpMessage = nls.localize(51, null);
  56877. })(StandaloneCodeEditorNLS = exports.StandaloneCodeEditorNLS || (exports.StandaloneCodeEditorNLS = {}));
  56878. var ToggleHighContrastNLS;
  56879. (function (ToggleHighContrastNLS) {
  56880. ToggleHighContrastNLS.toggleHighContrast = nls.localize(52, null);
  56881. })(ToggleHighContrastNLS = exports.ToggleHighContrastNLS || (exports.ToggleHighContrastNLS = {}));
  56882. var SimpleServicesNLS;
  56883. (function (SimpleServicesNLS) {
  56884. SimpleServicesNLS.bulkEditServiceSummary = nls.localize(53, null);
  56885. })(SimpleServicesNLS = exports.SimpleServicesNLS || (exports.SimpleServicesNLS = {}));
  56886. });
  56887. define(__m[427/*vs/nls!vs/editor/common/view/editorColorRegistry*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/common/view/editorColorRegistry", data); });
  56888. define(__m[428/*vs/nls!vs/editor/contrib/bracketMatching/bracketMatching*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/bracketMatching/bracketMatching", data); });
  56889. define(__m[429/*vs/nls!vs/editor/contrib/caretOperations/caretOperations*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/caretOperations/caretOperations", data); });
  56890. define(__m[430/*vs/nls!vs/editor/contrib/caretOperations/transpose*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/caretOperations/transpose", data); });
  56891. define(__m[431/*vs/nls!vs/editor/contrib/clipboard/clipboard*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/clipboard/clipboard", data); });
  56892. define(__m[432/*vs/nls!vs/editor/contrib/codeAction/codeActionCommands*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/codeAction/codeActionCommands", data); });
  56893. define(__m[433/*vs/nls!vs/editor/contrib/codeAction/lightBulbWidget*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/codeAction/lightBulbWidget", data); });
  56894. define(__m[434/*vs/nls!vs/editor/contrib/comment/comment*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/comment/comment", data); });
  56895. define(__m[435/*vs/nls!vs/editor/contrib/contextmenu/contextmenu*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/contextmenu/contextmenu", data); });
  56896. define(__m[436/*vs/nls!vs/editor/contrib/cursorUndo/cursorUndo*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/cursorUndo/cursorUndo", data); });
  56897. define(__m[437/*vs/nls!vs/editor/contrib/documentSymbols/outlineTree*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/documentSymbols/outlineTree", data); });
  56898. define(__m[438/*vs/nls!vs/editor/contrib/find/findController*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/find/findController", data); });
  56899. define(__m[439/*vs/nls!vs/editor/contrib/find/findWidget*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/find/findWidget", data); });
  56900. define(__m[440/*vs/nls!vs/editor/contrib/folding/folding*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/folding/folding", data); });
  56901. define(__m[441/*vs/nls!vs/editor/contrib/fontZoom/fontZoom*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/fontZoom/fontZoom", data); });
  56902. define(__m[442/*vs/nls!vs/editor/contrib/format/format*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/format/format", data); });
  56903. define(__m[443/*vs/nls!vs/editor/contrib/format/formatActions*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/format/formatActions", data); });
  56904. define(__m[444/*vs/nls!vs/editor/contrib/gotoError/gotoError*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/gotoError/gotoError", data); });
  56905. define(__m[445/*vs/nls!vs/editor/contrib/gotoError/gotoErrorWidget*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/gotoError/gotoErrorWidget", data); });
  56906. define(__m[446/*vs/nls!vs/editor/contrib/gotoSymbol/goToCommands*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/gotoSymbol/goToCommands", data); });
  56907. define(__m[447/*vs/nls!vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition", data); });
  56908. define(__m[448/*vs/nls!vs/editor/contrib/gotoSymbol/peek/referencesController*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/gotoSymbol/peek/referencesController", data); });
  56909. define(__m[449/*vs/nls!vs/editor/contrib/gotoSymbol/peek/referencesTree*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/gotoSymbol/peek/referencesTree", data); });
  56910. define(__m[450/*vs/nls!vs/editor/contrib/gotoSymbol/peek/referencesWidget*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/gotoSymbol/peek/referencesWidget", data); });
  56911. define(__m[451/*vs/nls!vs/editor/contrib/gotoSymbol/referencesModel*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/gotoSymbol/referencesModel", data); });
  56912. /*---------------------------------------------------------------------------------------------
  56913. * Copyright (c) Microsoft Corporation. All rights reserved.
  56914. * Licensed under the MIT License. See License.txt in the project root for license information.
  56915. *--------------------------------------------------------------------------------------------*/
  56916. define(__m[113/*vs/editor/contrib/gotoSymbol/referencesModel*/], __M([0/*require*/,1/*exports*/,451/*vs/nls!vs/editor/contrib/gotoSymbol/referencesModel*/,4/*vs/base/common/event*/,39/*vs/base/common/resources*/,2/*vs/base/common/lifecycle*/,5/*vs/base/common/strings*/,127/*vs/base/common/idGenerator*/,3/*vs/editor/common/core/range*/]), function (require, exports, nls_1, event_1, resources_1, lifecycle_1, strings, idGenerator_1, range_1) {
  56917. "use strict";
  56918. Object.defineProperty(exports, "__esModule", { value: true });
  56919. var OneReference = /** @class */ (function () {
  56920. function OneReference(isProviderFirst, parent, _range, _rangeCallback) {
  56921. this.isProviderFirst = isProviderFirst;
  56922. this.parent = parent;
  56923. this._range = _range;
  56924. this._rangeCallback = _rangeCallback;
  56925. this.id = idGenerator_1.defaultGenerator.nextId();
  56926. }
  56927. Object.defineProperty(OneReference.prototype, "uri", {
  56928. get: function () {
  56929. return this.parent.uri;
  56930. },
  56931. enumerable: true,
  56932. configurable: true
  56933. });
  56934. Object.defineProperty(OneReference.prototype, "range", {
  56935. get: function () {
  56936. return this._range;
  56937. },
  56938. set: function (value) {
  56939. this._range = value;
  56940. this._rangeCallback(this);
  56941. },
  56942. enumerable: true,
  56943. configurable: true
  56944. });
  56945. Object.defineProperty(OneReference.prototype, "ariaMessage", {
  56946. get: function () {
  56947. return nls_1.localize(0, null, resources_1.basename(this.uri), this.range.startLineNumber, this.range.startColumn);
  56948. },
  56949. enumerable: true,
  56950. configurable: true
  56951. });
  56952. return OneReference;
  56953. }());
  56954. exports.OneReference = OneReference;
  56955. var FilePreview = /** @class */ (function () {
  56956. function FilePreview(_modelReference) {
  56957. this._modelReference = _modelReference;
  56958. }
  56959. FilePreview.prototype.dispose = function () {
  56960. this._modelReference.dispose();
  56961. };
  56962. FilePreview.prototype.preview = function (range, n) {
  56963. if (n === void 0) { n = 8; }
  56964. var model = this._modelReference.object.textEditorModel;
  56965. if (!model) {
  56966. return undefined;
  56967. }
  56968. var startLineNumber = range.startLineNumber, startColumn = range.startColumn, endLineNumber = range.endLineNumber, endColumn = range.endColumn;
  56969. var word = model.getWordUntilPosition({ lineNumber: startLineNumber, column: startColumn - n });
  56970. var beforeRange = new range_1.Range(startLineNumber, word.startColumn, startLineNumber, startColumn);
  56971. var afterRange = new range_1.Range(endLineNumber, endColumn, endLineNumber, 1073741824 /* MAX_SAFE_SMALL_INTEGER */);
  56972. var before = model.getValueInRange(beforeRange).replace(/^\s+/, '');
  56973. var inside = model.getValueInRange(range);
  56974. var after = model.getValueInRange(afterRange).replace(/\s+$/, '');
  56975. return {
  56976. value: before + inside + after,
  56977. highlight: { start: before.length, end: before.length + inside.length }
  56978. };
  56979. };
  56980. return FilePreview;
  56981. }());
  56982. exports.FilePreview = FilePreview;
  56983. var FileReferences = /** @class */ (function () {
  56984. function FileReferences(parent, uri) {
  56985. this.parent = parent;
  56986. this.uri = uri;
  56987. this.children = [];
  56988. }
  56989. FileReferences.prototype.dispose = function () {
  56990. lifecycle_1.dispose(this._preview);
  56991. this._preview = undefined;
  56992. };
  56993. Object.defineProperty(FileReferences.prototype, "preview", {
  56994. get: function () {
  56995. return this._preview;
  56996. },
  56997. enumerable: true,
  56998. configurable: true
  56999. });
  57000. Object.defineProperty(FileReferences.prototype, "failure", {
  57001. get: function () {
  57002. return this._loadFailure;
  57003. },
  57004. enumerable: true,
  57005. configurable: true
  57006. });
  57007. Object.defineProperty(FileReferences.prototype, "ariaMessage", {
  57008. get: function () {
  57009. var len = this.children.length;
  57010. if (len === 1) {
  57011. return nls_1.localize(1, null, resources_1.basename(this.uri), this.uri.fsPath);
  57012. }
  57013. else {
  57014. return nls_1.localize(2, null, len, resources_1.basename(this.uri), this.uri.fsPath);
  57015. }
  57016. },
  57017. enumerable: true,
  57018. configurable: true
  57019. });
  57020. FileReferences.prototype.resolve = function (textModelResolverService) {
  57021. var _this = this;
  57022. if (this._resolved) {
  57023. return Promise.resolve(this);
  57024. }
  57025. return Promise.resolve(textModelResolverService.createModelReference(this.uri).then(function (modelReference) {
  57026. var model = modelReference.object;
  57027. if (!model) {
  57028. modelReference.dispose();
  57029. throw new Error();
  57030. }
  57031. _this._preview = new FilePreview(modelReference);
  57032. _this._resolved = true;
  57033. return _this;
  57034. }, function (err) {
  57035. // something wrong here
  57036. _this.children.length = 0;
  57037. _this._resolved = true;
  57038. _this._loadFailure = err;
  57039. return _this;
  57040. }));
  57041. };
  57042. return FileReferences;
  57043. }());
  57044. exports.FileReferences = FileReferences;
  57045. var ReferencesModel = /** @class */ (function () {
  57046. function ReferencesModel(links, title) {
  57047. var _this = this;
  57048. this._disposables = new lifecycle_1.DisposableStore();
  57049. this.groups = [];
  57050. this.references = [];
  57051. this._onDidChangeReferenceRange = new event_1.Emitter();
  57052. this.onDidChangeReferenceRange = this._onDidChangeReferenceRange.event;
  57053. this._links = links;
  57054. this._title = title;
  57055. // grouping and sorting
  57056. var providersFirst = links[0];
  57057. links.sort(ReferencesModel._compareReferences);
  57058. var current;
  57059. for (var _i = 0, links_1 = links; _i < links_1.length; _i++) {
  57060. var link = links_1[_i];
  57061. if (!current || current.uri.toString() !== link.uri.toString()) {
  57062. // new group
  57063. current = new FileReferences(this, link.uri);
  57064. this.groups.push(current);
  57065. }
  57066. // append, check for equality first!
  57067. if (current.children.length === 0 || !range_1.Range.equalsRange(link.range, current.children[current.children.length - 1].range)) {
  57068. var oneRef = new OneReference(providersFirst === link, current, link.targetSelectionRange || link.range, function (ref) { return _this._onDidChangeReferenceRange.fire(ref); });
  57069. this.references.push(oneRef);
  57070. current.children.push(oneRef);
  57071. }
  57072. }
  57073. }
  57074. ReferencesModel.prototype.dispose = function () {
  57075. lifecycle_1.dispose(this.groups);
  57076. this._disposables.dispose();
  57077. this._onDidChangeReferenceRange.dispose();
  57078. this.groups.length = 0;
  57079. };
  57080. ReferencesModel.prototype.clone = function () {
  57081. return new ReferencesModel(this._links, this._title);
  57082. };
  57083. Object.defineProperty(ReferencesModel.prototype, "title", {
  57084. get: function () {
  57085. return this._title;
  57086. },
  57087. enumerable: true,
  57088. configurable: true
  57089. });
  57090. Object.defineProperty(ReferencesModel.prototype, "isEmpty", {
  57091. get: function () {
  57092. return this.groups.length === 0;
  57093. },
  57094. enumerable: true,
  57095. configurable: true
  57096. });
  57097. Object.defineProperty(ReferencesModel.prototype, "ariaMessage", {
  57098. get: function () {
  57099. if (this.isEmpty) {
  57100. return nls_1.localize(3, null);
  57101. }
  57102. else if (this.references.length === 1) {
  57103. return nls_1.localize(4, null, this.references[0].uri.fsPath);
  57104. }
  57105. else if (this.groups.length === 1) {
  57106. return nls_1.localize(5, null, this.references.length, this.groups[0].uri.fsPath);
  57107. }
  57108. else {
  57109. return nls_1.localize(6, null, this.references.length, this.groups.length);
  57110. }
  57111. },
  57112. enumerable: true,
  57113. configurable: true
  57114. });
  57115. ReferencesModel.prototype.nextOrPreviousReference = function (reference, next) {
  57116. var parent = reference.parent;
  57117. var idx = parent.children.indexOf(reference);
  57118. var childCount = parent.children.length;
  57119. var groupCount = parent.parent.groups.length;
  57120. if (groupCount === 1 || next && idx + 1 < childCount || !next && idx > 0) {
  57121. // cycling within one file
  57122. if (next) {
  57123. idx = (idx + 1) % childCount;
  57124. }
  57125. else {
  57126. idx = (idx + childCount - 1) % childCount;
  57127. }
  57128. return parent.children[idx];
  57129. }
  57130. idx = parent.parent.groups.indexOf(parent);
  57131. if (next) {
  57132. idx = (idx + 1) % groupCount;
  57133. return parent.parent.groups[idx].children[0];
  57134. }
  57135. else {
  57136. idx = (idx + groupCount - 1) % groupCount;
  57137. return parent.parent.groups[idx].children[parent.parent.groups[idx].children.length - 1];
  57138. }
  57139. };
  57140. ReferencesModel.prototype.nearestReference = function (resource, position) {
  57141. var nearest = this.references.map(function (ref, idx) {
  57142. return {
  57143. idx: idx,
  57144. prefixLen: strings.commonPrefixLength(ref.uri.toString(), resource.toString()),
  57145. offsetDist: Math.abs(ref.range.startLineNumber - position.lineNumber) * 100 + Math.abs(ref.range.startColumn - position.column)
  57146. };
  57147. }).sort(function (a, b) {
  57148. if (a.prefixLen > b.prefixLen) {
  57149. return -1;
  57150. }
  57151. else if (a.prefixLen < b.prefixLen) {
  57152. return 1;
  57153. }
  57154. else if (a.offsetDist < b.offsetDist) {
  57155. return -1;
  57156. }
  57157. else if (a.offsetDist > b.offsetDist) {
  57158. return 1;
  57159. }
  57160. else {
  57161. return 0;
  57162. }
  57163. })[0];
  57164. if (nearest) {
  57165. return this.references[nearest.idx];
  57166. }
  57167. return undefined;
  57168. };
  57169. ReferencesModel.prototype.referenceAt = function (resource, position) {
  57170. for (var _i = 0, _a = this.references; _i < _a.length; _i++) {
  57171. var ref = _a[_i];
  57172. if (ref.uri.toString() === resource.toString()) {
  57173. if (range_1.Range.containsPosition(ref.range, position)) {
  57174. return ref;
  57175. }
  57176. }
  57177. }
  57178. return undefined;
  57179. };
  57180. ReferencesModel.prototype.firstReference = function () {
  57181. for (var _i = 0, _a = this.references; _i < _a.length; _i++) {
  57182. var ref = _a[_i];
  57183. if (ref.isProviderFirst) {
  57184. return ref;
  57185. }
  57186. }
  57187. return this.references[0];
  57188. };
  57189. ReferencesModel._compareReferences = function (a, b) {
  57190. return strings.compare(a.uri.toString(), b.uri.toString()) || range_1.Range.compareRangesUsingStarts(a.range, b.range);
  57191. };
  57192. return ReferencesModel;
  57193. }());
  57194. exports.ReferencesModel = ReferencesModel;
  57195. });
  57196. define(__m[452/*vs/nls!vs/editor/contrib/gotoSymbol/symbolNavigation*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/gotoSymbol/symbolNavigation", data); });
  57197. define(__m[453/*vs/nls!vs/editor/contrib/hover/hover*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/hover/hover", data); });
  57198. define(__m[454/*vs/nls!vs/editor/contrib/hover/modesContentHover*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/hover/modesContentHover", data); });
  57199. define(__m[455/*vs/nls!vs/editor/contrib/inPlaceReplace/inPlaceReplace*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/inPlaceReplace/inPlaceReplace", data); });
  57200. define(__m[456/*vs/nls!vs/editor/contrib/linesOperations/linesOperations*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/linesOperations/linesOperations", data); });
  57201. define(__m[457/*vs/nls!vs/editor/contrib/links/links*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/links/links", data); });
  57202. define(__m[458/*vs/nls!vs/editor/contrib/message/messageController*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/message/messageController", data); });
  57203. define(__m[459/*vs/nls!vs/editor/contrib/multicursor/multicursor*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/multicursor/multicursor", data); });
  57204. define(__m[460/*vs/nls!vs/editor/contrib/parameterHints/parameterHints*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/parameterHints/parameterHints", data); });
  57205. define(__m[461/*vs/nls!vs/editor/contrib/parameterHints/parameterHintsWidget*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/parameterHints/parameterHintsWidget", data); });
  57206. define(__m[462/*vs/nls!vs/editor/contrib/peekView/peekView*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/peekView/peekView", data); });
  57207. define(__m[463/*vs/nls!vs/editor/contrib/rename/rename*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/rename/rename", data); });
  57208. define(__m[464/*vs/nls!vs/editor/contrib/rename/renameInputField*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/rename/renameInputField", data); });
  57209. define(__m[465/*vs/nls!vs/editor/contrib/smartSelect/smartSelect*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/smartSelect/smartSelect", data); });
  57210. define(__m[466/*vs/nls!vs/editor/contrib/snippet/snippetVariables*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/snippet/snippetVariables", data); });
  57211. define(__m[467/*vs/nls!vs/editor/contrib/suggest/suggestController*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/suggest/suggestController", data); });
  57212. define(__m[468/*vs/nls!vs/editor/contrib/suggest/suggestWidget*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/suggest/suggestWidget", data); });
  57213. define(__m[469/*vs/nls!vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode", data); });
  57214. define(__m[470/*vs/nls!vs/editor/contrib/tokenization/tokenization*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/tokenization/tokenization", data); });
  57215. define(__m[471/*vs/nls!vs/editor/contrib/wordHighlighter/wordHighlighter*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/editor/contrib/wordHighlighter/wordHighlighter", data); });
  57216. define(__m[472/*vs/nls!vs/platform/configuration/common/configurationRegistry*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/platform/configuration/common/configurationRegistry", data); });
  57217. define(__m[473/*vs/nls!vs/platform/keybinding/common/abstractKeybindingService*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/platform/keybinding/common/abstractKeybindingService", data); });
  57218. define(__m[474/*vs/nls!vs/platform/list/browser/listService*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/platform/list/browser/listService", data); });
  57219. define(__m[475/*vs/nls!vs/platform/markers/common/markers*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/platform/markers/common/markers", data); });
  57220. define(__m[476/*vs/nls!vs/platform/theme/common/colorRegistry*/], __M([7/*vs/nls*/,8/*vs/nls!vs/editor/editor.main*/]), function(nls, data) { return nls.create("vs/platform/theme/common/colorRegistry", data); });
  57221. define(__m[477/*vs/platform/contextkey/common/contextkeys*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  57222. "use strict";
  57223. Object.defineProperty(exports, "__esModule", { value: true });
  57224. exports.InputFocusedContextKey = 'inputFocus';
  57225. });
  57226. /*---------------------------------------------------------------------------------------------
  57227. * Copyright (c) Microsoft Corporation. All rights reserved.
  57228. * Licensed under the MIT License. See License.txt in the project root for license information.
  57229. *--------------------------------------------------------------------------------------------*/
  57230. define(__m[478/*vs/platform/editor/common/editor*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  57231. "use strict";
  57232. Object.defineProperty(exports, "__esModule", { value: true });
  57233. var EditorOpenContext;
  57234. (function (EditorOpenContext) {
  57235. /**
  57236. * Default: the editor is opening via a programmatic call
  57237. * to the editor service API.
  57238. */
  57239. EditorOpenContext[EditorOpenContext["API"] = 0] = "API";
  57240. /**
  57241. * Indicates that a user action triggered the opening, e.g.
  57242. * via mouse or keyboard use.
  57243. */
  57244. EditorOpenContext[EditorOpenContext["USER"] = 1] = "USER";
  57245. })(EditorOpenContext = exports.EditorOpenContext || (exports.EditorOpenContext = {}));
  57246. });
  57247. define(__m[479/*vs/platform/extensions/common/extensions*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  57248. "use strict";
  57249. Object.defineProperty(exports, "__esModule", { value: true });
  57250. /**
  57251. * **!Do not construct directly!**
  57252. *
  57253. * **!Only static methods because it gets serialized!**
  57254. *
  57255. * This represents the "canonical" version for an extension identifier. Extension ids
  57256. * have to be case-insensitive (due to the marketplace), but we must ensure case
  57257. * preservation because the extension API is already public at this time.
  57258. *
  57259. * For example, given an extension with the publisher `"Hello"` and the name `"World"`,
  57260. * its canonical extension identifier is `"Hello.World"`. This extension could be
  57261. * referenced in some other extension's dependencies using the string `"hello.world"`.
  57262. *
  57263. * To make matters more complicated, an extension can optionally have an UUID. When two
  57264. * extensions have the same UUID, they are considered equal even if their identifier is different.
  57265. */
  57266. var ExtensionIdentifier = /** @class */ (function () {
  57267. function ExtensionIdentifier(value) {
  57268. this.value = value;
  57269. this._lower = value.toLowerCase();
  57270. }
  57271. /**
  57272. * Gives the value by which to index (for equality).
  57273. */
  57274. ExtensionIdentifier.toKey = function (id) {
  57275. if (typeof id === 'string') {
  57276. return id.toLowerCase();
  57277. }
  57278. return id._lower;
  57279. };
  57280. return ExtensionIdentifier;
  57281. }());
  57282. exports.ExtensionIdentifier = ExtensionIdentifier;
  57283. });
  57284. define(__m[208/*vs/platform/files/common/files*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  57285. "use strict";
  57286. Object.defineProperty(exports, "__esModule", { value: true });
  57287. var FileKind;
  57288. (function (FileKind) {
  57289. FileKind[FileKind["FILE"] = 0] = "FILE";
  57290. FileKind[FileKind["FOLDER"] = 1] = "FOLDER";
  57291. FileKind[FileKind["ROOT_FOLDER"] = 2] = "ROOT_FOLDER";
  57292. })(FileKind = exports.FileKind || (exports.FileKind = {}));
  57293. });
  57294. define(__m[209/*vs/platform/instantiation/common/descriptors*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  57295. "use strict";
  57296. Object.defineProperty(exports, "__esModule", { value: true });
  57297. var SyncDescriptor = /** @class */ (function () {
  57298. function SyncDescriptor(ctor, staticArguments, supportsDelayedInstantiation) {
  57299. if (staticArguments === void 0) { staticArguments = []; }
  57300. if (supportsDelayedInstantiation === void 0) { supportsDelayedInstantiation = false; }
  57301. this.ctor = ctor;
  57302. this.staticArguments = staticArguments;
  57303. this.supportsDelayedInstantiation = supportsDelayedInstantiation;
  57304. }
  57305. return SyncDescriptor;
  57306. }());
  57307. exports.SyncDescriptor = SyncDescriptor;
  57308. });
  57309. /*---------------------------------------------------------------------------------------------
  57310. * Copyright (c) Microsoft Corporation. All rights reserved.
  57311. * Licensed under the MIT License. See License.txt in the project root for license information.
  57312. *--------------------------------------------------------------------------------------------*/
  57313. define(__m[83/*vs/platform/instantiation/common/extensions*/], __M([0/*require*/,1/*exports*/,209/*vs/platform/instantiation/common/descriptors*/]), function (require, exports, descriptors_1) {
  57314. "use strict";
  57315. Object.defineProperty(exports, "__esModule", { value: true });
  57316. var _registry = [];
  57317. function registerSingleton(id, ctor, supportsDelayedInstantiation) {
  57318. _registry.push([id, new descriptors_1.SyncDescriptor(ctor, [], supportsDelayedInstantiation)]);
  57319. }
  57320. exports.registerSingleton = registerSingleton;
  57321. function getSingletonServiceDescriptors() {
  57322. return _registry;
  57323. }
  57324. exports.getSingletonServiceDescriptors = getSingletonServiceDescriptors;
  57325. });
  57326. /*---------------------------------------------------------------------------------------------
  57327. * Copyright (c) Microsoft Corporation. All rights reserved.
  57328. * Licensed under the MIT License. See License.txt in the project root for license information.
  57329. *--------------------------------------------------------------------------------------------*/
  57330. define(__m[480/*vs/platform/instantiation/common/graph*/], __M([0/*require*/,1/*exports*/,21/*vs/base/common/types*/,87/*vs/base/common/collections*/]), function (require, exports, types_1, collections_1) {
  57331. "use strict";
  57332. Object.defineProperty(exports, "__esModule", { value: true });
  57333. function newNode(data) {
  57334. return {
  57335. data: data,
  57336. incoming: Object.create(null),
  57337. outgoing: Object.create(null)
  57338. };
  57339. }
  57340. var Graph = /** @class */ (function () {
  57341. function Graph(_hashFn) {
  57342. this._hashFn = _hashFn;
  57343. this._nodes = Object.create(null);
  57344. // empty
  57345. }
  57346. Graph.prototype.roots = function () {
  57347. var ret = [];
  57348. collections_1.forEach(this._nodes, function (entry) {
  57349. if (types_1.isEmptyObject(entry.value.outgoing)) {
  57350. ret.push(entry.value);
  57351. }
  57352. });
  57353. return ret;
  57354. };
  57355. Graph.prototype.insertEdge = function (from, to) {
  57356. var fromNode = this.lookupOrInsertNode(from), toNode = this.lookupOrInsertNode(to);
  57357. fromNode.outgoing[this._hashFn(to)] = toNode;
  57358. toNode.incoming[this._hashFn(from)] = fromNode;
  57359. };
  57360. Graph.prototype.removeNode = function (data) {
  57361. var key = this._hashFn(data);
  57362. delete this._nodes[key];
  57363. collections_1.forEach(this._nodes, function (entry) {
  57364. delete entry.value.outgoing[key];
  57365. delete entry.value.incoming[key];
  57366. });
  57367. };
  57368. Graph.prototype.lookupOrInsertNode = function (data) {
  57369. var key = this._hashFn(data);
  57370. var node = this._nodes[key];
  57371. if (!node) {
  57372. node = newNode(data);
  57373. this._nodes[key] = node;
  57374. }
  57375. return node;
  57376. };
  57377. Graph.prototype.isEmpty = function () {
  57378. for (var _key in this._nodes) {
  57379. return false;
  57380. }
  57381. return true;
  57382. };
  57383. Graph.prototype.toString = function () {
  57384. var data = [];
  57385. collections_1.forEach(this._nodes, function (entry) {
  57386. data.push(entry.key + ", (incoming)[" + Object.keys(entry.value.incoming).join(', ') + "], (outgoing)[" + Object.keys(entry.value.outgoing).join(',') + "]");
  57387. });
  57388. return data.join('\n');
  57389. };
  57390. return Graph;
  57391. }());
  57392. exports.Graph = Graph;
  57393. });
  57394. /*---------------------------------------------------------------------------------------------
  57395. * Copyright (c) Microsoft Corporation. All rights reserved.
  57396. * Licensed under the MIT License. See License.txt in the project root for license information.
  57397. *--------------------------------------------------------------------------------------------*/
  57398. define(__m[11/*vs/platform/instantiation/common/instantiation*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  57399. "use strict";
  57400. Object.defineProperty(exports, "__esModule", { value: true });
  57401. // ------ internal util
  57402. var _util;
  57403. (function (_util) {
  57404. _util.serviceIds = new Map();
  57405. _util.DI_TARGET = '$di$target';
  57406. _util.DI_DEPENDENCIES = '$di$dependencies';
  57407. function getServiceDependencies(ctor) {
  57408. return ctor[_util.DI_DEPENDENCIES] || [];
  57409. }
  57410. _util.getServiceDependencies = getServiceDependencies;
  57411. })(_util = exports._util || (exports._util = {}));
  57412. exports.IInstantiationService = createDecorator('instantiationService');
  57413. function storeServiceDependency(id, target, index, optional) {
  57414. if (target[_util.DI_TARGET] === target) {
  57415. target[_util.DI_DEPENDENCIES].push({ id: id, index: index, optional: optional });
  57416. }
  57417. else {
  57418. target[_util.DI_DEPENDENCIES] = [{ id: id, index: index, optional: optional }];
  57419. target[_util.DI_TARGET] = target;
  57420. }
  57421. }
  57422. /**
  57423. * A *only* valid way to create a {{ServiceIdentifier}}.
  57424. */
  57425. function createDecorator(serviceId) {
  57426. if (_util.serviceIds.has(serviceId)) {
  57427. return _util.serviceIds.get(serviceId);
  57428. }
  57429. var id = function (target, key, index) {
  57430. if (arguments.length !== 3) {
  57431. throw new Error('@IServiceName-decorator can only be used to decorate a parameter');
  57432. }
  57433. storeServiceDependency(id, target, index, false);
  57434. };
  57435. id.toString = function () { return serviceId; };
  57436. _util.serviceIds.set(serviceId, id);
  57437. return id;
  57438. }
  57439. exports.createDecorator = createDecorator;
  57440. /**
  57441. * Mark a service dependency as optional.
  57442. */
  57443. function optional(serviceIdentifier) {
  57444. return function (target, key, index) {
  57445. if (arguments.length !== 3) {
  57446. throw new Error('@optional-decorator can only be used to decorate a parameter');
  57447. }
  57448. storeServiceDependency(serviceIdentifier, target, index, true);
  57449. };
  57450. }
  57451. exports.optional = optional;
  57452. });
  57453. /*---------------------------------------------------------------------------------------------
  57454. * Copyright (c) Microsoft Corporation. All rights reserved.
  57455. * Licensed under the MIT License. See License.txt in the project root for license information.
  57456. *--------------------------------------------------------------------------------------------*/
  57457. define(__m[156/*vs/editor/browser/services/bulkEditService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  57458. "use strict";
  57459. Object.defineProperty(exports, "__esModule", { value: true });
  57460. exports.IBulkEditService = instantiation_1.createDecorator('IWorkspaceEditService');
  57461. });
  57462. /*---------------------------------------------------------------------------------------------
  57463. * Copyright (c) Microsoft Corporation. All rights reserved.
  57464. * Licensed under the MIT License. See License.txt in the project root for license information.
  57465. *--------------------------------------------------------------------------------------------*/
  57466. define(__m[32/*vs/editor/browser/services/codeEditorService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  57467. "use strict";
  57468. Object.defineProperty(exports, "__esModule", { value: true });
  57469. exports.ICodeEditorService = instantiation_1.createDecorator('codeEditorService');
  57470. });
  57471. /*---------------------------------------------------------------------------------------------
  57472. * Copyright (c) Microsoft Corporation. All rights reserved.
  57473. * Licensed under the MIT License. See License.txt in the project root for license information.
  57474. *--------------------------------------------------------------------------------------------*/
  57475. define(__m[62/*vs/editor/common/services/editorWorkerService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  57476. "use strict";
  57477. Object.defineProperty(exports, "__esModule", { value: true });
  57478. exports.ID_EDITOR_WORKER_SERVICE = 'editorWorkerService';
  57479. exports.IEditorWorkerService = instantiation_1.createDecorator(exports.ID_EDITOR_WORKER_SERVICE);
  57480. });
  57481. /*---------------------------------------------------------------------------------------------
  57482. * Copyright (c) Microsoft Corporation. All rights reserved.
  57483. * Licensed under the MIT License. See License.txt in the project root for license information.
  57484. *--------------------------------------------------------------------------------------------*/
  57485. define(__m[210/*vs/editor/common/services/markersDecorationService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  57486. "use strict";
  57487. Object.defineProperty(exports, "__esModule", { value: true });
  57488. exports.IMarkerDecorationsService = instantiation_1.createDecorator('markerDecorationsService');
  57489. });
  57490. /*---------------------------------------------------------------------------------------------
  57491. * Copyright (c) Microsoft Corporation. All rights reserved.
  57492. * Licensed under the MIT License. See License.txt in the project root for license information.
  57493. *--------------------------------------------------------------------------------------------*/
  57494. define(__m[71/*vs/editor/common/services/modeService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  57495. "use strict";
  57496. Object.defineProperty(exports, "__esModule", { value: true });
  57497. exports.IModeService = instantiation_1.createDecorator('modeService');
  57498. });
  57499. /*---------------------------------------------------------------------------------------------
  57500. * Copyright (c) Microsoft Corporation. All rights reserved.
  57501. * Licensed under the MIT License. See License.txt in the project root for license information.
  57502. *--------------------------------------------------------------------------------------------*/
  57503. define(__m[49/*vs/editor/common/services/modelService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  57504. "use strict";
  57505. Object.defineProperty(exports, "__esModule", { value: true });
  57506. exports.IModelService = instantiation_1.createDecorator('modelService');
  57507. function shouldSynchronizeModel(model) {
  57508. return (!model.isTooLargeForSyncing() && !model.isForSimpleWidget);
  57509. }
  57510. exports.shouldSynchronizeModel = shouldSynchronizeModel;
  57511. });
  57512. /*---------------------------------------------------------------------------------------------
  57513. * Copyright (c) Microsoft Corporation. All rights reserved.
  57514. * Licensed under the MIT License. See License.txt in the project root for license information.
  57515. *--------------------------------------------------------------------------------------------*/
  57516. define(__m[481/*vs/editor/common/modes/languageFeatureRegistry*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,350/*vs/editor/common/modes/languageSelector*/,49/*vs/editor/common/services/modelService*/]), function (require, exports, event_1, lifecycle_1, languageSelector_1, modelService_1) {
  57517. "use strict";
  57518. Object.defineProperty(exports, "__esModule", { value: true });
  57519. function isExclusive(selector) {
  57520. if (typeof selector === 'string') {
  57521. return false;
  57522. }
  57523. else if (Array.isArray(selector)) {
  57524. return selector.every(isExclusive);
  57525. }
  57526. else {
  57527. return !!selector.exclusive;
  57528. }
  57529. }
  57530. var LanguageFeatureRegistry = /** @class */ (function () {
  57531. function LanguageFeatureRegistry() {
  57532. this._clock = 0;
  57533. this._entries = [];
  57534. this._onDidChange = new event_1.Emitter();
  57535. }
  57536. Object.defineProperty(LanguageFeatureRegistry.prototype, "onDidChange", {
  57537. get: function () {
  57538. return this._onDidChange.event;
  57539. },
  57540. enumerable: true,
  57541. configurable: true
  57542. });
  57543. LanguageFeatureRegistry.prototype.register = function (selector, provider) {
  57544. var _this = this;
  57545. var entry = {
  57546. selector: selector,
  57547. provider: provider,
  57548. _score: -1,
  57549. _time: this._clock++
  57550. };
  57551. this._entries.push(entry);
  57552. this._lastCandidate = undefined;
  57553. this._onDidChange.fire(this._entries.length);
  57554. return lifecycle_1.toDisposable(function () {
  57555. if (entry) {
  57556. var idx = _this._entries.indexOf(entry);
  57557. if (idx >= 0) {
  57558. _this._entries.splice(idx, 1);
  57559. _this._lastCandidate = undefined;
  57560. _this._onDidChange.fire(_this._entries.length);
  57561. entry = undefined;
  57562. }
  57563. }
  57564. });
  57565. };
  57566. LanguageFeatureRegistry.prototype.has = function (model) {
  57567. return this.all(model).length > 0;
  57568. };
  57569. LanguageFeatureRegistry.prototype.all = function (model) {
  57570. if (!model) {
  57571. return [];
  57572. }
  57573. this._updateScores(model);
  57574. var result = [];
  57575. // from registry
  57576. for (var _i = 0, _a = this._entries; _i < _a.length; _i++) {
  57577. var entry = _a[_i];
  57578. if (entry._score > 0) {
  57579. result.push(entry.provider);
  57580. }
  57581. }
  57582. return result;
  57583. };
  57584. LanguageFeatureRegistry.prototype.ordered = function (model) {
  57585. var result = [];
  57586. this._orderedForEach(model, function (entry) { return result.push(entry.provider); });
  57587. return result;
  57588. };
  57589. LanguageFeatureRegistry.prototype.orderedGroups = function (model) {
  57590. var result = [];
  57591. var lastBucket;
  57592. var lastBucketScore;
  57593. this._orderedForEach(model, function (entry) {
  57594. if (lastBucket && lastBucketScore === entry._score) {
  57595. lastBucket.push(entry.provider);
  57596. }
  57597. else {
  57598. lastBucketScore = entry._score;
  57599. lastBucket = [entry.provider];
  57600. result.push(lastBucket);
  57601. }
  57602. });
  57603. return result;
  57604. };
  57605. LanguageFeatureRegistry.prototype._orderedForEach = function (model, callback) {
  57606. if (!model) {
  57607. return;
  57608. }
  57609. this._updateScores(model);
  57610. for (var _i = 0, _a = this._entries; _i < _a.length; _i++) {
  57611. var entry = _a[_i];
  57612. if (entry._score > 0) {
  57613. callback(entry);
  57614. }
  57615. }
  57616. };
  57617. LanguageFeatureRegistry.prototype._updateScores = function (model) {
  57618. var candidate = {
  57619. uri: model.uri.toString(),
  57620. language: model.getLanguageIdentifier().language
  57621. };
  57622. if (this._lastCandidate
  57623. && this._lastCandidate.language === candidate.language
  57624. && this._lastCandidate.uri === candidate.uri) {
  57625. // nothing has changed
  57626. return;
  57627. }
  57628. this._lastCandidate = candidate;
  57629. for (var _i = 0, _a = this._entries; _i < _a.length; _i++) {
  57630. var entry = _a[_i];
  57631. entry._score = languageSelector_1.score(entry.selector, model.uri, model.getLanguageIdentifier().language, modelService_1.shouldSynchronizeModel(model));
  57632. if (isExclusive(entry.selector) && entry._score > 0) {
  57633. // support for one exclusive selector that overwrites
  57634. // any other selector
  57635. for (var _b = 0, _c = this._entries; _b < _c.length; _b++) {
  57636. var entry_1 = _c[_b];
  57637. entry_1._score = 0;
  57638. }
  57639. entry._score = 1000;
  57640. break;
  57641. }
  57642. }
  57643. // needs sorting
  57644. this._entries.sort(LanguageFeatureRegistry._compareByScoreAndTime);
  57645. };
  57646. LanguageFeatureRegistry._compareByScoreAndTime = function (a, b) {
  57647. if (a._score < b._score) {
  57648. return 1;
  57649. }
  57650. else if (a._score > b._score) {
  57651. return -1;
  57652. }
  57653. else if (a._time < b._time) {
  57654. return 1;
  57655. }
  57656. else if (a._time > b._time) {
  57657. return -1;
  57658. }
  57659. else {
  57660. return 0;
  57661. }
  57662. };
  57663. return LanguageFeatureRegistry;
  57664. }());
  57665. exports.LanguageFeatureRegistry = LanguageFeatureRegistry;
  57666. });
  57667. /*---------------------------------------------------------------------------------------------
  57668. * Copyright (c) Microsoft Corporation. All rights reserved.
  57669. * Licensed under the MIT License. See License.txt in the project root for license information.
  57670. *--------------------------------------------------------------------------------------------*/
  57671. define(__m[17/*vs/editor/common/modes*/], __M([0/*require*/,1/*exports*/,21/*vs/base/common/types*/,25/*vs/base/common/uri*/,3/*vs/editor/common/core/range*/,481/*vs/editor/common/modes/languageFeatureRegistry*/,358/*vs/editor/common/modes/tokenizationRegistry*/]), function (require, exports, types_1, uri_1, range_1, languageFeatureRegistry_1, tokenizationRegistry_1) {
  57672. "use strict";
  57673. Object.defineProperty(exports, "__esModule", { value: true });
  57674. /**
  57675. * @internal
  57676. */
  57677. var LanguageIdentifier = /** @class */ (function () {
  57678. function LanguageIdentifier(language, id) {
  57679. this.language = language;
  57680. this.id = id;
  57681. }
  57682. return LanguageIdentifier;
  57683. }());
  57684. exports.LanguageIdentifier = LanguageIdentifier;
  57685. /**
  57686. * @internal
  57687. */
  57688. var TokenMetadata = /** @class */ (function () {
  57689. function TokenMetadata() {
  57690. }
  57691. TokenMetadata.getLanguageId = function (metadata) {
  57692. return (metadata & 255 /* LANGUAGEID_MASK */) >>> 0 /* LANGUAGEID_OFFSET */;
  57693. };
  57694. TokenMetadata.getTokenType = function (metadata) {
  57695. return (metadata & 1792 /* TOKEN_TYPE_MASK */) >>> 8 /* TOKEN_TYPE_OFFSET */;
  57696. };
  57697. TokenMetadata.getFontStyle = function (metadata) {
  57698. return (metadata & 14336 /* FONT_STYLE_MASK */) >>> 11 /* FONT_STYLE_OFFSET */;
  57699. };
  57700. TokenMetadata.getForeground = function (metadata) {
  57701. return (metadata & 8372224 /* FOREGROUND_MASK */) >>> 14 /* FOREGROUND_OFFSET */;
  57702. };
  57703. TokenMetadata.getBackground = function (metadata) {
  57704. return (metadata & 4286578688 /* BACKGROUND_MASK */) >>> 23 /* BACKGROUND_OFFSET */;
  57705. };
  57706. TokenMetadata.getClassNameFromMetadata = function (metadata) {
  57707. var foreground = this.getForeground(metadata);
  57708. var className = 'mtk' + foreground;
  57709. var fontStyle = this.getFontStyle(metadata);
  57710. if (fontStyle & 1 /* Italic */) {
  57711. className += ' mtki';
  57712. }
  57713. if (fontStyle & 2 /* Bold */) {
  57714. className += ' mtkb';
  57715. }
  57716. if (fontStyle & 4 /* Underline */) {
  57717. className += ' mtku';
  57718. }
  57719. return className;
  57720. };
  57721. TokenMetadata.getInlineStyleFromMetadata = function (metadata, colorMap) {
  57722. var foreground = this.getForeground(metadata);
  57723. var fontStyle = this.getFontStyle(metadata);
  57724. var result = "color: " + colorMap[foreground] + ";";
  57725. if (fontStyle & 1 /* Italic */) {
  57726. result += 'font-style: italic;';
  57727. }
  57728. if (fontStyle & 2 /* Bold */) {
  57729. result += 'font-weight: bold;';
  57730. }
  57731. if (fontStyle & 4 /* Underline */) {
  57732. result += 'text-decoration: underline;';
  57733. }
  57734. return result;
  57735. };
  57736. return TokenMetadata;
  57737. }());
  57738. exports.TokenMetadata = TokenMetadata;
  57739. /**
  57740. * @internal
  57741. */
  57742. exports.completionKindToCssClass = (function () {
  57743. var data = Object.create(null);
  57744. data[0 /* Method */] = 'method';
  57745. data[1 /* Function */] = 'function';
  57746. data[2 /* Constructor */] = 'constructor';
  57747. data[3 /* Field */] = 'field';
  57748. data[4 /* Variable */] = 'variable';
  57749. data[5 /* Class */] = 'class';
  57750. data[6 /* Struct */] = 'struct';
  57751. data[7 /* Interface */] = 'interface';
  57752. data[8 /* Module */] = 'module';
  57753. data[9 /* Property */] = 'property';
  57754. data[10 /* Event */] = 'event';
  57755. data[11 /* Operator */] = 'operator';
  57756. data[12 /* Unit */] = 'unit';
  57757. data[13 /* Value */] = 'value';
  57758. data[14 /* Constant */] = 'constant';
  57759. data[15 /* Enum */] = 'enum';
  57760. data[16 /* EnumMember */] = 'enum-member';
  57761. data[17 /* Keyword */] = 'keyword';
  57762. data[25 /* Snippet */] = 'snippet';
  57763. data[18 /* Text */] = 'text';
  57764. data[19 /* Color */] = 'color';
  57765. data[20 /* File */] = 'file';
  57766. data[21 /* Reference */] = 'reference';
  57767. data[22 /* Customcolor */] = 'customcolor';
  57768. data[23 /* Folder */] = 'folder';
  57769. data[24 /* TypeParameter */] = 'type-parameter';
  57770. return function (kind) {
  57771. return data[kind] || 'property';
  57772. };
  57773. })();
  57774. /**
  57775. * @internal
  57776. */
  57777. exports.completionKindFromString = (function () {
  57778. var data = Object.create(null);
  57779. data['method'] = 0 /* Method */;
  57780. data['function'] = 1 /* Function */;
  57781. data['constructor'] = 2 /* Constructor */;
  57782. data['field'] = 3 /* Field */;
  57783. data['variable'] = 4 /* Variable */;
  57784. data['class'] = 5 /* Class */;
  57785. data['struct'] = 6 /* Struct */;
  57786. data['interface'] = 7 /* Interface */;
  57787. data['module'] = 8 /* Module */;
  57788. data['property'] = 9 /* Property */;
  57789. data['event'] = 10 /* Event */;
  57790. data['operator'] = 11 /* Operator */;
  57791. data['unit'] = 12 /* Unit */;
  57792. data['value'] = 13 /* Value */;
  57793. data['constant'] = 14 /* Constant */;
  57794. data['enum'] = 15 /* Enum */;
  57795. data['enum-member'] = 16 /* EnumMember */;
  57796. data['enumMember'] = 16 /* EnumMember */;
  57797. data['keyword'] = 17 /* Keyword */;
  57798. data['snippet'] = 25 /* Snippet */;
  57799. data['text'] = 18 /* Text */;
  57800. data['color'] = 19 /* Color */;
  57801. data['file'] = 20 /* File */;
  57802. data['reference'] = 21 /* Reference */;
  57803. data['customcolor'] = 22 /* Customcolor */;
  57804. data['folder'] = 23 /* Folder */;
  57805. data['type-parameter'] = 24 /* TypeParameter */;
  57806. data['typeParameter'] = 24 /* TypeParameter */;
  57807. return function (value, strict) {
  57808. var res = data[value];
  57809. if (typeof res === 'undefined' && !strict) {
  57810. res = 9 /* Property */;
  57811. }
  57812. return res;
  57813. };
  57814. })();
  57815. var SignatureHelpTriggerKind;
  57816. (function (SignatureHelpTriggerKind) {
  57817. SignatureHelpTriggerKind[SignatureHelpTriggerKind["Invoke"] = 1] = "Invoke";
  57818. SignatureHelpTriggerKind[SignatureHelpTriggerKind["TriggerCharacter"] = 2] = "TriggerCharacter";
  57819. SignatureHelpTriggerKind[SignatureHelpTriggerKind["ContentChange"] = 3] = "ContentChange";
  57820. })(SignatureHelpTriggerKind = exports.SignatureHelpTriggerKind || (exports.SignatureHelpTriggerKind = {}));
  57821. /**
  57822. * A document highlight kind.
  57823. */
  57824. var DocumentHighlightKind;
  57825. (function (DocumentHighlightKind) {
  57826. /**
  57827. * A textual occurrence.
  57828. */
  57829. DocumentHighlightKind[DocumentHighlightKind["Text"] = 0] = "Text";
  57830. /**
  57831. * Read-access of a symbol, like reading a variable.
  57832. */
  57833. DocumentHighlightKind[DocumentHighlightKind["Read"] = 1] = "Read";
  57834. /**
  57835. * Write-access of a symbol, like writing to a variable.
  57836. */
  57837. DocumentHighlightKind[DocumentHighlightKind["Write"] = 2] = "Write";
  57838. })(DocumentHighlightKind = exports.DocumentHighlightKind || (exports.DocumentHighlightKind = {}));
  57839. /**
  57840. * @internal
  57841. */
  57842. function isLocationLink(thing) {
  57843. return thing
  57844. && uri_1.URI.isUri(thing.uri)
  57845. && range_1.Range.isIRange(thing.range)
  57846. && (range_1.Range.isIRange(thing.originSelectionRange) || range_1.Range.isIRange(thing.targetSelectionRange));
  57847. }
  57848. exports.isLocationLink = isLocationLink;
  57849. /**
  57850. * @internal
  57851. */
  57852. var SymbolKinds;
  57853. (function (SymbolKinds) {
  57854. var byName = new Map();
  57855. byName.set('file', 0 /* File */);
  57856. byName.set('module', 1 /* Module */);
  57857. byName.set('namespace', 2 /* Namespace */);
  57858. byName.set('package', 3 /* Package */);
  57859. byName.set('class', 4 /* Class */);
  57860. byName.set('method', 5 /* Method */);
  57861. byName.set('property', 6 /* Property */);
  57862. byName.set('field', 7 /* Field */);
  57863. byName.set('constructor', 8 /* Constructor */);
  57864. byName.set('enum', 9 /* Enum */);
  57865. byName.set('interface', 10 /* Interface */);
  57866. byName.set('function', 11 /* Function */);
  57867. byName.set('variable', 12 /* Variable */);
  57868. byName.set('constant', 13 /* Constant */);
  57869. byName.set('string', 14 /* String */);
  57870. byName.set('number', 15 /* Number */);
  57871. byName.set('boolean', 16 /* Boolean */);
  57872. byName.set('array', 17 /* Array */);
  57873. byName.set('object', 18 /* Object */);
  57874. byName.set('key', 19 /* Key */);
  57875. byName.set('null', 20 /* Null */);
  57876. byName.set('enum-member', 21 /* EnumMember */);
  57877. byName.set('struct', 22 /* Struct */);
  57878. byName.set('event', 23 /* Event */);
  57879. byName.set('operator', 24 /* Operator */);
  57880. byName.set('type-parameter', 25 /* TypeParameter */);
  57881. var byKind = new Map();
  57882. byKind.set(0 /* File */, 'file');
  57883. byKind.set(1 /* Module */, 'module');
  57884. byKind.set(2 /* Namespace */, 'namespace');
  57885. byKind.set(3 /* Package */, 'package');
  57886. byKind.set(4 /* Class */, 'class');
  57887. byKind.set(5 /* Method */, 'method');
  57888. byKind.set(6 /* Property */, 'property');
  57889. byKind.set(7 /* Field */, 'field');
  57890. byKind.set(8 /* Constructor */, 'constructor');
  57891. byKind.set(9 /* Enum */, 'enum');
  57892. byKind.set(10 /* Interface */, 'interface');
  57893. byKind.set(11 /* Function */, 'function');
  57894. byKind.set(12 /* Variable */, 'variable');
  57895. byKind.set(13 /* Constant */, 'constant');
  57896. byKind.set(14 /* String */, 'string');
  57897. byKind.set(15 /* Number */, 'number');
  57898. byKind.set(16 /* Boolean */, 'boolean');
  57899. byKind.set(17 /* Array */, 'array');
  57900. byKind.set(18 /* Object */, 'object');
  57901. byKind.set(19 /* Key */, 'key');
  57902. byKind.set(20 /* Null */, 'null');
  57903. byKind.set(21 /* EnumMember */, 'enum-member');
  57904. byKind.set(22 /* Struct */, 'struct');
  57905. byKind.set(23 /* Event */, 'event');
  57906. byKind.set(24 /* Operator */, 'operator');
  57907. byKind.set(25 /* TypeParameter */, 'type-parameter');
  57908. /**
  57909. * @internal
  57910. */
  57911. function fromString(value) {
  57912. return byName.get(value);
  57913. }
  57914. SymbolKinds.fromString = fromString;
  57915. /**
  57916. * @internal
  57917. */
  57918. function toString(kind) {
  57919. return byKind.get(kind);
  57920. }
  57921. SymbolKinds.toString = toString;
  57922. /**
  57923. * @internal
  57924. */
  57925. function toCssClassName(kind, inline) {
  57926. return "codicon " + (inline ? 'inline' : 'block') + " codicon-symbol-" + (byKind.get(kind) || 'property');
  57927. }
  57928. SymbolKinds.toCssClassName = toCssClassName;
  57929. })(SymbolKinds = exports.SymbolKinds || (exports.SymbolKinds = {}));
  57930. var FoldingRangeKind = /** @class */ (function () {
  57931. /**
  57932. * Creates a new [FoldingRangeKind](#FoldingRangeKind).
  57933. *
  57934. * @param value of the kind.
  57935. */
  57936. function FoldingRangeKind(value) {
  57937. this.value = value;
  57938. }
  57939. /**
  57940. * Kind for folding range representing a comment. The value of the kind is 'comment'.
  57941. */
  57942. FoldingRangeKind.Comment = new FoldingRangeKind('comment');
  57943. /**
  57944. * Kind for folding range representing a import. The value of the kind is 'imports'.
  57945. */
  57946. FoldingRangeKind.Imports = new FoldingRangeKind('imports');
  57947. /**
  57948. * Kind for folding range representing regions (for example marked by `#region`, `#endregion`).
  57949. * The value of the kind is 'region'.
  57950. */
  57951. FoldingRangeKind.Region = new FoldingRangeKind('region');
  57952. return FoldingRangeKind;
  57953. }());
  57954. exports.FoldingRangeKind = FoldingRangeKind;
  57955. /**
  57956. * @internal
  57957. */
  57958. var WorkspaceFileEdit;
  57959. (function (WorkspaceFileEdit) {
  57960. /**
  57961. * @internal
  57962. */
  57963. function is(thing) {
  57964. return types_1.isObject(thing) && (Boolean(thing.newUri) || Boolean(thing.oldUri));
  57965. }
  57966. WorkspaceFileEdit.is = is;
  57967. })(WorkspaceFileEdit = exports.WorkspaceFileEdit || (exports.WorkspaceFileEdit = {}));
  57968. /**
  57969. * @internal
  57970. */
  57971. var WorkspaceTextEdit;
  57972. (function (WorkspaceTextEdit) {
  57973. /**
  57974. * @internal
  57975. */
  57976. function is(thing) {
  57977. return types_1.isObject(thing) && uri_1.URI.isUri(thing.resource) && types_1.isObject(thing.edit);
  57978. }
  57979. WorkspaceTextEdit.is = is;
  57980. })(WorkspaceTextEdit = exports.WorkspaceTextEdit || (exports.WorkspaceTextEdit = {}));
  57981. // --- feature registries ------
  57982. /**
  57983. * @internal
  57984. */
  57985. exports.ReferenceProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  57986. /**
  57987. * @internal
  57988. */
  57989. exports.RenameProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  57990. /**
  57991. * @internal
  57992. */
  57993. exports.CompletionProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  57994. /**
  57995. * @internal
  57996. */
  57997. exports.SignatureHelpProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  57998. /**
  57999. * @internal
  58000. */
  58001. exports.HoverProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58002. /**
  58003. * @internal
  58004. */
  58005. exports.DocumentSymbolProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58006. /**
  58007. * @internal
  58008. */
  58009. exports.DocumentHighlightProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58010. /**
  58011. * @internal
  58012. */
  58013. exports.DefinitionProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58014. /**
  58015. * @internal
  58016. */
  58017. exports.DeclarationProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58018. /**
  58019. * @internal
  58020. */
  58021. exports.ImplementationProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58022. /**
  58023. * @internal
  58024. */
  58025. exports.TypeDefinitionProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58026. /**
  58027. * @internal
  58028. */
  58029. exports.CodeLensProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58030. /**
  58031. * @internal
  58032. */
  58033. exports.CodeActionProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58034. /**
  58035. * @internal
  58036. */
  58037. exports.DocumentFormattingEditProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58038. /**
  58039. * @internal
  58040. */
  58041. exports.DocumentRangeFormattingEditProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58042. /**
  58043. * @internal
  58044. */
  58045. exports.OnTypeFormattingEditProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58046. /**
  58047. * @internal
  58048. */
  58049. exports.LinkProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58050. /**
  58051. * @internal
  58052. */
  58053. exports.ColorProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58054. /**
  58055. * @internal
  58056. */
  58057. exports.SelectionRangeRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58058. /**
  58059. * @internal
  58060. */
  58061. exports.FoldingRangeProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58062. /**
  58063. * @internal
  58064. */
  58065. exports.DocumentSemanticTokensProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58066. /**
  58067. * @internal
  58068. */
  58069. exports.DocumentRangeSemanticTokensProviderRegistry = new languageFeatureRegistry_1.LanguageFeatureRegistry();
  58070. /**
  58071. * @internal
  58072. */
  58073. exports.TokenizationRegistry = new tokenizationRegistry_1.TokenizationRegistryImpl();
  58074. });
  58075. /*---------------------------------------------------------------------------------------------
  58076. * Copyright (c) Microsoft Corporation. All rights reserved.
  58077. * Licensed under the MIT License. See License.txt in the project root for license information.
  58078. *--------------------------------------------------------------------------------------------*/
  58079. define(__m[93/*vs/editor/common/core/lineTokens*/], __M([0/*require*/,1/*exports*/,17/*vs/editor/common/modes*/]), function (require, exports, modes_1) {
  58080. "use strict";
  58081. Object.defineProperty(exports, "__esModule", { value: true });
  58082. var LineTokens = /** @class */ (function () {
  58083. function LineTokens(tokens, text) {
  58084. this._tokens = tokens;
  58085. this._tokensCount = (this._tokens.length >>> 1);
  58086. this._text = text;
  58087. }
  58088. LineTokens.prototype.equals = function (other) {
  58089. if (other instanceof LineTokens) {
  58090. return this.slicedEquals(other, 0, this._tokensCount);
  58091. }
  58092. return false;
  58093. };
  58094. LineTokens.prototype.slicedEquals = function (other, sliceFromTokenIndex, sliceTokenCount) {
  58095. if (this._text !== other._text) {
  58096. return false;
  58097. }
  58098. if (this._tokensCount !== other._tokensCount) {
  58099. return false;
  58100. }
  58101. var from = (sliceFromTokenIndex << 1);
  58102. var to = from + (sliceTokenCount << 1);
  58103. for (var i = from; i < to; i++) {
  58104. if (this._tokens[i] !== other._tokens[i]) {
  58105. return false;
  58106. }
  58107. }
  58108. return true;
  58109. };
  58110. LineTokens.prototype.getLineContent = function () {
  58111. return this._text;
  58112. };
  58113. LineTokens.prototype.getCount = function () {
  58114. return this._tokensCount;
  58115. };
  58116. LineTokens.prototype.getStartOffset = function (tokenIndex) {
  58117. if (tokenIndex > 0) {
  58118. return this._tokens[(tokenIndex - 1) << 1];
  58119. }
  58120. return 0;
  58121. };
  58122. LineTokens.prototype.getMetadata = function (tokenIndex) {
  58123. var metadata = this._tokens[(tokenIndex << 1) + 1];
  58124. return metadata;
  58125. };
  58126. LineTokens.prototype.getLanguageId = function (tokenIndex) {
  58127. var metadata = this._tokens[(tokenIndex << 1) + 1];
  58128. return modes_1.TokenMetadata.getLanguageId(metadata);
  58129. };
  58130. LineTokens.prototype.getStandardTokenType = function (tokenIndex) {
  58131. var metadata = this._tokens[(tokenIndex << 1) + 1];
  58132. return modes_1.TokenMetadata.getTokenType(metadata);
  58133. };
  58134. LineTokens.prototype.getForeground = function (tokenIndex) {
  58135. var metadata = this._tokens[(tokenIndex << 1) + 1];
  58136. return modes_1.TokenMetadata.getForeground(metadata);
  58137. };
  58138. LineTokens.prototype.getClassName = function (tokenIndex) {
  58139. var metadata = this._tokens[(tokenIndex << 1) + 1];
  58140. return modes_1.TokenMetadata.getClassNameFromMetadata(metadata);
  58141. };
  58142. LineTokens.prototype.getInlineStyle = function (tokenIndex, colorMap) {
  58143. var metadata = this._tokens[(tokenIndex << 1) + 1];
  58144. return modes_1.TokenMetadata.getInlineStyleFromMetadata(metadata, colorMap);
  58145. };
  58146. LineTokens.prototype.getEndOffset = function (tokenIndex) {
  58147. return this._tokens[tokenIndex << 1];
  58148. };
  58149. /**
  58150. * Find the token containing offset `offset`.
  58151. * @param offset The search offset
  58152. * @return The index of the token containing the offset.
  58153. */
  58154. LineTokens.prototype.findTokenIndexAtOffset = function (offset) {
  58155. return LineTokens.findIndexInTokensArray(this._tokens, offset);
  58156. };
  58157. LineTokens.prototype.inflate = function () {
  58158. return this;
  58159. };
  58160. LineTokens.prototype.sliceAndInflate = function (startOffset, endOffset, deltaOffset) {
  58161. return new SlicedLineTokens(this, startOffset, endOffset, deltaOffset);
  58162. };
  58163. LineTokens.convertToEndOffset = function (tokens, lineTextLength) {
  58164. var tokenCount = (tokens.length >>> 1);
  58165. var lastTokenIndex = tokenCount - 1;
  58166. for (var tokenIndex = 0; tokenIndex < lastTokenIndex; tokenIndex++) {
  58167. tokens[tokenIndex << 1] = tokens[(tokenIndex + 1) << 1];
  58168. }
  58169. tokens[lastTokenIndex << 1] = lineTextLength;
  58170. };
  58171. LineTokens.findIndexInTokensArray = function (tokens, desiredIndex) {
  58172. if (tokens.length <= 2) {
  58173. return 0;
  58174. }
  58175. var low = 0;
  58176. var high = (tokens.length >>> 1) - 1;
  58177. while (low < high) {
  58178. var mid = low + Math.floor((high - low) / 2);
  58179. var endOffset = tokens[(mid << 1)];
  58180. if (endOffset === desiredIndex) {
  58181. return mid + 1;
  58182. }
  58183. else if (endOffset < desiredIndex) {
  58184. low = mid + 1;
  58185. }
  58186. else if (endOffset > desiredIndex) {
  58187. high = mid;
  58188. }
  58189. }
  58190. return low;
  58191. };
  58192. return LineTokens;
  58193. }());
  58194. exports.LineTokens = LineTokens;
  58195. var SlicedLineTokens = /** @class */ (function () {
  58196. function SlicedLineTokens(source, startOffset, endOffset, deltaOffset) {
  58197. this._source = source;
  58198. this._startOffset = startOffset;
  58199. this._endOffset = endOffset;
  58200. this._deltaOffset = deltaOffset;
  58201. this._firstTokenIndex = source.findTokenIndexAtOffset(startOffset);
  58202. this._tokensCount = 0;
  58203. for (var i = this._firstTokenIndex, len = source.getCount(); i < len; i++) {
  58204. var tokenStartOffset = source.getStartOffset(i);
  58205. if (tokenStartOffset >= endOffset) {
  58206. break;
  58207. }
  58208. this._tokensCount++;
  58209. }
  58210. }
  58211. SlicedLineTokens.prototype.equals = function (other) {
  58212. if (other instanceof SlicedLineTokens) {
  58213. return (this._startOffset === other._startOffset
  58214. && this._endOffset === other._endOffset
  58215. && this._deltaOffset === other._deltaOffset
  58216. && this._source.slicedEquals(other._source, this._firstTokenIndex, this._tokensCount));
  58217. }
  58218. return false;
  58219. };
  58220. SlicedLineTokens.prototype.getCount = function () {
  58221. return this._tokensCount;
  58222. };
  58223. SlicedLineTokens.prototype.getForeground = function (tokenIndex) {
  58224. return this._source.getForeground(this._firstTokenIndex + tokenIndex);
  58225. };
  58226. SlicedLineTokens.prototype.getEndOffset = function (tokenIndex) {
  58227. var tokenEndOffset = this._source.getEndOffset(this._firstTokenIndex + tokenIndex);
  58228. return Math.min(this._endOffset, tokenEndOffset) - this._startOffset + this._deltaOffset;
  58229. };
  58230. SlicedLineTokens.prototype.getClassName = function (tokenIndex) {
  58231. return this._source.getClassName(this._firstTokenIndex + tokenIndex);
  58232. };
  58233. SlicedLineTokens.prototype.getInlineStyle = function (tokenIndex, colorMap) {
  58234. return this._source.getInlineStyle(this._firstTokenIndex + tokenIndex, colorMap);
  58235. };
  58236. SlicedLineTokens.prototype.findTokenIndexAtOffset = function (offset) {
  58237. return this._source.findTokenIndexAtOffset(offset + this._startOffset - this._deltaOffset) - this._firstTokenIndex;
  58238. };
  58239. return SlicedLineTokens;
  58240. }());
  58241. exports.SlicedLineTokens = SlicedLineTokens;
  58242. });
  58243. /*---------------------------------------------------------------------------------------------
  58244. * Copyright (c) Microsoft Corporation. All rights reserved.
  58245. * Licensed under the MIT License. See License.txt in the project root for license information.
  58246. *--------------------------------------------------------------------------------------------*/
  58247. define(__m[157/*vs/editor/common/model/tokensStore*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,93/*vs/editor/common/core/lineTokens*/,13/*vs/editor/common/core/position*/,17/*vs/editor/common/modes*/]), function (require, exports, arrays, lineTokens_1, position_1, modes_1) {
  58248. "use strict";
  58249. Object.defineProperty(exports, "__esModule", { value: true });
  58250. function countEOL(text) {
  58251. var eolCount = 0;
  58252. var firstLineLength = 0;
  58253. var lastLineStart = 0;
  58254. for (var i = 0, len = text.length; i < len; i++) {
  58255. var chr = text.charCodeAt(i);
  58256. if (chr === 13 /* CarriageReturn */) {
  58257. if (eolCount === 0) {
  58258. firstLineLength = i;
  58259. }
  58260. eolCount++;
  58261. if (i + 1 < len && text.charCodeAt(i + 1) === 10 /* LineFeed */) {
  58262. // \r\n... case
  58263. i++; // skip \n
  58264. }
  58265. else {
  58266. // \r... case
  58267. }
  58268. lastLineStart = i + 1;
  58269. }
  58270. else if (chr === 10 /* LineFeed */) {
  58271. if (eolCount === 0) {
  58272. firstLineLength = i;
  58273. }
  58274. eolCount++;
  58275. lastLineStart = i + 1;
  58276. }
  58277. }
  58278. if (eolCount === 0) {
  58279. firstLineLength = text.length;
  58280. }
  58281. return [eolCount, firstLineLength, text.length - lastLineStart];
  58282. }
  58283. exports.countEOL = countEOL;
  58284. function getDefaultMetadata(topLevelLanguageId) {
  58285. return ((topLevelLanguageId << 0 /* LANGUAGEID_OFFSET */)
  58286. | (0 /* Other */ << 8 /* TOKEN_TYPE_OFFSET */)
  58287. | (0 /* None */ << 11 /* FONT_STYLE_OFFSET */)
  58288. | (1 /* DefaultForeground */ << 14 /* FOREGROUND_OFFSET */)
  58289. | (2 /* DefaultBackground */ << 23 /* BACKGROUND_OFFSET */)) >>> 0;
  58290. }
  58291. var EMPTY_LINE_TOKENS = (new Uint32Array(0)).buffer;
  58292. var MultilineTokensBuilder = /** @class */ (function () {
  58293. function MultilineTokensBuilder() {
  58294. this.tokens = [];
  58295. }
  58296. MultilineTokensBuilder.prototype.add = function (lineNumber, lineTokens) {
  58297. if (this.tokens.length > 0) {
  58298. var last = this.tokens[this.tokens.length - 1];
  58299. var lastLineNumber = last.startLineNumber + last.tokens.length - 1;
  58300. if (lastLineNumber + 1 === lineNumber) {
  58301. // append
  58302. last.tokens.push(lineTokens);
  58303. return;
  58304. }
  58305. }
  58306. this.tokens.push(new MultilineTokens(lineNumber, [lineTokens]));
  58307. };
  58308. return MultilineTokensBuilder;
  58309. }());
  58310. exports.MultilineTokensBuilder = MultilineTokensBuilder;
  58311. var SparseEncodedTokens = /** @class */ (function () {
  58312. function SparseEncodedTokens(tokens) {
  58313. this._tokens = tokens;
  58314. this._tokenCount = tokens.length / 4;
  58315. }
  58316. SparseEncodedTokens.prototype.getMaxDeltaLine = function () {
  58317. var tokenCount = this.getTokenCount();
  58318. if (tokenCount === 0) {
  58319. return -1;
  58320. }
  58321. return this.getDeltaLine(tokenCount - 1);
  58322. };
  58323. SparseEncodedTokens.prototype.getTokenCount = function () {
  58324. return this._tokenCount;
  58325. };
  58326. SparseEncodedTokens.prototype.getDeltaLine = function (tokenIndex) {
  58327. return this._tokens[4 * tokenIndex];
  58328. };
  58329. SparseEncodedTokens.prototype.getStartCharacter = function (tokenIndex) {
  58330. return this._tokens[4 * tokenIndex + 1];
  58331. };
  58332. SparseEncodedTokens.prototype.getEndCharacter = function (tokenIndex) {
  58333. return this._tokens[4 * tokenIndex + 2];
  58334. };
  58335. SparseEncodedTokens.prototype.getMetadata = function (tokenIndex) {
  58336. return this._tokens[4 * tokenIndex + 3];
  58337. };
  58338. SparseEncodedTokens.prototype.clear = function () {
  58339. this._tokenCount = 0;
  58340. };
  58341. SparseEncodedTokens.prototype.acceptDeleteRange = function (horizontalShiftForFirstLineTokens, startDeltaLine, startCharacter, endDeltaLine, endCharacter) {
  58342. // This is a bit complex, here are the cases I used to think about this:
  58343. //
  58344. // 1. The token starts before the deletion range
  58345. // 1a. The token is completely before the deletion range
  58346. // -----------
  58347. // xxxxxxxxxxx
  58348. // 1b. The token starts before, the deletion range ends after the token
  58349. // -----------
  58350. // xxxxxxxxxxx
  58351. // 1c. The token starts before, the deletion range ends precisely with the token
  58352. // ---------------
  58353. // xxxxxxxx
  58354. // 1d. The token starts before, the deletion range is inside the token
  58355. // ---------------
  58356. // xxxxx
  58357. //
  58358. // 2. The token starts at the same position with the deletion range
  58359. // 2a. The token starts at the same position, and ends inside the deletion range
  58360. // -------
  58361. // xxxxxxxxxxx
  58362. // 2b. The token starts at the same position, and ends at the same position as the deletion range
  58363. // ----------
  58364. // xxxxxxxxxx
  58365. // 2c. The token starts at the same position, and ends after the deletion range
  58366. // -------------
  58367. // xxxxxxx
  58368. //
  58369. // 3. The token starts inside the deletion range
  58370. // 3a. The token is inside the deletion range
  58371. // -------
  58372. // xxxxxxxxxxxxx
  58373. // 3b. The token starts inside the deletion range, and ends at the same position as the deletion range
  58374. // ----------
  58375. // xxxxxxxxxxxxx
  58376. // 3c. The token starts inside the deletion range, and ends after the deletion range
  58377. // ------------
  58378. // xxxxxxxxxxx
  58379. //
  58380. // 4. The token starts after the deletion range
  58381. // -----------
  58382. // xxxxxxxx
  58383. //
  58384. var tokens = this._tokens;
  58385. var tokenCount = this._tokenCount;
  58386. var deletedLineCount = (endDeltaLine - startDeltaLine);
  58387. var newTokenCount = 0;
  58388. var hasDeletedTokens = false;
  58389. for (var i = 0; i < tokenCount; i++) {
  58390. var srcOffset = 4 * i;
  58391. var tokenDeltaLine = tokens[srcOffset];
  58392. var tokenStartCharacter = tokens[srcOffset + 1];
  58393. var tokenEndCharacter = tokens[srcOffset + 2];
  58394. var tokenMetadata = tokens[srcOffset + 3];
  58395. if (tokenDeltaLine < startDeltaLine || (tokenDeltaLine === startDeltaLine && tokenEndCharacter <= startCharacter)) {
  58396. // 1a. The token is completely before the deletion range
  58397. // => nothing to do
  58398. newTokenCount++;
  58399. continue;
  58400. }
  58401. else if (tokenDeltaLine === startDeltaLine && tokenStartCharacter < startCharacter) {
  58402. // 1b, 1c, 1d
  58403. // => the token survives, but it needs to shrink
  58404. if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
  58405. // 1d. The token starts before, the deletion range is inside the token
  58406. // => the token shrinks by the deletion character count
  58407. tokenEndCharacter -= (endCharacter - startCharacter);
  58408. }
  58409. else {
  58410. // 1b. The token starts before, the deletion range ends after the token
  58411. // 1c. The token starts before, the deletion range ends precisely with the token
  58412. // => the token shrinks its ending to the deletion start
  58413. tokenEndCharacter = startCharacter;
  58414. }
  58415. }
  58416. else if (tokenDeltaLine === startDeltaLine && tokenStartCharacter === startCharacter) {
  58417. // 2a, 2b, 2c
  58418. if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
  58419. // 2c. The token starts at the same position, and ends after the deletion range
  58420. // => the token shrinks by the deletion character count
  58421. tokenEndCharacter -= (endCharacter - startCharacter);
  58422. }
  58423. else {
  58424. // 2a. The token starts at the same position, and ends inside the deletion range
  58425. // 2b. The token starts at the same position, and ends at the same position as the deletion range
  58426. // => the token is deleted
  58427. hasDeletedTokens = true;
  58428. continue;
  58429. }
  58430. }
  58431. else if (tokenDeltaLine < endDeltaLine || (tokenDeltaLine === endDeltaLine && tokenStartCharacter < endCharacter)) {
  58432. // 3a, 3b, 3c
  58433. if (tokenDeltaLine === endDeltaLine && tokenEndCharacter > endCharacter) {
  58434. // 3c. The token starts inside the deletion range, and ends after the deletion range
  58435. // => the token moves left and shrinks
  58436. if (tokenDeltaLine === startDeltaLine) {
  58437. // the deletion started on the same line as the token
  58438. // => the token moves left and shrinks
  58439. tokenStartCharacter = startCharacter;
  58440. tokenEndCharacter = tokenStartCharacter + (tokenEndCharacter - endCharacter);
  58441. }
  58442. else {
  58443. // the deletion started on a line above the token
  58444. // => the token moves to the beginning of the line
  58445. tokenStartCharacter = 0;
  58446. tokenEndCharacter = tokenStartCharacter + (tokenEndCharacter - endCharacter);
  58447. }
  58448. }
  58449. else {
  58450. // 3a. The token is inside the deletion range
  58451. // 3b. The token starts inside the deletion range, and ends at the same position as the deletion range
  58452. // => the token is deleted
  58453. hasDeletedTokens = true;
  58454. continue;
  58455. }
  58456. }
  58457. else if (tokenDeltaLine > endDeltaLine) {
  58458. // 4. (partial) The token starts after the deletion range, on a line below...
  58459. if (deletedLineCount === 0 && !hasDeletedTokens) {
  58460. // early stop, there is no need to walk all the tokens and do nothing...
  58461. newTokenCount = tokenCount;
  58462. break;
  58463. }
  58464. tokenDeltaLine -= deletedLineCount;
  58465. }
  58466. else if (tokenDeltaLine === endDeltaLine && tokenStartCharacter >= endCharacter) {
  58467. // 4. (continued) The token starts after the deletion range, on the last line where a deletion occurs
  58468. if (horizontalShiftForFirstLineTokens && tokenDeltaLine === 0) {
  58469. tokenStartCharacter += horizontalShiftForFirstLineTokens;
  58470. tokenEndCharacter += horizontalShiftForFirstLineTokens;
  58471. }
  58472. tokenDeltaLine -= deletedLineCount;
  58473. tokenStartCharacter -= (endCharacter - startCharacter);
  58474. tokenEndCharacter -= (endCharacter - startCharacter);
  58475. }
  58476. else {
  58477. throw new Error("Not possible!");
  58478. }
  58479. var destOffset = 4 * newTokenCount;
  58480. tokens[destOffset] = tokenDeltaLine;
  58481. tokens[destOffset + 1] = tokenStartCharacter;
  58482. tokens[destOffset + 2] = tokenEndCharacter;
  58483. tokens[destOffset + 3] = tokenMetadata;
  58484. newTokenCount++;
  58485. }
  58486. this._tokenCount = newTokenCount;
  58487. };
  58488. SparseEncodedTokens.prototype.acceptInsertText = function (deltaLine, character, eolCount, firstLineLength, lastLineLength, firstCharCode) {
  58489. // Here are the cases I used to think about this:
  58490. //
  58491. // 1. The token is completely before the insertion point
  58492. // ----------- |
  58493. // 2. The token ends precisely at the insertion point
  58494. // -----------|
  58495. // 3. The token contains the insertion point
  58496. // -----|------
  58497. // 4. The token starts precisely at the insertion point
  58498. // |-----------
  58499. // 5. The token is completely after the insertion point
  58500. // | -----------
  58501. //
  58502. var isInsertingPreciselyOneWordCharacter = (eolCount === 0
  58503. && firstLineLength === 1
  58504. && ((firstCharCode >= 48 /* Digit0 */ && firstCharCode <= 57 /* Digit9 */)
  58505. || (firstCharCode >= 65 /* A */ && firstCharCode <= 90 /* Z */)
  58506. || (firstCharCode >= 97 /* a */ && firstCharCode <= 122 /* z */)));
  58507. var tokens = this._tokens;
  58508. var tokenCount = this._tokenCount;
  58509. for (var i = 0; i < tokenCount; i++) {
  58510. var offset = 4 * i;
  58511. var tokenDeltaLine = tokens[offset];
  58512. var tokenStartCharacter = tokens[offset + 1];
  58513. var tokenEndCharacter = tokens[offset + 2];
  58514. if (tokenDeltaLine < deltaLine || (tokenDeltaLine === deltaLine && tokenEndCharacter < character)) {
  58515. // 1. The token is completely before the insertion point
  58516. // => nothing to do
  58517. continue;
  58518. }
  58519. else if (tokenDeltaLine === deltaLine && tokenEndCharacter === character) {
  58520. // 2. The token ends precisely at the insertion point
  58521. // => expand the end character only if inserting precisely one character that is a word character
  58522. if (isInsertingPreciselyOneWordCharacter) {
  58523. tokenEndCharacter += 1;
  58524. }
  58525. else {
  58526. continue;
  58527. }
  58528. }
  58529. else if (tokenDeltaLine === deltaLine && tokenStartCharacter < character && character < tokenEndCharacter) {
  58530. // 3. The token contains the insertion point
  58531. if (eolCount === 0) {
  58532. // => just expand the end character
  58533. tokenEndCharacter += firstLineLength;
  58534. }
  58535. else {
  58536. // => cut off the token
  58537. tokenEndCharacter = character;
  58538. }
  58539. }
  58540. else {
  58541. // 4. or 5.
  58542. if (tokenDeltaLine === deltaLine && tokenStartCharacter === character) {
  58543. // 4. The token starts precisely at the insertion point
  58544. // => grow the token (by keeping its start constant) only if inserting precisely one character that is a word character
  58545. // => otherwise behave as in case 5.
  58546. if (isInsertingPreciselyOneWordCharacter) {
  58547. continue;
  58548. }
  58549. }
  58550. // => the token must move and keep its size constant
  58551. if (tokenDeltaLine === deltaLine) {
  58552. tokenDeltaLine += eolCount;
  58553. // this token is on the line where the insertion is taking place
  58554. if (eolCount === 0) {
  58555. tokenStartCharacter += firstLineLength;
  58556. tokenEndCharacter += firstLineLength;
  58557. }
  58558. else {
  58559. var tokenLength = tokenEndCharacter - tokenStartCharacter;
  58560. tokenStartCharacter = lastLineLength + (tokenStartCharacter - character);
  58561. tokenEndCharacter = tokenStartCharacter + tokenLength;
  58562. }
  58563. }
  58564. else {
  58565. tokenDeltaLine += eolCount;
  58566. }
  58567. }
  58568. tokens[offset] = tokenDeltaLine;
  58569. tokens[offset + 1] = tokenStartCharacter;
  58570. tokens[offset + 2] = tokenEndCharacter;
  58571. }
  58572. };
  58573. return SparseEncodedTokens;
  58574. }());
  58575. exports.SparseEncodedTokens = SparseEncodedTokens;
  58576. var LineTokens2 = /** @class */ (function () {
  58577. function LineTokens2(actual, startTokenIndex, endTokenIndex) {
  58578. this._actual = actual;
  58579. this._startTokenIndex = startTokenIndex;
  58580. this._endTokenIndex = endTokenIndex;
  58581. }
  58582. LineTokens2.prototype.getCount = function () {
  58583. return this._endTokenIndex - this._startTokenIndex + 1;
  58584. };
  58585. LineTokens2.prototype.getStartCharacter = function (tokenIndex) {
  58586. return this._actual.getStartCharacter(this._startTokenIndex + tokenIndex);
  58587. };
  58588. LineTokens2.prototype.getEndCharacter = function (tokenIndex) {
  58589. return this._actual.getEndCharacter(this._startTokenIndex + tokenIndex);
  58590. };
  58591. LineTokens2.prototype.getMetadata = function (tokenIndex) {
  58592. return this._actual.getMetadata(this._startTokenIndex + tokenIndex);
  58593. };
  58594. return LineTokens2;
  58595. }());
  58596. exports.LineTokens2 = LineTokens2;
  58597. var MultilineTokens2 = /** @class */ (function () {
  58598. function MultilineTokens2(startLineNumber, tokens) {
  58599. this.startLineNumber = startLineNumber;
  58600. this.tokens = tokens;
  58601. this.endLineNumber = this.startLineNumber + this.tokens.getMaxDeltaLine();
  58602. }
  58603. MultilineTokens2.prototype._updateEndLineNumber = function () {
  58604. this.endLineNumber = this.startLineNumber + this.tokens.getMaxDeltaLine();
  58605. };
  58606. MultilineTokens2.prototype.getLineTokens = function (lineNumber) {
  58607. if (this.startLineNumber <= lineNumber && lineNumber <= this.endLineNumber) {
  58608. var findResult = MultilineTokens2._findTokensWithLine(this.tokens, lineNumber - this.startLineNumber);
  58609. if (findResult) {
  58610. var startTokenIndex = findResult[0], endTokenIndex = findResult[1];
  58611. return new LineTokens2(this.tokens, startTokenIndex, endTokenIndex);
  58612. }
  58613. }
  58614. return null;
  58615. };
  58616. MultilineTokens2._findTokensWithLine = function (tokens, deltaLine) {
  58617. var low = 0;
  58618. var high = tokens.getTokenCount() - 1;
  58619. while (low < high) {
  58620. var mid = low + Math.floor((high - low) / 2);
  58621. var midDeltaLine = tokens.getDeltaLine(mid);
  58622. if (midDeltaLine < deltaLine) {
  58623. low = mid + 1;
  58624. }
  58625. else if (midDeltaLine > deltaLine) {
  58626. high = mid - 1;
  58627. }
  58628. else {
  58629. var min = mid;
  58630. while (min > low && tokens.getDeltaLine(min - 1) === deltaLine) {
  58631. min--;
  58632. }
  58633. var max = mid;
  58634. while (max < high && tokens.getDeltaLine(max + 1) === deltaLine) {
  58635. max++;
  58636. }
  58637. return [min, max];
  58638. }
  58639. }
  58640. if (tokens.getDeltaLine(low) === deltaLine) {
  58641. return [low, low];
  58642. }
  58643. return null;
  58644. };
  58645. MultilineTokens2.prototype.applyEdit = function (range, text) {
  58646. var _a = countEOL(text), eolCount = _a[0], firstLineLength = _a[1], lastLineLength = _a[2];
  58647. this.acceptEdit(range, eolCount, firstLineLength, lastLineLength, text.length > 0 ? text.charCodeAt(0) : 0 /* Null */);
  58648. };
  58649. MultilineTokens2.prototype.acceptEdit = function (range, eolCount, firstLineLength, lastLineLength, firstCharCode) {
  58650. this._acceptDeleteRange(range);
  58651. this._acceptInsertText(new position_1.Position(range.startLineNumber, range.startColumn), eolCount, firstLineLength, lastLineLength, firstCharCode);
  58652. this._updateEndLineNumber();
  58653. };
  58654. MultilineTokens2.prototype._acceptDeleteRange = function (range) {
  58655. if (range.startLineNumber === range.endLineNumber && range.startColumn === range.endColumn) {
  58656. // Nothing to delete
  58657. return;
  58658. }
  58659. var firstLineIndex = range.startLineNumber - this.startLineNumber;
  58660. var lastLineIndex = range.endLineNumber - this.startLineNumber;
  58661. if (lastLineIndex < 0) {
  58662. // this deletion occurs entirely before this block, so we only need to adjust line numbers
  58663. var deletedLinesCount = lastLineIndex - firstLineIndex;
  58664. this.startLineNumber -= deletedLinesCount;
  58665. return;
  58666. }
  58667. var tokenMaxDeltaLine = this.tokens.getMaxDeltaLine();
  58668. if (firstLineIndex >= tokenMaxDeltaLine + 1) {
  58669. // this deletion occurs entirely after this block, so there is nothing to do
  58670. return;
  58671. }
  58672. if (firstLineIndex < 0 && lastLineIndex >= tokenMaxDeltaLine + 1) {
  58673. // this deletion completely encompasses this block
  58674. this.startLineNumber = 0;
  58675. this.tokens.clear();
  58676. return;
  58677. }
  58678. if (firstLineIndex < 0) {
  58679. var deletedBefore = -firstLineIndex;
  58680. this.startLineNumber -= deletedBefore;
  58681. this.tokens.acceptDeleteRange(range.startColumn - 1, 0, 0, lastLineIndex, range.endColumn - 1);
  58682. }
  58683. else {
  58684. this.tokens.acceptDeleteRange(0, firstLineIndex, range.startColumn - 1, lastLineIndex, range.endColumn - 1);
  58685. }
  58686. };
  58687. MultilineTokens2.prototype._acceptInsertText = function (position, eolCount, firstLineLength, lastLineLength, firstCharCode) {
  58688. if (eolCount === 0 && firstLineLength === 0) {
  58689. // Nothing to insert
  58690. return;
  58691. }
  58692. var lineIndex = position.lineNumber - this.startLineNumber;
  58693. if (lineIndex < 0) {
  58694. // this insertion occurs before this block, so we only need to adjust line numbers
  58695. this.startLineNumber += eolCount;
  58696. return;
  58697. }
  58698. var tokenMaxDeltaLine = this.tokens.getMaxDeltaLine();
  58699. if (lineIndex >= tokenMaxDeltaLine + 1) {
  58700. // this insertion occurs after this block, so there is nothing to do
  58701. return;
  58702. }
  58703. this.tokens.acceptInsertText(lineIndex, position.column - 1, eolCount, firstLineLength, lastLineLength, firstCharCode);
  58704. };
  58705. return MultilineTokens2;
  58706. }());
  58707. exports.MultilineTokens2 = MultilineTokens2;
  58708. var MultilineTokens = /** @class */ (function () {
  58709. function MultilineTokens(startLineNumber, tokens) {
  58710. this.startLineNumber = startLineNumber;
  58711. this.tokens = tokens;
  58712. }
  58713. return MultilineTokens;
  58714. }());
  58715. exports.MultilineTokens = MultilineTokens;
  58716. function toUint32Array(arr) {
  58717. if (arr instanceof Uint32Array) {
  58718. return arr;
  58719. }
  58720. else {
  58721. return new Uint32Array(arr);
  58722. }
  58723. }
  58724. var TokensStore2 = /** @class */ (function () {
  58725. function TokensStore2() {
  58726. this._pieces = [];
  58727. }
  58728. TokensStore2.prototype.flush = function () {
  58729. this._pieces = [];
  58730. };
  58731. TokensStore2.prototype.set = function (pieces) {
  58732. this._pieces = pieces || [];
  58733. };
  58734. TokensStore2.prototype.addSemanticTokens = function (lineNumber, aTokens) {
  58735. var pieces = this._pieces;
  58736. if (pieces.length === 0) {
  58737. return aTokens;
  58738. }
  58739. var pieceIndex = TokensStore2._findFirstPieceWithLine(pieces, lineNumber);
  58740. var bTokens = this._pieces[pieceIndex].getLineTokens(lineNumber);
  58741. if (!bTokens) {
  58742. return aTokens;
  58743. }
  58744. var aLen = aTokens.getCount();
  58745. var bLen = bTokens.getCount();
  58746. var aIndex = 0;
  58747. var result = [], resultLen = 0;
  58748. for (var bIndex = 0; bIndex < bLen; bIndex++) {
  58749. var bStartCharacter = bTokens.getStartCharacter(bIndex);
  58750. var bEndCharacter = bTokens.getEndCharacter(bIndex);
  58751. var bMetadata = bTokens.getMetadata(bIndex);
  58752. var bMask = (((bMetadata & 1 /* SEMANTIC_USE_ITALIC */) ? 2048 /* ITALIC_MASK */ : 0)
  58753. | ((bMetadata & 2 /* SEMANTIC_USE_BOLD */) ? 4096 /* BOLD_MASK */ : 0)
  58754. | ((bMetadata & 4 /* SEMANTIC_USE_UNDERLINE */) ? 8192 /* UNDERLINE_MASK */ : 0)
  58755. | ((bMetadata & 8 /* SEMANTIC_USE_FOREGROUND */) ? 8372224 /* FOREGROUND_MASK */ : 0)
  58756. | ((bMetadata & 16 /* SEMANTIC_USE_BACKGROUND */) ? 4286578688 /* BACKGROUND_MASK */ : 0)) >>> 0;
  58757. var aMask = (~bMask) >>> 0;
  58758. // push any token from `a` that is before `b`
  58759. while (aIndex < aLen && aTokens.getEndOffset(aIndex) <= bStartCharacter) {
  58760. result[resultLen++] = aTokens.getEndOffset(aIndex);
  58761. result[resultLen++] = aTokens.getMetadata(aIndex);
  58762. aIndex++;
  58763. }
  58764. // push the token from `a` if it intersects the token from `b`
  58765. if (aIndex < aLen && aTokens.getStartOffset(aIndex) < bStartCharacter) {
  58766. result[resultLen++] = bStartCharacter;
  58767. result[resultLen++] = aTokens.getMetadata(aIndex);
  58768. }
  58769. // skip any tokens from `a` that are contained inside `b`
  58770. while (aIndex < aLen && aTokens.getEndOffset(aIndex) < bEndCharacter) {
  58771. result[resultLen++] = aTokens.getEndOffset(aIndex);
  58772. result[resultLen++] = (aTokens.getMetadata(aIndex) & aMask) | (bMetadata & bMask);
  58773. aIndex++;
  58774. }
  58775. if (aIndex < aLen && aTokens.getEndOffset(aIndex) === bEndCharacter) {
  58776. // `a` ends exactly at the same spot as `b`!
  58777. result[resultLen++] = aTokens.getEndOffset(aIndex);
  58778. result[resultLen++] = (aTokens.getMetadata(aIndex) & aMask) | (bMetadata & bMask);
  58779. aIndex++;
  58780. }
  58781. else {
  58782. var aMergeIndex = Math.min(Math.max(0, aIndex - 1), aLen - 1);
  58783. // push the token from `b`
  58784. result[resultLen++] = bEndCharacter;
  58785. result[resultLen++] = (aTokens.getMetadata(aMergeIndex) & aMask) | (bMetadata & bMask);
  58786. }
  58787. }
  58788. // push the remaining tokens from `a`
  58789. while (aIndex < aLen) {
  58790. result[resultLen++] = aTokens.getEndOffset(aIndex);
  58791. result[resultLen++] = aTokens.getMetadata(aIndex);
  58792. aIndex++;
  58793. }
  58794. return new lineTokens_1.LineTokens(new Uint32Array(result), aTokens.getLineContent());
  58795. };
  58796. TokensStore2._findFirstPieceWithLine = function (pieces, lineNumber) {
  58797. var low = 0;
  58798. var high = pieces.length - 1;
  58799. while (low < high) {
  58800. var mid = low + Math.floor((high - low) / 2);
  58801. if (pieces[mid].endLineNumber < lineNumber) {
  58802. low = mid + 1;
  58803. }
  58804. else if (pieces[mid].startLineNumber > lineNumber) {
  58805. high = mid - 1;
  58806. }
  58807. else {
  58808. while (mid > low && pieces[mid - 1].startLineNumber <= lineNumber && lineNumber <= pieces[mid - 1].endLineNumber) {
  58809. mid--;
  58810. }
  58811. return mid;
  58812. }
  58813. }
  58814. return low;
  58815. };
  58816. //#region Editing
  58817. TokensStore2.prototype.acceptEdit = function (range, eolCount, firstLineLength, lastLineLength, firstCharCode) {
  58818. for (var _i = 0, _a = this._pieces; _i < _a.length; _i++) {
  58819. var piece = _a[_i];
  58820. piece.acceptEdit(range, eolCount, firstLineLength, lastLineLength, firstCharCode);
  58821. }
  58822. };
  58823. return TokensStore2;
  58824. }());
  58825. exports.TokensStore2 = TokensStore2;
  58826. var TokensStore = /** @class */ (function () {
  58827. function TokensStore() {
  58828. this._lineTokens = [];
  58829. this._len = 0;
  58830. }
  58831. TokensStore.prototype.flush = function () {
  58832. this._lineTokens = [];
  58833. this._len = 0;
  58834. };
  58835. TokensStore.prototype.getTokens = function (topLevelLanguageId, lineIndex, lineText) {
  58836. var rawLineTokens = null;
  58837. if (lineIndex < this._len) {
  58838. rawLineTokens = this._lineTokens[lineIndex];
  58839. }
  58840. if (rawLineTokens !== null && rawLineTokens !== EMPTY_LINE_TOKENS) {
  58841. return new lineTokens_1.LineTokens(toUint32Array(rawLineTokens), lineText);
  58842. }
  58843. var lineTokens = new Uint32Array(2);
  58844. lineTokens[0] = lineText.length;
  58845. lineTokens[1] = getDefaultMetadata(topLevelLanguageId);
  58846. return new lineTokens_1.LineTokens(lineTokens, lineText);
  58847. };
  58848. TokensStore._massageTokens = function (topLevelLanguageId, lineTextLength, _tokens) {
  58849. var tokens = _tokens ? toUint32Array(_tokens) : null;
  58850. if (lineTextLength === 0) {
  58851. var hasDifferentLanguageId = false;
  58852. if (tokens && tokens.length > 1) {
  58853. hasDifferentLanguageId = (modes_1.TokenMetadata.getLanguageId(tokens[1]) !== topLevelLanguageId);
  58854. }
  58855. if (!hasDifferentLanguageId) {
  58856. return EMPTY_LINE_TOKENS;
  58857. }
  58858. }
  58859. if (!tokens || tokens.length === 0) {
  58860. var tokens_1 = new Uint32Array(2);
  58861. tokens_1[0] = lineTextLength;
  58862. tokens_1[1] = getDefaultMetadata(topLevelLanguageId);
  58863. return tokens_1.buffer;
  58864. }
  58865. // Ensure the last token covers the end of the text
  58866. tokens[tokens.length - 2] = lineTextLength;
  58867. if (tokens.byteOffset === 0 && tokens.byteLength === tokens.buffer.byteLength) {
  58868. // Store directly the ArrayBuffer pointer to save an object
  58869. return tokens.buffer;
  58870. }
  58871. return tokens;
  58872. };
  58873. TokensStore.prototype._ensureLine = function (lineIndex) {
  58874. while (lineIndex >= this._len) {
  58875. this._lineTokens[this._len] = null;
  58876. this._len++;
  58877. }
  58878. };
  58879. TokensStore.prototype._deleteLines = function (start, deleteCount) {
  58880. if (deleteCount === 0) {
  58881. return;
  58882. }
  58883. if (start + deleteCount > this._len) {
  58884. deleteCount = this._len - start;
  58885. }
  58886. this._lineTokens.splice(start, deleteCount);
  58887. this._len -= deleteCount;
  58888. };
  58889. TokensStore.prototype._insertLines = function (insertIndex, insertCount) {
  58890. if (insertCount === 0) {
  58891. return;
  58892. }
  58893. var lineTokens = [];
  58894. for (var i = 0; i < insertCount; i++) {
  58895. lineTokens[i] = null;
  58896. }
  58897. this._lineTokens = arrays.arrayInsert(this._lineTokens, insertIndex, lineTokens);
  58898. this._len += insertCount;
  58899. };
  58900. TokensStore.prototype.setTokens = function (topLevelLanguageId, lineIndex, lineTextLength, _tokens) {
  58901. var tokens = TokensStore._massageTokens(topLevelLanguageId, lineTextLength, _tokens);
  58902. this._ensureLine(lineIndex);
  58903. this._lineTokens[lineIndex] = tokens;
  58904. };
  58905. //#region Editing
  58906. TokensStore.prototype.acceptEdit = function (range, eolCount, firstLineLength) {
  58907. this._acceptDeleteRange(range);
  58908. this._acceptInsertText(new position_1.Position(range.startLineNumber, range.startColumn), eolCount, firstLineLength);
  58909. };
  58910. TokensStore.prototype._acceptDeleteRange = function (range) {
  58911. var firstLineIndex = range.startLineNumber - 1;
  58912. if (firstLineIndex >= this._len) {
  58913. return;
  58914. }
  58915. if (range.startLineNumber === range.endLineNumber) {
  58916. if (range.startColumn === range.endColumn) {
  58917. // Nothing to delete
  58918. return;
  58919. }
  58920. this._lineTokens[firstLineIndex] = TokensStore._delete(this._lineTokens[firstLineIndex], range.startColumn - 1, range.endColumn - 1);
  58921. return;
  58922. }
  58923. this._lineTokens[firstLineIndex] = TokensStore._deleteEnding(this._lineTokens[firstLineIndex], range.startColumn - 1);
  58924. var lastLineIndex = range.endLineNumber - 1;
  58925. var lastLineTokens = null;
  58926. if (lastLineIndex < this._len) {
  58927. lastLineTokens = TokensStore._deleteBeginning(this._lineTokens[lastLineIndex], range.endColumn - 1);
  58928. }
  58929. // Take remaining text on last line and append it to remaining text on first line
  58930. this._lineTokens[firstLineIndex] = TokensStore._append(this._lineTokens[firstLineIndex], lastLineTokens);
  58931. // Delete middle lines
  58932. this._deleteLines(range.startLineNumber, range.endLineNumber - range.startLineNumber);
  58933. };
  58934. TokensStore.prototype._acceptInsertText = function (position, eolCount, firstLineLength) {
  58935. if (eolCount === 0 && firstLineLength === 0) {
  58936. // Nothing to insert
  58937. return;
  58938. }
  58939. var lineIndex = position.lineNumber - 1;
  58940. if (lineIndex >= this._len) {
  58941. return;
  58942. }
  58943. if (eolCount === 0) {
  58944. // Inserting text on one line
  58945. this._lineTokens[lineIndex] = TokensStore._insert(this._lineTokens[lineIndex], position.column - 1, firstLineLength);
  58946. return;
  58947. }
  58948. this._lineTokens[lineIndex] = TokensStore._deleteEnding(this._lineTokens[lineIndex], position.column - 1);
  58949. this._lineTokens[lineIndex] = TokensStore._insert(this._lineTokens[lineIndex], position.column - 1, firstLineLength);
  58950. this._insertLines(position.lineNumber, eolCount);
  58951. };
  58952. TokensStore._deleteBeginning = function (lineTokens, toChIndex) {
  58953. if (lineTokens === null || lineTokens === EMPTY_LINE_TOKENS) {
  58954. return lineTokens;
  58955. }
  58956. return TokensStore._delete(lineTokens, 0, toChIndex);
  58957. };
  58958. TokensStore._deleteEnding = function (lineTokens, fromChIndex) {
  58959. if (lineTokens === null || lineTokens === EMPTY_LINE_TOKENS) {
  58960. return lineTokens;
  58961. }
  58962. var tokens = toUint32Array(lineTokens);
  58963. var lineTextLength = tokens[tokens.length - 2];
  58964. return TokensStore._delete(lineTokens, fromChIndex, lineTextLength);
  58965. };
  58966. TokensStore._delete = function (lineTokens, fromChIndex, toChIndex) {
  58967. if (lineTokens === null || lineTokens === EMPTY_LINE_TOKENS || fromChIndex === toChIndex) {
  58968. return lineTokens;
  58969. }
  58970. var tokens = toUint32Array(lineTokens);
  58971. var tokensCount = (tokens.length >>> 1);
  58972. // special case: deleting everything
  58973. if (fromChIndex === 0 && tokens[tokens.length - 2] === toChIndex) {
  58974. return EMPTY_LINE_TOKENS;
  58975. }
  58976. var fromTokenIndex = lineTokens_1.LineTokens.findIndexInTokensArray(tokens, fromChIndex);
  58977. var fromTokenStartOffset = (fromTokenIndex > 0 ? tokens[(fromTokenIndex - 1) << 1] : 0);
  58978. var fromTokenEndOffset = tokens[fromTokenIndex << 1];
  58979. if (toChIndex < fromTokenEndOffset) {
  58980. // the delete range is inside a single token
  58981. var delta_1 = (toChIndex - fromChIndex);
  58982. for (var i = fromTokenIndex; i < tokensCount; i++) {
  58983. tokens[i << 1] -= delta_1;
  58984. }
  58985. return lineTokens;
  58986. }
  58987. var dest;
  58988. var lastEnd;
  58989. if (fromTokenStartOffset !== fromChIndex) {
  58990. tokens[fromTokenIndex << 1] = fromChIndex;
  58991. dest = ((fromTokenIndex + 1) << 1);
  58992. lastEnd = fromChIndex;
  58993. }
  58994. else {
  58995. dest = (fromTokenIndex << 1);
  58996. lastEnd = fromTokenStartOffset;
  58997. }
  58998. var delta = (toChIndex - fromChIndex);
  58999. for (var tokenIndex = fromTokenIndex + 1; tokenIndex < tokensCount; tokenIndex++) {
  59000. var tokenEndOffset = tokens[tokenIndex << 1] - delta;
  59001. if (tokenEndOffset > lastEnd) {
  59002. tokens[dest++] = tokenEndOffset;
  59003. tokens[dest++] = tokens[(tokenIndex << 1) + 1];
  59004. lastEnd = tokenEndOffset;
  59005. }
  59006. }
  59007. if (dest === tokens.length) {
  59008. // nothing to trim
  59009. return lineTokens;
  59010. }
  59011. var tmp = new Uint32Array(dest);
  59012. tmp.set(tokens.subarray(0, dest), 0);
  59013. return tmp.buffer;
  59014. };
  59015. TokensStore._append = function (lineTokens, _otherTokens) {
  59016. if (_otherTokens === EMPTY_LINE_TOKENS) {
  59017. return lineTokens;
  59018. }
  59019. if (lineTokens === EMPTY_LINE_TOKENS) {
  59020. return _otherTokens;
  59021. }
  59022. if (lineTokens === null) {
  59023. return lineTokens;
  59024. }
  59025. if (_otherTokens === null) {
  59026. // cannot determine combined line length...
  59027. return null;
  59028. }
  59029. var myTokens = toUint32Array(lineTokens);
  59030. var otherTokens = toUint32Array(_otherTokens);
  59031. var otherTokensCount = (otherTokens.length >>> 1);
  59032. var result = new Uint32Array(myTokens.length + otherTokens.length);
  59033. result.set(myTokens, 0);
  59034. var dest = myTokens.length;
  59035. var delta = myTokens[myTokens.length - 2];
  59036. for (var i = 0; i < otherTokensCount; i++) {
  59037. result[dest++] = otherTokens[(i << 1)] + delta;
  59038. result[dest++] = otherTokens[(i << 1) + 1];
  59039. }
  59040. return result.buffer;
  59041. };
  59042. TokensStore._insert = function (lineTokens, chIndex, textLength) {
  59043. if (lineTokens === null || lineTokens === EMPTY_LINE_TOKENS) {
  59044. // nothing to do
  59045. return lineTokens;
  59046. }
  59047. var tokens = toUint32Array(lineTokens);
  59048. var tokensCount = (tokens.length >>> 1);
  59049. var fromTokenIndex = lineTokens_1.LineTokens.findIndexInTokensArray(tokens, chIndex);
  59050. if (fromTokenIndex > 0) {
  59051. var fromTokenStartOffset = tokens[(fromTokenIndex - 1) << 1];
  59052. if (fromTokenStartOffset === chIndex) {
  59053. fromTokenIndex--;
  59054. }
  59055. }
  59056. for (var tokenIndex = fromTokenIndex; tokenIndex < tokensCount; tokenIndex++) {
  59057. tokens[tokenIndex << 1] += textLength;
  59058. }
  59059. return lineTokens;
  59060. };
  59061. return TokensStore;
  59062. }());
  59063. exports.TokensStore = TokensStore;
  59064. });
  59065. /*---------------------------------------------------------------------------------------------
  59066. * Copyright (c) Microsoft Corporation. All rights reserved.
  59067. * Licensed under the MIT License. See License.txt in the project root for license information.
  59068. *--------------------------------------------------------------------------------------------*/
  59069. define(__m[63/*vs/editor/common/modes/nullMode*/], __M([0/*require*/,1/*exports*/,107/*vs/editor/common/core/token*/,17/*vs/editor/common/modes*/]), function (require, exports, token_1, modes_1) {
  59070. "use strict";
  59071. Object.defineProperty(exports, "__esModule", { value: true });
  59072. var NullStateImpl = /** @class */ (function () {
  59073. function NullStateImpl() {
  59074. }
  59075. NullStateImpl.prototype.clone = function () {
  59076. return this;
  59077. };
  59078. NullStateImpl.prototype.equals = function (other) {
  59079. return (this === other);
  59080. };
  59081. return NullStateImpl;
  59082. }());
  59083. exports.NULL_STATE = new NullStateImpl();
  59084. exports.NULL_MODE_ID = 'vs.editor.nullMode';
  59085. exports.NULL_LANGUAGE_IDENTIFIER = new modes_1.LanguageIdentifier(exports.NULL_MODE_ID, 0 /* Null */);
  59086. function nullTokenize(modeId, buffer, state, deltaOffset) {
  59087. return new token_1.TokenizationResult([new token_1.Token(deltaOffset, '', modeId)], state);
  59088. }
  59089. exports.nullTokenize = nullTokenize;
  59090. function nullTokenize2(languageId, buffer, state, deltaOffset) {
  59091. var tokens = new Uint32Array(2);
  59092. tokens[0] = deltaOffset;
  59093. tokens[1] = ((languageId << 0 /* LANGUAGEID_OFFSET */)
  59094. | (0 /* Other */ << 8 /* TOKEN_TYPE_OFFSET */)
  59095. | (0 /* None */ << 11 /* FONT_STYLE_OFFSET */)
  59096. | (1 /* DefaultForeground */ << 14 /* FOREGROUND_OFFSET */)
  59097. | (2 /* DefaultBackground */ << 23 /* BACKGROUND_OFFSET */)) >>> 0;
  59098. return new token_1.TokenizationResult2(tokens, state === null ? exports.NULL_STATE : state);
  59099. }
  59100. exports.nullTokenize2 = nullTokenize2;
  59101. });
  59102. /*---------------------------------------------------------------------------------------------
  59103. * Copyright (c) Microsoft Corporation. All rights reserved.
  59104. * Licensed under the MIT License. See License.txt in the project root for license information.
  59105. *--------------------------------------------------------------------------------------------*/
  59106. define(__m[482/*vs/editor/common/model/textModelTokens*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,10/*vs/base/common/errors*/,93/*vs/editor/common/core/lineTokens*/,13/*vs/editor/common/core/position*/,17/*vs/editor/common/modes*/,63/*vs/editor/common/modes/nullMode*/,2/*vs/base/common/lifecycle*/,132/*vs/base/common/stopwatch*/,157/*vs/editor/common/model/tokensStore*/,16/*vs/base/common/platform*/]), function (require, exports, arrays, errors_1, lineTokens_1, position_1, modes_1, nullMode_1, lifecycle_1, stopwatch_1, tokensStore_1, platform) {
  59107. "use strict";
  59108. Object.defineProperty(exports, "__esModule", { value: true });
  59109. var TokenizationStateStore = /** @class */ (function () {
  59110. function TokenizationStateStore() {
  59111. this._beginState = [];
  59112. this._valid = [];
  59113. this._len = 0;
  59114. this._invalidLineStartIndex = 0;
  59115. }
  59116. TokenizationStateStore.prototype._reset = function (initialState) {
  59117. this._beginState = [];
  59118. this._valid = [];
  59119. this._len = 0;
  59120. this._invalidLineStartIndex = 0;
  59121. if (initialState) {
  59122. this._setBeginState(0, initialState);
  59123. }
  59124. };
  59125. TokenizationStateStore.prototype.flush = function (initialState) {
  59126. this._reset(initialState);
  59127. };
  59128. Object.defineProperty(TokenizationStateStore.prototype, "invalidLineStartIndex", {
  59129. get: function () {
  59130. return this._invalidLineStartIndex;
  59131. },
  59132. enumerable: true,
  59133. configurable: true
  59134. });
  59135. TokenizationStateStore.prototype._invalidateLine = function (lineIndex) {
  59136. if (lineIndex < this._len) {
  59137. this._valid[lineIndex] = false;
  59138. }
  59139. if (lineIndex < this._invalidLineStartIndex) {
  59140. this._invalidLineStartIndex = lineIndex;
  59141. }
  59142. };
  59143. TokenizationStateStore.prototype._isValid = function (lineIndex) {
  59144. if (lineIndex < this._len) {
  59145. return this._valid[lineIndex];
  59146. }
  59147. return false;
  59148. };
  59149. TokenizationStateStore.prototype.getBeginState = function (lineIndex) {
  59150. if (lineIndex < this._len) {
  59151. return this._beginState[lineIndex];
  59152. }
  59153. return null;
  59154. };
  59155. TokenizationStateStore.prototype._ensureLine = function (lineIndex) {
  59156. while (lineIndex >= this._len) {
  59157. this._beginState[this._len] = null;
  59158. this._valid[this._len] = false;
  59159. this._len++;
  59160. }
  59161. };
  59162. TokenizationStateStore.prototype._deleteLines = function (start, deleteCount) {
  59163. if (deleteCount === 0) {
  59164. return;
  59165. }
  59166. if (start + deleteCount > this._len) {
  59167. deleteCount = this._len - start;
  59168. }
  59169. this._beginState.splice(start, deleteCount);
  59170. this._valid.splice(start, deleteCount);
  59171. this._len -= deleteCount;
  59172. };
  59173. TokenizationStateStore.prototype._insertLines = function (insertIndex, insertCount) {
  59174. if (insertCount === 0) {
  59175. return;
  59176. }
  59177. var beginState = [];
  59178. var valid = [];
  59179. for (var i = 0; i < insertCount; i++) {
  59180. beginState[i] = null;
  59181. valid[i] = false;
  59182. }
  59183. this._beginState = arrays.arrayInsert(this._beginState, insertIndex, beginState);
  59184. this._valid = arrays.arrayInsert(this._valid, insertIndex, valid);
  59185. this._len += insertCount;
  59186. };
  59187. TokenizationStateStore.prototype._setValid = function (lineIndex, valid) {
  59188. this._ensureLine(lineIndex);
  59189. this._valid[lineIndex] = valid;
  59190. };
  59191. TokenizationStateStore.prototype._setBeginState = function (lineIndex, beginState) {
  59192. this._ensureLine(lineIndex);
  59193. this._beginState[lineIndex] = beginState;
  59194. };
  59195. TokenizationStateStore.prototype.setEndState = function (linesLength, lineIndex, endState) {
  59196. this._setValid(lineIndex, true);
  59197. this._invalidLineStartIndex = lineIndex + 1;
  59198. // Check if this was the last line
  59199. if (lineIndex === linesLength - 1) {
  59200. return;
  59201. }
  59202. // Check if the end state has changed
  59203. var previousEndState = this.getBeginState(lineIndex + 1);
  59204. if (previousEndState === null || !endState.equals(previousEndState)) {
  59205. this._setBeginState(lineIndex + 1, endState);
  59206. this._invalidateLine(lineIndex + 1);
  59207. return;
  59208. }
  59209. // Perhaps we can skip tokenizing some lines...
  59210. var i = lineIndex + 1;
  59211. while (i < linesLength) {
  59212. if (!this._isValid(i)) {
  59213. break;
  59214. }
  59215. i++;
  59216. }
  59217. this._invalidLineStartIndex = i;
  59218. };
  59219. TokenizationStateStore.prototype.setFakeTokens = function (lineIndex) {
  59220. this._setValid(lineIndex, false);
  59221. };
  59222. //#region Editing
  59223. TokenizationStateStore.prototype.applyEdits = function (range, eolCount) {
  59224. var deletingLinesCnt = range.endLineNumber - range.startLineNumber;
  59225. var insertingLinesCnt = eolCount;
  59226. var editingLinesCnt = Math.min(deletingLinesCnt, insertingLinesCnt);
  59227. for (var j = editingLinesCnt; j >= 0; j--) {
  59228. this._invalidateLine(range.startLineNumber + j - 1);
  59229. }
  59230. this._acceptDeleteRange(range);
  59231. this._acceptInsertText(new position_1.Position(range.startLineNumber, range.startColumn), eolCount);
  59232. };
  59233. TokenizationStateStore.prototype._acceptDeleteRange = function (range) {
  59234. var firstLineIndex = range.startLineNumber - 1;
  59235. if (firstLineIndex >= this._len) {
  59236. return;
  59237. }
  59238. this._deleteLines(range.startLineNumber, range.endLineNumber - range.startLineNumber);
  59239. };
  59240. TokenizationStateStore.prototype._acceptInsertText = function (position, eolCount) {
  59241. var lineIndex = position.lineNumber - 1;
  59242. if (lineIndex >= this._len) {
  59243. return;
  59244. }
  59245. this._insertLines(position.lineNumber, eolCount);
  59246. };
  59247. return TokenizationStateStore;
  59248. }());
  59249. exports.TokenizationStateStore = TokenizationStateStore;
  59250. var TextModelTokenization = /** @class */ (function (_super) {
  59251. __extends(TextModelTokenization, _super);
  59252. function TextModelTokenization(textModel) {
  59253. var _this = _super.call(this) || this;
  59254. _this._isDisposed = false;
  59255. _this._textModel = textModel;
  59256. _this._tokenizationStateStore = new TokenizationStateStore();
  59257. _this._tokenizationSupport = null;
  59258. _this._register(modes_1.TokenizationRegistry.onDidChange(function (e) {
  59259. var languageIdentifier = _this._textModel.getLanguageIdentifier();
  59260. if (e.changedLanguages.indexOf(languageIdentifier.language) === -1) {
  59261. return;
  59262. }
  59263. _this._resetTokenizationState();
  59264. _this._textModel.clearTokens();
  59265. }));
  59266. _this._register(_this._textModel.onDidChangeRawContentFast(function (e) {
  59267. if (e.containsEvent(1 /* Flush */)) {
  59268. _this._resetTokenizationState();
  59269. return;
  59270. }
  59271. }));
  59272. _this._register(_this._textModel.onDidChangeContentFast(function (e) {
  59273. for (var i = 0, len = e.changes.length; i < len; i++) {
  59274. var change = e.changes[i];
  59275. var eolCount = tokensStore_1.countEOL(change.text)[0];
  59276. _this._tokenizationStateStore.applyEdits(change.range, eolCount);
  59277. }
  59278. _this._beginBackgroundTokenization();
  59279. }));
  59280. _this._register(_this._textModel.onDidChangeAttached(function () {
  59281. _this._beginBackgroundTokenization();
  59282. }));
  59283. _this._register(_this._textModel.onDidChangeLanguage(function () {
  59284. _this._resetTokenizationState();
  59285. _this._textModel.clearTokens();
  59286. }));
  59287. _this._resetTokenizationState();
  59288. return _this;
  59289. }
  59290. TextModelTokenization.prototype.dispose = function () {
  59291. this._isDisposed = true;
  59292. _super.prototype.dispose.call(this);
  59293. };
  59294. TextModelTokenization.prototype._resetTokenizationState = function () {
  59295. var _a = initializeTokenization(this._textModel), tokenizationSupport = _a[0], initialState = _a[1];
  59296. this._tokenizationSupport = tokenizationSupport;
  59297. this._tokenizationStateStore.flush(initialState);
  59298. this._beginBackgroundTokenization();
  59299. };
  59300. TextModelTokenization.prototype._beginBackgroundTokenization = function () {
  59301. var _this = this;
  59302. if (this._textModel.isAttachedToEditor() && this._hasLinesToTokenize()) {
  59303. platform.setImmediate(function () {
  59304. if (_this._isDisposed) {
  59305. // disposed in the meantime
  59306. return;
  59307. }
  59308. _this._revalidateTokensNow();
  59309. });
  59310. }
  59311. };
  59312. TextModelTokenization.prototype._revalidateTokensNow = function (toLineNumber) {
  59313. if (toLineNumber === void 0) { toLineNumber = this._textModel.getLineCount(); }
  59314. var MAX_ALLOWED_TIME = 1;
  59315. var builder = new tokensStore_1.MultilineTokensBuilder();
  59316. var sw = stopwatch_1.StopWatch.create(false);
  59317. while (this._hasLinesToTokenize()) {
  59318. if (sw.elapsed() > MAX_ALLOWED_TIME) {
  59319. // Stop if MAX_ALLOWED_TIME is reached
  59320. break;
  59321. }
  59322. var tokenizedLineNumber = this._tokenizeOneInvalidLine(builder);
  59323. if (tokenizedLineNumber >= toLineNumber) {
  59324. break;
  59325. }
  59326. }
  59327. this._beginBackgroundTokenization();
  59328. this._textModel.setTokens(builder.tokens);
  59329. };
  59330. TextModelTokenization.prototype.tokenizeViewport = function (startLineNumber, endLineNumber) {
  59331. var builder = new tokensStore_1.MultilineTokensBuilder();
  59332. this._tokenizeViewport(builder, startLineNumber, endLineNumber);
  59333. this._textModel.setTokens(builder.tokens);
  59334. };
  59335. TextModelTokenization.prototype.reset = function () {
  59336. this._resetTokenizationState();
  59337. this._textModel.clearTokens();
  59338. };
  59339. TextModelTokenization.prototype.forceTokenization = function (lineNumber) {
  59340. var builder = new tokensStore_1.MultilineTokensBuilder();
  59341. this._updateTokensUntilLine(builder, lineNumber);
  59342. this._textModel.setTokens(builder.tokens);
  59343. };
  59344. TextModelTokenization.prototype.isCheapToTokenize = function (lineNumber) {
  59345. if (!this._tokenizationSupport) {
  59346. return true;
  59347. }
  59348. var firstInvalidLineNumber = this._tokenizationStateStore.invalidLineStartIndex + 1;
  59349. if (lineNumber > firstInvalidLineNumber) {
  59350. return false;
  59351. }
  59352. if (lineNumber < firstInvalidLineNumber) {
  59353. return true;
  59354. }
  59355. if (this._textModel.getLineLength(lineNumber) < 2048 /* CHEAP_TOKENIZATION_LENGTH_LIMIT */) {
  59356. return true;
  59357. }
  59358. return false;
  59359. };
  59360. TextModelTokenization.prototype._hasLinesToTokenize = function () {
  59361. if (!this._tokenizationSupport) {
  59362. return false;
  59363. }
  59364. return (this._tokenizationStateStore.invalidLineStartIndex < this._textModel.getLineCount());
  59365. };
  59366. TextModelTokenization.prototype._tokenizeOneInvalidLine = function (builder) {
  59367. if (!this._hasLinesToTokenize()) {
  59368. return this._textModel.getLineCount() + 1;
  59369. }
  59370. var lineNumber = this._tokenizationStateStore.invalidLineStartIndex + 1;
  59371. this._updateTokensUntilLine(builder, lineNumber);
  59372. return lineNumber;
  59373. };
  59374. TextModelTokenization.prototype._updateTokensUntilLine = function (builder, lineNumber) {
  59375. if (!this._tokenizationSupport) {
  59376. return;
  59377. }
  59378. var languageIdentifier = this._textModel.getLanguageIdentifier();
  59379. var linesLength = this._textModel.getLineCount();
  59380. var endLineIndex = lineNumber - 1;
  59381. // Validate all states up to and including endLineIndex
  59382. for (var lineIndex = this._tokenizationStateStore.invalidLineStartIndex; lineIndex <= endLineIndex; lineIndex++) {
  59383. var text = this._textModel.getLineContent(lineIndex + 1);
  59384. var lineStartState = this._tokenizationStateStore.getBeginState(lineIndex);
  59385. var r = safeTokenize(languageIdentifier, this._tokenizationSupport, text, lineStartState);
  59386. builder.add(lineIndex + 1, r.tokens);
  59387. this._tokenizationStateStore.setEndState(linesLength, lineIndex, r.endState);
  59388. lineIndex = this._tokenizationStateStore.invalidLineStartIndex - 1; // -1 because the outer loop increments it
  59389. }
  59390. };
  59391. TextModelTokenization.prototype._tokenizeViewport = function (builder, startLineNumber, endLineNumber) {
  59392. if (!this._tokenizationSupport) {
  59393. // nothing to do
  59394. return;
  59395. }
  59396. if (endLineNumber <= this._tokenizationStateStore.invalidLineStartIndex) {
  59397. // nothing to do
  59398. return;
  59399. }
  59400. if (startLineNumber <= this._tokenizationStateStore.invalidLineStartIndex) {
  59401. // tokenization has reached the viewport start...
  59402. this._updateTokensUntilLine(builder, endLineNumber);
  59403. return;
  59404. }
  59405. var nonWhitespaceColumn = this._textModel.getLineFirstNonWhitespaceColumn(startLineNumber);
  59406. var fakeLines = [];
  59407. var initialState = null;
  59408. for (var i = startLineNumber - 1; nonWhitespaceColumn > 0 && i >= 1; i--) {
  59409. var newNonWhitespaceIndex = this._textModel.getLineFirstNonWhitespaceColumn(i);
  59410. if (newNonWhitespaceIndex === 0) {
  59411. continue;
  59412. }
  59413. if (newNonWhitespaceIndex < nonWhitespaceColumn) {
  59414. initialState = this._tokenizationStateStore.getBeginState(i - 1);
  59415. if (initialState) {
  59416. break;
  59417. }
  59418. fakeLines.push(this._textModel.getLineContent(i));
  59419. nonWhitespaceColumn = newNonWhitespaceIndex;
  59420. }
  59421. }
  59422. if (!initialState) {
  59423. initialState = this._tokenizationSupport.getInitialState();
  59424. }
  59425. var languageIdentifier = this._textModel.getLanguageIdentifier();
  59426. var state = initialState;
  59427. for (var i = fakeLines.length - 1; i >= 0; i--) {
  59428. var r = safeTokenize(languageIdentifier, this._tokenizationSupport, fakeLines[i], state);
  59429. state = r.endState;
  59430. }
  59431. for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
  59432. var text = this._textModel.getLineContent(lineNumber);
  59433. var r = safeTokenize(languageIdentifier, this._tokenizationSupport, text, state);
  59434. builder.add(lineNumber, r.tokens);
  59435. this._tokenizationStateStore.setFakeTokens(lineNumber - 1);
  59436. state = r.endState;
  59437. }
  59438. };
  59439. return TextModelTokenization;
  59440. }(lifecycle_1.Disposable));
  59441. exports.TextModelTokenization = TextModelTokenization;
  59442. function initializeTokenization(textModel) {
  59443. var languageIdentifier = textModel.getLanguageIdentifier();
  59444. var tokenizationSupport = (textModel.isTooLargeForTokenization()
  59445. ? null
  59446. : modes_1.TokenizationRegistry.get(languageIdentifier.language));
  59447. var initialState = null;
  59448. if (tokenizationSupport) {
  59449. try {
  59450. initialState = tokenizationSupport.getInitialState();
  59451. }
  59452. catch (e) {
  59453. errors_1.onUnexpectedError(e);
  59454. tokenizationSupport = null;
  59455. }
  59456. }
  59457. return [tokenizationSupport, initialState];
  59458. }
  59459. function safeTokenize(languageIdentifier, tokenizationSupport, text, state) {
  59460. var r = null;
  59461. if (tokenizationSupport) {
  59462. try {
  59463. r = tokenizationSupport.tokenize2(text, state.clone(), 0);
  59464. }
  59465. catch (e) {
  59466. errors_1.onUnexpectedError(e);
  59467. }
  59468. }
  59469. if (!r) {
  59470. r = nullMode_1.nullTokenize2(languageIdentifier.id, text, state, 0);
  59471. }
  59472. lineTokens_1.LineTokens.convertToEndOffset(r.tokens, text.length);
  59473. return r;
  59474. }
  59475. });
  59476. /*---------------------------------------------------------------------------------------------
  59477. * Copyright (c) Microsoft Corporation. All rights reserved.
  59478. * Licensed under the MIT License. See License.txt in the project root for license information.
  59479. *--------------------------------------------------------------------------------------------*/
  59480. define(__m[30/*vs/editor/common/model/textModel*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,5/*vs/base/common/strings*/,25/*vs/base/common/uri*/,33/*vs/editor/common/config/editorOptions*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,48/*vs/editor/common/model*/,342/*vs/editor/common/model/editStack*/,343/*vs/editor/common/model/indentationGuesser*/,344/*vs/editor/common/model/intervalTree*/,348/*vs/editor/common/model/pieceTreeTextBuffer/pieceTreeTextBufferBuilder*/,346/*vs/editor/common/model/textModelEvents*/,144/*vs/editor/common/model/textModelSearch*/,482/*vs/editor/common/model/textModelTokens*/,109/*vs/editor/common/model/wordHelper*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/,63/*vs/editor/common/modes/nullMode*/,145/*vs/editor/common/modes/supports*/,146/*vs/editor/common/modes/supports/richEditBrackets*/,21/*vs/base/common/types*/,157/*vs/editor/common/model/tokensStore*/,27/*vs/base/common/color*/]), function (require, exports, errors_1, event_1, lifecycle_1, strings, uri_1, editorOptions_1, position_1, range_1, selection_1, model, editStack_1, indentationGuesser_1, intervalTree_1, pieceTreeTextBufferBuilder_1, textModelEvents_1, textModelSearch_1, textModelTokens_1, wordHelper_1, languageConfigurationRegistry_1, nullMode_1, supports_1, richEditBrackets_1, types_1, tokensStore_1, color_1) {
  59481. "use strict";
  59482. Object.defineProperty(exports, "__esModule", { value: true });
  59483. function createTextBufferBuilder() {
  59484. return new pieceTreeTextBufferBuilder_1.PieceTreeTextBufferBuilder();
  59485. }
  59486. function createTextBufferFactory(text) {
  59487. var builder = createTextBufferBuilder();
  59488. builder.acceptChunk(text);
  59489. return builder.finish();
  59490. }
  59491. exports.createTextBufferFactory = createTextBufferFactory;
  59492. function createTextBuffer(value, defaultEOL) {
  59493. var factory = (typeof value === 'string' ? createTextBufferFactory(value) : value);
  59494. return factory.create(defaultEOL);
  59495. }
  59496. exports.createTextBuffer = createTextBuffer;
  59497. var MODEL_ID = 0;
  59498. var LIMIT_FIND_COUNT = 999;
  59499. exports.LONG_LINE_BOUNDARY = 10000;
  59500. var invalidFunc = function () { throw new Error("Invalid change accessor"); };
  59501. var TextModel = /** @class */ (function (_super) {
  59502. __extends(TextModel, _super);
  59503. //#endregion
  59504. function TextModel(source, creationOptions, languageIdentifier, associatedResource) {
  59505. if (associatedResource === void 0) { associatedResource = null; }
  59506. var _this = _super.call(this) || this;
  59507. //#region Events
  59508. _this._onWillDispose = _this._register(new event_1.Emitter());
  59509. _this.onWillDispose = _this._onWillDispose.event;
  59510. _this._onDidChangeDecorations = _this._register(new DidChangeDecorationsEmitter());
  59511. _this.onDidChangeDecorations = _this._onDidChangeDecorations.event;
  59512. _this._onDidChangeLanguage = _this._register(new event_1.Emitter());
  59513. _this.onDidChangeLanguage = _this._onDidChangeLanguage.event;
  59514. _this._onDidChangeLanguageConfiguration = _this._register(new event_1.Emitter());
  59515. _this.onDidChangeLanguageConfiguration = _this._onDidChangeLanguageConfiguration.event;
  59516. _this._onDidChangeTokens = _this._register(new event_1.Emitter());
  59517. _this.onDidChangeTokens = _this._onDidChangeTokens.event;
  59518. _this._onDidChangeOptions = _this._register(new event_1.Emitter());
  59519. _this.onDidChangeOptions = _this._onDidChangeOptions.event;
  59520. _this._onDidChangeAttached = _this._register(new event_1.Emitter());
  59521. _this.onDidChangeAttached = _this._onDidChangeAttached.event;
  59522. _this._eventEmitter = _this._register(new DidChangeContentEmitter());
  59523. // Generate a new unique model id
  59524. MODEL_ID++;
  59525. _this.id = '$model' + MODEL_ID;
  59526. _this.isForSimpleWidget = creationOptions.isForSimpleWidget;
  59527. if (typeof associatedResource === 'undefined' || associatedResource === null) {
  59528. _this._associatedResource = uri_1.URI.parse('inmemory://model/' + MODEL_ID);
  59529. }
  59530. else {
  59531. _this._associatedResource = associatedResource;
  59532. }
  59533. _this._attachedEditorCount = 0;
  59534. _this._buffer = createTextBuffer(source, creationOptions.defaultEOL);
  59535. _this._options = TextModel.resolveOptions(_this._buffer, creationOptions);
  59536. var bufferLineCount = _this._buffer.getLineCount();
  59537. var bufferTextLength = _this._buffer.getValueLengthInRange(new range_1.Range(1, 1, bufferLineCount, _this._buffer.getLineLength(bufferLineCount) + 1), 0 /* TextDefined */);
  59538. // !!! Make a decision in the ctor and permanently respect this decision !!!
  59539. // If a model is too large at construction time, it will never get tokenized,
  59540. // under no circumstances.
  59541. if (creationOptions.largeFileOptimizations) {
  59542. _this._isTooLargeForTokenization = ((bufferTextLength > TextModel.LARGE_FILE_SIZE_THRESHOLD)
  59543. || (bufferLineCount > TextModel.LARGE_FILE_LINE_COUNT_THRESHOLD));
  59544. }
  59545. else {
  59546. _this._isTooLargeForTokenization = false;
  59547. }
  59548. _this._isTooLargeForSyncing = (bufferTextLength > TextModel.MODEL_SYNC_LIMIT);
  59549. _this._versionId = 1;
  59550. _this._alternativeVersionId = 1;
  59551. _this._isDisposed = false;
  59552. _this._isDisposing = false;
  59553. _this._languageIdentifier = languageIdentifier || nullMode_1.NULL_LANGUAGE_IDENTIFIER;
  59554. _this._languageRegistryListener = languageConfigurationRegistry_1.LanguageConfigurationRegistry.onDidChange(function (e) {
  59555. if (e.languageIdentifier.id === _this._languageIdentifier.id) {
  59556. _this._onDidChangeLanguageConfiguration.fire({});
  59557. }
  59558. });
  59559. _this._instanceId = strings.singleLetterHash(MODEL_ID);
  59560. _this._lastDecorationId = 0;
  59561. _this._decorations = Object.create(null);
  59562. _this._decorationsTree = new DecorationsTrees();
  59563. _this._commandManager = new editStack_1.EditStack(_this);
  59564. _this._isUndoing = false;
  59565. _this._isRedoing = false;
  59566. _this._trimAutoWhitespaceLines = null;
  59567. _this._tokens = new tokensStore_1.TokensStore();
  59568. _this._tokens2 = new tokensStore_1.TokensStore2();
  59569. _this._tokenization = new textModelTokens_1.TextModelTokenization(_this);
  59570. return _this;
  59571. }
  59572. TextModel.createFromString = function (text, options, languageIdentifier, uri) {
  59573. if (options === void 0) { options = TextModel.DEFAULT_CREATION_OPTIONS; }
  59574. if (languageIdentifier === void 0) { languageIdentifier = null; }
  59575. if (uri === void 0) { uri = null; }
  59576. return new TextModel(text, options, languageIdentifier, uri);
  59577. };
  59578. TextModel.resolveOptions = function (textBuffer, options) {
  59579. if (options.detectIndentation) {
  59580. var guessedIndentation = indentationGuesser_1.guessIndentation(textBuffer, options.tabSize, options.insertSpaces);
  59581. return new model.TextModelResolvedOptions({
  59582. tabSize: guessedIndentation.tabSize,
  59583. indentSize: guessedIndentation.tabSize,
  59584. insertSpaces: guessedIndentation.insertSpaces,
  59585. trimAutoWhitespace: options.trimAutoWhitespace,
  59586. defaultEOL: options.defaultEOL
  59587. });
  59588. }
  59589. return new model.TextModelResolvedOptions({
  59590. tabSize: options.tabSize,
  59591. indentSize: options.indentSize,
  59592. insertSpaces: options.insertSpaces,
  59593. trimAutoWhitespace: options.trimAutoWhitespace,
  59594. defaultEOL: options.defaultEOL
  59595. });
  59596. };
  59597. TextModel.prototype.onDidChangeRawContentFast = function (listener) {
  59598. return this._eventEmitter.fastEvent(function (e) { return listener(e.rawContentChangedEvent); });
  59599. };
  59600. TextModel.prototype.onDidChangeRawContent = function (listener) {
  59601. return this._eventEmitter.slowEvent(function (e) { return listener(e.rawContentChangedEvent); });
  59602. };
  59603. TextModel.prototype.onDidChangeContentFast = function (listener) {
  59604. return this._eventEmitter.fastEvent(function (e) { return listener(e.contentChangedEvent); });
  59605. };
  59606. TextModel.prototype.onDidChangeContent = function (listener) {
  59607. return this._eventEmitter.slowEvent(function (e) { return listener(e.contentChangedEvent); });
  59608. };
  59609. TextModel.prototype.dispose = function () {
  59610. this._isDisposing = true;
  59611. this._onWillDispose.fire();
  59612. this._languageRegistryListener.dispose();
  59613. this._tokenization.dispose();
  59614. this._isDisposed = true;
  59615. _super.prototype.dispose.call(this);
  59616. this._isDisposing = false;
  59617. };
  59618. TextModel.prototype._assertNotDisposed = function () {
  59619. if (this._isDisposed) {
  59620. throw new Error('Model is disposed!');
  59621. }
  59622. };
  59623. TextModel.prototype._emitContentChangedEvent = function (rawChange, change) {
  59624. if (this._isDisposing) {
  59625. // Do not confuse listeners by emitting any event after disposing
  59626. return;
  59627. }
  59628. this._eventEmitter.fire(new textModelEvents_1.InternalModelContentChangeEvent(rawChange, change));
  59629. };
  59630. TextModel.prototype.setValue = function (value) {
  59631. this._assertNotDisposed();
  59632. if (value === null) {
  59633. // There's nothing to do
  59634. return;
  59635. }
  59636. var textBuffer = createTextBuffer(value, this._options.defaultEOL);
  59637. this.setValueFromTextBuffer(textBuffer);
  59638. };
  59639. TextModel.prototype._createContentChanged2 = function (range, rangeOffset, rangeLength, text, isUndoing, isRedoing, isFlush) {
  59640. return {
  59641. changes: [{
  59642. range: range,
  59643. rangeOffset: rangeOffset,
  59644. rangeLength: rangeLength,
  59645. text: text,
  59646. }],
  59647. eol: this._buffer.getEOL(),
  59648. versionId: this.getVersionId(),
  59649. isUndoing: isUndoing,
  59650. isRedoing: isRedoing,
  59651. isFlush: isFlush
  59652. };
  59653. };
  59654. TextModel.prototype.setValueFromTextBuffer = function (textBuffer) {
  59655. this._assertNotDisposed();
  59656. if (textBuffer === null) {
  59657. // There's nothing to do
  59658. return;
  59659. }
  59660. var oldFullModelRange = this.getFullModelRange();
  59661. var oldModelValueLength = this.getValueLengthInRange(oldFullModelRange);
  59662. var endLineNumber = this.getLineCount();
  59663. var endColumn = this.getLineMaxColumn(endLineNumber);
  59664. this._buffer = textBuffer;
  59665. this._increaseVersionId();
  59666. // Flush all tokens
  59667. this._tokens.flush();
  59668. this._tokens2.flush();
  59669. // Destroy all my decorations
  59670. this._decorations = Object.create(null);
  59671. this._decorationsTree = new DecorationsTrees();
  59672. // Destroy my edit history and settings
  59673. this._commandManager = new editStack_1.EditStack(this);
  59674. this._trimAutoWhitespaceLines = null;
  59675. this._emitContentChangedEvent(new textModelEvents_1.ModelRawContentChangedEvent([
  59676. new textModelEvents_1.ModelRawFlush()
  59677. ], this._versionId, false, false), this._createContentChanged2(new range_1.Range(1, 1, endLineNumber, endColumn), 0, oldModelValueLength, this.getValue(), false, false, true));
  59678. };
  59679. TextModel.prototype.setEOL = function (eol) {
  59680. this._assertNotDisposed();
  59681. var newEOL = (eol === 1 /* CRLF */ ? '\r\n' : '\n');
  59682. if (this._buffer.getEOL() === newEOL) {
  59683. // Nothing to do
  59684. return;
  59685. }
  59686. var oldFullModelRange = this.getFullModelRange();
  59687. var oldModelValueLength = this.getValueLengthInRange(oldFullModelRange);
  59688. var endLineNumber = this.getLineCount();
  59689. var endColumn = this.getLineMaxColumn(endLineNumber);
  59690. this._onBeforeEOLChange();
  59691. this._buffer.setEOL(newEOL);
  59692. this._increaseVersionId();
  59693. this._onAfterEOLChange();
  59694. this._emitContentChangedEvent(new textModelEvents_1.ModelRawContentChangedEvent([
  59695. new textModelEvents_1.ModelRawEOLChanged()
  59696. ], this._versionId, false, false), this._createContentChanged2(new range_1.Range(1, 1, endLineNumber, endColumn), 0, oldModelValueLength, this.getValue(), false, false, false));
  59697. };
  59698. TextModel.prototype._onBeforeEOLChange = function () {
  59699. // Ensure all decorations get their `range` set.
  59700. var versionId = this.getVersionId();
  59701. var allDecorations = this._decorationsTree.search(0, false, false, versionId);
  59702. this._ensureNodesHaveRanges(allDecorations);
  59703. };
  59704. TextModel.prototype._onAfterEOLChange = function () {
  59705. // Transform back `range` to offsets
  59706. var versionId = this.getVersionId();
  59707. var allDecorations = this._decorationsTree.collectNodesPostOrder();
  59708. for (var i = 0, len = allDecorations.length; i < len; i++) {
  59709. var node = allDecorations[i];
  59710. var delta = node.cachedAbsoluteStart - node.start;
  59711. var startOffset = this._buffer.getOffsetAt(node.range.startLineNumber, node.range.startColumn);
  59712. var endOffset = this._buffer.getOffsetAt(node.range.endLineNumber, node.range.endColumn);
  59713. node.cachedAbsoluteStart = startOffset;
  59714. node.cachedAbsoluteEnd = endOffset;
  59715. node.cachedVersionId = versionId;
  59716. node.start = startOffset - delta;
  59717. node.end = endOffset - delta;
  59718. intervalTree_1.recomputeMaxEnd(node);
  59719. }
  59720. };
  59721. TextModel.prototype.onBeforeAttached = function () {
  59722. this._attachedEditorCount++;
  59723. if (this._attachedEditorCount === 1) {
  59724. this._onDidChangeAttached.fire(undefined);
  59725. }
  59726. };
  59727. TextModel.prototype.onBeforeDetached = function () {
  59728. this._attachedEditorCount--;
  59729. if (this._attachedEditorCount === 0) {
  59730. this._onDidChangeAttached.fire(undefined);
  59731. }
  59732. };
  59733. TextModel.prototype.isAttachedToEditor = function () {
  59734. return this._attachedEditorCount > 0;
  59735. };
  59736. TextModel.prototype.getAttachedEditorCount = function () {
  59737. return this._attachedEditorCount;
  59738. };
  59739. TextModel.prototype.isTooLargeForSyncing = function () {
  59740. return this._isTooLargeForSyncing;
  59741. };
  59742. TextModel.prototype.isTooLargeForTokenization = function () {
  59743. return this._isTooLargeForTokenization;
  59744. };
  59745. TextModel.prototype.isDisposed = function () {
  59746. return this._isDisposed;
  59747. };
  59748. TextModel.prototype.isDominatedByLongLines = function () {
  59749. this._assertNotDisposed();
  59750. if (this.isTooLargeForTokenization()) {
  59751. // Cannot word wrap huge files anyways, so it doesn't really matter
  59752. return false;
  59753. }
  59754. var smallLineCharCount = 0;
  59755. var longLineCharCount = 0;
  59756. var lineCount = this._buffer.getLineCount();
  59757. for (var lineNumber = 1; lineNumber <= lineCount; lineNumber++) {
  59758. var lineLength = this._buffer.getLineLength(lineNumber);
  59759. if (lineLength >= exports.LONG_LINE_BOUNDARY) {
  59760. longLineCharCount += lineLength;
  59761. }
  59762. else {
  59763. smallLineCharCount += lineLength;
  59764. }
  59765. }
  59766. return (longLineCharCount > smallLineCharCount);
  59767. };
  59768. Object.defineProperty(TextModel.prototype, "uri", {
  59769. get: function () {
  59770. return this._associatedResource;
  59771. },
  59772. enumerable: true,
  59773. configurable: true
  59774. });
  59775. //#region Options
  59776. TextModel.prototype.getOptions = function () {
  59777. this._assertNotDisposed();
  59778. return this._options;
  59779. };
  59780. TextModel.prototype.getFormattingOptions = function () {
  59781. return {
  59782. tabSize: this._options.indentSize,
  59783. insertSpaces: this._options.insertSpaces
  59784. };
  59785. };
  59786. TextModel.prototype.updateOptions = function (_newOpts) {
  59787. this._assertNotDisposed();
  59788. var tabSize = (typeof _newOpts.tabSize !== 'undefined') ? _newOpts.tabSize : this._options.tabSize;
  59789. var indentSize = (typeof _newOpts.indentSize !== 'undefined') ? _newOpts.indentSize : this._options.indentSize;
  59790. var insertSpaces = (typeof _newOpts.insertSpaces !== 'undefined') ? _newOpts.insertSpaces : this._options.insertSpaces;
  59791. var trimAutoWhitespace = (typeof _newOpts.trimAutoWhitespace !== 'undefined') ? _newOpts.trimAutoWhitespace : this._options.trimAutoWhitespace;
  59792. var newOpts = new model.TextModelResolvedOptions({
  59793. tabSize: tabSize,
  59794. indentSize: indentSize,
  59795. insertSpaces: insertSpaces,
  59796. defaultEOL: this._options.defaultEOL,
  59797. trimAutoWhitespace: trimAutoWhitespace
  59798. });
  59799. if (this._options.equals(newOpts)) {
  59800. return;
  59801. }
  59802. var e = this._options.createChangeEvent(newOpts);
  59803. this._options = newOpts;
  59804. this._onDidChangeOptions.fire(e);
  59805. };
  59806. TextModel.prototype.detectIndentation = function (defaultInsertSpaces, defaultTabSize) {
  59807. this._assertNotDisposed();
  59808. var guessedIndentation = indentationGuesser_1.guessIndentation(this._buffer, defaultTabSize, defaultInsertSpaces);
  59809. this.updateOptions({
  59810. insertSpaces: guessedIndentation.insertSpaces,
  59811. tabSize: guessedIndentation.tabSize,
  59812. indentSize: guessedIndentation.tabSize,
  59813. });
  59814. };
  59815. TextModel._normalizeIndentationFromWhitespace = function (str, indentSize, insertSpaces) {
  59816. var spacesCnt = 0;
  59817. for (var i = 0; i < str.length; i++) {
  59818. if (str.charAt(i) === '\t') {
  59819. spacesCnt += indentSize;
  59820. }
  59821. else {
  59822. spacesCnt++;
  59823. }
  59824. }
  59825. var result = '';
  59826. if (!insertSpaces) {
  59827. var tabsCnt = Math.floor(spacesCnt / indentSize);
  59828. spacesCnt = spacesCnt % indentSize;
  59829. for (var i = 0; i < tabsCnt; i++) {
  59830. result += '\t';
  59831. }
  59832. }
  59833. for (var i = 0; i < spacesCnt; i++) {
  59834. result += ' ';
  59835. }
  59836. return result;
  59837. };
  59838. TextModel.normalizeIndentation = function (str, indentSize, insertSpaces) {
  59839. var firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(str);
  59840. if (firstNonWhitespaceIndex === -1) {
  59841. firstNonWhitespaceIndex = str.length;
  59842. }
  59843. return TextModel._normalizeIndentationFromWhitespace(str.substring(0, firstNonWhitespaceIndex), indentSize, insertSpaces) + str.substring(firstNonWhitespaceIndex);
  59844. };
  59845. TextModel.prototype.normalizeIndentation = function (str) {
  59846. this._assertNotDisposed();
  59847. return TextModel.normalizeIndentation(str, this._options.indentSize, this._options.insertSpaces);
  59848. };
  59849. //#endregion
  59850. //#region Reading
  59851. TextModel.prototype.getVersionId = function () {
  59852. this._assertNotDisposed();
  59853. return this._versionId;
  59854. };
  59855. TextModel.prototype.mightContainRTL = function () {
  59856. return this._buffer.mightContainRTL();
  59857. };
  59858. TextModel.prototype.mightContainNonBasicASCII = function () {
  59859. return this._buffer.mightContainNonBasicASCII();
  59860. };
  59861. TextModel.prototype.getAlternativeVersionId = function () {
  59862. this._assertNotDisposed();
  59863. return this._alternativeVersionId;
  59864. };
  59865. TextModel.prototype.getOffsetAt = function (rawPosition) {
  59866. this._assertNotDisposed();
  59867. var position = this._validatePosition(rawPosition.lineNumber, rawPosition.column, 0 /* Relaxed */);
  59868. return this._buffer.getOffsetAt(position.lineNumber, position.column);
  59869. };
  59870. TextModel.prototype.getPositionAt = function (rawOffset) {
  59871. this._assertNotDisposed();
  59872. var offset = (Math.min(this._buffer.getLength(), Math.max(0, rawOffset)));
  59873. return this._buffer.getPositionAt(offset);
  59874. };
  59875. TextModel.prototype._increaseVersionId = function () {
  59876. this._versionId = this._versionId + 1;
  59877. this._alternativeVersionId = this._versionId;
  59878. };
  59879. TextModel.prototype._overwriteAlternativeVersionId = function (newAlternativeVersionId) {
  59880. this._alternativeVersionId = newAlternativeVersionId;
  59881. };
  59882. TextModel.prototype.getValue = function (eol, preserveBOM) {
  59883. if (preserveBOM === void 0) { preserveBOM = false; }
  59884. this._assertNotDisposed();
  59885. var fullModelRange = this.getFullModelRange();
  59886. var fullModelValue = this.getValueInRange(fullModelRange, eol);
  59887. if (preserveBOM) {
  59888. return this._buffer.getBOM() + fullModelValue;
  59889. }
  59890. return fullModelValue;
  59891. };
  59892. TextModel.prototype.getValueLength = function (eol, preserveBOM) {
  59893. if (preserveBOM === void 0) { preserveBOM = false; }
  59894. this._assertNotDisposed();
  59895. var fullModelRange = this.getFullModelRange();
  59896. var fullModelValue = this.getValueLengthInRange(fullModelRange, eol);
  59897. if (preserveBOM) {
  59898. return this._buffer.getBOM().length + fullModelValue;
  59899. }
  59900. return fullModelValue;
  59901. };
  59902. TextModel.prototype.getValueInRange = function (rawRange, eol) {
  59903. if (eol === void 0) { eol = 0 /* TextDefined */; }
  59904. this._assertNotDisposed();
  59905. return this._buffer.getValueInRange(this.validateRange(rawRange), eol);
  59906. };
  59907. TextModel.prototype.getValueLengthInRange = function (rawRange, eol) {
  59908. if (eol === void 0) { eol = 0 /* TextDefined */; }
  59909. this._assertNotDisposed();
  59910. return this._buffer.getValueLengthInRange(this.validateRange(rawRange), eol);
  59911. };
  59912. TextModel.prototype.getCharacterCountInRange = function (rawRange, eol) {
  59913. if (eol === void 0) { eol = 0 /* TextDefined */; }
  59914. this._assertNotDisposed();
  59915. return this._buffer.getCharacterCountInRange(this.validateRange(rawRange), eol);
  59916. };
  59917. TextModel.prototype.getLineCount = function () {
  59918. this._assertNotDisposed();
  59919. return this._buffer.getLineCount();
  59920. };
  59921. TextModel.prototype.getLineContent = function (lineNumber) {
  59922. this._assertNotDisposed();
  59923. if (lineNumber < 1 || lineNumber > this.getLineCount()) {
  59924. throw new Error('Illegal value for lineNumber');
  59925. }
  59926. return this._buffer.getLineContent(lineNumber);
  59927. };
  59928. TextModel.prototype.getLineLength = function (lineNumber) {
  59929. this._assertNotDisposed();
  59930. if (lineNumber < 1 || lineNumber > this.getLineCount()) {
  59931. throw new Error('Illegal value for lineNumber');
  59932. }
  59933. return this._buffer.getLineLength(lineNumber);
  59934. };
  59935. TextModel.prototype.getLinesContent = function () {
  59936. this._assertNotDisposed();
  59937. return this._buffer.getLinesContent();
  59938. };
  59939. TextModel.prototype.getEOL = function () {
  59940. this._assertNotDisposed();
  59941. return this._buffer.getEOL();
  59942. };
  59943. TextModel.prototype.getLineMinColumn = function (lineNumber) {
  59944. this._assertNotDisposed();
  59945. return 1;
  59946. };
  59947. TextModel.prototype.getLineMaxColumn = function (lineNumber) {
  59948. this._assertNotDisposed();
  59949. if (lineNumber < 1 || lineNumber > this.getLineCount()) {
  59950. throw new Error('Illegal value for lineNumber');
  59951. }
  59952. return this._buffer.getLineLength(lineNumber) + 1;
  59953. };
  59954. TextModel.prototype.getLineFirstNonWhitespaceColumn = function (lineNumber) {
  59955. this._assertNotDisposed();
  59956. if (lineNumber < 1 || lineNumber > this.getLineCount()) {
  59957. throw new Error('Illegal value for lineNumber');
  59958. }
  59959. return this._buffer.getLineFirstNonWhitespaceColumn(lineNumber);
  59960. };
  59961. TextModel.prototype.getLineLastNonWhitespaceColumn = function (lineNumber) {
  59962. this._assertNotDisposed();
  59963. if (lineNumber < 1 || lineNumber > this.getLineCount()) {
  59964. throw new Error('Illegal value for lineNumber');
  59965. }
  59966. return this._buffer.getLineLastNonWhitespaceColumn(lineNumber);
  59967. };
  59968. /**
  59969. * Validates `range` is within buffer bounds, but allows it to sit in between surrogate pairs, etc.
  59970. * Will try to not allocate if possible.
  59971. */
  59972. TextModel.prototype._validateRangeRelaxedNoAllocations = function (range) {
  59973. var linesCount = this._buffer.getLineCount();
  59974. var initialStartLineNumber = range.startLineNumber;
  59975. var initialStartColumn = range.startColumn;
  59976. var startLineNumber;
  59977. var startColumn;
  59978. if (initialStartLineNumber < 1) {
  59979. startLineNumber = 1;
  59980. startColumn = 1;
  59981. }
  59982. else if (initialStartLineNumber > linesCount) {
  59983. startLineNumber = linesCount;
  59984. startColumn = this.getLineMaxColumn(startLineNumber);
  59985. }
  59986. else {
  59987. startLineNumber = initialStartLineNumber | 0;
  59988. if (initialStartColumn <= 1) {
  59989. startColumn = 1;
  59990. }
  59991. else {
  59992. var maxColumn = this.getLineMaxColumn(startLineNumber);
  59993. if (initialStartColumn >= maxColumn) {
  59994. startColumn = maxColumn;
  59995. }
  59996. else {
  59997. startColumn = initialStartColumn | 0;
  59998. }
  59999. }
  60000. }
  60001. var initialEndLineNumber = range.endLineNumber;
  60002. var initialEndColumn = range.endColumn;
  60003. var endLineNumber;
  60004. var endColumn;
  60005. if (initialEndLineNumber < 1) {
  60006. endLineNumber = 1;
  60007. endColumn = 1;
  60008. }
  60009. else if (initialEndLineNumber > linesCount) {
  60010. endLineNumber = linesCount;
  60011. endColumn = this.getLineMaxColumn(endLineNumber);
  60012. }
  60013. else {
  60014. endLineNumber = initialEndLineNumber | 0;
  60015. if (initialEndColumn <= 1) {
  60016. endColumn = 1;
  60017. }
  60018. else {
  60019. var maxColumn = this.getLineMaxColumn(endLineNumber);
  60020. if (initialEndColumn >= maxColumn) {
  60021. endColumn = maxColumn;
  60022. }
  60023. else {
  60024. endColumn = initialEndColumn | 0;
  60025. }
  60026. }
  60027. }
  60028. if (initialStartLineNumber === startLineNumber
  60029. && initialStartColumn === startColumn
  60030. && initialEndLineNumber === endLineNumber
  60031. && initialEndColumn === endColumn
  60032. && range instanceof range_1.Range
  60033. && !(range instanceof selection_1.Selection)) {
  60034. return range;
  60035. }
  60036. return new range_1.Range(startLineNumber, startColumn, endLineNumber, endColumn);
  60037. };
  60038. TextModel.prototype._isValidPosition = function (lineNumber, column, validationType) {
  60039. if (typeof lineNumber !== 'number' || typeof column !== 'number') {
  60040. return false;
  60041. }
  60042. if (isNaN(lineNumber) || isNaN(column)) {
  60043. return false;
  60044. }
  60045. if (lineNumber < 1 || column < 1) {
  60046. return false;
  60047. }
  60048. if ((lineNumber | 0) !== lineNumber || (column | 0) !== column) {
  60049. return false;
  60050. }
  60051. var lineCount = this._buffer.getLineCount();
  60052. if (lineNumber > lineCount) {
  60053. return false;
  60054. }
  60055. if (column === 1) {
  60056. return true;
  60057. }
  60058. var maxColumn = this.getLineMaxColumn(lineNumber);
  60059. if (column > maxColumn) {
  60060. return false;
  60061. }
  60062. if (validationType === 1 /* SurrogatePairs */) {
  60063. // !!At this point, column > 1
  60064. var charCodeBefore = this._buffer.getLineCharCode(lineNumber, column - 2);
  60065. if (strings.isHighSurrogate(charCodeBefore)) {
  60066. return false;
  60067. }
  60068. }
  60069. return true;
  60070. };
  60071. TextModel.prototype._validatePosition = function (_lineNumber, _column, validationType) {
  60072. var lineNumber = Math.floor((typeof _lineNumber === 'number' && !isNaN(_lineNumber)) ? _lineNumber : 1);
  60073. var column = Math.floor((typeof _column === 'number' && !isNaN(_column)) ? _column : 1);
  60074. var lineCount = this._buffer.getLineCount();
  60075. if (lineNumber < 1) {
  60076. return new position_1.Position(1, 1);
  60077. }
  60078. if (lineNumber > lineCount) {
  60079. return new position_1.Position(lineCount, this.getLineMaxColumn(lineCount));
  60080. }
  60081. if (column <= 1) {
  60082. return new position_1.Position(lineNumber, 1);
  60083. }
  60084. var maxColumn = this.getLineMaxColumn(lineNumber);
  60085. if (column >= maxColumn) {
  60086. return new position_1.Position(lineNumber, maxColumn);
  60087. }
  60088. if (validationType === 1 /* SurrogatePairs */) {
  60089. // If the position would end up in the middle of a high-low surrogate pair,
  60090. // we move it to before the pair
  60091. // !!At this point, column > 1
  60092. var charCodeBefore = this._buffer.getLineCharCode(lineNumber, column - 2);
  60093. if (strings.isHighSurrogate(charCodeBefore)) {
  60094. return new position_1.Position(lineNumber, column - 1);
  60095. }
  60096. }
  60097. return new position_1.Position(lineNumber, column);
  60098. };
  60099. TextModel.prototype.validatePosition = function (position) {
  60100. var validationType = 1 /* SurrogatePairs */;
  60101. this._assertNotDisposed();
  60102. // Avoid object allocation and cover most likely case
  60103. if (position instanceof position_1.Position) {
  60104. if (this._isValidPosition(position.lineNumber, position.column, validationType)) {
  60105. return position;
  60106. }
  60107. }
  60108. return this._validatePosition(position.lineNumber, position.column, validationType);
  60109. };
  60110. TextModel.prototype._isValidRange = function (range, validationType) {
  60111. var startLineNumber = range.startLineNumber;
  60112. var startColumn = range.startColumn;
  60113. var endLineNumber = range.endLineNumber;
  60114. var endColumn = range.endColumn;
  60115. if (!this._isValidPosition(startLineNumber, startColumn, 0 /* Relaxed */)) {
  60116. return false;
  60117. }
  60118. if (!this._isValidPosition(endLineNumber, endColumn, 0 /* Relaxed */)) {
  60119. return false;
  60120. }
  60121. if (validationType === 1 /* SurrogatePairs */) {
  60122. var charCodeBeforeStart = (startColumn > 1 ? this._buffer.getLineCharCode(startLineNumber, startColumn - 2) : 0);
  60123. var charCodeBeforeEnd = (endColumn > 1 && endColumn <= this._buffer.getLineLength(endLineNumber) ? this._buffer.getLineCharCode(endLineNumber, endColumn - 2) : 0);
  60124. var startInsideSurrogatePair = strings.isHighSurrogate(charCodeBeforeStart);
  60125. var endInsideSurrogatePair = strings.isHighSurrogate(charCodeBeforeEnd);
  60126. if (!startInsideSurrogatePair && !endInsideSurrogatePair) {
  60127. return true;
  60128. }
  60129. return false;
  60130. }
  60131. return true;
  60132. };
  60133. TextModel.prototype.validateRange = function (_range) {
  60134. var validationType = 1 /* SurrogatePairs */;
  60135. this._assertNotDisposed();
  60136. // Avoid object allocation and cover most likely case
  60137. if ((_range instanceof range_1.Range) && !(_range instanceof selection_1.Selection)) {
  60138. if (this._isValidRange(_range, validationType)) {
  60139. return _range;
  60140. }
  60141. }
  60142. var start = this._validatePosition(_range.startLineNumber, _range.startColumn, 0 /* Relaxed */);
  60143. var end = this._validatePosition(_range.endLineNumber, _range.endColumn, 0 /* Relaxed */);
  60144. var startLineNumber = start.lineNumber;
  60145. var startColumn = start.column;
  60146. var endLineNumber = end.lineNumber;
  60147. var endColumn = end.column;
  60148. if (validationType === 1 /* SurrogatePairs */) {
  60149. var charCodeBeforeStart = (startColumn > 1 ? this._buffer.getLineCharCode(startLineNumber, startColumn - 2) : 0);
  60150. var charCodeBeforeEnd = (endColumn > 1 && endColumn <= this._buffer.getLineLength(endLineNumber) ? this._buffer.getLineCharCode(endLineNumber, endColumn - 2) : 0);
  60151. var startInsideSurrogatePair = strings.isHighSurrogate(charCodeBeforeStart);
  60152. var endInsideSurrogatePair = strings.isHighSurrogate(charCodeBeforeEnd);
  60153. if (!startInsideSurrogatePair && !endInsideSurrogatePair) {
  60154. return new range_1.Range(startLineNumber, startColumn, endLineNumber, endColumn);
  60155. }
  60156. if (startLineNumber === endLineNumber && startColumn === endColumn) {
  60157. // do not expand a collapsed range, simply move it to a valid location
  60158. return new range_1.Range(startLineNumber, startColumn - 1, endLineNumber, endColumn - 1);
  60159. }
  60160. if (startInsideSurrogatePair && endInsideSurrogatePair) {
  60161. // expand range at both ends
  60162. return new range_1.Range(startLineNumber, startColumn - 1, endLineNumber, endColumn + 1);
  60163. }
  60164. if (startInsideSurrogatePair) {
  60165. // only expand range at the start
  60166. return new range_1.Range(startLineNumber, startColumn - 1, endLineNumber, endColumn);
  60167. }
  60168. // only expand range at the end
  60169. return new range_1.Range(startLineNumber, startColumn, endLineNumber, endColumn + 1);
  60170. }
  60171. return new range_1.Range(startLineNumber, startColumn, endLineNumber, endColumn);
  60172. };
  60173. TextModel.prototype.modifyPosition = function (rawPosition, offset) {
  60174. this._assertNotDisposed();
  60175. var candidate = this.getOffsetAt(rawPosition) + offset;
  60176. return this.getPositionAt(Math.min(this._buffer.getLength(), Math.max(0, candidate)));
  60177. };
  60178. TextModel.prototype.getFullModelRange = function () {
  60179. this._assertNotDisposed();
  60180. var lineCount = this.getLineCount();
  60181. return new range_1.Range(1, 1, lineCount, this.getLineMaxColumn(lineCount));
  60182. };
  60183. TextModel.prototype.findMatchesLineByLine = function (searchRange, searchData, captureMatches, limitResultCount) {
  60184. return this._buffer.findMatchesLineByLine(searchRange, searchData, captureMatches, limitResultCount);
  60185. };
  60186. TextModel.prototype.findMatches = function (searchString, rawSearchScope, isRegex, matchCase, wordSeparators, captureMatches, limitResultCount) {
  60187. if (limitResultCount === void 0) { limitResultCount = LIMIT_FIND_COUNT; }
  60188. this._assertNotDisposed();
  60189. var searchRange;
  60190. if (range_1.Range.isIRange(rawSearchScope)) {
  60191. searchRange = this.validateRange(rawSearchScope);
  60192. }
  60193. else {
  60194. searchRange = this.getFullModelRange();
  60195. }
  60196. if (!isRegex && searchString.indexOf('\n') < 0) {
  60197. // not regex, not multi line
  60198. var searchParams = new textModelSearch_1.SearchParams(searchString, isRegex, matchCase, wordSeparators);
  60199. var searchData = searchParams.parseSearchRequest();
  60200. if (!searchData) {
  60201. return [];
  60202. }
  60203. return this.findMatchesLineByLine(searchRange, searchData, captureMatches, limitResultCount);
  60204. }
  60205. return textModelSearch_1.TextModelSearch.findMatches(this, new textModelSearch_1.SearchParams(searchString, isRegex, matchCase, wordSeparators), searchRange, captureMatches, limitResultCount);
  60206. };
  60207. TextModel.prototype.findNextMatch = function (searchString, rawSearchStart, isRegex, matchCase, wordSeparators, captureMatches) {
  60208. this._assertNotDisposed();
  60209. var searchStart = this.validatePosition(rawSearchStart);
  60210. if (!isRegex && searchString.indexOf('\n') < 0) {
  60211. var searchParams = new textModelSearch_1.SearchParams(searchString, isRegex, matchCase, wordSeparators);
  60212. var searchData = searchParams.parseSearchRequest();
  60213. if (!searchData) {
  60214. return null;
  60215. }
  60216. var lineCount = this.getLineCount();
  60217. var searchRange = new range_1.Range(searchStart.lineNumber, searchStart.column, lineCount, this.getLineMaxColumn(lineCount));
  60218. var ret = this.findMatchesLineByLine(searchRange, searchData, captureMatches, 1);
  60219. textModelSearch_1.TextModelSearch.findNextMatch(this, new textModelSearch_1.SearchParams(searchString, isRegex, matchCase, wordSeparators), searchStart, captureMatches);
  60220. if (ret.length > 0) {
  60221. return ret[0];
  60222. }
  60223. searchRange = new range_1.Range(1, 1, searchStart.lineNumber, this.getLineMaxColumn(searchStart.lineNumber));
  60224. ret = this.findMatchesLineByLine(searchRange, searchData, captureMatches, 1);
  60225. if (ret.length > 0) {
  60226. return ret[0];
  60227. }
  60228. return null;
  60229. }
  60230. return textModelSearch_1.TextModelSearch.findNextMatch(this, new textModelSearch_1.SearchParams(searchString, isRegex, matchCase, wordSeparators), searchStart, captureMatches);
  60231. };
  60232. TextModel.prototype.findPreviousMatch = function (searchString, rawSearchStart, isRegex, matchCase, wordSeparators, captureMatches) {
  60233. this._assertNotDisposed();
  60234. var searchStart = this.validatePosition(rawSearchStart);
  60235. return textModelSearch_1.TextModelSearch.findPreviousMatch(this, new textModelSearch_1.SearchParams(searchString, isRegex, matchCase, wordSeparators), searchStart, captureMatches);
  60236. };
  60237. //#endregion
  60238. //#region Editing
  60239. TextModel.prototype.pushStackElement = function () {
  60240. this._commandManager.pushStackElement();
  60241. };
  60242. TextModel.prototype.pushEOL = function (eol) {
  60243. var currentEOL = (this.getEOL() === '\n' ? 0 /* LF */ : 1 /* CRLF */);
  60244. if (currentEOL === eol) {
  60245. return;
  60246. }
  60247. try {
  60248. this._onDidChangeDecorations.beginDeferredEmit();
  60249. this._eventEmitter.beginDeferredEmit();
  60250. this._commandManager.pushEOL(eol);
  60251. }
  60252. finally {
  60253. this._eventEmitter.endDeferredEmit();
  60254. this._onDidChangeDecorations.endDeferredEmit();
  60255. }
  60256. };
  60257. TextModel.prototype.pushEditOperations = function (beforeCursorState, editOperations, cursorStateComputer) {
  60258. try {
  60259. this._onDidChangeDecorations.beginDeferredEmit();
  60260. this._eventEmitter.beginDeferredEmit();
  60261. return this._pushEditOperations(beforeCursorState, editOperations, cursorStateComputer);
  60262. }
  60263. finally {
  60264. this._eventEmitter.endDeferredEmit();
  60265. this._onDidChangeDecorations.endDeferredEmit();
  60266. }
  60267. };
  60268. TextModel.prototype._pushEditOperations = function (beforeCursorState, editOperations, cursorStateComputer) {
  60269. var _this = this;
  60270. if (this._options.trimAutoWhitespace && this._trimAutoWhitespaceLines) {
  60271. // Go through each saved line number and insert a trim whitespace edit
  60272. // if it is safe to do so (no conflicts with other edits).
  60273. var incomingEdits = editOperations.map(function (op) {
  60274. return {
  60275. range: _this.validateRange(op.range),
  60276. text: op.text
  60277. };
  60278. });
  60279. // Sometimes, auto-formatters change ranges automatically which can cause undesired auto whitespace trimming near the cursor
  60280. // We'll use the following heuristic: if the edits occur near the cursor, then it's ok to trim auto whitespace
  60281. var editsAreNearCursors = true;
  60282. for (var i = 0, len = beforeCursorState.length; i < len; i++) {
  60283. var sel = beforeCursorState[i];
  60284. var foundEditNearSel = false;
  60285. for (var j = 0, lenJ = incomingEdits.length; j < lenJ; j++) {
  60286. var editRange = incomingEdits[j].range;
  60287. var selIsAbove = editRange.startLineNumber > sel.endLineNumber;
  60288. var selIsBelow = sel.startLineNumber > editRange.endLineNumber;
  60289. if (!selIsAbove && !selIsBelow) {
  60290. foundEditNearSel = true;
  60291. break;
  60292. }
  60293. }
  60294. if (!foundEditNearSel) {
  60295. editsAreNearCursors = false;
  60296. break;
  60297. }
  60298. }
  60299. if (editsAreNearCursors) {
  60300. for (var i = 0, len = this._trimAutoWhitespaceLines.length; i < len; i++) {
  60301. var trimLineNumber = this._trimAutoWhitespaceLines[i];
  60302. var maxLineColumn = this.getLineMaxColumn(trimLineNumber);
  60303. var allowTrimLine = true;
  60304. for (var j = 0, lenJ = incomingEdits.length; j < lenJ; j++) {
  60305. var editRange = incomingEdits[j].range;
  60306. var editText = incomingEdits[j].text;
  60307. if (trimLineNumber < editRange.startLineNumber || trimLineNumber > editRange.endLineNumber) {
  60308. // `trimLine` is completely outside this edit
  60309. continue;
  60310. }
  60311. // At this point:
  60312. // editRange.startLineNumber <= trimLine <= editRange.endLineNumber
  60313. if (trimLineNumber === editRange.startLineNumber && editRange.startColumn === maxLineColumn
  60314. && editRange.isEmpty() && editText && editText.length > 0 && editText.charAt(0) === '\n') {
  60315. // This edit inserts a new line (and maybe other text) after `trimLine`
  60316. continue;
  60317. }
  60318. if (trimLineNumber === editRange.startLineNumber && editRange.startColumn === 1
  60319. && editRange.isEmpty() && editText && editText.length > 0 && editText.charAt(editText.length - 1) === '\n') {
  60320. // This edit inserts a new line (and maybe other text) before `trimLine`
  60321. continue;
  60322. }
  60323. // Looks like we can't trim this line as it would interfere with an incoming edit
  60324. allowTrimLine = false;
  60325. break;
  60326. }
  60327. if (allowTrimLine) {
  60328. editOperations.push({
  60329. range: new range_1.Range(trimLineNumber, 1, trimLineNumber, maxLineColumn),
  60330. text: null
  60331. });
  60332. }
  60333. }
  60334. }
  60335. this._trimAutoWhitespaceLines = null;
  60336. }
  60337. return this._commandManager.pushEditOperation(beforeCursorState, editOperations, cursorStateComputer);
  60338. };
  60339. TextModel.prototype.applyEdits = function (rawOperations) {
  60340. try {
  60341. this._onDidChangeDecorations.beginDeferredEmit();
  60342. this._eventEmitter.beginDeferredEmit();
  60343. return this._applyEdits(rawOperations);
  60344. }
  60345. finally {
  60346. this._eventEmitter.endDeferredEmit();
  60347. this._onDidChangeDecorations.endDeferredEmit();
  60348. }
  60349. };
  60350. TextModel.prototype._applyEdits = function (rawOperations) {
  60351. for (var i = 0, len = rawOperations.length; i < len; i++) {
  60352. rawOperations[i].range = this.validateRange(rawOperations[i].range);
  60353. }
  60354. var oldLineCount = this._buffer.getLineCount();
  60355. var result = this._buffer.applyEdits(rawOperations, this._options.trimAutoWhitespace);
  60356. var newLineCount = this._buffer.getLineCount();
  60357. var contentChanges = result.changes;
  60358. this._trimAutoWhitespaceLines = result.trimAutoWhitespaceLineNumbers;
  60359. if (contentChanges.length !== 0) {
  60360. var rawContentChanges = [];
  60361. var lineCount = oldLineCount;
  60362. for (var i = 0, len = contentChanges.length; i < len; i++) {
  60363. var change = contentChanges[i];
  60364. var _a = tokensStore_1.countEOL(change.text), eolCount = _a[0], firstLineLength = _a[1], lastLineLength = _a[2];
  60365. this._tokens.acceptEdit(change.range, eolCount, firstLineLength);
  60366. this._tokens2.acceptEdit(change.range, eolCount, firstLineLength, lastLineLength, change.text.length > 0 ? change.text.charCodeAt(0) : 0 /* Null */);
  60367. this._onDidChangeDecorations.fire();
  60368. this._decorationsTree.acceptReplace(change.rangeOffset, change.rangeLength, change.text.length, change.forceMoveMarkers);
  60369. var startLineNumber = change.range.startLineNumber;
  60370. var endLineNumber = change.range.endLineNumber;
  60371. var deletingLinesCnt = endLineNumber - startLineNumber;
  60372. var insertingLinesCnt = eolCount;
  60373. var editingLinesCnt = Math.min(deletingLinesCnt, insertingLinesCnt);
  60374. var changeLineCountDelta = (insertingLinesCnt - deletingLinesCnt);
  60375. for (var j = editingLinesCnt; j >= 0; j--) {
  60376. var editLineNumber = startLineNumber + j;
  60377. var currentEditLineNumber = newLineCount - lineCount - changeLineCountDelta + editLineNumber;
  60378. rawContentChanges.push(new textModelEvents_1.ModelRawLineChanged(editLineNumber, this.getLineContent(currentEditLineNumber)));
  60379. }
  60380. if (editingLinesCnt < deletingLinesCnt) {
  60381. // Must delete some lines
  60382. var spliceStartLineNumber = startLineNumber + editingLinesCnt;
  60383. rawContentChanges.push(new textModelEvents_1.ModelRawLinesDeleted(spliceStartLineNumber + 1, endLineNumber));
  60384. }
  60385. if (editingLinesCnt < insertingLinesCnt) {
  60386. // Must insert some lines
  60387. var spliceLineNumber = startLineNumber + editingLinesCnt;
  60388. var cnt = insertingLinesCnt - editingLinesCnt;
  60389. var fromLineNumber = newLineCount - lineCount - cnt + spliceLineNumber + 1;
  60390. var newLines = [];
  60391. for (var i_1 = 0; i_1 < cnt; i_1++) {
  60392. var lineNumber = fromLineNumber + i_1;
  60393. newLines[lineNumber - fromLineNumber] = this.getLineContent(lineNumber);
  60394. }
  60395. rawContentChanges.push(new textModelEvents_1.ModelRawLinesInserted(spliceLineNumber + 1, startLineNumber + insertingLinesCnt, newLines));
  60396. }
  60397. lineCount += changeLineCountDelta;
  60398. }
  60399. this._increaseVersionId();
  60400. this._emitContentChangedEvent(new textModelEvents_1.ModelRawContentChangedEvent(rawContentChanges, this.getVersionId(), this._isUndoing, this._isRedoing), {
  60401. changes: contentChanges,
  60402. eol: this._buffer.getEOL(),
  60403. versionId: this.getVersionId(),
  60404. isUndoing: this._isUndoing,
  60405. isRedoing: this._isRedoing,
  60406. isFlush: false
  60407. });
  60408. }
  60409. return result.reverseEdits;
  60410. };
  60411. TextModel.prototype._undo = function () {
  60412. this._isUndoing = true;
  60413. var r = this._commandManager.undo();
  60414. this._isUndoing = false;
  60415. if (!r) {
  60416. return null;
  60417. }
  60418. this._overwriteAlternativeVersionId(r.recordedVersionId);
  60419. return r.selections;
  60420. };
  60421. TextModel.prototype.undo = function () {
  60422. try {
  60423. this._onDidChangeDecorations.beginDeferredEmit();
  60424. this._eventEmitter.beginDeferredEmit();
  60425. return this._undo();
  60426. }
  60427. finally {
  60428. this._eventEmitter.endDeferredEmit();
  60429. this._onDidChangeDecorations.endDeferredEmit();
  60430. }
  60431. };
  60432. TextModel.prototype.canUndo = function () {
  60433. return this._commandManager.canUndo();
  60434. };
  60435. TextModel.prototype._redo = function () {
  60436. this._isRedoing = true;
  60437. var r = this._commandManager.redo();
  60438. this._isRedoing = false;
  60439. if (!r) {
  60440. return null;
  60441. }
  60442. this._overwriteAlternativeVersionId(r.recordedVersionId);
  60443. return r.selections;
  60444. };
  60445. TextModel.prototype.redo = function () {
  60446. try {
  60447. this._onDidChangeDecorations.beginDeferredEmit();
  60448. this._eventEmitter.beginDeferredEmit();
  60449. return this._redo();
  60450. }
  60451. finally {
  60452. this._eventEmitter.endDeferredEmit();
  60453. this._onDidChangeDecorations.endDeferredEmit();
  60454. }
  60455. };
  60456. TextModel.prototype.canRedo = function () {
  60457. return this._commandManager.canRedo();
  60458. };
  60459. //#endregion
  60460. //#region Decorations
  60461. TextModel.prototype.changeDecorations = function (callback, ownerId) {
  60462. if (ownerId === void 0) { ownerId = 0; }
  60463. this._assertNotDisposed();
  60464. try {
  60465. this._onDidChangeDecorations.beginDeferredEmit();
  60466. return this._changeDecorations(ownerId, callback);
  60467. }
  60468. finally {
  60469. this._onDidChangeDecorations.endDeferredEmit();
  60470. }
  60471. };
  60472. TextModel.prototype._changeDecorations = function (ownerId, callback) {
  60473. var _this = this;
  60474. var changeAccessor = {
  60475. addDecoration: function (range, options) {
  60476. _this._onDidChangeDecorations.fire();
  60477. return _this._deltaDecorationsImpl(ownerId, [], [{ range: range, options: options }])[0];
  60478. },
  60479. changeDecoration: function (id, newRange) {
  60480. _this._onDidChangeDecorations.fire();
  60481. _this._changeDecorationImpl(id, newRange);
  60482. },
  60483. changeDecorationOptions: function (id, options) {
  60484. _this._onDidChangeDecorations.fire();
  60485. _this._changeDecorationOptionsImpl(id, _normalizeOptions(options));
  60486. },
  60487. removeDecoration: function (id) {
  60488. _this._onDidChangeDecorations.fire();
  60489. _this._deltaDecorationsImpl(ownerId, [id], []);
  60490. },
  60491. deltaDecorations: function (oldDecorations, newDecorations) {
  60492. if (oldDecorations.length === 0 && newDecorations.length === 0) {
  60493. // nothing to do
  60494. return [];
  60495. }
  60496. _this._onDidChangeDecorations.fire();
  60497. return _this._deltaDecorationsImpl(ownerId, oldDecorations, newDecorations);
  60498. }
  60499. };
  60500. var result = null;
  60501. try {
  60502. result = callback(changeAccessor);
  60503. }
  60504. catch (e) {
  60505. errors_1.onUnexpectedError(e);
  60506. }
  60507. // Invalidate change accessor
  60508. changeAccessor.addDecoration = invalidFunc;
  60509. changeAccessor.changeDecoration = invalidFunc;
  60510. changeAccessor.changeDecorationOptions = invalidFunc;
  60511. changeAccessor.removeDecoration = invalidFunc;
  60512. changeAccessor.deltaDecorations = invalidFunc;
  60513. return result;
  60514. };
  60515. TextModel.prototype.deltaDecorations = function (oldDecorations, newDecorations, ownerId) {
  60516. if (ownerId === void 0) { ownerId = 0; }
  60517. this._assertNotDisposed();
  60518. if (!oldDecorations) {
  60519. oldDecorations = [];
  60520. }
  60521. if (oldDecorations.length === 0 && newDecorations.length === 0) {
  60522. // nothing to do
  60523. return [];
  60524. }
  60525. try {
  60526. this._onDidChangeDecorations.beginDeferredEmit();
  60527. this._onDidChangeDecorations.fire();
  60528. return this._deltaDecorationsImpl(ownerId, oldDecorations, newDecorations);
  60529. }
  60530. finally {
  60531. this._onDidChangeDecorations.endDeferredEmit();
  60532. }
  60533. };
  60534. TextModel.prototype._getTrackedRange = function (id) {
  60535. return this.getDecorationRange(id);
  60536. };
  60537. TextModel.prototype._setTrackedRange = function (id, newRange, newStickiness) {
  60538. var node = (id ? this._decorations[id] : null);
  60539. if (!node) {
  60540. if (!newRange) {
  60541. // node doesn't exist, the request is to delete => nothing to do
  60542. return null;
  60543. }
  60544. // node doesn't exist, the request is to set => add the tracked range
  60545. return this._deltaDecorationsImpl(0, [], [{ range: newRange, options: TRACKED_RANGE_OPTIONS[newStickiness] }])[0];
  60546. }
  60547. if (!newRange) {
  60548. // node exists, the request is to delete => delete node
  60549. this._decorationsTree.delete(node);
  60550. delete this._decorations[node.id];
  60551. return null;
  60552. }
  60553. // node exists, the request is to set => change the tracked range and its options
  60554. var range = this._validateRangeRelaxedNoAllocations(newRange);
  60555. var startOffset = this._buffer.getOffsetAt(range.startLineNumber, range.startColumn);
  60556. var endOffset = this._buffer.getOffsetAt(range.endLineNumber, range.endColumn);
  60557. this._decorationsTree.delete(node);
  60558. node.reset(this.getVersionId(), startOffset, endOffset, range);
  60559. node.setOptions(TRACKED_RANGE_OPTIONS[newStickiness]);
  60560. this._decorationsTree.insert(node);
  60561. return node.id;
  60562. };
  60563. TextModel.prototype.removeAllDecorationsWithOwnerId = function (ownerId) {
  60564. if (this._isDisposed) {
  60565. return;
  60566. }
  60567. var nodes = this._decorationsTree.collectNodesFromOwner(ownerId);
  60568. for (var i = 0, len = nodes.length; i < len; i++) {
  60569. var node = nodes[i];
  60570. this._decorationsTree.delete(node);
  60571. delete this._decorations[node.id];
  60572. }
  60573. };
  60574. TextModel.prototype.getDecorationOptions = function (decorationId) {
  60575. var node = this._decorations[decorationId];
  60576. if (!node) {
  60577. return null;
  60578. }
  60579. return node.options;
  60580. };
  60581. TextModel.prototype.getDecorationRange = function (decorationId) {
  60582. var node = this._decorations[decorationId];
  60583. if (!node) {
  60584. return null;
  60585. }
  60586. var versionId = this.getVersionId();
  60587. if (node.cachedVersionId !== versionId) {
  60588. this._decorationsTree.resolveNode(node, versionId);
  60589. }
  60590. if (node.range === null) {
  60591. node.range = this._getRangeAt(node.cachedAbsoluteStart, node.cachedAbsoluteEnd);
  60592. }
  60593. return node.range;
  60594. };
  60595. TextModel.prototype.getLineDecorations = function (lineNumber, ownerId, filterOutValidation) {
  60596. if (ownerId === void 0) { ownerId = 0; }
  60597. if (filterOutValidation === void 0) { filterOutValidation = false; }
  60598. if (lineNumber < 1 || lineNumber > this.getLineCount()) {
  60599. return [];
  60600. }
  60601. return this.getLinesDecorations(lineNumber, lineNumber, ownerId, filterOutValidation);
  60602. };
  60603. TextModel.prototype.getLinesDecorations = function (_startLineNumber, _endLineNumber, ownerId, filterOutValidation) {
  60604. if (ownerId === void 0) { ownerId = 0; }
  60605. if (filterOutValidation === void 0) { filterOutValidation = false; }
  60606. var lineCount = this.getLineCount();
  60607. var startLineNumber = Math.min(lineCount, Math.max(1, _startLineNumber));
  60608. var endLineNumber = Math.min(lineCount, Math.max(1, _endLineNumber));
  60609. var endColumn = this.getLineMaxColumn(endLineNumber);
  60610. return this._getDecorationsInRange(new range_1.Range(startLineNumber, 1, endLineNumber, endColumn), ownerId, filterOutValidation);
  60611. };
  60612. TextModel.prototype.getDecorationsInRange = function (range, ownerId, filterOutValidation) {
  60613. if (ownerId === void 0) { ownerId = 0; }
  60614. if (filterOutValidation === void 0) { filterOutValidation = false; }
  60615. var validatedRange = this.validateRange(range);
  60616. return this._getDecorationsInRange(validatedRange, ownerId, filterOutValidation);
  60617. };
  60618. TextModel.prototype.getOverviewRulerDecorations = function (ownerId, filterOutValidation) {
  60619. if (ownerId === void 0) { ownerId = 0; }
  60620. if (filterOutValidation === void 0) { filterOutValidation = false; }
  60621. var versionId = this.getVersionId();
  60622. var result = this._decorationsTree.search(ownerId, filterOutValidation, true, versionId);
  60623. return this._ensureNodesHaveRanges(result);
  60624. };
  60625. TextModel.prototype.getAllDecorations = function (ownerId, filterOutValidation) {
  60626. if (ownerId === void 0) { ownerId = 0; }
  60627. if (filterOutValidation === void 0) { filterOutValidation = false; }
  60628. var versionId = this.getVersionId();
  60629. var result = this._decorationsTree.search(ownerId, filterOutValidation, false, versionId);
  60630. return this._ensureNodesHaveRanges(result);
  60631. };
  60632. TextModel.prototype._getDecorationsInRange = function (filterRange, filterOwnerId, filterOutValidation) {
  60633. var startOffset = this._buffer.getOffsetAt(filterRange.startLineNumber, filterRange.startColumn);
  60634. var endOffset = this._buffer.getOffsetAt(filterRange.endLineNumber, filterRange.endColumn);
  60635. var versionId = this.getVersionId();
  60636. var result = this._decorationsTree.intervalSearch(startOffset, endOffset, filterOwnerId, filterOutValidation, versionId);
  60637. return this._ensureNodesHaveRanges(result);
  60638. };
  60639. TextModel.prototype._ensureNodesHaveRanges = function (nodes) {
  60640. for (var i = 0, len = nodes.length; i < len; i++) {
  60641. var node = nodes[i];
  60642. if (node.range === null) {
  60643. node.range = this._getRangeAt(node.cachedAbsoluteStart, node.cachedAbsoluteEnd);
  60644. }
  60645. }
  60646. return nodes;
  60647. };
  60648. TextModel.prototype._getRangeAt = function (start, end) {
  60649. return this._buffer.getRangeAt(start, end - start);
  60650. };
  60651. TextModel.prototype._changeDecorationImpl = function (decorationId, _range) {
  60652. var node = this._decorations[decorationId];
  60653. if (!node) {
  60654. return;
  60655. }
  60656. var range = this._validateRangeRelaxedNoAllocations(_range);
  60657. var startOffset = this._buffer.getOffsetAt(range.startLineNumber, range.startColumn);
  60658. var endOffset = this._buffer.getOffsetAt(range.endLineNumber, range.endColumn);
  60659. this._decorationsTree.delete(node);
  60660. node.reset(this.getVersionId(), startOffset, endOffset, range);
  60661. this._decorationsTree.insert(node);
  60662. };
  60663. TextModel.prototype._changeDecorationOptionsImpl = function (decorationId, options) {
  60664. var node = this._decorations[decorationId];
  60665. if (!node) {
  60666. return;
  60667. }
  60668. var nodeWasInOverviewRuler = (node.options.overviewRuler && node.options.overviewRuler.color ? true : false);
  60669. var nodeIsInOverviewRuler = (options.overviewRuler && options.overviewRuler.color ? true : false);
  60670. if (nodeWasInOverviewRuler !== nodeIsInOverviewRuler) {
  60671. // Delete + Insert due to an overview ruler status change
  60672. this._decorationsTree.delete(node);
  60673. node.setOptions(options);
  60674. this._decorationsTree.insert(node);
  60675. }
  60676. else {
  60677. node.setOptions(options);
  60678. }
  60679. };
  60680. TextModel.prototype._deltaDecorationsImpl = function (ownerId, oldDecorationsIds, newDecorations) {
  60681. var versionId = this.getVersionId();
  60682. var oldDecorationsLen = oldDecorationsIds.length;
  60683. var oldDecorationIndex = 0;
  60684. var newDecorationsLen = newDecorations.length;
  60685. var newDecorationIndex = 0;
  60686. var result = new Array(newDecorationsLen);
  60687. while (oldDecorationIndex < oldDecorationsLen || newDecorationIndex < newDecorationsLen) {
  60688. var node = null;
  60689. if (oldDecorationIndex < oldDecorationsLen) {
  60690. // (1) get ourselves an old node
  60691. do {
  60692. node = this._decorations[oldDecorationsIds[oldDecorationIndex++]];
  60693. } while (!node && oldDecorationIndex < oldDecorationsLen);
  60694. // (2) remove the node from the tree (if it exists)
  60695. if (node) {
  60696. this._decorationsTree.delete(node);
  60697. }
  60698. }
  60699. if (newDecorationIndex < newDecorationsLen) {
  60700. // (3) create a new node if necessary
  60701. if (!node) {
  60702. var internalDecorationId = (++this._lastDecorationId);
  60703. var decorationId = this._instanceId + ";" + internalDecorationId;
  60704. node = new intervalTree_1.IntervalNode(decorationId, 0, 0);
  60705. this._decorations[decorationId] = node;
  60706. }
  60707. // (4) initialize node
  60708. var newDecoration = newDecorations[newDecorationIndex];
  60709. var range = this._validateRangeRelaxedNoAllocations(newDecoration.range);
  60710. var options = _normalizeOptions(newDecoration.options);
  60711. var startOffset = this._buffer.getOffsetAt(range.startLineNumber, range.startColumn);
  60712. var endOffset = this._buffer.getOffsetAt(range.endLineNumber, range.endColumn);
  60713. node.ownerId = ownerId;
  60714. node.reset(versionId, startOffset, endOffset, range);
  60715. node.setOptions(options);
  60716. this._decorationsTree.insert(node);
  60717. result[newDecorationIndex] = node.id;
  60718. newDecorationIndex++;
  60719. }
  60720. else {
  60721. if (node) {
  60722. delete this._decorations[node.id];
  60723. }
  60724. }
  60725. }
  60726. return result;
  60727. };
  60728. //#endregion
  60729. //#region Tokenization
  60730. TextModel.prototype.setLineTokens = function (lineNumber, tokens) {
  60731. if (lineNumber < 1 || lineNumber > this.getLineCount()) {
  60732. throw new Error('Illegal value for lineNumber');
  60733. }
  60734. this._tokens.setTokens(this._languageIdentifier.id, lineNumber - 1, this._buffer.getLineLength(lineNumber), tokens);
  60735. };
  60736. TextModel.prototype.setTokens = function (tokens) {
  60737. if (tokens.length === 0) {
  60738. return;
  60739. }
  60740. var ranges = [];
  60741. for (var i = 0, len = tokens.length; i < len; i++) {
  60742. var element = tokens[i];
  60743. ranges.push({ fromLineNumber: element.startLineNumber, toLineNumber: element.startLineNumber + element.tokens.length - 1 });
  60744. for (var j = 0, lenJ = element.tokens.length; j < lenJ; j++) {
  60745. this.setLineTokens(element.startLineNumber + j, element.tokens[j]);
  60746. }
  60747. }
  60748. this._emitModelTokensChangedEvent({
  60749. tokenizationSupportChanged: false,
  60750. ranges: ranges
  60751. });
  60752. };
  60753. TextModel.prototype.setSemanticTokens = function (tokens) {
  60754. this._tokens2.set(tokens);
  60755. this._emitModelTokensChangedEvent({
  60756. tokenizationSupportChanged: false,
  60757. ranges: [{ fromLineNumber: 1, toLineNumber: this.getLineCount() }]
  60758. });
  60759. };
  60760. TextModel.prototype.tokenizeViewport = function (startLineNumber, endLineNumber) {
  60761. startLineNumber = Math.max(1, startLineNumber);
  60762. endLineNumber = Math.min(this._buffer.getLineCount(), endLineNumber);
  60763. this._tokenization.tokenizeViewport(startLineNumber, endLineNumber);
  60764. };
  60765. TextModel.prototype.clearTokens = function () {
  60766. this._tokens.flush();
  60767. this._emitModelTokensChangedEvent({
  60768. tokenizationSupportChanged: true,
  60769. ranges: [{
  60770. fromLineNumber: 1,
  60771. toLineNumber: this._buffer.getLineCount()
  60772. }]
  60773. });
  60774. };
  60775. TextModel.prototype._emitModelTokensChangedEvent = function (e) {
  60776. if (!this._isDisposing) {
  60777. this._onDidChangeTokens.fire(e);
  60778. }
  60779. };
  60780. TextModel.prototype.resetTokenization = function () {
  60781. this._tokenization.reset();
  60782. };
  60783. TextModel.prototype.forceTokenization = function (lineNumber) {
  60784. if (lineNumber < 1 || lineNumber > this.getLineCount()) {
  60785. throw new Error('Illegal value for lineNumber');
  60786. }
  60787. this._tokenization.forceTokenization(lineNumber);
  60788. };
  60789. TextModel.prototype.isCheapToTokenize = function (lineNumber) {
  60790. return this._tokenization.isCheapToTokenize(lineNumber);
  60791. };
  60792. TextModel.prototype.tokenizeIfCheap = function (lineNumber) {
  60793. if (this.isCheapToTokenize(lineNumber)) {
  60794. this.forceTokenization(lineNumber);
  60795. }
  60796. };
  60797. TextModel.prototype.getLineTokens = function (lineNumber) {
  60798. if (lineNumber < 1 || lineNumber > this.getLineCount()) {
  60799. throw new Error('Illegal value for lineNumber');
  60800. }
  60801. return this._getLineTokens(lineNumber);
  60802. };
  60803. TextModel.prototype._getLineTokens = function (lineNumber) {
  60804. var lineText = this.getLineContent(lineNumber);
  60805. var syntacticTokens = this._tokens.getTokens(this._languageIdentifier.id, lineNumber - 1, lineText);
  60806. return this._tokens2.addSemanticTokens(lineNumber, syntacticTokens);
  60807. };
  60808. TextModel.prototype.getLanguageIdentifier = function () {
  60809. return this._languageIdentifier;
  60810. };
  60811. TextModel.prototype.getModeId = function () {
  60812. return this._languageIdentifier.language;
  60813. };
  60814. TextModel.prototype.setMode = function (languageIdentifier) {
  60815. if (this._languageIdentifier.id === languageIdentifier.id) {
  60816. // There's nothing to do
  60817. return;
  60818. }
  60819. var e = {
  60820. oldLanguage: this._languageIdentifier.language,
  60821. newLanguage: languageIdentifier.language
  60822. };
  60823. this._languageIdentifier = languageIdentifier;
  60824. this._onDidChangeLanguage.fire(e);
  60825. this._onDidChangeLanguageConfiguration.fire({});
  60826. };
  60827. TextModel.prototype.getLanguageIdAtPosition = function (lineNumber, column) {
  60828. var position = this.validatePosition(new position_1.Position(lineNumber, column));
  60829. var lineTokens = this.getLineTokens(position.lineNumber);
  60830. return lineTokens.getLanguageId(lineTokens.findTokenIndexAtOffset(position.column - 1));
  60831. };
  60832. // Having tokens allows implementing additional helper methods
  60833. TextModel.prototype.getWordAtPosition = function (_position) {
  60834. this._assertNotDisposed();
  60835. var position = this.validatePosition(_position);
  60836. var lineContent = this.getLineContent(position.lineNumber);
  60837. var lineTokens = this._getLineTokens(position.lineNumber);
  60838. var tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
  60839. // (1). First try checking right biased word
  60840. var _a = TextModel._findLanguageBoundaries(lineTokens, tokenIndex), rbStartOffset = _a[0], rbEndOffset = _a[1];
  60841. var rightBiasedWord = wordHelper_1.getWordAtText(position.column, languageConfigurationRegistry_1.LanguageConfigurationRegistry.getWordDefinition(lineTokens.getLanguageId(tokenIndex)), lineContent.substring(rbStartOffset, rbEndOffset), rbStartOffset);
  60842. // Make sure the result touches the original passed in position
  60843. if (rightBiasedWord && rightBiasedWord.startColumn <= _position.column && _position.column <= rightBiasedWord.endColumn) {
  60844. return rightBiasedWord;
  60845. }
  60846. // (2). Else, if we were at a language boundary, check the left biased word
  60847. if (tokenIndex > 0 && rbStartOffset === position.column - 1) {
  60848. // edge case, where `position` sits between two tokens belonging to two different languages
  60849. var _b = TextModel._findLanguageBoundaries(lineTokens, tokenIndex - 1), lbStartOffset = _b[0], lbEndOffset = _b[1];
  60850. var leftBiasedWord = wordHelper_1.getWordAtText(position.column, languageConfigurationRegistry_1.LanguageConfigurationRegistry.getWordDefinition(lineTokens.getLanguageId(tokenIndex - 1)), lineContent.substring(lbStartOffset, lbEndOffset), lbStartOffset);
  60851. // Make sure the result touches the original passed in position
  60852. if (leftBiasedWord && leftBiasedWord.startColumn <= _position.column && _position.column <= leftBiasedWord.endColumn) {
  60853. return leftBiasedWord;
  60854. }
  60855. }
  60856. return null;
  60857. };
  60858. TextModel._findLanguageBoundaries = function (lineTokens, tokenIndex) {
  60859. var languageId = lineTokens.getLanguageId(tokenIndex);
  60860. // go left until a different language is hit
  60861. var startOffset = 0;
  60862. for (var i = tokenIndex; i >= 0 && lineTokens.getLanguageId(i) === languageId; i--) {
  60863. startOffset = lineTokens.getStartOffset(i);
  60864. }
  60865. // go right until a different language is hit
  60866. var endOffset = lineTokens.getLineContent().length;
  60867. for (var i = tokenIndex, tokenCount = lineTokens.getCount(); i < tokenCount && lineTokens.getLanguageId(i) === languageId; i++) {
  60868. endOffset = lineTokens.getEndOffset(i);
  60869. }
  60870. return [startOffset, endOffset];
  60871. };
  60872. TextModel.prototype.getWordUntilPosition = function (position) {
  60873. var wordAtPosition = this.getWordAtPosition(position);
  60874. if (!wordAtPosition) {
  60875. return {
  60876. word: '',
  60877. startColumn: position.column,
  60878. endColumn: position.column
  60879. };
  60880. }
  60881. return {
  60882. word: wordAtPosition.word.substr(0, position.column - wordAtPosition.startColumn),
  60883. startColumn: wordAtPosition.startColumn,
  60884. endColumn: position.column
  60885. };
  60886. };
  60887. TextModel.prototype.findMatchingBracketUp = function (_bracket, _position) {
  60888. var bracket = _bracket.toLowerCase();
  60889. var position = this.validatePosition(_position);
  60890. var lineTokens = this._getLineTokens(position.lineNumber);
  60891. var languageId = lineTokens.getLanguageId(lineTokens.findTokenIndexAtOffset(position.column - 1));
  60892. var bracketsSupport = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getBracketsSupport(languageId);
  60893. if (!bracketsSupport) {
  60894. return null;
  60895. }
  60896. var data = bracketsSupport.textIsBracket[bracket];
  60897. if (!data) {
  60898. return null;
  60899. }
  60900. return this._findMatchingBracketUp(data, position);
  60901. };
  60902. TextModel.prototype.matchBracket = function (position) {
  60903. return this._matchBracket(this.validatePosition(position));
  60904. };
  60905. TextModel.prototype._matchBracket = function (position) {
  60906. var lineNumber = position.lineNumber;
  60907. var lineTokens = this._getLineTokens(lineNumber);
  60908. var tokenCount = lineTokens.getCount();
  60909. var lineText = this._buffer.getLineContent(lineNumber);
  60910. var tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
  60911. if (tokenIndex < 0) {
  60912. return null;
  60913. }
  60914. var currentModeBrackets = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getBracketsSupport(lineTokens.getLanguageId(tokenIndex));
  60915. // check that the token is not to be ignored
  60916. if (currentModeBrackets && !supports_1.ignoreBracketsInToken(lineTokens.getStandardTokenType(tokenIndex))) {
  60917. // limit search to not go before `maxBracketLength`
  60918. var searchStartOffset = Math.max(0, position.column - 1 - currentModeBrackets.maxBracketLength);
  60919. for (var i = tokenIndex - 1; i >= 0; i--) {
  60920. var tokenEndOffset = lineTokens.getEndOffset(i);
  60921. if (tokenEndOffset <= searchStartOffset) {
  60922. break;
  60923. }
  60924. if (supports_1.ignoreBracketsInToken(lineTokens.getStandardTokenType(i))) {
  60925. searchStartOffset = tokenEndOffset;
  60926. }
  60927. }
  60928. // limit search to not go after `maxBracketLength`
  60929. var searchEndOffset = Math.min(lineText.length, position.column - 1 + currentModeBrackets.maxBracketLength);
  60930. // it might be the case that [currentTokenStart -> currentTokenEnd] contains multiple brackets
  60931. // `bestResult` will contain the most right-side result
  60932. var bestResult = null;
  60933. while (true) {
  60934. var foundBracket = richEditBrackets_1.BracketsUtils.findNextBracketInRange(currentModeBrackets.forwardRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  60935. if (!foundBracket) {
  60936. // there are no more brackets in this text
  60937. break;
  60938. }
  60939. // check that we didn't hit a bracket too far away from position
  60940. if (foundBracket.startColumn <= position.column && position.column <= foundBracket.endColumn) {
  60941. var foundBracketText = lineText.substring(foundBracket.startColumn - 1, foundBracket.endColumn - 1).toLowerCase();
  60942. var r = this._matchFoundBracket(foundBracket, currentModeBrackets.textIsBracket[foundBracketText], currentModeBrackets.textIsOpenBracket[foundBracketText]);
  60943. if (r) {
  60944. bestResult = r;
  60945. }
  60946. }
  60947. searchStartOffset = foundBracket.endColumn - 1;
  60948. }
  60949. if (bestResult) {
  60950. return bestResult;
  60951. }
  60952. }
  60953. // If position is in between two tokens, try also looking in the previous token
  60954. if (tokenIndex > 0 && lineTokens.getStartOffset(tokenIndex) === position.column - 1) {
  60955. var prevTokenIndex = tokenIndex - 1;
  60956. var prevModeBrackets = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getBracketsSupport(lineTokens.getLanguageId(prevTokenIndex));
  60957. // check that previous token is not to be ignored
  60958. if (prevModeBrackets && !supports_1.ignoreBracketsInToken(lineTokens.getStandardTokenType(prevTokenIndex))) {
  60959. // limit search in case previous token is very large, there's no need to go beyond `maxBracketLength`
  60960. var searchStartOffset = Math.max(0, position.column - 1 - prevModeBrackets.maxBracketLength);
  60961. var searchEndOffset = Math.min(lineText.length, position.column - 1 + prevModeBrackets.maxBracketLength);
  60962. for (var i = prevTokenIndex + 1; i < tokenCount; i++) {
  60963. var tokenStartOffset = lineTokens.getStartOffset(i);
  60964. if (tokenStartOffset >= searchEndOffset) {
  60965. break;
  60966. }
  60967. if (supports_1.ignoreBracketsInToken(lineTokens.getStandardTokenType(i))) {
  60968. searchEndOffset = tokenStartOffset;
  60969. }
  60970. }
  60971. var foundBracket = richEditBrackets_1.BracketsUtils.findPrevBracketInRange(prevModeBrackets.reversedRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  60972. // check that we didn't hit a bracket too far away from position
  60973. if (foundBracket && foundBracket.startColumn <= position.column && position.column <= foundBracket.endColumn) {
  60974. var foundBracketText = lineText.substring(foundBracket.startColumn - 1, foundBracket.endColumn - 1).toLowerCase();
  60975. var r = this._matchFoundBracket(foundBracket, prevModeBrackets.textIsBracket[foundBracketText], prevModeBrackets.textIsOpenBracket[foundBracketText]);
  60976. if (r) {
  60977. return r;
  60978. }
  60979. }
  60980. }
  60981. }
  60982. return null;
  60983. };
  60984. TextModel.prototype._matchFoundBracket = function (foundBracket, data, isOpen) {
  60985. if (!data) {
  60986. return null;
  60987. }
  60988. if (isOpen) {
  60989. var matched = this._findMatchingBracketDown(data, foundBracket.getEndPosition());
  60990. if (matched) {
  60991. return [foundBracket, matched];
  60992. }
  60993. }
  60994. else {
  60995. var matched = this._findMatchingBracketUp(data, foundBracket.getStartPosition());
  60996. if (matched) {
  60997. return [foundBracket, matched];
  60998. }
  60999. }
  61000. return null;
  61001. };
  61002. TextModel.prototype._findMatchingBracketUp = function (bracket, position) {
  61003. // console.log('_findMatchingBracketUp: ', 'bracket: ', JSON.stringify(bracket), 'startPosition: ', String(position));
  61004. var languageId = bracket.languageIdentifier.id;
  61005. var reversedBracketRegex = bracket.reversedRegex;
  61006. var count = -1;
  61007. var searchPrevMatchingBracketInRange = function (lineNumber, lineText, searchStartOffset, searchEndOffset) {
  61008. while (true) {
  61009. var r = richEditBrackets_1.BracketsUtils.findPrevBracketInRange(reversedBracketRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61010. if (!r) {
  61011. break;
  61012. }
  61013. var hitText = lineText.substring(r.startColumn - 1, r.endColumn - 1).toLowerCase();
  61014. if (bracket.isOpen(hitText)) {
  61015. count++;
  61016. }
  61017. else if (bracket.isClose(hitText)) {
  61018. count--;
  61019. }
  61020. if (count === 0) {
  61021. return r;
  61022. }
  61023. searchEndOffset = r.startColumn - 1;
  61024. }
  61025. return null;
  61026. };
  61027. for (var lineNumber = position.lineNumber; lineNumber >= 1; lineNumber--) {
  61028. var lineTokens = this._getLineTokens(lineNumber);
  61029. var tokenCount = lineTokens.getCount();
  61030. var lineText = this._buffer.getLineContent(lineNumber);
  61031. var tokenIndex = tokenCount - 1;
  61032. var searchStartOffset = lineText.length;
  61033. var searchEndOffset = lineText.length;
  61034. if (lineNumber === position.lineNumber) {
  61035. tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
  61036. searchStartOffset = position.column - 1;
  61037. searchEndOffset = position.column - 1;
  61038. }
  61039. var prevSearchInToken = true;
  61040. for (; tokenIndex >= 0; tokenIndex--) {
  61041. var searchInToken = (lineTokens.getLanguageId(tokenIndex) === languageId && !supports_1.ignoreBracketsInToken(lineTokens.getStandardTokenType(tokenIndex)));
  61042. if (searchInToken) {
  61043. // this token should be searched
  61044. if (prevSearchInToken) {
  61045. // the previous token should be searched, simply extend searchStartOffset
  61046. searchStartOffset = lineTokens.getStartOffset(tokenIndex);
  61047. }
  61048. else {
  61049. // the previous token should not be searched
  61050. searchStartOffset = lineTokens.getStartOffset(tokenIndex);
  61051. searchEndOffset = lineTokens.getEndOffset(tokenIndex);
  61052. }
  61053. }
  61054. else {
  61055. // this token should not be searched
  61056. if (prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61057. var r = searchPrevMatchingBracketInRange(lineNumber, lineText, searchStartOffset, searchEndOffset);
  61058. if (r) {
  61059. return r;
  61060. }
  61061. }
  61062. }
  61063. prevSearchInToken = searchInToken;
  61064. }
  61065. if (prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61066. var r = searchPrevMatchingBracketInRange(lineNumber, lineText, searchStartOffset, searchEndOffset);
  61067. if (r) {
  61068. return r;
  61069. }
  61070. }
  61071. }
  61072. return null;
  61073. };
  61074. TextModel.prototype._findMatchingBracketDown = function (bracket, position) {
  61075. // console.log('_findMatchingBracketDown: ', 'bracket: ', JSON.stringify(bracket), 'startPosition: ', String(position));
  61076. var languageId = bracket.languageIdentifier.id;
  61077. var bracketRegex = bracket.forwardRegex;
  61078. var count = 1;
  61079. var searchNextMatchingBracketInRange = function (lineNumber, lineText, searchStartOffset, searchEndOffset) {
  61080. while (true) {
  61081. var r = richEditBrackets_1.BracketsUtils.findNextBracketInRange(bracketRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61082. if (!r) {
  61083. break;
  61084. }
  61085. var hitText = lineText.substring(r.startColumn - 1, r.endColumn - 1).toLowerCase();
  61086. if (bracket.isOpen(hitText)) {
  61087. count++;
  61088. }
  61089. else if (bracket.isClose(hitText)) {
  61090. count--;
  61091. }
  61092. if (count === 0) {
  61093. return r;
  61094. }
  61095. searchStartOffset = r.endColumn - 1;
  61096. }
  61097. return null;
  61098. };
  61099. var lineCount = this.getLineCount();
  61100. for (var lineNumber = position.lineNumber; lineNumber <= lineCount; lineNumber++) {
  61101. var lineTokens = this._getLineTokens(lineNumber);
  61102. var tokenCount = lineTokens.getCount();
  61103. var lineText = this._buffer.getLineContent(lineNumber);
  61104. var tokenIndex = 0;
  61105. var searchStartOffset = 0;
  61106. var searchEndOffset = 0;
  61107. if (lineNumber === position.lineNumber) {
  61108. tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
  61109. searchStartOffset = position.column - 1;
  61110. searchEndOffset = position.column - 1;
  61111. }
  61112. var prevSearchInToken = true;
  61113. for (; tokenIndex < tokenCount; tokenIndex++) {
  61114. var searchInToken = (lineTokens.getLanguageId(tokenIndex) === languageId && !supports_1.ignoreBracketsInToken(lineTokens.getStandardTokenType(tokenIndex)));
  61115. if (searchInToken) {
  61116. // this token should be searched
  61117. if (prevSearchInToken) {
  61118. // the previous token should be searched, simply extend searchEndOffset
  61119. searchEndOffset = lineTokens.getEndOffset(tokenIndex);
  61120. }
  61121. else {
  61122. // the previous token should not be searched
  61123. searchStartOffset = lineTokens.getStartOffset(tokenIndex);
  61124. searchEndOffset = lineTokens.getEndOffset(tokenIndex);
  61125. }
  61126. }
  61127. else {
  61128. // this token should not be searched
  61129. if (prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61130. var r = searchNextMatchingBracketInRange(lineNumber, lineText, searchStartOffset, searchEndOffset);
  61131. if (r) {
  61132. return r;
  61133. }
  61134. }
  61135. }
  61136. prevSearchInToken = searchInToken;
  61137. }
  61138. if (prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61139. var r = searchNextMatchingBracketInRange(lineNumber, lineText, searchStartOffset, searchEndOffset);
  61140. if (r) {
  61141. return r;
  61142. }
  61143. }
  61144. }
  61145. return null;
  61146. };
  61147. TextModel.prototype.findPrevBracket = function (_position) {
  61148. var position = this.validatePosition(_position);
  61149. var languageId = -1;
  61150. var modeBrackets = null;
  61151. for (var lineNumber = position.lineNumber; lineNumber >= 1; lineNumber--) {
  61152. var lineTokens = this._getLineTokens(lineNumber);
  61153. var tokenCount = lineTokens.getCount();
  61154. var lineText = this._buffer.getLineContent(lineNumber);
  61155. var tokenIndex = tokenCount - 1;
  61156. var searchStartOffset = lineText.length;
  61157. var searchEndOffset = lineText.length;
  61158. if (lineNumber === position.lineNumber) {
  61159. tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
  61160. searchStartOffset = position.column - 1;
  61161. searchEndOffset = position.column - 1;
  61162. var tokenLanguageId = lineTokens.getLanguageId(tokenIndex);
  61163. if (languageId !== tokenLanguageId) {
  61164. languageId = tokenLanguageId;
  61165. modeBrackets = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getBracketsSupport(languageId);
  61166. }
  61167. }
  61168. var prevSearchInToken = true;
  61169. for (; tokenIndex >= 0; tokenIndex--) {
  61170. var tokenLanguageId = lineTokens.getLanguageId(tokenIndex);
  61171. if (languageId !== tokenLanguageId) {
  61172. // language id change!
  61173. if (modeBrackets && prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61174. var r = richEditBrackets_1.BracketsUtils.findPrevBracketInRange(modeBrackets.reversedRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61175. if (r) {
  61176. return this._toFoundBracket(modeBrackets, r);
  61177. }
  61178. prevSearchInToken = false;
  61179. }
  61180. languageId = tokenLanguageId;
  61181. modeBrackets = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getBracketsSupport(languageId);
  61182. }
  61183. var searchInToken = (!!modeBrackets && !supports_1.ignoreBracketsInToken(lineTokens.getStandardTokenType(tokenIndex)));
  61184. if (searchInToken) {
  61185. // this token should be searched
  61186. if (prevSearchInToken) {
  61187. // the previous token should be searched, simply extend searchStartOffset
  61188. searchStartOffset = lineTokens.getStartOffset(tokenIndex);
  61189. }
  61190. else {
  61191. // the previous token should not be searched
  61192. searchStartOffset = lineTokens.getStartOffset(tokenIndex);
  61193. searchEndOffset = lineTokens.getEndOffset(tokenIndex);
  61194. }
  61195. }
  61196. else {
  61197. // this token should not be searched
  61198. if (modeBrackets && prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61199. var r = richEditBrackets_1.BracketsUtils.findPrevBracketInRange(modeBrackets.reversedRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61200. if (r) {
  61201. return this._toFoundBracket(modeBrackets, r);
  61202. }
  61203. }
  61204. }
  61205. prevSearchInToken = searchInToken;
  61206. }
  61207. if (modeBrackets && prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61208. var r = richEditBrackets_1.BracketsUtils.findPrevBracketInRange(modeBrackets.reversedRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61209. if (r) {
  61210. return this._toFoundBracket(modeBrackets, r);
  61211. }
  61212. }
  61213. }
  61214. return null;
  61215. };
  61216. TextModel.prototype.findNextBracket = function (_position) {
  61217. var position = this.validatePosition(_position);
  61218. var lineCount = this.getLineCount();
  61219. var languageId = -1;
  61220. var modeBrackets = null;
  61221. for (var lineNumber = position.lineNumber; lineNumber <= lineCount; lineNumber++) {
  61222. var lineTokens = this._getLineTokens(lineNumber);
  61223. var tokenCount = lineTokens.getCount();
  61224. var lineText = this._buffer.getLineContent(lineNumber);
  61225. var tokenIndex = 0;
  61226. var searchStartOffset = 0;
  61227. var searchEndOffset = 0;
  61228. if (lineNumber === position.lineNumber) {
  61229. tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
  61230. searchStartOffset = position.column - 1;
  61231. searchEndOffset = position.column - 1;
  61232. var tokenLanguageId = lineTokens.getLanguageId(tokenIndex);
  61233. if (languageId !== tokenLanguageId) {
  61234. languageId = tokenLanguageId;
  61235. modeBrackets = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getBracketsSupport(languageId);
  61236. }
  61237. }
  61238. var prevSearchInToken = true;
  61239. for (; tokenIndex < tokenCount; tokenIndex++) {
  61240. var tokenLanguageId = lineTokens.getLanguageId(tokenIndex);
  61241. if (languageId !== tokenLanguageId) {
  61242. // language id change!
  61243. if (modeBrackets && prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61244. var r = richEditBrackets_1.BracketsUtils.findNextBracketInRange(modeBrackets.forwardRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61245. if (r) {
  61246. return this._toFoundBracket(modeBrackets, r);
  61247. }
  61248. prevSearchInToken = false;
  61249. }
  61250. languageId = tokenLanguageId;
  61251. modeBrackets = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getBracketsSupport(languageId);
  61252. }
  61253. var searchInToken = (!!modeBrackets && !supports_1.ignoreBracketsInToken(lineTokens.getStandardTokenType(tokenIndex)));
  61254. if (searchInToken) {
  61255. // this token should be searched
  61256. if (prevSearchInToken) {
  61257. // the previous token should be searched, simply extend searchEndOffset
  61258. searchEndOffset = lineTokens.getEndOffset(tokenIndex);
  61259. }
  61260. else {
  61261. // the previous token should not be searched
  61262. searchStartOffset = lineTokens.getStartOffset(tokenIndex);
  61263. searchEndOffset = lineTokens.getEndOffset(tokenIndex);
  61264. }
  61265. }
  61266. else {
  61267. // this token should not be searched
  61268. if (modeBrackets && prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61269. var r = richEditBrackets_1.BracketsUtils.findNextBracketInRange(modeBrackets.forwardRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61270. if (r) {
  61271. return this._toFoundBracket(modeBrackets, r);
  61272. }
  61273. }
  61274. }
  61275. prevSearchInToken = searchInToken;
  61276. }
  61277. if (modeBrackets && prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61278. var r = richEditBrackets_1.BracketsUtils.findNextBracketInRange(modeBrackets.forwardRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61279. if (r) {
  61280. return this._toFoundBracket(modeBrackets, r);
  61281. }
  61282. }
  61283. }
  61284. return null;
  61285. };
  61286. TextModel.prototype.findEnclosingBrackets = function (_position, maxDuration) {
  61287. var _this = this;
  61288. if (maxDuration === void 0) { maxDuration = 1073741824 /* MAX_SAFE_SMALL_INTEGER */; }
  61289. var position = this.validatePosition(_position);
  61290. var lineCount = this.getLineCount();
  61291. var savedCounts = new Map();
  61292. var counts = [];
  61293. var resetCounts = function (languageId, modeBrackets) {
  61294. if (!savedCounts.has(languageId)) {
  61295. var tmp = [];
  61296. for (var i = 0, len = modeBrackets ? modeBrackets.brackets.length : 0; i < len; i++) {
  61297. tmp[i] = 0;
  61298. }
  61299. savedCounts.set(languageId, tmp);
  61300. }
  61301. counts = savedCounts.get(languageId);
  61302. };
  61303. var searchInRange = function (modeBrackets, lineNumber, lineText, searchStartOffset, searchEndOffset) {
  61304. while (true) {
  61305. var r = richEditBrackets_1.BracketsUtils.findNextBracketInRange(modeBrackets.forwardRegex, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61306. if (!r) {
  61307. break;
  61308. }
  61309. var hitText = lineText.substring(r.startColumn - 1, r.endColumn - 1).toLowerCase();
  61310. var bracket = modeBrackets.textIsBracket[hitText];
  61311. if (bracket) {
  61312. if (bracket.isOpen(hitText)) {
  61313. counts[bracket.index]++;
  61314. }
  61315. else if (bracket.isClose(hitText)) {
  61316. counts[bracket.index]--;
  61317. }
  61318. if (counts[bracket.index] === -1) {
  61319. return _this._matchFoundBracket(r, bracket, false);
  61320. }
  61321. }
  61322. searchStartOffset = r.endColumn - 1;
  61323. }
  61324. return null;
  61325. };
  61326. var languageId = -1;
  61327. var modeBrackets = null;
  61328. var startTime = Date.now();
  61329. for (var lineNumber = position.lineNumber; lineNumber <= lineCount; lineNumber++) {
  61330. var elapsedTime = Date.now() - startTime;
  61331. if (elapsedTime > maxDuration) {
  61332. return null;
  61333. }
  61334. var lineTokens = this._getLineTokens(lineNumber);
  61335. var tokenCount = lineTokens.getCount();
  61336. var lineText = this._buffer.getLineContent(lineNumber);
  61337. var tokenIndex = 0;
  61338. var searchStartOffset = 0;
  61339. var searchEndOffset = 0;
  61340. if (lineNumber === position.lineNumber) {
  61341. tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
  61342. searchStartOffset = position.column - 1;
  61343. searchEndOffset = position.column - 1;
  61344. var tokenLanguageId = lineTokens.getLanguageId(tokenIndex);
  61345. if (languageId !== tokenLanguageId) {
  61346. languageId = tokenLanguageId;
  61347. modeBrackets = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getBracketsSupport(languageId);
  61348. resetCounts(languageId, modeBrackets);
  61349. }
  61350. }
  61351. var prevSearchInToken = true;
  61352. for (; tokenIndex < tokenCount; tokenIndex++) {
  61353. var tokenLanguageId = lineTokens.getLanguageId(tokenIndex);
  61354. if (languageId !== tokenLanguageId) {
  61355. // language id change!
  61356. if (modeBrackets && prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61357. var r = searchInRange(modeBrackets, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61358. if (r) {
  61359. return r;
  61360. }
  61361. prevSearchInToken = false;
  61362. }
  61363. languageId = tokenLanguageId;
  61364. modeBrackets = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getBracketsSupport(languageId);
  61365. resetCounts(languageId, modeBrackets);
  61366. }
  61367. var searchInToken = (!!modeBrackets && !supports_1.ignoreBracketsInToken(lineTokens.getStandardTokenType(tokenIndex)));
  61368. if (searchInToken) {
  61369. // this token should be searched
  61370. if (prevSearchInToken) {
  61371. // the previous token should be searched, simply extend searchEndOffset
  61372. searchEndOffset = lineTokens.getEndOffset(tokenIndex);
  61373. }
  61374. else {
  61375. // the previous token should not be searched
  61376. searchStartOffset = lineTokens.getStartOffset(tokenIndex);
  61377. searchEndOffset = lineTokens.getEndOffset(tokenIndex);
  61378. }
  61379. }
  61380. else {
  61381. // this token should not be searched
  61382. if (modeBrackets && prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61383. var r = searchInRange(modeBrackets, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61384. if (r) {
  61385. return r;
  61386. }
  61387. }
  61388. }
  61389. prevSearchInToken = searchInToken;
  61390. }
  61391. if (modeBrackets && prevSearchInToken && searchStartOffset !== searchEndOffset) {
  61392. var r = searchInRange(modeBrackets, lineNumber, lineText, searchStartOffset, searchEndOffset);
  61393. if (r) {
  61394. return r;
  61395. }
  61396. }
  61397. }
  61398. return null;
  61399. };
  61400. TextModel.prototype._toFoundBracket = function (modeBrackets, r) {
  61401. if (!r) {
  61402. return null;
  61403. }
  61404. var text = this.getValueInRange(r);
  61405. text = text.toLowerCase();
  61406. var data = modeBrackets.textIsBracket[text];
  61407. if (!data) {
  61408. return null;
  61409. }
  61410. return {
  61411. range: r,
  61412. open: data.open,
  61413. close: data.close,
  61414. isOpen: modeBrackets.textIsOpenBracket[text]
  61415. };
  61416. };
  61417. /**
  61418. * Returns:
  61419. * - -1 => the line consists of whitespace
  61420. * - otherwise => the indent level is returned value
  61421. */
  61422. TextModel.computeIndentLevel = function (line, tabSize) {
  61423. var indent = 0;
  61424. var i = 0;
  61425. var len = line.length;
  61426. while (i < len) {
  61427. var chCode = line.charCodeAt(i);
  61428. if (chCode === 32 /* Space */) {
  61429. indent++;
  61430. }
  61431. else if (chCode === 9 /* Tab */) {
  61432. indent = indent - indent % tabSize + tabSize;
  61433. }
  61434. else {
  61435. break;
  61436. }
  61437. i++;
  61438. }
  61439. if (i === len) {
  61440. return -1; // line only consists of whitespace
  61441. }
  61442. return indent;
  61443. };
  61444. TextModel.prototype._computeIndentLevel = function (lineIndex) {
  61445. return TextModel.computeIndentLevel(this._buffer.getLineContent(lineIndex + 1), this._options.tabSize);
  61446. };
  61447. TextModel.prototype.getActiveIndentGuide = function (lineNumber, minLineNumber, maxLineNumber) {
  61448. var _this = this;
  61449. this._assertNotDisposed();
  61450. var lineCount = this.getLineCount();
  61451. if (lineNumber < 1 || lineNumber > lineCount) {
  61452. throw new Error('Illegal value for lineNumber');
  61453. }
  61454. var foldingRules = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getFoldingRules(this._languageIdentifier.id);
  61455. var offSide = Boolean(foldingRules && foldingRules.offSide);
  61456. var up_aboveContentLineIndex = -2; /* -2 is a marker for not having computed it */
  61457. var up_aboveContentLineIndent = -1;
  61458. var up_belowContentLineIndex = -2; /* -2 is a marker for not having computed it */
  61459. var up_belowContentLineIndent = -1;
  61460. var up_resolveIndents = function (lineNumber) {
  61461. if (up_aboveContentLineIndex !== -1 && (up_aboveContentLineIndex === -2 || up_aboveContentLineIndex > lineNumber - 1)) {
  61462. up_aboveContentLineIndex = -1;
  61463. up_aboveContentLineIndent = -1;
  61464. // must find previous line with content
  61465. for (var lineIndex = lineNumber - 2; lineIndex >= 0; lineIndex--) {
  61466. var indent_1 = _this._computeIndentLevel(lineIndex);
  61467. if (indent_1 >= 0) {
  61468. up_aboveContentLineIndex = lineIndex;
  61469. up_aboveContentLineIndent = indent_1;
  61470. break;
  61471. }
  61472. }
  61473. }
  61474. if (up_belowContentLineIndex === -2) {
  61475. up_belowContentLineIndex = -1;
  61476. up_belowContentLineIndent = -1;
  61477. // must find next line with content
  61478. for (var lineIndex = lineNumber; lineIndex < lineCount; lineIndex++) {
  61479. var indent_2 = _this._computeIndentLevel(lineIndex);
  61480. if (indent_2 >= 0) {
  61481. up_belowContentLineIndex = lineIndex;
  61482. up_belowContentLineIndent = indent_2;
  61483. break;
  61484. }
  61485. }
  61486. }
  61487. };
  61488. var down_aboveContentLineIndex = -2; /* -2 is a marker for not having computed it */
  61489. var down_aboveContentLineIndent = -1;
  61490. var down_belowContentLineIndex = -2; /* -2 is a marker for not having computed it */
  61491. var down_belowContentLineIndent = -1;
  61492. var down_resolveIndents = function (lineNumber) {
  61493. if (down_aboveContentLineIndex === -2) {
  61494. down_aboveContentLineIndex = -1;
  61495. down_aboveContentLineIndent = -1;
  61496. // must find previous line with content
  61497. for (var lineIndex = lineNumber - 2; lineIndex >= 0; lineIndex--) {
  61498. var indent_3 = _this._computeIndentLevel(lineIndex);
  61499. if (indent_3 >= 0) {
  61500. down_aboveContentLineIndex = lineIndex;
  61501. down_aboveContentLineIndent = indent_3;
  61502. break;
  61503. }
  61504. }
  61505. }
  61506. if (down_belowContentLineIndex !== -1 && (down_belowContentLineIndex === -2 || down_belowContentLineIndex < lineNumber - 1)) {
  61507. down_belowContentLineIndex = -1;
  61508. down_belowContentLineIndent = -1;
  61509. // must find next line with content
  61510. for (var lineIndex = lineNumber; lineIndex < lineCount; lineIndex++) {
  61511. var indent_4 = _this._computeIndentLevel(lineIndex);
  61512. if (indent_4 >= 0) {
  61513. down_belowContentLineIndex = lineIndex;
  61514. down_belowContentLineIndent = indent_4;
  61515. break;
  61516. }
  61517. }
  61518. }
  61519. };
  61520. var startLineNumber = 0;
  61521. var goUp = true;
  61522. var endLineNumber = 0;
  61523. var goDown = true;
  61524. var indent = 0;
  61525. for (var distance = 0; goUp || goDown; distance++) {
  61526. var upLineNumber = lineNumber - distance;
  61527. var downLineNumber = lineNumber + distance;
  61528. if (distance !== 0 && (upLineNumber < 1 || upLineNumber < minLineNumber)) {
  61529. goUp = false;
  61530. }
  61531. if (distance !== 0 && (downLineNumber > lineCount || downLineNumber > maxLineNumber)) {
  61532. goDown = false;
  61533. }
  61534. if (distance > 50000) {
  61535. // stop processing
  61536. goUp = false;
  61537. goDown = false;
  61538. }
  61539. if (goUp) {
  61540. // compute indent level going up
  61541. var upLineIndentLevel = void 0;
  61542. var currentIndent = this._computeIndentLevel(upLineNumber - 1);
  61543. if (currentIndent >= 0) {
  61544. // This line has content (besides whitespace)
  61545. // Use the line's indent
  61546. up_belowContentLineIndex = upLineNumber - 1;
  61547. up_belowContentLineIndent = currentIndent;
  61548. upLineIndentLevel = Math.ceil(currentIndent / this._options.indentSize);
  61549. }
  61550. else {
  61551. up_resolveIndents(upLineNumber);
  61552. upLineIndentLevel = this._getIndentLevelForWhitespaceLine(offSide, up_aboveContentLineIndent, up_belowContentLineIndent);
  61553. }
  61554. if (distance === 0) {
  61555. // This is the initial line number
  61556. startLineNumber = upLineNumber;
  61557. endLineNumber = downLineNumber;
  61558. indent = upLineIndentLevel;
  61559. if (indent === 0) {
  61560. // No need to continue
  61561. return { startLineNumber: startLineNumber, endLineNumber: endLineNumber, indent: indent };
  61562. }
  61563. continue;
  61564. }
  61565. if (upLineIndentLevel >= indent) {
  61566. startLineNumber = upLineNumber;
  61567. }
  61568. else {
  61569. goUp = false;
  61570. }
  61571. }
  61572. if (goDown) {
  61573. // compute indent level going down
  61574. var downLineIndentLevel = void 0;
  61575. var currentIndent = this._computeIndentLevel(downLineNumber - 1);
  61576. if (currentIndent >= 0) {
  61577. // This line has content (besides whitespace)
  61578. // Use the line's indent
  61579. down_aboveContentLineIndex = downLineNumber - 1;
  61580. down_aboveContentLineIndent = currentIndent;
  61581. downLineIndentLevel = Math.ceil(currentIndent / this._options.indentSize);
  61582. }
  61583. else {
  61584. down_resolveIndents(downLineNumber);
  61585. downLineIndentLevel = this._getIndentLevelForWhitespaceLine(offSide, down_aboveContentLineIndent, down_belowContentLineIndent);
  61586. }
  61587. if (downLineIndentLevel >= indent) {
  61588. endLineNumber = downLineNumber;
  61589. }
  61590. else {
  61591. goDown = false;
  61592. }
  61593. }
  61594. }
  61595. return { startLineNumber: startLineNumber, endLineNumber: endLineNumber, indent: indent };
  61596. };
  61597. TextModel.prototype.getLinesIndentGuides = function (startLineNumber, endLineNumber) {
  61598. this._assertNotDisposed();
  61599. var lineCount = this.getLineCount();
  61600. if (startLineNumber < 1 || startLineNumber > lineCount) {
  61601. throw new Error('Illegal value for startLineNumber');
  61602. }
  61603. if (endLineNumber < 1 || endLineNumber > lineCount) {
  61604. throw new Error('Illegal value for endLineNumber');
  61605. }
  61606. var foldingRules = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getFoldingRules(this._languageIdentifier.id);
  61607. var offSide = Boolean(foldingRules && foldingRules.offSide);
  61608. var result = new Array(endLineNumber - startLineNumber + 1);
  61609. var aboveContentLineIndex = -2; /* -2 is a marker for not having computed it */
  61610. var aboveContentLineIndent = -1;
  61611. var belowContentLineIndex = -2; /* -2 is a marker for not having computed it */
  61612. var belowContentLineIndent = -1;
  61613. for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
  61614. var resultIndex = lineNumber - startLineNumber;
  61615. var currentIndent = this._computeIndentLevel(lineNumber - 1);
  61616. if (currentIndent >= 0) {
  61617. // This line has content (besides whitespace)
  61618. // Use the line's indent
  61619. aboveContentLineIndex = lineNumber - 1;
  61620. aboveContentLineIndent = currentIndent;
  61621. result[resultIndex] = Math.ceil(currentIndent / this._options.indentSize);
  61622. continue;
  61623. }
  61624. if (aboveContentLineIndex === -2) {
  61625. aboveContentLineIndex = -1;
  61626. aboveContentLineIndent = -1;
  61627. // must find previous line with content
  61628. for (var lineIndex = lineNumber - 2; lineIndex >= 0; lineIndex--) {
  61629. var indent = this._computeIndentLevel(lineIndex);
  61630. if (indent >= 0) {
  61631. aboveContentLineIndex = lineIndex;
  61632. aboveContentLineIndent = indent;
  61633. break;
  61634. }
  61635. }
  61636. }
  61637. if (belowContentLineIndex !== -1 && (belowContentLineIndex === -2 || belowContentLineIndex < lineNumber - 1)) {
  61638. belowContentLineIndex = -1;
  61639. belowContentLineIndent = -1;
  61640. // must find next line with content
  61641. for (var lineIndex = lineNumber; lineIndex < lineCount; lineIndex++) {
  61642. var indent = this._computeIndentLevel(lineIndex);
  61643. if (indent >= 0) {
  61644. belowContentLineIndex = lineIndex;
  61645. belowContentLineIndent = indent;
  61646. break;
  61647. }
  61648. }
  61649. }
  61650. result[resultIndex] = this._getIndentLevelForWhitespaceLine(offSide, aboveContentLineIndent, belowContentLineIndent);
  61651. }
  61652. return result;
  61653. };
  61654. TextModel.prototype._getIndentLevelForWhitespaceLine = function (offSide, aboveContentLineIndent, belowContentLineIndent) {
  61655. if (aboveContentLineIndent === -1 || belowContentLineIndent === -1) {
  61656. // At the top or bottom of the file
  61657. return 0;
  61658. }
  61659. else if (aboveContentLineIndent < belowContentLineIndent) {
  61660. // we are inside the region above
  61661. return (1 + Math.floor(aboveContentLineIndent / this._options.indentSize));
  61662. }
  61663. else if (aboveContentLineIndent === belowContentLineIndent) {
  61664. // we are in between two regions
  61665. return Math.ceil(belowContentLineIndent / this._options.indentSize);
  61666. }
  61667. else {
  61668. if (offSide) {
  61669. // same level as region below
  61670. return Math.ceil(belowContentLineIndent / this._options.indentSize);
  61671. }
  61672. else {
  61673. // we are inside the region that ends below
  61674. return (1 + Math.floor(belowContentLineIndent / this._options.indentSize));
  61675. }
  61676. }
  61677. };
  61678. TextModel.MODEL_SYNC_LIMIT = 50 * 1024 * 1024; // 50 MB
  61679. TextModel.LARGE_FILE_SIZE_THRESHOLD = 20 * 1024 * 1024; // 20 MB;
  61680. TextModel.LARGE_FILE_LINE_COUNT_THRESHOLD = 300 * 1000; // 300K lines
  61681. TextModel.DEFAULT_CREATION_OPTIONS = {
  61682. isForSimpleWidget: false,
  61683. tabSize: editorOptions_1.EDITOR_MODEL_DEFAULTS.tabSize,
  61684. indentSize: editorOptions_1.EDITOR_MODEL_DEFAULTS.indentSize,
  61685. insertSpaces: editorOptions_1.EDITOR_MODEL_DEFAULTS.insertSpaces,
  61686. detectIndentation: false,
  61687. defaultEOL: 1 /* LF */,
  61688. trimAutoWhitespace: editorOptions_1.EDITOR_MODEL_DEFAULTS.trimAutoWhitespace,
  61689. largeFileOptimizations: editorOptions_1.EDITOR_MODEL_DEFAULTS.largeFileOptimizations,
  61690. };
  61691. return TextModel;
  61692. }(lifecycle_1.Disposable));
  61693. exports.TextModel = TextModel;
  61694. //#region Decorations
  61695. var DecorationsTrees = /** @class */ (function () {
  61696. function DecorationsTrees() {
  61697. this._decorationsTree0 = new intervalTree_1.IntervalTree();
  61698. this._decorationsTree1 = new intervalTree_1.IntervalTree();
  61699. }
  61700. DecorationsTrees.prototype.intervalSearch = function (start, end, filterOwnerId, filterOutValidation, cachedVersionId) {
  61701. var r0 = this._decorationsTree0.intervalSearch(start, end, filterOwnerId, filterOutValidation, cachedVersionId);
  61702. var r1 = this._decorationsTree1.intervalSearch(start, end, filterOwnerId, filterOutValidation, cachedVersionId);
  61703. return r0.concat(r1);
  61704. };
  61705. DecorationsTrees.prototype.search = function (filterOwnerId, filterOutValidation, overviewRulerOnly, cachedVersionId) {
  61706. if (overviewRulerOnly) {
  61707. return this._decorationsTree1.search(filterOwnerId, filterOutValidation, cachedVersionId);
  61708. }
  61709. else {
  61710. var r0 = this._decorationsTree0.search(filterOwnerId, filterOutValidation, cachedVersionId);
  61711. var r1 = this._decorationsTree1.search(filterOwnerId, filterOutValidation, cachedVersionId);
  61712. return r0.concat(r1);
  61713. }
  61714. };
  61715. DecorationsTrees.prototype.collectNodesFromOwner = function (ownerId) {
  61716. var r0 = this._decorationsTree0.collectNodesFromOwner(ownerId);
  61717. var r1 = this._decorationsTree1.collectNodesFromOwner(ownerId);
  61718. return r0.concat(r1);
  61719. };
  61720. DecorationsTrees.prototype.collectNodesPostOrder = function () {
  61721. var r0 = this._decorationsTree0.collectNodesPostOrder();
  61722. var r1 = this._decorationsTree1.collectNodesPostOrder();
  61723. return r0.concat(r1);
  61724. };
  61725. DecorationsTrees.prototype.insert = function (node) {
  61726. if (intervalTree_1.getNodeIsInOverviewRuler(node)) {
  61727. this._decorationsTree1.insert(node);
  61728. }
  61729. else {
  61730. this._decorationsTree0.insert(node);
  61731. }
  61732. };
  61733. DecorationsTrees.prototype.delete = function (node) {
  61734. if (intervalTree_1.getNodeIsInOverviewRuler(node)) {
  61735. this._decorationsTree1.delete(node);
  61736. }
  61737. else {
  61738. this._decorationsTree0.delete(node);
  61739. }
  61740. };
  61741. DecorationsTrees.prototype.resolveNode = function (node, cachedVersionId) {
  61742. if (intervalTree_1.getNodeIsInOverviewRuler(node)) {
  61743. this._decorationsTree1.resolveNode(node, cachedVersionId);
  61744. }
  61745. else {
  61746. this._decorationsTree0.resolveNode(node, cachedVersionId);
  61747. }
  61748. };
  61749. DecorationsTrees.prototype.acceptReplace = function (offset, length, textLength, forceMoveMarkers) {
  61750. this._decorationsTree0.acceptReplace(offset, length, textLength, forceMoveMarkers);
  61751. this._decorationsTree1.acceptReplace(offset, length, textLength, forceMoveMarkers);
  61752. };
  61753. return DecorationsTrees;
  61754. }());
  61755. function cleanClassName(className) {
  61756. return className.replace(/[^a-z0-9\-_]/gi, ' ');
  61757. }
  61758. var DecorationOptions = /** @class */ (function () {
  61759. function DecorationOptions(options) {
  61760. this.color = options.color || '';
  61761. this.darkColor = options.darkColor || '';
  61762. }
  61763. return DecorationOptions;
  61764. }());
  61765. var ModelDecorationOverviewRulerOptions = /** @class */ (function (_super) {
  61766. __extends(ModelDecorationOverviewRulerOptions, _super);
  61767. function ModelDecorationOverviewRulerOptions(options) {
  61768. var _this = _super.call(this, options) || this;
  61769. _this._resolvedColor = null;
  61770. _this.position = (typeof options.position === 'number' ? options.position : model.OverviewRulerLane.Center);
  61771. return _this;
  61772. }
  61773. ModelDecorationOverviewRulerOptions.prototype.getColor = function (theme) {
  61774. if (!this._resolvedColor) {
  61775. if (theme.type !== 'light' && this.darkColor) {
  61776. this._resolvedColor = this._resolveColor(this.darkColor, theme);
  61777. }
  61778. else {
  61779. this._resolvedColor = this._resolveColor(this.color, theme);
  61780. }
  61781. }
  61782. return this._resolvedColor;
  61783. };
  61784. ModelDecorationOverviewRulerOptions.prototype.invalidateCachedColor = function () {
  61785. this._resolvedColor = null;
  61786. };
  61787. ModelDecorationOverviewRulerOptions.prototype._resolveColor = function (color, theme) {
  61788. if (typeof color === 'string') {
  61789. return color;
  61790. }
  61791. var c = color ? theme.getColor(color.id) : null;
  61792. if (!c) {
  61793. return '';
  61794. }
  61795. return c.toString();
  61796. };
  61797. return ModelDecorationOverviewRulerOptions;
  61798. }(DecorationOptions));
  61799. exports.ModelDecorationOverviewRulerOptions = ModelDecorationOverviewRulerOptions;
  61800. var ModelDecorationMinimapOptions = /** @class */ (function (_super) {
  61801. __extends(ModelDecorationMinimapOptions, _super);
  61802. function ModelDecorationMinimapOptions(options) {
  61803. var _this = _super.call(this, options) || this;
  61804. _this.position = options.position;
  61805. return _this;
  61806. }
  61807. ModelDecorationMinimapOptions.prototype.getColor = function (theme) {
  61808. if (!this._resolvedColor) {
  61809. if (theme.type !== 'light' && this.darkColor) {
  61810. this._resolvedColor = this._resolveColor(this.darkColor, theme);
  61811. }
  61812. else {
  61813. this._resolvedColor = this._resolveColor(this.color, theme);
  61814. }
  61815. }
  61816. return this._resolvedColor;
  61817. };
  61818. ModelDecorationMinimapOptions.prototype.invalidateCachedColor = function () {
  61819. this._resolvedColor = undefined;
  61820. };
  61821. ModelDecorationMinimapOptions.prototype._resolveColor = function (color, theme) {
  61822. if (typeof color === 'string') {
  61823. return color_1.Color.fromHex(color);
  61824. }
  61825. return theme.getColor(color.id);
  61826. };
  61827. return ModelDecorationMinimapOptions;
  61828. }(DecorationOptions));
  61829. exports.ModelDecorationMinimapOptions = ModelDecorationMinimapOptions;
  61830. var ModelDecorationOptions = /** @class */ (function () {
  61831. function ModelDecorationOptions(options) {
  61832. this.stickiness = options.stickiness || 0 /* AlwaysGrowsWhenTypingAtEdges */;
  61833. this.zIndex = options.zIndex || 0;
  61834. this.className = options.className ? cleanClassName(options.className) : null;
  61835. this.hoverMessage = types_1.withUndefinedAsNull(options.hoverMessage);
  61836. this.glyphMarginHoverMessage = types_1.withUndefinedAsNull(options.glyphMarginHoverMessage);
  61837. this.isWholeLine = options.isWholeLine || false;
  61838. this.showIfCollapsed = options.showIfCollapsed || false;
  61839. this.collapseOnReplaceEdit = options.collapseOnReplaceEdit || false;
  61840. this.overviewRuler = options.overviewRuler ? new ModelDecorationOverviewRulerOptions(options.overviewRuler) : null;
  61841. this.minimap = options.minimap ? new ModelDecorationMinimapOptions(options.minimap) : null;
  61842. this.glyphMarginClassName = options.glyphMarginClassName ? cleanClassName(options.glyphMarginClassName) : null;
  61843. this.linesDecorationsClassName = options.linesDecorationsClassName ? cleanClassName(options.linesDecorationsClassName) : null;
  61844. this.marginClassName = options.marginClassName ? cleanClassName(options.marginClassName) : null;
  61845. this.inlineClassName = options.inlineClassName ? cleanClassName(options.inlineClassName) : null;
  61846. this.inlineClassNameAffectsLetterSpacing = options.inlineClassNameAffectsLetterSpacing || false;
  61847. this.beforeContentClassName = options.beforeContentClassName ? cleanClassName(options.beforeContentClassName) : null;
  61848. this.afterContentClassName = options.afterContentClassName ? cleanClassName(options.afterContentClassName) : null;
  61849. }
  61850. ModelDecorationOptions.register = function (options) {
  61851. return new ModelDecorationOptions(options);
  61852. };
  61853. ModelDecorationOptions.createDynamic = function (options) {
  61854. return new ModelDecorationOptions(options);
  61855. };
  61856. return ModelDecorationOptions;
  61857. }());
  61858. exports.ModelDecorationOptions = ModelDecorationOptions;
  61859. ModelDecorationOptions.EMPTY = ModelDecorationOptions.register({});
  61860. /**
  61861. * The order carefully matches the values of the enum.
  61862. */
  61863. var TRACKED_RANGE_OPTIONS = [
  61864. ModelDecorationOptions.register({ stickiness: 0 /* AlwaysGrowsWhenTypingAtEdges */ }),
  61865. ModelDecorationOptions.register({ stickiness: 1 /* NeverGrowsWhenTypingAtEdges */ }),
  61866. ModelDecorationOptions.register({ stickiness: 2 /* GrowsOnlyWhenTypingBefore */ }),
  61867. ModelDecorationOptions.register({ stickiness: 3 /* GrowsOnlyWhenTypingAfter */ }),
  61868. ];
  61869. function _normalizeOptions(options) {
  61870. if (options instanceof ModelDecorationOptions) {
  61871. return options;
  61872. }
  61873. return ModelDecorationOptions.createDynamic(options);
  61874. }
  61875. var DidChangeDecorationsEmitter = /** @class */ (function (_super) {
  61876. __extends(DidChangeDecorationsEmitter, _super);
  61877. function DidChangeDecorationsEmitter() {
  61878. var _this = _super.call(this) || this;
  61879. _this._actual = _this._register(new event_1.Emitter());
  61880. _this.event = _this._actual.event;
  61881. _this._deferredCnt = 0;
  61882. _this._shouldFire = false;
  61883. return _this;
  61884. }
  61885. DidChangeDecorationsEmitter.prototype.beginDeferredEmit = function () {
  61886. this._deferredCnt++;
  61887. };
  61888. DidChangeDecorationsEmitter.prototype.endDeferredEmit = function () {
  61889. this._deferredCnt--;
  61890. if (this._deferredCnt === 0) {
  61891. if (this._shouldFire) {
  61892. this._shouldFire = false;
  61893. this._actual.fire({});
  61894. }
  61895. }
  61896. };
  61897. DidChangeDecorationsEmitter.prototype.fire = function () {
  61898. this._shouldFire = true;
  61899. };
  61900. return DidChangeDecorationsEmitter;
  61901. }(lifecycle_1.Disposable));
  61902. exports.DidChangeDecorationsEmitter = DidChangeDecorationsEmitter;
  61903. //#endregion
  61904. var DidChangeContentEmitter = /** @class */ (function (_super) {
  61905. __extends(DidChangeContentEmitter, _super);
  61906. function DidChangeContentEmitter() {
  61907. var _this = _super.call(this) || this;
  61908. /**
  61909. * Both `fastEvent` and `slowEvent` work the same way and contain the same events, but first we invoke `fastEvent` and then `slowEvent`.
  61910. */
  61911. _this._fastEmitter = _this._register(new event_1.Emitter());
  61912. _this.fastEvent = _this._fastEmitter.event;
  61913. _this._slowEmitter = _this._register(new event_1.Emitter());
  61914. _this.slowEvent = _this._slowEmitter.event;
  61915. _this._deferredCnt = 0;
  61916. _this._deferredEvent = null;
  61917. return _this;
  61918. }
  61919. DidChangeContentEmitter.prototype.beginDeferredEmit = function () {
  61920. this._deferredCnt++;
  61921. };
  61922. DidChangeContentEmitter.prototype.endDeferredEmit = function () {
  61923. this._deferredCnt--;
  61924. if (this._deferredCnt === 0) {
  61925. if (this._deferredEvent !== null) {
  61926. var e = this._deferredEvent;
  61927. this._deferredEvent = null;
  61928. this._fastEmitter.fire(e);
  61929. this._slowEmitter.fire(e);
  61930. }
  61931. }
  61932. };
  61933. DidChangeContentEmitter.prototype.fire = function (e) {
  61934. if (this._deferredCnt > 0) {
  61935. if (this._deferredEvent) {
  61936. this._deferredEvent = this._deferredEvent.merge(e);
  61937. }
  61938. else {
  61939. this._deferredEvent = e;
  61940. }
  61941. return;
  61942. }
  61943. this._fastEmitter.fire(e);
  61944. this._slowEmitter.fire(e);
  61945. };
  61946. return DidChangeContentEmitter;
  61947. }(lifecycle_1.Disposable));
  61948. exports.DidChangeContentEmitter = DidChangeContentEmitter;
  61949. });
  61950. /*---------------------------------------------------------------------------------------------
  61951. * Copyright (c) Microsoft Corporation. All rights reserved.
  61952. * Licensed under the MIT License. See License.txt in the project root for license information.
  61953. *--------------------------------------------------------------------------------------------*/
  61954. define(__m[40/*vs/editor/common/controller/cursorCommon*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,5/*vs/base/common/strings*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,30/*vs/editor/common/model/textModel*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/]), function (require, exports, errors_1, strings, position_1, range_1, selection_1, textModel_1, languageConfigurationRegistry_1) {
  61955. "use strict";
  61956. Object.defineProperty(exports, "__esModule", { value: true });
  61957. var autoCloseAlways = function () { return true; };
  61958. var autoCloseNever = function () { return false; };
  61959. var autoCloseBeforeWhitespace = function (chr) { return (chr === ' ' || chr === '\t'); };
  61960. function appendEntry(target, key, value) {
  61961. if (target.has(key)) {
  61962. target.get(key).push(value);
  61963. }
  61964. else {
  61965. target.set(key, [value]);
  61966. }
  61967. }
  61968. var CursorConfiguration = /** @class */ (function () {
  61969. function CursorConfiguration(languageIdentifier, modelOptions, configuration) {
  61970. this._languageIdentifier = languageIdentifier;
  61971. var options = configuration.options;
  61972. var layoutInfo = options.get(107 /* layoutInfo */);
  61973. this.readOnly = options.get(68 /* readOnly */);
  61974. this.tabSize = modelOptions.tabSize;
  61975. this.indentSize = modelOptions.indentSize;
  61976. this.insertSpaces = modelOptions.insertSpaces;
  61977. this.lineHeight = options.get(49 /* lineHeight */);
  61978. this.pageSize = Math.max(1, Math.floor(layoutInfo.height / this.lineHeight) - 2);
  61979. this.useTabStops = options.get(95 /* useTabStops */);
  61980. this.wordSeparators = options.get(96 /* wordSeparators */);
  61981. this.emptySelectionClipboard = options.get(25 /* emptySelectionClipboard */);
  61982. this.copyWithSyntaxHighlighting = options.get(15 /* copyWithSyntaxHighlighting */);
  61983. this.multiCursorMergeOverlapping = options.get(58 /* multiCursorMergeOverlapping */);
  61984. this.multiCursorPaste = options.get(60 /* multiCursorPaste */);
  61985. this.autoClosingBrackets = options.get(5 /* autoClosingBrackets */);
  61986. this.autoClosingQuotes = options.get(7 /* autoClosingQuotes */);
  61987. this.autoClosingOvertype = options.get(6 /* autoClosingOvertype */);
  61988. this.autoSurround = options.get(10 /* autoSurround */);
  61989. this.autoIndent = options.get(8 /* autoIndent */);
  61990. this.autoClosingPairsOpen2 = new Map();
  61991. this.autoClosingPairsClose2 = new Map();
  61992. this.surroundingPairs = {};
  61993. this._electricChars = null;
  61994. this.shouldAutoCloseBefore = {
  61995. quote: CursorConfiguration._getShouldAutoClose(languageIdentifier, this.autoClosingQuotes),
  61996. bracket: CursorConfiguration._getShouldAutoClose(languageIdentifier, this.autoClosingBrackets)
  61997. };
  61998. var autoClosingPairs = CursorConfiguration._getAutoClosingPairs(languageIdentifier);
  61999. if (autoClosingPairs) {
  62000. for (var _i = 0, autoClosingPairs_1 = autoClosingPairs; _i < autoClosingPairs_1.length; _i++) {
  62001. var pair = autoClosingPairs_1[_i];
  62002. appendEntry(this.autoClosingPairsOpen2, pair.open.charAt(pair.open.length - 1), pair);
  62003. if (pair.close.length === 1) {
  62004. appendEntry(this.autoClosingPairsClose2, pair.close, pair);
  62005. }
  62006. }
  62007. }
  62008. var surroundingPairs = CursorConfiguration._getSurroundingPairs(languageIdentifier);
  62009. if (surroundingPairs) {
  62010. for (var _a = 0, surroundingPairs_1 = surroundingPairs; _a < surroundingPairs_1.length; _a++) {
  62011. var pair = surroundingPairs_1[_a];
  62012. this.surroundingPairs[pair.open] = pair.close;
  62013. }
  62014. }
  62015. }
  62016. CursorConfiguration.shouldRecreate = function (e) {
  62017. return (e.hasChanged(107 /* layoutInfo */)
  62018. || e.hasChanged(96 /* wordSeparators */)
  62019. || e.hasChanged(25 /* emptySelectionClipboard */)
  62020. || e.hasChanged(58 /* multiCursorMergeOverlapping */)
  62021. || e.hasChanged(60 /* multiCursorPaste */)
  62022. || e.hasChanged(5 /* autoClosingBrackets */)
  62023. || e.hasChanged(7 /* autoClosingQuotes */)
  62024. || e.hasChanged(6 /* autoClosingOvertype */)
  62025. || e.hasChanged(10 /* autoSurround */)
  62026. || e.hasChanged(95 /* useTabStops */)
  62027. || e.hasChanged(49 /* lineHeight */)
  62028. || e.hasChanged(68 /* readOnly */));
  62029. };
  62030. Object.defineProperty(CursorConfiguration.prototype, "electricChars", {
  62031. get: function () {
  62032. if (!this._electricChars) {
  62033. this._electricChars = {};
  62034. var electricChars = CursorConfiguration._getElectricCharacters(this._languageIdentifier);
  62035. if (electricChars) {
  62036. for (var _i = 0, electricChars_1 = electricChars; _i < electricChars_1.length; _i++) {
  62037. var char = electricChars_1[_i];
  62038. this._electricChars[char] = true;
  62039. }
  62040. }
  62041. }
  62042. return this._electricChars;
  62043. },
  62044. enumerable: true,
  62045. configurable: true
  62046. });
  62047. CursorConfiguration.prototype.normalizeIndentation = function (str) {
  62048. return textModel_1.TextModel.normalizeIndentation(str, this.indentSize, this.insertSpaces);
  62049. };
  62050. CursorConfiguration._getElectricCharacters = function (languageIdentifier) {
  62051. try {
  62052. return languageConfigurationRegistry_1.LanguageConfigurationRegistry.getElectricCharacters(languageIdentifier.id);
  62053. }
  62054. catch (e) {
  62055. errors_1.onUnexpectedError(e);
  62056. return null;
  62057. }
  62058. };
  62059. CursorConfiguration._getAutoClosingPairs = function (languageIdentifier) {
  62060. try {
  62061. return languageConfigurationRegistry_1.LanguageConfigurationRegistry.getAutoClosingPairs(languageIdentifier.id);
  62062. }
  62063. catch (e) {
  62064. errors_1.onUnexpectedError(e);
  62065. return null;
  62066. }
  62067. };
  62068. CursorConfiguration._getShouldAutoClose = function (languageIdentifier, autoCloseConfig) {
  62069. switch (autoCloseConfig) {
  62070. case 'beforeWhitespace':
  62071. return autoCloseBeforeWhitespace;
  62072. case 'languageDefined':
  62073. return CursorConfiguration._getLanguageDefinedShouldAutoClose(languageIdentifier);
  62074. case 'always':
  62075. return autoCloseAlways;
  62076. case 'never':
  62077. return autoCloseNever;
  62078. }
  62079. };
  62080. CursorConfiguration._getLanguageDefinedShouldAutoClose = function (languageIdentifier) {
  62081. try {
  62082. var autoCloseBeforeSet_1 = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getAutoCloseBeforeSet(languageIdentifier.id);
  62083. return function (c) { return autoCloseBeforeSet_1.indexOf(c) !== -1; };
  62084. }
  62085. catch (e) {
  62086. errors_1.onUnexpectedError(e);
  62087. return autoCloseNever;
  62088. }
  62089. };
  62090. CursorConfiguration._getSurroundingPairs = function (languageIdentifier) {
  62091. try {
  62092. return languageConfigurationRegistry_1.LanguageConfigurationRegistry.getSurroundingPairs(languageIdentifier.id);
  62093. }
  62094. catch (e) {
  62095. errors_1.onUnexpectedError(e);
  62096. return null;
  62097. }
  62098. };
  62099. return CursorConfiguration;
  62100. }());
  62101. exports.CursorConfiguration = CursorConfiguration;
  62102. /**
  62103. * Represents the cursor state on either the model or on the view model.
  62104. */
  62105. var SingleCursorState = /** @class */ (function () {
  62106. function SingleCursorState(selectionStart, selectionStartLeftoverVisibleColumns, position, leftoverVisibleColumns) {
  62107. this.selectionStart = selectionStart;
  62108. this.selectionStartLeftoverVisibleColumns = selectionStartLeftoverVisibleColumns;
  62109. this.position = position;
  62110. this.leftoverVisibleColumns = leftoverVisibleColumns;
  62111. this.selection = SingleCursorState._computeSelection(this.selectionStart, this.position);
  62112. }
  62113. SingleCursorState.prototype.equals = function (other) {
  62114. return (this.selectionStartLeftoverVisibleColumns === other.selectionStartLeftoverVisibleColumns
  62115. && this.leftoverVisibleColumns === other.leftoverVisibleColumns
  62116. && this.position.equals(other.position)
  62117. && this.selectionStart.equalsRange(other.selectionStart));
  62118. };
  62119. SingleCursorState.prototype.hasSelection = function () {
  62120. return (!this.selection.isEmpty() || !this.selectionStart.isEmpty());
  62121. };
  62122. SingleCursorState.prototype.move = function (inSelectionMode, lineNumber, column, leftoverVisibleColumns) {
  62123. if (inSelectionMode) {
  62124. // move just position
  62125. return new SingleCursorState(this.selectionStart, this.selectionStartLeftoverVisibleColumns, new position_1.Position(lineNumber, column), leftoverVisibleColumns);
  62126. }
  62127. else {
  62128. // move everything
  62129. return new SingleCursorState(new range_1.Range(lineNumber, column, lineNumber, column), leftoverVisibleColumns, new position_1.Position(lineNumber, column), leftoverVisibleColumns);
  62130. }
  62131. };
  62132. SingleCursorState._computeSelection = function (selectionStart, position) {
  62133. var startLineNumber, startColumn, endLineNumber, endColumn;
  62134. if (selectionStart.isEmpty()) {
  62135. startLineNumber = selectionStart.startLineNumber;
  62136. startColumn = selectionStart.startColumn;
  62137. endLineNumber = position.lineNumber;
  62138. endColumn = position.column;
  62139. }
  62140. else {
  62141. if (position.isBeforeOrEqual(selectionStart.getStartPosition())) {
  62142. startLineNumber = selectionStart.endLineNumber;
  62143. startColumn = selectionStart.endColumn;
  62144. endLineNumber = position.lineNumber;
  62145. endColumn = position.column;
  62146. }
  62147. else {
  62148. startLineNumber = selectionStart.startLineNumber;
  62149. startColumn = selectionStart.startColumn;
  62150. endLineNumber = position.lineNumber;
  62151. endColumn = position.column;
  62152. }
  62153. }
  62154. return new selection_1.Selection(startLineNumber, startColumn, endLineNumber, endColumn);
  62155. };
  62156. return SingleCursorState;
  62157. }());
  62158. exports.SingleCursorState = SingleCursorState;
  62159. var CursorContext = /** @class */ (function () {
  62160. function CursorContext(configuration, model, viewModel) {
  62161. this.model = model;
  62162. this.viewModel = viewModel;
  62163. this.config = new CursorConfiguration(this.model.getLanguageIdentifier(), this.model.getOptions(), configuration);
  62164. }
  62165. CursorContext.prototype.validateViewPosition = function (viewPosition, modelPosition) {
  62166. return this.viewModel.coordinatesConverter.validateViewPosition(viewPosition, modelPosition);
  62167. };
  62168. CursorContext.prototype.validateViewRange = function (viewRange, expectedModelRange) {
  62169. return this.viewModel.coordinatesConverter.validateViewRange(viewRange, expectedModelRange);
  62170. };
  62171. CursorContext.prototype.convertViewRangeToModelRange = function (viewRange) {
  62172. return this.viewModel.coordinatesConverter.convertViewRangeToModelRange(viewRange);
  62173. };
  62174. CursorContext.prototype.convertViewPositionToModelPosition = function (lineNumber, column) {
  62175. return this.viewModel.coordinatesConverter.convertViewPositionToModelPosition(new position_1.Position(lineNumber, column));
  62176. };
  62177. CursorContext.prototype.convertModelPositionToViewPosition = function (modelPosition) {
  62178. return this.viewModel.coordinatesConverter.convertModelPositionToViewPosition(modelPosition);
  62179. };
  62180. CursorContext.prototype.convertModelRangeToViewRange = function (modelRange) {
  62181. return this.viewModel.coordinatesConverter.convertModelRangeToViewRange(modelRange);
  62182. };
  62183. CursorContext.prototype.getCurrentScrollTop = function () {
  62184. return this.viewModel.viewLayout.getCurrentScrollTop();
  62185. };
  62186. CursorContext.prototype.getCompletelyVisibleViewRange = function () {
  62187. return this.viewModel.getCompletelyVisibleViewRange();
  62188. };
  62189. CursorContext.prototype.getCompletelyVisibleModelRange = function () {
  62190. var viewRange = this.viewModel.getCompletelyVisibleViewRange();
  62191. return this.viewModel.coordinatesConverter.convertViewRangeToModelRange(viewRange);
  62192. };
  62193. CursorContext.prototype.getCompletelyVisibleViewRangeAtScrollTop = function (scrollTop) {
  62194. return this.viewModel.getCompletelyVisibleViewRangeAtScrollTop(scrollTop);
  62195. };
  62196. CursorContext.prototype.getVerticalOffsetForViewLine = function (viewLineNumber) {
  62197. return this.viewModel.viewLayout.getVerticalOffsetForLineNumber(viewLineNumber);
  62198. };
  62199. return CursorContext;
  62200. }());
  62201. exports.CursorContext = CursorContext;
  62202. var PartialModelCursorState = /** @class */ (function () {
  62203. function PartialModelCursorState(modelState) {
  62204. this.modelState = modelState;
  62205. this.viewState = null;
  62206. }
  62207. return PartialModelCursorState;
  62208. }());
  62209. exports.PartialModelCursorState = PartialModelCursorState;
  62210. var PartialViewCursorState = /** @class */ (function () {
  62211. function PartialViewCursorState(viewState) {
  62212. this.modelState = null;
  62213. this.viewState = viewState;
  62214. }
  62215. return PartialViewCursorState;
  62216. }());
  62217. exports.PartialViewCursorState = PartialViewCursorState;
  62218. var CursorState = /** @class */ (function () {
  62219. function CursorState(modelState, viewState) {
  62220. this.modelState = modelState;
  62221. this.viewState = viewState;
  62222. }
  62223. CursorState.fromModelState = function (modelState) {
  62224. return new PartialModelCursorState(modelState);
  62225. };
  62226. CursorState.fromViewState = function (viewState) {
  62227. return new PartialViewCursorState(viewState);
  62228. };
  62229. CursorState.fromModelSelection = function (modelSelection) {
  62230. var selectionStartLineNumber = modelSelection.selectionStartLineNumber;
  62231. var selectionStartColumn = modelSelection.selectionStartColumn;
  62232. var positionLineNumber = modelSelection.positionLineNumber;
  62233. var positionColumn = modelSelection.positionColumn;
  62234. var modelState = new SingleCursorState(new range_1.Range(selectionStartLineNumber, selectionStartColumn, selectionStartLineNumber, selectionStartColumn), 0, new position_1.Position(positionLineNumber, positionColumn), 0);
  62235. return CursorState.fromModelState(modelState);
  62236. };
  62237. CursorState.fromModelSelections = function (modelSelections) {
  62238. var states = [];
  62239. for (var i = 0, len = modelSelections.length; i < len; i++) {
  62240. states[i] = this.fromModelSelection(modelSelections[i]);
  62241. }
  62242. return states;
  62243. };
  62244. CursorState.prototype.equals = function (other) {
  62245. return (this.viewState.equals(other.viewState) && this.modelState.equals(other.modelState));
  62246. };
  62247. return CursorState;
  62248. }());
  62249. exports.CursorState = CursorState;
  62250. var EditOperationResult = /** @class */ (function () {
  62251. function EditOperationResult(type, commands, opts) {
  62252. this.type = type;
  62253. this.commands = commands;
  62254. this.shouldPushStackElementBefore = opts.shouldPushStackElementBefore;
  62255. this.shouldPushStackElementAfter = opts.shouldPushStackElementAfter;
  62256. }
  62257. return EditOperationResult;
  62258. }());
  62259. exports.EditOperationResult = EditOperationResult;
  62260. /**
  62261. * Common operations that work and make sense both on the model and on the view model.
  62262. */
  62263. var CursorColumns = /** @class */ (function () {
  62264. function CursorColumns() {
  62265. }
  62266. CursorColumns.visibleColumnFromColumn = function (lineContent, column, tabSize) {
  62267. var lineContentLength = lineContent.length;
  62268. var endOffset = column - 1 < lineContentLength ? column - 1 : lineContentLength;
  62269. var result = 0;
  62270. var i = 0;
  62271. while (i < endOffset) {
  62272. var codePoint = strings.getNextCodePoint(lineContent, endOffset, i);
  62273. i += (codePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  62274. if (codePoint === 9 /* Tab */) {
  62275. result = CursorColumns.nextRenderTabStop(result, tabSize);
  62276. }
  62277. else {
  62278. var graphemeBreakType = strings.getGraphemeBreakType(codePoint);
  62279. while (i < endOffset) {
  62280. var nextCodePoint = strings.getNextCodePoint(lineContent, endOffset, i);
  62281. var nextGraphemeBreakType = strings.getGraphemeBreakType(nextCodePoint);
  62282. if (strings.breakBetweenGraphemeBreakType(graphemeBreakType, nextGraphemeBreakType)) {
  62283. break;
  62284. }
  62285. i += (nextCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  62286. graphemeBreakType = nextGraphemeBreakType;
  62287. }
  62288. if (strings.isFullWidthCharacter(codePoint) || strings.isEmojiImprecise(codePoint)) {
  62289. result = result + 2;
  62290. }
  62291. else {
  62292. result = result + 1;
  62293. }
  62294. }
  62295. }
  62296. return result;
  62297. };
  62298. CursorColumns.visibleColumnFromColumn2 = function (config, model, position) {
  62299. return this.visibleColumnFromColumn(model.getLineContent(position.lineNumber), position.column, config.tabSize);
  62300. };
  62301. CursorColumns.columnFromVisibleColumn = function (lineContent, visibleColumn, tabSize) {
  62302. if (visibleColumn <= 0) {
  62303. return 1;
  62304. }
  62305. var lineLength = lineContent.length;
  62306. var beforeVisibleColumn = 0;
  62307. var beforeColumn = 1;
  62308. var i = 0;
  62309. while (i < lineLength) {
  62310. var codePoint = strings.getNextCodePoint(lineContent, lineLength, i);
  62311. i += (codePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  62312. var afterVisibleColumn = void 0;
  62313. if (codePoint === 9 /* Tab */) {
  62314. afterVisibleColumn = CursorColumns.nextRenderTabStop(beforeVisibleColumn, tabSize);
  62315. }
  62316. else {
  62317. var graphemeBreakType = strings.getGraphemeBreakType(codePoint);
  62318. while (i < lineLength) {
  62319. var nextCodePoint = strings.getNextCodePoint(lineContent, lineLength, i);
  62320. var nextGraphemeBreakType = strings.getGraphemeBreakType(nextCodePoint);
  62321. if (strings.breakBetweenGraphemeBreakType(graphemeBreakType, nextGraphemeBreakType)) {
  62322. break;
  62323. }
  62324. i += (nextCodePoint >= 65536 /* UNICODE_SUPPLEMENTARY_PLANE_BEGIN */ ? 2 : 1);
  62325. graphemeBreakType = nextGraphemeBreakType;
  62326. }
  62327. if (strings.isFullWidthCharacter(codePoint) || strings.isEmojiImprecise(codePoint)) {
  62328. afterVisibleColumn = beforeVisibleColumn + 2;
  62329. }
  62330. else {
  62331. afterVisibleColumn = beforeVisibleColumn + 1;
  62332. }
  62333. }
  62334. var afterColumn = i + 1;
  62335. if (afterVisibleColumn >= visibleColumn) {
  62336. var beforeDelta = visibleColumn - beforeVisibleColumn;
  62337. var afterDelta = afterVisibleColumn - visibleColumn;
  62338. if (afterDelta < beforeDelta) {
  62339. return afterColumn;
  62340. }
  62341. else {
  62342. return beforeColumn;
  62343. }
  62344. }
  62345. beforeVisibleColumn = afterVisibleColumn;
  62346. beforeColumn = afterColumn;
  62347. }
  62348. // walked the entire string
  62349. return lineLength + 1;
  62350. };
  62351. CursorColumns.columnFromVisibleColumn2 = function (config, model, lineNumber, visibleColumn) {
  62352. var result = this.columnFromVisibleColumn(model.getLineContent(lineNumber), visibleColumn, config.tabSize);
  62353. var minColumn = model.getLineMinColumn(lineNumber);
  62354. if (result < minColumn) {
  62355. return minColumn;
  62356. }
  62357. var maxColumn = model.getLineMaxColumn(lineNumber);
  62358. if (result > maxColumn) {
  62359. return maxColumn;
  62360. }
  62361. return result;
  62362. };
  62363. /**
  62364. * ATTENTION: This works with 0-based columns (as oposed to the regular 1-based columns)
  62365. */
  62366. CursorColumns.nextRenderTabStop = function (visibleColumn, tabSize) {
  62367. return visibleColumn + tabSize - visibleColumn % tabSize;
  62368. };
  62369. /**
  62370. * ATTENTION: This works with 0-based columns (as oposed to the regular 1-based columns)
  62371. */
  62372. CursorColumns.nextIndentTabStop = function (visibleColumn, indentSize) {
  62373. return visibleColumn + indentSize - visibleColumn % indentSize;
  62374. };
  62375. /**
  62376. * ATTENTION: This works with 0-based columns (as oposed to the regular 1-based columns)
  62377. */
  62378. CursorColumns.prevRenderTabStop = function (column, tabSize) {
  62379. return column - 1 - (column - 1) % tabSize;
  62380. };
  62381. /**
  62382. * ATTENTION: This works with 0-based columns (as oposed to the regular 1-based columns)
  62383. */
  62384. CursorColumns.prevIndentTabStop = function (column, indentSize) {
  62385. return column - 1 - (column - 1) % indentSize;
  62386. };
  62387. return CursorColumns;
  62388. }());
  62389. exports.CursorColumns = CursorColumns;
  62390. function isQuote(ch) {
  62391. return (ch === '\'' || ch === '"' || ch === '`');
  62392. }
  62393. exports.isQuote = isQuote;
  62394. });
  62395. /*---------------------------------------------------------------------------------------------
  62396. * Copyright (c) Microsoft Corporation. All rights reserved.
  62397. * Licensed under the MIT License. See License.txt in the project root for license information.
  62398. *--------------------------------------------------------------------------------------------*/
  62399. define(__m[211/*vs/editor/common/commands/shiftCommand*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,40/*vs/editor/common/controller/cursorCommon*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/]), function (require, exports, strings, cursorCommon_1, range_1, selection_1, languageConfigurationRegistry_1) {
  62400. "use strict";
  62401. Object.defineProperty(exports, "__esModule", { value: true });
  62402. var repeatCache = Object.create(null);
  62403. function cachedStringRepeat(str, count) {
  62404. if (!repeatCache[str]) {
  62405. repeatCache[str] = ['', str];
  62406. }
  62407. var cache = repeatCache[str];
  62408. for (var i = cache.length; i <= count; i++) {
  62409. cache[i] = cache[i - 1] + str;
  62410. }
  62411. return cache[count];
  62412. }
  62413. exports.cachedStringRepeat = cachedStringRepeat;
  62414. var ShiftCommand = /** @class */ (function () {
  62415. function ShiftCommand(range, opts) {
  62416. this._opts = opts;
  62417. this._selection = range;
  62418. this._selectionId = null;
  62419. this._useLastEditRangeForCursorEndPosition = false;
  62420. this._selectionStartColumnStaysPut = false;
  62421. }
  62422. ShiftCommand.unshiftIndent = function (line, column, tabSize, indentSize, insertSpaces) {
  62423. // Determine the visible column where the content starts
  62424. var contentStartVisibleColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn(line, column, tabSize);
  62425. if (insertSpaces) {
  62426. var indent = cachedStringRepeat(' ', indentSize);
  62427. var desiredTabStop = cursorCommon_1.CursorColumns.prevIndentTabStop(contentStartVisibleColumn, indentSize);
  62428. var indentCount = desiredTabStop / indentSize; // will be an integer
  62429. return cachedStringRepeat(indent, indentCount);
  62430. }
  62431. else {
  62432. var indent = '\t';
  62433. var desiredTabStop = cursorCommon_1.CursorColumns.prevRenderTabStop(contentStartVisibleColumn, tabSize);
  62434. var indentCount = desiredTabStop / tabSize; // will be an integer
  62435. return cachedStringRepeat(indent, indentCount);
  62436. }
  62437. };
  62438. ShiftCommand.shiftIndent = function (line, column, tabSize, indentSize, insertSpaces) {
  62439. // Determine the visible column where the content starts
  62440. var contentStartVisibleColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn(line, column, tabSize);
  62441. if (insertSpaces) {
  62442. var indent = cachedStringRepeat(' ', indentSize);
  62443. var desiredTabStop = cursorCommon_1.CursorColumns.nextIndentTabStop(contentStartVisibleColumn, indentSize);
  62444. var indentCount = desiredTabStop / indentSize; // will be an integer
  62445. return cachedStringRepeat(indent, indentCount);
  62446. }
  62447. else {
  62448. var indent = '\t';
  62449. var desiredTabStop = cursorCommon_1.CursorColumns.nextRenderTabStop(contentStartVisibleColumn, tabSize);
  62450. var indentCount = desiredTabStop / tabSize; // will be an integer
  62451. return cachedStringRepeat(indent, indentCount);
  62452. }
  62453. };
  62454. ShiftCommand.prototype._addEditOperation = function (builder, range, text) {
  62455. if (this._useLastEditRangeForCursorEndPosition) {
  62456. builder.addTrackedEditOperation(range, text);
  62457. }
  62458. else {
  62459. builder.addEditOperation(range, text);
  62460. }
  62461. };
  62462. ShiftCommand.prototype.getEditOperations = function (model, builder) {
  62463. var startLine = this._selection.startLineNumber;
  62464. var endLine = this._selection.endLineNumber;
  62465. if (this._selection.endColumn === 1 && startLine !== endLine) {
  62466. endLine = endLine - 1;
  62467. }
  62468. var _a = this._opts, tabSize = _a.tabSize, indentSize = _a.indentSize, insertSpaces = _a.insertSpaces;
  62469. var shouldIndentEmptyLines = (startLine === endLine);
  62470. // if indenting or outdenting on a whitespace only line
  62471. if (this._selection.isEmpty()) {
  62472. if (/^\s*$/.test(model.getLineContent(startLine))) {
  62473. this._useLastEditRangeForCursorEndPosition = true;
  62474. }
  62475. }
  62476. if (this._opts.useTabStops) {
  62477. // keep track of previous line's "miss-alignment"
  62478. var previousLineExtraSpaces = 0, extraSpaces = 0;
  62479. for (var lineNumber = startLine; lineNumber <= endLine; lineNumber++, previousLineExtraSpaces = extraSpaces) {
  62480. extraSpaces = 0;
  62481. var lineText = model.getLineContent(lineNumber);
  62482. var indentationEndIndex = strings.firstNonWhitespaceIndex(lineText);
  62483. if (this._opts.isUnshift && (lineText.length === 0 || indentationEndIndex === 0)) {
  62484. // empty line or line with no leading whitespace => nothing to do
  62485. continue;
  62486. }
  62487. if (!shouldIndentEmptyLines && !this._opts.isUnshift && lineText.length === 0) {
  62488. // do not indent empty lines => nothing to do
  62489. continue;
  62490. }
  62491. if (indentationEndIndex === -1) {
  62492. // the entire line is whitespace
  62493. indentationEndIndex = lineText.length;
  62494. }
  62495. if (lineNumber > 1) {
  62496. var contentStartVisibleColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn(lineText, indentationEndIndex + 1, tabSize);
  62497. if (contentStartVisibleColumn % indentSize !== 0) {
  62498. // The current line is "miss-aligned", so let's see if this is expected...
  62499. // This can only happen when it has trailing commas in the indent
  62500. if (model.isCheapToTokenize(lineNumber - 1)) {
  62501. var enterAction = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getEnterAction(this._opts.autoIndent, model, new range_1.Range(lineNumber - 1, model.getLineMaxColumn(lineNumber - 1), lineNumber - 1, model.getLineMaxColumn(lineNumber - 1)));
  62502. if (enterAction) {
  62503. extraSpaces = previousLineExtraSpaces;
  62504. if (enterAction.appendText) {
  62505. for (var j = 0, lenJ = enterAction.appendText.length; j < lenJ && extraSpaces < indentSize; j++) {
  62506. if (enterAction.appendText.charCodeAt(j) === 32 /* Space */) {
  62507. extraSpaces++;
  62508. }
  62509. else {
  62510. break;
  62511. }
  62512. }
  62513. }
  62514. if (enterAction.removeText) {
  62515. extraSpaces = Math.max(0, extraSpaces - enterAction.removeText);
  62516. }
  62517. // Act as if `prefixSpaces` is not part of the indentation
  62518. for (var j = 0; j < extraSpaces; j++) {
  62519. if (indentationEndIndex === 0 || lineText.charCodeAt(indentationEndIndex - 1) !== 32 /* Space */) {
  62520. break;
  62521. }
  62522. indentationEndIndex--;
  62523. }
  62524. }
  62525. }
  62526. }
  62527. }
  62528. if (this._opts.isUnshift && indentationEndIndex === 0) {
  62529. // line with no leading whitespace => nothing to do
  62530. continue;
  62531. }
  62532. var desiredIndent = void 0;
  62533. if (this._opts.isUnshift) {
  62534. desiredIndent = ShiftCommand.unshiftIndent(lineText, indentationEndIndex + 1, tabSize, indentSize, insertSpaces);
  62535. }
  62536. else {
  62537. desiredIndent = ShiftCommand.shiftIndent(lineText, indentationEndIndex + 1, tabSize, indentSize, insertSpaces);
  62538. }
  62539. this._addEditOperation(builder, new range_1.Range(lineNumber, 1, lineNumber, indentationEndIndex + 1), desiredIndent);
  62540. if (lineNumber === startLine && !this._selection.isEmpty()) {
  62541. // Force the startColumn to stay put because we're inserting after it
  62542. this._selectionStartColumnStaysPut = (this._selection.startColumn <= indentationEndIndex + 1);
  62543. }
  62544. }
  62545. }
  62546. else {
  62547. var oneIndent = (insertSpaces ? cachedStringRepeat(' ', indentSize) : '\t');
  62548. for (var lineNumber = startLine; lineNumber <= endLine; lineNumber++) {
  62549. var lineText = model.getLineContent(lineNumber);
  62550. var indentationEndIndex = strings.firstNonWhitespaceIndex(lineText);
  62551. if (this._opts.isUnshift && (lineText.length === 0 || indentationEndIndex === 0)) {
  62552. // empty line or line with no leading whitespace => nothing to do
  62553. continue;
  62554. }
  62555. if (!shouldIndentEmptyLines && !this._opts.isUnshift && lineText.length === 0) {
  62556. // do not indent empty lines => nothing to do
  62557. continue;
  62558. }
  62559. if (indentationEndIndex === -1) {
  62560. // the entire line is whitespace
  62561. indentationEndIndex = lineText.length;
  62562. }
  62563. if (this._opts.isUnshift && indentationEndIndex === 0) {
  62564. // line with no leading whitespace => nothing to do
  62565. continue;
  62566. }
  62567. if (this._opts.isUnshift) {
  62568. indentationEndIndex = Math.min(indentationEndIndex, indentSize);
  62569. for (var i = 0; i < indentationEndIndex; i++) {
  62570. var chr = lineText.charCodeAt(i);
  62571. if (chr === 9 /* Tab */) {
  62572. indentationEndIndex = i + 1;
  62573. break;
  62574. }
  62575. }
  62576. this._addEditOperation(builder, new range_1.Range(lineNumber, 1, lineNumber, indentationEndIndex + 1), '');
  62577. }
  62578. else {
  62579. this._addEditOperation(builder, new range_1.Range(lineNumber, 1, lineNumber, 1), oneIndent);
  62580. if (lineNumber === startLine && !this._selection.isEmpty()) {
  62581. // Force the startColumn to stay put because we're inserting after it
  62582. this._selectionStartColumnStaysPut = (this._selection.startColumn === 1);
  62583. }
  62584. }
  62585. }
  62586. }
  62587. this._selectionId = builder.trackSelection(this._selection);
  62588. };
  62589. ShiftCommand.prototype.computeCursorState = function (model, helper) {
  62590. if (this._useLastEditRangeForCursorEndPosition) {
  62591. var lastOp = helper.getInverseEditOperations()[0];
  62592. return new selection_1.Selection(lastOp.range.endLineNumber, lastOp.range.endColumn, lastOp.range.endLineNumber, lastOp.range.endColumn);
  62593. }
  62594. var result = helper.getTrackedSelection(this._selectionId);
  62595. if (this._selectionStartColumnStaysPut) {
  62596. // The selection start should not move
  62597. var initialStartColumn = this._selection.startColumn;
  62598. var resultStartColumn = result.startColumn;
  62599. if (resultStartColumn <= initialStartColumn) {
  62600. return result;
  62601. }
  62602. if (result.getDirection() === 0 /* LTR */) {
  62603. return new selection_1.Selection(result.startLineNumber, initialStartColumn, result.endLineNumber, result.endColumn);
  62604. }
  62605. return new selection_1.Selection(result.endLineNumber, result.endColumn, result.startLineNumber, initialStartColumn);
  62606. }
  62607. return result;
  62608. };
  62609. return ShiftCommand;
  62610. }());
  62611. exports.ShiftCommand = ShiftCommand;
  62612. });
  62613. /*---------------------------------------------------------------------------------------------
  62614. * Copyright (c) Microsoft Corporation. All rights reserved.
  62615. * Licensed under the MIT License. See License.txt in the project root for license information.
  62616. *--------------------------------------------------------------------------------------------*/
  62617. define(__m[483/*vs/editor/common/controller/cursorColumnSelection*/], __M([0/*require*/,1/*exports*/,40/*vs/editor/common/controller/cursorCommon*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/]), function (require, exports, cursorCommon_1, position_1, range_1) {
  62618. "use strict";
  62619. Object.defineProperty(exports, "__esModule", { value: true });
  62620. var ColumnSelection = /** @class */ (function () {
  62621. function ColumnSelection() {
  62622. }
  62623. ColumnSelection.columnSelect = function (config, model, fromLineNumber, fromVisibleColumn, toLineNumber, toVisibleColumn) {
  62624. var lineCount = Math.abs(toLineNumber - fromLineNumber) + 1;
  62625. var reversed = (fromLineNumber > toLineNumber);
  62626. var isRTL = (fromVisibleColumn > toVisibleColumn);
  62627. var isLTR = (fromVisibleColumn < toVisibleColumn);
  62628. var result = [];
  62629. // console.log(`fromVisibleColumn: ${fromVisibleColumn}, toVisibleColumn: ${toVisibleColumn}`);
  62630. for (var i = 0; i < lineCount; i++) {
  62631. var lineNumber = fromLineNumber + (reversed ? -i : i);
  62632. var startColumn = cursorCommon_1.CursorColumns.columnFromVisibleColumn2(config, model, lineNumber, fromVisibleColumn);
  62633. var endColumn = cursorCommon_1.CursorColumns.columnFromVisibleColumn2(config, model, lineNumber, toVisibleColumn);
  62634. var visibleStartColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn2(config, model, new position_1.Position(lineNumber, startColumn));
  62635. var visibleEndColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn2(config, model, new position_1.Position(lineNumber, endColumn));
  62636. // console.log(`lineNumber: ${lineNumber}: visibleStartColumn: ${visibleStartColumn}, visibleEndColumn: ${visibleEndColumn}`);
  62637. if (isLTR) {
  62638. if (visibleStartColumn > toVisibleColumn) {
  62639. continue;
  62640. }
  62641. if (visibleEndColumn < fromVisibleColumn) {
  62642. continue;
  62643. }
  62644. }
  62645. if (isRTL) {
  62646. if (visibleEndColumn > fromVisibleColumn) {
  62647. continue;
  62648. }
  62649. if (visibleStartColumn < toVisibleColumn) {
  62650. continue;
  62651. }
  62652. }
  62653. result.push(new cursorCommon_1.SingleCursorState(new range_1.Range(lineNumber, startColumn, lineNumber, startColumn), 0, new position_1.Position(lineNumber, endColumn), 0));
  62654. }
  62655. if (result.length === 0) {
  62656. // We are after all the lines, so add cursor at the end of each line
  62657. for (var i = 0; i < lineCount; i++) {
  62658. var lineNumber = fromLineNumber + (reversed ? -i : i);
  62659. var maxColumn = model.getLineMaxColumn(lineNumber);
  62660. result.push(new cursorCommon_1.SingleCursorState(new range_1.Range(lineNumber, maxColumn, lineNumber, maxColumn), 0, new position_1.Position(lineNumber, maxColumn), 0));
  62661. }
  62662. }
  62663. return {
  62664. viewStates: result,
  62665. reversed: reversed,
  62666. fromLineNumber: fromLineNumber,
  62667. fromVisualColumn: fromVisibleColumn,
  62668. toLineNumber: toLineNumber,
  62669. toVisualColumn: toVisibleColumn
  62670. };
  62671. };
  62672. ColumnSelection.columnSelectLeft = function (config, model, prevColumnSelectData) {
  62673. var toViewVisualColumn = prevColumnSelectData.toViewVisualColumn;
  62674. if (toViewVisualColumn > 1) {
  62675. toViewVisualColumn--;
  62676. }
  62677. return ColumnSelection.columnSelect(config, model, prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.fromViewVisualColumn, prevColumnSelectData.toViewLineNumber, toViewVisualColumn);
  62678. };
  62679. ColumnSelection.columnSelectRight = function (config, model, prevColumnSelectData) {
  62680. var maxVisualViewColumn = 0;
  62681. var minViewLineNumber = Math.min(prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.toViewLineNumber);
  62682. var maxViewLineNumber = Math.max(prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.toViewLineNumber);
  62683. for (var lineNumber = minViewLineNumber; lineNumber <= maxViewLineNumber; lineNumber++) {
  62684. var lineMaxViewColumn = model.getLineMaxColumn(lineNumber);
  62685. var lineMaxVisualViewColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn2(config, model, new position_1.Position(lineNumber, lineMaxViewColumn));
  62686. maxVisualViewColumn = Math.max(maxVisualViewColumn, lineMaxVisualViewColumn);
  62687. }
  62688. var toViewVisualColumn = prevColumnSelectData.toViewVisualColumn;
  62689. if (toViewVisualColumn < maxVisualViewColumn) {
  62690. toViewVisualColumn++;
  62691. }
  62692. return this.columnSelect(config, model, prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.fromViewVisualColumn, prevColumnSelectData.toViewLineNumber, toViewVisualColumn);
  62693. };
  62694. ColumnSelection.columnSelectUp = function (config, model, prevColumnSelectData, isPaged) {
  62695. var linesCount = isPaged ? config.pageSize : 1;
  62696. var toViewLineNumber = Math.max(1, prevColumnSelectData.toViewLineNumber - linesCount);
  62697. return this.columnSelect(config, model, prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.fromViewVisualColumn, toViewLineNumber, prevColumnSelectData.toViewVisualColumn);
  62698. };
  62699. ColumnSelection.columnSelectDown = function (config, model, prevColumnSelectData, isPaged) {
  62700. var linesCount = isPaged ? config.pageSize : 1;
  62701. var toViewLineNumber = Math.min(model.getLineCount(), prevColumnSelectData.toViewLineNumber + linesCount);
  62702. return this.columnSelect(config, model, prevColumnSelectData.fromViewLineNumber, prevColumnSelectData.fromViewVisualColumn, toViewLineNumber, prevColumnSelectData.toViewVisualColumn);
  62703. };
  62704. return ColumnSelection;
  62705. }());
  62706. exports.ColumnSelection = ColumnSelection;
  62707. });
  62708. /*---------------------------------------------------------------------------------------------
  62709. * Copyright (c) Microsoft Corporation. All rights reserved.
  62710. * Licensed under the MIT License. See License.txt in the project root for license information.
  62711. *--------------------------------------------------------------------------------------------*/
  62712. define(__m[158/*vs/editor/common/controller/cursorMoveOperations*/], __M([0/*require*/,1/*exports*/,40/*vs/editor/common/controller/cursorCommon*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,5/*vs/base/common/strings*/]), function (require, exports, cursorCommon_1, position_1, range_1, strings) {
  62713. "use strict";
  62714. Object.defineProperty(exports, "__esModule", { value: true });
  62715. var CursorPosition = /** @class */ (function () {
  62716. function CursorPosition(lineNumber, column, leftoverVisibleColumns) {
  62717. this.lineNumber = lineNumber;
  62718. this.column = column;
  62719. this.leftoverVisibleColumns = leftoverVisibleColumns;
  62720. }
  62721. return CursorPosition;
  62722. }());
  62723. exports.CursorPosition = CursorPosition;
  62724. var MoveOperations = /** @class */ (function () {
  62725. function MoveOperations() {
  62726. }
  62727. MoveOperations.leftPosition = function (model, lineNumber, column) {
  62728. if (column > model.getLineMinColumn(lineNumber)) {
  62729. column = column - strings.prevCharLength(model.getLineContent(lineNumber), column - 1);
  62730. }
  62731. else if (lineNumber > 1) {
  62732. lineNumber = lineNumber - 1;
  62733. column = model.getLineMaxColumn(lineNumber);
  62734. }
  62735. return new position_1.Position(lineNumber, column);
  62736. };
  62737. MoveOperations.left = function (config, model, lineNumber, column) {
  62738. var pos = MoveOperations.leftPosition(model, lineNumber, column);
  62739. return new CursorPosition(pos.lineNumber, pos.column, 0);
  62740. };
  62741. MoveOperations.moveLeft = function (config, model, cursor, inSelectionMode, noOfColumns) {
  62742. var lineNumber, column;
  62743. if (cursor.hasSelection() && !inSelectionMode) {
  62744. // If we are in selection mode, move left without selection cancels selection and puts cursor at the beginning of the selection
  62745. lineNumber = cursor.selection.startLineNumber;
  62746. column = cursor.selection.startColumn;
  62747. }
  62748. else {
  62749. var r = MoveOperations.left(config, model, cursor.position.lineNumber, cursor.position.column - (noOfColumns - 1));
  62750. lineNumber = r.lineNumber;
  62751. column = r.column;
  62752. }
  62753. return cursor.move(inSelectionMode, lineNumber, column, 0);
  62754. };
  62755. MoveOperations.rightPosition = function (model, lineNumber, column) {
  62756. if (column < model.getLineMaxColumn(lineNumber)) {
  62757. column = column + strings.nextCharLength(model.getLineContent(lineNumber), column - 1);
  62758. }
  62759. else if (lineNumber < model.getLineCount()) {
  62760. lineNumber = lineNumber + 1;
  62761. column = model.getLineMinColumn(lineNumber);
  62762. }
  62763. return new position_1.Position(lineNumber, column);
  62764. };
  62765. MoveOperations.right = function (config, model, lineNumber, column) {
  62766. var pos = MoveOperations.rightPosition(model, lineNumber, column);
  62767. return new CursorPosition(pos.lineNumber, pos.column, 0);
  62768. };
  62769. MoveOperations.moveRight = function (config, model, cursor, inSelectionMode, noOfColumns) {
  62770. var lineNumber, column;
  62771. if (cursor.hasSelection() && !inSelectionMode) {
  62772. // If we are in selection mode, move right without selection cancels selection and puts cursor at the end of the selection
  62773. lineNumber = cursor.selection.endLineNumber;
  62774. column = cursor.selection.endColumn;
  62775. }
  62776. else {
  62777. var r = MoveOperations.right(config, model, cursor.position.lineNumber, cursor.position.column + (noOfColumns - 1));
  62778. lineNumber = r.lineNumber;
  62779. column = r.column;
  62780. }
  62781. return cursor.move(inSelectionMode, lineNumber, column, 0);
  62782. };
  62783. MoveOperations.down = function (config, model, lineNumber, column, leftoverVisibleColumns, count, allowMoveOnLastLine) {
  62784. var currentVisibleColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn(model.getLineContent(lineNumber), column, config.tabSize) + leftoverVisibleColumns;
  62785. lineNumber = lineNumber + count;
  62786. var lineCount = model.getLineCount();
  62787. if (lineNumber > lineCount) {
  62788. lineNumber = lineCount;
  62789. if (allowMoveOnLastLine) {
  62790. column = model.getLineMaxColumn(lineNumber);
  62791. }
  62792. else {
  62793. column = Math.min(model.getLineMaxColumn(lineNumber), column);
  62794. }
  62795. }
  62796. else {
  62797. column = cursorCommon_1.CursorColumns.columnFromVisibleColumn2(config, model, lineNumber, currentVisibleColumn);
  62798. }
  62799. leftoverVisibleColumns = currentVisibleColumn - cursorCommon_1.CursorColumns.visibleColumnFromColumn(model.getLineContent(lineNumber), column, config.tabSize);
  62800. return new CursorPosition(lineNumber, column, leftoverVisibleColumns);
  62801. };
  62802. MoveOperations.moveDown = function (config, model, cursor, inSelectionMode, linesCount) {
  62803. var lineNumber, column;
  62804. if (cursor.hasSelection() && !inSelectionMode) {
  62805. // If we are in selection mode, move down acts relative to the end of selection
  62806. lineNumber = cursor.selection.endLineNumber;
  62807. column = cursor.selection.endColumn;
  62808. }
  62809. else {
  62810. lineNumber = cursor.position.lineNumber;
  62811. column = cursor.position.column;
  62812. }
  62813. var r = MoveOperations.down(config, model, lineNumber, column, cursor.leftoverVisibleColumns, linesCount, true);
  62814. return cursor.move(inSelectionMode, r.lineNumber, r.column, r.leftoverVisibleColumns);
  62815. };
  62816. MoveOperations.translateDown = function (config, model, cursor) {
  62817. var selection = cursor.selection;
  62818. var selectionStart = MoveOperations.down(config, model, selection.selectionStartLineNumber, selection.selectionStartColumn, cursor.selectionStartLeftoverVisibleColumns, 1, false);
  62819. var position = MoveOperations.down(config, model, selection.positionLineNumber, selection.positionColumn, cursor.leftoverVisibleColumns, 1, false);
  62820. return new cursorCommon_1.SingleCursorState(new range_1.Range(selectionStart.lineNumber, selectionStart.column, selectionStart.lineNumber, selectionStart.column), selectionStart.leftoverVisibleColumns, new position_1.Position(position.lineNumber, position.column), position.leftoverVisibleColumns);
  62821. };
  62822. MoveOperations.up = function (config, model, lineNumber, column, leftoverVisibleColumns, count, allowMoveOnFirstLine) {
  62823. var currentVisibleColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn(model.getLineContent(lineNumber), column, config.tabSize) + leftoverVisibleColumns;
  62824. lineNumber = lineNumber - count;
  62825. if (lineNumber < 1) {
  62826. lineNumber = 1;
  62827. if (allowMoveOnFirstLine) {
  62828. column = model.getLineMinColumn(lineNumber);
  62829. }
  62830. else {
  62831. column = Math.min(model.getLineMaxColumn(lineNumber), column);
  62832. }
  62833. }
  62834. else {
  62835. column = cursorCommon_1.CursorColumns.columnFromVisibleColumn2(config, model, lineNumber, currentVisibleColumn);
  62836. }
  62837. leftoverVisibleColumns = currentVisibleColumn - cursorCommon_1.CursorColumns.visibleColumnFromColumn(model.getLineContent(lineNumber), column, config.tabSize);
  62838. return new CursorPosition(lineNumber, column, leftoverVisibleColumns);
  62839. };
  62840. MoveOperations.moveUp = function (config, model, cursor, inSelectionMode, linesCount) {
  62841. var lineNumber, column;
  62842. if (cursor.hasSelection() && !inSelectionMode) {
  62843. // If we are in selection mode, move up acts relative to the beginning of selection
  62844. lineNumber = cursor.selection.startLineNumber;
  62845. column = cursor.selection.startColumn;
  62846. }
  62847. else {
  62848. lineNumber = cursor.position.lineNumber;
  62849. column = cursor.position.column;
  62850. }
  62851. var r = MoveOperations.up(config, model, lineNumber, column, cursor.leftoverVisibleColumns, linesCount, true);
  62852. return cursor.move(inSelectionMode, r.lineNumber, r.column, r.leftoverVisibleColumns);
  62853. };
  62854. MoveOperations.translateUp = function (config, model, cursor) {
  62855. var selection = cursor.selection;
  62856. var selectionStart = MoveOperations.up(config, model, selection.selectionStartLineNumber, selection.selectionStartColumn, cursor.selectionStartLeftoverVisibleColumns, 1, false);
  62857. var position = MoveOperations.up(config, model, selection.positionLineNumber, selection.positionColumn, cursor.leftoverVisibleColumns, 1, false);
  62858. return new cursorCommon_1.SingleCursorState(new range_1.Range(selectionStart.lineNumber, selectionStart.column, selectionStart.lineNumber, selectionStart.column), selectionStart.leftoverVisibleColumns, new position_1.Position(position.lineNumber, position.column), position.leftoverVisibleColumns);
  62859. };
  62860. MoveOperations.moveToBeginningOfLine = function (config, model, cursor, inSelectionMode) {
  62861. var lineNumber = cursor.position.lineNumber;
  62862. var minColumn = model.getLineMinColumn(lineNumber);
  62863. var firstNonBlankColumn = model.getLineFirstNonWhitespaceColumn(lineNumber) || minColumn;
  62864. var column;
  62865. var relevantColumnNumber = cursor.position.column;
  62866. if (relevantColumnNumber === firstNonBlankColumn) {
  62867. column = minColumn;
  62868. }
  62869. else {
  62870. column = firstNonBlankColumn;
  62871. }
  62872. return cursor.move(inSelectionMode, lineNumber, column, 0);
  62873. };
  62874. MoveOperations.moveToEndOfLine = function (config, model, cursor, inSelectionMode) {
  62875. var lineNumber = cursor.position.lineNumber;
  62876. var maxColumn = model.getLineMaxColumn(lineNumber);
  62877. return cursor.move(inSelectionMode, lineNumber, maxColumn, 0);
  62878. };
  62879. MoveOperations.moveToBeginningOfBuffer = function (config, model, cursor, inSelectionMode) {
  62880. return cursor.move(inSelectionMode, 1, 1, 0);
  62881. };
  62882. MoveOperations.moveToEndOfBuffer = function (config, model, cursor, inSelectionMode) {
  62883. var lastLineNumber = model.getLineCount();
  62884. var lastColumn = model.getLineMaxColumn(lastLineNumber);
  62885. return cursor.move(inSelectionMode, lastLineNumber, lastColumn, 0);
  62886. };
  62887. return MoveOperations;
  62888. }());
  62889. exports.MoveOperations = MoveOperations;
  62890. });
  62891. /*---------------------------------------------------------------------------------------------
  62892. * Copyright (c) Microsoft Corporation. All rights reserved.
  62893. * Licensed under the MIT License. See License.txt in the project root for license information.
  62894. *--------------------------------------------------------------------------------------------*/
  62895. define(__m[212/*vs/editor/common/controller/cursorDeleteOperations*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,80/*vs/editor/common/commands/replaceCommand*/,40/*vs/editor/common/controller/cursorCommon*/,158/*vs/editor/common/controller/cursorMoveOperations*/,3/*vs/editor/common/core/range*/]), function (require, exports, strings, replaceCommand_1, cursorCommon_1, cursorMoveOperations_1, range_1) {
  62896. "use strict";
  62897. Object.defineProperty(exports, "__esModule", { value: true });
  62898. var DeleteOperations = /** @class */ (function () {
  62899. function DeleteOperations() {
  62900. }
  62901. DeleteOperations.deleteRight = function (prevEditOperationType, config, model, selections) {
  62902. var commands = [];
  62903. var shouldPushStackElementBefore = (prevEditOperationType !== 3 /* DeletingRight */);
  62904. for (var i = 0, len = selections.length; i < len; i++) {
  62905. var selection = selections[i];
  62906. var deleteSelection = selection;
  62907. if (deleteSelection.isEmpty()) {
  62908. var position = selection.getPosition();
  62909. var rightOfPosition = cursorMoveOperations_1.MoveOperations.right(config, model, position.lineNumber, position.column);
  62910. deleteSelection = new range_1.Range(rightOfPosition.lineNumber, rightOfPosition.column, position.lineNumber, position.column);
  62911. }
  62912. if (deleteSelection.isEmpty()) {
  62913. // Probably at end of file => ignore
  62914. commands[i] = null;
  62915. continue;
  62916. }
  62917. if (deleteSelection.startLineNumber !== deleteSelection.endLineNumber) {
  62918. shouldPushStackElementBefore = true;
  62919. }
  62920. commands[i] = new replaceCommand_1.ReplaceCommand(deleteSelection, '');
  62921. }
  62922. return [shouldPushStackElementBefore, commands];
  62923. };
  62924. DeleteOperations._isAutoClosingPairDelete = function (config, model, selections) {
  62925. if (config.autoClosingBrackets === 'never' && config.autoClosingQuotes === 'never') {
  62926. return false;
  62927. }
  62928. for (var i = 0, len = selections.length; i < len; i++) {
  62929. var selection = selections[i];
  62930. var position = selection.getPosition();
  62931. if (!selection.isEmpty()) {
  62932. return false;
  62933. }
  62934. var lineText = model.getLineContent(position.lineNumber);
  62935. var character = lineText[position.column - 2];
  62936. var autoClosingPairCandidates = config.autoClosingPairsOpen2.get(character);
  62937. if (!autoClosingPairCandidates) {
  62938. return false;
  62939. }
  62940. if (cursorCommon_1.isQuote(character)) {
  62941. if (config.autoClosingQuotes === 'never') {
  62942. return false;
  62943. }
  62944. }
  62945. else {
  62946. if (config.autoClosingBrackets === 'never') {
  62947. return false;
  62948. }
  62949. }
  62950. var afterCharacter = lineText[position.column - 1];
  62951. var foundAutoClosingPair = false;
  62952. for (var _i = 0, autoClosingPairCandidates_1 = autoClosingPairCandidates; _i < autoClosingPairCandidates_1.length; _i++) {
  62953. var autoClosingPairCandidate = autoClosingPairCandidates_1[_i];
  62954. if (autoClosingPairCandidate.open === character && autoClosingPairCandidate.close === afterCharacter) {
  62955. foundAutoClosingPair = true;
  62956. }
  62957. }
  62958. if (!foundAutoClosingPair) {
  62959. return false;
  62960. }
  62961. }
  62962. return true;
  62963. };
  62964. DeleteOperations._runAutoClosingPairDelete = function (config, model, selections) {
  62965. var commands = [];
  62966. for (var i = 0, len = selections.length; i < len; i++) {
  62967. var position = selections[i].getPosition();
  62968. var deleteSelection = new range_1.Range(position.lineNumber, position.column - 1, position.lineNumber, position.column + 1);
  62969. commands[i] = new replaceCommand_1.ReplaceCommand(deleteSelection, '');
  62970. }
  62971. return [true, commands];
  62972. };
  62973. DeleteOperations.deleteLeft = function (prevEditOperationType, config, model, selections) {
  62974. if (this._isAutoClosingPairDelete(config, model, selections)) {
  62975. return this._runAutoClosingPairDelete(config, model, selections);
  62976. }
  62977. var commands = [];
  62978. var shouldPushStackElementBefore = (prevEditOperationType !== 2 /* DeletingLeft */);
  62979. for (var i = 0, len = selections.length; i < len; i++) {
  62980. var selection = selections[i];
  62981. var deleteSelection = selection;
  62982. if (deleteSelection.isEmpty()) {
  62983. var position = selection.getPosition();
  62984. if (config.useTabStops && position.column > 1) {
  62985. var lineContent = model.getLineContent(position.lineNumber);
  62986. var firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
  62987. var lastIndentationColumn = (firstNonWhitespaceIndex === -1
  62988. ? /* entire string is whitespace */ lineContent.length + 1
  62989. : firstNonWhitespaceIndex + 1);
  62990. if (position.column <= lastIndentationColumn) {
  62991. var fromVisibleColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn2(config, model, position);
  62992. var toVisibleColumn = cursorCommon_1.CursorColumns.prevIndentTabStop(fromVisibleColumn, config.indentSize);
  62993. var toColumn = cursorCommon_1.CursorColumns.columnFromVisibleColumn2(config, model, position.lineNumber, toVisibleColumn);
  62994. deleteSelection = new range_1.Range(position.lineNumber, toColumn, position.lineNumber, position.column);
  62995. }
  62996. else {
  62997. deleteSelection = new range_1.Range(position.lineNumber, position.column - 1, position.lineNumber, position.column);
  62998. }
  62999. }
  63000. else {
  63001. var leftOfPosition = cursorMoveOperations_1.MoveOperations.left(config, model, position.lineNumber, position.column);
  63002. deleteSelection = new range_1.Range(leftOfPosition.lineNumber, leftOfPosition.column, position.lineNumber, position.column);
  63003. }
  63004. }
  63005. if (deleteSelection.isEmpty()) {
  63006. // Probably at beginning of file => ignore
  63007. commands[i] = null;
  63008. continue;
  63009. }
  63010. if (deleteSelection.startLineNumber !== deleteSelection.endLineNumber) {
  63011. shouldPushStackElementBefore = true;
  63012. }
  63013. commands[i] = new replaceCommand_1.ReplaceCommand(deleteSelection, '');
  63014. }
  63015. return [shouldPushStackElementBefore, commands];
  63016. };
  63017. DeleteOperations.cut = function (config, model, selections) {
  63018. var commands = [];
  63019. for (var i = 0, len = selections.length; i < len; i++) {
  63020. var selection = selections[i];
  63021. if (selection.isEmpty()) {
  63022. if (config.emptySelectionClipboard) {
  63023. // This is a full line cut
  63024. var position = selection.getPosition();
  63025. var startLineNumber = void 0, startColumn = void 0, endLineNumber = void 0, endColumn = void 0;
  63026. if (position.lineNumber < model.getLineCount()) {
  63027. // Cutting a line in the middle of the model
  63028. startLineNumber = position.lineNumber;
  63029. startColumn = 1;
  63030. endLineNumber = position.lineNumber + 1;
  63031. endColumn = 1;
  63032. }
  63033. else if (position.lineNumber > 1) {
  63034. // Cutting the last line & there are more than 1 lines in the model
  63035. startLineNumber = position.lineNumber - 1;
  63036. startColumn = model.getLineMaxColumn(position.lineNumber - 1);
  63037. endLineNumber = position.lineNumber;
  63038. endColumn = model.getLineMaxColumn(position.lineNumber);
  63039. }
  63040. else {
  63041. // Cutting the single line that the model contains
  63042. startLineNumber = position.lineNumber;
  63043. startColumn = 1;
  63044. endLineNumber = position.lineNumber;
  63045. endColumn = model.getLineMaxColumn(position.lineNumber);
  63046. }
  63047. var deleteSelection = new range_1.Range(startLineNumber, startColumn, endLineNumber, endColumn);
  63048. if (!deleteSelection.isEmpty()) {
  63049. commands[i] = new replaceCommand_1.ReplaceCommand(deleteSelection, '');
  63050. }
  63051. else {
  63052. commands[i] = null;
  63053. }
  63054. }
  63055. else {
  63056. // Cannot cut empty selection
  63057. commands[i] = null;
  63058. }
  63059. }
  63060. else {
  63061. commands[i] = new replaceCommand_1.ReplaceCommand(selection, '');
  63062. }
  63063. }
  63064. return new cursorCommon_1.EditOperationResult(0 /* Other */, commands, {
  63065. shouldPushStackElementBefore: true,
  63066. shouldPushStackElementAfter: true
  63067. });
  63068. };
  63069. return DeleteOperations;
  63070. }());
  63071. exports.DeleteOperations = DeleteOperations;
  63072. });
  63073. /*---------------------------------------------------------------------------------------------
  63074. * Copyright (c) Microsoft Corporation. All rights reserved.
  63075. * Licensed under the MIT License. See License.txt in the project root for license information.
  63076. *--------------------------------------------------------------------------------------------*/
  63077. define(__m[159/*vs/editor/common/controller/cursorTypeOperations*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,5/*vs/base/common/strings*/,80/*vs/editor/common/commands/replaceCommand*/,211/*vs/editor/common/commands/shiftCommand*/,340/*vs/editor/common/commands/surroundSelectionCommand*/,40/*vs/editor/common/controller/cursorCommon*/,89/*vs/editor/common/controller/wordCharacterClassifier*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,90/*vs/editor/common/modes/languageConfiguration*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/]), function (require, exports, errors_1, strings, replaceCommand_1, shiftCommand_1, surroundSelectionCommand_1, cursorCommon_1, wordCharacterClassifier_1, range_1, selection_1, languageConfiguration_1, languageConfigurationRegistry_1) {
  63078. "use strict";
  63079. Object.defineProperty(exports, "__esModule", { value: true });
  63080. var TypeOperations = /** @class */ (function () {
  63081. function TypeOperations() {
  63082. }
  63083. TypeOperations.indent = function (config, model, selections) {
  63084. if (model === null || selections === null) {
  63085. return [];
  63086. }
  63087. var commands = [];
  63088. for (var i = 0, len = selections.length; i < len; i++) {
  63089. commands[i] = new shiftCommand_1.ShiftCommand(selections[i], {
  63090. isUnshift: false,
  63091. tabSize: config.tabSize,
  63092. indentSize: config.indentSize,
  63093. insertSpaces: config.insertSpaces,
  63094. useTabStops: config.useTabStops,
  63095. autoIndent: config.autoIndent
  63096. });
  63097. }
  63098. return commands;
  63099. };
  63100. TypeOperations.outdent = function (config, model, selections) {
  63101. var commands = [];
  63102. for (var i = 0, len = selections.length; i < len; i++) {
  63103. commands[i] = new shiftCommand_1.ShiftCommand(selections[i], {
  63104. isUnshift: true,
  63105. tabSize: config.tabSize,
  63106. indentSize: config.indentSize,
  63107. insertSpaces: config.insertSpaces,
  63108. useTabStops: config.useTabStops,
  63109. autoIndent: config.autoIndent
  63110. });
  63111. }
  63112. return commands;
  63113. };
  63114. TypeOperations.shiftIndent = function (config, indentation, count) {
  63115. count = count || 1;
  63116. return shiftCommand_1.ShiftCommand.shiftIndent(indentation, indentation.length + count, config.tabSize, config.indentSize, config.insertSpaces);
  63117. };
  63118. TypeOperations.unshiftIndent = function (config, indentation, count) {
  63119. count = count || 1;
  63120. return shiftCommand_1.ShiftCommand.unshiftIndent(indentation, indentation.length + count, config.tabSize, config.indentSize, config.insertSpaces);
  63121. };
  63122. TypeOperations._distributedPaste = function (config, model, selections, text) {
  63123. var commands = [];
  63124. for (var i = 0, len = selections.length; i < len; i++) {
  63125. commands[i] = new replaceCommand_1.ReplaceCommand(selections[i], text[i]);
  63126. }
  63127. return new cursorCommon_1.EditOperationResult(0 /* Other */, commands, {
  63128. shouldPushStackElementBefore: true,
  63129. shouldPushStackElementAfter: true
  63130. });
  63131. };
  63132. TypeOperations._simplePaste = function (config, model, selections, text, pasteOnNewLine) {
  63133. var commands = [];
  63134. for (var i = 0, len = selections.length; i < len; i++) {
  63135. var selection = selections[i];
  63136. var position = selection.getPosition();
  63137. if (pasteOnNewLine && !selection.isEmpty()) {
  63138. pasteOnNewLine = false;
  63139. }
  63140. if (pasteOnNewLine && text.indexOf('\n') !== text.length - 1) {
  63141. pasteOnNewLine = false;
  63142. }
  63143. if (pasteOnNewLine) {
  63144. // Paste entire line at the beginning of line
  63145. var typeSelection = new range_1.Range(position.lineNumber, 1, position.lineNumber, 1);
  63146. commands[i] = new replaceCommand_1.ReplaceCommandThatPreservesSelection(typeSelection, text, selection, true);
  63147. }
  63148. else {
  63149. commands[i] = new replaceCommand_1.ReplaceCommand(selection, text);
  63150. }
  63151. }
  63152. return new cursorCommon_1.EditOperationResult(0 /* Other */, commands, {
  63153. shouldPushStackElementBefore: true,
  63154. shouldPushStackElementAfter: true
  63155. });
  63156. };
  63157. TypeOperations._distributePasteToCursors = function (config, selections, text, pasteOnNewLine, multicursorText) {
  63158. if (pasteOnNewLine) {
  63159. return null;
  63160. }
  63161. if (selections.length === 1) {
  63162. return null;
  63163. }
  63164. if (multicursorText && multicursorText.length === selections.length) {
  63165. return multicursorText;
  63166. }
  63167. if (config.multiCursorPaste === 'spread') {
  63168. // Try to spread the pasted text in case the line count matches the cursor count
  63169. // Remove trailing \n if present
  63170. if (text.charCodeAt(text.length - 1) === 10 /* LineFeed */) {
  63171. text = text.substr(0, text.length - 1);
  63172. }
  63173. // Remove trailing \r if present
  63174. if (text.charCodeAt(text.length - 1) === 13 /* CarriageReturn */) {
  63175. text = text.substr(0, text.length - 1);
  63176. }
  63177. var lines = text.split(/\r\n|\r|\n/);
  63178. if (lines.length === selections.length) {
  63179. return lines;
  63180. }
  63181. }
  63182. return null;
  63183. };
  63184. TypeOperations.paste = function (config, model, selections, text, pasteOnNewLine, multicursorText) {
  63185. var distributedPaste = this._distributePasteToCursors(config, selections, text, pasteOnNewLine, multicursorText);
  63186. if (distributedPaste) {
  63187. selections = selections.sort(range_1.Range.compareRangesUsingStarts);
  63188. return this._distributedPaste(config, model, selections, distributedPaste);
  63189. }
  63190. else {
  63191. return this._simplePaste(config, model, selections, text, pasteOnNewLine);
  63192. }
  63193. };
  63194. TypeOperations._goodIndentForLine = function (config, model, lineNumber) {
  63195. var action = null;
  63196. var indentation = '';
  63197. var expectedIndentAction = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getInheritIndentForLine(config.autoIndent, model, lineNumber, false);
  63198. if (expectedIndentAction) {
  63199. action = expectedIndentAction.action;
  63200. indentation = expectedIndentAction.indentation;
  63201. }
  63202. else if (lineNumber > 1) {
  63203. var lastLineNumber = void 0;
  63204. for (lastLineNumber = lineNumber - 1; lastLineNumber >= 1; lastLineNumber--) {
  63205. var lineText = model.getLineContent(lastLineNumber);
  63206. var nonWhitespaceIdx = strings.lastNonWhitespaceIndex(lineText);
  63207. if (nonWhitespaceIdx >= 0) {
  63208. break;
  63209. }
  63210. }
  63211. if (lastLineNumber < 1) {
  63212. // No previous line with content found
  63213. return null;
  63214. }
  63215. var maxColumn = model.getLineMaxColumn(lastLineNumber);
  63216. var expectedEnterAction = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getEnterAction(config.autoIndent, model, new range_1.Range(lastLineNumber, maxColumn, lastLineNumber, maxColumn));
  63217. if (expectedEnterAction) {
  63218. indentation = expectedEnterAction.indentation + expectedEnterAction.appendText;
  63219. }
  63220. }
  63221. if (action) {
  63222. if (action === languageConfiguration_1.IndentAction.Indent) {
  63223. indentation = TypeOperations.shiftIndent(config, indentation);
  63224. }
  63225. if (action === languageConfiguration_1.IndentAction.Outdent) {
  63226. indentation = TypeOperations.unshiftIndent(config, indentation);
  63227. }
  63228. indentation = config.normalizeIndentation(indentation);
  63229. }
  63230. if (!indentation) {
  63231. return null;
  63232. }
  63233. return indentation;
  63234. };
  63235. TypeOperations._replaceJumpToNextIndent = function (config, model, selection, insertsAutoWhitespace) {
  63236. var typeText = '';
  63237. var position = selection.getStartPosition();
  63238. if (config.insertSpaces) {
  63239. var visibleColumnFromColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn2(config, model, position);
  63240. var indentSize = config.indentSize;
  63241. var spacesCnt = indentSize - (visibleColumnFromColumn % indentSize);
  63242. for (var i = 0; i < spacesCnt; i++) {
  63243. typeText += ' ';
  63244. }
  63245. }
  63246. else {
  63247. typeText = '\t';
  63248. }
  63249. return new replaceCommand_1.ReplaceCommand(selection, typeText, insertsAutoWhitespace);
  63250. };
  63251. TypeOperations.tab = function (config, model, selections) {
  63252. var commands = [];
  63253. for (var i = 0, len = selections.length; i < len; i++) {
  63254. var selection = selections[i];
  63255. if (selection.isEmpty()) {
  63256. var lineText = model.getLineContent(selection.startLineNumber);
  63257. if (/^\s*$/.test(lineText) && model.isCheapToTokenize(selection.startLineNumber)) {
  63258. var goodIndent = this._goodIndentForLine(config, model, selection.startLineNumber);
  63259. goodIndent = goodIndent || '\t';
  63260. var possibleTypeText = config.normalizeIndentation(goodIndent);
  63261. if (!strings.startsWith(lineText, possibleTypeText)) {
  63262. commands[i] = new replaceCommand_1.ReplaceCommand(new range_1.Range(selection.startLineNumber, 1, selection.startLineNumber, lineText.length + 1), possibleTypeText, true);
  63263. continue;
  63264. }
  63265. }
  63266. commands[i] = this._replaceJumpToNextIndent(config, model, selection, true);
  63267. }
  63268. else {
  63269. if (selection.startLineNumber === selection.endLineNumber) {
  63270. var lineMaxColumn = model.getLineMaxColumn(selection.startLineNumber);
  63271. if (selection.startColumn !== 1 || selection.endColumn !== lineMaxColumn) {
  63272. // This is a single line selection that is not the entire line
  63273. commands[i] = this._replaceJumpToNextIndent(config, model, selection, false);
  63274. continue;
  63275. }
  63276. }
  63277. commands[i] = new shiftCommand_1.ShiftCommand(selection, {
  63278. isUnshift: false,
  63279. tabSize: config.tabSize,
  63280. indentSize: config.indentSize,
  63281. insertSpaces: config.insertSpaces,
  63282. useTabStops: config.useTabStops,
  63283. autoIndent: config.autoIndent
  63284. });
  63285. }
  63286. }
  63287. return commands;
  63288. };
  63289. TypeOperations.replacePreviousChar = function (prevEditOperationType, config, model, selections, txt, replaceCharCnt) {
  63290. var commands = [];
  63291. for (var i = 0, len = selections.length; i < len; i++) {
  63292. var selection = selections[i];
  63293. if (!selection.isEmpty()) {
  63294. // looks like https://github.com/Microsoft/vscode/issues/2773
  63295. // where a cursor operation occurred before a canceled composition
  63296. // => ignore composition
  63297. commands[i] = null;
  63298. continue;
  63299. }
  63300. var pos = selection.getPosition();
  63301. var startColumn = Math.max(1, pos.column - replaceCharCnt);
  63302. var range = new range_1.Range(pos.lineNumber, startColumn, pos.lineNumber, pos.column);
  63303. commands[i] = new replaceCommand_1.ReplaceCommand(range, txt);
  63304. }
  63305. return new cursorCommon_1.EditOperationResult(1 /* Typing */, commands, {
  63306. shouldPushStackElementBefore: (prevEditOperationType !== 1 /* Typing */),
  63307. shouldPushStackElementAfter: false
  63308. });
  63309. };
  63310. TypeOperations._typeCommand = function (range, text, keepPosition) {
  63311. if (keepPosition) {
  63312. return new replaceCommand_1.ReplaceCommandWithoutChangingPosition(range, text, true);
  63313. }
  63314. else {
  63315. return new replaceCommand_1.ReplaceCommand(range, text, true);
  63316. }
  63317. };
  63318. TypeOperations._enter = function (config, model, keepPosition, range) {
  63319. if (config.autoIndent === 0 /* None */) {
  63320. return TypeOperations._typeCommand(range, '\n', keepPosition);
  63321. }
  63322. if (!model.isCheapToTokenize(range.getStartPosition().lineNumber) || config.autoIndent === 1 /* Keep */) {
  63323. var lineText_1 = model.getLineContent(range.startLineNumber);
  63324. var indentation_1 = strings.getLeadingWhitespace(lineText_1).substring(0, range.startColumn - 1);
  63325. return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(indentation_1), keepPosition);
  63326. }
  63327. var r = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getEnterAction(config.autoIndent, model, range);
  63328. if (r) {
  63329. if (r.indentAction === languageConfiguration_1.IndentAction.None) {
  63330. // Nothing special
  63331. return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(r.indentation + r.appendText), keepPosition);
  63332. }
  63333. else if (r.indentAction === languageConfiguration_1.IndentAction.Indent) {
  63334. // Indent once
  63335. return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(r.indentation + r.appendText), keepPosition);
  63336. }
  63337. else if (r.indentAction === languageConfiguration_1.IndentAction.IndentOutdent) {
  63338. // Ultra special
  63339. var normalIndent = config.normalizeIndentation(r.indentation);
  63340. var increasedIndent = config.normalizeIndentation(r.indentation + r.appendText);
  63341. var typeText = '\n' + increasedIndent + '\n' + normalIndent;
  63342. if (keepPosition) {
  63343. return new replaceCommand_1.ReplaceCommandWithoutChangingPosition(range, typeText, true);
  63344. }
  63345. else {
  63346. return new replaceCommand_1.ReplaceCommandWithOffsetCursorState(range, typeText, -1, increasedIndent.length - normalIndent.length, true);
  63347. }
  63348. }
  63349. else if (r.indentAction === languageConfiguration_1.IndentAction.Outdent) {
  63350. var actualIndentation = TypeOperations.unshiftIndent(config, r.indentation);
  63351. return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(actualIndentation + r.appendText), keepPosition);
  63352. }
  63353. }
  63354. var lineText = model.getLineContent(range.startLineNumber);
  63355. var indentation = strings.getLeadingWhitespace(lineText).substring(0, range.startColumn - 1);
  63356. if (config.autoIndent >= 4 /* Full */) {
  63357. var ir = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getIndentForEnter(config.autoIndent, model, range, {
  63358. unshiftIndent: function (indent) {
  63359. return TypeOperations.unshiftIndent(config, indent);
  63360. },
  63361. shiftIndent: function (indent) {
  63362. return TypeOperations.shiftIndent(config, indent);
  63363. },
  63364. normalizeIndentation: function (indent) {
  63365. return config.normalizeIndentation(indent);
  63366. }
  63367. });
  63368. if (ir) {
  63369. var oldEndViewColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn2(config, model, range.getEndPosition());
  63370. var oldEndColumn = range.endColumn;
  63371. var beforeText = '\n';
  63372. if (indentation !== config.normalizeIndentation(ir.beforeEnter)) {
  63373. beforeText = config.normalizeIndentation(ir.beforeEnter) + lineText.substring(indentation.length, range.startColumn - 1) + '\n';
  63374. range = new range_1.Range(range.startLineNumber, 1, range.endLineNumber, range.endColumn);
  63375. }
  63376. var newLineContent = model.getLineContent(range.endLineNumber);
  63377. var firstNonWhitespace = strings.firstNonWhitespaceIndex(newLineContent);
  63378. if (firstNonWhitespace >= 0) {
  63379. range = range.setEndPosition(range.endLineNumber, Math.max(range.endColumn, firstNonWhitespace + 1));
  63380. }
  63381. else {
  63382. range = range.setEndPosition(range.endLineNumber, model.getLineMaxColumn(range.endLineNumber));
  63383. }
  63384. if (keepPosition) {
  63385. return new replaceCommand_1.ReplaceCommandWithoutChangingPosition(range, beforeText + config.normalizeIndentation(ir.afterEnter), true);
  63386. }
  63387. else {
  63388. var offset = 0;
  63389. if (oldEndColumn <= firstNonWhitespace + 1) {
  63390. if (!config.insertSpaces) {
  63391. oldEndViewColumn = Math.ceil(oldEndViewColumn / config.indentSize);
  63392. }
  63393. offset = Math.min(oldEndViewColumn + 1 - config.normalizeIndentation(ir.afterEnter).length - 1, 0);
  63394. }
  63395. return new replaceCommand_1.ReplaceCommandWithOffsetCursorState(range, beforeText + config.normalizeIndentation(ir.afterEnter), 0, offset, true);
  63396. }
  63397. }
  63398. }
  63399. return TypeOperations._typeCommand(range, '\n' + config.normalizeIndentation(indentation), keepPosition);
  63400. };
  63401. TypeOperations._isAutoIndentType = function (config, model, selections) {
  63402. if (config.autoIndent < 4 /* Full */) {
  63403. return false;
  63404. }
  63405. for (var i = 0, len = selections.length; i < len; i++) {
  63406. if (!model.isCheapToTokenize(selections[i].getEndPosition().lineNumber)) {
  63407. return false;
  63408. }
  63409. }
  63410. return true;
  63411. };
  63412. TypeOperations._runAutoIndentType = function (config, model, range, ch) {
  63413. var currentIndentation = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getIndentationAtPosition(model, range.startLineNumber, range.startColumn);
  63414. var actualIndentation = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getIndentActionForType(config.autoIndent, model, range, ch, {
  63415. shiftIndent: function (indentation) {
  63416. return TypeOperations.shiftIndent(config, indentation);
  63417. },
  63418. unshiftIndent: function (indentation) {
  63419. return TypeOperations.unshiftIndent(config, indentation);
  63420. },
  63421. });
  63422. if (actualIndentation === null) {
  63423. return null;
  63424. }
  63425. if (actualIndentation !== config.normalizeIndentation(currentIndentation)) {
  63426. var firstNonWhitespace = model.getLineFirstNonWhitespaceColumn(range.startLineNumber);
  63427. if (firstNonWhitespace === 0) {
  63428. return TypeOperations._typeCommand(new range_1.Range(range.startLineNumber, 0, range.endLineNumber, range.endColumn), config.normalizeIndentation(actualIndentation) + ch, false);
  63429. }
  63430. else {
  63431. return TypeOperations._typeCommand(new range_1.Range(range.startLineNumber, 0, range.endLineNumber, range.endColumn), config.normalizeIndentation(actualIndentation) +
  63432. model.getLineContent(range.startLineNumber).substring(firstNonWhitespace - 1, range.startColumn - 1) + ch, false);
  63433. }
  63434. }
  63435. return null;
  63436. };
  63437. TypeOperations._isAutoClosingOvertype = function (config, model, selections, autoClosedCharacters, ch) {
  63438. if (config.autoClosingOvertype === 'never') {
  63439. return false;
  63440. }
  63441. if (!config.autoClosingPairsClose2.has(ch)) {
  63442. return false;
  63443. }
  63444. for (var i = 0, len = selections.length; i < len; i++) {
  63445. var selection = selections[i];
  63446. if (!selection.isEmpty()) {
  63447. return false;
  63448. }
  63449. var position = selection.getPosition();
  63450. var lineText = model.getLineContent(position.lineNumber);
  63451. var afterCharacter = lineText.charAt(position.column - 1);
  63452. if (afterCharacter !== ch) {
  63453. return false;
  63454. }
  63455. // Do not over-type quotes after a backslash
  63456. var chIsQuote = cursorCommon_1.isQuote(ch);
  63457. var beforeCharacter = position.column > 2 ? lineText.charCodeAt(position.column - 2) : 0 /* Null */;
  63458. if (beforeCharacter === 92 /* Backslash */ && chIsQuote) {
  63459. return false;
  63460. }
  63461. // Must over-type a closing character typed by the editor
  63462. if (config.autoClosingOvertype === 'auto') {
  63463. var found = false;
  63464. for (var j = 0, lenJ = autoClosedCharacters.length; j < lenJ; j++) {
  63465. var autoClosedCharacter = autoClosedCharacters[j];
  63466. if (position.lineNumber === autoClosedCharacter.startLineNumber && position.column === autoClosedCharacter.startColumn) {
  63467. found = true;
  63468. break;
  63469. }
  63470. }
  63471. if (!found) {
  63472. return false;
  63473. }
  63474. }
  63475. }
  63476. return true;
  63477. };
  63478. TypeOperations._runAutoClosingOvertype = function (prevEditOperationType, config, model, selections, ch) {
  63479. var commands = [];
  63480. for (var i = 0, len = selections.length; i < len; i++) {
  63481. var selection = selections[i];
  63482. var position = selection.getPosition();
  63483. var typeSelection = new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column + 1);
  63484. commands[i] = new replaceCommand_1.ReplaceCommand(typeSelection, ch);
  63485. }
  63486. return new cursorCommon_1.EditOperationResult(1 /* Typing */, commands, {
  63487. shouldPushStackElementBefore: (prevEditOperationType !== 1 /* Typing */),
  63488. shouldPushStackElementAfter: false
  63489. });
  63490. };
  63491. TypeOperations._autoClosingPairIsSymmetric = function (autoClosingPair) {
  63492. var open = autoClosingPair.open, close = autoClosingPair.close;
  63493. return (open.indexOf(close) >= 0 || close.indexOf(open) >= 0);
  63494. };
  63495. TypeOperations._isBeforeClosingBrace = function (config, autoClosingPair, characterAfter) {
  63496. var otherAutoClosingPairs = config.autoClosingPairsClose2.get(characterAfter);
  63497. if (!otherAutoClosingPairs) {
  63498. return false;
  63499. }
  63500. var thisBraceIsSymmetric = TypeOperations._autoClosingPairIsSymmetric(autoClosingPair);
  63501. for (var _i = 0, otherAutoClosingPairs_1 = otherAutoClosingPairs; _i < otherAutoClosingPairs_1.length; _i++) {
  63502. var otherAutoClosingPair = otherAutoClosingPairs_1[_i];
  63503. var otherBraceIsSymmetric = TypeOperations._autoClosingPairIsSymmetric(otherAutoClosingPair);
  63504. if (!thisBraceIsSymmetric && otherBraceIsSymmetric) {
  63505. continue;
  63506. }
  63507. return true;
  63508. }
  63509. return false;
  63510. };
  63511. TypeOperations._findAutoClosingPairOpen = function (config, model, positions, ch) {
  63512. var autoClosingPairCandidates = config.autoClosingPairsOpen2.get(ch);
  63513. if (!autoClosingPairCandidates) {
  63514. return null;
  63515. }
  63516. // Determine which auto-closing pair it is
  63517. var autoClosingPair = null;
  63518. for (var _i = 0, autoClosingPairCandidates_1 = autoClosingPairCandidates; _i < autoClosingPairCandidates_1.length; _i++) {
  63519. var autoClosingPairCandidate = autoClosingPairCandidates_1[_i];
  63520. if (autoClosingPair === null || autoClosingPairCandidate.open.length > autoClosingPair.open.length) {
  63521. var candidateIsMatch = true;
  63522. for (var _a = 0, positions_1 = positions; _a < positions_1.length; _a++) {
  63523. var position = positions_1[_a];
  63524. var relevantText = model.getValueInRange(new range_1.Range(position.lineNumber, position.column - autoClosingPairCandidate.open.length + 1, position.lineNumber, position.column));
  63525. if (relevantText + ch !== autoClosingPairCandidate.open) {
  63526. candidateIsMatch = false;
  63527. break;
  63528. }
  63529. }
  63530. if (candidateIsMatch) {
  63531. autoClosingPair = autoClosingPairCandidate;
  63532. }
  63533. }
  63534. }
  63535. return autoClosingPair;
  63536. };
  63537. TypeOperations._isAutoClosingOpenCharType = function (config, model, selections, ch, insertOpenCharacter) {
  63538. var chIsQuote = cursorCommon_1.isQuote(ch);
  63539. var autoCloseConfig = chIsQuote ? config.autoClosingQuotes : config.autoClosingBrackets;
  63540. if (autoCloseConfig === 'never') {
  63541. return null;
  63542. }
  63543. var autoClosingPair = this._findAutoClosingPairOpen(config, model, selections.map(function (s) { return s.getPosition(); }), ch);
  63544. if (!autoClosingPair) {
  63545. return null;
  63546. }
  63547. var shouldAutoCloseBefore = chIsQuote ? config.shouldAutoCloseBefore.quote : config.shouldAutoCloseBefore.bracket;
  63548. for (var i = 0, len = selections.length; i < len; i++) {
  63549. var selection = selections[i];
  63550. if (!selection.isEmpty()) {
  63551. return null;
  63552. }
  63553. var position = selection.getPosition();
  63554. var lineText = model.getLineContent(position.lineNumber);
  63555. // Only consider auto closing the pair if a space follows or if another autoclosed pair follows
  63556. if (lineText.length > position.column - 1) {
  63557. var characterAfter = lineText.charAt(position.column - 1);
  63558. var isBeforeCloseBrace = TypeOperations._isBeforeClosingBrace(config, autoClosingPair, characterAfter);
  63559. if (!isBeforeCloseBrace && !shouldAutoCloseBefore(characterAfter)) {
  63560. return null;
  63561. }
  63562. }
  63563. if (!model.isCheapToTokenize(position.lineNumber)) {
  63564. // Do not force tokenization
  63565. return null;
  63566. }
  63567. // Do not auto-close ' or " after a word character
  63568. if (autoClosingPair.open.length === 1 && chIsQuote && autoCloseConfig !== 'always') {
  63569. var wordSeparators = wordCharacterClassifier_1.getMapForWordSeparators(config.wordSeparators);
  63570. if (insertOpenCharacter && position.column > 1 && wordSeparators.get(lineText.charCodeAt(position.column - 2)) === 0 /* Regular */) {
  63571. return null;
  63572. }
  63573. if (!insertOpenCharacter && position.column > 2 && wordSeparators.get(lineText.charCodeAt(position.column - 3)) === 0 /* Regular */) {
  63574. return null;
  63575. }
  63576. }
  63577. model.forceTokenization(position.lineNumber);
  63578. var lineTokens = model.getLineTokens(position.lineNumber);
  63579. var shouldAutoClosePair = false;
  63580. try {
  63581. shouldAutoClosePair = languageConfigurationRegistry_1.LanguageConfigurationRegistry.shouldAutoClosePair(autoClosingPair, lineTokens, insertOpenCharacter ? position.column : position.column - 1);
  63582. }
  63583. catch (e) {
  63584. errors_1.onUnexpectedError(e);
  63585. }
  63586. if (!shouldAutoClosePair) {
  63587. return null;
  63588. }
  63589. }
  63590. return autoClosingPair;
  63591. };
  63592. TypeOperations._runAutoClosingOpenCharType = function (prevEditOperationType, config, model, selections, ch, insertOpenCharacter, autoClosingPair) {
  63593. var commands = [];
  63594. for (var i = 0, len = selections.length; i < len; i++) {
  63595. var selection = selections[i];
  63596. commands[i] = new TypeWithAutoClosingCommand(selection, ch, insertOpenCharacter, autoClosingPair.close);
  63597. }
  63598. return new cursorCommon_1.EditOperationResult(1 /* Typing */, commands, {
  63599. shouldPushStackElementBefore: true,
  63600. shouldPushStackElementAfter: false
  63601. });
  63602. };
  63603. TypeOperations._shouldSurroundChar = function (config, ch) {
  63604. if (cursorCommon_1.isQuote(ch)) {
  63605. return (config.autoSurround === 'quotes' || config.autoSurround === 'languageDefined');
  63606. }
  63607. else {
  63608. // Character is a bracket
  63609. return (config.autoSurround === 'brackets' || config.autoSurround === 'languageDefined');
  63610. }
  63611. };
  63612. TypeOperations._isSurroundSelectionType = function (config, model, selections, ch) {
  63613. if (!TypeOperations._shouldSurroundChar(config, ch) || !config.surroundingPairs.hasOwnProperty(ch)) {
  63614. return false;
  63615. }
  63616. var isTypingAQuoteCharacter = cursorCommon_1.isQuote(ch);
  63617. for (var i = 0, len = selections.length; i < len; i++) {
  63618. var selection = selections[i];
  63619. if (selection.isEmpty()) {
  63620. return false;
  63621. }
  63622. var selectionContainsOnlyWhitespace = true;
  63623. for (var lineNumber = selection.startLineNumber; lineNumber <= selection.endLineNumber; lineNumber++) {
  63624. var lineText = model.getLineContent(lineNumber);
  63625. var startIndex = (lineNumber === selection.startLineNumber ? selection.startColumn - 1 : 0);
  63626. var endIndex = (lineNumber === selection.endLineNumber ? selection.endColumn - 1 : lineText.length);
  63627. var selectedText = lineText.substring(startIndex, endIndex);
  63628. if (/[^ \t]/.test(selectedText)) {
  63629. // this selected text contains something other than whitespace
  63630. selectionContainsOnlyWhitespace = false;
  63631. break;
  63632. }
  63633. }
  63634. if (selectionContainsOnlyWhitespace) {
  63635. return false;
  63636. }
  63637. if (isTypingAQuoteCharacter && selection.startLineNumber === selection.endLineNumber && selection.startColumn + 1 === selection.endColumn) {
  63638. var selectionText = model.getValueInRange(selection);
  63639. if (cursorCommon_1.isQuote(selectionText)) {
  63640. // Typing a quote character on top of another quote character
  63641. // => disable surround selection type
  63642. return false;
  63643. }
  63644. }
  63645. }
  63646. return true;
  63647. };
  63648. TypeOperations._runSurroundSelectionType = function (prevEditOperationType, config, model, selections, ch) {
  63649. var commands = [];
  63650. for (var i = 0, len = selections.length; i < len; i++) {
  63651. var selection = selections[i];
  63652. var closeCharacter = config.surroundingPairs[ch];
  63653. commands[i] = new surroundSelectionCommand_1.SurroundSelectionCommand(selection, ch, closeCharacter);
  63654. }
  63655. return new cursorCommon_1.EditOperationResult(0 /* Other */, commands, {
  63656. shouldPushStackElementBefore: true,
  63657. shouldPushStackElementAfter: true
  63658. });
  63659. };
  63660. TypeOperations._isTypeInterceptorElectricChar = function (config, model, selections) {
  63661. if (selections.length === 1 && model.isCheapToTokenize(selections[0].getEndPosition().lineNumber)) {
  63662. return true;
  63663. }
  63664. return false;
  63665. };
  63666. TypeOperations._typeInterceptorElectricChar = function (prevEditOperationType, config, model, selection, ch) {
  63667. if (!config.electricChars.hasOwnProperty(ch) || !selection.isEmpty()) {
  63668. return null;
  63669. }
  63670. var position = selection.getPosition();
  63671. model.forceTokenization(position.lineNumber);
  63672. var lineTokens = model.getLineTokens(position.lineNumber);
  63673. var electricAction;
  63674. try {
  63675. electricAction = languageConfigurationRegistry_1.LanguageConfigurationRegistry.onElectricCharacter(ch, lineTokens, position.column);
  63676. }
  63677. catch (e) {
  63678. errors_1.onUnexpectedError(e);
  63679. return null;
  63680. }
  63681. if (!electricAction) {
  63682. return null;
  63683. }
  63684. if (electricAction.matchOpenBracket) {
  63685. var endColumn = (lineTokens.getLineContent() + ch).lastIndexOf(electricAction.matchOpenBracket) + 1;
  63686. var match = model.findMatchingBracketUp(electricAction.matchOpenBracket, {
  63687. lineNumber: position.lineNumber,
  63688. column: endColumn
  63689. });
  63690. if (match) {
  63691. if (match.startLineNumber === position.lineNumber) {
  63692. // matched something on the same line => no change in indentation
  63693. return null;
  63694. }
  63695. var matchLine = model.getLineContent(match.startLineNumber);
  63696. var matchLineIndentation = strings.getLeadingWhitespace(matchLine);
  63697. var newIndentation = config.normalizeIndentation(matchLineIndentation);
  63698. var lineText = model.getLineContent(position.lineNumber);
  63699. var lineFirstNonBlankColumn = model.getLineFirstNonWhitespaceColumn(position.lineNumber) || position.column;
  63700. var prefix = lineText.substring(lineFirstNonBlankColumn - 1, position.column - 1);
  63701. var typeText = newIndentation + prefix + ch;
  63702. var typeSelection = new range_1.Range(position.lineNumber, 1, position.lineNumber, position.column);
  63703. var command = new replaceCommand_1.ReplaceCommand(typeSelection, typeText);
  63704. return new cursorCommon_1.EditOperationResult(1 /* Typing */, [command], {
  63705. shouldPushStackElementBefore: false,
  63706. shouldPushStackElementAfter: true
  63707. });
  63708. }
  63709. }
  63710. return null;
  63711. };
  63712. /**
  63713. * This is very similar with typing, but the character is already in the text buffer!
  63714. */
  63715. TypeOperations.compositionEndWithInterceptors = function (prevEditOperationType, config, model, selectionsWhenCompositionStarted, selections, autoClosedCharacters) {
  63716. if (!selectionsWhenCompositionStarted || selection_1.Selection.selectionsArrEqual(selectionsWhenCompositionStarted, selections)) {
  63717. // no content was typed
  63718. return null;
  63719. }
  63720. var ch = null;
  63721. // extract last typed character
  63722. for (var _i = 0, selections_1 = selections; _i < selections_1.length; _i++) {
  63723. var selection = selections_1[_i];
  63724. if (!selection.isEmpty()) {
  63725. return null;
  63726. }
  63727. var position = selection.getPosition();
  63728. var currentChar = model.getValueInRange(new range_1.Range(position.lineNumber, position.column - 1, position.lineNumber, position.column));
  63729. if (ch === null) {
  63730. ch = currentChar;
  63731. }
  63732. else if (ch !== currentChar) {
  63733. return null;
  63734. }
  63735. }
  63736. if (!ch) {
  63737. return null;
  63738. }
  63739. if (this._isAutoClosingOvertype(config, model, selections, autoClosedCharacters, ch)) {
  63740. // Unfortunately, the close character is at this point "doubled", so we need to delete it...
  63741. var commands = selections.map(function (s) { return new replaceCommand_1.ReplaceCommand(new range_1.Range(s.positionLineNumber, s.positionColumn, s.positionLineNumber, s.positionColumn + 1), '', false); });
  63742. return new cursorCommon_1.EditOperationResult(1 /* Typing */, commands, {
  63743. shouldPushStackElementBefore: true,
  63744. shouldPushStackElementAfter: false
  63745. });
  63746. }
  63747. var autoClosingPairOpenCharType = this._isAutoClosingOpenCharType(config, model, selections, ch, false);
  63748. if (autoClosingPairOpenCharType) {
  63749. return this._runAutoClosingOpenCharType(prevEditOperationType, config, model, selections, ch, false, autoClosingPairOpenCharType);
  63750. }
  63751. return null;
  63752. };
  63753. TypeOperations.typeWithInterceptors = function (prevEditOperationType, config, model, selections, autoClosedCharacters, ch) {
  63754. if (ch === '\n') {
  63755. var commands_1 = [];
  63756. for (var i = 0, len = selections.length; i < len; i++) {
  63757. commands_1[i] = TypeOperations._enter(config, model, false, selections[i]);
  63758. }
  63759. return new cursorCommon_1.EditOperationResult(1 /* Typing */, commands_1, {
  63760. shouldPushStackElementBefore: true,
  63761. shouldPushStackElementAfter: false,
  63762. });
  63763. }
  63764. if (this._isAutoIndentType(config, model, selections)) {
  63765. var commands_2 = [];
  63766. var autoIndentFails = false;
  63767. for (var i = 0, len = selections.length; i < len; i++) {
  63768. commands_2[i] = this._runAutoIndentType(config, model, selections[i], ch);
  63769. if (!commands_2[i]) {
  63770. autoIndentFails = true;
  63771. break;
  63772. }
  63773. }
  63774. if (!autoIndentFails) {
  63775. return new cursorCommon_1.EditOperationResult(1 /* Typing */, commands_2, {
  63776. shouldPushStackElementBefore: true,
  63777. shouldPushStackElementAfter: false,
  63778. });
  63779. }
  63780. }
  63781. if (this._isAutoClosingOvertype(config, model, selections, autoClosedCharacters, ch)) {
  63782. return this._runAutoClosingOvertype(prevEditOperationType, config, model, selections, ch);
  63783. }
  63784. var autoClosingPairOpenCharType = this._isAutoClosingOpenCharType(config, model, selections, ch, true);
  63785. if (autoClosingPairOpenCharType) {
  63786. return this._runAutoClosingOpenCharType(prevEditOperationType, config, model, selections, ch, true, autoClosingPairOpenCharType);
  63787. }
  63788. if (this._isSurroundSelectionType(config, model, selections, ch)) {
  63789. return this._runSurroundSelectionType(prevEditOperationType, config, model, selections, ch);
  63790. }
  63791. // Electric characters make sense only when dealing with a single cursor,
  63792. // as multiple cursors typing brackets for example would interfer with bracket matching
  63793. if (this._isTypeInterceptorElectricChar(config, model, selections)) {
  63794. var r = this._typeInterceptorElectricChar(prevEditOperationType, config, model, selections[0], ch);
  63795. if (r) {
  63796. return r;
  63797. }
  63798. }
  63799. // A simple character type
  63800. var commands = [];
  63801. for (var i = 0, len = selections.length; i < len; i++) {
  63802. commands[i] = new replaceCommand_1.ReplaceCommand(selections[i], ch);
  63803. }
  63804. var shouldPushStackElementBefore = (prevEditOperationType !== 1 /* Typing */);
  63805. if (ch === ' ') {
  63806. shouldPushStackElementBefore = true;
  63807. }
  63808. return new cursorCommon_1.EditOperationResult(1 /* Typing */, commands, {
  63809. shouldPushStackElementBefore: shouldPushStackElementBefore,
  63810. shouldPushStackElementAfter: false
  63811. });
  63812. };
  63813. TypeOperations.typeWithoutInterceptors = function (prevEditOperationType, config, model, selections, str) {
  63814. var commands = [];
  63815. for (var i = 0, len = selections.length; i < len; i++) {
  63816. commands[i] = new replaceCommand_1.ReplaceCommand(selections[i], str);
  63817. }
  63818. return new cursorCommon_1.EditOperationResult(1 /* Typing */, commands, {
  63819. shouldPushStackElementBefore: (prevEditOperationType !== 1 /* Typing */),
  63820. shouldPushStackElementAfter: false
  63821. });
  63822. };
  63823. TypeOperations.lineInsertBefore = function (config, model, selections) {
  63824. if (model === null || selections === null) {
  63825. return [];
  63826. }
  63827. var commands = [];
  63828. for (var i = 0, len = selections.length; i < len; i++) {
  63829. var lineNumber = selections[i].positionLineNumber;
  63830. if (lineNumber === 1) {
  63831. commands[i] = new replaceCommand_1.ReplaceCommandWithoutChangingPosition(new range_1.Range(1, 1, 1, 1), '\n');
  63832. }
  63833. else {
  63834. lineNumber--;
  63835. var column = model.getLineMaxColumn(lineNumber);
  63836. commands[i] = this._enter(config, model, false, new range_1.Range(lineNumber, column, lineNumber, column));
  63837. }
  63838. }
  63839. return commands;
  63840. };
  63841. TypeOperations.lineInsertAfter = function (config, model, selections) {
  63842. if (model === null || selections === null) {
  63843. return [];
  63844. }
  63845. var commands = [];
  63846. for (var i = 0, len = selections.length; i < len; i++) {
  63847. var lineNumber = selections[i].positionLineNumber;
  63848. var column = model.getLineMaxColumn(lineNumber);
  63849. commands[i] = this._enter(config, model, false, new range_1.Range(lineNumber, column, lineNumber, column));
  63850. }
  63851. return commands;
  63852. };
  63853. TypeOperations.lineBreakInsert = function (config, model, selections) {
  63854. var commands = [];
  63855. for (var i = 0, len = selections.length; i < len; i++) {
  63856. commands[i] = this._enter(config, model, true, selections[i]);
  63857. }
  63858. return commands;
  63859. };
  63860. return TypeOperations;
  63861. }());
  63862. exports.TypeOperations = TypeOperations;
  63863. var TypeWithAutoClosingCommand = /** @class */ (function (_super) {
  63864. __extends(TypeWithAutoClosingCommand, _super);
  63865. function TypeWithAutoClosingCommand(selection, openCharacter, insertOpenCharacter, closeCharacter) {
  63866. var _this = _super.call(this, selection, (insertOpenCharacter ? openCharacter : '') + closeCharacter, 0, -closeCharacter.length) || this;
  63867. _this._openCharacter = openCharacter;
  63868. _this._closeCharacter = closeCharacter;
  63869. _this.closeCharacterRange = null;
  63870. _this.enclosingRange = null;
  63871. return _this;
  63872. }
  63873. TypeWithAutoClosingCommand.prototype.computeCursorState = function (model, helper) {
  63874. var inverseEditOperations = helper.getInverseEditOperations();
  63875. var range = inverseEditOperations[0].range;
  63876. this.closeCharacterRange = new range_1.Range(range.startLineNumber, range.endColumn - this._closeCharacter.length, range.endLineNumber, range.endColumn);
  63877. this.enclosingRange = new range_1.Range(range.startLineNumber, range.endColumn - this._openCharacter.length - this._closeCharacter.length, range.endLineNumber, range.endColumn);
  63878. return _super.prototype.computeCursorState.call(this, model, helper);
  63879. };
  63880. return TypeWithAutoClosingCommand;
  63881. }(replaceCommand_1.ReplaceCommandWithOffsetCursorState));
  63882. exports.TypeWithAutoClosingCommand = TypeWithAutoClosingCommand;
  63883. });
  63884. /*---------------------------------------------------------------------------------------------
  63885. * Copyright (c) Microsoft Corporation. All rights reserved.
  63886. * Licensed under the MIT License. See License.txt in the project root for license information.
  63887. *--------------------------------------------------------------------------------------------*/
  63888. define(__m[160/*vs/editor/common/controller/cursorWordOperations*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,40/*vs/editor/common/controller/cursorCommon*/,89/*vs/editor/common/controller/wordCharacterClassifier*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/]), function (require, exports, strings, cursorCommon_1, wordCharacterClassifier_1, position_1, range_1) {
  63889. "use strict";
  63890. Object.defineProperty(exports, "__esModule", { value: true });
  63891. var WordOperations = /** @class */ (function () {
  63892. function WordOperations() {
  63893. }
  63894. WordOperations._createWord = function (lineContent, wordType, nextCharClass, start, end) {
  63895. // console.log('WORD ==> ' + start + ' => ' + end + ':::: <<<' + lineContent.substring(start, end) + '>>>');
  63896. return { start: start, end: end, wordType: wordType, nextCharClass: nextCharClass };
  63897. };
  63898. WordOperations._findPreviousWordOnLine = function (wordSeparators, model, position) {
  63899. var lineContent = model.getLineContent(position.lineNumber);
  63900. return this._doFindPreviousWordOnLine(lineContent, wordSeparators, position);
  63901. };
  63902. WordOperations._doFindPreviousWordOnLine = function (lineContent, wordSeparators, position) {
  63903. var wordType = 0 /* None */;
  63904. for (var chIndex = position.column - 2; chIndex >= 0; chIndex--) {
  63905. var chCode = lineContent.charCodeAt(chIndex);
  63906. var chClass = wordSeparators.get(chCode);
  63907. if (chClass === 0 /* Regular */) {
  63908. if (wordType === 2 /* Separator */) {
  63909. return this._createWord(lineContent, wordType, chClass, chIndex + 1, this._findEndOfWord(lineContent, wordSeparators, wordType, chIndex + 1));
  63910. }
  63911. wordType = 1 /* Regular */;
  63912. }
  63913. else if (chClass === 2 /* WordSeparator */) {
  63914. if (wordType === 1 /* Regular */) {
  63915. return this._createWord(lineContent, wordType, chClass, chIndex + 1, this._findEndOfWord(lineContent, wordSeparators, wordType, chIndex + 1));
  63916. }
  63917. wordType = 2 /* Separator */;
  63918. }
  63919. else if (chClass === 1 /* Whitespace */) {
  63920. if (wordType !== 0 /* None */) {
  63921. return this._createWord(lineContent, wordType, chClass, chIndex + 1, this._findEndOfWord(lineContent, wordSeparators, wordType, chIndex + 1));
  63922. }
  63923. }
  63924. }
  63925. if (wordType !== 0 /* None */) {
  63926. return this._createWord(lineContent, wordType, 1 /* Whitespace */, 0, this._findEndOfWord(lineContent, wordSeparators, wordType, 0));
  63927. }
  63928. return null;
  63929. };
  63930. WordOperations._findEndOfWord = function (lineContent, wordSeparators, wordType, startIndex) {
  63931. var len = lineContent.length;
  63932. for (var chIndex = startIndex; chIndex < len; chIndex++) {
  63933. var chCode = lineContent.charCodeAt(chIndex);
  63934. var chClass = wordSeparators.get(chCode);
  63935. if (chClass === 1 /* Whitespace */) {
  63936. return chIndex;
  63937. }
  63938. if (wordType === 1 /* Regular */ && chClass === 2 /* WordSeparator */) {
  63939. return chIndex;
  63940. }
  63941. if (wordType === 2 /* Separator */ && chClass === 0 /* Regular */) {
  63942. return chIndex;
  63943. }
  63944. }
  63945. return len;
  63946. };
  63947. WordOperations._findNextWordOnLine = function (wordSeparators, model, position) {
  63948. var lineContent = model.getLineContent(position.lineNumber);
  63949. return this._doFindNextWordOnLine(lineContent, wordSeparators, position);
  63950. };
  63951. WordOperations._doFindNextWordOnLine = function (lineContent, wordSeparators, position) {
  63952. var wordType = 0 /* None */;
  63953. var len = lineContent.length;
  63954. for (var chIndex = position.column - 1; chIndex < len; chIndex++) {
  63955. var chCode = lineContent.charCodeAt(chIndex);
  63956. var chClass = wordSeparators.get(chCode);
  63957. if (chClass === 0 /* Regular */) {
  63958. if (wordType === 2 /* Separator */) {
  63959. return this._createWord(lineContent, wordType, chClass, this._findStartOfWord(lineContent, wordSeparators, wordType, chIndex - 1), chIndex);
  63960. }
  63961. wordType = 1 /* Regular */;
  63962. }
  63963. else if (chClass === 2 /* WordSeparator */) {
  63964. if (wordType === 1 /* Regular */) {
  63965. return this._createWord(lineContent, wordType, chClass, this._findStartOfWord(lineContent, wordSeparators, wordType, chIndex - 1), chIndex);
  63966. }
  63967. wordType = 2 /* Separator */;
  63968. }
  63969. else if (chClass === 1 /* Whitespace */) {
  63970. if (wordType !== 0 /* None */) {
  63971. return this._createWord(lineContent, wordType, chClass, this._findStartOfWord(lineContent, wordSeparators, wordType, chIndex - 1), chIndex);
  63972. }
  63973. }
  63974. }
  63975. if (wordType !== 0 /* None */) {
  63976. return this._createWord(lineContent, wordType, 1 /* Whitespace */, this._findStartOfWord(lineContent, wordSeparators, wordType, len - 1), len);
  63977. }
  63978. return null;
  63979. };
  63980. WordOperations._findStartOfWord = function (lineContent, wordSeparators, wordType, startIndex) {
  63981. for (var chIndex = startIndex; chIndex >= 0; chIndex--) {
  63982. var chCode = lineContent.charCodeAt(chIndex);
  63983. var chClass = wordSeparators.get(chCode);
  63984. if (chClass === 1 /* Whitespace */) {
  63985. return chIndex + 1;
  63986. }
  63987. if (wordType === 1 /* Regular */ && chClass === 2 /* WordSeparator */) {
  63988. return chIndex + 1;
  63989. }
  63990. if (wordType === 2 /* Separator */ && chClass === 0 /* Regular */) {
  63991. return chIndex + 1;
  63992. }
  63993. }
  63994. return 0;
  63995. };
  63996. WordOperations.moveWordLeft = function (wordSeparators, model, position, wordNavigationType) {
  63997. var lineNumber = position.lineNumber;
  63998. var column = position.column;
  63999. var movedToPreviousLine = false;
  64000. if (column === 1) {
  64001. if (lineNumber > 1) {
  64002. movedToPreviousLine = true;
  64003. lineNumber = lineNumber - 1;
  64004. column = model.getLineMaxColumn(lineNumber);
  64005. }
  64006. }
  64007. var prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, column));
  64008. if (wordNavigationType === 0 /* WordStart */) {
  64009. if (prevWordOnLine && !movedToPreviousLine) {
  64010. // Special case for Visual Studio compatibility:
  64011. // when starting in the trim whitespace at the end of a line,
  64012. // go to the end of the last word
  64013. var lastWhitespaceColumn = model.getLineLastNonWhitespaceColumn(lineNumber);
  64014. if (lastWhitespaceColumn < column) {
  64015. return new position_1.Position(lineNumber, prevWordOnLine.end + 1);
  64016. }
  64017. }
  64018. return new position_1.Position(lineNumber, prevWordOnLine ? prevWordOnLine.start + 1 : 1);
  64019. }
  64020. if (wordNavigationType === 1 /* WordStartFast */) {
  64021. if (prevWordOnLine
  64022. && prevWordOnLine.wordType === 2 /* Separator */
  64023. && prevWordOnLine.end - prevWordOnLine.start === 1
  64024. && prevWordOnLine.nextCharClass === 0 /* Regular */) {
  64025. // Skip over a word made up of one single separator and followed by a regular character
  64026. prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, prevWordOnLine.start + 1));
  64027. }
  64028. return new position_1.Position(lineNumber, prevWordOnLine ? prevWordOnLine.start + 1 : 1);
  64029. }
  64030. if (wordNavigationType === 3 /* WordAccessibility */) {
  64031. while (prevWordOnLine
  64032. && prevWordOnLine.wordType === 2 /* Separator */) {
  64033. // Skip over words made up of only separators
  64034. prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, prevWordOnLine.start + 1));
  64035. }
  64036. return new position_1.Position(lineNumber, prevWordOnLine ? prevWordOnLine.start + 1 : 1);
  64037. }
  64038. // We are stopping at the ending of words
  64039. if (prevWordOnLine && column <= prevWordOnLine.end + 1) {
  64040. prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, prevWordOnLine.start + 1));
  64041. }
  64042. return new position_1.Position(lineNumber, prevWordOnLine ? prevWordOnLine.end + 1 : 1);
  64043. };
  64044. WordOperations._moveWordPartLeft = function (model, position) {
  64045. var lineNumber = position.lineNumber;
  64046. var maxColumn = model.getLineMaxColumn(lineNumber);
  64047. if (position.column === 1) {
  64048. return (lineNumber > 1 ? new position_1.Position(lineNumber - 1, model.getLineMaxColumn(lineNumber - 1)) : position);
  64049. }
  64050. var lineContent = model.getLineContent(lineNumber);
  64051. for (var column = position.column - 1; column > 1; column--) {
  64052. var left = lineContent.charCodeAt(column - 2);
  64053. var right = lineContent.charCodeAt(column - 1);
  64054. if (left !== 95 /* Underline */ && right === 95 /* Underline */) {
  64055. // snake_case_variables
  64056. return new position_1.Position(lineNumber, column);
  64057. }
  64058. if (strings.isLowerAsciiLetter(left) && strings.isUpperAsciiLetter(right)) {
  64059. // camelCaseVariables
  64060. return new position_1.Position(lineNumber, column);
  64061. }
  64062. if (strings.isUpperAsciiLetter(left) && strings.isUpperAsciiLetter(right)) {
  64063. // thisIsACamelCaseWithOneLetterWords
  64064. if (column + 1 < maxColumn) {
  64065. var rightRight = lineContent.charCodeAt(column);
  64066. if (strings.isLowerAsciiLetter(rightRight)) {
  64067. return new position_1.Position(lineNumber, column);
  64068. }
  64069. }
  64070. }
  64071. }
  64072. return new position_1.Position(lineNumber, 1);
  64073. };
  64074. WordOperations.moveWordRight = function (wordSeparators, model, position, wordNavigationType) {
  64075. var lineNumber = position.lineNumber;
  64076. var column = position.column;
  64077. var movedDown = false;
  64078. if (column === model.getLineMaxColumn(lineNumber)) {
  64079. if (lineNumber < model.getLineCount()) {
  64080. movedDown = true;
  64081. lineNumber = lineNumber + 1;
  64082. column = 1;
  64083. }
  64084. }
  64085. var nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, column));
  64086. if (wordNavigationType === 2 /* WordEnd */) {
  64087. if (nextWordOnLine && nextWordOnLine.wordType === 2 /* Separator */) {
  64088. if (nextWordOnLine.end - nextWordOnLine.start === 1 && nextWordOnLine.nextCharClass === 0 /* Regular */) {
  64089. // Skip over a word made up of one single separator and followed by a regular character
  64090. nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, nextWordOnLine.end + 1));
  64091. }
  64092. }
  64093. if (nextWordOnLine) {
  64094. column = nextWordOnLine.end + 1;
  64095. }
  64096. else {
  64097. column = model.getLineMaxColumn(lineNumber);
  64098. }
  64099. }
  64100. else if (wordNavigationType === 3 /* WordAccessibility */) {
  64101. if (movedDown) {
  64102. // If we move to the next line, pretend that the cursor is right before the first character.
  64103. // This is needed when the first word starts right at the first character - and in order not to miss it,
  64104. // we need to start before.
  64105. column = 0;
  64106. }
  64107. while (nextWordOnLine
  64108. && (nextWordOnLine.wordType === 2 /* Separator */
  64109. || nextWordOnLine.start + 1 <= column)) {
  64110. // Skip over a word made up of one single separator
  64111. // Also skip over word if it begins before current cursor position to ascertain we're moving forward at least 1 character.
  64112. nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, nextWordOnLine.end + 1));
  64113. }
  64114. if (nextWordOnLine) {
  64115. column = nextWordOnLine.start + 1;
  64116. }
  64117. else {
  64118. column = model.getLineMaxColumn(lineNumber);
  64119. }
  64120. }
  64121. else {
  64122. if (nextWordOnLine && !movedDown && column >= nextWordOnLine.start + 1) {
  64123. nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, nextWordOnLine.end + 1));
  64124. }
  64125. if (nextWordOnLine) {
  64126. column = nextWordOnLine.start + 1;
  64127. }
  64128. else {
  64129. column = model.getLineMaxColumn(lineNumber);
  64130. }
  64131. }
  64132. return new position_1.Position(lineNumber, column);
  64133. };
  64134. WordOperations._moveWordPartRight = function (model, position) {
  64135. var lineNumber = position.lineNumber;
  64136. var maxColumn = model.getLineMaxColumn(lineNumber);
  64137. if (position.column === maxColumn) {
  64138. return (lineNumber < model.getLineCount() ? new position_1.Position(lineNumber + 1, 1) : position);
  64139. }
  64140. var lineContent = model.getLineContent(lineNumber);
  64141. for (var column = position.column + 1; column < maxColumn; column++) {
  64142. var left = lineContent.charCodeAt(column - 2);
  64143. var right = lineContent.charCodeAt(column - 1);
  64144. if (left === 95 /* Underline */ && right !== 95 /* Underline */) {
  64145. // snake_case_variables
  64146. return new position_1.Position(lineNumber, column);
  64147. }
  64148. if (strings.isLowerAsciiLetter(left) && strings.isUpperAsciiLetter(right)) {
  64149. // camelCaseVariables
  64150. return new position_1.Position(lineNumber, column);
  64151. }
  64152. if (strings.isUpperAsciiLetter(left) && strings.isUpperAsciiLetter(right)) {
  64153. // thisIsACamelCaseWithOneLetterWords
  64154. if (column + 1 < maxColumn) {
  64155. var rightRight = lineContent.charCodeAt(column);
  64156. if (strings.isLowerAsciiLetter(rightRight)) {
  64157. return new position_1.Position(lineNumber, column);
  64158. }
  64159. }
  64160. }
  64161. }
  64162. return new position_1.Position(lineNumber, maxColumn);
  64163. };
  64164. WordOperations._deleteWordLeftWhitespace = function (model, position) {
  64165. var lineContent = model.getLineContent(position.lineNumber);
  64166. var startIndex = position.column - 2;
  64167. var lastNonWhitespace = strings.lastNonWhitespaceIndex(lineContent, startIndex);
  64168. if (lastNonWhitespace + 1 < startIndex) {
  64169. return new range_1.Range(position.lineNumber, lastNonWhitespace + 2, position.lineNumber, position.column);
  64170. }
  64171. return null;
  64172. };
  64173. WordOperations.deleteWordLeft = function (wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType) {
  64174. if (!selection.isEmpty()) {
  64175. return selection;
  64176. }
  64177. var position = new position_1.Position(selection.positionLineNumber, selection.positionColumn);
  64178. var lineNumber = position.lineNumber;
  64179. var column = position.column;
  64180. if (lineNumber === 1 && column === 1) {
  64181. // Ignore deleting at beginning of file
  64182. return null;
  64183. }
  64184. if (whitespaceHeuristics) {
  64185. var r = this._deleteWordLeftWhitespace(model, position);
  64186. if (r) {
  64187. return r;
  64188. }
  64189. }
  64190. var prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, position);
  64191. if (wordNavigationType === 0 /* WordStart */) {
  64192. if (prevWordOnLine) {
  64193. column = prevWordOnLine.start + 1;
  64194. }
  64195. else {
  64196. if (column > 1) {
  64197. column = 1;
  64198. }
  64199. else {
  64200. lineNumber--;
  64201. column = model.getLineMaxColumn(lineNumber);
  64202. }
  64203. }
  64204. }
  64205. else {
  64206. if (prevWordOnLine && column <= prevWordOnLine.end + 1) {
  64207. prevWordOnLine = WordOperations._findPreviousWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, prevWordOnLine.start + 1));
  64208. }
  64209. if (prevWordOnLine) {
  64210. column = prevWordOnLine.end + 1;
  64211. }
  64212. else {
  64213. if (column > 1) {
  64214. column = 1;
  64215. }
  64216. else {
  64217. lineNumber--;
  64218. column = model.getLineMaxColumn(lineNumber);
  64219. }
  64220. }
  64221. }
  64222. return new range_1.Range(lineNumber, column, position.lineNumber, position.column);
  64223. };
  64224. WordOperations._deleteWordPartLeft = function (model, selection) {
  64225. if (!selection.isEmpty()) {
  64226. return selection;
  64227. }
  64228. var pos = selection.getPosition();
  64229. var toPosition = WordOperations._moveWordPartLeft(model, pos);
  64230. return new range_1.Range(pos.lineNumber, pos.column, toPosition.lineNumber, toPosition.column);
  64231. };
  64232. WordOperations._findFirstNonWhitespaceChar = function (str, startIndex) {
  64233. var len = str.length;
  64234. for (var chIndex = startIndex; chIndex < len; chIndex++) {
  64235. var ch = str.charAt(chIndex);
  64236. if (ch !== ' ' && ch !== '\t') {
  64237. return chIndex;
  64238. }
  64239. }
  64240. return len;
  64241. };
  64242. WordOperations._deleteWordRightWhitespace = function (model, position) {
  64243. var lineContent = model.getLineContent(position.lineNumber);
  64244. var startIndex = position.column - 1;
  64245. var firstNonWhitespace = this._findFirstNonWhitespaceChar(lineContent, startIndex);
  64246. if (startIndex + 1 < firstNonWhitespace) {
  64247. // bingo
  64248. return new range_1.Range(position.lineNumber, position.column, position.lineNumber, firstNonWhitespace + 1);
  64249. }
  64250. return null;
  64251. };
  64252. WordOperations.deleteWordRight = function (wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType) {
  64253. if (!selection.isEmpty()) {
  64254. return selection;
  64255. }
  64256. var position = new position_1.Position(selection.positionLineNumber, selection.positionColumn);
  64257. var lineNumber = position.lineNumber;
  64258. var column = position.column;
  64259. var lineCount = model.getLineCount();
  64260. var maxColumn = model.getLineMaxColumn(lineNumber);
  64261. if (lineNumber === lineCount && column === maxColumn) {
  64262. // Ignore deleting at end of file
  64263. return null;
  64264. }
  64265. if (whitespaceHeuristics) {
  64266. var r = this._deleteWordRightWhitespace(model, position);
  64267. if (r) {
  64268. return r;
  64269. }
  64270. }
  64271. var nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, position);
  64272. if (wordNavigationType === 2 /* WordEnd */) {
  64273. if (nextWordOnLine) {
  64274. column = nextWordOnLine.end + 1;
  64275. }
  64276. else {
  64277. if (column < maxColumn || lineNumber === lineCount) {
  64278. column = maxColumn;
  64279. }
  64280. else {
  64281. lineNumber++;
  64282. nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, 1));
  64283. if (nextWordOnLine) {
  64284. column = nextWordOnLine.start + 1;
  64285. }
  64286. else {
  64287. column = model.getLineMaxColumn(lineNumber);
  64288. }
  64289. }
  64290. }
  64291. }
  64292. else {
  64293. if (nextWordOnLine && column >= nextWordOnLine.start + 1) {
  64294. nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, nextWordOnLine.end + 1));
  64295. }
  64296. if (nextWordOnLine) {
  64297. column = nextWordOnLine.start + 1;
  64298. }
  64299. else {
  64300. if (column < maxColumn || lineNumber === lineCount) {
  64301. column = maxColumn;
  64302. }
  64303. else {
  64304. lineNumber++;
  64305. nextWordOnLine = WordOperations._findNextWordOnLine(wordSeparators, model, new position_1.Position(lineNumber, 1));
  64306. if (nextWordOnLine) {
  64307. column = nextWordOnLine.start + 1;
  64308. }
  64309. else {
  64310. column = model.getLineMaxColumn(lineNumber);
  64311. }
  64312. }
  64313. }
  64314. }
  64315. return new range_1.Range(lineNumber, column, position.lineNumber, position.column);
  64316. };
  64317. WordOperations._deleteWordPartRight = function (model, selection) {
  64318. if (!selection.isEmpty()) {
  64319. return selection;
  64320. }
  64321. var pos = selection.getPosition();
  64322. var toPosition = WordOperations._moveWordPartRight(model, pos);
  64323. return new range_1.Range(pos.lineNumber, pos.column, toPosition.lineNumber, toPosition.column);
  64324. };
  64325. WordOperations.word = function (config, model, cursor, inSelectionMode, position) {
  64326. var wordSeparators = wordCharacterClassifier_1.getMapForWordSeparators(config.wordSeparators);
  64327. var prevWord = WordOperations._findPreviousWordOnLine(wordSeparators, model, position);
  64328. var nextWord = WordOperations._findNextWordOnLine(wordSeparators, model, position);
  64329. if (!inSelectionMode) {
  64330. // Entering word selection for the first time
  64331. var startColumn_1;
  64332. var endColumn_1;
  64333. if (prevWord && prevWord.wordType === 1 /* Regular */ && prevWord.start <= position.column - 1 && position.column - 1 <= prevWord.end) {
  64334. // isTouchingPrevWord
  64335. startColumn_1 = prevWord.start + 1;
  64336. endColumn_1 = prevWord.end + 1;
  64337. }
  64338. else if (nextWord && nextWord.wordType === 1 /* Regular */ && nextWord.start <= position.column - 1 && position.column - 1 <= nextWord.end) {
  64339. // isTouchingNextWord
  64340. startColumn_1 = nextWord.start + 1;
  64341. endColumn_1 = nextWord.end + 1;
  64342. }
  64343. else {
  64344. if (prevWord) {
  64345. startColumn_1 = prevWord.end + 1;
  64346. }
  64347. else {
  64348. startColumn_1 = 1;
  64349. }
  64350. if (nextWord) {
  64351. endColumn_1 = nextWord.start + 1;
  64352. }
  64353. else {
  64354. endColumn_1 = model.getLineMaxColumn(position.lineNumber);
  64355. }
  64356. }
  64357. return new cursorCommon_1.SingleCursorState(new range_1.Range(position.lineNumber, startColumn_1, position.lineNumber, endColumn_1), 0, new position_1.Position(position.lineNumber, endColumn_1), 0);
  64358. }
  64359. var startColumn;
  64360. var endColumn;
  64361. if (prevWord && prevWord.wordType === 1 /* Regular */ && prevWord.start < position.column - 1 && position.column - 1 < prevWord.end) {
  64362. // isInsidePrevWord
  64363. startColumn = prevWord.start + 1;
  64364. endColumn = prevWord.end + 1;
  64365. }
  64366. else if (nextWord && nextWord.wordType === 1 /* Regular */ && nextWord.start < position.column - 1 && position.column - 1 < nextWord.end) {
  64367. // isInsideNextWord
  64368. startColumn = nextWord.start + 1;
  64369. endColumn = nextWord.end + 1;
  64370. }
  64371. else {
  64372. startColumn = position.column;
  64373. endColumn = position.column;
  64374. }
  64375. var lineNumber = position.lineNumber;
  64376. var column;
  64377. if (cursor.selectionStart.containsPosition(position)) {
  64378. column = cursor.selectionStart.endColumn;
  64379. }
  64380. else if (position.isBeforeOrEqual(cursor.selectionStart.getStartPosition())) {
  64381. column = startColumn;
  64382. var possiblePosition = new position_1.Position(lineNumber, column);
  64383. if (cursor.selectionStart.containsPosition(possiblePosition)) {
  64384. column = cursor.selectionStart.endColumn;
  64385. }
  64386. }
  64387. else {
  64388. column = endColumn;
  64389. var possiblePosition = new position_1.Position(lineNumber, column);
  64390. if (cursor.selectionStart.containsPosition(possiblePosition)) {
  64391. column = cursor.selectionStart.startColumn;
  64392. }
  64393. }
  64394. return cursor.move(true, lineNumber, column, 0);
  64395. };
  64396. return WordOperations;
  64397. }());
  64398. exports.WordOperations = WordOperations;
  64399. var WordPartOperations = /** @class */ (function (_super) {
  64400. __extends(WordPartOperations, _super);
  64401. function WordPartOperations() {
  64402. return _super !== null && _super.apply(this, arguments) || this;
  64403. }
  64404. WordPartOperations.deleteWordPartLeft = function (wordSeparators, model, selection, whitespaceHeuristics) {
  64405. var candidates = enforceDefined([
  64406. WordOperations.deleteWordLeft(wordSeparators, model, selection, whitespaceHeuristics, 0 /* WordStart */),
  64407. WordOperations.deleteWordLeft(wordSeparators, model, selection, whitespaceHeuristics, 2 /* WordEnd */),
  64408. WordOperations._deleteWordPartLeft(model, selection)
  64409. ]);
  64410. candidates.sort(range_1.Range.compareRangesUsingEnds);
  64411. return candidates[2];
  64412. };
  64413. WordPartOperations.deleteWordPartRight = function (wordSeparators, model, selection, whitespaceHeuristics) {
  64414. var candidates = enforceDefined([
  64415. WordOperations.deleteWordRight(wordSeparators, model, selection, whitespaceHeuristics, 0 /* WordStart */),
  64416. WordOperations.deleteWordRight(wordSeparators, model, selection, whitespaceHeuristics, 2 /* WordEnd */),
  64417. WordOperations._deleteWordPartRight(model, selection)
  64418. ]);
  64419. candidates.sort(range_1.Range.compareRangesUsingStarts);
  64420. return candidates[0];
  64421. };
  64422. WordPartOperations.moveWordPartLeft = function (wordSeparators, model, position) {
  64423. var candidates = enforceDefined([
  64424. WordOperations.moveWordLeft(wordSeparators, model, position, 0 /* WordStart */),
  64425. WordOperations.moveWordLeft(wordSeparators, model, position, 2 /* WordEnd */),
  64426. WordOperations._moveWordPartLeft(model, position)
  64427. ]);
  64428. candidates.sort(position_1.Position.compare);
  64429. return candidates[2];
  64430. };
  64431. WordPartOperations.moveWordPartRight = function (wordSeparators, model, position) {
  64432. var candidates = enforceDefined([
  64433. WordOperations.moveWordRight(wordSeparators, model, position, 0 /* WordStart */),
  64434. WordOperations.moveWordRight(wordSeparators, model, position, 2 /* WordEnd */),
  64435. WordOperations._moveWordPartRight(model, position)
  64436. ]);
  64437. candidates.sort(position_1.Position.compare);
  64438. return candidates[0];
  64439. };
  64440. return WordPartOperations;
  64441. }(WordOperations));
  64442. exports.WordPartOperations = WordPartOperations;
  64443. function enforceDefined(arr) {
  64444. return arr.filter(function (el) { return Boolean(el); });
  64445. }
  64446. });
  64447. /*---------------------------------------------------------------------------------------------
  64448. * Copyright (c) Microsoft Corporation. All rights reserved.
  64449. * Licensed under the MIT License. See License.txt in the project root for license information.
  64450. *--------------------------------------------------------------------------------------------*/
  64451. define(__m[213/*vs/editor/common/controller/cursorMoveCommands*/], __M([0/*require*/,1/*exports*/,21/*vs/base/common/types*/,40/*vs/editor/common/controller/cursorCommon*/,158/*vs/editor/common/controller/cursorMoveOperations*/,160/*vs/editor/common/controller/cursorWordOperations*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/]), function (require, exports, types, cursorCommon_1, cursorMoveOperations_1, cursorWordOperations_1, position_1, range_1) {
  64452. "use strict";
  64453. Object.defineProperty(exports, "__esModule", { value: true });
  64454. var CursorMoveCommands = /** @class */ (function () {
  64455. function CursorMoveCommands() {
  64456. }
  64457. CursorMoveCommands.addCursorDown = function (context, cursors, useLogicalLine) {
  64458. var result = [], resultLen = 0;
  64459. for (var i = 0, len = cursors.length; i < len; i++) {
  64460. var cursor = cursors[i];
  64461. result[resultLen++] = new cursorCommon_1.CursorState(cursor.modelState, cursor.viewState);
  64462. if (useLogicalLine) {
  64463. result[resultLen++] = cursorCommon_1.CursorState.fromModelState(cursorMoveOperations_1.MoveOperations.translateDown(context.config, context.model, cursor.modelState));
  64464. }
  64465. else {
  64466. result[resultLen++] = cursorCommon_1.CursorState.fromViewState(cursorMoveOperations_1.MoveOperations.translateDown(context.config, context.viewModel, cursor.viewState));
  64467. }
  64468. }
  64469. return result;
  64470. };
  64471. CursorMoveCommands.addCursorUp = function (context, cursors, useLogicalLine) {
  64472. var result = [], resultLen = 0;
  64473. for (var i = 0, len = cursors.length; i < len; i++) {
  64474. var cursor = cursors[i];
  64475. result[resultLen++] = new cursorCommon_1.CursorState(cursor.modelState, cursor.viewState);
  64476. if (useLogicalLine) {
  64477. result[resultLen++] = cursorCommon_1.CursorState.fromModelState(cursorMoveOperations_1.MoveOperations.translateUp(context.config, context.model, cursor.modelState));
  64478. }
  64479. else {
  64480. result[resultLen++] = cursorCommon_1.CursorState.fromViewState(cursorMoveOperations_1.MoveOperations.translateUp(context.config, context.viewModel, cursor.viewState));
  64481. }
  64482. }
  64483. return result;
  64484. };
  64485. CursorMoveCommands.moveToBeginningOfLine = function (context, cursors, inSelectionMode) {
  64486. var result = [];
  64487. for (var i = 0, len = cursors.length; i < len; i++) {
  64488. var cursor = cursors[i];
  64489. result[i] = this._moveToLineStart(context, cursor, inSelectionMode);
  64490. }
  64491. return result;
  64492. };
  64493. CursorMoveCommands._moveToLineStart = function (context, cursor, inSelectionMode) {
  64494. var currentViewStateColumn = cursor.viewState.position.column;
  64495. var currentModelStateColumn = cursor.modelState.position.column;
  64496. var isFirstLineOfWrappedLine = currentViewStateColumn === currentModelStateColumn;
  64497. var currentViewStatelineNumber = cursor.viewState.position.lineNumber;
  64498. var firstNonBlankColumn = context.viewModel.getLineFirstNonWhitespaceColumn(currentViewStatelineNumber);
  64499. var isBeginningOfViewLine = currentViewStateColumn === firstNonBlankColumn;
  64500. if (!isFirstLineOfWrappedLine && !isBeginningOfViewLine) {
  64501. return this._moveToLineStartByView(context, cursor, inSelectionMode);
  64502. }
  64503. else {
  64504. return this._moveToLineStartByModel(context, cursor, inSelectionMode);
  64505. }
  64506. };
  64507. CursorMoveCommands._moveToLineStartByView = function (context, cursor, inSelectionMode) {
  64508. return cursorCommon_1.CursorState.fromViewState(cursorMoveOperations_1.MoveOperations.moveToBeginningOfLine(context.config, context.viewModel, cursor.viewState, inSelectionMode));
  64509. };
  64510. CursorMoveCommands._moveToLineStartByModel = function (context, cursor, inSelectionMode) {
  64511. return cursorCommon_1.CursorState.fromModelState(cursorMoveOperations_1.MoveOperations.moveToBeginningOfLine(context.config, context.model, cursor.modelState, inSelectionMode));
  64512. };
  64513. CursorMoveCommands.moveToEndOfLine = function (context, cursors, inSelectionMode) {
  64514. var result = [];
  64515. for (var i = 0, len = cursors.length; i < len; i++) {
  64516. var cursor = cursors[i];
  64517. result[i] = this._moveToLineEnd(context, cursor, inSelectionMode);
  64518. }
  64519. return result;
  64520. };
  64521. CursorMoveCommands._moveToLineEnd = function (context, cursor, inSelectionMode) {
  64522. var viewStatePosition = cursor.viewState.position;
  64523. var viewModelMaxColumn = context.viewModel.getLineMaxColumn(viewStatePosition.lineNumber);
  64524. var isEndOfViewLine = viewStatePosition.column === viewModelMaxColumn;
  64525. var modelStatePosition = cursor.modelState.position;
  64526. var modelMaxColumn = context.model.getLineMaxColumn(modelStatePosition.lineNumber);
  64527. var isEndLineOfWrappedLine = viewModelMaxColumn - viewStatePosition.column === modelMaxColumn - modelStatePosition.column;
  64528. if (isEndOfViewLine || isEndLineOfWrappedLine) {
  64529. return this._moveToLineEndByModel(context, cursor, inSelectionMode);
  64530. }
  64531. else {
  64532. return this._moveToLineEndByView(context, cursor, inSelectionMode);
  64533. }
  64534. };
  64535. CursorMoveCommands._moveToLineEndByView = function (context, cursor, inSelectionMode) {
  64536. return cursorCommon_1.CursorState.fromViewState(cursorMoveOperations_1.MoveOperations.moveToEndOfLine(context.config, context.viewModel, cursor.viewState, inSelectionMode));
  64537. };
  64538. CursorMoveCommands._moveToLineEndByModel = function (context, cursor, inSelectionMode) {
  64539. return cursorCommon_1.CursorState.fromModelState(cursorMoveOperations_1.MoveOperations.moveToEndOfLine(context.config, context.model, cursor.modelState, inSelectionMode));
  64540. };
  64541. CursorMoveCommands.expandLineSelection = function (context, cursors) {
  64542. var result = [];
  64543. for (var i = 0, len = cursors.length; i < len; i++) {
  64544. var cursor = cursors[i];
  64545. var startLineNumber = cursor.modelState.selection.startLineNumber;
  64546. var lineCount = context.model.getLineCount();
  64547. var endLineNumber = cursor.modelState.selection.endLineNumber;
  64548. var endColumn = void 0;
  64549. if (endLineNumber === lineCount) {
  64550. endColumn = context.model.getLineMaxColumn(lineCount);
  64551. }
  64552. else {
  64553. endLineNumber++;
  64554. endColumn = 1;
  64555. }
  64556. result[i] = cursorCommon_1.CursorState.fromModelState(new cursorCommon_1.SingleCursorState(new range_1.Range(startLineNumber, 1, startLineNumber, 1), 0, new position_1.Position(endLineNumber, endColumn), 0));
  64557. }
  64558. return result;
  64559. };
  64560. CursorMoveCommands.moveToBeginningOfBuffer = function (context, cursors, inSelectionMode) {
  64561. var result = [];
  64562. for (var i = 0, len = cursors.length; i < len; i++) {
  64563. var cursor = cursors[i];
  64564. result[i] = cursorCommon_1.CursorState.fromModelState(cursorMoveOperations_1.MoveOperations.moveToBeginningOfBuffer(context.config, context.model, cursor.modelState, inSelectionMode));
  64565. }
  64566. return result;
  64567. };
  64568. CursorMoveCommands.moveToEndOfBuffer = function (context, cursors, inSelectionMode) {
  64569. var result = [];
  64570. for (var i = 0, len = cursors.length; i < len; i++) {
  64571. var cursor = cursors[i];
  64572. result[i] = cursorCommon_1.CursorState.fromModelState(cursorMoveOperations_1.MoveOperations.moveToEndOfBuffer(context.config, context.model, cursor.modelState, inSelectionMode));
  64573. }
  64574. return result;
  64575. };
  64576. CursorMoveCommands.selectAll = function (context, cursor) {
  64577. var lineCount = context.model.getLineCount();
  64578. var maxColumn = context.model.getLineMaxColumn(lineCount);
  64579. return cursorCommon_1.CursorState.fromModelState(new cursorCommon_1.SingleCursorState(new range_1.Range(1, 1, 1, 1), 0, new position_1.Position(lineCount, maxColumn), 0));
  64580. };
  64581. CursorMoveCommands.line = function (context, cursor, inSelectionMode, _position, _viewPosition) {
  64582. var position = context.model.validatePosition(_position);
  64583. var viewPosition = (_viewPosition
  64584. ? context.validateViewPosition(new position_1.Position(_viewPosition.lineNumber, _viewPosition.column), position)
  64585. : context.convertModelPositionToViewPosition(position));
  64586. if (!inSelectionMode || !cursor.modelState.hasSelection()) {
  64587. // Entering line selection for the first time
  64588. var lineCount = context.model.getLineCount();
  64589. var selectToLineNumber = position.lineNumber + 1;
  64590. var selectToColumn = 1;
  64591. if (selectToLineNumber > lineCount) {
  64592. selectToLineNumber = lineCount;
  64593. selectToColumn = context.model.getLineMaxColumn(selectToLineNumber);
  64594. }
  64595. return cursorCommon_1.CursorState.fromModelState(new cursorCommon_1.SingleCursorState(new range_1.Range(position.lineNumber, 1, selectToLineNumber, selectToColumn), 0, new position_1.Position(selectToLineNumber, selectToColumn), 0));
  64596. }
  64597. // Continuing line selection
  64598. var enteringLineNumber = cursor.modelState.selectionStart.getStartPosition().lineNumber;
  64599. if (position.lineNumber < enteringLineNumber) {
  64600. return cursorCommon_1.CursorState.fromViewState(cursor.viewState.move(cursor.modelState.hasSelection(), viewPosition.lineNumber, 1, 0));
  64601. }
  64602. else if (position.lineNumber > enteringLineNumber) {
  64603. var lineCount = context.viewModel.getLineCount();
  64604. var selectToViewLineNumber = viewPosition.lineNumber + 1;
  64605. var selectToViewColumn = 1;
  64606. if (selectToViewLineNumber > lineCount) {
  64607. selectToViewLineNumber = lineCount;
  64608. selectToViewColumn = context.viewModel.getLineMaxColumn(selectToViewLineNumber);
  64609. }
  64610. return cursorCommon_1.CursorState.fromViewState(cursor.viewState.move(cursor.modelState.hasSelection(), selectToViewLineNumber, selectToViewColumn, 0));
  64611. }
  64612. else {
  64613. var endPositionOfSelectionStart = cursor.modelState.selectionStart.getEndPosition();
  64614. return cursorCommon_1.CursorState.fromModelState(cursor.modelState.move(cursor.modelState.hasSelection(), endPositionOfSelectionStart.lineNumber, endPositionOfSelectionStart.column, 0));
  64615. }
  64616. };
  64617. CursorMoveCommands.word = function (context, cursor, inSelectionMode, _position) {
  64618. var position = context.model.validatePosition(_position);
  64619. return cursorCommon_1.CursorState.fromModelState(cursorWordOperations_1.WordOperations.word(context.config, context.model, cursor.modelState, inSelectionMode, position));
  64620. };
  64621. CursorMoveCommands.cancelSelection = function (context, cursor) {
  64622. if (!cursor.modelState.hasSelection()) {
  64623. return new cursorCommon_1.CursorState(cursor.modelState, cursor.viewState);
  64624. }
  64625. var lineNumber = cursor.viewState.position.lineNumber;
  64626. var column = cursor.viewState.position.column;
  64627. return cursorCommon_1.CursorState.fromViewState(new cursorCommon_1.SingleCursorState(new range_1.Range(lineNumber, column, lineNumber, column), 0, new position_1.Position(lineNumber, column), 0));
  64628. };
  64629. CursorMoveCommands.moveTo = function (context, cursor, inSelectionMode, _position, _viewPosition) {
  64630. var position = context.model.validatePosition(_position);
  64631. var viewPosition = (_viewPosition
  64632. ? context.validateViewPosition(new position_1.Position(_viewPosition.lineNumber, _viewPosition.column), position)
  64633. : context.convertModelPositionToViewPosition(position));
  64634. return cursorCommon_1.CursorState.fromViewState(cursor.viewState.move(inSelectionMode, viewPosition.lineNumber, viewPosition.column, 0));
  64635. };
  64636. CursorMoveCommands.move = function (context, cursors, args) {
  64637. var inSelectionMode = args.select;
  64638. var value = args.value;
  64639. switch (args.direction) {
  64640. case 0 /* Left */: {
  64641. if (args.unit === 4 /* HalfLine */) {
  64642. // Move left by half the current line length
  64643. return this._moveHalfLineLeft(context, cursors, inSelectionMode);
  64644. }
  64645. else {
  64646. // Move left by `moveParams.value` columns
  64647. return this._moveLeft(context, cursors, inSelectionMode, value);
  64648. }
  64649. }
  64650. case 1 /* Right */: {
  64651. if (args.unit === 4 /* HalfLine */) {
  64652. // Move right by half the current line length
  64653. return this._moveHalfLineRight(context, cursors, inSelectionMode);
  64654. }
  64655. else {
  64656. // Move right by `moveParams.value` columns
  64657. return this._moveRight(context, cursors, inSelectionMode, value);
  64658. }
  64659. }
  64660. case 2 /* Up */: {
  64661. if (args.unit === 2 /* WrappedLine */) {
  64662. // Move up by view lines
  64663. return this._moveUpByViewLines(context, cursors, inSelectionMode, value);
  64664. }
  64665. else {
  64666. // Move up by model lines
  64667. return this._moveUpByModelLines(context, cursors, inSelectionMode, value);
  64668. }
  64669. }
  64670. case 3 /* Down */: {
  64671. if (args.unit === 2 /* WrappedLine */) {
  64672. // Move down by view lines
  64673. return this._moveDownByViewLines(context, cursors, inSelectionMode, value);
  64674. }
  64675. else {
  64676. // Move down by model lines
  64677. return this._moveDownByModelLines(context, cursors, inSelectionMode, value);
  64678. }
  64679. }
  64680. case 4 /* WrappedLineStart */: {
  64681. // Move to the beginning of the current view line
  64682. return this._moveToViewMinColumn(context, cursors, inSelectionMode);
  64683. }
  64684. case 5 /* WrappedLineFirstNonWhitespaceCharacter */: {
  64685. // Move to the first non-whitespace column of the current view line
  64686. return this._moveToViewFirstNonWhitespaceColumn(context, cursors, inSelectionMode);
  64687. }
  64688. case 6 /* WrappedLineColumnCenter */: {
  64689. // Move to the "center" of the current view line
  64690. return this._moveToViewCenterColumn(context, cursors, inSelectionMode);
  64691. }
  64692. case 7 /* WrappedLineEnd */: {
  64693. // Move to the end of the current view line
  64694. return this._moveToViewMaxColumn(context, cursors, inSelectionMode);
  64695. }
  64696. case 8 /* WrappedLineLastNonWhitespaceCharacter */: {
  64697. // Move to the last non-whitespace column of the current view line
  64698. return this._moveToViewLastNonWhitespaceColumn(context, cursors, inSelectionMode);
  64699. }
  64700. case 9 /* ViewPortTop */: {
  64701. // Move to the nth line start in the viewport (from the top)
  64702. var cursor = cursors[0];
  64703. var visibleModelRange = context.getCompletelyVisibleModelRange();
  64704. var modelLineNumber = this._firstLineNumberInRange(context.model, visibleModelRange, value);
  64705. var modelColumn = context.model.getLineFirstNonWhitespaceColumn(modelLineNumber);
  64706. return [this._moveToModelPosition(context, cursor, inSelectionMode, modelLineNumber, modelColumn)];
  64707. }
  64708. case 11 /* ViewPortBottom */: {
  64709. // Move to the nth line start in the viewport (from the bottom)
  64710. var cursor = cursors[0];
  64711. var visibleModelRange = context.getCompletelyVisibleModelRange();
  64712. var modelLineNumber = this._lastLineNumberInRange(context.model, visibleModelRange, value);
  64713. var modelColumn = context.model.getLineFirstNonWhitespaceColumn(modelLineNumber);
  64714. return [this._moveToModelPosition(context, cursor, inSelectionMode, modelLineNumber, modelColumn)];
  64715. }
  64716. case 10 /* ViewPortCenter */: {
  64717. // Move to the line start in the viewport center
  64718. var cursor = cursors[0];
  64719. var visibleModelRange = context.getCompletelyVisibleModelRange();
  64720. var modelLineNumber = Math.round((visibleModelRange.startLineNumber + visibleModelRange.endLineNumber) / 2);
  64721. var modelColumn = context.model.getLineFirstNonWhitespaceColumn(modelLineNumber);
  64722. return [this._moveToModelPosition(context, cursor, inSelectionMode, modelLineNumber, modelColumn)];
  64723. }
  64724. case 12 /* ViewPortIfOutside */: {
  64725. // Move to a position inside the viewport
  64726. var visibleViewRange = context.getCompletelyVisibleViewRange();
  64727. var result = [];
  64728. for (var i = 0, len = cursors.length; i < len; i++) {
  64729. var cursor = cursors[i];
  64730. result[i] = this.findPositionInViewportIfOutside(context, cursor, visibleViewRange, inSelectionMode);
  64731. }
  64732. return result;
  64733. }
  64734. }
  64735. return null;
  64736. };
  64737. CursorMoveCommands.findPositionInViewportIfOutside = function (context, cursor, visibleViewRange, inSelectionMode) {
  64738. var viewLineNumber = cursor.viewState.position.lineNumber;
  64739. if (visibleViewRange.startLineNumber <= viewLineNumber && viewLineNumber <= visibleViewRange.endLineNumber - 1) {
  64740. // Nothing to do, cursor is in viewport
  64741. return new cursorCommon_1.CursorState(cursor.modelState, cursor.viewState);
  64742. }
  64743. else {
  64744. if (viewLineNumber > visibleViewRange.endLineNumber - 1) {
  64745. viewLineNumber = visibleViewRange.endLineNumber - 1;
  64746. }
  64747. if (viewLineNumber < visibleViewRange.startLineNumber) {
  64748. viewLineNumber = visibleViewRange.startLineNumber;
  64749. }
  64750. var viewColumn = context.viewModel.getLineFirstNonWhitespaceColumn(viewLineNumber);
  64751. return this._moveToViewPosition(context, cursor, inSelectionMode, viewLineNumber, viewColumn);
  64752. }
  64753. };
  64754. /**
  64755. * Find the nth line start included in the range (from the start).
  64756. */
  64757. CursorMoveCommands._firstLineNumberInRange = function (model, range, count) {
  64758. var startLineNumber = range.startLineNumber;
  64759. if (range.startColumn !== model.getLineMinColumn(startLineNumber)) {
  64760. // Move on to the second line if the first line start is not included in the range
  64761. startLineNumber++;
  64762. }
  64763. return Math.min(range.endLineNumber, startLineNumber + count - 1);
  64764. };
  64765. /**
  64766. * Find the nth line start included in the range (from the end).
  64767. */
  64768. CursorMoveCommands._lastLineNumberInRange = function (model, range, count) {
  64769. var startLineNumber = range.startLineNumber;
  64770. if (range.startColumn !== model.getLineMinColumn(startLineNumber)) {
  64771. // Move on to the second line if the first line start is not included in the range
  64772. startLineNumber++;
  64773. }
  64774. return Math.max(startLineNumber, range.endLineNumber - count + 1);
  64775. };
  64776. CursorMoveCommands._moveLeft = function (context, cursors, inSelectionMode, noOfColumns) {
  64777. var result = [];
  64778. for (var i = 0, len = cursors.length; i < len; i++) {
  64779. var cursor = cursors[i];
  64780. var newViewState = cursorMoveOperations_1.MoveOperations.moveLeft(context.config, context.viewModel, cursor.viewState, inSelectionMode, noOfColumns);
  64781. if (noOfColumns === 1 && newViewState.position.lineNumber !== cursor.viewState.position.lineNumber) {
  64782. // moved over to the previous view line
  64783. var newViewModelPosition = context.viewModel.coordinatesConverter.convertViewPositionToModelPosition(newViewState.position);
  64784. if (newViewModelPosition.lineNumber === cursor.modelState.position.lineNumber) {
  64785. // stayed on the same model line => pass wrapping point where 2 view positions map to a single model position
  64786. newViewState = cursorMoveOperations_1.MoveOperations.moveLeft(context.config, context.viewModel, newViewState, inSelectionMode, 1);
  64787. }
  64788. }
  64789. result[i] = cursorCommon_1.CursorState.fromViewState(newViewState);
  64790. }
  64791. return result;
  64792. };
  64793. CursorMoveCommands._moveHalfLineLeft = function (context, cursors, inSelectionMode) {
  64794. var result = [];
  64795. for (var i = 0, len = cursors.length; i < len; i++) {
  64796. var cursor = cursors[i];
  64797. var viewLineNumber = cursor.viewState.position.lineNumber;
  64798. var halfLine = Math.round(context.viewModel.getLineContent(viewLineNumber).length / 2);
  64799. result[i] = cursorCommon_1.CursorState.fromViewState(cursorMoveOperations_1.MoveOperations.moveLeft(context.config, context.viewModel, cursor.viewState, inSelectionMode, halfLine));
  64800. }
  64801. return result;
  64802. };
  64803. CursorMoveCommands._moveRight = function (context, cursors, inSelectionMode, noOfColumns) {
  64804. var result = [];
  64805. for (var i = 0, len = cursors.length; i < len; i++) {
  64806. var cursor = cursors[i];
  64807. var newViewState = cursorMoveOperations_1.MoveOperations.moveRight(context.config, context.viewModel, cursor.viewState, inSelectionMode, noOfColumns);
  64808. if (noOfColumns === 1 && newViewState.position.lineNumber !== cursor.viewState.position.lineNumber) {
  64809. // moved over to the next view line
  64810. var newViewModelPosition = context.viewModel.coordinatesConverter.convertViewPositionToModelPosition(newViewState.position);
  64811. if (newViewModelPosition.lineNumber === cursor.modelState.position.lineNumber) {
  64812. // stayed on the same model line => pass wrapping point where 2 view positions map to a single model position
  64813. newViewState = cursorMoveOperations_1.MoveOperations.moveRight(context.config, context.viewModel, newViewState, inSelectionMode, 1);
  64814. }
  64815. }
  64816. result[i] = cursorCommon_1.CursorState.fromViewState(newViewState);
  64817. }
  64818. return result;
  64819. };
  64820. CursorMoveCommands._moveHalfLineRight = function (context, cursors, inSelectionMode) {
  64821. var result = [];
  64822. for (var i = 0, len = cursors.length; i < len; i++) {
  64823. var cursor = cursors[i];
  64824. var viewLineNumber = cursor.viewState.position.lineNumber;
  64825. var halfLine = Math.round(context.viewModel.getLineContent(viewLineNumber).length / 2);
  64826. result[i] = cursorCommon_1.CursorState.fromViewState(cursorMoveOperations_1.MoveOperations.moveRight(context.config, context.viewModel, cursor.viewState, inSelectionMode, halfLine));
  64827. }
  64828. return result;
  64829. };
  64830. CursorMoveCommands._moveDownByViewLines = function (context, cursors, inSelectionMode, linesCount) {
  64831. var result = [];
  64832. for (var i = 0, len = cursors.length; i < len; i++) {
  64833. var cursor = cursors[i];
  64834. result[i] = cursorCommon_1.CursorState.fromViewState(cursorMoveOperations_1.MoveOperations.moveDown(context.config, context.viewModel, cursor.viewState, inSelectionMode, linesCount));
  64835. }
  64836. return result;
  64837. };
  64838. CursorMoveCommands._moveDownByModelLines = function (context, cursors, inSelectionMode, linesCount) {
  64839. var result = [];
  64840. for (var i = 0, len = cursors.length; i < len; i++) {
  64841. var cursor = cursors[i];
  64842. result[i] = cursorCommon_1.CursorState.fromModelState(cursorMoveOperations_1.MoveOperations.moveDown(context.config, context.model, cursor.modelState, inSelectionMode, linesCount));
  64843. }
  64844. return result;
  64845. };
  64846. CursorMoveCommands._moveUpByViewLines = function (context, cursors, inSelectionMode, linesCount) {
  64847. var result = [];
  64848. for (var i = 0, len = cursors.length; i < len; i++) {
  64849. var cursor = cursors[i];
  64850. result[i] = cursorCommon_1.CursorState.fromViewState(cursorMoveOperations_1.MoveOperations.moveUp(context.config, context.viewModel, cursor.viewState, inSelectionMode, linesCount));
  64851. }
  64852. return result;
  64853. };
  64854. CursorMoveCommands._moveUpByModelLines = function (context, cursors, inSelectionMode, linesCount) {
  64855. var result = [];
  64856. for (var i = 0, len = cursors.length; i < len; i++) {
  64857. var cursor = cursors[i];
  64858. result[i] = cursorCommon_1.CursorState.fromModelState(cursorMoveOperations_1.MoveOperations.moveUp(context.config, context.model, cursor.modelState, inSelectionMode, linesCount));
  64859. }
  64860. return result;
  64861. };
  64862. CursorMoveCommands._moveToViewPosition = function (context, cursor, inSelectionMode, toViewLineNumber, toViewColumn) {
  64863. return cursorCommon_1.CursorState.fromViewState(cursor.viewState.move(inSelectionMode, toViewLineNumber, toViewColumn, 0));
  64864. };
  64865. CursorMoveCommands._moveToModelPosition = function (context, cursor, inSelectionMode, toModelLineNumber, toModelColumn) {
  64866. return cursorCommon_1.CursorState.fromModelState(cursor.modelState.move(inSelectionMode, toModelLineNumber, toModelColumn, 0));
  64867. };
  64868. CursorMoveCommands._moveToViewMinColumn = function (context, cursors, inSelectionMode) {
  64869. var result = [];
  64870. for (var i = 0, len = cursors.length; i < len; i++) {
  64871. var cursor = cursors[i];
  64872. var viewLineNumber = cursor.viewState.position.lineNumber;
  64873. var viewColumn = context.viewModel.getLineMinColumn(viewLineNumber);
  64874. result[i] = this._moveToViewPosition(context, cursor, inSelectionMode, viewLineNumber, viewColumn);
  64875. }
  64876. return result;
  64877. };
  64878. CursorMoveCommands._moveToViewFirstNonWhitespaceColumn = function (context, cursors, inSelectionMode) {
  64879. var result = [];
  64880. for (var i = 0, len = cursors.length; i < len; i++) {
  64881. var cursor = cursors[i];
  64882. var viewLineNumber = cursor.viewState.position.lineNumber;
  64883. var viewColumn = context.viewModel.getLineFirstNonWhitespaceColumn(viewLineNumber);
  64884. result[i] = this._moveToViewPosition(context, cursor, inSelectionMode, viewLineNumber, viewColumn);
  64885. }
  64886. return result;
  64887. };
  64888. CursorMoveCommands._moveToViewCenterColumn = function (context, cursors, inSelectionMode) {
  64889. var result = [];
  64890. for (var i = 0, len = cursors.length; i < len; i++) {
  64891. var cursor = cursors[i];
  64892. var viewLineNumber = cursor.viewState.position.lineNumber;
  64893. var viewColumn = Math.round((context.viewModel.getLineMaxColumn(viewLineNumber) + context.viewModel.getLineMinColumn(viewLineNumber)) / 2);
  64894. result[i] = this._moveToViewPosition(context, cursor, inSelectionMode, viewLineNumber, viewColumn);
  64895. }
  64896. return result;
  64897. };
  64898. CursorMoveCommands._moveToViewMaxColumn = function (context, cursors, inSelectionMode) {
  64899. var result = [];
  64900. for (var i = 0, len = cursors.length; i < len; i++) {
  64901. var cursor = cursors[i];
  64902. var viewLineNumber = cursor.viewState.position.lineNumber;
  64903. var viewColumn = context.viewModel.getLineMaxColumn(viewLineNumber);
  64904. result[i] = this._moveToViewPosition(context, cursor, inSelectionMode, viewLineNumber, viewColumn);
  64905. }
  64906. return result;
  64907. };
  64908. CursorMoveCommands._moveToViewLastNonWhitespaceColumn = function (context, cursors, inSelectionMode) {
  64909. var result = [];
  64910. for (var i = 0, len = cursors.length; i < len; i++) {
  64911. var cursor = cursors[i];
  64912. var viewLineNumber = cursor.viewState.position.lineNumber;
  64913. var viewColumn = context.viewModel.getLineLastNonWhitespaceColumn(viewLineNumber);
  64914. result[i] = this._moveToViewPosition(context, cursor, inSelectionMode, viewLineNumber, viewColumn);
  64915. }
  64916. return result;
  64917. };
  64918. return CursorMoveCommands;
  64919. }());
  64920. exports.CursorMoveCommands = CursorMoveCommands;
  64921. var CursorMove;
  64922. (function (CursorMove) {
  64923. var isCursorMoveArgs = function (arg) {
  64924. if (!types.isObject(arg)) {
  64925. return false;
  64926. }
  64927. var cursorMoveArg = arg;
  64928. if (!types.isString(cursorMoveArg.to)) {
  64929. return false;
  64930. }
  64931. if (!types.isUndefined(cursorMoveArg.select) && !types.isBoolean(cursorMoveArg.select)) {
  64932. return false;
  64933. }
  64934. if (!types.isUndefined(cursorMoveArg.by) && !types.isString(cursorMoveArg.by)) {
  64935. return false;
  64936. }
  64937. if (!types.isUndefined(cursorMoveArg.value) && !types.isNumber(cursorMoveArg.value)) {
  64938. return false;
  64939. }
  64940. return true;
  64941. };
  64942. CursorMove.description = {
  64943. description: 'Move cursor to a logical position in the view',
  64944. args: [
  64945. {
  64946. name: 'Cursor move argument object',
  64947. description: "Property-value pairs that can be passed through this argument:\n\t\t\t\t\t* 'to': A mandatory logical position value providing where to move the cursor.\n\t\t\t\t\t\t```\n\t\t\t\t\t\t'left', 'right', 'up', 'down'\n\t\t\t\t\t\t'wrappedLineStart', 'wrappedLineEnd', 'wrappedLineColumnCenter'\n\t\t\t\t\t\t'wrappedLineFirstNonWhitespaceCharacter', 'wrappedLineLastNonWhitespaceCharacter'\n\t\t\t\t\t\t'viewPortTop', 'viewPortCenter', 'viewPortBottom', 'viewPortIfOutside'\n\t\t\t\t\t\t```\n\t\t\t\t\t* 'by': Unit to move. Default is computed based on 'to' value.\n\t\t\t\t\t\t```\n\t\t\t\t\t\t'line', 'wrappedLine', 'character', 'halfLine'\n\t\t\t\t\t\t```\n\t\t\t\t\t* 'value': Number of units to move. Default is '1'.\n\t\t\t\t\t* 'select': If 'true' makes the selection. Default is 'false'.\n\t\t\t\t",
  64948. constraint: isCursorMoveArgs,
  64949. schema: {
  64950. 'type': 'object',
  64951. 'required': ['to'],
  64952. 'properties': {
  64953. 'to': {
  64954. 'type': 'string',
  64955. 'enum': ['left', 'right', 'up', 'down', 'wrappedLineStart', 'wrappedLineEnd', 'wrappedLineColumnCenter', 'wrappedLineFirstNonWhitespaceCharacter', 'wrappedLineLastNonWhitespaceCharacter', 'viewPortTop', 'viewPortCenter', 'viewPortBottom', 'viewPortIfOutside']
  64956. },
  64957. 'by': {
  64958. 'type': 'string',
  64959. 'enum': ['line', 'wrappedLine', 'character', 'halfLine']
  64960. },
  64961. 'value': {
  64962. 'type': 'number',
  64963. 'default': 1
  64964. },
  64965. 'select': {
  64966. 'type': 'boolean',
  64967. 'default': false
  64968. }
  64969. }
  64970. }
  64971. }
  64972. ]
  64973. };
  64974. /**
  64975. * Positions in the view for cursor move command.
  64976. */
  64977. CursorMove.RawDirection = {
  64978. Left: 'left',
  64979. Right: 'right',
  64980. Up: 'up',
  64981. Down: 'down',
  64982. WrappedLineStart: 'wrappedLineStart',
  64983. WrappedLineFirstNonWhitespaceCharacter: 'wrappedLineFirstNonWhitespaceCharacter',
  64984. WrappedLineColumnCenter: 'wrappedLineColumnCenter',
  64985. WrappedLineEnd: 'wrappedLineEnd',
  64986. WrappedLineLastNonWhitespaceCharacter: 'wrappedLineLastNonWhitespaceCharacter',
  64987. ViewPortTop: 'viewPortTop',
  64988. ViewPortCenter: 'viewPortCenter',
  64989. ViewPortBottom: 'viewPortBottom',
  64990. ViewPortIfOutside: 'viewPortIfOutside'
  64991. };
  64992. /**
  64993. * Units for Cursor move 'by' argument
  64994. */
  64995. CursorMove.RawUnit = {
  64996. Line: 'line',
  64997. WrappedLine: 'wrappedLine',
  64998. Character: 'character',
  64999. HalfLine: 'halfLine'
  65000. };
  65001. function parse(args) {
  65002. if (!args.to) {
  65003. // illegal arguments
  65004. return null;
  65005. }
  65006. var direction;
  65007. switch (args.to) {
  65008. case CursorMove.RawDirection.Left:
  65009. direction = 0 /* Left */;
  65010. break;
  65011. case CursorMove.RawDirection.Right:
  65012. direction = 1 /* Right */;
  65013. break;
  65014. case CursorMove.RawDirection.Up:
  65015. direction = 2 /* Up */;
  65016. break;
  65017. case CursorMove.RawDirection.Down:
  65018. direction = 3 /* Down */;
  65019. break;
  65020. case CursorMove.RawDirection.WrappedLineStart:
  65021. direction = 4 /* WrappedLineStart */;
  65022. break;
  65023. case CursorMove.RawDirection.WrappedLineFirstNonWhitespaceCharacter:
  65024. direction = 5 /* WrappedLineFirstNonWhitespaceCharacter */;
  65025. break;
  65026. case CursorMove.RawDirection.WrappedLineColumnCenter:
  65027. direction = 6 /* WrappedLineColumnCenter */;
  65028. break;
  65029. case CursorMove.RawDirection.WrappedLineEnd:
  65030. direction = 7 /* WrappedLineEnd */;
  65031. break;
  65032. case CursorMove.RawDirection.WrappedLineLastNonWhitespaceCharacter:
  65033. direction = 8 /* WrappedLineLastNonWhitespaceCharacter */;
  65034. break;
  65035. case CursorMove.RawDirection.ViewPortTop:
  65036. direction = 9 /* ViewPortTop */;
  65037. break;
  65038. case CursorMove.RawDirection.ViewPortBottom:
  65039. direction = 11 /* ViewPortBottom */;
  65040. break;
  65041. case CursorMove.RawDirection.ViewPortCenter:
  65042. direction = 10 /* ViewPortCenter */;
  65043. break;
  65044. case CursorMove.RawDirection.ViewPortIfOutside:
  65045. direction = 12 /* ViewPortIfOutside */;
  65046. break;
  65047. default:
  65048. // illegal arguments
  65049. return null;
  65050. }
  65051. var unit = 0 /* None */;
  65052. switch (args.by) {
  65053. case CursorMove.RawUnit.Line:
  65054. unit = 1 /* Line */;
  65055. break;
  65056. case CursorMove.RawUnit.WrappedLine:
  65057. unit = 2 /* WrappedLine */;
  65058. break;
  65059. case CursorMove.RawUnit.Character:
  65060. unit = 3 /* Character */;
  65061. break;
  65062. case CursorMove.RawUnit.HalfLine:
  65063. unit = 4 /* HalfLine */;
  65064. break;
  65065. }
  65066. return {
  65067. direction: direction,
  65068. unit: unit,
  65069. select: (!!args.select),
  65070. value: (args.value || 1)
  65071. };
  65072. }
  65073. CursorMove.parse = parse;
  65074. })(CursorMove = exports.CursorMove || (exports.CursorMove = {}));
  65075. });
  65076. /*---------------------------------------------------------------------------------------------
  65077. * Copyright (c) Microsoft Corporation. All rights reserved.
  65078. * Licensed under the MIT License. See License.txt in the project root for license information.
  65079. *--------------------------------------------------------------------------------------------*/
  65080. define(__m[484/*vs/editor/common/controller/oneCursor*/], __M([0/*require*/,1/*exports*/,40/*vs/editor/common/controller/cursorCommon*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/]), function (require, exports, cursorCommon_1, position_1, range_1, selection_1) {
  65081. "use strict";
  65082. Object.defineProperty(exports, "__esModule", { value: true });
  65083. var OneCursor = /** @class */ (function () {
  65084. function OneCursor(context) {
  65085. this._selTrackedRange = null;
  65086. this._trackSelection = true;
  65087. this._setState(context, new cursorCommon_1.SingleCursorState(new range_1.Range(1, 1, 1, 1), 0, new position_1.Position(1, 1), 0), new cursorCommon_1.SingleCursorState(new range_1.Range(1, 1, 1, 1), 0, new position_1.Position(1, 1), 0));
  65088. }
  65089. OneCursor.prototype.dispose = function (context) {
  65090. this._removeTrackedRange(context);
  65091. };
  65092. OneCursor.prototype.startTrackingSelection = function (context) {
  65093. this._trackSelection = true;
  65094. this._updateTrackedRange(context);
  65095. };
  65096. OneCursor.prototype.stopTrackingSelection = function (context) {
  65097. this._trackSelection = false;
  65098. this._removeTrackedRange(context);
  65099. };
  65100. OneCursor.prototype._updateTrackedRange = function (context) {
  65101. if (!this._trackSelection) {
  65102. // don't track the selection
  65103. return;
  65104. }
  65105. this._selTrackedRange = context.model._setTrackedRange(this._selTrackedRange, this.modelState.selection, 0 /* AlwaysGrowsWhenTypingAtEdges */);
  65106. };
  65107. OneCursor.prototype._removeTrackedRange = function (context) {
  65108. this._selTrackedRange = context.model._setTrackedRange(this._selTrackedRange, null, 0 /* AlwaysGrowsWhenTypingAtEdges */);
  65109. };
  65110. OneCursor.prototype.asCursorState = function () {
  65111. return new cursorCommon_1.CursorState(this.modelState, this.viewState);
  65112. };
  65113. OneCursor.prototype.readSelectionFromMarkers = function (context) {
  65114. var range = context.model._getTrackedRange(this._selTrackedRange);
  65115. if (this.modelState.selection.getDirection() === 0 /* LTR */) {
  65116. return new selection_1.Selection(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
  65117. }
  65118. return new selection_1.Selection(range.endLineNumber, range.endColumn, range.startLineNumber, range.startColumn);
  65119. };
  65120. OneCursor.prototype.ensureValidState = function (context) {
  65121. this._setState(context, this.modelState, this.viewState);
  65122. };
  65123. OneCursor.prototype.setState = function (context, modelState, viewState) {
  65124. this._setState(context, modelState, viewState);
  65125. };
  65126. OneCursor.prototype._setState = function (context, modelState, viewState) {
  65127. if (!modelState) {
  65128. if (!viewState) {
  65129. return;
  65130. }
  65131. // We only have the view state => compute the model state
  65132. var selectionStart = context.model.validateRange(context.convertViewRangeToModelRange(viewState.selectionStart));
  65133. var position = context.model.validatePosition(context.convertViewPositionToModelPosition(viewState.position.lineNumber, viewState.position.column));
  65134. modelState = new cursorCommon_1.SingleCursorState(selectionStart, viewState.selectionStartLeftoverVisibleColumns, position, viewState.leftoverVisibleColumns);
  65135. }
  65136. else {
  65137. // Validate new model state
  65138. var selectionStart = context.model.validateRange(modelState.selectionStart);
  65139. var selectionStartLeftoverVisibleColumns = modelState.selectionStart.equalsRange(selectionStart) ? modelState.selectionStartLeftoverVisibleColumns : 0;
  65140. var position = context.model.validatePosition(modelState.position);
  65141. var leftoverVisibleColumns = modelState.position.equals(position) ? modelState.leftoverVisibleColumns : 0;
  65142. modelState = new cursorCommon_1.SingleCursorState(selectionStart, selectionStartLeftoverVisibleColumns, position, leftoverVisibleColumns);
  65143. }
  65144. if (!viewState) {
  65145. // We only have the model state => compute the view state
  65146. var viewSelectionStart1 = context.convertModelPositionToViewPosition(new position_1.Position(modelState.selectionStart.startLineNumber, modelState.selectionStart.startColumn));
  65147. var viewSelectionStart2 = context.convertModelPositionToViewPosition(new position_1.Position(modelState.selectionStart.endLineNumber, modelState.selectionStart.endColumn));
  65148. var viewSelectionStart = new range_1.Range(viewSelectionStart1.lineNumber, viewSelectionStart1.column, viewSelectionStart2.lineNumber, viewSelectionStart2.column);
  65149. var viewPosition = context.convertModelPositionToViewPosition(modelState.position);
  65150. viewState = new cursorCommon_1.SingleCursorState(viewSelectionStart, modelState.selectionStartLeftoverVisibleColumns, viewPosition, modelState.leftoverVisibleColumns);
  65151. }
  65152. else {
  65153. // Validate new view state
  65154. var viewSelectionStart = context.validateViewRange(viewState.selectionStart, modelState.selectionStart);
  65155. var viewPosition = context.validateViewPosition(viewState.position, modelState.position);
  65156. viewState = new cursorCommon_1.SingleCursorState(viewSelectionStart, modelState.selectionStartLeftoverVisibleColumns, viewPosition, modelState.leftoverVisibleColumns);
  65157. }
  65158. this.modelState = modelState;
  65159. this.viewState = viewState;
  65160. this._updateTrackedRange(context);
  65161. };
  65162. return OneCursor;
  65163. }());
  65164. exports.OneCursor = OneCursor;
  65165. });
  65166. /*---------------------------------------------------------------------------------------------
  65167. * Copyright (c) Microsoft Corporation. All rights reserved.
  65168. * Licensed under the MIT License. See License.txt in the project root for license information.
  65169. *--------------------------------------------------------------------------------------------*/
  65170. define(__m[485/*vs/editor/common/controller/cursorCollection*/], __M([0/*require*/,1/*exports*/,40/*vs/editor/common/controller/cursorCommon*/,484/*vs/editor/common/controller/oneCursor*/,22/*vs/editor/common/core/selection*/]), function (require, exports, cursorCommon_1, oneCursor_1, selection_1) {
  65171. "use strict";
  65172. Object.defineProperty(exports, "__esModule", { value: true });
  65173. var CursorCollection = /** @class */ (function () {
  65174. function CursorCollection(context) {
  65175. this.context = context;
  65176. this.primaryCursor = new oneCursor_1.OneCursor(context);
  65177. this.secondaryCursors = [];
  65178. this.lastAddedCursorIndex = 0;
  65179. }
  65180. CursorCollection.prototype.dispose = function () {
  65181. this.primaryCursor.dispose(this.context);
  65182. this.killSecondaryCursors();
  65183. };
  65184. CursorCollection.prototype.startTrackingSelections = function () {
  65185. this.primaryCursor.startTrackingSelection(this.context);
  65186. for (var i = 0, len = this.secondaryCursors.length; i < len; i++) {
  65187. this.secondaryCursors[i].startTrackingSelection(this.context);
  65188. }
  65189. };
  65190. CursorCollection.prototype.stopTrackingSelections = function () {
  65191. this.primaryCursor.stopTrackingSelection(this.context);
  65192. for (var i = 0, len = this.secondaryCursors.length; i < len; i++) {
  65193. this.secondaryCursors[i].stopTrackingSelection(this.context);
  65194. }
  65195. };
  65196. CursorCollection.prototype.updateContext = function (context) {
  65197. this.context = context;
  65198. };
  65199. CursorCollection.prototype.ensureValidState = function () {
  65200. this.primaryCursor.ensureValidState(this.context);
  65201. for (var i = 0, len = this.secondaryCursors.length; i < len; i++) {
  65202. this.secondaryCursors[i].ensureValidState(this.context);
  65203. }
  65204. };
  65205. CursorCollection.prototype.readSelectionFromMarkers = function () {
  65206. var result = [];
  65207. result[0] = this.primaryCursor.readSelectionFromMarkers(this.context);
  65208. for (var i = 0, len = this.secondaryCursors.length; i < len; i++) {
  65209. result[i + 1] = this.secondaryCursors[i].readSelectionFromMarkers(this.context);
  65210. }
  65211. return result;
  65212. };
  65213. CursorCollection.prototype.getAll = function () {
  65214. var result = [];
  65215. result[0] = this.primaryCursor.asCursorState();
  65216. for (var i = 0, len = this.secondaryCursors.length; i < len; i++) {
  65217. result[i + 1] = this.secondaryCursors[i].asCursorState();
  65218. }
  65219. return result;
  65220. };
  65221. CursorCollection.prototype.getViewPositions = function () {
  65222. var result = [];
  65223. result[0] = this.primaryCursor.viewState.position;
  65224. for (var i = 0, len = this.secondaryCursors.length; i < len; i++) {
  65225. result[i + 1] = this.secondaryCursors[i].viewState.position;
  65226. }
  65227. return result;
  65228. };
  65229. CursorCollection.prototype.getSelections = function () {
  65230. var result = [];
  65231. result[0] = this.primaryCursor.modelState.selection;
  65232. for (var i = 0, len = this.secondaryCursors.length; i < len; i++) {
  65233. result[i + 1] = this.secondaryCursors[i].modelState.selection;
  65234. }
  65235. return result;
  65236. };
  65237. CursorCollection.prototype.getViewSelections = function () {
  65238. var result = [];
  65239. result[0] = this.primaryCursor.viewState.selection;
  65240. for (var i = 0, len = this.secondaryCursors.length; i < len; i++) {
  65241. result[i + 1] = this.secondaryCursors[i].viewState.selection;
  65242. }
  65243. return result;
  65244. };
  65245. CursorCollection.prototype.setSelections = function (selections) {
  65246. this.setStates(cursorCommon_1.CursorState.fromModelSelections(selections));
  65247. };
  65248. CursorCollection.prototype.getPrimaryCursor = function () {
  65249. return this.primaryCursor.asCursorState();
  65250. };
  65251. CursorCollection.prototype.setStates = function (states) {
  65252. if (states === null) {
  65253. return;
  65254. }
  65255. this.primaryCursor.setState(this.context, states[0].modelState, states[0].viewState);
  65256. this._setSecondaryStates(states.slice(1));
  65257. };
  65258. /**
  65259. * Creates or disposes secondary cursors as necessary to match the number of `secondarySelections`.
  65260. */
  65261. CursorCollection.prototype._setSecondaryStates = function (secondaryStates) {
  65262. var secondaryCursorsLength = this.secondaryCursors.length;
  65263. var secondaryStatesLength = secondaryStates.length;
  65264. if (secondaryCursorsLength < secondaryStatesLength) {
  65265. var createCnt = secondaryStatesLength - secondaryCursorsLength;
  65266. for (var i = 0; i < createCnt; i++) {
  65267. this._addSecondaryCursor();
  65268. }
  65269. }
  65270. else if (secondaryCursorsLength > secondaryStatesLength) {
  65271. var removeCnt = secondaryCursorsLength - secondaryStatesLength;
  65272. for (var i = 0; i < removeCnt; i++) {
  65273. this._removeSecondaryCursor(this.secondaryCursors.length - 1);
  65274. }
  65275. }
  65276. for (var i = 0; i < secondaryStatesLength; i++) {
  65277. this.secondaryCursors[i].setState(this.context, secondaryStates[i].modelState, secondaryStates[i].viewState);
  65278. }
  65279. };
  65280. CursorCollection.prototype.killSecondaryCursors = function () {
  65281. this._setSecondaryStates([]);
  65282. };
  65283. CursorCollection.prototype._addSecondaryCursor = function () {
  65284. this.secondaryCursors.push(new oneCursor_1.OneCursor(this.context));
  65285. this.lastAddedCursorIndex = this.secondaryCursors.length;
  65286. };
  65287. CursorCollection.prototype.getLastAddedCursorIndex = function () {
  65288. if (this.secondaryCursors.length === 0 || this.lastAddedCursorIndex === 0) {
  65289. return 0;
  65290. }
  65291. return this.lastAddedCursorIndex;
  65292. };
  65293. CursorCollection.prototype._removeSecondaryCursor = function (removeIndex) {
  65294. if (this.lastAddedCursorIndex >= removeIndex + 1) {
  65295. this.lastAddedCursorIndex--;
  65296. }
  65297. this.secondaryCursors[removeIndex].dispose(this.context);
  65298. this.secondaryCursors.splice(removeIndex, 1);
  65299. };
  65300. CursorCollection.prototype._getAll = function () {
  65301. var result = [];
  65302. result[0] = this.primaryCursor;
  65303. for (var i = 0, len = this.secondaryCursors.length; i < len; i++) {
  65304. result[i + 1] = this.secondaryCursors[i];
  65305. }
  65306. return result;
  65307. };
  65308. CursorCollection.prototype.normalize = function () {
  65309. if (this.secondaryCursors.length === 0) {
  65310. return;
  65311. }
  65312. var cursors = this._getAll();
  65313. var sortedCursors = [];
  65314. for (var i = 0, len = cursors.length; i < len; i++) {
  65315. sortedCursors.push({
  65316. index: i,
  65317. selection: cursors[i].modelState.selection,
  65318. });
  65319. }
  65320. sortedCursors.sort(function (a, b) {
  65321. if (a.selection.startLineNumber === b.selection.startLineNumber) {
  65322. return a.selection.startColumn - b.selection.startColumn;
  65323. }
  65324. return a.selection.startLineNumber - b.selection.startLineNumber;
  65325. });
  65326. for (var sortedCursorIndex = 0; sortedCursorIndex < sortedCursors.length - 1; sortedCursorIndex++) {
  65327. var current = sortedCursors[sortedCursorIndex];
  65328. var next = sortedCursors[sortedCursorIndex + 1];
  65329. var currentSelection = current.selection;
  65330. var nextSelection = next.selection;
  65331. if (!this.context.config.multiCursorMergeOverlapping) {
  65332. continue;
  65333. }
  65334. var shouldMergeCursors = void 0;
  65335. if (nextSelection.isEmpty() || currentSelection.isEmpty()) {
  65336. // Merge touching cursors if one of them is collapsed
  65337. shouldMergeCursors = nextSelection.getStartPosition().isBeforeOrEqual(currentSelection.getEndPosition());
  65338. }
  65339. else {
  65340. // Merge only overlapping cursors (i.e. allow touching ranges)
  65341. shouldMergeCursors = nextSelection.getStartPosition().isBefore(currentSelection.getEndPosition());
  65342. }
  65343. if (shouldMergeCursors) {
  65344. var winnerSortedCursorIndex = current.index < next.index ? sortedCursorIndex : sortedCursorIndex + 1;
  65345. var looserSortedCursorIndex = current.index < next.index ? sortedCursorIndex + 1 : sortedCursorIndex;
  65346. var looserIndex = sortedCursors[looserSortedCursorIndex].index;
  65347. var winnerIndex = sortedCursors[winnerSortedCursorIndex].index;
  65348. var looserSelection = sortedCursors[looserSortedCursorIndex].selection;
  65349. var winnerSelection = sortedCursors[winnerSortedCursorIndex].selection;
  65350. if (!looserSelection.equalsSelection(winnerSelection)) {
  65351. var resultingRange = looserSelection.plusRange(winnerSelection);
  65352. var looserSelectionIsLTR = (looserSelection.selectionStartLineNumber === looserSelection.startLineNumber && looserSelection.selectionStartColumn === looserSelection.startColumn);
  65353. var winnerSelectionIsLTR = (winnerSelection.selectionStartLineNumber === winnerSelection.startLineNumber && winnerSelection.selectionStartColumn === winnerSelection.startColumn);
  65354. // Give more importance to the last added cursor (think Ctrl-dragging + hitting another cursor)
  65355. var resultingSelectionIsLTR = void 0;
  65356. if (looserIndex === this.lastAddedCursorIndex) {
  65357. resultingSelectionIsLTR = looserSelectionIsLTR;
  65358. this.lastAddedCursorIndex = winnerIndex;
  65359. }
  65360. else {
  65361. // Winner takes it all
  65362. resultingSelectionIsLTR = winnerSelectionIsLTR;
  65363. }
  65364. var resultingSelection = void 0;
  65365. if (resultingSelectionIsLTR) {
  65366. resultingSelection = new selection_1.Selection(resultingRange.startLineNumber, resultingRange.startColumn, resultingRange.endLineNumber, resultingRange.endColumn);
  65367. }
  65368. else {
  65369. resultingSelection = new selection_1.Selection(resultingRange.endLineNumber, resultingRange.endColumn, resultingRange.startLineNumber, resultingRange.startColumn);
  65370. }
  65371. sortedCursors[winnerSortedCursorIndex].selection = resultingSelection;
  65372. var resultingState = cursorCommon_1.CursorState.fromModelSelection(resultingSelection);
  65373. cursors[winnerIndex].setState(this.context, resultingState.modelState, resultingState.viewState);
  65374. }
  65375. for (var _i = 0, sortedCursors_1 = sortedCursors; _i < sortedCursors_1.length; _i++) {
  65376. var sortedCursor = sortedCursors_1[_i];
  65377. if (sortedCursor.index > looserIndex) {
  65378. sortedCursor.index--;
  65379. }
  65380. }
  65381. cursors.splice(looserIndex, 1);
  65382. sortedCursors.splice(looserSortedCursorIndex, 1);
  65383. this._removeSecondaryCursor(looserIndex - 1);
  65384. sortedCursorIndex--;
  65385. }
  65386. }
  65387. };
  65388. return CursorCollection;
  65389. }());
  65390. exports.CursorCollection = CursorCollection;
  65391. });
  65392. /*---------------------------------------------------------------------------------------------
  65393. * Copyright (c) Microsoft Corporation. All rights reserved.
  65394. * Licensed under the MIT License. See License.txt in the project root for license information.
  65395. *--------------------------------------------------------------------------------------------*/
  65396. define(__m[486/*vs/editor/common/controller/cursor*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,4/*vs/base/common/event*/,5/*vs/base/common/strings*/,485/*vs/editor/common/controller/cursorCollection*/,40/*vs/editor/common/controller/cursorCommon*/,212/*vs/editor/common/controller/cursorDeleteOperations*/,159/*vs/editor/common/controller/cursorTypeOperations*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,68/*vs/editor/common/editorCommon*/,81/*vs/editor/common/view/viewEvents*/,2/*vs/base/common/lifecycle*/]), function (require, exports, errors_1, event_1, strings, cursorCollection_1, cursorCommon_1, cursorDeleteOperations_1, cursorTypeOperations_1, range_1, selection_1, editorCommon, viewEvents, lifecycle_1) {
  65397. "use strict";
  65398. Object.defineProperty(exports, "__esModule", { value: true });
  65399. function containsLineMappingChanged(events) {
  65400. for (var i = 0, len = events.length; i < len; i++) {
  65401. if (events[i].type === 8 /* ViewLineMappingChanged */) {
  65402. return true;
  65403. }
  65404. }
  65405. return false;
  65406. }
  65407. var CursorStateChangedEvent = /** @class */ (function () {
  65408. function CursorStateChangedEvent(selections, modelVersionId, oldSelections, oldModelVersionId, source, reason) {
  65409. this.selections = selections;
  65410. this.modelVersionId = modelVersionId;
  65411. this.oldSelections = oldSelections;
  65412. this.oldModelVersionId = oldModelVersionId;
  65413. this.source = source;
  65414. this.reason = reason;
  65415. }
  65416. return CursorStateChangedEvent;
  65417. }());
  65418. exports.CursorStateChangedEvent = CursorStateChangedEvent;
  65419. /**
  65420. * A snapshot of the cursor and the model state
  65421. */
  65422. var CursorModelState = /** @class */ (function () {
  65423. function CursorModelState(model, cursor) {
  65424. this.modelVersionId = model.getVersionId();
  65425. this.cursorState = cursor.getAll();
  65426. }
  65427. CursorModelState.prototype.equals = function (other) {
  65428. if (!other) {
  65429. return false;
  65430. }
  65431. if (this.modelVersionId !== other.modelVersionId) {
  65432. return false;
  65433. }
  65434. if (this.cursorState.length !== other.cursorState.length) {
  65435. return false;
  65436. }
  65437. for (var i = 0, len = this.cursorState.length; i < len; i++) {
  65438. if (!this.cursorState[i].equals(other.cursorState[i])) {
  65439. return false;
  65440. }
  65441. }
  65442. return true;
  65443. };
  65444. return CursorModelState;
  65445. }());
  65446. exports.CursorModelState = CursorModelState;
  65447. var AutoClosedAction = /** @class */ (function () {
  65448. function AutoClosedAction(model, autoClosedCharactersDecorations, autoClosedEnclosingDecorations) {
  65449. this._model = model;
  65450. this._autoClosedCharactersDecorations = autoClosedCharactersDecorations;
  65451. this._autoClosedEnclosingDecorations = autoClosedEnclosingDecorations;
  65452. }
  65453. AutoClosedAction.getAllAutoClosedCharacters = function (autoClosedActions) {
  65454. var autoClosedCharacters = [];
  65455. for (var _i = 0, autoClosedActions_1 = autoClosedActions; _i < autoClosedActions_1.length; _i++) {
  65456. var autoClosedAction = autoClosedActions_1[_i];
  65457. autoClosedCharacters = autoClosedCharacters.concat(autoClosedAction.getAutoClosedCharactersRanges());
  65458. }
  65459. return autoClosedCharacters;
  65460. };
  65461. AutoClosedAction.prototype.dispose = function () {
  65462. this._autoClosedCharactersDecorations = this._model.deltaDecorations(this._autoClosedCharactersDecorations, []);
  65463. this._autoClosedEnclosingDecorations = this._model.deltaDecorations(this._autoClosedEnclosingDecorations, []);
  65464. };
  65465. AutoClosedAction.prototype.getAutoClosedCharactersRanges = function () {
  65466. var result = [];
  65467. for (var i = 0; i < this._autoClosedCharactersDecorations.length; i++) {
  65468. var decorationRange = this._model.getDecorationRange(this._autoClosedCharactersDecorations[i]);
  65469. if (decorationRange) {
  65470. result.push(decorationRange);
  65471. }
  65472. }
  65473. return result;
  65474. };
  65475. AutoClosedAction.prototype.isValid = function (selections) {
  65476. var enclosingRanges = [];
  65477. for (var i = 0; i < this._autoClosedEnclosingDecorations.length; i++) {
  65478. var decorationRange = this._model.getDecorationRange(this._autoClosedEnclosingDecorations[i]);
  65479. if (decorationRange) {
  65480. enclosingRanges.push(decorationRange);
  65481. if (decorationRange.startLineNumber !== decorationRange.endLineNumber) {
  65482. // Stop tracking if the range becomes multiline...
  65483. return false;
  65484. }
  65485. }
  65486. }
  65487. enclosingRanges.sort(range_1.Range.compareRangesUsingStarts);
  65488. selections.sort(range_1.Range.compareRangesUsingStarts);
  65489. for (var i = 0; i < selections.length; i++) {
  65490. if (i >= enclosingRanges.length) {
  65491. return false;
  65492. }
  65493. if (!enclosingRanges[i].strictContainsRange(selections[i])) {
  65494. return false;
  65495. }
  65496. }
  65497. return true;
  65498. };
  65499. return AutoClosedAction;
  65500. }());
  65501. var Cursor = /** @class */ (function (_super) {
  65502. __extends(Cursor, _super);
  65503. function Cursor(configuration, model, viewModel) {
  65504. var _this = _super.call(this) || this;
  65505. _this._onDidReachMaxCursorCount = _this._register(new event_1.Emitter());
  65506. _this.onDidReachMaxCursorCount = _this._onDidReachMaxCursorCount.event;
  65507. _this._onDidAttemptReadOnlyEdit = _this._register(new event_1.Emitter());
  65508. _this.onDidAttemptReadOnlyEdit = _this._onDidAttemptReadOnlyEdit.event;
  65509. _this._onDidChange = _this._register(new event_1.Emitter());
  65510. _this.onDidChange = _this._onDidChange.event;
  65511. _this._configuration = configuration;
  65512. _this._model = model;
  65513. _this._knownModelVersionId = _this._model.getVersionId();
  65514. _this._viewModel = viewModel;
  65515. _this.context = new cursorCommon_1.CursorContext(_this._configuration, _this._model, _this._viewModel);
  65516. _this._cursors = new cursorCollection_1.CursorCollection(_this.context);
  65517. _this._isHandling = false;
  65518. _this._isDoingComposition = false;
  65519. _this._selectionsWhenCompositionStarted = null;
  65520. _this._columnSelectData = null;
  65521. _this._autoClosedActions = [];
  65522. _this._prevEditOperationType = 0 /* Other */;
  65523. _this._register(_this._model.onDidChangeRawContent(function (e) {
  65524. _this._knownModelVersionId = e.versionId;
  65525. if (_this._isHandling) {
  65526. return;
  65527. }
  65528. var hadFlushEvent = e.containsEvent(1 /* Flush */);
  65529. _this._onModelContentChanged(hadFlushEvent);
  65530. }));
  65531. _this._register(viewModel.addEventListener(function (events) {
  65532. if (!containsLineMappingChanged(events)) {
  65533. return;
  65534. }
  65535. if (_this._knownModelVersionId !== _this._model.getVersionId()) {
  65536. // There are model change events that I didn't yet receive.
  65537. //
  65538. // This can happen when editing the model, and the view model receives the change events first,
  65539. // and the view model emits line mapping changed events, all before the cursor gets a chance to
  65540. // recover from markers.
  65541. //
  65542. // The model change listener above will be called soon and we'll ensure a valid cursor state there.
  65543. return;
  65544. }
  65545. // Ensure valid state
  65546. _this.setStates('viewModel', 0 /* NotSet */, _this.getAll());
  65547. }));
  65548. var updateCursorContext = function () {
  65549. _this.context = new cursorCommon_1.CursorContext(_this._configuration, _this._model, _this._viewModel);
  65550. _this._cursors.updateContext(_this.context);
  65551. };
  65552. _this._register(_this._model.onDidChangeLanguage(function (e) {
  65553. updateCursorContext();
  65554. }));
  65555. _this._register(_this._model.onDidChangeLanguageConfiguration(function () {
  65556. updateCursorContext();
  65557. }));
  65558. _this._register(_this._model.onDidChangeOptions(function () {
  65559. updateCursorContext();
  65560. }));
  65561. _this._register(_this._configuration.onDidChange(function (e) {
  65562. if (cursorCommon_1.CursorConfiguration.shouldRecreate(e)) {
  65563. updateCursorContext();
  65564. }
  65565. }));
  65566. return _this;
  65567. }
  65568. Cursor.prototype.dispose = function () {
  65569. this._cursors.dispose();
  65570. this._autoClosedActions = lifecycle_1.dispose(this._autoClosedActions);
  65571. _super.prototype.dispose.call(this);
  65572. };
  65573. Cursor.prototype._validateAutoClosedActions = function () {
  65574. if (this._autoClosedActions.length > 0) {
  65575. var selections = this._cursors.getSelections();
  65576. for (var i = 0; i < this._autoClosedActions.length; i++) {
  65577. var autoClosedAction = this._autoClosedActions[i];
  65578. if (!autoClosedAction.isValid(selections)) {
  65579. autoClosedAction.dispose();
  65580. this._autoClosedActions.splice(i, 1);
  65581. i--;
  65582. }
  65583. }
  65584. }
  65585. };
  65586. // ------ some getters/setters
  65587. Cursor.prototype.getPrimaryCursor = function () {
  65588. return this._cursors.getPrimaryCursor();
  65589. };
  65590. Cursor.prototype.getLastAddedCursorIndex = function () {
  65591. return this._cursors.getLastAddedCursorIndex();
  65592. };
  65593. Cursor.prototype.getAll = function () {
  65594. return this._cursors.getAll();
  65595. };
  65596. Cursor.prototype.setStates = function (source, reason, states) {
  65597. if (states !== null && states.length > Cursor.MAX_CURSOR_COUNT) {
  65598. states = states.slice(0, Cursor.MAX_CURSOR_COUNT);
  65599. this._onDidReachMaxCursorCount.fire(undefined);
  65600. }
  65601. var oldState = new CursorModelState(this._model, this);
  65602. this._cursors.setStates(states);
  65603. this._cursors.normalize();
  65604. this._columnSelectData = null;
  65605. this._validateAutoClosedActions();
  65606. this._emitStateChangedIfNecessary(source, reason, oldState);
  65607. };
  65608. Cursor.prototype.setColumnSelectData = function (columnSelectData) {
  65609. this._columnSelectData = columnSelectData;
  65610. };
  65611. Cursor.prototype.reveal = function (source, horizontal, target, scrollType) {
  65612. this._revealRange(source, target, 0 /* Simple */, horizontal, scrollType);
  65613. };
  65614. Cursor.prototype.revealRange = function (source, revealHorizontal, viewRange, verticalType, scrollType) {
  65615. this.emitCursorRevealRange(source, viewRange, verticalType, revealHorizontal, scrollType);
  65616. };
  65617. Cursor.prototype.scrollTo = function (desiredScrollTop) {
  65618. this._viewModel.viewLayout.setScrollPositionSmooth({
  65619. scrollTop: desiredScrollTop
  65620. });
  65621. };
  65622. Cursor.prototype.saveState = function () {
  65623. var result = [];
  65624. var selections = this._cursors.getSelections();
  65625. for (var i = 0, len = selections.length; i < len; i++) {
  65626. var selection = selections[i];
  65627. result.push({
  65628. inSelectionMode: !selection.isEmpty(),
  65629. selectionStart: {
  65630. lineNumber: selection.selectionStartLineNumber,
  65631. column: selection.selectionStartColumn,
  65632. },
  65633. position: {
  65634. lineNumber: selection.positionLineNumber,
  65635. column: selection.positionColumn,
  65636. }
  65637. });
  65638. }
  65639. return result;
  65640. };
  65641. Cursor.prototype.restoreState = function (states) {
  65642. var desiredSelections = [];
  65643. for (var i = 0, len = states.length; i < len; i++) {
  65644. var state = states[i];
  65645. var positionLineNumber = 1;
  65646. var positionColumn = 1;
  65647. // Avoid missing properties on the literal
  65648. if (state.position && state.position.lineNumber) {
  65649. positionLineNumber = state.position.lineNumber;
  65650. }
  65651. if (state.position && state.position.column) {
  65652. positionColumn = state.position.column;
  65653. }
  65654. var selectionStartLineNumber = positionLineNumber;
  65655. var selectionStartColumn = positionColumn;
  65656. // Avoid missing properties on the literal
  65657. if (state.selectionStart && state.selectionStart.lineNumber) {
  65658. selectionStartLineNumber = state.selectionStart.lineNumber;
  65659. }
  65660. if (state.selectionStart && state.selectionStart.column) {
  65661. selectionStartColumn = state.selectionStart.column;
  65662. }
  65663. desiredSelections.push({
  65664. selectionStartLineNumber: selectionStartLineNumber,
  65665. selectionStartColumn: selectionStartColumn,
  65666. positionLineNumber: positionLineNumber,
  65667. positionColumn: positionColumn
  65668. });
  65669. }
  65670. this.setStates('restoreState', 0 /* NotSet */, cursorCommon_1.CursorState.fromModelSelections(desiredSelections));
  65671. this.reveal('restoreState', true, 0 /* Primary */, 1 /* Immediate */);
  65672. };
  65673. Cursor.prototype._onModelContentChanged = function (hadFlushEvent) {
  65674. this._prevEditOperationType = 0 /* Other */;
  65675. if (hadFlushEvent) {
  65676. // a model.setValue() was called
  65677. this._cursors.dispose();
  65678. this._cursors = new cursorCollection_1.CursorCollection(this.context);
  65679. this._validateAutoClosedActions();
  65680. this._emitStateChangedIfNecessary('model', 1 /* ContentFlush */, null);
  65681. }
  65682. else {
  65683. var selectionsFromMarkers = this._cursors.readSelectionFromMarkers();
  65684. this.setStates('modelChange', 2 /* RecoverFromMarkers */, cursorCommon_1.CursorState.fromModelSelections(selectionsFromMarkers));
  65685. }
  65686. };
  65687. Cursor.prototype.getSelection = function () {
  65688. return this._cursors.getPrimaryCursor().modelState.selection;
  65689. };
  65690. Cursor.prototype.getColumnSelectData = function () {
  65691. if (this._columnSelectData) {
  65692. return this._columnSelectData;
  65693. }
  65694. var primaryCursor = this._cursors.getPrimaryCursor();
  65695. var primaryPos = primaryCursor.viewState.selectionStart.getStartPosition();
  65696. var viewLineNumber = primaryPos.lineNumber;
  65697. var viewVisualColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn2(this.context.config, this.context.viewModel, primaryPos);
  65698. return {
  65699. isReal: false,
  65700. fromViewLineNumber: viewLineNumber,
  65701. fromViewVisualColumn: viewVisualColumn,
  65702. toViewLineNumber: viewLineNumber,
  65703. toViewVisualColumn: viewVisualColumn,
  65704. };
  65705. };
  65706. Cursor.prototype.getSelections = function () {
  65707. return this._cursors.getSelections();
  65708. };
  65709. Cursor.prototype.getViewSelections = function () {
  65710. return this._cursors.getViewSelections();
  65711. };
  65712. Cursor.prototype.getPosition = function () {
  65713. return this._cursors.getPrimaryCursor().modelState.position;
  65714. };
  65715. Cursor.prototype.setSelections = function (source, selections) {
  65716. this.setStates(source, 0 /* NotSet */, cursorCommon_1.CursorState.fromModelSelections(selections));
  65717. };
  65718. Cursor.prototype.getPrevEditOperationType = function () {
  65719. return this._prevEditOperationType;
  65720. };
  65721. Cursor.prototype.setPrevEditOperationType = function (type) {
  65722. this._prevEditOperationType = type;
  65723. };
  65724. // ------ auxiliary handling logic
  65725. Cursor.prototype._pushAutoClosedAction = function (autoClosedCharactersRanges, autoClosedEnclosingRanges) {
  65726. var autoClosedCharactersDeltaDecorations = [];
  65727. var autoClosedEnclosingDeltaDecorations = [];
  65728. for (var i = 0, len = autoClosedCharactersRanges.length; i < len; i++) {
  65729. autoClosedCharactersDeltaDecorations.push({
  65730. range: autoClosedCharactersRanges[i],
  65731. options: {
  65732. inlineClassName: 'auto-closed-character',
  65733. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */
  65734. }
  65735. });
  65736. autoClosedEnclosingDeltaDecorations.push({
  65737. range: autoClosedEnclosingRanges[i],
  65738. options: {
  65739. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */
  65740. }
  65741. });
  65742. }
  65743. var autoClosedCharactersDecorations = this._model.deltaDecorations([], autoClosedCharactersDeltaDecorations);
  65744. var autoClosedEnclosingDecorations = this._model.deltaDecorations([], autoClosedEnclosingDeltaDecorations);
  65745. this._autoClosedActions.push(new AutoClosedAction(this._model, autoClosedCharactersDecorations, autoClosedEnclosingDecorations));
  65746. };
  65747. Cursor.prototype._executeEditOperation = function (opResult) {
  65748. if (!opResult) {
  65749. // Nothing to execute
  65750. return;
  65751. }
  65752. if (opResult.shouldPushStackElementBefore) {
  65753. this._model.pushStackElement();
  65754. }
  65755. var result = CommandExecutor.executeCommands(this._model, this._cursors.getSelections(), opResult.commands);
  65756. if (result) {
  65757. // The commands were applied correctly
  65758. this._interpretCommandResult(result);
  65759. // Check for auto-closing closed characters
  65760. var autoClosedCharactersRanges = [];
  65761. var autoClosedEnclosingRanges = [];
  65762. for (var i = 0; i < opResult.commands.length; i++) {
  65763. var command = opResult.commands[i];
  65764. if (command instanceof cursorTypeOperations_1.TypeWithAutoClosingCommand && command.enclosingRange && command.closeCharacterRange) {
  65765. autoClosedCharactersRanges.push(command.closeCharacterRange);
  65766. autoClosedEnclosingRanges.push(command.enclosingRange);
  65767. }
  65768. }
  65769. if (autoClosedCharactersRanges.length > 0) {
  65770. this._pushAutoClosedAction(autoClosedCharactersRanges, autoClosedEnclosingRanges);
  65771. }
  65772. this._prevEditOperationType = opResult.type;
  65773. }
  65774. if (opResult.shouldPushStackElementAfter) {
  65775. this._model.pushStackElement();
  65776. }
  65777. };
  65778. Cursor.prototype._interpretCommandResult = function (cursorState) {
  65779. if (!cursorState || cursorState.length === 0) {
  65780. cursorState = this._cursors.readSelectionFromMarkers();
  65781. }
  65782. this._columnSelectData = null;
  65783. this._cursors.setSelections(cursorState);
  65784. this._cursors.normalize();
  65785. };
  65786. // -----------------------------------------------------------------------------------------------------------
  65787. // ----- emitting events
  65788. Cursor.prototype._emitStateChangedIfNecessary = function (source, reason, oldState) {
  65789. var newState = new CursorModelState(this._model, this);
  65790. if (newState.equals(oldState)) {
  65791. return false;
  65792. }
  65793. var selections = this._cursors.getSelections();
  65794. var viewSelections = this._cursors.getViewSelections();
  65795. // Let the view get the event first.
  65796. try {
  65797. var eventsCollector = this._beginEmit();
  65798. eventsCollector.emit(new viewEvents.ViewCursorStateChangedEvent(viewSelections, selections));
  65799. }
  65800. finally {
  65801. this._endEmit();
  65802. }
  65803. // Only after the view has been notified, let the rest of the world know...
  65804. if (!oldState
  65805. || oldState.cursorState.length !== newState.cursorState.length
  65806. || newState.cursorState.some(function (newCursorState, i) { return !newCursorState.modelState.equals(oldState.cursorState[i].modelState); })) {
  65807. var oldSelections = oldState ? oldState.cursorState.map(function (s) { return s.modelState.selection; }) : null;
  65808. var oldModelVersionId = oldState ? oldState.modelVersionId : 0;
  65809. this._onDidChange.fire(new CursorStateChangedEvent(selections, newState.modelVersionId, oldSelections, oldModelVersionId, source || 'keyboard', reason));
  65810. }
  65811. return true;
  65812. };
  65813. Cursor.prototype._revealRange = function (source, revealTarget, verticalType, revealHorizontal, scrollType) {
  65814. var viewPositions = this._cursors.getViewPositions();
  65815. var viewPosition = viewPositions[0];
  65816. if (revealTarget === 1 /* TopMost */) {
  65817. for (var i = 1; i < viewPositions.length; i++) {
  65818. if (viewPositions[i].isBefore(viewPosition)) {
  65819. viewPosition = viewPositions[i];
  65820. }
  65821. }
  65822. }
  65823. else if (revealTarget === 2 /* BottomMost */) {
  65824. for (var i = 1; i < viewPositions.length; i++) {
  65825. if (viewPosition.isBeforeOrEqual(viewPositions[i])) {
  65826. viewPosition = viewPositions[i];
  65827. }
  65828. }
  65829. }
  65830. else {
  65831. if (viewPositions.length > 1) {
  65832. // no revealing!
  65833. return;
  65834. }
  65835. }
  65836. var viewRange = new range_1.Range(viewPosition.lineNumber, viewPosition.column, viewPosition.lineNumber, viewPosition.column);
  65837. this.emitCursorRevealRange(source, viewRange, verticalType, revealHorizontal, scrollType);
  65838. };
  65839. Cursor.prototype.emitCursorRevealRange = function (source, viewRange, verticalType, revealHorizontal, scrollType) {
  65840. try {
  65841. var eventsCollector = this._beginEmit();
  65842. eventsCollector.emit(new viewEvents.ViewRevealRangeRequestEvent(source, viewRange, verticalType, revealHorizontal, scrollType));
  65843. }
  65844. finally {
  65845. this._endEmit();
  65846. }
  65847. };
  65848. // -----------------------------------------------------------------------------------------------------------
  65849. // ----- handlers beyond this point
  65850. Cursor.prototype._findAutoClosingPairs = function (edits) {
  65851. if (!edits.length) {
  65852. return null;
  65853. }
  65854. var indices = [];
  65855. for (var i = 0, len = edits.length; i < len; i++) {
  65856. var edit = edits[i];
  65857. if (!edit.text || edit.text.indexOf('\n') >= 0) {
  65858. return null;
  65859. }
  65860. var m = edit.text.match(/([)\]}>'"`])([^)\]}>'"`]*)$/);
  65861. if (!m) {
  65862. return null;
  65863. }
  65864. var closeChar = m[1];
  65865. var autoClosingPairsCandidates = this.context.config.autoClosingPairsClose2.get(closeChar);
  65866. if (!autoClosingPairsCandidates || autoClosingPairsCandidates.length !== 1) {
  65867. return null;
  65868. }
  65869. var openChar = autoClosingPairsCandidates[0].open;
  65870. var closeCharIndex = edit.text.length - m[2].length - 1;
  65871. var openCharIndex = edit.text.lastIndexOf(openChar, closeCharIndex - 1);
  65872. if (openCharIndex === -1) {
  65873. return null;
  65874. }
  65875. indices.push([openCharIndex, closeCharIndex]);
  65876. }
  65877. return indices;
  65878. };
  65879. Cursor.prototype.executeEdits = function (source, edits, cursorStateComputer) {
  65880. var _this = this;
  65881. var autoClosingIndices = null;
  65882. if (source === 'snippet') {
  65883. autoClosingIndices = this._findAutoClosingPairs(edits);
  65884. }
  65885. if (autoClosingIndices) {
  65886. edits[0]._isTracked = true;
  65887. }
  65888. var autoClosedCharactersRanges = [];
  65889. var autoClosedEnclosingRanges = [];
  65890. var selections = this._model.pushEditOperations(this.getSelections(), edits, function (undoEdits) {
  65891. if (autoClosingIndices) {
  65892. for (var i = 0, len = autoClosingIndices.length; i < len; i++) {
  65893. var _a = autoClosingIndices[i], openCharInnerIndex = _a[0], closeCharInnerIndex = _a[1];
  65894. var undoEdit = undoEdits[i];
  65895. var lineNumber = undoEdit.range.startLineNumber;
  65896. var openCharIndex = undoEdit.range.startColumn - 1 + openCharInnerIndex;
  65897. var closeCharIndex = undoEdit.range.startColumn - 1 + closeCharInnerIndex;
  65898. autoClosedCharactersRanges.push(new range_1.Range(lineNumber, closeCharIndex + 1, lineNumber, closeCharIndex + 2));
  65899. autoClosedEnclosingRanges.push(new range_1.Range(lineNumber, openCharIndex + 1, lineNumber, closeCharIndex + 2));
  65900. }
  65901. }
  65902. var selections = cursorStateComputer(undoEdits);
  65903. if (selections) {
  65904. // Don't recover the selection from markers because
  65905. // we know what it should be.
  65906. _this._isHandling = true;
  65907. }
  65908. return selections;
  65909. });
  65910. if (selections) {
  65911. this._isHandling = false;
  65912. this.setSelections(source, selections);
  65913. }
  65914. if (autoClosedCharactersRanges.length > 0) {
  65915. this._pushAutoClosedAction(autoClosedCharactersRanges, autoClosedEnclosingRanges);
  65916. }
  65917. };
  65918. Cursor.prototype.trigger = function (source, handlerId, payload) {
  65919. var H = editorCommon.Handler;
  65920. if (handlerId === H.CompositionStart) {
  65921. this._isDoingComposition = true;
  65922. this._selectionsWhenCompositionStarted = this.getSelections().slice(0);
  65923. return;
  65924. }
  65925. if (handlerId === H.CompositionEnd) {
  65926. this._isDoingComposition = false;
  65927. }
  65928. if (this._configuration.options.get(68 /* readOnly */)) {
  65929. // All the remaining handlers will try to edit the model,
  65930. // but we cannot edit when read only...
  65931. this._onDidAttemptReadOnlyEdit.fire(undefined);
  65932. return;
  65933. }
  65934. var oldState = new CursorModelState(this._model, this);
  65935. var cursorChangeReason = 0 /* NotSet */;
  65936. if (handlerId !== H.Undo && handlerId !== H.Redo) {
  65937. // TODO@Alex: if the undo/redo stack contains non-null selections
  65938. // it would also be OK to stop tracking selections here
  65939. this._cursors.stopTrackingSelections();
  65940. }
  65941. // ensure valid state on all cursors
  65942. this._cursors.ensureValidState();
  65943. this._isHandling = true;
  65944. try {
  65945. switch (handlerId) {
  65946. case H.Type:
  65947. this._type(source, payload.text);
  65948. break;
  65949. case H.ReplacePreviousChar:
  65950. this._replacePreviousChar(payload.text, payload.replaceCharCnt);
  65951. break;
  65952. case H.Paste:
  65953. cursorChangeReason = 4 /* Paste */;
  65954. this._paste(payload.text, payload.pasteOnNewLine, payload.multicursorText || []);
  65955. break;
  65956. case H.Cut:
  65957. this._cut();
  65958. break;
  65959. case H.Undo:
  65960. cursorChangeReason = 5 /* Undo */;
  65961. this._interpretCommandResult(this._model.undo());
  65962. break;
  65963. case H.Redo:
  65964. cursorChangeReason = 6 /* Redo */;
  65965. this._interpretCommandResult(this._model.redo());
  65966. break;
  65967. case H.ExecuteCommand:
  65968. this._externalExecuteCommand(payload);
  65969. break;
  65970. case H.ExecuteCommands:
  65971. this._externalExecuteCommands(payload);
  65972. break;
  65973. case H.CompositionEnd:
  65974. this._interpretCompositionEnd(source);
  65975. break;
  65976. }
  65977. }
  65978. catch (err) {
  65979. errors_1.onUnexpectedError(err);
  65980. }
  65981. this._isHandling = false;
  65982. if (handlerId !== H.Undo && handlerId !== H.Redo) {
  65983. this._cursors.startTrackingSelections();
  65984. }
  65985. this._validateAutoClosedActions();
  65986. if (this._emitStateChangedIfNecessary(source, cursorChangeReason, oldState)) {
  65987. this._revealRange(source, 0 /* Primary */, 0 /* Simple */, true, 0 /* Smooth */);
  65988. }
  65989. };
  65990. Cursor.prototype._interpretCompositionEnd = function (source) {
  65991. if (!this._isDoingComposition && source === 'keyboard') {
  65992. // composition finishes, let's check if we need to auto complete if necessary.
  65993. var autoClosedCharacters = AutoClosedAction.getAllAutoClosedCharacters(this._autoClosedActions);
  65994. this._executeEditOperation(cursorTypeOperations_1.TypeOperations.compositionEndWithInterceptors(this._prevEditOperationType, this.context.config, this.context.model, this._selectionsWhenCompositionStarted, this.getSelections(), autoClosedCharacters));
  65995. this._selectionsWhenCompositionStarted = null;
  65996. }
  65997. };
  65998. Cursor.prototype._type = function (source, text) {
  65999. if (!this._isDoingComposition && source === 'keyboard') {
  66000. // If this event is coming straight from the keyboard, look for electric characters and enter
  66001. var len = text.length;
  66002. var offset = 0;
  66003. while (offset < len) {
  66004. var charLength = strings.nextCharLength(text, offset);
  66005. var chr = text.substr(offset, charLength);
  66006. // Here we must interpret each typed character individually
  66007. var autoClosedCharacters = AutoClosedAction.getAllAutoClosedCharacters(this._autoClosedActions);
  66008. this._executeEditOperation(cursorTypeOperations_1.TypeOperations.typeWithInterceptors(this._prevEditOperationType, this.context.config, this.context.model, this.getSelections(), autoClosedCharacters, chr));
  66009. offset += charLength;
  66010. }
  66011. }
  66012. else {
  66013. this._executeEditOperation(cursorTypeOperations_1.TypeOperations.typeWithoutInterceptors(this._prevEditOperationType, this.context.config, this.context.model, this.getSelections(), text));
  66014. }
  66015. };
  66016. Cursor.prototype._replacePreviousChar = function (text, replaceCharCnt) {
  66017. this._executeEditOperation(cursorTypeOperations_1.TypeOperations.replacePreviousChar(this._prevEditOperationType, this.context.config, this.context.model, this.getSelections(), text, replaceCharCnt));
  66018. };
  66019. Cursor.prototype._paste = function (text, pasteOnNewLine, multicursorText) {
  66020. this._executeEditOperation(cursorTypeOperations_1.TypeOperations.paste(this.context.config, this.context.model, this.getSelections(), text, pasteOnNewLine, multicursorText));
  66021. };
  66022. Cursor.prototype._cut = function () {
  66023. this._executeEditOperation(cursorDeleteOperations_1.DeleteOperations.cut(this.context.config, this.context.model, this.getSelections()));
  66024. };
  66025. Cursor.prototype._externalExecuteCommand = function (command) {
  66026. this._cursors.killSecondaryCursors();
  66027. this._executeEditOperation(new cursorCommon_1.EditOperationResult(0 /* Other */, [command], {
  66028. shouldPushStackElementBefore: false,
  66029. shouldPushStackElementAfter: false
  66030. }));
  66031. };
  66032. Cursor.prototype._externalExecuteCommands = function (commands) {
  66033. this._executeEditOperation(new cursorCommon_1.EditOperationResult(0 /* Other */, commands, {
  66034. shouldPushStackElementBefore: false,
  66035. shouldPushStackElementAfter: false
  66036. }));
  66037. };
  66038. Cursor.MAX_CURSOR_COUNT = 10000;
  66039. return Cursor;
  66040. }(viewEvents.ViewEventEmitter));
  66041. exports.Cursor = Cursor;
  66042. var CommandExecutor = /** @class */ (function () {
  66043. function CommandExecutor() {
  66044. }
  66045. CommandExecutor.executeCommands = function (model, selectionsBefore, commands) {
  66046. var ctx = {
  66047. model: model,
  66048. selectionsBefore: selectionsBefore,
  66049. trackedRanges: [],
  66050. trackedRangesDirection: []
  66051. };
  66052. var result = this._innerExecuteCommands(ctx, commands);
  66053. for (var i = 0, len = ctx.trackedRanges.length; i < len; i++) {
  66054. ctx.model._setTrackedRange(ctx.trackedRanges[i], null, 0 /* AlwaysGrowsWhenTypingAtEdges */);
  66055. }
  66056. return result;
  66057. };
  66058. CommandExecutor._innerExecuteCommands = function (ctx, commands) {
  66059. if (this._arrayIsEmpty(commands)) {
  66060. return null;
  66061. }
  66062. var commandsData = this._getEditOperations(ctx, commands);
  66063. if (commandsData.operations.length === 0) {
  66064. return null;
  66065. }
  66066. var rawOperations = commandsData.operations;
  66067. var loserCursorsMap = this._getLoserCursorMap(rawOperations);
  66068. if (loserCursorsMap.hasOwnProperty('0')) {
  66069. // These commands are very messed up
  66070. console.warn('Ignoring commands');
  66071. return null;
  66072. }
  66073. // Remove operations belonging to losing cursors
  66074. var filteredOperations = [];
  66075. for (var i = 0, len = rawOperations.length; i < len; i++) {
  66076. if (!loserCursorsMap.hasOwnProperty(rawOperations[i].identifier.major.toString())) {
  66077. filteredOperations.push(rawOperations[i]);
  66078. }
  66079. }
  66080. // TODO@Alex: find a better way to do this.
  66081. // give the hint that edit operations are tracked to the model
  66082. if (commandsData.hadTrackedEditOperation && filteredOperations.length > 0) {
  66083. filteredOperations[0]._isTracked = true;
  66084. }
  66085. var selectionsAfter = ctx.model.pushEditOperations(ctx.selectionsBefore, filteredOperations, function (inverseEditOperations) {
  66086. var groupedInverseEditOperations = [];
  66087. for (var i = 0; i < ctx.selectionsBefore.length; i++) {
  66088. groupedInverseEditOperations[i] = [];
  66089. }
  66090. for (var _i = 0, inverseEditOperations_1 = inverseEditOperations; _i < inverseEditOperations_1.length; _i++) {
  66091. var op = inverseEditOperations_1[_i];
  66092. if (!op.identifier) {
  66093. // perhaps auto whitespace trim edits
  66094. continue;
  66095. }
  66096. groupedInverseEditOperations[op.identifier.major].push(op);
  66097. }
  66098. var minorBasedSorter = function (a, b) {
  66099. return a.identifier.minor - b.identifier.minor;
  66100. };
  66101. var cursorSelections = [];
  66102. var _loop_1 = function (i) {
  66103. if (groupedInverseEditOperations[i].length > 0) {
  66104. groupedInverseEditOperations[i].sort(minorBasedSorter);
  66105. cursorSelections[i] = commands[i].computeCursorState(ctx.model, {
  66106. getInverseEditOperations: function () {
  66107. return groupedInverseEditOperations[i];
  66108. },
  66109. getTrackedSelection: function (id) {
  66110. var idx = parseInt(id, 10);
  66111. var range = ctx.model._getTrackedRange(ctx.trackedRanges[idx]);
  66112. if (ctx.trackedRangesDirection[idx] === 0 /* LTR */) {
  66113. return new selection_1.Selection(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
  66114. }
  66115. return new selection_1.Selection(range.endLineNumber, range.endColumn, range.startLineNumber, range.startColumn);
  66116. }
  66117. });
  66118. }
  66119. else {
  66120. cursorSelections[i] = ctx.selectionsBefore[i];
  66121. }
  66122. };
  66123. for (var i = 0; i < ctx.selectionsBefore.length; i++) {
  66124. _loop_1(i);
  66125. }
  66126. return cursorSelections;
  66127. });
  66128. if (!selectionsAfter) {
  66129. selectionsAfter = ctx.selectionsBefore;
  66130. }
  66131. // Extract losing cursors
  66132. var losingCursors = [];
  66133. for (var losingCursorIndex in loserCursorsMap) {
  66134. if (loserCursorsMap.hasOwnProperty(losingCursorIndex)) {
  66135. losingCursors.push(parseInt(losingCursorIndex, 10));
  66136. }
  66137. }
  66138. // Sort losing cursors descending
  66139. losingCursors.sort(function (a, b) {
  66140. return b - a;
  66141. });
  66142. // Remove losing cursors
  66143. for (var _i = 0, losingCursors_1 = losingCursors; _i < losingCursors_1.length; _i++) {
  66144. var losingCursor = losingCursors_1[_i];
  66145. selectionsAfter.splice(losingCursor, 1);
  66146. }
  66147. return selectionsAfter;
  66148. };
  66149. CommandExecutor._arrayIsEmpty = function (commands) {
  66150. for (var i = 0, len = commands.length; i < len; i++) {
  66151. if (commands[i]) {
  66152. return false;
  66153. }
  66154. }
  66155. return true;
  66156. };
  66157. CommandExecutor._getEditOperations = function (ctx, commands) {
  66158. var operations = [];
  66159. var hadTrackedEditOperation = false;
  66160. for (var i = 0, len = commands.length; i < len; i++) {
  66161. var command = commands[i];
  66162. if (command) {
  66163. var r = this._getEditOperationsFromCommand(ctx, i, command);
  66164. operations = operations.concat(r.operations);
  66165. hadTrackedEditOperation = hadTrackedEditOperation || r.hadTrackedEditOperation;
  66166. }
  66167. }
  66168. return {
  66169. operations: operations,
  66170. hadTrackedEditOperation: hadTrackedEditOperation
  66171. };
  66172. };
  66173. CommandExecutor._getEditOperationsFromCommand = function (ctx, majorIdentifier, command) {
  66174. // This method acts as a transaction, if the command fails
  66175. // everything it has done is ignored
  66176. var operations = [];
  66177. var operationMinor = 0;
  66178. var addEditOperation = function (selection, text, forceMoveMarkers) {
  66179. if (forceMoveMarkers === void 0) { forceMoveMarkers = false; }
  66180. if (selection.isEmpty() && text === '') {
  66181. // This command wants to add a no-op => no thank you
  66182. return;
  66183. }
  66184. operations.push({
  66185. identifier: {
  66186. major: majorIdentifier,
  66187. minor: operationMinor++
  66188. },
  66189. range: selection,
  66190. text: text,
  66191. forceMoveMarkers: forceMoveMarkers,
  66192. isAutoWhitespaceEdit: command.insertsAutoWhitespace
  66193. });
  66194. };
  66195. var hadTrackedEditOperation = false;
  66196. var addTrackedEditOperation = function (selection, text, forceMoveMarkers) {
  66197. hadTrackedEditOperation = true;
  66198. addEditOperation(selection, text, forceMoveMarkers);
  66199. };
  66200. var trackSelection = function (selection, trackPreviousOnEmpty) {
  66201. var stickiness;
  66202. if (selection.isEmpty()) {
  66203. if (typeof trackPreviousOnEmpty === 'boolean') {
  66204. if (trackPreviousOnEmpty) {
  66205. stickiness = 2 /* GrowsOnlyWhenTypingBefore */;
  66206. }
  66207. else {
  66208. stickiness = 3 /* GrowsOnlyWhenTypingAfter */;
  66209. }
  66210. }
  66211. else {
  66212. // Try to lock it with surrounding text
  66213. var maxLineColumn = ctx.model.getLineMaxColumn(selection.startLineNumber);
  66214. if (selection.startColumn === maxLineColumn) {
  66215. stickiness = 2 /* GrowsOnlyWhenTypingBefore */;
  66216. }
  66217. else {
  66218. stickiness = 3 /* GrowsOnlyWhenTypingAfter */;
  66219. }
  66220. }
  66221. }
  66222. else {
  66223. stickiness = 1 /* NeverGrowsWhenTypingAtEdges */;
  66224. }
  66225. var l = ctx.trackedRanges.length;
  66226. var id = ctx.model._setTrackedRange(null, selection, stickiness);
  66227. ctx.trackedRanges[l] = id;
  66228. ctx.trackedRangesDirection[l] = selection.getDirection();
  66229. return l.toString();
  66230. };
  66231. var editOperationBuilder = {
  66232. addEditOperation: addEditOperation,
  66233. addTrackedEditOperation: addTrackedEditOperation,
  66234. trackSelection: trackSelection
  66235. };
  66236. try {
  66237. command.getEditOperations(ctx.model, editOperationBuilder);
  66238. }
  66239. catch (e) {
  66240. // TODO@Alex use notification service if this should be user facing
  66241. // e.friendlyMessage = nls.localize('corrupt.commands', "Unexpected exception while executing command.");
  66242. errors_1.onUnexpectedError(e);
  66243. return {
  66244. operations: [],
  66245. hadTrackedEditOperation: false
  66246. };
  66247. }
  66248. return {
  66249. operations: operations,
  66250. hadTrackedEditOperation: hadTrackedEditOperation
  66251. };
  66252. };
  66253. CommandExecutor._getLoserCursorMap = function (operations) {
  66254. // This is destructive on the array
  66255. operations = operations.slice(0);
  66256. // Sort operations with last one first
  66257. operations.sort(function (a, b) {
  66258. // Note the minus!
  66259. return -(range_1.Range.compareRangesUsingEnds(a.range, b.range));
  66260. });
  66261. // Operations can not overlap!
  66262. var loserCursorsMap = {};
  66263. for (var i = 1; i < operations.length; i++) {
  66264. var previousOp = operations[i - 1];
  66265. var currentOp = operations[i];
  66266. if (previousOp.range.getStartPosition().isBefore(currentOp.range.getEndPosition())) {
  66267. var loserMajor = void 0;
  66268. if (previousOp.identifier.major > currentOp.identifier.major) {
  66269. // previousOp loses the battle
  66270. loserMajor = previousOp.identifier.major;
  66271. }
  66272. else {
  66273. loserMajor = currentOp.identifier.major;
  66274. }
  66275. loserCursorsMap[loserMajor.toString()] = true;
  66276. for (var j = 0; j < operations.length; j++) {
  66277. if (operations[j].identifier.major === loserMajor) {
  66278. operations.splice(j, 1);
  66279. if (j < i) {
  66280. i--;
  66281. }
  66282. j--;
  66283. }
  66284. }
  66285. if (i > 0) {
  66286. i--;
  66287. }
  66288. }
  66289. }
  66290. return loserCursorsMap;
  66291. };
  66292. return CommandExecutor;
  66293. }());
  66294. });
  66295. /*---------------------------------------------------------------------------------------------
  66296. * Copyright (c) Microsoft Corporation. All rights reserved.
  66297. * Licensed under the MIT License. See License.txt in the project root for license information.
  66298. *--------------------------------------------------------------------------------------------*/
  66299. define(__m[214/*vs/editor/common/modes/textToHtmlTokenizer*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,93/*vs/editor/common/core/lineTokens*/,63/*vs/editor/common/modes/nullMode*/]), function (require, exports, strings, lineTokens_1, nullMode_1) {
  66300. "use strict";
  66301. Object.defineProperty(exports, "__esModule", { value: true });
  66302. var fallback = {
  66303. getInitialState: function () { return nullMode_1.NULL_STATE; },
  66304. tokenize2: function (buffer, state, deltaOffset) { return nullMode_1.nullTokenize2(0 /* Null */, buffer, state, deltaOffset); }
  66305. };
  66306. function tokenizeToString(text, tokenizationSupport) {
  66307. if (tokenizationSupport === void 0) { tokenizationSupport = fallback; }
  66308. return _tokenizeToString(text, tokenizationSupport || fallback);
  66309. }
  66310. exports.tokenizeToString = tokenizeToString;
  66311. function tokenizeLineToHTML(text, viewLineTokens, colorMap, startOffset, endOffset, tabSize, useNbsp) {
  66312. var result = "<div>";
  66313. var charIndex = startOffset;
  66314. var tabsCharDelta = 0;
  66315. for (var tokenIndex = 0, tokenCount = viewLineTokens.getCount(); tokenIndex < tokenCount; tokenIndex++) {
  66316. var tokenEndIndex = viewLineTokens.getEndOffset(tokenIndex);
  66317. if (tokenEndIndex <= startOffset) {
  66318. continue;
  66319. }
  66320. var partContent = '';
  66321. for (; charIndex < tokenEndIndex && charIndex < endOffset; charIndex++) {
  66322. var charCode = text.charCodeAt(charIndex);
  66323. switch (charCode) {
  66324. case 9 /* Tab */:
  66325. var insertSpacesCount = tabSize - (charIndex + tabsCharDelta) % tabSize;
  66326. tabsCharDelta += insertSpacesCount - 1;
  66327. while (insertSpacesCount > 0) {
  66328. partContent += useNbsp ? '&#160;' : ' ';
  66329. insertSpacesCount--;
  66330. }
  66331. break;
  66332. case 60 /* LessThan */:
  66333. partContent += '&lt;';
  66334. break;
  66335. case 62 /* GreaterThan */:
  66336. partContent += '&gt;';
  66337. break;
  66338. case 38 /* Ampersand */:
  66339. partContent += '&amp;';
  66340. break;
  66341. case 0 /* Null */:
  66342. partContent += '&#00;';
  66343. break;
  66344. case 65279 /* UTF8_BOM */:
  66345. case 8232 /* LINE_SEPARATOR_2028 */:
  66346. partContent += '\ufffd';
  66347. break;
  66348. case 13 /* CarriageReturn */:
  66349. // zero width space, because carriage return would introduce a line break
  66350. partContent += '&#8203';
  66351. break;
  66352. case 32 /* Space */:
  66353. partContent += useNbsp ? '&#160;' : ' ';
  66354. break;
  66355. default:
  66356. partContent += String.fromCharCode(charCode);
  66357. }
  66358. }
  66359. result += "<span style=\"" + viewLineTokens.getInlineStyle(tokenIndex, colorMap) + "\">" + partContent + "</span>";
  66360. if (tokenEndIndex > endOffset || charIndex >= endOffset) {
  66361. break;
  66362. }
  66363. }
  66364. result += "</div>";
  66365. return result;
  66366. }
  66367. exports.tokenizeLineToHTML = tokenizeLineToHTML;
  66368. function _tokenizeToString(text, tokenizationSupport) {
  66369. var result = "<div class=\"monaco-tokenized-source\">";
  66370. var lines = text.split(/\r\n|\r|\n/);
  66371. var currentState = tokenizationSupport.getInitialState();
  66372. for (var i = 0, len = lines.length; i < len; i++) {
  66373. var line = lines[i];
  66374. if (i > 0) {
  66375. result += "<br/>";
  66376. }
  66377. var tokenizationResult = tokenizationSupport.tokenize2(line, currentState, 0);
  66378. lineTokens_1.LineTokens.convertToEndOffset(tokenizationResult.tokens, line.length);
  66379. var lineTokens = new lineTokens_1.LineTokens(tokenizationResult.tokens, line);
  66380. var viewLineTokens = lineTokens.inflate();
  66381. var startOffset = 0;
  66382. for (var j = 0, lenJ = viewLineTokens.getCount(); j < lenJ; j++) {
  66383. var type = viewLineTokens.getClassName(j);
  66384. var endIndex = viewLineTokens.getEndOffset(j);
  66385. result += "<span class=\"" + type + "\">" + strings.escape(line.substring(startOffset, endIndex)) + "</span>";
  66386. startOffset = endIndex;
  66387. }
  66388. currentState = tokenizationResult.endState;
  66389. }
  66390. result += "</div>";
  66391. return result;
  66392. }
  66393. });
  66394. /*---------------------------------------------------------------------------------------------
  66395. * Copyright (c) Microsoft Corporation. All rights reserved.
  66396. * Licensed under the MIT License. See License.txt in the project root for license information.
  66397. *--------------------------------------------------------------------------------------------*/
  66398. define(__m[84/*vs/editor/common/services/resolverService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  66399. "use strict";
  66400. Object.defineProperty(exports, "__esModule", { value: true });
  66401. exports.ITextModelService = instantiation_1.createDecorator('textModelService');
  66402. });
  66403. define(__m[114/*vs/editor/common/services/textResourceConfigurationService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  66404. "use strict";
  66405. Object.defineProperty(exports, "__esModule", { value: true });
  66406. exports.ITextResourceConfigurationService = instantiation_1.createDecorator('textResourceConfigurationService');
  66407. exports.ITextResourcePropertiesService = instantiation_1.createDecorator('textResourcePropertiesService');
  66408. });
  66409. /*---------------------------------------------------------------------------------------------
  66410. * Copyright (c) Microsoft Corporation. All rights reserved.
  66411. * Licensed under the MIT License. See License.txt in the project root for license information.
  66412. *--------------------------------------------------------------------------------------------*/
  66413. define(__m[215/*vs/editor/common/viewModel/minimapTokensColorTracker*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,339/*vs/editor/common/core/rgba*/,17/*vs/editor/common/modes*/]), function (require, exports, event_1, rgba_1, modes_1) {
  66414. "use strict";
  66415. Object.defineProperty(exports, "__esModule", { value: true });
  66416. var MinimapTokensColorTracker = /** @class */ (function () {
  66417. function MinimapTokensColorTracker() {
  66418. var _this = this;
  66419. this._onDidChange = new event_1.Emitter();
  66420. this.onDidChange = this._onDidChange.event;
  66421. this._updateColorMap();
  66422. modes_1.TokenizationRegistry.onDidChange(function (e) {
  66423. if (e.changedColorMap) {
  66424. _this._updateColorMap();
  66425. }
  66426. });
  66427. }
  66428. MinimapTokensColorTracker.getInstance = function () {
  66429. if (!this._INSTANCE) {
  66430. this._INSTANCE = new MinimapTokensColorTracker();
  66431. }
  66432. return this._INSTANCE;
  66433. };
  66434. MinimapTokensColorTracker.prototype._updateColorMap = function () {
  66435. var colorMap = modes_1.TokenizationRegistry.getColorMap();
  66436. if (!colorMap) {
  66437. this._colors = [rgba_1.RGBA8.Empty];
  66438. this._backgroundIsLight = true;
  66439. return;
  66440. }
  66441. this._colors = [rgba_1.RGBA8.Empty];
  66442. for (var colorId = 1; colorId < colorMap.length; colorId++) {
  66443. var source = colorMap[colorId].rgba;
  66444. // Use a VM friendly data-type
  66445. this._colors[colorId] = new rgba_1.RGBA8(source.r, source.g, source.b, Math.round(source.a * 255));
  66446. }
  66447. var backgroundLuminosity = colorMap[2 /* DefaultBackground */].getRelativeLuminance();
  66448. this._backgroundIsLight = backgroundLuminosity >= 0.5;
  66449. this._onDidChange.fire(undefined);
  66450. };
  66451. MinimapTokensColorTracker.prototype.getColor = function (colorId) {
  66452. if (colorId < 1 || colorId >= this._colors.length) {
  66453. // background color (basically invisible)
  66454. colorId = 2 /* DefaultBackground */;
  66455. }
  66456. return this._colors[colorId];
  66457. };
  66458. MinimapTokensColorTracker.prototype.backgroundIsLight = function () {
  66459. return this._backgroundIsLight;
  66460. };
  66461. MinimapTokensColorTracker._INSTANCE = null;
  66462. return MinimapTokensColorTracker;
  66463. }());
  66464. exports.MinimapTokensColorTracker = MinimapTokensColorTracker;
  66465. });
  66466. /*---------------------------------------------------------------------------------------------
  66467. * Copyright (c) Microsoft Corporation. All rights reserved.
  66468. * Licensed under the MIT License. See License.txt in the project root for license information.
  66469. *--------------------------------------------------------------------------------------------*/
  66470. define(__m[161/*vs/editor/common/viewModel/splitLinesCollection*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,30/*vs/editor/common/model/textModel*/,81/*vs/editor/common/view/viewEvents*/,194/*vs/editor/common/viewModel/prefixSumComputer*/,69/*vs/editor/common/viewModel/viewModel*/]), function (require, exports, arrays, position_1, range_1, textModel_1, viewEvents, prefixSumComputer_1, viewModel_1) {
  66471. "use strict";
  66472. Object.defineProperty(exports, "__esModule", { value: true });
  66473. var OutputPosition = /** @class */ (function () {
  66474. function OutputPosition(outputLineIndex, outputOffset) {
  66475. this.outputLineIndex = outputLineIndex;
  66476. this.outputOffset = outputOffset;
  66477. }
  66478. return OutputPosition;
  66479. }());
  66480. exports.OutputPosition = OutputPosition;
  66481. var LineBreakData = /** @class */ (function () {
  66482. function LineBreakData(breakOffsets, breakOffsetsVisibleColumn, wrappedTextIndentLength) {
  66483. this.breakOffsets = breakOffsets;
  66484. this.breakOffsetsVisibleColumn = breakOffsetsVisibleColumn;
  66485. this.wrappedTextIndentLength = wrappedTextIndentLength;
  66486. }
  66487. LineBreakData.getInputOffsetOfOutputPosition = function (breakOffsets, outputLineIndex, outputOffset) {
  66488. if (outputLineIndex === 0) {
  66489. return outputOffset;
  66490. }
  66491. else {
  66492. return breakOffsets[outputLineIndex - 1] + outputOffset;
  66493. }
  66494. };
  66495. LineBreakData.getOutputPositionOfInputOffset = function (breakOffsets, inputOffset) {
  66496. var low = 0;
  66497. var high = breakOffsets.length - 1;
  66498. var mid = 0;
  66499. var midStart = 0;
  66500. while (low <= high) {
  66501. mid = low + ((high - low) / 2) | 0;
  66502. var midStop = breakOffsets[mid];
  66503. midStart = mid > 0 ? breakOffsets[mid - 1] : 0;
  66504. if (inputOffset < midStart) {
  66505. high = mid - 1;
  66506. }
  66507. else if (inputOffset >= midStop) {
  66508. low = mid + 1;
  66509. }
  66510. else {
  66511. break;
  66512. }
  66513. }
  66514. return new OutputPosition(mid, inputOffset - midStart);
  66515. };
  66516. return LineBreakData;
  66517. }());
  66518. exports.LineBreakData = LineBreakData;
  66519. var CoordinatesConverter = /** @class */ (function () {
  66520. function CoordinatesConverter(lines) {
  66521. this._lines = lines;
  66522. }
  66523. // View -> Model conversion and related methods
  66524. CoordinatesConverter.prototype.convertViewPositionToModelPosition = function (viewPosition) {
  66525. return this._lines.convertViewPositionToModelPosition(viewPosition.lineNumber, viewPosition.column);
  66526. };
  66527. CoordinatesConverter.prototype.convertViewRangeToModelRange = function (viewRange) {
  66528. return this._lines.convertViewRangeToModelRange(viewRange);
  66529. };
  66530. CoordinatesConverter.prototype.validateViewPosition = function (viewPosition, expectedModelPosition) {
  66531. return this._lines.validateViewPosition(viewPosition.lineNumber, viewPosition.column, expectedModelPosition);
  66532. };
  66533. CoordinatesConverter.prototype.validateViewRange = function (viewRange, expectedModelRange) {
  66534. return this._lines.validateViewRange(viewRange, expectedModelRange);
  66535. };
  66536. // Model -> View conversion and related methods
  66537. CoordinatesConverter.prototype.convertModelPositionToViewPosition = function (modelPosition) {
  66538. return this._lines.convertModelPositionToViewPosition(modelPosition.lineNumber, modelPosition.column);
  66539. };
  66540. CoordinatesConverter.prototype.convertModelRangeToViewRange = function (modelRange) {
  66541. return this._lines.convertModelRangeToViewRange(modelRange);
  66542. };
  66543. CoordinatesConverter.prototype.modelPositionIsVisible = function (modelPosition) {
  66544. return this._lines.modelPositionIsVisible(modelPosition.lineNumber, modelPosition.column);
  66545. };
  66546. return CoordinatesConverter;
  66547. }());
  66548. exports.CoordinatesConverter = CoordinatesConverter;
  66549. var LineNumberMapper = /** @class */ (function () {
  66550. function LineNumberMapper(viewLineCounts) {
  66551. this._counts = viewLineCounts;
  66552. this._isValid = false;
  66553. this._validEndIndex = -1;
  66554. this._modelToView = [];
  66555. this._viewToModel = [];
  66556. }
  66557. LineNumberMapper.prototype._invalidate = function (index) {
  66558. this._isValid = false;
  66559. this._validEndIndex = Math.min(this._validEndIndex, index - 1);
  66560. };
  66561. LineNumberMapper.prototype._ensureValid = function () {
  66562. if (this._isValid) {
  66563. return;
  66564. }
  66565. for (var i = this._validEndIndex + 1, len = this._counts.length; i < len; i++) {
  66566. var viewLineCount = this._counts[i];
  66567. var viewLinesAbove = (i > 0 ? this._modelToView[i - 1] : 0);
  66568. this._modelToView[i] = viewLinesAbove + viewLineCount;
  66569. for (var j = 0; j < viewLineCount; j++) {
  66570. this._viewToModel[viewLinesAbove + j] = i;
  66571. }
  66572. }
  66573. // trim things
  66574. this._modelToView.length = this._counts.length;
  66575. this._viewToModel.length = this._modelToView[this._modelToView.length - 1];
  66576. // mark as valid
  66577. this._isValid = true;
  66578. this._validEndIndex = this._counts.length - 1;
  66579. };
  66580. LineNumberMapper.prototype.changeValue = function (index, value) {
  66581. if (this._counts[index] === value) {
  66582. // no change
  66583. return;
  66584. }
  66585. this._counts[index] = value;
  66586. this._invalidate(index);
  66587. };
  66588. LineNumberMapper.prototype.removeValues = function (start, deleteCount) {
  66589. this._counts.splice(start, deleteCount);
  66590. this._invalidate(start);
  66591. };
  66592. LineNumberMapper.prototype.insertValues = function (insertIndex, insertArr) {
  66593. this._counts = arrays.arrayInsert(this._counts, insertIndex, insertArr);
  66594. this._invalidate(insertIndex);
  66595. };
  66596. LineNumberMapper.prototype.getTotalValue = function () {
  66597. this._ensureValid();
  66598. return this._viewToModel.length;
  66599. };
  66600. LineNumberMapper.prototype.getAccumulatedValue = function (index) {
  66601. this._ensureValid();
  66602. return this._modelToView[index];
  66603. };
  66604. LineNumberMapper.prototype.getIndexOf = function (accumulatedValue) {
  66605. this._ensureValid();
  66606. var modelLineIndex = this._viewToModel[accumulatedValue];
  66607. var viewLinesAbove = (modelLineIndex > 0 ? this._modelToView[modelLineIndex - 1] : 0);
  66608. return new prefixSumComputer_1.PrefixSumIndexOfResult(modelLineIndex, accumulatedValue - viewLinesAbove);
  66609. };
  66610. return LineNumberMapper;
  66611. }());
  66612. var SplitLinesCollection = /** @class */ (function () {
  66613. function SplitLinesCollection(model, domLineBreaksComputerFactory, monospaceLineBreaksComputerFactory, fontInfo, tabSize, wrappingStrategy, wrappingColumn, wrappingIndent) {
  66614. this.model = model;
  66615. this._validModelVersionId = -1;
  66616. this._domLineBreaksComputerFactory = domLineBreaksComputerFactory;
  66617. this._monospaceLineBreaksComputerFactory = monospaceLineBreaksComputerFactory;
  66618. this.fontInfo = fontInfo;
  66619. this.tabSize = tabSize;
  66620. this.wrappingStrategy = wrappingStrategy;
  66621. this.wrappingColumn = wrappingColumn;
  66622. this.wrappingIndent = wrappingIndent;
  66623. this._constructLines(/*resetHiddenAreas*/ true, null);
  66624. }
  66625. SplitLinesCollection.prototype.dispose = function () {
  66626. this.hiddenAreasIds = this.model.deltaDecorations(this.hiddenAreasIds, []);
  66627. };
  66628. SplitLinesCollection.prototype.createCoordinatesConverter = function () {
  66629. return new CoordinatesConverter(this);
  66630. };
  66631. SplitLinesCollection.prototype._constructLines = function (resetHiddenAreas, previousLineBreaks) {
  66632. var _this = this;
  66633. this.lines = [];
  66634. if (resetHiddenAreas) {
  66635. this.hiddenAreasIds = [];
  66636. }
  66637. var linesContent = this.model.getLinesContent();
  66638. var lineCount = linesContent.length;
  66639. var lineBreaksComputer = this.createLineBreaksComputer();
  66640. for (var i = 0; i < lineCount; i++) {
  66641. lineBreaksComputer.addRequest(linesContent[i], previousLineBreaks ? previousLineBreaks[i] : null);
  66642. }
  66643. var linesBreaks = lineBreaksComputer.finalize();
  66644. var values = [];
  66645. var hiddenAreas = this.hiddenAreasIds.map(function (areaId) { return _this.model.getDecorationRange(areaId); }).sort(range_1.Range.compareRangesUsingStarts);
  66646. var hiddenAreaStart = 1, hiddenAreaEnd = 0;
  66647. var hiddenAreaIdx = -1;
  66648. var nextLineNumberToUpdateHiddenArea = (hiddenAreaIdx + 1 < hiddenAreas.length) ? hiddenAreaEnd + 1 : lineCount + 2;
  66649. for (var i = 0; i < lineCount; i++) {
  66650. var lineNumber = i + 1;
  66651. if (lineNumber === nextLineNumberToUpdateHiddenArea) {
  66652. hiddenAreaIdx++;
  66653. hiddenAreaStart = hiddenAreas[hiddenAreaIdx].startLineNumber;
  66654. hiddenAreaEnd = hiddenAreas[hiddenAreaIdx].endLineNumber;
  66655. nextLineNumberToUpdateHiddenArea = (hiddenAreaIdx + 1 < hiddenAreas.length) ? hiddenAreaEnd + 1 : lineCount + 2;
  66656. }
  66657. var isInHiddenArea = (lineNumber >= hiddenAreaStart && lineNumber <= hiddenAreaEnd);
  66658. var line = createSplitLine(linesBreaks[i], !isInHiddenArea);
  66659. values[i] = line.getViewLineCount();
  66660. this.lines[i] = line;
  66661. }
  66662. this._validModelVersionId = this.model.getVersionId();
  66663. this.prefixSumComputer = new LineNumberMapper(values);
  66664. };
  66665. SplitLinesCollection.prototype.getHiddenAreas = function () {
  66666. var _this = this;
  66667. return this.hiddenAreasIds.map(function (decId) {
  66668. return _this.model.getDecorationRange(decId);
  66669. });
  66670. };
  66671. SplitLinesCollection.prototype._reduceRanges = function (_ranges) {
  66672. var _this = this;
  66673. if (_ranges.length === 0) {
  66674. return [];
  66675. }
  66676. var ranges = _ranges.map(function (r) { return _this.model.validateRange(r); }).sort(range_1.Range.compareRangesUsingStarts);
  66677. var result = [];
  66678. var currentRangeStart = ranges[0].startLineNumber;
  66679. var currentRangeEnd = ranges[0].endLineNumber;
  66680. for (var i = 1, len = ranges.length; i < len; i++) {
  66681. var range = ranges[i];
  66682. if (range.startLineNumber > currentRangeEnd + 1) {
  66683. result.push(new range_1.Range(currentRangeStart, 1, currentRangeEnd, 1));
  66684. currentRangeStart = range.startLineNumber;
  66685. currentRangeEnd = range.endLineNumber;
  66686. }
  66687. else if (range.endLineNumber > currentRangeEnd) {
  66688. currentRangeEnd = range.endLineNumber;
  66689. }
  66690. }
  66691. result.push(new range_1.Range(currentRangeStart, 1, currentRangeEnd, 1));
  66692. return result;
  66693. };
  66694. SplitLinesCollection.prototype.setHiddenAreas = function (_ranges) {
  66695. var _this = this;
  66696. var newRanges = this._reduceRanges(_ranges);
  66697. // BEGIN TODO@Martin: Please stop calling this method on each model change!
  66698. var oldRanges = this.hiddenAreasIds.map(function (areaId) { return _this.model.getDecorationRange(areaId); }).sort(range_1.Range.compareRangesUsingStarts);
  66699. if (newRanges.length === oldRanges.length) {
  66700. var hasDifference = false;
  66701. for (var i = 0; i < newRanges.length; i++) {
  66702. if (!newRanges[i].equalsRange(oldRanges[i])) {
  66703. hasDifference = true;
  66704. break;
  66705. }
  66706. }
  66707. if (!hasDifference) {
  66708. return false;
  66709. }
  66710. }
  66711. // END TODO@Martin: Please stop calling this method on each model change!
  66712. var newDecorations = [];
  66713. for (var _i = 0, newRanges_1 = newRanges; _i < newRanges_1.length; _i++) {
  66714. var newRange = newRanges_1[_i];
  66715. newDecorations.push({
  66716. range: newRange,
  66717. options: textModel_1.ModelDecorationOptions.EMPTY
  66718. });
  66719. }
  66720. this.hiddenAreasIds = this.model.deltaDecorations(this.hiddenAreasIds, newDecorations);
  66721. var hiddenAreas = newRanges;
  66722. var hiddenAreaStart = 1, hiddenAreaEnd = 0;
  66723. var hiddenAreaIdx = -1;
  66724. var nextLineNumberToUpdateHiddenArea = (hiddenAreaIdx + 1 < hiddenAreas.length) ? hiddenAreaEnd + 1 : this.lines.length + 2;
  66725. var hasVisibleLine = false;
  66726. for (var i = 0; i < this.lines.length; i++) {
  66727. var lineNumber = i + 1;
  66728. if (lineNumber === nextLineNumberToUpdateHiddenArea) {
  66729. hiddenAreaIdx++;
  66730. hiddenAreaStart = hiddenAreas[hiddenAreaIdx].startLineNumber;
  66731. hiddenAreaEnd = hiddenAreas[hiddenAreaIdx].endLineNumber;
  66732. nextLineNumberToUpdateHiddenArea = (hiddenAreaIdx + 1 < hiddenAreas.length) ? hiddenAreaEnd + 1 : this.lines.length + 2;
  66733. }
  66734. var lineChanged = false;
  66735. if (lineNumber >= hiddenAreaStart && lineNumber <= hiddenAreaEnd) {
  66736. // Line should be hidden
  66737. if (this.lines[i].isVisible()) {
  66738. this.lines[i] = this.lines[i].setVisible(false);
  66739. lineChanged = true;
  66740. }
  66741. }
  66742. else {
  66743. hasVisibleLine = true;
  66744. // Line should be visible
  66745. if (!this.lines[i].isVisible()) {
  66746. this.lines[i] = this.lines[i].setVisible(true);
  66747. lineChanged = true;
  66748. }
  66749. }
  66750. if (lineChanged) {
  66751. var newOutputLineCount = this.lines[i].getViewLineCount();
  66752. this.prefixSumComputer.changeValue(i, newOutputLineCount);
  66753. }
  66754. }
  66755. if (!hasVisibleLine) {
  66756. // Cannot have everything be hidden => reveal everything!
  66757. this.setHiddenAreas([]);
  66758. }
  66759. return true;
  66760. };
  66761. SplitLinesCollection.prototype.modelPositionIsVisible = function (modelLineNumber, _modelColumn) {
  66762. if (modelLineNumber < 1 || modelLineNumber > this.lines.length) {
  66763. // invalid arguments
  66764. return false;
  66765. }
  66766. return this.lines[modelLineNumber - 1].isVisible();
  66767. };
  66768. SplitLinesCollection.prototype.setTabSize = function (newTabSize) {
  66769. if (this.tabSize === newTabSize) {
  66770. return false;
  66771. }
  66772. this.tabSize = newTabSize;
  66773. this._constructLines(/*resetHiddenAreas*/ false, null);
  66774. return true;
  66775. };
  66776. SplitLinesCollection.prototype.setWrappingSettings = function (fontInfo, wrappingStrategy, wrappingColumn, wrappingIndent) {
  66777. var equalFontInfo = this.fontInfo.equals(fontInfo);
  66778. var equalWrappingStrategy = (this.wrappingStrategy === wrappingStrategy);
  66779. var equalWrappingColumn = (this.wrappingColumn === wrappingColumn);
  66780. var equalWrappingIndent = (this.wrappingIndent === wrappingIndent);
  66781. if (equalFontInfo && equalWrappingStrategy && equalWrappingColumn && equalWrappingIndent) {
  66782. return false;
  66783. }
  66784. var onlyWrappingColumnChanged = (equalFontInfo && equalWrappingStrategy && !equalWrappingColumn && equalWrappingIndent);
  66785. this.fontInfo = fontInfo;
  66786. this.wrappingStrategy = wrappingStrategy;
  66787. this.wrappingColumn = wrappingColumn;
  66788. this.wrappingIndent = wrappingIndent;
  66789. var previousLineBreaks = null;
  66790. if (onlyWrappingColumnChanged) {
  66791. previousLineBreaks = [];
  66792. for (var i = 0, len = this.lines.length; i < len; i++) {
  66793. previousLineBreaks[i] = this.lines[i].getLineBreakData();
  66794. }
  66795. }
  66796. this._constructLines(/*resetHiddenAreas*/ false, previousLineBreaks);
  66797. return true;
  66798. };
  66799. SplitLinesCollection.prototype.createLineBreaksComputer = function () {
  66800. var lineBreaksComputerFactory = (this.wrappingStrategy === 'advanced'
  66801. ? this._domLineBreaksComputerFactory
  66802. : this._monospaceLineBreaksComputerFactory);
  66803. return lineBreaksComputerFactory.createLineBreaksComputer(this.fontInfo, this.tabSize, this.wrappingColumn, this.wrappingIndent);
  66804. };
  66805. SplitLinesCollection.prototype.onModelFlushed = function () {
  66806. this._constructLines(/*resetHiddenAreas*/ true, null);
  66807. };
  66808. SplitLinesCollection.prototype.onModelLinesDeleted = function (versionId, fromLineNumber, toLineNumber) {
  66809. if (versionId <= this._validModelVersionId) {
  66810. // Here we check for versionId in case the lines were reconstructed in the meantime.
  66811. // We don't want to apply stale change events on top of a newer read model state.
  66812. return null;
  66813. }
  66814. var outputFromLineNumber = (fromLineNumber === 1 ? 1 : this.prefixSumComputer.getAccumulatedValue(fromLineNumber - 2) + 1);
  66815. var outputToLineNumber = this.prefixSumComputer.getAccumulatedValue(toLineNumber - 1);
  66816. this.lines.splice(fromLineNumber - 1, toLineNumber - fromLineNumber + 1);
  66817. this.prefixSumComputer.removeValues(fromLineNumber - 1, toLineNumber - fromLineNumber + 1);
  66818. return new viewEvents.ViewLinesDeletedEvent(outputFromLineNumber, outputToLineNumber);
  66819. };
  66820. SplitLinesCollection.prototype.onModelLinesInserted = function (versionId, fromLineNumber, _toLineNumber, lineBreaks) {
  66821. if (versionId <= this._validModelVersionId) {
  66822. // Here we check for versionId in case the lines were reconstructed in the meantime.
  66823. // We don't want to apply stale change events on top of a newer read model state.
  66824. return null;
  66825. }
  66826. var hiddenAreas = this.getHiddenAreas();
  66827. var isInHiddenArea = false;
  66828. var testPosition = new position_1.Position(fromLineNumber, 1);
  66829. for (var _i = 0, hiddenAreas_1 = hiddenAreas; _i < hiddenAreas_1.length; _i++) {
  66830. var hiddenArea = hiddenAreas_1[_i];
  66831. if (hiddenArea.containsPosition(testPosition)) {
  66832. isInHiddenArea = true;
  66833. break;
  66834. }
  66835. }
  66836. var outputFromLineNumber = (fromLineNumber === 1 ? 1 : this.prefixSumComputer.getAccumulatedValue(fromLineNumber - 2) + 1);
  66837. var totalOutputLineCount = 0;
  66838. var insertLines = [];
  66839. var insertPrefixSumValues = [];
  66840. for (var i = 0, len = lineBreaks.length; i < len; i++) {
  66841. var line = createSplitLine(lineBreaks[i], !isInHiddenArea);
  66842. insertLines.push(line);
  66843. var outputLineCount = line.getViewLineCount();
  66844. totalOutputLineCount += outputLineCount;
  66845. insertPrefixSumValues[i] = outputLineCount;
  66846. }
  66847. // TODO@Alex: use arrays.arrayInsert
  66848. this.lines = this.lines.slice(0, fromLineNumber - 1).concat(insertLines).concat(this.lines.slice(fromLineNumber - 1));
  66849. this.prefixSumComputer.insertValues(fromLineNumber - 1, insertPrefixSumValues);
  66850. return new viewEvents.ViewLinesInsertedEvent(outputFromLineNumber, outputFromLineNumber + totalOutputLineCount - 1);
  66851. };
  66852. SplitLinesCollection.prototype.onModelLineChanged = function (versionId, lineNumber, lineBreakData) {
  66853. if (versionId <= this._validModelVersionId) {
  66854. // Here we check for versionId in case the lines were reconstructed in the meantime.
  66855. // We don't want to apply stale change events on top of a newer read model state.
  66856. return [false, null, null, null];
  66857. }
  66858. var lineIndex = lineNumber - 1;
  66859. var oldOutputLineCount = this.lines[lineIndex].getViewLineCount();
  66860. var isVisible = this.lines[lineIndex].isVisible();
  66861. var line = createSplitLine(lineBreakData, isVisible);
  66862. this.lines[lineIndex] = line;
  66863. var newOutputLineCount = this.lines[lineIndex].getViewLineCount();
  66864. var lineMappingChanged = false;
  66865. var changeFrom = 0;
  66866. var changeTo = -1;
  66867. var insertFrom = 0;
  66868. var insertTo = -1;
  66869. var deleteFrom = 0;
  66870. var deleteTo = -1;
  66871. if (oldOutputLineCount > newOutputLineCount) {
  66872. changeFrom = (lineNumber === 1 ? 1 : this.prefixSumComputer.getAccumulatedValue(lineNumber - 2) + 1);
  66873. changeTo = changeFrom + newOutputLineCount - 1;
  66874. deleteFrom = changeTo + 1;
  66875. deleteTo = deleteFrom + (oldOutputLineCount - newOutputLineCount) - 1;
  66876. lineMappingChanged = true;
  66877. }
  66878. else if (oldOutputLineCount < newOutputLineCount) {
  66879. changeFrom = (lineNumber === 1 ? 1 : this.prefixSumComputer.getAccumulatedValue(lineNumber - 2) + 1);
  66880. changeTo = changeFrom + oldOutputLineCount - 1;
  66881. insertFrom = changeTo + 1;
  66882. insertTo = insertFrom + (newOutputLineCount - oldOutputLineCount) - 1;
  66883. lineMappingChanged = true;
  66884. }
  66885. else {
  66886. changeFrom = (lineNumber === 1 ? 1 : this.prefixSumComputer.getAccumulatedValue(lineNumber - 2) + 1);
  66887. changeTo = changeFrom + newOutputLineCount - 1;
  66888. }
  66889. this.prefixSumComputer.changeValue(lineIndex, newOutputLineCount);
  66890. var viewLinesChangedEvent = (changeFrom <= changeTo ? new viewEvents.ViewLinesChangedEvent(changeFrom, changeTo) : null);
  66891. var viewLinesInsertedEvent = (insertFrom <= insertTo ? new viewEvents.ViewLinesInsertedEvent(insertFrom, insertTo) : null);
  66892. var viewLinesDeletedEvent = (deleteFrom <= deleteTo ? new viewEvents.ViewLinesDeletedEvent(deleteFrom, deleteTo) : null);
  66893. return [lineMappingChanged, viewLinesChangedEvent, viewLinesInsertedEvent, viewLinesDeletedEvent];
  66894. };
  66895. SplitLinesCollection.prototype.acceptVersionId = function (versionId) {
  66896. this._validModelVersionId = versionId;
  66897. if (this.lines.length === 1 && !this.lines[0].isVisible()) {
  66898. // At least one line must be visible => reset hidden areas
  66899. this.setHiddenAreas([]);
  66900. }
  66901. };
  66902. SplitLinesCollection.prototype.getViewLineCount = function () {
  66903. return this.prefixSumComputer.getTotalValue();
  66904. };
  66905. SplitLinesCollection.prototype._toValidViewLineNumber = function (viewLineNumber) {
  66906. if (viewLineNumber < 1) {
  66907. return 1;
  66908. }
  66909. var viewLineCount = this.getViewLineCount();
  66910. if (viewLineNumber > viewLineCount) {
  66911. return viewLineCount;
  66912. }
  66913. return viewLineNumber | 0;
  66914. };
  66915. SplitLinesCollection.prototype.getActiveIndentGuide = function (viewLineNumber, minLineNumber, maxLineNumber) {
  66916. viewLineNumber = this._toValidViewLineNumber(viewLineNumber);
  66917. minLineNumber = this._toValidViewLineNumber(minLineNumber);
  66918. maxLineNumber = this._toValidViewLineNumber(maxLineNumber);
  66919. var modelPosition = this.convertViewPositionToModelPosition(viewLineNumber, this.getViewLineMinColumn(viewLineNumber));
  66920. var modelMinPosition = this.convertViewPositionToModelPosition(minLineNumber, this.getViewLineMinColumn(minLineNumber));
  66921. var modelMaxPosition = this.convertViewPositionToModelPosition(maxLineNumber, this.getViewLineMinColumn(maxLineNumber));
  66922. var result = this.model.getActiveIndentGuide(modelPosition.lineNumber, modelMinPosition.lineNumber, modelMaxPosition.lineNumber);
  66923. var viewStartPosition = this.convertModelPositionToViewPosition(result.startLineNumber, 1);
  66924. var viewEndPosition = this.convertModelPositionToViewPosition(result.endLineNumber, this.model.getLineMaxColumn(result.endLineNumber));
  66925. return {
  66926. startLineNumber: viewStartPosition.lineNumber,
  66927. endLineNumber: viewEndPosition.lineNumber,
  66928. indent: result.indent
  66929. };
  66930. };
  66931. SplitLinesCollection.prototype.getViewLinesIndentGuides = function (viewStartLineNumber, viewEndLineNumber) {
  66932. viewStartLineNumber = this._toValidViewLineNumber(viewStartLineNumber);
  66933. viewEndLineNumber = this._toValidViewLineNumber(viewEndLineNumber);
  66934. var modelStart = this.convertViewPositionToModelPosition(viewStartLineNumber, this.getViewLineMinColumn(viewStartLineNumber));
  66935. var modelEnd = this.convertViewPositionToModelPosition(viewEndLineNumber, this.getViewLineMaxColumn(viewEndLineNumber));
  66936. var result = [];
  66937. var resultRepeatCount = [];
  66938. var resultRepeatOption = [];
  66939. var modelStartLineIndex = modelStart.lineNumber - 1;
  66940. var modelEndLineIndex = modelEnd.lineNumber - 1;
  66941. var reqStart = null;
  66942. for (var modelLineIndex = modelStartLineIndex; modelLineIndex <= modelEndLineIndex; modelLineIndex++) {
  66943. var line = this.lines[modelLineIndex];
  66944. if (line.isVisible()) {
  66945. var viewLineStartIndex = line.getViewLineNumberOfModelPosition(0, modelLineIndex === modelStartLineIndex ? modelStart.column : 1);
  66946. var viewLineEndIndex = line.getViewLineNumberOfModelPosition(0, this.model.getLineMaxColumn(modelLineIndex + 1));
  66947. var count = viewLineEndIndex - viewLineStartIndex + 1;
  66948. var option = 0 /* BlockNone */;
  66949. if (count > 1 && line.getViewLineMinColumn(this.model, modelLineIndex + 1, viewLineEndIndex) === 1) {
  66950. // wrapped lines should block indent guides
  66951. option = (viewLineStartIndex === 0 ? 1 /* BlockSubsequent */ : 2 /* BlockAll */);
  66952. }
  66953. resultRepeatCount.push(count);
  66954. resultRepeatOption.push(option);
  66955. // merge into previous request
  66956. if (reqStart === null) {
  66957. reqStart = new position_1.Position(modelLineIndex + 1, 0);
  66958. }
  66959. }
  66960. else {
  66961. // hit invisible line => flush request
  66962. if (reqStart !== null) {
  66963. result = result.concat(this.model.getLinesIndentGuides(reqStart.lineNumber, modelLineIndex));
  66964. reqStart = null;
  66965. }
  66966. }
  66967. }
  66968. if (reqStart !== null) {
  66969. result = result.concat(this.model.getLinesIndentGuides(reqStart.lineNumber, modelEnd.lineNumber));
  66970. reqStart = null;
  66971. }
  66972. var viewLineCount = viewEndLineNumber - viewStartLineNumber + 1;
  66973. var viewIndents = new Array(viewLineCount);
  66974. var currIndex = 0;
  66975. for (var i = 0, len = result.length; i < len; i++) {
  66976. var value = result[i];
  66977. var count = Math.min(viewLineCount - currIndex, resultRepeatCount[i]);
  66978. var option = resultRepeatOption[i];
  66979. var blockAtIndex = void 0;
  66980. if (option === 2 /* BlockAll */) {
  66981. blockAtIndex = 0;
  66982. }
  66983. else if (option === 1 /* BlockSubsequent */) {
  66984. blockAtIndex = 1;
  66985. }
  66986. else {
  66987. blockAtIndex = count;
  66988. }
  66989. for (var j = 0; j < count; j++) {
  66990. if (j === blockAtIndex) {
  66991. value = 0;
  66992. }
  66993. viewIndents[currIndex++] = value;
  66994. }
  66995. }
  66996. return viewIndents;
  66997. };
  66998. SplitLinesCollection.prototype.getViewLineContent = function (viewLineNumber) {
  66999. viewLineNumber = this._toValidViewLineNumber(viewLineNumber);
  67000. var r = this.prefixSumComputer.getIndexOf(viewLineNumber - 1);
  67001. var lineIndex = r.index;
  67002. var remainder = r.remainder;
  67003. return this.lines[lineIndex].getViewLineContent(this.model, lineIndex + 1, remainder);
  67004. };
  67005. SplitLinesCollection.prototype.getViewLineLength = function (viewLineNumber) {
  67006. viewLineNumber = this._toValidViewLineNumber(viewLineNumber);
  67007. var r = this.prefixSumComputer.getIndexOf(viewLineNumber - 1);
  67008. var lineIndex = r.index;
  67009. var remainder = r.remainder;
  67010. return this.lines[lineIndex].getViewLineLength(this.model, lineIndex + 1, remainder);
  67011. };
  67012. SplitLinesCollection.prototype.getViewLineMinColumn = function (viewLineNumber) {
  67013. viewLineNumber = this._toValidViewLineNumber(viewLineNumber);
  67014. var r = this.prefixSumComputer.getIndexOf(viewLineNumber - 1);
  67015. var lineIndex = r.index;
  67016. var remainder = r.remainder;
  67017. return this.lines[lineIndex].getViewLineMinColumn(this.model, lineIndex + 1, remainder);
  67018. };
  67019. SplitLinesCollection.prototype.getViewLineMaxColumn = function (viewLineNumber) {
  67020. viewLineNumber = this._toValidViewLineNumber(viewLineNumber);
  67021. var r = this.prefixSumComputer.getIndexOf(viewLineNumber - 1);
  67022. var lineIndex = r.index;
  67023. var remainder = r.remainder;
  67024. return this.lines[lineIndex].getViewLineMaxColumn(this.model, lineIndex + 1, remainder);
  67025. };
  67026. SplitLinesCollection.prototype.getViewLineData = function (viewLineNumber) {
  67027. viewLineNumber = this._toValidViewLineNumber(viewLineNumber);
  67028. var r = this.prefixSumComputer.getIndexOf(viewLineNumber - 1);
  67029. var lineIndex = r.index;
  67030. var remainder = r.remainder;
  67031. return this.lines[lineIndex].getViewLineData(this.model, lineIndex + 1, remainder);
  67032. };
  67033. SplitLinesCollection.prototype.getViewLinesData = function (viewStartLineNumber, viewEndLineNumber, needed) {
  67034. viewStartLineNumber = this._toValidViewLineNumber(viewStartLineNumber);
  67035. viewEndLineNumber = this._toValidViewLineNumber(viewEndLineNumber);
  67036. var start = this.prefixSumComputer.getIndexOf(viewStartLineNumber - 1);
  67037. var viewLineNumber = viewStartLineNumber;
  67038. var startModelLineIndex = start.index;
  67039. var startRemainder = start.remainder;
  67040. var result = [];
  67041. for (var modelLineIndex = startModelLineIndex, len = this.model.getLineCount(); modelLineIndex < len; modelLineIndex++) {
  67042. var line = this.lines[modelLineIndex];
  67043. if (!line.isVisible()) {
  67044. continue;
  67045. }
  67046. var fromViewLineIndex = (modelLineIndex === startModelLineIndex ? startRemainder : 0);
  67047. var remainingViewLineCount = line.getViewLineCount() - fromViewLineIndex;
  67048. var lastLine = false;
  67049. if (viewLineNumber + remainingViewLineCount > viewEndLineNumber) {
  67050. lastLine = true;
  67051. remainingViewLineCount = viewEndLineNumber - viewLineNumber + 1;
  67052. }
  67053. var toViewLineIndex = fromViewLineIndex + remainingViewLineCount;
  67054. line.getViewLinesData(this.model, modelLineIndex + 1, fromViewLineIndex, toViewLineIndex, viewLineNumber - viewStartLineNumber, needed, result);
  67055. viewLineNumber += remainingViewLineCount;
  67056. if (lastLine) {
  67057. break;
  67058. }
  67059. }
  67060. return result;
  67061. };
  67062. SplitLinesCollection.prototype.validateViewPosition = function (viewLineNumber, viewColumn, expectedModelPosition) {
  67063. viewLineNumber = this._toValidViewLineNumber(viewLineNumber);
  67064. var r = this.prefixSumComputer.getIndexOf(viewLineNumber - 1);
  67065. var lineIndex = r.index;
  67066. var remainder = r.remainder;
  67067. var line = this.lines[lineIndex];
  67068. var minColumn = line.getViewLineMinColumn(this.model, lineIndex + 1, remainder);
  67069. var maxColumn = line.getViewLineMaxColumn(this.model, lineIndex + 1, remainder);
  67070. if (viewColumn < minColumn) {
  67071. viewColumn = minColumn;
  67072. }
  67073. if (viewColumn > maxColumn) {
  67074. viewColumn = maxColumn;
  67075. }
  67076. var computedModelColumn = line.getModelColumnOfViewPosition(remainder, viewColumn);
  67077. var computedModelPosition = this.model.validatePosition(new position_1.Position(lineIndex + 1, computedModelColumn));
  67078. if (computedModelPosition.equals(expectedModelPosition)) {
  67079. return new position_1.Position(viewLineNumber, viewColumn);
  67080. }
  67081. return this.convertModelPositionToViewPosition(expectedModelPosition.lineNumber, expectedModelPosition.column);
  67082. };
  67083. SplitLinesCollection.prototype.validateViewRange = function (viewRange, expectedModelRange) {
  67084. var validViewStart = this.validateViewPosition(viewRange.startLineNumber, viewRange.startColumn, expectedModelRange.getStartPosition());
  67085. var validViewEnd = this.validateViewPosition(viewRange.endLineNumber, viewRange.endColumn, expectedModelRange.getEndPosition());
  67086. return new range_1.Range(validViewStart.lineNumber, validViewStart.column, validViewEnd.lineNumber, validViewEnd.column);
  67087. };
  67088. SplitLinesCollection.prototype.convertViewPositionToModelPosition = function (viewLineNumber, viewColumn) {
  67089. viewLineNumber = this._toValidViewLineNumber(viewLineNumber);
  67090. var r = this.prefixSumComputer.getIndexOf(viewLineNumber - 1);
  67091. var lineIndex = r.index;
  67092. var remainder = r.remainder;
  67093. var inputColumn = this.lines[lineIndex].getModelColumnOfViewPosition(remainder, viewColumn);
  67094. // console.log('out -> in ' + viewLineNumber + ',' + viewColumn + ' ===> ' + (lineIndex+1) + ',' + inputColumn);
  67095. return this.model.validatePosition(new position_1.Position(lineIndex + 1, inputColumn));
  67096. };
  67097. SplitLinesCollection.prototype.convertViewRangeToModelRange = function (viewRange) {
  67098. var start = this.convertViewPositionToModelPosition(viewRange.startLineNumber, viewRange.startColumn);
  67099. var end = this.convertViewPositionToModelPosition(viewRange.endLineNumber, viewRange.endColumn);
  67100. return new range_1.Range(start.lineNumber, start.column, end.lineNumber, end.column);
  67101. };
  67102. SplitLinesCollection.prototype.convertModelPositionToViewPosition = function (_modelLineNumber, _modelColumn) {
  67103. var validPosition = this.model.validatePosition(new position_1.Position(_modelLineNumber, _modelColumn));
  67104. var inputLineNumber = validPosition.lineNumber;
  67105. var inputColumn = validPosition.column;
  67106. var lineIndex = inputLineNumber - 1, lineIndexChanged = false;
  67107. while (lineIndex > 0 && !this.lines[lineIndex].isVisible()) {
  67108. lineIndex--;
  67109. lineIndexChanged = true;
  67110. }
  67111. if (lineIndex === 0 && !this.lines[lineIndex].isVisible()) {
  67112. // Could not reach a real line
  67113. // console.log('in -> out ' + inputLineNumber + ',' + inputColumn + ' ===> ' + 1 + ',' + 1);
  67114. return new position_1.Position(1, 1);
  67115. }
  67116. var deltaLineNumber = 1 + (lineIndex === 0 ? 0 : this.prefixSumComputer.getAccumulatedValue(lineIndex - 1));
  67117. var r;
  67118. if (lineIndexChanged) {
  67119. r = this.lines[lineIndex].getViewPositionOfModelPosition(deltaLineNumber, this.model.getLineMaxColumn(lineIndex + 1));
  67120. }
  67121. else {
  67122. r = this.lines[inputLineNumber - 1].getViewPositionOfModelPosition(deltaLineNumber, inputColumn);
  67123. }
  67124. // console.log('in -> out ' + inputLineNumber + ',' + inputColumn + ' ===> ' + r.lineNumber + ',' + r);
  67125. return r;
  67126. };
  67127. SplitLinesCollection.prototype.convertModelRangeToViewRange = function (modelRange) {
  67128. var start = this.convertModelPositionToViewPosition(modelRange.startLineNumber, modelRange.startColumn);
  67129. var end = this.convertModelPositionToViewPosition(modelRange.endLineNumber, modelRange.endColumn);
  67130. if (modelRange.startLineNumber === modelRange.endLineNumber && start.lineNumber !== end.lineNumber) {
  67131. // This is a single line range that ends up taking more lines due to wrapping
  67132. if (end.column === this.getViewLineMinColumn(end.lineNumber)) {
  67133. // the end column lands on the first column of the next line
  67134. return new range_1.Range(start.lineNumber, start.column, end.lineNumber - 1, this.getViewLineMaxColumn(end.lineNumber - 1));
  67135. }
  67136. }
  67137. return new range_1.Range(start.lineNumber, start.column, end.lineNumber, end.column);
  67138. };
  67139. SplitLinesCollection.prototype._getViewLineNumberForModelPosition = function (inputLineNumber, inputColumn) {
  67140. var lineIndex = inputLineNumber - 1;
  67141. if (this.lines[lineIndex].isVisible()) {
  67142. // this model line is visible
  67143. var deltaLineNumber_1 = 1 + (lineIndex === 0 ? 0 : this.prefixSumComputer.getAccumulatedValue(lineIndex - 1));
  67144. return this.lines[lineIndex].getViewLineNumberOfModelPosition(deltaLineNumber_1, inputColumn);
  67145. }
  67146. // this model line is not visible
  67147. while (lineIndex > 0 && !this.lines[lineIndex].isVisible()) {
  67148. lineIndex--;
  67149. }
  67150. if (lineIndex === 0 && !this.lines[lineIndex].isVisible()) {
  67151. // Could not reach a real line
  67152. return 1;
  67153. }
  67154. var deltaLineNumber = 1 + (lineIndex === 0 ? 0 : this.prefixSumComputer.getAccumulatedValue(lineIndex - 1));
  67155. return this.lines[lineIndex].getViewLineNumberOfModelPosition(deltaLineNumber, this.model.getLineMaxColumn(lineIndex + 1));
  67156. };
  67157. SplitLinesCollection.prototype.getAllOverviewRulerDecorations = function (ownerId, filterOutValidation, theme) {
  67158. var decorations = this.model.getOverviewRulerDecorations(ownerId, filterOutValidation);
  67159. var result = new OverviewRulerDecorations();
  67160. for (var _i = 0, decorations_1 = decorations; _i < decorations_1.length; _i++) {
  67161. var decoration = decorations_1[_i];
  67162. var opts = decoration.options.overviewRuler;
  67163. var lane = opts ? opts.position : 0;
  67164. if (lane === 0) {
  67165. continue;
  67166. }
  67167. var color = opts.getColor(theme);
  67168. var viewStartLineNumber = this._getViewLineNumberForModelPosition(decoration.range.startLineNumber, decoration.range.startColumn);
  67169. var viewEndLineNumber = this._getViewLineNumberForModelPosition(decoration.range.endLineNumber, decoration.range.endColumn);
  67170. result.accept(color, viewStartLineNumber, viewEndLineNumber, lane);
  67171. }
  67172. return result.result;
  67173. };
  67174. SplitLinesCollection.prototype.getDecorationsInRange = function (range, ownerId, filterOutValidation) {
  67175. var modelStart = this.convertViewPositionToModelPosition(range.startLineNumber, range.startColumn);
  67176. var modelEnd = this.convertViewPositionToModelPosition(range.endLineNumber, range.endColumn);
  67177. if (modelEnd.lineNumber - modelStart.lineNumber <= range.endLineNumber - range.startLineNumber) {
  67178. // most likely there are no hidden lines => fast path
  67179. // fetch decorations from column 1 to cover the case of wrapped lines that have whole line decorations at column 1
  67180. return this.model.getDecorationsInRange(new range_1.Range(modelStart.lineNumber, 1, modelEnd.lineNumber, modelEnd.column), ownerId, filterOutValidation);
  67181. }
  67182. var result = [];
  67183. var modelStartLineIndex = modelStart.lineNumber - 1;
  67184. var modelEndLineIndex = modelEnd.lineNumber - 1;
  67185. var reqStart = null;
  67186. for (var modelLineIndex = modelStartLineIndex; modelLineIndex <= modelEndLineIndex; modelLineIndex++) {
  67187. var line = this.lines[modelLineIndex];
  67188. if (line.isVisible()) {
  67189. // merge into previous request
  67190. if (reqStart === null) {
  67191. reqStart = new position_1.Position(modelLineIndex + 1, modelLineIndex === modelStartLineIndex ? modelStart.column : 1);
  67192. }
  67193. }
  67194. else {
  67195. // hit invisible line => flush request
  67196. if (reqStart !== null) {
  67197. var maxLineColumn = this.model.getLineMaxColumn(modelLineIndex);
  67198. result = result.concat(this.model.getDecorationsInRange(new range_1.Range(reqStart.lineNumber, reqStart.column, modelLineIndex, maxLineColumn), ownerId, filterOutValidation));
  67199. reqStart = null;
  67200. }
  67201. }
  67202. }
  67203. if (reqStart !== null) {
  67204. result = result.concat(this.model.getDecorationsInRange(new range_1.Range(reqStart.lineNumber, reqStart.column, modelEnd.lineNumber, modelEnd.column), ownerId, filterOutValidation));
  67205. reqStart = null;
  67206. }
  67207. result.sort(function (a, b) {
  67208. var res = range_1.Range.compareRangesUsingStarts(a.range, b.range);
  67209. if (res === 0) {
  67210. if (a.id < b.id) {
  67211. return -1;
  67212. }
  67213. if (a.id > b.id) {
  67214. return 1;
  67215. }
  67216. return 0;
  67217. }
  67218. return res;
  67219. });
  67220. // Eliminate duplicate decorations that might have intersected our visible ranges multiple times
  67221. var finalResult = [], finalResultLen = 0;
  67222. var prevDecId = null;
  67223. for (var _i = 0, result_1 = result; _i < result_1.length; _i++) {
  67224. var dec = result_1[_i];
  67225. var decId = dec.id;
  67226. if (prevDecId === decId) {
  67227. // skip
  67228. continue;
  67229. }
  67230. prevDecId = decId;
  67231. finalResult[finalResultLen++] = dec;
  67232. }
  67233. return finalResult;
  67234. };
  67235. return SplitLinesCollection;
  67236. }());
  67237. exports.SplitLinesCollection = SplitLinesCollection;
  67238. var VisibleIdentitySplitLine = /** @class */ (function () {
  67239. function VisibleIdentitySplitLine() {
  67240. }
  67241. VisibleIdentitySplitLine.prototype.isVisible = function () {
  67242. return true;
  67243. };
  67244. VisibleIdentitySplitLine.prototype.setVisible = function (isVisible) {
  67245. if (isVisible) {
  67246. return this;
  67247. }
  67248. return InvisibleIdentitySplitLine.INSTANCE;
  67249. };
  67250. VisibleIdentitySplitLine.prototype.getLineBreakData = function () {
  67251. return null;
  67252. };
  67253. VisibleIdentitySplitLine.prototype.getViewLineCount = function () {
  67254. return 1;
  67255. };
  67256. VisibleIdentitySplitLine.prototype.getViewLineContent = function (model, modelLineNumber, _outputLineIndex) {
  67257. return model.getLineContent(modelLineNumber);
  67258. };
  67259. VisibleIdentitySplitLine.prototype.getViewLineLength = function (model, modelLineNumber, _outputLineIndex) {
  67260. return model.getLineLength(modelLineNumber);
  67261. };
  67262. VisibleIdentitySplitLine.prototype.getViewLineMinColumn = function (model, modelLineNumber, _outputLineIndex) {
  67263. return model.getLineMinColumn(modelLineNumber);
  67264. };
  67265. VisibleIdentitySplitLine.prototype.getViewLineMaxColumn = function (model, modelLineNumber, _outputLineIndex) {
  67266. return model.getLineMaxColumn(modelLineNumber);
  67267. };
  67268. VisibleIdentitySplitLine.prototype.getViewLineData = function (model, modelLineNumber, _outputLineIndex) {
  67269. var lineTokens = model.getLineTokens(modelLineNumber);
  67270. var lineContent = lineTokens.getLineContent();
  67271. return new viewModel_1.ViewLineData(lineContent, false, 1, lineContent.length + 1, 0, lineTokens.inflate());
  67272. };
  67273. VisibleIdentitySplitLine.prototype.getViewLinesData = function (model, modelLineNumber, _fromOuputLineIndex, _toOutputLineIndex, globalStartIndex, needed, result) {
  67274. if (!needed[globalStartIndex]) {
  67275. result[globalStartIndex] = null;
  67276. return;
  67277. }
  67278. result[globalStartIndex] = this.getViewLineData(model, modelLineNumber, 0);
  67279. };
  67280. VisibleIdentitySplitLine.prototype.getModelColumnOfViewPosition = function (_outputLineIndex, outputColumn) {
  67281. return outputColumn;
  67282. };
  67283. VisibleIdentitySplitLine.prototype.getViewPositionOfModelPosition = function (deltaLineNumber, inputColumn) {
  67284. return new position_1.Position(deltaLineNumber, inputColumn);
  67285. };
  67286. VisibleIdentitySplitLine.prototype.getViewLineNumberOfModelPosition = function (deltaLineNumber, _inputColumn) {
  67287. return deltaLineNumber;
  67288. };
  67289. VisibleIdentitySplitLine.INSTANCE = new VisibleIdentitySplitLine();
  67290. return VisibleIdentitySplitLine;
  67291. }());
  67292. var InvisibleIdentitySplitLine = /** @class */ (function () {
  67293. function InvisibleIdentitySplitLine() {
  67294. }
  67295. InvisibleIdentitySplitLine.prototype.isVisible = function () {
  67296. return false;
  67297. };
  67298. InvisibleIdentitySplitLine.prototype.setVisible = function (isVisible) {
  67299. if (!isVisible) {
  67300. return this;
  67301. }
  67302. return VisibleIdentitySplitLine.INSTANCE;
  67303. };
  67304. InvisibleIdentitySplitLine.prototype.getLineBreakData = function () {
  67305. return null;
  67306. };
  67307. InvisibleIdentitySplitLine.prototype.getViewLineCount = function () {
  67308. return 0;
  67309. };
  67310. InvisibleIdentitySplitLine.prototype.getViewLineContent = function (_model, _modelLineNumber, _outputLineIndex) {
  67311. throw new Error('Not supported');
  67312. };
  67313. InvisibleIdentitySplitLine.prototype.getViewLineLength = function (_model, _modelLineNumber, _outputLineIndex) {
  67314. throw new Error('Not supported');
  67315. };
  67316. InvisibleIdentitySplitLine.prototype.getViewLineMinColumn = function (_model, _modelLineNumber, _outputLineIndex) {
  67317. throw new Error('Not supported');
  67318. };
  67319. InvisibleIdentitySplitLine.prototype.getViewLineMaxColumn = function (_model, _modelLineNumber, _outputLineIndex) {
  67320. throw new Error('Not supported');
  67321. };
  67322. InvisibleIdentitySplitLine.prototype.getViewLineData = function (_model, _modelLineNumber, _outputLineIndex) {
  67323. throw new Error('Not supported');
  67324. };
  67325. InvisibleIdentitySplitLine.prototype.getViewLinesData = function (_model, _modelLineNumber, _fromOuputLineIndex, _toOutputLineIndex, _globalStartIndex, _needed, _result) {
  67326. throw new Error('Not supported');
  67327. };
  67328. InvisibleIdentitySplitLine.prototype.getModelColumnOfViewPosition = function (_outputLineIndex, _outputColumn) {
  67329. throw new Error('Not supported');
  67330. };
  67331. InvisibleIdentitySplitLine.prototype.getViewPositionOfModelPosition = function (_deltaLineNumber, _inputColumn) {
  67332. throw new Error('Not supported');
  67333. };
  67334. InvisibleIdentitySplitLine.prototype.getViewLineNumberOfModelPosition = function (_deltaLineNumber, _inputColumn) {
  67335. throw new Error('Not supported');
  67336. };
  67337. InvisibleIdentitySplitLine.INSTANCE = new InvisibleIdentitySplitLine();
  67338. return InvisibleIdentitySplitLine;
  67339. }());
  67340. var SplitLine = /** @class */ (function () {
  67341. function SplitLine(lineBreakData, isVisible) {
  67342. this._lineBreakData = lineBreakData;
  67343. this._isVisible = isVisible;
  67344. }
  67345. SplitLine.prototype.isVisible = function () {
  67346. return this._isVisible;
  67347. };
  67348. SplitLine.prototype.setVisible = function (isVisible) {
  67349. this._isVisible = isVisible;
  67350. return this;
  67351. };
  67352. SplitLine.prototype.getLineBreakData = function () {
  67353. return this._lineBreakData;
  67354. };
  67355. SplitLine.prototype.getViewLineCount = function () {
  67356. if (!this._isVisible) {
  67357. return 0;
  67358. }
  67359. return this._lineBreakData.breakOffsets.length;
  67360. };
  67361. SplitLine.prototype.getInputStartOffsetOfOutputLineIndex = function (outputLineIndex) {
  67362. return LineBreakData.getInputOffsetOfOutputPosition(this._lineBreakData.breakOffsets, outputLineIndex, 0);
  67363. };
  67364. SplitLine.prototype.getInputEndOffsetOfOutputLineIndex = function (model, modelLineNumber, outputLineIndex) {
  67365. if (outputLineIndex + 1 === this._lineBreakData.breakOffsets.length) {
  67366. return model.getLineMaxColumn(modelLineNumber) - 1;
  67367. }
  67368. return LineBreakData.getInputOffsetOfOutputPosition(this._lineBreakData.breakOffsets, outputLineIndex + 1, 0);
  67369. };
  67370. SplitLine.prototype.getViewLineContent = function (model, modelLineNumber, outputLineIndex) {
  67371. if (!this._isVisible) {
  67372. throw new Error('Not supported');
  67373. }
  67374. var startOffset = this.getInputStartOffsetOfOutputLineIndex(outputLineIndex);
  67375. var endOffset = this.getInputEndOffsetOfOutputLineIndex(model, modelLineNumber, outputLineIndex);
  67376. var r = model.getValueInRange({
  67377. startLineNumber: modelLineNumber,
  67378. startColumn: startOffset + 1,
  67379. endLineNumber: modelLineNumber,
  67380. endColumn: endOffset + 1
  67381. });
  67382. if (outputLineIndex > 0) {
  67383. r = spaces(this._lineBreakData.wrappedTextIndentLength) + r;
  67384. }
  67385. return r;
  67386. };
  67387. SplitLine.prototype.getViewLineLength = function (model, modelLineNumber, outputLineIndex) {
  67388. if (!this._isVisible) {
  67389. throw new Error('Not supported');
  67390. }
  67391. var startOffset = this.getInputStartOffsetOfOutputLineIndex(outputLineIndex);
  67392. var endOffset = this.getInputEndOffsetOfOutputLineIndex(model, modelLineNumber, outputLineIndex);
  67393. var r = endOffset - startOffset;
  67394. if (outputLineIndex > 0) {
  67395. r = this._lineBreakData.wrappedTextIndentLength + r;
  67396. }
  67397. return r;
  67398. };
  67399. SplitLine.prototype.getViewLineMinColumn = function (_model, _modelLineNumber, outputLineIndex) {
  67400. if (!this._isVisible) {
  67401. throw new Error('Not supported');
  67402. }
  67403. if (outputLineIndex > 0) {
  67404. return this._lineBreakData.wrappedTextIndentLength + 1;
  67405. }
  67406. return 1;
  67407. };
  67408. SplitLine.prototype.getViewLineMaxColumn = function (model, modelLineNumber, outputLineIndex) {
  67409. if (!this._isVisible) {
  67410. throw new Error('Not supported');
  67411. }
  67412. return this.getViewLineContent(model, modelLineNumber, outputLineIndex).length + 1;
  67413. };
  67414. SplitLine.prototype.getViewLineData = function (model, modelLineNumber, outputLineIndex) {
  67415. if (!this._isVisible) {
  67416. throw new Error('Not supported');
  67417. }
  67418. var startOffset = this.getInputStartOffsetOfOutputLineIndex(outputLineIndex);
  67419. var endOffset = this.getInputEndOffsetOfOutputLineIndex(model, modelLineNumber, outputLineIndex);
  67420. var lineContent = model.getValueInRange({
  67421. startLineNumber: modelLineNumber,
  67422. startColumn: startOffset + 1,
  67423. endLineNumber: modelLineNumber,
  67424. endColumn: endOffset + 1
  67425. });
  67426. if (outputLineIndex > 0) {
  67427. lineContent = spaces(this._lineBreakData.wrappedTextIndentLength) + lineContent;
  67428. }
  67429. var minColumn = (outputLineIndex > 0 ? this._lineBreakData.wrappedTextIndentLength + 1 : 1);
  67430. var maxColumn = lineContent.length + 1;
  67431. var continuesWithWrappedLine = (outputLineIndex + 1 < this.getViewLineCount());
  67432. var deltaStartIndex = 0;
  67433. if (outputLineIndex > 0) {
  67434. deltaStartIndex = this._lineBreakData.wrappedTextIndentLength;
  67435. }
  67436. var lineTokens = model.getLineTokens(modelLineNumber);
  67437. var startVisibleColumn = (outputLineIndex === 0 ? 0 : this._lineBreakData.breakOffsetsVisibleColumn[outputLineIndex - 1]);
  67438. return new viewModel_1.ViewLineData(lineContent, continuesWithWrappedLine, minColumn, maxColumn, startVisibleColumn, lineTokens.sliceAndInflate(startOffset, endOffset, deltaStartIndex));
  67439. };
  67440. SplitLine.prototype.getViewLinesData = function (model, modelLineNumber, fromOuputLineIndex, toOutputLineIndex, globalStartIndex, needed, result) {
  67441. if (!this._isVisible) {
  67442. throw new Error('Not supported');
  67443. }
  67444. for (var outputLineIndex = fromOuputLineIndex; outputLineIndex < toOutputLineIndex; outputLineIndex++) {
  67445. var globalIndex = globalStartIndex + outputLineIndex - fromOuputLineIndex;
  67446. if (!needed[globalIndex]) {
  67447. result[globalIndex] = null;
  67448. continue;
  67449. }
  67450. result[globalIndex] = this.getViewLineData(model, modelLineNumber, outputLineIndex);
  67451. }
  67452. };
  67453. SplitLine.prototype.getModelColumnOfViewPosition = function (outputLineIndex, outputColumn) {
  67454. if (!this._isVisible) {
  67455. throw new Error('Not supported');
  67456. }
  67457. var adjustedColumn = outputColumn - 1;
  67458. if (outputLineIndex > 0) {
  67459. if (adjustedColumn < this._lineBreakData.wrappedTextIndentLength) {
  67460. adjustedColumn = 0;
  67461. }
  67462. else {
  67463. adjustedColumn -= this._lineBreakData.wrappedTextIndentLength;
  67464. }
  67465. }
  67466. return LineBreakData.getInputOffsetOfOutputPosition(this._lineBreakData.breakOffsets, outputLineIndex, adjustedColumn) + 1;
  67467. };
  67468. SplitLine.prototype.getViewPositionOfModelPosition = function (deltaLineNumber, inputColumn) {
  67469. if (!this._isVisible) {
  67470. throw new Error('Not supported');
  67471. }
  67472. var r = LineBreakData.getOutputPositionOfInputOffset(this._lineBreakData.breakOffsets, inputColumn - 1);
  67473. var outputLineIndex = r.outputLineIndex;
  67474. var outputColumn = r.outputOffset + 1;
  67475. if (outputLineIndex > 0) {
  67476. outputColumn += this._lineBreakData.wrappedTextIndentLength;
  67477. }
  67478. // console.log('in -> out ' + deltaLineNumber + ',' + inputColumn + ' ===> ' + (deltaLineNumber+outputLineIndex) + ',' + outputColumn);
  67479. return new position_1.Position(deltaLineNumber + outputLineIndex, outputColumn);
  67480. };
  67481. SplitLine.prototype.getViewLineNumberOfModelPosition = function (deltaLineNumber, inputColumn) {
  67482. if (!this._isVisible) {
  67483. throw new Error('Not supported');
  67484. }
  67485. var r = LineBreakData.getOutputPositionOfInputOffset(this._lineBreakData.breakOffsets, inputColumn - 1);
  67486. return (deltaLineNumber + r.outputLineIndex);
  67487. };
  67488. return SplitLine;
  67489. }());
  67490. exports.SplitLine = SplitLine;
  67491. var _spaces = [''];
  67492. function spaces(count) {
  67493. if (count >= _spaces.length) {
  67494. for (var i = 1; i <= count; i++) {
  67495. _spaces[i] = _makeSpaces(i);
  67496. }
  67497. }
  67498. return _spaces[count];
  67499. }
  67500. function _makeSpaces(count) {
  67501. return new Array(count + 1).join(' ');
  67502. }
  67503. function createSplitLine(lineBreakData, isVisible) {
  67504. if (lineBreakData === null) {
  67505. // No mapping needed
  67506. if (isVisible) {
  67507. return VisibleIdentitySplitLine.INSTANCE;
  67508. }
  67509. return InvisibleIdentitySplitLine.INSTANCE;
  67510. }
  67511. else {
  67512. return new SplitLine(lineBreakData, isVisible);
  67513. }
  67514. }
  67515. var IdentityCoordinatesConverter = /** @class */ (function () {
  67516. function IdentityCoordinatesConverter(lines) {
  67517. this._lines = lines;
  67518. }
  67519. IdentityCoordinatesConverter.prototype._validPosition = function (pos) {
  67520. return this._lines.model.validatePosition(pos);
  67521. };
  67522. IdentityCoordinatesConverter.prototype._validRange = function (range) {
  67523. return this._lines.model.validateRange(range);
  67524. };
  67525. // View -> Model conversion and related methods
  67526. IdentityCoordinatesConverter.prototype.convertViewPositionToModelPosition = function (viewPosition) {
  67527. return this._validPosition(viewPosition);
  67528. };
  67529. IdentityCoordinatesConverter.prototype.convertViewRangeToModelRange = function (viewRange) {
  67530. return this._validRange(viewRange);
  67531. };
  67532. IdentityCoordinatesConverter.prototype.validateViewPosition = function (_viewPosition, expectedModelPosition) {
  67533. return this._validPosition(expectedModelPosition);
  67534. };
  67535. IdentityCoordinatesConverter.prototype.validateViewRange = function (_viewRange, expectedModelRange) {
  67536. return this._validRange(expectedModelRange);
  67537. };
  67538. // Model -> View conversion and related methods
  67539. IdentityCoordinatesConverter.prototype.convertModelPositionToViewPosition = function (modelPosition) {
  67540. return this._validPosition(modelPosition);
  67541. };
  67542. IdentityCoordinatesConverter.prototype.convertModelRangeToViewRange = function (modelRange) {
  67543. return this._validRange(modelRange);
  67544. };
  67545. IdentityCoordinatesConverter.prototype.modelPositionIsVisible = function (modelPosition) {
  67546. var lineCount = this._lines.model.getLineCount();
  67547. if (modelPosition.lineNumber < 1 || modelPosition.lineNumber > lineCount) {
  67548. // invalid arguments
  67549. return false;
  67550. }
  67551. return true;
  67552. };
  67553. return IdentityCoordinatesConverter;
  67554. }());
  67555. exports.IdentityCoordinatesConverter = IdentityCoordinatesConverter;
  67556. var IdentityLinesCollection = /** @class */ (function () {
  67557. function IdentityLinesCollection(model) {
  67558. this.model = model;
  67559. }
  67560. IdentityLinesCollection.prototype.dispose = function () {
  67561. };
  67562. IdentityLinesCollection.prototype.createCoordinatesConverter = function () {
  67563. return new IdentityCoordinatesConverter(this);
  67564. };
  67565. IdentityLinesCollection.prototype.getHiddenAreas = function () {
  67566. return [];
  67567. };
  67568. IdentityLinesCollection.prototype.setHiddenAreas = function (_ranges) {
  67569. return false;
  67570. };
  67571. IdentityLinesCollection.prototype.setTabSize = function (_newTabSize) {
  67572. return false;
  67573. };
  67574. IdentityLinesCollection.prototype.setWrappingSettings = function (_fontInfo, _wrappingStrategy, _wrappingColumn, _wrappingIndent) {
  67575. return false;
  67576. };
  67577. IdentityLinesCollection.prototype.createLineBreaksComputer = function () {
  67578. var result = [];
  67579. return {
  67580. addRequest: function (lineText, previousLineBreakData) {
  67581. result.push(null);
  67582. },
  67583. finalize: function () {
  67584. return result;
  67585. }
  67586. };
  67587. };
  67588. IdentityLinesCollection.prototype.onModelFlushed = function () {
  67589. };
  67590. IdentityLinesCollection.prototype.onModelLinesDeleted = function (_versionId, fromLineNumber, toLineNumber) {
  67591. return new viewEvents.ViewLinesDeletedEvent(fromLineNumber, toLineNumber);
  67592. };
  67593. IdentityLinesCollection.prototype.onModelLinesInserted = function (_versionId, fromLineNumber, toLineNumber, lineBreaks) {
  67594. return new viewEvents.ViewLinesInsertedEvent(fromLineNumber, toLineNumber);
  67595. };
  67596. IdentityLinesCollection.prototype.onModelLineChanged = function (_versionId, lineNumber, lineBreakData) {
  67597. return [false, new viewEvents.ViewLinesChangedEvent(lineNumber, lineNumber), null, null];
  67598. };
  67599. IdentityLinesCollection.prototype.acceptVersionId = function (_versionId) {
  67600. };
  67601. IdentityLinesCollection.prototype.getViewLineCount = function () {
  67602. return this.model.getLineCount();
  67603. };
  67604. IdentityLinesCollection.prototype.getActiveIndentGuide = function (viewLineNumber, _minLineNumber, _maxLineNumber) {
  67605. return {
  67606. startLineNumber: viewLineNumber,
  67607. endLineNumber: viewLineNumber,
  67608. indent: 0
  67609. };
  67610. };
  67611. IdentityLinesCollection.prototype.getViewLinesIndentGuides = function (viewStartLineNumber, viewEndLineNumber) {
  67612. var viewLineCount = viewEndLineNumber - viewStartLineNumber + 1;
  67613. var result = new Array(viewLineCount);
  67614. for (var i = 0; i < viewLineCount; i++) {
  67615. result[i] = 0;
  67616. }
  67617. return result;
  67618. };
  67619. IdentityLinesCollection.prototype.getViewLineContent = function (viewLineNumber) {
  67620. return this.model.getLineContent(viewLineNumber);
  67621. };
  67622. IdentityLinesCollection.prototype.getViewLineLength = function (viewLineNumber) {
  67623. return this.model.getLineLength(viewLineNumber);
  67624. };
  67625. IdentityLinesCollection.prototype.getViewLineMinColumn = function (viewLineNumber) {
  67626. return this.model.getLineMinColumn(viewLineNumber);
  67627. };
  67628. IdentityLinesCollection.prototype.getViewLineMaxColumn = function (viewLineNumber) {
  67629. return this.model.getLineMaxColumn(viewLineNumber);
  67630. };
  67631. IdentityLinesCollection.prototype.getViewLineData = function (viewLineNumber) {
  67632. var lineTokens = this.model.getLineTokens(viewLineNumber);
  67633. var lineContent = lineTokens.getLineContent();
  67634. return new viewModel_1.ViewLineData(lineContent, false, 1, lineContent.length + 1, 0, lineTokens.inflate());
  67635. };
  67636. IdentityLinesCollection.prototype.getViewLinesData = function (viewStartLineNumber, viewEndLineNumber, needed) {
  67637. var lineCount = this.model.getLineCount();
  67638. viewStartLineNumber = Math.min(Math.max(1, viewStartLineNumber), lineCount);
  67639. viewEndLineNumber = Math.min(Math.max(1, viewEndLineNumber), lineCount);
  67640. var result = [];
  67641. for (var lineNumber = viewStartLineNumber; lineNumber <= viewEndLineNumber; lineNumber++) {
  67642. var idx = lineNumber - viewStartLineNumber;
  67643. if (!needed[idx]) {
  67644. result[idx] = null;
  67645. }
  67646. result[idx] = this.getViewLineData(lineNumber);
  67647. }
  67648. return result;
  67649. };
  67650. IdentityLinesCollection.prototype.getAllOverviewRulerDecorations = function (ownerId, filterOutValidation, theme) {
  67651. var decorations = this.model.getOverviewRulerDecorations(ownerId, filterOutValidation);
  67652. var result = new OverviewRulerDecorations();
  67653. for (var _i = 0, decorations_2 = decorations; _i < decorations_2.length; _i++) {
  67654. var decoration = decorations_2[_i];
  67655. var opts = decoration.options.overviewRuler;
  67656. var lane = opts ? opts.position : 0;
  67657. if (lane === 0) {
  67658. continue;
  67659. }
  67660. var color = opts.getColor(theme);
  67661. var viewStartLineNumber = decoration.range.startLineNumber;
  67662. var viewEndLineNumber = decoration.range.endLineNumber;
  67663. result.accept(color, viewStartLineNumber, viewEndLineNumber, lane);
  67664. }
  67665. return result.result;
  67666. };
  67667. IdentityLinesCollection.prototype.getDecorationsInRange = function (range, ownerId, filterOutValidation) {
  67668. return this.model.getDecorationsInRange(range, ownerId, filterOutValidation);
  67669. };
  67670. return IdentityLinesCollection;
  67671. }());
  67672. exports.IdentityLinesCollection = IdentityLinesCollection;
  67673. var OverviewRulerDecorations = /** @class */ (function () {
  67674. function OverviewRulerDecorations() {
  67675. this.result = Object.create(null);
  67676. }
  67677. OverviewRulerDecorations.prototype.accept = function (color, startLineNumber, endLineNumber, lane) {
  67678. var prev = this.result[color];
  67679. if (prev) {
  67680. var prevLane = prev[prev.length - 3];
  67681. var prevEndLineNumber = prev[prev.length - 1];
  67682. if (prevLane === lane && prevEndLineNumber + 1 >= startLineNumber) {
  67683. // merge into prev
  67684. if (endLineNumber > prevEndLineNumber) {
  67685. prev[prev.length - 1] = endLineNumber;
  67686. }
  67687. return;
  67688. }
  67689. // push
  67690. prev.push(lane, startLineNumber, endLineNumber);
  67691. }
  67692. else {
  67693. this.result[color] = [lane, startLineNumber, endLineNumber];
  67694. }
  67695. };
  67696. return OverviewRulerDecorations;
  67697. }());
  67698. });
  67699. /*---------------------------------------------------------------------------------------------
  67700. * Copyright (c) Microsoft Corporation. All rights reserved.
  67701. * Licensed under the MIT License. See License.txt in the project root for license information.
  67702. *--------------------------------------------------------------------------------------------*/
  67703. define(__m[487/*vs/editor/common/viewModel/monospaceLineBreaksComputer*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,79/*vs/editor/common/core/characterClassifier*/,161/*vs/editor/common/viewModel/splitLinesCollection*/]), function (require, exports, strings, characterClassifier_1, splitLinesCollection_1) {
  67704. "use strict";
  67705. Object.defineProperty(exports, "__esModule", { value: true });
  67706. var WrappingCharacterClassifier = /** @class */ (function (_super) {
  67707. __extends(WrappingCharacterClassifier, _super);
  67708. function WrappingCharacterClassifier(BREAK_BEFORE, BREAK_AFTER) {
  67709. var _this = _super.call(this, 0 /* NONE */) || this;
  67710. for (var i = 0; i < BREAK_BEFORE.length; i++) {
  67711. _this.set(BREAK_BEFORE.charCodeAt(i), 1 /* BREAK_BEFORE */);
  67712. }
  67713. for (var i = 0; i < BREAK_AFTER.length; i++) {
  67714. _this.set(BREAK_AFTER.charCodeAt(i), 2 /* BREAK_AFTER */);
  67715. }
  67716. return _this;
  67717. }
  67718. WrappingCharacterClassifier.prototype.get = function (charCode) {
  67719. if (charCode >= 0 && charCode < 256) {
  67720. return this._asciiMap[charCode];
  67721. }
  67722. else {
  67723. // Initialize CharacterClass.BREAK_IDEOGRAPHIC for these Unicode ranges:
  67724. // 1. CJK Unified Ideographs (0x4E00 -- 0x9FFF)
  67725. // 2. CJK Unified Ideographs Extension A (0x3400 -- 0x4DBF)
  67726. // 3. Hiragana and Katakana (0x3040 -- 0x30FF)
  67727. if ((charCode >= 0x3040 && charCode <= 0x30FF)
  67728. || (charCode >= 0x3400 && charCode <= 0x4DBF)
  67729. || (charCode >= 0x4E00 && charCode <= 0x9FFF)) {
  67730. return 3 /* BREAK_IDEOGRAPHIC */;
  67731. }
  67732. return (this._map.get(charCode) || this._defaultValue);
  67733. }
  67734. };
  67735. return WrappingCharacterClassifier;
  67736. }(characterClassifier_1.CharacterClassifier));
  67737. var arrPool1 = [];
  67738. var arrPool2 = [];
  67739. var MonospaceLineBreaksComputerFactory = /** @class */ (function () {
  67740. function MonospaceLineBreaksComputerFactory(breakBeforeChars, breakAfterChars) {
  67741. this.classifier = new WrappingCharacterClassifier(breakBeforeChars, breakAfterChars);
  67742. }
  67743. MonospaceLineBreaksComputerFactory.create = function (options) {
  67744. return new MonospaceLineBreaksComputerFactory(options.get(99 /* wordWrapBreakBeforeCharacters */), options.get(98 /* wordWrapBreakAfterCharacters */));
  67745. };
  67746. MonospaceLineBreaksComputerFactory.prototype.createLineBreaksComputer = function (fontInfo, tabSize, wrappingColumn, wrappingIndent) {
  67747. var _this = this;
  67748. tabSize = tabSize | 0; //@perf
  67749. wrappingColumn = +wrappingColumn; //@perf
  67750. var requests = [];
  67751. var previousBreakingData = [];
  67752. return {
  67753. addRequest: function (lineText, previousLineBreakData) {
  67754. requests.push(lineText);
  67755. previousBreakingData.push(previousLineBreakData);
  67756. },
  67757. finalize: function () {
  67758. var columnsForFullWidthChar = fontInfo.typicalFullwidthCharacterWidth / fontInfo.typicalHalfwidthCharacterWidth; //@perf
  67759. var result = [];
  67760. for (var i = 0, len = requests.length; i < len; i++) {
  67761. var previousLineBreakData = previousBreakingData[i];
  67762. if (previousLineBreakData) {
  67763. result[i] = createLineBreaksFromPreviousLineBreaks(_this.classifier, previousLineBreakData, requests[i], tabSize, wrappingColumn, columnsForFullWidthChar, wrappingIndent);
  67764. }
  67765. else {
  67766. result[i] = createLineBreaks(_this.classifier, requests[i], tabSize, wrappingColumn, columnsForFullWidthChar, wrappingIndent);
  67767. }
  67768. }
  67769. arrPool1.length = 0;
  67770. arrPool2.length = 0;
  67771. return result;
  67772. }
  67773. };
  67774. };
  67775. return MonospaceLineBreaksComputerFactory;
  67776. }());
  67777. exports.MonospaceLineBreaksComputerFactory = MonospaceLineBreaksComputerFactory;
  67778. function createLineBreaksFromPreviousLineBreaks(classifier, previousBreakingData, lineText, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent) {
  67779. if (firstLineBreakColumn === -1) {
  67780. return null;
  67781. }
  67782. var len = lineText.length;
  67783. if (len <= 1) {
  67784. return null;
  67785. }
  67786. var prevBreakingOffsets = previousBreakingData.breakOffsets;
  67787. var prevBreakingOffsetsVisibleColumn = previousBreakingData.breakOffsetsVisibleColumn;
  67788. var wrappedTextIndentLength = computeWrappedTextIndentLength(lineText, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent);
  67789. var wrappedLineBreakColumn = firstLineBreakColumn - wrappedTextIndentLength;
  67790. var breakingOffsets = arrPool1;
  67791. var breakingOffsetsVisibleColumn = arrPool2;
  67792. var breakingOffsetsCount = 0;
  67793. var breakingColumn = firstLineBreakColumn;
  67794. var prevLen = prevBreakingOffsets.length;
  67795. var prevIndex = 0;
  67796. if (prevIndex >= 0) {
  67797. var bestDistance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex] - breakingColumn);
  67798. while (prevIndex + 1 < prevLen) {
  67799. var distance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex + 1] - breakingColumn);
  67800. if (distance >= bestDistance) {
  67801. break;
  67802. }
  67803. bestDistance = distance;
  67804. prevIndex++;
  67805. }
  67806. }
  67807. while (prevIndex < prevLen) {
  67808. // Allow for prevIndex to be -1 (for the case where we hit a tab when walking backwards from the first break)
  67809. var prevBreakOffset = prevIndex < 0 ? 0 : prevBreakingOffsets[prevIndex];
  67810. var prevBreakoffsetVisibleColumn = prevIndex < 0 ? 0 : prevBreakingOffsetsVisibleColumn[prevIndex];
  67811. var breakOffset = 0;
  67812. var breakOffsetVisibleColumn = 0;
  67813. var forcedBreakOffset = 0;
  67814. var forcedBreakOffsetVisibleColumn = 0;
  67815. // initially, we search as much as possible to the right (if it fits)
  67816. if (prevBreakoffsetVisibleColumn <= breakingColumn) {
  67817. var visibleColumn = prevBreakoffsetVisibleColumn;
  67818. var prevCharCode = lineText.charCodeAt(prevBreakOffset - 1);
  67819. var prevCharCodeClass = classifier.get(prevCharCode);
  67820. var entireLineFits = true;
  67821. for (var i = prevBreakOffset; i < len; i++) {
  67822. var charStartOffset = i;
  67823. var charCode = lineText.charCodeAt(i);
  67824. var charCodeClass = void 0;
  67825. var charWidth = void 0;
  67826. if (strings.isHighSurrogate(charCode)) {
  67827. // A surrogate pair must always be considered as a single unit, so it is never to be broken
  67828. i++;
  67829. charCodeClass = 0 /* NONE */;
  67830. charWidth = 2;
  67831. }
  67832. else {
  67833. charCodeClass = classifier.get(charCode);
  67834. charWidth = computeCharWidth(charCode, visibleColumn, tabSize, columnsForFullWidthChar);
  67835. }
  67836. if (canBreak(prevCharCode, prevCharCodeClass, charCode, charCodeClass)) {
  67837. breakOffset = charStartOffset;
  67838. breakOffsetVisibleColumn = visibleColumn;
  67839. }
  67840. visibleColumn += charWidth;
  67841. // check if adding character at `i` will go over the breaking column
  67842. if (visibleColumn > breakingColumn) {
  67843. // We need to break at least before character at `i`:
  67844. forcedBreakOffset = charStartOffset;
  67845. forcedBreakOffsetVisibleColumn = visibleColumn - charWidth;
  67846. if (visibleColumn - breakOffsetVisibleColumn > wrappedLineBreakColumn) {
  67847. // Cannot break at `breakOffset` => reset it if it was set
  67848. breakOffset = 0;
  67849. }
  67850. entireLineFits = false;
  67851. break;
  67852. }
  67853. prevCharCode = charCode;
  67854. prevCharCodeClass = charCodeClass;
  67855. }
  67856. if (entireLineFits) {
  67857. // there is no more need to break => stop the outer loop!
  67858. if (breakingOffsetsCount > 0) {
  67859. // Add last segment
  67860. breakingOffsets[breakingOffsetsCount] = prevBreakingOffsets[prevBreakingOffsets.length - 1];
  67861. breakingOffsetsVisibleColumn[breakingOffsetsCount] = prevBreakingOffsetsVisibleColumn[prevBreakingOffsets.length - 1];
  67862. breakingOffsetsCount++;
  67863. }
  67864. break;
  67865. }
  67866. }
  67867. if (breakOffset === 0) {
  67868. // must search left
  67869. var visibleColumn = prevBreakoffsetVisibleColumn;
  67870. var charCode = lineText.charCodeAt(prevBreakOffset);
  67871. var charCodeClass = classifier.get(charCode);
  67872. var hitATabCharacter = false;
  67873. for (var i = prevBreakOffset - 1; i >= 0; i--) {
  67874. var charStartOffset = i + 1;
  67875. var prevCharCode = lineText.charCodeAt(i);
  67876. if (prevCharCode === 9 /* Tab */) {
  67877. // cannot determine the width of a tab when going backwards, so we must go forwards
  67878. hitATabCharacter = true;
  67879. break;
  67880. }
  67881. var prevCharCodeClass = void 0;
  67882. var prevCharWidth = void 0;
  67883. if (strings.isLowSurrogate(prevCharCode)) {
  67884. // A surrogate pair must always be considered as a single unit, so it is never to be broken
  67885. i--;
  67886. prevCharCodeClass = 0 /* NONE */;
  67887. prevCharWidth = 2;
  67888. }
  67889. else {
  67890. prevCharCodeClass = classifier.get(prevCharCode);
  67891. prevCharWidth = (strings.isFullWidthCharacter(prevCharCode) ? columnsForFullWidthChar : 1);
  67892. }
  67893. if (visibleColumn <= breakingColumn) {
  67894. if (forcedBreakOffset === 0) {
  67895. forcedBreakOffset = charStartOffset;
  67896. forcedBreakOffsetVisibleColumn = visibleColumn;
  67897. }
  67898. if (visibleColumn <= breakingColumn - wrappedLineBreakColumn) {
  67899. // went too far!
  67900. break;
  67901. }
  67902. if (canBreak(prevCharCode, prevCharCodeClass, charCode, charCodeClass)) {
  67903. breakOffset = charStartOffset;
  67904. breakOffsetVisibleColumn = visibleColumn;
  67905. break;
  67906. }
  67907. }
  67908. visibleColumn -= prevCharWidth;
  67909. charCode = prevCharCode;
  67910. charCodeClass = prevCharCodeClass;
  67911. }
  67912. if (breakOffset !== 0) {
  67913. var remainingWidthOfNextLine = wrappedLineBreakColumn - (forcedBreakOffsetVisibleColumn - breakOffsetVisibleColumn);
  67914. if (remainingWidthOfNextLine <= tabSize) {
  67915. var charCodeAtForcedBreakOffset = lineText.charCodeAt(forcedBreakOffset);
  67916. var charWidth = void 0;
  67917. if (strings.isHighSurrogate(charCodeAtForcedBreakOffset)) {
  67918. // A surrogate pair must always be considered as a single unit, so it is never to be broken
  67919. charWidth = 2;
  67920. }
  67921. else {
  67922. charWidth = computeCharWidth(charCodeAtForcedBreakOffset, forcedBreakOffsetVisibleColumn, tabSize, columnsForFullWidthChar);
  67923. }
  67924. if (remainingWidthOfNextLine - charWidth < 0) {
  67925. // it is not worth it to break at breakOffset, it just introduces an extra needless line!
  67926. breakOffset = 0;
  67927. }
  67928. }
  67929. }
  67930. if (hitATabCharacter) {
  67931. // cannot determine the width of a tab when going backwards, so we must go forwards from the previous break
  67932. prevIndex--;
  67933. continue;
  67934. }
  67935. }
  67936. if (breakOffset === 0) {
  67937. // Could not find a good breaking point
  67938. breakOffset = forcedBreakOffset;
  67939. breakOffsetVisibleColumn = forcedBreakOffsetVisibleColumn;
  67940. }
  67941. breakingOffsets[breakingOffsetsCount] = breakOffset;
  67942. breakingOffsetsVisibleColumn[breakingOffsetsCount] = breakOffsetVisibleColumn;
  67943. breakingOffsetsCount++;
  67944. breakingColumn = breakOffsetVisibleColumn + wrappedLineBreakColumn;
  67945. while (prevIndex < 0 || (prevIndex < prevLen && prevBreakingOffsetsVisibleColumn[prevIndex] < breakOffsetVisibleColumn)) {
  67946. prevIndex++;
  67947. }
  67948. var bestDistance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex] - breakingColumn);
  67949. while (prevIndex + 1 < prevLen) {
  67950. var distance = Math.abs(prevBreakingOffsetsVisibleColumn[prevIndex + 1] - breakingColumn);
  67951. if (distance >= bestDistance) {
  67952. break;
  67953. }
  67954. bestDistance = distance;
  67955. prevIndex++;
  67956. }
  67957. }
  67958. if (breakingOffsetsCount === 0) {
  67959. return null;
  67960. }
  67961. // Doing here some object reuse which ends up helping a huge deal with GC pauses!
  67962. breakingOffsets.length = breakingOffsetsCount;
  67963. breakingOffsetsVisibleColumn.length = breakingOffsetsCount;
  67964. arrPool1 = previousBreakingData.breakOffsets;
  67965. arrPool2 = previousBreakingData.breakOffsetsVisibleColumn;
  67966. previousBreakingData.breakOffsets = breakingOffsets;
  67967. previousBreakingData.breakOffsetsVisibleColumn = breakingOffsetsVisibleColumn;
  67968. previousBreakingData.wrappedTextIndentLength = wrappedTextIndentLength;
  67969. return previousBreakingData;
  67970. }
  67971. function createLineBreaks(classifier, lineText, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent) {
  67972. if (firstLineBreakColumn === -1) {
  67973. return null;
  67974. }
  67975. var len = lineText.length;
  67976. if (len <= 1) {
  67977. return null;
  67978. }
  67979. var wrappedTextIndentLength = computeWrappedTextIndentLength(lineText, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent);
  67980. var wrappedLineBreakColumn = firstLineBreakColumn - wrappedTextIndentLength;
  67981. var breakingOffsets = [];
  67982. var breakingOffsetsVisibleColumn = [];
  67983. var breakingOffsetsCount = 0;
  67984. var breakOffset = 0;
  67985. var breakOffsetVisibleColumn = 0;
  67986. var breakingColumn = firstLineBreakColumn;
  67987. var prevCharCode = lineText.charCodeAt(0);
  67988. var prevCharCodeClass = classifier.get(prevCharCode);
  67989. var visibleColumn = computeCharWidth(prevCharCode, 0, tabSize, columnsForFullWidthChar);
  67990. var startOffset = 1;
  67991. if (strings.isHighSurrogate(prevCharCode)) {
  67992. // A surrogate pair must always be considered as a single unit, so it is never to be broken
  67993. visibleColumn += 1;
  67994. prevCharCode = lineText.charCodeAt(1);
  67995. prevCharCodeClass = classifier.get(prevCharCode);
  67996. startOffset++;
  67997. }
  67998. for (var i = startOffset; i < len; i++) {
  67999. var charStartOffset = i;
  68000. var charCode = lineText.charCodeAt(i);
  68001. var charCodeClass = void 0;
  68002. var charWidth = void 0;
  68003. if (strings.isHighSurrogate(charCode)) {
  68004. // A surrogate pair must always be considered as a single unit, so it is never to be broken
  68005. i++;
  68006. charCodeClass = 0 /* NONE */;
  68007. charWidth = 2;
  68008. }
  68009. else {
  68010. charCodeClass = classifier.get(charCode);
  68011. charWidth = computeCharWidth(charCode, visibleColumn, tabSize, columnsForFullWidthChar);
  68012. }
  68013. if (canBreak(prevCharCode, prevCharCodeClass, charCode, charCodeClass)) {
  68014. breakOffset = charStartOffset;
  68015. breakOffsetVisibleColumn = visibleColumn;
  68016. }
  68017. visibleColumn += charWidth;
  68018. // check if adding character at `i` will go over the breaking column
  68019. if (visibleColumn > breakingColumn) {
  68020. // We need to break at least before character at `i`:
  68021. if (breakOffset === 0 || visibleColumn - breakOffsetVisibleColumn > wrappedLineBreakColumn) {
  68022. // Cannot break at `breakOffset`, must break at `i`
  68023. breakOffset = charStartOffset;
  68024. breakOffsetVisibleColumn = visibleColumn - charWidth;
  68025. }
  68026. breakingOffsets[breakingOffsetsCount] = breakOffset;
  68027. breakingOffsetsVisibleColumn[breakingOffsetsCount] = breakOffsetVisibleColumn;
  68028. breakingOffsetsCount++;
  68029. breakingColumn = breakOffsetVisibleColumn + wrappedLineBreakColumn;
  68030. breakOffset = 0;
  68031. }
  68032. prevCharCode = charCode;
  68033. prevCharCodeClass = charCodeClass;
  68034. }
  68035. if (breakingOffsetsCount === 0) {
  68036. return null;
  68037. }
  68038. // Add last segment
  68039. breakingOffsets[breakingOffsetsCount] = len;
  68040. breakingOffsetsVisibleColumn[breakingOffsetsCount] = visibleColumn;
  68041. return new splitLinesCollection_1.LineBreakData(breakingOffsets, breakingOffsetsVisibleColumn, wrappedTextIndentLength);
  68042. }
  68043. function computeCharWidth(charCode, visibleColumn, tabSize, columnsForFullWidthChar) {
  68044. if (charCode === 9 /* Tab */) {
  68045. return (tabSize - (visibleColumn % tabSize));
  68046. }
  68047. if (strings.isFullWidthCharacter(charCode)) {
  68048. return columnsForFullWidthChar;
  68049. }
  68050. return 1;
  68051. }
  68052. function tabCharacterWidth(visibleColumn, tabSize) {
  68053. return (tabSize - (visibleColumn % tabSize));
  68054. }
  68055. /**
  68056. * Kinsoku Shori : Don't break after a leading character, like an open bracket
  68057. * Kinsoku Shori : Don't break before a trailing character, like a period
  68058. */
  68059. function canBreak(prevCharCode, prevCharCodeClass, charCode, charCodeClass) {
  68060. return (charCode !== 32 /* Space */
  68061. && ((prevCharCodeClass === 2 /* BREAK_AFTER */)
  68062. || (prevCharCodeClass === 3 /* BREAK_IDEOGRAPHIC */ && charCodeClass !== 2 /* BREAK_AFTER */)
  68063. || (charCodeClass === 1 /* BREAK_BEFORE */)
  68064. || (charCodeClass === 3 /* BREAK_IDEOGRAPHIC */ && prevCharCodeClass !== 1 /* BREAK_BEFORE */)));
  68065. }
  68066. function computeWrappedTextIndentLength(lineText, tabSize, firstLineBreakColumn, columnsForFullWidthChar, wrappingIndent) {
  68067. var wrappedTextIndentLength = 0;
  68068. if (wrappingIndent !== 0 /* None */) {
  68069. var firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineText);
  68070. if (firstNonWhitespaceIndex !== -1) {
  68071. // Track existing indent
  68072. for (var i = 0; i < firstNonWhitespaceIndex; i++) {
  68073. var charWidth = (lineText.charCodeAt(i) === 9 /* Tab */ ? tabCharacterWidth(wrappedTextIndentLength, tabSize) : 1);
  68074. wrappedTextIndentLength += charWidth;
  68075. }
  68076. // Increase indent of continuation lines, if desired
  68077. var numberOfAdditionalTabs = (wrappingIndent === 3 /* DeepIndent */ ? 2 : wrappingIndent === 2 /* Indent */ ? 1 : 0);
  68078. for (var i = 0; i < numberOfAdditionalTabs; i++) {
  68079. var charWidth = tabCharacterWidth(wrappedTextIndentLength, tabSize);
  68080. wrappedTextIndentLength += charWidth;
  68081. }
  68082. // Force sticking to beginning of line if no character would fit except for the indentation
  68083. if (wrappedTextIndentLength + columnsForFullWidthChar > firstLineBreakColumn) {
  68084. wrappedTextIndentLength = 0;
  68085. }
  68086. }
  68087. }
  68088. return wrappedTextIndentLength;
  68089. }
  68090. });
  68091. /*---------------------------------------------------------------------------------------------
  68092. * Copyright (c) Microsoft Corporation. All rights reserved.
  68093. * Licensed under the MIT License. See License.txt in the project root for license information.
  68094. *--------------------------------------------------------------------------------------------*/
  68095. define(__m[488/*vs/editor/common/viewModel/viewModelImpl*/], __M([0/*require*/,1/*exports*/,27/*vs/base/common/color*/,5/*vs/base/common/strings*/,33/*vs/editor/common/config/editorOptions*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,17/*vs/editor/common/modes*/,214/*vs/editor/common/modes/textToHtmlTokenizer*/,215/*vs/editor/common/viewModel/minimapTokensColorTracker*/,81/*vs/editor/common/view/viewEvents*/,373/*vs/editor/common/viewLayout/viewLayout*/,161/*vs/editor/common/viewModel/splitLinesCollection*/,69/*vs/editor/common/viewModel/viewModel*/,424/*vs/editor/common/viewModel/viewModelDecorations*/,15/*vs/base/common/async*/,16/*vs/base/common/platform*/]), function (require, exports, color_1, strings, editorOptions_1, position_1, range_1, modes_1, textToHtmlTokenizer_1, minimapTokensColorTracker_1, viewEvents, viewLayout_1, splitLinesCollection_1, viewModel_1, viewModelDecorations_1, async_1, platform) {
  68096. "use strict";
  68097. Object.defineProperty(exports, "__esModule", { value: true });
  68098. var USE_IDENTITY_LINES_COLLECTION = true;
  68099. var ViewModel = /** @class */ (function (_super) {
  68100. __extends(ViewModel, _super);
  68101. function ViewModel(editorId, configuration, model, domLineBreaksComputerFactory, monospaceLineBreaksComputerFactory, scheduleAtNextAnimationFrame) {
  68102. var _this = _super.call(this) || this;
  68103. _this.editorId = editorId;
  68104. _this.configuration = configuration;
  68105. _this.model = model;
  68106. _this._tokenizeViewportSoon = _this._register(new async_1.RunOnceScheduler(function () { return _this.tokenizeViewport(); }, 50));
  68107. _this.hasFocus = false;
  68108. _this.viewportStartLine = -1;
  68109. _this.viewportStartLineTrackedRange = null;
  68110. _this.viewportStartLineDelta = 0;
  68111. if (USE_IDENTITY_LINES_COLLECTION && _this.model.isTooLargeForTokenization()) {
  68112. _this.lines = new splitLinesCollection_1.IdentityLinesCollection(_this.model);
  68113. }
  68114. else {
  68115. var options = _this.configuration.options;
  68116. var fontInfo = options.get(34 /* fontInfo */);
  68117. var wrappingStrategy = options.get(103 /* wrappingStrategy */);
  68118. var wrappingInfo = options.get(108 /* wrappingInfo */);
  68119. var wrappingIndent = options.get(102 /* wrappingIndent */);
  68120. _this.lines = new splitLinesCollection_1.SplitLinesCollection(_this.model, domLineBreaksComputerFactory, monospaceLineBreaksComputerFactory, fontInfo, _this.model.getOptions().tabSize, wrappingStrategy, wrappingInfo.wrappingColumn, wrappingIndent);
  68121. }
  68122. _this.coordinatesConverter = _this.lines.createCoordinatesConverter();
  68123. _this.viewLayout = _this._register(new viewLayout_1.ViewLayout(_this.configuration, _this.getLineCount(), scheduleAtNextAnimationFrame));
  68124. _this._register(_this.viewLayout.onDidScroll(function (e) {
  68125. if (e.scrollTopChanged) {
  68126. _this._tokenizeViewportSoon.schedule();
  68127. }
  68128. try {
  68129. var eventsCollector = _this._beginEmit();
  68130. eventsCollector.emit(new viewEvents.ViewScrollChangedEvent(e));
  68131. }
  68132. finally {
  68133. _this._endEmit();
  68134. }
  68135. }));
  68136. _this._register(_this.viewLayout.onDidContentSizeChange(function (e) {
  68137. try {
  68138. var eventsCollector = _this._beginEmit();
  68139. eventsCollector.emit(new viewEvents.ViewContentSizeChangedEvent(e));
  68140. }
  68141. finally {
  68142. _this._endEmit();
  68143. }
  68144. }));
  68145. _this.decorations = new viewModelDecorations_1.ViewModelDecorations(_this.editorId, _this.model, _this.configuration, _this.lines, _this.coordinatesConverter);
  68146. _this._registerModelEvents();
  68147. _this._register(_this.configuration.onDidChange(function (e) {
  68148. try {
  68149. var eventsCollector = _this._beginEmit();
  68150. _this._onConfigurationChanged(eventsCollector, e);
  68151. }
  68152. finally {
  68153. _this._endEmit();
  68154. }
  68155. }));
  68156. _this._register(minimapTokensColorTracker_1.MinimapTokensColorTracker.getInstance().onDidChange(function () {
  68157. try {
  68158. var eventsCollector = _this._beginEmit();
  68159. eventsCollector.emit(new viewEvents.ViewTokensColorsChangedEvent());
  68160. }
  68161. finally {
  68162. _this._endEmit();
  68163. }
  68164. }));
  68165. return _this;
  68166. }
  68167. ViewModel.prototype.dispose = function () {
  68168. // First remove listeners, as disposing the lines might end up sending
  68169. // model decoration changed events ... and we no longer care about them ...
  68170. _super.prototype.dispose.call(this);
  68171. this.decorations.dispose();
  68172. this.lines.dispose();
  68173. this.invalidateMinimapColorCache();
  68174. this.viewportStartLineTrackedRange = this.model._setTrackedRange(this.viewportStartLineTrackedRange, null, 1 /* NeverGrowsWhenTypingAtEdges */);
  68175. };
  68176. ViewModel.prototype.tokenizeViewport = function () {
  68177. var linesViewportData = this.viewLayout.getLinesViewportData();
  68178. var startPosition = this.coordinatesConverter.convertViewPositionToModelPosition(new position_1.Position(linesViewportData.startLineNumber, 1));
  68179. var endPosition = this.coordinatesConverter.convertViewPositionToModelPosition(new position_1.Position(linesViewportData.endLineNumber, 1));
  68180. this.model.tokenizeViewport(startPosition.lineNumber, endPosition.lineNumber);
  68181. };
  68182. ViewModel.prototype.setHasFocus = function (hasFocus) {
  68183. this.hasFocus = hasFocus;
  68184. };
  68185. ViewModel.prototype._onConfigurationChanged = function (eventsCollector, e) {
  68186. // We might need to restore the current centered view range, so save it (if available)
  68187. var previousViewportStartModelPosition = null;
  68188. if (this.viewportStartLine !== -1) {
  68189. var previousViewportStartViewPosition = new position_1.Position(this.viewportStartLine, this.getLineMinColumn(this.viewportStartLine));
  68190. previousViewportStartModelPosition = this.coordinatesConverter.convertViewPositionToModelPosition(previousViewportStartViewPosition);
  68191. }
  68192. var restorePreviousViewportStart = false;
  68193. var options = this.configuration.options;
  68194. var fontInfo = options.get(34 /* fontInfo */);
  68195. var wrappingStrategy = options.get(103 /* wrappingStrategy */);
  68196. var wrappingInfo = options.get(108 /* wrappingInfo */);
  68197. var wrappingIndent = options.get(102 /* wrappingIndent */);
  68198. if (this.lines.setWrappingSettings(fontInfo, wrappingStrategy, wrappingInfo.wrappingColumn, wrappingIndent)) {
  68199. eventsCollector.emit(new viewEvents.ViewFlushedEvent());
  68200. eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
  68201. eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
  68202. this.decorations.onLineMappingChanged();
  68203. this.viewLayout.onFlushed(this.getLineCount());
  68204. if (this.viewLayout.getCurrentScrollTop() !== 0) {
  68205. // Never change the scroll position from 0 to something else...
  68206. restorePreviousViewportStart = true;
  68207. }
  68208. }
  68209. if (e.hasChanged(68 /* readOnly */)) {
  68210. // Must read again all decorations due to readOnly filtering
  68211. this.decorations.reset();
  68212. eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
  68213. }
  68214. eventsCollector.emit(new viewEvents.ViewConfigurationChangedEvent(e));
  68215. this.viewLayout.onConfigurationChanged(e);
  68216. if (restorePreviousViewportStart && previousViewportStartModelPosition) {
  68217. var viewPosition = this.coordinatesConverter.convertModelPositionToViewPosition(previousViewportStartModelPosition);
  68218. var viewPositionTop = this.viewLayout.getVerticalOffsetForLineNumber(viewPosition.lineNumber);
  68219. this.viewLayout.setScrollPositionNow({ scrollTop: viewPositionTop + this.viewportStartLineDelta });
  68220. }
  68221. };
  68222. ViewModel.prototype._registerModelEvents = function () {
  68223. var _this = this;
  68224. this._register(this.model.onDidChangeRawContentFast(function (e) {
  68225. try {
  68226. var eventsCollector = _this._beginEmit();
  68227. var hadOtherModelChange = false;
  68228. var hadModelLineChangeThatChangedLineMapping = false;
  68229. var changes = e.changes;
  68230. var versionId = e.versionId;
  68231. // Do a first pass to compute line mappings, and a second pass to actually interpret them
  68232. var lineBreaksComputer = _this.lines.createLineBreaksComputer();
  68233. for (var _i = 0, changes_1 = changes; _i < changes_1.length; _i++) {
  68234. var change = changes_1[_i];
  68235. switch (change.changeType) {
  68236. case 4 /* LinesInserted */: {
  68237. for (var _a = 0, _b = change.detail; _a < _b.length; _a++) {
  68238. var line = _b[_a];
  68239. lineBreaksComputer.addRequest(line, null);
  68240. }
  68241. break;
  68242. }
  68243. case 2 /* LineChanged */: {
  68244. lineBreaksComputer.addRequest(change.detail, null);
  68245. break;
  68246. }
  68247. }
  68248. }
  68249. var lineBreaks = lineBreaksComputer.finalize();
  68250. var lineBreaksOffset = 0;
  68251. for (var _c = 0, changes_2 = changes; _c < changes_2.length; _c++) {
  68252. var change = changes_2[_c];
  68253. switch (change.changeType) {
  68254. case 1 /* Flush */: {
  68255. _this.lines.onModelFlushed();
  68256. eventsCollector.emit(new viewEvents.ViewFlushedEvent());
  68257. _this.decorations.reset();
  68258. _this.viewLayout.onFlushed(_this.getLineCount());
  68259. hadOtherModelChange = true;
  68260. break;
  68261. }
  68262. case 3 /* LinesDeleted */: {
  68263. var linesDeletedEvent = _this.lines.onModelLinesDeleted(versionId, change.fromLineNumber, change.toLineNumber);
  68264. if (linesDeletedEvent !== null) {
  68265. eventsCollector.emit(linesDeletedEvent);
  68266. _this.viewLayout.onLinesDeleted(linesDeletedEvent.fromLineNumber, linesDeletedEvent.toLineNumber);
  68267. }
  68268. hadOtherModelChange = true;
  68269. break;
  68270. }
  68271. case 4 /* LinesInserted */: {
  68272. var insertedLineBreaks = lineBreaks.slice(lineBreaksOffset, lineBreaksOffset + change.detail.length);
  68273. lineBreaksOffset += change.detail.length;
  68274. var linesInsertedEvent = _this.lines.onModelLinesInserted(versionId, change.fromLineNumber, change.toLineNumber, insertedLineBreaks);
  68275. if (linesInsertedEvent !== null) {
  68276. eventsCollector.emit(linesInsertedEvent);
  68277. _this.viewLayout.onLinesInserted(linesInsertedEvent.fromLineNumber, linesInsertedEvent.toLineNumber);
  68278. }
  68279. hadOtherModelChange = true;
  68280. break;
  68281. }
  68282. case 2 /* LineChanged */: {
  68283. var changedLineBreakData = lineBreaks[lineBreaksOffset];
  68284. lineBreaksOffset++;
  68285. var _d = _this.lines.onModelLineChanged(versionId, change.lineNumber, changedLineBreakData), lineMappingChanged = _d[0], linesChangedEvent = _d[1], linesInsertedEvent = _d[2], linesDeletedEvent = _d[3];
  68286. hadModelLineChangeThatChangedLineMapping = lineMappingChanged;
  68287. if (linesChangedEvent) {
  68288. eventsCollector.emit(linesChangedEvent);
  68289. }
  68290. if (linesInsertedEvent) {
  68291. eventsCollector.emit(linesInsertedEvent);
  68292. _this.viewLayout.onLinesInserted(linesInsertedEvent.fromLineNumber, linesInsertedEvent.toLineNumber);
  68293. }
  68294. if (linesDeletedEvent) {
  68295. eventsCollector.emit(linesDeletedEvent);
  68296. _this.viewLayout.onLinesDeleted(linesDeletedEvent.fromLineNumber, linesDeletedEvent.toLineNumber);
  68297. }
  68298. break;
  68299. }
  68300. case 5 /* EOLChanged */: {
  68301. // Nothing to do. The new version will be accepted below
  68302. break;
  68303. }
  68304. }
  68305. }
  68306. _this.lines.acceptVersionId(versionId);
  68307. _this.viewLayout.onHeightMaybeChanged();
  68308. if (!hadOtherModelChange && hadModelLineChangeThatChangedLineMapping) {
  68309. eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
  68310. eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
  68311. _this.decorations.onLineMappingChanged();
  68312. }
  68313. }
  68314. finally {
  68315. _this._endEmit();
  68316. }
  68317. // Update the configuration and reset the centered view line
  68318. _this.viewportStartLine = -1;
  68319. _this.configuration.setMaxLineNumber(_this.model.getLineCount());
  68320. // Recover viewport
  68321. if (!_this.hasFocus && _this.model.getAttachedEditorCount() >= 2 && _this.viewportStartLineTrackedRange) {
  68322. var modelRange = _this.model._getTrackedRange(_this.viewportStartLineTrackedRange);
  68323. if (modelRange) {
  68324. var viewPosition = _this.coordinatesConverter.convertModelPositionToViewPosition(modelRange.getStartPosition());
  68325. var viewPositionTop = _this.viewLayout.getVerticalOffsetForLineNumber(viewPosition.lineNumber);
  68326. _this.viewLayout.setScrollPositionNow({ scrollTop: viewPositionTop + _this.viewportStartLineDelta });
  68327. }
  68328. }
  68329. }));
  68330. this._register(this.model.onDidChangeTokens(function (e) {
  68331. var viewRanges = [];
  68332. for (var j = 0, lenJ = e.ranges.length; j < lenJ; j++) {
  68333. var modelRange = e.ranges[j];
  68334. var viewStartLineNumber = _this.coordinatesConverter.convertModelPositionToViewPosition(new position_1.Position(modelRange.fromLineNumber, 1)).lineNumber;
  68335. var viewEndLineNumber = _this.coordinatesConverter.convertModelPositionToViewPosition(new position_1.Position(modelRange.toLineNumber, _this.model.getLineMaxColumn(modelRange.toLineNumber))).lineNumber;
  68336. viewRanges[j] = {
  68337. fromLineNumber: viewStartLineNumber,
  68338. toLineNumber: viewEndLineNumber
  68339. };
  68340. }
  68341. try {
  68342. var eventsCollector = _this._beginEmit();
  68343. eventsCollector.emit(new viewEvents.ViewTokensChangedEvent(viewRanges));
  68344. }
  68345. finally {
  68346. _this._endEmit();
  68347. }
  68348. if (e.tokenizationSupportChanged) {
  68349. _this._tokenizeViewportSoon.schedule();
  68350. }
  68351. }));
  68352. this._register(this.model.onDidChangeLanguageConfiguration(function (e) {
  68353. try {
  68354. var eventsCollector = _this._beginEmit();
  68355. eventsCollector.emit(new viewEvents.ViewLanguageConfigurationEvent());
  68356. }
  68357. finally {
  68358. _this._endEmit();
  68359. }
  68360. }));
  68361. this._register(this.model.onDidChangeOptions(function (e) {
  68362. // A tab size change causes a line mapping changed event => all view parts will repaint OK, no further event needed here
  68363. if (_this.lines.setTabSize(_this.model.getOptions().tabSize)) {
  68364. _this.decorations.onLineMappingChanged();
  68365. _this.viewLayout.onFlushed(_this.getLineCount());
  68366. try {
  68367. var eventsCollector = _this._beginEmit();
  68368. eventsCollector.emit(new viewEvents.ViewFlushedEvent());
  68369. eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
  68370. eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
  68371. }
  68372. finally {
  68373. _this._endEmit();
  68374. }
  68375. }
  68376. }));
  68377. this._register(this.model.onDidChangeDecorations(function (e) {
  68378. _this.decorations.onModelDecorationsChanged();
  68379. try {
  68380. var eventsCollector = _this._beginEmit();
  68381. eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
  68382. }
  68383. finally {
  68384. _this._endEmit();
  68385. }
  68386. }));
  68387. };
  68388. ViewModel.prototype.setHiddenAreas = function (ranges) {
  68389. try {
  68390. var eventsCollector = this._beginEmit();
  68391. var lineMappingChanged = this.lines.setHiddenAreas(ranges);
  68392. if (lineMappingChanged) {
  68393. eventsCollector.emit(new viewEvents.ViewFlushedEvent());
  68394. eventsCollector.emit(new viewEvents.ViewLineMappingChangedEvent());
  68395. eventsCollector.emit(new viewEvents.ViewDecorationsChangedEvent());
  68396. this.decorations.onLineMappingChanged();
  68397. this.viewLayout.onFlushed(this.getLineCount());
  68398. this.viewLayout.onHeightMaybeChanged();
  68399. }
  68400. }
  68401. finally {
  68402. this._endEmit();
  68403. }
  68404. };
  68405. ViewModel.prototype.getVisibleRanges = function () {
  68406. var visibleViewRange = this.getCompletelyVisibleViewRange();
  68407. var visibleRange = this.coordinatesConverter.convertViewRangeToModelRange(visibleViewRange);
  68408. var hiddenAreas = this.lines.getHiddenAreas();
  68409. if (hiddenAreas.length === 0) {
  68410. return [visibleRange];
  68411. }
  68412. var result = [], resultLen = 0;
  68413. var startLineNumber = visibleRange.startLineNumber;
  68414. var startColumn = visibleRange.startColumn;
  68415. var endLineNumber = visibleRange.endLineNumber;
  68416. var endColumn = visibleRange.endColumn;
  68417. for (var i = 0, len = hiddenAreas.length; i < len; i++) {
  68418. var hiddenStartLineNumber = hiddenAreas[i].startLineNumber;
  68419. var hiddenEndLineNumber = hiddenAreas[i].endLineNumber;
  68420. if (hiddenEndLineNumber < startLineNumber) {
  68421. continue;
  68422. }
  68423. if (hiddenStartLineNumber > endLineNumber) {
  68424. continue;
  68425. }
  68426. if (startLineNumber < hiddenStartLineNumber) {
  68427. result[resultLen++] = new range_1.Range(startLineNumber, startColumn, hiddenStartLineNumber - 1, this.model.getLineMaxColumn(hiddenStartLineNumber - 1));
  68428. }
  68429. startLineNumber = hiddenEndLineNumber + 1;
  68430. startColumn = 1;
  68431. }
  68432. if (startLineNumber < endLineNumber || (startLineNumber === endLineNumber && startColumn < endColumn)) {
  68433. result[resultLen++] = new range_1.Range(startLineNumber, startColumn, endLineNumber, endColumn);
  68434. }
  68435. return result;
  68436. };
  68437. ViewModel.prototype.getCompletelyVisibleViewRange = function () {
  68438. var partialData = this.viewLayout.getLinesViewportData();
  68439. var startViewLineNumber = partialData.completelyVisibleStartLineNumber;
  68440. var endViewLineNumber = partialData.completelyVisibleEndLineNumber;
  68441. return new range_1.Range(startViewLineNumber, this.getLineMinColumn(startViewLineNumber), endViewLineNumber, this.getLineMaxColumn(endViewLineNumber));
  68442. };
  68443. ViewModel.prototype.getCompletelyVisibleViewRangeAtScrollTop = function (scrollTop) {
  68444. var partialData = this.viewLayout.getLinesViewportDataAtScrollTop(scrollTop);
  68445. var startViewLineNumber = partialData.completelyVisibleStartLineNumber;
  68446. var endViewLineNumber = partialData.completelyVisibleEndLineNumber;
  68447. return new range_1.Range(startViewLineNumber, this.getLineMinColumn(startViewLineNumber), endViewLineNumber, this.getLineMaxColumn(endViewLineNumber));
  68448. };
  68449. ViewModel.prototype.saveState = function () {
  68450. var compatViewState = this.viewLayout.saveState();
  68451. var scrollTop = compatViewState.scrollTop;
  68452. var firstViewLineNumber = this.viewLayout.getLineNumberAtVerticalOffset(scrollTop);
  68453. var firstPosition = this.coordinatesConverter.convertViewPositionToModelPosition(new position_1.Position(firstViewLineNumber, this.getLineMinColumn(firstViewLineNumber)));
  68454. var firstPositionDeltaTop = this.viewLayout.getVerticalOffsetForLineNumber(firstViewLineNumber) - scrollTop;
  68455. return {
  68456. scrollLeft: compatViewState.scrollLeft,
  68457. firstPosition: firstPosition,
  68458. firstPositionDeltaTop: firstPositionDeltaTop
  68459. };
  68460. };
  68461. ViewModel.prototype.reduceRestoreState = function (state) {
  68462. if (typeof state.firstPosition === 'undefined') {
  68463. // This is a view state serialized by an older version
  68464. return this._reduceRestoreStateCompatibility(state);
  68465. }
  68466. var modelPosition = this.model.validatePosition(state.firstPosition);
  68467. var viewPosition = this.coordinatesConverter.convertModelPositionToViewPosition(modelPosition);
  68468. var scrollTop = this.viewLayout.getVerticalOffsetForLineNumber(viewPosition.lineNumber) - state.firstPositionDeltaTop;
  68469. return {
  68470. scrollLeft: state.scrollLeft,
  68471. scrollTop: scrollTop
  68472. };
  68473. };
  68474. ViewModel.prototype._reduceRestoreStateCompatibility = function (state) {
  68475. return {
  68476. scrollLeft: state.scrollLeft,
  68477. scrollTop: state.scrollTopWithoutViewZones
  68478. };
  68479. };
  68480. ViewModel.prototype.getTabSize = function () {
  68481. return this.model.getOptions().tabSize;
  68482. };
  68483. ViewModel.prototype.getOptions = function () {
  68484. return this.model.getOptions();
  68485. };
  68486. ViewModel.prototype.getLineCount = function () {
  68487. return this.lines.getViewLineCount();
  68488. };
  68489. /**
  68490. * Gives a hint that a lot of requests are about to come in for these line numbers.
  68491. */
  68492. ViewModel.prototype.setViewport = function (startLineNumber, endLineNumber, centeredLineNumber) {
  68493. this.viewportStartLine = startLineNumber;
  68494. var position = this.coordinatesConverter.convertViewPositionToModelPosition(new position_1.Position(startLineNumber, this.getLineMinColumn(startLineNumber)));
  68495. this.viewportStartLineTrackedRange = this.model._setTrackedRange(this.viewportStartLineTrackedRange, new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column), 1 /* NeverGrowsWhenTypingAtEdges */);
  68496. var viewportStartLineTop = this.viewLayout.getVerticalOffsetForLineNumber(startLineNumber);
  68497. var scrollTop = this.viewLayout.getCurrentScrollTop();
  68498. this.viewportStartLineDelta = scrollTop - viewportStartLineTop;
  68499. };
  68500. ViewModel.prototype.getActiveIndentGuide = function (lineNumber, minLineNumber, maxLineNumber) {
  68501. return this.lines.getActiveIndentGuide(lineNumber, minLineNumber, maxLineNumber);
  68502. };
  68503. ViewModel.prototype.getLinesIndentGuides = function (startLineNumber, endLineNumber) {
  68504. return this.lines.getViewLinesIndentGuides(startLineNumber, endLineNumber);
  68505. };
  68506. ViewModel.prototype.getLineContent = function (lineNumber) {
  68507. return this.lines.getViewLineContent(lineNumber);
  68508. };
  68509. ViewModel.prototype.getLineLength = function (lineNumber) {
  68510. return this.lines.getViewLineLength(lineNumber);
  68511. };
  68512. ViewModel.prototype.getLineMinColumn = function (lineNumber) {
  68513. return this.lines.getViewLineMinColumn(lineNumber);
  68514. };
  68515. ViewModel.prototype.getLineMaxColumn = function (lineNumber) {
  68516. return this.lines.getViewLineMaxColumn(lineNumber);
  68517. };
  68518. ViewModel.prototype.getLineFirstNonWhitespaceColumn = function (lineNumber) {
  68519. var result = strings.firstNonWhitespaceIndex(this.getLineContent(lineNumber));
  68520. if (result === -1) {
  68521. return 0;
  68522. }
  68523. return result + 1;
  68524. };
  68525. ViewModel.prototype.getLineLastNonWhitespaceColumn = function (lineNumber) {
  68526. var result = strings.lastNonWhitespaceIndex(this.getLineContent(lineNumber));
  68527. if (result === -1) {
  68528. return 0;
  68529. }
  68530. return result + 2;
  68531. };
  68532. ViewModel.prototype.getDecorationsInViewport = function (visibleRange) {
  68533. return this.decorations.getDecorationsViewportData(visibleRange).decorations;
  68534. };
  68535. ViewModel.prototype.getViewLineRenderingData = function (visibleRange, lineNumber) {
  68536. var mightContainRTL = this.model.mightContainRTL();
  68537. var mightContainNonBasicASCII = this.model.mightContainNonBasicASCII();
  68538. var tabSize = this.getTabSize();
  68539. var lineData = this.lines.getViewLineData(lineNumber);
  68540. var allInlineDecorations = this.decorations.getDecorationsViewportData(visibleRange).inlineDecorations;
  68541. var inlineDecorations = allInlineDecorations[lineNumber - visibleRange.startLineNumber];
  68542. return new viewModel_1.ViewLineRenderingData(lineData.minColumn, lineData.maxColumn, lineData.content, lineData.continuesWithWrappedLine, mightContainRTL, mightContainNonBasicASCII, lineData.tokens, inlineDecorations, tabSize, lineData.startVisibleColumn);
  68543. };
  68544. ViewModel.prototype.getViewLineData = function (lineNumber) {
  68545. return this.lines.getViewLineData(lineNumber);
  68546. };
  68547. ViewModel.prototype.getMinimapLinesRenderingData = function (startLineNumber, endLineNumber, needed) {
  68548. var result = this.lines.getViewLinesData(startLineNumber, endLineNumber, needed);
  68549. return new viewModel_1.MinimapLinesRenderingData(this.getTabSize(), result);
  68550. };
  68551. ViewModel.prototype.getAllOverviewRulerDecorations = function (theme) {
  68552. return this.lines.getAllOverviewRulerDecorations(this.editorId, editorOptions_1.filterValidationDecorations(this.configuration.options), theme);
  68553. };
  68554. ViewModel.prototype.invalidateOverviewRulerColorCache = function () {
  68555. var decorations = this.model.getOverviewRulerDecorations();
  68556. for (var _i = 0, decorations_1 = decorations; _i < decorations_1.length; _i++) {
  68557. var decoration = decorations_1[_i];
  68558. var opts = decoration.options.overviewRuler;
  68559. if (opts) {
  68560. opts.invalidateCachedColor();
  68561. }
  68562. }
  68563. };
  68564. ViewModel.prototype.invalidateMinimapColorCache = function () {
  68565. var decorations = this.model.getAllDecorations();
  68566. for (var _i = 0, decorations_2 = decorations; _i < decorations_2.length; _i++) {
  68567. var decoration = decorations_2[_i];
  68568. var opts = decoration.options.minimap;
  68569. if (opts) {
  68570. opts.invalidateCachedColor();
  68571. }
  68572. }
  68573. };
  68574. ViewModel.prototype.getValueInRange = function (range, eol) {
  68575. var modelRange = this.coordinatesConverter.convertViewRangeToModelRange(range);
  68576. return this.model.getValueInRange(modelRange, eol);
  68577. };
  68578. ViewModel.prototype.getModelLineMaxColumn = function (modelLineNumber) {
  68579. return this.model.getLineMaxColumn(modelLineNumber);
  68580. };
  68581. ViewModel.prototype.validateModelPosition = function (position) {
  68582. return this.model.validatePosition(position);
  68583. };
  68584. ViewModel.prototype.validateModelRange = function (range) {
  68585. return this.model.validateRange(range);
  68586. };
  68587. ViewModel.prototype.deduceModelPositionRelativeToViewPosition = function (viewAnchorPosition, deltaOffset, lineFeedCnt) {
  68588. var modelAnchor = this.coordinatesConverter.convertViewPositionToModelPosition(viewAnchorPosition);
  68589. if (this.model.getEOL().length === 2) {
  68590. // This model uses CRLF, so the delta must take that into account
  68591. if (deltaOffset < 0) {
  68592. deltaOffset -= lineFeedCnt;
  68593. }
  68594. else {
  68595. deltaOffset += lineFeedCnt;
  68596. }
  68597. }
  68598. var modelAnchorOffset = this.model.getOffsetAt(modelAnchor);
  68599. var resultOffset = modelAnchorOffset + deltaOffset;
  68600. return this.model.getPositionAt(resultOffset);
  68601. };
  68602. ViewModel.prototype.getEOL = function () {
  68603. return this.model.getEOL();
  68604. };
  68605. ViewModel.prototype.getPlainTextToCopy = function (modelRanges, emptySelectionClipboard, forceCRLF) {
  68606. var newLineCharacter = forceCRLF ? '\r\n' : this.model.getEOL();
  68607. modelRanges = modelRanges.slice(0);
  68608. modelRanges.sort(range_1.Range.compareRangesUsingStarts);
  68609. var hasEmptyRange = false;
  68610. var hasNonEmptyRange = false;
  68611. for (var _i = 0, modelRanges_1 = modelRanges; _i < modelRanges_1.length; _i++) {
  68612. var range = modelRanges_1[_i];
  68613. if (range.isEmpty()) {
  68614. hasEmptyRange = true;
  68615. }
  68616. else {
  68617. hasNonEmptyRange = true;
  68618. }
  68619. }
  68620. if (!hasNonEmptyRange) {
  68621. // all ranges are empty
  68622. if (!emptySelectionClipboard) {
  68623. return '';
  68624. }
  68625. var modelLineNumbers = modelRanges.map(function (r) { return r.startLineNumber; });
  68626. var result_1 = '';
  68627. for (var i = 0; i < modelLineNumbers.length; i++) {
  68628. if (i > 0 && modelLineNumbers[i - 1] === modelLineNumbers[i]) {
  68629. continue;
  68630. }
  68631. result_1 += this.model.getLineContent(modelLineNumbers[i]) + newLineCharacter;
  68632. }
  68633. return result_1;
  68634. }
  68635. if (hasEmptyRange && emptySelectionClipboard) {
  68636. // mixed empty selections and non-empty selections
  68637. var result_2 = [];
  68638. var prevModelLineNumber = 0;
  68639. for (var _a = 0, modelRanges_2 = modelRanges; _a < modelRanges_2.length; _a++) {
  68640. var modelRange = modelRanges_2[_a];
  68641. var modelLineNumber = modelRange.startLineNumber;
  68642. if (modelRange.isEmpty()) {
  68643. if (modelLineNumber !== prevModelLineNumber) {
  68644. result_2.push(this.model.getLineContent(modelLineNumber));
  68645. }
  68646. }
  68647. else {
  68648. result_2.push(this.model.getValueInRange(modelRange, forceCRLF ? 2 /* CRLF */ : 0 /* TextDefined */));
  68649. }
  68650. prevModelLineNumber = modelLineNumber;
  68651. }
  68652. return result_2.length === 1 ? result_2[0] : result_2;
  68653. }
  68654. var result = [];
  68655. for (var _b = 0, modelRanges_3 = modelRanges; _b < modelRanges_3.length; _b++) {
  68656. var modelRange = modelRanges_3[_b];
  68657. if (!modelRange.isEmpty()) {
  68658. result.push(this.model.getValueInRange(modelRange, forceCRLF ? 2 /* CRLF */ : 0 /* TextDefined */));
  68659. }
  68660. }
  68661. return result.length === 1 ? result[0] : result;
  68662. };
  68663. ViewModel.prototype.getRichTextToCopy = function (modelRanges, emptySelectionClipboard) {
  68664. var languageId = this.model.getLanguageIdentifier();
  68665. if (languageId.id === 1 /* PlainText */) {
  68666. return null;
  68667. }
  68668. if (modelRanges.length !== 1) {
  68669. // no multiple selection support at this time
  68670. return null;
  68671. }
  68672. var range = modelRanges[0];
  68673. if (range.isEmpty()) {
  68674. if (!emptySelectionClipboard) {
  68675. // nothing to copy
  68676. return null;
  68677. }
  68678. var lineNumber = range.startLineNumber;
  68679. range = new range_1.Range(lineNumber, this.model.getLineMinColumn(lineNumber), lineNumber, this.model.getLineMaxColumn(lineNumber));
  68680. }
  68681. var fontInfo = this.configuration.options.get(34 /* fontInfo */);
  68682. var colorMap = this._getColorMap();
  68683. var fontFamily = fontInfo.fontFamily === editorOptions_1.EDITOR_FONT_DEFAULTS.fontFamily ? fontInfo.fontFamily : "'" + fontInfo.fontFamily + "', " + editorOptions_1.EDITOR_FONT_DEFAULTS.fontFamily;
  68684. return {
  68685. mode: languageId.language,
  68686. html: ("<div style=\""
  68687. + ("color: " + colorMap[1 /* DefaultForeground */] + ";")
  68688. + ("background-color: " + colorMap[2 /* DefaultBackground */] + ";")
  68689. + ("font-family: " + fontFamily + ";")
  68690. + ("font-weight: " + fontInfo.fontWeight + ";")
  68691. + ("font-size: " + fontInfo.fontSize + "px;")
  68692. + ("line-height: " + fontInfo.lineHeight + "px;")
  68693. + "white-space: pre;"
  68694. + "\">"
  68695. + this._getHTMLToCopy(range, colorMap)
  68696. + '</div>')
  68697. };
  68698. };
  68699. ViewModel.prototype._getHTMLToCopy = function (modelRange, colorMap) {
  68700. var startLineNumber = modelRange.startLineNumber;
  68701. var startColumn = modelRange.startColumn;
  68702. var endLineNumber = modelRange.endLineNumber;
  68703. var endColumn = modelRange.endColumn;
  68704. var tabSize = this.getTabSize();
  68705. var result = '';
  68706. for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
  68707. var lineTokens = this.model.getLineTokens(lineNumber);
  68708. var lineContent = lineTokens.getLineContent();
  68709. var startOffset = (lineNumber === startLineNumber ? startColumn - 1 : 0);
  68710. var endOffset = (lineNumber === endLineNumber ? endColumn - 1 : lineContent.length);
  68711. if (lineContent === '') {
  68712. result += '<br>';
  68713. }
  68714. else {
  68715. result += textToHtmlTokenizer_1.tokenizeLineToHTML(lineContent, lineTokens.inflate(), colorMap, startOffset, endOffset, tabSize, platform.isWindows);
  68716. }
  68717. }
  68718. return result;
  68719. };
  68720. ViewModel.prototype._getColorMap = function () {
  68721. var colorMap = modes_1.TokenizationRegistry.getColorMap();
  68722. var result = ['#000000'];
  68723. if (colorMap) {
  68724. for (var i = 1, len = colorMap.length; i < len; i++) {
  68725. result[i] = color_1.Color.Format.CSS.formatHex(colorMap[i]);
  68726. }
  68727. }
  68728. return result;
  68729. };
  68730. return ViewModel;
  68731. }(viewEvents.ViewEventEmitter));
  68732. exports.ViewModel = ViewModel;
  68733. });
  68734. /*---------------------------------------------------------------------------------------------
  68735. * Copyright (c) Microsoft Corporation. All rights reserved.
  68736. * Licensed under the MIT License. See License.txt in the project root for license information.
  68737. *--------------------------------------------------------------------------------------------*/
  68738. define(__m[489/*vs/editor/contrib/documentSymbols/outlineModel*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,26/*vs/base/common/cancellation*/,87/*vs/base/common/collections*/,10/*vs/base/common/errors*/,38/*vs/base/common/map*/,17/*vs/editor/common/modes*/]), function (require, exports, arrays_1, cancellation_1, collections_1, errors_1, map_1, modes_1) {
  68739. "use strict";
  68740. Object.defineProperty(exports, "__esModule", { value: true });
  68741. var TreeElement = /** @class */ (function () {
  68742. function TreeElement() {
  68743. }
  68744. TreeElement.prototype.remove = function () {
  68745. if (this.parent) {
  68746. delete this.parent.children[this.id];
  68747. }
  68748. };
  68749. TreeElement.findId = function (candidate, container) {
  68750. // complex id-computation which contains the origin/extension,
  68751. // the parent path, and some dedupe logic when names collide
  68752. var candidateId;
  68753. if (typeof candidate === 'string') {
  68754. candidateId = container.id + "/" + candidate;
  68755. }
  68756. else {
  68757. candidateId = container.id + "/" + candidate.name;
  68758. if (container.children[candidateId] !== undefined) {
  68759. candidateId = container.id + "/" + candidate.name + "_" + candidate.range.startLineNumber + "_" + candidate.range.startColumn;
  68760. }
  68761. }
  68762. var id = candidateId;
  68763. for (var i = 0; container.children[id] !== undefined; i++) {
  68764. id = candidateId + "_" + i;
  68765. }
  68766. return id;
  68767. };
  68768. TreeElement.empty = function (element) {
  68769. for (var _key in element.children) {
  68770. return false;
  68771. }
  68772. return true;
  68773. };
  68774. return TreeElement;
  68775. }());
  68776. exports.TreeElement = TreeElement;
  68777. var OutlineElement = /** @class */ (function (_super) {
  68778. __extends(OutlineElement, _super);
  68779. function OutlineElement(id, parent, symbol) {
  68780. var _this = _super.call(this) || this;
  68781. _this.id = id;
  68782. _this.parent = parent;
  68783. _this.symbol = symbol;
  68784. _this.children = Object.create(null);
  68785. return _this;
  68786. }
  68787. return OutlineElement;
  68788. }(TreeElement));
  68789. exports.OutlineElement = OutlineElement;
  68790. var OutlineGroup = /** @class */ (function (_super) {
  68791. __extends(OutlineGroup, _super);
  68792. function OutlineGroup(id, parent, provider, providerIndex) {
  68793. var _this = _super.call(this) || this;
  68794. _this.id = id;
  68795. _this.parent = parent;
  68796. _this.provider = provider;
  68797. _this.providerIndex = providerIndex;
  68798. _this.children = Object.create(null);
  68799. return _this;
  68800. }
  68801. return OutlineGroup;
  68802. }(TreeElement));
  68803. exports.OutlineGroup = OutlineGroup;
  68804. var MovingAverage = /** @class */ (function () {
  68805. function MovingAverage() {
  68806. this._n = 1;
  68807. this._val = 0;
  68808. }
  68809. MovingAverage.prototype.update = function (value) {
  68810. this._val = this._val + (value - this._val) / this._n;
  68811. this._n += 1;
  68812. return this;
  68813. };
  68814. return MovingAverage;
  68815. }());
  68816. var OutlineModel = /** @class */ (function (_super) {
  68817. __extends(OutlineModel, _super);
  68818. function OutlineModel(textModel) {
  68819. var _this = _super.call(this) || this;
  68820. _this.textModel = textModel;
  68821. _this.id = 'root';
  68822. _this.parent = undefined;
  68823. _this._groups = Object.create(null);
  68824. _this.children = Object.create(null);
  68825. _this.id = 'root';
  68826. _this.parent = undefined;
  68827. return _this;
  68828. }
  68829. OutlineModel.create = function (textModel, token) {
  68830. var _this = this;
  68831. var key = this._keys.for(textModel, true);
  68832. var data = OutlineModel._requests.get(key);
  68833. if (!data) {
  68834. var source = new cancellation_1.CancellationTokenSource();
  68835. data = {
  68836. promiseCnt: 0,
  68837. source: source,
  68838. promise: OutlineModel._create(textModel, source.token),
  68839. model: undefined,
  68840. };
  68841. OutlineModel._requests.set(key, data);
  68842. // keep moving average of request durations
  68843. var now_1 = Date.now();
  68844. data.promise.then(function () {
  68845. var key = _this._keys.for(textModel, false);
  68846. var avg = _this._requestDurations.get(key);
  68847. if (!avg) {
  68848. avg = new MovingAverage();
  68849. _this._requestDurations.set(key, avg);
  68850. }
  68851. avg.update(Date.now() - now_1);
  68852. });
  68853. }
  68854. if (data.model) {
  68855. // resolved -> return data
  68856. return Promise.resolve(data.model);
  68857. }
  68858. // increase usage counter
  68859. data.promiseCnt += 1;
  68860. token.onCancellationRequested(function () {
  68861. // last -> cancel provider request, remove cached promise
  68862. if (--data.promiseCnt === 0) {
  68863. data.source.cancel();
  68864. OutlineModel._requests.delete(key);
  68865. }
  68866. });
  68867. return new Promise(function (resolve, reject) {
  68868. data.promise.then(function (model) {
  68869. data.model = model;
  68870. resolve(model);
  68871. }, function (err) {
  68872. OutlineModel._requests.delete(key);
  68873. reject(err);
  68874. });
  68875. });
  68876. };
  68877. OutlineModel._create = function (textModel, token) {
  68878. var cts = new cancellation_1.CancellationTokenSource(token);
  68879. var result = new OutlineModel(textModel);
  68880. var provider = modes_1.DocumentSymbolProviderRegistry.ordered(textModel);
  68881. var promises = provider.map(function (provider, index) {
  68882. var id = TreeElement.findId("provider_" + index, result);
  68883. var group = new OutlineGroup(id, result, provider, index);
  68884. return Promise.resolve(provider.provideDocumentSymbols(result.textModel, cts.token)).then(function (result) {
  68885. for (var _i = 0, _a = result || []; _i < _a.length; _i++) {
  68886. var info = _a[_i];
  68887. OutlineModel._makeOutlineElement(info, group);
  68888. }
  68889. return group;
  68890. }, function (err) {
  68891. errors_1.onUnexpectedExternalError(err);
  68892. return group;
  68893. }).then(function (group) {
  68894. if (!TreeElement.empty(group)) {
  68895. result._groups[id] = group;
  68896. }
  68897. else {
  68898. group.remove();
  68899. }
  68900. });
  68901. });
  68902. var listener = modes_1.DocumentSymbolProviderRegistry.onDidChange(function () {
  68903. var newProvider = modes_1.DocumentSymbolProviderRegistry.ordered(textModel);
  68904. if (!arrays_1.equals(newProvider, provider)) {
  68905. cts.cancel();
  68906. }
  68907. });
  68908. return Promise.all(promises).then(function () {
  68909. if (cts.token.isCancellationRequested && !token.isCancellationRequested) {
  68910. return OutlineModel._create(textModel, token);
  68911. }
  68912. else {
  68913. return result._compact();
  68914. }
  68915. }).finally(function () {
  68916. listener.dispose();
  68917. });
  68918. };
  68919. OutlineModel._makeOutlineElement = function (info, container) {
  68920. var id = TreeElement.findId(info, container);
  68921. var res = new OutlineElement(id, container, info);
  68922. if (info.children) {
  68923. for (var _i = 0, _a = info.children; _i < _a.length; _i++) {
  68924. var childInfo = _a[_i];
  68925. OutlineModel._makeOutlineElement(childInfo, res);
  68926. }
  68927. }
  68928. container.children[res.id] = res;
  68929. };
  68930. OutlineModel.prototype._compact = function () {
  68931. var count = 0;
  68932. for (var key in this._groups) {
  68933. var group = this._groups[key];
  68934. if (collections_1.first(group.children) === undefined) { // empty
  68935. delete this._groups[key];
  68936. }
  68937. else {
  68938. count += 1;
  68939. }
  68940. }
  68941. if (count !== 1) {
  68942. //
  68943. this.children = this._groups;
  68944. }
  68945. else {
  68946. // adopt all elements of the first group
  68947. var group = collections_1.first(this._groups);
  68948. for (var key in group.children) {
  68949. var child = group.children[key];
  68950. child.parent = this;
  68951. this.children[child.id] = child;
  68952. }
  68953. }
  68954. return this;
  68955. };
  68956. OutlineModel._requestDurations = new map_1.LRUCache(50, 0.7);
  68957. OutlineModel._requests = new map_1.LRUCache(9, 0.75);
  68958. OutlineModel._keys = new /** @class */ (function () {
  68959. function class_1() {
  68960. this._counter = 1;
  68961. this._data = new WeakMap();
  68962. }
  68963. class_1.prototype.for = function (textModel, version) {
  68964. return textModel.id + "/" + (version ? textModel.getVersionId() : '') + "/" + this._hash(modes_1.DocumentSymbolProviderRegistry.all(textModel));
  68965. };
  68966. class_1.prototype._hash = function (providers) {
  68967. var result = '';
  68968. for (var _i = 0, providers_1 = providers; _i < providers_1.length; _i++) {
  68969. var provider = providers_1[_i];
  68970. var n = this._data.get(provider);
  68971. if (typeof n === 'undefined') {
  68972. n = this._counter++;
  68973. this._data.set(provider, n);
  68974. }
  68975. result += n;
  68976. }
  68977. return result;
  68978. };
  68979. return class_1;
  68980. }());
  68981. return OutlineModel;
  68982. }(TreeElement));
  68983. exports.OutlineModel = OutlineModel;
  68984. });
  68985. /*---------------------------------------------------------------------------------------------
  68986. * Copyright (c) Microsoft Corporation. All rights reserved.
  68987. * Licensed under the MIT License. See License.txt in the project root for license information.
  68988. *--------------------------------------------------------------------------------------------*/
  68989. define(__m[490/*vs/editor/contrib/folding/foldingDecorations*/], __M([0/*require*/,1/*exports*/,30/*vs/editor/common/model/textModel*/]), function (require, exports, textModel_1) {
  68990. "use strict";
  68991. Object.defineProperty(exports, "__esModule", { value: true });
  68992. var FoldingDecorationProvider = /** @class */ (function () {
  68993. function FoldingDecorationProvider(editor) {
  68994. this.editor = editor;
  68995. this.autoHideFoldingControls = true;
  68996. this.showFoldingHighlights = true;
  68997. }
  68998. FoldingDecorationProvider.prototype.getDecorationOption = function (isCollapsed) {
  68999. if (isCollapsed) {
  69000. return this.showFoldingHighlights ? FoldingDecorationProvider.COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION : FoldingDecorationProvider.COLLAPSED_VISUAL_DECORATION;
  69001. }
  69002. else if (this.autoHideFoldingControls) {
  69003. return FoldingDecorationProvider.EXPANDED_AUTO_HIDE_VISUAL_DECORATION;
  69004. }
  69005. else {
  69006. return FoldingDecorationProvider.EXPANDED_VISUAL_DECORATION;
  69007. }
  69008. };
  69009. FoldingDecorationProvider.prototype.deltaDecorations = function (oldDecorations, newDecorations) {
  69010. return this.editor.deltaDecorations(oldDecorations, newDecorations);
  69011. };
  69012. FoldingDecorationProvider.prototype.changeDecorations = function (callback) {
  69013. return this.editor.changeDecorations(callback);
  69014. };
  69015. FoldingDecorationProvider.COLLAPSED_VISUAL_DECORATION = textModel_1.ModelDecorationOptions.register({
  69016. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  69017. afterContentClassName: 'inline-folded',
  69018. linesDecorationsClassName: 'codicon codicon-chevron-right'
  69019. });
  69020. FoldingDecorationProvider.COLLAPSED_HIGHLIGHTED_VISUAL_DECORATION = textModel_1.ModelDecorationOptions.register({
  69021. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  69022. afterContentClassName: 'inline-folded',
  69023. className: 'folded-background',
  69024. isWholeLine: true,
  69025. linesDecorationsClassName: 'codicon codicon-chevron-right'
  69026. });
  69027. FoldingDecorationProvider.EXPANDED_AUTO_HIDE_VISUAL_DECORATION = textModel_1.ModelDecorationOptions.register({
  69028. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  69029. linesDecorationsClassName: 'codicon codicon-chevron-down'
  69030. });
  69031. FoldingDecorationProvider.EXPANDED_VISUAL_DECORATION = textModel_1.ModelDecorationOptions.register({
  69032. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  69033. linesDecorationsClassName: 'codicon codicon-chevron-down alwaysShowFoldIcons'
  69034. });
  69035. return FoldingDecorationProvider;
  69036. }());
  69037. exports.FoldingDecorationProvider = FoldingDecorationProvider;
  69038. });
  69039. /*---------------------------------------------------------------------------------------------
  69040. * Copyright (c) Microsoft Corporation. All rights reserved.
  69041. * Licensed under the MIT License. See License.txt in the project root for license information.
  69042. *--------------------------------------------------------------------------------------------*/
  69043. define(__m[491/*vs/editor/contrib/folding/indentRangeProvider*/], __M([0/*require*/,1/*exports*/,150/*vs/editor/contrib/folding/foldingRanges*/,30/*vs/editor/common/model/textModel*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/]), function (require, exports, foldingRanges_1, textModel_1, languageConfigurationRegistry_1) {
  69044. "use strict";
  69045. Object.defineProperty(exports, "__esModule", { value: true });
  69046. var MAX_FOLDING_REGIONS_FOR_INDENT_LIMIT = 5000;
  69047. exports.ID_INDENT_PROVIDER = 'indent';
  69048. var IndentRangeProvider = /** @class */ (function () {
  69049. function IndentRangeProvider(editorModel) {
  69050. this.editorModel = editorModel;
  69051. this.id = exports.ID_INDENT_PROVIDER;
  69052. }
  69053. IndentRangeProvider.prototype.dispose = function () {
  69054. };
  69055. IndentRangeProvider.prototype.compute = function (cancelationToken) {
  69056. var foldingRules = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getFoldingRules(this.editorModel.getLanguageIdentifier().id);
  69057. var offSide = foldingRules && !!foldingRules.offSide;
  69058. var markers = foldingRules && foldingRules.markers;
  69059. return Promise.resolve(computeRanges(this.editorModel, offSide, markers));
  69060. };
  69061. return IndentRangeProvider;
  69062. }());
  69063. exports.IndentRangeProvider = IndentRangeProvider;
  69064. // public only for testing
  69065. var RangesCollector = /** @class */ (function () {
  69066. function RangesCollector(foldingRangesLimit) {
  69067. this._startIndexes = [];
  69068. this._endIndexes = [];
  69069. this._indentOccurrences = [];
  69070. this._length = 0;
  69071. this._foldingRangesLimit = foldingRangesLimit;
  69072. }
  69073. RangesCollector.prototype.insertFirst = function (startLineNumber, endLineNumber, indent) {
  69074. if (startLineNumber > foldingRanges_1.MAX_LINE_NUMBER || endLineNumber > foldingRanges_1.MAX_LINE_NUMBER) {
  69075. return;
  69076. }
  69077. var index = this._length;
  69078. this._startIndexes[index] = startLineNumber;
  69079. this._endIndexes[index] = endLineNumber;
  69080. this._length++;
  69081. if (indent < 1000) {
  69082. this._indentOccurrences[indent] = (this._indentOccurrences[indent] || 0) + 1;
  69083. }
  69084. };
  69085. RangesCollector.prototype.toIndentRanges = function (model) {
  69086. if (this._length <= this._foldingRangesLimit) {
  69087. // reverse and create arrays of the exact length
  69088. var startIndexes = new Uint32Array(this._length);
  69089. var endIndexes = new Uint32Array(this._length);
  69090. for (var i = this._length - 1, k = 0; i >= 0; i--, k++) {
  69091. startIndexes[k] = this._startIndexes[i];
  69092. endIndexes[k] = this._endIndexes[i];
  69093. }
  69094. return new foldingRanges_1.FoldingRegions(startIndexes, endIndexes);
  69095. }
  69096. else {
  69097. var entries = 0;
  69098. var maxIndent = this._indentOccurrences.length;
  69099. for (var i = 0; i < this._indentOccurrences.length; i++) {
  69100. var n = this._indentOccurrences[i];
  69101. if (n) {
  69102. if (n + entries > this._foldingRangesLimit) {
  69103. maxIndent = i;
  69104. break;
  69105. }
  69106. entries += n;
  69107. }
  69108. }
  69109. var tabSize = model.getOptions().tabSize;
  69110. // reverse and create arrays of the exact length
  69111. var startIndexes = new Uint32Array(this._foldingRangesLimit);
  69112. var endIndexes = new Uint32Array(this._foldingRangesLimit);
  69113. for (var i = this._length - 1, k = 0; i >= 0; i--) {
  69114. var startIndex = this._startIndexes[i];
  69115. var lineContent = model.getLineContent(startIndex);
  69116. var indent = textModel_1.TextModel.computeIndentLevel(lineContent, tabSize);
  69117. if (indent < maxIndent || (indent === maxIndent && entries++ < this._foldingRangesLimit)) {
  69118. startIndexes[k] = startIndex;
  69119. endIndexes[k] = this._endIndexes[i];
  69120. k++;
  69121. }
  69122. }
  69123. return new foldingRanges_1.FoldingRegions(startIndexes, endIndexes);
  69124. }
  69125. };
  69126. return RangesCollector;
  69127. }());
  69128. exports.RangesCollector = RangesCollector;
  69129. function computeRanges(model, offSide, markers, foldingRangesLimit) {
  69130. if (foldingRangesLimit === void 0) { foldingRangesLimit = MAX_FOLDING_REGIONS_FOR_INDENT_LIMIT; }
  69131. var tabSize = model.getOptions().tabSize;
  69132. var result = new RangesCollector(foldingRangesLimit);
  69133. var pattern = undefined;
  69134. if (markers) {
  69135. pattern = new RegExp("(" + markers.start.source + ")|(?:" + markers.end.source + ")");
  69136. }
  69137. var previousRegions = [];
  69138. var line = model.getLineCount() + 1;
  69139. previousRegions.push({ indent: -1, endAbove: line, line: line }); // sentinel, to make sure there's at least one entry
  69140. for (var line_1 = model.getLineCount(); line_1 > 0; line_1--) {
  69141. var lineContent = model.getLineContent(line_1);
  69142. var indent = textModel_1.TextModel.computeIndentLevel(lineContent, tabSize);
  69143. var previous = previousRegions[previousRegions.length - 1];
  69144. if (indent === -1) {
  69145. if (offSide) {
  69146. // for offSide languages, empty lines are associated to the previous block
  69147. // note: the next block is already written to the results, so this only
  69148. // impacts the end position of the block before
  69149. previous.endAbove = line_1;
  69150. }
  69151. continue; // only whitespace
  69152. }
  69153. var m = void 0;
  69154. if (pattern && (m = lineContent.match(pattern))) {
  69155. // folding pattern match
  69156. if (m[1]) { // start pattern match
  69157. // discard all regions until the folding pattern
  69158. var i = previousRegions.length - 1;
  69159. while (i > 0 && previousRegions[i].indent !== -2) {
  69160. i--;
  69161. }
  69162. if (i > 0) {
  69163. previousRegions.length = i + 1;
  69164. previous = previousRegions[i];
  69165. // new folding range from pattern, includes the end line
  69166. result.insertFirst(line_1, previous.line, indent);
  69167. previous.line = line_1;
  69168. previous.indent = indent;
  69169. previous.endAbove = line_1;
  69170. continue;
  69171. }
  69172. else {
  69173. // no end marker found, treat line as a regular line
  69174. }
  69175. }
  69176. else { // end pattern match
  69177. previousRegions.push({ indent: -2, endAbove: line_1, line: line_1 });
  69178. continue;
  69179. }
  69180. }
  69181. if (previous.indent > indent) {
  69182. // discard all regions with larger indent
  69183. do {
  69184. previousRegions.pop();
  69185. previous = previousRegions[previousRegions.length - 1];
  69186. } while (previous.indent > indent);
  69187. // new folding range
  69188. var endLineNumber = previous.endAbove - 1;
  69189. if (endLineNumber - line_1 >= 1) { // needs at east size 1
  69190. result.insertFirst(line_1, endLineNumber, indent);
  69191. }
  69192. }
  69193. if (previous.indent === indent) {
  69194. previous.endAbove = line_1;
  69195. }
  69196. else { // previous.indent < indent
  69197. // new region with a bigger indent
  69198. previousRegions.push({ indent: indent, endAbove: line_1, line: line_1 });
  69199. }
  69200. }
  69201. return result.toIndentRanges(model);
  69202. }
  69203. exports.computeRanges = computeRanges;
  69204. });
  69205. /*---------------------------------------------------------------------------------------------
  69206. * Copyright (c) Microsoft Corporation. All rights reserved.
  69207. * Licensed under the MIT License. See License.txt in the project root for license information.
  69208. *--------------------------------------------------------------------------------------------*/
  69209. define(__m[492/*vs/editor/contrib/linesOperations/moveLinesCommand*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,211/*vs/editor/common/commands/shiftCommand*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,90/*vs/editor/common/modes/languageConfiguration*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/,385/*vs/editor/contrib/indentation/indentUtils*/]), function (require, exports, strings, shiftCommand_1, range_1, selection_1, languageConfiguration_1, languageConfigurationRegistry_1, indentUtils) {
  69210. "use strict";
  69211. Object.defineProperty(exports, "__esModule", { value: true });
  69212. var MoveLinesCommand = /** @class */ (function () {
  69213. function MoveLinesCommand(selection, isMovingDown, autoIndent) {
  69214. this._selection = selection;
  69215. this._isMovingDown = isMovingDown;
  69216. this._autoIndent = autoIndent;
  69217. this._selectionId = null;
  69218. this._moveEndLineSelectionShrink = false;
  69219. }
  69220. MoveLinesCommand.prototype.getEditOperations = function (model, builder) {
  69221. var modelLineCount = model.getLineCount();
  69222. if (this._isMovingDown && this._selection.endLineNumber === modelLineCount) {
  69223. this._selectionId = builder.trackSelection(this._selection);
  69224. return;
  69225. }
  69226. if (!this._isMovingDown && this._selection.startLineNumber === 1) {
  69227. this._selectionId = builder.trackSelection(this._selection);
  69228. return;
  69229. }
  69230. this._moveEndPositionDown = false;
  69231. var s = this._selection;
  69232. if (s.startLineNumber < s.endLineNumber && s.endColumn === 1) {
  69233. this._moveEndPositionDown = true;
  69234. s = s.setEndPosition(s.endLineNumber - 1, model.getLineMaxColumn(s.endLineNumber - 1));
  69235. }
  69236. var _a = model.getOptions(), tabSize = _a.tabSize, indentSize = _a.indentSize, insertSpaces = _a.insertSpaces;
  69237. var indentConverter = this.buildIndentConverter(tabSize, indentSize, insertSpaces);
  69238. var virtualModel = {
  69239. getLineTokens: function (lineNumber) {
  69240. return model.getLineTokens(lineNumber);
  69241. },
  69242. getLanguageIdentifier: function () {
  69243. return model.getLanguageIdentifier();
  69244. },
  69245. getLanguageIdAtPosition: function (lineNumber, column) {
  69246. return model.getLanguageIdAtPosition(lineNumber, column);
  69247. },
  69248. getLineContent: null,
  69249. };
  69250. if (s.startLineNumber === s.endLineNumber && model.getLineMaxColumn(s.startLineNumber) === 1) {
  69251. // Current line is empty
  69252. var lineNumber = s.startLineNumber;
  69253. var otherLineNumber = (this._isMovingDown ? lineNumber + 1 : lineNumber - 1);
  69254. if (model.getLineMaxColumn(otherLineNumber) === 1) {
  69255. // Other line number is empty too, so no editing is needed
  69256. // Add a no-op to force running by the model
  69257. builder.addEditOperation(new range_1.Range(1, 1, 1, 1), null);
  69258. }
  69259. else {
  69260. // Type content from other line number on line number
  69261. builder.addEditOperation(new range_1.Range(lineNumber, 1, lineNumber, 1), model.getLineContent(otherLineNumber));
  69262. // Remove content from other line number
  69263. builder.addEditOperation(new range_1.Range(otherLineNumber, 1, otherLineNumber, model.getLineMaxColumn(otherLineNumber)), null);
  69264. }
  69265. // Track selection at the other line number
  69266. s = new selection_1.Selection(otherLineNumber, 1, otherLineNumber, 1);
  69267. }
  69268. else {
  69269. var movingLineNumber_1;
  69270. var movingLineText = void 0;
  69271. if (this._isMovingDown) {
  69272. movingLineNumber_1 = s.endLineNumber + 1;
  69273. movingLineText = model.getLineContent(movingLineNumber_1);
  69274. // Delete line that needs to be moved
  69275. builder.addEditOperation(new range_1.Range(movingLineNumber_1 - 1, model.getLineMaxColumn(movingLineNumber_1 - 1), movingLineNumber_1, model.getLineMaxColumn(movingLineNumber_1)), null);
  69276. var insertingText_1 = movingLineText;
  69277. if (this.shouldAutoIndent(model, s)) {
  69278. var movingLineMatchResult = this.matchEnterRule(model, indentConverter, tabSize, movingLineNumber_1, s.startLineNumber - 1);
  69279. // if s.startLineNumber - 1 matches onEnter rule, we still honor that.
  69280. if (movingLineMatchResult !== null) {
  69281. var oldIndentation = strings.getLeadingWhitespace(model.getLineContent(movingLineNumber_1));
  69282. var newSpaceCnt = movingLineMatchResult + indentUtils.getSpaceCnt(oldIndentation, tabSize);
  69283. var newIndentation = indentUtils.generateIndent(newSpaceCnt, tabSize, insertSpaces);
  69284. insertingText_1 = newIndentation + this.trimLeft(movingLineText);
  69285. }
  69286. else {
  69287. // no enter rule matches, let's check indentatin rules then.
  69288. virtualModel.getLineContent = function (lineNumber) {
  69289. if (lineNumber === s.startLineNumber) {
  69290. return model.getLineContent(movingLineNumber_1);
  69291. }
  69292. else {
  69293. return model.getLineContent(lineNumber);
  69294. }
  69295. };
  69296. var indentOfMovingLine = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getGoodIndentForLine(this._autoIndent, virtualModel, model.getLanguageIdAtPosition(movingLineNumber_1, 1), s.startLineNumber, indentConverter);
  69297. if (indentOfMovingLine !== null) {
  69298. var oldIndentation = strings.getLeadingWhitespace(model.getLineContent(movingLineNumber_1));
  69299. var newSpaceCnt = indentUtils.getSpaceCnt(indentOfMovingLine, tabSize);
  69300. var oldSpaceCnt = indentUtils.getSpaceCnt(oldIndentation, tabSize);
  69301. if (newSpaceCnt !== oldSpaceCnt) {
  69302. var newIndentation = indentUtils.generateIndent(newSpaceCnt, tabSize, insertSpaces);
  69303. insertingText_1 = newIndentation + this.trimLeft(movingLineText);
  69304. }
  69305. }
  69306. }
  69307. // add edit operations for moving line first to make sure it's executed after we make indentation change
  69308. // to s.startLineNumber
  69309. builder.addEditOperation(new range_1.Range(s.startLineNumber, 1, s.startLineNumber, 1), insertingText_1 + '\n');
  69310. var ret = this.matchEnterRule(model, indentConverter, tabSize, s.startLineNumber, s.startLineNumber, insertingText_1);
  69311. // check if the line being moved before matches onEnter rules, if so let's adjust the indentation by onEnter rules.
  69312. if (ret !== null) {
  69313. if (ret !== 0) {
  69314. this.getIndentEditsOfMovingBlock(model, builder, s, tabSize, insertSpaces, ret);
  69315. }
  69316. }
  69317. else {
  69318. // it doesn't match onEnter rules, let's check indentation rules then.
  69319. virtualModel.getLineContent = function (lineNumber) {
  69320. if (lineNumber === s.startLineNumber) {
  69321. return insertingText_1;
  69322. }
  69323. else if (lineNumber >= s.startLineNumber + 1 && lineNumber <= s.endLineNumber + 1) {
  69324. return model.getLineContent(lineNumber - 1);
  69325. }
  69326. else {
  69327. return model.getLineContent(lineNumber);
  69328. }
  69329. };
  69330. var newIndentatOfMovingBlock = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getGoodIndentForLine(this._autoIndent, virtualModel, model.getLanguageIdAtPosition(movingLineNumber_1, 1), s.startLineNumber + 1, indentConverter);
  69331. if (newIndentatOfMovingBlock !== null) {
  69332. var oldIndentation = strings.getLeadingWhitespace(model.getLineContent(s.startLineNumber));
  69333. var newSpaceCnt = indentUtils.getSpaceCnt(newIndentatOfMovingBlock, tabSize);
  69334. var oldSpaceCnt = indentUtils.getSpaceCnt(oldIndentation, tabSize);
  69335. if (newSpaceCnt !== oldSpaceCnt) {
  69336. var spaceCntOffset = newSpaceCnt - oldSpaceCnt;
  69337. this.getIndentEditsOfMovingBlock(model, builder, s, tabSize, insertSpaces, spaceCntOffset);
  69338. }
  69339. }
  69340. }
  69341. }
  69342. else {
  69343. // Insert line that needs to be moved before
  69344. builder.addEditOperation(new range_1.Range(s.startLineNumber, 1, s.startLineNumber, 1), insertingText_1 + '\n');
  69345. }
  69346. }
  69347. else {
  69348. movingLineNumber_1 = s.startLineNumber - 1;
  69349. movingLineText = model.getLineContent(movingLineNumber_1);
  69350. // Delete line that needs to be moved
  69351. builder.addEditOperation(new range_1.Range(movingLineNumber_1, 1, movingLineNumber_1 + 1, 1), null);
  69352. // Insert line that needs to be moved after
  69353. builder.addEditOperation(new range_1.Range(s.endLineNumber, model.getLineMaxColumn(s.endLineNumber), s.endLineNumber, model.getLineMaxColumn(s.endLineNumber)), '\n' + movingLineText);
  69354. if (this.shouldAutoIndent(model, s)) {
  69355. virtualModel.getLineContent = function (lineNumber) {
  69356. if (lineNumber === movingLineNumber_1) {
  69357. return model.getLineContent(s.startLineNumber);
  69358. }
  69359. else {
  69360. return model.getLineContent(lineNumber);
  69361. }
  69362. };
  69363. var ret = this.matchEnterRule(model, indentConverter, tabSize, s.startLineNumber, s.startLineNumber - 2);
  69364. // check if s.startLineNumber - 2 matches onEnter rules, if so adjust the moving block by onEnter rules.
  69365. if (ret !== null) {
  69366. if (ret !== 0) {
  69367. this.getIndentEditsOfMovingBlock(model, builder, s, tabSize, insertSpaces, ret);
  69368. }
  69369. }
  69370. else {
  69371. // it doesn't match any onEnter rule, let's check indentation rules then.
  69372. var indentOfFirstLine = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getGoodIndentForLine(this._autoIndent, virtualModel, model.getLanguageIdAtPosition(s.startLineNumber, 1), movingLineNumber_1, indentConverter);
  69373. if (indentOfFirstLine !== null) {
  69374. // adjust the indentation of the moving block
  69375. var oldIndent = strings.getLeadingWhitespace(model.getLineContent(s.startLineNumber));
  69376. var newSpaceCnt = indentUtils.getSpaceCnt(indentOfFirstLine, tabSize);
  69377. var oldSpaceCnt = indentUtils.getSpaceCnt(oldIndent, tabSize);
  69378. if (newSpaceCnt !== oldSpaceCnt) {
  69379. var spaceCntOffset = newSpaceCnt - oldSpaceCnt;
  69380. this.getIndentEditsOfMovingBlock(model, builder, s, tabSize, insertSpaces, spaceCntOffset);
  69381. }
  69382. }
  69383. }
  69384. }
  69385. }
  69386. }
  69387. this._selectionId = builder.trackSelection(s);
  69388. };
  69389. MoveLinesCommand.prototype.buildIndentConverter = function (tabSize, indentSize, insertSpaces) {
  69390. return {
  69391. shiftIndent: function (indentation) {
  69392. return shiftCommand_1.ShiftCommand.shiftIndent(indentation, indentation.length + 1, tabSize, indentSize, insertSpaces);
  69393. },
  69394. unshiftIndent: function (indentation) {
  69395. return shiftCommand_1.ShiftCommand.unshiftIndent(indentation, indentation.length + 1, tabSize, indentSize, insertSpaces);
  69396. }
  69397. };
  69398. };
  69399. MoveLinesCommand.prototype.matchEnterRule = function (model, indentConverter, tabSize, line, oneLineAbove, oneLineAboveText) {
  69400. var validPrecedingLine = oneLineAbove;
  69401. while (validPrecedingLine >= 1) {
  69402. // ship empty lines as empty lines just inherit indentation
  69403. var lineContent = void 0;
  69404. if (validPrecedingLine === oneLineAbove && oneLineAboveText !== undefined) {
  69405. lineContent = oneLineAboveText;
  69406. }
  69407. else {
  69408. lineContent = model.getLineContent(validPrecedingLine);
  69409. }
  69410. var nonWhitespaceIdx = strings.lastNonWhitespaceIndex(lineContent);
  69411. if (nonWhitespaceIdx >= 0) {
  69412. break;
  69413. }
  69414. validPrecedingLine--;
  69415. }
  69416. if (validPrecedingLine < 1 || line > model.getLineCount()) {
  69417. return null;
  69418. }
  69419. var maxColumn = model.getLineMaxColumn(validPrecedingLine);
  69420. var enter = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getEnterAction(this._autoIndent, model, new range_1.Range(validPrecedingLine, maxColumn, validPrecedingLine, maxColumn));
  69421. if (enter) {
  69422. var enterPrefix = enter.indentation;
  69423. if (enter.indentAction === languageConfiguration_1.IndentAction.None) {
  69424. enterPrefix = enter.indentation + enter.appendText;
  69425. }
  69426. else if (enter.indentAction === languageConfiguration_1.IndentAction.Indent) {
  69427. enterPrefix = enter.indentation + enter.appendText;
  69428. }
  69429. else if (enter.indentAction === languageConfiguration_1.IndentAction.IndentOutdent) {
  69430. enterPrefix = enter.indentation;
  69431. }
  69432. else if (enter.indentAction === languageConfiguration_1.IndentAction.Outdent) {
  69433. enterPrefix = indentConverter.unshiftIndent(enter.indentation) + enter.appendText;
  69434. }
  69435. var movingLineText = model.getLineContent(line);
  69436. if (this.trimLeft(movingLineText).indexOf(this.trimLeft(enterPrefix)) >= 0) {
  69437. var oldIndentation = strings.getLeadingWhitespace(model.getLineContent(line));
  69438. var newIndentation = strings.getLeadingWhitespace(enterPrefix);
  69439. var indentMetadataOfMovelingLine = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getIndentMetadata(model, line);
  69440. if (indentMetadataOfMovelingLine !== null && indentMetadataOfMovelingLine & 2 /* DECREASE_MASK */) {
  69441. newIndentation = indentConverter.unshiftIndent(newIndentation);
  69442. }
  69443. var newSpaceCnt = indentUtils.getSpaceCnt(newIndentation, tabSize);
  69444. var oldSpaceCnt = indentUtils.getSpaceCnt(oldIndentation, tabSize);
  69445. return newSpaceCnt - oldSpaceCnt;
  69446. }
  69447. }
  69448. return null;
  69449. };
  69450. MoveLinesCommand.prototype.trimLeft = function (str) {
  69451. return str.replace(/^\s+/, '');
  69452. };
  69453. MoveLinesCommand.prototype.shouldAutoIndent = function (model, selection) {
  69454. if (this._autoIndent < 4 /* Full */) {
  69455. return false;
  69456. }
  69457. // if it's not easy to tokenize, we stop auto indent.
  69458. if (!model.isCheapToTokenize(selection.startLineNumber)) {
  69459. return false;
  69460. }
  69461. var languageAtSelectionStart = model.getLanguageIdAtPosition(selection.startLineNumber, 1);
  69462. var languageAtSelectionEnd = model.getLanguageIdAtPosition(selection.endLineNumber, 1);
  69463. if (languageAtSelectionStart !== languageAtSelectionEnd) {
  69464. return false;
  69465. }
  69466. if (languageConfigurationRegistry_1.LanguageConfigurationRegistry.getIndentRulesSupport(languageAtSelectionStart) === null) {
  69467. return false;
  69468. }
  69469. return true;
  69470. };
  69471. MoveLinesCommand.prototype.getIndentEditsOfMovingBlock = function (model, builder, s, tabSize, insertSpaces, offset) {
  69472. for (var i = s.startLineNumber; i <= s.endLineNumber; i++) {
  69473. var lineContent = model.getLineContent(i);
  69474. var originalIndent = strings.getLeadingWhitespace(lineContent);
  69475. var originalSpacesCnt = indentUtils.getSpaceCnt(originalIndent, tabSize);
  69476. var newSpacesCnt = originalSpacesCnt + offset;
  69477. var newIndent = indentUtils.generateIndent(newSpacesCnt, tabSize, insertSpaces);
  69478. if (newIndent !== originalIndent) {
  69479. builder.addEditOperation(new range_1.Range(i, 1, i, originalIndent.length + 1), newIndent);
  69480. if (i === s.endLineNumber && s.endColumn <= originalIndent.length + 1 && newIndent === '') {
  69481. // as users select part of the original indent white spaces
  69482. // when we adjust the indentation of endLine, we should adjust the cursor position as well.
  69483. this._moveEndLineSelectionShrink = true;
  69484. }
  69485. }
  69486. }
  69487. };
  69488. MoveLinesCommand.prototype.computeCursorState = function (model, helper) {
  69489. var result = helper.getTrackedSelection(this._selectionId);
  69490. if (this._moveEndPositionDown) {
  69491. result = result.setEndPosition(result.endLineNumber + 1, 1);
  69492. }
  69493. if (this._moveEndLineSelectionShrink && result.startLineNumber < result.endLineNumber) {
  69494. result = result.setEndPosition(result.endLineNumber, 2);
  69495. }
  69496. return result;
  69497. };
  69498. return MoveLinesCommand;
  69499. }());
  69500. exports.MoveLinesCommand = MoveLinesCommand;
  69501. });
  69502. /*---------------------------------------------------------------------------------------------
  69503. * Copyright (c) Microsoft Corporation. All rights reserved.
  69504. * Licensed under the MIT License. See License.txt in the project root for license information.
  69505. *--------------------------------------------------------------------------------------------*/
  69506. define(__m[493/*vs/editor/contrib/zoneWidget/zoneWidget*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,104/*vs/base/browser/ui/sash/sash*/,27/*vs/base/common/color*/,127/*vs/base/common/idGenerator*/,2/*vs/base/common/lifecycle*/,31/*vs/base/common/objects*/,3/*vs/editor/common/core/range*/,30/*vs/editor/common/model/textModel*/,324/*vs/css!vs/editor/contrib/zoneWidget/zoneWidget*/]), function (require, exports, dom, sash_1, color_1, idGenerator_1, lifecycle_1, objects, range_1, textModel_1) {
  69507. "use strict";
  69508. Object.defineProperty(exports, "__esModule", { value: true });
  69509. var defaultColor = new color_1.Color(new color_1.RGBA(0, 122, 204));
  69510. var defaultOptions = {
  69511. showArrow: true,
  69512. showFrame: true,
  69513. className: '',
  69514. frameColor: defaultColor,
  69515. arrowColor: defaultColor,
  69516. keepEditorSelection: false
  69517. };
  69518. var WIDGET_ID = 'vs.editor.contrib.zoneWidget';
  69519. var ViewZoneDelegate = /** @class */ (function () {
  69520. function ViewZoneDelegate(domNode, afterLineNumber, afterColumn, heightInLines, onDomNodeTop, onComputedHeight) {
  69521. this.id = ''; // A valid zone id should be greater than 0
  69522. this.domNode = domNode;
  69523. this.afterLineNumber = afterLineNumber;
  69524. this.afterColumn = afterColumn;
  69525. this.heightInLines = heightInLines;
  69526. this._onDomNodeTop = onDomNodeTop;
  69527. this._onComputedHeight = onComputedHeight;
  69528. }
  69529. ViewZoneDelegate.prototype.onDomNodeTop = function (top) {
  69530. this._onDomNodeTop(top);
  69531. };
  69532. ViewZoneDelegate.prototype.onComputedHeight = function (height) {
  69533. this._onComputedHeight(height);
  69534. };
  69535. return ViewZoneDelegate;
  69536. }());
  69537. exports.ViewZoneDelegate = ViewZoneDelegate;
  69538. var OverlayWidgetDelegate = /** @class */ (function () {
  69539. function OverlayWidgetDelegate(id, domNode) {
  69540. this._id = id;
  69541. this._domNode = domNode;
  69542. }
  69543. OverlayWidgetDelegate.prototype.getId = function () {
  69544. return this._id;
  69545. };
  69546. OverlayWidgetDelegate.prototype.getDomNode = function () {
  69547. return this._domNode;
  69548. };
  69549. OverlayWidgetDelegate.prototype.getPosition = function () {
  69550. return null;
  69551. };
  69552. return OverlayWidgetDelegate;
  69553. }());
  69554. exports.OverlayWidgetDelegate = OverlayWidgetDelegate;
  69555. var Arrow = /** @class */ (function () {
  69556. function Arrow(_editor) {
  69557. this._editor = _editor;
  69558. this._ruleName = Arrow._IdGenerator.nextId();
  69559. this._decorations = [];
  69560. this._color = null;
  69561. this._height = -1;
  69562. //
  69563. }
  69564. Arrow.prototype.dispose = function () {
  69565. this.hide();
  69566. dom.removeCSSRulesContainingSelector(this._ruleName);
  69567. };
  69568. Object.defineProperty(Arrow.prototype, "color", {
  69569. set: function (value) {
  69570. if (this._color !== value) {
  69571. this._color = value;
  69572. this._updateStyle();
  69573. }
  69574. },
  69575. enumerable: true,
  69576. configurable: true
  69577. });
  69578. Object.defineProperty(Arrow.prototype, "height", {
  69579. set: function (value) {
  69580. if (this._height !== value) {
  69581. this._height = value;
  69582. this._updateStyle();
  69583. }
  69584. },
  69585. enumerable: true,
  69586. configurable: true
  69587. });
  69588. Arrow.prototype._updateStyle = function () {
  69589. dom.removeCSSRulesContainingSelector(this._ruleName);
  69590. dom.createCSSRule(".monaco-editor " + this._ruleName, "border-style: solid; border-color: transparent; border-bottom-color: " + this._color + "; border-width: " + this._height + "px; bottom: -" + this._height + "px; margin-left: -" + this._height + "px; ");
  69591. };
  69592. Arrow.prototype.show = function (where) {
  69593. this._decorations = this._editor.deltaDecorations(this._decorations, [{ range: range_1.Range.fromPositions(where), options: { className: this._ruleName, stickiness: 1 /* NeverGrowsWhenTypingAtEdges */ } }]);
  69594. };
  69595. Arrow.prototype.hide = function () {
  69596. this._editor.deltaDecorations(this._decorations, []);
  69597. };
  69598. Arrow._IdGenerator = new idGenerator_1.IdGenerator('.arrow-decoration-');
  69599. return Arrow;
  69600. }());
  69601. var ZoneWidget = /** @class */ (function () {
  69602. function ZoneWidget(editor, options) {
  69603. var _this = this;
  69604. if (options === void 0) { options = {}; }
  69605. this._arrow = null;
  69606. this._overlayWidget = null;
  69607. this._resizeSash = null;
  69608. this._positionMarkerId = [];
  69609. this._viewZone = null;
  69610. this._disposables = new lifecycle_1.DisposableStore();
  69611. this.container = null;
  69612. this._isShowing = false;
  69613. this.editor = editor;
  69614. this.options = objects.deepClone(options);
  69615. objects.mixin(this.options, defaultOptions, false);
  69616. this.domNode = document.createElement('div');
  69617. if (!this.options.isAccessible) {
  69618. this.domNode.setAttribute('aria-hidden', 'true');
  69619. this.domNode.setAttribute('role', 'presentation');
  69620. }
  69621. this._disposables.add(this.editor.onDidLayoutChange(function (info) {
  69622. var width = _this._getWidth(info);
  69623. _this.domNode.style.width = width + 'px';
  69624. _this.domNode.style.left = _this._getLeft(info) + 'px';
  69625. _this._onWidth(width);
  69626. }));
  69627. }
  69628. ZoneWidget.prototype.dispose = function () {
  69629. var _this = this;
  69630. if (this._overlayWidget) {
  69631. this.editor.removeOverlayWidget(this._overlayWidget);
  69632. this._overlayWidget = null;
  69633. }
  69634. if (this._viewZone) {
  69635. this.editor.changeViewZones(function (accessor) {
  69636. if (_this._viewZone) {
  69637. accessor.removeZone(_this._viewZone.id);
  69638. }
  69639. _this._viewZone = null;
  69640. });
  69641. }
  69642. this.editor.deltaDecorations(this._positionMarkerId, []);
  69643. this._positionMarkerId = [];
  69644. this._disposables.dispose();
  69645. };
  69646. ZoneWidget.prototype.create = function () {
  69647. dom.addClass(this.domNode, 'zone-widget');
  69648. if (this.options.className) {
  69649. dom.addClass(this.domNode, this.options.className);
  69650. }
  69651. this.container = document.createElement('div');
  69652. dom.addClass(this.container, 'zone-widget-container');
  69653. this.domNode.appendChild(this.container);
  69654. if (this.options.showArrow) {
  69655. this._arrow = new Arrow(this.editor);
  69656. this._disposables.add(this._arrow);
  69657. }
  69658. this._fillContainer(this.container);
  69659. this._initSash();
  69660. this._applyStyles();
  69661. };
  69662. ZoneWidget.prototype.style = function (styles) {
  69663. if (styles.frameColor) {
  69664. this.options.frameColor = styles.frameColor;
  69665. }
  69666. if (styles.arrowColor) {
  69667. this.options.arrowColor = styles.arrowColor;
  69668. }
  69669. this._applyStyles();
  69670. };
  69671. ZoneWidget.prototype._applyStyles = function () {
  69672. if (this.container && this.options.frameColor) {
  69673. var frameColor = this.options.frameColor.toString();
  69674. this.container.style.borderTopColor = frameColor;
  69675. this.container.style.borderBottomColor = frameColor;
  69676. }
  69677. if (this._arrow && this.options.arrowColor) {
  69678. var arrowColor = this.options.arrowColor.toString();
  69679. this._arrow.color = arrowColor;
  69680. }
  69681. };
  69682. ZoneWidget.prototype._getWidth = function (info) {
  69683. return info.width - info.minimapWidth - info.verticalScrollbarWidth;
  69684. };
  69685. ZoneWidget.prototype._getLeft = function (info) {
  69686. // If minimap is to the left, we move beyond it
  69687. if (info.minimapWidth > 0 && info.minimapLeft === 0) {
  69688. return info.minimapWidth;
  69689. }
  69690. return 0;
  69691. };
  69692. ZoneWidget.prototype._onViewZoneTop = function (top) {
  69693. this.domNode.style.top = top + 'px';
  69694. };
  69695. ZoneWidget.prototype._onViewZoneHeight = function (height) {
  69696. this.domNode.style.height = height + "px";
  69697. if (this.container) {
  69698. var containerHeight = height - this._decoratingElementsHeight();
  69699. this.container.style.height = containerHeight + "px";
  69700. var layoutInfo = this.editor.getLayoutInfo();
  69701. this._doLayout(containerHeight, this._getWidth(layoutInfo));
  69702. }
  69703. if (this._resizeSash) {
  69704. this._resizeSash.layout();
  69705. }
  69706. };
  69707. Object.defineProperty(ZoneWidget.prototype, "position", {
  69708. get: function () {
  69709. var id = this._positionMarkerId[0];
  69710. if (!id) {
  69711. return undefined;
  69712. }
  69713. var model = this.editor.getModel();
  69714. if (!model) {
  69715. return undefined;
  69716. }
  69717. var range = model.getDecorationRange(id);
  69718. if (!range) {
  69719. return undefined;
  69720. }
  69721. return range.getStartPosition();
  69722. },
  69723. enumerable: true,
  69724. configurable: true
  69725. });
  69726. ZoneWidget.prototype.show = function (rangeOrPos, heightInLines) {
  69727. var range = range_1.Range.isIRange(rangeOrPos) ? range_1.Range.lift(rangeOrPos) : range_1.Range.fromPositions(rangeOrPos);
  69728. this._isShowing = true;
  69729. this._showImpl(range, heightInLines);
  69730. this._isShowing = false;
  69731. this._positionMarkerId = this.editor.deltaDecorations(this._positionMarkerId, [{ range: range, options: textModel_1.ModelDecorationOptions.EMPTY }]);
  69732. };
  69733. ZoneWidget.prototype.hide = function () {
  69734. var _this = this;
  69735. if (this._viewZone) {
  69736. this.editor.changeViewZones(function (accessor) {
  69737. if (_this._viewZone) {
  69738. accessor.removeZone(_this._viewZone.id);
  69739. }
  69740. });
  69741. this._viewZone = null;
  69742. }
  69743. if (this._overlayWidget) {
  69744. this.editor.removeOverlayWidget(this._overlayWidget);
  69745. this._overlayWidget = null;
  69746. }
  69747. if (this._arrow) {
  69748. this._arrow.hide();
  69749. }
  69750. };
  69751. ZoneWidget.prototype._decoratingElementsHeight = function () {
  69752. var lineHeight = this.editor.getOption(49 /* lineHeight */);
  69753. var result = 0;
  69754. if (this.options.showArrow) {
  69755. var arrowHeight = Math.round(lineHeight / 3);
  69756. result += 2 * arrowHeight;
  69757. }
  69758. if (this.options.showFrame) {
  69759. var frameThickness = Math.round(lineHeight / 9);
  69760. result += 2 * frameThickness;
  69761. }
  69762. return result;
  69763. };
  69764. ZoneWidget.prototype._showImpl = function (where, heightInLines) {
  69765. var _this = this;
  69766. var position = where.getStartPosition();
  69767. var layoutInfo = this.editor.getLayoutInfo();
  69768. var width = this._getWidth(layoutInfo);
  69769. this.domNode.style.width = width + "px";
  69770. this.domNode.style.left = this._getLeft(layoutInfo) + 'px';
  69771. // Render the widget as zone (rendering) and widget (lifecycle)
  69772. var viewZoneDomNode = document.createElement('div');
  69773. viewZoneDomNode.style.overflow = 'hidden';
  69774. var lineHeight = this.editor.getOption(49 /* lineHeight */);
  69775. // adjust heightInLines to viewport
  69776. var maxHeightInLines = (this.editor.getLayoutInfo().height / lineHeight) * 0.8;
  69777. if (heightInLines >= maxHeightInLines) {
  69778. heightInLines = maxHeightInLines;
  69779. }
  69780. var arrowHeight = 0;
  69781. var frameThickness = 0;
  69782. // Render the arrow one 1/3 of an editor line height
  69783. if (this._arrow && this.options.showArrow) {
  69784. arrowHeight = Math.round(lineHeight / 3);
  69785. this._arrow.height = arrowHeight;
  69786. this._arrow.show(position);
  69787. }
  69788. // Render the frame as 1/9 of an editor line height
  69789. if (this.options.showFrame) {
  69790. frameThickness = Math.round(lineHeight / 9);
  69791. }
  69792. // insert zone widget
  69793. this.editor.changeViewZones(function (accessor) {
  69794. if (_this._viewZone) {
  69795. accessor.removeZone(_this._viewZone.id);
  69796. }
  69797. if (_this._overlayWidget) {
  69798. _this.editor.removeOverlayWidget(_this._overlayWidget);
  69799. _this._overlayWidget = null;
  69800. }
  69801. _this.domNode.style.top = '-1000px';
  69802. _this._viewZone = new ViewZoneDelegate(viewZoneDomNode, position.lineNumber, position.column, heightInLines, function (top) { return _this._onViewZoneTop(top); }, function (height) { return _this._onViewZoneHeight(height); });
  69803. _this._viewZone.id = accessor.addZone(_this._viewZone);
  69804. _this._overlayWidget = new OverlayWidgetDelegate(WIDGET_ID + _this._viewZone.id, _this.domNode);
  69805. _this.editor.addOverlayWidget(_this._overlayWidget);
  69806. });
  69807. if (this.container && this.options.showFrame) {
  69808. var width_1 = this.options.frameWidth ? this.options.frameWidth : frameThickness;
  69809. this.container.style.borderTopWidth = width_1 + 'px';
  69810. this.container.style.borderBottomWidth = width_1 + 'px';
  69811. }
  69812. var containerHeight = heightInLines * lineHeight - this._decoratingElementsHeight();
  69813. if (this.container) {
  69814. this.container.style.top = arrowHeight + 'px';
  69815. this.container.style.height = containerHeight + 'px';
  69816. this.container.style.overflow = 'hidden';
  69817. }
  69818. this._doLayout(containerHeight, width);
  69819. if (!this.options.keepEditorSelection) {
  69820. this.editor.setSelection(where);
  69821. }
  69822. var model = this.editor.getModel();
  69823. if (model) {
  69824. var revealLine = where.endLineNumber + 1;
  69825. if (revealLine <= model.getLineCount()) {
  69826. // reveal line below the zone widget
  69827. this.revealLine(revealLine, false);
  69828. }
  69829. else {
  69830. // reveal last line atop
  69831. this.revealLine(model.getLineCount(), true);
  69832. }
  69833. }
  69834. };
  69835. ZoneWidget.prototype.revealLine = function (lineNumber, isLastLine) {
  69836. if (isLastLine) {
  69837. this.editor.revealLineInCenter(lineNumber, 0 /* Smooth */);
  69838. }
  69839. else {
  69840. this.editor.revealLine(lineNumber, 0 /* Smooth */);
  69841. }
  69842. };
  69843. ZoneWidget.prototype.setCssClass = function (className, classToReplace) {
  69844. if (!this.container) {
  69845. return;
  69846. }
  69847. if (classToReplace) {
  69848. this.container.classList.remove(classToReplace);
  69849. }
  69850. dom.addClass(this.container, className);
  69851. };
  69852. ZoneWidget.prototype._onWidth = function (widthInPixel) {
  69853. // implement in subclass
  69854. };
  69855. ZoneWidget.prototype._doLayout = function (heightInPixel, widthInPixel) {
  69856. // implement in subclass
  69857. };
  69858. ZoneWidget.prototype._relayout = function (newHeightInLines) {
  69859. var _this = this;
  69860. if (this._viewZone && this._viewZone.heightInLines !== newHeightInLines) {
  69861. this.editor.changeViewZones(function (accessor) {
  69862. if (_this._viewZone) {
  69863. _this._viewZone.heightInLines = newHeightInLines;
  69864. accessor.layoutZone(_this._viewZone.id);
  69865. }
  69866. });
  69867. }
  69868. };
  69869. // --- sash
  69870. ZoneWidget.prototype._initSash = function () {
  69871. var _this = this;
  69872. if (this._resizeSash) {
  69873. return;
  69874. }
  69875. this._resizeSash = this._disposables.add(new sash_1.Sash(this.domNode, this, { orientation: 1 /* HORIZONTAL */ }));
  69876. if (!this.options.isResizeable) {
  69877. this._resizeSash.hide();
  69878. this._resizeSash.state = 0 /* Disabled */;
  69879. }
  69880. var data;
  69881. this._disposables.add(this._resizeSash.onDidStart(function (e) {
  69882. if (_this._viewZone) {
  69883. data = {
  69884. startY: e.startY,
  69885. heightInLines: _this._viewZone.heightInLines,
  69886. };
  69887. }
  69888. }));
  69889. this._disposables.add(this._resizeSash.onDidEnd(function () {
  69890. data = undefined;
  69891. }));
  69892. this._disposables.add(this._resizeSash.onDidChange(function (evt) {
  69893. if (data) {
  69894. var lineDelta = (evt.currentY - data.startY) / _this.editor.getOption(49 /* lineHeight */);
  69895. var roundedLineDelta = lineDelta < 0 ? Math.ceil(lineDelta) : Math.floor(lineDelta);
  69896. var newHeightInLines = data.heightInLines + roundedLineDelta;
  69897. if (newHeightInLines > 5 && newHeightInLines < 35) {
  69898. _this._relayout(newHeightInLines);
  69899. }
  69900. }
  69901. }));
  69902. };
  69903. ZoneWidget.prototype.getHorizontalSashLeft = function () {
  69904. return 0;
  69905. };
  69906. ZoneWidget.prototype.getHorizontalSashTop = function () {
  69907. return (this.domNode.style.height === null ? 0 : parseInt(this.domNode.style.height)) - (this._decoratingElementsHeight() / 2);
  69908. };
  69909. ZoneWidget.prototype.getHorizontalSashWidth = function () {
  69910. var layoutInfo = this.editor.getLayoutInfo();
  69911. return layoutInfo.width - layoutInfo.minimapWidth;
  69912. };
  69913. return ZoneWidget;
  69914. }());
  69915. exports.ZoneWidget = ZoneWidget;
  69916. });
  69917. /*---------------------------------------------------------------------------------------------
  69918. * Copyright (c) Microsoft Corporation. All rights reserved.
  69919. * Licensed under the MIT License. See License.txt in the project root for license information.
  69920. *--------------------------------------------------------------------------------------------*/
  69921. define(__m[216/*vs/editor/standalone/common/monarch/monarchLexer*/], __M([0/*require*/,1/*exports*/,107/*vs/editor/common/core/token*/,17/*vs/editor/common/modes*/,63/*vs/editor/common/modes/nullMode*/,203/*vs/editor/standalone/common/monarch/monarchCommon*/]), function (require, exports, token_1, modes, nullMode_1, monarchCommon) {
  69922. "use strict";
  69923. Object.defineProperty(exports, "__esModule", { value: true });
  69924. var CACHE_STACK_DEPTH = 5;
  69925. /**
  69926. * Reuse the same stack elements up to a certain depth.
  69927. */
  69928. var MonarchStackElementFactory = /** @class */ (function () {
  69929. function MonarchStackElementFactory(maxCacheDepth) {
  69930. this._maxCacheDepth = maxCacheDepth;
  69931. this._entries = Object.create(null);
  69932. }
  69933. MonarchStackElementFactory.create = function (parent, state) {
  69934. return this._INSTANCE.create(parent, state);
  69935. };
  69936. MonarchStackElementFactory.prototype.create = function (parent, state) {
  69937. if (parent !== null && parent.depth >= this._maxCacheDepth) {
  69938. // no caching above a certain depth
  69939. return new MonarchStackElement(parent, state);
  69940. }
  69941. var stackElementId = MonarchStackElement.getStackElementId(parent);
  69942. if (stackElementId.length > 0) {
  69943. stackElementId += '|';
  69944. }
  69945. stackElementId += state;
  69946. var result = this._entries[stackElementId];
  69947. if (result) {
  69948. return result;
  69949. }
  69950. result = new MonarchStackElement(parent, state);
  69951. this._entries[stackElementId] = result;
  69952. return result;
  69953. };
  69954. MonarchStackElementFactory._INSTANCE = new MonarchStackElementFactory(CACHE_STACK_DEPTH);
  69955. return MonarchStackElementFactory;
  69956. }());
  69957. var MonarchStackElement = /** @class */ (function () {
  69958. function MonarchStackElement(parent, state) {
  69959. this.parent = parent;
  69960. this.state = state;
  69961. this.depth = (this.parent ? this.parent.depth : 0) + 1;
  69962. }
  69963. MonarchStackElement.getStackElementId = function (element) {
  69964. var result = '';
  69965. while (element !== null) {
  69966. if (result.length > 0) {
  69967. result += '|';
  69968. }
  69969. result += element.state;
  69970. element = element.parent;
  69971. }
  69972. return result;
  69973. };
  69974. MonarchStackElement._equals = function (a, b) {
  69975. while (a !== null && b !== null) {
  69976. if (a === b) {
  69977. return true;
  69978. }
  69979. if (a.state !== b.state) {
  69980. return false;
  69981. }
  69982. a = a.parent;
  69983. b = b.parent;
  69984. }
  69985. if (a === null && b === null) {
  69986. return true;
  69987. }
  69988. return false;
  69989. };
  69990. MonarchStackElement.prototype.equals = function (other) {
  69991. return MonarchStackElement._equals(this, other);
  69992. };
  69993. MonarchStackElement.prototype.push = function (state) {
  69994. return MonarchStackElementFactory.create(this, state);
  69995. };
  69996. MonarchStackElement.prototype.pop = function () {
  69997. return this.parent;
  69998. };
  69999. MonarchStackElement.prototype.popall = function () {
  70000. var result = this;
  70001. while (result.parent) {
  70002. result = result.parent;
  70003. }
  70004. return result;
  70005. };
  70006. MonarchStackElement.prototype.switchTo = function (state) {
  70007. return MonarchStackElementFactory.create(this.parent, state);
  70008. };
  70009. return MonarchStackElement;
  70010. }());
  70011. var EmbeddedModeData = /** @class */ (function () {
  70012. function EmbeddedModeData(modeId, state) {
  70013. this.modeId = modeId;
  70014. this.state = state;
  70015. }
  70016. EmbeddedModeData.prototype.equals = function (other) {
  70017. return (this.modeId === other.modeId
  70018. && this.state.equals(other.state));
  70019. };
  70020. EmbeddedModeData.prototype.clone = function () {
  70021. var stateClone = this.state.clone();
  70022. // save an object
  70023. if (stateClone === this.state) {
  70024. return this;
  70025. }
  70026. return new EmbeddedModeData(this.modeId, this.state);
  70027. };
  70028. return EmbeddedModeData;
  70029. }());
  70030. /**
  70031. * Reuse the same line states up to a certain depth.
  70032. */
  70033. var MonarchLineStateFactory = /** @class */ (function () {
  70034. function MonarchLineStateFactory(maxCacheDepth) {
  70035. this._maxCacheDepth = maxCacheDepth;
  70036. this._entries = Object.create(null);
  70037. }
  70038. MonarchLineStateFactory.create = function (stack, embeddedModeData) {
  70039. return this._INSTANCE.create(stack, embeddedModeData);
  70040. };
  70041. MonarchLineStateFactory.prototype.create = function (stack, embeddedModeData) {
  70042. if (embeddedModeData !== null) {
  70043. // no caching when embedding
  70044. return new MonarchLineState(stack, embeddedModeData);
  70045. }
  70046. if (stack !== null && stack.depth >= this._maxCacheDepth) {
  70047. // no caching above a certain depth
  70048. return new MonarchLineState(stack, embeddedModeData);
  70049. }
  70050. var stackElementId = MonarchStackElement.getStackElementId(stack);
  70051. var result = this._entries[stackElementId];
  70052. if (result) {
  70053. return result;
  70054. }
  70055. result = new MonarchLineState(stack, null);
  70056. this._entries[stackElementId] = result;
  70057. return result;
  70058. };
  70059. MonarchLineStateFactory._INSTANCE = new MonarchLineStateFactory(CACHE_STACK_DEPTH);
  70060. return MonarchLineStateFactory;
  70061. }());
  70062. var MonarchLineState = /** @class */ (function () {
  70063. function MonarchLineState(stack, embeddedModeData) {
  70064. this.stack = stack;
  70065. this.embeddedModeData = embeddedModeData;
  70066. }
  70067. MonarchLineState.prototype.clone = function () {
  70068. var embeddedModeDataClone = this.embeddedModeData ? this.embeddedModeData.clone() : null;
  70069. // save an object
  70070. if (embeddedModeDataClone === this.embeddedModeData) {
  70071. return this;
  70072. }
  70073. return MonarchLineStateFactory.create(this.stack, this.embeddedModeData);
  70074. };
  70075. MonarchLineState.prototype.equals = function (other) {
  70076. if (!(other instanceof MonarchLineState)) {
  70077. return false;
  70078. }
  70079. if (!this.stack.equals(other.stack)) {
  70080. return false;
  70081. }
  70082. if (this.embeddedModeData === null && other.embeddedModeData === null) {
  70083. return true;
  70084. }
  70085. if (this.embeddedModeData === null || other.embeddedModeData === null) {
  70086. return false;
  70087. }
  70088. return this.embeddedModeData.equals(other.embeddedModeData);
  70089. };
  70090. return MonarchLineState;
  70091. }());
  70092. var MonarchClassicTokensCollector = /** @class */ (function () {
  70093. function MonarchClassicTokensCollector() {
  70094. this._tokens = [];
  70095. this._language = null;
  70096. this._lastTokenType = null;
  70097. this._lastTokenLanguage = null;
  70098. }
  70099. MonarchClassicTokensCollector.prototype.enterMode = function (startOffset, modeId) {
  70100. this._language = modeId;
  70101. };
  70102. MonarchClassicTokensCollector.prototype.emit = function (startOffset, type) {
  70103. if (this._lastTokenType === type && this._lastTokenLanguage === this._language) {
  70104. return;
  70105. }
  70106. this._lastTokenType = type;
  70107. this._lastTokenLanguage = this._language;
  70108. this._tokens.push(new token_1.Token(startOffset, type, this._language));
  70109. };
  70110. MonarchClassicTokensCollector.prototype.nestedModeTokenize = function (embeddedModeLine, embeddedModeData, offsetDelta) {
  70111. var nestedModeId = embeddedModeData.modeId;
  70112. var embeddedModeState = embeddedModeData.state;
  70113. var nestedModeTokenizationSupport = modes.TokenizationRegistry.get(nestedModeId);
  70114. if (!nestedModeTokenizationSupport) {
  70115. this.enterMode(offsetDelta, nestedModeId);
  70116. this.emit(offsetDelta, '');
  70117. return embeddedModeState;
  70118. }
  70119. var nestedResult = nestedModeTokenizationSupport.tokenize(embeddedModeLine, embeddedModeState, offsetDelta);
  70120. this._tokens = this._tokens.concat(nestedResult.tokens);
  70121. this._lastTokenType = null;
  70122. this._lastTokenLanguage = null;
  70123. this._language = null;
  70124. return nestedResult.endState;
  70125. };
  70126. MonarchClassicTokensCollector.prototype.finalize = function (endState) {
  70127. return new token_1.TokenizationResult(this._tokens, endState);
  70128. };
  70129. return MonarchClassicTokensCollector;
  70130. }());
  70131. var MonarchModernTokensCollector = /** @class */ (function () {
  70132. function MonarchModernTokensCollector(modeService, theme) {
  70133. this._modeService = modeService;
  70134. this._theme = theme;
  70135. this._prependTokens = null;
  70136. this._tokens = [];
  70137. this._currentLanguageId = 0 /* Null */;
  70138. this._lastTokenMetadata = 0;
  70139. }
  70140. MonarchModernTokensCollector.prototype.enterMode = function (startOffset, modeId) {
  70141. this._currentLanguageId = this._modeService.getLanguageIdentifier(modeId).id;
  70142. };
  70143. MonarchModernTokensCollector.prototype.emit = function (startOffset, type) {
  70144. var metadata = this._theme.match(this._currentLanguageId, type);
  70145. if (this._lastTokenMetadata === metadata) {
  70146. return;
  70147. }
  70148. this._lastTokenMetadata = metadata;
  70149. this._tokens.push(startOffset);
  70150. this._tokens.push(metadata);
  70151. };
  70152. MonarchModernTokensCollector._merge = function (a, b, c) {
  70153. var aLen = (a !== null ? a.length : 0);
  70154. var bLen = b.length;
  70155. var cLen = (c !== null ? c.length : 0);
  70156. if (aLen === 0 && bLen === 0 && cLen === 0) {
  70157. return new Uint32Array(0);
  70158. }
  70159. if (aLen === 0 && bLen === 0) {
  70160. return c;
  70161. }
  70162. if (bLen === 0 && cLen === 0) {
  70163. return a;
  70164. }
  70165. var result = new Uint32Array(aLen + bLen + cLen);
  70166. if (a !== null) {
  70167. result.set(a);
  70168. }
  70169. for (var i = 0; i < bLen; i++) {
  70170. result[aLen + i] = b[i];
  70171. }
  70172. if (c !== null) {
  70173. result.set(c, aLen + bLen);
  70174. }
  70175. return result;
  70176. };
  70177. MonarchModernTokensCollector.prototype.nestedModeTokenize = function (embeddedModeLine, embeddedModeData, offsetDelta) {
  70178. var nestedModeId = embeddedModeData.modeId;
  70179. var embeddedModeState = embeddedModeData.state;
  70180. var nestedModeTokenizationSupport = modes.TokenizationRegistry.get(nestedModeId);
  70181. if (!nestedModeTokenizationSupport) {
  70182. this.enterMode(offsetDelta, nestedModeId);
  70183. this.emit(offsetDelta, '');
  70184. return embeddedModeState;
  70185. }
  70186. var nestedResult = nestedModeTokenizationSupport.tokenize2(embeddedModeLine, embeddedModeState, offsetDelta);
  70187. this._prependTokens = MonarchModernTokensCollector._merge(this._prependTokens, this._tokens, nestedResult.tokens);
  70188. this._tokens = [];
  70189. this._currentLanguageId = 0;
  70190. this._lastTokenMetadata = 0;
  70191. return nestedResult.endState;
  70192. };
  70193. MonarchModernTokensCollector.prototype.finalize = function (endState) {
  70194. return new token_1.TokenizationResult2(MonarchModernTokensCollector._merge(this._prependTokens, this._tokens, null), endState);
  70195. };
  70196. return MonarchModernTokensCollector;
  70197. }());
  70198. var MonarchTokenizer = /** @class */ (function () {
  70199. function MonarchTokenizer(modeService, standaloneThemeService, modeId, lexer) {
  70200. var _this = this;
  70201. this._modeService = modeService;
  70202. this._standaloneThemeService = standaloneThemeService;
  70203. this._modeId = modeId;
  70204. this._lexer = lexer;
  70205. this._embeddedModes = Object.create(null);
  70206. this.embeddedLoaded = Promise.resolve(undefined);
  70207. // Set up listening for embedded modes
  70208. var emitting = false;
  70209. this._tokenizationRegistryListener = modes.TokenizationRegistry.onDidChange(function (e) {
  70210. if (emitting) {
  70211. return;
  70212. }
  70213. var isOneOfMyEmbeddedModes = false;
  70214. for (var i = 0, len = e.changedLanguages.length; i < len; i++) {
  70215. var language = e.changedLanguages[i];
  70216. if (_this._embeddedModes[language]) {
  70217. isOneOfMyEmbeddedModes = true;
  70218. break;
  70219. }
  70220. }
  70221. if (isOneOfMyEmbeddedModes) {
  70222. emitting = true;
  70223. modes.TokenizationRegistry.fire([_this._modeId]);
  70224. emitting = false;
  70225. }
  70226. });
  70227. }
  70228. MonarchTokenizer.prototype.dispose = function () {
  70229. this._tokenizationRegistryListener.dispose();
  70230. };
  70231. MonarchTokenizer.prototype.getLoadStatus = function () {
  70232. var promises = [];
  70233. for (var nestedModeId in this._embeddedModes) {
  70234. var tokenizationSupport = modes.TokenizationRegistry.get(nestedModeId);
  70235. if (tokenizationSupport) {
  70236. // The nested mode is already loaded
  70237. if (tokenizationSupport instanceof MonarchTokenizer) {
  70238. var nestedModeStatus = tokenizationSupport.getLoadStatus();
  70239. if (nestedModeStatus.loaded === false) {
  70240. promises.push(nestedModeStatus.promise);
  70241. }
  70242. }
  70243. continue;
  70244. }
  70245. var tokenizationSupportPromise = modes.TokenizationRegistry.getPromise(nestedModeId);
  70246. if (tokenizationSupportPromise) {
  70247. // The nested mode is in the process of being loaded
  70248. promises.push(tokenizationSupportPromise);
  70249. }
  70250. }
  70251. if (promises.length === 0) {
  70252. return {
  70253. loaded: true
  70254. };
  70255. }
  70256. return {
  70257. loaded: false,
  70258. promise: Promise.all(promises).then(function (_) { return undefined; })
  70259. };
  70260. };
  70261. MonarchTokenizer.prototype.getInitialState = function () {
  70262. var rootState = MonarchStackElementFactory.create(null, this._lexer.start);
  70263. return MonarchLineStateFactory.create(rootState, null);
  70264. };
  70265. MonarchTokenizer.prototype.tokenize = function (line, lineState, offsetDelta) {
  70266. var tokensCollector = new MonarchClassicTokensCollector();
  70267. var endLineState = this._tokenize(line, lineState, offsetDelta, tokensCollector);
  70268. return tokensCollector.finalize(endLineState);
  70269. };
  70270. MonarchTokenizer.prototype.tokenize2 = function (line, lineState, offsetDelta) {
  70271. var tokensCollector = new MonarchModernTokensCollector(this._modeService, this._standaloneThemeService.getTheme().tokenTheme);
  70272. var endLineState = this._tokenize(line, lineState, offsetDelta, tokensCollector);
  70273. return tokensCollector.finalize(endLineState);
  70274. };
  70275. MonarchTokenizer.prototype._tokenize = function (line, lineState, offsetDelta, collector) {
  70276. if (lineState.embeddedModeData) {
  70277. return this._nestedTokenize(line, lineState, offsetDelta, collector);
  70278. }
  70279. else {
  70280. return this._myTokenize(line, lineState, offsetDelta, collector);
  70281. }
  70282. };
  70283. MonarchTokenizer.prototype._findLeavingNestedModeOffset = function (line, state) {
  70284. var rules = this._lexer.tokenizer[state.stack.state];
  70285. if (!rules) {
  70286. rules = monarchCommon.findRules(this._lexer, state.stack.state); // do parent matching
  70287. if (!rules) {
  70288. throw monarchCommon.createError(this._lexer, 'tokenizer state is not defined: ' + state.stack.state);
  70289. }
  70290. }
  70291. var popOffset = -1;
  70292. var hasEmbeddedPopRule = false;
  70293. for (var _i = 0, rules_1 = rules; _i < rules_1.length; _i++) {
  70294. var rule = rules_1[_i];
  70295. if (!monarchCommon.isIAction(rule.action) || rule.action.nextEmbedded !== '@pop') {
  70296. continue;
  70297. }
  70298. hasEmbeddedPopRule = true;
  70299. var regex = rule.regex;
  70300. var regexSource = rule.regex.source;
  70301. if (regexSource.substr(0, 4) === '^(?:' && regexSource.substr(regexSource.length - 1, 1) === ')') {
  70302. regex = new RegExp(regexSource.substr(4, regexSource.length - 5), regex.ignoreCase ? 'i' : '');
  70303. }
  70304. var result = line.search(regex);
  70305. if (result === -1 || (result !== 0 && rule.matchOnlyAtLineStart)) {
  70306. continue;
  70307. }
  70308. if (popOffset === -1 || result < popOffset) {
  70309. popOffset = result;
  70310. }
  70311. }
  70312. if (!hasEmbeddedPopRule) {
  70313. throw monarchCommon.createError(this._lexer, 'no rule containing nextEmbedded: "@pop" in tokenizer embedded state: ' + state.stack.state);
  70314. }
  70315. return popOffset;
  70316. };
  70317. MonarchTokenizer.prototype._nestedTokenize = function (line, lineState, offsetDelta, tokensCollector) {
  70318. var popOffset = this._findLeavingNestedModeOffset(line, lineState);
  70319. if (popOffset === -1) {
  70320. // tokenization will not leave nested mode
  70321. var nestedEndState = tokensCollector.nestedModeTokenize(line, lineState.embeddedModeData, offsetDelta);
  70322. return MonarchLineStateFactory.create(lineState.stack, new EmbeddedModeData(lineState.embeddedModeData.modeId, nestedEndState));
  70323. }
  70324. var nestedModeLine = line.substring(0, popOffset);
  70325. if (nestedModeLine.length > 0) {
  70326. // tokenize with the nested mode
  70327. tokensCollector.nestedModeTokenize(nestedModeLine, lineState.embeddedModeData, offsetDelta);
  70328. }
  70329. var restOfTheLine = line.substring(popOffset);
  70330. return this._myTokenize(restOfTheLine, lineState, offsetDelta + popOffset, tokensCollector);
  70331. };
  70332. MonarchTokenizer.prototype._safeRuleName = function (rule) {
  70333. if (rule) {
  70334. return rule.name;
  70335. }
  70336. return '(unknown)';
  70337. };
  70338. MonarchTokenizer.prototype._myTokenize = function (line, lineState, offsetDelta, tokensCollector) {
  70339. tokensCollector.enterMode(offsetDelta, this._modeId);
  70340. var lineLength = line.length;
  70341. var embeddedModeData = lineState.embeddedModeData;
  70342. var stack = lineState.stack;
  70343. var pos = 0;
  70344. var groupMatching = null;
  70345. // See https://github.com/Microsoft/monaco-editor/issues/1235:
  70346. // Evaluate rules at least once for an empty line
  70347. var forceEvaluation = true;
  70348. while (forceEvaluation || pos < lineLength) {
  70349. var pos0 = pos;
  70350. var stackLen0 = stack.depth;
  70351. var groupLen0 = groupMatching ? groupMatching.groups.length : 0;
  70352. var state = stack.state;
  70353. var matches = null;
  70354. var matched = null;
  70355. var action = null;
  70356. var rule = null;
  70357. var enteringEmbeddedMode = null;
  70358. // check if we need to process group matches first
  70359. if (groupMatching) {
  70360. matches = groupMatching.matches;
  70361. var groupEntry = groupMatching.groups.shift();
  70362. matched = groupEntry.matched;
  70363. action = groupEntry.action;
  70364. rule = groupMatching.rule;
  70365. // cleanup if necessary
  70366. if (groupMatching.groups.length === 0) {
  70367. groupMatching = null;
  70368. }
  70369. }
  70370. else {
  70371. // otherwise we match on the token stream
  70372. if (!forceEvaluation && pos >= lineLength) {
  70373. // nothing to do
  70374. break;
  70375. }
  70376. forceEvaluation = false;
  70377. // get the rules for this state
  70378. var rules = this._lexer.tokenizer[state];
  70379. if (!rules) {
  70380. rules = monarchCommon.findRules(this._lexer, state); // do parent matching
  70381. if (!rules) {
  70382. throw monarchCommon.createError(this._lexer, 'tokenizer state is not defined: ' + state);
  70383. }
  70384. }
  70385. // try each rule until we match
  70386. var restOfLine = line.substr(pos);
  70387. for (var _i = 0, rules_2 = rules; _i < rules_2.length; _i++) {
  70388. var rule_1 = rules_2[_i];
  70389. if (pos === 0 || !rule_1.matchOnlyAtLineStart) {
  70390. matches = restOfLine.match(rule_1.regex);
  70391. if (matches) {
  70392. matched = matches[0];
  70393. action = rule_1.action;
  70394. break;
  70395. }
  70396. }
  70397. }
  70398. }
  70399. // We matched 'rule' with 'matches' and 'action'
  70400. if (!matches) {
  70401. matches = [''];
  70402. matched = '';
  70403. }
  70404. if (!action) {
  70405. // bad: we didn't match anything, and there is no action to take
  70406. // we need to advance the stream or we get progress trouble
  70407. if (pos < lineLength) {
  70408. matches = [line.charAt(pos)];
  70409. matched = matches[0];
  70410. }
  70411. action = this._lexer.defaultToken;
  70412. }
  70413. if (matched === null) {
  70414. // should never happen, needed for strict null checking
  70415. break;
  70416. }
  70417. // advance stream
  70418. pos += matched.length;
  70419. // maybe call action function (used for 'cases')
  70420. while (monarchCommon.isFuzzyAction(action) && monarchCommon.isIAction(action) && action.test) {
  70421. action = action.test(matched, matches, state, pos === lineLength);
  70422. }
  70423. var result = null;
  70424. // set the result: either a string or an array of actions
  70425. if (typeof action === 'string' || Array.isArray(action)) {
  70426. result = action;
  70427. }
  70428. else if (action.group) {
  70429. result = action.group;
  70430. }
  70431. else if (action.token !== null && action.token !== undefined) {
  70432. // do $n replacements?
  70433. if (action.tokenSubst) {
  70434. result = monarchCommon.substituteMatches(this._lexer, action.token, matched, matches, state);
  70435. }
  70436. else {
  70437. result = action.token;
  70438. }
  70439. // enter embedded mode?
  70440. if (action.nextEmbedded) {
  70441. if (action.nextEmbedded === '@pop') {
  70442. if (!embeddedModeData) {
  70443. throw monarchCommon.createError(this._lexer, 'cannot pop embedded mode if not inside one');
  70444. }
  70445. embeddedModeData = null;
  70446. }
  70447. else if (embeddedModeData) {
  70448. throw monarchCommon.createError(this._lexer, 'cannot enter embedded mode from within an embedded mode');
  70449. }
  70450. else {
  70451. enteringEmbeddedMode = monarchCommon.substituteMatches(this._lexer, action.nextEmbedded, matched, matches, state);
  70452. }
  70453. }
  70454. // state transformations
  70455. if (action.goBack) { // back up the stream..
  70456. pos = Math.max(0, pos - action.goBack);
  70457. }
  70458. if (action.switchTo && typeof action.switchTo === 'string') {
  70459. var nextState = monarchCommon.substituteMatches(this._lexer, action.switchTo, matched, matches, state); // switch state without a push...
  70460. if (nextState[0] === '@') {
  70461. nextState = nextState.substr(1); // peel off starting '@'
  70462. }
  70463. if (!monarchCommon.findRules(this._lexer, nextState)) {
  70464. throw monarchCommon.createError(this._lexer, 'trying to switch to a state \'' + nextState + '\' that is undefined in rule: ' + this._safeRuleName(rule));
  70465. }
  70466. else {
  70467. stack = stack.switchTo(nextState);
  70468. }
  70469. }
  70470. else if (action.transform && typeof action.transform === 'function') {
  70471. throw monarchCommon.createError(this._lexer, 'action.transform not supported');
  70472. }
  70473. else if (action.next) {
  70474. if (action.next === '@push') {
  70475. if (stack.depth >= this._lexer.maxStack) {
  70476. throw monarchCommon.createError(this._lexer, 'maximum tokenizer stack size reached: [' +
  70477. stack.state + ',' + stack.parent.state + ',...]');
  70478. }
  70479. else {
  70480. stack = stack.push(state);
  70481. }
  70482. }
  70483. else if (action.next === '@pop') {
  70484. if (stack.depth <= 1) {
  70485. throw monarchCommon.createError(this._lexer, 'trying to pop an empty stack in rule: ' + this._safeRuleName(rule));
  70486. }
  70487. else {
  70488. stack = stack.pop();
  70489. }
  70490. }
  70491. else if (action.next === '@popall') {
  70492. stack = stack.popall();
  70493. }
  70494. else {
  70495. var nextState = monarchCommon.substituteMatches(this._lexer, action.next, matched, matches, state);
  70496. if (nextState[0] === '@') {
  70497. nextState = nextState.substr(1); // peel off starting '@'
  70498. }
  70499. if (!monarchCommon.findRules(this._lexer, nextState)) {
  70500. throw monarchCommon.createError(this._lexer, 'trying to set a next state \'' + nextState + '\' that is undefined in rule: ' + this._safeRuleName(rule));
  70501. }
  70502. else {
  70503. stack = stack.push(nextState);
  70504. }
  70505. }
  70506. }
  70507. if (action.log && typeof (action.log) === 'string') {
  70508. monarchCommon.log(this._lexer, this._lexer.languageId + ': ' + monarchCommon.substituteMatches(this._lexer, action.log, matched, matches, state));
  70509. }
  70510. }
  70511. // check result
  70512. if (result === null) {
  70513. throw monarchCommon.createError(this._lexer, 'lexer rule has no well-defined action in rule: ' + this._safeRuleName(rule));
  70514. }
  70515. // is the result a group match?
  70516. if (Array.isArray(result)) {
  70517. if (groupMatching && groupMatching.groups.length > 0) {
  70518. throw monarchCommon.createError(this._lexer, 'groups cannot be nested: ' + this._safeRuleName(rule));
  70519. }
  70520. if (matches.length !== result.length + 1) {
  70521. throw monarchCommon.createError(this._lexer, 'matched number of groups does not match the number of actions in rule: ' + this._safeRuleName(rule));
  70522. }
  70523. var totalLen = 0;
  70524. for (var i = 1; i < matches.length; i++) {
  70525. totalLen += matches[i].length;
  70526. }
  70527. if (totalLen !== matched.length) {
  70528. throw monarchCommon.createError(this._lexer, 'with groups, all characters should be matched in consecutive groups in rule: ' + this._safeRuleName(rule));
  70529. }
  70530. groupMatching = {
  70531. rule: rule,
  70532. matches: matches,
  70533. groups: []
  70534. };
  70535. for (var i = 0; i < result.length; i++) {
  70536. groupMatching.groups[i] = {
  70537. action: result[i],
  70538. matched: matches[i + 1]
  70539. };
  70540. }
  70541. pos -= matched.length;
  70542. // call recursively to initiate first result match
  70543. continue;
  70544. }
  70545. else {
  70546. // regular result
  70547. // check for '@rematch'
  70548. if (result === '@rematch') {
  70549. pos -= matched.length;
  70550. matched = ''; // better set the next state too..
  70551. matches = null;
  70552. result = '';
  70553. }
  70554. // check progress
  70555. if (matched.length === 0) {
  70556. if (lineLength === 0 || stackLen0 !== stack.depth || state !== stack.state || (!groupMatching ? 0 : groupMatching.groups.length) !== groupLen0) {
  70557. continue;
  70558. }
  70559. else {
  70560. throw monarchCommon.createError(this._lexer, 'no progress in tokenizer in rule: ' + this._safeRuleName(rule));
  70561. }
  70562. }
  70563. // return the result (and check for brace matching)
  70564. // todo: for efficiency we could pre-sanitize tokenPostfix and substitutions
  70565. var tokenType = null;
  70566. if (monarchCommon.isString(result) && result.indexOf('@brackets') === 0) {
  70567. var rest = result.substr('@brackets'.length);
  70568. var bracket = findBracket(this._lexer, matched);
  70569. if (!bracket) {
  70570. throw monarchCommon.createError(this._lexer, '@brackets token returned but no bracket defined as: ' + matched);
  70571. }
  70572. tokenType = monarchCommon.sanitize(bracket.token + rest);
  70573. }
  70574. else {
  70575. var token = (result === '' ? '' : result + this._lexer.tokenPostfix);
  70576. tokenType = monarchCommon.sanitize(token);
  70577. }
  70578. tokensCollector.emit(pos0 + offsetDelta, tokenType);
  70579. }
  70580. if (enteringEmbeddedMode !== null) {
  70581. // substitute language alias to known modes to support syntax highlighting
  70582. var enteringEmbeddedModeId = this._modeService.getModeIdForLanguageName(enteringEmbeddedMode);
  70583. if (enteringEmbeddedModeId) {
  70584. enteringEmbeddedMode = enteringEmbeddedModeId;
  70585. }
  70586. var embeddedModeData_1 = this._getNestedEmbeddedModeData(enteringEmbeddedMode);
  70587. if (pos < lineLength) {
  70588. // there is content from the embedded mode on this line
  70589. var restOfLine = line.substr(pos);
  70590. return this._nestedTokenize(restOfLine, MonarchLineStateFactory.create(stack, embeddedModeData_1), offsetDelta + pos, tokensCollector);
  70591. }
  70592. else {
  70593. return MonarchLineStateFactory.create(stack, embeddedModeData_1);
  70594. }
  70595. }
  70596. }
  70597. return MonarchLineStateFactory.create(stack, embeddedModeData);
  70598. };
  70599. MonarchTokenizer.prototype._getNestedEmbeddedModeData = function (mimetypeOrModeId) {
  70600. var nestedModeId = this._locateMode(mimetypeOrModeId);
  70601. if (nestedModeId) {
  70602. var tokenizationSupport = modes.TokenizationRegistry.get(nestedModeId);
  70603. if (tokenizationSupport) {
  70604. return new EmbeddedModeData(nestedModeId, tokenizationSupport.getInitialState());
  70605. }
  70606. }
  70607. return new EmbeddedModeData(nestedModeId || nullMode_1.NULL_MODE_ID, nullMode_1.NULL_STATE);
  70608. };
  70609. MonarchTokenizer.prototype._locateMode = function (mimetypeOrModeId) {
  70610. if (!mimetypeOrModeId || !this._modeService.isRegisteredMode(mimetypeOrModeId)) {
  70611. return null;
  70612. }
  70613. if (mimetypeOrModeId === this._modeId) {
  70614. // embedding myself...
  70615. return mimetypeOrModeId;
  70616. }
  70617. var modeId = this._modeService.getModeId(mimetypeOrModeId);
  70618. if (modeId) {
  70619. // Fire mode loading event
  70620. this._modeService.triggerMode(modeId);
  70621. this._embeddedModes[modeId] = true;
  70622. }
  70623. return modeId;
  70624. };
  70625. return MonarchTokenizer;
  70626. }());
  70627. exports.MonarchTokenizer = MonarchTokenizer;
  70628. /**
  70629. * Searches for a bracket in the 'brackets' attribute that matches the input.
  70630. */
  70631. function findBracket(lexer, matched) {
  70632. if (!matched) {
  70633. return null;
  70634. }
  70635. matched = monarchCommon.fixCase(lexer, matched);
  70636. var brackets = lexer.brackets;
  70637. for (var _i = 0, brackets_1 = brackets; _i < brackets_1.length; _i++) {
  70638. var bracket = brackets_1[_i];
  70639. if (bracket.open === matched) {
  70640. return { token: bracket.token, bracketType: 1 /* Open */ };
  70641. }
  70642. else if (bracket.close === matched) {
  70643. return { token: bracket.token, bracketType: -1 /* Close */ };
  70644. }
  70645. }
  70646. return null;
  70647. }
  70648. function createTokenizationSupport(modeService, standaloneThemeService, modeId, lexer) {
  70649. return new MonarchTokenizer(modeService, standaloneThemeService, modeId, lexer);
  70650. }
  70651. exports.createTokenizationSupport = createTokenizationSupport;
  70652. });
  70653. /*---------------------------------------------------------------------------------------------
  70654. * Copyright (c) Microsoft Corporation. All rights reserved.
  70655. * Licensed under the MIT License. See License.txt in the project root for license information.
  70656. *--------------------------------------------------------------------------------------------*/
  70657. define(__m[494/*vs/editor/standalone/browser/colorizer*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,5/*vs/base/common/strings*/,93/*vs/editor/common/core/lineTokens*/,17/*vs/editor/common/modes*/,110/*vs/editor/common/viewLayout/viewLineRenderer*/,69/*vs/editor/common/viewModel/viewModel*/,216/*vs/editor/standalone/common/monarch/monarchLexer*/]), function (require, exports, async_1, strings, lineTokens_1, modes_1, viewLineRenderer_1, viewModel_1, monarchLexer_1) {
  70658. "use strict";
  70659. Object.defineProperty(exports, "__esModule", { value: true });
  70660. var Colorizer = /** @class */ (function () {
  70661. function Colorizer() {
  70662. }
  70663. Colorizer.colorizeElement = function (themeService, modeService, domNode, options) {
  70664. options = options || {};
  70665. var theme = options.theme || 'vs';
  70666. var mimeType = options.mimeType || domNode.getAttribute('lang') || domNode.getAttribute('data-lang');
  70667. if (!mimeType) {
  70668. console.error('Mode not detected');
  70669. return Promise.resolve();
  70670. }
  70671. themeService.setTheme(theme);
  70672. var text = domNode.firstChild ? domNode.firstChild.nodeValue : '';
  70673. domNode.className += ' ' + theme;
  70674. var render = function (str) {
  70675. domNode.innerHTML = str;
  70676. };
  70677. return this.colorize(modeService, text || '', mimeType, options).then(render, function (err) { return console.error(err); });
  70678. };
  70679. Colorizer.colorize = function (modeService, text, mimeType, options) {
  70680. var tabSize = 4;
  70681. if (options && typeof options.tabSize === 'number') {
  70682. tabSize = options.tabSize;
  70683. }
  70684. if (strings.startsWithUTF8BOM(text)) {
  70685. text = text.substr(1);
  70686. }
  70687. var lines = text.split(/\r\n|\r|\n/);
  70688. var language = modeService.getModeId(mimeType);
  70689. if (!language) {
  70690. return Promise.resolve(_fakeColorize(lines, tabSize));
  70691. }
  70692. // Send out the event to create the mode
  70693. modeService.triggerMode(language);
  70694. var tokenizationSupport = modes_1.TokenizationRegistry.get(language);
  70695. if (tokenizationSupport) {
  70696. return _colorize(lines, tabSize, tokenizationSupport);
  70697. }
  70698. var tokenizationSupportPromise = modes_1.TokenizationRegistry.getPromise(language);
  70699. if (tokenizationSupportPromise) {
  70700. // A tokenizer will be registered soon
  70701. return new Promise(function (resolve, reject) {
  70702. tokenizationSupportPromise.then(function (tokenizationSupport) {
  70703. _colorize(lines, tabSize, tokenizationSupport).then(resolve, reject);
  70704. }, reject);
  70705. });
  70706. }
  70707. return new Promise(function (resolve, reject) {
  70708. var listener = null;
  70709. var timeout = null;
  70710. var execute = function () {
  70711. if (listener) {
  70712. listener.dispose();
  70713. listener = null;
  70714. }
  70715. if (timeout) {
  70716. timeout.dispose();
  70717. timeout = null;
  70718. }
  70719. var tokenizationSupport = modes_1.TokenizationRegistry.get(language);
  70720. if (tokenizationSupport) {
  70721. _colorize(lines, tabSize, tokenizationSupport).then(resolve, reject);
  70722. return;
  70723. }
  70724. resolve(_fakeColorize(lines, tabSize));
  70725. };
  70726. // wait 500ms for mode to load, then give up
  70727. timeout = new async_1.TimeoutTimer();
  70728. timeout.cancelAndSet(execute, 500);
  70729. listener = modes_1.TokenizationRegistry.onDidChange(function (e) {
  70730. if (e.changedLanguages.indexOf(language) >= 0) {
  70731. execute();
  70732. }
  70733. });
  70734. });
  70735. };
  70736. Colorizer.colorizeLine = function (line, mightContainNonBasicASCII, mightContainRTL, tokens, tabSize) {
  70737. if (tabSize === void 0) { tabSize = 4; }
  70738. var isBasicASCII = viewModel_1.ViewLineRenderingData.isBasicASCII(line, mightContainNonBasicASCII);
  70739. var containsRTL = viewModel_1.ViewLineRenderingData.containsRTL(line, isBasicASCII, mightContainRTL);
  70740. var renderResult = viewLineRenderer_1.renderViewLine2(new viewLineRenderer_1.RenderLineInput(false, true, line, false, isBasicASCII, containsRTL, 0, tokens, [], tabSize, 0, 0, 0, -1, 'none', false, false, null));
  70741. return renderResult.html;
  70742. };
  70743. Colorizer.colorizeModelLine = function (model, lineNumber, tabSize) {
  70744. if (tabSize === void 0) { tabSize = 4; }
  70745. var content = model.getLineContent(lineNumber);
  70746. model.forceTokenization(lineNumber);
  70747. var tokens = model.getLineTokens(lineNumber);
  70748. var inflatedTokens = tokens.inflate();
  70749. return this.colorizeLine(content, model.mightContainNonBasicASCII(), model.mightContainRTL(), inflatedTokens, tabSize);
  70750. };
  70751. return Colorizer;
  70752. }());
  70753. exports.Colorizer = Colorizer;
  70754. function _colorize(lines, tabSize, tokenizationSupport) {
  70755. return new Promise(function (c, e) {
  70756. var execute = function () {
  70757. var result = _actualColorize(lines, tabSize, tokenizationSupport);
  70758. if (tokenizationSupport instanceof monarchLexer_1.MonarchTokenizer) {
  70759. var status_1 = tokenizationSupport.getLoadStatus();
  70760. if (status_1.loaded === false) {
  70761. status_1.promise.then(execute, e);
  70762. return;
  70763. }
  70764. }
  70765. c(result);
  70766. };
  70767. execute();
  70768. });
  70769. }
  70770. function _fakeColorize(lines, tabSize) {
  70771. var html = [];
  70772. var defaultMetadata = ((0 /* None */ << 11 /* FONT_STYLE_OFFSET */)
  70773. | (1 /* DefaultForeground */ << 14 /* FOREGROUND_OFFSET */)
  70774. | (2 /* DefaultBackground */ << 23 /* BACKGROUND_OFFSET */)) >>> 0;
  70775. var tokens = new Uint32Array(2);
  70776. tokens[0] = 0;
  70777. tokens[1] = defaultMetadata;
  70778. for (var i = 0, length_1 = lines.length; i < length_1; i++) {
  70779. var line = lines[i];
  70780. tokens[0] = line.length;
  70781. var lineTokens = new lineTokens_1.LineTokens(tokens, line);
  70782. var isBasicASCII = viewModel_1.ViewLineRenderingData.isBasicASCII(line, /* check for basic ASCII */ true);
  70783. var containsRTL = viewModel_1.ViewLineRenderingData.containsRTL(line, isBasicASCII, /* check for RTL */ true);
  70784. var renderResult = viewLineRenderer_1.renderViewLine2(new viewLineRenderer_1.RenderLineInput(false, true, line, false, isBasicASCII, containsRTL, 0, lineTokens, [], tabSize, 0, 0, 0, -1, 'none', false, false, null));
  70785. html = html.concat(renderResult.html);
  70786. html.push('<br/>');
  70787. }
  70788. return html.join('');
  70789. }
  70790. function _actualColorize(lines, tabSize, tokenizationSupport) {
  70791. var html = [];
  70792. var state = tokenizationSupport.getInitialState();
  70793. for (var i = 0, length_2 = lines.length; i < length_2; i++) {
  70794. var line = lines[i];
  70795. var tokenizeResult = tokenizationSupport.tokenize2(line, state, 0);
  70796. lineTokens_1.LineTokens.convertToEndOffset(tokenizeResult.tokens, line.length);
  70797. var lineTokens = new lineTokens_1.LineTokens(tokenizeResult.tokens, line);
  70798. var isBasicASCII = viewModel_1.ViewLineRenderingData.isBasicASCII(line, /* check for basic ASCII */ true);
  70799. var containsRTL = viewModel_1.ViewLineRenderingData.containsRTL(line, isBasicASCII, /* check for RTL */ true);
  70800. var renderResult = viewLineRenderer_1.renderViewLine2(new viewLineRenderer_1.RenderLineInput(false, true, line, false, isBasicASCII, containsRTL, 0, lineTokens.inflate(), [], tabSize, 0, 0, 0, -1, 'none', false, false, null));
  70801. html = html.concat(renderResult.html);
  70802. html.push('<br/>');
  70803. state = tokenizeResult.endState;
  70804. }
  70805. return html.join('');
  70806. }
  70807. });
  70808. /*---------------------------------------------------------------------------------------------
  70809. * Copyright (c) Microsoft Corporation. All rights reserved.
  70810. * Licensed under the MIT License. See License.txt in the project root for license information.
  70811. *--------------------------------------------------------------------------------------------*/
  70812. define(__m[94/*vs/editor/standalone/common/standaloneThemeService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  70813. "use strict";
  70814. Object.defineProperty(exports, "__esModule", { value: true });
  70815. exports.IStandaloneThemeService = instantiation_1.createDecorator('themeService');
  70816. });
  70817. /*---------------------------------------------------------------------------------------------
  70818. * Copyright (c) Microsoft Corporation. All rights reserved.
  70819. * Licensed under the MIT License. See License.txt in the project root for license information.
  70820. *--------------------------------------------------------------------------------------------*/
  70821. define(__m[162/*vs/platform/clipboard/common/clipboardService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  70822. "use strict";
  70823. Object.defineProperty(exports, "__esModule", { value: true });
  70824. exports.IClipboardService = instantiation_1.createDecorator('clipboardService');
  70825. });
  70826. /*---------------------------------------------------------------------------------------------
  70827. * Copyright (c) Microsoft Corporation. All rights reserved.
  70828. * Licensed under the MIT License. See License.txt in the project root for license information.
  70829. *--------------------------------------------------------------------------------------------*/
  70830. var __spreadArrays = (this && this.__spreadArrays) || function () {
  70831. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  70832. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  70833. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  70834. r[k] = a[j];
  70835. return r;
  70836. };
  70837. define(__m[29/*vs/platform/commands/common/commands*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,21/*vs/base/common/types*/,11/*vs/platform/instantiation/common/instantiation*/,4/*vs/base/common/event*/,76/*vs/base/common/linkedList*/,38/*vs/base/common/map*/]), function (require, exports, lifecycle_1, types_1, instantiation_1, event_1, linkedList_1, map_1) {
  70838. "use strict";
  70839. Object.defineProperty(exports, "__esModule", { value: true });
  70840. exports.ICommandService = instantiation_1.createDecorator('commandService');
  70841. exports.CommandsRegistry = new /** @class */ (function () {
  70842. function class_1() {
  70843. this._commands = new Map();
  70844. this._onDidRegisterCommand = new event_1.Emitter();
  70845. this.onDidRegisterCommand = this._onDidRegisterCommand.event;
  70846. }
  70847. class_1.prototype.registerCommand = function (idOrCommand, handler) {
  70848. var _this = this;
  70849. if (!idOrCommand) {
  70850. throw new Error("invalid command");
  70851. }
  70852. if (typeof idOrCommand === 'string') {
  70853. if (!handler) {
  70854. throw new Error("invalid command");
  70855. }
  70856. return this.registerCommand({ id: idOrCommand, handler: handler });
  70857. }
  70858. // add argument validation if rich command metadata is provided
  70859. if (idOrCommand.description) {
  70860. var constraints_1 = [];
  70861. for (var _i = 0, _a = idOrCommand.description.args; _i < _a.length; _i++) {
  70862. var arg = _a[_i];
  70863. constraints_1.push(arg.constraint);
  70864. }
  70865. var actualHandler_1 = idOrCommand.handler;
  70866. idOrCommand.handler = function (accessor) {
  70867. var args = [];
  70868. for (var _i = 1; _i < arguments.length; _i++) {
  70869. args[_i - 1] = arguments[_i];
  70870. }
  70871. types_1.validateConstraints(args, constraints_1);
  70872. return actualHandler_1.apply(void 0, __spreadArrays([accessor], args));
  70873. };
  70874. }
  70875. // find a place to store the command
  70876. var id = idOrCommand.id;
  70877. var commands = this._commands.get(id);
  70878. if (!commands) {
  70879. commands = new linkedList_1.LinkedList();
  70880. this._commands.set(id, commands);
  70881. }
  70882. var removeFn = commands.unshift(idOrCommand);
  70883. var ret = lifecycle_1.toDisposable(function () {
  70884. removeFn();
  70885. var command = _this._commands.get(id);
  70886. if (command === null || command === void 0 ? void 0 : command.isEmpty()) {
  70887. _this._commands.delete(id);
  70888. }
  70889. });
  70890. // tell the world about this command
  70891. this._onDidRegisterCommand.fire(id);
  70892. return ret;
  70893. };
  70894. class_1.prototype.registerCommandAlias = function (oldId, newId) {
  70895. return exports.CommandsRegistry.registerCommand(oldId, function (accessor) {
  70896. var _a;
  70897. var args = [];
  70898. for (var _i = 1; _i < arguments.length; _i++) {
  70899. args[_i - 1] = arguments[_i];
  70900. }
  70901. return (_a = accessor.get(exports.ICommandService)).executeCommand.apply(_a, __spreadArrays([newId], args));
  70902. });
  70903. };
  70904. class_1.prototype.getCommand = function (id) {
  70905. var list = this._commands.get(id);
  70906. if (!list || list.isEmpty()) {
  70907. return undefined;
  70908. }
  70909. return list.iterator().next().value;
  70910. };
  70911. class_1.prototype.getCommands = function () {
  70912. var result = new Map();
  70913. for (var _i = 0, _a = map_1.keys(this._commands); _i < _a.length; _i++) {
  70914. var key = _a[_i];
  70915. var command = this.getCommand(key);
  70916. if (command) {
  70917. result.set(key, command);
  70918. }
  70919. }
  70920. return result;
  70921. };
  70922. return class_1;
  70923. }());
  70924. });
  70925. /*---------------------------------------------------------------------------------------------
  70926. * Copyright (c) Microsoft Corporation. All rights reserved.
  70927. * Licensed under the MIT License. See License.txt in the project root for license information.
  70928. *--------------------------------------------------------------------------------------------*/
  70929. define(__m[495/*vs/editor/contrib/links/getLinks*/], __M([0/*require*/,1/*exports*/,26/*vs/base/common/cancellation*/,10/*vs/base/common/errors*/,25/*vs/base/common/uri*/,3/*vs/editor/common/core/range*/,17/*vs/editor/common/modes*/,49/*vs/editor/common/services/modelService*/,29/*vs/platform/commands/common/commands*/,2/*vs/base/common/lifecycle*/,19/*vs/base/common/arrays*/]), function (require, exports, cancellation_1, errors_1, uri_1, range_1, modes_1, modelService_1, commands_1, lifecycle_1, arrays_1) {
  70930. "use strict";
  70931. Object.defineProperty(exports, "__esModule", { value: true });
  70932. var Link = /** @class */ (function () {
  70933. function Link(link, provider) {
  70934. this._link = link;
  70935. this._provider = provider;
  70936. }
  70937. Link.prototype.toJSON = function () {
  70938. return {
  70939. range: this.range,
  70940. url: this.url,
  70941. tooltip: this.tooltip
  70942. };
  70943. };
  70944. Object.defineProperty(Link.prototype, "range", {
  70945. get: function () {
  70946. return this._link.range;
  70947. },
  70948. enumerable: true,
  70949. configurable: true
  70950. });
  70951. Object.defineProperty(Link.prototype, "url", {
  70952. get: function () {
  70953. return this._link.url;
  70954. },
  70955. enumerable: true,
  70956. configurable: true
  70957. });
  70958. Object.defineProperty(Link.prototype, "tooltip", {
  70959. get: function () {
  70960. return this._link.tooltip;
  70961. },
  70962. enumerable: true,
  70963. configurable: true
  70964. });
  70965. Link.prototype.resolve = function (token) {
  70966. return __awaiter(this, void 0, void 0, function () {
  70967. var _this = this;
  70968. return __generator(this, function (_a) {
  70969. if (this._link.url) {
  70970. return [2 /*return*/, this._link.url];
  70971. }
  70972. if (typeof this._provider.resolveLink === 'function') {
  70973. return [2 /*return*/, Promise.resolve(this._provider.resolveLink(this._link, token)).then(function (value) {
  70974. _this._link = value || _this._link;
  70975. if (_this._link.url) {
  70976. // recurse
  70977. return _this.resolve(token);
  70978. }
  70979. return Promise.reject(new Error('missing'));
  70980. })];
  70981. }
  70982. return [2 /*return*/, Promise.reject(new Error('missing'))];
  70983. });
  70984. });
  70985. };
  70986. return Link;
  70987. }());
  70988. exports.Link = Link;
  70989. var LinksList = /** @class */ (function (_super) {
  70990. __extends(LinksList, _super);
  70991. function LinksList(tuples) {
  70992. var _this = _super.call(this) || this;
  70993. var links = [];
  70994. var _loop_1 = function (list, provider) {
  70995. // merge all links
  70996. var newLinks = list.links.map(function (link) { return new Link(link, provider); });
  70997. links = LinksList._union(links, newLinks);
  70998. // register disposables
  70999. if (lifecycle_1.isDisposable(provider)) {
  71000. this_1._register(provider);
  71001. }
  71002. };
  71003. var this_1 = this;
  71004. for (var _i = 0, tuples_1 = tuples; _i < tuples_1.length; _i++) {
  71005. var _a = tuples_1[_i], list = _a[0], provider = _a[1];
  71006. _loop_1(list, provider);
  71007. }
  71008. _this.links = links;
  71009. return _this;
  71010. }
  71011. LinksList._union = function (oldLinks, newLinks) {
  71012. // reunite oldLinks with newLinks and remove duplicates
  71013. var result = [];
  71014. var oldIndex;
  71015. var oldLen;
  71016. var newIndex;
  71017. var newLen;
  71018. for (oldIndex = 0, newIndex = 0, oldLen = oldLinks.length, newLen = newLinks.length; oldIndex < oldLen && newIndex < newLen;) {
  71019. var oldLink = oldLinks[oldIndex];
  71020. var newLink = newLinks[newIndex];
  71021. if (range_1.Range.areIntersectingOrTouching(oldLink.range, newLink.range)) {
  71022. // Remove the oldLink
  71023. oldIndex++;
  71024. continue;
  71025. }
  71026. var comparisonResult = range_1.Range.compareRangesUsingStarts(oldLink.range, newLink.range);
  71027. if (comparisonResult < 0) {
  71028. // oldLink is before
  71029. result.push(oldLink);
  71030. oldIndex++;
  71031. }
  71032. else {
  71033. // newLink is before
  71034. result.push(newLink);
  71035. newIndex++;
  71036. }
  71037. }
  71038. for (; oldIndex < oldLen; oldIndex++) {
  71039. result.push(oldLinks[oldIndex]);
  71040. }
  71041. for (; newIndex < newLen; newIndex++) {
  71042. result.push(newLinks[newIndex]);
  71043. }
  71044. return result;
  71045. };
  71046. return LinksList;
  71047. }(lifecycle_1.Disposable));
  71048. exports.LinksList = LinksList;
  71049. function getLinks(model, token) {
  71050. var lists = [];
  71051. // ask all providers for links in parallel
  71052. var promises = modes_1.LinkProviderRegistry.ordered(model).reverse().map(function (provider, i) {
  71053. return Promise.resolve(provider.provideLinks(model, token)).then(function (result) {
  71054. if (result) {
  71055. lists[i] = [result, provider];
  71056. }
  71057. }, errors_1.onUnexpectedExternalError);
  71058. });
  71059. return Promise.all(promises).then(function () {
  71060. var result = new LinksList(arrays_1.coalesce(lists));
  71061. if (!token.isCancellationRequested) {
  71062. return result;
  71063. }
  71064. result.dispose();
  71065. return new LinksList([]);
  71066. });
  71067. }
  71068. exports.getLinks = getLinks;
  71069. commands_1.CommandsRegistry.registerCommand('_executeLinkProvider', function (accessor) {
  71070. var args = [];
  71071. for (var _i = 1; _i < arguments.length; _i++) {
  71072. args[_i - 1] = arguments[_i];
  71073. }
  71074. return __awaiter(void 0, void 0, void 0, function () {
  71075. var uri, model, list, result;
  71076. return __generator(this, function (_a) {
  71077. switch (_a.label) {
  71078. case 0:
  71079. uri = args[0];
  71080. if (!(uri instanceof uri_1.URI)) {
  71081. return [2 /*return*/, []];
  71082. }
  71083. model = accessor.get(modelService_1.IModelService).getModel(uri);
  71084. if (!model) {
  71085. return [2 /*return*/, []];
  71086. }
  71087. return [4 /*yield*/, getLinks(model, cancellation_1.CancellationToken.None)];
  71088. case 1:
  71089. list = _a.sent();
  71090. if (!list) {
  71091. return [2 /*return*/, []];
  71092. }
  71093. result = list.links.slice(0);
  71094. list.dispose();
  71095. return [2 /*return*/, result];
  71096. }
  71097. });
  71098. });
  71099. });
  71100. });
  71101. /*---------------------------------------------------------------------------------------------
  71102. * Copyright (c) Microsoft Corporation. All rights reserved.
  71103. * Licensed under the MIT License. See License.txt in the project root for license information.
  71104. *--------------------------------------------------------------------------------------------*/
  71105. define(__m[496/*vs/editor/contrib/quickOpen/quickOpen*/], __M([0/*require*/,1/*exports*/,25/*vs/base/common/uri*/,3/*vs/editor/common/core/range*/,49/*vs/editor/common/services/modelService*/,26/*vs/base/common/cancellation*/,84/*vs/editor/common/services/resolverService*/,489/*vs/editor/contrib/documentSymbols/outlineModel*/,87/*vs/base/common/collections*/,29/*vs/platform/commands/common/commands*/,21/*vs/base/common/types*/]), function (require, exports, uri_1, range_1, modelService_1, cancellation_1, resolverService_1, outlineModel_1, collections_1, commands_1, types_1) {
  71106. "use strict";
  71107. Object.defineProperty(exports, "__esModule", { value: true });
  71108. function getDocumentSymbols(document, flat, token) {
  71109. return __awaiter(this, void 0, void 0, function () {
  71110. var model, roots, _i, _a, child, flatEntries;
  71111. return __generator(this, function (_b) {
  71112. switch (_b.label) {
  71113. case 0: return [4 /*yield*/, outlineModel_1.OutlineModel.create(document, token)];
  71114. case 1:
  71115. model = _b.sent();
  71116. roots = [];
  71117. for (_i = 0, _a = collections_1.values(model.children); _i < _a.length; _i++) {
  71118. child = _a[_i];
  71119. if (child instanceof outlineModel_1.OutlineElement) {
  71120. roots.push(child.symbol);
  71121. }
  71122. else {
  71123. roots.push.apply(roots, collections_1.values(child.children).map(function (child) { return child.symbol; }));
  71124. }
  71125. }
  71126. flatEntries = [];
  71127. if (token.isCancellationRequested) {
  71128. return [2 /*return*/, flatEntries];
  71129. }
  71130. if (flat) {
  71131. flatten(flatEntries, roots, '');
  71132. }
  71133. else {
  71134. flatEntries = roots;
  71135. }
  71136. return [2 /*return*/, flatEntries.sort(compareEntriesUsingStart)];
  71137. }
  71138. });
  71139. });
  71140. }
  71141. exports.getDocumentSymbols = getDocumentSymbols;
  71142. function compareEntriesUsingStart(a, b) {
  71143. return range_1.Range.compareRangesUsingStarts(a.range, b.range);
  71144. }
  71145. function flatten(bucket, entries, overrideContainerLabel) {
  71146. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  71147. var entry = entries_1[_i];
  71148. bucket.push({
  71149. kind: entry.kind,
  71150. tags: entry.tags,
  71151. name: entry.name,
  71152. detail: entry.detail,
  71153. containerName: entry.containerName || overrideContainerLabel,
  71154. range: entry.range,
  71155. selectionRange: entry.selectionRange,
  71156. children: undefined,
  71157. });
  71158. if (entry.children) {
  71159. flatten(bucket, entry.children, entry.name);
  71160. }
  71161. }
  71162. }
  71163. commands_1.CommandsRegistry.registerCommand('_executeDocumentSymbolProvider', function (accessor) {
  71164. var args = [];
  71165. for (var _i = 1; _i < arguments.length; _i++) {
  71166. args[_i - 1] = arguments[_i];
  71167. }
  71168. return __awaiter(this, void 0, void 0, function () {
  71169. var resource, model, reference;
  71170. return __generator(this, function (_a) {
  71171. switch (_a.label) {
  71172. case 0:
  71173. resource = args[0];
  71174. types_1.assertType(uri_1.URI.isUri(resource));
  71175. model = accessor.get(modelService_1.IModelService).getModel(resource);
  71176. if (model) {
  71177. return [2 /*return*/, getDocumentSymbols(model, false, cancellation_1.CancellationToken.None)];
  71178. }
  71179. return [4 /*yield*/, accessor.get(resolverService_1.ITextModelService).createModelReference(resource)];
  71180. case 1:
  71181. reference = _a.sent();
  71182. _a.label = 2;
  71183. case 2:
  71184. _a.trys.push([2, , 4, 5]);
  71185. return [4 /*yield*/, getDocumentSymbols(reference.object.textEditorModel, false, cancellation_1.CancellationToken.None)];
  71186. case 3: return [2 /*return*/, _a.sent()];
  71187. case 4:
  71188. reference.dispose();
  71189. return [7 /*endfinally*/];
  71190. case 5: return [2 /*return*/];
  71191. }
  71192. });
  71193. });
  71194. });
  71195. });
  71196. /*---------------------------------------------------------------------------------------------
  71197. * Copyright (c) Microsoft Corporation. All rights reserved.
  71198. * Licensed under the MIT License. See License.txt in the project root for license information.
  71199. *--------------------------------------------------------------------------------------------*/
  71200. define(__m[18/*vs/platform/contextkey/common/contextkey*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, strings_1, instantiation_1) {
  71201. "use strict";
  71202. Object.defineProperty(exports, "__esModule", { value: true });
  71203. var ContextKeyExpr = /** @class */ (function () {
  71204. function ContextKeyExpr() {
  71205. }
  71206. ContextKeyExpr.has = function (key) {
  71207. return ContextKeyDefinedExpr.create(key);
  71208. };
  71209. ContextKeyExpr.equals = function (key, value) {
  71210. return ContextKeyEqualsExpr.create(key, value);
  71211. };
  71212. ContextKeyExpr.regex = function (key, value) {
  71213. return ContextKeyRegexExpr.create(key, value);
  71214. };
  71215. ContextKeyExpr.not = function (key) {
  71216. return ContextKeyNotExpr.create(key);
  71217. };
  71218. ContextKeyExpr.and = function () {
  71219. var expr = [];
  71220. for (var _i = 0; _i < arguments.length; _i++) {
  71221. expr[_i] = arguments[_i];
  71222. }
  71223. return ContextKeyAndExpr.create(expr);
  71224. };
  71225. ContextKeyExpr.or = function () {
  71226. var expr = [];
  71227. for (var _i = 0; _i < arguments.length; _i++) {
  71228. expr[_i] = arguments[_i];
  71229. }
  71230. return ContextKeyOrExpr.create(expr);
  71231. };
  71232. ContextKeyExpr.deserialize = function (serialized, strict) {
  71233. if (strict === void 0) { strict = false; }
  71234. if (!serialized) {
  71235. return undefined;
  71236. }
  71237. return this._deserializeOrExpression(serialized, strict);
  71238. };
  71239. ContextKeyExpr._deserializeOrExpression = function (serialized, strict) {
  71240. var _this = this;
  71241. var pieces = serialized.split('||');
  71242. return ContextKeyOrExpr.create(pieces.map(function (p) { return _this._deserializeAndExpression(p, strict); }));
  71243. };
  71244. ContextKeyExpr._deserializeAndExpression = function (serialized, strict) {
  71245. var _this = this;
  71246. var pieces = serialized.split('&&');
  71247. return ContextKeyAndExpr.create(pieces.map(function (p) { return _this._deserializeOne(p, strict); }));
  71248. };
  71249. ContextKeyExpr._deserializeOne = function (serializedOne, strict) {
  71250. serializedOne = serializedOne.trim();
  71251. if (serializedOne.indexOf('!=') >= 0) {
  71252. var pieces = serializedOne.split('!=');
  71253. return ContextKeyNotEqualsExpr.create(pieces[0].trim(), this._deserializeValue(pieces[1], strict));
  71254. }
  71255. if (serializedOne.indexOf('==') >= 0) {
  71256. var pieces = serializedOne.split('==');
  71257. return ContextKeyEqualsExpr.create(pieces[0].trim(), this._deserializeValue(pieces[1], strict));
  71258. }
  71259. if (serializedOne.indexOf('=~') >= 0) {
  71260. var pieces = serializedOne.split('=~');
  71261. return ContextKeyRegexExpr.create(pieces[0].trim(), this._deserializeRegexValue(pieces[1], strict));
  71262. }
  71263. if (/^\!\s*/.test(serializedOne)) {
  71264. return ContextKeyNotExpr.create(serializedOne.substr(1).trim());
  71265. }
  71266. return ContextKeyDefinedExpr.create(serializedOne);
  71267. };
  71268. ContextKeyExpr._deserializeValue = function (serializedValue, strict) {
  71269. serializedValue = serializedValue.trim();
  71270. if (serializedValue === 'true') {
  71271. return true;
  71272. }
  71273. if (serializedValue === 'false') {
  71274. return false;
  71275. }
  71276. var m = /^'([^']*)'$/.exec(serializedValue);
  71277. if (m) {
  71278. return m[1].trim();
  71279. }
  71280. return serializedValue;
  71281. };
  71282. ContextKeyExpr._deserializeRegexValue = function (serializedValue, strict) {
  71283. if (strings_1.isFalsyOrWhitespace(serializedValue)) {
  71284. if (strict) {
  71285. throw new Error('missing regexp-value for =~-expression');
  71286. }
  71287. else {
  71288. console.warn('missing regexp-value for =~-expression');
  71289. }
  71290. return null;
  71291. }
  71292. var start = serializedValue.indexOf('/');
  71293. var end = serializedValue.lastIndexOf('/');
  71294. if (start === end || start < 0 /* || to < 0 */) {
  71295. if (strict) {
  71296. throw new Error("bad regexp-value '" + serializedValue + "', missing /-enclosure");
  71297. }
  71298. else {
  71299. console.warn("bad regexp-value '" + serializedValue + "', missing /-enclosure");
  71300. }
  71301. return null;
  71302. }
  71303. var value = serializedValue.slice(start + 1, end);
  71304. var caseIgnoreFlag = serializedValue[end + 1] === 'i' ? 'i' : '';
  71305. try {
  71306. return new RegExp(value, caseIgnoreFlag);
  71307. }
  71308. catch (e) {
  71309. if (strict) {
  71310. throw new Error("bad regexp-value '" + serializedValue + "', parse error: " + e);
  71311. }
  71312. else {
  71313. console.warn("bad regexp-value '" + serializedValue + "', parse error: " + e);
  71314. }
  71315. return null;
  71316. }
  71317. };
  71318. return ContextKeyExpr;
  71319. }());
  71320. exports.ContextKeyExpr = ContextKeyExpr;
  71321. function cmp(a, b) {
  71322. var aType = a.getType();
  71323. var bType = b.getType();
  71324. if (aType !== bType) {
  71325. return aType - bType;
  71326. }
  71327. switch (aType) {
  71328. case 1 /* Defined */:
  71329. return a.cmp(b);
  71330. case 2 /* Not */:
  71331. return a.cmp(b);
  71332. case 3 /* Equals */:
  71333. return a.cmp(b);
  71334. case 4 /* NotEquals */:
  71335. return a.cmp(b);
  71336. case 6 /* Regex */:
  71337. return a.cmp(b);
  71338. case 7 /* NotRegex */:
  71339. return a.cmp(b);
  71340. case 5 /* And */:
  71341. return a.cmp(b);
  71342. default:
  71343. throw new Error('Unknown ContextKeyExpr!');
  71344. }
  71345. }
  71346. var ContextKeyDefinedExpr = /** @class */ (function () {
  71347. function ContextKeyDefinedExpr(key) {
  71348. this.key = key;
  71349. }
  71350. ContextKeyDefinedExpr.create = function (key) {
  71351. return new ContextKeyDefinedExpr(key);
  71352. };
  71353. ContextKeyDefinedExpr.prototype.getType = function () {
  71354. return 1 /* Defined */;
  71355. };
  71356. ContextKeyDefinedExpr.prototype.cmp = function (other) {
  71357. if (this.key < other.key) {
  71358. return -1;
  71359. }
  71360. if (this.key > other.key) {
  71361. return 1;
  71362. }
  71363. return 0;
  71364. };
  71365. ContextKeyDefinedExpr.prototype.equals = function (other) {
  71366. if (other instanceof ContextKeyDefinedExpr) {
  71367. return (this.key === other.key);
  71368. }
  71369. return false;
  71370. };
  71371. ContextKeyDefinedExpr.prototype.evaluate = function (context) {
  71372. return (!!context.getValue(this.key));
  71373. };
  71374. ContextKeyDefinedExpr.prototype.keys = function () {
  71375. return [this.key];
  71376. };
  71377. ContextKeyDefinedExpr.prototype.negate = function () {
  71378. return ContextKeyNotExpr.create(this.key);
  71379. };
  71380. return ContextKeyDefinedExpr;
  71381. }());
  71382. exports.ContextKeyDefinedExpr = ContextKeyDefinedExpr;
  71383. var ContextKeyEqualsExpr = /** @class */ (function () {
  71384. function ContextKeyEqualsExpr(key, value) {
  71385. this.key = key;
  71386. this.value = value;
  71387. }
  71388. ContextKeyEqualsExpr.create = function (key, value) {
  71389. if (typeof value === 'boolean') {
  71390. if (value) {
  71391. return ContextKeyDefinedExpr.create(key);
  71392. }
  71393. return ContextKeyNotExpr.create(key);
  71394. }
  71395. return new ContextKeyEqualsExpr(key, value);
  71396. };
  71397. ContextKeyEqualsExpr.prototype.getType = function () {
  71398. return 3 /* Equals */;
  71399. };
  71400. ContextKeyEqualsExpr.prototype.cmp = function (other) {
  71401. if (this.key < other.key) {
  71402. return -1;
  71403. }
  71404. if (this.key > other.key) {
  71405. return 1;
  71406. }
  71407. if (this.value < other.value) {
  71408. return -1;
  71409. }
  71410. if (this.value > other.value) {
  71411. return 1;
  71412. }
  71413. return 0;
  71414. };
  71415. ContextKeyEqualsExpr.prototype.equals = function (other) {
  71416. if (other instanceof ContextKeyEqualsExpr) {
  71417. return (this.key === other.key && this.value === other.value);
  71418. }
  71419. return false;
  71420. };
  71421. ContextKeyEqualsExpr.prototype.evaluate = function (context) {
  71422. // Intentional ==
  71423. // eslint-disable-next-line eqeqeq
  71424. return (context.getValue(this.key) == this.value);
  71425. };
  71426. ContextKeyEqualsExpr.prototype.keys = function () {
  71427. return [this.key];
  71428. };
  71429. ContextKeyEqualsExpr.prototype.negate = function () {
  71430. return ContextKeyNotEqualsExpr.create(this.key, this.value);
  71431. };
  71432. return ContextKeyEqualsExpr;
  71433. }());
  71434. exports.ContextKeyEqualsExpr = ContextKeyEqualsExpr;
  71435. var ContextKeyNotEqualsExpr = /** @class */ (function () {
  71436. function ContextKeyNotEqualsExpr(key, value) {
  71437. this.key = key;
  71438. this.value = value;
  71439. }
  71440. ContextKeyNotEqualsExpr.create = function (key, value) {
  71441. if (typeof value === 'boolean') {
  71442. if (value) {
  71443. return ContextKeyNotExpr.create(key);
  71444. }
  71445. return ContextKeyDefinedExpr.create(key);
  71446. }
  71447. return new ContextKeyNotEqualsExpr(key, value);
  71448. };
  71449. ContextKeyNotEqualsExpr.prototype.getType = function () {
  71450. return 4 /* NotEquals */;
  71451. };
  71452. ContextKeyNotEqualsExpr.prototype.cmp = function (other) {
  71453. if (this.key < other.key) {
  71454. return -1;
  71455. }
  71456. if (this.key > other.key) {
  71457. return 1;
  71458. }
  71459. if (this.value < other.value) {
  71460. return -1;
  71461. }
  71462. if (this.value > other.value) {
  71463. return 1;
  71464. }
  71465. return 0;
  71466. };
  71467. ContextKeyNotEqualsExpr.prototype.equals = function (other) {
  71468. if (other instanceof ContextKeyNotEqualsExpr) {
  71469. return (this.key === other.key && this.value === other.value);
  71470. }
  71471. return false;
  71472. };
  71473. ContextKeyNotEqualsExpr.prototype.evaluate = function (context) {
  71474. // Intentional !=
  71475. // eslint-disable-next-line eqeqeq
  71476. return (context.getValue(this.key) != this.value);
  71477. };
  71478. ContextKeyNotEqualsExpr.prototype.keys = function () {
  71479. return [this.key];
  71480. };
  71481. ContextKeyNotEqualsExpr.prototype.negate = function () {
  71482. return ContextKeyEqualsExpr.create(this.key, this.value);
  71483. };
  71484. return ContextKeyNotEqualsExpr;
  71485. }());
  71486. exports.ContextKeyNotEqualsExpr = ContextKeyNotEqualsExpr;
  71487. var ContextKeyNotExpr = /** @class */ (function () {
  71488. function ContextKeyNotExpr(key) {
  71489. this.key = key;
  71490. }
  71491. ContextKeyNotExpr.create = function (key) {
  71492. return new ContextKeyNotExpr(key);
  71493. };
  71494. ContextKeyNotExpr.prototype.getType = function () {
  71495. return 2 /* Not */;
  71496. };
  71497. ContextKeyNotExpr.prototype.cmp = function (other) {
  71498. if (this.key < other.key) {
  71499. return -1;
  71500. }
  71501. if (this.key > other.key) {
  71502. return 1;
  71503. }
  71504. return 0;
  71505. };
  71506. ContextKeyNotExpr.prototype.equals = function (other) {
  71507. if (other instanceof ContextKeyNotExpr) {
  71508. return (this.key === other.key);
  71509. }
  71510. return false;
  71511. };
  71512. ContextKeyNotExpr.prototype.evaluate = function (context) {
  71513. return (!context.getValue(this.key));
  71514. };
  71515. ContextKeyNotExpr.prototype.keys = function () {
  71516. return [this.key];
  71517. };
  71518. ContextKeyNotExpr.prototype.negate = function () {
  71519. return ContextKeyDefinedExpr.create(this.key);
  71520. };
  71521. return ContextKeyNotExpr;
  71522. }());
  71523. exports.ContextKeyNotExpr = ContextKeyNotExpr;
  71524. var ContextKeyRegexExpr = /** @class */ (function () {
  71525. function ContextKeyRegexExpr(key, regexp) {
  71526. this.key = key;
  71527. this.regexp = regexp;
  71528. //
  71529. }
  71530. ContextKeyRegexExpr.create = function (key, regexp) {
  71531. return new ContextKeyRegexExpr(key, regexp);
  71532. };
  71533. ContextKeyRegexExpr.prototype.getType = function () {
  71534. return 6 /* Regex */;
  71535. };
  71536. ContextKeyRegexExpr.prototype.cmp = function (other) {
  71537. if (this.key < other.key) {
  71538. return -1;
  71539. }
  71540. if (this.key > other.key) {
  71541. return 1;
  71542. }
  71543. var thisSource = this.regexp ? this.regexp.source : '';
  71544. var otherSource = other.regexp ? other.regexp.source : '';
  71545. if (thisSource < otherSource) {
  71546. return -1;
  71547. }
  71548. if (thisSource > otherSource) {
  71549. return 1;
  71550. }
  71551. return 0;
  71552. };
  71553. ContextKeyRegexExpr.prototype.equals = function (other) {
  71554. if (other instanceof ContextKeyRegexExpr) {
  71555. var thisSource = this.regexp ? this.regexp.source : '';
  71556. var otherSource = other.regexp ? other.regexp.source : '';
  71557. return (this.key === other.key && thisSource === otherSource);
  71558. }
  71559. return false;
  71560. };
  71561. ContextKeyRegexExpr.prototype.evaluate = function (context) {
  71562. var value = context.getValue(this.key);
  71563. return this.regexp ? this.regexp.test(value) : false;
  71564. };
  71565. ContextKeyRegexExpr.prototype.keys = function () {
  71566. return [this.key];
  71567. };
  71568. ContextKeyRegexExpr.prototype.negate = function () {
  71569. return ContextKeyNotRegexExpr.create(this);
  71570. };
  71571. return ContextKeyRegexExpr;
  71572. }());
  71573. exports.ContextKeyRegexExpr = ContextKeyRegexExpr;
  71574. var ContextKeyNotRegexExpr = /** @class */ (function () {
  71575. function ContextKeyNotRegexExpr(_actual) {
  71576. this._actual = _actual;
  71577. //
  71578. }
  71579. ContextKeyNotRegexExpr.create = function (actual) {
  71580. return new ContextKeyNotRegexExpr(actual);
  71581. };
  71582. ContextKeyNotRegexExpr.prototype.getType = function () {
  71583. return 7 /* NotRegex */;
  71584. };
  71585. ContextKeyNotRegexExpr.prototype.cmp = function (other) {
  71586. return this._actual.cmp(other._actual);
  71587. };
  71588. ContextKeyNotRegexExpr.prototype.equals = function (other) {
  71589. if (other instanceof ContextKeyNotRegexExpr) {
  71590. return this._actual.equals(other._actual);
  71591. }
  71592. return false;
  71593. };
  71594. ContextKeyNotRegexExpr.prototype.evaluate = function (context) {
  71595. return !this._actual.evaluate(context);
  71596. };
  71597. ContextKeyNotRegexExpr.prototype.keys = function () {
  71598. return this._actual.keys();
  71599. };
  71600. ContextKeyNotRegexExpr.prototype.negate = function () {
  71601. return this._actual;
  71602. };
  71603. return ContextKeyNotRegexExpr;
  71604. }());
  71605. exports.ContextKeyNotRegexExpr = ContextKeyNotRegexExpr;
  71606. var ContextKeyAndExpr = /** @class */ (function () {
  71607. function ContextKeyAndExpr(expr) {
  71608. this.expr = expr;
  71609. }
  71610. ContextKeyAndExpr.create = function (_expr) {
  71611. var expr = ContextKeyAndExpr._normalizeArr(_expr);
  71612. if (expr.length === 0) {
  71613. return undefined;
  71614. }
  71615. if (expr.length === 1) {
  71616. return expr[0];
  71617. }
  71618. return new ContextKeyAndExpr(expr);
  71619. };
  71620. ContextKeyAndExpr.prototype.getType = function () {
  71621. return 5 /* And */;
  71622. };
  71623. ContextKeyAndExpr.prototype.cmp = function (other) {
  71624. if (this.expr.length < other.expr.length) {
  71625. return -1;
  71626. }
  71627. if (this.expr.length > other.expr.length) {
  71628. return 1;
  71629. }
  71630. for (var i = 0, len = this.expr.length; i < len; i++) {
  71631. var r = cmp(this.expr[i], other.expr[i]);
  71632. if (r !== 0) {
  71633. return r;
  71634. }
  71635. }
  71636. return 0;
  71637. };
  71638. ContextKeyAndExpr.prototype.equals = function (other) {
  71639. if (other instanceof ContextKeyAndExpr) {
  71640. if (this.expr.length !== other.expr.length) {
  71641. return false;
  71642. }
  71643. for (var i = 0, len = this.expr.length; i < len; i++) {
  71644. if (!this.expr[i].equals(other.expr[i])) {
  71645. return false;
  71646. }
  71647. }
  71648. return true;
  71649. }
  71650. return false;
  71651. };
  71652. ContextKeyAndExpr.prototype.evaluate = function (context) {
  71653. for (var i = 0, len = this.expr.length; i < len; i++) {
  71654. if (!this.expr[i].evaluate(context)) {
  71655. return false;
  71656. }
  71657. }
  71658. return true;
  71659. };
  71660. ContextKeyAndExpr._normalizeArr = function (arr) {
  71661. var expr = [];
  71662. if (arr) {
  71663. for (var i = 0, len = arr.length; i < len; i++) {
  71664. var e = arr[i];
  71665. if (!e) {
  71666. continue;
  71667. }
  71668. if (e instanceof ContextKeyAndExpr) {
  71669. expr = expr.concat(e.expr);
  71670. continue;
  71671. }
  71672. if (e instanceof ContextKeyOrExpr) {
  71673. // Not allowed, because we don't have parens!
  71674. throw new Error("It is not allowed to have an or expression here due to lack of parens! For example \"a && (b||c)\" is not supported, use \"(a&&b) || (a&&c)\" instead.");
  71675. }
  71676. expr.push(e);
  71677. }
  71678. expr.sort(cmp);
  71679. }
  71680. return expr;
  71681. };
  71682. ContextKeyAndExpr.prototype.keys = function () {
  71683. var result = [];
  71684. for (var _i = 0, _a = this.expr; _i < _a.length; _i++) {
  71685. var expr = _a[_i];
  71686. result.push.apply(result, expr.keys());
  71687. }
  71688. return result;
  71689. };
  71690. ContextKeyAndExpr.prototype.negate = function () {
  71691. var result = [];
  71692. for (var _i = 0, _a = this.expr; _i < _a.length; _i++) {
  71693. var expr = _a[_i];
  71694. result.push(expr.negate());
  71695. }
  71696. return ContextKeyOrExpr.create(result);
  71697. };
  71698. return ContextKeyAndExpr;
  71699. }());
  71700. exports.ContextKeyAndExpr = ContextKeyAndExpr;
  71701. var ContextKeyOrExpr = /** @class */ (function () {
  71702. function ContextKeyOrExpr(expr) {
  71703. this.expr = expr;
  71704. }
  71705. ContextKeyOrExpr.create = function (_expr) {
  71706. var expr = ContextKeyOrExpr._normalizeArr(_expr);
  71707. if (expr.length === 0) {
  71708. return undefined;
  71709. }
  71710. if (expr.length === 1) {
  71711. return expr[0];
  71712. }
  71713. return new ContextKeyOrExpr(expr);
  71714. };
  71715. ContextKeyOrExpr.prototype.getType = function () {
  71716. return 8 /* Or */;
  71717. };
  71718. ContextKeyOrExpr.prototype.equals = function (other) {
  71719. if (other instanceof ContextKeyOrExpr) {
  71720. if (this.expr.length !== other.expr.length) {
  71721. return false;
  71722. }
  71723. for (var i = 0, len = this.expr.length; i < len; i++) {
  71724. if (!this.expr[i].equals(other.expr[i])) {
  71725. return false;
  71726. }
  71727. }
  71728. return true;
  71729. }
  71730. return false;
  71731. };
  71732. ContextKeyOrExpr.prototype.evaluate = function (context) {
  71733. for (var i = 0, len = this.expr.length; i < len; i++) {
  71734. if (this.expr[i].evaluate(context)) {
  71735. return true;
  71736. }
  71737. }
  71738. return false;
  71739. };
  71740. ContextKeyOrExpr._normalizeArr = function (arr) {
  71741. var expr = [];
  71742. if (arr) {
  71743. for (var i = 0, len = arr.length; i < len; i++) {
  71744. var e = arr[i];
  71745. if (!e) {
  71746. continue;
  71747. }
  71748. if (e instanceof ContextKeyOrExpr) {
  71749. expr = expr.concat(e.expr);
  71750. continue;
  71751. }
  71752. expr.push(e);
  71753. }
  71754. expr.sort(cmp);
  71755. }
  71756. return expr;
  71757. };
  71758. ContextKeyOrExpr.prototype.keys = function () {
  71759. var result = [];
  71760. for (var _i = 0, _a = this.expr; _i < _a.length; _i++) {
  71761. var expr = _a[_i];
  71762. result.push.apply(result, expr.keys());
  71763. }
  71764. return result;
  71765. };
  71766. ContextKeyOrExpr.prototype.negate = function () {
  71767. var result = [];
  71768. for (var _i = 0, _a = this.expr; _i < _a.length; _i++) {
  71769. var expr = _a[_i];
  71770. result.push(expr.negate());
  71771. }
  71772. var terminals = function (node) {
  71773. if (node instanceof ContextKeyOrExpr) {
  71774. return node.expr;
  71775. }
  71776. return [node];
  71777. };
  71778. // We don't support parens, so here we distribute the AND over the OR terminals
  71779. // We always take the first 2 AND pairs and distribute them
  71780. while (result.length > 1) {
  71781. var LEFT = result.shift();
  71782. var RIGHT = result.shift();
  71783. var all = [];
  71784. for (var _b = 0, _c = terminals(LEFT); _b < _c.length; _b++) {
  71785. var left = _c[_b];
  71786. for (var _d = 0, _e = terminals(RIGHT); _d < _e.length; _d++) {
  71787. var right = _e[_d];
  71788. all.push(ContextKeyExpr.and(left, right));
  71789. }
  71790. }
  71791. result.unshift(ContextKeyExpr.or.apply(ContextKeyExpr, all));
  71792. }
  71793. return result[0];
  71794. };
  71795. return ContextKeyOrExpr;
  71796. }());
  71797. exports.ContextKeyOrExpr = ContextKeyOrExpr;
  71798. var RawContextKey = /** @class */ (function (_super) {
  71799. __extends(RawContextKey, _super);
  71800. function RawContextKey(key, defaultValue) {
  71801. var _this = _super.call(this, key) || this;
  71802. _this._defaultValue = defaultValue;
  71803. return _this;
  71804. }
  71805. RawContextKey.prototype.bindTo = function (target) {
  71806. return target.createKey(this.key, this._defaultValue);
  71807. };
  71808. RawContextKey.prototype.getValue = function (target) {
  71809. return target.getContextKeyValue(this.key);
  71810. };
  71811. RawContextKey.prototype.toNegated = function () {
  71812. return ContextKeyExpr.not(this.key);
  71813. };
  71814. return RawContextKey;
  71815. }(ContextKeyDefinedExpr));
  71816. exports.RawContextKey = RawContextKey;
  71817. exports.IContextKeyService = instantiation_1.createDecorator('contextKeyService');
  71818. exports.SET_CONTEXT_COMMAND_ID = 'setContext';
  71819. });
  71820. /*---------------------------------------------------------------------------------------------
  71821. * Copyright (c) Microsoft Corporation. All rights reserved.
  71822. * Licensed under the MIT License. See License.txt in the project root for license information.
  71823. *--------------------------------------------------------------------------------------------*/
  71824. define(__m[23/*vs/editor/common/editorContextKeys*/], __M([0/*require*/,1/*exports*/,18/*vs/platform/contextkey/common/contextkey*/]), function (require, exports, contextkey_1) {
  71825. "use strict";
  71826. Object.defineProperty(exports, "__esModule", { value: true });
  71827. var EditorContextKeys;
  71828. (function (EditorContextKeys) {
  71829. EditorContextKeys.editorSimpleInput = new contextkey_1.RawContextKey('editorSimpleInput', false);
  71830. /**
  71831. * A context key that is set when the editor's text has focus (cursor is blinking).
  71832. */
  71833. EditorContextKeys.editorTextFocus = new contextkey_1.RawContextKey('editorTextFocus', false);
  71834. /**
  71835. * A context key that is set when the editor's text or an editor's widget has focus.
  71836. */
  71837. EditorContextKeys.focus = new contextkey_1.RawContextKey('editorFocus', false);
  71838. /**
  71839. * A context key that is set when any editor input has focus (regular editor, repl input...).
  71840. */
  71841. EditorContextKeys.textInputFocus = new contextkey_1.RawContextKey('textInputFocus', false);
  71842. EditorContextKeys.readOnly = new contextkey_1.RawContextKey('editorReadonly', false);
  71843. EditorContextKeys.writable = EditorContextKeys.readOnly.toNegated();
  71844. EditorContextKeys.hasNonEmptySelection = new contextkey_1.RawContextKey('editorHasSelection', false);
  71845. EditorContextKeys.hasOnlyEmptySelection = EditorContextKeys.hasNonEmptySelection.toNegated();
  71846. EditorContextKeys.hasMultipleSelections = new contextkey_1.RawContextKey('editorHasMultipleSelections', false);
  71847. EditorContextKeys.hasSingleSelection = EditorContextKeys.hasMultipleSelections.toNegated();
  71848. EditorContextKeys.tabMovesFocus = new contextkey_1.RawContextKey('editorTabMovesFocus', false);
  71849. EditorContextKeys.tabDoesNotMoveFocus = EditorContextKeys.tabMovesFocus.toNegated();
  71850. EditorContextKeys.isInEmbeddedEditor = new contextkey_1.RawContextKey('isInEmbeddedEditor', false);
  71851. EditorContextKeys.canUndo = new contextkey_1.RawContextKey('canUndo', false);
  71852. EditorContextKeys.canRedo = new contextkey_1.RawContextKey('canRedo', false);
  71853. // -- mode context keys
  71854. EditorContextKeys.languageId = new contextkey_1.RawContextKey('editorLangId', '');
  71855. EditorContextKeys.hasCompletionItemProvider = new contextkey_1.RawContextKey('editorHasCompletionItemProvider', false);
  71856. EditorContextKeys.hasCodeActionsProvider = new contextkey_1.RawContextKey('editorHasCodeActionsProvider', false);
  71857. EditorContextKeys.hasCodeLensProvider = new contextkey_1.RawContextKey('editorHasCodeLensProvider', false);
  71858. EditorContextKeys.hasDefinitionProvider = new contextkey_1.RawContextKey('editorHasDefinitionProvider', false);
  71859. EditorContextKeys.hasDeclarationProvider = new contextkey_1.RawContextKey('editorHasDeclarationProvider', false);
  71860. EditorContextKeys.hasImplementationProvider = new contextkey_1.RawContextKey('editorHasImplementationProvider', false);
  71861. EditorContextKeys.hasTypeDefinitionProvider = new contextkey_1.RawContextKey('editorHasTypeDefinitionProvider', false);
  71862. EditorContextKeys.hasHoverProvider = new contextkey_1.RawContextKey('editorHasHoverProvider', false);
  71863. EditorContextKeys.hasDocumentHighlightProvider = new contextkey_1.RawContextKey('editorHasDocumentHighlightProvider', false);
  71864. EditorContextKeys.hasDocumentSymbolProvider = new contextkey_1.RawContextKey('editorHasDocumentSymbolProvider', false);
  71865. EditorContextKeys.hasReferenceProvider = new contextkey_1.RawContextKey('editorHasReferenceProvider', false);
  71866. EditorContextKeys.hasRenameProvider = new contextkey_1.RawContextKey('editorHasRenameProvider', false);
  71867. EditorContextKeys.hasSignatureHelpProvider = new contextkey_1.RawContextKey('editorHasSignatureHelpProvider', false);
  71868. // -- mode context keys: formatting
  71869. EditorContextKeys.hasDocumentFormattingProvider = new contextkey_1.RawContextKey('editorHasDocumentFormattingProvider', false);
  71870. EditorContextKeys.hasDocumentSelectionFormattingProvider = new contextkey_1.RawContextKey('editorHasDocumentSelectionFormattingProvider', false);
  71871. EditorContextKeys.hasMultipleDocumentFormattingProvider = new contextkey_1.RawContextKey('editorHasMultipleDocumentFormattingProvider', false);
  71872. EditorContextKeys.hasMultipleDocumentSelectionFormattingProvider = new contextkey_1.RawContextKey('editorHasMultipleDocumentSelectionFormattingProvider', false);
  71873. })(EditorContextKeys = exports.EditorContextKeys || (exports.EditorContextKeys = {}));
  71874. });
  71875. /*---------------------------------------------------------------------------------------------
  71876. * Copyright (c) Microsoft Corporation. All rights reserved.
  71877. * Licensed under the MIT License. See License.txt in the project root for license information.
  71878. *--------------------------------------------------------------------------------------------*/
  71879. var __param = (this && this.__param) || function (paramIndex, decorator) {
  71880. return function (target, key) { decorator(target, key, paramIndex); }
  71881. };
  71882. define(__m[497/*vs/editor/contrib/suggest/suggestAlternatives*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,18/*vs/platform/contextkey/common/contextkey*/]), function (require, exports, lifecycle_1, contextkey_1) {
  71883. "use strict";
  71884. Object.defineProperty(exports, "__esModule", { value: true });
  71885. var SuggestAlternatives = /** @class */ (function () {
  71886. function SuggestAlternatives(_editor, contextKeyService) {
  71887. this._editor = _editor;
  71888. this._index = 0;
  71889. this._ckOtherSuggestions = SuggestAlternatives.OtherSuggestions.bindTo(contextKeyService);
  71890. }
  71891. SuggestAlternatives.prototype.dispose = function () {
  71892. this.reset();
  71893. };
  71894. SuggestAlternatives.prototype.reset = function () {
  71895. this._ckOtherSuggestions.reset();
  71896. lifecycle_1.dispose(this._listener);
  71897. this._model = undefined;
  71898. this._acceptNext = undefined;
  71899. this._ignore = false;
  71900. };
  71901. SuggestAlternatives.prototype.set = function (_a, acceptNext) {
  71902. var _this = this;
  71903. var model = _a.model, index = _a.index;
  71904. // no suggestions -> nothing to do
  71905. if (model.items.length === 0) {
  71906. this.reset();
  71907. return;
  71908. }
  71909. // no alternative suggestions -> nothing to do
  71910. var nextIndex = SuggestAlternatives._moveIndex(true, model, index);
  71911. if (nextIndex === index) {
  71912. this.reset();
  71913. return;
  71914. }
  71915. this._acceptNext = acceptNext;
  71916. this._model = model;
  71917. this._index = index;
  71918. this._listener = this._editor.onDidChangeCursorPosition(function () {
  71919. if (!_this._ignore) {
  71920. _this.reset();
  71921. }
  71922. });
  71923. this._ckOtherSuggestions.set(true);
  71924. };
  71925. SuggestAlternatives._moveIndex = function (fwd, model, index) {
  71926. var newIndex = index;
  71927. while (true) {
  71928. newIndex = (newIndex + model.items.length + (fwd ? +1 : -1)) % model.items.length;
  71929. if (newIndex === index) {
  71930. break;
  71931. }
  71932. if (!model.items[newIndex].completion.additionalTextEdits) {
  71933. break;
  71934. }
  71935. }
  71936. return newIndex;
  71937. };
  71938. SuggestAlternatives.prototype.next = function () {
  71939. this._move(true);
  71940. };
  71941. SuggestAlternatives.prototype.prev = function () {
  71942. this._move(false);
  71943. };
  71944. SuggestAlternatives.prototype._move = function (fwd) {
  71945. if (!this._model) {
  71946. // nothing to reason about
  71947. return;
  71948. }
  71949. try {
  71950. this._ignore = true;
  71951. this._index = SuggestAlternatives._moveIndex(fwd, this._model, this._index);
  71952. this._acceptNext({ index: this._index, item: this._model.items[this._index], model: this._model });
  71953. }
  71954. finally {
  71955. this._ignore = false;
  71956. }
  71957. };
  71958. SuggestAlternatives.OtherSuggestions = new contextkey_1.RawContextKey('hasOtherSuggestions', false);
  71959. SuggestAlternatives = __decorate([
  71960. __param(1, contextkey_1.IContextKeyService)
  71961. ], SuggestAlternatives);
  71962. return SuggestAlternatives;
  71963. }());
  71964. exports.SuggestAlternatives = SuggestAlternatives;
  71965. });
  71966. /*---------------------------------------------------------------------------------------------
  71967. * Copyright (c) Microsoft Corporation. All rights reserved.
  71968. * Licensed under the MIT License. See License.txt in the project root for license information.
  71969. *--------------------------------------------------------------------------------------------*/
  71970. define(__m[498/*vs/editor/contrib/suggest/wordContextKey*/], __M([0/*require*/,1/*exports*/,18/*vs/platform/contextkey/common/contextkey*/,2/*vs/base/common/lifecycle*/]), function (require, exports, contextkey_1, lifecycle_1) {
  71971. "use strict";
  71972. Object.defineProperty(exports, "__esModule", { value: true });
  71973. var WordContextKey = /** @class */ (function (_super) {
  71974. __extends(WordContextKey, _super);
  71975. function WordContextKey(_editor, contextKeyService) {
  71976. var _this = _super.call(this) || this;
  71977. _this._editor = _editor;
  71978. _this._enabled = false;
  71979. _this._ckAtEnd = WordContextKey.AtEnd.bindTo(contextKeyService);
  71980. _this._register(_this._editor.onDidChangeConfiguration(function (e) { return e.hasChanged(94 /* tabCompletion */) && _this._update(); }));
  71981. _this._update();
  71982. return _this;
  71983. }
  71984. WordContextKey.prototype.dispose = function () {
  71985. _super.prototype.dispose.call(this);
  71986. lifecycle_1.dispose(this._selectionListener);
  71987. this._ckAtEnd.reset();
  71988. };
  71989. WordContextKey.prototype._update = function () {
  71990. var _this = this;
  71991. // only update this when tab completions are enabled
  71992. var enabled = this._editor.getOption(94 /* tabCompletion */) === 'on';
  71993. if (this._enabled === enabled) {
  71994. return;
  71995. }
  71996. this._enabled = enabled;
  71997. if (this._enabled) {
  71998. var checkForWordEnd = function () {
  71999. if (!_this._editor.hasModel()) {
  72000. _this._ckAtEnd.set(false);
  72001. return;
  72002. }
  72003. var model = _this._editor.getModel();
  72004. var selection = _this._editor.getSelection();
  72005. var word = model.getWordAtPosition(selection.getStartPosition());
  72006. if (!word) {
  72007. _this._ckAtEnd.set(false);
  72008. return;
  72009. }
  72010. _this._ckAtEnd.set(word.endColumn === selection.getStartPosition().column);
  72011. };
  72012. this._selectionListener = this._editor.onDidChangeCursorSelection(checkForWordEnd);
  72013. checkForWordEnd();
  72014. }
  72015. else if (this._selectionListener) {
  72016. this._ckAtEnd.reset();
  72017. this._selectionListener.dispose();
  72018. this._selectionListener = undefined;
  72019. }
  72020. };
  72021. WordContextKey.AtEnd = new contextkey_1.RawContextKey('atEndOfWord', false);
  72022. WordContextKey = __decorate([
  72023. __param(1, contextkey_1.IContextKeyService)
  72024. ], WordContextKey);
  72025. return WordContextKey;
  72026. }(lifecycle_1.Disposable));
  72027. exports.WordContextKey = WordContextKey;
  72028. });
  72029. /*---------------------------------------------------------------------------------------------
  72030. * Copyright (c) Microsoft Corporation. All rights reserved.
  72031. * Licensed under the MIT License. See License.txt in the project root for license information.
  72032. *--------------------------------------------------------------------------------------------*/
  72033. define(__m[64/*vs/platform/accessibility/common/accessibility*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/,18/*vs/platform/contextkey/common/contextkey*/]), function (require, exports, instantiation_1, contextkey_1) {
  72034. "use strict";
  72035. Object.defineProperty(exports, "__esModule", { value: true });
  72036. exports.IAccessibilityService = instantiation_1.createDecorator('accessibilityService');
  72037. exports.CONTEXT_ACCESSIBILITY_MODE_ENABLED = new contextkey_1.RawContextKey('accessibilityModeEnabled', false);
  72038. });
  72039. /*---------------------------------------------------------------------------------------------
  72040. * Copyright (c) Microsoft Corporation. All rights reserved.
  72041. * Licensed under the MIT License. See License.txt in the project root for license information.
  72042. *--------------------------------------------------------------------------------------------*/
  72043. var __spreadArrays = (this && this.__spreadArrays) || function () {
  72044. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  72045. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  72046. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  72047. r[k] = a[j];
  72048. return r;
  72049. };
  72050. define(__m[65/*vs/platform/actions/common/actions*/], __M([0/*require*/,1/*exports*/,55/*vs/base/common/actions*/,11/*vs/platform/instantiation/common/instantiation*/,18/*vs/platform/contextkey/common/contextkey*/,29/*vs/platform/commands/common/commands*/,4/*vs/base/common/event*/]), function (require, exports, actions_1, instantiation_1, contextkey_1, commands_1, event_1) {
  72051. "use strict";
  72052. Object.defineProperty(exports, "__esModule", { value: true });
  72053. function isIMenuItem(item) {
  72054. return item.command !== undefined;
  72055. }
  72056. exports.isIMenuItem = isIMenuItem;
  72057. exports.IMenuService = instantiation_1.createDecorator('menuService');
  72058. exports.MenuRegistry = new /** @class */ (function () {
  72059. function class_1() {
  72060. this._commands = new Map();
  72061. this._menuItems = new Map();
  72062. this._onDidChangeMenu = new event_1.Emitter();
  72063. this.onDidChangeMenu = this._onDidChangeMenu.event;
  72064. }
  72065. class_1.prototype.addCommand = function (command) {
  72066. var _this = this;
  72067. this._commands.set(command.id, command);
  72068. this._onDidChangeMenu.fire(0 /* CommandPalette */);
  72069. return {
  72070. dispose: function () {
  72071. if (_this._commands.delete(command.id)) {
  72072. _this._onDidChangeMenu.fire(0 /* CommandPalette */);
  72073. }
  72074. }
  72075. };
  72076. };
  72077. class_1.prototype.getCommand = function (id) {
  72078. return this._commands.get(id);
  72079. };
  72080. class_1.prototype.getCommands = function () {
  72081. var map = new Map();
  72082. this._commands.forEach(function (value, key) { return map.set(key, value); });
  72083. return map;
  72084. };
  72085. class_1.prototype.appendMenuItem = function (id, item) {
  72086. var _this = this;
  72087. var array = this._menuItems.get(id);
  72088. if (!array) {
  72089. array = [item];
  72090. this._menuItems.set(id, array);
  72091. }
  72092. else {
  72093. array.push(item);
  72094. }
  72095. this._onDidChangeMenu.fire(id);
  72096. return {
  72097. dispose: function () {
  72098. var idx = array.indexOf(item);
  72099. if (idx >= 0) {
  72100. array.splice(idx, 1);
  72101. _this._onDidChangeMenu.fire(id);
  72102. }
  72103. }
  72104. };
  72105. };
  72106. class_1.prototype.getMenuItems = function (id) {
  72107. var result = (this._menuItems.get(id) || []).slice(0);
  72108. if (id === 0 /* CommandPalette */) {
  72109. // CommandPalette is special because it shows
  72110. // all commands by default
  72111. this._appendImplicitItems(result);
  72112. }
  72113. return result;
  72114. };
  72115. class_1.prototype._appendImplicitItems = function (result) {
  72116. var set = new Set();
  72117. var temp = result.filter(function (item) { return isIMenuItem(item); });
  72118. for (var _i = 0, temp_1 = temp; _i < temp_1.length; _i++) {
  72119. var _a = temp_1[_i], command = _a.command, alt = _a.alt;
  72120. set.add(command.id);
  72121. if (alt) {
  72122. set.add(alt.id);
  72123. }
  72124. }
  72125. this._commands.forEach(function (command, id) {
  72126. if (!set.has(id)) {
  72127. result.push({ command: command });
  72128. }
  72129. });
  72130. };
  72131. return class_1;
  72132. }());
  72133. var ExecuteCommandAction = /** @class */ (function (_super) {
  72134. __extends(ExecuteCommandAction, _super);
  72135. function ExecuteCommandAction(id, label, _commandService) {
  72136. var _this = _super.call(this, id, label) || this;
  72137. _this._commandService = _commandService;
  72138. return _this;
  72139. }
  72140. ExecuteCommandAction.prototype.run = function () {
  72141. var _a;
  72142. var args = [];
  72143. for (var _i = 0; _i < arguments.length; _i++) {
  72144. args[_i] = arguments[_i];
  72145. }
  72146. return (_a = this._commandService).executeCommand.apply(_a, __spreadArrays([this.id], args));
  72147. };
  72148. ExecuteCommandAction = __decorate([
  72149. __param(2, commands_1.ICommandService)
  72150. ], ExecuteCommandAction);
  72151. return ExecuteCommandAction;
  72152. }(actions_1.Action));
  72153. exports.ExecuteCommandAction = ExecuteCommandAction;
  72154. var SubmenuItemAction = /** @class */ (function (_super) {
  72155. __extends(SubmenuItemAction, _super);
  72156. function SubmenuItemAction(item) {
  72157. var _this = this;
  72158. typeof item.title === 'string' ? _this = _super.call(this, '', item.title, 'submenu') || this : _this = _super.call(this, '', item.title.value, 'submenu') || this;
  72159. _this.item = item;
  72160. return _this;
  72161. }
  72162. return SubmenuItemAction;
  72163. }(actions_1.Action));
  72164. exports.SubmenuItemAction = SubmenuItemAction;
  72165. var MenuItemAction = /** @class */ (function (_super) {
  72166. __extends(MenuItemAction, _super);
  72167. function MenuItemAction(item, alt, options, contextKeyService, commandService) {
  72168. var _this = this;
  72169. typeof item.title === 'string' ? _this = _super.call(this, item.id, item.title, commandService) || this : _this = _super.call(this, item.id, item.title.value, commandService) || this;
  72170. _this._cssClass = undefined;
  72171. _this._enabled = !item.precondition || contextKeyService.contextMatchesRules(item.precondition);
  72172. _this._checked = Boolean(item.toggled && contextKeyService.contextMatchesRules(item.toggled));
  72173. _this._options = options || {};
  72174. _this.item = item;
  72175. _this.alt = alt ? new MenuItemAction(alt, undefined, _this._options, contextKeyService, commandService) : undefined;
  72176. return _this;
  72177. }
  72178. MenuItemAction.prototype.dispose = function () {
  72179. if (this.alt) {
  72180. this.alt.dispose();
  72181. }
  72182. _super.prototype.dispose.call(this);
  72183. };
  72184. MenuItemAction.prototype.run = function () {
  72185. var args = [];
  72186. for (var _i = 0; _i < arguments.length; _i++) {
  72187. args[_i] = arguments[_i];
  72188. }
  72189. var runArgs = [];
  72190. if (this._options.arg) {
  72191. runArgs = __spreadArrays(runArgs, [this._options.arg]);
  72192. }
  72193. if (this._options.shouldForwardArgs) {
  72194. runArgs = __spreadArrays(runArgs, args);
  72195. }
  72196. return _super.prototype.run.apply(this, runArgs);
  72197. };
  72198. MenuItemAction = __decorate([
  72199. __param(3, contextkey_1.IContextKeyService),
  72200. __param(4, commands_1.ICommandService)
  72201. ], MenuItemAction);
  72202. return MenuItemAction;
  72203. }(ExecuteCommandAction));
  72204. exports.MenuItemAction = MenuItemAction;
  72205. });
  72206. //#endregion
  72207. /*---------------------------------------------------------------------------------------------
  72208. * Copyright (c) Microsoft Corporation. All rights reserved.
  72209. * Licensed under the MIT License. See License.txt in the project root for license information.
  72210. *--------------------------------------------------------------------------------------------*/
  72211. define(__m[499/*vs/platform/actions/common/menuService*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,65/*vs/platform/actions/common/actions*/,29/*vs/platform/commands/common/commands*/,18/*vs/platform/contextkey/common/contextkey*/]), function (require, exports, event_1, lifecycle_1, actions_1, commands_1, contextkey_1) {
  72212. "use strict";
  72213. Object.defineProperty(exports, "__esModule", { value: true });
  72214. var MenuService = /** @class */ (function () {
  72215. function MenuService(_commandService) {
  72216. this._commandService = _commandService;
  72217. //
  72218. }
  72219. MenuService.prototype.createMenu = function (id, contextKeyService) {
  72220. return new Menu(id, this._commandService, contextKeyService);
  72221. };
  72222. MenuService = __decorate([
  72223. __param(0, commands_1.ICommandService)
  72224. ], MenuService);
  72225. return MenuService;
  72226. }());
  72227. exports.MenuService = MenuService;
  72228. var Menu = /** @class */ (function () {
  72229. function Menu(_id, _commandService, _contextKeyService) {
  72230. var _this = this;
  72231. this._id = _id;
  72232. this._commandService = _commandService;
  72233. this._contextKeyService = _contextKeyService;
  72234. this._onDidChange = new event_1.Emitter();
  72235. this._dispoables = new lifecycle_1.DisposableStore();
  72236. this._menuGroups = [];
  72237. this._contextKeys = new Set();
  72238. this._build();
  72239. // rebuild this menu whenever the menu registry reports an
  72240. // event for this MenuId
  72241. this._dispoables.add(event_1.Event.debounce(event_1.Event.filter(actions_1.MenuRegistry.onDidChangeMenu, function (menuId) { return menuId === _this._id; }), function () { }, 50)(this._build, this));
  72242. // when context keys change we need to check if the menu also
  72243. // has changed
  72244. this._dispoables.add(event_1.Event.debounce(this._contextKeyService.onDidChangeContext, function (last, event) { return last || event.affectsSome(_this._contextKeys); }, 50)(function (e) { return e && _this._onDidChange.fire(undefined); }, this));
  72245. }
  72246. Menu.prototype.dispose = function () {
  72247. this._dispoables.dispose();
  72248. this._onDidChange.dispose();
  72249. };
  72250. Menu.prototype._build = function () {
  72251. // reset
  72252. this._menuGroups.length = 0;
  72253. this._contextKeys.clear();
  72254. var menuItems = actions_1.MenuRegistry.getMenuItems(this._id);
  72255. var group;
  72256. menuItems.sort(Menu._compareMenuItems);
  72257. for (var _i = 0, menuItems_1 = menuItems; _i < menuItems_1.length; _i++) {
  72258. var item = menuItems_1[_i];
  72259. // group by groupId
  72260. var groupName = item.group || '';
  72261. if (!group || group[0] !== groupName) {
  72262. group = [groupName, []];
  72263. this._menuGroups.push(group);
  72264. }
  72265. group[1].push(item);
  72266. // keep keys for eventing
  72267. Menu._fillInKbExprKeys(item.when, this._contextKeys);
  72268. // keep precondition keys for event if applicable
  72269. if (actions_1.isIMenuItem(item) && item.command.precondition) {
  72270. Menu._fillInKbExprKeys(item.command.precondition, this._contextKeys);
  72271. }
  72272. // keep toggled keys for event if applicable
  72273. if (actions_1.isIMenuItem(item) && item.command.toggled) {
  72274. Menu._fillInKbExprKeys(item.command.toggled, this._contextKeys);
  72275. }
  72276. }
  72277. this._onDidChange.fire(this);
  72278. };
  72279. Menu.prototype.getActions = function (options) {
  72280. var result = [];
  72281. for (var _i = 0, _a = this._menuGroups; _i < _a.length; _i++) {
  72282. var group = _a[_i];
  72283. var id = group[0], items = group[1];
  72284. var activeActions = [];
  72285. for (var _b = 0, items_1 = items; _b < items_1.length; _b++) {
  72286. var item = items_1[_b];
  72287. if (this._contextKeyService.contextMatchesRules(item.when)) {
  72288. var action = actions_1.isIMenuItem(item)
  72289. ? new actions_1.MenuItemAction(item.command, item.alt, options, this._contextKeyService, this._commandService)
  72290. : new actions_1.SubmenuItemAction(item);
  72291. activeActions.push(action);
  72292. }
  72293. }
  72294. if (activeActions.length > 0) {
  72295. result.push([id, activeActions]);
  72296. }
  72297. }
  72298. return result;
  72299. };
  72300. Menu._fillInKbExprKeys = function (exp, set) {
  72301. if (exp) {
  72302. for (var _i = 0, _a = exp.keys(); _i < _a.length; _i++) {
  72303. var key = _a[_i];
  72304. set.add(key);
  72305. }
  72306. }
  72307. };
  72308. Menu._compareMenuItems = function (a, b) {
  72309. var aGroup = a.group;
  72310. var bGroup = b.group;
  72311. if (aGroup !== bGroup) {
  72312. // Falsy groups come last
  72313. if (!aGroup) {
  72314. return 1;
  72315. }
  72316. else if (!bGroup) {
  72317. return -1;
  72318. }
  72319. // 'navigation' group comes first
  72320. if (aGroup === 'navigation') {
  72321. return -1;
  72322. }
  72323. else if (bGroup === 'navigation') {
  72324. return 1;
  72325. }
  72326. // lexical sort for groups
  72327. var value = aGroup.localeCompare(bGroup);
  72328. if (value !== 0) {
  72329. return value;
  72330. }
  72331. }
  72332. // sort on priority - default is 0
  72333. var aPrio = a.order || 0;
  72334. var bPrio = b.order || 0;
  72335. if (aPrio < bPrio) {
  72336. return -1;
  72337. }
  72338. else if (aPrio > bPrio) {
  72339. return 1;
  72340. }
  72341. // sort on titles
  72342. return Menu._compareTitles(actions_1.isIMenuItem(a) ? a.command.title : a.title, actions_1.isIMenuItem(b) ? b.command.title : b.title);
  72343. };
  72344. Menu._compareTitles = function (a, b) {
  72345. var aStr = typeof a === 'string' ? a : a.value;
  72346. var bStr = typeof b === 'string' ? b : b.value;
  72347. return aStr.localeCompare(bStr);
  72348. };
  72349. Menu = __decorate([
  72350. __param(1, commands_1.ICommandService),
  72351. __param(2, contextkey_1.IContextKeyService)
  72352. ], Menu);
  72353. return Menu;
  72354. }());
  72355. });
  72356. /*---------------------------------------------------------------------------------------------
  72357. * Copyright (c) Microsoft Corporation. All rights reserved.
  72358. * Licensed under the MIT License. See License.txt in the project root for license information.
  72359. *--------------------------------------------------------------------------------------------*/
  72360. define(__m[66/*vs/platform/contextview/browser/contextView*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  72361. "use strict";
  72362. Object.defineProperty(exports, "__esModule", { value: true });
  72363. exports.IContextViewService = instantiation_1.createDecorator('contextViewService');
  72364. exports.IContextMenuService = instantiation_1.createDecorator('contextMenuService');
  72365. });
  72366. define(__m[500/*vs/platform/dialogs/common/dialogs*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  72367. "use strict";
  72368. Object.defineProperty(exports, "__esModule", { value: true });
  72369. exports.IDialogService = instantiation_1.createDecorator('dialogService');
  72370. });
  72371. /*---------------------------------------------------------------------------------------------
  72372. * Copyright (c) Microsoft Corporation. All rights reserved.
  72373. * Licensed under the MIT License. See License.txt in the project root for license information.
  72374. *--------------------------------------------------------------------------------------------*/
  72375. define(__m[115/*vs/platform/instantiation/common/serviceCollection*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  72376. "use strict";
  72377. Object.defineProperty(exports, "__esModule", { value: true });
  72378. var ServiceCollection = /** @class */ (function () {
  72379. function ServiceCollection() {
  72380. var entries = [];
  72381. for (var _i = 0; _i < arguments.length; _i++) {
  72382. entries[_i] = arguments[_i];
  72383. }
  72384. this._entries = new Map();
  72385. for (var _a = 0, entries_1 = entries; _a < entries_1.length; _a++) {
  72386. var _b = entries_1[_a], id = _b[0], service = _b[1];
  72387. this.set(id, service);
  72388. }
  72389. }
  72390. ServiceCollection.prototype.set = function (id, instanceOrDescriptor) {
  72391. var result = this._entries.get(id);
  72392. this._entries.set(id, instanceOrDescriptor);
  72393. return result;
  72394. };
  72395. ServiceCollection.prototype.has = function (id) {
  72396. return this._entries.has(id);
  72397. };
  72398. ServiceCollection.prototype.get = function (id) {
  72399. return this._entries.get(id);
  72400. };
  72401. return ServiceCollection;
  72402. }());
  72403. exports.ServiceCollection = ServiceCollection;
  72404. });
  72405. /*---------------------------------------------------------------------------------------------
  72406. * Copyright (c) Microsoft Corporation. All rights reserved.
  72407. * Licensed under the MIT License. See License.txt in the project root for license information.
  72408. *--------------------------------------------------------------------------------------------*/
  72409. var __spreadArrays = (this && this.__spreadArrays) || function () {
  72410. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  72411. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  72412. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  72413. r[k] = a[j];
  72414. return r;
  72415. };
  72416. define(__m[501/*vs/platform/instantiation/common/instantiationService*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,480/*vs/platform/instantiation/common/graph*/,209/*vs/platform/instantiation/common/descriptors*/,11/*vs/platform/instantiation/common/instantiation*/,115/*vs/platform/instantiation/common/serviceCollection*/,15/*vs/base/common/async*/]), function (require, exports, errors_1, graph_1, descriptors_1, instantiation_1, serviceCollection_1, async_1) {
  72417. "use strict";
  72418. Object.defineProperty(exports, "__esModule", { value: true });
  72419. // TRACING
  72420. var _enableTracing = false;
  72421. var _canUseProxy = typeof Proxy === 'function';
  72422. var CyclicDependencyError = /** @class */ (function (_super) {
  72423. __extends(CyclicDependencyError, _super);
  72424. function CyclicDependencyError(graph) {
  72425. var _this = _super.call(this, 'cyclic dependency between services') || this;
  72426. _this.message = graph.toString();
  72427. return _this;
  72428. }
  72429. return CyclicDependencyError;
  72430. }(Error));
  72431. var InstantiationService = /** @class */ (function () {
  72432. function InstantiationService(services, strict, parent) {
  72433. if (services === void 0) { services = new serviceCollection_1.ServiceCollection(); }
  72434. if (strict === void 0) { strict = false; }
  72435. this._services = services;
  72436. this._strict = strict;
  72437. this._parent = parent;
  72438. this._services.set(instantiation_1.IInstantiationService, this);
  72439. }
  72440. InstantiationService.prototype.createChild = function (services) {
  72441. return new InstantiationService(services, this._strict, this);
  72442. };
  72443. InstantiationService.prototype.invokeFunction = function (fn) {
  72444. var _this = this;
  72445. var args = [];
  72446. for (var _i = 1; _i < arguments.length; _i++) {
  72447. args[_i - 1] = arguments[_i];
  72448. }
  72449. var _trace = Trace.traceInvocation(fn);
  72450. var _done = false;
  72451. try {
  72452. var accessor = {
  72453. get: function (id, isOptional) {
  72454. if (_done) {
  72455. throw errors_1.illegalState('service accessor is only valid during the invocation of its target method');
  72456. }
  72457. var result = _this._getOrCreateServiceInstance(id, _trace);
  72458. if (!result && isOptional !== instantiation_1.optional) {
  72459. throw new Error("[invokeFunction] unknown service '" + id + "'");
  72460. }
  72461. return result;
  72462. }
  72463. };
  72464. return fn.apply(undefined, __spreadArrays([accessor], args));
  72465. }
  72466. finally {
  72467. _done = true;
  72468. _trace.stop();
  72469. }
  72470. };
  72471. InstantiationService.prototype.createInstance = function (ctorOrDescriptor) {
  72472. var rest = [];
  72473. for (var _i = 1; _i < arguments.length; _i++) {
  72474. rest[_i - 1] = arguments[_i];
  72475. }
  72476. var _trace;
  72477. var result;
  72478. if (ctorOrDescriptor instanceof descriptors_1.SyncDescriptor) {
  72479. _trace = Trace.traceCreation(ctorOrDescriptor.ctor);
  72480. result = this._createInstance(ctorOrDescriptor.ctor, ctorOrDescriptor.staticArguments.concat(rest), _trace);
  72481. }
  72482. else {
  72483. _trace = Trace.traceCreation(ctorOrDescriptor);
  72484. result = this._createInstance(ctorOrDescriptor, rest, _trace);
  72485. }
  72486. _trace.stop();
  72487. return result;
  72488. };
  72489. InstantiationService.prototype._createInstance = function (ctor, args, _trace) {
  72490. if (args === void 0) { args = []; }
  72491. // arguments defined by service decorators
  72492. var serviceDependencies = instantiation_1._util.getServiceDependencies(ctor).sort(function (a, b) { return a.index - b.index; });
  72493. var serviceArgs = [];
  72494. for (var _i = 0, serviceDependencies_1 = serviceDependencies; _i < serviceDependencies_1.length; _i++) {
  72495. var dependency = serviceDependencies_1[_i];
  72496. var service = this._getOrCreateServiceInstance(dependency.id, _trace);
  72497. if (!service && this._strict && !dependency.optional) {
  72498. throw new Error("[createInstance] " + ctor.name + " depends on UNKNOWN service " + dependency.id + ".");
  72499. }
  72500. serviceArgs.push(service);
  72501. }
  72502. var firstServiceArgPos = serviceDependencies.length > 0 ? serviceDependencies[0].index : args.length;
  72503. // check for argument mismatches, adjust static args if needed
  72504. if (args.length !== firstServiceArgPos) {
  72505. console.warn("[createInstance] First service dependency of " + ctor.name + " at position " + (firstServiceArgPos + 1) + " conflicts with " + args.length + " static arguments");
  72506. var delta = firstServiceArgPos - args.length;
  72507. if (delta > 0) {
  72508. args = args.concat(new Array(delta));
  72509. }
  72510. else {
  72511. args = args.slice(0, firstServiceArgPos);
  72512. }
  72513. }
  72514. // now create the instance
  72515. return new (ctor.bind.apply(ctor, __spreadArrays([void 0], __spreadArrays(args, serviceArgs))))();
  72516. };
  72517. InstantiationService.prototype._setServiceInstance = function (id, instance) {
  72518. if (this._services.get(id) instanceof descriptors_1.SyncDescriptor) {
  72519. this._services.set(id, instance);
  72520. }
  72521. else if (this._parent) {
  72522. this._parent._setServiceInstance(id, instance);
  72523. }
  72524. else {
  72525. throw new Error('illegalState - setting UNKNOWN service instance');
  72526. }
  72527. };
  72528. InstantiationService.prototype._getServiceInstanceOrDescriptor = function (id) {
  72529. var instanceOrDesc = this._services.get(id);
  72530. if (!instanceOrDesc && this._parent) {
  72531. return this._parent._getServiceInstanceOrDescriptor(id);
  72532. }
  72533. else {
  72534. return instanceOrDesc;
  72535. }
  72536. };
  72537. InstantiationService.prototype._getOrCreateServiceInstance = function (id, _trace) {
  72538. var thing = this._getServiceInstanceOrDescriptor(id);
  72539. if (thing instanceof descriptors_1.SyncDescriptor) {
  72540. return this._createAndCacheServiceInstance(id, thing, _trace.branch(id, true));
  72541. }
  72542. else {
  72543. _trace.branch(id, false);
  72544. return thing;
  72545. }
  72546. };
  72547. InstantiationService.prototype._createAndCacheServiceInstance = function (id, desc, _trace) {
  72548. var graph = new graph_1.Graph(function (data) { return data.id.toString(); });
  72549. var cycleCount = 0;
  72550. var stack = [{ id: id, desc: desc, _trace: _trace }];
  72551. while (stack.length) {
  72552. var item = stack.pop();
  72553. graph.lookupOrInsertNode(item);
  72554. // a weak but working heuristic for cycle checks
  72555. if (cycleCount++ > 150) {
  72556. throw new CyclicDependencyError(graph);
  72557. }
  72558. // check all dependencies for existence and if they need to be created first
  72559. for (var _i = 0, _a = instantiation_1._util.getServiceDependencies(item.desc.ctor); _i < _a.length; _i++) {
  72560. var dependency = _a[_i];
  72561. var instanceOrDesc = this._getServiceInstanceOrDescriptor(dependency.id);
  72562. if (!instanceOrDesc && !dependency.optional) {
  72563. console.warn("[createInstance] " + id + " depends on " + dependency.id + " which is NOT registered.");
  72564. }
  72565. if (instanceOrDesc instanceof descriptors_1.SyncDescriptor) {
  72566. var d = { id: dependency.id, desc: instanceOrDesc, _trace: item._trace.branch(dependency.id, true) };
  72567. graph.insertEdge(item, d);
  72568. stack.push(d);
  72569. }
  72570. }
  72571. }
  72572. while (true) {
  72573. var roots = graph.roots();
  72574. // if there is no more roots but still
  72575. // nodes in the graph we have a cycle
  72576. if (roots.length === 0) {
  72577. if (!graph.isEmpty()) {
  72578. throw new CyclicDependencyError(graph);
  72579. }
  72580. break;
  72581. }
  72582. for (var _b = 0, roots_1 = roots; _b < roots_1.length; _b++) {
  72583. var data = roots_1[_b].data;
  72584. // create instance and overwrite the service collections
  72585. var instance = this._createServiceInstanceWithOwner(data.id, data.desc.ctor, data.desc.staticArguments, data.desc.supportsDelayedInstantiation, data._trace);
  72586. this._setServiceInstance(data.id, instance);
  72587. graph.removeNode(data);
  72588. }
  72589. }
  72590. return this._getServiceInstanceOrDescriptor(id);
  72591. };
  72592. InstantiationService.prototype._createServiceInstanceWithOwner = function (id, ctor, args, supportsDelayedInstantiation, _trace) {
  72593. if (args === void 0) { args = []; }
  72594. if (this._services.get(id) instanceof descriptors_1.SyncDescriptor) {
  72595. return this._createServiceInstance(ctor, args, supportsDelayedInstantiation, _trace);
  72596. }
  72597. else if (this._parent) {
  72598. return this._parent._createServiceInstanceWithOwner(id, ctor, args, supportsDelayedInstantiation, _trace);
  72599. }
  72600. else {
  72601. throw new Error("illegalState - creating UNKNOWN service instance " + ctor.name);
  72602. }
  72603. };
  72604. InstantiationService.prototype._createServiceInstance = function (ctor, args, _supportsDelayedInstantiation, _trace) {
  72605. var _this = this;
  72606. if (args === void 0) { args = []; }
  72607. if (!_supportsDelayedInstantiation || !_canUseProxy) {
  72608. // eager instantiation or no support JS proxies (e.g. IE11)
  72609. return this._createInstance(ctor, args, _trace);
  72610. }
  72611. else {
  72612. // Return a proxy object that's backed by an idle value. That
  72613. // strategy is to instantiate services in our idle time or when actually
  72614. // needed but not when injected into a consumer
  72615. var idle_1 = new async_1.IdleValue(function () { return _this._createInstance(ctor, args, _trace); });
  72616. return new Proxy(Object.create(null), {
  72617. get: function (target, key) {
  72618. if (key in target) {
  72619. return target[key];
  72620. }
  72621. var obj = idle_1.getValue();
  72622. var prop = obj[key];
  72623. if (typeof prop !== 'function') {
  72624. return prop;
  72625. }
  72626. prop = prop.bind(obj);
  72627. target[key] = prop;
  72628. return prop;
  72629. },
  72630. set: function (_target, p, value) {
  72631. idle_1.getValue()[p] = value;
  72632. return true;
  72633. }
  72634. });
  72635. }
  72636. };
  72637. return InstantiationService;
  72638. }());
  72639. exports.InstantiationService = InstantiationService;
  72640. var Trace = /** @class */ (function () {
  72641. function Trace(type, name) {
  72642. this.type = type;
  72643. this.name = name;
  72644. this._start = Date.now();
  72645. this._dep = [];
  72646. }
  72647. Trace.traceInvocation = function (ctor) {
  72648. return !_enableTracing ? Trace._None : new Trace(1 /* Invocation */, ctor.name || ctor.toString().substring(0, 42).replace(/\n/g, ''));
  72649. };
  72650. Trace.traceCreation = function (ctor) {
  72651. return !_enableTracing ? Trace._None : new Trace(0 /* Creation */, ctor.name);
  72652. };
  72653. Trace.prototype.branch = function (id, first) {
  72654. var child = new Trace(2 /* Branch */, id.toString());
  72655. this._dep.push([id, first, child]);
  72656. return child;
  72657. };
  72658. Trace.prototype.stop = function () {
  72659. var dur = Date.now() - this._start;
  72660. Trace._totals += dur;
  72661. var causedCreation = false;
  72662. function printChild(n, trace) {
  72663. var res = [];
  72664. var prefix = new Array(n + 1).join('\t');
  72665. for (var _i = 0, _a = trace._dep; _i < _a.length; _i++) {
  72666. var _b = _a[_i], id = _b[0], first = _b[1], child = _b[2];
  72667. if (first && child) {
  72668. causedCreation = true;
  72669. res.push(prefix + "CREATES -> " + id);
  72670. var nested = printChild(n + 1, child);
  72671. if (nested) {
  72672. res.push(nested);
  72673. }
  72674. }
  72675. else {
  72676. res.push(prefix + "uses -> " + id);
  72677. }
  72678. }
  72679. return res.join('\n');
  72680. }
  72681. var lines = [
  72682. (this.type === 0 /* Creation */ ? 'CREATE' : 'CALL') + " " + this.name,
  72683. "" + printChild(1, this),
  72684. "DONE, took " + dur.toFixed(2) + "ms (grand total " + Trace._totals.toFixed(2) + "ms)"
  72685. ];
  72686. if (dur > 2 || causedCreation) {
  72687. console.log(lines.join('\n'));
  72688. }
  72689. };
  72690. Trace._None = new /** @class */ (function (_super) {
  72691. __extends(class_1, _super);
  72692. function class_1() {
  72693. return _super.call(this, -1, null) || this;
  72694. }
  72695. class_1.prototype.stop = function () { };
  72696. class_1.prototype.branch = function () { return this; };
  72697. return class_1;
  72698. }(Trace));
  72699. Trace._totals = 0;
  72700. return Trace;
  72701. }());
  72702. });
  72703. //#endregion
  72704. /*---------------------------------------------------------------------------------------------
  72705. * Copyright (c) Microsoft Corporation. All rights reserved.
  72706. * Licensed under the MIT License. See License.txt in the project root for license information.
  72707. *--------------------------------------------------------------------------------------------*/
  72708. define(__m[502/*vs/platform/keybinding/common/abstractKeybindingService*/], __M([0/*require*/,1/*exports*/,473/*vs/nls!vs/platform/keybinding/common/abstractKeybindingService*/,15/*vs/base/common/async*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/]), function (require, exports, nls, async_1, event_1, lifecycle_1) {
  72709. "use strict";
  72710. Object.defineProperty(exports, "__esModule", { value: true });
  72711. var AbstractKeybindingService = /** @class */ (function (_super) {
  72712. __extends(AbstractKeybindingService, _super);
  72713. function AbstractKeybindingService(_contextKeyService, _commandService, _telemetryService, _notificationService) {
  72714. var _this = _super.call(this) || this;
  72715. _this._contextKeyService = _contextKeyService;
  72716. _this._commandService = _commandService;
  72717. _this._telemetryService = _telemetryService;
  72718. _this._notificationService = _notificationService;
  72719. _this._onDidUpdateKeybindings = _this._register(new event_1.Emitter());
  72720. _this._currentChord = null;
  72721. _this._currentChordChecker = new async_1.IntervalTimer();
  72722. _this._currentChordStatusMessage = null;
  72723. return _this;
  72724. }
  72725. Object.defineProperty(AbstractKeybindingService.prototype, "onDidUpdateKeybindings", {
  72726. get: function () {
  72727. return this._onDidUpdateKeybindings ? this._onDidUpdateKeybindings.event : event_1.Event.None; // Sinon stubbing walks properties on prototype
  72728. },
  72729. enumerable: true,
  72730. configurable: true
  72731. });
  72732. AbstractKeybindingService.prototype.dispose = function () {
  72733. _super.prototype.dispose.call(this);
  72734. };
  72735. AbstractKeybindingService.prototype.getKeybindings = function () {
  72736. return this._getResolver().getKeybindings();
  72737. };
  72738. AbstractKeybindingService.prototype.lookupKeybinding = function (commandId) {
  72739. var result = this._getResolver().lookupPrimaryKeybinding(commandId);
  72740. if (!result) {
  72741. return undefined;
  72742. }
  72743. return result.resolvedKeybinding;
  72744. };
  72745. AbstractKeybindingService.prototype.softDispatch = function (e, target) {
  72746. var keybinding = this.resolveKeyboardEvent(e);
  72747. if (keybinding.isChord()) {
  72748. console.warn('Unexpected keyboard event mapped to a chord');
  72749. return null;
  72750. }
  72751. var firstPart = keybinding.getDispatchParts()[0];
  72752. if (firstPart === null) {
  72753. // cannot be dispatched, probably only modifier keys
  72754. return null;
  72755. }
  72756. var contextValue = this._contextKeyService.getContext(target);
  72757. var currentChord = this._currentChord ? this._currentChord.keypress : null;
  72758. return this._getResolver().resolve(contextValue, currentChord, firstPart);
  72759. };
  72760. AbstractKeybindingService.prototype._enterChordMode = function (firstPart, keypressLabel) {
  72761. var _this = this;
  72762. this._currentChord = {
  72763. keypress: firstPart,
  72764. label: keypressLabel
  72765. };
  72766. this._currentChordStatusMessage = this._notificationService.status(nls.localize(0, null, keypressLabel));
  72767. var chordEnterTime = Date.now();
  72768. this._currentChordChecker.cancelAndSet(function () {
  72769. if (!_this._documentHasFocus()) {
  72770. // Focus has been lost => leave chord mode
  72771. _this._leaveChordMode();
  72772. return;
  72773. }
  72774. if (Date.now() - chordEnterTime > 5000) {
  72775. // 5 seconds elapsed => leave chord mode
  72776. _this._leaveChordMode();
  72777. }
  72778. }, 500);
  72779. };
  72780. AbstractKeybindingService.prototype._leaveChordMode = function () {
  72781. if (this._currentChordStatusMessage) {
  72782. this._currentChordStatusMessage.dispose();
  72783. this._currentChordStatusMessage = null;
  72784. }
  72785. this._currentChordChecker.cancel();
  72786. this._currentChord = null;
  72787. };
  72788. AbstractKeybindingService.prototype._dispatch = function (e, target) {
  72789. return this._doDispatch(this.resolveKeyboardEvent(e), target);
  72790. };
  72791. AbstractKeybindingService.prototype._doDispatch = function (keybinding, target) {
  72792. var _this = this;
  72793. var shouldPreventDefault = false;
  72794. if (keybinding.isChord()) {
  72795. console.warn('Unexpected keyboard event mapped to a chord');
  72796. return false;
  72797. }
  72798. var firstPart = keybinding.getDispatchParts()[0];
  72799. if (firstPart === null) {
  72800. // cannot be dispatched, probably only modifier keys
  72801. return shouldPreventDefault;
  72802. }
  72803. var contextValue = this._contextKeyService.getContext(target);
  72804. var currentChord = this._currentChord ? this._currentChord.keypress : null;
  72805. var keypressLabel = keybinding.getLabel();
  72806. var resolveResult = this._getResolver().resolve(contextValue, currentChord, firstPart);
  72807. if (resolveResult && resolveResult.enterChord) {
  72808. shouldPreventDefault = true;
  72809. this._enterChordMode(firstPart, keypressLabel);
  72810. return shouldPreventDefault;
  72811. }
  72812. if (this._currentChord) {
  72813. if (!resolveResult || !resolveResult.commandId) {
  72814. this._notificationService.status(nls.localize(1, null, this._currentChord.label, keypressLabel), { hideAfter: 10 * 1000 /* 10s */ });
  72815. shouldPreventDefault = true;
  72816. }
  72817. }
  72818. this._leaveChordMode();
  72819. if (resolveResult && resolveResult.commandId) {
  72820. if (!resolveResult.bubble) {
  72821. shouldPreventDefault = true;
  72822. }
  72823. if (typeof resolveResult.commandArgs === 'undefined') {
  72824. this._commandService.executeCommand(resolveResult.commandId).then(undefined, function (err) { return _this._notificationService.warn(err); });
  72825. }
  72826. else {
  72827. this._commandService.executeCommand(resolveResult.commandId, resolveResult.commandArgs).then(undefined, function (err) { return _this._notificationService.warn(err); });
  72828. }
  72829. this._telemetryService.publicLog2('workbenchActionExecuted', { id: resolveResult.commandId, from: 'keybinding' });
  72830. }
  72831. return shouldPreventDefault;
  72832. };
  72833. AbstractKeybindingService.prototype.mightProducePrintableCharacter = function (event) {
  72834. if (event.ctrlKey || event.metaKey) {
  72835. // ignore ctrl/cmd-combination but not shift/alt-combinatios
  72836. return false;
  72837. }
  72838. // weak check for certain ranges. this is properly implemented in a subclass
  72839. // with access to the KeyboardMapperFactory.
  72840. if ((event.keyCode >= 31 /* KEY_A */ && event.keyCode <= 56 /* KEY_Z */)
  72841. || (event.keyCode >= 21 /* KEY_0 */ && event.keyCode <= 30 /* KEY_9 */)) {
  72842. return true;
  72843. }
  72844. return false;
  72845. };
  72846. return AbstractKeybindingService;
  72847. }(lifecycle_1.Disposable));
  72848. exports.AbstractKeybindingService = AbstractKeybindingService;
  72849. });
  72850. /*---------------------------------------------------------------------------------------------
  72851. * Copyright (c) Microsoft Corporation. All rights reserved.
  72852. * Licensed under the MIT License. See License.txt in the project root for license information.
  72853. *--------------------------------------------------------------------------------------------*/
  72854. define(__m[503/*vs/platform/keybinding/common/baseResolvedKeybinding*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,207/*vs/base/common/keybindingLabels*/,36/*vs/base/common/keyCodes*/]), function (require, exports, errors_1, keybindingLabels_1, keyCodes_1) {
  72855. "use strict";
  72856. Object.defineProperty(exports, "__esModule", { value: true });
  72857. var BaseResolvedKeybinding = /** @class */ (function (_super) {
  72858. __extends(BaseResolvedKeybinding, _super);
  72859. function BaseResolvedKeybinding(os, parts) {
  72860. var _this = _super.call(this) || this;
  72861. if (parts.length === 0) {
  72862. throw errors_1.illegalArgument("parts");
  72863. }
  72864. _this._os = os;
  72865. _this._parts = parts;
  72866. return _this;
  72867. }
  72868. BaseResolvedKeybinding.prototype.getLabel = function () {
  72869. var _this = this;
  72870. return keybindingLabels_1.UILabelProvider.toLabel(this._os, this._parts, function (keybinding) { return _this._getLabel(keybinding); });
  72871. };
  72872. BaseResolvedKeybinding.prototype.getAriaLabel = function () {
  72873. var _this = this;
  72874. return keybindingLabels_1.AriaLabelProvider.toLabel(this._os, this._parts, function (keybinding) { return _this._getAriaLabel(keybinding); });
  72875. };
  72876. BaseResolvedKeybinding.prototype.isChord = function () {
  72877. return (this._parts.length > 1);
  72878. };
  72879. BaseResolvedKeybinding.prototype.getParts = function () {
  72880. var _this = this;
  72881. return this._parts.map(function (keybinding) { return _this._getPart(keybinding); });
  72882. };
  72883. BaseResolvedKeybinding.prototype._getPart = function (keybinding) {
  72884. return new keyCodes_1.ResolvedKeybindingPart(keybinding.ctrlKey, keybinding.shiftKey, keybinding.altKey, keybinding.metaKey, this._getLabel(keybinding), this._getAriaLabel(keybinding));
  72885. };
  72886. BaseResolvedKeybinding.prototype.getDispatchParts = function () {
  72887. var _this = this;
  72888. return this._parts.map(function (keybinding) { return _this._getDispatchPart(keybinding); });
  72889. };
  72890. return BaseResolvedKeybinding;
  72891. }(keyCodes_1.ResolvedKeybinding));
  72892. exports.BaseResolvedKeybinding = BaseResolvedKeybinding;
  72893. });
  72894. /*---------------------------------------------------------------------------------------------
  72895. * Copyright (c) Microsoft Corporation. All rights reserved.
  72896. * Licensed under the MIT License. See License.txt in the project root for license information.
  72897. *--------------------------------------------------------------------------------------------*/
  72898. define(__m[34/*vs/platform/keybinding/common/keybinding*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  72899. "use strict";
  72900. Object.defineProperty(exports, "__esModule", { value: true });
  72901. exports.IKeybindingService = instantiation_1.createDecorator('keybindingService');
  72902. });
  72903. define(__m[217/*vs/platform/keybinding/common/keybindingResolver*/], __M([0/*require*/,1/*exports*/,18/*vs/platform/contextkey/common/contextkey*/]), function (require, exports, contextkey_1) {
  72904. "use strict";
  72905. Object.defineProperty(exports, "__esModule", { value: true });
  72906. var KeybindingResolver = /** @class */ (function () {
  72907. function KeybindingResolver(defaultKeybindings, overrides) {
  72908. this._defaultKeybindings = defaultKeybindings;
  72909. this._defaultBoundCommands = new Map();
  72910. for (var i = 0, len = defaultKeybindings.length; i < len; i++) {
  72911. var command = defaultKeybindings[i].command;
  72912. if (command) {
  72913. this._defaultBoundCommands.set(command, true);
  72914. }
  72915. }
  72916. this._map = new Map();
  72917. this._lookupMap = new Map();
  72918. this._keybindings = KeybindingResolver.combine(defaultKeybindings, overrides);
  72919. for (var i = 0, len = this._keybindings.length; i < len; i++) {
  72920. var k = this._keybindings[i];
  72921. if (k.keypressParts.length === 0) {
  72922. // unbound
  72923. continue;
  72924. }
  72925. // TODO@chords
  72926. this._addKeyPress(k.keypressParts[0], k);
  72927. }
  72928. }
  72929. KeybindingResolver._isTargetedForRemoval = function (defaultKb, keypressFirstPart, keypressChordPart, command, when) {
  72930. if (defaultKb.command !== command) {
  72931. return false;
  72932. }
  72933. // TODO@chords
  72934. if (keypressFirstPart && defaultKb.keypressParts[0] !== keypressFirstPart) {
  72935. return false;
  72936. }
  72937. // TODO@chords
  72938. if (keypressChordPart && defaultKb.keypressParts[1] !== keypressChordPart) {
  72939. return false;
  72940. }
  72941. if (when) {
  72942. if (!defaultKb.when) {
  72943. return false;
  72944. }
  72945. if (!when.equals(defaultKb.when)) {
  72946. return false;
  72947. }
  72948. }
  72949. return true;
  72950. };
  72951. /**
  72952. * Looks for rules containing -command in `overrides` and removes them directly from `defaults`.
  72953. */
  72954. KeybindingResolver.combine = function (defaults, rawOverrides) {
  72955. defaults = defaults.slice(0);
  72956. var overrides = [];
  72957. for (var _i = 0, rawOverrides_1 = rawOverrides; _i < rawOverrides_1.length; _i++) {
  72958. var override = rawOverrides_1[_i];
  72959. if (!override.command || override.command.length === 0 || override.command.charAt(0) !== '-') {
  72960. overrides.push(override);
  72961. continue;
  72962. }
  72963. var command = override.command.substr(1);
  72964. // TODO@chords
  72965. var keypressFirstPart = override.keypressParts[0];
  72966. var keypressChordPart = override.keypressParts[1];
  72967. var when = override.when;
  72968. for (var j = defaults.length - 1; j >= 0; j--) {
  72969. if (this._isTargetedForRemoval(defaults[j], keypressFirstPart, keypressChordPart, command, when)) {
  72970. defaults.splice(j, 1);
  72971. }
  72972. }
  72973. }
  72974. return defaults.concat(overrides);
  72975. };
  72976. KeybindingResolver.prototype._addKeyPress = function (keypress, item) {
  72977. var conflicts = this._map.get(keypress);
  72978. if (typeof conflicts === 'undefined') {
  72979. // There is no conflict so far
  72980. this._map.set(keypress, [item]);
  72981. this._addToLookupMap(item);
  72982. return;
  72983. }
  72984. for (var i = conflicts.length - 1; i >= 0; i--) {
  72985. var conflict = conflicts[i];
  72986. if (conflict.command === item.command) {
  72987. continue;
  72988. }
  72989. var conflictIsChord = (conflict.keypressParts.length > 1);
  72990. var itemIsChord = (item.keypressParts.length > 1);
  72991. // TODO@chords
  72992. if (conflictIsChord && itemIsChord && conflict.keypressParts[1] !== item.keypressParts[1]) {
  72993. // The conflict only shares the chord start with this command
  72994. continue;
  72995. }
  72996. if (KeybindingResolver.whenIsEntirelyIncluded(conflict.when, item.when)) {
  72997. // `item` completely overwrites `conflict`
  72998. // Remove conflict from the lookupMap
  72999. this._removeFromLookupMap(conflict);
  73000. }
  73001. }
  73002. conflicts.push(item);
  73003. this._addToLookupMap(item);
  73004. };
  73005. KeybindingResolver.prototype._addToLookupMap = function (item) {
  73006. if (!item.command) {
  73007. return;
  73008. }
  73009. var arr = this._lookupMap.get(item.command);
  73010. if (typeof arr === 'undefined') {
  73011. arr = [item];
  73012. this._lookupMap.set(item.command, arr);
  73013. }
  73014. else {
  73015. arr.push(item);
  73016. }
  73017. };
  73018. KeybindingResolver.prototype._removeFromLookupMap = function (item) {
  73019. if (!item.command) {
  73020. return;
  73021. }
  73022. var arr = this._lookupMap.get(item.command);
  73023. if (typeof arr === 'undefined') {
  73024. return;
  73025. }
  73026. for (var i = 0, len = arr.length; i < len; i++) {
  73027. if (arr[i] === item) {
  73028. arr.splice(i, 1);
  73029. return;
  73030. }
  73031. }
  73032. };
  73033. /**
  73034. * Returns true if it is provable `a` implies `b`.
  73035. */
  73036. KeybindingResolver.whenIsEntirelyIncluded = function (a, b) {
  73037. if (!b) {
  73038. return true;
  73039. }
  73040. if (!a) {
  73041. return false;
  73042. }
  73043. return this._implies(a, b);
  73044. };
  73045. /**
  73046. * Returns true if it is provable `p` implies `q`.
  73047. */
  73048. KeybindingResolver._implies = function (p, q) {
  73049. var notP = p.negate();
  73050. var terminals = function (node) {
  73051. if (node instanceof contextkey_1.ContextKeyOrExpr) {
  73052. return node.expr;
  73053. }
  73054. return [node];
  73055. };
  73056. var expr = terminals(notP).concat(terminals(q));
  73057. for (var i = 0; i < expr.length; i++) {
  73058. var a = expr[i];
  73059. var notA = a.negate();
  73060. for (var j = i + 1; j < expr.length; j++) {
  73061. var b = expr[j];
  73062. if (notA.equals(b)) {
  73063. return true;
  73064. }
  73065. }
  73066. }
  73067. return false;
  73068. };
  73069. KeybindingResolver.prototype.getKeybindings = function () {
  73070. return this._keybindings;
  73071. };
  73072. KeybindingResolver.prototype.lookupPrimaryKeybinding = function (commandId) {
  73073. var items = this._lookupMap.get(commandId);
  73074. if (typeof items === 'undefined' || items.length === 0) {
  73075. return null;
  73076. }
  73077. return items[items.length - 1];
  73078. };
  73079. KeybindingResolver.prototype.resolve = function (context, currentChord, keypress) {
  73080. var lookupMap = null;
  73081. if (currentChord !== null) {
  73082. // Fetch all chord bindings for `currentChord`
  73083. var candidates = this._map.get(currentChord);
  73084. if (typeof candidates === 'undefined') {
  73085. // No chords starting with `currentChord`
  73086. return null;
  73087. }
  73088. lookupMap = [];
  73089. for (var i = 0, len = candidates.length; i < len; i++) {
  73090. var candidate = candidates[i];
  73091. // TODO@chords
  73092. if (candidate.keypressParts[1] === keypress) {
  73093. lookupMap.push(candidate);
  73094. }
  73095. }
  73096. }
  73097. else {
  73098. var candidates = this._map.get(keypress);
  73099. if (typeof candidates === 'undefined') {
  73100. // No bindings with `keypress`
  73101. return null;
  73102. }
  73103. lookupMap = candidates;
  73104. }
  73105. var result = this._findCommand(context, lookupMap);
  73106. if (!result) {
  73107. return null;
  73108. }
  73109. // TODO@chords
  73110. if (currentChord === null && result.keypressParts.length > 1 && result.keypressParts[1] !== null) {
  73111. return {
  73112. enterChord: true,
  73113. commandId: null,
  73114. commandArgs: null,
  73115. bubble: false
  73116. };
  73117. }
  73118. return {
  73119. enterChord: false,
  73120. commandId: result.command,
  73121. commandArgs: result.commandArgs,
  73122. bubble: result.bubble
  73123. };
  73124. };
  73125. KeybindingResolver.prototype._findCommand = function (context, matches) {
  73126. for (var i = matches.length - 1; i >= 0; i--) {
  73127. var k = matches[i];
  73128. if (!KeybindingResolver.contextMatchesRules(context, k.when)) {
  73129. continue;
  73130. }
  73131. return k;
  73132. }
  73133. return null;
  73134. };
  73135. KeybindingResolver.contextMatchesRules = function (context, rules) {
  73136. if (!rules) {
  73137. return true;
  73138. }
  73139. return rules.evaluate(context);
  73140. };
  73141. return KeybindingResolver;
  73142. }());
  73143. exports.KeybindingResolver = KeybindingResolver;
  73144. });
  73145. /*---------------------------------------------------------------------------------------------
  73146. * Copyright (c) Microsoft Corporation. All rights reserved.
  73147. * Licensed under the MIT License. See License.txt in the project root for license information.
  73148. *--------------------------------------------------------------------------------------------*/
  73149. define(__m[504/*vs/platform/keybinding/common/resolvedKeybindingItem*/], __M([0/*require*/,1/*exports*/]), function (require, exports) {
  73150. "use strict";
  73151. Object.defineProperty(exports, "__esModule", { value: true });
  73152. var ResolvedKeybindingItem = /** @class */ (function () {
  73153. function ResolvedKeybindingItem(resolvedKeybinding, command, commandArgs, when, isDefault) {
  73154. this.resolvedKeybinding = resolvedKeybinding;
  73155. this.keypressParts = resolvedKeybinding ? removeElementsAfterNulls(resolvedKeybinding.getDispatchParts()) : [];
  73156. this.bubble = (command ? command.charCodeAt(0) === 94 /* Caret */ : false);
  73157. this.command = this.bubble ? command.substr(1) : command;
  73158. this.commandArgs = commandArgs;
  73159. this.when = when;
  73160. this.isDefault = isDefault;
  73161. }
  73162. return ResolvedKeybindingItem;
  73163. }());
  73164. exports.ResolvedKeybindingItem = ResolvedKeybindingItem;
  73165. function removeElementsAfterNulls(arr) {
  73166. var result = [];
  73167. for (var i = 0, len = arr.length; i < len; i++) {
  73168. var element = arr[i];
  73169. if (!element) {
  73170. // stop processing at first encountered null
  73171. return result;
  73172. }
  73173. result.push(element);
  73174. }
  73175. return result;
  73176. }
  73177. exports.removeElementsAfterNulls = removeElementsAfterNulls;
  73178. });
  73179. /*---------------------------------------------------------------------------------------------
  73180. * Copyright (c) Microsoft Corporation. All rights reserved.
  73181. * Licensed under the MIT License. See License.txt in the project root for license information.
  73182. *--------------------------------------------------------------------------------------------*/
  73183. define(__m[505/*vs/platform/keybinding/common/usLayoutResolvedKeybinding*/], __M([0/*require*/,1/*exports*/,36/*vs/base/common/keyCodes*/,503/*vs/platform/keybinding/common/baseResolvedKeybinding*/]), function (require, exports, keyCodes_1, baseResolvedKeybinding_1) {
  73184. "use strict";
  73185. Object.defineProperty(exports, "__esModule", { value: true });
  73186. /**
  73187. * Do not instantiate. Use KeybindingService to get a ResolvedKeybinding seeded with information about the current kb layout.
  73188. */
  73189. var USLayoutResolvedKeybinding = /** @class */ (function (_super) {
  73190. __extends(USLayoutResolvedKeybinding, _super);
  73191. function USLayoutResolvedKeybinding(actual, os) {
  73192. return _super.call(this, os, actual.parts) || this;
  73193. }
  73194. USLayoutResolvedKeybinding.prototype._keyCodeToUILabel = function (keyCode) {
  73195. if (this._os === 2 /* Macintosh */) {
  73196. switch (keyCode) {
  73197. case 15 /* LeftArrow */:
  73198. return '←';
  73199. case 16 /* UpArrow */:
  73200. return '↑';
  73201. case 17 /* RightArrow */:
  73202. return '→';
  73203. case 18 /* DownArrow */:
  73204. return '↓';
  73205. }
  73206. }
  73207. return keyCodes_1.KeyCodeUtils.toString(keyCode);
  73208. };
  73209. USLayoutResolvedKeybinding.prototype._getLabel = function (keybinding) {
  73210. if (keybinding.isDuplicateModifierCase()) {
  73211. return '';
  73212. }
  73213. return this._keyCodeToUILabel(keybinding.keyCode);
  73214. };
  73215. USLayoutResolvedKeybinding.prototype._getAriaLabel = function (keybinding) {
  73216. if (keybinding.isDuplicateModifierCase()) {
  73217. return '';
  73218. }
  73219. return keyCodes_1.KeyCodeUtils.toString(keybinding.keyCode);
  73220. };
  73221. USLayoutResolvedKeybinding.prototype._getDispatchPart = function (keybinding) {
  73222. return USLayoutResolvedKeybinding.getDispatchStr(keybinding);
  73223. };
  73224. USLayoutResolvedKeybinding.getDispatchStr = function (keybinding) {
  73225. if (keybinding.isModifierKey()) {
  73226. return null;
  73227. }
  73228. var result = '';
  73229. if (keybinding.ctrlKey) {
  73230. result += 'ctrl+';
  73231. }
  73232. if (keybinding.shiftKey) {
  73233. result += 'shift+';
  73234. }
  73235. if (keybinding.altKey) {
  73236. result += 'alt+';
  73237. }
  73238. if (keybinding.metaKey) {
  73239. result += 'meta+';
  73240. }
  73241. result += keyCodes_1.KeyCodeUtils.toString(keybinding.keyCode);
  73242. return result;
  73243. };
  73244. return USLayoutResolvedKeybinding;
  73245. }(baseResolvedKeybinding_1.BaseResolvedKeybinding));
  73246. exports.USLayoutResolvedKeybinding = USLayoutResolvedKeybinding;
  73247. });
  73248. /*---------------------------------------------------------------------------------------------
  73249. * Copyright (c) Microsoft Corporation. All rights reserved.
  73250. * Licensed under the MIT License. See License.txt in the project root for license information.
  73251. *--------------------------------------------------------------------------------------------*/
  73252. define(__m[116/*vs/platform/label/common/label*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  73253. "use strict";
  73254. Object.defineProperty(exports, "__esModule", { value: true });
  73255. var LABEL_SERVICE_ID = 'label';
  73256. exports.ILabelService = instantiation_1.createDecorator(LABEL_SERVICE_ID);
  73257. });
  73258. /*---------------------------------------------------------------------------------------------
  73259. * Copyright (c) Microsoft Corporation. All rights reserved.
  73260. * Licensed under the MIT License. See License.txt in the project root for license information.
  73261. *--------------------------------------------------------------------------------------------*/
  73262. define(__m[218/*vs/platform/layout/browser/layoutService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  73263. "use strict";
  73264. Object.defineProperty(exports, "__esModule", { value: true });
  73265. exports.ILayoutService = instantiation_1.createDecorator('layoutService');
  73266. });
  73267. /*---------------------------------------------------------------------------------------------
  73268. * Copyright (c) Microsoft Corporation. All rights reserved.
  73269. * Licensed under the MIT License. See License.txt in the project root for license information.
  73270. *--------------------------------------------------------------------------------------------*/
  73271. define(__m[506/*vs/platform/contextview/browser/contextViewService*/], __M([0/*require*/,1/*exports*/,265/*vs/base/browser/ui/contextview/contextview*/,2/*vs/base/common/lifecycle*/,218/*vs/platform/layout/browser/layoutService*/]), function (require, exports, contextview_1, lifecycle_1, layoutService_1) {
  73272. "use strict";
  73273. Object.defineProperty(exports, "__esModule", { value: true });
  73274. var ContextViewService = /** @class */ (function (_super) {
  73275. __extends(ContextViewService, _super);
  73276. function ContextViewService(layoutService) {
  73277. var _this = _super.call(this) || this;
  73278. _this.layoutService = layoutService;
  73279. _this.contextView = _this._register(new contextview_1.ContextView(layoutService.container));
  73280. _this.layout();
  73281. _this._register(layoutService.onLayout(function () { return _this.layout(); }));
  73282. return _this;
  73283. }
  73284. // ContextView
  73285. ContextViewService.prototype.setContainer = function (container) {
  73286. this.contextView.setContainer(container);
  73287. };
  73288. ContextViewService.prototype.showContextView = function (delegate) {
  73289. this.contextView.show(delegate);
  73290. };
  73291. ContextViewService.prototype.layout = function () {
  73292. this.contextView.layout();
  73293. };
  73294. ContextViewService.prototype.hideContextView = function (data) {
  73295. this.contextView.hide(data);
  73296. };
  73297. ContextViewService = __decorate([
  73298. __param(0, layoutService_1.ILayoutService)
  73299. ], ContextViewService);
  73300. return ContextViewService;
  73301. }(lifecycle_1.Disposable));
  73302. exports.ContextViewService = ContextViewService;
  73303. });
  73304. /*---------------------------------------------------------------------------------------------
  73305. * Copyright (c) Microsoft Corporation. All rights reserved.
  73306. * Licensed under the MIT License. See License.txt in the project root for license information.
  73307. *--------------------------------------------------------------------------------------------*/
  73308. define(__m[95/*vs/platform/log/common/log*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  73309. "use strict";
  73310. Object.defineProperty(exports, "__esModule", { value: true });
  73311. exports.ILogService = instantiation_1.createDecorator('logService');
  73312. var LogLevel;
  73313. (function (LogLevel) {
  73314. LogLevel[LogLevel["Trace"] = 0] = "Trace";
  73315. LogLevel[LogLevel["Debug"] = 1] = "Debug";
  73316. LogLevel[LogLevel["Info"] = 2] = "Info";
  73317. LogLevel[LogLevel["Warning"] = 3] = "Warning";
  73318. LogLevel[LogLevel["Error"] = 4] = "Error";
  73319. LogLevel[LogLevel["Critical"] = 5] = "Critical";
  73320. LogLevel[LogLevel["Off"] = 6] = "Off";
  73321. })(LogLevel = exports.LogLevel || (exports.LogLevel = {}));
  73322. var NullLogService = /** @class */ (function () {
  73323. function NullLogService() {
  73324. }
  73325. NullLogService.prototype.getLevel = function () { return LogLevel.Info; };
  73326. NullLogService.prototype.trace = function (message) {
  73327. var args = [];
  73328. for (var _i = 1; _i < arguments.length; _i++) {
  73329. args[_i - 1] = arguments[_i];
  73330. }
  73331. };
  73332. NullLogService.prototype.error = function (message) {
  73333. var args = [];
  73334. for (var _i = 1; _i < arguments.length; _i++) {
  73335. args[_i - 1] = arguments[_i];
  73336. }
  73337. };
  73338. NullLogService.prototype.dispose = function () { };
  73339. return NullLogService;
  73340. }());
  73341. exports.NullLogService = NullLogService;
  73342. });
  73343. /*---------------------------------------------------------------------------------------------
  73344. * Copyright (c) Microsoft Corporation. All rights reserved.
  73345. * Licensed under the MIT License. See License.txt in the project root for license information.
  73346. *--------------------------------------------------------------------------------------------*/
  73347. define(__m[219/*vs/editor/common/services/editorWorkerServiceImpl*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,2/*vs/base/common/lifecycle*/,182/*vs/base/common/worker/simpleWorker*/,258/*vs/base/worker/defaultWorkerFactory*/,3/*vs/editor/common/core/range*/,17/*vs/editor/common/modes*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/,365/*vs/editor/common/services/editorSimpleWorker*/,49/*vs/editor/common/services/modelService*/,114/*vs/editor/common/services/textResourceConfigurationService*/,5/*vs/base/common/strings*/,19/*vs/base/common/arrays*/,95/*vs/platform/log/common/log*/,132/*vs/base/common/stopwatch*/]), function (require, exports, async_1, lifecycle_1, simpleWorker_1, defaultWorkerFactory_1, range_1, modes, languageConfigurationRegistry_1, editorSimpleWorker_1, modelService_1, textResourceConfigurationService_1, strings_1, arrays_1, log_1, stopwatch_1) {
  73348. "use strict";
  73349. Object.defineProperty(exports, "__esModule", { value: true });
  73350. /**
  73351. * Stop syncing a model to the worker if it was not needed for 1 min.
  73352. */
  73353. var STOP_SYNC_MODEL_DELTA_TIME_MS = 60 * 1000;
  73354. /**
  73355. * Stop the worker if it was not needed for 5 min.
  73356. */
  73357. var STOP_WORKER_DELTA_TIME_MS = 5 * 60 * 1000;
  73358. function canSyncModel(modelService, resource) {
  73359. var model = modelService.getModel(resource);
  73360. if (!model) {
  73361. return false;
  73362. }
  73363. if (model.isTooLargeForSyncing()) {
  73364. return false;
  73365. }
  73366. return true;
  73367. }
  73368. var EditorWorkerServiceImpl = /** @class */ (function (_super) {
  73369. __extends(EditorWorkerServiceImpl, _super);
  73370. function EditorWorkerServiceImpl(modelService, configurationService, logService) {
  73371. var _this = _super.call(this) || this;
  73372. _this._modelService = modelService;
  73373. _this._workerManager = _this._register(new WorkerManager(_this._modelService));
  73374. _this._logService = logService;
  73375. // todo@joh make sure this happens only once
  73376. _this._register(modes.LinkProviderRegistry.register('*', {
  73377. provideLinks: function (model, token) {
  73378. if (!canSyncModel(_this._modelService, model.uri)) {
  73379. return Promise.resolve({ links: [] }); // File too large
  73380. }
  73381. return _this._workerManager.withWorker().then(function (client) { return client.computeLinks(model.uri); }).then(function (links) {
  73382. return links && { links: links };
  73383. });
  73384. }
  73385. }));
  73386. _this._register(modes.CompletionProviderRegistry.register('*', new WordBasedCompletionItemProvider(_this._workerManager, configurationService, _this._modelService)));
  73387. return _this;
  73388. }
  73389. EditorWorkerServiceImpl.prototype.dispose = function () {
  73390. _super.prototype.dispose.call(this);
  73391. };
  73392. EditorWorkerServiceImpl.prototype.canComputeDiff = function (original, modified) {
  73393. return (canSyncModel(this._modelService, original) && canSyncModel(this._modelService, modified));
  73394. };
  73395. EditorWorkerServiceImpl.prototype.computeDiff = function (original, modified, ignoreTrimWhitespace, maxComputationTime) {
  73396. return this._workerManager.withWorker().then(function (client) { return client.computeDiff(original, modified, ignoreTrimWhitespace, maxComputationTime); });
  73397. };
  73398. EditorWorkerServiceImpl.prototype.computeMoreMinimalEdits = function (resource, edits) {
  73399. var _this = this;
  73400. if (arrays_1.isNonEmptyArray(edits)) {
  73401. if (!canSyncModel(this._modelService, resource)) {
  73402. return Promise.resolve(edits); // File too large
  73403. }
  73404. var sw_1 = stopwatch_1.StopWatch.create(true);
  73405. var result = this._workerManager.withWorker().then(function (client) { return client.computeMoreMinimalEdits(resource, edits); });
  73406. result.finally(function () { return _this._logService.trace('FORMAT#computeMoreMinimalEdits', resource.toString(true), sw_1.elapsed()); });
  73407. return result;
  73408. }
  73409. else {
  73410. return Promise.resolve(undefined);
  73411. }
  73412. };
  73413. EditorWorkerServiceImpl.prototype.canNavigateValueSet = function (resource) {
  73414. return (canSyncModel(this._modelService, resource));
  73415. };
  73416. EditorWorkerServiceImpl.prototype.navigateValueSet = function (resource, range, up) {
  73417. return this._workerManager.withWorker().then(function (client) { return client.navigateValueSet(resource, range, up); });
  73418. };
  73419. EditorWorkerServiceImpl.prototype.canComputeWordRanges = function (resource) {
  73420. return canSyncModel(this._modelService, resource);
  73421. };
  73422. EditorWorkerServiceImpl.prototype.computeWordRanges = function (resource, range) {
  73423. return this._workerManager.withWorker().then(function (client) { return client.computeWordRanges(resource, range); });
  73424. };
  73425. EditorWorkerServiceImpl = __decorate([
  73426. __param(0, modelService_1.IModelService),
  73427. __param(1, textResourceConfigurationService_1.ITextResourceConfigurationService),
  73428. __param(2, log_1.ILogService)
  73429. ], EditorWorkerServiceImpl);
  73430. return EditorWorkerServiceImpl;
  73431. }(lifecycle_1.Disposable));
  73432. exports.EditorWorkerServiceImpl = EditorWorkerServiceImpl;
  73433. var WordBasedCompletionItemProvider = /** @class */ (function () {
  73434. function WordBasedCompletionItemProvider(workerManager, configurationService, modelService) {
  73435. this._debugDisplayName = 'wordbasedCompletions';
  73436. this._workerManager = workerManager;
  73437. this._configurationService = configurationService;
  73438. this._modelService = modelService;
  73439. }
  73440. WordBasedCompletionItemProvider.prototype.provideCompletionItems = function (model, position) {
  73441. return __awaiter(this, void 0, void 0, function () {
  73442. var wordBasedSuggestions, word, replace, insert, client, words;
  73443. return __generator(this, function (_a) {
  73444. switch (_a.label) {
  73445. case 0:
  73446. wordBasedSuggestions = this._configurationService.getValue(model.uri, position, 'editor').wordBasedSuggestions;
  73447. if (!wordBasedSuggestions) {
  73448. return [2 /*return*/, undefined];
  73449. }
  73450. if (!canSyncModel(this._modelService, model.uri)) {
  73451. return [2 /*return*/, undefined]; // File too large
  73452. }
  73453. word = model.getWordAtPosition(position);
  73454. replace = !word ? range_1.Range.fromPositions(position) : new range_1.Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn);
  73455. insert = replace.setEndPosition(position.lineNumber, position.column);
  73456. return [4 /*yield*/, this._workerManager.withWorker()];
  73457. case 1:
  73458. client = _a.sent();
  73459. return [4 /*yield*/, client.textualSuggest(model.uri, position)];
  73460. case 2:
  73461. words = _a.sent();
  73462. if (!words) {
  73463. return [2 /*return*/, undefined];
  73464. }
  73465. return [2 /*return*/, {
  73466. suggestions: words.map(function (word) {
  73467. return {
  73468. kind: 18 /* Text */,
  73469. label: word,
  73470. insertText: word,
  73471. range: { insert: insert, replace: replace }
  73472. };
  73473. })
  73474. }];
  73475. }
  73476. });
  73477. });
  73478. };
  73479. return WordBasedCompletionItemProvider;
  73480. }());
  73481. var WorkerManager = /** @class */ (function (_super) {
  73482. __extends(WorkerManager, _super);
  73483. function WorkerManager(modelService) {
  73484. var _this = _super.call(this) || this;
  73485. _this._modelService = modelService;
  73486. _this._editorWorkerClient = null;
  73487. _this._lastWorkerUsedTime = (new Date()).getTime();
  73488. var stopWorkerInterval = _this._register(new async_1.IntervalTimer());
  73489. stopWorkerInterval.cancelAndSet(function () { return _this._checkStopIdleWorker(); }, Math.round(STOP_WORKER_DELTA_TIME_MS / 2));
  73490. _this._register(_this._modelService.onModelRemoved(function (_) { return _this._checkStopEmptyWorker(); }));
  73491. return _this;
  73492. }
  73493. WorkerManager.prototype.dispose = function () {
  73494. if (this._editorWorkerClient) {
  73495. this._editorWorkerClient.dispose();
  73496. this._editorWorkerClient = null;
  73497. }
  73498. _super.prototype.dispose.call(this);
  73499. };
  73500. /**
  73501. * Check if the model service has no more models and stop the worker if that is the case.
  73502. */
  73503. WorkerManager.prototype._checkStopEmptyWorker = function () {
  73504. if (!this._editorWorkerClient) {
  73505. return;
  73506. }
  73507. var models = this._modelService.getModels();
  73508. if (models.length === 0) {
  73509. // There are no more models => nothing possible for me to do
  73510. this._editorWorkerClient.dispose();
  73511. this._editorWorkerClient = null;
  73512. }
  73513. };
  73514. /**
  73515. * Check if the worker has been idle for a while and then stop it.
  73516. */
  73517. WorkerManager.prototype._checkStopIdleWorker = function () {
  73518. if (!this._editorWorkerClient) {
  73519. return;
  73520. }
  73521. var timeSinceLastWorkerUsedTime = (new Date()).getTime() - this._lastWorkerUsedTime;
  73522. if (timeSinceLastWorkerUsedTime > STOP_WORKER_DELTA_TIME_MS) {
  73523. this._editorWorkerClient.dispose();
  73524. this._editorWorkerClient = null;
  73525. }
  73526. };
  73527. WorkerManager.prototype.withWorker = function () {
  73528. this._lastWorkerUsedTime = (new Date()).getTime();
  73529. if (!this._editorWorkerClient) {
  73530. this._editorWorkerClient = new EditorWorkerClient(this._modelService, false, 'editorWorkerService');
  73531. }
  73532. return Promise.resolve(this._editorWorkerClient);
  73533. };
  73534. return WorkerManager;
  73535. }(lifecycle_1.Disposable));
  73536. var EditorModelManager = /** @class */ (function (_super) {
  73537. __extends(EditorModelManager, _super);
  73538. function EditorModelManager(proxy, modelService, keepIdleModels) {
  73539. var _this = _super.call(this) || this;
  73540. _this._syncedModels = Object.create(null);
  73541. _this._syncedModelsLastUsedTime = Object.create(null);
  73542. _this._proxy = proxy;
  73543. _this._modelService = modelService;
  73544. if (!keepIdleModels) {
  73545. var timer = new async_1.IntervalTimer();
  73546. timer.cancelAndSet(function () { return _this._checkStopModelSync(); }, Math.round(STOP_SYNC_MODEL_DELTA_TIME_MS / 2));
  73547. _this._register(timer);
  73548. }
  73549. return _this;
  73550. }
  73551. EditorModelManager.prototype.dispose = function () {
  73552. for (var modelUrl in this._syncedModels) {
  73553. lifecycle_1.dispose(this._syncedModels[modelUrl]);
  73554. }
  73555. this._syncedModels = Object.create(null);
  73556. this._syncedModelsLastUsedTime = Object.create(null);
  73557. _super.prototype.dispose.call(this);
  73558. };
  73559. EditorModelManager.prototype.ensureSyncedResources = function (resources) {
  73560. for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
  73561. var resource = resources_1[_i];
  73562. var resourceStr = resource.toString();
  73563. if (!this._syncedModels[resourceStr]) {
  73564. this._beginModelSync(resource);
  73565. }
  73566. if (this._syncedModels[resourceStr]) {
  73567. this._syncedModelsLastUsedTime[resourceStr] = (new Date()).getTime();
  73568. }
  73569. }
  73570. };
  73571. EditorModelManager.prototype._checkStopModelSync = function () {
  73572. var currentTime = (new Date()).getTime();
  73573. var toRemove = [];
  73574. for (var modelUrl in this._syncedModelsLastUsedTime) {
  73575. var elapsedTime = currentTime - this._syncedModelsLastUsedTime[modelUrl];
  73576. if (elapsedTime > STOP_SYNC_MODEL_DELTA_TIME_MS) {
  73577. toRemove.push(modelUrl);
  73578. }
  73579. }
  73580. for (var _i = 0, toRemove_1 = toRemove; _i < toRemove_1.length; _i++) {
  73581. var e = toRemove_1[_i];
  73582. this._stopModelSync(e);
  73583. }
  73584. };
  73585. EditorModelManager.prototype._beginModelSync = function (resource) {
  73586. var _this = this;
  73587. var model = this._modelService.getModel(resource);
  73588. if (!model) {
  73589. return;
  73590. }
  73591. if (model.isTooLargeForSyncing()) {
  73592. return;
  73593. }
  73594. var modelUrl = resource.toString();
  73595. this._proxy.acceptNewModel({
  73596. url: model.uri.toString(),
  73597. lines: model.getLinesContent(),
  73598. EOL: model.getEOL(),
  73599. versionId: model.getVersionId()
  73600. });
  73601. var toDispose = new lifecycle_1.DisposableStore();
  73602. toDispose.add(model.onDidChangeContent(function (e) {
  73603. _this._proxy.acceptModelChanged(modelUrl.toString(), e);
  73604. }));
  73605. toDispose.add(model.onWillDispose(function () {
  73606. _this._stopModelSync(modelUrl);
  73607. }));
  73608. toDispose.add(lifecycle_1.toDisposable(function () {
  73609. _this._proxy.acceptRemovedModel(modelUrl);
  73610. }));
  73611. this._syncedModels[modelUrl] = toDispose;
  73612. };
  73613. EditorModelManager.prototype._stopModelSync = function (modelUrl) {
  73614. var toDispose = this._syncedModels[modelUrl];
  73615. delete this._syncedModels[modelUrl];
  73616. delete this._syncedModelsLastUsedTime[modelUrl];
  73617. lifecycle_1.dispose(toDispose);
  73618. };
  73619. return EditorModelManager;
  73620. }(lifecycle_1.Disposable));
  73621. var SynchronousWorkerClient = /** @class */ (function () {
  73622. function SynchronousWorkerClient(instance) {
  73623. this._instance = instance;
  73624. this._proxyObj = Promise.resolve(this._instance);
  73625. }
  73626. SynchronousWorkerClient.prototype.dispose = function () {
  73627. this._instance.dispose();
  73628. };
  73629. SynchronousWorkerClient.prototype.getProxyObject = function () {
  73630. return this._proxyObj;
  73631. };
  73632. return SynchronousWorkerClient;
  73633. }());
  73634. var EditorWorkerHost = /** @class */ (function () {
  73635. function EditorWorkerHost(workerClient) {
  73636. this._workerClient = workerClient;
  73637. }
  73638. // foreign host request
  73639. EditorWorkerHost.prototype.fhr = function (method, args) {
  73640. return this._workerClient.fhr(method, args);
  73641. };
  73642. return EditorWorkerHost;
  73643. }());
  73644. exports.EditorWorkerHost = EditorWorkerHost;
  73645. var EditorWorkerClient = /** @class */ (function (_super) {
  73646. __extends(EditorWorkerClient, _super);
  73647. function EditorWorkerClient(modelService, keepIdleModels, label) {
  73648. var _this = _super.call(this) || this;
  73649. _this._modelService = modelService;
  73650. _this._keepIdleModels = keepIdleModels;
  73651. _this._workerFactory = new defaultWorkerFactory_1.DefaultWorkerFactory(label);
  73652. _this._worker = null;
  73653. _this._modelManager = null;
  73654. return _this;
  73655. }
  73656. // foreign host request
  73657. EditorWorkerClient.prototype.fhr = function (method, args) {
  73658. throw new Error("Not implemented!");
  73659. };
  73660. EditorWorkerClient.prototype._getOrCreateWorker = function () {
  73661. if (!this._worker) {
  73662. try {
  73663. this._worker = this._register(new simpleWorker_1.SimpleWorkerClient(this._workerFactory, 'vs/editor/common/services/editorSimpleWorker', new EditorWorkerHost(this)));
  73664. }
  73665. catch (err) {
  73666. simpleWorker_1.logOnceWebWorkerWarning(err);
  73667. this._worker = new SynchronousWorkerClient(new editorSimpleWorker_1.EditorSimpleWorker(new EditorWorkerHost(this), null));
  73668. }
  73669. }
  73670. return this._worker;
  73671. };
  73672. EditorWorkerClient.prototype._getProxy = function () {
  73673. var _this = this;
  73674. return this._getOrCreateWorker().getProxyObject().then(undefined, function (err) {
  73675. simpleWorker_1.logOnceWebWorkerWarning(err);
  73676. _this._worker = new SynchronousWorkerClient(new editorSimpleWorker_1.EditorSimpleWorker(new EditorWorkerHost(_this), null));
  73677. return _this._getOrCreateWorker().getProxyObject();
  73678. });
  73679. };
  73680. EditorWorkerClient.prototype._getOrCreateModelManager = function (proxy) {
  73681. if (!this._modelManager) {
  73682. this._modelManager = this._register(new EditorModelManager(proxy, this._modelService, this._keepIdleModels));
  73683. }
  73684. return this._modelManager;
  73685. };
  73686. EditorWorkerClient.prototype._withSyncedResources = function (resources) {
  73687. var _this = this;
  73688. return this._getProxy().then(function (proxy) {
  73689. _this._getOrCreateModelManager(proxy).ensureSyncedResources(resources);
  73690. return proxy;
  73691. });
  73692. };
  73693. EditorWorkerClient.prototype.computeDiff = function (original, modified, ignoreTrimWhitespace, maxComputationTime) {
  73694. return this._withSyncedResources([original, modified]).then(function (proxy) {
  73695. return proxy.computeDiff(original.toString(), modified.toString(), ignoreTrimWhitespace, maxComputationTime);
  73696. });
  73697. };
  73698. EditorWorkerClient.prototype.computeMoreMinimalEdits = function (resource, edits) {
  73699. return this._withSyncedResources([resource]).then(function (proxy) {
  73700. return proxy.computeMoreMinimalEdits(resource.toString(), edits);
  73701. });
  73702. };
  73703. EditorWorkerClient.prototype.computeLinks = function (resource) {
  73704. return this._withSyncedResources([resource]).then(function (proxy) {
  73705. return proxy.computeLinks(resource.toString());
  73706. });
  73707. };
  73708. EditorWorkerClient.prototype.textualSuggest = function (resource, position) {
  73709. var _this = this;
  73710. return this._withSyncedResources([resource]).then(function (proxy) {
  73711. var model = _this._modelService.getModel(resource);
  73712. if (!model) {
  73713. return null;
  73714. }
  73715. var wordDefRegExp = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getWordDefinition(model.getLanguageIdentifier().id);
  73716. var wordDef = wordDefRegExp.source;
  73717. var wordDefFlags = strings_1.regExpFlags(wordDefRegExp);
  73718. return proxy.textualSuggest(resource.toString(), position, wordDef, wordDefFlags);
  73719. });
  73720. };
  73721. EditorWorkerClient.prototype.computeWordRanges = function (resource, range) {
  73722. var _this = this;
  73723. return this._withSyncedResources([resource]).then(function (proxy) {
  73724. var model = _this._modelService.getModel(resource);
  73725. if (!model) {
  73726. return Promise.resolve(null);
  73727. }
  73728. var wordDefRegExp = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getWordDefinition(model.getLanguageIdentifier().id);
  73729. var wordDef = wordDefRegExp.source;
  73730. var wordDefFlags = strings_1.regExpFlags(wordDefRegExp);
  73731. return proxy.computeWordRanges(resource.toString(), range, wordDef, wordDefFlags);
  73732. });
  73733. };
  73734. EditorWorkerClient.prototype.navigateValueSet = function (resource, range, up) {
  73735. var _this = this;
  73736. return this._withSyncedResources([resource]).then(function (proxy) {
  73737. var model = _this._modelService.getModel(resource);
  73738. if (!model) {
  73739. return null;
  73740. }
  73741. var wordDefRegExp = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getWordDefinition(model.getLanguageIdentifier().id);
  73742. var wordDef = wordDefRegExp.source;
  73743. var wordDefFlags = strings_1.regExpFlags(wordDefRegExp);
  73744. return proxy.navigateValueSet(resource.toString(), range, up, wordDef, wordDefFlags);
  73745. });
  73746. };
  73747. return EditorWorkerClient;
  73748. }(lifecycle_1.Disposable));
  73749. exports.EditorWorkerClient = EditorWorkerClient;
  73750. });
  73751. /*---------------------------------------------------------------------------------------------
  73752. * Copyright (c) Microsoft Corporation. All rights reserved.
  73753. * Licensed under the MIT License. See License.txt in the project root for license information.
  73754. *--------------------------------------------------------------------------------------------*/
  73755. define(__m[507/*vs/editor/common/services/webWorker*/], __M([0/*require*/,1/*exports*/,219/*vs/editor/common/services/editorWorkerServiceImpl*/,21/*vs/base/common/types*/]), function (require, exports, editorWorkerServiceImpl_1, types) {
  73756. "use strict";
  73757. Object.defineProperty(exports, "__esModule", { value: true });
  73758. /**
  73759. * Create a new web worker that has model syncing capabilities built in.
  73760. * Specify an AMD module to load that will `create` an object that will be proxied.
  73761. */
  73762. function createWebWorker(modelService, opts) {
  73763. return new MonacoWebWorkerImpl(modelService, opts);
  73764. }
  73765. exports.createWebWorker = createWebWorker;
  73766. var MonacoWebWorkerImpl = /** @class */ (function (_super) {
  73767. __extends(MonacoWebWorkerImpl, _super);
  73768. function MonacoWebWorkerImpl(modelService, opts) {
  73769. var _this = _super.call(this, modelService, opts.keepIdleModels || false, opts.label) || this;
  73770. _this._foreignModuleId = opts.moduleId;
  73771. _this._foreignModuleCreateData = opts.createData || null;
  73772. _this._foreignModuleHost = opts.host || null;
  73773. _this._foreignProxy = null;
  73774. return _this;
  73775. }
  73776. // foreign host request
  73777. MonacoWebWorkerImpl.prototype.fhr = function (method, args) {
  73778. if (!this._foreignModuleHost || typeof this._foreignModuleHost[method] !== 'function') {
  73779. return Promise.reject(new Error('Missing method ' + method + ' or missing main thread foreign host.'));
  73780. }
  73781. try {
  73782. return Promise.resolve(this._foreignModuleHost[method].apply(this._foreignModuleHost, args));
  73783. }
  73784. catch (e) {
  73785. return Promise.reject(e);
  73786. }
  73787. };
  73788. MonacoWebWorkerImpl.prototype._getForeignProxy = function () {
  73789. var _this = this;
  73790. if (!this._foreignProxy) {
  73791. this._foreignProxy = this._getProxy().then(function (proxy) {
  73792. var foreignHostMethods = _this._foreignModuleHost ? types.getAllMethodNames(_this._foreignModuleHost) : [];
  73793. return proxy.loadForeignModule(_this._foreignModuleId, _this._foreignModuleCreateData, foreignHostMethods).then(function (foreignMethods) {
  73794. _this._foreignModuleCreateData = null;
  73795. var proxyMethodRequest = function (method, args) {
  73796. return proxy.fmr(method, args);
  73797. };
  73798. var createProxyMethod = function (method, proxyMethodRequest) {
  73799. return function () {
  73800. var args = Array.prototype.slice.call(arguments, 0);
  73801. return proxyMethodRequest(method, args);
  73802. };
  73803. };
  73804. var foreignProxy = {};
  73805. for (var _i = 0, foreignMethods_1 = foreignMethods; _i < foreignMethods_1.length; _i++) {
  73806. var foreignMethod = foreignMethods_1[_i];
  73807. foreignProxy[foreignMethod] = createProxyMethod(foreignMethod, proxyMethodRequest);
  73808. }
  73809. return foreignProxy;
  73810. });
  73811. });
  73812. }
  73813. return this._foreignProxy;
  73814. };
  73815. MonacoWebWorkerImpl.prototype.getProxy = function () {
  73816. return this._getForeignProxy();
  73817. };
  73818. MonacoWebWorkerImpl.prototype.withSyncedResources = function (resources) {
  73819. var _this = this;
  73820. return this._withSyncedResources(resources).then(function (_) { return _this.getProxy(); });
  73821. };
  73822. return MonacoWebWorkerImpl;
  73823. }(editorWorkerServiceImpl_1.EditorWorkerClient));
  73824. });
  73825. /*---------------------------------------------------------------------------------------------
  73826. * Copyright (c) Microsoft Corporation. All rights reserved.
  73827. * Licensed under the MIT License. See License.txt in the project root for license information.
  73828. *--------------------------------------------------------------------------------------------*/
  73829. define(__m[72/*vs/platform/markers/common/markers*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/,475/*vs/nls!vs/platform/markers/common/markers*/,112/*vs/base/common/severity*/]), function (require, exports, instantiation_1, nls_1, severity_1) {
  73830. "use strict";
  73831. Object.defineProperty(exports, "__esModule", { value: true });
  73832. var MarkerSeverity;
  73833. (function (MarkerSeverity) {
  73834. MarkerSeverity[MarkerSeverity["Hint"] = 1] = "Hint";
  73835. MarkerSeverity[MarkerSeverity["Info"] = 2] = "Info";
  73836. MarkerSeverity[MarkerSeverity["Warning"] = 4] = "Warning";
  73837. MarkerSeverity[MarkerSeverity["Error"] = 8] = "Error";
  73838. })(MarkerSeverity = exports.MarkerSeverity || (exports.MarkerSeverity = {}));
  73839. (function (MarkerSeverity) {
  73840. function compare(a, b) {
  73841. return b - a;
  73842. }
  73843. MarkerSeverity.compare = compare;
  73844. var _displayStrings = Object.create(null);
  73845. _displayStrings[MarkerSeverity.Error] = nls_1.localize(0, null);
  73846. _displayStrings[MarkerSeverity.Warning] = nls_1.localize(1, null);
  73847. _displayStrings[MarkerSeverity.Info] = nls_1.localize(2, null);
  73848. function toString(a) {
  73849. return _displayStrings[a] || '';
  73850. }
  73851. MarkerSeverity.toString = toString;
  73852. function fromSeverity(severity) {
  73853. switch (severity) {
  73854. case severity_1.default.Error: return MarkerSeverity.Error;
  73855. case severity_1.default.Warning: return MarkerSeverity.Warning;
  73856. case severity_1.default.Info: return MarkerSeverity.Info;
  73857. case severity_1.default.Ignore: return MarkerSeverity.Hint;
  73858. }
  73859. }
  73860. MarkerSeverity.fromSeverity = fromSeverity;
  73861. function toSeverity(severity) {
  73862. switch (severity) {
  73863. case MarkerSeverity.Error: return severity_1.default.Error;
  73864. case MarkerSeverity.Warning: return severity_1.default.Warning;
  73865. case MarkerSeverity.Info: return severity_1.default.Info;
  73866. case MarkerSeverity.Hint: return severity_1.default.Ignore;
  73867. }
  73868. }
  73869. MarkerSeverity.toSeverity = toSeverity;
  73870. })(MarkerSeverity = exports.MarkerSeverity || (exports.MarkerSeverity = {}));
  73871. var IMarkerData;
  73872. (function (IMarkerData) {
  73873. var emptyString = '';
  73874. function makeKey(markerData) {
  73875. return makeKeyOptionalMessage(markerData, true);
  73876. }
  73877. IMarkerData.makeKey = makeKey;
  73878. function makeKeyOptionalMessage(markerData, useMessage) {
  73879. var result = [emptyString];
  73880. if (markerData.source) {
  73881. result.push(markerData.source.replace('¦', '\¦'));
  73882. }
  73883. else {
  73884. result.push(emptyString);
  73885. }
  73886. if (markerData.code) {
  73887. if (typeof markerData.code === 'string') {
  73888. result.push(markerData.code.replace('¦', '\¦'));
  73889. }
  73890. else {
  73891. result.push(markerData.code.value.replace('¦', '\¦'));
  73892. }
  73893. }
  73894. else {
  73895. result.push(emptyString);
  73896. }
  73897. if (markerData.severity !== undefined && markerData.severity !== null) {
  73898. result.push(MarkerSeverity.toString(markerData.severity));
  73899. }
  73900. else {
  73901. result.push(emptyString);
  73902. }
  73903. // Modifed to not include the message as part of the marker key to work around
  73904. // https://github.com/microsoft/vscode/issues/77475
  73905. if (markerData.message && useMessage) {
  73906. result.push(markerData.message.replace('¦', '\¦'));
  73907. }
  73908. else {
  73909. result.push(emptyString);
  73910. }
  73911. if (markerData.startLineNumber !== undefined && markerData.startLineNumber !== null) {
  73912. result.push(markerData.startLineNumber.toString());
  73913. }
  73914. else {
  73915. result.push(emptyString);
  73916. }
  73917. if (markerData.startColumn !== undefined && markerData.startColumn !== null) {
  73918. result.push(markerData.startColumn.toString());
  73919. }
  73920. else {
  73921. result.push(emptyString);
  73922. }
  73923. if (markerData.endLineNumber !== undefined && markerData.endLineNumber !== null) {
  73924. result.push(markerData.endLineNumber.toString());
  73925. }
  73926. else {
  73927. result.push(emptyString);
  73928. }
  73929. if (markerData.endColumn !== undefined && markerData.endColumn !== null) {
  73930. result.push(markerData.endColumn.toString());
  73931. }
  73932. else {
  73933. result.push(emptyString);
  73934. }
  73935. result.push(emptyString);
  73936. return result.join('¦');
  73937. }
  73938. IMarkerData.makeKeyOptionalMessage = makeKeyOptionalMessage;
  73939. })(IMarkerData = exports.IMarkerData || (exports.IMarkerData = {}));
  73940. exports.IMarkerService = instantiation_1.createDecorator('markerService');
  73941. });
  73942. /*---------------------------------------------------------------------------------------------
  73943. * Copyright (c) Microsoft Corporation. All rights reserved.
  73944. * Licensed under the MIT License. See License.txt in the project root for license information.
  73945. *--------------------------------------------------------------------------------------------*/
  73946. define(__m[508/*vs/platform/markers/common/markerService*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,46/*vs/base/common/network*/,21/*vs/base/common/types*/,4/*vs/base/common/event*/,72/*vs/platform/markers/common/markers*/]), function (require, exports, arrays_1, network_1, types_1, event_1, markers_1) {
  73947. "use strict";
  73948. Object.defineProperty(exports, "__esModule", { value: true });
  73949. var MapMap;
  73950. (function (MapMap) {
  73951. function get(map, key1, key2) {
  73952. if (map[key1]) {
  73953. return map[key1][key2];
  73954. }
  73955. return undefined;
  73956. }
  73957. MapMap.get = get;
  73958. function set(map, key1, key2, value) {
  73959. if (!map[key1]) {
  73960. map[key1] = Object.create(null);
  73961. }
  73962. map[key1][key2] = value;
  73963. }
  73964. MapMap.set = set;
  73965. function remove(map, key1, key2) {
  73966. if (map[key1] && map[key1][key2]) {
  73967. delete map[key1][key2];
  73968. if (types_1.isEmptyObject(map[key1])) {
  73969. delete map[key1];
  73970. }
  73971. return true;
  73972. }
  73973. return false;
  73974. }
  73975. MapMap.remove = remove;
  73976. })(MapMap || (MapMap = {}));
  73977. var MarkerStats = /** @class */ (function () {
  73978. function MarkerStats(service) {
  73979. this.errors = 0;
  73980. this.infos = 0;
  73981. this.warnings = 0;
  73982. this.unknowns = 0;
  73983. this._data = Object.create(null);
  73984. this._service = service;
  73985. this._subscription = service.onMarkerChanged(this._update, this);
  73986. }
  73987. MarkerStats.prototype.dispose = function () {
  73988. this._subscription.dispose();
  73989. this._data = undefined;
  73990. };
  73991. MarkerStats.prototype._update = function (resources) {
  73992. if (!this._data) {
  73993. return;
  73994. }
  73995. for (var _i = 0, resources_1 = resources; _i < resources_1.length; _i++) {
  73996. var resource = resources_1[_i];
  73997. var key = resource.toString();
  73998. var oldStats = this._data[key];
  73999. if (oldStats) {
  74000. this._substract(oldStats);
  74001. }
  74002. var newStats = this._resourceStats(resource);
  74003. this._add(newStats);
  74004. this._data[key] = newStats;
  74005. }
  74006. };
  74007. MarkerStats.prototype._resourceStats = function (resource) {
  74008. var result = { errors: 0, warnings: 0, infos: 0, unknowns: 0 };
  74009. // TODO this is a hack
  74010. if (resource.scheme === network_1.Schemas.inMemory || resource.scheme === network_1.Schemas.walkThrough || resource.scheme === network_1.Schemas.walkThroughSnippet) {
  74011. return result;
  74012. }
  74013. for (var _i = 0, _a = this._service.read({ resource: resource }); _i < _a.length; _i++) {
  74014. var severity = _a[_i].severity;
  74015. if (severity === markers_1.MarkerSeverity.Error) {
  74016. result.errors += 1;
  74017. }
  74018. else if (severity === markers_1.MarkerSeverity.Warning) {
  74019. result.warnings += 1;
  74020. }
  74021. else if (severity === markers_1.MarkerSeverity.Info) {
  74022. result.infos += 1;
  74023. }
  74024. else {
  74025. result.unknowns += 1;
  74026. }
  74027. }
  74028. return result;
  74029. };
  74030. MarkerStats.prototype._substract = function (op) {
  74031. this.errors -= op.errors;
  74032. this.warnings -= op.warnings;
  74033. this.infos -= op.infos;
  74034. this.unknowns -= op.unknowns;
  74035. };
  74036. MarkerStats.prototype._add = function (op) {
  74037. this.errors += op.errors;
  74038. this.warnings += op.warnings;
  74039. this.infos += op.infos;
  74040. this.unknowns += op.unknowns;
  74041. };
  74042. return MarkerStats;
  74043. }());
  74044. var MarkerService = /** @class */ (function () {
  74045. function MarkerService() {
  74046. this._onMarkerChanged = new event_1.Emitter();
  74047. this._onMarkerChangedEvent = event_1.Event.debounce(this._onMarkerChanged.event, MarkerService._debouncer, 0);
  74048. this._byResource = Object.create(null);
  74049. this._byOwner = Object.create(null);
  74050. this._stats = new MarkerStats(this);
  74051. }
  74052. MarkerService.prototype.dispose = function () {
  74053. this._stats.dispose();
  74054. };
  74055. Object.defineProperty(MarkerService.prototype, "onMarkerChanged", {
  74056. get: function () {
  74057. return this._onMarkerChangedEvent;
  74058. },
  74059. enumerable: true,
  74060. configurable: true
  74061. });
  74062. MarkerService.prototype.remove = function (owner, resources) {
  74063. for (var _i = 0, _a = resources || []; _i < _a.length; _i++) {
  74064. var resource = _a[_i];
  74065. this.changeOne(owner, resource, []);
  74066. }
  74067. };
  74068. MarkerService.prototype.changeOne = function (owner, resource, markerData) {
  74069. if (arrays_1.isFalsyOrEmpty(markerData)) {
  74070. // remove marker for this (owner,resource)-tuple
  74071. var a = MapMap.remove(this._byResource, resource.toString(), owner);
  74072. var b = MapMap.remove(this._byOwner, owner, resource.toString());
  74073. if (a !== b) {
  74074. throw new Error('invalid marker service state');
  74075. }
  74076. if (a && b) {
  74077. this._onMarkerChanged.fire([resource]);
  74078. }
  74079. }
  74080. else {
  74081. // insert marker for this (owner,resource)-tuple
  74082. var markers = [];
  74083. for (var _i = 0, markerData_1 = markerData; _i < markerData_1.length; _i++) {
  74084. var data = markerData_1[_i];
  74085. var marker = MarkerService._toMarker(owner, resource, data);
  74086. if (marker) {
  74087. markers.push(marker);
  74088. }
  74089. }
  74090. MapMap.set(this._byResource, resource.toString(), owner, markers);
  74091. MapMap.set(this._byOwner, owner, resource.toString(), markers);
  74092. this._onMarkerChanged.fire([resource]);
  74093. }
  74094. };
  74095. MarkerService._toMarker = function (owner, resource, data) {
  74096. var code = data.code, severity = data.severity, message = data.message, source = data.source, startLineNumber = data.startLineNumber, startColumn = data.startColumn, endLineNumber = data.endLineNumber, endColumn = data.endColumn, relatedInformation = data.relatedInformation, tags = data.tags;
  74097. if (!message) {
  74098. return undefined;
  74099. }
  74100. // santize data
  74101. startLineNumber = startLineNumber > 0 ? startLineNumber : 1;
  74102. startColumn = startColumn > 0 ? startColumn : 1;
  74103. endLineNumber = endLineNumber >= startLineNumber ? endLineNumber : startLineNumber;
  74104. endColumn = endColumn > 0 ? endColumn : startColumn;
  74105. return {
  74106. resource: resource,
  74107. owner: owner,
  74108. code: code,
  74109. severity: severity,
  74110. message: message,
  74111. source: source,
  74112. startLineNumber: startLineNumber,
  74113. startColumn: startColumn,
  74114. endLineNumber: endLineNumber,
  74115. endColumn: endColumn,
  74116. relatedInformation: relatedInformation,
  74117. tags: tags,
  74118. };
  74119. };
  74120. MarkerService.prototype.read = function (filter) {
  74121. if (filter === void 0) { filter = Object.create(null); }
  74122. var owner = filter.owner, resource = filter.resource, severities = filter.severities, take = filter.take;
  74123. if (!take || take < 0) {
  74124. take = -1;
  74125. }
  74126. if (owner && resource) {
  74127. // exactly one owner AND resource
  74128. var data = MapMap.get(this._byResource, resource.toString(), owner);
  74129. if (!data) {
  74130. return [];
  74131. }
  74132. else {
  74133. var result = [];
  74134. for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
  74135. var marker = data_1[_i];
  74136. if (MarkerService._accept(marker, severities)) {
  74137. var newLen = result.push(marker);
  74138. if (take > 0 && newLen === take) {
  74139. break;
  74140. }
  74141. }
  74142. }
  74143. return result;
  74144. }
  74145. }
  74146. else if (!owner && !resource) {
  74147. // all
  74148. var result = [];
  74149. for (var key1 in this._byResource) {
  74150. for (var key2 in this._byResource[key1]) {
  74151. for (var _a = 0, _b = this._byResource[key1][key2]; _a < _b.length; _a++) {
  74152. var data = _b[_a];
  74153. if (MarkerService._accept(data, severities)) {
  74154. var newLen = result.push(data);
  74155. if (take > 0 && newLen === take) {
  74156. return result;
  74157. }
  74158. }
  74159. }
  74160. }
  74161. }
  74162. return result;
  74163. }
  74164. else {
  74165. // of one resource OR owner
  74166. var map = owner
  74167. ? this._byOwner[owner]
  74168. : resource ? this._byResource[resource.toString()] : undefined;
  74169. if (!map) {
  74170. return [];
  74171. }
  74172. var result = [];
  74173. for (var key in map) {
  74174. for (var _c = 0, _d = map[key]; _c < _d.length; _c++) {
  74175. var data = _d[_c];
  74176. if (MarkerService._accept(data, severities)) {
  74177. var newLen = result.push(data);
  74178. if (take > 0 && newLen === take) {
  74179. return result;
  74180. }
  74181. }
  74182. }
  74183. }
  74184. return result;
  74185. }
  74186. };
  74187. MarkerService._accept = function (marker, severities) {
  74188. return severities === undefined || (severities & marker.severity) === marker.severity;
  74189. };
  74190. MarkerService._debouncer = function (last, event) {
  74191. if (!last) {
  74192. MarkerService._dedupeMap = Object.create(null);
  74193. last = [];
  74194. }
  74195. for (var _i = 0, event_2 = event; _i < event_2.length; _i++) {
  74196. var uri = event_2[_i];
  74197. if (MarkerService._dedupeMap[uri.toString()] === undefined) {
  74198. MarkerService._dedupeMap[uri.toString()] = true;
  74199. last.push(uri);
  74200. }
  74201. }
  74202. return last;
  74203. };
  74204. return MarkerService;
  74205. }());
  74206. exports.MarkerService = MarkerService;
  74207. });
  74208. /*---------------------------------------------------------------------------------------------
  74209. * Copyright (c) Microsoft Corporation. All rights reserved.
  74210. * Licensed under the MIT License. See License.txt in the project root for license information.
  74211. *--------------------------------------------------------------------------------------------*/
  74212. define(__m[35/*vs/platform/notification/common/notification*/], __M([0/*require*/,1/*exports*/,112/*vs/base/common/severity*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, severity_1, instantiation_1) {
  74213. "use strict";
  74214. Object.defineProperty(exports, "__esModule", { value: true });
  74215. exports.Severity = severity_1.default;
  74216. exports.INotificationService = instantiation_1.createDecorator('notificationService');
  74217. var NoOpNotification = /** @class */ (function () {
  74218. function NoOpNotification() {
  74219. }
  74220. return NoOpNotification;
  74221. }());
  74222. exports.NoOpNotification = NoOpNotification;
  74223. });
  74224. /*---------------------------------------------------------------------------------------------
  74225. * Copyright (c) Microsoft Corporation. All rights reserved.
  74226. * Licensed under the MIT License. See License.txt in the project root for license information.
  74227. *--------------------------------------------------------------------------------------------*/
  74228. define(__m[51/*vs/platform/opener/common/opener*/], __M([0/*require*/,1/*exports*/,25/*vs/base/common/uri*/,11/*vs/platform/instantiation/common/instantiation*/,2/*vs/base/common/lifecycle*/,5/*vs/base/common/strings*/]), function (require, exports, uri_1, instantiation_1, lifecycle_1, strings_1) {
  74229. "use strict";
  74230. Object.defineProperty(exports, "__esModule", { value: true });
  74231. exports.IOpenerService = instantiation_1.createDecorator('openerService');
  74232. exports.NullOpenerService = Object.freeze({
  74233. _serviceBrand: undefined,
  74234. registerOpener: function () { return lifecycle_1.Disposable.None; },
  74235. registerValidator: function () { return lifecycle_1.Disposable.None; },
  74236. registerExternalUriResolver: function () { return lifecycle_1.Disposable.None; },
  74237. setExternalOpener: function () { },
  74238. open: function () {
  74239. return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
  74240. return [2 /*return*/, false];
  74241. }); });
  74242. },
  74243. resolveExternalUri: function (uri) {
  74244. return __awaiter(this, void 0, void 0, function () { return __generator(this, function (_a) {
  74245. return [2 /*return*/, { resolved: uri, dispose: function () { } }];
  74246. }); });
  74247. },
  74248. });
  74249. function matchesScheme(target, scheme) {
  74250. if (uri_1.URI.isUri(target)) {
  74251. return strings_1.equalsIgnoreCase(target.scheme, scheme);
  74252. }
  74253. else {
  74254. return strings_1.startsWithIgnoreCase(target, scheme + ':');
  74255. }
  74256. }
  74257. exports.matchesScheme = matchesScheme;
  74258. });
  74259. /*---------------------------------------------------------------------------------------------
  74260. * Copyright (c) Microsoft Corporation. All rights reserved.
  74261. * Licensed under the MIT License. See License.txt in the project root for license information.
  74262. *--------------------------------------------------------------------------------------------*/
  74263. var __spreadArrays = (this && this.__spreadArrays) || function () {
  74264. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  74265. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  74266. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  74267. r[k] = a[j];
  74268. return r;
  74269. };
  74270. define(__m[509/*vs/editor/browser/services/openerService*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,76/*vs/base/common/linkedList*/,180/*vs/base/common/marshalling*/,46/*vs/base/common/network*/,39/*vs/base/common/resources*/,25/*vs/base/common/uri*/,32/*vs/editor/browser/services/codeEditorService*/,29/*vs/platform/commands/common/commands*/,51/*vs/platform/opener/common/opener*/,478/*vs/platform/editor/common/editor*/]), function (require, exports, dom, linkedList_1, marshalling_1, network_1, resources_1, uri_1, codeEditorService_1, commands_1, opener_1, editor_1) {
  74271. "use strict";
  74272. Object.defineProperty(exports, "__esModule", { value: true });
  74273. var CommandOpener = /** @class */ (function () {
  74274. function CommandOpener(_commandService) {
  74275. this._commandService = _commandService;
  74276. }
  74277. CommandOpener.prototype.open = function (target) {
  74278. return __awaiter(this, void 0, void 0, function () {
  74279. var args;
  74280. var _a;
  74281. return __generator(this, function (_b) {
  74282. switch (_b.label) {
  74283. case 0:
  74284. if (!opener_1.matchesScheme(target, network_1.Schemas.command)) {
  74285. return [2 /*return*/, false];
  74286. }
  74287. // run command or bail out if command isn't known
  74288. if (typeof target === 'string') {
  74289. target = uri_1.URI.parse(target);
  74290. }
  74291. if (!commands_1.CommandsRegistry.getCommand(target.path)) {
  74292. throw new Error("command '" + target.path + "' NOT known");
  74293. }
  74294. args = [];
  74295. try {
  74296. args = marshalling_1.parse(decodeURIComponent(target.query));
  74297. }
  74298. catch (_c) {
  74299. // ignore and retry
  74300. try {
  74301. args = marshalling_1.parse(target.query);
  74302. }
  74303. catch (_d) {
  74304. // ignore error
  74305. }
  74306. }
  74307. if (!Array.isArray(args)) {
  74308. args = [args];
  74309. }
  74310. return [4 /*yield*/, (_a = this._commandService).executeCommand.apply(_a, __spreadArrays([target.path], args))];
  74311. case 1:
  74312. _b.sent();
  74313. return [2 /*return*/, true];
  74314. }
  74315. });
  74316. });
  74317. };
  74318. CommandOpener = __decorate([
  74319. __param(0, commands_1.ICommandService)
  74320. ], CommandOpener);
  74321. return CommandOpener;
  74322. }());
  74323. var EditorOpener = /** @class */ (function () {
  74324. function EditorOpener(_editorService) {
  74325. this._editorService = _editorService;
  74326. }
  74327. EditorOpener.prototype.open = function (target, options) {
  74328. return __awaiter(this, void 0, void 0, function () {
  74329. var selection, match;
  74330. return __generator(this, function (_a) {
  74331. switch (_a.label) {
  74332. case 0:
  74333. if (typeof target === 'string') {
  74334. target = uri_1.URI.parse(target);
  74335. }
  74336. selection = undefined;
  74337. match = /^L?(\d+)(?:,(\d+))?/.exec(target.fragment);
  74338. if (match) {
  74339. // support file:///some/file.js#73,84
  74340. // support file:///some/file.js#L73
  74341. selection = {
  74342. startLineNumber: parseInt(match[1]),
  74343. startColumn: match[2] ? parseInt(match[2]) : 1
  74344. };
  74345. // remove fragment
  74346. target = target.with({ fragment: '' });
  74347. }
  74348. if (target.scheme === network_1.Schemas.file) {
  74349. target = resources_1.normalizePath(target); // workaround for non-normalized paths (https://github.com/Microsoft/vscode/issues/12954)
  74350. }
  74351. return [4 /*yield*/, this._editorService.openCodeEditor({ resource: target, options: { selection: selection, context: (options === null || options === void 0 ? void 0 : options.fromUserGesture) ? editor_1.EditorOpenContext.USER : editor_1.EditorOpenContext.API } }, this._editorService.getFocusedCodeEditor(), options === null || options === void 0 ? void 0 : options.openToSide)];
  74352. case 1:
  74353. _a.sent();
  74354. return [2 /*return*/, true];
  74355. }
  74356. });
  74357. });
  74358. };
  74359. EditorOpener = __decorate([
  74360. __param(0, codeEditorService_1.ICodeEditorService)
  74361. ], EditorOpener);
  74362. return EditorOpener;
  74363. }());
  74364. var OpenerService = /** @class */ (function () {
  74365. function OpenerService(editorService, commandService) {
  74366. var _this = this;
  74367. this._openers = new linkedList_1.LinkedList();
  74368. this._validators = new linkedList_1.LinkedList();
  74369. this._resolvers = new linkedList_1.LinkedList();
  74370. // Default external opener is going through window.open()
  74371. this._externalOpener = {
  74372. openExternal: function (href) {
  74373. dom.windowOpenNoOpener(href);
  74374. return Promise.resolve(true);
  74375. }
  74376. };
  74377. // Default opener: maito, http(s), command, and catch-all-editors
  74378. this._openers.push({
  74379. open: function (target, options) { return __awaiter(_this, void 0, void 0, function () {
  74380. return __generator(this, function (_a) {
  74381. switch (_a.label) {
  74382. case 0:
  74383. if (!((options === null || options === void 0 ? void 0 : options.openExternal) || opener_1.matchesScheme(target, network_1.Schemas.mailto) || opener_1.matchesScheme(target, network_1.Schemas.http) || opener_1.matchesScheme(target, network_1.Schemas.https))) return [3 /*break*/, 2];
  74384. // open externally
  74385. return [4 /*yield*/, this._doOpenExternal(target, options)];
  74386. case 1:
  74387. // open externally
  74388. _a.sent();
  74389. return [2 /*return*/, true];
  74390. case 2: return [2 /*return*/, false];
  74391. }
  74392. });
  74393. }); }
  74394. });
  74395. this._openers.push(new CommandOpener(commandService));
  74396. this._openers.push(new EditorOpener(editorService));
  74397. }
  74398. OpenerService.prototype.open = function (target, options) {
  74399. return __awaiter(this, void 0, void 0, function () {
  74400. var _i, _a, validator, _b, _c, opener_2, handled;
  74401. return __generator(this, function (_d) {
  74402. switch (_d.label) {
  74403. case 0:
  74404. _i = 0, _a = this._validators.toArray();
  74405. _d.label = 1;
  74406. case 1:
  74407. if (!(_i < _a.length)) return [3 /*break*/, 4];
  74408. validator = _a[_i];
  74409. return [4 /*yield*/, validator.shouldOpen(target)];
  74410. case 2:
  74411. if (!(_d.sent())) {
  74412. return [2 /*return*/, false];
  74413. }
  74414. _d.label = 3;
  74415. case 3:
  74416. _i++;
  74417. return [3 /*break*/, 1];
  74418. case 4:
  74419. _b = 0, _c = this._openers.toArray();
  74420. _d.label = 5;
  74421. case 5:
  74422. if (!(_b < _c.length)) return [3 /*break*/, 8];
  74423. opener_2 = _c[_b];
  74424. return [4 /*yield*/, opener_2.open(target, options)];
  74425. case 6:
  74426. handled = _d.sent();
  74427. if (handled) {
  74428. return [2 /*return*/, true];
  74429. }
  74430. _d.label = 7;
  74431. case 7:
  74432. _b++;
  74433. return [3 /*break*/, 5];
  74434. case 8: return [2 /*return*/, false];
  74435. }
  74436. });
  74437. });
  74438. };
  74439. OpenerService.prototype.resolveExternalUri = function (resource, options) {
  74440. return __awaiter(this, void 0, void 0, function () {
  74441. var _i, _a, resolver, result;
  74442. return __generator(this, function (_b) {
  74443. switch (_b.label) {
  74444. case 0:
  74445. _i = 0, _a = this._resolvers.toArray();
  74446. _b.label = 1;
  74447. case 1:
  74448. if (!(_i < _a.length)) return [3 /*break*/, 4];
  74449. resolver = _a[_i];
  74450. return [4 /*yield*/, resolver.resolveExternalUri(resource, options)];
  74451. case 2:
  74452. result = _b.sent();
  74453. if (result) {
  74454. return [2 /*return*/, result];
  74455. }
  74456. _b.label = 3;
  74457. case 3:
  74458. _i++;
  74459. return [3 /*break*/, 1];
  74460. case 4: return [2 /*return*/, { resolved: resource, dispose: function () { } }];
  74461. }
  74462. });
  74463. });
  74464. };
  74465. OpenerService.prototype._doOpenExternal = function (resource, options) {
  74466. return __awaiter(this, void 0, void 0, function () {
  74467. var uri, resolved;
  74468. return __generator(this, function (_a) {
  74469. switch (_a.label) {
  74470. case 0:
  74471. uri = typeof resource === 'string' ? uri_1.URI.parse(resource) : resource;
  74472. return [4 /*yield*/, this.resolveExternalUri(uri, options)];
  74473. case 1:
  74474. resolved = (_a.sent()).resolved;
  74475. if (typeof resource === 'string' && uri.toString() === resolved.toString()) {
  74476. // open the url-string AS IS
  74477. return [2 /*return*/, this._externalOpener.openExternal(resource)];
  74478. }
  74479. else {
  74480. // open URI using the toString(noEncode)+encodeURI-trick
  74481. return [2 /*return*/, this._externalOpener.openExternal(encodeURI(resolved.toString(true)))];
  74482. }
  74483. return [2 /*return*/];
  74484. }
  74485. });
  74486. });
  74487. };
  74488. OpenerService.prototype.dispose = function () {
  74489. this._validators.clear();
  74490. };
  74491. OpenerService = __decorate([
  74492. __param(0, codeEditorService_1.ICodeEditorService),
  74493. __param(1, commands_1.ICommandService)
  74494. ], OpenerService);
  74495. return OpenerService;
  74496. }());
  74497. exports.OpenerService = OpenerService;
  74498. });
  74499. /*---------------------------------------------------------------------------------------------
  74500. * Copyright (c) Microsoft Corporation. All rights reserved.
  74501. * Licensed under the MIT License. See License.txt in the project root for license information.
  74502. *--------------------------------------------------------------------------------------------*/
  74503. define(__m[117/*vs/editor/contrib/markdown/markdownRenderer*/], __M([0/*require*/,1/*exports*/,248/*vs/base/browser/markdownRenderer*/,51/*vs/platform/opener/common/opener*/,71/*vs/editor/common/services/modeService*/,10/*vs/base/common/errors*/,214/*vs/editor/common/modes/textToHtmlTokenizer*/,11/*vs/platform/instantiation/common/instantiation*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,17/*vs/editor/common/modes*/]), function (require, exports, markdownRenderer_1, opener_1, modeService_1, errors_1, textToHtmlTokenizer_1, instantiation_1, event_1, lifecycle_1, modes_1) {
  74504. "use strict";
  74505. Object.defineProperty(exports, "__esModule", { value: true });
  74506. var MarkdownRenderer = /** @class */ (function (_super) {
  74507. __extends(MarkdownRenderer, _super);
  74508. function MarkdownRenderer(_editor, _modeService, _openerService) {
  74509. if (_openerService === void 0) { _openerService = opener_1.NullOpenerService; }
  74510. var _this = _super.call(this) || this;
  74511. _this._editor = _editor;
  74512. _this._modeService = _modeService;
  74513. _this._openerService = _openerService;
  74514. _this._onDidRenderCodeBlock = _this._register(new event_1.Emitter());
  74515. _this.onDidRenderCodeBlock = _this._onDidRenderCodeBlock.event;
  74516. return _this;
  74517. }
  74518. MarkdownRenderer.prototype.getOptions = function (disposeables) {
  74519. var _this = this;
  74520. return {
  74521. codeBlockRenderer: function (languageAlias, value) {
  74522. // In markdown,
  74523. // it is possible that we stumble upon language aliases (e.g.js instead of javascript)
  74524. // it is possible no alias is given in which case we fall back to the current editor lang
  74525. var modeId = null;
  74526. if (languageAlias) {
  74527. modeId = _this._modeService.getModeIdForLanguageName(languageAlias);
  74528. }
  74529. else {
  74530. var model = _this._editor.getModel();
  74531. if (model) {
  74532. modeId = model.getLanguageIdentifier().language;
  74533. }
  74534. }
  74535. _this._modeService.triggerMode(modeId || '');
  74536. return Promise.resolve(true).then(function (_) {
  74537. var promise = modes_1.TokenizationRegistry.getPromise(modeId || '');
  74538. if (promise) {
  74539. return promise.then(function (support) { return textToHtmlTokenizer_1.tokenizeToString(value, support); });
  74540. }
  74541. return textToHtmlTokenizer_1.tokenizeToString(value, undefined);
  74542. }).then(function (code) {
  74543. return "<span style=\"font-family: " + _this._editor.getOption(34 /* fontInfo */).fontFamily + "\">" + code + "</span>";
  74544. });
  74545. },
  74546. codeBlockRenderCallback: function () { return _this._onDidRenderCodeBlock.fire(); },
  74547. actionHandler: {
  74548. callback: function (content) {
  74549. _this._openerService.open(content, { fromUserGesture: true }).catch(errors_1.onUnexpectedError);
  74550. },
  74551. disposeables: disposeables
  74552. }
  74553. };
  74554. };
  74555. MarkdownRenderer.prototype.render = function (markdown) {
  74556. var disposeables = new lifecycle_1.DisposableStore();
  74557. var element;
  74558. if (!markdown) {
  74559. element = document.createElement('span');
  74560. }
  74561. else {
  74562. element = markdownRenderer_1.renderMarkdown(markdown, this.getOptions(disposeables));
  74563. }
  74564. return {
  74565. element: element,
  74566. dispose: function () { return disposeables.dispose(); }
  74567. };
  74568. };
  74569. MarkdownRenderer = __decorate([
  74570. __param(1, modeService_1.IModeService),
  74571. __param(2, instantiation_1.optional(opener_1.IOpenerService))
  74572. ], MarkdownRenderer);
  74573. return MarkdownRenderer;
  74574. }(lifecycle_1.Disposable));
  74575. exports.MarkdownRenderer = MarkdownRenderer;
  74576. });
  74577. /*---------------------------------------------------------------------------------------------
  74578. * Copyright (c) Microsoft Corporation. All rights reserved.
  74579. * Licensed under the MIT License. See License.txt in the project root for license information.
  74580. *--------------------------------------------------------------------------------------------*/
  74581. define(__m[510/*vs/editor/contrib/hover/modesGlyphHover*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,75/*vs/base/common/htmlContent*/,2/*vs/base/common/lifecycle*/,200/*vs/editor/contrib/hover/hoverOperation*/,201/*vs/editor/contrib/hover/hoverWidgets*/,117/*vs/editor/contrib/markdown/markdownRenderer*/,51/*vs/platform/opener/common/opener*/,19/*vs/base/common/arrays*/]), function (require, exports, dom_1, htmlContent_1, lifecycle_1, hoverOperation_1, hoverWidgets_1, markdownRenderer_1, opener_1, arrays_1) {
  74582. "use strict";
  74583. Object.defineProperty(exports, "__esModule", { value: true });
  74584. var MarginComputer = /** @class */ (function () {
  74585. function MarginComputer(editor) {
  74586. this._editor = editor;
  74587. this._lineNumber = -1;
  74588. this._result = [];
  74589. }
  74590. MarginComputer.prototype.setLineNumber = function (lineNumber) {
  74591. this._lineNumber = lineNumber;
  74592. this._result = [];
  74593. };
  74594. MarginComputer.prototype.clearResult = function () {
  74595. this._result = [];
  74596. };
  74597. MarginComputer.prototype.computeSync = function () {
  74598. var toHoverMessage = function (contents) {
  74599. return {
  74600. value: contents
  74601. };
  74602. };
  74603. var lineDecorations = this._editor.getLineDecorations(this._lineNumber);
  74604. var result = [];
  74605. if (!lineDecorations) {
  74606. return result;
  74607. }
  74608. for (var _i = 0, lineDecorations_1 = lineDecorations; _i < lineDecorations_1.length; _i++) {
  74609. var d = lineDecorations_1[_i];
  74610. if (!d.options.glyphMarginClassName) {
  74611. continue;
  74612. }
  74613. var hoverMessage = d.options.glyphMarginHoverMessage;
  74614. if (!hoverMessage || htmlContent_1.isEmptyMarkdownString(hoverMessage)) {
  74615. continue;
  74616. }
  74617. result.push.apply(result, arrays_1.asArray(hoverMessage).map(toHoverMessage));
  74618. }
  74619. return result;
  74620. };
  74621. MarginComputer.prototype.onResult = function (result, isFromSynchronousComputation) {
  74622. this._result = this._result.concat(result);
  74623. };
  74624. MarginComputer.prototype.getResult = function () {
  74625. return this._result;
  74626. };
  74627. MarginComputer.prototype.getResultWithLoadingMessage = function () {
  74628. return this.getResult();
  74629. };
  74630. return MarginComputer;
  74631. }());
  74632. var ModesGlyphHoverWidget = /** @class */ (function (_super) {
  74633. __extends(ModesGlyphHoverWidget, _super);
  74634. function ModesGlyphHoverWidget(editor, modeService, openerService) {
  74635. if (openerService === void 0) { openerService = opener_1.NullOpenerService; }
  74636. var _this = _super.call(this, ModesGlyphHoverWidget.ID, editor) || this;
  74637. _this._renderDisposeables = _this._register(new lifecycle_1.DisposableStore());
  74638. _this._messages = [];
  74639. _this._lastLineNumber = -1;
  74640. _this._markdownRenderer = _this._register(new markdownRenderer_1.MarkdownRenderer(_this._editor, modeService, openerService));
  74641. _this._computer = new MarginComputer(_this._editor);
  74642. _this._hoverOperation = new hoverOperation_1.HoverOperation(_this._computer, function (result) { return _this._withResult(result); }, undefined, function (result) { return _this._withResult(result); }, 300);
  74643. return _this;
  74644. }
  74645. ModesGlyphHoverWidget.prototype.dispose = function () {
  74646. this._hoverOperation.cancel();
  74647. _super.prototype.dispose.call(this);
  74648. };
  74649. ModesGlyphHoverWidget.prototype.onModelDecorationsChanged = function () {
  74650. if (this.isVisible) {
  74651. // The decorations have changed and the hover is visible,
  74652. // we need to recompute the displayed text
  74653. this._hoverOperation.cancel();
  74654. this._computer.clearResult();
  74655. this._hoverOperation.start(0 /* Delayed */);
  74656. }
  74657. };
  74658. ModesGlyphHoverWidget.prototype.startShowingAt = function (lineNumber) {
  74659. if (this._lastLineNumber === lineNumber) {
  74660. // We have to show the widget at the exact same line number as before, so no work is needed
  74661. return;
  74662. }
  74663. this._hoverOperation.cancel();
  74664. this.hide();
  74665. this._lastLineNumber = lineNumber;
  74666. this._computer.setLineNumber(lineNumber);
  74667. this._hoverOperation.start(0 /* Delayed */);
  74668. };
  74669. ModesGlyphHoverWidget.prototype.hide = function () {
  74670. this._lastLineNumber = -1;
  74671. this._hoverOperation.cancel();
  74672. _super.prototype.hide.call(this);
  74673. };
  74674. ModesGlyphHoverWidget.prototype._withResult = function (result) {
  74675. this._messages = result;
  74676. if (this._messages.length > 0) {
  74677. this._renderMessages(this._lastLineNumber, this._messages);
  74678. }
  74679. else {
  74680. this.hide();
  74681. }
  74682. };
  74683. ModesGlyphHoverWidget.prototype._renderMessages = function (lineNumber, messages) {
  74684. this._renderDisposeables.clear();
  74685. var fragment = document.createDocumentFragment();
  74686. for (var _i = 0, messages_1 = messages; _i < messages_1.length; _i++) {
  74687. var msg = messages_1[_i];
  74688. var renderedContents = this._markdownRenderer.render(msg.value);
  74689. this._renderDisposeables.add(renderedContents);
  74690. fragment.appendChild(dom_1.$('div.hover-row', undefined, renderedContents.element));
  74691. }
  74692. this.updateContents(fragment);
  74693. this.showAt(lineNumber);
  74694. };
  74695. ModesGlyphHoverWidget.ID = 'editor.contrib.modesGlyphHoverWidget';
  74696. return ModesGlyphHoverWidget;
  74697. }(hoverWidgets_1.GlyphHoverWidget));
  74698. exports.ModesGlyphHoverWidget = ModesGlyphHoverWidget;
  74699. });
  74700. /*---------------------------------------------------------------------------------------------
  74701. * Copyright (c) Microsoft Corporation. All rights reserved.
  74702. * Licensed under the MIT License. See License.txt in the project root for license information.
  74703. *--------------------------------------------------------------------------------------------*/
  74704. define(__m[73/*vs/platform/progress/common/progress*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  74705. "use strict";
  74706. Object.defineProperty(exports, "__esModule", { value: true });
  74707. exports.IEditorProgressService = instantiation_1.createDecorator('editorProgressService');
  74708. });
  74709. /*---------------------------------------------------------------------------------------------
  74710. * Copyright (c) Microsoft Corporation. All rights reserved.
  74711. * Licensed under the MIT License. See License.txt in the project root for license information.
  74712. *--------------------------------------------------------------------------------------------*/
  74713. define(__m[42/*vs/platform/registry/common/platform*/], __M([0/*require*/,1/*exports*/,21/*vs/base/common/types*/,124/*vs/base/common/assert*/]), function (require, exports, Types, Assert) {
  74714. "use strict";
  74715. Object.defineProperty(exports, "__esModule", { value: true });
  74716. var RegistryImpl = /** @class */ (function () {
  74717. function RegistryImpl() {
  74718. this.data = new Map();
  74719. }
  74720. RegistryImpl.prototype.add = function (id, data) {
  74721. Assert.ok(Types.isString(id));
  74722. Assert.ok(Types.isObject(data));
  74723. Assert.ok(!this.data.has(id), 'There is already an extension with this id');
  74724. this.data.set(id, data);
  74725. };
  74726. RegistryImpl.prototype.as = function (id) {
  74727. return this.data.get(id) || null;
  74728. };
  74729. return RegistryImpl;
  74730. }());
  74731. exports.Registry = new RegistryImpl();
  74732. });
  74733. /*---------------------------------------------------------------------------------------------
  74734. * Copyright (c) Microsoft Corporation. All rights reserved.
  74735. * Licensed under the MIT License. See License.txt in the project root for license information.
  74736. *--------------------------------------------------------------------------------------------*/
  74737. define(__m[118/*vs/editor/common/modes/modesRegistry*/], __M([0/*require*/,1/*exports*/,425/*vs/nls!vs/editor/common/modes/modesRegistry*/,4/*vs/base/common/event*/,17/*vs/editor/common/modes*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/,42/*vs/platform/registry/common/platform*/]), function (require, exports, nls, event_1, modes_1, languageConfigurationRegistry_1, platform_1) {
  74738. "use strict";
  74739. Object.defineProperty(exports, "__esModule", { value: true });
  74740. // Define extension point ids
  74741. exports.Extensions = {
  74742. ModesRegistry: 'editor.modesRegistry'
  74743. };
  74744. var EditorModesRegistry = /** @class */ (function () {
  74745. function EditorModesRegistry() {
  74746. this._onDidChangeLanguages = new event_1.Emitter();
  74747. this.onDidChangeLanguages = this._onDidChangeLanguages.event;
  74748. this._languages = [];
  74749. this._dynamicLanguages = [];
  74750. }
  74751. // --- languages
  74752. EditorModesRegistry.prototype.registerLanguage = function (def) {
  74753. this._languages.push(def);
  74754. this._onDidChangeLanguages.fire(undefined);
  74755. };
  74756. EditorModesRegistry.prototype.getLanguages = function () {
  74757. return [].concat(this._languages).concat(this._dynamicLanguages);
  74758. };
  74759. return EditorModesRegistry;
  74760. }());
  74761. exports.EditorModesRegistry = EditorModesRegistry;
  74762. exports.ModesRegistry = new EditorModesRegistry();
  74763. platform_1.Registry.add(exports.Extensions.ModesRegistry, exports.ModesRegistry);
  74764. exports.PLAINTEXT_MODE_ID = 'plaintext';
  74765. exports.PLAINTEXT_LANGUAGE_IDENTIFIER = new modes_1.LanguageIdentifier(exports.PLAINTEXT_MODE_ID, 1 /* PlainText */);
  74766. exports.ModesRegistry.registerLanguage({
  74767. id: exports.PLAINTEXT_MODE_ID,
  74768. extensions: ['.txt', '.gitignore'],
  74769. aliases: [nls.localize(0, null), 'text'],
  74770. mimetypes: ['text/plain']
  74771. });
  74772. languageConfigurationRegistry_1.LanguageConfigurationRegistry.register(exports.PLAINTEXT_LANGUAGE_IDENTIFIER, {
  74773. brackets: [
  74774. ['(', ')'],
  74775. ['[', ']'],
  74776. ['{', '}'],
  74777. ],
  74778. surroundingPairs: [
  74779. { open: '{', close: '}' },
  74780. { open: '[', close: ']' },
  74781. { open: '(', close: ')' },
  74782. { open: '<', close: '>' },
  74783. { open: '\"', close: '\"' },
  74784. { open: '\'', close: '\'' },
  74785. { open: '`', close: '`' },
  74786. ],
  74787. folding: {
  74788. offSide: true
  74789. }
  74790. });
  74791. });
  74792. /*---------------------------------------------------------------------------------------------
  74793. * Copyright (c) Microsoft Corporation. All rights reserved.
  74794. * Licensed under the MIT License. See License.txt in the project root for license information.
  74795. *--------------------------------------------------------------------------------------------*/
  74796. define(__m[511/*vs/editor/common/services/getIconClasses*/], __M([0/*require*/,1/*exports*/,46/*vs/base/common/network*/,39/*vs/base/common/resources*/,118/*vs/editor/common/modes/modesRegistry*/,208/*vs/platform/files/common/files*/]), function (require, exports, network_1, resources_1, modesRegistry_1, files_1) {
  74797. "use strict";
  74798. Object.defineProperty(exports, "__esModule", { value: true });
  74799. function getIconClasses(modelService, modeService, resource, fileKind) {
  74800. // we always set these base classes even if we do not have a path
  74801. var classes = fileKind === files_1.FileKind.ROOT_FOLDER ? ['rootfolder-icon'] : fileKind === files_1.FileKind.FOLDER ? ['folder-icon'] : ['file-icon'];
  74802. if (resource) {
  74803. // Get the path and name of the resource. For data-URIs, we need to parse specially
  74804. var name_1;
  74805. if (resource.scheme === network_1.Schemas.data) {
  74806. var metadata = resources_1.DataUri.parseMetaData(resource);
  74807. name_1 = metadata.get(resources_1.DataUri.META_DATA_LABEL);
  74808. }
  74809. else {
  74810. name_1 = cssEscape(resources_1.basenameOrAuthority(resource).toLowerCase());
  74811. }
  74812. // Folders
  74813. if (fileKind === files_1.FileKind.FOLDER) {
  74814. classes.push(name_1 + "-name-folder-icon");
  74815. }
  74816. // Files
  74817. else {
  74818. // Name & Extension(s)
  74819. if (name_1) {
  74820. classes.push(name_1 + "-name-file-icon");
  74821. var dotSegments = name_1.split('.');
  74822. for (var i = 1; i < dotSegments.length; i++) {
  74823. classes.push(dotSegments.slice(i).join('.') + "-ext-file-icon"); // add each combination of all found extensions if more than one
  74824. }
  74825. classes.push("ext-file-icon"); // extra segment to increase file-ext score
  74826. }
  74827. // Detected Mode
  74828. var detectedModeId = detectModeId(modelService, modeService, resource);
  74829. if (detectedModeId) {
  74830. classes.push(cssEscape(detectedModeId) + "-lang-file-icon");
  74831. }
  74832. }
  74833. }
  74834. return classes;
  74835. }
  74836. exports.getIconClasses = getIconClasses;
  74837. function detectModeId(modelService, modeService, resource) {
  74838. if (!resource) {
  74839. return null; // we need a resource at least
  74840. }
  74841. var modeId = null;
  74842. // Data URI: check for encoded metadata
  74843. if (resource.scheme === network_1.Schemas.data) {
  74844. var metadata = resources_1.DataUri.parseMetaData(resource);
  74845. var mime = metadata.get(resources_1.DataUri.META_DATA_MIME);
  74846. if (mime) {
  74847. modeId = modeService.getModeId(mime);
  74848. }
  74849. }
  74850. // Any other URI: check for model if existing
  74851. else {
  74852. var model = modelService.getModel(resource);
  74853. if (model) {
  74854. modeId = model.getModeId();
  74855. }
  74856. }
  74857. // only take if the mode is specific (aka no just plain text)
  74858. if (modeId && modeId !== modesRegistry_1.PLAINTEXT_MODE_ID) {
  74859. return modeId;
  74860. }
  74861. // otherwise fallback to path based detection
  74862. return modeService.getModeIdByFilepathOrFirstLine(resource);
  74863. }
  74864. exports.detectModeId = detectModeId;
  74865. function cssEscape(val) {
  74866. return val.replace(/\s/g, '\\$&'); // make sure to not introduce CSS classes from files that contain whitespace
  74867. }
  74868. exports.cssEscape = cssEscape;
  74869. });
  74870. /*---------------------------------------------------------------------------------------------
  74871. * Copyright (c) Microsoft Corporation. All rights reserved.
  74872. * Licensed under the MIT License. See License.txt in the project root for license information.
  74873. *--------------------------------------------------------------------------------------------*/
  74874. define(__m[220/*vs/platform/jsonschemas/common/jsonContributionRegistry*/], __M([0/*require*/,1/*exports*/,42/*vs/platform/registry/common/platform*/,4/*vs/base/common/event*/]), function (require, exports, platform, event_1) {
  74875. "use strict";
  74876. Object.defineProperty(exports, "__esModule", { value: true });
  74877. exports.Extensions = {
  74878. JSONContribution: 'base.contributions.json'
  74879. };
  74880. function normalizeId(id) {
  74881. if (id.length > 0 && id.charAt(id.length - 1) === '#') {
  74882. return id.substring(0, id.length - 1);
  74883. }
  74884. return id;
  74885. }
  74886. var JSONContributionRegistry = /** @class */ (function () {
  74887. function JSONContributionRegistry() {
  74888. this._onDidChangeSchema = new event_1.Emitter();
  74889. this.schemasById = {};
  74890. }
  74891. JSONContributionRegistry.prototype.registerSchema = function (uri, unresolvedSchemaContent) {
  74892. this.schemasById[normalizeId(uri)] = unresolvedSchemaContent;
  74893. this._onDidChangeSchema.fire(uri);
  74894. };
  74895. JSONContributionRegistry.prototype.notifySchemaChanged = function (uri) {
  74896. this._onDidChangeSchema.fire(uri);
  74897. };
  74898. return JSONContributionRegistry;
  74899. }());
  74900. var jsonContributionRegistry = new JSONContributionRegistry();
  74901. platform.Registry.add(exports.Extensions.JSONContribution, jsonContributionRegistry);
  74902. });
  74903. /*---------------------------------------------------------------------------------------------
  74904. * Copyright (c) Microsoft Corporation. All rights reserved.
  74905. * Licensed under the MIT License. See License.txt in the project root for license information.
  74906. *--------------------------------------------------------------------------------------------*/
  74907. define(__m[85/*vs/platform/configuration/common/configurationRegistry*/], __M([0/*require*/,1/*exports*/,472/*vs/nls!vs/platform/configuration/common/configurationRegistry*/,4/*vs/base/common/event*/,42/*vs/platform/registry/common/platform*/,21/*vs/base/common/types*/,220/*vs/platform/jsonschemas/common/jsonContributionRegistry*/,38/*vs/base/common/map*/]), function (require, exports, nls, event_1, platform_1, types, jsonContributionRegistry_1, map_1) {
  74908. "use strict";
  74909. Object.defineProperty(exports, "__esModule", { value: true });
  74910. exports.Extensions = {
  74911. Configuration: 'base.contributions.configuration'
  74912. };
  74913. exports.allSettings = { properties: {}, patternProperties: {} };
  74914. exports.applicationSettings = { properties: {}, patternProperties: {} };
  74915. exports.machineSettings = { properties: {}, patternProperties: {} };
  74916. exports.machineOverridableSettings = { properties: {}, patternProperties: {} };
  74917. exports.windowSettings = { properties: {}, patternProperties: {} };
  74918. exports.resourceSettings = { properties: {}, patternProperties: {} };
  74919. exports.resourceLanguageSettingsSchemaId = 'vscode://schemas/settings/resourceLanguage';
  74920. var contributionRegistry = platform_1.Registry.as(jsonContributionRegistry_1.Extensions.JSONContribution);
  74921. var ConfigurationRegistry = /** @class */ (function () {
  74922. function ConfigurationRegistry() {
  74923. this.overrideIdentifiers = new Set();
  74924. this._onDidSchemaChange = new event_1.Emitter();
  74925. this._onDidUpdateConfiguration = new event_1.Emitter();
  74926. this.defaultOverridesConfigurationNode = {
  74927. id: 'defaultOverrides',
  74928. title: nls.localize(0, null),
  74929. properties: {}
  74930. };
  74931. this.configurationContributors = [this.defaultOverridesConfigurationNode];
  74932. this.resourceLanguageSettingsSchema = { properties: {}, patternProperties: {}, additionalProperties: false, errorMessage: 'Unknown editor configuration setting', allowTrailingCommas: true, allowComments: true };
  74933. this.configurationProperties = {};
  74934. this.excludedConfigurationProperties = {};
  74935. contributionRegistry.registerSchema(exports.resourceLanguageSettingsSchemaId, this.resourceLanguageSettingsSchema);
  74936. }
  74937. ConfigurationRegistry.prototype.registerConfiguration = function (configuration, validate) {
  74938. if (validate === void 0) { validate = true; }
  74939. this.registerConfigurations([configuration], validate);
  74940. };
  74941. ConfigurationRegistry.prototype.registerConfigurations = function (configurations, validate) {
  74942. var _this = this;
  74943. if (validate === void 0) { validate = true; }
  74944. var properties = [];
  74945. configurations.forEach(function (configuration) {
  74946. properties.push.apply(properties, _this.validateAndRegisterProperties(configuration, validate)); // fills in defaults
  74947. _this.configurationContributors.push(configuration);
  74948. _this.registerJSONConfiguration(configuration);
  74949. });
  74950. contributionRegistry.registerSchema(exports.resourceLanguageSettingsSchemaId, this.resourceLanguageSettingsSchema);
  74951. this._onDidSchemaChange.fire();
  74952. this._onDidUpdateConfiguration.fire(properties);
  74953. };
  74954. ConfigurationRegistry.prototype.registerOverrideIdentifiers = function (overrideIdentifiers) {
  74955. for (var _i = 0, overrideIdentifiers_1 = overrideIdentifiers; _i < overrideIdentifiers_1.length; _i++) {
  74956. var overrideIdentifier = overrideIdentifiers_1[_i];
  74957. this.overrideIdentifiers.add(overrideIdentifier);
  74958. }
  74959. this.updateOverridePropertyPatternKey();
  74960. };
  74961. ConfigurationRegistry.prototype.validateAndRegisterProperties = function (configuration, validate, scope) {
  74962. if (validate === void 0) { validate = true; }
  74963. if (scope === void 0) { scope = 3 /* WINDOW */; }
  74964. scope = types.isUndefinedOrNull(configuration.scope) ? scope : configuration.scope;
  74965. var propertyKeys = [];
  74966. var properties = configuration.properties;
  74967. if (properties) {
  74968. for (var key in properties) {
  74969. if (validate && validateProperty(key)) {
  74970. delete properties[key];
  74971. continue;
  74972. }
  74973. // fill in default values
  74974. var property = properties[key];
  74975. var defaultValue = property.default;
  74976. if (types.isUndefined(defaultValue)) {
  74977. property.default = getDefaultValue(property.type);
  74978. }
  74979. if (exports.OVERRIDE_PROPERTY_PATTERN.test(key)) {
  74980. property.scope = undefined; // No scope for overridable properties `[${identifier}]`
  74981. }
  74982. else {
  74983. property.scope = types.isUndefinedOrNull(property.scope) ? scope : property.scope;
  74984. }
  74985. // Add to properties maps
  74986. // Property is included by default if 'included' is unspecified
  74987. if (properties[key].hasOwnProperty('included') && !properties[key].included) {
  74988. this.excludedConfigurationProperties[key] = properties[key];
  74989. delete properties[key];
  74990. continue;
  74991. }
  74992. else {
  74993. this.configurationProperties[key] = properties[key];
  74994. }
  74995. propertyKeys.push(key);
  74996. }
  74997. }
  74998. var subNodes = configuration.allOf;
  74999. if (subNodes) {
  75000. for (var _i = 0, subNodes_1 = subNodes; _i < subNodes_1.length; _i++) {
  75001. var node = subNodes_1[_i];
  75002. propertyKeys.push.apply(propertyKeys, this.validateAndRegisterProperties(node, validate, scope));
  75003. }
  75004. }
  75005. return propertyKeys;
  75006. };
  75007. ConfigurationRegistry.prototype.getConfigurationProperties = function () {
  75008. return this.configurationProperties;
  75009. };
  75010. ConfigurationRegistry.prototype.registerJSONConfiguration = function (configuration) {
  75011. var _this = this;
  75012. var register = function (configuration) {
  75013. var properties = configuration.properties;
  75014. if (properties) {
  75015. for (var key in properties) {
  75016. exports.allSettings.properties[key] = properties[key];
  75017. switch (properties[key].scope) {
  75018. case 1 /* APPLICATION */:
  75019. exports.applicationSettings.properties[key] = properties[key];
  75020. break;
  75021. case 2 /* MACHINE */:
  75022. exports.machineSettings.properties[key] = properties[key];
  75023. break;
  75024. case 6 /* MACHINE_OVERRIDABLE */:
  75025. exports.machineOverridableSettings.properties[key] = properties[key];
  75026. break;
  75027. case 3 /* WINDOW */:
  75028. exports.windowSettings.properties[key] = properties[key];
  75029. break;
  75030. case 4 /* RESOURCE */:
  75031. exports.resourceSettings.properties[key] = properties[key];
  75032. break;
  75033. case 5 /* LANGUAGE_OVERRIDABLE */:
  75034. exports.resourceSettings.properties[key] = properties[key];
  75035. _this.resourceLanguageSettingsSchema.properties[key] = properties[key];
  75036. break;
  75037. }
  75038. }
  75039. }
  75040. var subNodes = configuration.allOf;
  75041. if (subNodes) {
  75042. subNodes.forEach(register);
  75043. }
  75044. };
  75045. register(configuration);
  75046. };
  75047. ConfigurationRegistry.prototype.updateOverridePropertyPatternKey = function () {
  75048. var _a;
  75049. for (var _i = 0, _b = map_1.values(this.overrideIdentifiers); _i < _b.length; _i++) {
  75050. var overrideIdentifier = _b[_i];
  75051. var overrideIdentifierProperty = "[" + overrideIdentifier + "]";
  75052. var resourceLanguagePropertiesSchema = {
  75053. type: 'object',
  75054. description: nls.localize(1, null),
  75055. errorMessage: nls.localize(2, null),
  75056. $ref: exports.resourceLanguageSettingsSchemaId,
  75057. default: (_a = this.defaultOverridesConfigurationNode.properties[overrideIdentifierProperty]) === null || _a === void 0 ? void 0 : _a.default
  75058. };
  75059. exports.allSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
  75060. exports.applicationSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
  75061. exports.machineSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
  75062. exports.machineOverridableSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
  75063. exports.windowSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
  75064. exports.resourceSettings.properties[overrideIdentifierProperty] = resourceLanguagePropertiesSchema;
  75065. }
  75066. this._onDidSchemaChange.fire();
  75067. };
  75068. return ConfigurationRegistry;
  75069. }());
  75070. var OVERRIDE_PROPERTY = '\\[.*\\]$';
  75071. exports.OVERRIDE_PROPERTY_PATTERN = new RegExp(OVERRIDE_PROPERTY);
  75072. function getDefaultValue(type) {
  75073. var t = Array.isArray(type) ? type[0] : type;
  75074. switch (t) {
  75075. case 'boolean':
  75076. return false;
  75077. case 'integer':
  75078. case 'number':
  75079. return 0;
  75080. case 'string':
  75081. return '';
  75082. case 'array':
  75083. return [];
  75084. case 'object':
  75085. return {};
  75086. default:
  75087. return null;
  75088. }
  75089. }
  75090. exports.getDefaultValue = getDefaultValue;
  75091. var configurationRegistry = new ConfigurationRegistry();
  75092. platform_1.Registry.add(exports.Extensions.Configuration, configurationRegistry);
  75093. function validateProperty(property) {
  75094. if (exports.OVERRIDE_PROPERTY_PATTERN.test(property)) {
  75095. return nls.localize(3, null, property);
  75096. }
  75097. if (configurationRegistry.getConfigurationProperties()[property] !== undefined) {
  75098. return nls.localize(4, null, property);
  75099. }
  75100. return null;
  75101. }
  75102. exports.validateProperty = validateProperty;
  75103. });
  75104. /*---------------------------------------------------------------------------------------------
  75105. * Copyright (c) Microsoft Corporation. All rights reserved.
  75106. * Licensed under the MIT License. See License.txt in the project root for license information.
  75107. *--------------------------------------------------------------------------------------------*/
  75108. define(__m[163/*vs/editor/common/config/commonEditorConfig*/], __M([0/*require*/,1/*exports*/,422/*vs/nls!vs/editor/common/config/commonEditorConfig*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,31/*vs/base/common/objects*/,19/*vs/base/common/arrays*/,33/*vs/editor/common/config/editorOptions*/,105/*vs/editor/common/config/editorZoom*/,142/*vs/editor/common/config/fontInfo*/,85/*vs/platform/configuration/common/configurationRegistry*/,42/*vs/platform/registry/common/platform*/,87/*vs/base/common/collections*/]), function (require, exports, nls, event_1, lifecycle_1, objects, arrays, editorOptions_1, editorZoom_1, fontInfo_1, configurationRegistry_1, platform_1, collections_1) {
  75109. "use strict";
  75110. Object.defineProperty(exports, "__esModule", { value: true });
  75111. exports.TabFocus = new /** @class */ (function () {
  75112. function class_1() {
  75113. this._tabFocus = false;
  75114. this._onDidChangeTabFocus = new event_1.Emitter();
  75115. this.onDidChangeTabFocus = this._onDidChangeTabFocus.event;
  75116. }
  75117. class_1.prototype.getTabFocusMode = function () {
  75118. return this._tabFocus;
  75119. };
  75120. class_1.prototype.setTabFocusMode = function (tabFocusMode) {
  75121. if (this._tabFocus === tabFocusMode) {
  75122. return;
  75123. }
  75124. this._tabFocus = tabFocusMode;
  75125. this._onDidChangeTabFocus.fire(this._tabFocus);
  75126. };
  75127. return class_1;
  75128. }());
  75129. var hasOwnProperty = Object.hasOwnProperty;
  75130. var ComputedEditorOptions = /** @class */ (function () {
  75131. function ComputedEditorOptions() {
  75132. this._values = [];
  75133. }
  75134. ComputedEditorOptions.prototype._read = function (id) {
  75135. return this._values[id];
  75136. };
  75137. ComputedEditorOptions.prototype.get = function (id) {
  75138. return this._values[id];
  75139. };
  75140. ComputedEditorOptions.prototype._write = function (id, value) {
  75141. this._values[id] = value;
  75142. };
  75143. return ComputedEditorOptions;
  75144. }());
  75145. exports.ComputedEditorOptions = ComputedEditorOptions;
  75146. var RawEditorOptions = /** @class */ (function () {
  75147. function RawEditorOptions() {
  75148. this._values = [];
  75149. }
  75150. RawEditorOptions.prototype._read = function (id) {
  75151. return this._values[id];
  75152. };
  75153. RawEditorOptions.prototype._write = function (id, value) {
  75154. this._values[id] = value;
  75155. };
  75156. return RawEditorOptions;
  75157. }());
  75158. var EditorConfiguration2 = /** @class */ (function () {
  75159. function EditorConfiguration2() {
  75160. }
  75161. EditorConfiguration2.readOptions = function (_options) {
  75162. var options = _options;
  75163. var result = new RawEditorOptions();
  75164. for (var _i = 0, editorOptionsRegistry_2 = editorOptions_1.editorOptionsRegistry; _i < editorOptionsRegistry_2.length; _i++) {
  75165. var editorOption = editorOptionsRegistry_2[_i];
  75166. var value = (editorOption.name === '_never_' ? undefined : options[editorOption.name]);
  75167. result._write(editorOption.id, value);
  75168. }
  75169. return result;
  75170. };
  75171. EditorConfiguration2.validateOptions = function (options) {
  75172. var result = new editorOptions_1.ValidatedEditorOptions();
  75173. for (var _i = 0, editorOptionsRegistry_3 = editorOptions_1.editorOptionsRegistry; _i < editorOptionsRegistry_3.length; _i++) {
  75174. var editorOption = editorOptionsRegistry_3[_i];
  75175. result._write(editorOption.id, editorOption.validate(options._read(editorOption.id)));
  75176. }
  75177. return result;
  75178. };
  75179. EditorConfiguration2.computeOptions = function (options, env) {
  75180. var result = new ComputedEditorOptions();
  75181. for (var _i = 0, editorOptionsRegistry_4 = editorOptions_1.editorOptionsRegistry; _i < editorOptionsRegistry_4.length; _i++) {
  75182. var editorOption = editorOptionsRegistry_4[_i];
  75183. result._write(editorOption.id, editorOption.compute(env, result, options._read(editorOption.id)));
  75184. }
  75185. return result;
  75186. };
  75187. EditorConfiguration2._deepEquals = function (a, b) {
  75188. if (typeof a !== 'object' || typeof b !== 'object') {
  75189. return (a === b);
  75190. }
  75191. if (Array.isArray(a) || Array.isArray(b)) {
  75192. return (Array.isArray(a) && Array.isArray(b) ? arrays.equals(a, b) : false);
  75193. }
  75194. for (var key in a) {
  75195. if (!EditorConfiguration2._deepEquals(a[key], b[key])) {
  75196. return false;
  75197. }
  75198. }
  75199. return true;
  75200. };
  75201. EditorConfiguration2.checkEquals = function (a, b) {
  75202. var result = [];
  75203. var somethingChanged = false;
  75204. for (var _i = 0, editorOptionsRegistry_5 = editorOptions_1.editorOptionsRegistry; _i < editorOptionsRegistry_5.length; _i++) {
  75205. var editorOption = editorOptionsRegistry_5[_i];
  75206. var changed = !EditorConfiguration2._deepEquals(a._read(editorOption.id), b._read(editorOption.id));
  75207. result[editorOption.id] = changed;
  75208. if (changed) {
  75209. somethingChanged = true;
  75210. }
  75211. }
  75212. return (somethingChanged ? new editorOptions_1.ConfigurationChangedEvent(result) : null);
  75213. };
  75214. return EditorConfiguration2;
  75215. }());
  75216. /**
  75217. * Compatibility with old options
  75218. */
  75219. function migrateOptions(options) {
  75220. var wordWrap = options.wordWrap;
  75221. if (wordWrap === true) {
  75222. options.wordWrap = 'on';
  75223. }
  75224. else if (wordWrap === false) {
  75225. options.wordWrap = 'off';
  75226. }
  75227. var lineNumbers = options.lineNumbers;
  75228. if (lineNumbers === true) {
  75229. options.lineNumbers = 'on';
  75230. }
  75231. else if (lineNumbers === false) {
  75232. options.lineNumbers = 'off';
  75233. }
  75234. var autoClosingBrackets = options.autoClosingBrackets;
  75235. if (autoClosingBrackets === false) {
  75236. options.autoClosingBrackets = 'never';
  75237. options.autoClosingQuotes = 'never';
  75238. options.autoSurround = 'never';
  75239. }
  75240. var cursorBlinking = options.cursorBlinking;
  75241. if (cursorBlinking === 'visible') {
  75242. options.cursorBlinking = 'solid';
  75243. }
  75244. var renderWhitespace = options.renderWhitespace;
  75245. if (renderWhitespace === true) {
  75246. options.renderWhitespace = 'boundary';
  75247. }
  75248. else if (renderWhitespace === false) {
  75249. options.renderWhitespace = 'none';
  75250. }
  75251. var renderLineHighlight = options.renderLineHighlight;
  75252. if (renderLineHighlight === true) {
  75253. options.renderLineHighlight = 'line';
  75254. }
  75255. else if (renderLineHighlight === false) {
  75256. options.renderLineHighlight = 'none';
  75257. }
  75258. var acceptSuggestionOnEnter = options.acceptSuggestionOnEnter;
  75259. if (acceptSuggestionOnEnter === true) {
  75260. options.acceptSuggestionOnEnter = 'on';
  75261. }
  75262. else if (acceptSuggestionOnEnter === false) {
  75263. options.acceptSuggestionOnEnter = 'off';
  75264. }
  75265. var tabCompletion = options.tabCompletion;
  75266. if (tabCompletion === false) {
  75267. options.tabCompletion = 'off';
  75268. }
  75269. else if (tabCompletion === true) {
  75270. options.tabCompletion = 'onlySnippets';
  75271. }
  75272. var suggest = options.suggest;
  75273. if (suggest && typeof suggest.filteredTypes === 'object' && suggest.filteredTypes) {
  75274. var mapping = {};
  75275. mapping['method'] = 'showMethods';
  75276. mapping['function'] = 'showFunctions';
  75277. mapping['constructor'] = 'showConstructors';
  75278. mapping['field'] = 'showFields';
  75279. mapping['variable'] = 'showVariables';
  75280. mapping['class'] = 'showClasses';
  75281. mapping['struct'] = 'showStructs';
  75282. mapping['interface'] = 'showInterfaces';
  75283. mapping['module'] = 'showModules';
  75284. mapping['property'] = 'showProperties';
  75285. mapping['event'] = 'showEvents';
  75286. mapping['operator'] = 'showOperators';
  75287. mapping['unit'] = 'showUnits';
  75288. mapping['value'] = 'showValues';
  75289. mapping['constant'] = 'showConstants';
  75290. mapping['enum'] = 'showEnums';
  75291. mapping['enumMember'] = 'showEnumMembers';
  75292. mapping['keyword'] = 'showKeywords';
  75293. mapping['text'] = 'showWords';
  75294. mapping['color'] = 'showColors';
  75295. mapping['file'] = 'showFiles';
  75296. mapping['reference'] = 'showReferences';
  75297. mapping['folder'] = 'showFolders';
  75298. mapping['typeParameter'] = 'showTypeParameters';
  75299. mapping['snippet'] = 'showSnippets';
  75300. collections_1.forEach(mapping, function (entry) {
  75301. var value = suggest.filteredTypes[entry.key];
  75302. if (value === false) {
  75303. suggest[entry.value] = value;
  75304. }
  75305. });
  75306. // delete (<any>suggest).filteredTypes;
  75307. }
  75308. var hover = options.hover;
  75309. if (hover === true) {
  75310. options.hover = {
  75311. enabled: true
  75312. };
  75313. }
  75314. else if (hover === false) {
  75315. options.hover = {
  75316. enabled: false
  75317. };
  75318. }
  75319. var parameterHints = options.parameterHints;
  75320. if (parameterHints === true) {
  75321. options.parameterHints = {
  75322. enabled: true
  75323. };
  75324. }
  75325. else if (parameterHints === false) {
  75326. options.parameterHints = {
  75327. enabled: false
  75328. };
  75329. }
  75330. var autoIndent = options.autoIndent;
  75331. if (autoIndent === true) {
  75332. options.autoIndent = 'full';
  75333. }
  75334. else if (autoIndent === false) {
  75335. options.autoIndent = 'advanced';
  75336. }
  75337. var matchBrackets = options.matchBrackets;
  75338. if (matchBrackets === true) {
  75339. options.matchBrackets = 'always';
  75340. }
  75341. else if (matchBrackets === false) {
  75342. options.matchBrackets = 'never';
  75343. }
  75344. }
  75345. function deepCloneAndMigrateOptions(_options) {
  75346. var options = objects.deepClone(_options);
  75347. migrateOptions(options);
  75348. return options;
  75349. }
  75350. var CommonEditorConfiguration = /** @class */ (function (_super) {
  75351. __extends(CommonEditorConfiguration, _super);
  75352. function CommonEditorConfiguration(isSimpleWidget, _options) {
  75353. var _this = _super.call(this) || this;
  75354. _this._onDidChange = _this._register(new event_1.Emitter());
  75355. _this.onDidChange = _this._onDidChange.event;
  75356. _this.isSimpleWidget = isSimpleWidget;
  75357. _this._isDominatedByLongLines = false;
  75358. _this._lineNumbersDigitCount = 1;
  75359. _this._rawOptions = deepCloneAndMigrateOptions(_options);
  75360. _this._readOptions = EditorConfiguration2.readOptions(_this._rawOptions);
  75361. _this._validatedOptions = EditorConfiguration2.validateOptions(_this._readOptions);
  75362. _this._register(editorZoom_1.EditorZoom.onDidChangeZoomLevel(function (_) { return _this._recomputeOptions(); }));
  75363. _this._register(exports.TabFocus.onDidChangeTabFocus(function (_) { return _this._recomputeOptions(); }));
  75364. return _this;
  75365. }
  75366. CommonEditorConfiguration.prototype.observeReferenceElement = function (dimension) {
  75367. };
  75368. CommonEditorConfiguration.prototype.dispose = function () {
  75369. _super.prototype.dispose.call(this);
  75370. };
  75371. CommonEditorConfiguration.prototype._recomputeOptions = function () {
  75372. var oldOptions = this.options;
  75373. var newOptions = this._computeInternalOptions();
  75374. if (!oldOptions) {
  75375. this.options = newOptions;
  75376. }
  75377. else {
  75378. var changeEvent = EditorConfiguration2.checkEquals(oldOptions, newOptions);
  75379. if (changeEvent === null) {
  75380. // nothing changed!
  75381. return;
  75382. }
  75383. this.options = newOptions;
  75384. this._onDidChange.fire(changeEvent);
  75385. }
  75386. };
  75387. CommonEditorConfiguration.prototype.getRawOptions = function () {
  75388. return this._rawOptions;
  75389. };
  75390. CommonEditorConfiguration.prototype._computeInternalOptions = function () {
  75391. var partialEnv = this._getEnvConfiguration();
  75392. var bareFontInfo = fontInfo_1.BareFontInfo.createFromValidatedSettings(this._validatedOptions, partialEnv.zoomLevel, this.isSimpleWidget);
  75393. var env = {
  75394. outerWidth: partialEnv.outerWidth,
  75395. outerHeight: partialEnv.outerHeight,
  75396. fontInfo: this.readConfiguration(bareFontInfo),
  75397. extraEditorClassName: partialEnv.extraEditorClassName,
  75398. isDominatedByLongLines: this._isDominatedByLongLines,
  75399. lineNumbersDigitCount: this._lineNumbersDigitCount,
  75400. emptySelectionClipboard: partialEnv.emptySelectionClipboard,
  75401. pixelRatio: partialEnv.pixelRatio,
  75402. tabFocusMode: exports.TabFocus.getTabFocusMode(),
  75403. accessibilitySupport: partialEnv.accessibilitySupport
  75404. };
  75405. return EditorConfiguration2.computeOptions(this._validatedOptions, env);
  75406. };
  75407. CommonEditorConfiguration._subsetEquals = function (base, subset) {
  75408. for (var key in subset) {
  75409. if (hasOwnProperty.call(subset, key)) {
  75410. var subsetValue = subset[key];
  75411. var baseValue = base[key];
  75412. if (baseValue === subsetValue) {
  75413. continue;
  75414. }
  75415. if (Array.isArray(baseValue) && Array.isArray(subsetValue)) {
  75416. if (!arrays.equals(baseValue, subsetValue)) {
  75417. return false;
  75418. }
  75419. continue;
  75420. }
  75421. if (typeof baseValue === 'object' && typeof subsetValue === 'object') {
  75422. if (!this._subsetEquals(baseValue, subsetValue)) {
  75423. return false;
  75424. }
  75425. continue;
  75426. }
  75427. return false;
  75428. }
  75429. }
  75430. return true;
  75431. };
  75432. CommonEditorConfiguration.prototype.updateOptions = function (_newOptions) {
  75433. if (typeof _newOptions === 'undefined') {
  75434. return;
  75435. }
  75436. var newOptions = deepCloneAndMigrateOptions(_newOptions);
  75437. if (CommonEditorConfiguration._subsetEquals(this._rawOptions, newOptions)) {
  75438. return;
  75439. }
  75440. this._rawOptions = objects.mixin(this._rawOptions, newOptions || {});
  75441. this._readOptions = EditorConfiguration2.readOptions(this._rawOptions);
  75442. this._validatedOptions = EditorConfiguration2.validateOptions(this._readOptions);
  75443. this._recomputeOptions();
  75444. };
  75445. CommonEditorConfiguration.prototype.setIsDominatedByLongLines = function (isDominatedByLongLines) {
  75446. this._isDominatedByLongLines = isDominatedByLongLines;
  75447. this._recomputeOptions();
  75448. };
  75449. CommonEditorConfiguration.prototype.setMaxLineNumber = function (maxLineNumber) {
  75450. var digitCount = CommonEditorConfiguration._digitCount(maxLineNumber);
  75451. if (this._lineNumbersDigitCount === digitCount) {
  75452. return;
  75453. }
  75454. this._lineNumbersDigitCount = digitCount;
  75455. this._recomputeOptions();
  75456. };
  75457. CommonEditorConfiguration._digitCount = function (n) {
  75458. var r = 0;
  75459. while (n) {
  75460. n = Math.floor(n / 10);
  75461. r++;
  75462. }
  75463. return r ? r : 1;
  75464. };
  75465. return CommonEditorConfiguration;
  75466. }(lifecycle_1.Disposable));
  75467. exports.CommonEditorConfiguration = CommonEditorConfiguration;
  75468. exports.editorConfigurationBaseNode = Object.freeze({
  75469. id: 'editor',
  75470. order: 5,
  75471. type: 'object',
  75472. title: nls.localize(0, null),
  75473. scope: 5 /* LANGUAGE_OVERRIDABLE */,
  75474. });
  75475. var configurationRegistry = platform_1.Registry.as(configurationRegistry_1.Extensions.Configuration);
  75476. var editorConfiguration = __assign(__assign({}, exports.editorConfigurationBaseNode), { properties: {
  75477. 'editor.tabSize': {
  75478. type: 'number',
  75479. default: editorOptions_1.EDITOR_MODEL_DEFAULTS.tabSize,
  75480. minimum: 1,
  75481. markdownDescription: nls.localize(1, null)
  75482. },
  75483. // 'editor.indentSize': {
  75484. // 'anyOf': [
  75485. // {
  75486. // type: 'string',
  75487. // enum: ['tabSize']
  75488. // },
  75489. // {
  75490. // type: 'number',
  75491. // minimum: 1
  75492. // }
  75493. // ],
  75494. // default: 'tabSize',
  75495. // markdownDescription: nls.localize('indentSize', "The number of spaces used for indentation or 'tabSize' to use the value from `#editor.tabSize#`. This setting is overridden based on the file contents when `#editor.detectIndentation#` is on.")
  75496. // },
  75497. 'editor.insertSpaces': {
  75498. type: 'boolean',
  75499. default: editorOptions_1.EDITOR_MODEL_DEFAULTS.insertSpaces,
  75500. markdownDescription: nls.localize(2, null)
  75501. },
  75502. 'editor.detectIndentation': {
  75503. type: 'boolean',
  75504. default: editorOptions_1.EDITOR_MODEL_DEFAULTS.detectIndentation,
  75505. markdownDescription: nls.localize(3, null)
  75506. },
  75507. 'editor.trimAutoWhitespace': {
  75508. type: 'boolean',
  75509. default: editorOptions_1.EDITOR_MODEL_DEFAULTS.trimAutoWhitespace,
  75510. description: nls.localize(4, null)
  75511. },
  75512. 'editor.largeFileOptimizations': {
  75513. type: 'boolean',
  75514. default: editorOptions_1.EDITOR_MODEL_DEFAULTS.largeFileOptimizations,
  75515. description: nls.localize(5, null)
  75516. },
  75517. 'editor.wordBasedSuggestions': {
  75518. type: 'boolean',
  75519. default: true,
  75520. description: nls.localize(6, null)
  75521. },
  75522. 'editor.semanticHighlighting.enabled': {
  75523. type: 'boolean',
  75524. default: false,
  75525. description: nls.localize(7, null)
  75526. },
  75527. 'editor.stablePeek': {
  75528. type: 'boolean',
  75529. default: false,
  75530. markdownDescription: nls.localize(8, null)
  75531. },
  75532. 'editor.maxTokenizationLineLength': {
  75533. type: 'integer',
  75534. default: 20000,
  75535. description: nls.localize(9, null)
  75536. },
  75537. 'diffEditor.maxComputationTime': {
  75538. type: 'number',
  75539. default: 5000,
  75540. description: nls.localize(10, null)
  75541. },
  75542. 'diffEditor.renderSideBySide': {
  75543. type: 'boolean',
  75544. default: true,
  75545. description: nls.localize(11, null)
  75546. },
  75547. 'diffEditor.ignoreTrimWhitespace': {
  75548. type: 'boolean',
  75549. default: true,
  75550. description: nls.localize(12, null)
  75551. },
  75552. 'diffEditor.renderIndicators': {
  75553. type: 'boolean',
  75554. default: true,
  75555. description: nls.localize(13, null)
  75556. }
  75557. } });
  75558. function isConfigurationPropertySchema(x) {
  75559. return (typeof x.type !== 'undefined' || typeof x.anyOf !== 'undefined');
  75560. }
  75561. // Add properties from the Editor Option Registry
  75562. for (var _i = 0, editorOptionsRegistry_1 = editorOptions_1.editorOptionsRegistry; _i < editorOptionsRegistry_1.length; _i++) {
  75563. var editorOption = editorOptionsRegistry_1[_i];
  75564. var schema = editorOption.schema;
  75565. if (typeof schema !== 'undefined') {
  75566. if (isConfigurationPropertySchema(schema)) {
  75567. // This is a single schema contribution
  75568. editorConfiguration.properties["editor." + editorOption.name] = schema;
  75569. }
  75570. else {
  75571. for (var key in schema) {
  75572. if (hasOwnProperty.call(schema, key)) {
  75573. editorConfiguration.properties[key] = schema[key];
  75574. }
  75575. }
  75576. }
  75577. }
  75578. }
  75579. var cachedEditorConfigurationKeys = null;
  75580. function getEditorConfigurationKeys() {
  75581. if (cachedEditorConfigurationKeys === null) {
  75582. cachedEditorConfigurationKeys = Object.create(null);
  75583. Object.keys(editorConfiguration.properties).forEach(function (prop) {
  75584. cachedEditorConfigurationKeys[prop] = true;
  75585. });
  75586. }
  75587. return cachedEditorConfigurationKeys;
  75588. }
  75589. function isEditorConfigurationKey(key) {
  75590. var editorConfigurationKeys = getEditorConfigurationKeys();
  75591. return (editorConfigurationKeys["editor." + key] || false);
  75592. }
  75593. exports.isEditorConfigurationKey = isEditorConfigurationKey;
  75594. function isDiffEditorConfigurationKey(key) {
  75595. var editorConfigurationKeys = getEditorConfigurationKeys();
  75596. return (editorConfigurationKeys["diffEditor." + key] || false);
  75597. }
  75598. exports.isDiffEditorConfigurationKey = isDiffEditorConfigurationKey;
  75599. configurationRegistry.registerConfiguration(editorConfiguration);
  75600. });
  75601. /*---------------------------------------------------------------------------------------------
  75602. * Copyright (c) Microsoft Corporation. All rights reserved.
  75603. * Licensed under the MIT License. See License.txt in the project root for license information.
  75604. *--------------------------------------------------------------------------------------------*/
  75605. define(__m[60/*vs/editor/browser/config/configuration*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,333/*vs/editor/browser/config/charWidthReader*/,185/*vs/editor/browser/config/elementSizeObserver*/,163/*vs/editor/common/config/commonEditorConfig*/,33/*vs/editor/common/config/editorOptions*/,142/*vs/editor/common/config/fontInfo*/]), function (require, exports, browser, event_1, lifecycle_1, platform, charWidthReader_1, elementSizeObserver_1, commonEditorConfig_1, editorOptions_1, fontInfo_1) {
  75606. "use strict";
  75607. Object.defineProperty(exports, "__esModule", { value: true });
  75608. var CSSBasedConfigurationCache = /** @class */ (function () {
  75609. function CSSBasedConfigurationCache() {
  75610. this._keys = Object.create(null);
  75611. this._values = Object.create(null);
  75612. }
  75613. CSSBasedConfigurationCache.prototype.has = function (item) {
  75614. var itemId = item.getId();
  75615. return !!this._values[itemId];
  75616. };
  75617. CSSBasedConfigurationCache.prototype.get = function (item) {
  75618. var itemId = item.getId();
  75619. return this._values[itemId];
  75620. };
  75621. CSSBasedConfigurationCache.prototype.put = function (item, value) {
  75622. var itemId = item.getId();
  75623. this._keys[itemId] = item;
  75624. this._values[itemId] = value;
  75625. };
  75626. CSSBasedConfigurationCache.prototype.remove = function (item) {
  75627. var itemId = item.getId();
  75628. delete this._keys[itemId];
  75629. delete this._values[itemId];
  75630. };
  75631. CSSBasedConfigurationCache.prototype.getValues = function () {
  75632. var _this = this;
  75633. return Object.keys(this._keys).map(function (id) { return _this._values[id]; });
  75634. };
  75635. return CSSBasedConfigurationCache;
  75636. }());
  75637. function clearAllFontInfos() {
  75638. CSSBasedConfiguration.INSTANCE.clearCache();
  75639. }
  75640. exports.clearAllFontInfos = clearAllFontInfos;
  75641. var CSSBasedConfiguration = /** @class */ (function (_super) {
  75642. __extends(CSSBasedConfiguration, _super);
  75643. function CSSBasedConfiguration() {
  75644. var _this = _super.call(this) || this;
  75645. _this._onDidChange = _this._register(new event_1.Emitter());
  75646. _this.onDidChange = _this._onDidChange.event;
  75647. _this._cache = new CSSBasedConfigurationCache();
  75648. _this._evictUntrustedReadingsTimeout = -1;
  75649. return _this;
  75650. }
  75651. CSSBasedConfiguration.prototype.dispose = function () {
  75652. if (this._evictUntrustedReadingsTimeout !== -1) {
  75653. clearTimeout(this._evictUntrustedReadingsTimeout);
  75654. this._evictUntrustedReadingsTimeout = -1;
  75655. }
  75656. _super.prototype.dispose.call(this);
  75657. };
  75658. CSSBasedConfiguration.prototype.clearCache = function () {
  75659. this._cache = new CSSBasedConfigurationCache();
  75660. this._onDidChange.fire();
  75661. };
  75662. CSSBasedConfiguration.prototype._writeToCache = function (item, value) {
  75663. var _this = this;
  75664. this._cache.put(item, value);
  75665. if (!value.isTrusted && this._evictUntrustedReadingsTimeout === -1) {
  75666. // Try reading again after some time
  75667. this._evictUntrustedReadingsTimeout = setTimeout(function () {
  75668. _this._evictUntrustedReadingsTimeout = -1;
  75669. _this._evictUntrustedReadings();
  75670. }, 5000);
  75671. }
  75672. };
  75673. CSSBasedConfiguration.prototype._evictUntrustedReadings = function () {
  75674. var values = this._cache.getValues();
  75675. var somethingRemoved = false;
  75676. for (var i = 0, len = values.length; i < len; i++) {
  75677. var item = values[i];
  75678. if (!item.isTrusted) {
  75679. somethingRemoved = true;
  75680. this._cache.remove(item);
  75681. }
  75682. }
  75683. if (somethingRemoved) {
  75684. this._onDidChange.fire();
  75685. }
  75686. };
  75687. CSSBasedConfiguration.prototype.readConfiguration = function (bareFontInfo) {
  75688. if (!this._cache.has(bareFontInfo)) {
  75689. var readConfig = CSSBasedConfiguration._actualReadConfiguration(bareFontInfo);
  75690. if (readConfig.typicalHalfwidthCharacterWidth <= 2 || readConfig.typicalFullwidthCharacterWidth <= 2 || readConfig.spaceWidth <= 2 || readConfig.maxDigitWidth <= 2) {
  75691. // Hey, it's Bug 14341 ... we couldn't read
  75692. readConfig = new fontInfo_1.FontInfo({
  75693. zoomLevel: browser.getZoomLevel(),
  75694. fontFamily: readConfig.fontFamily,
  75695. fontWeight: readConfig.fontWeight,
  75696. fontSize: readConfig.fontSize,
  75697. fontFeatureSettings: readConfig.fontFeatureSettings,
  75698. lineHeight: readConfig.lineHeight,
  75699. letterSpacing: readConfig.letterSpacing,
  75700. isMonospace: readConfig.isMonospace,
  75701. typicalHalfwidthCharacterWidth: Math.max(readConfig.typicalHalfwidthCharacterWidth, 5),
  75702. typicalFullwidthCharacterWidth: Math.max(readConfig.typicalFullwidthCharacterWidth, 5),
  75703. canUseHalfwidthRightwardsArrow: readConfig.canUseHalfwidthRightwardsArrow,
  75704. spaceWidth: Math.max(readConfig.spaceWidth, 5),
  75705. middotWidth: Math.max(readConfig.middotWidth, 5),
  75706. maxDigitWidth: Math.max(readConfig.maxDigitWidth, 5),
  75707. }, false);
  75708. }
  75709. this._writeToCache(bareFontInfo, readConfig);
  75710. }
  75711. return this._cache.get(bareFontInfo);
  75712. };
  75713. CSSBasedConfiguration.createRequest = function (chr, type, all, monospace) {
  75714. var result = new charWidthReader_1.CharWidthRequest(chr, type);
  75715. all.push(result);
  75716. if (monospace) {
  75717. monospace.push(result);
  75718. }
  75719. return result;
  75720. };
  75721. CSSBasedConfiguration._actualReadConfiguration = function (bareFontInfo) {
  75722. var all = [];
  75723. var monospace = [];
  75724. var typicalHalfwidthCharacter = this.createRequest('n', 0 /* Regular */, all, monospace);
  75725. var typicalFullwidthCharacter = this.createRequest('\uff4d', 0 /* Regular */, all, null);
  75726. var space = this.createRequest(' ', 0 /* Regular */, all, monospace);
  75727. var digit0 = this.createRequest('0', 0 /* Regular */, all, monospace);
  75728. var digit1 = this.createRequest('1', 0 /* Regular */, all, monospace);
  75729. var digit2 = this.createRequest('2', 0 /* Regular */, all, monospace);
  75730. var digit3 = this.createRequest('3', 0 /* Regular */, all, monospace);
  75731. var digit4 = this.createRequest('4', 0 /* Regular */, all, monospace);
  75732. var digit5 = this.createRequest('5', 0 /* Regular */, all, monospace);
  75733. var digit6 = this.createRequest('6', 0 /* Regular */, all, monospace);
  75734. var digit7 = this.createRequest('7', 0 /* Regular */, all, monospace);
  75735. var digit8 = this.createRequest('8', 0 /* Regular */, all, monospace);
  75736. var digit9 = this.createRequest('9', 0 /* Regular */, all, monospace);
  75737. // monospace test: used for whitespace rendering
  75738. var rightwardsArrow = this.createRequest('→', 0 /* Regular */, all, monospace);
  75739. var halfwidthRightwardsArrow = this.createRequest('→', 0 /* Regular */, all, null);
  75740. // middle dot character
  75741. var middot = this.createRequest('·', 0 /* Regular */, all, monospace);
  75742. // monospace test: some characters
  75743. this.createRequest('|', 0 /* Regular */, all, monospace);
  75744. this.createRequest('/', 0 /* Regular */, all, monospace);
  75745. this.createRequest('-', 0 /* Regular */, all, monospace);
  75746. this.createRequest('_', 0 /* Regular */, all, monospace);
  75747. this.createRequest('i', 0 /* Regular */, all, monospace);
  75748. this.createRequest('l', 0 /* Regular */, all, monospace);
  75749. this.createRequest('m', 0 /* Regular */, all, monospace);
  75750. // monospace italic test
  75751. this.createRequest('|', 1 /* Italic */, all, monospace);
  75752. this.createRequest('_', 1 /* Italic */, all, monospace);
  75753. this.createRequest('i', 1 /* Italic */, all, monospace);
  75754. this.createRequest('l', 1 /* Italic */, all, monospace);
  75755. this.createRequest('m', 1 /* Italic */, all, monospace);
  75756. this.createRequest('n', 1 /* Italic */, all, monospace);
  75757. // monospace bold test
  75758. this.createRequest('|', 2 /* Bold */, all, monospace);
  75759. this.createRequest('_', 2 /* Bold */, all, monospace);
  75760. this.createRequest('i', 2 /* Bold */, all, monospace);
  75761. this.createRequest('l', 2 /* Bold */, all, monospace);
  75762. this.createRequest('m', 2 /* Bold */, all, monospace);
  75763. this.createRequest('n', 2 /* Bold */, all, monospace);
  75764. charWidthReader_1.readCharWidths(bareFontInfo, all);
  75765. var maxDigitWidth = Math.max(digit0.width, digit1.width, digit2.width, digit3.width, digit4.width, digit5.width, digit6.width, digit7.width, digit8.width, digit9.width);
  75766. var isMonospace = (bareFontInfo.fontFeatureSettings === editorOptions_1.EditorFontLigatures.OFF);
  75767. var referenceWidth = monospace[0].width;
  75768. for (var i = 1, len = monospace.length; isMonospace && i < len; i++) {
  75769. var diff = referenceWidth - monospace[i].width;
  75770. if (diff < -0.001 || diff > 0.001) {
  75771. isMonospace = false;
  75772. break;
  75773. }
  75774. }
  75775. var canUseHalfwidthRightwardsArrow = true;
  75776. if (isMonospace && halfwidthRightwardsArrow.width !== referenceWidth) {
  75777. // using a halfwidth rightwards arrow would break monospace...
  75778. canUseHalfwidthRightwardsArrow = false;
  75779. }
  75780. if (halfwidthRightwardsArrow.width > rightwardsArrow.width) {
  75781. // using a halfwidth rightwards arrow would paint a larger arrow than a regular rightwards arrow
  75782. canUseHalfwidthRightwardsArrow = false;
  75783. }
  75784. // let's trust the zoom level only 2s after it was changed.
  75785. var canTrustBrowserZoomLevel = (browser.getTimeSinceLastZoomLevelChanged() > 2000);
  75786. return new fontInfo_1.FontInfo({
  75787. zoomLevel: browser.getZoomLevel(),
  75788. fontFamily: bareFontInfo.fontFamily,
  75789. fontWeight: bareFontInfo.fontWeight,
  75790. fontSize: bareFontInfo.fontSize,
  75791. fontFeatureSettings: bareFontInfo.fontFeatureSettings,
  75792. lineHeight: bareFontInfo.lineHeight,
  75793. letterSpacing: bareFontInfo.letterSpacing,
  75794. isMonospace: isMonospace,
  75795. typicalHalfwidthCharacterWidth: typicalHalfwidthCharacter.width,
  75796. typicalFullwidthCharacterWidth: typicalFullwidthCharacter.width,
  75797. canUseHalfwidthRightwardsArrow: canUseHalfwidthRightwardsArrow,
  75798. spaceWidth: space.width,
  75799. middotWidth: middot.width,
  75800. maxDigitWidth: maxDigitWidth
  75801. }, canTrustBrowserZoomLevel);
  75802. };
  75803. CSSBasedConfiguration.INSTANCE = new CSSBasedConfiguration();
  75804. return CSSBasedConfiguration;
  75805. }(lifecycle_1.Disposable));
  75806. var Configuration = /** @class */ (function (_super) {
  75807. __extends(Configuration, _super);
  75808. function Configuration(isSimpleWidget, options, referenceDomElement, accessibilityService) {
  75809. if (referenceDomElement === void 0) { referenceDomElement = null; }
  75810. var _this = _super.call(this, isSimpleWidget, options) || this;
  75811. _this.accessibilityService = accessibilityService;
  75812. _this._elementSizeObserver = _this._register(new elementSizeObserver_1.ElementSizeObserver(referenceDomElement, options.dimension, function () { return _this._onReferenceDomElementSizeChanged(); }));
  75813. _this._register(CSSBasedConfiguration.INSTANCE.onDidChange(function () { return _this._onCSSBasedConfigurationChanged(); }));
  75814. if (_this._validatedOptions.get(9 /* automaticLayout */)) {
  75815. _this._elementSizeObserver.startObserving();
  75816. }
  75817. _this._register(browser.onDidChangeZoomLevel(function (_) { return _this._recomputeOptions(); }));
  75818. _this._register(_this.accessibilityService.onDidChangeScreenReaderOptimized(function () { return _this._recomputeOptions(); }));
  75819. _this._recomputeOptions();
  75820. return _this;
  75821. }
  75822. Configuration.applyFontInfoSlow = function (domNode, fontInfo) {
  75823. domNode.style.fontFamily = fontInfo.getMassagedFontFamily();
  75824. domNode.style.fontWeight = fontInfo.fontWeight;
  75825. domNode.style.fontSize = fontInfo.fontSize + 'px';
  75826. domNode.style.fontFeatureSettings = fontInfo.fontFeatureSettings;
  75827. domNode.style.lineHeight = fontInfo.lineHeight + 'px';
  75828. domNode.style.letterSpacing = fontInfo.letterSpacing + 'px';
  75829. };
  75830. Configuration.applyFontInfo = function (domNode, fontInfo) {
  75831. domNode.setFontFamily(fontInfo.getMassagedFontFamily());
  75832. domNode.setFontWeight(fontInfo.fontWeight);
  75833. domNode.setFontSize(fontInfo.fontSize);
  75834. domNode.setFontFeatureSettings(fontInfo.fontFeatureSettings);
  75835. domNode.setLineHeight(fontInfo.lineHeight);
  75836. domNode.setLetterSpacing(fontInfo.letterSpacing);
  75837. };
  75838. Configuration.prototype._onReferenceDomElementSizeChanged = function () {
  75839. this._recomputeOptions();
  75840. };
  75841. Configuration.prototype._onCSSBasedConfigurationChanged = function () {
  75842. this._recomputeOptions();
  75843. };
  75844. Configuration.prototype.observeReferenceElement = function (dimension) {
  75845. this._elementSizeObserver.observe(dimension);
  75846. };
  75847. Configuration.prototype.dispose = function () {
  75848. _super.prototype.dispose.call(this);
  75849. };
  75850. Configuration.prototype._getExtraEditorClassName = function () {
  75851. var extra = '';
  75852. if (!browser.isSafari && !browser.isWebkitWebView) {
  75853. // Use user-select: none in all browsers except Safari and native macOS WebView
  75854. extra += 'no-user-select ';
  75855. }
  75856. if (platform.isMacintosh) {
  75857. extra += 'mac ';
  75858. }
  75859. return extra;
  75860. };
  75861. Configuration.prototype._getEnvConfiguration = function () {
  75862. return {
  75863. extraEditorClassName: this._getExtraEditorClassName(),
  75864. outerWidth: this._elementSizeObserver.getWidth(),
  75865. outerHeight: this._elementSizeObserver.getHeight(),
  75866. emptySelectionClipboard: browser.isWebKit || browser.isFirefox,
  75867. pixelRatio: browser.getPixelRatio(),
  75868. zoomLevel: browser.getZoomLevel(),
  75869. accessibilitySupport: (this.accessibilityService.isScreenReaderOptimized()
  75870. ? 2 /* Enabled */
  75871. : this.accessibilityService.getAccessibilitySupport())
  75872. };
  75873. };
  75874. Configuration.prototype.readConfiguration = function (bareFontInfo) {
  75875. return CSSBasedConfiguration.INSTANCE.readConfiguration(bareFontInfo);
  75876. };
  75877. return Configuration;
  75878. }(commonEditorConfig_1.CommonEditorConfiguration));
  75879. exports.Configuration = Configuration;
  75880. });
  75881. /*---------------------------------------------------------------------------------------------
  75882. * Copyright (c) Microsoft Corporation. All rights reserved.
  75883. * Licensed under the MIT License. See License.txt in the project root for license information.
  75884. *--------------------------------------------------------------------------------------------*/
  75885. define(__m[512/*vs/editor/browser/view/domLineBreaksComputer*/], __M([0/*require*/,1/*exports*/,161/*vs/editor/common/viewModel/splitLinesCollection*/,106/*vs/editor/common/core/stringBuilder*/,5/*vs/base/common/strings*/,60/*vs/editor/browser/config/configuration*/]), function (require, exports, splitLinesCollection_1, stringBuilder_1, strings, configuration_1) {
  75886. "use strict";
  75887. Object.defineProperty(exports, "__esModule", { value: true });
  75888. var DOMLineBreaksComputerFactory = /** @class */ (function () {
  75889. function DOMLineBreaksComputerFactory() {
  75890. }
  75891. DOMLineBreaksComputerFactory.create = function () {
  75892. return new DOMLineBreaksComputerFactory();
  75893. };
  75894. DOMLineBreaksComputerFactory.prototype.createLineBreaksComputer = function (fontInfo, tabSize, wrappingColumn, wrappingIndent) {
  75895. tabSize = tabSize | 0; //@perf
  75896. wrappingColumn = +wrappingColumn; //@perf
  75897. var requests = [];
  75898. return {
  75899. addRequest: function (lineText, previousLineBreakData) {
  75900. requests.push(lineText);
  75901. },
  75902. finalize: function () {
  75903. return createLineBreaks(requests, fontInfo, tabSize, wrappingColumn, wrappingIndent);
  75904. }
  75905. };
  75906. };
  75907. return DOMLineBreaksComputerFactory;
  75908. }());
  75909. exports.DOMLineBreaksComputerFactory = DOMLineBreaksComputerFactory;
  75910. function createLineBreaks(requests, fontInfo, tabSize, firstLineBreakColumn, wrappingIndent) {
  75911. if (firstLineBreakColumn === -1) {
  75912. var result_1 = [];
  75913. for (var i = 0, len = requests.length; i < len; i++) {
  75914. result_1[i] = null;
  75915. }
  75916. return result_1;
  75917. }
  75918. var overallWidth = Math.round(firstLineBreakColumn * fontInfo.typicalHalfwidthCharacterWidth);
  75919. // Cannot respect WrappingIndent.Indent and WrappingIndent.DeepIndent because that would require
  75920. // two dom layouts, in order to first set the width of the first line, and then set the width of the wrapped lines
  75921. if (wrappingIndent === 2 /* Indent */ || wrappingIndent === 3 /* DeepIndent */) {
  75922. wrappingIndent = 1 /* Same */;
  75923. }
  75924. var containerDomNode = document.createElement('div');
  75925. configuration_1.Configuration.applyFontInfoSlow(containerDomNode, fontInfo);
  75926. var sb = stringBuilder_1.createStringBuilder(10000);
  75927. var firstNonWhitespaceIndices = [];
  75928. var wrappedTextIndentLengths = [];
  75929. var renderLineContents = [];
  75930. var allCharOffsets = [];
  75931. var allVisibleColumns = [];
  75932. for (var i = 0; i < requests.length; i++) {
  75933. var lineContent = requests[i];
  75934. var firstNonWhitespaceIndex = 0;
  75935. var wrappedTextIndentLength = 0;
  75936. var width = overallWidth;
  75937. if (wrappingIndent !== 0 /* None */) {
  75938. firstNonWhitespaceIndex = strings.firstNonWhitespaceIndex(lineContent);
  75939. if (firstNonWhitespaceIndex === -1) {
  75940. // all whitespace line
  75941. firstNonWhitespaceIndex = 0;
  75942. }
  75943. else {
  75944. // Track existing indent
  75945. for (var i_1 = 0; i_1 < firstNonWhitespaceIndex; i_1++) {
  75946. var charWidth = (lineContent.charCodeAt(i_1) === 9 /* Tab */
  75947. ? (tabSize - (wrappedTextIndentLength % tabSize))
  75948. : 1);
  75949. wrappedTextIndentLength += charWidth;
  75950. }
  75951. var indentWidth = Math.ceil(fontInfo.spaceWidth * wrappedTextIndentLength);
  75952. // Force sticking to beginning of line if no character would fit except for the indentation
  75953. if (indentWidth + fontInfo.typicalFullwidthCharacterWidth > overallWidth) {
  75954. firstNonWhitespaceIndex = 0;
  75955. wrappedTextIndentLength = 0;
  75956. }
  75957. else {
  75958. width = overallWidth - indentWidth;
  75959. }
  75960. }
  75961. }
  75962. var renderLineContent = lineContent.substr(firstNonWhitespaceIndex);
  75963. var tmp = renderLine(renderLineContent, wrappedTextIndentLength, tabSize, width, sb);
  75964. firstNonWhitespaceIndices[i] = firstNonWhitespaceIndex;
  75965. wrappedTextIndentLengths[i] = wrappedTextIndentLength;
  75966. renderLineContents[i] = renderLineContent;
  75967. allCharOffsets[i] = tmp[0];
  75968. allVisibleColumns[i] = tmp[1];
  75969. }
  75970. containerDomNode.innerHTML = sb.build();
  75971. containerDomNode.style.position = 'absolute';
  75972. containerDomNode.style.top = '10000';
  75973. containerDomNode.style.wordWrap = 'break-word';
  75974. document.body.appendChild(containerDomNode);
  75975. var range = document.createRange();
  75976. var lineDomNodes = Array.prototype.slice.call(containerDomNode.children, 0);
  75977. var result = [];
  75978. for (var i = 0; i < requests.length; i++) {
  75979. var lineDomNode = lineDomNodes[i];
  75980. var breakOffsets = readLineBreaks(range, lineDomNode, renderLineContents[i], allCharOffsets[i]);
  75981. if (breakOffsets === null) {
  75982. result[i] = null;
  75983. continue;
  75984. }
  75985. var firstNonWhitespaceIndex = firstNonWhitespaceIndices[i];
  75986. var wrappedTextIndentLength = wrappedTextIndentLengths[i];
  75987. var visibleColumns = allVisibleColumns[i];
  75988. var breakOffsetsVisibleColumn = [];
  75989. for (var j = 0, len = breakOffsets.length; j < len; j++) {
  75990. breakOffsetsVisibleColumn[j] = visibleColumns[breakOffsets[j]];
  75991. }
  75992. if (firstNonWhitespaceIndex !== 0) {
  75993. // All break offsets are relative to the renderLineContent, make them absolute again
  75994. for (var j = 0, len = breakOffsets.length; j < len; j++) {
  75995. breakOffsets[j] += firstNonWhitespaceIndex;
  75996. }
  75997. }
  75998. result[i] = new splitLinesCollection_1.LineBreakData(breakOffsets, breakOffsetsVisibleColumn, wrappedTextIndentLength);
  75999. }
  76000. document.body.removeChild(containerDomNode);
  76001. return result;
  76002. }
  76003. function renderLine(lineContent, initialVisibleColumn, tabSize, width, sb) {
  76004. sb.appendASCIIString('<div style="width:');
  76005. sb.appendASCIIString(String(width));
  76006. sb.appendASCIIString('px;">');
  76007. // if (containsRTL) {
  76008. // sb.appendASCIIString('" dir="ltr');
  76009. // }
  76010. var len = lineContent.length;
  76011. var visibleColumn = initialVisibleColumn;
  76012. var charOffset = 0;
  76013. var charOffsets = [];
  76014. var visibleColumns = [];
  76015. var nextCharCode = (0 < len ? lineContent.charCodeAt(0) : 0 /* Null */);
  76016. for (var charIndex = 0; charIndex < len; charIndex++) {
  76017. charOffsets[charIndex] = charOffset;
  76018. visibleColumns[charIndex] = visibleColumn;
  76019. var charCode = nextCharCode;
  76020. nextCharCode = (charIndex + 1 < len ? lineContent.charCodeAt(charIndex + 1) : 0 /* Null */);
  76021. var producedCharacters = 1;
  76022. var charWidth = 1;
  76023. switch (charCode) {
  76024. case 9 /* Tab */:
  76025. producedCharacters = (tabSize - (visibleColumn % tabSize));
  76026. charWidth = producedCharacters;
  76027. for (var space = 1; space <= producedCharacters; space++) {
  76028. if (space < producedCharacters) {
  76029. sb.write1(0xA0); // &nbsp;
  76030. }
  76031. else {
  76032. sb.appendASCII(32 /* Space */);
  76033. }
  76034. }
  76035. break;
  76036. case 32 /* Space */:
  76037. if (nextCharCode === 32 /* Space */) {
  76038. sb.write1(0xA0); // &nbsp;
  76039. }
  76040. else {
  76041. sb.appendASCII(32 /* Space */);
  76042. }
  76043. break;
  76044. case 60 /* LessThan */:
  76045. sb.appendASCIIString('&lt;');
  76046. break;
  76047. case 62 /* GreaterThan */:
  76048. sb.appendASCIIString('&gt;');
  76049. break;
  76050. case 38 /* Ampersand */:
  76051. sb.appendASCIIString('&amp;');
  76052. break;
  76053. case 0 /* Null */:
  76054. sb.appendASCIIString('&#00;');
  76055. break;
  76056. case 65279 /* UTF8_BOM */:
  76057. case 8232 /* LINE_SEPARATOR_2028 */:
  76058. sb.write1(0xFFFD);
  76059. break;
  76060. default:
  76061. if (strings.isFullWidthCharacter(charCode)) {
  76062. charWidth++;
  76063. }
  76064. // if (renderControlCharacters && charCode < 32) {
  76065. // sb.write1(9216 + charCode);
  76066. // } else {
  76067. sb.write1(charCode);
  76068. // }
  76069. }
  76070. charOffset += producedCharacters;
  76071. visibleColumn += charWidth;
  76072. }
  76073. charOffsets[lineContent.length] = charOffset;
  76074. visibleColumns[lineContent.length] = visibleColumn;
  76075. sb.appendASCIIString('</div>');
  76076. return [charOffsets, visibleColumns];
  76077. }
  76078. function readLineBreaks(range, lineDomNode, lineContent, charOffsets) {
  76079. if (lineContent.length <= 1) {
  76080. return null;
  76081. }
  76082. var textContentNode = lineDomNode.firstChild;
  76083. var breakOffsets = [];
  76084. discoverBreaks(range, textContentNode, charOffsets, 0, null, lineContent.length - 1, null, breakOffsets);
  76085. if (breakOffsets.length === 0) {
  76086. return null;
  76087. }
  76088. breakOffsets.push(lineContent.length);
  76089. return breakOffsets;
  76090. }
  76091. function discoverBreaks(range, textContentNode, charOffsets, low, lowRects, high, highRects, result) {
  76092. if (low === high) {
  76093. return;
  76094. }
  76095. lowRects = lowRects || readClientRect(range, textContentNode, charOffsets[low], charOffsets[low + 1]);
  76096. highRects = highRects || readClientRect(range, textContentNode, charOffsets[high], charOffsets[high + 1]);
  76097. if (Math.abs(lowRects[0].top - highRects[0].top) <= 0.1) {
  76098. // same line
  76099. return;
  76100. }
  76101. // there is at least one line break between these two offsets
  76102. if (low + 1 === high) {
  76103. // the two characters are adjacent, so the line break must be exactly between them
  76104. result.push(high);
  76105. return;
  76106. }
  76107. var mid = low + ((high - low) / 2) | 0;
  76108. var midRects = readClientRect(range, textContentNode, charOffsets[mid], charOffsets[mid + 1]);
  76109. discoverBreaks(range, textContentNode, charOffsets, low, lowRects, mid, midRects, result);
  76110. discoverBreaks(range, textContentNode, charOffsets, mid, midRects, high, highRects, result);
  76111. }
  76112. function readClientRect(range, textContentNode, startOffset, endOffset) {
  76113. range.setStart(textContentNode, startOffset);
  76114. range.setEnd(textContentNode, endOffset);
  76115. return range.getClientRects();
  76116. }
  76117. });
  76118. /*---------------------------------------------------------------------------------------------
  76119. * Copyright (c) Microsoft Corporation. All rights reserved.
  76120. * Licensed under the MIT License. See License.txt in the project root for license information.
  76121. *--------------------------------------------------------------------------------------------*/
  76122. define(__m[513/*vs/editor/browser/view/viewOverlays*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,60/*vs/editor/browser/config/configuration*/,143/*vs/editor/browser/view/viewLayer*/,37/*vs/editor/browser/view/viewPart*/]), function (require, exports, fastDomNode_1, configuration_1, viewLayer_1, viewPart_1) {
  76123. "use strict";
  76124. Object.defineProperty(exports, "__esModule", { value: true });
  76125. var ViewOverlays = /** @class */ (function (_super) {
  76126. __extends(ViewOverlays, _super);
  76127. function ViewOverlays(context) {
  76128. var _this = _super.call(this, context) || this;
  76129. _this._visibleLines = new viewLayer_1.VisibleLinesCollection(_this);
  76130. _this.domNode = _this._visibleLines.domNode;
  76131. _this._dynamicOverlays = [];
  76132. _this._isFocused = false;
  76133. _this.domNode.setClassName('view-overlays');
  76134. return _this;
  76135. }
  76136. ViewOverlays.prototype.shouldRender = function () {
  76137. if (_super.prototype.shouldRender.call(this)) {
  76138. return true;
  76139. }
  76140. for (var i = 0, len = this._dynamicOverlays.length; i < len; i++) {
  76141. var dynamicOverlay = this._dynamicOverlays[i];
  76142. if (dynamicOverlay.shouldRender()) {
  76143. return true;
  76144. }
  76145. }
  76146. return false;
  76147. };
  76148. ViewOverlays.prototype.dispose = function () {
  76149. _super.prototype.dispose.call(this);
  76150. for (var i = 0, len = this._dynamicOverlays.length; i < len; i++) {
  76151. var dynamicOverlay = this._dynamicOverlays[i];
  76152. dynamicOverlay.dispose();
  76153. }
  76154. this._dynamicOverlays = [];
  76155. };
  76156. ViewOverlays.prototype.getDomNode = function () {
  76157. return this.domNode;
  76158. };
  76159. // ---- begin IVisibleLinesHost
  76160. ViewOverlays.prototype.createVisibleLine = function () {
  76161. return new ViewOverlayLine(this._context.configuration, this._dynamicOverlays);
  76162. };
  76163. // ---- end IVisibleLinesHost
  76164. ViewOverlays.prototype.addDynamicOverlay = function (overlay) {
  76165. this._dynamicOverlays.push(overlay);
  76166. };
  76167. // ----- event handlers
  76168. ViewOverlays.prototype.onConfigurationChanged = function (e) {
  76169. this._visibleLines.onConfigurationChanged(e);
  76170. var startLineNumber = this._visibleLines.getStartLineNumber();
  76171. var endLineNumber = this._visibleLines.getEndLineNumber();
  76172. for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
  76173. var line = this._visibleLines.getVisibleLine(lineNumber);
  76174. line.onConfigurationChanged(e);
  76175. }
  76176. return true;
  76177. };
  76178. ViewOverlays.prototype.onFlushed = function (e) {
  76179. return this._visibleLines.onFlushed(e);
  76180. };
  76181. ViewOverlays.prototype.onFocusChanged = function (e) {
  76182. this._isFocused = e.isFocused;
  76183. return true;
  76184. };
  76185. ViewOverlays.prototype.onLinesChanged = function (e) {
  76186. return this._visibleLines.onLinesChanged(e);
  76187. };
  76188. ViewOverlays.prototype.onLinesDeleted = function (e) {
  76189. return this._visibleLines.onLinesDeleted(e);
  76190. };
  76191. ViewOverlays.prototype.onLinesInserted = function (e) {
  76192. return this._visibleLines.onLinesInserted(e);
  76193. };
  76194. ViewOverlays.prototype.onScrollChanged = function (e) {
  76195. return this._visibleLines.onScrollChanged(e) || true;
  76196. };
  76197. ViewOverlays.prototype.onTokensChanged = function (e) {
  76198. return this._visibleLines.onTokensChanged(e);
  76199. };
  76200. ViewOverlays.prototype.onZonesChanged = function (e) {
  76201. return this._visibleLines.onZonesChanged(e);
  76202. };
  76203. // ----- end event handlers
  76204. ViewOverlays.prototype.prepareRender = function (ctx) {
  76205. var toRender = this._dynamicOverlays.filter(function (overlay) { return overlay.shouldRender(); });
  76206. for (var i = 0, len = toRender.length; i < len; i++) {
  76207. var dynamicOverlay = toRender[i];
  76208. dynamicOverlay.prepareRender(ctx);
  76209. dynamicOverlay.onDidRender();
  76210. }
  76211. };
  76212. ViewOverlays.prototype.render = function (ctx) {
  76213. // Overwriting to bypass `shouldRender` flag
  76214. this._viewOverlaysRender(ctx);
  76215. this.domNode.toggleClassName('focused', this._isFocused);
  76216. };
  76217. ViewOverlays.prototype._viewOverlaysRender = function (ctx) {
  76218. this._visibleLines.renderLines(ctx.viewportData);
  76219. };
  76220. return ViewOverlays;
  76221. }(viewPart_1.ViewPart));
  76222. exports.ViewOverlays = ViewOverlays;
  76223. var ViewOverlayLine = /** @class */ (function () {
  76224. function ViewOverlayLine(configuration, dynamicOverlays) {
  76225. this._configuration = configuration;
  76226. this._lineHeight = this._configuration.options.get(49 /* lineHeight */);
  76227. this._dynamicOverlays = dynamicOverlays;
  76228. this._domNode = null;
  76229. this._renderedContent = null;
  76230. }
  76231. ViewOverlayLine.prototype.getDomNode = function () {
  76232. if (!this._domNode) {
  76233. return null;
  76234. }
  76235. return this._domNode.domNode;
  76236. };
  76237. ViewOverlayLine.prototype.setDomNode = function (domNode) {
  76238. this._domNode = fastDomNode_1.createFastDomNode(domNode);
  76239. };
  76240. ViewOverlayLine.prototype.onContentChanged = function () {
  76241. // Nothing
  76242. };
  76243. ViewOverlayLine.prototype.onTokensChanged = function () {
  76244. // Nothing
  76245. };
  76246. ViewOverlayLine.prototype.onConfigurationChanged = function (e) {
  76247. this._lineHeight = this._configuration.options.get(49 /* lineHeight */);
  76248. };
  76249. ViewOverlayLine.prototype.renderLine = function (lineNumber, deltaTop, viewportData, sb) {
  76250. var result = '';
  76251. for (var i = 0, len = this._dynamicOverlays.length; i < len; i++) {
  76252. var dynamicOverlay = this._dynamicOverlays[i];
  76253. result += dynamicOverlay.render(viewportData.startLineNumber, lineNumber);
  76254. }
  76255. if (this._renderedContent === result) {
  76256. // No rendering needed
  76257. return false;
  76258. }
  76259. this._renderedContent = result;
  76260. sb.appendASCIIString('<div style="position:absolute;top:');
  76261. sb.appendASCIIString(String(deltaTop));
  76262. sb.appendASCIIString('px;width:100%;height:');
  76263. sb.appendASCIIString(String(this._lineHeight));
  76264. sb.appendASCIIString('px;">');
  76265. sb.appendASCIIString(result);
  76266. sb.appendASCIIString('</div>');
  76267. return true;
  76268. };
  76269. ViewOverlayLine.prototype.layoutLine = function (lineNumber, deltaTop) {
  76270. if (this._domNode) {
  76271. this._domNode.setTop(deltaTop);
  76272. this._domNode.setHeight(this._lineHeight);
  76273. }
  76274. };
  76275. return ViewOverlayLine;
  76276. }());
  76277. exports.ViewOverlayLine = ViewOverlayLine;
  76278. var ContentViewOverlays = /** @class */ (function (_super) {
  76279. __extends(ContentViewOverlays, _super);
  76280. function ContentViewOverlays(context) {
  76281. var _this = _super.call(this, context) || this;
  76282. var options = _this._context.configuration.options;
  76283. var layoutInfo = options.get(107 /* layoutInfo */);
  76284. _this._contentWidth = layoutInfo.contentWidth;
  76285. _this.domNode.setHeight(0);
  76286. return _this;
  76287. }
  76288. // --- begin event handlers
  76289. ContentViewOverlays.prototype.onConfigurationChanged = function (e) {
  76290. var options = this._context.configuration.options;
  76291. var layoutInfo = options.get(107 /* layoutInfo */);
  76292. this._contentWidth = layoutInfo.contentWidth;
  76293. return _super.prototype.onConfigurationChanged.call(this, e) || true;
  76294. };
  76295. ContentViewOverlays.prototype.onScrollChanged = function (e) {
  76296. return _super.prototype.onScrollChanged.call(this, e) || e.scrollWidthChanged;
  76297. };
  76298. // --- end event handlers
  76299. ContentViewOverlays.prototype._viewOverlaysRender = function (ctx) {
  76300. _super.prototype._viewOverlaysRender.call(this, ctx);
  76301. this.domNode.setWidth(Math.max(ctx.scrollWidth, this._contentWidth));
  76302. };
  76303. return ContentViewOverlays;
  76304. }(ViewOverlays));
  76305. exports.ContentViewOverlays = ContentViewOverlays;
  76306. var MarginViewOverlays = /** @class */ (function (_super) {
  76307. __extends(MarginViewOverlays, _super);
  76308. function MarginViewOverlays(context) {
  76309. var _this = _super.call(this, context) || this;
  76310. var options = _this._context.configuration.options;
  76311. var layoutInfo = options.get(107 /* layoutInfo */);
  76312. _this._contentLeft = layoutInfo.contentLeft;
  76313. _this.domNode.setClassName('margin-view-overlays');
  76314. _this.domNode.setWidth(1);
  76315. configuration_1.Configuration.applyFontInfo(_this.domNode, options.get(34 /* fontInfo */));
  76316. return _this;
  76317. }
  76318. MarginViewOverlays.prototype.onConfigurationChanged = function (e) {
  76319. var options = this._context.configuration.options;
  76320. configuration_1.Configuration.applyFontInfo(this.domNode, options.get(34 /* fontInfo */));
  76321. var layoutInfo = options.get(107 /* layoutInfo */);
  76322. this._contentLeft = layoutInfo.contentLeft;
  76323. return _super.prototype.onConfigurationChanged.call(this, e) || true;
  76324. };
  76325. MarginViewOverlays.prototype.onScrollChanged = function (e) {
  76326. return _super.prototype.onScrollChanged.call(this, e) || e.scrollHeightChanged;
  76327. };
  76328. MarginViewOverlays.prototype._viewOverlaysRender = function (ctx) {
  76329. _super.prototype._viewOverlaysRender.call(this, ctx);
  76330. var height = Math.min(ctx.scrollHeight, 1000000);
  76331. this.domNode.setHeight(height);
  76332. this.domNode.setWidth(this._contentLeft);
  76333. };
  76334. return MarginViewOverlays;
  76335. }(ViewOverlays));
  76336. exports.MarginViewOverlays = MarginViewOverlays;
  76337. });
  76338. /*---------------------------------------------------------------------------------------------
  76339. * Copyright (c) Microsoft Corporation. All rights reserved.
  76340. * Licensed under the MIT License. See License.txt in the project root for license information.
  76341. *--------------------------------------------------------------------------------------------*/
  76342. define(__m[514/*vs/editor/browser/viewParts/viewCursors/viewCursor*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,28/*vs/base/browser/fastDomNode*/,5/*vs/base/common/strings*/,60/*vs/editor/browser/config/configuration*/,33/*vs/editor/common/config/editorOptions*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/]), function (require, exports, dom, fastDomNode_1, strings, configuration_1, editorOptions_1, position_1, range_1) {
  76343. "use strict";
  76344. Object.defineProperty(exports, "__esModule", { value: true });
  76345. var ViewCursorRenderData = /** @class */ (function () {
  76346. function ViewCursorRenderData(top, left, width, height, textContent, textContentClassName) {
  76347. this.top = top;
  76348. this.left = left;
  76349. this.width = width;
  76350. this.height = height;
  76351. this.textContent = textContent;
  76352. this.textContentClassName = textContentClassName;
  76353. }
  76354. return ViewCursorRenderData;
  76355. }());
  76356. var ViewCursor = /** @class */ (function () {
  76357. function ViewCursor(context) {
  76358. this._context = context;
  76359. var options = this._context.configuration.options;
  76360. var fontInfo = options.get(34 /* fontInfo */);
  76361. this._cursorStyle = options.get(18 /* cursorStyle */);
  76362. this._lineHeight = options.get(49 /* lineHeight */);
  76363. this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
  76364. this._lineCursorWidth = Math.min(options.get(21 /* cursorWidth */), this._typicalHalfwidthCharacterWidth);
  76365. this._isVisible = true;
  76366. // Create the dom node
  76367. this._domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  76368. this._domNode.setClassName('cursor');
  76369. this._domNode.setHeight(this._lineHeight);
  76370. this._domNode.setTop(0);
  76371. this._domNode.setLeft(0);
  76372. configuration_1.Configuration.applyFontInfo(this._domNode, fontInfo);
  76373. this._domNode.setDisplay('none');
  76374. this._position = new position_1.Position(1, 1);
  76375. this._lastRenderedContent = '';
  76376. this._renderData = null;
  76377. }
  76378. ViewCursor.prototype.getDomNode = function () {
  76379. return this._domNode;
  76380. };
  76381. ViewCursor.prototype.getPosition = function () {
  76382. return this._position;
  76383. };
  76384. ViewCursor.prototype.show = function () {
  76385. if (!this._isVisible) {
  76386. this._domNode.setVisibility('inherit');
  76387. this._isVisible = true;
  76388. }
  76389. };
  76390. ViewCursor.prototype.hide = function () {
  76391. if (this._isVisible) {
  76392. this._domNode.setVisibility('hidden');
  76393. this._isVisible = false;
  76394. }
  76395. };
  76396. ViewCursor.prototype.onConfigurationChanged = function (e) {
  76397. var options = this._context.configuration.options;
  76398. var fontInfo = options.get(34 /* fontInfo */);
  76399. this._cursorStyle = options.get(18 /* cursorStyle */);
  76400. this._lineHeight = options.get(49 /* lineHeight */);
  76401. this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
  76402. this._lineCursorWidth = Math.min(options.get(21 /* cursorWidth */), this._typicalHalfwidthCharacterWidth);
  76403. configuration_1.Configuration.applyFontInfo(this._domNode, fontInfo);
  76404. return true;
  76405. };
  76406. ViewCursor.prototype.onCursorPositionChanged = function (position) {
  76407. this._position = position;
  76408. return true;
  76409. };
  76410. ViewCursor.prototype._prepareRender = function (ctx) {
  76411. var textContent = '';
  76412. if (this._cursorStyle === editorOptions_1.TextEditorCursorStyle.Line || this._cursorStyle === editorOptions_1.TextEditorCursorStyle.LineThin) {
  76413. var visibleRange = ctx.visibleRangeForPosition(this._position);
  76414. if (!visibleRange || visibleRange.outsideRenderedLine) {
  76415. // Outside viewport
  76416. return null;
  76417. }
  76418. var width_1;
  76419. if (this._cursorStyle === editorOptions_1.TextEditorCursorStyle.Line) {
  76420. width_1 = dom.computeScreenAwareSize(this._lineCursorWidth > 0 ? this._lineCursorWidth : 2);
  76421. if (width_1 > 2) {
  76422. var lineContent_1 = this._context.model.getLineContent(this._position.lineNumber);
  76423. var nextCharLength_1 = strings.nextCharLength(lineContent_1, this._position.column - 1);
  76424. textContent = lineContent_1.substr(this._position.column - 1, nextCharLength_1);
  76425. }
  76426. }
  76427. else {
  76428. width_1 = dom.computeScreenAwareSize(1);
  76429. }
  76430. var left = visibleRange.left;
  76431. if (width_1 >= 2 && left >= 1) {
  76432. // try to center cursor
  76433. left -= 1;
  76434. }
  76435. var top_1 = ctx.getVerticalOffsetForLineNumber(this._position.lineNumber) - ctx.bigNumbersDelta;
  76436. return new ViewCursorRenderData(top_1, left, width_1, this._lineHeight, textContent, '');
  76437. }
  76438. var lineContent = this._context.model.getLineContent(this._position.lineNumber);
  76439. var nextCharLength = strings.nextCharLength(lineContent, this._position.column - 1);
  76440. var visibleRangeForCharacter = ctx.linesVisibleRangesForRange(new range_1.Range(this._position.lineNumber, this._position.column, this._position.lineNumber, this._position.column + nextCharLength), false);
  76441. if (!visibleRangeForCharacter || visibleRangeForCharacter.length === 0) {
  76442. // Outside viewport
  76443. return null;
  76444. }
  76445. var firstVisibleRangeForCharacter = visibleRangeForCharacter[0];
  76446. if (firstVisibleRangeForCharacter.outsideRenderedLine || firstVisibleRangeForCharacter.ranges.length === 0) {
  76447. // Outside viewport
  76448. return null;
  76449. }
  76450. var range = firstVisibleRangeForCharacter.ranges[0];
  76451. var width = range.width < 1 ? this._typicalHalfwidthCharacterWidth : range.width;
  76452. var textContentClassName = '';
  76453. if (this._cursorStyle === editorOptions_1.TextEditorCursorStyle.Block) {
  76454. var lineData = this._context.model.getViewLineData(this._position.lineNumber);
  76455. textContent = lineContent.substr(this._position.column - 1, nextCharLength);
  76456. var tokenIndex = lineData.tokens.findTokenIndexAtOffset(this._position.column - 1);
  76457. textContentClassName = lineData.tokens.getClassName(tokenIndex);
  76458. }
  76459. var top = ctx.getVerticalOffsetForLineNumber(this._position.lineNumber) - ctx.bigNumbersDelta;
  76460. var height = this._lineHeight;
  76461. // Underline might interfere with clicking
  76462. if (this._cursorStyle === editorOptions_1.TextEditorCursorStyle.Underline || this._cursorStyle === editorOptions_1.TextEditorCursorStyle.UnderlineThin) {
  76463. top += this._lineHeight - 2;
  76464. height = 2;
  76465. }
  76466. return new ViewCursorRenderData(top, range.left, width, height, textContent, textContentClassName);
  76467. };
  76468. ViewCursor.prototype.prepareRender = function (ctx) {
  76469. this._renderData = this._prepareRender(ctx);
  76470. };
  76471. ViewCursor.prototype.render = function (ctx) {
  76472. if (!this._renderData) {
  76473. this._domNode.setDisplay('none');
  76474. return null;
  76475. }
  76476. if (this._lastRenderedContent !== this._renderData.textContent) {
  76477. this._lastRenderedContent = this._renderData.textContent;
  76478. this._domNode.domNode.textContent = this._lastRenderedContent;
  76479. }
  76480. this._domNode.setClassName('cursor ' + this._renderData.textContentClassName);
  76481. this._domNode.setDisplay('block');
  76482. this._domNode.setTop(this._renderData.top);
  76483. this._domNode.setLeft(this._renderData.left);
  76484. this._domNode.setWidth(this._renderData.width);
  76485. this._domNode.setLineHeight(this._renderData.height);
  76486. this._domNode.setHeight(this._renderData.height);
  76487. return {
  76488. domNode: this._domNode.domNode,
  76489. position: this._position,
  76490. contentLeft: this._renderData.left,
  76491. height: this._renderData.height,
  76492. width: 2
  76493. };
  76494. };
  76495. return ViewCursor;
  76496. }());
  76497. exports.ViewCursor = ViewCursor;
  76498. });
  76499. /*---------------------------------------------------------------------------------------------
  76500. * Copyright (c) Microsoft Corporation. All rights reserved.
  76501. * Licensed under the MIT License. See License.txt in the project root for license information.
  76502. *--------------------------------------------------------------------------------------------*/
  76503. define(__m[515/*vs/editor/common/services/languagesRegistry*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,252/*vs/base/common/mime*/,5/*vs/base/common/strings*/,17/*vs/editor/common/modes*/,118/*vs/editor/common/modes/modesRegistry*/,63/*vs/editor/common/modes/nullMode*/,85/*vs/platform/configuration/common/configurationRegistry*/,42/*vs/platform/registry/common/platform*/]), function (require, exports, errors_1, event_1, lifecycle_1, mime, strings, modes_1, modesRegistry_1, nullMode_1, configurationRegistry_1, platform_1) {
  76504. "use strict";
  76505. Object.defineProperty(exports, "__esModule", { value: true });
  76506. var hasOwnProperty = Object.prototype.hasOwnProperty;
  76507. var LanguagesRegistry = /** @class */ (function (_super) {
  76508. __extends(LanguagesRegistry, _super);
  76509. function LanguagesRegistry(useModesRegistry, warnOnOverwrite) {
  76510. if (useModesRegistry === void 0) { useModesRegistry = true; }
  76511. if (warnOnOverwrite === void 0) { warnOnOverwrite = false; }
  76512. var _this = _super.call(this) || this;
  76513. _this._onDidChange = _this._register(new event_1.Emitter());
  76514. _this.onDidChange = _this._onDidChange.event;
  76515. _this._warnOnOverwrite = warnOnOverwrite;
  76516. _this._nextLanguageId2 = 1;
  76517. _this._languageIdToLanguage = [];
  76518. _this._languageToLanguageId = Object.create(null);
  76519. _this._languages = {};
  76520. _this._mimeTypesMap = {};
  76521. _this._nameMap = {};
  76522. _this._lowercaseNameMap = {};
  76523. if (useModesRegistry) {
  76524. _this._initializeFromRegistry();
  76525. _this._register(modesRegistry_1.ModesRegistry.onDidChangeLanguages(function (m) { return _this._initializeFromRegistry(); }));
  76526. }
  76527. return _this;
  76528. }
  76529. LanguagesRegistry.prototype._initializeFromRegistry = function () {
  76530. this._languages = {};
  76531. this._mimeTypesMap = {};
  76532. this._nameMap = {};
  76533. this._lowercaseNameMap = {};
  76534. var desc = modesRegistry_1.ModesRegistry.getLanguages();
  76535. this._registerLanguages(desc);
  76536. };
  76537. LanguagesRegistry.prototype._registerLanguages = function (desc) {
  76538. var _this = this;
  76539. for (var _i = 0, desc_1 = desc; _i < desc_1.length; _i++) {
  76540. var d = desc_1[_i];
  76541. this._registerLanguage(d);
  76542. }
  76543. // Rebuild fast path maps
  76544. this._mimeTypesMap = {};
  76545. this._nameMap = {};
  76546. this._lowercaseNameMap = {};
  76547. Object.keys(this._languages).forEach(function (langId) {
  76548. var language = _this._languages[langId];
  76549. if (language.name) {
  76550. _this._nameMap[language.name] = language.identifier;
  76551. }
  76552. language.aliases.forEach(function (alias) {
  76553. _this._lowercaseNameMap[alias.toLowerCase()] = language.identifier;
  76554. });
  76555. language.mimetypes.forEach(function (mimetype) {
  76556. _this._mimeTypesMap[mimetype] = language.identifier;
  76557. });
  76558. });
  76559. platform_1.Registry.as(configurationRegistry_1.Extensions.Configuration).registerOverrideIdentifiers(modesRegistry_1.ModesRegistry.getLanguages().map(function (language) { return language.id; }));
  76560. this._onDidChange.fire();
  76561. };
  76562. LanguagesRegistry.prototype._getLanguageId = function (language) {
  76563. if (this._languageToLanguageId[language]) {
  76564. return this._languageToLanguageId[language];
  76565. }
  76566. var languageId = this._nextLanguageId2++;
  76567. this._languageIdToLanguage[languageId] = language;
  76568. this._languageToLanguageId[language] = languageId;
  76569. return languageId;
  76570. };
  76571. LanguagesRegistry.prototype._registerLanguage = function (lang) {
  76572. var langId = lang.id;
  76573. var resolvedLanguage;
  76574. if (hasOwnProperty.call(this._languages, langId)) {
  76575. resolvedLanguage = this._languages[langId];
  76576. }
  76577. else {
  76578. var languageId = this._getLanguageId(langId);
  76579. resolvedLanguage = {
  76580. identifier: new modes_1.LanguageIdentifier(langId, languageId),
  76581. name: null,
  76582. mimetypes: [],
  76583. aliases: [],
  76584. extensions: [],
  76585. filenames: [],
  76586. configurationFiles: []
  76587. };
  76588. this._languages[langId] = resolvedLanguage;
  76589. }
  76590. this._mergeLanguage(resolvedLanguage, lang);
  76591. };
  76592. LanguagesRegistry.prototype._mergeLanguage = function (resolvedLanguage, lang) {
  76593. var _a;
  76594. var langId = lang.id;
  76595. var primaryMime = null;
  76596. if (Array.isArray(lang.mimetypes) && lang.mimetypes.length > 0) {
  76597. (_a = resolvedLanguage.mimetypes).push.apply(_a, lang.mimetypes);
  76598. primaryMime = lang.mimetypes[0];
  76599. }
  76600. if (!primaryMime) {
  76601. primaryMime = "text/x-" + langId;
  76602. resolvedLanguage.mimetypes.push(primaryMime);
  76603. }
  76604. if (Array.isArray(lang.extensions)) {
  76605. for (var _i = 0, _b = lang.extensions; _i < _b.length; _i++) {
  76606. var extension = _b[_i];
  76607. mime.registerTextMime({ id: langId, mime: primaryMime, extension: extension }, this._warnOnOverwrite);
  76608. resolvedLanguage.extensions.push(extension);
  76609. }
  76610. }
  76611. if (Array.isArray(lang.filenames)) {
  76612. for (var _c = 0, _d = lang.filenames; _c < _d.length; _c++) {
  76613. var filename = _d[_c];
  76614. mime.registerTextMime({ id: langId, mime: primaryMime, filename: filename }, this._warnOnOverwrite);
  76615. resolvedLanguage.filenames.push(filename);
  76616. }
  76617. }
  76618. if (Array.isArray(lang.filenamePatterns)) {
  76619. for (var _e = 0, _f = lang.filenamePatterns; _e < _f.length; _e++) {
  76620. var filenamePattern = _f[_e];
  76621. mime.registerTextMime({ id: langId, mime: primaryMime, filepattern: filenamePattern }, this._warnOnOverwrite);
  76622. }
  76623. }
  76624. if (typeof lang.firstLine === 'string' && lang.firstLine.length > 0) {
  76625. var firstLineRegexStr = lang.firstLine;
  76626. if (firstLineRegexStr.charAt(0) !== '^') {
  76627. firstLineRegexStr = '^' + firstLineRegexStr;
  76628. }
  76629. try {
  76630. var firstLineRegex = new RegExp(firstLineRegexStr);
  76631. if (!strings.regExpLeadsToEndlessLoop(firstLineRegex)) {
  76632. mime.registerTextMime({ id: langId, mime: primaryMime, firstline: firstLineRegex }, this._warnOnOverwrite);
  76633. }
  76634. }
  76635. catch (err) {
  76636. // Most likely, the regex was bad
  76637. errors_1.onUnexpectedError(err);
  76638. }
  76639. }
  76640. resolvedLanguage.aliases.push(langId);
  76641. var langAliases = null;
  76642. if (typeof lang.aliases !== 'undefined' && Array.isArray(lang.aliases)) {
  76643. if (lang.aliases.length === 0) {
  76644. // signal that this language should not get a name
  76645. langAliases = [null];
  76646. }
  76647. else {
  76648. langAliases = lang.aliases;
  76649. }
  76650. }
  76651. if (langAliases !== null) {
  76652. for (var _g = 0, langAliases_1 = langAliases; _g < langAliases_1.length; _g++) {
  76653. var langAlias = langAliases_1[_g];
  76654. if (!langAlias || langAlias.length === 0) {
  76655. continue;
  76656. }
  76657. resolvedLanguage.aliases.push(langAlias);
  76658. }
  76659. }
  76660. var containsAliases = (langAliases !== null && langAliases.length > 0);
  76661. if (containsAliases && langAliases[0] === null) {
  76662. // signal that this language should not get a name
  76663. }
  76664. else {
  76665. var bestName = (containsAliases ? langAliases[0] : null) || langId;
  76666. if (containsAliases || !resolvedLanguage.name) {
  76667. resolvedLanguage.name = bestName;
  76668. }
  76669. }
  76670. if (lang.configuration) {
  76671. resolvedLanguage.configurationFiles.push(lang.configuration);
  76672. }
  76673. };
  76674. LanguagesRegistry.prototype.isRegisteredMode = function (mimetypeOrModeId) {
  76675. // Is this a known mime type ?
  76676. if (hasOwnProperty.call(this._mimeTypesMap, mimetypeOrModeId)) {
  76677. return true;
  76678. }
  76679. // Is this a known mode id ?
  76680. return hasOwnProperty.call(this._languages, mimetypeOrModeId);
  76681. };
  76682. LanguagesRegistry.prototype.getModeIdForLanguageNameLowercase = function (languageNameLower) {
  76683. if (!hasOwnProperty.call(this._lowercaseNameMap, languageNameLower)) {
  76684. return null;
  76685. }
  76686. return this._lowercaseNameMap[languageNameLower].language;
  76687. };
  76688. LanguagesRegistry.prototype.extractModeIds = function (commaSeparatedMimetypesOrCommaSeparatedIds) {
  76689. var _this = this;
  76690. if (!commaSeparatedMimetypesOrCommaSeparatedIds) {
  76691. return [];
  76692. }
  76693. return (commaSeparatedMimetypesOrCommaSeparatedIds.
  76694. split(',').
  76695. map(function (mimeTypeOrId) { return mimeTypeOrId.trim(); }).
  76696. map(function (mimeTypeOrId) {
  76697. if (hasOwnProperty.call(_this._mimeTypesMap, mimeTypeOrId)) {
  76698. return _this._mimeTypesMap[mimeTypeOrId].language;
  76699. }
  76700. return mimeTypeOrId;
  76701. }).
  76702. filter(function (modeId) {
  76703. return hasOwnProperty.call(_this._languages, modeId);
  76704. }));
  76705. };
  76706. LanguagesRegistry.prototype.getLanguageIdentifier = function (_modeId) {
  76707. if (_modeId === nullMode_1.NULL_MODE_ID || _modeId === 0 /* Null */) {
  76708. return nullMode_1.NULL_LANGUAGE_IDENTIFIER;
  76709. }
  76710. var modeId;
  76711. if (typeof _modeId === 'string') {
  76712. modeId = _modeId;
  76713. }
  76714. else {
  76715. modeId = this._languageIdToLanguage[_modeId];
  76716. if (!modeId) {
  76717. return null;
  76718. }
  76719. }
  76720. if (!hasOwnProperty.call(this._languages, modeId)) {
  76721. return null;
  76722. }
  76723. return this._languages[modeId].identifier;
  76724. };
  76725. LanguagesRegistry.prototype.getModeIdsFromFilepathOrFirstLine = function (resource, firstLine) {
  76726. if (!resource && !firstLine) {
  76727. return [];
  76728. }
  76729. var mimeTypes = mime.guessMimeTypes(resource, firstLine);
  76730. return this.extractModeIds(mimeTypes.join(','));
  76731. };
  76732. return LanguagesRegistry;
  76733. }(lifecycle_1.Disposable));
  76734. exports.LanguagesRegistry = LanguagesRegistry;
  76735. });
  76736. /*---------------------------------------------------------------------------------------------
  76737. * Copyright (c) Microsoft Corporation. All rights reserved.
  76738. * Licensed under the MIT License. See License.txt in the project root for license information.
  76739. *--------------------------------------------------------------------------------------------*/
  76740. define(__m[516/*vs/editor/common/services/modeServiceImpl*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,349/*vs/editor/common/modes/abstractMode*/,63/*vs/editor/common/modes/nullMode*/,515/*vs/editor/common/services/languagesRegistry*/,19/*vs/base/common/arrays*/]), function (require, exports, event_1, lifecycle_1, abstractMode_1, nullMode_1, languagesRegistry_1, arrays_1) {
  76741. "use strict";
  76742. Object.defineProperty(exports, "__esModule", { value: true });
  76743. var LanguageSelection = /** @class */ (function (_super) {
  76744. __extends(LanguageSelection, _super);
  76745. function LanguageSelection(onLanguagesMaybeChanged, selector) {
  76746. var _this = _super.call(this) || this;
  76747. _this._onDidChange = _this._register(new event_1.Emitter());
  76748. _this.onDidChange = _this._onDidChange.event;
  76749. _this._selector = selector;
  76750. _this.languageIdentifier = _this._selector();
  76751. _this._register(onLanguagesMaybeChanged(function () { return _this._evaluate(); }));
  76752. return _this;
  76753. }
  76754. LanguageSelection.prototype._evaluate = function () {
  76755. var languageIdentifier = this._selector();
  76756. if (languageIdentifier.id === this.languageIdentifier.id) {
  76757. // no change
  76758. return;
  76759. }
  76760. this.languageIdentifier = languageIdentifier;
  76761. this._onDidChange.fire(this.languageIdentifier);
  76762. };
  76763. return LanguageSelection;
  76764. }(lifecycle_1.Disposable));
  76765. var ModeServiceImpl = /** @class */ (function () {
  76766. function ModeServiceImpl(warnOnOverwrite) {
  76767. var _this = this;
  76768. if (warnOnOverwrite === void 0) { warnOnOverwrite = false; }
  76769. this._onDidCreateMode = new event_1.Emitter();
  76770. this.onDidCreateMode = this._onDidCreateMode.event;
  76771. this._onLanguagesMaybeChanged = new event_1.Emitter();
  76772. this.onLanguagesMaybeChanged = this._onLanguagesMaybeChanged.event;
  76773. this._instantiatedModes = {};
  76774. this._registry = new languagesRegistry_1.LanguagesRegistry(true, warnOnOverwrite);
  76775. this._registry.onDidChange(function () { return _this._onLanguagesMaybeChanged.fire(); });
  76776. }
  76777. ModeServiceImpl.prototype.isRegisteredMode = function (mimetypeOrModeId) {
  76778. return this._registry.isRegisteredMode(mimetypeOrModeId);
  76779. };
  76780. ModeServiceImpl.prototype.getModeIdForLanguageName = function (alias) {
  76781. return this._registry.getModeIdForLanguageNameLowercase(alias);
  76782. };
  76783. ModeServiceImpl.prototype.getModeIdByFilepathOrFirstLine = function (resource, firstLine) {
  76784. var modeIds = this._registry.getModeIdsFromFilepathOrFirstLine(resource, firstLine);
  76785. return arrays_1.firstOrDefault(modeIds, null);
  76786. };
  76787. ModeServiceImpl.prototype.getModeId = function (commaSeparatedMimetypesOrCommaSeparatedIds) {
  76788. var modeIds = this._registry.extractModeIds(commaSeparatedMimetypesOrCommaSeparatedIds);
  76789. return arrays_1.firstOrDefault(modeIds, null);
  76790. };
  76791. ModeServiceImpl.prototype.getLanguageIdentifier = function (modeId) {
  76792. return this._registry.getLanguageIdentifier(modeId);
  76793. };
  76794. // --- instantiation
  76795. ModeServiceImpl.prototype.create = function (commaSeparatedMimetypesOrCommaSeparatedIds) {
  76796. var _this = this;
  76797. return new LanguageSelection(this.onLanguagesMaybeChanged, function () {
  76798. var modeId = _this.getModeId(commaSeparatedMimetypesOrCommaSeparatedIds);
  76799. return _this._createModeAndGetLanguageIdentifier(modeId);
  76800. });
  76801. };
  76802. ModeServiceImpl.prototype.createByFilepathOrFirstLine = function (resource, firstLine) {
  76803. var _this = this;
  76804. return new LanguageSelection(this.onLanguagesMaybeChanged, function () {
  76805. var modeId = _this.getModeIdByFilepathOrFirstLine(resource, firstLine);
  76806. return _this._createModeAndGetLanguageIdentifier(modeId);
  76807. });
  76808. };
  76809. ModeServiceImpl.prototype._createModeAndGetLanguageIdentifier = function (modeId) {
  76810. // Fall back to plain text if no mode was found
  76811. var languageIdentifier = this.getLanguageIdentifier(modeId || 'plaintext') || nullMode_1.NULL_LANGUAGE_IDENTIFIER;
  76812. this._getOrCreateMode(languageIdentifier.language);
  76813. return languageIdentifier;
  76814. };
  76815. ModeServiceImpl.prototype.triggerMode = function (commaSeparatedMimetypesOrCommaSeparatedIds) {
  76816. var modeId = this.getModeId(commaSeparatedMimetypesOrCommaSeparatedIds);
  76817. // Fall back to plain text if no mode was found
  76818. this._getOrCreateMode(modeId || 'plaintext');
  76819. };
  76820. ModeServiceImpl.prototype._getOrCreateMode = function (modeId) {
  76821. if (!this._instantiatedModes.hasOwnProperty(modeId)) {
  76822. var languageIdentifier = this.getLanguageIdentifier(modeId) || nullMode_1.NULL_LANGUAGE_IDENTIFIER;
  76823. this._instantiatedModes[modeId] = new abstractMode_1.FrankensteinMode(languageIdentifier);
  76824. this._onDidCreateMode.fire(this._instantiatedModes[modeId]);
  76825. }
  76826. return this._instantiatedModes[modeId];
  76827. };
  76828. return ModeServiceImpl;
  76829. }());
  76830. exports.ModeServiceImpl = ModeServiceImpl;
  76831. });
  76832. define(__m[43/*vs/platform/configuration/common/configuration*/], __M([0/*require*/,1/*exports*/,42/*vs/platform/registry/common/platform*/,11/*vs/platform/instantiation/common/instantiation*/,85/*vs/platform/configuration/common/configurationRegistry*/]), function (require, exports, platform_1, instantiation_1, configurationRegistry_1) {
  76833. "use strict";
  76834. Object.defineProperty(exports, "__esModule", { value: true });
  76835. exports.IConfigurationService = instantiation_1.createDecorator('configurationService');
  76836. function toValuesTree(properties, conflictReporter) {
  76837. var root = Object.create(null);
  76838. for (var key in properties) {
  76839. addToValueTree(root, key, properties[key], conflictReporter);
  76840. }
  76841. return root;
  76842. }
  76843. exports.toValuesTree = toValuesTree;
  76844. function addToValueTree(settingsTreeRoot, key, value, conflictReporter) {
  76845. var segments = key.split('.');
  76846. var last = segments.pop();
  76847. var curr = settingsTreeRoot;
  76848. for (var i = 0; i < segments.length; i++) {
  76849. var s = segments[i];
  76850. var obj = curr[s];
  76851. switch (typeof obj) {
  76852. case 'undefined':
  76853. obj = curr[s] = Object.create(null);
  76854. break;
  76855. case 'object':
  76856. break;
  76857. default:
  76858. conflictReporter("Ignoring " + key + " as " + segments.slice(0, i + 1).join('.') + " is " + JSON.stringify(obj));
  76859. return;
  76860. }
  76861. curr = obj;
  76862. }
  76863. if (typeof curr === 'object') {
  76864. curr[last] = value; // workaround https://github.com/Microsoft/vscode/issues/13606
  76865. }
  76866. else {
  76867. conflictReporter("Ignoring " + key + " as " + segments.join('.') + " is " + JSON.stringify(curr));
  76868. }
  76869. }
  76870. exports.addToValueTree = addToValueTree;
  76871. function removeFromValueTree(valueTree, key) {
  76872. var segments = key.split('.');
  76873. doRemoveFromValueTree(valueTree, segments);
  76874. }
  76875. exports.removeFromValueTree = removeFromValueTree;
  76876. function doRemoveFromValueTree(valueTree, segments) {
  76877. var first = segments.shift();
  76878. if (segments.length === 0) {
  76879. // Reached last segment
  76880. delete valueTree[first];
  76881. return;
  76882. }
  76883. if (Object.keys(valueTree).indexOf(first) !== -1) {
  76884. var value = valueTree[first];
  76885. if (typeof value === 'object' && !Array.isArray(value)) {
  76886. doRemoveFromValueTree(value, segments);
  76887. if (Object.keys(value).length === 0) {
  76888. delete valueTree[first];
  76889. }
  76890. }
  76891. }
  76892. }
  76893. /**
  76894. * A helper function to get the configuration value with a specific settings path (e.g. config.some.setting)
  76895. */
  76896. function getConfigurationValue(config, settingPath, defaultValue) {
  76897. function accessSetting(config, path) {
  76898. var current = config;
  76899. for (var _i = 0, path_1 = path; _i < path_1.length; _i++) {
  76900. var component = path_1[_i];
  76901. if (typeof current !== 'object' || current === null) {
  76902. return undefined;
  76903. }
  76904. current = current[component];
  76905. }
  76906. return current;
  76907. }
  76908. var path = settingPath.split('.');
  76909. var result = accessSetting(config, path);
  76910. return typeof result === 'undefined' ? defaultValue : result;
  76911. }
  76912. exports.getConfigurationValue = getConfigurationValue;
  76913. function getConfigurationKeys() {
  76914. var properties = platform_1.Registry.as(configurationRegistry_1.Extensions.Configuration).getConfigurationProperties();
  76915. return Object.keys(properties);
  76916. }
  76917. exports.getConfigurationKeys = getConfigurationKeys;
  76918. function getDefaultValues() {
  76919. var valueTreeRoot = Object.create(null);
  76920. var properties = platform_1.Registry.as(configurationRegistry_1.Extensions.Configuration).getConfigurationProperties();
  76921. for (var key in properties) {
  76922. var value = properties[key].default;
  76923. addToValueTree(valueTreeRoot, key, value, function (message) { return console.error("Conflict in default settings: " + message); });
  76924. }
  76925. return valueTreeRoot;
  76926. }
  76927. exports.getDefaultValues = getDefaultValues;
  76928. function overrideIdentifierFromKey(key) {
  76929. return key.substring(1, key.length - 1);
  76930. }
  76931. exports.overrideIdentifierFromKey = overrideIdentifierFromKey;
  76932. function getMigratedSettingValue(configurationService, currentSettingName, legacySettingName) {
  76933. var setting = configurationService.inspect(currentSettingName);
  76934. var legacySetting = configurationService.inspect(legacySettingName);
  76935. if (typeof setting.userValue !== 'undefined' || typeof setting.workspaceValue !== 'undefined' || typeof setting.workspaceFolderValue !== 'undefined') {
  76936. return setting.value;
  76937. }
  76938. else if (typeof legacySetting.userValue !== 'undefined' || typeof legacySetting.workspaceValue !== 'undefined' || typeof legacySetting.workspaceFolderValue !== 'undefined') {
  76939. return legacySetting.value;
  76940. }
  76941. else {
  76942. return setting.defaultValue;
  76943. }
  76944. }
  76945. exports.getMigratedSettingValue = getMigratedSettingValue;
  76946. });
  76947. /*---------------------------------------------------------------------------------------------
  76948. * Copyright (c) Microsoft Corporation. All rights reserved.
  76949. * Licensed under the MIT License. See License.txt in the project root for license information.
  76950. *--------------------------------------------------------------------------------------------*/
  76951. define(__m[517/*vs/platform/accessibility/common/accessibilityService*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,64/*vs/platform/accessibility/common/accessibility*/,4/*vs/base/common/event*/,18/*vs/platform/contextkey/common/contextkey*/,43/*vs/platform/configuration/common/configuration*/]), function (require, exports, lifecycle_1, accessibility_1, event_1, contextkey_1, configuration_1) {
  76952. "use strict";
  76953. Object.defineProperty(exports, "__esModule", { value: true });
  76954. var AccessibilityService = /** @class */ (function (_super) {
  76955. __extends(AccessibilityService, _super);
  76956. function AccessibilityService(_contextKeyService, _configurationService) {
  76957. var _this = _super.call(this) || this;
  76958. _this._contextKeyService = _contextKeyService;
  76959. _this._configurationService = _configurationService;
  76960. _this._accessibilitySupport = 0 /* Unknown */;
  76961. _this._onDidChangeScreenReaderOptimized = new event_1.Emitter();
  76962. _this._accessibilityModeEnabledContext = accessibility_1.CONTEXT_ACCESSIBILITY_MODE_ENABLED.bindTo(_this._contextKeyService);
  76963. var updateContextKey = function () { return _this._accessibilityModeEnabledContext.set(_this.isScreenReaderOptimized()); };
  76964. _this._register(_this._configurationService.onDidChangeConfiguration(function (e) {
  76965. if (e.affectsConfiguration('editor.accessibilitySupport')) {
  76966. updateContextKey();
  76967. _this._onDidChangeScreenReaderOptimized.fire();
  76968. }
  76969. }));
  76970. updateContextKey();
  76971. _this.onDidChangeScreenReaderOptimized(function () { return updateContextKey(); });
  76972. return _this;
  76973. }
  76974. Object.defineProperty(AccessibilityService.prototype, "onDidChangeScreenReaderOptimized", {
  76975. get: function () {
  76976. return this._onDidChangeScreenReaderOptimized.event;
  76977. },
  76978. enumerable: true,
  76979. configurable: true
  76980. });
  76981. AccessibilityService.prototype.isScreenReaderOptimized = function () {
  76982. var config = this._configurationService.getValue('editor.accessibilitySupport');
  76983. return config === 'on' || (config === 'auto' && this._accessibilitySupport === 2 /* Enabled */);
  76984. };
  76985. AccessibilityService.prototype.getAccessibilitySupport = function () {
  76986. return this._accessibilitySupport;
  76987. };
  76988. AccessibilityService = __decorate([
  76989. __param(0, contextkey_1.IContextKeyService),
  76990. __param(1, configuration_1.IConfigurationService)
  76991. ], AccessibilityService);
  76992. return AccessibilityService;
  76993. }(lifecycle_1.Disposable));
  76994. exports.AccessibilityService = AccessibilityService;
  76995. });
  76996. var __spreadArrays = (this && this.__spreadArrays) || function () {
  76997. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  76998. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  76999. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  77000. r[k] = a[j];
  77001. return r;
  77002. };
  77003. define(__m[518/*vs/platform/configuration/common/configurationModels*/], __M([0/*require*/,1/*exports*/,38/*vs/base/common/map*/,19/*vs/base/common/arrays*/,21/*vs/base/common/types*/,31/*vs/base/common/objects*/,85/*vs/platform/configuration/common/configurationRegistry*/,43/*vs/platform/configuration/common/configuration*/]), function (require, exports, map_1, arrays, types, objects, configurationRegistry_1, configuration_1) {
  77004. "use strict";
  77005. Object.defineProperty(exports, "__esModule", { value: true });
  77006. var ConfigurationModel = /** @class */ (function () {
  77007. function ConfigurationModel(_contents, _keys, _overrides) {
  77008. if (_contents === void 0) { _contents = {}; }
  77009. if (_keys === void 0) { _keys = []; }
  77010. if (_overrides === void 0) { _overrides = []; }
  77011. this._contents = _contents;
  77012. this._keys = _keys;
  77013. this._overrides = _overrides;
  77014. this.isFrozen = false;
  77015. }
  77016. Object.defineProperty(ConfigurationModel.prototype, "contents", {
  77017. get: function () {
  77018. return this.checkAndFreeze(this._contents);
  77019. },
  77020. enumerable: true,
  77021. configurable: true
  77022. });
  77023. Object.defineProperty(ConfigurationModel.prototype, "overrides", {
  77024. get: function () {
  77025. return this.checkAndFreeze(this._overrides);
  77026. },
  77027. enumerable: true,
  77028. configurable: true
  77029. });
  77030. Object.defineProperty(ConfigurationModel.prototype, "keys", {
  77031. get: function () {
  77032. return this.checkAndFreeze(this._keys);
  77033. },
  77034. enumerable: true,
  77035. configurable: true
  77036. });
  77037. ConfigurationModel.prototype.isEmpty = function () {
  77038. return this._keys.length === 0 && Object.keys(this._contents).length === 0 && this._overrides.length === 0;
  77039. };
  77040. ConfigurationModel.prototype.getValue = function (section) {
  77041. return section ? configuration_1.getConfigurationValue(this.contents, section) : this.contents;
  77042. };
  77043. ConfigurationModel.prototype.getOverrideValue = function (section, overrideIdentifier) {
  77044. var overrideContents = this.getContentsForOverrideIdentifer(overrideIdentifier);
  77045. return overrideContents
  77046. ? section ? configuration_1.getConfigurationValue(overrideContents, section) : overrideContents
  77047. : undefined;
  77048. };
  77049. ConfigurationModel.prototype.override = function (identifier) {
  77050. var overrideContents = this.getContentsForOverrideIdentifer(identifier);
  77051. if (!overrideContents || typeof overrideContents !== 'object' || !Object.keys(overrideContents).length) {
  77052. // If there are no valid overrides, return self
  77053. return this;
  77054. }
  77055. var contents = {};
  77056. for (var _i = 0, _a = arrays.distinct(__spreadArrays(Object.keys(this.contents), Object.keys(overrideContents))); _i < _a.length; _i++) {
  77057. var key = _a[_i];
  77058. var contentsForKey = this.contents[key];
  77059. var overrideContentsForKey = overrideContents[key];
  77060. // If there are override contents for the key, clone and merge otherwise use base contents
  77061. if (overrideContentsForKey) {
  77062. // Clone and merge only if base contents and override contents are of type object otherwise just override
  77063. if (typeof contentsForKey === 'object' && typeof overrideContentsForKey === 'object') {
  77064. contentsForKey = objects.deepClone(contentsForKey);
  77065. this.mergeContents(contentsForKey, overrideContentsForKey);
  77066. }
  77067. else {
  77068. contentsForKey = overrideContentsForKey;
  77069. }
  77070. }
  77071. contents[key] = contentsForKey;
  77072. }
  77073. return new ConfigurationModel(contents, this.keys, this.overrides);
  77074. };
  77075. ConfigurationModel.prototype.merge = function () {
  77076. var others = [];
  77077. for (var _i = 0; _i < arguments.length; _i++) {
  77078. others[_i] = arguments[_i];
  77079. }
  77080. var contents = objects.deepClone(this.contents);
  77081. var overrides = objects.deepClone(this.overrides);
  77082. var keys = __spreadArrays(this.keys);
  77083. for (var _a = 0, others_1 = others; _a < others_1.length; _a++) {
  77084. var other = others_1[_a];
  77085. this.mergeContents(contents, other.contents);
  77086. var _loop_1 = function (otherOverride) {
  77087. var override = overrides.filter(function (o) { return arrays.equals(o.identifiers, otherOverride.identifiers); })[0];
  77088. if (override) {
  77089. this_1.mergeContents(override.contents, otherOverride.contents);
  77090. }
  77091. else {
  77092. overrides.push(objects.deepClone(otherOverride));
  77093. }
  77094. };
  77095. var this_1 = this;
  77096. for (var _b = 0, _c = other.overrides; _b < _c.length; _b++) {
  77097. var otherOverride = _c[_b];
  77098. _loop_1(otherOverride);
  77099. }
  77100. for (var _d = 0, _e = other.keys; _d < _e.length; _d++) {
  77101. var key = _e[_d];
  77102. if (keys.indexOf(key) === -1) {
  77103. keys.push(key);
  77104. }
  77105. }
  77106. }
  77107. return new ConfigurationModel(contents, keys, overrides);
  77108. };
  77109. ConfigurationModel.prototype.freeze = function () {
  77110. this.isFrozen = true;
  77111. return this;
  77112. };
  77113. ConfigurationModel.prototype.mergeContents = function (source, target) {
  77114. for (var _i = 0, _a = Object.keys(target); _i < _a.length; _i++) {
  77115. var key = _a[_i];
  77116. if (key in source) {
  77117. if (types.isObject(source[key]) && types.isObject(target[key])) {
  77118. this.mergeContents(source[key], target[key]);
  77119. continue;
  77120. }
  77121. }
  77122. source[key] = objects.deepClone(target[key]);
  77123. }
  77124. };
  77125. ConfigurationModel.prototype.checkAndFreeze = function (data) {
  77126. if (this.isFrozen && !Object.isFrozen(data)) {
  77127. return objects.deepFreeze(data);
  77128. }
  77129. return data;
  77130. };
  77131. ConfigurationModel.prototype.getContentsForOverrideIdentifer = function (identifier) {
  77132. for (var _i = 0, _a = this.overrides; _i < _a.length; _i++) {
  77133. var override = _a[_i];
  77134. if (override.identifiers.indexOf(identifier) !== -1) {
  77135. return override.contents;
  77136. }
  77137. }
  77138. return null;
  77139. };
  77140. ConfigurationModel.prototype.toJSON = function () {
  77141. return {
  77142. contents: this.contents,
  77143. overrides: this.overrides,
  77144. keys: this.keys
  77145. };
  77146. };
  77147. // Update methods
  77148. ConfigurationModel.prototype.setValue = function (key, value) {
  77149. this.addKey(key);
  77150. configuration_1.addToValueTree(this.contents, key, value, function (e) { throw new Error(e); });
  77151. };
  77152. ConfigurationModel.prototype.removeValue = function (key) {
  77153. if (this.removeKey(key)) {
  77154. configuration_1.removeFromValueTree(this.contents, key);
  77155. }
  77156. };
  77157. ConfigurationModel.prototype.addKey = function (key) {
  77158. var index = this.keys.length;
  77159. for (var i = 0; i < index; i++) {
  77160. if (key.indexOf(this.keys[i]) === 0) {
  77161. index = i;
  77162. }
  77163. }
  77164. this.keys.splice(index, 1, key);
  77165. };
  77166. ConfigurationModel.prototype.removeKey = function (key) {
  77167. var index = this.keys.indexOf(key);
  77168. if (index !== -1) {
  77169. this.keys.splice(index, 1);
  77170. return true;
  77171. }
  77172. return false;
  77173. };
  77174. return ConfigurationModel;
  77175. }());
  77176. exports.ConfigurationModel = ConfigurationModel;
  77177. var DefaultConfigurationModel = /** @class */ (function (_super) {
  77178. __extends(DefaultConfigurationModel, _super);
  77179. function DefaultConfigurationModel() {
  77180. var _this = this;
  77181. var contents = configuration_1.getDefaultValues();
  77182. var keys = configuration_1.getConfigurationKeys();
  77183. var overrides = [];
  77184. for (var _i = 0, _a = Object.keys(contents); _i < _a.length; _i++) {
  77185. var key = _a[_i];
  77186. if (configurationRegistry_1.OVERRIDE_PROPERTY_PATTERN.test(key)) {
  77187. overrides.push({
  77188. identifiers: [configuration_1.overrideIdentifierFromKey(key).trim()],
  77189. keys: Object.keys(contents[key]),
  77190. contents: configuration_1.toValuesTree(contents[key], function (message) { return console.error("Conflict in default settings file: " + message); }),
  77191. });
  77192. }
  77193. }
  77194. _this = _super.call(this, contents, keys, overrides) || this;
  77195. return _this;
  77196. }
  77197. return DefaultConfigurationModel;
  77198. }(ConfigurationModel));
  77199. exports.DefaultConfigurationModel = DefaultConfigurationModel;
  77200. var Configuration = /** @class */ (function () {
  77201. function Configuration(_defaultConfiguration, _localUserConfiguration, _remoteUserConfiguration, _workspaceConfiguration, _folderConfigurations, _memoryConfiguration, _memoryConfigurationByResource, _freeze) {
  77202. if (_remoteUserConfiguration === void 0) { _remoteUserConfiguration = new ConfigurationModel(); }
  77203. if (_workspaceConfiguration === void 0) { _workspaceConfiguration = new ConfigurationModel(); }
  77204. if (_folderConfigurations === void 0) { _folderConfigurations = new map_1.ResourceMap(); }
  77205. if (_memoryConfiguration === void 0) { _memoryConfiguration = new ConfigurationModel(); }
  77206. if (_memoryConfigurationByResource === void 0) { _memoryConfigurationByResource = new map_1.ResourceMap(); }
  77207. if (_freeze === void 0) { _freeze = true; }
  77208. this._defaultConfiguration = _defaultConfiguration;
  77209. this._localUserConfiguration = _localUserConfiguration;
  77210. this._remoteUserConfiguration = _remoteUserConfiguration;
  77211. this._workspaceConfiguration = _workspaceConfiguration;
  77212. this._folderConfigurations = _folderConfigurations;
  77213. this._memoryConfiguration = _memoryConfiguration;
  77214. this._memoryConfigurationByResource = _memoryConfigurationByResource;
  77215. this._freeze = _freeze;
  77216. this._workspaceConsolidatedConfiguration = null;
  77217. this._foldersConsolidatedConfigurations = new map_1.ResourceMap();
  77218. this._userConfiguration = null;
  77219. }
  77220. Configuration.prototype.getValue = function (section, overrides, workspace) {
  77221. var consolidateConfigurationModel = this.getConsolidateConfigurationModel(overrides, workspace);
  77222. return consolidateConfigurationModel.getValue(section);
  77223. };
  77224. Configuration.prototype.updateValue = function (key, value, overrides) {
  77225. if (overrides === void 0) { overrides = {}; }
  77226. var memoryConfiguration;
  77227. if (overrides.resource) {
  77228. memoryConfiguration = this._memoryConfigurationByResource.get(overrides.resource);
  77229. if (!memoryConfiguration) {
  77230. memoryConfiguration = new ConfigurationModel();
  77231. this._memoryConfigurationByResource.set(overrides.resource, memoryConfiguration);
  77232. }
  77233. }
  77234. else {
  77235. memoryConfiguration = this._memoryConfiguration;
  77236. }
  77237. if (value === undefined) {
  77238. memoryConfiguration.removeValue(key);
  77239. }
  77240. else {
  77241. memoryConfiguration.setValue(key, value);
  77242. }
  77243. if (!overrides.resource) {
  77244. this._workspaceConsolidatedConfiguration = null;
  77245. }
  77246. };
  77247. Configuration.prototype.inspect = function (key, overrides, workspace) {
  77248. var consolidateConfigurationModel = this.getConsolidateConfigurationModel(overrides, workspace);
  77249. var folderConfigurationModel = this.getFolderConfigurationModelForResource(overrides.resource, workspace);
  77250. var memoryConfigurationModel = overrides.resource ? this._memoryConfigurationByResource.get(overrides.resource) || this._memoryConfiguration : this._memoryConfiguration;
  77251. var defaultValue = overrides.overrideIdentifier ? this._defaultConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this._defaultConfiguration.freeze().getValue(key);
  77252. var userValue = overrides.overrideIdentifier ? this.userConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.userConfiguration.freeze().getValue(key);
  77253. var userLocalValue = overrides.overrideIdentifier ? this.localUserConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.localUserConfiguration.freeze().getValue(key);
  77254. var userRemoteValue = overrides.overrideIdentifier ? this.remoteUserConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this.remoteUserConfiguration.freeze().getValue(key);
  77255. var workspaceValue = workspace ? overrides.overrideIdentifier ? this._workspaceConfiguration.freeze().override(overrides.overrideIdentifier).getValue(key) : this._workspaceConfiguration.freeze().getValue(key) : undefined; //Check on workspace exists or not because _workspaceConfiguration is never null
  77256. var workspaceFolderValue = folderConfigurationModel ? overrides.overrideIdentifier ? folderConfigurationModel.freeze().override(overrides.overrideIdentifier).getValue(key) : folderConfigurationModel.freeze().getValue(key) : undefined;
  77257. var memoryValue = overrides.overrideIdentifier ? memoryConfigurationModel.override(overrides.overrideIdentifier).getValue(key) : memoryConfigurationModel.getValue(key);
  77258. var value = consolidateConfigurationModel.getValue(key);
  77259. var overrideIdentifiers = arrays.distinct(arrays.flatten(consolidateConfigurationModel.overrides.map(function (override) { return override.identifiers; }))).filter(function (overrideIdentifier) { return consolidateConfigurationModel.getOverrideValue(key, overrideIdentifier) !== undefined; });
  77260. return {
  77261. defaultValue: defaultValue,
  77262. userValue: userValue,
  77263. userLocalValue: userLocalValue,
  77264. userRemoteValue: userRemoteValue,
  77265. workspaceValue: workspaceValue,
  77266. workspaceFolderValue: workspaceFolderValue,
  77267. memoryValue: memoryValue,
  77268. value: value,
  77269. default: defaultValue !== undefined ? { value: this._defaultConfiguration.freeze().getValue(key), override: overrides.overrideIdentifier ? this._defaultConfiguration.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
  77270. user: userValue !== undefined ? { value: this.userConfiguration.freeze().getValue(key), override: overrides.overrideIdentifier ? this.userConfiguration.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
  77271. userLocal: userLocalValue !== undefined ? { value: this.localUserConfiguration.freeze().getValue(key), override: overrides.overrideIdentifier ? this.localUserConfiguration.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
  77272. userRemote: userRemoteValue !== undefined ? { value: this.remoteUserConfiguration.freeze().getValue(key), override: overrides.overrideIdentifier ? this.remoteUserConfiguration.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
  77273. workspace: workspaceValue !== undefined ? { value: this._workspaceConfiguration.freeze().getValue(key), override: overrides.overrideIdentifier ? this._workspaceConfiguration.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
  77274. workspaceFolder: workspaceFolderValue !== undefined ? { value: folderConfigurationModel === null || folderConfigurationModel === void 0 ? void 0 : folderConfigurationModel.freeze().getValue(key), override: overrides.overrideIdentifier ? folderConfigurationModel === null || folderConfigurationModel === void 0 ? void 0 : folderConfigurationModel.freeze().getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
  77275. memory: memoryValue !== undefined ? { value: memoryConfigurationModel.getValue(key), override: overrides.overrideIdentifier ? memoryConfigurationModel.getOverrideValue(key, overrides.overrideIdentifier) : undefined } : undefined,
  77276. overrideIdentifiers: overrideIdentifiers.length ? overrideIdentifiers : undefined
  77277. };
  77278. };
  77279. Object.defineProperty(Configuration.prototype, "userConfiguration", {
  77280. get: function () {
  77281. if (!this._userConfiguration) {
  77282. this._userConfiguration = this._remoteUserConfiguration.isEmpty() ? this._localUserConfiguration : this._localUserConfiguration.merge(this._remoteUserConfiguration);
  77283. if (this._freeze) {
  77284. this._userConfiguration.freeze();
  77285. }
  77286. }
  77287. return this._userConfiguration;
  77288. },
  77289. enumerable: true,
  77290. configurable: true
  77291. });
  77292. Object.defineProperty(Configuration.prototype, "localUserConfiguration", {
  77293. get: function () {
  77294. return this._localUserConfiguration;
  77295. },
  77296. enumerable: true,
  77297. configurable: true
  77298. });
  77299. Object.defineProperty(Configuration.prototype, "remoteUserConfiguration", {
  77300. get: function () {
  77301. return this._remoteUserConfiguration;
  77302. },
  77303. enumerable: true,
  77304. configurable: true
  77305. });
  77306. Configuration.prototype.getConsolidateConfigurationModel = function (overrides, workspace) {
  77307. var configurationModel = this.getConsolidatedConfigurationModelForResource(overrides, workspace);
  77308. return overrides.overrideIdentifier ? configurationModel.override(overrides.overrideIdentifier) : configurationModel;
  77309. };
  77310. Configuration.prototype.getConsolidatedConfigurationModelForResource = function (_a, workspace) {
  77311. var resource = _a.resource;
  77312. var consolidateConfiguration = this.getWorkspaceConsolidatedConfiguration();
  77313. if (workspace && resource) {
  77314. var root = workspace.getFolder(resource);
  77315. if (root) {
  77316. consolidateConfiguration = this.getFolderConsolidatedConfiguration(root.uri) || consolidateConfiguration;
  77317. }
  77318. var memoryConfigurationForResource = this._memoryConfigurationByResource.get(resource);
  77319. if (memoryConfigurationForResource) {
  77320. consolidateConfiguration = consolidateConfiguration.merge(memoryConfigurationForResource);
  77321. }
  77322. }
  77323. return consolidateConfiguration;
  77324. };
  77325. Configuration.prototype.getWorkspaceConsolidatedConfiguration = function () {
  77326. if (!this._workspaceConsolidatedConfiguration) {
  77327. this._workspaceConsolidatedConfiguration = this._defaultConfiguration.merge(this.userConfiguration, this._workspaceConfiguration, this._memoryConfiguration);
  77328. if (this._freeze) {
  77329. this._workspaceConfiguration = this._workspaceConfiguration.freeze();
  77330. }
  77331. }
  77332. return this._workspaceConsolidatedConfiguration;
  77333. };
  77334. Configuration.prototype.getFolderConsolidatedConfiguration = function (folder) {
  77335. var folderConsolidatedConfiguration = this._foldersConsolidatedConfigurations.get(folder);
  77336. if (!folderConsolidatedConfiguration) {
  77337. var workspaceConsolidateConfiguration = this.getWorkspaceConsolidatedConfiguration();
  77338. var folderConfiguration = this._folderConfigurations.get(folder);
  77339. if (folderConfiguration) {
  77340. folderConsolidatedConfiguration = workspaceConsolidateConfiguration.merge(folderConfiguration);
  77341. if (this._freeze) {
  77342. folderConsolidatedConfiguration = folderConsolidatedConfiguration.freeze();
  77343. }
  77344. this._foldersConsolidatedConfigurations.set(folder, folderConsolidatedConfiguration);
  77345. }
  77346. else {
  77347. folderConsolidatedConfiguration = workspaceConsolidateConfiguration;
  77348. }
  77349. }
  77350. return folderConsolidatedConfiguration;
  77351. };
  77352. Configuration.prototype.getFolderConfigurationModelForResource = function (resource, workspace) {
  77353. if (workspace && resource) {
  77354. var root = workspace.getFolder(resource);
  77355. if (root) {
  77356. return this._folderConfigurations.get(root.uri);
  77357. }
  77358. }
  77359. return undefined;
  77360. };
  77361. return Configuration;
  77362. }());
  77363. exports.Configuration = Configuration;
  77364. });
  77365. /*---------------------------------------------------------------------------------------------
  77366. * Copyright (c) Microsoft Corporation. All rights reserved.
  77367. * Licensed under the MIT License. See License.txt in the project root for license information.
  77368. *--------------------------------------------------------------------------------------------*/
  77369. define(__m[519/*vs/platform/contextkey/browser/contextKeyService*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,38/*vs/base/common/map*/,29/*vs/platform/commands/common/commands*/,43/*vs/platform/configuration/common/configuration*/,18/*vs/platform/contextkey/common/contextkey*/,217/*vs/platform/keybinding/common/keybindingResolver*/]), function (require, exports, event_1, lifecycle_1, map_1, commands_1, configuration_1, contextkey_1, keybindingResolver_1) {
  77370. "use strict";
  77371. Object.defineProperty(exports, "__esModule", { value: true });
  77372. var KEYBINDING_CONTEXT_ATTR = 'data-keybinding-context';
  77373. var Context = /** @class */ (function () {
  77374. function Context(id, parent) {
  77375. this._id = id;
  77376. this._parent = parent;
  77377. this._value = Object.create(null);
  77378. this._value['_contextId'] = id;
  77379. }
  77380. Context.prototype.setValue = function (key, value) {
  77381. // console.log('SET ' + key + ' = ' + value + ' ON ' + this._id);
  77382. if (this._value[key] !== value) {
  77383. this._value[key] = value;
  77384. return true;
  77385. }
  77386. return false;
  77387. };
  77388. Context.prototype.removeValue = function (key) {
  77389. // console.log('REMOVE ' + key + ' FROM ' + this._id);
  77390. if (key in this._value) {
  77391. delete this._value[key];
  77392. return true;
  77393. }
  77394. return false;
  77395. };
  77396. Context.prototype.getValue = function (key) {
  77397. var ret = this._value[key];
  77398. if (typeof ret === 'undefined' && this._parent) {
  77399. return this._parent.getValue(key);
  77400. }
  77401. return ret;
  77402. };
  77403. return Context;
  77404. }());
  77405. exports.Context = Context;
  77406. var NullContext = /** @class */ (function (_super) {
  77407. __extends(NullContext, _super);
  77408. function NullContext() {
  77409. return _super.call(this, -1, null) || this;
  77410. }
  77411. NullContext.prototype.setValue = function (key, value) {
  77412. return false;
  77413. };
  77414. NullContext.prototype.removeValue = function (key) {
  77415. return false;
  77416. };
  77417. NullContext.prototype.getValue = function (key) {
  77418. return undefined;
  77419. };
  77420. NullContext.INSTANCE = new NullContext();
  77421. return NullContext;
  77422. }(Context));
  77423. var ConfigAwareContextValuesContainer = /** @class */ (function (_super) {
  77424. __extends(ConfigAwareContextValuesContainer, _super);
  77425. function ConfigAwareContextValuesContainer(id, _configurationService, emitter) {
  77426. var _this = _super.call(this, id, null) || this;
  77427. _this._configurationService = _configurationService;
  77428. _this._values = new Map();
  77429. _this._listener = _this._configurationService.onDidChangeConfiguration(function (event) {
  77430. if (event.source === 6 /* DEFAULT */) {
  77431. // new setting, reset everything
  77432. var allKeys = map_1.keys(_this._values);
  77433. _this._values.clear();
  77434. emitter.fire(new ArrayContextKeyChangeEvent(allKeys));
  77435. }
  77436. else {
  77437. var changedKeys = [];
  77438. for (var _i = 0, _a = event.affectedKeys; _i < _a.length; _i++) {
  77439. var configKey = _a[_i];
  77440. var contextKey = "config." + configKey;
  77441. if (_this._values.has(contextKey)) {
  77442. _this._values.delete(contextKey);
  77443. changedKeys.push(contextKey);
  77444. }
  77445. }
  77446. emitter.fire(new ArrayContextKeyChangeEvent(changedKeys));
  77447. }
  77448. });
  77449. return _this;
  77450. }
  77451. ConfigAwareContextValuesContainer.prototype.dispose = function () {
  77452. this._listener.dispose();
  77453. };
  77454. ConfigAwareContextValuesContainer.prototype.getValue = function (key) {
  77455. if (key.indexOf(ConfigAwareContextValuesContainer._keyPrefix) !== 0) {
  77456. return _super.prototype.getValue.call(this, key);
  77457. }
  77458. if (this._values.has(key)) {
  77459. return this._values.get(key);
  77460. }
  77461. var configKey = key.substr(ConfigAwareContextValuesContainer._keyPrefix.length);
  77462. var configValue = this._configurationService.getValue(configKey);
  77463. var value = undefined;
  77464. switch (typeof configValue) {
  77465. case 'number':
  77466. case 'boolean':
  77467. case 'string':
  77468. value = configValue;
  77469. break;
  77470. }
  77471. this._values.set(key, value);
  77472. return value;
  77473. };
  77474. ConfigAwareContextValuesContainer.prototype.setValue = function (key, value) {
  77475. return _super.prototype.setValue.call(this, key, value);
  77476. };
  77477. ConfigAwareContextValuesContainer.prototype.removeValue = function (key) {
  77478. return _super.prototype.removeValue.call(this, key);
  77479. };
  77480. ConfigAwareContextValuesContainer._keyPrefix = 'config.';
  77481. return ConfigAwareContextValuesContainer;
  77482. }(Context));
  77483. var ContextKey = /** @class */ (function () {
  77484. function ContextKey(service, key, defaultValue) {
  77485. this._service = service;
  77486. this._key = key;
  77487. this._defaultValue = defaultValue;
  77488. this.reset();
  77489. }
  77490. ContextKey.prototype.set = function (value) {
  77491. this._service.setContext(this._key, value);
  77492. };
  77493. ContextKey.prototype.reset = function () {
  77494. if (typeof this._defaultValue === 'undefined') {
  77495. this._service.removeContext(this._key);
  77496. }
  77497. else {
  77498. this._service.setContext(this._key, this._defaultValue);
  77499. }
  77500. };
  77501. ContextKey.prototype.get = function () {
  77502. return this._service.getContextKeyValue(this._key);
  77503. };
  77504. return ContextKey;
  77505. }());
  77506. var SimpleContextKeyChangeEvent = /** @class */ (function () {
  77507. function SimpleContextKeyChangeEvent(key) {
  77508. this.key = key;
  77509. }
  77510. SimpleContextKeyChangeEvent.prototype.affectsSome = function (keys) {
  77511. return keys.has(this.key);
  77512. };
  77513. return SimpleContextKeyChangeEvent;
  77514. }());
  77515. var ArrayContextKeyChangeEvent = /** @class */ (function () {
  77516. function ArrayContextKeyChangeEvent(keys) {
  77517. this.keys = keys;
  77518. }
  77519. ArrayContextKeyChangeEvent.prototype.affectsSome = function (keys) {
  77520. for (var _i = 0, _a = this.keys; _i < _a.length; _i++) {
  77521. var key = _a[_i];
  77522. if (keys.has(key)) {
  77523. return true;
  77524. }
  77525. }
  77526. return false;
  77527. };
  77528. return ArrayContextKeyChangeEvent;
  77529. }());
  77530. var CompositeContextKeyChangeEvent = /** @class */ (function () {
  77531. function CompositeContextKeyChangeEvent(events) {
  77532. this.events = events;
  77533. }
  77534. CompositeContextKeyChangeEvent.prototype.affectsSome = function (keys) {
  77535. for (var _i = 0, _a = this.events; _i < _a.length; _i++) {
  77536. var e = _a[_i];
  77537. if (e.affectsSome(keys)) {
  77538. return true;
  77539. }
  77540. }
  77541. return false;
  77542. };
  77543. return CompositeContextKeyChangeEvent;
  77544. }());
  77545. var AbstractContextKeyService = /** @class */ (function () {
  77546. function AbstractContextKeyService(myContextId) {
  77547. this._onDidChangeContext = new event_1.PauseableEmitter({ merge: function (input) { return new CompositeContextKeyChangeEvent(input); } });
  77548. this._isDisposed = false;
  77549. this._myContextId = myContextId;
  77550. }
  77551. AbstractContextKeyService.prototype.createKey = function (key, defaultValue) {
  77552. if (this._isDisposed) {
  77553. throw new Error("AbstractContextKeyService has been disposed");
  77554. }
  77555. return new ContextKey(this, key, defaultValue);
  77556. };
  77557. Object.defineProperty(AbstractContextKeyService.prototype, "onDidChangeContext", {
  77558. get: function () {
  77559. return this._onDidChangeContext.event;
  77560. },
  77561. enumerable: true,
  77562. configurable: true
  77563. });
  77564. AbstractContextKeyService.prototype.bufferChangeEvents = function (callback) {
  77565. this._onDidChangeContext.pause();
  77566. try {
  77567. callback();
  77568. }
  77569. finally {
  77570. this._onDidChangeContext.resume();
  77571. }
  77572. };
  77573. AbstractContextKeyService.prototype.createScoped = function (domNode) {
  77574. if (this._isDisposed) {
  77575. throw new Error("AbstractContextKeyService has been disposed");
  77576. }
  77577. return new ScopedContextKeyService(this, domNode);
  77578. };
  77579. AbstractContextKeyService.prototype.contextMatchesRules = function (rules) {
  77580. if (this._isDisposed) {
  77581. throw new Error("AbstractContextKeyService has been disposed");
  77582. }
  77583. var context = this.getContextValuesContainer(this._myContextId);
  77584. var result = keybindingResolver_1.KeybindingResolver.contextMatchesRules(context, rules);
  77585. // console.group(rules.serialize() + ' -> ' + result);
  77586. // rules.keys().forEach(key => { console.log(key, ctx[key]); });
  77587. // console.groupEnd();
  77588. return result;
  77589. };
  77590. AbstractContextKeyService.prototype.getContextKeyValue = function (key) {
  77591. if (this._isDisposed) {
  77592. return undefined;
  77593. }
  77594. return this.getContextValuesContainer(this._myContextId).getValue(key);
  77595. };
  77596. AbstractContextKeyService.prototype.setContext = function (key, value) {
  77597. if (this._isDisposed) {
  77598. return;
  77599. }
  77600. var myContext = this.getContextValuesContainer(this._myContextId);
  77601. if (!myContext) {
  77602. return;
  77603. }
  77604. if (myContext.setValue(key, value)) {
  77605. this._onDidChangeContext.fire(new SimpleContextKeyChangeEvent(key));
  77606. }
  77607. };
  77608. AbstractContextKeyService.prototype.removeContext = function (key) {
  77609. if (this._isDisposed) {
  77610. return;
  77611. }
  77612. if (this.getContextValuesContainer(this._myContextId).removeValue(key)) {
  77613. this._onDidChangeContext.fire(new SimpleContextKeyChangeEvent(key));
  77614. }
  77615. };
  77616. AbstractContextKeyService.prototype.getContext = function (target) {
  77617. if (this._isDisposed) {
  77618. return NullContext.INSTANCE;
  77619. }
  77620. return this.getContextValuesContainer(findContextAttr(target));
  77621. };
  77622. return AbstractContextKeyService;
  77623. }());
  77624. exports.AbstractContextKeyService = AbstractContextKeyService;
  77625. var ContextKeyService = /** @class */ (function (_super) {
  77626. __extends(ContextKeyService, _super);
  77627. function ContextKeyService(configurationService) {
  77628. var _this = _super.call(this, 0) || this;
  77629. _this._contexts = new Map();
  77630. _this._toDispose = new lifecycle_1.DisposableStore();
  77631. _this._lastContextId = 0;
  77632. var myContext = new ConfigAwareContextValuesContainer(_this._myContextId, configurationService, _this._onDidChangeContext);
  77633. _this._contexts.set(_this._myContextId, myContext);
  77634. _this._toDispose.add(myContext);
  77635. return _this;
  77636. // Uncomment this to see the contexts continuously logged
  77637. // let lastLoggedValue: string | null = null;
  77638. // setInterval(() => {
  77639. // let values = Object.keys(this._contexts).map((key) => this._contexts[key]);
  77640. // let logValue = values.map(v => JSON.stringify(v._value, null, '\t')).join('\n');
  77641. // if (lastLoggedValue !== logValue) {
  77642. // lastLoggedValue = logValue;
  77643. // console.log(lastLoggedValue);
  77644. // }
  77645. // }, 2000);
  77646. }
  77647. ContextKeyService.prototype.dispose = function () {
  77648. this._isDisposed = true;
  77649. this._toDispose.dispose();
  77650. };
  77651. ContextKeyService.prototype.getContextValuesContainer = function (contextId) {
  77652. if (this._isDisposed) {
  77653. return NullContext.INSTANCE;
  77654. }
  77655. return this._contexts.get(contextId) || NullContext.INSTANCE;
  77656. };
  77657. ContextKeyService.prototype.createChildContext = function (parentContextId) {
  77658. if (parentContextId === void 0) { parentContextId = this._myContextId; }
  77659. if (this._isDisposed) {
  77660. throw new Error("ContextKeyService has been disposed");
  77661. }
  77662. var id = (++this._lastContextId);
  77663. this._contexts.set(id, new Context(id, this.getContextValuesContainer(parentContextId)));
  77664. return id;
  77665. };
  77666. ContextKeyService.prototype.disposeContext = function (contextId) {
  77667. if (!this._isDisposed) {
  77668. this._contexts.delete(contextId);
  77669. }
  77670. };
  77671. ContextKeyService = __decorate([
  77672. __param(0, configuration_1.IConfigurationService)
  77673. ], ContextKeyService);
  77674. return ContextKeyService;
  77675. }(AbstractContextKeyService));
  77676. exports.ContextKeyService = ContextKeyService;
  77677. var ScopedContextKeyService = /** @class */ (function (_super) {
  77678. __extends(ScopedContextKeyService, _super);
  77679. function ScopedContextKeyService(parent, domNode) {
  77680. var _this = _super.call(this, parent.createChildContext()) || this;
  77681. _this._parent = parent;
  77682. if (domNode) {
  77683. _this._domNode = domNode;
  77684. _this._domNode.setAttribute(KEYBINDING_CONTEXT_ATTR, String(_this._myContextId));
  77685. }
  77686. return _this;
  77687. }
  77688. ScopedContextKeyService.prototype.dispose = function () {
  77689. this._isDisposed = true;
  77690. this._parent.disposeContext(this._myContextId);
  77691. if (this._domNode) {
  77692. this._domNode.removeAttribute(KEYBINDING_CONTEXT_ATTR);
  77693. this._domNode = undefined;
  77694. }
  77695. };
  77696. Object.defineProperty(ScopedContextKeyService.prototype, "onDidChangeContext", {
  77697. get: function () {
  77698. return event_1.Event.any(this._parent.onDidChangeContext, this._onDidChangeContext.event);
  77699. },
  77700. enumerable: true,
  77701. configurable: true
  77702. });
  77703. ScopedContextKeyService.prototype.getContextValuesContainer = function (contextId) {
  77704. if (this._isDisposed) {
  77705. return NullContext.INSTANCE;
  77706. }
  77707. return this._parent.getContextValuesContainer(contextId);
  77708. };
  77709. ScopedContextKeyService.prototype.createChildContext = function (parentContextId) {
  77710. if (parentContextId === void 0) { parentContextId = this._myContextId; }
  77711. if (this._isDisposed) {
  77712. throw new Error("ScopedContextKeyService has been disposed");
  77713. }
  77714. return this._parent.createChildContext(parentContextId);
  77715. };
  77716. ScopedContextKeyService.prototype.disposeContext = function (contextId) {
  77717. if (this._isDisposed) {
  77718. return;
  77719. }
  77720. this._parent.disposeContext(contextId);
  77721. };
  77722. return ScopedContextKeyService;
  77723. }(AbstractContextKeyService));
  77724. function findContextAttr(domNode) {
  77725. while (domNode) {
  77726. if (domNode.hasAttribute(KEYBINDING_CONTEXT_ATTR)) {
  77727. var attr = domNode.getAttribute(KEYBINDING_CONTEXT_ATTR);
  77728. if (attr) {
  77729. return parseInt(attr, 10);
  77730. }
  77731. return NaN;
  77732. }
  77733. domNode = domNode.parentElement;
  77734. }
  77735. return 0;
  77736. }
  77737. commands_1.CommandsRegistry.registerCommand(contextkey_1.SET_CONTEXT_COMMAND_ID, function (accessor, contextKey, contextValue) {
  77738. accessor.get(contextkey_1.IContextKeyService).createKey(String(contextKey), contextValue);
  77739. });
  77740. });
  77741. /*---------------------------------------------------------------------------------------------
  77742. * Copyright (c) Microsoft Corporation. All rights reserved.
  77743. * Licensed under the MIT License. See License.txt in the project root for license information.
  77744. *--------------------------------------------------------------------------------------------*/
  77745. define(__m[86/*vs/platform/keybinding/common/keybindingsRegistry*/], __M([0/*require*/,1/*exports*/,36/*vs/base/common/keyCodes*/,16/*vs/base/common/platform*/,29/*vs/platform/commands/common/commands*/,42/*vs/platform/registry/common/platform*/]), function (require, exports, keyCodes_1, platform_1, commands_1, platform_2) {
  77746. "use strict";
  77747. Object.defineProperty(exports, "__esModule", { value: true });
  77748. var KeybindingsRegistryImpl = /** @class */ (function () {
  77749. function KeybindingsRegistryImpl() {
  77750. this._coreKeybindings = [];
  77751. this._extensionKeybindings = [];
  77752. this._cachedMergedKeybindings = null;
  77753. }
  77754. /**
  77755. * Take current platform into account and reduce to primary & secondary.
  77756. */
  77757. KeybindingsRegistryImpl.bindToCurrentPlatform = function (kb) {
  77758. if (platform_1.OS === 1 /* Windows */) {
  77759. if (kb && kb.win) {
  77760. return kb.win;
  77761. }
  77762. }
  77763. else if (platform_1.OS === 2 /* Macintosh */) {
  77764. if (kb && kb.mac) {
  77765. return kb.mac;
  77766. }
  77767. }
  77768. else {
  77769. if (kb && kb.linux) {
  77770. return kb.linux;
  77771. }
  77772. }
  77773. return kb;
  77774. };
  77775. KeybindingsRegistryImpl.prototype.registerKeybindingRule = function (rule) {
  77776. var actualKb = KeybindingsRegistryImpl.bindToCurrentPlatform(rule);
  77777. if (actualKb && actualKb.primary) {
  77778. var kk = keyCodes_1.createKeybinding(actualKb.primary, platform_1.OS);
  77779. if (kk) {
  77780. this._registerDefaultKeybinding(kk, rule.id, rule.args, rule.weight, 0, rule.when);
  77781. }
  77782. }
  77783. if (actualKb && Array.isArray(actualKb.secondary)) {
  77784. for (var i = 0, len = actualKb.secondary.length; i < len; i++) {
  77785. var k = actualKb.secondary[i];
  77786. var kk = keyCodes_1.createKeybinding(k, platform_1.OS);
  77787. if (kk) {
  77788. this._registerDefaultKeybinding(kk, rule.id, rule.args, rule.weight, -i - 1, rule.when);
  77789. }
  77790. }
  77791. }
  77792. };
  77793. KeybindingsRegistryImpl.prototype.registerCommandAndKeybindingRule = function (desc) {
  77794. this.registerKeybindingRule(desc);
  77795. commands_1.CommandsRegistry.registerCommand(desc);
  77796. };
  77797. KeybindingsRegistryImpl._mightProduceChar = function (keyCode) {
  77798. if (keyCode >= 21 /* KEY_0 */ && keyCode <= 30 /* KEY_9 */) {
  77799. return true;
  77800. }
  77801. if (keyCode >= 31 /* KEY_A */ && keyCode <= 56 /* KEY_Z */) {
  77802. return true;
  77803. }
  77804. return (keyCode === 80 /* US_SEMICOLON */
  77805. || keyCode === 81 /* US_EQUAL */
  77806. || keyCode === 82 /* US_COMMA */
  77807. || keyCode === 83 /* US_MINUS */
  77808. || keyCode === 84 /* US_DOT */
  77809. || keyCode === 85 /* US_SLASH */
  77810. || keyCode === 86 /* US_BACKTICK */
  77811. || keyCode === 110 /* ABNT_C1 */
  77812. || keyCode === 111 /* ABNT_C2 */
  77813. || keyCode === 87 /* US_OPEN_SQUARE_BRACKET */
  77814. || keyCode === 88 /* US_BACKSLASH */
  77815. || keyCode === 89 /* US_CLOSE_SQUARE_BRACKET */
  77816. || keyCode === 90 /* US_QUOTE */
  77817. || keyCode === 91 /* OEM_8 */
  77818. || keyCode === 92 /* OEM_102 */);
  77819. };
  77820. KeybindingsRegistryImpl.prototype._assertNoCtrlAlt = function (keybinding, commandId) {
  77821. if (keybinding.ctrlKey && keybinding.altKey && !keybinding.metaKey) {
  77822. if (KeybindingsRegistryImpl._mightProduceChar(keybinding.keyCode)) {
  77823. console.warn('Ctrl+Alt+ keybindings should not be used by default under Windows. Offender: ', keybinding, ' for ', commandId);
  77824. }
  77825. }
  77826. };
  77827. KeybindingsRegistryImpl.prototype._registerDefaultKeybinding = function (keybinding, commandId, commandArgs, weight1, weight2, when) {
  77828. if (platform_1.OS === 1 /* Windows */) {
  77829. this._assertNoCtrlAlt(keybinding.parts[0], commandId);
  77830. }
  77831. this._coreKeybindings.push({
  77832. keybinding: keybinding,
  77833. command: commandId,
  77834. commandArgs: commandArgs,
  77835. when: when,
  77836. weight1: weight1,
  77837. weight2: weight2
  77838. });
  77839. this._cachedMergedKeybindings = null;
  77840. };
  77841. KeybindingsRegistryImpl.prototype.getDefaultKeybindings = function () {
  77842. if (!this._cachedMergedKeybindings) {
  77843. this._cachedMergedKeybindings = [].concat(this._coreKeybindings).concat(this._extensionKeybindings);
  77844. this._cachedMergedKeybindings.sort(sorter);
  77845. }
  77846. return this._cachedMergedKeybindings.slice(0);
  77847. };
  77848. return KeybindingsRegistryImpl;
  77849. }());
  77850. exports.KeybindingsRegistry = new KeybindingsRegistryImpl();
  77851. // Define extension point ids
  77852. exports.Extensions = {
  77853. EditorModes: 'platform.keybindingsRegistry'
  77854. };
  77855. platform_2.Registry.add(exports.Extensions.EditorModes, exports.KeybindingsRegistry);
  77856. function sorter(a, b) {
  77857. if (a.weight1 !== b.weight1) {
  77858. return a.weight1 - b.weight1;
  77859. }
  77860. if (a.command < b.command) {
  77861. return -1;
  77862. }
  77863. if (a.command > b.command) {
  77864. return 1;
  77865. }
  77866. return a.weight2 - b.weight2;
  77867. }
  77868. });
  77869. /*---------------------------------------------------------------------------------------------
  77870. * Copyright (c) Microsoft Corporation. All rights reserved.
  77871. * Licensed under the MIT License. See License.txt in the project root for license information.
  77872. *--------------------------------------------------------------------------------------------*/
  77873. define(__m[520/*vs/platform/browser/contextScopedHistoryWidget*/], __M([0/*require*/,1/*exports*/,18/*vs/platform/contextkey/common/contextkey*/,400/*vs/base/browser/ui/findinput/findInput*/,86/*vs/platform/keybinding/common/keybindingsRegistry*/,401/*vs/base/browser/ui/findinput/replaceInput*/]), function (require, exports, contextkey_1, findInput_1, keybindingsRegistry_1, replaceInput_1) {
  77874. "use strict";
  77875. Object.defineProperty(exports, "__esModule", { value: true });
  77876. exports.HistoryNavigationWidgetContext = 'historyNavigationWidget';
  77877. exports.HistoryNavigationEnablementContext = 'historyNavigationEnabled';
  77878. function bindContextScopedWidget(contextKeyService, widget, contextKey) {
  77879. new contextkey_1.RawContextKey(contextKey, widget).bindTo(contextKeyService);
  77880. }
  77881. function createWidgetScopedContextKeyService(contextKeyService, widget) {
  77882. return contextKeyService.createScoped(widget.target);
  77883. }
  77884. function getContextScopedWidget(contextKeyService, contextKey) {
  77885. return contextKeyService.getContext(document.activeElement).getValue(contextKey);
  77886. }
  77887. function createAndBindHistoryNavigationWidgetScopedContextKeyService(contextKeyService, widget) {
  77888. var scopedContextKeyService = createWidgetScopedContextKeyService(contextKeyService, widget);
  77889. bindContextScopedWidget(scopedContextKeyService, widget, exports.HistoryNavigationWidgetContext);
  77890. var historyNavigationEnablement = new contextkey_1.RawContextKey(exports.HistoryNavigationEnablementContext, true).bindTo(scopedContextKeyService);
  77891. return { scopedContextKeyService: scopedContextKeyService, historyNavigationEnablement: historyNavigationEnablement };
  77892. }
  77893. exports.createAndBindHistoryNavigationWidgetScopedContextKeyService = createAndBindHistoryNavigationWidgetScopedContextKeyService;
  77894. var ContextScopedFindInput = /** @class */ (function (_super) {
  77895. __extends(ContextScopedFindInput, _super);
  77896. function ContextScopedFindInput(container, contextViewProvider, options, contextKeyService, showFindOptions) {
  77897. if (showFindOptions === void 0) { showFindOptions = false; }
  77898. var _this = _super.call(this, container, contextViewProvider, showFindOptions, options) || this;
  77899. _this._register(createAndBindHistoryNavigationWidgetScopedContextKeyService(contextKeyService, { target: _this.inputBox.element, historyNavigator: _this.inputBox }).scopedContextKeyService);
  77900. return _this;
  77901. }
  77902. ContextScopedFindInput = __decorate([
  77903. __param(3, contextkey_1.IContextKeyService)
  77904. ], ContextScopedFindInput);
  77905. return ContextScopedFindInput;
  77906. }(findInput_1.FindInput));
  77907. exports.ContextScopedFindInput = ContextScopedFindInput;
  77908. var ContextScopedReplaceInput = /** @class */ (function (_super) {
  77909. __extends(ContextScopedReplaceInput, _super);
  77910. function ContextScopedReplaceInput(container, contextViewProvider, options, contextKeyService, showReplaceOptions) {
  77911. if (showReplaceOptions === void 0) { showReplaceOptions = false; }
  77912. var _this = _super.call(this, container, contextViewProvider, showReplaceOptions, options) || this;
  77913. _this._register(createAndBindHistoryNavigationWidgetScopedContextKeyService(contextKeyService, { target: _this.inputBox.element, historyNavigator: _this.inputBox }).scopedContextKeyService);
  77914. return _this;
  77915. }
  77916. ContextScopedReplaceInput = __decorate([
  77917. __param(3, contextkey_1.IContextKeyService)
  77918. ], ContextScopedReplaceInput);
  77919. return ContextScopedReplaceInput;
  77920. }(replaceInput_1.ReplaceInput));
  77921. exports.ContextScopedReplaceInput = ContextScopedReplaceInput;
  77922. keybindingsRegistry_1.KeybindingsRegistry.registerCommandAndKeybindingRule({
  77923. id: 'history.showPrevious',
  77924. weight: 200 /* WorkbenchContrib */,
  77925. when: contextkey_1.ContextKeyExpr.and(contextkey_1.ContextKeyExpr.has(exports.HistoryNavigationWidgetContext), contextkey_1.ContextKeyExpr.equals(exports.HistoryNavigationEnablementContext, true)),
  77926. primary: 16 /* UpArrow */,
  77927. secondary: [512 /* Alt */ | 16 /* UpArrow */],
  77928. handler: function (accessor, arg2) {
  77929. var widget = getContextScopedWidget(accessor.get(contextkey_1.IContextKeyService), exports.HistoryNavigationWidgetContext);
  77930. if (widget) {
  77931. var historyInputBox = widget.historyNavigator;
  77932. historyInputBox.showPreviousValue();
  77933. }
  77934. }
  77935. });
  77936. keybindingsRegistry_1.KeybindingsRegistry.registerCommandAndKeybindingRule({
  77937. id: 'history.showNext',
  77938. weight: 200 /* WorkbenchContrib */,
  77939. when: contextkey_1.ContextKeyExpr.and(contextkey_1.ContextKeyExpr.has(exports.HistoryNavigationWidgetContext), contextkey_1.ContextKeyExpr.equals(exports.HistoryNavigationEnablementContext, true)),
  77940. primary: 18 /* DownArrow */,
  77941. secondary: [512 /* Alt */ | 18 /* DownArrow */],
  77942. handler: function (accessor, arg2) {
  77943. var widget = getContextScopedWidget(accessor.get(contextkey_1.IContextKeyService), exports.HistoryNavigationWidgetContext);
  77944. if (widget) {
  77945. var historyInputBox = widget.historyNavigator;
  77946. historyInputBox.showNextValue();
  77947. }
  77948. }
  77949. });
  77950. });
  77951. /*---------------------------------------------------------------------------------------------
  77952. * Copyright (c) Microsoft Corporation. All rights reserved.
  77953. * Licensed under the MIT License. See License.txt in the project root for license information.
  77954. *--------------------------------------------------------------------------------------------*/
  77955. define(__m[74/*vs/platform/storage/common/storage*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,21/*vs/base/common/types*/]), function (require, exports, instantiation_1, event_1, lifecycle_1, types_1) {
  77956. "use strict";
  77957. Object.defineProperty(exports, "__esModule", { value: true });
  77958. exports.IStorageService = instantiation_1.createDecorator('storageService');
  77959. var WillSaveStateReason;
  77960. (function (WillSaveStateReason) {
  77961. WillSaveStateReason[WillSaveStateReason["NONE"] = 0] = "NONE";
  77962. WillSaveStateReason[WillSaveStateReason["SHUTDOWN"] = 1] = "SHUTDOWN";
  77963. })(WillSaveStateReason = exports.WillSaveStateReason || (exports.WillSaveStateReason = {}));
  77964. var InMemoryStorageService = /** @class */ (function (_super) {
  77965. __extends(InMemoryStorageService, _super);
  77966. function InMemoryStorageService() {
  77967. var _this = _super !== null && _super.apply(this, arguments) || this;
  77968. _this._onDidChangeStorage = _this._register(new event_1.Emitter());
  77969. _this.onDidChangeStorage = _this._onDidChangeStorage.event;
  77970. _this._onWillSaveState = _this._register(new event_1.Emitter());
  77971. _this.onWillSaveState = _this._onWillSaveState.event;
  77972. _this.globalCache = new Map();
  77973. _this.workspaceCache = new Map();
  77974. return _this;
  77975. }
  77976. InMemoryStorageService.prototype.getCache = function (scope) {
  77977. return scope === 0 /* GLOBAL */ ? this.globalCache : this.workspaceCache;
  77978. };
  77979. InMemoryStorageService.prototype.get = function (key, scope, fallbackValue) {
  77980. var value = this.getCache(scope).get(key);
  77981. if (types_1.isUndefinedOrNull(value)) {
  77982. return fallbackValue;
  77983. }
  77984. return value;
  77985. };
  77986. InMemoryStorageService.prototype.getBoolean = function (key, scope, fallbackValue) {
  77987. var value = this.getCache(scope).get(key);
  77988. if (types_1.isUndefinedOrNull(value)) {
  77989. return fallbackValue;
  77990. }
  77991. return value === 'true';
  77992. };
  77993. InMemoryStorageService.prototype.store = function (key, value, scope) {
  77994. // We remove the key for undefined/null values
  77995. if (types_1.isUndefinedOrNull(value)) {
  77996. return this.remove(key, scope);
  77997. }
  77998. // Otherwise, convert to String and store
  77999. var valueStr = String(value);
  78000. // Return early if value already set
  78001. var currentValue = this.getCache(scope).get(key);
  78002. if (currentValue === valueStr) {
  78003. return Promise.resolve();
  78004. }
  78005. // Update in cache
  78006. this.getCache(scope).set(key, valueStr);
  78007. // Events
  78008. this._onDidChangeStorage.fire({ scope: scope, key: key });
  78009. return Promise.resolve();
  78010. };
  78011. InMemoryStorageService.prototype.remove = function (key, scope) {
  78012. var wasDeleted = this.getCache(scope).delete(key);
  78013. if (!wasDeleted) {
  78014. return Promise.resolve(); // Return early if value already deleted
  78015. }
  78016. // Events
  78017. this._onDidChangeStorage.fire({ scope: scope, key: key });
  78018. return Promise.resolve();
  78019. };
  78020. return InMemoryStorageService;
  78021. }(lifecycle_1.Disposable));
  78022. exports.InMemoryStorageService = InMemoryStorageService;
  78023. });
  78024. /*---------------------------------------------------------------------------------------------
  78025. * Copyright (c) Microsoft Corporation. All rights reserved.
  78026. * Licensed under the MIT License. See License.txt in the project root for license information.
  78027. *--------------------------------------------------------------------------------------------*/
  78028. define(__m[521/*vs/editor/contrib/suggest/suggestMemory*/], __M([0/*require*/,1/*exports*/,38/*vs/base/common/map*/,74/*vs/platform/storage/common/storage*/,17/*vs/editor/common/modes*/,2/*vs/base/common/lifecycle*/,15/*vs/base/common/async*/,11/*vs/platform/instantiation/common/instantiation*/,43/*vs/platform/configuration/common/configuration*/,83/*vs/platform/instantiation/common/extensions*/]), function (require, exports, map_1, storage_1, modes_1, lifecycle_1, async_1, instantiation_1, configuration_1, extensions_1) {
  78029. "use strict";
  78030. Object.defineProperty(exports, "__esModule", { value: true });
  78031. var Memory = /** @class */ (function () {
  78032. function Memory() {
  78033. }
  78034. Memory.prototype.select = function (model, pos, items) {
  78035. if (items.length === 0) {
  78036. return 0;
  78037. }
  78038. var topScore = items[0].score[0];
  78039. for (var i = 1; i < items.length; i++) {
  78040. var _a = items[i], score = _a.score, suggestion = _a.completion;
  78041. if (score[0] !== topScore) {
  78042. // stop when leaving the group of top matches
  78043. break;
  78044. }
  78045. if (suggestion.preselect) {
  78046. // stop when seeing an auto-select-item
  78047. return i;
  78048. }
  78049. }
  78050. return 0;
  78051. };
  78052. return Memory;
  78053. }());
  78054. exports.Memory = Memory;
  78055. var NoMemory = /** @class */ (function (_super) {
  78056. __extends(NoMemory, _super);
  78057. function NoMemory() {
  78058. return _super !== null && _super.apply(this, arguments) || this;
  78059. }
  78060. NoMemory.prototype.memorize = function (model, pos, item) {
  78061. // no-op
  78062. };
  78063. NoMemory.prototype.toJSON = function () {
  78064. return undefined;
  78065. };
  78066. NoMemory.prototype.fromJSON = function () {
  78067. //
  78068. };
  78069. return NoMemory;
  78070. }(Memory));
  78071. exports.NoMemory = NoMemory;
  78072. var LRUMemory = /** @class */ (function (_super) {
  78073. __extends(LRUMemory, _super);
  78074. function LRUMemory() {
  78075. var _this = _super !== null && _super.apply(this, arguments) || this;
  78076. _this._cache = new map_1.LRUCache(300, 0.66);
  78077. _this._seq = 0;
  78078. return _this;
  78079. }
  78080. LRUMemory.prototype.memorize = function (model, pos, item) {
  78081. var label = item.completion.label;
  78082. var key = model.getLanguageIdentifier().language + "/" + label;
  78083. this._cache.set(key, {
  78084. touch: this._seq++,
  78085. type: item.completion.kind,
  78086. insertText: item.completion.insertText
  78087. });
  78088. };
  78089. LRUMemory.prototype.select = function (model, pos, items) {
  78090. if (items.length === 0) {
  78091. return 0;
  78092. }
  78093. var lineSuffix = model.getLineContent(pos.lineNumber).substr(pos.column - 10, pos.column - 1);
  78094. if (/\s$/.test(lineSuffix)) {
  78095. return _super.prototype.select.call(this, model, pos, items);
  78096. }
  78097. var topScore = items[0].score[0];
  78098. var indexPreselect = -1;
  78099. var indexRecency = -1;
  78100. var seq = -1;
  78101. for (var i = 0; i < items.length; i++) {
  78102. if (items[i].score[0] !== topScore) {
  78103. // consider only top items
  78104. break;
  78105. }
  78106. var key = model.getLanguageIdentifier().language + "/" + items[i].completion.label;
  78107. var item = this._cache.peek(key);
  78108. if (item && item.touch > seq && item.type === items[i].completion.kind && item.insertText === items[i].completion.insertText) {
  78109. seq = item.touch;
  78110. indexRecency = i;
  78111. }
  78112. if (items[i].completion.preselect && indexPreselect === -1) {
  78113. // stop when seeing an auto-select-item
  78114. return indexPreselect = i;
  78115. }
  78116. }
  78117. if (indexRecency !== -1) {
  78118. return indexRecency;
  78119. }
  78120. else if (indexPreselect !== -1) {
  78121. return indexPreselect;
  78122. }
  78123. else {
  78124. return 0;
  78125. }
  78126. };
  78127. LRUMemory.prototype.toJSON = function () {
  78128. var data = [];
  78129. this._cache.forEach(function (value, key) {
  78130. data.push([key, value]);
  78131. });
  78132. return data;
  78133. };
  78134. LRUMemory.prototype.fromJSON = function (data) {
  78135. this._cache.clear();
  78136. var seq = 0;
  78137. for (var _i = 0, data_1 = data; _i < data_1.length; _i++) {
  78138. var _a = data_1[_i], key = _a[0], value = _a[1];
  78139. value.touch = seq;
  78140. value.type = typeof value.type === 'number' ? value.type : modes_1.completionKindFromString(value.type);
  78141. this._cache.set(key, value);
  78142. }
  78143. this._seq = this._cache.size;
  78144. };
  78145. return LRUMemory;
  78146. }(Memory));
  78147. exports.LRUMemory = LRUMemory;
  78148. var PrefixMemory = /** @class */ (function (_super) {
  78149. __extends(PrefixMemory, _super);
  78150. function PrefixMemory() {
  78151. var _this = _super !== null && _super.apply(this, arguments) || this;
  78152. _this._trie = map_1.TernarySearchTree.forStrings();
  78153. _this._seq = 0;
  78154. return _this;
  78155. }
  78156. PrefixMemory.prototype.memorize = function (model, pos, item) {
  78157. var word = model.getWordUntilPosition(pos).word;
  78158. var key = model.getLanguageIdentifier().language + "/" + word;
  78159. this._trie.set(key, {
  78160. type: item.completion.kind,
  78161. insertText: item.completion.insertText,
  78162. touch: this._seq++
  78163. });
  78164. };
  78165. PrefixMemory.prototype.select = function (model, pos, items) {
  78166. var word = model.getWordUntilPosition(pos).word;
  78167. if (!word) {
  78168. return _super.prototype.select.call(this, model, pos, items);
  78169. }
  78170. var key = model.getLanguageIdentifier().language + "/" + word;
  78171. var item = this._trie.get(key);
  78172. if (!item) {
  78173. item = this._trie.findSubstr(key);
  78174. }
  78175. if (item) {
  78176. for (var i = 0; i < items.length; i++) {
  78177. var _a = items[i].completion, kind = _a.kind, insertText = _a.insertText;
  78178. if (kind === item.type && insertText === item.insertText) {
  78179. return i;
  78180. }
  78181. }
  78182. }
  78183. return _super.prototype.select.call(this, model, pos, items);
  78184. };
  78185. PrefixMemory.prototype.toJSON = function () {
  78186. var entries = [];
  78187. this._trie.forEach(function (value, key) { return entries.push([key, value]); });
  78188. // sort by last recently used (touch), then
  78189. // take the top 200 item and normalize their
  78190. // touch
  78191. entries
  78192. .sort(function (a, b) { return -(a[1].touch - b[1].touch); })
  78193. .forEach(function (value, i) { return value[1].touch = i; });
  78194. return entries.slice(0, 200);
  78195. };
  78196. PrefixMemory.prototype.fromJSON = function (data) {
  78197. this._trie.clear();
  78198. if (data.length > 0) {
  78199. this._seq = data[0][1].touch + 1;
  78200. for (var _i = 0, data_2 = data; _i < data_2.length; _i++) {
  78201. var _a = data_2[_i], key = _a[0], value = _a[1];
  78202. value.type = typeof value.type === 'number' ? value.type : modes_1.completionKindFromString(value.type);
  78203. this._trie.set(key, value);
  78204. }
  78205. }
  78206. };
  78207. return PrefixMemory;
  78208. }(Memory));
  78209. exports.PrefixMemory = PrefixMemory;
  78210. var SuggestMemoryService = /** @class */ (function (_super) {
  78211. __extends(SuggestMemoryService, _super);
  78212. function SuggestMemoryService(_storageService, _configService) {
  78213. var _this = _super.call(this) || this;
  78214. _this._storageService = _storageService;
  78215. _this._configService = _configService;
  78216. _this._storagePrefix = 'suggest/memories';
  78217. var update = function () {
  78218. var mode = _this._configService.getValue('editor.suggestSelection');
  78219. var share = _this._configService.getValue('editor.suggest.shareSuggestSelections');
  78220. _this._update(mode, share, false);
  78221. };
  78222. _this._persistSoon = _this._register(new async_1.RunOnceScheduler(function () { return _this._saveState(); }, 500));
  78223. _this._register(_storageService.onWillSaveState(function (e) {
  78224. if (e.reason === storage_1.WillSaveStateReason.SHUTDOWN) {
  78225. _this._saveState();
  78226. }
  78227. }));
  78228. _this._register(_this._configService.onDidChangeConfiguration(function (e) {
  78229. if (e.affectsConfiguration('editor.suggestSelection') || e.affectsConfiguration('editor.suggest.shareSuggestSelections')) {
  78230. update();
  78231. }
  78232. }));
  78233. _this._register(_this._storageService.onDidChangeStorage(function (e) {
  78234. if (e.scope === 0 /* GLOBAL */ && e.key.indexOf(_this._storagePrefix) === 0) {
  78235. if (!document.hasFocus()) {
  78236. // windows that aren't focused have to drop their current
  78237. // storage value and accept what's stored now
  78238. _this._update(_this._mode, _this._shareMem, true);
  78239. }
  78240. }
  78241. }));
  78242. update();
  78243. return _this;
  78244. }
  78245. SuggestMemoryService.prototype._update = function (mode, shareMem, force) {
  78246. if (!force && this._mode === mode && this._shareMem === shareMem) {
  78247. return;
  78248. }
  78249. this._shareMem = shareMem;
  78250. this._mode = mode;
  78251. this._strategy = mode === 'recentlyUsedByPrefix' ? new PrefixMemory() : mode === 'recentlyUsed' ? new LRUMemory() : new NoMemory();
  78252. try {
  78253. var scope = shareMem ? 0 /* GLOBAL */ : 1 /* WORKSPACE */;
  78254. var raw = this._storageService.get(this._storagePrefix + "/" + this._mode, scope);
  78255. if (raw) {
  78256. this._strategy.fromJSON(JSON.parse(raw));
  78257. }
  78258. }
  78259. catch (e) {
  78260. // things can go wrong with JSON...
  78261. }
  78262. };
  78263. SuggestMemoryService.prototype.memorize = function (model, pos, item) {
  78264. this._strategy.memorize(model, pos, item);
  78265. this._persistSoon.schedule();
  78266. };
  78267. SuggestMemoryService.prototype.select = function (model, pos, items) {
  78268. return this._strategy.select(model, pos, items);
  78269. };
  78270. SuggestMemoryService.prototype._saveState = function () {
  78271. var raw = JSON.stringify(this._strategy);
  78272. var scope = this._shareMem ? 0 /* GLOBAL */ : 1 /* WORKSPACE */;
  78273. this._storageService.store(this._storagePrefix + "/" + this._mode, raw, scope);
  78274. };
  78275. SuggestMemoryService = __decorate([
  78276. __param(0, storage_1.IStorageService),
  78277. __param(1, configuration_1.IConfigurationService)
  78278. ], SuggestMemoryService);
  78279. return SuggestMemoryService;
  78280. }(lifecycle_1.Disposable));
  78281. exports.SuggestMemoryService = SuggestMemoryService;
  78282. exports.ISuggestMemoryService = instantiation_1.createDecorator('ISuggestMemories');
  78283. extensions_1.registerSingleton(exports.ISuggestMemoryService, SuggestMemoryService, true);
  78284. });
  78285. /*---------------------------------------------------------------------------------------------
  78286. * Copyright (c) Microsoft Corporation. All rights reserved.
  78287. * Licensed under the MIT License. See License.txt in the project root for license information.
  78288. *--------------------------------------------------------------------------------------------*/
  78289. define(__m[96/*vs/platform/telemetry/common/telemetry*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/]), function (require, exports, instantiation_1) {
  78290. "use strict";
  78291. Object.defineProperty(exports, "__esModule", { value: true });
  78292. exports.ITelemetryService = instantiation_1.createDecorator('telemetryService');
  78293. });
  78294. /*---------------------------------------------------------------------------------------------
  78295. * Copyright (c) Microsoft Corporation. All rights reserved.
  78296. * Licensed under the MIT License. See License.txt in the project root for license information.
  78297. *--------------------------------------------------------------------------------------------*/
  78298. define(__m[12/*vs/editor/browser/editorExtensions*/], __M([0/*require*/,1/*exports*/,10/*vs/base/common/errors*/,25/*vs/base/common/uri*/,32/*vs/editor/browser/services/codeEditorService*/,13/*vs/editor/common/core/position*/,49/*vs/editor/common/services/modelService*/,84/*vs/editor/common/services/resolverService*/,65/*vs/platform/actions/common/actions*/,29/*vs/platform/commands/common/commands*/,18/*vs/platform/contextkey/common/contextkey*/,86/*vs/platform/keybinding/common/keybindingsRegistry*/,42/*vs/platform/registry/common/platform*/,96/*vs/platform/telemetry/common/telemetry*/,21/*vs/base/common/types*/]), function (require, exports, errors_1, uri_1, codeEditorService_1, position_1, modelService_1, resolverService_1, actions_1, commands_1, contextkey_1, keybindingsRegistry_1, platform_1, telemetry_1, types_1) {
  78299. "use strict";
  78300. Object.defineProperty(exports, "__esModule", { value: true });
  78301. var Command = /** @class */ (function () {
  78302. function Command(opts) {
  78303. this.id = opts.id;
  78304. this.precondition = opts.precondition;
  78305. this._kbOpts = opts.kbOpts;
  78306. this._menuOpts = opts.menuOpts;
  78307. this._description = opts.description;
  78308. }
  78309. Command.prototype.register = function () {
  78310. var _this = this;
  78311. if (Array.isArray(this._menuOpts)) {
  78312. this._menuOpts.forEach(this._registerMenuItem, this);
  78313. }
  78314. else if (this._menuOpts) {
  78315. this._registerMenuItem(this._menuOpts);
  78316. }
  78317. if (this._kbOpts) {
  78318. var kbWhen = this._kbOpts.kbExpr;
  78319. if (this.precondition) {
  78320. if (kbWhen) {
  78321. kbWhen = contextkey_1.ContextKeyExpr.and(kbWhen, this.precondition);
  78322. }
  78323. else {
  78324. kbWhen = this.precondition;
  78325. }
  78326. }
  78327. keybindingsRegistry_1.KeybindingsRegistry.registerCommandAndKeybindingRule({
  78328. id: this.id,
  78329. handler: function (accessor, args) { return _this.runCommand(accessor, args); },
  78330. weight: this._kbOpts.weight,
  78331. when: kbWhen,
  78332. primary: this._kbOpts.primary,
  78333. secondary: this._kbOpts.secondary,
  78334. win: this._kbOpts.win,
  78335. linux: this._kbOpts.linux,
  78336. mac: this._kbOpts.mac,
  78337. description: this._description
  78338. });
  78339. }
  78340. else {
  78341. commands_1.CommandsRegistry.registerCommand({
  78342. id: this.id,
  78343. handler: function (accessor, args) { return _this.runCommand(accessor, args); },
  78344. description: this._description
  78345. });
  78346. }
  78347. };
  78348. Command.prototype._registerMenuItem = function (item) {
  78349. actions_1.MenuRegistry.appendMenuItem(item.menuId, {
  78350. group: item.group,
  78351. command: {
  78352. id: this.id,
  78353. title: item.title,
  78354. },
  78355. when: item.when,
  78356. order: item.order
  78357. });
  78358. };
  78359. return Command;
  78360. }());
  78361. exports.Command = Command;
  78362. var EditorCommand = /** @class */ (function (_super) {
  78363. __extends(EditorCommand, _super);
  78364. function EditorCommand() {
  78365. return _super !== null && _super.apply(this, arguments) || this;
  78366. }
  78367. /**
  78368. * Create a command class that is bound to a certain editor contribution.
  78369. */
  78370. EditorCommand.bindToContribution = function (controllerGetter) {
  78371. return /** @class */ (function (_super) {
  78372. __extends(EditorControllerCommandImpl, _super);
  78373. function EditorControllerCommandImpl(opts) {
  78374. var _this = _super.call(this, opts) || this;
  78375. _this._callback = opts.handler;
  78376. return _this;
  78377. }
  78378. EditorControllerCommandImpl.prototype.runEditorCommand = function (accessor, editor, args) {
  78379. var controller = controllerGetter(editor);
  78380. if (controller) {
  78381. this._callback(controllerGetter(editor), args);
  78382. }
  78383. };
  78384. return EditorControllerCommandImpl;
  78385. }(EditorCommand));
  78386. };
  78387. EditorCommand.prototype.runCommand = function (accessor, args) {
  78388. var _this = this;
  78389. var codeEditorService = accessor.get(codeEditorService_1.ICodeEditorService);
  78390. // Find the editor with text focus or active
  78391. var editor = codeEditorService.getFocusedCodeEditor() || codeEditorService.getActiveCodeEditor();
  78392. if (!editor) {
  78393. // well, at least we tried...
  78394. return;
  78395. }
  78396. return editor.invokeWithinContext(function (editorAccessor) {
  78397. var kbService = editorAccessor.get(contextkey_1.IContextKeyService);
  78398. if (!kbService.contextMatchesRules(types_1.withNullAsUndefined(_this.precondition))) {
  78399. // precondition does not hold
  78400. return;
  78401. }
  78402. return _this.runEditorCommand(editorAccessor, editor, args);
  78403. });
  78404. };
  78405. return EditorCommand;
  78406. }(Command));
  78407. exports.EditorCommand = EditorCommand;
  78408. var EditorAction = /** @class */ (function (_super) {
  78409. __extends(EditorAction, _super);
  78410. function EditorAction(opts) {
  78411. var _this = _super.call(this, EditorAction.convertOptions(opts)) || this;
  78412. _this.label = opts.label;
  78413. _this.alias = opts.alias;
  78414. return _this;
  78415. }
  78416. EditorAction.convertOptions = function (opts) {
  78417. var menuOpts;
  78418. if (Array.isArray(opts.menuOpts)) {
  78419. menuOpts = opts.menuOpts;
  78420. }
  78421. else if (opts.menuOpts) {
  78422. menuOpts = [opts.menuOpts];
  78423. }
  78424. else {
  78425. menuOpts = [];
  78426. }
  78427. function withDefaults(item) {
  78428. if (!item.menuId) {
  78429. item.menuId = 7 /* EditorContext */;
  78430. }
  78431. if (!item.title) {
  78432. item.title = opts.label;
  78433. }
  78434. item.when = contextkey_1.ContextKeyExpr.and(opts.precondition, item.when);
  78435. return item;
  78436. }
  78437. if (Array.isArray(opts.contextMenuOpts)) {
  78438. menuOpts.push.apply(menuOpts, opts.contextMenuOpts.map(withDefaults));
  78439. }
  78440. else if (opts.contextMenuOpts) {
  78441. menuOpts.push(withDefaults(opts.contextMenuOpts));
  78442. }
  78443. opts.menuOpts = menuOpts;
  78444. return opts;
  78445. };
  78446. EditorAction.prototype.runEditorCommand = function (accessor, editor, args) {
  78447. this.reportTelemetry(accessor, editor);
  78448. return this.run(accessor, editor, args || {});
  78449. };
  78450. EditorAction.prototype.reportTelemetry = function (accessor, editor) {
  78451. accessor.get(telemetry_1.ITelemetryService).publicLog2('editorActionInvoked', { name: this.label, id: this.id });
  78452. };
  78453. return EditorAction;
  78454. }(EditorCommand));
  78455. exports.EditorAction = EditorAction;
  78456. //#endregion EditorAction
  78457. // --- Registration of commands and actions
  78458. function registerLanguageCommand(id, handler) {
  78459. commands_1.CommandsRegistry.registerCommand(id, function (accessor, args) { return handler(accessor, args || {}); });
  78460. }
  78461. exports.registerLanguageCommand = registerLanguageCommand;
  78462. function registerDefaultLanguageCommand(id, handler) {
  78463. registerLanguageCommand(id, function (accessor, args) {
  78464. var resource = args.resource, position = args.position;
  78465. if (!(resource instanceof uri_1.URI)) {
  78466. throw errors_1.illegalArgument('resource');
  78467. }
  78468. if (!position_1.Position.isIPosition(position)) {
  78469. throw errors_1.illegalArgument('position');
  78470. }
  78471. var model = accessor.get(modelService_1.IModelService).getModel(resource);
  78472. if (model) {
  78473. var editorPosition = position_1.Position.lift(position);
  78474. return handler(model, editorPosition, args);
  78475. }
  78476. return accessor.get(resolverService_1.ITextModelService).createModelReference(resource).then(function (reference) {
  78477. return new Promise(function (resolve, reject) {
  78478. try {
  78479. var result = handler(reference.object.textEditorModel, position_1.Position.lift(position), args);
  78480. resolve(result);
  78481. }
  78482. catch (err) {
  78483. reject(err);
  78484. }
  78485. }).finally(function () {
  78486. reference.dispose();
  78487. });
  78488. });
  78489. });
  78490. }
  78491. exports.registerDefaultLanguageCommand = registerDefaultLanguageCommand;
  78492. function registerModelAndPositionCommand(id, handler) {
  78493. commands_1.CommandsRegistry.registerCommand(id, function (accessor) {
  78494. var args = [];
  78495. for (var _i = 1; _i < arguments.length; _i++) {
  78496. args[_i - 1] = arguments[_i];
  78497. }
  78498. var resource = args[0], position = args[1];
  78499. types_1.assertType(uri_1.URI.isUri(resource));
  78500. types_1.assertType(position_1.Position.isIPosition(position));
  78501. var model = accessor.get(modelService_1.IModelService).getModel(resource);
  78502. if (model) {
  78503. var editorPosition = position_1.Position.lift(position);
  78504. return handler(model, editorPosition, args.slice(2));
  78505. }
  78506. return accessor.get(resolverService_1.ITextModelService).createModelReference(resource).then(function (reference) {
  78507. return new Promise(function (resolve, reject) {
  78508. try {
  78509. var result = handler(reference.object.textEditorModel, position_1.Position.lift(position), args.slice(2));
  78510. resolve(result);
  78511. }
  78512. catch (err) {
  78513. reject(err);
  78514. }
  78515. }).finally(function () {
  78516. reference.dispose();
  78517. });
  78518. });
  78519. });
  78520. }
  78521. exports.registerModelAndPositionCommand = registerModelAndPositionCommand;
  78522. function registerModelCommand(id, handler) {
  78523. commands_1.CommandsRegistry.registerCommand(id, function (accessor) {
  78524. var args = [];
  78525. for (var _i = 1; _i < arguments.length; _i++) {
  78526. args[_i - 1] = arguments[_i];
  78527. }
  78528. var resource = args[0];
  78529. types_1.assertType(uri_1.URI.isUri(resource));
  78530. var model = accessor.get(modelService_1.IModelService).getModel(resource);
  78531. if (model) {
  78532. return handler(model, args.slice(1));
  78533. }
  78534. return accessor.get(resolverService_1.ITextModelService).createModelReference(resource).then(function (reference) {
  78535. return new Promise(function (resolve, reject) {
  78536. try {
  78537. var result = handler(reference.object.textEditorModel, args.slice(1));
  78538. resolve(result);
  78539. }
  78540. catch (err) {
  78541. reject(err);
  78542. }
  78543. }).finally(function () {
  78544. reference.dispose();
  78545. });
  78546. });
  78547. });
  78548. }
  78549. exports.registerModelCommand = registerModelCommand;
  78550. function registerEditorCommand(editorCommand) {
  78551. EditorContributionRegistry.INSTANCE.registerEditorCommand(editorCommand);
  78552. return editorCommand;
  78553. }
  78554. exports.registerEditorCommand = registerEditorCommand;
  78555. function registerEditorAction(ctor) {
  78556. EditorContributionRegistry.INSTANCE.registerEditorAction(new ctor());
  78557. }
  78558. exports.registerEditorAction = registerEditorAction;
  78559. function registerInstantiatedEditorAction(editorAction) {
  78560. EditorContributionRegistry.INSTANCE.registerEditorAction(editorAction);
  78561. }
  78562. exports.registerInstantiatedEditorAction = registerInstantiatedEditorAction;
  78563. function registerEditorContribution(id, ctor) {
  78564. EditorContributionRegistry.INSTANCE.registerEditorContribution(id, ctor);
  78565. }
  78566. exports.registerEditorContribution = registerEditorContribution;
  78567. var EditorExtensionsRegistry;
  78568. (function (EditorExtensionsRegistry) {
  78569. function getEditorCommand(commandId) {
  78570. return EditorContributionRegistry.INSTANCE.getEditorCommand(commandId);
  78571. }
  78572. EditorExtensionsRegistry.getEditorCommand = getEditorCommand;
  78573. function getEditorActions() {
  78574. return EditorContributionRegistry.INSTANCE.getEditorActions();
  78575. }
  78576. EditorExtensionsRegistry.getEditorActions = getEditorActions;
  78577. function getEditorContributions() {
  78578. return EditorContributionRegistry.INSTANCE.getEditorContributions();
  78579. }
  78580. EditorExtensionsRegistry.getEditorContributions = getEditorContributions;
  78581. function getSomeEditorContributions(ids) {
  78582. return EditorContributionRegistry.INSTANCE.getEditorContributions().filter(function (c) { return ids.indexOf(c.id) >= 0; });
  78583. }
  78584. EditorExtensionsRegistry.getSomeEditorContributions = getSomeEditorContributions;
  78585. function getDiffEditorContributions() {
  78586. return EditorContributionRegistry.INSTANCE.getDiffEditorContributions();
  78587. }
  78588. EditorExtensionsRegistry.getDiffEditorContributions = getDiffEditorContributions;
  78589. })(EditorExtensionsRegistry = exports.EditorExtensionsRegistry || (exports.EditorExtensionsRegistry = {}));
  78590. // Editor extension points
  78591. var Extensions = {
  78592. EditorCommonContributions: 'editor.contributions'
  78593. };
  78594. var EditorContributionRegistry = /** @class */ (function () {
  78595. function EditorContributionRegistry() {
  78596. this.editorContributions = [];
  78597. this.diffEditorContributions = [];
  78598. this.editorActions = [];
  78599. this.editorCommands = Object.create(null);
  78600. }
  78601. EditorContributionRegistry.prototype.registerEditorContribution = function (id, ctor) {
  78602. this.editorContributions.push({ id: id, ctor: ctor });
  78603. };
  78604. EditorContributionRegistry.prototype.getEditorContributions = function () {
  78605. return this.editorContributions.slice(0);
  78606. };
  78607. EditorContributionRegistry.prototype.getDiffEditorContributions = function () {
  78608. return this.diffEditorContributions.slice(0);
  78609. };
  78610. EditorContributionRegistry.prototype.registerEditorAction = function (action) {
  78611. action.register();
  78612. this.editorActions.push(action);
  78613. };
  78614. EditorContributionRegistry.prototype.getEditorActions = function () {
  78615. return this.editorActions.slice(0);
  78616. };
  78617. EditorContributionRegistry.prototype.registerEditorCommand = function (editorCommand) {
  78618. editorCommand.register();
  78619. this.editorCommands[editorCommand.id] = editorCommand;
  78620. };
  78621. EditorContributionRegistry.prototype.getEditorCommand = function (commandId) {
  78622. return (this.editorCommands[commandId] || null);
  78623. };
  78624. EditorContributionRegistry.INSTANCE = new EditorContributionRegistry();
  78625. return EditorContributionRegistry;
  78626. }());
  78627. platform_1.Registry.add(Extensions.EditorCommonContributions, EditorContributionRegistry.INSTANCE);
  78628. });
  78629. /*---------------------------------------------------------------------------------------------
  78630. * Copyright (c) Microsoft Corporation. All rights reserved.
  78631. * Licensed under the MIT License. See License.txt in the project root for license information.
  78632. *--------------------------------------------------------------------------------------------*/
  78633. define(__m[164/*vs/editor/browser/controller/coreCommands*/], __M([0/*require*/,1/*exports*/,415/*vs/nls!vs/editor/browser/controller/coreCommands*/,21/*vs/base/common/types*/,12/*vs/editor/browser/editorExtensions*/,32/*vs/editor/browser/services/codeEditorService*/,483/*vs/editor/common/controller/cursorColumnSelection*/,40/*vs/editor/common/controller/cursorCommon*/,212/*vs/editor/common/controller/cursorDeleteOperations*/,213/*vs/editor/common/controller/cursorMoveCommands*/,159/*vs/editor/common/controller/cursorTypeOperations*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,68/*vs/editor/common/editorCommon*/,23/*vs/editor/common/editorContextKeys*/,18/*vs/platform/contextkey/common/contextkey*/]), function (require, exports, nls, types, editorExtensions_1, codeEditorService_1, cursorColumnSelection_1, cursorCommon_1, cursorDeleteOperations_1, cursorMoveCommands_1, cursorTypeOperations_1, position_1, range_1, editorCommon_1, editorContextKeys_1, contextkey_1) {
  78634. "use strict";
  78635. Object.defineProperty(exports, "__esModule", { value: true });
  78636. var CORE_WEIGHT = 0 /* EditorCore */;
  78637. var CoreEditorCommand = /** @class */ (function (_super) {
  78638. __extends(CoreEditorCommand, _super);
  78639. function CoreEditorCommand() {
  78640. return _super !== null && _super.apply(this, arguments) || this;
  78641. }
  78642. CoreEditorCommand.prototype.runEditorCommand = function (accessor, editor, args) {
  78643. var cursors = editor._getCursors();
  78644. if (!cursors) {
  78645. // the editor has no view => has no cursors
  78646. return;
  78647. }
  78648. this.runCoreEditorCommand(cursors, args || {});
  78649. };
  78650. return CoreEditorCommand;
  78651. }(editorExtensions_1.EditorCommand));
  78652. exports.CoreEditorCommand = CoreEditorCommand;
  78653. var EditorScroll_;
  78654. (function (EditorScroll_) {
  78655. var isEditorScrollArgs = function (arg) {
  78656. if (!types.isObject(arg)) {
  78657. return false;
  78658. }
  78659. var scrollArg = arg;
  78660. if (!types.isString(scrollArg.to)) {
  78661. return false;
  78662. }
  78663. if (!types.isUndefined(scrollArg.by) && !types.isString(scrollArg.by)) {
  78664. return false;
  78665. }
  78666. if (!types.isUndefined(scrollArg.value) && !types.isNumber(scrollArg.value)) {
  78667. return false;
  78668. }
  78669. if (!types.isUndefined(scrollArg.revealCursor) && !types.isBoolean(scrollArg.revealCursor)) {
  78670. return false;
  78671. }
  78672. return true;
  78673. };
  78674. EditorScroll_.description = {
  78675. description: 'Scroll editor in the given direction',
  78676. args: [
  78677. {
  78678. name: 'Editor scroll argument object',
  78679. description: "Property-value pairs that can be passed through this argument:\n\t\t\t\t\t* 'to': A mandatory direction value.\n\t\t\t\t\t\t```\n\t\t\t\t\t\t'up', 'down'\n\t\t\t\t\t\t```\n\t\t\t\t\t* 'by': Unit to move. Default is computed based on 'to' value.\n\t\t\t\t\t\t```\n\t\t\t\t\t\t'line', 'wrappedLine', 'page', 'halfPage'\n\t\t\t\t\t\t```\n\t\t\t\t\t* 'value': Number of units to move. Default is '1'.\n\t\t\t\t\t* 'revealCursor': If 'true' reveals the cursor if it is outside view port.\n\t\t\t\t",
  78680. constraint: isEditorScrollArgs,
  78681. schema: {
  78682. 'type': 'object',
  78683. 'required': ['to'],
  78684. 'properties': {
  78685. 'to': {
  78686. 'type': 'string',
  78687. 'enum': ['up', 'down']
  78688. },
  78689. 'by': {
  78690. 'type': 'string',
  78691. 'enum': ['line', 'wrappedLine', 'page', 'halfPage']
  78692. },
  78693. 'value': {
  78694. 'type': 'number',
  78695. 'default': 1
  78696. },
  78697. 'revealCursor': {
  78698. 'type': 'boolean',
  78699. }
  78700. }
  78701. }
  78702. }
  78703. ]
  78704. };
  78705. /**
  78706. * Directions in the view for editor scroll command.
  78707. */
  78708. EditorScroll_.RawDirection = {
  78709. Up: 'up',
  78710. Down: 'down',
  78711. };
  78712. /**
  78713. * Units for editor scroll 'by' argument
  78714. */
  78715. EditorScroll_.RawUnit = {
  78716. Line: 'line',
  78717. WrappedLine: 'wrappedLine',
  78718. Page: 'page',
  78719. HalfPage: 'halfPage'
  78720. };
  78721. function parse(args) {
  78722. var direction;
  78723. switch (args.to) {
  78724. case EditorScroll_.RawDirection.Up:
  78725. direction = 1 /* Up */;
  78726. break;
  78727. case EditorScroll_.RawDirection.Down:
  78728. direction = 2 /* Down */;
  78729. break;
  78730. default:
  78731. // Illegal arguments
  78732. return null;
  78733. }
  78734. var unit;
  78735. switch (args.by) {
  78736. case EditorScroll_.RawUnit.Line:
  78737. unit = 1 /* Line */;
  78738. break;
  78739. case EditorScroll_.RawUnit.WrappedLine:
  78740. unit = 2 /* WrappedLine */;
  78741. break;
  78742. case EditorScroll_.RawUnit.Page:
  78743. unit = 3 /* Page */;
  78744. break;
  78745. case EditorScroll_.RawUnit.HalfPage:
  78746. unit = 4 /* HalfPage */;
  78747. break;
  78748. default:
  78749. unit = 2 /* WrappedLine */;
  78750. }
  78751. var value = Math.floor(args.value || 1);
  78752. var revealCursor = !!args.revealCursor;
  78753. return {
  78754. direction: direction,
  78755. unit: unit,
  78756. value: value,
  78757. revealCursor: revealCursor,
  78758. select: (!!args.select)
  78759. };
  78760. }
  78761. EditorScroll_.parse = parse;
  78762. })(EditorScroll_ = exports.EditorScroll_ || (exports.EditorScroll_ = {}));
  78763. var RevealLine_;
  78764. (function (RevealLine_) {
  78765. var isRevealLineArgs = function (arg) {
  78766. if (!types.isObject(arg)) {
  78767. return false;
  78768. }
  78769. var reveaLineArg = arg;
  78770. if (!types.isNumber(reveaLineArg.lineNumber)) {
  78771. return false;
  78772. }
  78773. if (!types.isUndefined(reveaLineArg.at) && !types.isString(reveaLineArg.at)) {
  78774. return false;
  78775. }
  78776. return true;
  78777. };
  78778. RevealLine_.description = {
  78779. description: 'Reveal the given line at the given logical position',
  78780. args: [
  78781. {
  78782. name: 'Reveal line argument object',
  78783. description: "Property-value pairs that can be passed through this argument:\n\t\t\t\t\t* 'lineNumber': A mandatory line number value.\n\t\t\t\t\t* 'at': Logical position at which line has to be revealed .\n\t\t\t\t\t\t```\n\t\t\t\t\t\t'top', 'center', 'bottom'\n\t\t\t\t\t\t```\n\t\t\t\t",
  78784. constraint: isRevealLineArgs,
  78785. schema: {
  78786. 'type': 'object',
  78787. 'required': ['lineNumber'],
  78788. 'properties': {
  78789. 'lineNumber': {
  78790. 'type': 'number',
  78791. },
  78792. 'at': {
  78793. 'type': 'string',
  78794. 'enum': ['top', 'center', 'bottom']
  78795. }
  78796. }
  78797. }
  78798. }
  78799. ]
  78800. };
  78801. /**
  78802. * Values for reveal line 'at' argument
  78803. */
  78804. RevealLine_.RawAtArgument = {
  78805. Top: 'top',
  78806. Center: 'center',
  78807. Bottom: 'bottom'
  78808. };
  78809. })(RevealLine_ = exports.RevealLine_ || (exports.RevealLine_ = {}));
  78810. var CoreNavigationCommands;
  78811. (function (CoreNavigationCommands) {
  78812. var BaseMoveToCommand = /** @class */ (function (_super) {
  78813. __extends(BaseMoveToCommand, _super);
  78814. function BaseMoveToCommand(opts) {
  78815. var _this = _super.call(this, opts) || this;
  78816. _this._inSelectionMode = opts.inSelectionMode;
  78817. return _this;
  78818. }
  78819. BaseMoveToCommand.prototype.runCoreEditorCommand = function (cursors, args) {
  78820. cursors.context.model.pushStackElement();
  78821. cursors.setStates(args.source, 3 /* Explicit */, [
  78822. cursorMoveCommands_1.CursorMoveCommands.moveTo(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position, args.viewPosition)
  78823. ]);
  78824. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  78825. };
  78826. return BaseMoveToCommand;
  78827. }(CoreEditorCommand));
  78828. CoreNavigationCommands.MoveTo = editorExtensions_1.registerEditorCommand(new BaseMoveToCommand({
  78829. id: '_moveTo',
  78830. inSelectionMode: false,
  78831. precondition: undefined
  78832. }));
  78833. CoreNavigationCommands.MoveToSelect = editorExtensions_1.registerEditorCommand(new BaseMoveToCommand({
  78834. id: '_moveToSelect',
  78835. inSelectionMode: true,
  78836. precondition: undefined
  78837. }));
  78838. var ColumnSelectCommand = /** @class */ (function (_super) {
  78839. __extends(ColumnSelectCommand, _super);
  78840. function ColumnSelectCommand() {
  78841. return _super !== null && _super.apply(this, arguments) || this;
  78842. }
  78843. ColumnSelectCommand.prototype.runCoreEditorCommand = function (cursors, args) {
  78844. cursors.context.model.pushStackElement();
  78845. var result = this._getColumnSelectResult(cursors.context, cursors.getPrimaryCursor(), cursors.getColumnSelectData(), args);
  78846. cursors.setStates(args.source, 3 /* Explicit */, result.viewStates.map(function (viewState) { return cursorCommon_1.CursorState.fromViewState(viewState); }));
  78847. cursors.setColumnSelectData({
  78848. isReal: true,
  78849. fromViewLineNumber: result.fromLineNumber,
  78850. fromViewVisualColumn: result.fromVisualColumn,
  78851. toViewLineNumber: result.toLineNumber,
  78852. toViewVisualColumn: result.toVisualColumn
  78853. });
  78854. cursors.reveal(args.source, true, (result.reversed ? 1 /* TopMost */ : 2 /* BottomMost */), 0 /* Smooth */);
  78855. };
  78856. return ColumnSelectCommand;
  78857. }(CoreEditorCommand));
  78858. CoreNavigationCommands.ColumnSelect = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  78859. __extends(class_1, _super);
  78860. function class_1() {
  78861. return _super.call(this, {
  78862. id: 'columnSelect',
  78863. precondition: undefined
  78864. }) || this;
  78865. }
  78866. class_1.prototype._getColumnSelectResult = function (context, primary, prevColumnSelectData, args) {
  78867. // validate `args`
  78868. var validatedPosition = context.model.validatePosition(args.position);
  78869. var validatedViewPosition = context.validateViewPosition(new position_1.Position(args.viewPosition.lineNumber, args.viewPosition.column), validatedPosition);
  78870. var fromViewLineNumber = args.doColumnSelect ? prevColumnSelectData.fromViewLineNumber : validatedViewPosition.lineNumber;
  78871. var fromViewVisualColumn = args.doColumnSelect ? prevColumnSelectData.fromViewVisualColumn : args.mouseColumn - 1;
  78872. return cursorColumnSelection_1.ColumnSelection.columnSelect(context.config, context.viewModel, fromViewLineNumber, fromViewVisualColumn, validatedViewPosition.lineNumber, args.mouseColumn - 1);
  78873. };
  78874. return class_1;
  78875. }(ColumnSelectCommand)));
  78876. CoreNavigationCommands.CursorColumnSelectLeft = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  78877. __extends(class_2, _super);
  78878. function class_2() {
  78879. return _super.call(this, {
  78880. id: 'cursorColumnSelectLeft',
  78881. precondition: undefined,
  78882. kbOpts: {
  78883. weight: CORE_WEIGHT,
  78884. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  78885. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 512 /* Alt */ | 15 /* LeftArrow */,
  78886. linux: { primary: 0 }
  78887. }
  78888. }) || this;
  78889. }
  78890. class_2.prototype._getColumnSelectResult = function (context, primary, prevColumnSelectData, args) {
  78891. return cursorColumnSelection_1.ColumnSelection.columnSelectLeft(context.config, context.viewModel, prevColumnSelectData);
  78892. };
  78893. return class_2;
  78894. }(ColumnSelectCommand)));
  78895. CoreNavigationCommands.CursorColumnSelectRight = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  78896. __extends(class_3, _super);
  78897. function class_3() {
  78898. return _super.call(this, {
  78899. id: 'cursorColumnSelectRight',
  78900. precondition: undefined,
  78901. kbOpts: {
  78902. weight: CORE_WEIGHT,
  78903. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  78904. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 512 /* Alt */ | 17 /* RightArrow */,
  78905. linux: { primary: 0 }
  78906. }
  78907. }) || this;
  78908. }
  78909. class_3.prototype._getColumnSelectResult = function (context, primary, prevColumnSelectData, args) {
  78910. return cursorColumnSelection_1.ColumnSelection.columnSelectRight(context.config, context.viewModel, prevColumnSelectData);
  78911. };
  78912. return class_3;
  78913. }(ColumnSelectCommand)));
  78914. var ColumnSelectUpCommand = /** @class */ (function (_super) {
  78915. __extends(ColumnSelectUpCommand, _super);
  78916. function ColumnSelectUpCommand(opts) {
  78917. var _this = _super.call(this, opts) || this;
  78918. _this._isPaged = opts.isPaged;
  78919. return _this;
  78920. }
  78921. ColumnSelectUpCommand.prototype._getColumnSelectResult = function (context, primary, prevColumnSelectData, args) {
  78922. return cursorColumnSelection_1.ColumnSelection.columnSelectUp(context.config, context.viewModel, prevColumnSelectData, this._isPaged);
  78923. };
  78924. return ColumnSelectUpCommand;
  78925. }(ColumnSelectCommand));
  78926. CoreNavigationCommands.CursorColumnSelectUp = editorExtensions_1.registerEditorCommand(new ColumnSelectUpCommand({
  78927. isPaged: false,
  78928. id: 'cursorColumnSelectUp',
  78929. precondition: undefined,
  78930. kbOpts: {
  78931. weight: CORE_WEIGHT,
  78932. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  78933. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 512 /* Alt */ | 16 /* UpArrow */,
  78934. linux: { primary: 0 }
  78935. }
  78936. }));
  78937. CoreNavigationCommands.CursorColumnSelectPageUp = editorExtensions_1.registerEditorCommand(new ColumnSelectUpCommand({
  78938. isPaged: true,
  78939. id: 'cursorColumnSelectPageUp',
  78940. precondition: undefined,
  78941. kbOpts: {
  78942. weight: CORE_WEIGHT,
  78943. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  78944. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 512 /* Alt */ | 11 /* PageUp */,
  78945. linux: { primary: 0 }
  78946. }
  78947. }));
  78948. var ColumnSelectDownCommand = /** @class */ (function (_super) {
  78949. __extends(ColumnSelectDownCommand, _super);
  78950. function ColumnSelectDownCommand(opts) {
  78951. var _this = _super.call(this, opts) || this;
  78952. _this._isPaged = opts.isPaged;
  78953. return _this;
  78954. }
  78955. ColumnSelectDownCommand.prototype._getColumnSelectResult = function (context, primary, prevColumnSelectData, args) {
  78956. return cursorColumnSelection_1.ColumnSelection.columnSelectDown(context.config, context.viewModel, prevColumnSelectData, this._isPaged);
  78957. };
  78958. return ColumnSelectDownCommand;
  78959. }(ColumnSelectCommand));
  78960. CoreNavigationCommands.CursorColumnSelectDown = editorExtensions_1.registerEditorCommand(new ColumnSelectDownCommand({
  78961. isPaged: false,
  78962. id: 'cursorColumnSelectDown',
  78963. precondition: undefined,
  78964. kbOpts: {
  78965. weight: CORE_WEIGHT,
  78966. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  78967. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 512 /* Alt */ | 18 /* DownArrow */,
  78968. linux: { primary: 0 }
  78969. }
  78970. }));
  78971. CoreNavigationCommands.CursorColumnSelectPageDown = editorExtensions_1.registerEditorCommand(new ColumnSelectDownCommand({
  78972. isPaged: true,
  78973. id: 'cursorColumnSelectPageDown',
  78974. precondition: undefined,
  78975. kbOpts: {
  78976. weight: CORE_WEIGHT,
  78977. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  78978. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 512 /* Alt */ | 12 /* PageDown */,
  78979. linux: { primary: 0 }
  78980. }
  78981. }));
  78982. var CursorMoveImpl = /** @class */ (function (_super) {
  78983. __extends(CursorMoveImpl, _super);
  78984. function CursorMoveImpl() {
  78985. return _super.call(this, {
  78986. id: 'cursorMove',
  78987. precondition: undefined,
  78988. description: cursorMoveCommands_1.CursorMove.description
  78989. }) || this;
  78990. }
  78991. CursorMoveImpl.prototype.runCoreEditorCommand = function (cursors, args) {
  78992. var parsed = cursorMoveCommands_1.CursorMove.parse(args);
  78993. if (!parsed) {
  78994. // illegal arguments
  78995. return;
  78996. }
  78997. this._runCursorMove(cursors, args.source, parsed);
  78998. };
  78999. CursorMoveImpl.prototype._runCursorMove = function (cursors, source, args) {
  79000. cursors.context.model.pushStackElement();
  79001. cursors.setStates(source, 3 /* Explicit */, cursorMoveCommands_1.CursorMoveCommands.move(cursors.context, cursors.getAll(), args));
  79002. cursors.reveal(source, true, 0 /* Primary */, 0 /* Smooth */);
  79003. };
  79004. return CursorMoveImpl;
  79005. }(CoreEditorCommand));
  79006. CoreNavigationCommands.CursorMoveImpl = CursorMoveImpl;
  79007. CoreNavigationCommands.CursorMove = editorExtensions_1.registerEditorCommand(new CursorMoveImpl());
  79008. var CursorMoveBasedCommand = /** @class */ (function (_super) {
  79009. __extends(CursorMoveBasedCommand, _super);
  79010. function CursorMoveBasedCommand(opts) {
  79011. var _this = _super.call(this, opts) || this;
  79012. _this._staticArgs = opts.args;
  79013. return _this;
  79014. }
  79015. CursorMoveBasedCommand.prototype.runCoreEditorCommand = function (cursors, dynamicArgs) {
  79016. var args = this._staticArgs;
  79017. if (this._staticArgs.value === -1 /* PAGE_SIZE_MARKER */) {
  79018. // -1 is a marker for page size
  79019. args = {
  79020. direction: this._staticArgs.direction,
  79021. unit: this._staticArgs.unit,
  79022. select: this._staticArgs.select,
  79023. value: cursors.context.config.pageSize
  79024. };
  79025. }
  79026. CoreNavigationCommands.CursorMove._runCursorMove(cursors, dynamicArgs.source, args);
  79027. };
  79028. return CursorMoveBasedCommand;
  79029. }(CoreEditorCommand));
  79030. CoreNavigationCommands.CursorLeft = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79031. args: {
  79032. direction: 0 /* Left */,
  79033. unit: 0 /* None */,
  79034. select: false,
  79035. value: 1
  79036. },
  79037. id: 'cursorLeft',
  79038. precondition: undefined,
  79039. kbOpts: {
  79040. weight: CORE_WEIGHT,
  79041. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79042. primary: 15 /* LeftArrow */,
  79043. mac: { primary: 15 /* LeftArrow */, secondary: [256 /* WinCtrl */ | 32 /* KEY_B */] }
  79044. }
  79045. }));
  79046. CoreNavigationCommands.CursorLeftSelect = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79047. args: {
  79048. direction: 0 /* Left */,
  79049. unit: 0 /* None */,
  79050. select: true,
  79051. value: 1
  79052. },
  79053. id: 'cursorLeftSelect',
  79054. precondition: undefined,
  79055. kbOpts: {
  79056. weight: CORE_WEIGHT,
  79057. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79058. primary: 1024 /* Shift */ | 15 /* LeftArrow */
  79059. }
  79060. }));
  79061. CoreNavigationCommands.CursorRight = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79062. args: {
  79063. direction: 1 /* Right */,
  79064. unit: 0 /* None */,
  79065. select: false,
  79066. value: 1
  79067. },
  79068. id: 'cursorRight',
  79069. precondition: undefined,
  79070. kbOpts: {
  79071. weight: CORE_WEIGHT,
  79072. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79073. primary: 17 /* RightArrow */,
  79074. mac: { primary: 17 /* RightArrow */, secondary: [256 /* WinCtrl */ | 36 /* KEY_F */] }
  79075. }
  79076. }));
  79077. CoreNavigationCommands.CursorRightSelect = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79078. args: {
  79079. direction: 1 /* Right */,
  79080. unit: 0 /* None */,
  79081. select: true,
  79082. value: 1
  79083. },
  79084. id: 'cursorRightSelect',
  79085. precondition: undefined,
  79086. kbOpts: {
  79087. weight: CORE_WEIGHT,
  79088. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79089. primary: 1024 /* Shift */ | 17 /* RightArrow */
  79090. }
  79091. }));
  79092. CoreNavigationCommands.CursorUp = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79093. args: {
  79094. direction: 2 /* Up */,
  79095. unit: 2 /* WrappedLine */,
  79096. select: false,
  79097. value: 1
  79098. },
  79099. id: 'cursorUp',
  79100. precondition: undefined,
  79101. kbOpts: {
  79102. weight: CORE_WEIGHT,
  79103. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79104. primary: 16 /* UpArrow */,
  79105. mac: { primary: 16 /* UpArrow */, secondary: [256 /* WinCtrl */ | 46 /* KEY_P */] }
  79106. }
  79107. }));
  79108. CoreNavigationCommands.CursorUpSelect = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79109. args: {
  79110. direction: 2 /* Up */,
  79111. unit: 2 /* WrappedLine */,
  79112. select: true,
  79113. value: 1
  79114. },
  79115. id: 'cursorUpSelect',
  79116. precondition: undefined,
  79117. kbOpts: {
  79118. weight: CORE_WEIGHT,
  79119. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79120. primary: 1024 /* Shift */ | 16 /* UpArrow */,
  79121. secondary: [2048 /* CtrlCmd */ | 1024 /* Shift */ | 16 /* UpArrow */],
  79122. mac: { primary: 1024 /* Shift */ | 16 /* UpArrow */ },
  79123. linux: { primary: 1024 /* Shift */ | 16 /* UpArrow */ }
  79124. }
  79125. }));
  79126. CoreNavigationCommands.CursorPageUp = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79127. args: {
  79128. direction: 2 /* Up */,
  79129. unit: 2 /* WrappedLine */,
  79130. select: false,
  79131. value: -1 /* PAGE_SIZE_MARKER */
  79132. },
  79133. id: 'cursorPageUp',
  79134. precondition: undefined,
  79135. kbOpts: {
  79136. weight: CORE_WEIGHT,
  79137. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79138. primary: 11 /* PageUp */
  79139. }
  79140. }));
  79141. CoreNavigationCommands.CursorPageUpSelect = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79142. args: {
  79143. direction: 2 /* Up */,
  79144. unit: 2 /* WrappedLine */,
  79145. select: true,
  79146. value: -1 /* PAGE_SIZE_MARKER */
  79147. },
  79148. id: 'cursorPageUpSelect',
  79149. precondition: undefined,
  79150. kbOpts: {
  79151. weight: CORE_WEIGHT,
  79152. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79153. primary: 1024 /* Shift */ | 11 /* PageUp */
  79154. }
  79155. }));
  79156. CoreNavigationCommands.CursorDown = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79157. args: {
  79158. direction: 3 /* Down */,
  79159. unit: 2 /* WrappedLine */,
  79160. select: false,
  79161. value: 1
  79162. },
  79163. id: 'cursorDown',
  79164. precondition: undefined,
  79165. kbOpts: {
  79166. weight: CORE_WEIGHT,
  79167. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79168. primary: 18 /* DownArrow */,
  79169. mac: { primary: 18 /* DownArrow */, secondary: [256 /* WinCtrl */ | 44 /* KEY_N */] }
  79170. }
  79171. }));
  79172. CoreNavigationCommands.CursorDownSelect = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79173. args: {
  79174. direction: 3 /* Down */,
  79175. unit: 2 /* WrappedLine */,
  79176. select: true,
  79177. value: 1
  79178. },
  79179. id: 'cursorDownSelect',
  79180. precondition: undefined,
  79181. kbOpts: {
  79182. weight: CORE_WEIGHT,
  79183. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79184. primary: 1024 /* Shift */ | 18 /* DownArrow */,
  79185. secondary: [2048 /* CtrlCmd */ | 1024 /* Shift */ | 18 /* DownArrow */],
  79186. mac: { primary: 1024 /* Shift */ | 18 /* DownArrow */ },
  79187. linux: { primary: 1024 /* Shift */ | 18 /* DownArrow */ }
  79188. }
  79189. }));
  79190. CoreNavigationCommands.CursorPageDown = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79191. args: {
  79192. direction: 3 /* Down */,
  79193. unit: 2 /* WrappedLine */,
  79194. select: false,
  79195. value: -1 /* PAGE_SIZE_MARKER */
  79196. },
  79197. id: 'cursorPageDown',
  79198. precondition: undefined,
  79199. kbOpts: {
  79200. weight: CORE_WEIGHT,
  79201. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79202. primary: 12 /* PageDown */
  79203. }
  79204. }));
  79205. CoreNavigationCommands.CursorPageDownSelect = editorExtensions_1.registerEditorCommand(new CursorMoveBasedCommand({
  79206. args: {
  79207. direction: 3 /* Down */,
  79208. unit: 2 /* WrappedLine */,
  79209. select: true,
  79210. value: -1 /* PAGE_SIZE_MARKER */
  79211. },
  79212. id: 'cursorPageDownSelect',
  79213. precondition: undefined,
  79214. kbOpts: {
  79215. weight: CORE_WEIGHT,
  79216. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79217. primary: 1024 /* Shift */ | 12 /* PageDown */
  79218. }
  79219. }));
  79220. CoreNavigationCommands.CreateCursor = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79221. __extends(class_4, _super);
  79222. function class_4() {
  79223. return _super.call(this, {
  79224. id: 'createCursor',
  79225. precondition: undefined
  79226. }) || this;
  79227. }
  79228. class_4.prototype.runCoreEditorCommand = function (cursors, args) {
  79229. var context = cursors.context;
  79230. var newState;
  79231. if (args.wholeLine) {
  79232. newState = cursorMoveCommands_1.CursorMoveCommands.line(context, cursors.getPrimaryCursor(), false, args.position, args.viewPosition);
  79233. }
  79234. else {
  79235. newState = cursorMoveCommands_1.CursorMoveCommands.moveTo(context, cursors.getPrimaryCursor(), false, args.position, args.viewPosition);
  79236. }
  79237. var states = cursors.getAll();
  79238. // Check if we should remove a cursor (sort of like a toggle)
  79239. if (states.length > 1) {
  79240. var newModelPosition = (newState.modelState ? newState.modelState.position : null);
  79241. var newViewPosition = (newState.viewState ? newState.viewState.position : null);
  79242. for (var i = 0, len = states.length; i < len; i++) {
  79243. var state = states[i];
  79244. if (newModelPosition && !state.modelState.selection.containsPosition(newModelPosition)) {
  79245. continue;
  79246. }
  79247. if (newViewPosition && !state.viewState.selection.containsPosition(newViewPosition)) {
  79248. continue;
  79249. }
  79250. // => Remove the cursor
  79251. states.splice(i, 1);
  79252. cursors.context.model.pushStackElement();
  79253. cursors.setStates(args.source, 3 /* Explicit */, states);
  79254. return;
  79255. }
  79256. }
  79257. // => Add the new cursor
  79258. states.push(newState);
  79259. cursors.context.model.pushStackElement();
  79260. cursors.setStates(args.source, 3 /* Explicit */, states);
  79261. };
  79262. return class_4;
  79263. }(CoreEditorCommand)));
  79264. CoreNavigationCommands.LastCursorMoveToSelect = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79265. __extends(class_5, _super);
  79266. function class_5() {
  79267. return _super.call(this, {
  79268. id: '_lastCursorMoveToSelect',
  79269. precondition: undefined
  79270. }) || this;
  79271. }
  79272. class_5.prototype.runCoreEditorCommand = function (cursors, args) {
  79273. var context = cursors.context;
  79274. var lastAddedCursorIndex = cursors.getLastAddedCursorIndex();
  79275. var states = cursors.getAll();
  79276. var newStates = states.slice(0);
  79277. newStates[lastAddedCursorIndex] = cursorMoveCommands_1.CursorMoveCommands.moveTo(context, states[lastAddedCursorIndex], true, args.position, args.viewPosition);
  79278. cursors.context.model.pushStackElement();
  79279. cursors.setStates(args.source, 3 /* Explicit */, newStates);
  79280. };
  79281. return class_5;
  79282. }(CoreEditorCommand)));
  79283. var HomeCommand = /** @class */ (function (_super) {
  79284. __extends(HomeCommand, _super);
  79285. function HomeCommand(opts) {
  79286. var _this = _super.call(this, opts) || this;
  79287. _this._inSelectionMode = opts.inSelectionMode;
  79288. return _this;
  79289. }
  79290. HomeCommand.prototype.runCoreEditorCommand = function (cursors, args) {
  79291. cursors.context.model.pushStackElement();
  79292. cursors.setStates(args.source, 3 /* Explicit */, cursorMoveCommands_1.CursorMoveCommands.moveToBeginningOfLine(cursors.context, cursors.getAll(), this._inSelectionMode));
  79293. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  79294. };
  79295. return HomeCommand;
  79296. }(CoreEditorCommand));
  79297. CoreNavigationCommands.CursorHome = editorExtensions_1.registerEditorCommand(new HomeCommand({
  79298. inSelectionMode: false,
  79299. id: 'cursorHome',
  79300. precondition: undefined,
  79301. kbOpts: {
  79302. weight: CORE_WEIGHT,
  79303. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79304. primary: 14 /* Home */,
  79305. mac: { primary: 14 /* Home */, secondary: [2048 /* CtrlCmd */ | 15 /* LeftArrow */] }
  79306. }
  79307. }));
  79308. CoreNavigationCommands.CursorHomeSelect = editorExtensions_1.registerEditorCommand(new HomeCommand({
  79309. inSelectionMode: true,
  79310. id: 'cursorHomeSelect',
  79311. precondition: undefined,
  79312. kbOpts: {
  79313. weight: CORE_WEIGHT,
  79314. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79315. primary: 1024 /* Shift */ | 14 /* Home */,
  79316. mac: { primary: 1024 /* Shift */ | 14 /* Home */, secondary: [2048 /* CtrlCmd */ | 1024 /* Shift */ | 15 /* LeftArrow */] }
  79317. }
  79318. }));
  79319. CoreNavigationCommands.CursorLineStart = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79320. __extends(class_6, _super);
  79321. function class_6() {
  79322. return _super.call(this, {
  79323. id: 'cursorLineStart',
  79324. precondition: undefined,
  79325. kbOpts: {
  79326. weight: CORE_WEIGHT,
  79327. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79328. primary: 0,
  79329. mac: { primary: 256 /* WinCtrl */ | 31 /* KEY_A */ }
  79330. }
  79331. }) || this;
  79332. }
  79333. class_6.prototype.runCoreEditorCommand = function (cursors, args) {
  79334. cursors.context.model.pushStackElement();
  79335. cursors.setStates(args.source, 3 /* Explicit */, this._exec(cursors.context, cursors.getAll()));
  79336. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  79337. };
  79338. class_6.prototype._exec = function (context, cursors) {
  79339. var result = [];
  79340. for (var i = 0, len = cursors.length; i < len; i++) {
  79341. var cursor = cursors[i];
  79342. var lineNumber = cursor.modelState.position.lineNumber;
  79343. result[i] = cursorCommon_1.CursorState.fromModelState(cursor.modelState.move(false, lineNumber, 1, 0));
  79344. }
  79345. return result;
  79346. };
  79347. return class_6;
  79348. }(CoreEditorCommand)));
  79349. var EndCommand = /** @class */ (function (_super) {
  79350. __extends(EndCommand, _super);
  79351. function EndCommand(opts) {
  79352. var _this = _super.call(this, opts) || this;
  79353. _this._inSelectionMode = opts.inSelectionMode;
  79354. return _this;
  79355. }
  79356. EndCommand.prototype.runCoreEditorCommand = function (cursors, args) {
  79357. cursors.context.model.pushStackElement();
  79358. cursors.setStates(args.source, 3 /* Explicit */, cursorMoveCommands_1.CursorMoveCommands.moveToEndOfLine(cursors.context, cursors.getAll(), this._inSelectionMode));
  79359. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  79360. };
  79361. return EndCommand;
  79362. }(CoreEditorCommand));
  79363. CoreNavigationCommands.CursorEnd = editorExtensions_1.registerEditorCommand(new EndCommand({
  79364. inSelectionMode: false,
  79365. id: 'cursorEnd',
  79366. precondition: undefined,
  79367. kbOpts: {
  79368. weight: CORE_WEIGHT,
  79369. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79370. primary: 13 /* End */,
  79371. mac: { primary: 13 /* End */, secondary: [2048 /* CtrlCmd */ | 17 /* RightArrow */] }
  79372. }
  79373. }));
  79374. CoreNavigationCommands.CursorEndSelect = editorExtensions_1.registerEditorCommand(new EndCommand({
  79375. inSelectionMode: true,
  79376. id: 'cursorEndSelect',
  79377. precondition: undefined,
  79378. kbOpts: {
  79379. weight: CORE_WEIGHT,
  79380. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79381. primary: 1024 /* Shift */ | 13 /* End */,
  79382. mac: { primary: 1024 /* Shift */ | 13 /* End */, secondary: [2048 /* CtrlCmd */ | 1024 /* Shift */ | 17 /* RightArrow */] }
  79383. }
  79384. }));
  79385. CoreNavigationCommands.CursorLineEnd = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79386. __extends(class_7, _super);
  79387. function class_7() {
  79388. return _super.call(this, {
  79389. id: 'cursorLineEnd',
  79390. precondition: undefined,
  79391. kbOpts: {
  79392. weight: CORE_WEIGHT,
  79393. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79394. primary: 0,
  79395. mac: { primary: 256 /* WinCtrl */ | 35 /* KEY_E */ }
  79396. }
  79397. }) || this;
  79398. }
  79399. class_7.prototype.runCoreEditorCommand = function (cursors, args) {
  79400. cursors.context.model.pushStackElement();
  79401. cursors.setStates(args.source, 3 /* Explicit */, this._exec(cursors.context, cursors.getAll()));
  79402. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  79403. };
  79404. class_7.prototype._exec = function (context, cursors) {
  79405. var result = [];
  79406. for (var i = 0, len = cursors.length; i < len; i++) {
  79407. var cursor = cursors[i];
  79408. var lineNumber = cursor.modelState.position.lineNumber;
  79409. var maxColumn = context.model.getLineMaxColumn(lineNumber);
  79410. result[i] = cursorCommon_1.CursorState.fromModelState(cursor.modelState.move(false, lineNumber, maxColumn, 0));
  79411. }
  79412. return result;
  79413. };
  79414. return class_7;
  79415. }(CoreEditorCommand)));
  79416. var TopCommand = /** @class */ (function (_super) {
  79417. __extends(TopCommand, _super);
  79418. function TopCommand(opts) {
  79419. var _this = _super.call(this, opts) || this;
  79420. _this._inSelectionMode = opts.inSelectionMode;
  79421. return _this;
  79422. }
  79423. TopCommand.prototype.runCoreEditorCommand = function (cursors, args) {
  79424. cursors.context.model.pushStackElement();
  79425. cursors.setStates(args.source, 3 /* Explicit */, cursorMoveCommands_1.CursorMoveCommands.moveToBeginningOfBuffer(cursors.context, cursors.getAll(), this._inSelectionMode));
  79426. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  79427. };
  79428. return TopCommand;
  79429. }(CoreEditorCommand));
  79430. CoreNavigationCommands.CursorTop = editorExtensions_1.registerEditorCommand(new TopCommand({
  79431. inSelectionMode: false,
  79432. id: 'cursorTop',
  79433. precondition: undefined,
  79434. kbOpts: {
  79435. weight: CORE_WEIGHT,
  79436. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79437. primary: 2048 /* CtrlCmd */ | 14 /* Home */,
  79438. mac: { primary: 2048 /* CtrlCmd */ | 16 /* UpArrow */ }
  79439. }
  79440. }));
  79441. CoreNavigationCommands.CursorTopSelect = editorExtensions_1.registerEditorCommand(new TopCommand({
  79442. inSelectionMode: true,
  79443. id: 'cursorTopSelect',
  79444. precondition: undefined,
  79445. kbOpts: {
  79446. weight: CORE_WEIGHT,
  79447. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79448. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 14 /* Home */,
  79449. mac: { primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 16 /* UpArrow */ }
  79450. }
  79451. }));
  79452. var BottomCommand = /** @class */ (function (_super) {
  79453. __extends(BottomCommand, _super);
  79454. function BottomCommand(opts) {
  79455. var _this = _super.call(this, opts) || this;
  79456. _this._inSelectionMode = opts.inSelectionMode;
  79457. return _this;
  79458. }
  79459. BottomCommand.prototype.runCoreEditorCommand = function (cursors, args) {
  79460. cursors.context.model.pushStackElement();
  79461. cursors.setStates(args.source, 3 /* Explicit */, cursorMoveCommands_1.CursorMoveCommands.moveToEndOfBuffer(cursors.context, cursors.getAll(), this._inSelectionMode));
  79462. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  79463. };
  79464. return BottomCommand;
  79465. }(CoreEditorCommand));
  79466. CoreNavigationCommands.CursorBottom = editorExtensions_1.registerEditorCommand(new BottomCommand({
  79467. inSelectionMode: false,
  79468. id: 'cursorBottom',
  79469. precondition: undefined,
  79470. kbOpts: {
  79471. weight: CORE_WEIGHT,
  79472. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79473. primary: 2048 /* CtrlCmd */ | 13 /* End */,
  79474. mac: { primary: 2048 /* CtrlCmd */ | 18 /* DownArrow */ }
  79475. }
  79476. }));
  79477. CoreNavigationCommands.CursorBottomSelect = editorExtensions_1.registerEditorCommand(new BottomCommand({
  79478. inSelectionMode: true,
  79479. id: 'cursorBottomSelect',
  79480. precondition: undefined,
  79481. kbOpts: {
  79482. weight: CORE_WEIGHT,
  79483. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79484. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 13 /* End */,
  79485. mac: { primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 18 /* DownArrow */ }
  79486. }
  79487. }));
  79488. var EditorScrollImpl = /** @class */ (function (_super) {
  79489. __extends(EditorScrollImpl, _super);
  79490. function EditorScrollImpl() {
  79491. return _super.call(this, {
  79492. id: 'editorScroll',
  79493. precondition: undefined,
  79494. description: EditorScroll_.description
  79495. }) || this;
  79496. }
  79497. EditorScrollImpl.prototype.runCoreEditorCommand = function (cursors, args) {
  79498. var parsed = EditorScroll_.parse(args);
  79499. if (!parsed) {
  79500. // illegal arguments
  79501. return;
  79502. }
  79503. this._runEditorScroll(cursors, args.source, parsed);
  79504. };
  79505. EditorScrollImpl.prototype._runEditorScroll = function (cursors, source, args) {
  79506. var desiredScrollTop = this._computeDesiredScrollTop(cursors.context, args);
  79507. if (args.revealCursor) {
  79508. // must ensure cursor is in new visible range
  79509. var desiredVisibleViewRange = cursors.context.getCompletelyVisibleViewRangeAtScrollTop(desiredScrollTop);
  79510. cursors.setStates(source, 3 /* Explicit */, [
  79511. cursorMoveCommands_1.CursorMoveCommands.findPositionInViewportIfOutside(cursors.context, cursors.getPrimaryCursor(), desiredVisibleViewRange, args.select)
  79512. ]);
  79513. }
  79514. cursors.scrollTo(desiredScrollTop);
  79515. };
  79516. EditorScrollImpl.prototype._computeDesiredScrollTop = function (context, args) {
  79517. if (args.unit === 1 /* Line */) {
  79518. // scrolling by model lines
  79519. var visibleModelRange = context.getCompletelyVisibleModelRange();
  79520. var desiredTopModelLineNumber = void 0;
  79521. if (args.direction === 1 /* Up */) {
  79522. // must go x model lines up
  79523. desiredTopModelLineNumber = Math.max(1, visibleModelRange.startLineNumber - args.value);
  79524. }
  79525. else {
  79526. // must go x model lines down
  79527. desiredTopModelLineNumber = Math.min(context.model.getLineCount(), visibleModelRange.startLineNumber + args.value);
  79528. }
  79529. var desiredTopViewPosition = context.convertModelPositionToViewPosition(new position_1.Position(desiredTopModelLineNumber, 1));
  79530. return context.getVerticalOffsetForViewLine(desiredTopViewPosition.lineNumber);
  79531. }
  79532. var noOfLines;
  79533. if (args.unit === 3 /* Page */) {
  79534. noOfLines = context.config.pageSize * args.value;
  79535. }
  79536. else if (args.unit === 4 /* HalfPage */) {
  79537. noOfLines = Math.round(context.config.pageSize / 2) * args.value;
  79538. }
  79539. else {
  79540. noOfLines = args.value;
  79541. }
  79542. var deltaLines = (args.direction === 1 /* Up */ ? -1 : 1) * noOfLines;
  79543. return context.getCurrentScrollTop() + deltaLines * context.config.lineHeight;
  79544. };
  79545. return EditorScrollImpl;
  79546. }(CoreEditorCommand));
  79547. CoreNavigationCommands.EditorScrollImpl = EditorScrollImpl;
  79548. CoreNavigationCommands.EditorScroll = editorExtensions_1.registerEditorCommand(new EditorScrollImpl());
  79549. CoreNavigationCommands.ScrollLineUp = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79550. __extends(class_8, _super);
  79551. function class_8() {
  79552. return _super.call(this, {
  79553. id: 'scrollLineUp',
  79554. precondition: undefined,
  79555. kbOpts: {
  79556. weight: CORE_WEIGHT,
  79557. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79558. primary: 2048 /* CtrlCmd */ | 16 /* UpArrow */,
  79559. mac: { primary: 256 /* WinCtrl */ | 11 /* PageUp */ }
  79560. }
  79561. }) || this;
  79562. }
  79563. class_8.prototype.runCoreEditorCommand = function (cursors, args) {
  79564. CoreNavigationCommands.EditorScroll._runEditorScroll(cursors, args.source, {
  79565. direction: 1 /* Up */,
  79566. unit: 2 /* WrappedLine */,
  79567. value: 1,
  79568. revealCursor: false,
  79569. select: false
  79570. });
  79571. };
  79572. return class_8;
  79573. }(CoreEditorCommand)));
  79574. CoreNavigationCommands.ScrollPageUp = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79575. __extends(class_9, _super);
  79576. function class_9() {
  79577. return _super.call(this, {
  79578. id: 'scrollPageUp',
  79579. precondition: undefined,
  79580. kbOpts: {
  79581. weight: CORE_WEIGHT,
  79582. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79583. primary: 2048 /* CtrlCmd */ | 11 /* PageUp */,
  79584. win: { primary: 512 /* Alt */ | 11 /* PageUp */ },
  79585. linux: { primary: 512 /* Alt */ | 11 /* PageUp */ }
  79586. }
  79587. }) || this;
  79588. }
  79589. class_9.prototype.runCoreEditorCommand = function (cursors, args) {
  79590. CoreNavigationCommands.EditorScroll._runEditorScroll(cursors, args.source, {
  79591. direction: 1 /* Up */,
  79592. unit: 3 /* Page */,
  79593. value: 1,
  79594. revealCursor: false,
  79595. select: false
  79596. });
  79597. };
  79598. return class_9;
  79599. }(CoreEditorCommand)));
  79600. CoreNavigationCommands.ScrollLineDown = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79601. __extends(class_10, _super);
  79602. function class_10() {
  79603. return _super.call(this, {
  79604. id: 'scrollLineDown',
  79605. precondition: undefined,
  79606. kbOpts: {
  79607. weight: CORE_WEIGHT,
  79608. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79609. primary: 2048 /* CtrlCmd */ | 18 /* DownArrow */,
  79610. mac: { primary: 256 /* WinCtrl */ | 12 /* PageDown */ }
  79611. }
  79612. }) || this;
  79613. }
  79614. class_10.prototype.runCoreEditorCommand = function (cursors, args) {
  79615. CoreNavigationCommands.EditorScroll._runEditorScroll(cursors, args.source, {
  79616. direction: 2 /* Down */,
  79617. unit: 2 /* WrappedLine */,
  79618. value: 1,
  79619. revealCursor: false,
  79620. select: false
  79621. });
  79622. };
  79623. return class_10;
  79624. }(CoreEditorCommand)));
  79625. CoreNavigationCommands.ScrollPageDown = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79626. __extends(class_11, _super);
  79627. function class_11() {
  79628. return _super.call(this, {
  79629. id: 'scrollPageDown',
  79630. precondition: undefined,
  79631. kbOpts: {
  79632. weight: CORE_WEIGHT,
  79633. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79634. primary: 2048 /* CtrlCmd */ | 12 /* PageDown */,
  79635. win: { primary: 512 /* Alt */ | 12 /* PageDown */ },
  79636. linux: { primary: 512 /* Alt */ | 12 /* PageDown */ }
  79637. }
  79638. }) || this;
  79639. }
  79640. class_11.prototype.runCoreEditorCommand = function (cursors, args) {
  79641. CoreNavigationCommands.EditorScroll._runEditorScroll(cursors, args.source, {
  79642. direction: 2 /* Down */,
  79643. unit: 3 /* Page */,
  79644. value: 1,
  79645. revealCursor: false,
  79646. select: false
  79647. });
  79648. };
  79649. return class_11;
  79650. }(CoreEditorCommand)));
  79651. var WordCommand = /** @class */ (function (_super) {
  79652. __extends(WordCommand, _super);
  79653. function WordCommand(opts) {
  79654. var _this = _super.call(this, opts) || this;
  79655. _this._inSelectionMode = opts.inSelectionMode;
  79656. return _this;
  79657. }
  79658. WordCommand.prototype.runCoreEditorCommand = function (cursors, args) {
  79659. cursors.context.model.pushStackElement();
  79660. cursors.setStates(args.source, 3 /* Explicit */, [
  79661. cursorMoveCommands_1.CursorMoveCommands.word(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position)
  79662. ]);
  79663. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  79664. };
  79665. return WordCommand;
  79666. }(CoreEditorCommand));
  79667. CoreNavigationCommands.WordSelect = editorExtensions_1.registerEditorCommand(new WordCommand({
  79668. inSelectionMode: false,
  79669. id: '_wordSelect',
  79670. precondition: undefined
  79671. }));
  79672. CoreNavigationCommands.WordSelectDrag = editorExtensions_1.registerEditorCommand(new WordCommand({
  79673. inSelectionMode: true,
  79674. id: '_wordSelectDrag',
  79675. precondition: undefined
  79676. }));
  79677. CoreNavigationCommands.LastCursorWordSelect = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79678. __extends(class_12, _super);
  79679. function class_12() {
  79680. return _super.call(this, {
  79681. id: 'lastCursorWordSelect',
  79682. precondition: undefined
  79683. }) || this;
  79684. }
  79685. class_12.prototype.runCoreEditorCommand = function (cursors, args) {
  79686. var context = cursors.context;
  79687. var lastAddedCursorIndex = cursors.getLastAddedCursorIndex();
  79688. var states = cursors.getAll();
  79689. var newStates = states.slice(0);
  79690. var lastAddedState = states[lastAddedCursorIndex];
  79691. newStates[lastAddedCursorIndex] = cursorMoveCommands_1.CursorMoveCommands.word(context, lastAddedState, lastAddedState.modelState.hasSelection(), args.position);
  79692. context.model.pushStackElement();
  79693. cursors.setStates(args.source, 3 /* Explicit */, newStates);
  79694. };
  79695. return class_12;
  79696. }(CoreEditorCommand)));
  79697. var LineCommand = /** @class */ (function (_super) {
  79698. __extends(LineCommand, _super);
  79699. function LineCommand(opts) {
  79700. var _this = _super.call(this, opts) || this;
  79701. _this._inSelectionMode = opts.inSelectionMode;
  79702. return _this;
  79703. }
  79704. LineCommand.prototype.runCoreEditorCommand = function (cursors, args) {
  79705. cursors.context.model.pushStackElement();
  79706. cursors.setStates(args.source, 3 /* Explicit */, [
  79707. cursorMoveCommands_1.CursorMoveCommands.line(cursors.context, cursors.getPrimaryCursor(), this._inSelectionMode, args.position, args.viewPosition)
  79708. ]);
  79709. cursors.reveal(args.source, false, 0 /* Primary */, 0 /* Smooth */);
  79710. };
  79711. return LineCommand;
  79712. }(CoreEditorCommand));
  79713. CoreNavigationCommands.LineSelect = editorExtensions_1.registerEditorCommand(new LineCommand({
  79714. inSelectionMode: false,
  79715. id: '_lineSelect',
  79716. precondition: undefined
  79717. }));
  79718. CoreNavigationCommands.LineSelectDrag = editorExtensions_1.registerEditorCommand(new LineCommand({
  79719. inSelectionMode: true,
  79720. id: '_lineSelectDrag',
  79721. precondition: undefined
  79722. }));
  79723. var LastCursorLineCommand = /** @class */ (function (_super) {
  79724. __extends(LastCursorLineCommand, _super);
  79725. function LastCursorLineCommand(opts) {
  79726. var _this = _super.call(this, opts) || this;
  79727. _this._inSelectionMode = opts.inSelectionMode;
  79728. return _this;
  79729. }
  79730. LastCursorLineCommand.prototype.runCoreEditorCommand = function (cursors, args) {
  79731. var lastAddedCursorIndex = cursors.getLastAddedCursorIndex();
  79732. var states = cursors.getAll();
  79733. var newStates = states.slice(0);
  79734. newStates[lastAddedCursorIndex] = cursorMoveCommands_1.CursorMoveCommands.line(cursors.context, states[lastAddedCursorIndex], this._inSelectionMode, args.position, args.viewPosition);
  79735. cursors.context.model.pushStackElement();
  79736. cursors.setStates(args.source, 3 /* Explicit */, newStates);
  79737. };
  79738. return LastCursorLineCommand;
  79739. }(CoreEditorCommand));
  79740. CoreNavigationCommands.LastCursorLineSelect = editorExtensions_1.registerEditorCommand(new LastCursorLineCommand({
  79741. inSelectionMode: false,
  79742. id: 'lastCursorLineSelect',
  79743. precondition: undefined
  79744. }));
  79745. CoreNavigationCommands.LastCursorLineSelectDrag = editorExtensions_1.registerEditorCommand(new LastCursorLineCommand({
  79746. inSelectionMode: true,
  79747. id: 'lastCursorLineSelectDrag',
  79748. precondition: undefined
  79749. }));
  79750. CoreNavigationCommands.ExpandLineSelection = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79751. __extends(class_13, _super);
  79752. function class_13() {
  79753. return _super.call(this, {
  79754. id: 'expandLineSelection',
  79755. precondition: undefined,
  79756. kbOpts: {
  79757. weight: CORE_WEIGHT,
  79758. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79759. primary: 2048 /* CtrlCmd */ | 42 /* KEY_L */
  79760. }
  79761. }) || this;
  79762. }
  79763. class_13.prototype.runCoreEditorCommand = function (cursors, args) {
  79764. cursors.context.model.pushStackElement();
  79765. cursors.setStates(args.source, 3 /* Explicit */, cursorMoveCommands_1.CursorMoveCommands.expandLineSelection(cursors.context, cursors.getAll()));
  79766. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  79767. };
  79768. return class_13;
  79769. }(CoreEditorCommand)));
  79770. CoreNavigationCommands.CancelSelection = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79771. __extends(class_14, _super);
  79772. function class_14() {
  79773. return _super.call(this, {
  79774. id: 'cancelSelection',
  79775. precondition: editorContextKeys_1.EditorContextKeys.hasNonEmptySelection,
  79776. kbOpts: {
  79777. weight: CORE_WEIGHT,
  79778. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79779. primary: 9 /* Escape */,
  79780. secondary: [1024 /* Shift */ | 9 /* Escape */]
  79781. }
  79782. }) || this;
  79783. }
  79784. class_14.prototype.runCoreEditorCommand = function (cursors, args) {
  79785. cursors.context.model.pushStackElement();
  79786. cursors.setStates(args.source, 3 /* Explicit */, [
  79787. cursorMoveCommands_1.CursorMoveCommands.cancelSelection(cursors.context, cursors.getPrimaryCursor())
  79788. ]);
  79789. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  79790. };
  79791. return class_14;
  79792. }(CoreEditorCommand)));
  79793. CoreNavigationCommands.RemoveSecondaryCursors = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79794. __extends(class_15, _super);
  79795. function class_15() {
  79796. return _super.call(this, {
  79797. id: 'removeSecondaryCursors',
  79798. precondition: editorContextKeys_1.EditorContextKeys.hasMultipleSelections,
  79799. kbOpts: {
  79800. weight: CORE_WEIGHT + 1,
  79801. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79802. primary: 9 /* Escape */,
  79803. secondary: [1024 /* Shift */ | 9 /* Escape */]
  79804. }
  79805. }) || this;
  79806. }
  79807. class_15.prototype.runCoreEditorCommand = function (cursors, args) {
  79808. cursors.context.model.pushStackElement();
  79809. cursors.setStates(args.source, 3 /* Explicit */, [
  79810. cursors.getPrimaryCursor()
  79811. ]);
  79812. cursors.reveal(args.source, true, 0 /* Primary */, 0 /* Smooth */);
  79813. };
  79814. return class_15;
  79815. }(CoreEditorCommand)));
  79816. CoreNavigationCommands.RevealLine = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79817. __extends(class_16, _super);
  79818. function class_16() {
  79819. return _super.call(this, {
  79820. id: 'revealLine',
  79821. precondition: undefined,
  79822. description: RevealLine_.description
  79823. }) || this;
  79824. }
  79825. class_16.prototype.runCoreEditorCommand = function (cursors, args) {
  79826. var revealLineArg = args;
  79827. var lineNumber = (revealLineArg.lineNumber || 0) + 1;
  79828. if (lineNumber < 1) {
  79829. lineNumber = 1;
  79830. }
  79831. var lineCount = cursors.context.model.getLineCount();
  79832. if (lineNumber > lineCount) {
  79833. lineNumber = lineCount;
  79834. }
  79835. var range = new range_1.Range(lineNumber, 1, lineNumber, cursors.context.model.getLineMaxColumn(lineNumber));
  79836. var revealAt = 0 /* Simple */;
  79837. if (revealLineArg.at) {
  79838. switch (revealLineArg.at) {
  79839. case RevealLine_.RawAtArgument.Top:
  79840. revealAt = 3 /* Top */;
  79841. break;
  79842. case RevealLine_.RawAtArgument.Center:
  79843. revealAt = 1 /* Center */;
  79844. break;
  79845. case RevealLine_.RawAtArgument.Bottom:
  79846. revealAt = 4 /* Bottom */;
  79847. break;
  79848. default:
  79849. break;
  79850. }
  79851. }
  79852. var viewRange = cursors.context.convertModelRangeToViewRange(range);
  79853. cursors.revealRange(args.source, false, viewRange, revealAt, 0 /* Smooth */);
  79854. };
  79855. return class_16;
  79856. }(CoreEditorCommand)));
  79857. CoreNavigationCommands.SelectAll = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79858. __extends(class_17, _super);
  79859. function class_17() {
  79860. return _super.call(this, {
  79861. id: 'selectAll',
  79862. precondition: undefined
  79863. }) || this;
  79864. }
  79865. class_17.prototype.runCoreEditorCommand = function (cursors, args) {
  79866. cursors.context.model.pushStackElement();
  79867. cursors.setStates(args.source, 3 /* Explicit */, [
  79868. cursorMoveCommands_1.CursorMoveCommands.selectAll(cursors.context, cursors.getPrimaryCursor())
  79869. ]);
  79870. };
  79871. return class_17;
  79872. }(CoreEditorCommand)));
  79873. CoreNavigationCommands.SetSelection = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79874. __extends(class_18, _super);
  79875. function class_18() {
  79876. return _super.call(this, {
  79877. id: 'setSelection',
  79878. precondition: undefined
  79879. }) || this;
  79880. }
  79881. class_18.prototype.runCoreEditorCommand = function (cursors, args) {
  79882. cursors.context.model.pushStackElement();
  79883. cursors.setStates(args.source, 3 /* Explicit */, [
  79884. cursorCommon_1.CursorState.fromModelSelection(args.selection)
  79885. ]);
  79886. };
  79887. return class_18;
  79888. }(CoreEditorCommand)));
  79889. })(CoreNavigationCommands = exports.CoreNavigationCommands || (exports.CoreNavigationCommands = {}));
  79890. var CoreEditingCommands;
  79891. (function (CoreEditingCommands) {
  79892. var CoreEditingCommand = /** @class */ (function (_super) {
  79893. __extends(CoreEditingCommand, _super);
  79894. function CoreEditingCommand() {
  79895. return _super !== null && _super.apply(this, arguments) || this;
  79896. }
  79897. CoreEditingCommand.prototype.runEditorCommand = function (accessor, editor, args) {
  79898. var cursors = editor._getCursors();
  79899. if (!cursors) {
  79900. // the editor has no view => has no cursors
  79901. return;
  79902. }
  79903. this.runCoreEditingCommand(editor, cursors, args || {});
  79904. };
  79905. return CoreEditingCommand;
  79906. }(editorExtensions_1.EditorCommand));
  79907. CoreEditingCommands.CoreEditingCommand = CoreEditingCommand;
  79908. CoreEditingCommands.LineBreakInsert = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79909. __extends(class_19, _super);
  79910. function class_19() {
  79911. return _super.call(this, {
  79912. id: 'lineBreakInsert',
  79913. precondition: editorContextKeys_1.EditorContextKeys.writable,
  79914. kbOpts: {
  79915. weight: CORE_WEIGHT,
  79916. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79917. primary: 0,
  79918. mac: { primary: 256 /* WinCtrl */ | 45 /* KEY_O */ }
  79919. }
  79920. }) || this;
  79921. }
  79922. class_19.prototype.runCoreEditingCommand = function (editor, cursors, args) {
  79923. editor.pushUndoStop();
  79924. editor.executeCommands(this.id, cursorTypeOperations_1.TypeOperations.lineBreakInsert(cursors.context.config, cursors.context.model, cursors.getAll().map(function (s) { return s.modelState.selection; })));
  79925. };
  79926. return class_19;
  79927. }(CoreEditingCommand)));
  79928. CoreEditingCommands.Outdent = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79929. __extends(class_20, _super);
  79930. function class_20() {
  79931. return _super.call(this, {
  79932. id: 'outdent',
  79933. precondition: editorContextKeys_1.EditorContextKeys.writable,
  79934. kbOpts: {
  79935. weight: CORE_WEIGHT,
  79936. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.editorTextFocus, editorContextKeys_1.EditorContextKeys.tabDoesNotMoveFocus),
  79937. primary: 1024 /* Shift */ | 2 /* Tab */
  79938. }
  79939. }) || this;
  79940. }
  79941. class_20.prototype.runCoreEditingCommand = function (editor, cursors, args) {
  79942. editor.pushUndoStop();
  79943. editor.executeCommands(this.id, cursorTypeOperations_1.TypeOperations.outdent(cursors.context.config, cursors.context.model, cursors.getAll().map(function (s) { return s.modelState.selection; })));
  79944. editor.pushUndoStop();
  79945. };
  79946. return class_20;
  79947. }(CoreEditingCommand)));
  79948. CoreEditingCommands.Tab = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79949. __extends(class_21, _super);
  79950. function class_21() {
  79951. return _super.call(this, {
  79952. id: 'tab',
  79953. precondition: editorContextKeys_1.EditorContextKeys.writable,
  79954. kbOpts: {
  79955. weight: CORE_WEIGHT,
  79956. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.editorTextFocus, editorContextKeys_1.EditorContextKeys.tabDoesNotMoveFocus),
  79957. primary: 2 /* Tab */
  79958. }
  79959. }) || this;
  79960. }
  79961. class_21.prototype.runCoreEditingCommand = function (editor, cursors, args) {
  79962. editor.pushUndoStop();
  79963. editor.executeCommands(this.id, cursorTypeOperations_1.TypeOperations.tab(cursors.context.config, cursors.context.model, cursors.getAll().map(function (s) { return s.modelState.selection; })));
  79964. editor.pushUndoStop();
  79965. };
  79966. return class_21;
  79967. }(CoreEditingCommand)));
  79968. CoreEditingCommands.DeleteLeft = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79969. __extends(class_22, _super);
  79970. function class_22() {
  79971. return _super.call(this, {
  79972. id: 'deleteLeft',
  79973. precondition: editorContextKeys_1.EditorContextKeys.writable,
  79974. kbOpts: {
  79975. weight: CORE_WEIGHT,
  79976. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  79977. primary: 1 /* Backspace */,
  79978. secondary: [1024 /* Shift */ | 1 /* Backspace */],
  79979. mac: { primary: 1 /* Backspace */, secondary: [1024 /* Shift */ | 1 /* Backspace */, 256 /* WinCtrl */ | 38 /* KEY_H */, 256 /* WinCtrl */ | 1 /* Backspace */] }
  79980. }
  79981. }) || this;
  79982. }
  79983. class_22.prototype.runCoreEditingCommand = function (editor, cursors, args) {
  79984. var _a = cursorDeleteOperations_1.DeleteOperations.deleteLeft(cursors.getPrevEditOperationType(), cursors.context.config, cursors.context.model, cursors.getAll().map(function (s) { return s.modelState.selection; })), shouldPushStackElementBefore = _a[0], commands = _a[1];
  79985. if (shouldPushStackElementBefore) {
  79986. editor.pushUndoStop();
  79987. }
  79988. editor.executeCommands(this.id, commands);
  79989. cursors.setPrevEditOperationType(2 /* DeletingLeft */);
  79990. };
  79991. return class_22;
  79992. }(CoreEditingCommand)));
  79993. CoreEditingCommands.DeleteRight = editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  79994. __extends(class_23, _super);
  79995. function class_23() {
  79996. return _super.call(this, {
  79997. id: 'deleteRight',
  79998. precondition: editorContextKeys_1.EditorContextKeys.writable,
  79999. kbOpts: {
  80000. weight: CORE_WEIGHT,
  80001. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  80002. primary: 20 /* Delete */,
  80003. mac: { primary: 20 /* Delete */, secondary: [256 /* WinCtrl */ | 34 /* KEY_D */, 256 /* WinCtrl */ | 20 /* Delete */] }
  80004. }
  80005. }) || this;
  80006. }
  80007. class_23.prototype.runCoreEditingCommand = function (editor, cursors, args) {
  80008. var _a = cursorDeleteOperations_1.DeleteOperations.deleteRight(cursors.getPrevEditOperationType(), cursors.context.config, cursors.context.model, cursors.getAll().map(function (s) { return s.modelState.selection; })), shouldPushStackElementBefore = _a[0], commands = _a[1];
  80009. if (shouldPushStackElementBefore) {
  80010. editor.pushUndoStop();
  80011. }
  80012. editor.executeCommands(this.id, commands);
  80013. cursors.setPrevEditOperationType(3 /* DeletingRight */);
  80014. };
  80015. return class_23;
  80016. }(CoreEditingCommand)));
  80017. })(CoreEditingCommands = exports.CoreEditingCommands || (exports.CoreEditingCommands = {}));
  80018. function registerCommand(command) {
  80019. command.register();
  80020. }
  80021. /**
  80022. * A command that will:
  80023. * 1. invoke a command on the focused editor.
  80024. * 2. otherwise, invoke a browser built-in command on the `activeElement`.
  80025. * 3. otherwise, invoke a command on the workbench active editor.
  80026. */
  80027. var EditorOrNativeTextInputCommand = /** @class */ (function (_super) {
  80028. __extends(EditorOrNativeTextInputCommand, _super);
  80029. function EditorOrNativeTextInputCommand(opts) {
  80030. var _this = _super.call(this, opts) || this;
  80031. _this._editorHandler = opts.editorHandler;
  80032. _this._inputHandler = opts.inputHandler;
  80033. return _this;
  80034. }
  80035. EditorOrNativeTextInputCommand.prototype.runCommand = function (accessor, args) {
  80036. var focusedEditor = accessor.get(codeEditorService_1.ICodeEditorService).getFocusedCodeEditor();
  80037. // Only if editor text focus (i.e. not if editor has widget focus).
  80038. if (focusedEditor && focusedEditor.hasTextFocus()) {
  80039. return this._runEditorHandler(accessor, focusedEditor, args);
  80040. }
  80041. // Ignore this action when user is focused on an element that allows for entering text
  80042. var activeElement = document.activeElement;
  80043. if (activeElement && ['input', 'textarea'].indexOf(activeElement.tagName.toLowerCase()) >= 0) {
  80044. document.execCommand(this._inputHandler);
  80045. return;
  80046. }
  80047. // Redirecting to active editor
  80048. var activeEditor = accessor.get(codeEditorService_1.ICodeEditorService).getActiveCodeEditor();
  80049. if (activeEditor) {
  80050. activeEditor.focus();
  80051. return this._runEditorHandler(accessor, activeEditor, args);
  80052. }
  80053. };
  80054. EditorOrNativeTextInputCommand.prototype._runEditorHandler = function (accessor, editor, args) {
  80055. var HANDLER = this._editorHandler;
  80056. if (typeof HANDLER === 'string') {
  80057. editor.trigger('keyboard', HANDLER, args);
  80058. }
  80059. else {
  80060. args = args || {};
  80061. args.source = 'keyboard';
  80062. HANDLER.runEditorCommand(accessor, editor, args);
  80063. }
  80064. };
  80065. return EditorOrNativeTextInputCommand;
  80066. }(editorExtensions_1.Command));
  80067. /**
  80068. * A command that will invoke a command on the focused editor.
  80069. */
  80070. var EditorHandlerCommand = /** @class */ (function (_super) {
  80071. __extends(EditorHandlerCommand, _super);
  80072. function EditorHandlerCommand(id, handlerId, description) {
  80073. var _this = _super.call(this, {
  80074. id: id,
  80075. precondition: undefined,
  80076. description: description
  80077. }) || this;
  80078. _this._handlerId = handlerId;
  80079. return _this;
  80080. }
  80081. EditorHandlerCommand.prototype.runCommand = function (accessor, args) {
  80082. var editor = accessor.get(codeEditorService_1.ICodeEditorService).getFocusedCodeEditor();
  80083. if (!editor) {
  80084. return;
  80085. }
  80086. editor.trigger('keyboard', this._handlerId, args);
  80087. };
  80088. return EditorHandlerCommand;
  80089. }(editorExtensions_1.Command));
  80090. registerCommand(new EditorOrNativeTextInputCommand({
  80091. editorHandler: CoreNavigationCommands.SelectAll,
  80092. inputHandler: 'selectAll',
  80093. id: 'editor.action.selectAll',
  80094. precondition: editorContextKeys_1.EditorContextKeys.textInputFocus,
  80095. kbOpts: {
  80096. weight: CORE_WEIGHT,
  80097. kbExpr: null,
  80098. primary: 2048 /* CtrlCmd */ | 31 /* KEY_A */
  80099. },
  80100. menuOpts: {
  80101. menuId: 25 /* MenubarSelectionMenu */,
  80102. group: '1_basic',
  80103. title: nls.localize(0, null),
  80104. order: 1
  80105. }
  80106. }));
  80107. registerCommand(new EditorOrNativeTextInputCommand({
  80108. editorHandler: editorCommon_1.Handler.Undo,
  80109. inputHandler: 'undo',
  80110. id: editorCommon_1.Handler.Undo,
  80111. precondition: editorContextKeys_1.EditorContextKeys.writable,
  80112. kbOpts: {
  80113. weight: CORE_WEIGHT,
  80114. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  80115. primary: 2048 /* CtrlCmd */ | 56 /* KEY_Z */
  80116. },
  80117. menuOpts: {
  80118. menuId: 17 /* MenubarEditMenu */,
  80119. group: '1_do',
  80120. title: nls.localize(1, null),
  80121. order: 1
  80122. }
  80123. }));
  80124. registerCommand(new EditorHandlerCommand('default:' + editorCommon_1.Handler.Undo, editorCommon_1.Handler.Undo));
  80125. registerCommand(new EditorOrNativeTextInputCommand({
  80126. editorHandler: editorCommon_1.Handler.Redo,
  80127. inputHandler: 'redo',
  80128. id: editorCommon_1.Handler.Redo,
  80129. precondition: editorContextKeys_1.EditorContextKeys.writable,
  80130. kbOpts: {
  80131. weight: CORE_WEIGHT,
  80132. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  80133. primary: 2048 /* CtrlCmd */ | 55 /* KEY_Y */,
  80134. secondary: [2048 /* CtrlCmd */ | 1024 /* Shift */ | 56 /* KEY_Z */],
  80135. mac: { primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 56 /* KEY_Z */ }
  80136. },
  80137. menuOpts: {
  80138. menuId: 17 /* MenubarEditMenu */,
  80139. group: '1_do',
  80140. title: nls.localize(2, null),
  80141. order: 2
  80142. }
  80143. }));
  80144. registerCommand(new EditorHandlerCommand('default:' + editorCommon_1.Handler.Redo, editorCommon_1.Handler.Redo));
  80145. function registerOverwritableCommand(handlerId, description) {
  80146. registerCommand(new EditorHandlerCommand('default:' + handlerId, handlerId));
  80147. registerCommand(new EditorHandlerCommand(handlerId, handlerId, description));
  80148. }
  80149. registerOverwritableCommand(editorCommon_1.Handler.Type, {
  80150. description: "Type",
  80151. args: [{
  80152. name: 'args',
  80153. schema: {
  80154. 'type': 'object',
  80155. 'required': ['text'],
  80156. 'properties': {
  80157. 'text': {
  80158. 'type': 'string'
  80159. }
  80160. },
  80161. }
  80162. }]
  80163. });
  80164. registerOverwritableCommand(editorCommon_1.Handler.ReplacePreviousChar);
  80165. registerOverwritableCommand(editorCommon_1.Handler.CompositionStart);
  80166. registerOverwritableCommand(editorCommon_1.Handler.CompositionEnd);
  80167. registerOverwritableCommand(editorCommon_1.Handler.Paste);
  80168. registerOverwritableCommand(editorCommon_1.Handler.Cut);
  80169. });
  80170. /*---------------------------------------------------------------------------------------------
  80171. * Copyright (c) Microsoft Corporation. All rights reserved.
  80172. * Licensed under the MIT License. See License.txt in the project root for license information.
  80173. *--------------------------------------------------------------------------------------------*/
  80174. define(__m[522/*vs/editor/browser/core/keybindingCancellation*/], __M([0/*require*/,1/*exports*/,12/*vs/editor/browser/editorExtensions*/,18/*vs/platform/contextkey/common/contextkey*/,26/*vs/base/common/cancellation*/,76/*vs/base/common/linkedList*/,11/*vs/platform/instantiation/common/instantiation*/,83/*vs/platform/instantiation/common/extensions*/]), function (require, exports, editorExtensions_1, contextkey_1, cancellation_1, linkedList_1, instantiation_1, extensions_1) {
  80175. "use strict";
  80176. Object.defineProperty(exports, "__esModule", { value: true });
  80177. var IEditorCancellationTokens = instantiation_1.createDecorator('IEditorCancelService');
  80178. var ctxCancellableOperation = new contextkey_1.RawContextKey('cancellableOperation', false);
  80179. extensions_1.registerSingleton(IEditorCancellationTokens, /** @class */ (function () {
  80180. function class_1() {
  80181. this._tokens = new WeakMap();
  80182. }
  80183. class_1.prototype.add = function (editor, cts) {
  80184. var data = this._tokens.get(editor);
  80185. if (!data) {
  80186. data = editor.invokeWithinContext(function (accessor) {
  80187. var key = ctxCancellableOperation.bindTo(accessor.get(contextkey_1.IContextKeyService));
  80188. var tokens = new linkedList_1.LinkedList();
  80189. return { key: key, tokens: tokens };
  80190. });
  80191. this._tokens.set(editor, data);
  80192. }
  80193. var removeFn;
  80194. data.key.set(true);
  80195. removeFn = data.tokens.push(cts);
  80196. return function () {
  80197. // remove w/o cancellation
  80198. if (removeFn) {
  80199. removeFn();
  80200. data.key.set(!data.tokens.isEmpty());
  80201. removeFn = undefined;
  80202. }
  80203. };
  80204. };
  80205. class_1.prototype.cancel = function (editor) {
  80206. var data = this._tokens.get(editor);
  80207. if (!data) {
  80208. return;
  80209. }
  80210. // remove with cancellation
  80211. var cts = data.tokens.pop();
  80212. if (cts) {
  80213. cts.cancel();
  80214. data.key.set(!data.tokens.isEmpty());
  80215. }
  80216. };
  80217. return class_1;
  80218. }()), true);
  80219. var EditorKeybindingCancellationTokenSource = /** @class */ (function (_super) {
  80220. __extends(EditorKeybindingCancellationTokenSource, _super);
  80221. function EditorKeybindingCancellationTokenSource(editor, parent) {
  80222. var _this = _super.call(this, parent) || this;
  80223. _this.editor = editor;
  80224. _this._unregister = editor.invokeWithinContext(function (accessor) { return accessor.get(IEditorCancellationTokens).add(editor, _this); });
  80225. return _this;
  80226. }
  80227. EditorKeybindingCancellationTokenSource.prototype.dispose = function () {
  80228. this._unregister();
  80229. _super.prototype.dispose.call(this);
  80230. };
  80231. return EditorKeybindingCancellationTokenSource;
  80232. }(cancellation_1.CancellationTokenSource));
  80233. exports.EditorKeybindingCancellationTokenSource = EditorKeybindingCancellationTokenSource;
  80234. editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  80235. __extends(class_2, _super);
  80236. function class_2() {
  80237. return _super.call(this, {
  80238. id: 'editor.cancelOperation',
  80239. kbOpts: {
  80240. weight: 100 /* EditorContrib */,
  80241. primary: 9 /* Escape */
  80242. },
  80243. precondition: ctxCancellableOperation
  80244. }) || this;
  80245. }
  80246. class_2.prototype.runEditorCommand = function (accessor, editor) {
  80247. accessor.get(IEditorCancellationTokens).cancel(editor);
  80248. };
  80249. return class_2;
  80250. }(editorExtensions_1.EditorCommand)));
  80251. });
  80252. /*---------------------------------------------------------------------------------------------
  80253. * Copyright (c) Microsoft Corporation. All rights reserved.
  80254. * Licensed under the MIT License. See License.txt in the project root for license information.
  80255. *--------------------------------------------------------------------------------------------*/
  80256. define(__m[67/*vs/editor/browser/core/editorState*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,26/*vs/base/common/cancellation*/,2/*vs/base/common/lifecycle*/,522/*vs/editor/browser/core/keybindingCancellation*/]), function (require, exports, strings, cancellation_1, lifecycle_1, keybindingCancellation_1) {
  80257. "use strict";
  80258. Object.defineProperty(exports, "__esModule", { value: true });
  80259. var EditorState = /** @class */ (function () {
  80260. function EditorState(editor, flags) {
  80261. this.flags = flags;
  80262. if ((this.flags & 1 /* Value */) !== 0) {
  80263. var model = editor.getModel();
  80264. this.modelVersionId = model ? strings.format('{0}#{1}', model.uri.toString(), model.getVersionId()) : null;
  80265. }
  80266. else {
  80267. this.modelVersionId = null;
  80268. }
  80269. if ((this.flags & 4 /* Position */) !== 0) {
  80270. this.position = editor.getPosition();
  80271. }
  80272. else {
  80273. this.position = null;
  80274. }
  80275. if ((this.flags & 2 /* Selection */) !== 0) {
  80276. this.selection = editor.getSelection();
  80277. }
  80278. else {
  80279. this.selection = null;
  80280. }
  80281. if ((this.flags & 8 /* Scroll */) !== 0) {
  80282. this.scrollLeft = editor.getScrollLeft();
  80283. this.scrollTop = editor.getScrollTop();
  80284. }
  80285. else {
  80286. this.scrollLeft = -1;
  80287. this.scrollTop = -1;
  80288. }
  80289. }
  80290. EditorState.prototype._equals = function (other) {
  80291. if (!(other instanceof EditorState)) {
  80292. return false;
  80293. }
  80294. var state = other;
  80295. if (this.modelVersionId !== state.modelVersionId) {
  80296. return false;
  80297. }
  80298. if (this.scrollLeft !== state.scrollLeft || this.scrollTop !== state.scrollTop) {
  80299. return false;
  80300. }
  80301. if (!this.position && state.position || this.position && !state.position || this.position && state.position && !this.position.equals(state.position)) {
  80302. return false;
  80303. }
  80304. if (!this.selection && state.selection || this.selection && !state.selection || this.selection && state.selection && !this.selection.equalsRange(state.selection)) {
  80305. return false;
  80306. }
  80307. return true;
  80308. };
  80309. EditorState.prototype.validate = function (editor) {
  80310. return this._equals(new EditorState(editor, this.flags));
  80311. };
  80312. return EditorState;
  80313. }());
  80314. exports.EditorState = EditorState;
  80315. /**
  80316. * A cancellation token source that cancels when the editor changes as expressed
  80317. * by the provided flags
  80318. */
  80319. var EditorStateCancellationTokenSource = /** @class */ (function (_super) {
  80320. __extends(EditorStateCancellationTokenSource, _super);
  80321. function EditorStateCancellationTokenSource(editor, flags, parent) {
  80322. var _this = _super.call(this, editor, parent) || this;
  80323. _this.editor = editor;
  80324. _this._listener = new lifecycle_1.DisposableStore();
  80325. if (flags & 4 /* Position */) {
  80326. _this._listener.add(editor.onDidChangeCursorPosition(function (_) { return _this.cancel(); }));
  80327. }
  80328. if (flags & 2 /* Selection */) {
  80329. _this._listener.add(editor.onDidChangeCursorSelection(function (_) { return _this.cancel(); }));
  80330. }
  80331. if (flags & 8 /* Scroll */) {
  80332. _this._listener.add(editor.onDidScrollChange(function (_) { return _this.cancel(); }));
  80333. }
  80334. if (flags & 1 /* Value */) {
  80335. _this._listener.add(editor.onDidChangeModel(function (_) { return _this.cancel(); }));
  80336. _this._listener.add(editor.onDidChangeModelContent(function (_) { return _this.cancel(); }));
  80337. }
  80338. return _this;
  80339. }
  80340. EditorStateCancellationTokenSource.prototype.dispose = function () {
  80341. this._listener.dispose();
  80342. _super.prototype.dispose.call(this);
  80343. };
  80344. return EditorStateCancellationTokenSource;
  80345. }(keybindingCancellation_1.EditorKeybindingCancellationTokenSource));
  80346. exports.EditorStateCancellationTokenSource = EditorStateCancellationTokenSource;
  80347. /**
  80348. * A cancellation token source that cancels when the provided model changes
  80349. */
  80350. var TextModelCancellationTokenSource = /** @class */ (function (_super) {
  80351. __extends(TextModelCancellationTokenSource, _super);
  80352. function TextModelCancellationTokenSource(model, parent) {
  80353. var _this = _super.call(this, parent) || this;
  80354. _this._listener = model.onDidChangeContent(function () { return _this.cancel(); });
  80355. return _this;
  80356. }
  80357. TextModelCancellationTokenSource.prototype.dispose = function () {
  80358. this._listener.dispose();
  80359. _super.prototype.dispose.call(this);
  80360. };
  80361. return TextModelCancellationTokenSource;
  80362. }(cancellation_1.CancellationTokenSource));
  80363. exports.TextModelCancellationTokenSource = TextModelCancellationTokenSource;
  80364. var StableEditorScrollState = /** @class */ (function () {
  80365. function StableEditorScrollState(_visiblePosition, _visiblePositionScrollDelta) {
  80366. this._visiblePosition = _visiblePosition;
  80367. this._visiblePositionScrollDelta = _visiblePositionScrollDelta;
  80368. }
  80369. StableEditorScrollState.capture = function (editor) {
  80370. var visiblePosition = null;
  80371. var visiblePositionScrollDelta = 0;
  80372. if (editor.getScrollTop() !== 0) {
  80373. var visibleRanges = editor.getVisibleRanges();
  80374. if (visibleRanges.length > 0) {
  80375. visiblePosition = visibleRanges[0].getStartPosition();
  80376. var visiblePositionScrollTop = editor.getTopForPosition(visiblePosition.lineNumber, visiblePosition.column);
  80377. visiblePositionScrollDelta = editor.getScrollTop() - visiblePositionScrollTop;
  80378. }
  80379. }
  80380. return new StableEditorScrollState(visiblePosition, visiblePositionScrollDelta);
  80381. };
  80382. StableEditorScrollState.prototype.restore = function (editor) {
  80383. if (this._visiblePosition) {
  80384. var visiblePositionScrollTop = editor.getTopForPosition(this._visiblePosition.lineNumber, this._visiblePosition.column);
  80385. editor.setScrollTop(visiblePositionScrollTop + this._visiblePositionScrollDelta);
  80386. }
  80387. };
  80388. return StableEditorScrollState;
  80389. }());
  80390. exports.StableEditorScrollState = StableEditorScrollState;
  80391. });
  80392. /*---------------------------------------------------------------------------------------------
  80393. * Copyright (c) Microsoft Corporation. All rights reserved.
  80394. * Licensed under the MIT License. See License.txt in the project root for license information.
  80395. *--------------------------------------------------------------------------------------------*/
  80396. define(__m[523/*vs/editor/browser/view/viewController*/], __M([0/*require*/,1/*exports*/,164/*vs/editor/browser/controller/coreCommands*/,13/*vs/editor/common/core/position*/,16/*vs/base/common/platform*/]), function (require, exports, coreCommands_1, position_1, platform) {
  80397. "use strict";
  80398. Object.defineProperty(exports, "__esModule", { value: true });
  80399. var ViewController = /** @class */ (function () {
  80400. function ViewController(configuration, viewModel, outgoingEvents, commandDelegate) {
  80401. this.configuration = configuration;
  80402. this.viewModel = viewModel;
  80403. this.outgoingEvents = outgoingEvents;
  80404. this.commandDelegate = commandDelegate;
  80405. }
  80406. ViewController.prototype._execMouseCommand = function (editorCommand, args) {
  80407. args.source = 'mouse';
  80408. this.commandDelegate.executeEditorCommand(editorCommand, args);
  80409. };
  80410. ViewController.prototype.paste = function (source, text, pasteOnNewLine, multicursorText, mode) {
  80411. this.commandDelegate.paste(source, text, pasteOnNewLine, multicursorText, mode);
  80412. };
  80413. ViewController.prototype.type = function (source, text) {
  80414. this.commandDelegate.type(source, text);
  80415. };
  80416. ViewController.prototype.replacePreviousChar = function (source, text, replaceCharCnt) {
  80417. this.commandDelegate.replacePreviousChar(source, text, replaceCharCnt);
  80418. };
  80419. ViewController.prototype.compositionStart = function (source) {
  80420. this.commandDelegate.compositionStart(source);
  80421. };
  80422. ViewController.prototype.compositionEnd = function (source) {
  80423. this.commandDelegate.compositionEnd(source);
  80424. };
  80425. ViewController.prototype.cut = function (source) {
  80426. this.commandDelegate.cut(source);
  80427. };
  80428. ViewController.prototype.setSelection = function (source, modelSelection) {
  80429. this.commandDelegate.executeEditorCommand(coreCommands_1.CoreNavigationCommands.SetSelection, {
  80430. source: source,
  80431. selection: modelSelection
  80432. });
  80433. };
  80434. ViewController.prototype._validateViewColumn = function (viewPosition) {
  80435. var minColumn = this.viewModel.getLineMinColumn(viewPosition.lineNumber);
  80436. if (viewPosition.column < minColumn) {
  80437. return new position_1.Position(viewPosition.lineNumber, minColumn);
  80438. }
  80439. return viewPosition;
  80440. };
  80441. ViewController.prototype._hasMulticursorModifier = function (data) {
  80442. switch (this.configuration.options.get(59 /* multiCursorModifier */)) {
  80443. case 'altKey':
  80444. return data.altKey;
  80445. case 'ctrlKey':
  80446. return data.ctrlKey;
  80447. case 'metaKey':
  80448. return data.metaKey;
  80449. }
  80450. return false;
  80451. };
  80452. ViewController.prototype._hasNonMulticursorModifier = function (data) {
  80453. switch (this.configuration.options.get(59 /* multiCursorModifier */)) {
  80454. case 'altKey':
  80455. return data.ctrlKey || data.metaKey;
  80456. case 'ctrlKey':
  80457. return data.altKey || data.metaKey;
  80458. case 'metaKey':
  80459. return data.ctrlKey || data.altKey;
  80460. }
  80461. return false;
  80462. };
  80463. ViewController.prototype.dispatchMouse = function (data) {
  80464. var selectionClipboardIsOn = (platform.isLinux && this.configuration.options.get(81 /* selectionClipboard */));
  80465. if (data.middleButton && !selectionClipboardIsOn) {
  80466. this._columnSelect(data.position, data.mouseColumn, data.inSelectionMode);
  80467. }
  80468. else if (data.startedOnLineNumbers) {
  80469. // If the dragging started on the gutter, then have operations work on the entire line
  80470. if (this._hasMulticursorModifier(data)) {
  80471. if (data.inSelectionMode) {
  80472. this._lastCursorLineSelect(data.position);
  80473. }
  80474. else {
  80475. this._createCursor(data.position, true);
  80476. }
  80477. }
  80478. else {
  80479. if (data.inSelectionMode) {
  80480. this._lineSelectDrag(data.position);
  80481. }
  80482. else {
  80483. this._lineSelect(data.position);
  80484. }
  80485. }
  80486. }
  80487. else if (data.mouseDownCount >= 4) {
  80488. this._selectAll();
  80489. }
  80490. else if (data.mouseDownCount === 3) {
  80491. if (this._hasMulticursorModifier(data)) {
  80492. if (data.inSelectionMode) {
  80493. this._lastCursorLineSelectDrag(data.position);
  80494. }
  80495. else {
  80496. this._lastCursorLineSelect(data.position);
  80497. }
  80498. }
  80499. else {
  80500. if (data.inSelectionMode) {
  80501. this._lineSelectDrag(data.position);
  80502. }
  80503. else {
  80504. this._lineSelect(data.position);
  80505. }
  80506. }
  80507. }
  80508. else if (data.mouseDownCount === 2) {
  80509. if (this._hasMulticursorModifier(data)) {
  80510. this._lastCursorWordSelect(data.position);
  80511. }
  80512. else {
  80513. if (data.inSelectionMode) {
  80514. this._wordSelectDrag(data.position);
  80515. }
  80516. else {
  80517. this._wordSelect(data.position);
  80518. }
  80519. }
  80520. }
  80521. else {
  80522. if (this._hasMulticursorModifier(data)) {
  80523. if (!this._hasNonMulticursorModifier(data)) {
  80524. if (data.shiftKey) {
  80525. this._columnSelect(data.position, data.mouseColumn, true);
  80526. }
  80527. else {
  80528. // Do multi-cursor operations only when purely alt is pressed
  80529. if (data.inSelectionMode) {
  80530. this._lastCursorMoveToSelect(data.position);
  80531. }
  80532. else {
  80533. this._createCursor(data.position, false);
  80534. }
  80535. }
  80536. }
  80537. }
  80538. else {
  80539. if (data.inSelectionMode) {
  80540. if (data.altKey) {
  80541. this._columnSelect(data.position, data.mouseColumn, true);
  80542. }
  80543. else {
  80544. this._moveToSelect(data.position);
  80545. }
  80546. }
  80547. else {
  80548. this.moveTo(data.position);
  80549. }
  80550. }
  80551. }
  80552. };
  80553. ViewController.prototype._usualArgs = function (viewPosition) {
  80554. viewPosition = this._validateViewColumn(viewPosition);
  80555. return {
  80556. position: this._convertViewToModelPosition(viewPosition),
  80557. viewPosition: viewPosition
  80558. };
  80559. };
  80560. ViewController.prototype.moveTo = function (viewPosition) {
  80561. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.MoveTo, this._usualArgs(viewPosition));
  80562. };
  80563. ViewController.prototype._moveToSelect = function (viewPosition) {
  80564. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.MoveToSelect, this._usualArgs(viewPosition));
  80565. };
  80566. ViewController.prototype._columnSelect = function (viewPosition, mouseColumn, doColumnSelect) {
  80567. viewPosition = this._validateViewColumn(viewPosition);
  80568. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.ColumnSelect, {
  80569. position: this._convertViewToModelPosition(viewPosition),
  80570. viewPosition: viewPosition,
  80571. mouseColumn: mouseColumn,
  80572. doColumnSelect: doColumnSelect
  80573. });
  80574. };
  80575. ViewController.prototype._createCursor = function (viewPosition, wholeLine) {
  80576. viewPosition = this._validateViewColumn(viewPosition);
  80577. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.CreateCursor, {
  80578. position: this._convertViewToModelPosition(viewPosition),
  80579. viewPosition: viewPosition,
  80580. wholeLine: wholeLine
  80581. });
  80582. };
  80583. ViewController.prototype._lastCursorMoveToSelect = function (viewPosition) {
  80584. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.LastCursorMoveToSelect, this._usualArgs(viewPosition));
  80585. };
  80586. ViewController.prototype._wordSelect = function (viewPosition) {
  80587. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.WordSelect, this._usualArgs(viewPosition));
  80588. };
  80589. ViewController.prototype._wordSelectDrag = function (viewPosition) {
  80590. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.WordSelectDrag, this._usualArgs(viewPosition));
  80591. };
  80592. ViewController.prototype._lastCursorWordSelect = function (viewPosition) {
  80593. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.LastCursorWordSelect, this._usualArgs(viewPosition));
  80594. };
  80595. ViewController.prototype._lineSelect = function (viewPosition) {
  80596. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.LineSelect, this._usualArgs(viewPosition));
  80597. };
  80598. ViewController.prototype._lineSelectDrag = function (viewPosition) {
  80599. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.LineSelectDrag, this._usualArgs(viewPosition));
  80600. };
  80601. ViewController.prototype._lastCursorLineSelect = function (viewPosition) {
  80602. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.LastCursorLineSelect, this._usualArgs(viewPosition));
  80603. };
  80604. ViewController.prototype._lastCursorLineSelectDrag = function (viewPosition) {
  80605. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.LastCursorLineSelectDrag, this._usualArgs(viewPosition));
  80606. };
  80607. ViewController.prototype._selectAll = function () {
  80608. this._execMouseCommand(coreCommands_1.CoreNavigationCommands.SelectAll, {});
  80609. };
  80610. // ----------------------
  80611. ViewController.prototype._convertViewToModelPosition = function (viewPosition) {
  80612. return this.viewModel.coordinatesConverter.convertViewPositionToModelPosition(viewPosition);
  80613. };
  80614. ViewController.prototype.emitKeyDown = function (e) {
  80615. this.outgoingEvents.emitKeyDown(e);
  80616. };
  80617. ViewController.prototype.emitKeyUp = function (e) {
  80618. this.outgoingEvents.emitKeyUp(e);
  80619. };
  80620. ViewController.prototype.emitContextMenu = function (e) {
  80621. this.outgoingEvents.emitContextMenu(e);
  80622. };
  80623. ViewController.prototype.emitMouseMove = function (e) {
  80624. this.outgoingEvents.emitMouseMove(e);
  80625. };
  80626. ViewController.prototype.emitMouseLeave = function (e) {
  80627. this.outgoingEvents.emitMouseLeave(e);
  80628. };
  80629. ViewController.prototype.emitMouseUp = function (e) {
  80630. this.outgoingEvents.emitMouseUp(e);
  80631. };
  80632. ViewController.prototype.emitMouseDown = function (e) {
  80633. this.outgoingEvents.emitMouseDown(e);
  80634. };
  80635. ViewController.prototype.emitMouseDrag = function (e) {
  80636. this.outgoingEvents.emitMouseDrag(e);
  80637. };
  80638. ViewController.prototype.emitMouseDrop = function (e) {
  80639. this.outgoingEvents.emitMouseDrop(e);
  80640. };
  80641. ViewController.prototype.emitMouseWheel = function (e) {
  80642. this.outgoingEvents.emitMouseWheel(e);
  80643. };
  80644. return ViewController;
  80645. }());
  80646. exports.ViewController = ViewController;
  80647. });
  80648. /*---------------------------------------------------------------------------------------------
  80649. * Copyright (c) Microsoft Corporation. All rights reserved.
  80650. * Licensed under the MIT License. See License.txt in the project root for license information.
  80651. *--------------------------------------------------------------------------------------------*/
  80652. define(__m[524/*vs/editor/contrib/caretOperations/caretOperations*/], __M([0/*require*/,1/*exports*/,429/*vs/nls!vs/editor/contrib/caretOperations/caretOperations*/,12/*vs/editor/browser/editorExtensions*/,23/*vs/editor/common/editorContextKeys*/,374/*vs/editor/contrib/caretOperations/moveCaretCommand*/]), function (require, exports, nls, editorExtensions_1, editorContextKeys_1, moveCaretCommand_1) {
  80653. "use strict";
  80654. Object.defineProperty(exports, "__esModule", { value: true });
  80655. var MoveCaretAction = /** @class */ (function (_super) {
  80656. __extends(MoveCaretAction, _super);
  80657. function MoveCaretAction(left, opts) {
  80658. var _this = _super.call(this, opts) || this;
  80659. _this.left = left;
  80660. return _this;
  80661. }
  80662. MoveCaretAction.prototype.run = function (accessor, editor) {
  80663. if (!editor.hasModel()) {
  80664. return;
  80665. }
  80666. var commands = [];
  80667. var selections = editor.getSelections();
  80668. for (var _i = 0, selections_1 = selections; _i < selections_1.length; _i++) {
  80669. var selection = selections_1[_i];
  80670. commands.push(new moveCaretCommand_1.MoveCaretCommand(selection, this.left));
  80671. }
  80672. editor.pushUndoStop();
  80673. editor.executeCommands(this.id, commands);
  80674. editor.pushUndoStop();
  80675. };
  80676. return MoveCaretAction;
  80677. }(editorExtensions_1.EditorAction));
  80678. var MoveCaretLeftAction = /** @class */ (function (_super) {
  80679. __extends(MoveCaretLeftAction, _super);
  80680. function MoveCaretLeftAction() {
  80681. return _super.call(this, true, {
  80682. id: 'editor.action.moveCarretLeftAction',
  80683. label: nls.localize(0, null),
  80684. alias: 'Move Caret Left',
  80685. precondition: editorContextKeys_1.EditorContextKeys.writable
  80686. }) || this;
  80687. }
  80688. return MoveCaretLeftAction;
  80689. }(MoveCaretAction));
  80690. var MoveCaretRightAction = /** @class */ (function (_super) {
  80691. __extends(MoveCaretRightAction, _super);
  80692. function MoveCaretRightAction() {
  80693. return _super.call(this, false, {
  80694. id: 'editor.action.moveCarretRightAction',
  80695. label: nls.localize(1, null),
  80696. alias: 'Move Caret Right',
  80697. precondition: editorContextKeys_1.EditorContextKeys.writable
  80698. }) || this;
  80699. }
  80700. return MoveCaretRightAction;
  80701. }(MoveCaretAction));
  80702. editorExtensions_1.registerEditorAction(MoveCaretLeftAction);
  80703. editorExtensions_1.registerEditorAction(MoveCaretRightAction);
  80704. });
  80705. /*---------------------------------------------------------------------------------------------
  80706. * Copyright (c) Microsoft Corporation. All rights reserved.
  80707. * Licensed under the MIT License. See License.txt in the project root for license information.
  80708. *--------------------------------------------------------------------------------------------*/
  80709. define(__m[525/*vs/editor/contrib/caretOperations/transpose*/], __M([0/*require*/,1/*exports*/,430/*vs/nls!vs/editor/contrib/caretOperations/transpose*/,12/*vs/editor/browser/editorExtensions*/,80/*vs/editor/common/commands/replaceCommand*/,3/*vs/editor/common/core/range*/,23/*vs/editor/common/editorContextKeys*/,158/*vs/editor/common/controller/cursorMoveOperations*/]), function (require, exports, nls, editorExtensions_1, replaceCommand_1, range_1, editorContextKeys_1, cursorMoveOperations_1) {
  80710. "use strict";
  80711. Object.defineProperty(exports, "__esModule", { value: true });
  80712. var TransposeLettersAction = /** @class */ (function (_super) {
  80713. __extends(TransposeLettersAction, _super);
  80714. function TransposeLettersAction() {
  80715. return _super.call(this, {
  80716. id: 'editor.action.transposeLetters',
  80717. label: nls.localize(0, null),
  80718. alias: 'Transpose Letters',
  80719. precondition: editorContextKeys_1.EditorContextKeys.writable,
  80720. kbOpts: {
  80721. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  80722. primary: 0,
  80723. mac: {
  80724. primary: 256 /* WinCtrl */ | 50 /* KEY_T */
  80725. },
  80726. weight: 100 /* EditorContrib */
  80727. }
  80728. }) || this;
  80729. }
  80730. TransposeLettersAction.prototype.run = function (accessor, editor) {
  80731. if (!editor.hasModel()) {
  80732. return;
  80733. }
  80734. var model = editor.getModel();
  80735. var commands = [];
  80736. var selections = editor.getSelections();
  80737. for (var _i = 0, selections_1 = selections; _i < selections_1.length; _i++) {
  80738. var selection = selections_1[_i];
  80739. if (!selection.isEmpty()) {
  80740. continue;
  80741. }
  80742. var lineNumber = selection.startLineNumber;
  80743. var column = selection.startColumn;
  80744. var lastColumn = model.getLineMaxColumn(lineNumber);
  80745. if (lineNumber === 1 && (column === 1 || (column === 2 && lastColumn === 2))) {
  80746. // at beginning of file, nothing to do
  80747. continue;
  80748. }
  80749. // handle special case: when at end of line, transpose left two chars
  80750. // otherwise, transpose left and right chars
  80751. var endPosition = (column === lastColumn) ?
  80752. selection.getPosition() :
  80753. cursorMoveOperations_1.MoveOperations.rightPosition(model, selection.getPosition().lineNumber, selection.getPosition().column);
  80754. var middlePosition = cursorMoveOperations_1.MoveOperations.leftPosition(model, endPosition.lineNumber, endPosition.column);
  80755. var beginPosition = cursorMoveOperations_1.MoveOperations.leftPosition(model, middlePosition.lineNumber, middlePosition.column);
  80756. var leftChar = model.getValueInRange(range_1.Range.fromPositions(beginPosition, middlePosition));
  80757. var rightChar = model.getValueInRange(range_1.Range.fromPositions(middlePosition, endPosition));
  80758. var replaceRange = range_1.Range.fromPositions(beginPosition, endPosition);
  80759. commands.push(new replaceCommand_1.ReplaceCommand(replaceRange, rightChar + leftChar));
  80760. }
  80761. if (commands.length > 0) {
  80762. editor.pushUndoStop();
  80763. editor.executeCommands(this.id, commands);
  80764. editor.pushUndoStop();
  80765. }
  80766. };
  80767. return TransposeLettersAction;
  80768. }(editorExtensions_1.EditorAction));
  80769. editorExtensions_1.registerEditorAction(TransposeLettersAction);
  80770. });
  80771. /*---------------------------------------------------------------------------------------------
  80772. * Copyright (c) Microsoft Corporation. All rights reserved.
  80773. * Licensed under the MIT License. See License.txt in the project root for license information.
  80774. *--------------------------------------------------------------------------------------------*/
  80775. define(__m[526/*vs/editor/contrib/clipboard/clipboard*/], __M([0/*require*/,1/*exports*/,431/*vs/nls!vs/editor/contrib/clipboard/clipboard*/,24/*vs/base/browser/browser*/,16/*vs/base/common/platform*/,189/*vs/editor/browser/controller/textAreaInput*/,12/*vs/editor/browser/editorExtensions*/,32/*vs/editor/browser/services/codeEditorService*/,23/*vs/editor/common/editorContextKeys*/,303/*vs/css!vs/editor/contrib/clipboard/clipboard*/]), function (require, exports, nls, browser, platform, textAreaInput_1, editorExtensions_1, codeEditorService_1, editorContextKeys_1) {
  80776. "use strict";
  80777. Object.defineProperty(exports, "__esModule", { value: true });
  80778. var CLIPBOARD_CONTEXT_MENU_GROUP = '9_cutcopypaste';
  80779. var supportsCut = (platform.isNative || document.queryCommandSupported('cut'));
  80780. var supportsCopy = (platform.isNative || document.queryCommandSupported('copy'));
  80781. // IE and Edge have trouble with setting html content in clipboard
  80782. var supportsCopyWithSyntaxHighlighting = (supportsCopy && !browser.isEdgeOrIE);
  80783. // Chrome incorrectly returns true for document.queryCommandSupported('paste')
  80784. // when the paste feature is available but the calling script has insufficient
  80785. // privileges to actually perform the action
  80786. var supportsPaste = (platform.isNative || (!browser.isChrome && document.queryCommandSupported('paste')));
  80787. var ExecCommandAction = /** @class */ (function (_super) {
  80788. __extends(ExecCommandAction, _super);
  80789. function ExecCommandAction(browserCommand, opts) {
  80790. var _this = _super.call(this, opts) || this;
  80791. _this.browserCommand = browserCommand;
  80792. return _this;
  80793. }
  80794. ExecCommandAction.prototype.runCommand = function (accessor, args) {
  80795. var focusedEditor = accessor.get(codeEditorService_1.ICodeEditorService).getFocusedCodeEditor();
  80796. // Only if editor text focus (i.e. not if editor has widget focus).
  80797. if (focusedEditor && focusedEditor.hasTextFocus()) {
  80798. focusedEditor.trigger('keyboard', this.id, args);
  80799. return;
  80800. }
  80801. document.execCommand(this.browserCommand);
  80802. };
  80803. ExecCommandAction.prototype.run = function (accessor, editor) {
  80804. editor.focus();
  80805. document.execCommand(this.browserCommand);
  80806. };
  80807. return ExecCommandAction;
  80808. }(editorExtensions_1.EditorAction));
  80809. var ExecCommandCutAction = /** @class */ (function (_super) {
  80810. __extends(ExecCommandCutAction, _super);
  80811. function ExecCommandCutAction() {
  80812. var _this = this;
  80813. var kbOpts = {
  80814. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  80815. primary: 2048 /* CtrlCmd */ | 54 /* KEY_X */,
  80816. win: { primary: 2048 /* CtrlCmd */ | 54 /* KEY_X */, secondary: [1024 /* Shift */ | 20 /* Delete */] },
  80817. weight: 100 /* EditorContrib */
  80818. };
  80819. // Do not bind cut keybindings in the browser,
  80820. // since browsers do that for us and it avoids security prompts
  80821. if (!platform.isNative) {
  80822. kbOpts = undefined;
  80823. }
  80824. _this = _super.call(this, 'cut', {
  80825. id: 'editor.action.clipboardCutAction',
  80826. label: nls.localize(0, null),
  80827. alias: 'Cut',
  80828. precondition: editorContextKeys_1.EditorContextKeys.writable,
  80829. kbOpts: kbOpts,
  80830. contextMenuOpts: {
  80831. group: CLIPBOARD_CONTEXT_MENU_GROUP,
  80832. order: 1
  80833. },
  80834. menuOpts: {
  80835. menuId: 17 /* MenubarEditMenu */,
  80836. group: '2_ccp',
  80837. title: nls.localize(1, null),
  80838. order: 1
  80839. }
  80840. }) || this;
  80841. return _this;
  80842. }
  80843. ExecCommandCutAction.prototype.run = function (accessor, editor) {
  80844. if (!editor.hasModel()) {
  80845. return;
  80846. }
  80847. var emptySelectionClipboard = editor.getOption(25 /* emptySelectionClipboard */);
  80848. if (!emptySelectionClipboard && editor.getSelection().isEmpty()) {
  80849. return;
  80850. }
  80851. _super.prototype.run.call(this, accessor, editor);
  80852. };
  80853. return ExecCommandCutAction;
  80854. }(ExecCommandAction));
  80855. var ExecCommandCopyAction = /** @class */ (function (_super) {
  80856. __extends(ExecCommandCopyAction, _super);
  80857. function ExecCommandCopyAction() {
  80858. var _this = this;
  80859. var kbOpts = {
  80860. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  80861. primary: 2048 /* CtrlCmd */ | 33 /* KEY_C */,
  80862. win: { primary: 2048 /* CtrlCmd */ | 33 /* KEY_C */, secondary: [2048 /* CtrlCmd */ | 19 /* Insert */] },
  80863. weight: 100 /* EditorContrib */
  80864. };
  80865. // Do not bind copy keybindings in the browser,
  80866. // since browsers do that for us and it avoids security prompts
  80867. if (!platform.isNative) {
  80868. kbOpts = undefined;
  80869. }
  80870. _this = _super.call(this, 'copy', {
  80871. id: 'editor.action.clipboardCopyAction',
  80872. label: nls.localize(2, null),
  80873. alias: 'Copy',
  80874. precondition: undefined,
  80875. kbOpts: kbOpts,
  80876. contextMenuOpts: {
  80877. group: CLIPBOARD_CONTEXT_MENU_GROUP,
  80878. order: 2
  80879. },
  80880. menuOpts: {
  80881. menuId: 17 /* MenubarEditMenu */,
  80882. group: '2_ccp',
  80883. title: nls.localize(3, null),
  80884. order: 2
  80885. }
  80886. }) || this;
  80887. return _this;
  80888. }
  80889. ExecCommandCopyAction.prototype.run = function (accessor, editor) {
  80890. if (!editor.hasModel()) {
  80891. return;
  80892. }
  80893. var emptySelectionClipboard = editor.getOption(25 /* emptySelectionClipboard */);
  80894. if (!emptySelectionClipboard && editor.getSelection().isEmpty()) {
  80895. return;
  80896. }
  80897. _super.prototype.run.call(this, accessor, editor);
  80898. };
  80899. return ExecCommandCopyAction;
  80900. }(ExecCommandAction));
  80901. var ExecCommandPasteAction = /** @class */ (function (_super) {
  80902. __extends(ExecCommandPasteAction, _super);
  80903. function ExecCommandPasteAction() {
  80904. var _this = this;
  80905. var kbOpts = {
  80906. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  80907. primary: 2048 /* CtrlCmd */ | 52 /* KEY_V */,
  80908. win: { primary: 2048 /* CtrlCmd */ | 52 /* KEY_V */, secondary: [1024 /* Shift */ | 19 /* Insert */] },
  80909. weight: 100 /* EditorContrib */
  80910. };
  80911. // Do not bind paste keybindings in the browser,
  80912. // since browsers do that for us and it avoids security prompts
  80913. if (!platform.isNative) {
  80914. kbOpts = undefined;
  80915. }
  80916. _this = _super.call(this, 'paste', {
  80917. id: 'editor.action.clipboardPasteAction',
  80918. label: nls.localize(4, null),
  80919. alias: 'Paste',
  80920. precondition: editorContextKeys_1.EditorContextKeys.writable,
  80921. kbOpts: kbOpts,
  80922. contextMenuOpts: {
  80923. group: CLIPBOARD_CONTEXT_MENU_GROUP,
  80924. order: 3
  80925. },
  80926. menuOpts: {
  80927. menuId: 17 /* MenubarEditMenu */,
  80928. group: '2_ccp',
  80929. title: nls.localize(5, null),
  80930. order: 3
  80931. }
  80932. }) || this;
  80933. return _this;
  80934. }
  80935. return ExecCommandPasteAction;
  80936. }(ExecCommandAction));
  80937. var ExecCommandCopyWithSyntaxHighlightingAction = /** @class */ (function (_super) {
  80938. __extends(ExecCommandCopyWithSyntaxHighlightingAction, _super);
  80939. function ExecCommandCopyWithSyntaxHighlightingAction() {
  80940. return _super.call(this, 'copy', {
  80941. id: 'editor.action.clipboardCopyWithSyntaxHighlightingAction',
  80942. label: nls.localize(6, null),
  80943. alias: 'Copy With Syntax Highlighting',
  80944. precondition: undefined,
  80945. kbOpts: {
  80946. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  80947. primary: 0,
  80948. weight: 100 /* EditorContrib */
  80949. }
  80950. }) || this;
  80951. }
  80952. ExecCommandCopyWithSyntaxHighlightingAction.prototype.run = function (accessor, editor) {
  80953. if (!editor.hasModel()) {
  80954. return;
  80955. }
  80956. var emptySelectionClipboard = editor.getOption(25 /* emptySelectionClipboard */);
  80957. if (!emptySelectionClipboard && editor.getSelection().isEmpty()) {
  80958. return;
  80959. }
  80960. textAreaInput_1.CopyOptions.forceCopyWithSyntaxHighlighting = true;
  80961. _super.prototype.run.call(this, accessor, editor);
  80962. textAreaInput_1.CopyOptions.forceCopyWithSyntaxHighlighting = false;
  80963. };
  80964. return ExecCommandCopyWithSyntaxHighlightingAction;
  80965. }(ExecCommandAction));
  80966. if (supportsCut) {
  80967. editorExtensions_1.registerEditorAction(ExecCommandCutAction);
  80968. }
  80969. if (supportsCopy) {
  80970. editorExtensions_1.registerEditorAction(ExecCommandCopyAction);
  80971. }
  80972. if (supportsPaste) {
  80973. editorExtensions_1.registerEditorAction(ExecCommandPasteAction);
  80974. }
  80975. if (supportsCopyWithSyntaxHighlighting) {
  80976. editorExtensions_1.registerEditorAction(ExecCommandCopyWithSyntaxHighlightingAction);
  80977. }
  80978. });
  80979. /*---------------------------------------------------------------------------------------------
  80980. * Copyright (c) Microsoft Corporation. All rights reserved.
  80981. * Licensed under the MIT License. See License.txt in the project root for license information.
  80982. *--------------------------------------------------------------------------------------------*/
  80983. var __spreadArrays = (this && this.__spreadArrays) || function () {
  80984. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  80985. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  80986. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  80987. r[k] = a[j];
  80988. return r;
  80989. };
  80990. define(__m[119/*vs/editor/contrib/codeAction/codeAction*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,26/*vs/base/common/cancellation*/,10/*vs/base/common/errors*/,2/*vs/base/common/lifecycle*/,25/*vs/base/common/uri*/,67/*vs/editor/browser/core/editorState*/,12/*vs/editor/browser/editorExtensions*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,17/*vs/editor/common/modes*/,49/*vs/editor/common/services/modelService*/,111/*vs/editor/contrib/codeAction/types*/]), function (require, exports, arrays_1, cancellation_1, errors_1, lifecycle_1, uri_1, editorState_1, editorExtensions_1, range_1, selection_1, modes, modelService_1, types_1) {
  80991. "use strict";
  80992. Object.defineProperty(exports, "__esModule", { value: true });
  80993. exports.codeActionCommandId = 'editor.action.codeAction';
  80994. exports.refactorCommandId = 'editor.action.refactor';
  80995. exports.sourceActionCommandId = 'editor.action.sourceAction';
  80996. exports.organizeImportsCommandId = 'editor.action.organizeImports';
  80997. exports.fixAllCommandId = 'editor.action.fixAll';
  80998. var ManagedCodeActionSet = /** @class */ (function (_super) {
  80999. __extends(ManagedCodeActionSet, _super);
  81000. function ManagedCodeActionSet(actions, disposables) {
  81001. var _this = _super.call(this) || this;
  81002. _this._register(disposables);
  81003. _this.allActions = arrays_1.mergeSort(__spreadArrays(actions), ManagedCodeActionSet.codeActionsComparator);
  81004. _this.validActions = _this.allActions.filter(function (action) { return !action.disabled; });
  81005. return _this;
  81006. }
  81007. ManagedCodeActionSet.codeActionsComparator = function (a, b) {
  81008. if (arrays_1.isNonEmptyArray(a.diagnostics)) {
  81009. if (arrays_1.isNonEmptyArray(b.diagnostics)) {
  81010. return a.diagnostics[0].message.localeCompare(b.diagnostics[0].message);
  81011. }
  81012. else {
  81013. return -1;
  81014. }
  81015. }
  81016. else if (arrays_1.isNonEmptyArray(b.diagnostics)) {
  81017. return 1;
  81018. }
  81019. else {
  81020. return 0; // both have no diagnostics
  81021. }
  81022. };
  81023. Object.defineProperty(ManagedCodeActionSet.prototype, "hasAutoFix", {
  81024. get: function () {
  81025. return this.validActions.some(function (fix) { return !!fix.kind && types_1.CodeActionKind.QuickFix.contains(new types_1.CodeActionKind(fix.kind)) && !!fix.isPreferred; });
  81026. },
  81027. enumerable: true,
  81028. configurable: true
  81029. });
  81030. return ManagedCodeActionSet;
  81031. }(lifecycle_1.Disposable));
  81032. function getCodeActions(model, rangeOrSelection, trigger, token) {
  81033. var _this = this;
  81034. var _a;
  81035. var filter = trigger.filter || {};
  81036. var codeActionContext = {
  81037. only: (_a = filter.include) === null || _a === void 0 ? void 0 : _a.value,
  81038. trigger: trigger.type,
  81039. };
  81040. var cts = new editorState_1.TextModelCancellationTokenSource(model, token);
  81041. var providers = getCodeActionProviders(model, filter);
  81042. var disposables = new lifecycle_1.DisposableStore();
  81043. var promises = providers.map(function (provider) { return __awaiter(_this, void 0, void 0, function () {
  81044. var providedCodeActions, err_1;
  81045. return __generator(this, function (_a) {
  81046. switch (_a.label) {
  81047. case 0:
  81048. _a.trys.push([0, 2, , 3]);
  81049. return [4 /*yield*/, provider.provideCodeActions(model, rangeOrSelection, codeActionContext, cts.token)];
  81050. case 1:
  81051. providedCodeActions = _a.sent();
  81052. if (cts.token.isCancellationRequested || !providedCodeActions) {
  81053. return [2 /*return*/, []];
  81054. }
  81055. disposables.add(providedCodeActions);
  81056. return [2 /*return*/, providedCodeActions.actions.filter(function (action) { return action && types_1.filtersAction(filter, action); })];
  81057. case 2:
  81058. err_1 = _a.sent();
  81059. if (errors_1.isPromiseCanceledError(err_1)) {
  81060. throw err_1;
  81061. }
  81062. errors_1.onUnexpectedExternalError(err_1);
  81063. return [2 /*return*/, []];
  81064. case 3: return [2 /*return*/];
  81065. }
  81066. });
  81067. }); });
  81068. var listener = modes.CodeActionProviderRegistry.onDidChange(function () {
  81069. var newProviders = modes.CodeActionProviderRegistry.all(model);
  81070. if (!arrays_1.equals(newProviders, providers)) {
  81071. cts.cancel();
  81072. }
  81073. });
  81074. return Promise.all(promises)
  81075. .then(arrays_1.flatten)
  81076. .then(function (actions) { return new ManagedCodeActionSet(actions, disposables); })
  81077. .finally(function () {
  81078. listener.dispose();
  81079. cts.dispose();
  81080. });
  81081. }
  81082. exports.getCodeActions = getCodeActions;
  81083. function getCodeActionProviders(model, filter) {
  81084. return modes.CodeActionProviderRegistry.all(model)
  81085. // Don't include providers that we know will not return code actions of interest
  81086. .filter(function (provider) {
  81087. if (!provider.providedCodeActionKinds) {
  81088. // We don't know what type of actions this provider will return.
  81089. return true;
  81090. }
  81091. return provider.providedCodeActionKinds.some(function (kind) { return types_1.mayIncludeActionsOfKind(filter, new types_1.CodeActionKind(kind)); });
  81092. });
  81093. }
  81094. editorExtensions_1.registerLanguageCommand('_executeCodeActionProvider', function (accessor, args) {
  81095. return __awaiter(this, void 0, void 0, function () {
  81096. var resource, rangeOrSelection, kind, model, validatedRangeOrSelection, codeActionSet;
  81097. return __generator(this, function (_a) {
  81098. switch (_a.label) {
  81099. case 0:
  81100. resource = args.resource, rangeOrSelection = args.rangeOrSelection, kind = args.kind;
  81101. if (!(resource instanceof uri_1.URI)) {
  81102. throw errors_1.illegalArgument();
  81103. }
  81104. model = accessor.get(modelService_1.IModelService).getModel(resource);
  81105. if (!model) {
  81106. throw errors_1.illegalArgument();
  81107. }
  81108. validatedRangeOrSelection = selection_1.Selection.isISelection(rangeOrSelection)
  81109. ? selection_1.Selection.liftSelection(rangeOrSelection)
  81110. : range_1.Range.isIRange(rangeOrSelection)
  81111. ? model.validateRange(rangeOrSelection)
  81112. : undefined;
  81113. if (!validatedRangeOrSelection) {
  81114. throw errors_1.illegalArgument();
  81115. }
  81116. return [4 /*yield*/, getCodeActions(model, validatedRangeOrSelection, { type: 2 /* Manual */, filter: { includeSourceActions: true, include: kind && kind.value ? new types_1.CodeActionKind(kind.value) : undefined } }, cancellation_1.CancellationToken.None)];
  81117. case 1:
  81118. codeActionSet = _a.sent();
  81119. setTimeout(function () { return codeActionSet.dispose(); }, 100);
  81120. return [2 /*return*/, codeActionSet.validActions];
  81121. }
  81122. });
  81123. });
  81124. });
  81125. });
  81126. /*---------------------------------------------------------------------------------------------
  81127. * Copyright (c) Microsoft Corporation. All rights reserved.
  81128. * Licensed under the MIT License. See License.txt in the project root for license information.
  81129. *--------------------------------------------------------------------------------------------*/
  81130. var __spreadArrays = (this && this.__spreadArrays) || function () {
  81131. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  81132. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  81133. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  81134. r[k] = a[j];
  81135. return r;
  81136. };
  81137. define(__m[527/*vs/editor/contrib/codeAction/codeActionMenu*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,70/*vs/base/browser/ui/actionbar/actionbar*/,55/*vs/base/common/actions*/,10/*vs/base/common/errors*/,128/*vs/base/common/lazy*/,2/*vs/base/common/lifecycle*/,13/*vs/editor/common/core/position*/,17/*vs/editor/common/modes*/,119/*vs/editor/contrib/codeAction/codeAction*/,111/*vs/editor/contrib/codeAction/types*/,66/*vs/platform/contextview/browser/contextView*/,34/*vs/platform/keybinding/common/keybinding*/]), function (require, exports, dom_1, actionbar_1, actions_1, errors_1, lazy_1, lifecycle_1, position_1, modes_1, codeAction_1, types_1, contextView_1, keybinding_1) {
  81138. "use strict";
  81139. Object.defineProperty(exports, "__esModule", { value: true });
  81140. var CodeActionAction = /** @class */ (function (_super) {
  81141. __extends(CodeActionAction, _super);
  81142. function CodeActionAction(action, callback) {
  81143. var _this = _super.call(this, action.command ? action.command.id : action.title, action.title, undefined, !action.disabled, callback) || this;
  81144. _this.action = action;
  81145. return _this;
  81146. }
  81147. return CodeActionAction;
  81148. }(actions_1.Action));
  81149. var CodeActionMenu = /** @class */ (function (_super) {
  81150. __extends(CodeActionMenu, _super);
  81151. function CodeActionMenu(_editor, _delegate, _contextMenuService, keybindingService) {
  81152. var _this = _super.call(this) || this;
  81153. _this._editor = _editor;
  81154. _this._delegate = _delegate;
  81155. _this._contextMenuService = _contextMenuService;
  81156. _this._visible = false;
  81157. _this._showingActions = _this._register(new lifecycle_1.MutableDisposable());
  81158. _this._keybindingResolver = new CodeActionKeybindingResolver({
  81159. getKeybindings: function () { return keybindingService.getKeybindings(); }
  81160. });
  81161. return _this;
  81162. }
  81163. Object.defineProperty(CodeActionMenu.prototype, "isVisible", {
  81164. get: function () {
  81165. return this._visible;
  81166. },
  81167. enumerable: true,
  81168. configurable: true
  81169. });
  81170. CodeActionMenu.prototype.show = function (trigger, codeActions, at, options) {
  81171. return __awaiter(this, void 0, void 0, function () {
  81172. var actionsToShow, menuActions, anchor, resolver;
  81173. var _this = this;
  81174. return __generator(this, function (_a) {
  81175. actionsToShow = options.includeDisabledActions ? codeActions.allActions : codeActions.validActions;
  81176. if (!actionsToShow.length) {
  81177. this._visible = false;
  81178. return [2 /*return*/];
  81179. }
  81180. if (!this._editor.getDomNode()) {
  81181. // cancel when editor went off-dom
  81182. this._visible = false;
  81183. throw errors_1.canceled();
  81184. }
  81185. this._visible = true;
  81186. this._showingActions.value = codeActions;
  81187. menuActions = this.getMenuActions(trigger, actionsToShow);
  81188. anchor = position_1.Position.isIPosition(at) ? this._toCoords(at) : at || { x: 0, y: 0 };
  81189. resolver = this._keybindingResolver.getResolver();
  81190. this._contextMenuService.showContextMenu({
  81191. getAnchor: function () { return anchor; },
  81192. getActions: function () { return menuActions; },
  81193. onHide: function () {
  81194. _this._visible = false;
  81195. _this._editor.focus();
  81196. },
  81197. autoSelectFirstItem: true,
  81198. getKeyBinding: function (action) { return action instanceof CodeActionAction ? resolver(action.action) : undefined; },
  81199. });
  81200. return [2 /*return*/];
  81201. });
  81202. });
  81203. };
  81204. CodeActionMenu.prototype.getMenuActions = function (trigger, actionsToShow) {
  81205. var _this = this;
  81206. var _a, _b;
  81207. var toCodeActionAction = function (action) { return new CodeActionAction(action, function () { return _this._delegate.onSelectCodeAction(action); }); };
  81208. var result = actionsToShow
  81209. .map(toCodeActionAction);
  81210. var model = this._editor.getModel();
  81211. if (model && result.length) {
  81212. for (var _i = 0, _c = modes_1.CodeActionProviderRegistry.all(model); _i < _c.length; _i++) {
  81213. var provider = _c[_i];
  81214. if (provider._getAdditionalMenuItems) {
  81215. var items = provider._getAdditionalMenuItems({ trigger: trigger.type, only: (_b = (_a = trigger.filter) === null || _a === void 0 ? void 0 : _a.include) === null || _b === void 0 ? void 0 : _b.value }, actionsToShow);
  81216. if (items.length) {
  81217. result.push.apply(result, __spreadArrays([new actionbar_1.Separator()], items.map(function (command) { return toCodeActionAction({
  81218. title: command.title,
  81219. command: command,
  81220. }); })));
  81221. }
  81222. }
  81223. }
  81224. }
  81225. return result;
  81226. };
  81227. CodeActionMenu.prototype._toCoords = function (position) {
  81228. if (!this._editor.hasModel()) {
  81229. return { x: 0, y: 0 };
  81230. }
  81231. this._editor.revealPosition(position, 1 /* Immediate */);
  81232. this._editor.render();
  81233. // Translate to absolute editor position
  81234. var cursorCoords = this._editor.getScrolledVisiblePosition(position);
  81235. var editorCoords = dom_1.getDomNodePagePosition(this._editor.getDomNode());
  81236. var x = editorCoords.left + cursorCoords.left;
  81237. var y = editorCoords.top + cursorCoords.top + cursorCoords.height;
  81238. return { x: x, y: y };
  81239. };
  81240. CodeActionMenu = __decorate([
  81241. __param(2, contextView_1.IContextMenuService),
  81242. __param(3, keybinding_1.IKeybindingService)
  81243. ], CodeActionMenu);
  81244. return CodeActionMenu;
  81245. }(lifecycle_1.Disposable));
  81246. exports.CodeActionMenu = CodeActionMenu;
  81247. var CodeActionKeybindingResolver = /** @class */ (function () {
  81248. function CodeActionKeybindingResolver(_keybindingProvider) {
  81249. this._keybindingProvider = _keybindingProvider;
  81250. }
  81251. CodeActionKeybindingResolver.prototype.getResolver = function () {
  81252. var _this = this;
  81253. // Lazy since we may not actually ever read the value
  81254. var allCodeActionBindings = new lazy_1.Lazy(function () {
  81255. return _this._keybindingProvider.getKeybindings()
  81256. .filter(function (item) { return CodeActionKeybindingResolver.codeActionCommands.indexOf(item.command) >= 0; })
  81257. .filter(function (item) { return item.resolvedKeybinding; })
  81258. .map(function (item) {
  81259. // Special case these commands since they come built-in with VS Code and don't use 'commandArgs'
  81260. var commandArgs = item.commandArgs;
  81261. if (item.command === codeAction_1.organizeImportsCommandId) {
  81262. commandArgs = { kind: types_1.CodeActionKind.SourceOrganizeImports.value };
  81263. }
  81264. else if (item.command === codeAction_1.fixAllCommandId) {
  81265. commandArgs = { kind: types_1.CodeActionKind.SourceFixAll.value };
  81266. }
  81267. return __assign({ resolvedKeybinding: item.resolvedKeybinding }, types_1.CodeActionCommandArgs.fromUser(commandArgs, {
  81268. kind: types_1.CodeActionKind.None,
  81269. apply: "never" /* Never */
  81270. }));
  81271. });
  81272. });
  81273. return function (action) {
  81274. if (action.kind) {
  81275. var binding = _this.bestKeybindingForCodeAction(action, allCodeActionBindings.getValue());
  81276. return binding === null || binding === void 0 ? void 0 : binding.resolvedKeybinding;
  81277. }
  81278. return undefined;
  81279. };
  81280. };
  81281. CodeActionKeybindingResolver.prototype.bestKeybindingForCodeAction = function (action, candidates) {
  81282. if (!action.kind) {
  81283. return undefined;
  81284. }
  81285. var kind = new types_1.CodeActionKind(action.kind);
  81286. return candidates
  81287. .filter(function (candidate) { return candidate.kind.contains(kind); })
  81288. .filter(function (candidate) {
  81289. if (candidate.preferred) {
  81290. // If the candidate keybinding only applies to preferred actions, the this action must also be preferred
  81291. return action.isPreferred;
  81292. }
  81293. return true;
  81294. })
  81295. .reduceRight(function (currentBest, candidate) {
  81296. if (!currentBest) {
  81297. return candidate;
  81298. }
  81299. // Select the more specific binding
  81300. return currentBest.kind.contains(candidate.kind) ? candidate : currentBest;
  81301. }, undefined);
  81302. };
  81303. CodeActionKeybindingResolver.codeActionCommands = [
  81304. codeAction_1.refactorCommandId,
  81305. codeAction_1.codeActionCommandId,
  81306. codeAction_1.sourceActionCommandId,
  81307. codeAction_1.organizeImportsCommandId,
  81308. codeAction_1.fixAllCommandId
  81309. ];
  81310. return CodeActionKeybindingResolver;
  81311. }());
  81312. exports.CodeActionKeybindingResolver = CodeActionKeybindingResolver;
  81313. });
  81314. /*---------------------------------------------------------------------------------------------
  81315. * Copyright (c) Microsoft Corporation. All rights reserved.
  81316. * Licensed under the MIT License. See License.txt in the project root for license information.
  81317. *--------------------------------------------------------------------------------------------*/
  81318. define(__m[528/*vs/editor/contrib/codeAction/codeActionModel*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,3/*vs/editor/common/core/range*/,17/*vs/editor/common/modes*/,18/*vs/platform/contextkey/common/contextkey*/,119/*vs/editor/contrib/codeAction/codeAction*/,39/*vs/base/common/resources*/]), function (require, exports, async_1, event_1, lifecycle_1, range_1, modes_1, contextkey_1, codeAction_1, resources_1) {
  81319. "use strict";
  81320. Object.defineProperty(exports, "__esModule", { value: true });
  81321. exports.SUPPORTED_CODE_ACTIONS = new contextkey_1.RawContextKey('supportedCodeAction', '');
  81322. var CodeActionOracle = /** @class */ (function (_super) {
  81323. __extends(CodeActionOracle, _super);
  81324. function CodeActionOracle(_editor, _markerService, _signalChange, _delay) {
  81325. if (_delay === void 0) { _delay = 250; }
  81326. var _this = _super.call(this) || this;
  81327. _this._editor = _editor;
  81328. _this._markerService = _markerService;
  81329. _this._signalChange = _signalChange;
  81330. _this._delay = _delay;
  81331. _this._autoTriggerTimer = _this._register(new async_1.TimeoutTimer());
  81332. _this._register(_this._markerService.onMarkerChanged(function (e) { return _this._onMarkerChanges(e); }));
  81333. _this._register(_this._editor.onDidChangeCursorPosition(function () { return _this._onCursorChange(); }));
  81334. return _this;
  81335. }
  81336. CodeActionOracle.prototype.trigger = function (trigger) {
  81337. var selection = this._getRangeOfSelectionUnlessWhitespaceEnclosed(trigger);
  81338. return this._createEventAndSignalChange(trigger, selection);
  81339. };
  81340. CodeActionOracle.prototype._onMarkerChanges = function (resources) {
  81341. var _this = this;
  81342. var model = this._editor.getModel();
  81343. if (!model) {
  81344. return;
  81345. }
  81346. if (resources.some(function (resource) { return resources_1.isEqual(resource, model.uri); })) {
  81347. this._autoTriggerTimer.cancelAndSet(function () {
  81348. _this.trigger({ type: 1 /* Auto */ });
  81349. }, this._delay);
  81350. }
  81351. };
  81352. CodeActionOracle.prototype._onCursorChange = function () {
  81353. var _this = this;
  81354. this._autoTriggerTimer.cancelAndSet(function () {
  81355. _this.trigger({ type: 1 /* Auto */ });
  81356. }, this._delay);
  81357. };
  81358. CodeActionOracle.prototype._getRangeOfMarker = function (selection) {
  81359. var model = this._editor.getModel();
  81360. if (!model) {
  81361. return undefined;
  81362. }
  81363. for (var _i = 0, _a = this._markerService.read({ resource: model.uri }); _i < _a.length; _i++) {
  81364. var marker = _a[_i];
  81365. var markerRange = model.validateRange(marker);
  81366. if (range_1.Range.intersectRanges(markerRange, selection)) {
  81367. return range_1.Range.lift(markerRange);
  81368. }
  81369. }
  81370. return undefined;
  81371. };
  81372. CodeActionOracle.prototype._getRangeOfSelectionUnlessWhitespaceEnclosed = function (trigger) {
  81373. if (!this._editor.hasModel()) {
  81374. return undefined;
  81375. }
  81376. var model = this._editor.getModel();
  81377. var selection = this._editor.getSelection();
  81378. if (selection.isEmpty() && trigger.type === 1 /* Auto */) {
  81379. var _a = selection.getPosition(), lineNumber = _a.lineNumber, column = _a.column;
  81380. var line = model.getLineContent(lineNumber);
  81381. if (line.length === 0) {
  81382. // empty line
  81383. return undefined;
  81384. }
  81385. else if (column === 1) {
  81386. // look only right
  81387. if (/\s/.test(line[0])) {
  81388. return undefined;
  81389. }
  81390. }
  81391. else if (column === model.getLineMaxColumn(lineNumber)) {
  81392. // look only left
  81393. if (/\s/.test(line[line.length - 1])) {
  81394. return undefined;
  81395. }
  81396. }
  81397. else {
  81398. // look left and right
  81399. if (/\s/.test(line[column - 2]) && /\s/.test(line[column - 1])) {
  81400. return undefined;
  81401. }
  81402. }
  81403. }
  81404. return selection;
  81405. };
  81406. CodeActionOracle.prototype._createEventAndSignalChange = function (trigger, selection) {
  81407. var model = this._editor.getModel();
  81408. if (!selection || !model) {
  81409. // cancel
  81410. this._signalChange(undefined);
  81411. return undefined;
  81412. }
  81413. var markerRange = this._getRangeOfMarker(selection);
  81414. var position = markerRange ? markerRange.getStartPosition() : selection.getStartPosition();
  81415. var e = {
  81416. trigger: trigger,
  81417. selection: selection,
  81418. position: position
  81419. };
  81420. this._signalChange(e);
  81421. return e;
  81422. };
  81423. return CodeActionOracle;
  81424. }(lifecycle_1.Disposable));
  81425. var CodeActionsState;
  81426. (function (CodeActionsState) {
  81427. CodeActionsState.Empty = { type: 0 /* Empty */ };
  81428. var Triggered = /** @class */ (function () {
  81429. function Triggered(trigger, rangeOrSelection, position, actions) {
  81430. this.trigger = trigger;
  81431. this.rangeOrSelection = rangeOrSelection;
  81432. this.position = position;
  81433. this.actions = actions;
  81434. this.type = 1 /* Triggered */;
  81435. }
  81436. return Triggered;
  81437. }());
  81438. CodeActionsState.Triggered = Triggered;
  81439. })(CodeActionsState = exports.CodeActionsState || (exports.CodeActionsState = {}));
  81440. var CodeActionModel = /** @class */ (function (_super) {
  81441. __extends(CodeActionModel, _super);
  81442. function CodeActionModel(_editor, _markerService, contextKeyService, _progressService) {
  81443. var _this = _super.call(this) || this;
  81444. _this._editor = _editor;
  81445. _this._markerService = _markerService;
  81446. _this._progressService = _progressService;
  81447. _this._codeActionOracle = _this._register(new lifecycle_1.MutableDisposable());
  81448. _this._state = CodeActionsState.Empty;
  81449. _this._onDidChangeState = _this._register(new event_1.Emitter());
  81450. _this.onDidChangeState = _this._onDidChangeState.event;
  81451. _this._supportedCodeActions = exports.SUPPORTED_CODE_ACTIONS.bindTo(contextKeyService);
  81452. _this._register(_this._editor.onDidChangeModel(function () { return _this._update(); }));
  81453. _this._register(_this._editor.onDidChangeModelLanguage(function () { return _this._update(); }));
  81454. _this._register(modes_1.CodeActionProviderRegistry.onDidChange(function () { return _this._update(); }));
  81455. _this._update();
  81456. return _this;
  81457. }
  81458. CodeActionModel.prototype.dispose = function () {
  81459. _super.prototype.dispose.call(this);
  81460. this.setState(CodeActionsState.Empty, true);
  81461. };
  81462. CodeActionModel.prototype._update = function () {
  81463. var _this = this;
  81464. this._codeActionOracle.value = undefined;
  81465. this.setState(CodeActionsState.Empty);
  81466. var model = this._editor.getModel();
  81467. if (model
  81468. && modes_1.CodeActionProviderRegistry.has(model)
  81469. && !this._editor.getOption(68 /* readOnly */)) {
  81470. var supportedActions = [];
  81471. for (var _i = 0, _a = modes_1.CodeActionProviderRegistry.all(model); _i < _a.length; _i++) {
  81472. var provider = _a[_i];
  81473. if (Array.isArray(provider.providedCodeActionKinds)) {
  81474. supportedActions.push.apply(supportedActions, provider.providedCodeActionKinds);
  81475. }
  81476. }
  81477. this._supportedCodeActions.set(supportedActions.join(' '));
  81478. this._codeActionOracle.value = new CodeActionOracle(this._editor, this._markerService, function (trigger) {
  81479. if (!trigger) {
  81480. _this.setState(CodeActionsState.Empty);
  81481. return;
  81482. }
  81483. var actions = async_1.createCancelablePromise(function (token) { return codeAction_1.getCodeActions(model, trigger.selection, trigger.trigger, token); });
  81484. if (_this._progressService && trigger.trigger.type === 2 /* Manual */) {
  81485. _this._progressService.showWhile(actions, 250);
  81486. }
  81487. _this.setState(new CodeActionsState.Triggered(trigger.trigger, trigger.selection, trigger.position, actions));
  81488. }, undefined);
  81489. this._codeActionOracle.value.trigger({ type: 1 /* Auto */ });
  81490. }
  81491. else {
  81492. this._supportedCodeActions.reset();
  81493. }
  81494. };
  81495. CodeActionModel.prototype.trigger = function (trigger) {
  81496. if (this._codeActionOracle.value) {
  81497. this._codeActionOracle.value.trigger(trigger);
  81498. }
  81499. };
  81500. CodeActionModel.prototype.setState = function (newState, skipNotify) {
  81501. if (newState === this._state) {
  81502. return;
  81503. }
  81504. // Cancel old request
  81505. if (this._state.type === 1 /* Triggered */) {
  81506. this._state.actions.cancel();
  81507. }
  81508. this._state = newState;
  81509. if (!skipNotify) {
  81510. this._onDidChangeState.fire(newState);
  81511. }
  81512. };
  81513. return CodeActionModel;
  81514. }(lifecycle_1.Disposable));
  81515. exports.CodeActionModel = CodeActionModel;
  81516. });
  81517. /*---------------------------------------------------------------------------------------------
  81518. * Copyright (c) Microsoft Corporation. All rights reserved.
  81519. * Licensed under the MIT License. See License.txt in the project root for license information.
  81520. *--------------------------------------------------------------------------------------------*/
  81521. define(__m[221/*vs/editor/contrib/codelens/codelens*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,26/*vs/base/common/cancellation*/,10/*vs/base/common/errors*/,25/*vs/base/common/uri*/,12/*vs/editor/browser/editorExtensions*/,17/*vs/editor/common/modes*/,49/*vs/editor/common/services/modelService*/,2/*vs/base/common/lifecycle*/]), function (require, exports, arrays_1, cancellation_1, errors_1, uri_1, editorExtensions_1, modes_1, modelService_1, lifecycle_1) {
  81522. "use strict";
  81523. Object.defineProperty(exports, "__esModule", { value: true });
  81524. var CodeLensModel = /** @class */ (function () {
  81525. function CodeLensModel() {
  81526. this.lenses = [];
  81527. this._disposables = new lifecycle_1.DisposableStore();
  81528. }
  81529. CodeLensModel.prototype.dispose = function () {
  81530. this._disposables.dispose();
  81531. };
  81532. CodeLensModel.prototype.add = function (list, provider) {
  81533. this._disposables.add(list);
  81534. for (var _i = 0, _a = list.lenses; _i < _a.length; _i++) {
  81535. var symbol = _a[_i];
  81536. this.lenses.push({ symbol: symbol, provider: provider });
  81537. }
  81538. };
  81539. return CodeLensModel;
  81540. }());
  81541. exports.CodeLensModel = CodeLensModel;
  81542. function getCodeLensData(model, token) {
  81543. var provider = modes_1.CodeLensProviderRegistry.ordered(model);
  81544. var providerRanks = new Map();
  81545. var result = new CodeLensModel();
  81546. var promises = provider.map(function (provider, i) {
  81547. providerRanks.set(provider, i);
  81548. return Promise.resolve(provider.provideCodeLenses(model, token))
  81549. .then(function (list) { return list && result.add(list, provider); })
  81550. .catch(errors_1.onUnexpectedExternalError);
  81551. });
  81552. return Promise.all(promises).then(function () {
  81553. result.lenses = arrays_1.mergeSort(result.lenses, function (a, b) {
  81554. // sort by lineNumber, provider-rank, and column
  81555. if (a.symbol.range.startLineNumber < b.symbol.range.startLineNumber) {
  81556. return -1;
  81557. }
  81558. else if (a.symbol.range.startLineNumber > b.symbol.range.startLineNumber) {
  81559. return 1;
  81560. }
  81561. else if (providerRanks.get(a.provider) < providerRanks.get(b.provider)) {
  81562. return -1;
  81563. }
  81564. else if (providerRanks.get(a.provider) > providerRanks.get(b.provider)) {
  81565. return 1;
  81566. }
  81567. else if (a.symbol.range.startColumn < b.symbol.range.startColumn) {
  81568. return -1;
  81569. }
  81570. else if (a.symbol.range.startColumn > b.symbol.range.startColumn) {
  81571. return 1;
  81572. }
  81573. else {
  81574. return 0;
  81575. }
  81576. });
  81577. return result;
  81578. });
  81579. }
  81580. exports.getCodeLensData = getCodeLensData;
  81581. editorExtensions_1.registerLanguageCommand('_executeCodeLensProvider', function (accessor, args) {
  81582. var resource = args.resource, itemResolveCount = args.itemResolveCount;
  81583. if (!(resource instanceof uri_1.URI)) {
  81584. throw errors_1.illegalArgument();
  81585. }
  81586. var model = accessor.get(modelService_1.IModelService).getModel(resource);
  81587. if (!model) {
  81588. throw errors_1.illegalArgument();
  81589. }
  81590. var result = [];
  81591. var disposables = new lifecycle_1.DisposableStore();
  81592. return getCodeLensData(model, cancellation_1.CancellationToken.None).then(function (value) {
  81593. disposables.add(value);
  81594. var resolve = [];
  81595. var _loop_1 = function (item) {
  81596. if (typeof itemResolveCount === 'undefined' || Boolean(item.symbol.command)) {
  81597. result.push(item.symbol);
  81598. }
  81599. else if (itemResolveCount-- > 0 && item.provider.resolveCodeLens) {
  81600. resolve.push(Promise.resolve(item.provider.resolveCodeLens(model, item.symbol, cancellation_1.CancellationToken.None)).then(function (symbol) { return result.push(symbol || item.symbol); }));
  81601. }
  81602. };
  81603. for (var _i = 0, _a = value.lenses; _i < _a.length; _i++) {
  81604. var item = _a[_i];
  81605. _loop_1(item);
  81606. }
  81607. return Promise.all(resolve);
  81608. }).then(function () {
  81609. return result;
  81610. }).finally(function () {
  81611. // make sure to return results, then (on next tick)
  81612. // dispose the results
  81613. setTimeout(function () { return disposables.dispose(); }, 100);
  81614. });
  81615. });
  81616. });
  81617. /*---------------------------------------------------------------------------------------------
  81618. * Copyright (c) Microsoft Corporation. All rights reserved.
  81619. * Licensed under the MIT License. See License.txt in the project root for license information.
  81620. *--------------------------------------------------------------------------------------------*/
  81621. define(__m[529/*vs/editor/contrib/codelens/codeLensCache*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/,83/*vs/platform/instantiation/common/extensions*/,221/*vs/editor/contrib/codelens/codelens*/,38/*vs/base/common/map*/,74/*vs/platform/storage/common/storage*/,3/*vs/editor/common/core/range*/,15/*vs/base/common/async*/,102/*vs/base/common/functional*/]), function (require, exports, instantiation_1, extensions_1, codelens_1, map_1, storage_1, range_1, async_1, functional_1) {
  81622. "use strict";
  81623. Object.defineProperty(exports, "__esModule", { value: true });
  81624. exports.ICodeLensCache = instantiation_1.createDecorator('ICodeLensCache');
  81625. var CacheItem = /** @class */ (function () {
  81626. function CacheItem(lineCount, data) {
  81627. this.lineCount = lineCount;
  81628. this.data = data;
  81629. }
  81630. return CacheItem;
  81631. }());
  81632. var CodeLensCache = /** @class */ (function () {
  81633. function CodeLensCache(storageService) {
  81634. var _this = this;
  81635. this._fakeProvider = new /** @class */ (function () {
  81636. function class_1() {
  81637. }
  81638. class_1.prototype.provideCodeLenses = function () {
  81639. throw new Error('not supported');
  81640. };
  81641. return class_1;
  81642. }());
  81643. this._cache = new map_1.LRUCache(20, 0.75);
  81644. // remove old data
  81645. var oldkey = 'codelens/cache';
  81646. async_1.runWhenIdle(function () { return storageService.remove(oldkey, 1 /* WORKSPACE */); });
  81647. // restore lens data on start
  81648. var key = 'codelens/cache2';
  81649. var raw = storageService.get(key, 1 /* WORKSPACE */, '{}');
  81650. this._deserialize(raw);
  81651. // store lens data on shutdown
  81652. functional_1.once(storageService.onWillSaveState)(function (e) {
  81653. if (e.reason === storage_1.WillSaveStateReason.SHUTDOWN) {
  81654. storageService.store(key, _this._serialize(), 1 /* WORKSPACE */);
  81655. }
  81656. });
  81657. }
  81658. CodeLensCache.prototype.put = function (model, data) {
  81659. // create a copy of the model that is without command-ids
  81660. // but with comand-labels
  81661. var copyItems = data.lenses.map(function (item) {
  81662. var _a;
  81663. return {
  81664. range: item.symbol.range,
  81665. command: item.symbol.command && { id: '', title: (_a = item.symbol.command) === null || _a === void 0 ? void 0 : _a.title },
  81666. };
  81667. });
  81668. var copyModel = new codelens_1.CodeLensModel();
  81669. copyModel.add({ lenses: copyItems, dispose: function () { } }, this._fakeProvider);
  81670. var item = new CacheItem(model.getLineCount(), copyModel);
  81671. this._cache.set(model.uri.toString(), item);
  81672. };
  81673. CodeLensCache.prototype.get = function (model) {
  81674. var item = this._cache.get(model.uri.toString());
  81675. return item && item.lineCount === model.getLineCount() ? item.data : undefined;
  81676. };
  81677. CodeLensCache.prototype.delete = function (model) {
  81678. this._cache.delete(model.uri.toString());
  81679. };
  81680. // --- persistence
  81681. CodeLensCache.prototype._serialize = function () {
  81682. var data = Object.create(null);
  81683. this._cache.forEach(function (value, key) {
  81684. var lines = new Set();
  81685. for (var _i = 0, _a = value.data.lenses; _i < _a.length; _i++) {
  81686. var d = _a[_i];
  81687. lines.add(d.symbol.range.startLineNumber);
  81688. }
  81689. data[key] = {
  81690. lineCount: value.lineCount,
  81691. lines: map_1.values(lines)
  81692. };
  81693. });
  81694. return JSON.stringify(data);
  81695. };
  81696. CodeLensCache.prototype._deserialize = function (raw) {
  81697. try {
  81698. var data = JSON.parse(raw);
  81699. for (var key in data) {
  81700. var element = data[key];
  81701. var lenses = [];
  81702. for (var _i = 0, _a = element.lines; _i < _a.length; _i++) {
  81703. var line = _a[_i];
  81704. lenses.push({ range: new range_1.Range(line, 1, line, 11) });
  81705. }
  81706. var model = new codelens_1.CodeLensModel();
  81707. model.add({ lenses: lenses, dispose: function () { } }, this._fakeProvider);
  81708. this._cache.set(key, new CacheItem(element.lineCount, model));
  81709. }
  81710. }
  81711. catch (_b) {
  81712. // ignore...
  81713. }
  81714. };
  81715. CodeLensCache = __decorate([
  81716. __param(0, storage_1.IStorageService)
  81717. ], CodeLensCache);
  81718. return CodeLensCache;
  81719. }());
  81720. exports.CodeLensCache = CodeLensCache;
  81721. extensions_1.registerSingleton(exports.ICodeLensCache, CodeLensCache);
  81722. });
  81723. /*---------------------------------------------------------------------------------------------
  81724. * Copyright (c) Microsoft Corporation. All rights reserved.
  81725. * Licensed under the MIT License. See License.txt in the project root for license information.
  81726. *--------------------------------------------------------------------------------------------*/
  81727. define(__m[222/*vs/editor/contrib/colorPicker/color*/], __M([0/*require*/,1/*exports*/,26/*vs/base/common/cancellation*/,10/*vs/base/common/errors*/,25/*vs/base/common/uri*/,12/*vs/editor/browser/editorExtensions*/,3/*vs/editor/common/core/range*/,17/*vs/editor/common/modes*/,49/*vs/editor/common/services/modelService*/]), function (require, exports, cancellation_1, errors_1, uri_1, editorExtensions_1, range_1, modes_1, modelService_1) {
  81728. "use strict";
  81729. Object.defineProperty(exports, "__esModule", { value: true });
  81730. function getColors(model, token) {
  81731. var colors = [];
  81732. var providers = modes_1.ColorProviderRegistry.ordered(model).reverse();
  81733. var promises = providers.map(function (provider) { return Promise.resolve(provider.provideDocumentColors(model, token)).then(function (result) {
  81734. if (Array.isArray(result)) {
  81735. for (var _i = 0, result_1 = result; _i < result_1.length; _i++) {
  81736. var colorInfo = result_1[_i];
  81737. colors.push({ colorInfo: colorInfo, provider: provider });
  81738. }
  81739. }
  81740. }); });
  81741. return Promise.all(promises).then(function () { return colors; });
  81742. }
  81743. exports.getColors = getColors;
  81744. function getColorPresentations(model, colorInfo, provider, token) {
  81745. return Promise.resolve(provider.provideColorPresentations(model, colorInfo, token));
  81746. }
  81747. exports.getColorPresentations = getColorPresentations;
  81748. editorExtensions_1.registerLanguageCommand('_executeDocumentColorProvider', function (accessor, args) {
  81749. var resource = args.resource;
  81750. if (!(resource instanceof uri_1.URI)) {
  81751. throw errors_1.illegalArgument();
  81752. }
  81753. var model = accessor.get(modelService_1.IModelService).getModel(resource);
  81754. if (!model) {
  81755. throw errors_1.illegalArgument();
  81756. }
  81757. var rawCIs = [];
  81758. var providers = modes_1.ColorProviderRegistry.ordered(model).reverse();
  81759. var promises = providers.map(function (provider) { return Promise.resolve(provider.provideDocumentColors(model, cancellation_1.CancellationToken.None)).then(function (result) {
  81760. if (Array.isArray(result)) {
  81761. for (var _i = 0, result_2 = result; _i < result_2.length; _i++) {
  81762. var ci = result_2[_i];
  81763. rawCIs.push({ range: ci.range, color: [ci.color.red, ci.color.green, ci.color.blue, ci.color.alpha] });
  81764. }
  81765. }
  81766. }); });
  81767. return Promise.all(promises).then(function () { return rawCIs; });
  81768. });
  81769. editorExtensions_1.registerLanguageCommand('_executeColorPresentationProvider', function (accessor, args) {
  81770. var resource = args.resource, color = args.color, range = args.range;
  81771. if (!(resource instanceof uri_1.URI) || !Array.isArray(color) || color.length !== 4 || !range_1.Range.isIRange(range)) {
  81772. throw errors_1.illegalArgument();
  81773. }
  81774. var red = color[0], green = color[1], blue = color[2], alpha = color[3];
  81775. var model = accessor.get(modelService_1.IModelService).getModel(resource);
  81776. if (!model) {
  81777. throw errors_1.illegalArgument();
  81778. }
  81779. var colorInfo = {
  81780. range: range,
  81781. color: { red: red, green: green, blue: blue, alpha: alpha }
  81782. };
  81783. var presentations = [];
  81784. var providers = modes_1.ColorProviderRegistry.ordered(model).reverse();
  81785. var promises = providers.map(function (provider) { return Promise.resolve(provider.provideColorPresentations(model, colorInfo, cancellation_1.CancellationToken.None)).then(function (result) {
  81786. if (Array.isArray(result)) {
  81787. presentations.push.apply(presentations, result);
  81788. }
  81789. }); });
  81790. return Promise.all(promises).then(function () { return presentations; });
  81791. });
  81792. });
  81793. /*---------------------------------------------------------------------------------------------
  81794. * Copyright (c) Microsoft Corporation. All rights reserved.
  81795. * Licensed under the MIT License. See License.txt in the project root for license information.
  81796. *--------------------------------------------------------------------------------------------*/
  81797. define(__m[223/*vs/editor/contrib/colorPicker/colorDetector*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,27/*vs/base/common/color*/,10/*vs/base/common/errors*/,125/*vs/base/common/hash*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,32/*vs/editor/browser/services/codeEditorService*/,3/*vs/editor/common/core/range*/,30/*vs/editor/common/model/textModel*/,17/*vs/editor/common/modes*/,222/*vs/editor/contrib/colorPicker/color*/,43/*vs/platform/configuration/common/configuration*/]), function (require, exports, async_1, color_1, errors_1, hash_1, lifecycle_1, editorExtensions_1, codeEditorService_1, range_1, textModel_1, modes_1, color_2, configuration_1) {
  81798. "use strict";
  81799. Object.defineProperty(exports, "__esModule", { value: true });
  81800. var MAX_DECORATORS = 500;
  81801. var ColorDetector = /** @class */ (function (_super) {
  81802. __extends(ColorDetector, _super);
  81803. function ColorDetector(_editor, _codeEditorService, _configurationService) {
  81804. var _this = _super.call(this) || this;
  81805. _this._editor = _editor;
  81806. _this._codeEditorService = _codeEditorService;
  81807. _this._configurationService = _configurationService;
  81808. _this._localToDispose = _this._register(new lifecycle_1.DisposableStore());
  81809. _this._decorationsIds = [];
  81810. _this._colorDatas = new Map();
  81811. _this._colorDecoratorIds = [];
  81812. _this._decorationsTypes = new Set();
  81813. _this._register(_editor.onDidChangeModel(function (e) {
  81814. _this._isEnabled = _this.isEnabled();
  81815. _this.onModelChanged();
  81816. }));
  81817. _this._register(_editor.onDidChangeModelLanguage(function (e) { return _this.onModelChanged(); }));
  81818. _this._register(modes_1.ColorProviderRegistry.onDidChange(function (e) { return _this.onModelChanged(); }));
  81819. _this._register(_editor.onDidChangeConfiguration(function (e) {
  81820. var prevIsEnabled = _this._isEnabled;
  81821. _this._isEnabled = _this.isEnabled();
  81822. if (prevIsEnabled !== _this._isEnabled) {
  81823. if (_this._isEnabled) {
  81824. _this.onModelChanged();
  81825. }
  81826. else {
  81827. _this.removeAllDecorations();
  81828. }
  81829. }
  81830. }));
  81831. _this._timeoutTimer = null;
  81832. _this._computePromise = null;
  81833. _this._isEnabled = _this.isEnabled();
  81834. _this.onModelChanged();
  81835. return _this;
  81836. }
  81837. ColorDetector.prototype.isEnabled = function () {
  81838. var model = this._editor.getModel();
  81839. if (!model) {
  81840. return false;
  81841. }
  81842. var languageId = model.getLanguageIdentifier();
  81843. // handle deprecated settings. [languageId].colorDecorators.enable
  81844. var deprecatedConfig = this._configurationService.getValue(languageId.language);
  81845. if (deprecatedConfig) {
  81846. var colorDecorators = deprecatedConfig['colorDecorators']; // deprecatedConfig.valueOf('.colorDecorators.enable');
  81847. if (colorDecorators && colorDecorators['enable'] !== undefined && !colorDecorators['enable']) {
  81848. return colorDecorators['enable'];
  81849. }
  81850. }
  81851. return this._editor.getOption(12 /* colorDecorators */);
  81852. };
  81853. ColorDetector.get = function (editor) {
  81854. return editor.getContribution(this.ID);
  81855. };
  81856. ColorDetector.prototype.dispose = function () {
  81857. this.stop();
  81858. this.removeAllDecorations();
  81859. _super.prototype.dispose.call(this);
  81860. };
  81861. ColorDetector.prototype.onModelChanged = function () {
  81862. var _this = this;
  81863. this.stop();
  81864. if (!this._isEnabled) {
  81865. return;
  81866. }
  81867. var model = this._editor.getModel();
  81868. if (!model || !modes_1.ColorProviderRegistry.has(model)) {
  81869. return;
  81870. }
  81871. this._localToDispose.add(this._editor.onDidChangeModelContent(function (e) {
  81872. if (!_this._timeoutTimer) {
  81873. _this._timeoutTimer = new async_1.TimeoutTimer();
  81874. _this._timeoutTimer.cancelAndSet(function () {
  81875. _this._timeoutTimer = null;
  81876. _this.beginCompute();
  81877. }, ColorDetector.RECOMPUTE_TIME);
  81878. }
  81879. }));
  81880. this.beginCompute();
  81881. };
  81882. ColorDetector.prototype.beginCompute = function () {
  81883. var _this = this;
  81884. this._computePromise = async_1.createCancelablePromise(function (token) {
  81885. var model = _this._editor.getModel();
  81886. if (!model) {
  81887. return Promise.resolve([]);
  81888. }
  81889. return color_2.getColors(model, token);
  81890. });
  81891. this._computePromise.then(function (colorInfos) {
  81892. _this.updateDecorations(colorInfos);
  81893. _this.updateColorDecorators(colorInfos);
  81894. _this._computePromise = null;
  81895. }, errors_1.onUnexpectedError);
  81896. };
  81897. ColorDetector.prototype.stop = function () {
  81898. if (this._timeoutTimer) {
  81899. this._timeoutTimer.cancel();
  81900. this._timeoutTimer = null;
  81901. }
  81902. if (this._computePromise) {
  81903. this._computePromise.cancel();
  81904. this._computePromise = null;
  81905. }
  81906. this._localToDispose.clear();
  81907. };
  81908. ColorDetector.prototype.updateDecorations = function (colorDatas) {
  81909. var _this = this;
  81910. var decorations = colorDatas.map(function (c) { return ({
  81911. range: {
  81912. startLineNumber: c.colorInfo.range.startLineNumber,
  81913. startColumn: c.colorInfo.range.startColumn,
  81914. endLineNumber: c.colorInfo.range.endLineNumber,
  81915. endColumn: c.colorInfo.range.endColumn
  81916. },
  81917. options: textModel_1.ModelDecorationOptions.EMPTY
  81918. }); });
  81919. this._decorationsIds = this._editor.deltaDecorations(this._decorationsIds, decorations);
  81920. this._colorDatas = new Map();
  81921. this._decorationsIds.forEach(function (id, i) { return _this._colorDatas.set(id, colorDatas[i]); });
  81922. };
  81923. ColorDetector.prototype.updateColorDecorators = function (colorData) {
  81924. var _this = this;
  81925. var decorations = [];
  81926. var newDecorationsTypes = {};
  81927. for (var i = 0; i < colorData.length && decorations.length < MAX_DECORATORS; i++) {
  81928. var _a = colorData[i].colorInfo.color, red = _a.red, green = _a.green, blue = _a.blue, alpha = _a.alpha;
  81929. var rgba = new color_1.RGBA(Math.round(red * 255), Math.round(green * 255), Math.round(blue * 255), alpha);
  81930. var subKey = hash_1.hash(rgba).toString(16);
  81931. var color = "rgba(" + rgba.r + ", " + rgba.g + ", " + rgba.b + ", " + rgba.a + ")";
  81932. var key = 'colorBox-' + subKey;
  81933. if (!this._decorationsTypes.has(key) && !newDecorationsTypes[key]) {
  81934. this._codeEditorService.registerDecorationType(key, {
  81935. before: {
  81936. contentText: ' ',
  81937. border: 'solid 0.1em #000',
  81938. margin: '0.1em 0.2em 0 0.2em',
  81939. width: '0.8em',
  81940. height: '0.8em',
  81941. backgroundColor: color
  81942. },
  81943. dark: {
  81944. before: {
  81945. border: 'solid 0.1em #eee'
  81946. }
  81947. }
  81948. }, undefined, this._editor);
  81949. }
  81950. newDecorationsTypes[key] = true;
  81951. decorations.push({
  81952. range: {
  81953. startLineNumber: colorData[i].colorInfo.range.startLineNumber,
  81954. startColumn: colorData[i].colorInfo.range.startColumn,
  81955. endLineNumber: colorData[i].colorInfo.range.endLineNumber,
  81956. endColumn: colorData[i].colorInfo.range.endColumn
  81957. },
  81958. options: this._codeEditorService.resolveDecorationOptions(key, true)
  81959. });
  81960. }
  81961. this._decorationsTypes.forEach(function (subType) {
  81962. if (!newDecorationsTypes[subType]) {
  81963. _this._codeEditorService.removeDecorationType(subType);
  81964. }
  81965. });
  81966. this._colorDecoratorIds = this._editor.deltaDecorations(this._colorDecoratorIds, decorations);
  81967. };
  81968. ColorDetector.prototype.removeAllDecorations = function () {
  81969. var _this = this;
  81970. this._decorationsIds = this._editor.deltaDecorations(this._decorationsIds, []);
  81971. this._colorDecoratorIds = this._editor.deltaDecorations(this._colorDecoratorIds, []);
  81972. this._decorationsTypes.forEach(function (subType) {
  81973. _this._codeEditorService.removeDecorationType(subType);
  81974. });
  81975. };
  81976. ColorDetector.prototype.getColorData = function (position) {
  81977. var _this = this;
  81978. var model = this._editor.getModel();
  81979. if (!model) {
  81980. return null;
  81981. }
  81982. var decorations = model
  81983. .getDecorationsInRange(range_1.Range.fromPositions(position, position))
  81984. .filter(function (d) { return _this._colorDatas.has(d.id); });
  81985. if (decorations.length === 0) {
  81986. return null;
  81987. }
  81988. return this._colorDatas.get(decorations[0].id);
  81989. };
  81990. ColorDetector.ID = 'editor.contrib.colorDetector';
  81991. ColorDetector.RECOMPUTE_TIME = 1000; // ms
  81992. ColorDetector = __decorate([
  81993. __param(1, codeEditorService_1.ICodeEditorService),
  81994. __param(2, configuration_1.IConfigurationService)
  81995. ], ColorDetector);
  81996. return ColorDetector;
  81997. }(lifecycle_1.Disposable));
  81998. exports.ColorDetector = ColorDetector;
  81999. editorExtensions_1.registerEditorContribution(ColorDetector.ID, ColorDetector);
  82000. });
  82001. /*---------------------------------------------------------------------------------------------
  82002. * Copyright (c) Microsoft Corporation. All rights reserved.
  82003. * Licensed under the MIT License. See License.txt in the project root for license information.
  82004. *--------------------------------------------------------------------------------------------*/
  82005. define(__m[530/*vs/editor/contrib/comment/comment*/], __M([0/*require*/,1/*exports*/,434/*vs/nls!vs/editor/contrib/comment/comment*/,36/*vs/base/common/keyCodes*/,12/*vs/editor/browser/editorExtensions*/,23/*vs/editor/common/editorContextKeys*/,196/*vs/editor/contrib/comment/blockCommentCommand*/,376/*vs/editor/contrib/comment/lineCommentCommand*/]), function (require, exports, nls, keyCodes_1, editorExtensions_1, editorContextKeys_1, blockCommentCommand_1, lineCommentCommand_1) {
  82006. "use strict";
  82007. Object.defineProperty(exports, "__esModule", { value: true });
  82008. var CommentLineAction = /** @class */ (function (_super) {
  82009. __extends(CommentLineAction, _super);
  82010. function CommentLineAction(type, opts) {
  82011. var _this = _super.call(this, opts) || this;
  82012. _this._type = type;
  82013. return _this;
  82014. }
  82015. CommentLineAction.prototype.run = function (accessor, editor) {
  82016. if (!editor.hasModel()) {
  82017. return;
  82018. }
  82019. var model = editor.getModel();
  82020. var commands = [];
  82021. var selections = editor.getSelections();
  82022. var modelOptions = model.getOptions();
  82023. var commentsOptions = editor.getOption(13 /* comments */);
  82024. for (var _i = 0, selections_1 = selections; _i < selections_1.length; _i++) {
  82025. var selection = selections_1[_i];
  82026. commands.push(new lineCommentCommand_1.LineCommentCommand(selection, modelOptions.tabSize, this._type, commentsOptions.insertSpace));
  82027. }
  82028. editor.pushUndoStop();
  82029. editor.executeCommands(this.id, commands);
  82030. editor.pushUndoStop();
  82031. };
  82032. return CommentLineAction;
  82033. }(editorExtensions_1.EditorAction));
  82034. var ToggleCommentLineAction = /** @class */ (function (_super) {
  82035. __extends(ToggleCommentLineAction, _super);
  82036. function ToggleCommentLineAction() {
  82037. return _super.call(this, 0 /* Toggle */, {
  82038. id: 'editor.action.commentLine',
  82039. label: nls.localize(0, null),
  82040. alias: 'Toggle Line Comment',
  82041. precondition: editorContextKeys_1.EditorContextKeys.writable,
  82042. kbOpts: {
  82043. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  82044. primary: 2048 /* CtrlCmd */ | 85 /* US_SLASH */,
  82045. weight: 100 /* EditorContrib */
  82046. },
  82047. menuOpts: {
  82048. menuId: 17 /* MenubarEditMenu */,
  82049. group: '5_insert',
  82050. title: nls.localize(1, null),
  82051. order: 1
  82052. }
  82053. }) || this;
  82054. }
  82055. return ToggleCommentLineAction;
  82056. }(CommentLineAction));
  82057. var AddLineCommentAction = /** @class */ (function (_super) {
  82058. __extends(AddLineCommentAction, _super);
  82059. function AddLineCommentAction() {
  82060. return _super.call(this, 1 /* ForceAdd */, {
  82061. id: 'editor.action.addCommentLine',
  82062. label: nls.localize(2, null),
  82063. alias: 'Add Line Comment',
  82064. precondition: editorContextKeys_1.EditorContextKeys.writable,
  82065. kbOpts: {
  82066. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  82067. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 33 /* KEY_C */),
  82068. weight: 100 /* EditorContrib */
  82069. }
  82070. }) || this;
  82071. }
  82072. return AddLineCommentAction;
  82073. }(CommentLineAction));
  82074. var RemoveLineCommentAction = /** @class */ (function (_super) {
  82075. __extends(RemoveLineCommentAction, _super);
  82076. function RemoveLineCommentAction() {
  82077. return _super.call(this, 2 /* ForceRemove */, {
  82078. id: 'editor.action.removeCommentLine',
  82079. label: nls.localize(3, null),
  82080. alias: 'Remove Line Comment',
  82081. precondition: editorContextKeys_1.EditorContextKeys.writable,
  82082. kbOpts: {
  82083. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  82084. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 51 /* KEY_U */),
  82085. weight: 100 /* EditorContrib */
  82086. }
  82087. }) || this;
  82088. }
  82089. return RemoveLineCommentAction;
  82090. }(CommentLineAction));
  82091. var BlockCommentAction = /** @class */ (function (_super) {
  82092. __extends(BlockCommentAction, _super);
  82093. function BlockCommentAction() {
  82094. return _super.call(this, {
  82095. id: 'editor.action.blockComment',
  82096. label: nls.localize(4, null),
  82097. alias: 'Toggle Block Comment',
  82098. precondition: editorContextKeys_1.EditorContextKeys.writable,
  82099. kbOpts: {
  82100. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  82101. primary: 1024 /* Shift */ | 512 /* Alt */ | 31 /* KEY_A */,
  82102. linux: { primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 31 /* KEY_A */ },
  82103. weight: 100 /* EditorContrib */
  82104. },
  82105. menuOpts: {
  82106. menuId: 17 /* MenubarEditMenu */,
  82107. group: '5_insert',
  82108. title: nls.localize(5, null),
  82109. order: 2
  82110. }
  82111. }) || this;
  82112. }
  82113. BlockCommentAction.prototype.run = function (accessor, editor) {
  82114. if (!editor.hasModel()) {
  82115. return;
  82116. }
  82117. var commentsOptions = editor.getOption(13 /* comments */);
  82118. var commands = [];
  82119. var selections = editor.getSelections();
  82120. for (var _i = 0, selections_2 = selections; _i < selections_2.length; _i++) {
  82121. var selection = selections_2[_i];
  82122. commands.push(new blockCommentCommand_1.BlockCommentCommand(selection, commentsOptions.insertSpace));
  82123. }
  82124. editor.pushUndoStop();
  82125. editor.executeCommands(this.id, commands);
  82126. editor.pushUndoStop();
  82127. };
  82128. return BlockCommentAction;
  82129. }(editorExtensions_1.EditorAction));
  82130. editorExtensions_1.registerEditorAction(ToggleCommentLineAction);
  82131. editorExtensions_1.registerEditorAction(AddLineCommentAction);
  82132. editorExtensions_1.registerEditorAction(RemoveLineCommentAction);
  82133. editorExtensions_1.registerEditorAction(BlockCommentAction);
  82134. });
  82135. /*---------------------------------------------------------------------------------------------
  82136. * Copyright (c) Microsoft Corporation. All rights reserved.
  82137. * Licensed under the MIT License. See License.txt in the project root for license information.
  82138. *--------------------------------------------------------------------------------------------*/
  82139. define(__m[531/*vs/editor/contrib/contextmenu/contextmenu*/], __M([0/*require*/,1/*exports*/,435/*vs/nls!vs/editor/contrib/contextmenu/contextmenu*/,6/*vs/base/browser/dom*/,70/*vs/base/browser/ui/actionbar/actionbar*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,23/*vs/editor/common/editorContextKeys*/,65/*vs/platform/actions/common/actions*/,18/*vs/platform/contextkey/common/contextkey*/,66/*vs/platform/contextview/browser/contextView*/,34/*vs/platform/keybinding/common/keybinding*/,405/*vs/base/browser/contextmenu*/]), function (require, exports, nls, dom, actionbar_1, lifecycle_1, editorExtensions_1, editorContextKeys_1, actions_1, contextkey_1, contextView_1, keybinding_1, contextmenu_1) {
  82140. "use strict";
  82141. Object.defineProperty(exports, "__esModule", { value: true });
  82142. var ContextMenuController = /** @class */ (function () {
  82143. function ContextMenuController(editor, _contextMenuService, _contextViewService, _contextKeyService, _keybindingService, _menuService) {
  82144. var _this = this;
  82145. this._contextMenuService = _contextMenuService;
  82146. this._contextViewService = _contextViewService;
  82147. this._contextKeyService = _contextKeyService;
  82148. this._keybindingService = _keybindingService;
  82149. this._menuService = _menuService;
  82150. this._toDispose = new lifecycle_1.DisposableStore();
  82151. this._contextMenuIsBeingShownCount = 0;
  82152. this._editor = editor;
  82153. this._toDispose.add(this._editor.onContextMenu(function (e) { return _this._onContextMenu(e); }));
  82154. this._toDispose.add(this._editor.onMouseWheel(function (e) {
  82155. if (_this._contextMenuIsBeingShownCount > 0) {
  82156. _this._contextViewService.hideContextView();
  82157. }
  82158. }));
  82159. this._toDispose.add(this._editor.onKeyDown(function (e) {
  82160. if (e.keyCode === 58 /* ContextMenu */) {
  82161. // Chrome is funny like that
  82162. e.preventDefault();
  82163. e.stopPropagation();
  82164. _this.showContextMenu();
  82165. }
  82166. }));
  82167. }
  82168. ContextMenuController.get = function (editor) {
  82169. return editor.getContribution(ContextMenuController.ID);
  82170. };
  82171. ContextMenuController.prototype._onContextMenu = function (e) {
  82172. if (!this._editor.hasModel()) {
  82173. return;
  82174. }
  82175. if (!this._editor.getOption(14 /* contextmenu */)) {
  82176. this._editor.focus();
  82177. // Ensure the cursor is at the position of the mouse click
  82178. if (e.target.position && !this._editor.getSelection().containsPosition(e.target.position)) {
  82179. this._editor.setPosition(e.target.position);
  82180. }
  82181. return; // Context menu is turned off through configuration
  82182. }
  82183. if (e.target.type === 12 /* OVERLAY_WIDGET */) {
  82184. return; // allow native menu on widgets to support right click on input field for example in find
  82185. }
  82186. e.event.preventDefault();
  82187. if (e.target.type !== 6 /* CONTENT_TEXT */ && e.target.type !== 7 /* CONTENT_EMPTY */ && e.target.type !== 1 /* TEXTAREA */) {
  82188. return; // only support mouse click into text or native context menu key for now
  82189. }
  82190. // Ensure the editor gets focus if it hasn't, so the right events are being sent to other contributions
  82191. this._editor.focus();
  82192. // Ensure the cursor is at the position of the mouse click
  82193. if (e.target.position) {
  82194. var hasSelectionAtPosition = false;
  82195. for (var _i = 0, _a = this._editor.getSelections(); _i < _a.length; _i++) {
  82196. var selection = _a[_i];
  82197. if (selection.containsPosition(e.target.position)) {
  82198. hasSelectionAtPosition = true;
  82199. break;
  82200. }
  82201. }
  82202. if (!hasSelectionAtPosition) {
  82203. this._editor.setPosition(e.target.position);
  82204. }
  82205. }
  82206. // Unless the user triggerd the context menu through Shift+F10, use the mouse position as menu position
  82207. var anchor = null;
  82208. if (e.target.type !== 1 /* TEXTAREA */) {
  82209. anchor = { x: e.event.posx - 1, width: 2, y: e.event.posy - 1, height: 2 };
  82210. }
  82211. // Show the context menu
  82212. this.showContextMenu(anchor);
  82213. };
  82214. ContextMenuController.prototype.showContextMenu = function (anchor) {
  82215. if (!this._editor.getOption(14 /* contextmenu */)) {
  82216. return; // Context menu is turned off through configuration
  82217. }
  82218. if (!this._editor.hasModel()) {
  82219. return;
  82220. }
  82221. if (!this._contextMenuService) {
  82222. this._editor.focus();
  82223. return; // We need the context menu service to function
  82224. }
  82225. // Find actions available for menu
  82226. var menuActions = this._getMenuActions(this._editor.getModel(), 7 /* EditorContext */);
  82227. // Show menu if we have actions to show
  82228. if (menuActions.length > 0) {
  82229. this._doShowContextMenu(menuActions, anchor);
  82230. }
  82231. };
  82232. ContextMenuController.prototype._getMenuActions = function (model, menuId) {
  82233. var result = [];
  82234. // get menu groups
  82235. var menu = this._menuService.createMenu(menuId, this._contextKeyService);
  82236. var groups = menu.getActions({ arg: model.uri });
  82237. menu.dispose();
  82238. // translate them into other actions
  82239. for (var _i = 0, groups_1 = groups; _i < groups_1.length; _i++) {
  82240. var group = groups_1[_i];
  82241. var actions = group[1];
  82242. var addedItems = 0;
  82243. for (var _a = 0, actions_2 = actions; _a < actions_2.length; _a++) {
  82244. var action = actions_2[_a];
  82245. if (action instanceof actions_1.SubmenuItemAction) {
  82246. var subActions = this._getMenuActions(model, action.item.submenu);
  82247. if (subActions.length > 0) {
  82248. result.push(new contextmenu_1.ContextSubMenu(action.label, subActions));
  82249. addedItems++;
  82250. }
  82251. }
  82252. else {
  82253. result.push(action);
  82254. addedItems++;
  82255. }
  82256. }
  82257. if (addedItems) {
  82258. result.push(new actionbar_1.Separator());
  82259. }
  82260. }
  82261. if (result.length) {
  82262. result.pop(); // remove last separator
  82263. }
  82264. return result;
  82265. };
  82266. ContextMenuController.prototype._doShowContextMenu = function (actions, anchor) {
  82267. var _this = this;
  82268. if (anchor === void 0) { anchor = null; }
  82269. if (!this._editor.hasModel()) {
  82270. return;
  82271. }
  82272. // Disable hover
  82273. var oldHoverSetting = this._editor.getOption(44 /* hover */);
  82274. this._editor.updateOptions({
  82275. hover: {
  82276. enabled: false
  82277. }
  82278. });
  82279. if (!anchor) {
  82280. // Ensure selection is visible
  82281. this._editor.revealPosition(this._editor.getPosition(), 1 /* Immediate */);
  82282. this._editor.render();
  82283. var cursorCoords = this._editor.getScrolledVisiblePosition(this._editor.getPosition());
  82284. // Translate to absolute editor position
  82285. var editorCoords = dom.getDomNodePagePosition(this._editor.getDomNode());
  82286. var posx = editorCoords.left + cursorCoords.left;
  82287. var posy = editorCoords.top + cursorCoords.top + cursorCoords.height;
  82288. anchor = { x: posx, y: posy };
  82289. }
  82290. // Show menu
  82291. this._contextMenuIsBeingShownCount++;
  82292. this._contextMenuService.showContextMenu({
  82293. getAnchor: function () { return anchor; },
  82294. getActions: function () { return actions; },
  82295. getActionViewItem: function (action) {
  82296. var keybinding = _this._keybindingFor(action);
  82297. if (keybinding) {
  82298. return new actionbar_1.ActionViewItem(action, action, { label: true, keybinding: keybinding.getLabel(), isMenu: true });
  82299. }
  82300. var customActionViewItem = action;
  82301. if (typeof customActionViewItem.getActionViewItem === 'function') {
  82302. return customActionViewItem.getActionViewItem();
  82303. }
  82304. return new actionbar_1.ActionViewItem(action, action, { icon: true, label: true, isMenu: true });
  82305. },
  82306. getKeyBinding: function (action) {
  82307. return _this._keybindingFor(action);
  82308. },
  82309. onHide: function (wasCancelled) {
  82310. _this._contextMenuIsBeingShownCount--;
  82311. _this._editor.focus();
  82312. _this._editor.updateOptions({
  82313. hover: oldHoverSetting
  82314. });
  82315. }
  82316. });
  82317. };
  82318. ContextMenuController.prototype._keybindingFor = function (action) {
  82319. return this._keybindingService.lookupKeybinding(action.id);
  82320. };
  82321. ContextMenuController.prototype.dispose = function () {
  82322. if (this._contextMenuIsBeingShownCount > 0) {
  82323. this._contextViewService.hideContextView();
  82324. }
  82325. this._toDispose.dispose();
  82326. };
  82327. ContextMenuController.ID = 'editor.contrib.contextmenu';
  82328. ContextMenuController = __decorate([
  82329. __param(1, contextView_1.IContextMenuService),
  82330. __param(2, contextView_1.IContextViewService),
  82331. __param(3, contextkey_1.IContextKeyService),
  82332. __param(4, keybinding_1.IKeybindingService),
  82333. __param(5, actions_1.IMenuService)
  82334. ], ContextMenuController);
  82335. return ContextMenuController;
  82336. }());
  82337. exports.ContextMenuController = ContextMenuController;
  82338. var ShowContextMenu = /** @class */ (function (_super) {
  82339. __extends(ShowContextMenu, _super);
  82340. function ShowContextMenu() {
  82341. return _super.call(this, {
  82342. id: 'editor.action.showContextMenu',
  82343. label: nls.localize(0, null),
  82344. alias: 'Show Editor Context Menu',
  82345. precondition: undefined,
  82346. kbOpts: {
  82347. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  82348. primary: 1024 /* Shift */ | 68 /* F10 */,
  82349. weight: 100 /* EditorContrib */
  82350. }
  82351. }) || this;
  82352. }
  82353. ShowContextMenu.prototype.run = function (accessor, editor) {
  82354. var contribution = ContextMenuController.get(editor);
  82355. contribution.showContextMenu();
  82356. };
  82357. return ShowContextMenu;
  82358. }(editorExtensions_1.EditorAction));
  82359. editorExtensions_1.registerEditorContribution(ContextMenuController.ID, ContextMenuController);
  82360. editorExtensions_1.registerEditorAction(ShowContextMenu);
  82361. });
  82362. /*---------------------------------------------------------------------------------------------
  82363. * Copyright (c) Microsoft Corporation. All rights reserved.
  82364. * Licensed under the MIT License. See License.txt in the project root for license information.
  82365. *--------------------------------------------------------------------------------------------*/
  82366. define(__m[532/*vs/editor/contrib/cursorUndo/cursorUndo*/], __M([0/*require*/,1/*exports*/,436/*vs/nls!vs/editor/contrib/cursorUndo/cursorUndo*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,23/*vs/editor/common/editorContextKeys*/]), function (require, exports, nls, lifecycle_1, editorExtensions_1, editorContextKeys_1) {
  82367. "use strict";
  82368. Object.defineProperty(exports, "__esModule", { value: true });
  82369. var CursorState = /** @class */ (function () {
  82370. function CursorState(selections) {
  82371. this.selections = selections;
  82372. }
  82373. CursorState.prototype.equals = function (other) {
  82374. var thisLen = this.selections.length;
  82375. var otherLen = other.selections.length;
  82376. if (thisLen !== otherLen) {
  82377. return false;
  82378. }
  82379. for (var i = 0; i < thisLen; i++) {
  82380. if (!this.selections[i].equalsSelection(other.selections[i])) {
  82381. return false;
  82382. }
  82383. }
  82384. return true;
  82385. };
  82386. return CursorState;
  82387. }());
  82388. var StackElement = /** @class */ (function () {
  82389. function StackElement(cursorState, scrollTop, scrollLeft) {
  82390. this.cursorState = cursorState;
  82391. this.scrollTop = scrollTop;
  82392. this.scrollLeft = scrollLeft;
  82393. }
  82394. return StackElement;
  82395. }());
  82396. var CursorUndoRedoController = /** @class */ (function (_super) {
  82397. __extends(CursorUndoRedoController, _super);
  82398. function CursorUndoRedoController(editor) {
  82399. var _this = _super.call(this) || this;
  82400. _this._editor = editor;
  82401. _this._isCursorUndoRedo = false;
  82402. _this._undoStack = [];
  82403. _this._redoStack = [];
  82404. _this._register(editor.onDidChangeModel(function (e) {
  82405. _this._undoStack = [];
  82406. _this._redoStack = [];
  82407. }));
  82408. _this._register(editor.onDidChangeModelContent(function (e) {
  82409. _this._undoStack = [];
  82410. _this._redoStack = [];
  82411. }));
  82412. _this._register(editor.onDidChangeCursorSelection(function (e) {
  82413. if (_this._isCursorUndoRedo) {
  82414. return;
  82415. }
  82416. if (!e.oldSelections) {
  82417. return;
  82418. }
  82419. if (e.oldModelVersionId !== e.modelVersionId) {
  82420. return;
  82421. }
  82422. var prevState = new CursorState(e.oldSelections);
  82423. var isEqualToLastUndoStack = (_this._undoStack.length > 0 && _this._undoStack[_this._undoStack.length - 1].cursorState.equals(prevState));
  82424. if (!isEqualToLastUndoStack) {
  82425. _this._undoStack.push(new StackElement(prevState, editor.getScrollTop(), editor.getScrollLeft()));
  82426. _this._redoStack = [];
  82427. if (_this._undoStack.length > 50) {
  82428. // keep the cursor undo stack bounded
  82429. _this._undoStack.shift();
  82430. }
  82431. }
  82432. }));
  82433. return _this;
  82434. }
  82435. CursorUndoRedoController.get = function (editor) {
  82436. return editor.getContribution(CursorUndoRedoController.ID);
  82437. };
  82438. CursorUndoRedoController.prototype.cursorUndo = function () {
  82439. if (!this._editor.hasModel() || this._undoStack.length === 0) {
  82440. return;
  82441. }
  82442. this._redoStack.push(new StackElement(new CursorState(this._editor.getSelections()), this._editor.getScrollTop(), this._editor.getScrollLeft()));
  82443. this._applyState(this._undoStack.pop());
  82444. };
  82445. CursorUndoRedoController.prototype.cursorRedo = function () {
  82446. if (!this._editor.hasModel() || this._redoStack.length === 0) {
  82447. return;
  82448. }
  82449. this._undoStack.push(new StackElement(new CursorState(this._editor.getSelections()), this._editor.getScrollTop(), this._editor.getScrollLeft()));
  82450. this._applyState(this._redoStack.pop());
  82451. };
  82452. CursorUndoRedoController.prototype._applyState = function (stackElement) {
  82453. this._isCursorUndoRedo = true;
  82454. this._editor.setSelections(stackElement.cursorState.selections);
  82455. this._editor.setScrollPosition({
  82456. scrollTop: stackElement.scrollTop,
  82457. scrollLeft: stackElement.scrollLeft
  82458. });
  82459. this._isCursorUndoRedo = false;
  82460. };
  82461. CursorUndoRedoController.ID = 'editor.contrib.cursorUndoRedoController';
  82462. return CursorUndoRedoController;
  82463. }(lifecycle_1.Disposable));
  82464. exports.CursorUndoRedoController = CursorUndoRedoController;
  82465. var CursorUndo = /** @class */ (function (_super) {
  82466. __extends(CursorUndo, _super);
  82467. function CursorUndo() {
  82468. return _super.call(this, {
  82469. id: 'cursorUndo',
  82470. label: nls.localize(0, null),
  82471. alias: 'Cursor Undo',
  82472. precondition: undefined,
  82473. kbOpts: {
  82474. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  82475. primary: 2048 /* CtrlCmd */ | 51 /* KEY_U */,
  82476. weight: 100 /* EditorContrib */
  82477. }
  82478. }) || this;
  82479. }
  82480. CursorUndo.prototype.run = function (accessor, editor, args) {
  82481. CursorUndoRedoController.get(editor).cursorUndo();
  82482. };
  82483. return CursorUndo;
  82484. }(editorExtensions_1.EditorAction));
  82485. exports.CursorUndo = CursorUndo;
  82486. var CursorRedo = /** @class */ (function (_super) {
  82487. __extends(CursorRedo, _super);
  82488. function CursorRedo() {
  82489. return _super.call(this, {
  82490. id: 'cursorRedo',
  82491. label: nls.localize(1, null),
  82492. alias: 'Cursor Redo',
  82493. precondition: undefined
  82494. }) || this;
  82495. }
  82496. CursorRedo.prototype.run = function (accessor, editor, args) {
  82497. CursorUndoRedoController.get(editor).cursorRedo();
  82498. };
  82499. return CursorRedo;
  82500. }(editorExtensions_1.EditorAction));
  82501. exports.CursorRedo = CursorRedo;
  82502. editorExtensions_1.registerEditorContribution(CursorUndoRedoController.ID, CursorUndoRedoController);
  82503. editorExtensions_1.registerEditorAction(CursorUndo);
  82504. editorExtensions_1.registerEditorAction(CursorRedo);
  82505. });
  82506. /*---------------------------------------------------------------------------------------------
  82507. * Copyright (c) Microsoft Corporation. All rights reserved.
  82508. * Licensed under the MIT License. See License.txt in the project root for license information.
  82509. *--------------------------------------------------------------------------------------------*/
  82510. define(__m[533/*vs/editor/contrib/dnd/dnd*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,12/*vs/editor/browser/editorExtensions*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,377/*vs/editor/contrib/dnd/dragAndDropCommand*/,30/*vs/editor/common/model/textModel*/,307/*vs/css!vs/editor/contrib/dnd/dnd*/]), function (require, exports, lifecycle_1, platform_1, editorExtensions_1, position_1, range_1, selection_1, dragAndDropCommand_1, textModel_1) {
  82511. "use strict";
  82512. Object.defineProperty(exports, "__esModule", { value: true });
  82513. function hasTriggerModifier(e) {
  82514. if (platform_1.isMacintosh) {
  82515. return e.altKey;
  82516. }
  82517. else {
  82518. return e.ctrlKey;
  82519. }
  82520. }
  82521. var DragAndDropController = /** @class */ (function (_super) {
  82522. __extends(DragAndDropController, _super);
  82523. function DragAndDropController(editor) {
  82524. var _this = _super.call(this) || this;
  82525. _this._editor = editor;
  82526. _this._register(_this._editor.onMouseDown(function (e) { return _this._onEditorMouseDown(e); }));
  82527. _this._register(_this._editor.onMouseUp(function (e) { return _this._onEditorMouseUp(e); }));
  82528. _this._register(_this._editor.onMouseDrag(function (e) { return _this._onEditorMouseDrag(e); }));
  82529. _this._register(_this._editor.onMouseDrop(function (e) { return _this._onEditorMouseDrop(e); }));
  82530. _this._register(_this._editor.onKeyDown(function (e) { return _this.onEditorKeyDown(e); }));
  82531. _this._register(_this._editor.onKeyUp(function (e) { return _this.onEditorKeyUp(e); }));
  82532. _this._register(_this._editor.onDidBlurEditorWidget(function () { return _this.onEditorBlur(); }));
  82533. _this._dndDecorationIds = [];
  82534. _this._mouseDown = false;
  82535. _this._modifierPressed = false;
  82536. _this._dragSelection = null;
  82537. return _this;
  82538. }
  82539. DragAndDropController.prototype.onEditorBlur = function () {
  82540. this._removeDecoration();
  82541. this._dragSelection = null;
  82542. this._mouseDown = false;
  82543. this._modifierPressed = false;
  82544. };
  82545. DragAndDropController.prototype.onEditorKeyDown = function (e) {
  82546. if (!this._editor.getOption(24 /* dragAndDrop */)) {
  82547. return;
  82548. }
  82549. if (hasTriggerModifier(e)) {
  82550. this._modifierPressed = true;
  82551. }
  82552. if (this._mouseDown && hasTriggerModifier(e)) {
  82553. this._editor.updateOptions({
  82554. mouseStyle: 'copy'
  82555. });
  82556. }
  82557. };
  82558. DragAndDropController.prototype.onEditorKeyUp = function (e) {
  82559. if (!this._editor.getOption(24 /* dragAndDrop */)) {
  82560. return;
  82561. }
  82562. if (hasTriggerModifier(e)) {
  82563. this._modifierPressed = false;
  82564. }
  82565. if (this._mouseDown && e.keyCode === DragAndDropController.TRIGGER_KEY_VALUE) {
  82566. this._editor.updateOptions({
  82567. mouseStyle: 'default'
  82568. });
  82569. }
  82570. };
  82571. DragAndDropController.prototype._onEditorMouseDown = function (mouseEvent) {
  82572. this._mouseDown = true;
  82573. };
  82574. DragAndDropController.prototype._onEditorMouseUp = function (mouseEvent) {
  82575. this._mouseDown = false;
  82576. // Whenever users release the mouse, the drag and drop operation should finish and the cursor should revert to text.
  82577. this._editor.updateOptions({
  82578. mouseStyle: 'text'
  82579. });
  82580. };
  82581. DragAndDropController.prototype._onEditorMouseDrag = function (mouseEvent) {
  82582. var target = mouseEvent.target;
  82583. if (this._dragSelection === null) {
  82584. var selections = this._editor.getSelections() || [];
  82585. var possibleSelections = selections.filter(function (selection) { return target.position && selection.containsPosition(target.position); });
  82586. if (possibleSelections.length === 1) {
  82587. this._dragSelection = possibleSelections[0];
  82588. }
  82589. else {
  82590. return;
  82591. }
  82592. }
  82593. if (hasTriggerModifier(mouseEvent.event)) {
  82594. this._editor.updateOptions({
  82595. mouseStyle: 'copy'
  82596. });
  82597. }
  82598. else {
  82599. this._editor.updateOptions({
  82600. mouseStyle: 'default'
  82601. });
  82602. }
  82603. if (target.position) {
  82604. if (this._dragSelection.containsPosition(target.position)) {
  82605. this._removeDecoration();
  82606. }
  82607. else {
  82608. this.showAt(target.position);
  82609. }
  82610. }
  82611. };
  82612. DragAndDropController.prototype._onEditorMouseDrop = function (mouseEvent) {
  82613. if (mouseEvent.target && (this._hitContent(mouseEvent.target) || this._hitMargin(mouseEvent.target)) && mouseEvent.target.position) {
  82614. var newCursorPosition_1 = new position_1.Position(mouseEvent.target.position.lineNumber, mouseEvent.target.position.column);
  82615. if (this._dragSelection === null) {
  82616. var newSelections = null;
  82617. if (mouseEvent.event.shiftKey) {
  82618. var primarySelection = this._editor.getSelection();
  82619. if (primarySelection) {
  82620. var selectionStartLineNumber = primarySelection.selectionStartLineNumber, selectionStartColumn = primarySelection.selectionStartColumn;
  82621. newSelections = [new selection_1.Selection(selectionStartLineNumber, selectionStartColumn, newCursorPosition_1.lineNumber, newCursorPosition_1.column)];
  82622. }
  82623. }
  82624. else {
  82625. newSelections = (this._editor.getSelections() || []).map(function (selection) {
  82626. if (selection.containsPosition(newCursorPosition_1)) {
  82627. return new selection_1.Selection(newCursorPosition_1.lineNumber, newCursorPosition_1.column, newCursorPosition_1.lineNumber, newCursorPosition_1.column);
  82628. }
  82629. else {
  82630. return selection;
  82631. }
  82632. });
  82633. }
  82634. // Use `mouse` as the source instead of `api`.
  82635. this._editor.setSelections(newSelections || [], 'mouse');
  82636. }
  82637. else if (!this._dragSelection.containsPosition(newCursorPosition_1) ||
  82638. ((hasTriggerModifier(mouseEvent.event) ||
  82639. this._modifierPressed) && (this._dragSelection.getEndPosition().equals(newCursorPosition_1) || this._dragSelection.getStartPosition().equals(newCursorPosition_1)) // we allow users to paste content beside the selection
  82640. )) {
  82641. this._editor.pushUndoStop();
  82642. this._editor.executeCommand(DragAndDropController.ID, new dragAndDropCommand_1.DragAndDropCommand(this._dragSelection, newCursorPosition_1, hasTriggerModifier(mouseEvent.event) || this._modifierPressed));
  82643. this._editor.pushUndoStop();
  82644. }
  82645. }
  82646. this._editor.updateOptions({
  82647. mouseStyle: 'text'
  82648. });
  82649. this._removeDecoration();
  82650. this._dragSelection = null;
  82651. this._mouseDown = false;
  82652. };
  82653. DragAndDropController.prototype.showAt = function (position) {
  82654. var newDecorations = [{
  82655. range: new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column),
  82656. options: DragAndDropController._DECORATION_OPTIONS
  82657. }];
  82658. this._dndDecorationIds = this._editor.deltaDecorations(this._dndDecorationIds, newDecorations);
  82659. this._editor.revealPosition(position, 1 /* Immediate */);
  82660. };
  82661. DragAndDropController.prototype._removeDecoration = function () {
  82662. this._dndDecorationIds = this._editor.deltaDecorations(this._dndDecorationIds, []);
  82663. };
  82664. DragAndDropController.prototype._hitContent = function (target) {
  82665. return target.type === 6 /* CONTENT_TEXT */ ||
  82666. target.type === 7 /* CONTENT_EMPTY */;
  82667. };
  82668. DragAndDropController.prototype._hitMargin = function (target) {
  82669. return target.type === 2 /* GUTTER_GLYPH_MARGIN */ ||
  82670. target.type === 3 /* GUTTER_LINE_NUMBERS */ ||
  82671. target.type === 4 /* GUTTER_LINE_DECORATIONS */;
  82672. };
  82673. DragAndDropController.prototype.dispose = function () {
  82674. this._removeDecoration();
  82675. this._dragSelection = null;
  82676. this._mouseDown = false;
  82677. this._modifierPressed = false;
  82678. _super.prototype.dispose.call(this);
  82679. };
  82680. DragAndDropController.ID = 'editor.contrib.dragAndDrop';
  82681. DragAndDropController.TRIGGER_KEY_VALUE = platform_1.isMacintosh ? 6 /* Alt */ : 5 /* Ctrl */;
  82682. DragAndDropController._DECORATION_OPTIONS = textModel_1.ModelDecorationOptions.register({
  82683. className: 'dnd-target'
  82684. });
  82685. return DragAndDropController;
  82686. }(lifecycle_1.Disposable));
  82687. exports.DragAndDropController = DragAndDropController;
  82688. editorExtensions_1.registerEditorContribution(DragAndDropController.ID, DragAndDropController);
  82689. });
  82690. /*---------------------------------------------------------------------------------------------
  82691. * Copyright (c) Microsoft Corporation. All rights reserved.
  82692. * Licensed under the MIT License. See License.txt in the project root for license information.
  82693. *--------------------------------------------------------------------------------------------*/
  82694. define(__m[534/*vs/editor/contrib/fontZoom/fontZoom*/], __M([0/*require*/,1/*exports*/,441/*vs/nls!vs/editor/contrib/fontZoom/fontZoom*/,12/*vs/editor/browser/editorExtensions*/,105/*vs/editor/common/config/editorZoom*/]), function (require, exports, nls, editorExtensions_1, editorZoom_1) {
  82695. "use strict";
  82696. Object.defineProperty(exports, "__esModule", { value: true });
  82697. var EditorFontZoomIn = /** @class */ (function (_super) {
  82698. __extends(EditorFontZoomIn, _super);
  82699. function EditorFontZoomIn() {
  82700. return _super.call(this, {
  82701. id: 'editor.action.fontZoomIn',
  82702. label: nls.localize(0, null),
  82703. alias: 'Editor Font Zoom In',
  82704. precondition: undefined
  82705. }) || this;
  82706. }
  82707. EditorFontZoomIn.prototype.run = function (accessor, editor) {
  82708. editorZoom_1.EditorZoom.setZoomLevel(editorZoom_1.EditorZoom.getZoomLevel() + 1);
  82709. };
  82710. return EditorFontZoomIn;
  82711. }(editorExtensions_1.EditorAction));
  82712. var EditorFontZoomOut = /** @class */ (function (_super) {
  82713. __extends(EditorFontZoomOut, _super);
  82714. function EditorFontZoomOut() {
  82715. return _super.call(this, {
  82716. id: 'editor.action.fontZoomOut',
  82717. label: nls.localize(1, null),
  82718. alias: 'Editor Font Zoom Out',
  82719. precondition: undefined
  82720. }) || this;
  82721. }
  82722. EditorFontZoomOut.prototype.run = function (accessor, editor) {
  82723. editorZoom_1.EditorZoom.setZoomLevel(editorZoom_1.EditorZoom.getZoomLevel() - 1);
  82724. };
  82725. return EditorFontZoomOut;
  82726. }(editorExtensions_1.EditorAction));
  82727. var EditorFontZoomReset = /** @class */ (function (_super) {
  82728. __extends(EditorFontZoomReset, _super);
  82729. function EditorFontZoomReset() {
  82730. return _super.call(this, {
  82731. id: 'editor.action.fontZoomReset',
  82732. label: nls.localize(2, null),
  82733. alias: 'Editor Font Zoom Reset',
  82734. precondition: undefined
  82735. }) || this;
  82736. }
  82737. EditorFontZoomReset.prototype.run = function (accessor, editor) {
  82738. editorZoom_1.EditorZoom.setZoomLevel(0);
  82739. };
  82740. return EditorFontZoomReset;
  82741. }(editorExtensions_1.EditorAction));
  82742. editorExtensions_1.registerEditorAction(EditorFontZoomIn);
  82743. editorExtensions_1.registerEditorAction(EditorFontZoomOut);
  82744. editorExtensions_1.registerEditorAction(EditorFontZoomReset);
  82745. });
  82746. /*---------------------------------------------------------------------------------------------
  82747. * Copyright (c) Microsoft Corporation. All rights reserved.
  82748. * Licensed under the MIT License. See License.txt in the project root for license information.
  82749. *--------------------------------------------------------------------------------------------*/
  82750. define(__m[535/*vs/editor/contrib/format/format*/], __M([0/*require*/,1/*exports*/,50/*vs/base/browser/ui/aria/aria*/,19/*vs/base/common/arrays*/,26/*vs/base/common/cancellation*/,10/*vs/base/common/errors*/,25/*vs/base/common/uri*/,67/*vs/editor/browser/core/editorState*/,108/*vs/editor/browser/editorBrowser*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,17/*vs/editor/common/modes*/,62/*vs/editor/common/services/editorWorkerService*/,49/*vs/editor/common/services/modelService*/,198/*vs/editor/contrib/format/formattingEdit*/,442/*vs/nls!vs/editor/contrib/format/format*/,479/*vs/platform/extensions/common/extensions*/,11/*vs/platform/instantiation/common/instantiation*/,76/*vs/base/common/linkedList*/,29/*vs/platform/commands/common/commands*/,21/*vs/base/common/types*/]), function (require, exports, aria_1, arrays_1, cancellation_1, errors_1, uri_1, editorState_1, editorBrowser_1, position_1, range_1, selection_1, modes_1, editorWorkerService_1, modelService_1, formattingEdit_1, nls, extensions_1, instantiation_1, linkedList_1, commands_1, types_1) {
  82751. "use strict";
  82752. Object.defineProperty(exports, "__esModule", { value: true });
  82753. function alertFormattingEdits(edits) {
  82754. edits = edits.filter(function (edit) { return edit.range; });
  82755. if (!edits.length) {
  82756. return;
  82757. }
  82758. var range = edits[0].range;
  82759. for (var i = 1; i < edits.length; i++) {
  82760. range = range_1.Range.plusRange(range, edits[i].range);
  82761. }
  82762. var startLineNumber = range.startLineNumber, endLineNumber = range.endLineNumber;
  82763. if (startLineNumber === endLineNumber) {
  82764. if (edits.length === 1) {
  82765. aria_1.alert(nls.localize(0, null, startLineNumber));
  82766. }
  82767. else {
  82768. aria_1.alert(nls.localize(1, null, edits.length, startLineNumber));
  82769. }
  82770. }
  82771. else {
  82772. if (edits.length === 1) {
  82773. aria_1.alert(nls.localize(2, null, startLineNumber, endLineNumber));
  82774. }
  82775. else {
  82776. aria_1.alert(nls.localize(3, null, edits.length, startLineNumber, endLineNumber));
  82777. }
  82778. }
  82779. }
  82780. exports.alertFormattingEdits = alertFormattingEdits;
  82781. function getRealAndSyntheticDocumentFormattersOrdered(model) {
  82782. var result = [];
  82783. var seen = new Set();
  82784. // (1) add all document formatter
  82785. var docFormatter = modes_1.DocumentFormattingEditProviderRegistry.ordered(model);
  82786. for (var _i = 0, docFormatter_1 = docFormatter; _i < docFormatter_1.length; _i++) {
  82787. var formatter = docFormatter_1[_i];
  82788. result.push(formatter);
  82789. if (formatter.extensionId) {
  82790. seen.add(extensions_1.ExtensionIdentifier.toKey(formatter.extensionId));
  82791. }
  82792. }
  82793. // (2) add all range formatter as document formatter (unless the same extension already did that)
  82794. var rangeFormatter = modes_1.DocumentRangeFormattingEditProviderRegistry.ordered(model);
  82795. var _loop_1 = function (formatter) {
  82796. if (formatter.extensionId) {
  82797. if (seen.has(extensions_1.ExtensionIdentifier.toKey(formatter.extensionId))) {
  82798. return "continue";
  82799. }
  82800. seen.add(extensions_1.ExtensionIdentifier.toKey(formatter.extensionId));
  82801. }
  82802. result.push({
  82803. displayName: formatter.displayName,
  82804. extensionId: formatter.extensionId,
  82805. provideDocumentFormattingEdits: function (model, options, token) {
  82806. return formatter.provideDocumentRangeFormattingEdits(model, model.getFullModelRange(), options, token);
  82807. }
  82808. });
  82809. };
  82810. for (var _a = 0, rangeFormatter_1 = rangeFormatter; _a < rangeFormatter_1.length; _a++) {
  82811. var formatter = rangeFormatter_1[_a];
  82812. _loop_1(formatter);
  82813. }
  82814. return result;
  82815. }
  82816. exports.getRealAndSyntheticDocumentFormattersOrdered = getRealAndSyntheticDocumentFormattersOrdered;
  82817. var FormattingConflicts = /** @class */ (function () {
  82818. function FormattingConflicts() {
  82819. }
  82820. FormattingConflicts.select = function (formatter, document, mode) {
  82821. return __awaiter(this, void 0, void 0, function () {
  82822. var selector;
  82823. return __generator(this, function (_a) {
  82824. switch (_a.label) {
  82825. case 0:
  82826. if (formatter.length === 0) {
  82827. return [2 /*return*/, undefined];
  82828. }
  82829. selector = FormattingConflicts._selectors.iterator().next().value;
  82830. if (!selector) return [3 /*break*/, 2];
  82831. return [4 /*yield*/, selector(formatter, document, mode)];
  82832. case 1: return [2 /*return*/, _a.sent()];
  82833. case 2: return [2 /*return*/, formatter[0]];
  82834. }
  82835. });
  82836. });
  82837. };
  82838. FormattingConflicts._selectors = new linkedList_1.LinkedList();
  82839. return FormattingConflicts;
  82840. }());
  82841. exports.FormattingConflicts = FormattingConflicts;
  82842. function formatDocumentRangeWithSelectedProvider(accessor, editorOrModel, range, mode, token) {
  82843. return __awaiter(this, void 0, void 0, function () {
  82844. var instaService, model, provider, selected;
  82845. return __generator(this, function (_a) {
  82846. switch (_a.label) {
  82847. case 0:
  82848. instaService = accessor.get(instantiation_1.IInstantiationService);
  82849. model = editorBrowser_1.isCodeEditor(editorOrModel) ? editorOrModel.getModel() : editorOrModel;
  82850. provider = modes_1.DocumentRangeFormattingEditProviderRegistry.ordered(model);
  82851. return [4 /*yield*/, FormattingConflicts.select(provider, model, mode)];
  82852. case 1:
  82853. selected = _a.sent();
  82854. if (!selected) return [3 /*break*/, 3];
  82855. return [4 /*yield*/, instaService.invokeFunction(formatDocumentRangeWithProvider, selected, editorOrModel, range, token)];
  82856. case 2:
  82857. _a.sent();
  82858. _a.label = 3;
  82859. case 3: return [2 /*return*/];
  82860. }
  82861. });
  82862. });
  82863. }
  82864. exports.formatDocumentRangeWithSelectedProvider = formatDocumentRangeWithSelectedProvider;
  82865. function formatDocumentRangeWithProvider(accessor, provider, editorOrModel, range, token) {
  82866. return __awaiter(this, void 0, void 0, function () {
  82867. var workerService, model, cts, edits, rawEdits, range_2, initialSelection_1;
  82868. return __generator(this, function (_a) {
  82869. switch (_a.label) {
  82870. case 0:
  82871. workerService = accessor.get(editorWorkerService_1.IEditorWorkerService);
  82872. if (editorBrowser_1.isCodeEditor(editorOrModel)) {
  82873. model = editorOrModel.getModel();
  82874. cts = new editorState_1.EditorStateCancellationTokenSource(editorOrModel, 1 /* Value */ | 4 /* Position */, token);
  82875. }
  82876. else {
  82877. model = editorOrModel;
  82878. cts = new editorState_1.TextModelCancellationTokenSource(editorOrModel, token);
  82879. }
  82880. _a.label = 1;
  82881. case 1:
  82882. _a.trys.push([1, , 4, 5]);
  82883. return [4 /*yield*/, provider.provideDocumentRangeFormattingEdits(model, range, model.getFormattingOptions(), cts.token)];
  82884. case 2:
  82885. rawEdits = _a.sent();
  82886. return [4 /*yield*/, workerService.computeMoreMinimalEdits(model.uri, rawEdits)];
  82887. case 3:
  82888. edits = _a.sent();
  82889. if (cts.token.isCancellationRequested) {
  82890. return [2 /*return*/, true];
  82891. }
  82892. return [3 /*break*/, 5];
  82893. case 4:
  82894. cts.dispose();
  82895. return [7 /*endfinally*/];
  82896. case 5:
  82897. if (!edits || edits.length === 0) {
  82898. return [2 /*return*/, false];
  82899. }
  82900. if (editorBrowser_1.isCodeEditor(editorOrModel)) {
  82901. // use editor to apply edits
  82902. formattingEdit_1.FormattingEdit.execute(editorOrModel, edits);
  82903. alertFormattingEdits(edits);
  82904. editorOrModel.pushUndoStop();
  82905. editorOrModel.revealPositionInCenterIfOutsideViewport(editorOrModel.getPosition(), 1 /* Immediate */);
  82906. }
  82907. else {
  82908. range_2 = edits[0].range;
  82909. initialSelection_1 = new selection_1.Selection(range_2.startLineNumber, range_2.startColumn, range_2.endLineNumber, range_2.endColumn);
  82910. model.pushEditOperations([initialSelection_1], edits.map(function (edit) {
  82911. return {
  82912. text: edit.text,
  82913. range: range_1.Range.lift(edit.range),
  82914. forceMoveMarkers: true
  82915. };
  82916. }), function (undoEdits) {
  82917. for (var _i = 0, undoEdits_1 = undoEdits; _i < undoEdits_1.length; _i++) {
  82918. var range_3 = undoEdits_1[_i].range;
  82919. if (range_1.Range.areIntersectingOrTouching(range_3, initialSelection_1)) {
  82920. return [new selection_1.Selection(range_3.startLineNumber, range_3.startColumn, range_3.endLineNumber, range_3.endColumn)];
  82921. }
  82922. }
  82923. return null;
  82924. });
  82925. }
  82926. return [2 /*return*/, true];
  82927. }
  82928. });
  82929. });
  82930. }
  82931. exports.formatDocumentRangeWithProvider = formatDocumentRangeWithProvider;
  82932. function formatDocumentWithSelectedProvider(accessor, editorOrModel, mode, token) {
  82933. return __awaiter(this, void 0, void 0, function () {
  82934. var instaService, model, provider, selected;
  82935. return __generator(this, function (_a) {
  82936. switch (_a.label) {
  82937. case 0:
  82938. instaService = accessor.get(instantiation_1.IInstantiationService);
  82939. model = editorBrowser_1.isCodeEditor(editorOrModel) ? editorOrModel.getModel() : editorOrModel;
  82940. provider = getRealAndSyntheticDocumentFormattersOrdered(model);
  82941. return [4 /*yield*/, FormattingConflicts.select(provider, model, mode)];
  82942. case 1:
  82943. selected = _a.sent();
  82944. if (!selected) return [3 /*break*/, 3];
  82945. return [4 /*yield*/, instaService.invokeFunction(formatDocumentWithProvider, selected, editorOrModel, mode, token)];
  82946. case 2:
  82947. _a.sent();
  82948. _a.label = 3;
  82949. case 3: return [2 /*return*/];
  82950. }
  82951. });
  82952. });
  82953. }
  82954. exports.formatDocumentWithSelectedProvider = formatDocumentWithSelectedProvider;
  82955. function formatDocumentWithProvider(accessor, provider, editorOrModel, mode, token) {
  82956. return __awaiter(this, void 0, void 0, function () {
  82957. var workerService, model, cts, edits, rawEdits, range, initialSelection_2;
  82958. return __generator(this, function (_a) {
  82959. switch (_a.label) {
  82960. case 0:
  82961. workerService = accessor.get(editorWorkerService_1.IEditorWorkerService);
  82962. if (editorBrowser_1.isCodeEditor(editorOrModel)) {
  82963. model = editorOrModel.getModel();
  82964. cts = new editorState_1.EditorStateCancellationTokenSource(editorOrModel, 1 /* Value */ | 4 /* Position */, token);
  82965. }
  82966. else {
  82967. model = editorOrModel;
  82968. cts = new editorState_1.TextModelCancellationTokenSource(editorOrModel, token);
  82969. }
  82970. _a.label = 1;
  82971. case 1:
  82972. _a.trys.push([1, , 4, 5]);
  82973. return [4 /*yield*/, provider.provideDocumentFormattingEdits(model, model.getFormattingOptions(), cts.token)];
  82974. case 2:
  82975. rawEdits = _a.sent();
  82976. return [4 /*yield*/, workerService.computeMoreMinimalEdits(model.uri, rawEdits)];
  82977. case 3:
  82978. edits = _a.sent();
  82979. if (cts.token.isCancellationRequested) {
  82980. return [2 /*return*/, true];
  82981. }
  82982. return [3 /*break*/, 5];
  82983. case 4:
  82984. cts.dispose();
  82985. return [7 /*endfinally*/];
  82986. case 5:
  82987. if (!edits || edits.length === 0) {
  82988. return [2 /*return*/, false];
  82989. }
  82990. if (editorBrowser_1.isCodeEditor(editorOrModel)) {
  82991. // use editor to apply edits
  82992. formattingEdit_1.FormattingEdit.execute(editorOrModel, edits);
  82993. if (mode !== 2 /* Silent */) {
  82994. alertFormattingEdits(edits);
  82995. editorOrModel.pushUndoStop();
  82996. editorOrModel.revealPositionInCenterIfOutsideViewport(editorOrModel.getPosition(), 1 /* Immediate */);
  82997. }
  82998. }
  82999. else {
  83000. range = edits[0].range;
  83001. initialSelection_2 = new selection_1.Selection(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn);
  83002. model.pushEditOperations([initialSelection_2], edits.map(function (edit) {
  83003. return {
  83004. text: edit.text,
  83005. range: range_1.Range.lift(edit.range),
  83006. forceMoveMarkers: true
  83007. };
  83008. }), function (undoEdits) {
  83009. for (var _i = 0, undoEdits_2 = undoEdits; _i < undoEdits_2.length; _i++) {
  83010. var range_4 = undoEdits_2[_i].range;
  83011. if (range_1.Range.areIntersectingOrTouching(range_4, initialSelection_2)) {
  83012. return [new selection_1.Selection(range_4.startLineNumber, range_4.startColumn, range_4.endLineNumber, range_4.endColumn)];
  83013. }
  83014. }
  83015. return null;
  83016. });
  83017. }
  83018. return [2 /*return*/, true];
  83019. }
  83020. });
  83021. });
  83022. }
  83023. exports.formatDocumentWithProvider = formatDocumentWithProvider;
  83024. function getDocumentRangeFormattingEditsUntilResult(workerService, model, range, options, token) {
  83025. return __awaiter(this, void 0, void 0, function () {
  83026. var providers, _i, providers_1, provider, rawEdits;
  83027. return __generator(this, function (_a) {
  83028. switch (_a.label) {
  83029. case 0:
  83030. providers = modes_1.DocumentRangeFormattingEditProviderRegistry.ordered(model);
  83031. _i = 0, providers_1 = providers;
  83032. _a.label = 1;
  83033. case 1:
  83034. if (!(_i < providers_1.length)) return [3 /*break*/, 5];
  83035. provider = providers_1[_i];
  83036. return [4 /*yield*/, Promise.resolve(provider.provideDocumentRangeFormattingEdits(model, range, options, token)).catch(errors_1.onUnexpectedExternalError)];
  83037. case 2:
  83038. rawEdits = _a.sent();
  83039. if (!arrays_1.isNonEmptyArray(rawEdits)) return [3 /*break*/, 4];
  83040. return [4 /*yield*/, workerService.computeMoreMinimalEdits(model.uri, rawEdits)];
  83041. case 3: return [2 /*return*/, _a.sent()];
  83042. case 4:
  83043. _i++;
  83044. return [3 /*break*/, 1];
  83045. case 5: return [2 /*return*/, undefined];
  83046. }
  83047. });
  83048. });
  83049. }
  83050. exports.getDocumentRangeFormattingEditsUntilResult = getDocumentRangeFormattingEditsUntilResult;
  83051. function getDocumentFormattingEditsUntilResult(workerService, model, options, token) {
  83052. return __awaiter(this, void 0, void 0, function () {
  83053. var providers, _i, providers_2, provider, rawEdits;
  83054. return __generator(this, function (_a) {
  83055. switch (_a.label) {
  83056. case 0:
  83057. providers = getRealAndSyntheticDocumentFormattersOrdered(model);
  83058. _i = 0, providers_2 = providers;
  83059. _a.label = 1;
  83060. case 1:
  83061. if (!(_i < providers_2.length)) return [3 /*break*/, 5];
  83062. provider = providers_2[_i];
  83063. return [4 /*yield*/, Promise.resolve(provider.provideDocumentFormattingEdits(model, options, token)).catch(errors_1.onUnexpectedExternalError)];
  83064. case 2:
  83065. rawEdits = _a.sent();
  83066. if (!arrays_1.isNonEmptyArray(rawEdits)) return [3 /*break*/, 4];
  83067. return [4 /*yield*/, workerService.computeMoreMinimalEdits(model.uri, rawEdits)];
  83068. case 3: return [2 /*return*/, _a.sent()];
  83069. case 4:
  83070. _i++;
  83071. return [3 /*break*/, 1];
  83072. case 5: return [2 /*return*/, undefined];
  83073. }
  83074. });
  83075. });
  83076. }
  83077. exports.getDocumentFormattingEditsUntilResult = getDocumentFormattingEditsUntilResult;
  83078. function getOnTypeFormattingEdits(workerService, model, position, ch, options) {
  83079. var providers = modes_1.OnTypeFormattingEditProviderRegistry.ordered(model);
  83080. if (providers.length === 0) {
  83081. return Promise.resolve(undefined);
  83082. }
  83083. if (providers[0].autoFormatTriggerCharacters.indexOf(ch) < 0) {
  83084. return Promise.resolve(undefined);
  83085. }
  83086. return Promise.resolve(providers[0].provideOnTypeFormattingEdits(model, position, ch, options, cancellation_1.CancellationToken.None)).catch(errors_1.onUnexpectedExternalError).then(function (edits) {
  83087. return workerService.computeMoreMinimalEdits(model.uri, edits);
  83088. });
  83089. }
  83090. exports.getOnTypeFormattingEdits = getOnTypeFormattingEdits;
  83091. commands_1.CommandsRegistry.registerCommand('_executeFormatRangeProvider', function (accessor) {
  83092. var args = [];
  83093. for (var _i = 1; _i < arguments.length; _i++) {
  83094. args[_i - 1] = arguments[_i];
  83095. }
  83096. var resource = args[0], range = args[1], options = args[2];
  83097. types_1.assertType(uri_1.URI.isUri(resource));
  83098. types_1.assertType(range_1.Range.isIRange(range));
  83099. var model = accessor.get(modelService_1.IModelService).getModel(resource);
  83100. if (!model) {
  83101. throw errors_1.illegalArgument('resource');
  83102. }
  83103. return getDocumentRangeFormattingEditsUntilResult(accessor.get(editorWorkerService_1.IEditorWorkerService), model, range_1.Range.lift(range), options, cancellation_1.CancellationToken.None);
  83104. });
  83105. commands_1.CommandsRegistry.registerCommand('_executeFormatDocumentProvider', function (accessor) {
  83106. var args = [];
  83107. for (var _i = 1; _i < arguments.length; _i++) {
  83108. args[_i - 1] = arguments[_i];
  83109. }
  83110. var resource = args[0], options = args[1];
  83111. types_1.assertType(uri_1.URI.isUri(resource));
  83112. var model = accessor.get(modelService_1.IModelService).getModel(resource);
  83113. if (!model) {
  83114. throw errors_1.illegalArgument('resource');
  83115. }
  83116. return getDocumentFormattingEditsUntilResult(accessor.get(editorWorkerService_1.IEditorWorkerService), model, options, cancellation_1.CancellationToken.None);
  83117. });
  83118. commands_1.CommandsRegistry.registerCommand('_executeFormatOnTypeProvider', function (accessor) {
  83119. var args = [];
  83120. for (var _i = 1; _i < arguments.length; _i++) {
  83121. args[_i - 1] = arguments[_i];
  83122. }
  83123. var resource = args[0], position = args[1], ch = args[2], options = args[3];
  83124. types_1.assertType(uri_1.URI.isUri(resource));
  83125. types_1.assertType(position_1.Position.isIPosition(position));
  83126. types_1.assertType(typeof ch === 'string');
  83127. var model = accessor.get(modelService_1.IModelService).getModel(resource);
  83128. if (!model) {
  83129. throw errors_1.illegalArgument('resource');
  83130. }
  83131. return getOnTypeFormattingEdits(accessor.get(editorWorkerService_1.IEditorWorkerService), model, position_1.Position.lift(position), ch, options);
  83132. });
  83133. });
  83134. /*---------------------------------------------------------------------------------------------
  83135. * Copyright (c) Microsoft Corporation. All rights reserved.
  83136. * Licensed under the MIT License. See License.txt in the project root for license information.
  83137. *--------------------------------------------------------------------------------------------*/
  83138. define(__m[536/*vs/editor/contrib/format/formatActions*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,26/*vs/base/common/cancellation*/,36/*vs/base/common/keyCodes*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,32/*vs/editor/browser/services/codeEditorService*/,79/*vs/editor/common/core/characterClassifier*/,3/*vs/editor/common/core/range*/,23/*vs/editor/common/editorContextKeys*/,17/*vs/editor/common/modes*/,62/*vs/editor/common/services/editorWorkerService*/,535/*vs/editor/contrib/format/format*/,198/*vs/editor/contrib/format/formattingEdit*/,443/*vs/nls!vs/editor/contrib/format/formatActions*/,29/*vs/platform/commands/common/commands*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,10/*vs/base/common/errors*/]), function (require, exports, arrays_1, cancellation_1, keyCodes_1, lifecycle_1, editorExtensions_1, codeEditorService_1, characterClassifier_1, range_1, editorContextKeys_1, modes_1, editorWorkerService_1, format_1, formattingEdit_1, nls, commands_1, contextkey_1, instantiation_1, errors_1) {
  83139. "use strict";
  83140. Object.defineProperty(exports, "__esModule", { value: true });
  83141. var FormatOnType = /** @class */ (function () {
  83142. function FormatOnType(editor, _workerService) {
  83143. var _this = this;
  83144. this._workerService = _workerService;
  83145. this._callOnDispose = new lifecycle_1.DisposableStore();
  83146. this._callOnModel = new lifecycle_1.DisposableStore();
  83147. this._editor = editor;
  83148. this._callOnDispose.add(editor.onDidChangeConfiguration(function () { return _this._update(); }));
  83149. this._callOnDispose.add(editor.onDidChangeModel(function () { return _this._update(); }));
  83150. this._callOnDispose.add(editor.onDidChangeModelLanguage(function () { return _this._update(); }));
  83151. this._callOnDispose.add(modes_1.OnTypeFormattingEditProviderRegistry.onDidChange(this._update, this));
  83152. }
  83153. FormatOnType.prototype.dispose = function () {
  83154. this._callOnDispose.dispose();
  83155. this._callOnModel.dispose();
  83156. };
  83157. FormatOnType.prototype._update = function () {
  83158. var _this = this;
  83159. // clean up
  83160. this._callOnModel.clear();
  83161. // we are disabled
  83162. if (!this._editor.getOption(39 /* formatOnType */)) {
  83163. return;
  83164. }
  83165. // no model
  83166. if (!this._editor.hasModel()) {
  83167. return;
  83168. }
  83169. var model = this._editor.getModel();
  83170. // no support
  83171. var support = modes_1.OnTypeFormattingEditProviderRegistry.ordered(model)[0];
  83172. if (!support || !support.autoFormatTriggerCharacters) {
  83173. return;
  83174. }
  83175. // register typing listeners that will trigger the format
  83176. var triggerChars = new characterClassifier_1.CharacterSet();
  83177. for (var _i = 0, _a = support.autoFormatTriggerCharacters; _i < _a.length; _i++) {
  83178. var ch = _a[_i];
  83179. triggerChars.add(ch.charCodeAt(0));
  83180. }
  83181. this._callOnModel.add(this._editor.onDidType(function (text) {
  83182. var lastCharCode = text.charCodeAt(text.length - 1);
  83183. if (triggerChars.has(lastCharCode)) {
  83184. _this._trigger(String.fromCharCode(lastCharCode));
  83185. }
  83186. }));
  83187. };
  83188. FormatOnType.prototype._trigger = function (ch) {
  83189. var _this = this;
  83190. if (!this._editor.hasModel()) {
  83191. return;
  83192. }
  83193. if (this._editor.getSelections().length > 1) {
  83194. return;
  83195. }
  83196. var model = this._editor.getModel();
  83197. var position = this._editor.getPosition();
  83198. var canceled = false;
  83199. // install a listener that checks if edits happens before the
  83200. // position on which we format right now. If so, we won't
  83201. // apply the format edits
  83202. var unbind = this._editor.onDidChangeModelContent(function (e) {
  83203. if (e.isFlush) {
  83204. // a model.setValue() was called
  83205. // cancel only once
  83206. canceled = true;
  83207. unbind.dispose();
  83208. return;
  83209. }
  83210. for (var i = 0, len = e.changes.length; i < len; i++) {
  83211. var change = e.changes[i];
  83212. if (change.range.endLineNumber <= position.lineNumber) {
  83213. // cancel only once
  83214. canceled = true;
  83215. unbind.dispose();
  83216. return;
  83217. }
  83218. }
  83219. });
  83220. format_1.getOnTypeFormattingEdits(this._workerService, model, position, ch, model.getFormattingOptions()).then(function (edits) {
  83221. unbind.dispose();
  83222. if (canceled) {
  83223. return;
  83224. }
  83225. if (arrays_1.isNonEmptyArray(edits)) {
  83226. formattingEdit_1.FormattingEdit.execute(_this._editor, edits);
  83227. format_1.alertFormattingEdits(edits);
  83228. }
  83229. }, function (err) {
  83230. unbind.dispose();
  83231. throw err;
  83232. });
  83233. };
  83234. FormatOnType.ID = 'editor.contrib.autoFormat';
  83235. FormatOnType = __decorate([
  83236. __param(1, editorWorkerService_1.IEditorWorkerService)
  83237. ], FormatOnType);
  83238. return FormatOnType;
  83239. }());
  83240. var FormatOnPaste = /** @class */ (function () {
  83241. function FormatOnPaste(editor, _instantiationService) {
  83242. var _this = this;
  83243. this.editor = editor;
  83244. this._instantiationService = _instantiationService;
  83245. this._callOnDispose = new lifecycle_1.DisposableStore();
  83246. this._callOnModel = new lifecycle_1.DisposableStore();
  83247. this._callOnDispose.add(editor.onDidChangeConfiguration(function () { return _this._update(); }));
  83248. this._callOnDispose.add(editor.onDidChangeModel(function () { return _this._update(); }));
  83249. this._callOnDispose.add(editor.onDidChangeModelLanguage(function () { return _this._update(); }));
  83250. this._callOnDispose.add(modes_1.DocumentRangeFormattingEditProviderRegistry.onDidChange(this._update, this));
  83251. }
  83252. FormatOnPaste.prototype.dispose = function () {
  83253. this._callOnDispose.dispose();
  83254. this._callOnModel.dispose();
  83255. };
  83256. FormatOnPaste.prototype._update = function () {
  83257. var _this = this;
  83258. // clean up
  83259. this._callOnModel.clear();
  83260. // we are disabled
  83261. if (!this.editor.getOption(38 /* formatOnPaste */)) {
  83262. return;
  83263. }
  83264. // no model
  83265. if (!this.editor.hasModel()) {
  83266. return;
  83267. }
  83268. // no formatter
  83269. if (!modes_1.DocumentRangeFormattingEditProviderRegistry.has(this.editor.getModel())) {
  83270. return;
  83271. }
  83272. this._callOnModel.add(this.editor.onDidPaste(function (_a) {
  83273. var range = _a.range;
  83274. return _this._trigger(range);
  83275. }));
  83276. };
  83277. FormatOnPaste.prototype._trigger = function (range) {
  83278. if (!this.editor.hasModel()) {
  83279. return;
  83280. }
  83281. if (this.editor.getSelections().length > 1) {
  83282. return;
  83283. }
  83284. this._instantiationService.invokeFunction(format_1.formatDocumentRangeWithSelectedProvider, this.editor, range, 2 /* Silent */, cancellation_1.CancellationToken.None).catch(errors_1.onUnexpectedError);
  83285. };
  83286. FormatOnPaste.ID = 'editor.contrib.formatOnPaste';
  83287. FormatOnPaste = __decorate([
  83288. __param(1, instantiation_1.IInstantiationService)
  83289. ], FormatOnPaste);
  83290. return FormatOnPaste;
  83291. }());
  83292. var FormatDocumentAction = /** @class */ (function (_super) {
  83293. __extends(FormatDocumentAction, _super);
  83294. function FormatDocumentAction() {
  83295. return _super.call(this, {
  83296. id: 'editor.action.formatDocument',
  83297. label: nls.localize(0, null),
  83298. alias: 'Format Document',
  83299. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, editorContextKeys_1.EditorContextKeys.hasDocumentFormattingProvider),
  83300. kbOpts: {
  83301. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.editorTextFocus, editorContextKeys_1.EditorContextKeys.hasDocumentFormattingProvider),
  83302. primary: 1024 /* Shift */ | 512 /* Alt */ | 36 /* KEY_F */,
  83303. linux: { primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 39 /* KEY_I */ },
  83304. weight: 100 /* EditorContrib */
  83305. },
  83306. contextMenuOpts: {
  83307. when: editorContextKeys_1.EditorContextKeys.hasDocumentFormattingProvider,
  83308. group: '1_modification',
  83309. order: 1.3
  83310. }
  83311. }) || this;
  83312. }
  83313. FormatDocumentAction.prototype.run = function (accessor, editor) {
  83314. return __awaiter(this, void 0, void 0, function () {
  83315. var instaService;
  83316. return __generator(this, function (_a) {
  83317. switch (_a.label) {
  83318. case 0:
  83319. if (!editor.hasModel()) return [3 /*break*/, 2];
  83320. instaService = accessor.get(instantiation_1.IInstantiationService);
  83321. return [4 /*yield*/, instaService.invokeFunction(format_1.formatDocumentWithSelectedProvider, editor, 1 /* Explicit */, cancellation_1.CancellationToken.None)];
  83322. case 1:
  83323. _a.sent();
  83324. _a.label = 2;
  83325. case 2: return [2 /*return*/];
  83326. }
  83327. });
  83328. });
  83329. };
  83330. return FormatDocumentAction;
  83331. }(editorExtensions_1.EditorAction));
  83332. var FormatSelectionAction = /** @class */ (function (_super) {
  83333. __extends(FormatSelectionAction, _super);
  83334. function FormatSelectionAction() {
  83335. return _super.call(this, {
  83336. id: 'editor.action.formatSelection',
  83337. label: nls.localize(1, null),
  83338. alias: 'Format Selection',
  83339. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, editorContextKeys_1.EditorContextKeys.hasDocumentSelectionFormattingProvider),
  83340. kbOpts: {
  83341. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.editorTextFocus, editorContextKeys_1.EditorContextKeys.hasDocumentSelectionFormattingProvider),
  83342. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 36 /* KEY_F */),
  83343. weight: 100 /* EditorContrib */
  83344. },
  83345. contextMenuOpts: {
  83346. when: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasDocumentSelectionFormattingProvider, editorContextKeys_1.EditorContextKeys.hasNonEmptySelection),
  83347. group: '1_modification',
  83348. order: 1.31
  83349. }
  83350. }) || this;
  83351. }
  83352. FormatSelectionAction.prototype.run = function (accessor, editor) {
  83353. return __awaiter(this, void 0, void 0, function () {
  83354. var instaService, model, range;
  83355. return __generator(this, function (_a) {
  83356. switch (_a.label) {
  83357. case 0:
  83358. if (!editor.hasModel()) {
  83359. return [2 /*return*/];
  83360. }
  83361. instaService = accessor.get(instantiation_1.IInstantiationService);
  83362. model = editor.getModel();
  83363. range = editor.getSelection();
  83364. if (range.isEmpty()) {
  83365. range = new range_1.Range(range.startLineNumber, 1, range.startLineNumber, model.getLineMaxColumn(range.startLineNumber));
  83366. }
  83367. return [4 /*yield*/, instaService.invokeFunction(format_1.formatDocumentRangeWithSelectedProvider, editor, range, 1 /* Explicit */, cancellation_1.CancellationToken.None)];
  83368. case 1:
  83369. _a.sent();
  83370. return [2 /*return*/];
  83371. }
  83372. });
  83373. });
  83374. };
  83375. return FormatSelectionAction;
  83376. }(editorExtensions_1.EditorAction));
  83377. editorExtensions_1.registerEditorContribution(FormatOnType.ID, FormatOnType);
  83378. editorExtensions_1.registerEditorContribution(FormatOnPaste.ID, FormatOnPaste);
  83379. editorExtensions_1.registerEditorAction(FormatDocumentAction);
  83380. editorExtensions_1.registerEditorAction(FormatSelectionAction);
  83381. // this is the old format action that does both (format document OR format selection)
  83382. // and we keep it here such that existing keybinding configurations etc will still work
  83383. commands_1.CommandsRegistry.registerCommand('editor.action.format', function (accessor) { return __awaiter(void 0, void 0, void 0, function () {
  83384. var editor, commandService;
  83385. return __generator(this, function (_a) {
  83386. switch (_a.label) {
  83387. case 0:
  83388. editor = accessor.get(codeEditorService_1.ICodeEditorService).getFocusedCodeEditor();
  83389. if (!editor || !editor.hasModel()) {
  83390. return [2 /*return*/];
  83391. }
  83392. commandService = accessor.get(commands_1.ICommandService);
  83393. if (!editor.getSelection().isEmpty()) return [3 /*break*/, 2];
  83394. return [4 /*yield*/, commandService.executeCommand('editor.action.formatDocument')];
  83395. case 1:
  83396. _a.sent();
  83397. return [3 /*break*/, 4];
  83398. case 2: return [4 /*yield*/, commandService.executeCommand('editor.action.formatSelection')];
  83399. case 3:
  83400. _a.sent();
  83401. _a.label = 4;
  83402. case 4: return [2 /*return*/];
  83403. }
  83404. });
  83405. }); });
  83406. });
  83407. /*---------------------------------------------------------------------------------------------
  83408. * Copyright (c) Microsoft Corporation. All rights reserved.
  83409. * Licensed under the MIT License. See License.txt in the project root for license information.
  83410. *--------------------------------------------------------------------------------------------*/
  83411. define(__m[224/*vs/editor/contrib/gotoSymbol/goToSymbol*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,26/*vs/base/common/cancellation*/,10/*vs/base/common/errors*/,12/*vs/editor/browser/editorExtensions*/,17/*vs/editor/common/modes*/]), function (require, exports, arrays_1, cancellation_1, errors_1, editorExtensions_1, modes_1) {
  83412. "use strict";
  83413. Object.defineProperty(exports, "__esModule", { value: true });
  83414. function getLocationLinks(model, position, registry, provide) {
  83415. var provider = registry.ordered(model);
  83416. // get results
  83417. var promises = provider.map(function (provider) {
  83418. return Promise.resolve(provide(provider, model, position)).then(undefined, function (err) {
  83419. errors_1.onUnexpectedExternalError(err);
  83420. return undefined;
  83421. });
  83422. });
  83423. return Promise.all(promises)
  83424. .then(arrays_1.flatten)
  83425. .then(arrays_1.coalesce);
  83426. }
  83427. function getDefinitionsAtPosition(model, position, token) {
  83428. return getLocationLinks(model, position, modes_1.DefinitionProviderRegistry, function (provider, model, position) {
  83429. return provider.provideDefinition(model, position, token);
  83430. });
  83431. }
  83432. exports.getDefinitionsAtPosition = getDefinitionsAtPosition;
  83433. function getDeclarationsAtPosition(model, position, token) {
  83434. return getLocationLinks(model, position, modes_1.DeclarationProviderRegistry, function (provider, model, position) {
  83435. return provider.provideDeclaration(model, position, token);
  83436. });
  83437. }
  83438. exports.getDeclarationsAtPosition = getDeclarationsAtPosition;
  83439. function getImplementationsAtPosition(model, position, token) {
  83440. return getLocationLinks(model, position, modes_1.ImplementationProviderRegistry, function (provider, model, position) {
  83441. return provider.provideImplementation(model, position, token);
  83442. });
  83443. }
  83444. exports.getImplementationsAtPosition = getImplementationsAtPosition;
  83445. function getTypeDefinitionsAtPosition(model, position, token) {
  83446. return getLocationLinks(model, position, modes_1.TypeDefinitionProviderRegistry, function (provider, model, position) {
  83447. return provider.provideTypeDefinition(model, position, token);
  83448. });
  83449. }
  83450. exports.getTypeDefinitionsAtPosition = getTypeDefinitionsAtPosition;
  83451. function getReferencesAtPosition(model, position, compact, token) {
  83452. var _this = this;
  83453. return getLocationLinks(model, position, modes_1.ReferenceProviderRegistry, function (provider, model, position) { return __awaiter(_this, void 0, void 0, function () {
  83454. var result, resultWithoutDeclaration;
  83455. return __generator(this, function (_a) {
  83456. switch (_a.label) {
  83457. case 0: return [4 /*yield*/, provider.provideReferences(model, position, { includeDeclaration: true }, token)];
  83458. case 1:
  83459. result = _a.sent();
  83460. if (!compact || !result || result.length !== 2) {
  83461. return [2 /*return*/, result];
  83462. }
  83463. return [4 /*yield*/, provider.provideReferences(model, position, { includeDeclaration: false }, token)];
  83464. case 2:
  83465. resultWithoutDeclaration = _a.sent();
  83466. if (resultWithoutDeclaration && resultWithoutDeclaration.length === 1) {
  83467. return [2 /*return*/, resultWithoutDeclaration];
  83468. }
  83469. return [2 /*return*/, result];
  83470. }
  83471. });
  83472. }); });
  83473. }
  83474. exports.getReferencesAtPosition = getReferencesAtPosition;
  83475. editorExtensions_1.registerModelAndPositionCommand('_executeDefinitionProvider', function (model, position) { return getDefinitionsAtPosition(model, position, cancellation_1.CancellationToken.None); });
  83476. editorExtensions_1.registerModelAndPositionCommand('_executeDeclarationProvider', function (model, position) { return getDeclarationsAtPosition(model, position, cancellation_1.CancellationToken.None); });
  83477. editorExtensions_1.registerModelAndPositionCommand('_executeImplementationProvider', function (model, position) { return getImplementationsAtPosition(model, position, cancellation_1.CancellationToken.None); });
  83478. editorExtensions_1.registerModelAndPositionCommand('_executeTypeDefinitionProvider', function (model, position) { return getTypeDefinitionsAtPosition(model, position, cancellation_1.CancellationToken.None); });
  83479. editorExtensions_1.registerModelAndPositionCommand('_executeReferenceProvider', function (model, position) { return getReferencesAtPosition(model, position, false, cancellation_1.CancellationToken.None); });
  83480. });
  83481. /*---------------------------------------------------------------------------------------------
  83482. * Copyright (c) Microsoft Corporation. All rights reserved.
  83483. * Licensed under the MIT License. See License.txt in the project root for license information.
  83484. *--------------------------------------------------------------------------------------------*/
  83485. define(__m[537/*vs/editor/contrib/gotoSymbol/symbolNavigation*/], __M([0/*require*/,1/*exports*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,83/*vs/platform/instantiation/common/extensions*/,86/*vs/platform/keybinding/common/keybindingsRegistry*/,12/*vs/editor/browser/editorExtensions*/,32/*vs/editor/browser/services/codeEditorService*/,3/*vs/editor/common/core/range*/,2/*vs/base/common/lifecycle*/,4/*vs/base/common/event*/,452/*vs/nls!vs/editor/contrib/gotoSymbol/symbolNavigation*/,34/*vs/platform/keybinding/common/keybinding*/,35/*vs/platform/notification/common/notification*/,39/*vs/base/common/resources*/]), function (require, exports, contextkey_1, instantiation_1, extensions_1, keybindingsRegistry_1, editorExtensions_1, codeEditorService_1, range_1, lifecycle_1, event_1, nls_1, keybinding_1, notification_1, resources_1) {
  83486. "use strict";
  83487. Object.defineProperty(exports, "__esModule", { value: true });
  83488. exports.ctxHasSymbols = new contextkey_1.RawContextKey('hasSymbols', false);
  83489. exports.ISymbolNavigationService = instantiation_1.createDecorator('ISymbolNavigationService');
  83490. var SymbolNavigationService = /** @class */ (function () {
  83491. function SymbolNavigationService(contextKeyService, _editorService, _notificationService, _keybindingService) {
  83492. this._editorService = _editorService;
  83493. this._notificationService = _notificationService;
  83494. this._keybindingService = _keybindingService;
  83495. this._currentModel = undefined;
  83496. this._currentIdx = -1;
  83497. this._ignoreEditorChange = false;
  83498. this._ctxHasSymbols = exports.ctxHasSymbols.bindTo(contextKeyService);
  83499. }
  83500. SymbolNavigationService.prototype.reset = function () {
  83501. this._ctxHasSymbols.reset();
  83502. lifecycle_1.dispose(this._currentState);
  83503. lifecycle_1.dispose(this._currentMessage);
  83504. this._currentModel = undefined;
  83505. this._currentIdx = -1;
  83506. };
  83507. SymbolNavigationService.prototype.put = function (anchor) {
  83508. var _this = this;
  83509. var refModel = anchor.parent.parent;
  83510. if (refModel.references.length <= 1) {
  83511. this.reset();
  83512. return;
  83513. }
  83514. this._currentModel = refModel;
  83515. this._currentIdx = refModel.references.indexOf(anchor);
  83516. this._ctxHasSymbols.set(true);
  83517. this._showMessage();
  83518. var editorState = new EditorState(this._editorService);
  83519. var listener = editorState.onDidChange(function (_) {
  83520. if (_this._ignoreEditorChange) {
  83521. return;
  83522. }
  83523. var editor = _this._editorService.getActiveCodeEditor();
  83524. if (!editor) {
  83525. return;
  83526. }
  83527. var model = editor.getModel();
  83528. var position = editor.getPosition();
  83529. if (!model || !position) {
  83530. return;
  83531. }
  83532. var seenUri = false;
  83533. var seenPosition = false;
  83534. for (var _i = 0, _a = refModel.references; _i < _a.length; _i++) {
  83535. var reference = _a[_i];
  83536. if (resources_1.isEqual(reference.uri, model.uri)) {
  83537. seenUri = true;
  83538. seenPosition = seenPosition || range_1.Range.containsPosition(reference.range, position);
  83539. }
  83540. else if (seenUri) {
  83541. break;
  83542. }
  83543. }
  83544. if (!seenUri || !seenPosition) {
  83545. _this.reset();
  83546. }
  83547. });
  83548. this._currentState = lifecycle_1.combinedDisposable(editorState, listener);
  83549. };
  83550. SymbolNavigationService.prototype.revealNext = function (source) {
  83551. var _this = this;
  83552. if (!this._currentModel) {
  83553. return Promise.resolve();
  83554. }
  83555. // get next result and advance
  83556. this._currentIdx += 1;
  83557. this._currentIdx %= this._currentModel.references.length;
  83558. var reference = this._currentModel.references[this._currentIdx];
  83559. // status
  83560. this._showMessage();
  83561. // open editor, ignore events while that happens
  83562. this._ignoreEditorChange = true;
  83563. return this._editorService.openCodeEditor({
  83564. resource: reference.uri,
  83565. options: {
  83566. selection: range_1.Range.collapseToStart(reference.range),
  83567. revealInCenterIfOutsideViewport: true
  83568. }
  83569. }, source).finally(function () {
  83570. _this._ignoreEditorChange = false;
  83571. });
  83572. };
  83573. SymbolNavigationService.prototype._showMessage = function () {
  83574. lifecycle_1.dispose(this._currentMessage);
  83575. var kb = this._keybindingService.lookupKeybinding('editor.gotoNextSymbolFromResult');
  83576. var message = kb
  83577. ? nls_1.localize(0, null, this._currentIdx + 1, this._currentModel.references.length, kb.getLabel())
  83578. : nls_1.localize(1, null, this._currentIdx + 1, this._currentModel.references.length);
  83579. this._currentMessage = this._notificationService.status(message);
  83580. };
  83581. SymbolNavigationService = __decorate([
  83582. __param(0, contextkey_1.IContextKeyService),
  83583. __param(1, codeEditorService_1.ICodeEditorService),
  83584. __param(2, notification_1.INotificationService),
  83585. __param(3, keybinding_1.IKeybindingService)
  83586. ], SymbolNavigationService);
  83587. return SymbolNavigationService;
  83588. }());
  83589. extensions_1.registerSingleton(exports.ISymbolNavigationService, SymbolNavigationService, true);
  83590. editorExtensions_1.registerEditorCommand(new /** @class */ (function (_super) {
  83591. __extends(class_1, _super);
  83592. function class_1() {
  83593. return _super.call(this, {
  83594. id: 'editor.gotoNextSymbolFromResult',
  83595. precondition: exports.ctxHasSymbols,
  83596. kbOpts: {
  83597. weight: 100 /* EditorContrib */,
  83598. primary: 70 /* F12 */
  83599. }
  83600. }) || this;
  83601. }
  83602. class_1.prototype.runEditorCommand = function (accessor, editor) {
  83603. return accessor.get(exports.ISymbolNavigationService).revealNext(editor);
  83604. };
  83605. return class_1;
  83606. }(editorExtensions_1.EditorCommand)));
  83607. keybindingsRegistry_1.KeybindingsRegistry.registerCommandAndKeybindingRule({
  83608. id: 'editor.gotoNextSymbolFromResult.cancel',
  83609. weight: 100 /* EditorContrib */,
  83610. when: exports.ctxHasSymbols,
  83611. primary: 9 /* Escape */,
  83612. handler: function (accessor) {
  83613. accessor.get(exports.ISymbolNavigationService).reset();
  83614. }
  83615. });
  83616. //
  83617. var EditorState = /** @class */ (function () {
  83618. function EditorState(editorService) {
  83619. this._listener = new Map();
  83620. this._disposables = new lifecycle_1.DisposableStore();
  83621. this._onDidChange = new event_1.Emitter();
  83622. this.onDidChange = this._onDidChange.event;
  83623. this._disposables.add(editorService.onCodeEditorRemove(this._onDidRemoveEditor, this));
  83624. this._disposables.add(editorService.onCodeEditorAdd(this._onDidAddEditor, this));
  83625. editorService.listCodeEditors().forEach(this._onDidAddEditor, this);
  83626. }
  83627. EditorState.prototype.dispose = function () {
  83628. this._disposables.dispose();
  83629. this._onDidChange.dispose();
  83630. this._listener.forEach(lifecycle_1.dispose);
  83631. };
  83632. EditorState.prototype._onDidAddEditor = function (editor) {
  83633. var _this = this;
  83634. this._listener.set(editor, lifecycle_1.combinedDisposable(editor.onDidChangeCursorPosition(function (_) { return _this._onDidChange.fire({ editor: editor }); }), editor.onDidChangeModelContent(function (_) { return _this._onDidChange.fire({ editor: editor }); })));
  83635. };
  83636. EditorState.prototype._onDidRemoveEditor = function (editor) {
  83637. lifecycle_1.dispose(this._listener.get(editor));
  83638. this._listener.delete(editor);
  83639. };
  83640. EditorState = __decorate([
  83641. __param(0, codeEditorService_1.ICodeEditorService)
  83642. ], EditorState);
  83643. return EditorState;
  83644. }());
  83645. });
  83646. /*---------------------------------------------------------------------------------------------
  83647. * Copyright (c) Microsoft Corporation. All rights reserved.
  83648. * Licensed under the MIT License. See License.txt in the project root for license information.
  83649. *--------------------------------------------------------------------------------------------*/
  83650. define(__m[538/*vs/editor/contrib/hover/getHover*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,26/*vs/base/common/cancellation*/,10/*vs/base/common/errors*/,12/*vs/editor/browser/editorExtensions*/,17/*vs/editor/common/modes*/]), function (require, exports, arrays_1, cancellation_1, errors_1, editorExtensions_1, modes_1) {
  83651. "use strict";
  83652. Object.defineProperty(exports, "__esModule", { value: true });
  83653. function getHover(model, position, token) {
  83654. var supports = modes_1.HoverProviderRegistry.ordered(model);
  83655. var promises = supports.map(function (support) {
  83656. return Promise.resolve(support.provideHover(model, position, token)).then(function (hover) {
  83657. return hover && isValid(hover) ? hover : undefined;
  83658. }, function (err) {
  83659. errors_1.onUnexpectedExternalError(err);
  83660. return undefined;
  83661. });
  83662. });
  83663. return Promise.all(promises).then(arrays_1.coalesce);
  83664. }
  83665. exports.getHover = getHover;
  83666. editorExtensions_1.registerModelAndPositionCommand('_executeHoverProvider', function (model, position) { return getHover(model, position, cancellation_1.CancellationToken.None); });
  83667. function isValid(result) {
  83668. var hasRange = (typeof result.range !== 'undefined');
  83669. var hasHtmlContent = typeof result.contents !== 'undefined' && result.contents && result.contents.length > 0;
  83670. return hasRange && hasHtmlContent;
  83671. }
  83672. });
  83673. /*---------------------------------------------------------------------------------------------
  83674. * Copyright (c) Microsoft Corporation. All rights reserved.
  83675. * Licensed under the MIT License. See License.txt in the project root for license information.
  83676. *--------------------------------------------------------------------------------------------*/
  83677. define(__m[539/*vs/editor/contrib/linesOperations/linesOperations*/], __M([0/*require*/,1/*exports*/,456/*vs/nls!vs/editor/contrib/linesOperations/linesOperations*/,36/*vs/base/common/keyCodes*/,164/*vs/editor/browser/controller/coreCommands*/,12/*vs/editor/browser/editorExtensions*/,80/*vs/editor/common/commands/replaceCommand*/,338/*vs/editor/common/commands/trimTrailingWhitespaceCommand*/,159/*vs/editor/common/controller/cursorTypeOperations*/,58/*vs/editor/common/core/editOperation*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,23/*vs/editor/common/editorContextKeys*/,386/*vs/editor/contrib/linesOperations/copyLinesCommand*/,492/*vs/editor/contrib/linesOperations/moveLinesCommand*/,387/*vs/editor/contrib/linesOperations/sortLinesCommand*/]), function (require, exports, nls, keyCodes_1, coreCommands_1, editorExtensions_1, replaceCommand_1, trimTrailingWhitespaceCommand_1, cursorTypeOperations_1, editOperation_1, position_1, range_1, selection_1, editorContextKeys_1, copyLinesCommand_1, moveLinesCommand_1, sortLinesCommand_1) {
  83678. "use strict";
  83679. Object.defineProperty(exports, "__esModule", { value: true });
  83680. // copy lines
  83681. var AbstractCopyLinesAction = /** @class */ (function (_super) {
  83682. __extends(AbstractCopyLinesAction, _super);
  83683. function AbstractCopyLinesAction(down, opts) {
  83684. var _this = _super.call(this, opts) || this;
  83685. _this.down = down;
  83686. return _this;
  83687. }
  83688. AbstractCopyLinesAction.prototype.run = function (_accessor, editor) {
  83689. var commands = [];
  83690. var selections = editor.getSelections() || [];
  83691. for (var _i = 0, selections_1 = selections; _i < selections_1.length; _i++) {
  83692. var selection = selections_1[_i];
  83693. commands.push(new copyLinesCommand_1.CopyLinesCommand(selection, this.down));
  83694. }
  83695. editor.pushUndoStop();
  83696. editor.executeCommands(this.id, commands);
  83697. editor.pushUndoStop();
  83698. };
  83699. return AbstractCopyLinesAction;
  83700. }(editorExtensions_1.EditorAction));
  83701. var CopyLinesUpAction = /** @class */ (function (_super) {
  83702. __extends(CopyLinesUpAction, _super);
  83703. function CopyLinesUpAction() {
  83704. return _super.call(this, false, {
  83705. id: 'editor.action.copyLinesUpAction',
  83706. label: nls.localize(0, null),
  83707. alias: 'Copy Line Up',
  83708. precondition: editorContextKeys_1.EditorContextKeys.writable,
  83709. kbOpts: {
  83710. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  83711. primary: 512 /* Alt */ | 1024 /* Shift */ | 16 /* UpArrow */,
  83712. linux: { primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 1024 /* Shift */ | 16 /* UpArrow */ },
  83713. weight: 100 /* EditorContrib */
  83714. },
  83715. menuOpts: {
  83716. menuId: 25 /* MenubarSelectionMenu */,
  83717. group: '2_line',
  83718. title: nls.localize(1, null),
  83719. order: 1
  83720. }
  83721. }) || this;
  83722. }
  83723. return CopyLinesUpAction;
  83724. }(AbstractCopyLinesAction));
  83725. var CopyLinesDownAction = /** @class */ (function (_super) {
  83726. __extends(CopyLinesDownAction, _super);
  83727. function CopyLinesDownAction() {
  83728. return _super.call(this, true, {
  83729. id: 'editor.action.copyLinesDownAction',
  83730. label: nls.localize(2, null),
  83731. alias: 'Copy Line Down',
  83732. precondition: editorContextKeys_1.EditorContextKeys.writable,
  83733. kbOpts: {
  83734. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  83735. primary: 512 /* Alt */ | 1024 /* Shift */ | 18 /* DownArrow */,
  83736. linux: { primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 1024 /* Shift */ | 18 /* DownArrow */ },
  83737. weight: 100 /* EditorContrib */
  83738. },
  83739. menuOpts: {
  83740. menuId: 25 /* MenubarSelectionMenu */,
  83741. group: '2_line',
  83742. title: nls.localize(3, null),
  83743. order: 2
  83744. }
  83745. }) || this;
  83746. }
  83747. return CopyLinesDownAction;
  83748. }(AbstractCopyLinesAction));
  83749. var DuplicateSelectionAction = /** @class */ (function (_super) {
  83750. __extends(DuplicateSelectionAction, _super);
  83751. function DuplicateSelectionAction() {
  83752. return _super.call(this, {
  83753. id: 'editor.action.duplicateSelection',
  83754. label: nls.localize(4, null),
  83755. alias: 'Duplicate Selection',
  83756. precondition: editorContextKeys_1.EditorContextKeys.writable,
  83757. menuOpts: {
  83758. menuId: 25 /* MenubarSelectionMenu */,
  83759. group: '2_line',
  83760. title: nls.localize(5, null),
  83761. order: 5
  83762. }
  83763. }) || this;
  83764. }
  83765. DuplicateSelectionAction.prototype.run = function (accessor, editor, args) {
  83766. if (!editor.hasModel()) {
  83767. return;
  83768. }
  83769. var commands = [];
  83770. var selections = editor.getSelections();
  83771. var model = editor.getModel();
  83772. for (var _i = 0, selections_2 = selections; _i < selections_2.length; _i++) {
  83773. var selection = selections_2[_i];
  83774. if (selection.isEmpty()) {
  83775. commands.push(new copyLinesCommand_1.CopyLinesCommand(selection, true));
  83776. }
  83777. else {
  83778. var insertSelection = new selection_1.Selection(selection.endLineNumber, selection.endColumn, selection.endLineNumber, selection.endColumn);
  83779. commands.push(new replaceCommand_1.ReplaceCommandThatSelectsText(insertSelection, model.getValueInRange(selection)));
  83780. }
  83781. }
  83782. editor.pushUndoStop();
  83783. editor.executeCommands(this.id, commands);
  83784. editor.pushUndoStop();
  83785. };
  83786. return DuplicateSelectionAction;
  83787. }(editorExtensions_1.EditorAction));
  83788. exports.DuplicateSelectionAction = DuplicateSelectionAction;
  83789. // move lines
  83790. var AbstractMoveLinesAction = /** @class */ (function (_super) {
  83791. __extends(AbstractMoveLinesAction, _super);
  83792. function AbstractMoveLinesAction(down, opts) {
  83793. var _this = _super.call(this, opts) || this;
  83794. _this.down = down;
  83795. return _this;
  83796. }
  83797. AbstractMoveLinesAction.prototype.run = function (_accessor, editor) {
  83798. var commands = [];
  83799. var selections = editor.getSelections() || [];
  83800. var autoIndent = editor.getOption(8 /* autoIndent */);
  83801. for (var _i = 0, selections_3 = selections; _i < selections_3.length; _i++) {
  83802. var selection = selections_3[_i];
  83803. commands.push(new moveLinesCommand_1.MoveLinesCommand(selection, this.down, autoIndent));
  83804. }
  83805. editor.pushUndoStop();
  83806. editor.executeCommands(this.id, commands);
  83807. editor.pushUndoStop();
  83808. };
  83809. return AbstractMoveLinesAction;
  83810. }(editorExtensions_1.EditorAction));
  83811. var MoveLinesUpAction = /** @class */ (function (_super) {
  83812. __extends(MoveLinesUpAction, _super);
  83813. function MoveLinesUpAction() {
  83814. return _super.call(this, false, {
  83815. id: 'editor.action.moveLinesUpAction',
  83816. label: nls.localize(6, null),
  83817. alias: 'Move Line Up',
  83818. precondition: editorContextKeys_1.EditorContextKeys.writable,
  83819. kbOpts: {
  83820. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  83821. primary: 512 /* Alt */ | 16 /* UpArrow */,
  83822. linux: { primary: 512 /* Alt */ | 16 /* UpArrow */ },
  83823. weight: 100 /* EditorContrib */
  83824. },
  83825. menuOpts: {
  83826. menuId: 25 /* MenubarSelectionMenu */,
  83827. group: '2_line',
  83828. title: nls.localize(7, null),
  83829. order: 3
  83830. }
  83831. }) || this;
  83832. }
  83833. return MoveLinesUpAction;
  83834. }(AbstractMoveLinesAction));
  83835. var MoveLinesDownAction = /** @class */ (function (_super) {
  83836. __extends(MoveLinesDownAction, _super);
  83837. function MoveLinesDownAction() {
  83838. return _super.call(this, true, {
  83839. id: 'editor.action.moveLinesDownAction',
  83840. label: nls.localize(8, null),
  83841. alias: 'Move Line Down',
  83842. precondition: editorContextKeys_1.EditorContextKeys.writable,
  83843. kbOpts: {
  83844. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  83845. primary: 512 /* Alt */ | 18 /* DownArrow */,
  83846. linux: { primary: 512 /* Alt */ | 18 /* DownArrow */ },
  83847. weight: 100 /* EditorContrib */
  83848. },
  83849. menuOpts: {
  83850. menuId: 25 /* MenubarSelectionMenu */,
  83851. group: '2_line',
  83852. title: nls.localize(9, null),
  83853. order: 4
  83854. }
  83855. }) || this;
  83856. }
  83857. return MoveLinesDownAction;
  83858. }(AbstractMoveLinesAction));
  83859. var AbstractSortLinesAction = /** @class */ (function (_super) {
  83860. __extends(AbstractSortLinesAction, _super);
  83861. function AbstractSortLinesAction(descending, opts) {
  83862. var _this = _super.call(this, opts) || this;
  83863. _this.descending = descending;
  83864. return _this;
  83865. }
  83866. AbstractSortLinesAction.prototype.run = function (_accessor, editor) {
  83867. var selections = editor.getSelections() || [];
  83868. for (var _i = 0, selections_4 = selections; _i < selections_4.length; _i++) {
  83869. var selection = selections_4[_i];
  83870. if (!sortLinesCommand_1.SortLinesCommand.canRun(editor.getModel(), selection, this.descending)) {
  83871. return;
  83872. }
  83873. }
  83874. var commands = [];
  83875. for (var i = 0, len = selections.length; i < len; i++) {
  83876. commands[i] = new sortLinesCommand_1.SortLinesCommand(selections[i], this.descending);
  83877. }
  83878. editor.pushUndoStop();
  83879. editor.executeCommands(this.id, commands);
  83880. editor.pushUndoStop();
  83881. };
  83882. return AbstractSortLinesAction;
  83883. }(editorExtensions_1.EditorAction));
  83884. exports.AbstractSortLinesAction = AbstractSortLinesAction;
  83885. var SortLinesAscendingAction = /** @class */ (function (_super) {
  83886. __extends(SortLinesAscendingAction, _super);
  83887. function SortLinesAscendingAction() {
  83888. return _super.call(this, false, {
  83889. id: 'editor.action.sortLinesAscending',
  83890. label: nls.localize(10, null),
  83891. alias: 'Sort Lines Ascending',
  83892. precondition: editorContextKeys_1.EditorContextKeys.writable
  83893. }) || this;
  83894. }
  83895. return SortLinesAscendingAction;
  83896. }(AbstractSortLinesAction));
  83897. exports.SortLinesAscendingAction = SortLinesAscendingAction;
  83898. var SortLinesDescendingAction = /** @class */ (function (_super) {
  83899. __extends(SortLinesDescendingAction, _super);
  83900. function SortLinesDescendingAction() {
  83901. return _super.call(this, true, {
  83902. id: 'editor.action.sortLinesDescending',
  83903. label: nls.localize(11, null),
  83904. alias: 'Sort Lines Descending',
  83905. precondition: editorContextKeys_1.EditorContextKeys.writable
  83906. }) || this;
  83907. }
  83908. return SortLinesDescendingAction;
  83909. }(AbstractSortLinesAction));
  83910. exports.SortLinesDescendingAction = SortLinesDescendingAction;
  83911. var TrimTrailingWhitespaceAction = /** @class */ (function (_super) {
  83912. __extends(TrimTrailingWhitespaceAction, _super);
  83913. function TrimTrailingWhitespaceAction() {
  83914. return _super.call(this, {
  83915. id: TrimTrailingWhitespaceAction.ID,
  83916. label: nls.localize(12, null),
  83917. alias: 'Trim Trailing Whitespace',
  83918. precondition: editorContextKeys_1.EditorContextKeys.writable,
  83919. kbOpts: {
  83920. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  83921. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 54 /* KEY_X */),
  83922. weight: 100 /* EditorContrib */
  83923. }
  83924. }) || this;
  83925. }
  83926. TrimTrailingWhitespaceAction.prototype.run = function (_accessor, editor, args) {
  83927. var cursors = [];
  83928. if (args.reason === 'auto-save') {
  83929. // See https://github.com/editorconfig/editorconfig-vscode/issues/47
  83930. // It is very convenient for the editor config extension to invoke this action.
  83931. // So, if we get a reason:'auto-save' passed in, let's preserve cursor positions.
  83932. cursors = (editor.getSelections() || []).map(function (s) { return new position_1.Position(s.positionLineNumber, s.positionColumn); });
  83933. }
  83934. var selection = editor.getSelection();
  83935. if (selection === null) {
  83936. return;
  83937. }
  83938. var command = new trimTrailingWhitespaceCommand_1.TrimTrailingWhitespaceCommand(selection, cursors);
  83939. editor.pushUndoStop();
  83940. editor.executeCommands(this.id, [command]);
  83941. editor.pushUndoStop();
  83942. };
  83943. TrimTrailingWhitespaceAction.ID = 'editor.action.trimTrailingWhitespace';
  83944. return TrimTrailingWhitespaceAction;
  83945. }(editorExtensions_1.EditorAction));
  83946. exports.TrimTrailingWhitespaceAction = TrimTrailingWhitespaceAction;
  83947. var DeleteLinesAction = /** @class */ (function (_super) {
  83948. __extends(DeleteLinesAction, _super);
  83949. function DeleteLinesAction() {
  83950. return _super.call(this, {
  83951. id: 'editor.action.deleteLines',
  83952. label: nls.localize(13, null),
  83953. alias: 'Delete Line',
  83954. precondition: editorContextKeys_1.EditorContextKeys.writable,
  83955. kbOpts: {
  83956. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  83957. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 41 /* KEY_K */,
  83958. weight: 100 /* EditorContrib */
  83959. }
  83960. }) || this;
  83961. }
  83962. DeleteLinesAction.prototype.run = function (_accessor, editor) {
  83963. if (!editor.hasModel()) {
  83964. return;
  83965. }
  83966. var ops = this._getLinesToRemove(editor);
  83967. var model = editor.getModel();
  83968. if (model.getLineCount() === 1 && model.getLineMaxColumn(1) === 1) {
  83969. // Model is empty
  83970. return;
  83971. }
  83972. var linesDeleted = 0;
  83973. var edits = [];
  83974. var cursorState = [];
  83975. for (var i = 0, len = ops.length; i < len; i++) {
  83976. var op = ops[i];
  83977. var startLineNumber = op.startLineNumber;
  83978. var endLineNumber = op.endLineNumber;
  83979. var startColumn = 1;
  83980. var endColumn = model.getLineMaxColumn(endLineNumber);
  83981. if (endLineNumber < model.getLineCount()) {
  83982. endLineNumber += 1;
  83983. endColumn = 1;
  83984. }
  83985. else if (startLineNumber > 1) {
  83986. startLineNumber -= 1;
  83987. startColumn = model.getLineMaxColumn(startLineNumber);
  83988. }
  83989. edits.push(editOperation_1.EditOperation.replace(new selection_1.Selection(startLineNumber, startColumn, endLineNumber, endColumn), ''));
  83990. cursorState.push(new selection_1.Selection(startLineNumber - linesDeleted, op.positionColumn, startLineNumber - linesDeleted, op.positionColumn));
  83991. linesDeleted += (op.endLineNumber - op.startLineNumber + 1);
  83992. }
  83993. editor.pushUndoStop();
  83994. editor.executeEdits(this.id, edits, cursorState);
  83995. editor.pushUndoStop();
  83996. };
  83997. DeleteLinesAction.prototype._getLinesToRemove = function (editor) {
  83998. // Construct delete operations
  83999. var operations = editor.getSelections().map(function (s) {
  84000. var endLineNumber = s.endLineNumber;
  84001. if (s.startLineNumber < s.endLineNumber && s.endColumn === 1) {
  84002. endLineNumber -= 1;
  84003. }
  84004. return {
  84005. startLineNumber: s.startLineNumber,
  84006. selectionStartColumn: s.selectionStartColumn,
  84007. endLineNumber: endLineNumber,
  84008. positionColumn: s.positionColumn
  84009. };
  84010. });
  84011. // Sort delete operations
  84012. operations.sort(function (a, b) {
  84013. if (a.startLineNumber === b.startLineNumber) {
  84014. return a.endLineNumber - b.endLineNumber;
  84015. }
  84016. return a.startLineNumber - b.startLineNumber;
  84017. });
  84018. // Merge delete operations which are adjacent or overlapping
  84019. var mergedOperations = [];
  84020. var previousOperation = operations[0];
  84021. for (var i = 1; i < operations.length; i++) {
  84022. if (previousOperation.endLineNumber + 1 >= operations[i].startLineNumber) {
  84023. // Merge current operations into the previous one
  84024. previousOperation.endLineNumber = operations[i].endLineNumber;
  84025. }
  84026. else {
  84027. // Push previous operation
  84028. mergedOperations.push(previousOperation);
  84029. previousOperation = operations[i];
  84030. }
  84031. }
  84032. // Push the last operation
  84033. mergedOperations.push(previousOperation);
  84034. return mergedOperations;
  84035. };
  84036. return DeleteLinesAction;
  84037. }(editorExtensions_1.EditorAction));
  84038. exports.DeleteLinesAction = DeleteLinesAction;
  84039. var IndentLinesAction = /** @class */ (function (_super) {
  84040. __extends(IndentLinesAction, _super);
  84041. function IndentLinesAction() {
  84042. return _super.call(this, {
  84043. id: 'editor.action.indentLines',
  84044. label: nls.localize(14, null),
  84045. alias: 'Indent Line',
  84046. precondition: editorContextKeys_1.EditorContextKeys.writable,
  84047. kbOpts: {
  84048. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  84049. primary: 2048 /* CtrlCmd */ | 89 /* US_CLOSE_SQUARE_BRACKET */,
  84050. weight: 100 /* EditorContrib */
  84051. }
  84052. }) || this;
  84053. }
  84054. IndentLinesAction.prototype.run = function (_accessor, editor) {
  84055. var cursors = editor._getCursors();
  84056. if (!cursors) {
  84057. return;
  84058. }
  84059. editor.pushUndoStop();
  84060. editor.executeCommands(this.id, cursorTypeOperations_1.TypeOperations.indent(cursors.context.config, editor.getModel(), editor.getSelections()));
  84061. editor.pushUndoStop();
  84062. };
  84063. return IndentLinesAction;
  84064. }(editorExtensions_1.EditorAction));
  84065. exports.IndentLinesAction = IndentLinesAction;
  84066. var OutdentLinesAction = /** @class */ (function (_super) {
  84067. __extends(OutdentLinesAction, _super);
  84068. function OutdentLinesAction() {
  84069. return _super.call(this, {
  84070. id: 'editor.action.outdentLines',
  84071. label: nls.localize(15, null),
  84072. alias: 'Outdent Line',
  84073. precondition: editorContextKeys_1.EditorContextKeys.writable,
  84074. kbOpts: {
  84075. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  84076. primary: 2048 /* CtrlCmd */ | 87 /* US_OPEN_SQUARE_BRACKET */,
  84077. weight: 100 /* EditorContrib */
  84078. }
  84079. }) || this;
  84080. }
  84081. OutdentLinesAction.prototype.run = function (_accessor, editor) {
  84082. coreCommands_1.CoreEditingCommands.Outdent.runEditorCommand(_accessor, editor, null);
  84083. };
  84084. return OutdentLinesAction;
  84085. }(editorExtensions_1.EditorAction));
  84086. var InsertLineBeforeAction = /** @class */ (function (_super) {
  84087. __extends(InsertLineBeforeAction, _super);
  84088. function InsertLineBeforeAction() {
  84089. return _super.call(this, {
  84090. id: 'editor.action.insertLineBefore',
  84091. label: nls.localize(16, null),
  84092. alias: 'Insert Line Above',
  84093. precondition: editorContextKeys_1.EditorContextKeys.writable,
  84094. kbOpts: {
  84095. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  84096. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 3 /* Enter */,
  84097. weight: 100 /* EditorContrib */
  84098. }
  84099. }) || this;
  84100. }
  84101. InsertLineBeforeAction.prototype.run = function (_accessor, editor) {
  84102. var cursors = editor._getCursors();
  84103. if (!cursors) {
  84104. return;
  84105. }
  84106. editor.pushUndoStop();
  84107. editor.executeCommands(this.id, cursorTypeOperations_1.TypeOperations.lineInsertBefore(cursors.context.config, editor.getModel(), editor.getSelections()));
  84108. };
  84109. return InsertLineBeforeAction;
  84110. }(editorExtensions_1.EditorAction));
  84111. exports.InsertLineBeforeAction = InsertLineBeforeAction;
  84112. var InsertLineAfterAction = /** @class */ (function (_super) {
  84113. __extends(InsertLineAfterAction, _super);
  84114. function InsertLineAfterAction() {
  84115. return _super.call(this, {
  84116. id: 'editor.action.insertLineAfter',
  84117. label: nls.localize(17, null),
  84118. alias: 'Insert Line Below',
  84119. precondition: editorContextKeys_1.EditorContextKeys.writable,
  84120. kbOpts: {
  84121. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  84122. primary: 2048 /* CtrlCmd */ | 3 /* Enter */,
  84123. weight: 100 /* EditorContrib */
  84124. }
  84125. }) || this;
  84126. }
  84127. InsertLineAfterAction.prototype.run = function (_accessor, editor) {
  84128. var cursors = editor._getCursors();
  84129. if (!cursors) {
  84130. return;
  84131. }
  84132. editor.pushUndoStop();
  84133. editor.executeCommands(this.id, cursorTypeOperations_1.TypeOperations.lineInsertAfter(cursors.context.config, editor.getModel(), editor.getSelections()));
  84134. };
  84135. return InsertLineAfterAction;
  84136. }(editorExtensions_1.EditorAction));
  84137. exports.InsertLineAfterAction = InsertLineAfterAction;
  84138. var AbstractDeleteAllToBoundaryAction = /** @class */ (function (_super) {
  84139. __extends(AbstractDeleteAllToBoundaryAction, _super);
  84140. function AbstractDeleteAllToBoundaryAction() {
  84141. return _super !== null && _super.apply(this, arguments) || this;
  84142. }
  84143. AbstractDeleteAllToBoundaryAction.prototype.run = function (_accessor, editor) {
  84144. if (!editor.hasModel()) {
  84145. return;
  84146. }
  84147. var primaryCursor = editor.getSelection();
  84148. var rangesToDelete = this._getRangesToDelete(editor);
  84149. // merge overlapping selections
  84150. var effectiveRanges = [];
  84151. for (var i = 0, count = rangesToDelete.length - 1; i < count; i++) {
  84152. var range = rangesToDelete[i];
  84153. var nextRange = rangesToDelete[i + 1];
  84154. if (range_1.Range.intersectRanges(range, nextRange) === null) {
  84155. effectiveRanges.push(range);
  84156. }
  84157. else {
  84158. rangesToDelete[i + 1] = range_1.Range.plusRange(range, nextRange);
  84159. }
  84160. }
  84161. effectiveRanges.push(rangesToDelete[rangesToDelete.length - 1]);
  84162. var endCursorState = this._getEndCursorState(primaryCursor, effectiveRanges);
  84163. var edits = effectiveRanges.map(function (range) {
  84164. return editOperation_1.EditOperation.replace(range, '');
  84165. });
  84166. editor.pushUndoStop();
  84167. editor.executeEdits(this.id, edits, endCursorState);
  84168. editor.pushUndoStop();
  84169. };
  84170. return AbstractDeleteAllToBoundaryAction;
  84171. }(editorExtensions_1.EditorAction));
  84172. exports.AbstractDeleteAllToBoundaryAction = AbstractDeleteAllToBoundaryAction;
  84173. var DeleteAllLeftAction = /** @class */ (function (_super) {
  84174. __extends(DeleteAllLeftAction, _super);
  84175. function DeleteAllLeftAction() {
  84176. return _super.call(this, {
  84177. id: 'deleteAllLeft',
  84178. label: nls.localize(18, null),
  84179. alias: 'Delete All Left',
  84180. precondition: editorContextKeys_1.EditorContextKeys.writable,
  84181. kbOpts: {
  84182. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  84183. primary: 0,
  84184. mac: { primary: 2048 /* CtrlCmd */ | 1 /* Backspace */ },
  84185. weight: 100 /* EditorContrib */
  84186. }
  84187. }) || this;
  84188. }
  84189. DeleteAllLeftAction.prototype._getEndCursorState = function (primaryCursor, rangesToDelete) {
  84190. var endPrimaryCursor = null;
  84191. var endCursorState = [];
  84192. var deletedLines = 0;
  84193. rangesToDelete.forEach(function (range) {
  84194. var endCursor;
  84195. if (range.endColumn === 1 && deletedLines > 0) {
  84196. var newStartLine = range.startLineNumber - deletedLines;
  84197. endCursor = new selection_1.Selection(newStartLine, range.startColumn, newStartLine, range.startColumn);
  84198. }
  84199. else {
  84200. endCursor = new selection_1.Selection(range.startLineNumber, range.startColumn, range.startLineNumber, range.startColumn);
  84201. }
  84202. deletedLines += range.endLineNumber - range.startLineNumber;
  84203. if (range.intersectRanges(primaryCursor)) {
  84204. endPrimaryCursor = endCursor;
  84205. }
  84206. else {
  84207. endCursorState.push(endCursor);
  84208. }
  84209. });
  84210. if (endPrimaryCursor) {
  84211. endCursorState.unshift(endPrimaryCursor);
  84212. }
  84213. return endCursorState;
  84214. };
  84215. DeleteAllLeftAction.prototype._getRangesToDelete = function (editor) {
  84216. var selections = editor.getSelections();
  84217. if (selections === null) {
  84218. return [];
  84219. }
  84220. var rangesToDelete = selections;
  84221. var model = editor.getModel();
  84222. if (model === null) {
  84223. return [];
  84224. }
  84225. rangesToDelete.sort(range_1.Range.compareRangesUsingStarts);
  84226. rangesToDelete = rangesToDelete.map(function (selection) {
  84227. if (selection.isEmpty()) {
  84228. if (selection.startColumn === 1) {
  84229. var deleteFromLine = Math.max(1, selection.startLineNumber - 1);
  84230. var deleteFromColumn = selection.startLineNumber === 1 ? 1 : model.getLineContent(deleteFromLine).length + 1;
  84231. return new range_1.Range(deleteFromLine, deleteFromColumn, selection.startLineNumber, 1);
  84232. }
  84233. else {
  84234. return new range_1.Range(selection.startLineNumber, 1, selection.startLineNumber, selection.startColumn);
  84235. }
  84236. }
  84237. else {
  84238. return new range_1.Range(selection.startLineNumber, 1, selection.endLineNumber, selection.endColumn);
  84239. }
  84240. });
  84241. return rangesToDelete;
  84242. };
  84243. return DeleteAllLeftAction;
  84244. }(AbstractDeleteAllToBoundaryAction));
  84245. exports.DeleteAllLeftAction = DeleteAllLeftAction;
  84246. var DeleteAllRightAction = /** @class */ (function (_super) {
  84247. __extends(DeleteAllRightAction, _super);
  84248. function DeleteAllRightAction() {
  84249. return _super.call(this, {
  84250. id: 'deleteAllRight',
  84251. label: nls.localize(19, null),
  84252. alias: 'Delete All Right',
  84253. precondition: editorContextKeys_1.EditorContextKeys.writable,
  84254. kbOpts: {
  84255. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  84256. primary: 0,
  84257. mac: { primary: 256 /* WinCtrl */ | 41 /* KEY_K */, secondary: [2048 /* CtrlCmd */ | 20 /* Delete */] },
  84258. weight: 100 /* EditorContrib */
  84259. }
  84260. }) || this;
  84261. }
  84262. DeleteAllRightAction.prototype._getEndCursorState = function (primaryCursor, rangesToDelete) {
  84263. var endPrimaryCursor = null;
  84264. var endCursorState = [];
  84265. for (var i = 0, len = rangesToDelete.length, offset = 0; i < len; i++) {
  84266. var range = rangesToDelete[i];
  84267. var endCursor = new selection_1.Selection(range.startLineNumber - offset, range.startColumn, range.startLineNumber - offset, range.startColumn);
  84268. if (range.intersectRanges(primaryCursor)) {
  84269. endPrimaryCursor = endCursor;
  84270. }
  84271. else {
  84272. endCursorState.push(endCursor);
  84273. }
  84274. }
  84275. if (endPrimaryCursor) {
  84276. endCursorState.unshift(endPrimaryCursor);
  84277. }
  84278. return endCursorState;
  84279. };
  84280. DeleteAllRightAction.prototype._getRangesToDelete = function (editor) {
  84281. var model = editor.getModel();
  84282. if (model === null) {
  84283. return [];
  84284. }
  84285. var selections = editor.getSelections();
  84286. if (selections === null) {
  84287. return [];
  84288. }
  84289. var rangesToDelete = selections.map(function (sel) {
  84290. if (sel.isEmpty()) {
  84291. var maxColumn = model.getLineMaxColumn(sel.startLineNumber);
  84292. if (sel.startColumn === maxColumn) {
  84293. return new range_1.Range(sel.startLineNumber, sel.startColumn, sel.startLineNumber + 1, 1);
  84294. }
  84295. else {
  84296. return new range_1.Range(sel.startLineNumber, sel.startColumn, sel.startLineNumber, maxColumn);
  84297. }
  84298. }
  84299. return sel;
  84300. });
  84301. rangesToDelete.sort(range_1.Range.compareRangesUsingStarts);
  84302. return rangesToDelete;
  84303. };
  84304. return DeleteAllRightAction;
  84305. }(AbstractDeleteAllToBoundaryAction));
  84306. exports.DeleteAllRightAction = DeleteAllRightAction;
  84307. var JoinLinesAction = /** @class */ (function (_super) {
  84308. __extends(JoinLinesAction, _super);
  84309. function JoinLinesAction() {
  84310. return _super.call(this, {
  84311. id: 'editor.action.joinLines',
  84312. label: nls.localize(20, null),
  84313. alias: 'Join Lines',
  84314. precondition: editorContextKeys_1.EditorContextKeys.writable,
  84315. kbOpts: {
  84316. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  84317. primary: 0,
  84318. mac: { primary: 256 /* WinCtrl */ | 40 /* KEY_J */ },
  84319. weight: 100 /* EditorContrib */
  84320. }
  84321. }) || this;
  84322. }
  84323. JoinLinesAction.prototype.run = function (_accessor, editor) {
  84324. var selections = editor.getSelections();
  84325. if (selections === null) {
  84326. return;
  84327. }
  84328. var primaryCursor = editor.getSelection();
  84329. if (primaryCursor === null) {
  84330. return;
  84331. }
  84332. selections.sort(range_1.Range.compareRangesUsingStarts);
  84333. var reducedSelections = [];
  84334. var lastSelection = selections.reduce(function (previousValue, currentValue) {
  84335. if (previousValue.isEmpty()) {
  84336. if (previousValue.endLineNumber === currentValue.startLineNumber) {
  84337. if (primaryCursor.equalsSelection(previousValue)) {
  84338. primaryCursor = currentValue;
  84339. }
  84340. return currentValue;
  84341. }
  84342. if (currentValue.startLineNumber > previousValue.endLineNumber + 1) {
  84343. reducedSelections.push(previousValue);
  84344. return currentValue;
  84345. }
  84346. else {
  84347. return new selection_1.Selection(previousValue.startLineNumber, previousValue.startColumn, currentValue.endLineNumber, currentValue.endColumn);
  84348. }
  84349. }
  84350. else {
  84351. if (currentValue.startLineNumber > previousValue.endLineNumber) {
  84352. reducedSelections.push(previousValue);
  84353. return currentValue;
  84354. }
  84355. else {
  84356. return new selection_1.Selection(previousValue.startLineNumber, previousValue.startColumn, currentValue.endLineNumber, currentValue.endColumn);
  84357. }
  84358. }
  84359. });
  84360. reducedSelections.push(lastSelection);
  84361. var model = editor.getModel();
  84362. if (model === null) {
  84363. return;
  84364. }
  84365. var edits = [];
  84366. var endCursorState = [];
  84367. var endPrimaryCursor = primaryCursor;
  84368. var lineOffset = 0;
  84369. for (var i = 0, len = reducedSelections.length; i < len; i++) {
  84370. var selection = reducedSelections[i];
  84371. var startLineNumber = selection.startLineNumber;
  84372. var startColumn = 1;
  84373. var columnDeltaOffset = 0;
  84374. var endLineNumber = void 0, endColumn = void 0;
  84375. var selectionEndPositionOffset = model.getLineContent(selection.endLineNumber).length - selection.endColumn;
  84376. if (selection.isEmpty() || selection.startLineNumber === selection.endLineNumber) {
  84377. var position = selection.getStartPosition();
  84378. if (position.lineNumber < model.getLineCount()) {
  84379. endLineNumber = startLineNumber + 1;
  84380. endColumn = model.getLineMaxColumn(endLineNumber);
  84381. }
  84382. else {
  84383. endLineNumber = position.lineNumber;
  84384. endColumn = model.getLineMaxColumn(position.lineNumber);
  84385. }
  84386. }
  84387. else {
  84388. endLineNumber = selection.endLineNumber;
  84389. endColumn = model.getLineMaxColumn(endLineNumber);
  84390. }
  84391. var trimmedLinesContent = model.getLineContent(startLineNumber);
  84392. for (var i_1 = startLineNumber + 1; i_1 <= endLineNumber; i_1++) {
  84393. var lineText = model.getLineContent(i_1);
  84394. var firstNonWhitespaceIdx = model.getLineFirstNonWhitespaceColumn(i_1);
  84395. if (firstNonWhitespaceIdx >= 1) {
  84396. var insertSpace = true;
  84397. if (trimmedLinesContent === '') {
  84398. insertSpace = false;
  84399. }
  84400. if (insertSpace && (trimmedLinesContent.charAt(trimmedLinesContent.length - 1) === ' ' ||
  84401. trimmedLinesContent.charAt(trimmedLinesContent.length - 1) === '\t')) {
  84402. insertSpace = false;
  84403. trimmedLinesContent = trimmedLinesContent.replace(/[\s\uFEFF\xA0]+$/g, ' ');
  84404. }
  84405. var lineTextWithoutIndent = lineText.substr(firstNonWhitespaceIdx - 1);
  84406. trimmedLinesContent += (insertSpace ? ' ' : '') + lineTextWithoutIndent;
  84407. if (insertSpace) {
  84408. columnDeltaOffset = lineTextWithoutIndent.length + 1;
  84409. }
  84410. else {
  84411. columnDeltaOffset = lineTextWithoutIndent.length;
  84412. }
  84413. }
  84414. else {
  84415. columnDeltaOffset = 0;
  84416. }
  84417. }
  84418. var deleteSelection = new range_1.Range(startLineNumber, startColumn, endLineNumber, endColumn);
  84419. if (!deleteSelection.isEmpty()) {
  84420. var resultSelection = void 0;
  84421. if (selection.isEmpty()) {
  84422. edits.push(editOperation_1.EditOperation.replace(deleteSelection, trimmedLinesContent));
  84423. resultSelection = new selection_1.Selection(deleteSelection.startLineNumber - lineOffset, trimmedLinesContent.length - columnDeltaOffset + 1, startLineNumber - lineOffset, trimmedLinesContent.length - columnDeltaOffset + 1);
  84424. }
  84425. else {
  84426. if (selection.startLineNumber === selection.endLineNumber) {
  84427. edits.push(editOperation_1.EditOperation.replace(deleteSelection, trimmedLinesContent));
  84428. resultSelection = new selection_1.Selection(selection.startLineNumber - lineOffset, selection.startColumn, selection.endLineNumber - lineOffset, selection.endColumn);
  84429. }
  84430. else {
  84431. edits.push(editOperation_1.EditOperation.replace(deleteSelection, trimmedLinesContent));
  84432. resultSelection = new selection_1.Selection(selection.startLineNumber - lineOffset, selection.startColumn, selection.startLineNumber - lineOffset, trimmedLinesContent.length - selectionEndPositionOffset);
  84433. }
  84434. }
  84435. if (range_1.Range.intersectRanges(deleteSelection, primaryCursor) !== null) {
  84436. endPrimaryCursor = resultSelection;
  84437. }
  84438. else {
  84439. endCursorState.push(resultSelection);
  84440. }
  84441. }
  84442. lineOffset += deleteSelection.endLineNumber - deleteSelection.startLineNumber;
  84443. }
  84444. endCursorState.unshift(endPrimaryCursor);
  84445. editor.pushUndoStop();
  84446. editor.executeEdits(this.id, edits, endCursorState);
  84447. editor.pushUndoStop();
  84448. };
  84449. return JoinLinesAction;
  84450. }(editorExtensions_1.EditorAction));
  84451. exports.JoinLinesAction = JoinLinesAction;
  84452. var TransposeAction = /** @class */ (function (_super) {
  84453. __extends(TransposeAction, _super);
  84454. function TransposeAction() {
  84455. return _super.call(this, {
  84456. id: 'editor.action.transpose',
  84457. label: nls.localize(21, null),
  84458. alias: 'Transpose characters around the cursor',
  84459. precondition: editorContextKeys_1.EditorContextKeys.writable
  84460. }) || this;
  84461. }
  84462. TransposeAction.prototype.run = function (_accessor, editor) {
  84463. var selections = editor.getSelections();
  84464. if (selections === null) {
  84465. return;
  84466. }
  84467. var model = editor.getModel();
  84468. if (model === null) {
  84469. return;
  84470. }
  84471. var commands = [];
  84472. for (var i = 0, len = selections.length; i < len; i++) {
  84473. var selection = selections[i];
  84474. if (!selection.isEmpty()) {
  84475. continue;
  84476. }
  84477. var cursor = selection.getStartPosition();
  84478. var maxColumn = model.getLineMaxColumn(cursor.lineNumber);
  84479. if (cursor.column >= maxColumn) {
  84480. if (cursor.lineNumber === model.getLineCount()) {
  84481. continue;
  84482. }
  84483. // The cursor is at the end of current line and current line is not empty
  84484. // then we transpose the character before the cursor and the line break if there is any following line.
  84485. var deleteSelection = new range_1.Range(cursor.lineNumber, Math.max(1, cursor.column - 1), cursor.lineNumber + 1, 1);
  84486. var chars = model.getValueInRange(deleteSelection).split('').reverse().join('');
  84487. commands.push(new replaceCommand_1.ReplaceCommand(new selection_1.Selection(cursor.lineNumber, Math.max(1, cursor.column - 1), cursor.lineNumber + 1, 1), chars));
  84488. }
  84489. else {
  84490. var deleteSelection = new range_1.Range(cursor.lineNumber, Math.max(1, cursor.column - 1), cursor.lineNumber, cursor.column + 1);
  84491. var chars = model.getValueInRange(deleteSelection).split('').reverse().join('');
  84492. commands.push(new replaceCommand_1.ReplaceCommandThatPreservesSelection(deleteSelection, chars, new selection_1.Selection(cursor.lineNumber, cursor.column + 1, cursor.lineNumber, cursor.column + 1)));
  84493. }
  84494. }
  84495. editor.pushUndoStop();
  84496. editor.executeCommands(this.id, commands);
  84497. editor.pushUndoStop();
  84498. };
  84499. return TransposeAction;
  84500. }(editorExtensions_1.EditorAction));
  84501. exports.TransposeAction = TransposeAction;
  84502. var AbstractCaseAction = /** @class */ (function (_super) {
  84503. __extends(AbstractCaseAction, _super);
  84504. function AbstractCaseAction() {
  84505. return _super !== null && _super.apply(this, arguments) || this;
  84506. }
  84507. AbstractCaseAction.prototype.run = function (_accessor, editor) {
  84508. var selections = editor.getSelections();
  84509. if (selections === null) {
  84510. return;
  84511. }
  84512. var model = editor.getModel();
  84513. if (model === null) {
  84514. return;
  84515. }
  84516. var wordSeparators = editor.getOption(96 /* wordSeparators */);
  84517. var commands = [];
  84518. for (var i = 0, len = selections.length; i < len; i++) {
  84519. var selection = selections[i];
  84520. if (selection.isEmpty()) {
  84521. var cursor = selection.getStartPosition();
  84522. var word = model.getWordAtPosition(cursor);
  84523. if (!word) {
  84524. continue;
  84525. }
  84526. var wordRange = new range_1.Range(cursor.lineNumber, word.startColumn, cursor.lineNumber, word.endColumn);
  84527. var text = model.getValueInRange(wordRange);
  84528. commands.push(new replaceCommand_1.ReplaceCommandThatPreservesSelection(wordRange, this._modifyText(text, wordSeparators), new selection_1.Selection(cursor.lineNumber, cursor.column, cursor.lineNumber, cursor.column)));
  84529. }
  84530. else {
  84531. var text = model.getValueInRange(selection);
  84532. commands.push(new replaceCommand_1.ReplaceCommandThatPreservesSelection(selection, this._modifyText(text, wordSeparators), selection));
  84533. }
  84534. }
  84535. editor.pushUndoStop();
  84536. editor.executeCommands(this.id, commands);
  84537. editor.pushUndoStop();
  84538. };
  84539. return AbstractCaseAction;
  84540. }(editorExtensions_1.EditorAction));
  84541. exports.AbstractCaseAction = AbstractCaseAction;
  84542. var UpperCaseAction = /** @class */ (function (_super) {
  84543. __extends(UpperCaseAction, _super);
  84544. function UpperCaseAction() {
  84545. return _super.call(this, {
  84546. id: 'editor.action.transformToUppercase',
  84547. label: nls.localize(22, null),
  84548. alias: 'Transform to Uppercase',
  84549. precondition: editorContextKeys_1.EditorContextKeys.writable
  84550. }) || this;
  84551. }
  84552. UpperCaseAction.prototype._modifyText = function (text, wordSeparators) {
  84553. return text.toLocaleUpperCase();
  84554. };
  84555. return UpperCaseAction;
  84556. }(AbstractCaseAction));
  84557. exports.UpperCaseAction = UpperCaseAction;
  84558. var LowerCaseAction = /** @class */ (function (_super) {
  84559. __extends(LowerCaseAction, _super);
  84560. function LowerCaseAction() {
  84561. return _super.call(this, {
  84562. id: 'editor.action.transformToLowercase',
  84563. label: nls.localize(23, null),
  84564. alias: 'Transform to Lowercase',
  84565. precondition: editorContextKeys_1.EditorContextKeys.writable
  84566. }) || this;
  84567. }
  84568. LowerCaseAction.prototype._modifyText = function (text, wordSeparators) {
  84569. return text.toLocaleLowerCase();
  84570. };
  84571. return LowerCaseAction;
  84572. }(AbstractCaseAction));
  84573. exports.LowerCaseAction = LowerCaseAction;
  84574. var TitleCaseAction = /** @class */ (function (_super) {
  84575. __extends(TitleCaseAction, _super);
  84576. function TitleCaseAction() {
  84577. return _super.call(this, {
  84578. id: 'editor.action.transformToTitlecase',
  84579. label: nls.localize(24, null),
  84580. alias: 'Transform to Title Case',
  84581. precondition: editorContextKeys_1.EditorContextKeys.writable
  84582. }) || this;
  84583. }
  84584. TitleCaseAction.prototype._modifyText = function (text, wordSeparators) {
  84585. var separators = '\r\n\t ' + wordSeparators;
  84586. var excludedChars = separators.split('');
  84587. var title = '';
  84588. var startUpperCase = true;
  84589. for (var i = 0; i < text.length; i++) {
  84590. var currentChar = text[i];
  84591. if (excludedChars.indexOf(currentChar) >= 0) {
  84592. startUpperCase = true;
  84593. title += currentChar;
  84594. }
  84595. else if (startUpperCase) {
  84596. startUpperCase = false;
  84597. title += currentChar.toLocaleUpperCase();
  84598. }
  84599. else {
  84600. title += currentChar.toLocaleLowerCase();
  84601. }
  84602. }
  84603. return title;
  84604. };
  84605. return TitleCaseAction;
  84606. }(AbstractCaseAction));
  84607. exports.TitleCaseAction = TitleCaseAction;
  84608. editorExtensions_1.registerEditorAction(CopyLinesUpAction);
  84609. editorExtensions_1.registerEditorAction(CopyLinesDownAction);
  84610. editorExtensions_1.registerEditorAction(DuplicateSelectionAction);
  84611. editorExtensions_1.registerEditorAction(MoveLinesUpAction);
  84612. editorExtensions_1.registerEditorAction(MoveLinesDownAction);
  84613. editorExtensions_1.registerEditorAction(SortLinesAscendingAction);
  84614. editorExtensions_1.registerEditorAction(SortLinesDescendingAction);
  84615. editorExtensions_1.registerEditorAction(TrimTrailingWhitespaceAction);
  84616. editorExtensions_1.registerEditorAction(DeleteLinesAction);
  84617. editorExtensions_1.registerEditorAction(IndentLinesAction);
  84618. editorExtensions_1.registerEditorAction(OutdentLinesAction);
  84619. editorExtensions_1.registerEditorAction(InsertLineBeforeAction);
  84620. editorExtensions_1.registerEditorAction(InsertLineAfterAction);
  84621. editorExtensions_1.registerEditorAction(DeleteAllLeftAction);
  84622. editorExtensions_1.registerEditorAction(DeleteAllRightAction);
  84623. editorExtensions_1.registerEditorAction(JoinLinesAction);
  84624. editorExtensions_1.registerEditorAction(TransposeAction);
  84625. editorExtensions_1.registerEditorAction(UpperCaseAction);
  84626. editorExtensions_1.registerEditorAction(LowerCaseAction);
  84627. editorExtensions_1.registerEditorAction(TitleCaseAction);
  84628. });
  84629. /*---------------------------------------------------------------------------------------------
  84630. * Copyright (c) Microsoft Corporation. All rights reserved.
  84631. * Licensed under the MIT License. See License.txt in the project root for license information.
  84632. *--------------------------------------------------------------------------------------------*/
  84633. define(__m[165/*vs/editor/contrib/parameterHints/provideSignatureHelp*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,10/*vs/base/common/errors*/,12/*vs/editor/browser/editorExtensions*/,17/*vs/editor/common/modes*/,18/*vs/platform/contextkey/common/contextkey*/,26/*vs/base/common/cancellation*/]), function (require, exports, async_1, errors_1, editorExtensions_1, modes, contextkey_1, cancellation_1) {
  84634. "use strict";
  84635. Object.defineProperty(exports, "__esModule", { value: true });
  84636. exports.Context = {
  84637. Visible: new contextkey_1.RawContextKey('parameterHintsVisible', false),
  84638. MultipleSignatures: new contextkey_1.RawContextKey('parameterHintsMultipleSignatures', false),
  84639. };
  84640. function provideSignatureHelp(model, position, context, token) {
  84641. var supports = modes.SignatureHelpProviderRegistry.ordered(model);
  84642. return async_1.first(supports.map(function (support) { return function () {
  84643. return Promise.resolve(support.provideSignatureHelp(model, position, token, context))
  84644. .catch(function (e) { return errors_1.onUnexpectedExternalError(e); });
  84645. }; }));
  84646. }
  84647. exports.provideSignatureHelp = provideSignatureHelp;
  84648. editorExtensions_1.registerDefaultLanguageCommand('_executeSignatureHelpProvider', function (model, position, args) { return __awaiter(void 0, void 0, void 0, function () {
  84649. var result;
  84650. return __generator(this, function (_a) {
  84651. switch (_a.label) {
  84652. case 0: return [4 /*yield*/, provideSignatureHelp(model, position, {
  84653. triggerKind: modes.SignatureHelpTriggerKind.Invoke,
  84654. isRetrigger: false,
  84655. triggerCharacter: args['triggerCharacter']
  84656. }, cancellation_1.CancellationToken.None)];
  84657. case 1:
  84658. result = _a.sent();
  84659. if (!result) {
  84660. return [2 /*return*/, undefined];
  84661. }
  84662. setTimeout(function () { return result.dispose(); }, 0);
  84663. return [2 /*return*/, result.value];
  84664. }
  84665. });
  84666. }); });
  84667. });
  84668. /*---------------------------------------------------------------------------------------------
  84669. * Copyright (c) Microsoft Corporation. All rights reserved.
  84670. * Licensed under the MIT License. See License.txt in the project root for license information.
  84671. *--------------------------------------------------------------------------------------------*/
  84672. define(__m[540/*vs/editor/contrib/parameterHints/parameterHintsModel*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,10/*vs/base/common/errors*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,79/*vs/editor/common/core/characterClassifier*/,17/*vs/editor/common/modes*/,165/*vs/editor/contrib/parameterHints/provideSignatureHelp*/]), function (require, exports, async_1, errors_1, event_1, lifecycle_1, characterClassifier_1, modes, provideSignatureHelp_1) {
  84673. "use strict";
  84674. Object.defineProperty(exports, "__esModule", { value: true });
  84675. var ParameterHintState;
  84676. (function (ParameterHintState) {
  84677. ParameterHintState.Default = { type: 0 /* Default */ };
  84678. var Pending = /** @class */ (function () {
  84679. function Pending(request) {
  84680. this.request = request;
  84681. this.type = 2 /* Pending */;
  84682. }
  84683. return Pending;
  84684. }());
  84685. ParameterHintState.Pending = Pending;
  84686. var Active = /** @class */ (function () {
  84687. function Active(hints) {
  84688. this.hints = hints;
  84689. this.type = 1 /* Active */;
  84690. }
  84691. return Active;
  84692. }());
  84693. ParameterHintState.Active = Active;
  84694. })(ParameterHintState || (ParameterHintState = {}));
  84695. var ParameterHintsModel = /** @class */ (function (_super) {
  84696. __extends(ParameterHintsModel, _super);
  84697. function ParameterHintsModel(editor, delay) {
  84698. if (delay === void 0) { delay = ParameterHintsModel.DEFAULT_DELAY; }
  84699. var _this = _super.call(this) || this;
  84700. _this._onChangedHints = _this._register(new event_1.Emitter());
  84701. _this.onChangedHints = _this._onChangedHints.event;
  84702. _this.triggerOnType = false;
  84703. _this._state = ParameterHintState.Default;
  84704. _this._pendingTriggers = [];
  84705. _this._lastSignatureHelpResult = _this._register(new lifecycle_1.MutableDisposable());
  84706. _this.triggerChars = new characterClassifier_1.CharacterSet();
  84707. _this.retriggerChars = new characterClassifier_1.CharacterSet();
  84708. _this.triggerId = 0;
  84709. _this.editor = editor;
  84710. _this.throttledDelayer = new async_1.Delayer(delay);
  84711. _this._register(_this.editor.onDidChangeConfiguration(function () { return _this.onEditorConfigurationChange(); }));
  84712. _this._register(_this.editor.onDidChangeModel(function (e) { return _this.onModelChanged(); }));
  84713. _this._register(_this.editor.onDidChangeModelLanguage(function (_) { return _this.onModelChanged(); }));
  84714. _this._register(_this.editor.onDidChangeCursorSelection(function (e) { return _this.onCursorChange(e); }));
  84715. _this._register(_this.editor.onDidChangeModelContent(function (e) { return _this.onModelContentChange(); }));
  84716. _this._register(modes.SignatureHelpProviderRegistry.onDidChange(_this.onModelChanged, _this));
  84717. _this._register(_this.editor.onDidType(function (text) { return _this.onDidType(text); }));
  84718. _this.onEditorConfigurationChange();
  84719. _this.onModelChanged();
  84720. return _this;
  84721. }
  84722. Object.defineProperty(ParameterHintsModel.prototype, "state", {
  84723. get: function () { return this._state; },
  84724. set: function (value) {
  84725. if (this._state.type === 2 /* Pending */) {
  84726. this._state.request.cancel();
  84727. }
  84728. this._state = value;
  84729. },
  84730. enumerable: true,
  84731. configurable: true
  84732. });
  84733. ParameterHintsModel.prototype.cancel = function (silent) {
  84734. if (silent === void 0) { silent = false; }
  84735. this.state = ParameterHintState.Default;
  84736. this.throttledDelayer.cancel();
  84737. if (!silent) {
  84738. this._onChangedHints.fire(undefined);
  84739. }
  84740. };
  84741. ParameterHintsModel.prototype.trigger = function (context, delay) {
  84742. var _this = this;
  84743. var model = this.editor.getModel();
  84744. if (!model || !modes.SignatureHelpProviderRegistry.has(model)) {
  84745. return;
  84746. }
  84747. var triggerId = ++this.triggerId;
  84748. this._pendingTriggers.push(context);
  84749. this.throttledDelayer.trigger(function () {
  84750. return _this.doTrigger(triggerId);
  84751. }, delay)
  84752. .catch(errors_1.onUnexpectedError);
  84753. };
  84754. ParameterHintsModel.prototype.next = function () {
  84755. if (this.state.type !== 1 /* Active */) {
  84756. return;
  84757. }
  84758. var length = this.state.hints.signatures.length;
  84759. var activeSignature = this.state.hints.activeSignature;
  84760. var last = (activeSignature % length) === (length - 1);
  84761. var cycle = this.editor.getOption(64 /* parameterHints */).cycle;
  84762. // If there is only one signature, or we're on last signature of list
  84763. if ((length < 2 || last) && !cycle) {
  84764. this.cancel();
  84765. return;
  84766. }
  84767. this.updateActiveSignature(last && cycle ? 0 : activeSignature + 1);
  84768. };
  84769. ParameterHintsModel.prototype.previous = function () {
  84770. if (this.state.type !== 1 /* Active */) {
  84771. return;
  84772. }
  84773. var length = this.state.hints.signatures.length;
  84774. var activeSignature = this.state.hints.activeSignature;
  84775. var first = activeSignature === 0;
  84776. var cycle = this.editor.getOption(64 /* parameterHints */).cycle;
  84777. // If there is only one signature, or we're on first signature of list
  84778. if ((length < 2 || first) && !cycle) {
  84779. this.cancel();
  84780. return;
  84781. }
  84782. this.updateActiveSignature(first && cycle ? length - 1 : activeSignature - 1);
  84783. };
  84784. ParameterHintsModel.prototype.updateActiveSignature = function (activeSignature) {
  84785. if (this.state.type !== 1 /* Active */) {
  84786. return;
  84787. }
  84788. this.state = new ParameterHintState.Active(__assign(__assign({}, this.state.hints), { activeSignature: activeSignature }));
  84789. this._onChangedHints.fire(this.state.hints);
  84790. };
  84791. ParameterHintsModel.prototype.doTrigger = function (triggerId) {
  84792. return __awaiter(this, void 0, void 0, function () {
  84793. var isRetrigger, activeSignatureHelp, context, triggerContext, model, position, result, error_1;
  84794. return __generator(this, function (_a) {
  84795. switch (_a.label) {
  84796. case 0:
  84797. isRetrigger = this.state.type === 1 /* Active */ || this.state.type === 2 /* Pending */;
  84798. activeSignatureHelp = this.state.type === 1 /* Active */ ? this.state.hints : undefined;
  84799. this.cancel(true);
  84800. if (this._pendingTriggers.length === 0) {
  84801. return [2 /*return*/, false];
  84802. }
  84803. context = this._pendingTriggers.reduce(mergeTriggerContexts);
  84804. this._pendingTriggers = [];
  84805. triggerContext = {
  84806. triggerKind: context.triggerKind,
  84807. triggerCharacter: context.triggerCharacter,
  84808. isRetrigger: isRetrigger,
  84809. activeSignatureHelp: activeSignatureHelp
  84810. };
  84811. if (!this.editor.hasModel()) {
  84812. return [2 /*return*/, false];
  84813. }
  84814. model = this.editor.getModel();
  84815. position = this.editor.getPosition();
  84816. this.state = new ParameterHintState.Pending(async_1.createCancelablePromise(function (token) {
  84817. return provideSignatureHelp_1.provideSignatureHelp(model, position, triggerContext, token);
  84818. }));
  84819. _a.label = 1;
  84820. case 1:
  84821. _a.trys.push([1, 3, , 4]);
  84822. return [4 /*yield*/, this.state.request];
  84823. case 2:
  84824. result = _a.sent();
  84825. // Check that we are still resolving the correct signature help
  84826. if (triggerId !== this.triggerId) {
  84827. result === null || result === void 0 ? void 0 : result.dispose();
  84828. return [2 /*return*/, false];
  84829. }
  84830. if (!result || !result.value.signatures || result.value.signatures.length === 0) {
  84831. result === null || result === void 0 ? void 0 : result.dispose();
  84832. this._lastSignatureHelpResult.clear();
  84833. this.cancel();
  84834. return [2 /*return*/, false];
  84835. }
  84836. else {
  84837. this.state = new ParameterHintState.Active(result.value);
  84838. this._lastSignatureHelpResult.value = result;
  84839. this._onChangedHints.fire(this.state.hints);
  84840. return [2 /*return*/, true];
  84841. }
  84842. return [3 /*break*/, 4];
  84843. case 3:
  84844. error_1 = _a.sent();
  84845. if (triggerId === this.triggerId) {
  84846. this.state = ParameterHintState.Default;
  84847. }
  84848. errors_1.onUnexpectedError(error_1);
  84849. return [2 /*return*/, false];
  84850. case 4: return [2 /*return*/];
  84851. }
  84852. });
  84853. });
  84854. };
  84855. Object.defineProperty(ParameterHintsModel.prototype, "isTriggered", {
  84856. get: function () {
  84857. return this.state.type === 1 /* Active */
  84858. || this.state.type === 2 /* Pending */
  84859. || this.throttledDelayer.isTriggered();
  84860. },
  84861. enumerable: true,
  84862. configurable: true
  84863. });
  84864. ParameterHintsModel.prototype.onModelChanged = function () {
  84865. this.cancel();
  84866. // Update trigger characters
  84867. this.triggerChars = new characterClassifier_1.CharacterSet();
  84868. this.retriggerChars = new characterClassifier_1.CharacterSet();
  84869. var model = this.editor.getModel();
  84870. if (!model) {
  84871. return;
  84872. }
  84873. for (var _i = 0, _a = modes.SignatureHelpProviderRegistry.ordered(model); _i < _a.length; _i++) {
  84874. var support = _a[_i];
  84875. for (var _b = 0, _c = support.signatureHelpTriggerCharacters || []; _b < _c.length; _b++) {
  84876. var ch = _c[_b];
  84877. this.triggerChars.add(ch.charCodeAt(0));
  84878. // All trigger characters are also considered retrigger characters
  84879. this.retriggerChars.add(ch.charCodeAt(0));
  84880. }
  84881. for (var _d = 0, _e = support.signatureHelpRetriggerCharacters || []; _d < _e.length; _d++) {
  84882. var ch = _e[_d];
  84883. this.retriggerChars.add(ch.charCodeAt(0));
  84884. }
  84885. }
  84886. };
  84887. ParameterHintsModel.prototype.onDidType = function (text) {
  84888. if (!this.triggerOnType) {
  84889. return;
  84890. }
  84891. var lastCharIndex = text.length - 1;
  84892. var triggerCharCode = text.charCodeAt(lastCharIndex);
  84893. if (this.triggerChars.has(triggerCharCode) || this.isTriggered && this.retriggerChars.has(triggerCharCode)) {
  84894. this.trigger({
  84895. triggerKind: modes.SignatureHelpTriggerKind.TriggerCharacter,
  84896. triggerCharacter: text.charAt(lastCharIndex),
  84897. });
  84898. }
  84899. };
  84900. ParameterHintsModel.prototype.onCursorChange = function (e) {
  84901. if (e.source === 'mouse') {
  84902. this.cancel();
  84903. }
  84904. else if (this.isTriggered) {
  84905. this.trigger({ triggerKind: modes.SignatureHelpTriggerKind.ContentChange });
  84906. }
  84907. };
  84908. ParameterHintsModel.prototype.onModelContentChange = function () {
  84909. if (this.isTriggered) {
  84910. this.trigger({ triggerKind: modes.SignatureHelpTriggerKind.ContentChange });
  84911. }
  84912. };
  84913. ParameterHintsModel.prototype.onEditorConfigurationChange = function () {
  84914. this.triggerOnType = this.editor.getOption(64 /* parameterHints */).enabled;
  84915. if (!this.triggerOnType) {
  84916. this.cancel();
  84917. }
  84918. };
  84919. ParameterHintsModel.prototype.dispose = function () {
  84920. this.cancel(true);
  84921. _super.prototype.dispose.call(this);
  84922. };
  84923. ParameterHintsModel.DEFAULT_DELAY = 120; // ms
  84924. return ParameterHintsModel;
  84925. }(lifecycle_1.Disposable));
  84926. exports.ParameterHintsModel = ParameterHintsModel;
  84927. function mergeTriggerContexts(previous, current) {
  84928. switch (current.triggerKind) {
  84929. case modes.SignatureHelpTriggerKind.Invoke:
  84930. // Invoke overrides previous triggers.
  84931. return current;
  84932. case modes.SignatureHelpTriggerKind.ContentChange:
  84933. // Ignore content changes triggers
  84934. return previous;
  84935. case modes.SignatureHelpTriggerKind.TriggerCharacter:
  84936. default:
  84937. return current;
  84938. }
  84939. }
  84940. });
  84941. /*---------------------------------------------------------------------------------------------
  84942. * Copyright (c) Microsoft Corporation. All rights reserved.
  84943. * Licensed under the MIT License. See License.txt in the project root for license information.
  84944. *--------------------------------------------------------------------------------------------*/
  84945. define(__m[541/*vs/editor/contrib/smartSelect/smartSelect*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,26/*vs/base/common/cancellation*/,12/*vs/editor/browser/editorExtensions*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,23/*vs/editor/common/editorContextKeys*/,17/*vs/editor/common/modes*/,465/*vs/nls!vs/editor/contrib/smartSelect/smartSelect*/,2/*vs/base/common/lifecycle*/,388/*vs/editor/contrib/smartSelect/wordSelections*/,202/*vs/editor/contrib/smartSelect/bracketSelections*/,29/*vs/platform/commands/common/commands*/,10/*vs/base/common/errors*/]), function (require, exports, arrays, cancellation_1, editorExtensions_1, position_1, range_1, selection_1, editorContextKeys_1, modes, nls, lifecycle_1, wordSelections_1, bracketSelections_1, commands_1, errors_1) {
  84946. "use strict";
  84947. Object.defineProperty(exports, "__esModule", { value: true });
  84948. var SelectionRanges = /** @class */ (function () {
  84949. function SelectionRanges(index, ranges) {
  84950. this.index = index;
  84951. this.ranges = ranges;
  84952. }
  84953. SelectionRanges.prototype.mov = function (fwd) {
  84954. var index = this.index + (fwd ? 1 : -1);
  84955. if (index < 0 || index >= this.ranges.length) {
  84956. return this;
  84957. }
  84958. var res = new SelectionRanges(index, this.ranges);
  84959. if (res.ranges[index].equalsRange(this.ranges[this.index])) {
  84960. // next range equals this range, retry with next-next
  84961. return res.mov(fwd);
  84962. }
  84963. return res;
  84964. };
  84965. return SelectionRanges;
  84966. }());
  84967. var SmartSelectController = /** @class */ (function () {
  84968. function SmartSelectController(editor) {
  84969. this._ignoreSelection = false;
  84970. this._editor = editor;
  84971. }
  84972. SmartSelectController.get = function (editor) {
  84973. return editor.getContribution(SmartSelectController.ID);
  84974. };
  84975. SmartSelectController.prototype.dispose = function () {
  84976. lifecycle_1.dispose(this._selectionListener);
  84977. };
  84978. SmartSelectController.prototype.run = function (forward) {
  84979. var _this = this;
  84980. if (!this._editor.hasModel()) {
  84981. return;
  84982. }
  84983. var selections = this._editor.getSelections();
  84984. var model = this._editor.getModel();
  84985. if (!modes.SelectionRangeRegistry.has(model)) {
  84986. return;
  84987. }
  84988. var promise = Promise.resolve(undefined);
  84989. if (!this._state) {
  84990. promise = provideSelectionRanges(model, selections.map(function (s) { return s.getPosition(); }), cancellation_1.CancellationToken.None).then(function (ranges) {
  84991. if (!arrays.isNonEmptyArray(ranges) || ranges.length !== selections.length) {
  84992. // invalid result
  84993. return;
  84994. }
  84995. if (!_this._editor.hasModel() || !arrays.equals(_this._editor.getSelections(), selections, function (a, b) { return a.equalsSelection(b); })) {
  84996. // invalid editor state
  84997. return;
  84998. }
  84999. var _loop_1 = function (i) {
  85000. ranges[i] = ranges[i].filter(function (range) {
  85001. // filter ranges inside the selection
  85002. return range.containsPosition(selections[i].getStartPosition()) && range.containsPosition(selections[i].getEndPosition());
  85003. });
  85004. // prepend current selection
  85005. ranges[i].unshift(selections[i]);
  85006. };
  85007. for (var i = 0; i < ranges.length; i++) {
  85008. _loop_1(i);
  85009. }
  85010. _this._state = ranges.map(function (ranges) { return new SelectionRanges(0, ranges); });
  85011. // listen to caret move and forget about state
  85012. lifecycle_1.dispose(_this._selectionListener);
  85013. _this._selectionListener = _this._editor.onDidChangeCursorPosition(function () {
  85014. if (!_this._ignoreSelection) {
  85015. lifecycle_1.dispose(_this._selectionListener);
  85016. _this._state = undefined;
  85017. }
  85018. });
  85019. });
  85020. }
  85021. return promise.then(function () {
  85022. if (!_this._state) {
  85023. // no state
  85024. return;
  85025. }
  85026. _this._state = _this._state.map(function (state) { return state.mov(forward); });
  85027. var selections = _this._state.map(function (state) { return selection_1.Selection.fromPositions(state.ranges[state.index].getStartPosition(), state.ranges[state.index].getEndPosition()); });
  85028. _this._ignoreSelection = true;
  85029. try {
  85030. _this._editor.setSelections(selections);
  85031. }
  85032. finally {
  85033. _this._ignoreSelection = false;
  85034. }
  85035. });
  85036. };
  85037. SmartSelectController.ID = 'editor.contrib.smartSelectController';
  85038. return SmartSelectController;
  85039. }());
  85040. var AbstractSmartSelect = /** @class */ (function (_super) {
  85041. __extends(AbstractSmartSelect, _super);
  85042. function AbstractSmartSelect(forward, opts) {
  85043. var _this = _super.call(this, opts) || this;
  85044. _this._forward = forward;
  85045. return _this;
  85046. }
  85047. AbstractSmartSelect.prototype.run = function (_accessor, editor) {
  85048. return __awaiter(this, void 0, void 0, function () {
  85049. var controller;
  85050. return __generator(this, function (_a) {
  85051. switch (_a.label) {
  85052. case 0:
  85053. controller = SmartSelectController.get(editor);
  85054. if (!controller) return [3 /*break*/, 2];
  85055. return [4 /*yield*/, controller.run(this._forward)];
  85056. case 1:
  85057. _a.sent();
  85058. _a.label = 2;
  85059. case 2: return [2 /*return*/];
  85060. }
  85061. });
  85062. });
  85063. };
  85064. return AbstractSmartSelect;
  85065. }(editorExtensions_1.EditorAction));
  85066. var GrowSelectionAction = /** @class */ (function (_super) {
  85067. __extends(GrowSelectionAction, _super);
  85068. function GrowSelectionAction() {
  85069. return _super.call(this, true, {
  85070. id: 'editor.action.smartSelect.expand',
  85071. label: nls.localize(0, null),
  85072. alias: 'Expand Selection',
  85073. precondition: undefined,
  85074. kbOpts: {
  85075. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  85076. primary: 1024 /* Shift */ | 512 /* Alt */ | 17 /* RightArrow */,
  85077. mac: {
  85078. primary: 2048 /* CtrlCmd */ | 256 /* WinCtrl */ | 1024 /* Shift */ | 17 /* RightArrow */,
  85079. secondary: [256 /* WinCtrl */ | 1024 /* Shift */ | 17 /* RightArrow */],
  85080. },
  85081. weight: 100 /* EditorContrib */
  85082. },
  85083. menuOpts: {
  85084. menuId: 25 /* MenubarSelectionMenu */,
  85085. group: '1_basic',
  85086. title: nls.localize(1, null),
  85087. order: 2
  85088. }
  85089. }) || this;
  85090. }
  85091. return GrowSelectionAction;
  85092. }(AbstractSmartSelect));
  85093. // renamed command id
  85094. commands_1.CommandsRegistry.registerCommandAlias('editor.action.smartSelect.grow', 'editor.action.smartSelect.expand');
  85095. var ShrinkSelectionAction = /** @class */ (function (_super) {
  85096. __extends(ShrinkSelectionAction, _super);
  85097. function ShrinkSelectionAction() {
  85098. return _super.call(this, false, {
  85099. id: 'editor.action.smartSelect.shrink',
  85100. label: nls.localize(2, null),
  85101. alias: 'Shrink Selection',
  85102. precondition: undefined,
  85103. kbOpts: {
  85104. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  85105. primary: 1024 /* Shift */ | 512 /* Alt */ | 15 /* LeftArrow */,
  85106. mac: {
  85107. primary: 2048 /* CtrlCmd */ | 256 /* WinCtrl */ | 1024 /* Shift */ | 15 /* LeftArrow */,
  85108. secondary: [256 /* WinCtrl */ | 1024 /* Shift */ | 15 /* LeftArrow */],
  85109. },
  85110. weight: 100 /* EditorContrib */
  85111. },
  85112. menuOpts: {
  85113. menuId: 25 /* MenubarSelectionMenu */,
  85114. group: '1_basic',
  85115. title: nls.localize(3, null),
  85116. order: 3
  85117. }
  85118. }) || this;
  85119. }
  85120. return ShrinkSelectionAction;
  85121. }(AbstractSmartSelect));
  85122. editorExtensions_1.registerEditorContribution(SmartSelectController.ID, SmartSelectController);
  85123. editorExtensions_1.registerEditorAction(GrowSelectionAction);
  85124. editorExtensions_1.registerEditorAction(ShrinkSelectionAction);
  85125. // word selection
  85126. modes.SelectionRangeRegistry.register('*', new wordSelections_1.WordSelectionRangeProvider());
  85127. function provideSelectionRanges(model, positions, token) {
  85128. var providers = modes.SelectionRangeRegistry.all(model);
  85129. if (providers.length === 1) {
  85130. // add word selection and bracket selection when no provider exists
  85131. providers.unshift(new bracketSelections_1.BracketSelectionRangeProvider());
  85132. }
  85133. var work = [];
  85134. var allRawRanges = [];
  85135. for (var _i = 0, providers_1 = providers; _i < providers_1.length; _i++) {
  85136. var provider = providers_1[_i];
  85137. work.push(Promise.resolve(provider.provideSelectionRanges(model, positions, token)).then(function (allProviderRanges) {
  85138. if (arrays.isNonEmptyArray(allProviderRanges) && allProviderRanges.length === positions.length) {
  85139. for (var i = 0; i < positions.length; i++) {
  85140. if (!allRawRanges[i]) {
  85141. allRawRanges[i] = [];
  85142. }
  85143. for (var _i = 0, _a = allProviderRanges[i]; _i < _a.length; _i++) {
  85144. var oneProviderRanges = _a[_i];
  85145. if (range_1.Range.isIRange(oneProviderRanges.range) && range_1.Range.containsPosition(oneProviderRanges.range, positions[i])) {
  85146. allRawRanges[i].push(range_1.Range.lift(oneProviderRanges.range));
  85147. }
  85148. }
  85149. }
  85150. }
  85151. }, errors_1.onUnexpectedExternalError));
  85152. }
  85153. return Promise.all(work).then(function () {
  85154. return allRawRanges.map(function (oneRawRanges) {
  85155. if (oneRawRanges.length === 0) {
  85156. return [];
  85157. }
  85158. // sort all by start/end position
  85159. oneRawRanges.sort(function (a, b) {
  85160. if (position_1.Position.isBefore(a.getStartPosition(), b.getStartPosition())) {
  85161. return 1;
  85162. }
  85163. else if (position_1.Position.isBefore(b.getStartPosition(), a.getStartPosition())) {
  85164. return -1;
  85165. }
  85166. else if (position_1.Position.isBefore(a.getEndPosition(), b.getEndPosition())) {
  85167. return -1;
  85168. }
  85169. else if (position_1.Position.isBefore(b.getEndPosition(), a.getEndPosition())) {
  85170. return 1;
  85171. }
  85172. else {
  85173. return 0;
  85174. }
  85175. });
  85176. // remove ranges that don't contain the former range or that are equal to the
  85177. // former range
  85178. var oneRanges = [];
  85179. var last;
  85180. for (var _i = 0, oneRawRanges_1 = oneRawRanges; _i < oneRawRanges_1.length; _i++) {
  85181. var range = oneRawRanges_1[_i];
  85182. if (!last || (range_1.Range.containsRange(range, last) && !range_1.Range.equalsRange(range, last))) {
  85183. oneRanges.push(range);
  85184. last = range;
  85185. }
  85186. }
  85187. // add ranges that expand trivia at line starts and ends whenever a range
  85188. // wraps onto the a new line
  85189. var oneRangesWithTrivia = [oneRanges[0]];
  85190. for (var i = 1; i < oneRanges.length; i++) {
  85191. var prev = oneRanges[i - 1];
  85192. var cur = oneRanges[i];
  85193. if (cur.startLineNumber !== prev.startLineNumber || cur.endLineNumber !== prev.endLineNumber) {
  85194. // add line/block range without leading/failing whitespace
  85195. var rangeNoWhitespace = new range_1.Range(prev.startLineNumber, model.getLineFirstNonWhitespaceColumn(prev.startLineNumber), prev.endLineNumber, model.getLineLastNonWhitespaceColumn(prev.endLineNumber));
  85196. if (rangeNoWhitespace.containsRange(prev) && !rangeNoWhitespace.equalsRange(prev) && cur.containsRange(rangeNoWhitespace) && !cur.equalsRange(rangeNoWhitespace)) {
  85197. oneRangesWithTrivia.push(rangeNoWhitespace);
  85198. }
  85199. // add line/block range
  85200. var rangeFull = new range_1.Range(prev.startLineNumber, 1, prev.endLineNumber, model.getLineMaxColumn(prev.endLineNumber));
  85201. if (rangeFull.containsRange(prev) && !rangeFull.equalsRange(rangeNoWhitespace) && cur.containsRange(rangeFull) && !cur.equalsRange(rangeFull)) {
  85202. oneRangesWithTrivia.push(rangeFull);
  85203. }
  85204. }
  85205. oneRangesWithTrivia.push(cur);
  85206. }
  85207. return oneRangesWithTrivia;
  85208. });
  85209. });
  85210. }
  85211. exports.provideSelectionRanges = provideSelectionRanges;
  85212. editorExtensions_1.registerModelCommand('_executeSelectionRangeProvider', function (model) {
  85213. var args = [];
  85214. for (var _i = 1; _i < arguments.length; _i++) {
  85215. args[_i - 1] = arguments[_i];
  85216. }
  85217. var positions = args[0];
  85218. return provideSelectionRanges(model, positions, cancellation_1.CancellationToken.None);
  85219. });
  85220. });
  85221. /*---------------------------------------------------------------------------------------------
  85222. * Copyright (c) Microsoft Corporation. All rights reserved.
  85223. * Licensed under the MIT License. See License.txt in the project root for license information.
  85224. *--------------------------------------------------------------------------------------------*/
  85225. define(__m[120/*vs/editor/contrib/suggest/suggest*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,31/*vs/base/common/objects*/,10/*vs/base/common/errors*/,12/*vs/editor/browser/editorExtensions*/,17/*vs/editor/common/modes*/,13/*vs/editor/common/core/position*/,18/*vs/platform/contextkey/common/contextkey*/,26/*vs/base/common/cancellation*/,3/*vs/editor/common/core/range*/,61/*vs/base/common/filters*/,2/*vs/base/common/lifecycle*/]), function (require, exports, async_1, objects_1, errors_1, editorExtensions_1, modes, position_1, contextkey_1, cancellation_1, range_1, filters_1, lifecycle_1) {
  85226. "use strict";
  85227. Object.defineProperty(exports, "__esModule", { value: true });
  85228. exports.Context = {
  85229. Visible: new contextkey_1.RawContextKey('suggestWidgetVisible', false),
  85230. MultipleSuggestions: new contextkey_1.RawContextKey('suggestWidgetMultipleSuggestions', false),
  85231. MakesTextEdit: new contextkey_1.RawContextKey('suggestionMakesTextEdit', true),
  85232. AcceptSuggestionsOnEnter: new contextkey_1.RawContextKey('acceptSuggestionOnEnter', true)
  85233. };
  85234. var CompletionItem = /** @class */ (function () {
  85235. function CompletionItem(position, completion, container, provider, model) {
  85236. var _this = this;
  85237. this.position = position;
  85238. this.completion = completion;
  85239. this.container = container;
  85240. this.provider = provider;
  85241. this.isResolved = false;
  85242. // sorting, filtering
  85243. this.score = filters_1.FuzzyScore.Default;
  85244. this.distance = 0;
  85245. this.textLabel = typeof completion.label === 'string'
  85246. ? completion.label
  85247. : completion.label.name;
  85248. // ensure lower-variants (perf)
  85249. this.labelLow = this.textLabel.toLowerCase();
  85250. this.sortTextLow = completion.sortText && completion.sortText.toLowerCase();
  85251. this.filterTextLow = completion.filterText && completion.filterText.toLowerCase();
  85252. // normalize ranges
  85253. if (range_1.Range.isIRange(completion.range)) {
  85254. this.editStart = new position_1.Position(completion.range.startLineNumber, completion.range.startColumn);
  85255. this.editInsertEnd = new position_1.Position(completion.range.endLineNumber, completion.range.endColumn);
  85256. this.editReplaceEnd = new position_1.Position(completion.range.endLineNumber, completion.range.endColumn);
  85257. }
  85258. else {
  85259. this.editStart = new position_1.Position(completion.range.insert.startLineNumber, completion.range.insert.startColumn);
  85260. this.editInsertEnd = new position_1.Position(completion.range.insert.endLineNumber, completion.range.insert.endColumn);
  85261. this.editReplaceEnd = new position_1.Position(completion.range.replace.endLineNumber, completion.range.replace.endColumn);
  85262. }
  85263. // create the suggestion resolver
  85264. var resolveCompletionItem = provider.resolveCompletionItem;
  85265. if (typeof resolveCompletionItem !== 'function') {
  85266. this.resolve = function () { return Promise.resolve(); };
  85267. this.isResolved = true;
  85268. }
  85269. else {
  85270. var cached_1;
  85271. this.resolve = function (token) {
  85272. if (!cached_1) {
  85273. cached_1 = Promise.resolve(resolveCompletionItem.call(provider, model, position, completion, token)).then(function (value) {
  85274. objects_1.assign(completion, value);
  85275. _this.isResolved = true;
  85276. }, function (err) {
  85277. if (errors_1.isPromiseCanceledError(err)) {
  85278. // the IPC queue will reject the request with the
  85279. // cancellation error -> reset cached
  85280. cached_1 = undefined;
  85281. }
  85282. });
  85283. token.onCancellationRequested(function () {
  85284. if (!_this.isResolved) {
  85285. // cancellation after the request has been
  85286. // dispatched -> reset cache
  85287. cached_1 = undefined;
  85288. }
  85289. });
  85290. }
  85291. return cached_1;
  85292. };
  85293. }
  85294. }
  85295. return CompletionItem;
  85296. }());
  85297. exports.CompletionItem = CompletionItem;
  85298. var CompletionOptions = /** @class */ (function () {
  85299. function CompletionOptions(snippetSortOrder, kindFilter, providerFilter) {
  85300. if (snippetSortOrder === void 0) { snippetSortOrder = 2 /* Bottom */; }
  85301. if (kindFilter === void 0) { kindFilter = new Set(); }
  85302. if (providerFilter === void 0) { providerFilter = new Set(); }
  85303. this.snippetSortOrder = snippetSortOrder;
  85304. this.kindFilter = kindFilter;
  85305. this.providerFilter = providerFilter;
  85306. }
  85307. CompletionOptions.default = new CompletionOptions();
  85308. return CompletionOptions;
  85309. }());
  85310. exports.CompletionOptions = CompletionOptions;
  85311. var _snippetSuggestSupport;
  85312. function getSnippetSuggestSupport() {
  85313. return _snippetSuggestSupport;
  85314. }
  85315. exports.getSnippetSuggestSupport = getSnippetSuggestSupport;
  85316. function provideSuggestionItems(model, position, options, context, token) {
  85317. if (options === void 0) { options = CompletionOptions.default; }
  85318. if (context === void 0) { context = { triggerKind: 0 /* Invoke */ }; }
  85319. if (token === void 0) { token = cancellation_1.CancellationToken.None; }
  85320. var word = model.getWordAtPosition(position);
  85321. var defaultReplaceRange = word ? new range_1.Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn) : range_1.Range.fromPositions(position);
  85322. var defaultInsertRange = defaultReplaceRange.setEndPosition(position.lineNumber, position.column);
  85323. // const wordUntil = model.getWordUntilPosition(position);
  85324. // const defaultRange = new Range(position.lineNumber, wordUntil.startColumn, position.lineNumber, wordUntil.endColumn);
  85325. position = position.clone();
  85326. // get provider groups, always add snippet suggestion provider
  85327. var supports = modes.CompletionProviderRegistry.orderedGroups(model);
  85328. // add snippets provider unless turned off
  85329. if (!options.kindFilter.has(25 /* Snippet */) && _snippetSuggestSupport) {
  85330. supports.unshift([_snippetSuggestSupport]);
  85331. }
  85332. var allSuggestions = [];
  85333. var disposables = new lifecycle_1.DisposableStore();
  85334. var hasResult = false;
  85335. // add suggestions from contributed providers - providers are ordered in groups of
  85336. // equal score and once a group produces a result the process stops
  85337. var factory = supports.map(function (supports) { return function () {
  85338. // for each support in the group ask for suggestions
  85339. return Promise.all(supports.map(function (provider) {
  85340. if (options.providerFilter.size > 0 && !options.providerFilter.has(provider)) {
  85341. return undefined;
  85342. }
  85343. return Promise.resolve(provider.provideCompletionItems(model, position, context, token)).then(function (container) {
  85344. var len = allSuggestions.length;
  85345. if (container) {
  85346. for (var _i = 0, _a = container.suggestions || []; _i < _a.length; _i++) {
  85347. var suggestion = _a[_i];
  85348. if (!options.kindFilter.has(suggestion.kind)) {
  85349. // fill in default range when missing
  85350. if (!suggestion.range) {
  85351. suggestion.range = { insert: defaultInsertRange, replace: defaultReplaceRange };
  85352. }
  85353. // fill in default sortText when missing
  85354. if (!suggestion.sortText) {
  85355. suggestion.sortText = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;
  85356. }
  85357. allSuggestions.push(new CompletionItem(position, suggestion, container, provider, model));
  85358. }
  85359. }
  85360. if (lifecycle_1.isDisposable(container)) {
  85361. disposables.add(container);
  85362. }
  85363. }
  85364. if (len !== allSuggestions.length && provider !== _snippetSuggestSupport) {
  85365. hasResult = true;
  85366. }
  85367. }, errors_1.onUnexpectedExternalError);
  85368. }));
  85369. }; });
  85370. var result = async_1.first(factory, function () {
  85371. // stop on result or cancellation
  85372. return hasResult || token.isCancellationRequested;
  85373. }).then(function () {
  85374. if (token.isCancellationRequested) {
  85375. disposables.dispose();
  85376. return Promise.reject(errors_1.canceled());
  85377. }
  85378. return allSuggestions.sort(getSuggestionComparator(options.snippetSortOrder));
  85379. });
  85380. // result.then(items => {
  85381. // console.log(model.getWordUntilPosition(position), items.map(item => `${item.suggestion.label}, type=${item.suggestion.type}, incomplete?${item.container.incomplete}, overwriteBefore=${item.suggestion.overwriteBefore}`));
  85382. // return items;
  85383. // }, err => {
  85384. // console.warn(model.getWordUntilPosition(position), err);
  85385. // });
  85386. return result;
  85387. }
  85388. exports.provideSuggestionItems = provideSuggestionItems;
  85389. function defaultComparator(a, b) {
  85390. // check with 'sortText'
  85391. if (a.sortTextLow && b.sortTextLow) {
  85392. if (a.sortTextLow < b.sortTextLow) {
  85393. return -1;
  85394. }
  85395. else if (a.sortTextLow > b.sortTextLow) {
  85396. return 1;
  85397. }
  85398. }
  85399. // check with 'label'
  85400. if (a.completion.label < b.completion.label) {
  85401. return -1;
  85402. }
  85403. else if (a.completion.label > b.completion.label) {
  85404. return 1;
  85405. }
  85406. // check with 'type'
  85407. return a.completion.kind - b.completion.kind;
  85408. }
  85409. function snippetUpComparator(a, b) {
  85410. if (a.completion.kind !== b.completion.kind) {
  85411. if (a.completion.kind === 25 /* Snippet */) {
  85412. return -1;
  85413. }
  85414. else if (b.completion.kind === 25 /* Snippet */) {
  85415. return 1;
  85416. }
  85417. }
  85418. return defaultComparator(a, b);
  85419. }
  85420. function snippetDownComparator(a, b) {
  85421. if (a.completion.kind !== b.completion.kind) {
  85422. if (a.completion.kind === 25 /* Snippet */) {
  85423. return 1;
  85424. }
  85425. else if (b.completion.kind === 25 /* Snippet */) {
  85426. return -1;
  85427. }
  85428. }
  85429. return defaultComparator(a, b);
  85430. }
  85431. var _snippetComparators = new Map();
  85432. _snippetComparators.set(0 /* Top */, snippetUpComparator);
  85433. _snippetComparators.set(2 /* Bottom */, snippetDownComparator);
  85434. _snippetComparators.set(1 /* Inline */, defaultComparator);
  85435. function getSuggestionComparator(snippetConfig) {
  85436. return _snippetComparators.get(snippetConfig);
  85437. }
  85438. exports.getSuggestionComparator = getSuggestionComparator;
  85439. editorExtensions_1.registerDefaultLanguageCommand('_executeCompletionItemProvider', function (model, position, args) { return __awaiter(void 0, void 0, void 0, function () {
  85440. var result, disposables, resolving, maxItemsToResolve, items, _i, items_1, item;
  85441. return __generator(this, function (_a) {
  85442. switch (_a.label) {
  85443. case 0:
  85444. result = {
  85445. incomplete: false,
  85446. suggestions: []
  85447. };
  85448. disposables = new lifecycle_1.DisposableStore();
  85449. resolving = [];
  85450. maxItemsToResolve = args['maxItemsToResolve'] || 0;
  85451. return [4 /*yield*/, provideSuggestionItems(model, position)];
  85452. case 1:
  85453. items = _a.sent();
  85454. for (_i = 0, items_1 = items; _i < items_1.length; _i++) {
  85455. item = items_1[_i];
  85456. if (resolving.length < maxItemsToResolve) {
  85457. resolving.push(item.resolve(cancellation_1.CancellationToken.None));
  85458. }
  85459. result.incomplete = result.incomplete || item.container.incomplete;
  85460. result.suggestions.push(item.completion);
  85461. if (lifecycle_1.isDisposable(item.container)) {
  85462. disposables.add(item.container);
  85463. }
  85464. }
  85465. _a.label = 2;
  85466. case 2:
  85467. _a.trys.push([2, , 4, 5]);
  85468. return [4 /*yield*/, Promise.all(resolving)];
  85469. case 3:
  85470. _a.sent();
  85471. return [2 /*return*/, result];
  85472. case 4:
  85473. setTimeout(function () { return disposables.dispose(); }, 100);
  85474. return [7 /*endfinally*/];
  85475. case 5: return [2 /*return*/];
  85476. }
  85477. });
  85478. }); });
  85479. var _provider = new /** @class */ (function () {
  85480. function class_1() {
  85481. this.onlyOnceSuggestions = [];
  85482. }
  85483. class_1.prototype.provideCompletionItems = function () {
  85484. var suggestions = this.onlyOnceSuggestions.slice(0);
  85485. var result = { suggestions: suggestions };
  85486. this.onlyOnceSuggestions.length = 0;
  85487. return result;
  85488. };
  85489. return class_1;
  85490. }());
  85491. modes.CompletionProviderRegistry.register('*', _provider);
  85492. function showSimpleSuggestions(editor, suggestions) {
  85493. setTimeout(function () {
  85494. var _a;
  85495. (_a = _provider.onlyOnceSuggestions).push.apply(_a, suggestions);
  85496. editor.getContribution('editor.contrib.suggestController').triggerSuggest(new Set().add(_provider));
  85497. }, 0);
  85498. }
  85499. exports.showSimpleSuggestions = showSimpleSuggestions;
  85500. });
  85501. /*---------------------------------------------------------------------------------------------
  85502. * Copyright (c) Microsoft Corporation. All rights reserved.
  85503. * Licensed under the MIT License. See License.txt in the project root for license information.
  85504. *--------------------------------------------------------------------------------------------*/
  85505. define(__m[225/*vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode*/], __M([0/*require*/,1/*exports*/,469/*vs/nls!vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode*/,50/*vs/base/browser/ui/aria/aria*/,12/*vs/editor/browser/editorExtensions*/,163/*vs/editor/common/config/commonEditorConfig*/]), function (require, exports, nls, aria_1, editorExtensions_1, commonEditorConfig_1) {
  85506. "use strict";
  85507. Object.defineProperty(exports, "__esModule", { value: true });
  85508. var ToggleTabFocusModeAction = /** @class */ (function (_super) {
  85509. __extends(ToggleTabFocusModeAction, _super);
  85510. function ToggleTabFocusModeAction() {
  85511. return _super.call(this, {
  85512. id: ToggleTabFocusModeAction.ID,
  85513. label: nls.localize(0, null),
  85514. alias: 'Toggle Tab Key Moves Focus',
  85515. precondition: undefined,
  85516. kbOpts: {
  85517. kbExpr: null,
  85518. primary: 2048 /* CtrlCmd */ | 43 /* KEY_M */,
  85519. mac: { primary: 256 /* WinCtrl */ | 1024 /* Shift */ | 43 /* KEY_M */ },
  85520. weight: 100 /* EditorContrib */
  85521. }
  85522. }) || this;
  85523. }
  85524. ToggleTabFocusModeAction.prototype.run = function (accessor, editor) {
  85525. var oldValue = commonEditorConfig_1.TabFocus.getTabFocusMode();
  85526. var newValue = !oldValue;
  85527. commonEditorConfig_1.TabFocus.setTabFocusMode(newValue);
  85528. if (newValue) {
  85529. aria_1.alert(nls.localize(1, null));
  85530. }
  85531. else {
  85532. aria_1.alert(nls.localize(2, null));
  85533. }
  85534. };
  85535. ToggleTabFocusModeAction.ID = 'editor.action.toggleTabFocusMode';
  85536. return ToggleTabFocusModeAction;
  85537. }(editorExtensions_1.EditorAction));
  85538. exports.ToggleTabFocusModeAction = ToggleTabFocusModeAction;
  85539. editorExtensions_1.registerEditorAction(ToggleTabFocusModeAction);
  85540. });
  85541. /*---------------------------------------------------------------------------------------------
  85542. * Copyright (c) Microsoft Corporation. All rights reserved.
  85543. * Licensed under the MIT License. See License.txt in the project root for license information.
  85544. *--------------------------------------------------------------------------------------------*/
  85545. define(__m[542/*vs/editor/contrib/tokenization/tokenization*/], __M([0/*require*/,1/*exports*/,470/*vs/nls!vs/editor/contrib/tokenization/tokenization*/,12/*vs/editor/browser/editorExtensions*/,132/*vs/base/common/stopwatch*/]), function (require, exports, nls, editorExtensions_1, stopwatch_1) {
  85546. "use strict";
  85547. Object.defineProperty(exports, "__esModule", { value: true });
  85548. var ForceRetokenizeAction = /** @class */ (function (_super) {
  85549. __extends(ForceRetokenizeAction, _super);
  85550. function ForceRetokenizeAction() {
  85551. return _super.call(this, {
  85552. id: 'editor.action.forceRetokenize',
  85553. label: nls.localize(0, null),
  85554. alias: 'Developer: Force Retokenize',
  85555. precondition: undefined
  85556. }) || this;
  85557. }
  85558. ForceRetokenizeAction.prototype.run = function (accessor, editor) {
  85559. if (!editor.hasModel()) {
  85560. return;
  85561. }
  85562. var model = editor.getModel();
  85563. model.resetTokenization();
  85564. var sw = new stopwatch_1.StopWatch(true);
  85565. model.forceTokenization(model.getLineCount());
  85566. sw.stop();
  85567. console.log("tokenization took " + sw.elapsed());
  85568. };
  85569. return ForceRetokenizeAction;
  85570. }(editorExtensions_1.EditorAction));
  85571. editorExtensions_1.registerEditorAction(ForceRetokenizeAction);
  85572. });
  85573. /*---------------------------------------------------------------------------------------------
  85574. * Copyright (c) Microsoft Corporation. All rights reserved.
  85575. * Licensed under the MIT License. See License.txt in the project root for license information.
  85576. *--------------------------------------------------------------------------------------------*/
  85577. define(__m[226/*vs/editor/contrib/wordOperations/wordOperations*/], __M([0/*require*/,1/*exports*/,12/*vs/editor/browser/editorExtensions*/,80/*vs/editor/common/commands/replaceCommand*/,40/*vs/editor/common/controller/cursorCommon*/,160/*vs/editor/common/controller/cursorWordOperations*/,89/*vs/editor/common/controller/wordCharacterClassifier*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,23/*vs/editor/common/editorContextKeys*/,64/*vs/platform/accessibility/common/accessibility*/,18/*vs/platform/contextkey/common/contextkey*/,33/*vs/editor/common/config/editorOptions*/]), function (require, exports, editorExtensions_1, replaceCommand_1, cursorCommon_1, cursorWordOperations_1, wordCharacterClassifier_1, position_1, range_1, selection_1, editorContextKeys_1, accessibility_1, contextkey_1, editorOptions_1) {
  85578. "use strict";
  85579. Object.defineProperty(exports, "__esModule", { value: true });
  85580. var MoveWordCommand = /** @class */ (function (_super) {
  85581. __extends(MoveWordCommand, _super);
  85582. function MoveWordCommand(opts) {
  85583. var _this = _super.call(this, opts) || this;
  85584. _this._inSelectionMode = opts.inSelectionMode;
  85585. _this._wordNavigationType = opts.wordNavigationType;
  85586. return _this;
  85587. }
  85588. MoveWordCommand.prototype.runEditorCommand = function (accessor, editor, args) {
  85589. var _this = this;
  85590. if (!editor.hasModel()) {
  85591. return;
  85592. }
  85593. var wordSeparators = wordCharacterClassifier_1.getMapForWordSeparators(editor.getOption(96 /* wordSeparators */));
  85594. var model = editor.getModel();
  85595. var selections = editor.getSelections();
  85596. var result = selections.map(function (sel) {
  85597. var inPosition = new position_1.Position(sel.positionLineNumber, sel.positionColumn);
  85598. var outPosition = _this._move(wordSeparators, model, inPosition, _this._wordNavigationType);
  85599. return _this._moveTo(sel, outPosition, _this._inSelectionMode);
  85600. });
  85601. editor._getCursors().setStates('moveWordCommand', 0 /* NotSet */, result.map(function (r) { return cursorCommon_1.CursorState.fromModelSelection(r); }));
  85602. if (result.length === 1) {
  85603. var pos = new position_1.Position(result[0].positionLineNumber, result[0].positionColumn);
  85604. editor.revealPosition(pos, 0 /* Smooth */);
  85605. }
  85606. };
  85607. MoveWordCommand.prototype._moveTo = function (from, to, inSelectionMode) {
  85608. if (inSelectionMode) {
  85609. // move just position
  85610. return new selection_1.Selection(from.selectionStartLineNumber, from.selectionStartColumn, to.lineNumber, to.column);
  85611. }
  85612. else {
  85613. // move everything
  85614. return new selection_1.Selection(to.lineNumber, to.column, to.lineNumber, to.column);
  85615. }
  85616. };
  85617. return MoveWordCommand;
  85618. }(editorExtensions_1.EditorCommand));
  85619. exports.MoveWordCommand = MoveWordCommand;
  85620. var WordLeftCommand = /** @class */ (function (_super) {
  85621. __extends(WordLeftCommand, _super);
  85622. function WordLeftCommand() {
  85623. return _super !== null && _super.apply(this, arguments) || this;
  85624. }
  85625. WordLeftCommand.prototype._move = function (wordSeparators, model, position, wordNavigationType) {
  85626. return cursorWordOperations_1.WordOperations.moveWordLeft(wordSeparators, model, position, wordNavigationType);
  85627. };
  85628. return WordLeftCommand;
  85629. }(MoveWordCommand));
  85630. exports.WordLeftCommand = WordLeftCommand;
  85631. var WordRightCommand = /** @class */ (function (_super) {
  85632. __extends(WordRightCommand, _super);
  85633. function WordRightCommand() {
  85634. return _super !== null && _super.apply(this, arguments) || this;
  85635. }
  85636. WordRightCommand.prototype._move = function (wordSeparators, model, position, wordNavigationType) {
  85637. return cursorWordOperations_1.WordOperations.moveWordRight(wordSeparators, model, position, wordNavigationType);
  85638. };
  85639. return WordRightCommand;
  85640. }(MoveWordCommand));
  85641. exports.WordRightCommand = WordRightCommand;
  85642. var CursorWordStartLeft = /** @class */ (function (_super) {
  85643. __extends(CursorWordStartLeft, _super);
  85644. function CursorWordStartLeft() {
  85645. return _super.call(this, {
  85646. inSelectionMode: false,
  85647. wordNavigationType: 0 /* WordStart */,
  85648. id: 'cursorWordStartLeft',
  85649. precondition: undefined,
  85650. kbOpts: {
  85651. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  85652. primary: 2048 /* CtrlCmd */ | 15 /* LeftArrow */,
  85653. mac: { primary: 512 /* Alt */ | 15 /* LeftArrow */ },
  85654. weight: 100 /* EditorContrib */
  85655. }
  85656. }) || this;
  85657. }
  85658. return CursorWordStartLeft;
  85659. }(WordLeftCommand));
  85660. exports.CursorWordStartLeft = CursorWordStartLeft;
  85661. var CursorWordEndLeft = /** @class */ (function (_super) {
  85662. __extends(CursorWordEndLeft, _super);
  85663. function CursorWordEndLeft() {
  85664. return _super.call(this, {
  85665. inSelectionMode: false,
  85666. wordNavigationType: 2 /* WordEnd */,
  85667. id: 'cursorWordEndLeft',
  85668. precondition: undefined
  85669. }) || this;
  85670. }
  85671. return CursorWordEndLeft;
  85672. }(WordLeftCommand));
  85673. exports.CursorWordEndLeft = CursorWordEndLeft;
  85674. var CursorWordLeft = /** @class */ (function (_super) {
  85675. __extends(CursorWordLeft, _super);
  85676. function CursorWordLeft() {
  85677. return _super.call(this, {
  85678. inSelectionMode: false,
  85679. wordNavigationType: 1 /* WordStartFast */,
  85680. id: 'cursorWordLeft',
  85681. precondition: undefined
  85682. }) || this;
  85683. }
  85684. return CursorWordLeft;
  85685. }(WordLeftCommand));
  85686. exports.CursorWordLeft = CursorWordLeft;
  85687. var CursorWordStartLeftSelect = /** @class */ (function (_super) {
  85688. __extends(CursorWordStartLeftSelect, _super);
  85689. function CursorWordStartLeftSelect() {
  85690. return _super.call(this, {
  85691. inSelectionMode: true,
  85692. wordNavigationType: 0 /* WordStart */,
  85693. id: 'cursorWordStartLeftSelect',
  85694. precondition: undefined,
  85695. kbOpts: {
  85696. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  85697. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 15 /* LeftArrow */,
  85698. mac: { primary: 512 /* Alt */ | 1024 /* Shift */ | 15 /* LeftArrow */ },
  85699. weight: 100 /* EditorContrib */
  85700. }
  85701. }) || this;
  85702. }
  85703. return CursorWordStartLeftSelect;
  85704. }(WordLeftCommand));
  85705. exports.CursorWordStartLeftSelect = CursorWordStartLeftSelect;
  85706. var CursorWordEndLeftSelect = /** @class */ (function (_super) {
  85707. __extends(CursorWordEndLeftSelect, _super);
  85708. function CursorWordEndLeftSelect() {
  85709. return _super.call(this, {
  85710. inSelectionMode: true,
  85711. wordNavigationType: 2 /* WordEnd */,
  85712. id: 'cursorWordEndLeftSelect',
  85713. precondition: undefined
  85714. }) || this;
  85715. }
  85716. return CursorWordEndLeftSelect;
  85717. }(WordLeftCommand));
  85718. exports.CursorWordEndLeftSelect = CursorWordEndLeftSelect;
  85719. var CursorWordLeftSelect = /** @class */ (function (_super) {
  85720. __extends(CursorWordLeftSelect, _super);
  85721. function CursorWordLeftSelect() {
  85722. return _super.call(this, {
  85723. inSelectionMode: true,
  85724. wordNavigationType: 1 /* WordStartFast */,
  85725. id: 'cursorWordLeftSelect',
  85726. precondition: undefined
  85727. }) || this;
  85728. }
  85729. return CursorWordLeftSelect;
  85730. }(WordLeftCommand));
  85731. exports.CursorWordLeftSelect = CursorWordLeftSelect;
  85732. // Accessibility navigation commands should only be enabled on windows since they are tuned to what NVDA expects
  85733. var CursorWordAccessibilityLeft = /** @class */ (function (_super) {
  85734. __extends(CursorWordAccessibilityLeft, _super);
  85735. function CursorWordAccessibilityLeft() {
  85736. return _super.call(this, {
  85737. inSelectionMode: false,
  85738. wordNavigationType: 3 /* WordAccessibility */,
  85739. id: 'cursorWordAccessibilityLeft',
  85740. precondition: undefined,
  85741. kbOpts: {
  85742. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.textInputFocus, accessibility_1.CONTEXT_ACCESSIBILITY_MODE_ENABLED),
  85743. win: { primary: 2048 /* CtrlCmd */ | 15 /* LeftArrow */ },
  85744. weight: 100 /* EditorContrib */ + 1
  85745. }
  85746. }) || this;
  85747. }
  85748. CursorWordAccessibilityLeft.prototype._move = function (_, model, position, wordNavigationType) {
  85749. return _super.prototype._move.call(this, wordCharacterClassifier_1.getMapForWordSeparators(editorOptions_1.EditorOptions.wordSeparators.defaultValue), model, position, wordNavigationType);
  85750. };
  85751. return CursorWordAccessibilityLeft;
  85752. }(WordLeftCommand));
  85753. exports.CursorWordAccessibilityLeft = CursorWordAccessibilityLeft;
  85754. var CursorWordAccessibilityLeftSelect = /** @class */ (function (_super) {
  85755. __extends(CursorWordAccessibilityLeftSelect, _super);
  85756. function CursorWordAccessibilityLeftSelect() {
  85757. return _super.call(this, {
  85758. inSelectionMode: true,
  85759. wordNavigationType: 3 /* WordAccessibility */,
  85760. id: 'cursorWordAccessibilityLeftSelect',
  85761. precondition: undefined,
  85762. kbOpts: {
  85763. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.textInputFocus, accessibility_1.CONTEXT_ACCESSIBILITY_MODE_ENABLED),
  85764. win: { primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 15 /* LeftArrow */ },
  85765. weight: 100 /* EditorContrib */ + 1
  85766. }
  85767. }) || this;
  85768. }
  85769. CursorWordAccessibilityLeftSelect.prototype._move = function (_, model, position, wordNavigationType) {
  85770. return _super.prototype._move.call(this, wordCharacterClassifier_1.getMapForWordSeparators(editorOptions_1.EditorOptions.wordSeparators.defaultValue), model, position, wordNavigationType);
  85771. };
  85772. return CursorWordAccessibilityLeftSelect;
  85773. }(WordLeftCommand));
  85774. exports.CursorWordAccessibilityLeftSelect = CursorWordAccessibilityLeftSelect;
  85775. var CursorWordStartRight = /** @class */ (function (_super) {
  85776. __extends(CursorWordStartRight, _super);
  85777. function CursorWordStartRight() {
  85778. return _super.call(this, {
  85779. inSelectionMode: false,
  85780. wordNavigationType: 0 /* WordStart */,
  85781. id: 'cursorWordStartRight',
  85782. precondition: undefined
  85783. }) || this;
  85784. }
  85785. return CursorWordStartRight;
  85786. }(WordRightCommand));
  85787. exports.CursorWordStartRight = CursorWordStartRight;
  85788. var CursorWordEndRight = /** @class */ (function (_super) {
  85789. __extends(CursorWordEndRight, _super);
  85790. function CursorWordEndRight() {
  85791. return _super.call(this, {
  85792. inSelectionMode: false,
  85793. wordNavigationType: 2 /* WordEnd */,
  85794. id: 'cursorWordEndRight',
  85795. precondition: undefined,
  85796. kbOpts: {
  85797. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  85798. primary: 2048 /* CtrlCmd */ | 17 /* RightArrow */,
  85799. mac: { primary: 512 /* Alt */ | 17 /* RightArrow */ },
  85800. weight: 100 /* EditorContrib */
  85801. }
  85802. }) || this;
  85803. }
  85804. return CursorWordEndRight;
  85805. }(WordRightCommand));
  85806. exports.CursorWordEndRight = CursorWordEndRight;
  85807. var CursorWordRight = /** @class */ (function (_super) {
  85808. __extends(CursorWordRight, _super);
  85809. function CursorWordRight() {
  85810. return _super.call(this, {
  85811. inSelectionMode: false,
  85812. wordNavigationType: 2 /* WordEnd */,
  85813. id: 'cursorWordRight',
  85814. precondition: undefined
  85815. }) || this;
  85816. }
  85817. return CursorWordRight;
  85818. }(WordRightCommand));
  85819. exports.CursorWordRight = CursorWordRight;
  85820. var CursorWordStartRightSelect = /** @class */ (function (_super) {
  85821. __extends(CursorWordStartRightSelect, _super);
  85822. function CursorWordStartRightSelect() {
  85823. return _super.call(this, {
  85824. inSelectionMode: true,
  85825. wordNavigationType: 0 /* WordStart */,
  85826. id: 'cursorWordStartRightSelect',
  85827. precondition: undefined
  85828. }) || this;
  85829. }
  85830. return CursorWordStartRightSelect;
  85831. }(WordRightCommand));
  85832. exports.CursorWordStartRightSelect = CursorWordStartRightSelect;
  85833. var CursorWordEndRightSelect = /** @class */ (function (_super) {
  85834. __extends(CursorWordEndRightSelect, _super);
  85835. function CursorWordEndRightSelect() {
  85836. return _super.call(this, {
  85837. inSelectionMode: true,
  85838. wordNavigationType: 2 /* WordEnd */,
  85839. id: 'cursorWordEndRightSelect',
  85840. precondition: undefined,
  85841. kbOpts: {
  85842. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  85843. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 17 /* RightArrow */,
  85844. mac: { primary: 512 /* Alt */ | 1024 /* Shift */ | 17 /* RightArrow */ },
  85845. weight: 100 /* EditorContrib */
  85846. }
  85847. }) || this;
  85848. }
  85849. return CursorWordEndRightSelect;
  85850. }(WordRightCommand));
  85851. exports.CursorWordEndRightSelect = CursorWordEndRightSelect;
  85852. var CursorWordRightSelect = /** @class */ (function (_super) {
  85853. __extends(CursorWordRightSelect, _super);
  85854. function CursorWordRightSelect() {
  85855. return _super.call(this, {
  85856. inSelectionMode: true,
  85857. wordNavigationType: 2 /* WordEnd */,
  85858. id: 'cursorWordRightSelect',
  85859. precondition: undefined
  85860. }) || this;
  85861. }
  85862. return CursorWordRightSelect;
  85863. }(WordRightCommand));
  85864. exports.CursorWordRightSelect = CursorWordRightSelect;
  85865. var CursorWordAccessibilityRight = /** @class */ (function (_super) {
  85866. __extends(CursorWordAccessibilityRight, _super);
  85867. function CursorWordAccessibilityRight() {
  85868. return _super.call(this, {
  85869. inSelectionMode: false,
  85870. wordNavigationType: 3 /* WordAccessibility */,
  85871. id: 'cursorWordAccessibilityRight',
  85872. precondition: undefined,
  85873. kbOpts: {
  85874. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.textInputFocus, accessibility_1.CONTEXT_ACCESSIBILITY_MODE_ENABLED),
  85875. win: { primary: 2048 /* CtrlCmd */ | 17 /* RightArrow */ },
  85876. weight: 100 /* EditorContrib */ + 1
  85877. }
  85878. }) || this;
  85879. }
  85880. CursorWordAccessibilityRight.prototype._move = function (_, model, position, wordNavigationType) {
  85881. return _super.prototype._move.call(this, wordCharacterClassifier_1.getMapForWordSeparators(editorOptions_1.EditorOptions.wordSeparators.defaultValue), model, position, wordNavigationType);
  85882. };
  85883. return CursorWordAccessibilityRight;
  85884. }(WordRightCommand));
  85885. exports.CursorWordAccessibilityRight = CursorWordAccessibilityRight;
  85886. var CursorWordAccessibilityRightSelect = /** @class */ (function (_super) {
  85887. __extends(CursorWordAccessibilityRightSelect, _super);
  85888. function CursorWordAccessibilityRightSelect() {
  85889. return _super.call(this, {
  85890. inSelectionMode: true,
  85891. wordNavigationType: 3 /* WordAccessibility */,
  85892. id: 'cursorWordAccessibilityRightSelect',
  85893. precondition: undefined,
  85894. kbOpts: {
  85895. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.textInputFocus, accessibility_1.CONTEXT_ACCESSIBILITY_MODE_ENABLED),
  85896. win: { primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 17 /* RightArrow */ },
  85897. weight: 100 /* EditorContrib */ + 1
  85898. }
  85899. }) || this;
  85900. }
  85901. CursorWordAccessibilityRightSelect.prototype._move = function (_, model, position, wordNavigationType) {
  85902. return _super.prototype._move.call(this, wordCharacterClassifier_1.getMapForWordSeparators(editorOptions_1.EditorOptions.wordSeparators.defaultValue), model, position, wordNavigationType);
  85903. };
  85904. return CursorWordAccessibilityRightSelect;
  85905. }(WordRightCommand));
  85906. exports.CursorWordAccessibilityRightSelect = CursorWordAccessibilityRightSelect;
  85907. var DeleteWordCommand = /** @class */ (function (_super) {
  85908. __extends(DeleteWordCommand, _super);
  85909. function DeleteWordCommand(opts) {
  85910. var _this = _super.call(this, opts) || this;
  85911. _this._whitespaceHeuristics = opts.whitespaceHeuristics;
  85912. _this._wordNavigationType = opts.wordNavigationType;
  85913. return _this;
  85914. }
  85915. DeleteWordCommand.prototype.runEditorCommand = function (accessor, editor, args) {
  85916. var _this = this;
  85917. if (!editor.hasModel()) {
  85918. return;
  85919. }
  85920. var wordSeparators = wordCharacterClassifier_1.getMapForWordSeparators(editor.getOption(96 /* wordSeparators */));
  85921. var model = editor.getModel();
  85922. var selections = editor.getSelections();
  85923. var commands = selections.map(function (sel) {
  85924. var deleteRange = _this._delete(wordSeparators, model, sel, _this._whitespaceHeuristics, _this._wordNavigationType);
  85925. return new replaceCommand_1.ReplaceCommand(deleteRange, '');
  85926. });
  85927. editor.pushUndoStop();
  85928. editor.executeCommands(this.id, commands);
  85929. editor.pushUndoStop();
  85930. };
  85931. return DeleteWordCommand;
  85932. }(editorExtensions_1.EditorCommand));
  85933. exports.DeleteWordCommand = DeleteWordCommand;
  85934. var DeleteWordLeftCommand = /** @class */ (function (_super) {
  85935. __extends(DeleteWordLeftCommand, _super);
  85936. function DeleteWordLeftCommand() {
  85937. return _super !== null && _super.apply(this, arguments) || this;
  85938. }
  85939. DeleteWordLeftCommand.prototype._delete = function (wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType) {
  85940. var r = cursorWordOperations_1.WordOperations.deleteWordLeft(wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType);
  85941. if (r) {
  85942. return r;
  85943. }
  85944. return new range_1.Range(1, 1, 1, 1);
  85945. };
  85946. return DeleteWordLeftCommand;
  85947. }(DeleteWordCommand));
  85948. exports.DeleteWordLeftCommand = DeleteWordLeftCommand;
  85949. var DeleteWordRightCommand = /** @class */ (function (_super) {
  85950. __extends(DeleteWordRightCommand, _super);
  85951. function DeleteWordRightCommand() {
  85952. return _super !== null && _super.apply(this, arguments) || this;
  85953. }
  85954. DeleteWordRightCommand.prototype._delete = function (wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType) {
  85955. var r = cursorWordOperations_1.WordOperations.deleteWordRight(wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType);
  85956. if (r) {
  85957. return r;
  85958. }
  85959. var lineCount = model.getLineCount();
  85960. var maxColumn = model.getLineMaxColumn(lineCount);
  85961. return new range_1.Range(lineCount, maxColumn, lineCount, maxColumn);
  85962. };
  85963. return DeleteWordRightCommand;
  85964. }(DeleteWordCommand));
  85965. exports.DeleteWordRightCommand = DeleteWordRightCommand;
  85966. var DeleteWordStartLeft = /** @class */ (function (_super) {
  85967. __extends(DeleteWordStartLeft, _super);
  85968. function DeleteWordStartLeft() {
  85969. return _super.call(this, {
  85970. whitespaceHeuristics: false,
  85971. wordNavigationType: 0 /* WordStart */,
  85972. id: 'deleteWordStartLeft',
  85973. precondition: editorContextKeys_1.EditorContextKeys.writable
  85974. }) || this;
  85975. }
  85976. return DeleteWordStartLeft;
  85977. }(DeleteWordLeftCommand));
  85978. exports.DeleteWordStartLeft = DeleteWordStartLeft;
  85979. var DeleteWordEndLeft = /** @class */ (function (_super) {
  85980. __extends(DeleteWordEndLeft, _super);
  85981. function DeleteWordEndLeft() {
  85982. return _super.call(this, {
  85983. whitespaceHeuristics: false,
  85984. wordNavigationType: 2 /* WordEnd */,
  85985. id: 'deleteWordEndLeft',
  85986. precondition: editorContextKeys_1.EditorContextKeys.writable
  85987. }) || this;
  85988. }
  85989. return DeleteWordEndLeft;
  85990. }(DeleteWordLeftCommand));
  85991. exports.DeleteWordEndLeft = DeleteWordEndLeft;
  85992. var DeleteWordLeft = /** @class */ (function (_super) {
  85993. __extends(DeleteWordLeft, _super);
  85994. function DeleteWordLeft() {
  85995. return _super.call(this, {
  85996. whitespaceHeuristics: true,
  85997. wordNavigationType: 0 /* WordStart */,
  85998. id: 'deleteWordLeft',
  85999. precondition: editorContextKeys_1.EditorContextKeys.writable,
  86000. kbOpts: {
  86001. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  86002. primary: 2048 /* CtrlCmd */ | 1 /* Backspace */,
  86003. mac: { primary: 512 /* Alt */ | 1 /* Backspace */ },
  86004. weight: 100 /* EditorContrib */
  86005. }
  86006. }) || this;
  86007. }
  86008. return DeleteWordLeft;
  86009. }(DeleteWordLeftCommand));
  86010. exports.DeleteWordLeft = DeleteWordLeft;
  86011. var DeleteWordStartRight = /** @class */ (function (_super) {
  86012. __extends(DeleteWordStartRight, _super);
  86013. function DeleteWordStartRight() {
  86014. return _super.call(this, {
  86015. whitespaceHeuristics: false,
  86016. wordNavigationType: 0 /* WordStart */,
  86017. id: 'deleteWordStartRight',
  86018. precondition: editorContextKeys_1.EditorContextKeys.writable
  86019. }) || this;
  86020. }
  86021. return DeleteWordStartRight;
  86022. }(DeleteWordRightCommand));
  86023. exports.DeleteWordStartRight = DeleteWordStartRight;
  86024. var DeleteWordEndRight = /** @class */ (function (_super) {
  86025. __extends(DeleteWordEndRight, _super);
  86026. function DeleteWordEndRight() {
  86027. return _super.call(this, {
  86028. whitespaceHeuristics: false,
  86029. wordNavigationType: 2 /* WordEnd */,
  86030. id: 'deleteWordEndRight',
  86031. precondition: editorContextKeys_1.EditorContextKeys.writable
  86032. }) || this;
  86033. }
  86034. return DeleteWordEndRight;
  86035. }(DeleteWordRightCommand));
  86036. exports.DeleteWordEndRight = DeleteWordEndRight;
  86037. var DeleteWordRight = /** @class */ (function (_super) {
  86038. __extends(DeleteWordRight, _super);
  86039. function DeleteWordRight() {
  86040. return _super.call(this, {
  86041. whitespaceHeuristics: true,
  86042. wordNavigationType: 2 /* WordEnd */,
  86043. id: 'deleteWordRight',
  86044. precondition: editorContextKeys_1.EditorContextKeys.writable,
  86045. kbOpts: {
  86046. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  86047. primary: 2048 /* CtrlCmd */ | 20 /* Delete */,
  86048. mac: { primary: 512 /* Alt */ | 20 /* Delete */ },
  86049. weight: 100 /* EditorContrib */
  86050. }
  86051. }) || this;
  86052. }
  86053. return DeleteWordRight;
  86054. }(DeleteWordRightCommand));
  86055. exports.DeleteWordRight = DeleteWordRight;
  86056. editorExtensions_1.registerEditorCommand(new CursorWordStartLeft());
  86057. editorExtensions_1.registerEditorCommand(new CursorWordEndLeft());
  86058. editorExtensions_1.registerEditorCommand(new CursorWordLeft());
  86059. editorExtensions_1.registerEditorCommand(new CursorWordStartLeftSelect());
  86060. editorExtensions_1.registerEditorCommand(new CursorWordEndLeftSelect());
  86061. editorExtensions_1.registerEditorCommand(new CursorWordLeftSelect());
  86062. editorExtensions_1.registerEditorCommand(new CursorWordStartRight());
  86063. editorExtensions_1.registerEditorCommand(new CursorWordEndRight());
  86064. editorExtensions_1.registerEditorCommand(new CursorWordRight());
  86065. editorExtensions_1.registerEditorCommand(new CursorWordStartRightSelect());
  86066. editorExtensions_1.registerEditorCommand(new CursorWordEndRightSelect());
  86067. editorExtensions_1.registerEditorCommand(new CursorWordRightSelect());
  86068. editorExtensions_1.registerEditorCommand(new CursorWordAccessibilityLeft());
  86069. editorExtensions_1.registerEditorCommand(new CursorWordAccessibilityLeftSelect());
  86070. editorExtensions_1.registerEditorCommand(new CursorWordAccessibilityRight());
  86071. editorExtensions_1.registerEditorCommand(new CursorWordAccessibilityRightSelect());
  86072. editorExtensions_1.registerEditorCommand(new DeleteWordStartLeft());
  86073. editorExtensions_1.registerEditorCommand(new DeleteWordEndLeft());
  86074. editorExtensions_1.registerEditorCommand(new DeleteWordLeft());
  86075. editorExtensions_1.registerEditorCommand(new DeleteWordStartRight());
  86076. editorExtensions_1.registerEditorCommand(new DeleteWordEndRight());
  86077. editorExtensions_1.registerEditorCommand(new DeleteWordRight());
  86078. });
  86079. /*---------------------------------------------------------------------------------------------
  86080. * Copyright (c) Microsoft Corporation. All rights reserved.
  86081. * Licensed under the MIT License. See License.txt in the project root for license information.
  86082. *--------------------------------------------------------------------------------------------*/
  86083. define(__m[543/*vs/editor/contrib/wordPartOperations/wordPartOperations*/], __M([0/*require*/,1/*exports*/,12/*vs/editor/browser/editorExtensions*/,160/*vs/editor/common/controller/cursorWordOperations*/,3/*vs/editor/common/core/range*/,23/*vs/editor/common/editorContextKeys*/,226/*vs/editor/contrib/wordOperations/wordOperations*/,29/*vs/platform/commands/common/commands*/]), function (require, exports, editorExtensions_1, cursorWordOperations_1, range_1, editorContextKeys_1, wordOperations_1, commands_1) {
  86084. "use strict";
  86085. Object.defineProperty(exports, "__esModule", { value: true });
  86086. var DeleteWordPartLeft = /** @class */ (function (_super) {
  86087. __extends(DeleteWordPartLeft, _super);
  86088. function DeleteWordPartLeft() {
  86089. return _super.call(this, {
  86090. whitespaceHeuristics: true,
  86091. wordNavigationType: 0 /* WordStart */,
  86092. id: 'deleteWordPartLeft',
  86093. precondition: editorContextKeys_1.EditorContextKeys.writable,
  86094. kbOpts: {
  86095. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  86096. primary: 0,
  86097. mac: { primary: 256 /* WinCtrl */ | 512 /* Alt */ | 1 /* Backspace */ },
  86098. weight: 100 /* EditorContrib */
  86099. }
  86100. }) || this;
  86101. }
  86102. DeleteWordPartLeft.prototype._delete = function (wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType) {
  86103. var r = cursorWordOperations_1.WordPartOperations.deleteWordPartLeft(wordSeparators, model, selection, whitespaceHeuristics);
  86104. if (r) {
  86105. return r;
  86106. }
  86107. return new range_1.Range(1, 1, 1, 1);
  86108. };
  86109. return DeleteWordPartLeft;
  86110. }(wordOperations_1.DeleteWordCommand));
  86111. exports.DeleteWordPartLeft = DeleteWordPartLeft;
  86112. var DeleteWordPartRight = /** @class */ (function (_super) {
  86113. __extends(DeleteWordPartRight, _super);
  86114. function DeleteWordPartRight() {
  86115. return _super.call(this, {
  86116. whitespaceHeuristics: true,
  86117. wordNavigationType: 2 /* WordEnd */,
  86118. id: 'deleteWordPartRight',
  86119. precondition: editorContextKeys_1.EditorContextKeys.writable,
  86120. kbOpts: {
  86121. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  86122. primary: 0,
  86123. mac: { primary: 256 /* WinCtrl */ | 512 /* Alt */ | 20 /* Delete */ },
  86124. weight: 100 /* EditorContrib */
  86125. }
  86126. }) || this;
  86127. }
  86128. DeleteWordPartRight.prototype._delete = function (wordSeparators, model, selection, whitespaceHeuristics, wordNavigationType) {
  86129. var r = cursorWordOperations_1.WordPartOperations.deleteWordPartRight(wordSeparators, model, selection, whitespaceHeuristics);
  86130. if (r) {
  86131. return r;
  86132. }
  86133. var lineCount = model.getLineCount();
  86134. var maxColumn = model.getLineMaxColumn(lineCount);
  86135. return new range_1.Range(lineCount, maxColumn, lineCount, maxColumn);
  86136. };
  86137. return DeleteWordPartRight;
  86138. }(wordOperations_1.DeleteWordCommand));
  86139. exports.DeleteWordPartRight = DeleteWordPartRight;
  86140. var WordPartLeftCommand = /** @class */ (function (_super) {
  86141. __extends(WordPartLeftCommand, _super);
  86142. function WordPartLeftCommand() {
  86143. return _super !== null && _super.apply(this, arguments) || this;
  86144. }
  86145. WordPartLeftCommand.prototype._move = function (wordSeparators, model, position, wordNavigationType) {
  86146. return cursorWordOperations_1.WordPartOperations.moveWordPartLeft(wordSeparators, model, position);
  86147. };
  86148. return WordPartLeftCommand;
  86149. }(wordOperations_1.MoveWordCommand));
  86150. exports.WordPartLeftCommand = WordPartLeftCommand;
  86151. var CursorWordPartLeft = /** @class */ (function (_super) {
  86152. __extends(CursorWordPartLeft, _super);
  86153. function CursorWordPartLeft() {
  86154. return _super.call(this, {
  86155. inSelectionMode: false,
  86156. wordNavigationType: 0 /* WordStart */,
  86157. id: 'cursorWordPartLeft',
  86158. precondition: undefined,
  86159. kbOpts: {
  86160. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  86161. primary: 0,
  86162. mac: { primary: 256 /* WinCtrl */ | 512 /* Alt */ | 15 /* LeftArrow */ },
  86163. weight: 100 /* EditorContrib */
  86164. }
  86165. }) || this;
  86166. }
  86167. return CursorWordPartLeft;
  86168. }(WordPartLeftCommand));
  86169. exports.CursorWordPartLeft = CursorWordPartLeft;
  86170. // Register previous id for compatibility purposes
  86171. commands_1.CommandsRegistry.registerCommandAlias('cursorWordPartStartLeft', 'cursorWordPartLeft');
  86172. var CursorWordPartLeftSelect = /** @class */ (function (_super) {
  86173. __extends(CursorWordPartLeftSelect, _super);
  86174. function CursorWordPartLeftSelect() {
  86175. return _super.call(this, {
  86176. inSelectionMode: true,
  86177. wordNavigationType: 0 /* WordStart */,
  86178. id: 'cursorWordPartLeftSelect',
  86179. precondition: undefined,
  86180. kbOpts: {
  86181. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  86182. primary: 0,
  86183. mac: { primary: 256 /* WinCtrl */ | 512 /* Alt */ | 1024 /* Shift */ | 15 /* LeftArrow */ },
  86184. weight: 100 /* EditorContrib */
  86185. }
  86186. }) || this;
  86187. }
  86188. return CursorWordPartLeftSelect;
  86189. }(WordPartLeftCommand));
  86190. exports.CursorWordPartLeftSelect = CursorWordPartLeftSelect;
  86191. // Register previous id for compatibility purposes
  86192. commands_1.CommandsRegistry.registerCommandAlias('cursorWordPartStartLeftSelect', 'cursorWordPartLeftSelect');
  86193. var WordPartRightCommand = /** @class */ (function (_super) {
  86194. __extends(WordPartRightCommand, _super);
  86195. function WordPartRightCommand() {
  86196. return _super !== null && _super.apply(this, arguments) || this;
  86197. }
  86198. WordPartRightCommand.prototype._move = function (wordSeparators, model, position, wordNavigationType) {
  86199. return cursorWordOperations_1.WordPartOperations.moveWordPartRight(wordSeparators, model, position);
  86200. };
  86201. return WordPartRightCommand;
  86202. }(wordOperations_1.MoveWordCommand));
  86203. exports.WordPartRightCommand = WordPartRightCommand;
  86204. var CursorWordPartRight = /** @class */ (function (_super) {
  86205. __extends(CursorWordPartRight, _super);
  86206. function CursorWordPartRight() {
  86207. return _super.call(this, {
  86208. inSelectionMode: false,
  86209. wordNavigationType: 2 /* WordEnd */,
  86210. id: 'cursorWordPartRight',
  86211. precondition: undefined,
  86212. kbOpts: {
  86213. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  86214. primary: 0,
  86215. mac: { primary: 256 /* WinCtrl */ | 512 /* Alt */ | 17 /* RightArrow */ },
  86216. weight: 100 /* EditorContrib */
  86217. }
  86218. }) || this;
  86219. }
  86220. return CursorWordPartRight;
  86221. }(WordPartRightCommand));
  86222. exports.CursorWordPartRight = CursorWordPartRight;
  86223. var CursorWordPartRightSelect = /** @class */ (function (_super) {
  86224. __extends(CursorWordPartRightSelect, _super);
  86225. function CursorWordPartRightSelect() {
  86226. return _super.call(this, {
  86227. inSelectionMode: true,
  86228. wordNavigationType: 2 /* WordEnd */,
  86229. id: 'cursorWordPartRightSelect',
  86230. precondition: undefined,
  86231. kbOpts: {
  86232. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  86233. primary: 0,
  86234. mac: { primary: 256 /* WinCtrl */ | 512 /* Alt */ | 1024 /* Shift */ | 17 /* RightArrow */ },
  86235. weight: 100 /* EditorContrib */
  86236. }
  86237. }) || this;
  86238. }
  86239. return CursorWordPartRightSelect;
  86240. }(WordPartRightCommand));
  86241. exports.CursorWordPartRightSelect = CursorWordPartRightSelect;
  86242. editorExtensions_1.registerEditorCommand(new DeleteWordPartLeft());
  86243. editorExtensions_1.registerEditorCommand(new DeleteWordPartRight());
  86244. editorExtensions_1.registerEditorCommand(new CursorWordPartLeft());
  86245. editorExtensions_1.registerEditorCommand(new CursorWordPartLeftSelect());
  86246. editorExtensions_1.registerEditorCommand(new CursorWordPartRight());
  86247. editorExtensions_1.registerEditorCommand(new CursorWordPartRightSelect());
  86248. });
  86249. /*---------------------------------------------------------------------------------------------
  86250. * Copyright (c) Microsoft Corporation. All rights reserved.
  86251. * Licensed under the MIT License. See License.txt in the project root for license information.
  86252. *--------------------------------------------------------------------------------------------*/
  86253. define(__m[544/*vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,6/*vs/base/browser/dom*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,326/*vs/css!vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard*/]), function (require, exports, browser, dom, lifecycle_1, editorExtensions_1) {
  86254. "use strict";
  86255. Object.defineProperty(exports, "__esModule", { value: true });
  86256. var IPadShowKeyboard = /** @class */ (function (_super) {
  86257. __extends(IPadShowKeyboard, _super);
  86258. function IPadShowKeyboard(editor) {
  86259. var _this = _super.call(this) || this;
  86260. _this.editor = editor;
  86261. _this.widget = null;
  86262. if (browser.isIPad) {
  86263. _this._register(editor.onDidChangeConfiguration(function () { return _this.update(); }));
  86264. _this.update();
  86265. }
  86266. return _this;
  86267. }
  86268. IPadShowKeyboard.prototype.update = function () {
  86269. var shouldHaveWidget = (!this.editor.getOption(68 /* readOnly */));
  86270. if (!this.widget && shouldHaveWidget) {
  86271. this.widget = new ShowKeyboardWidget(this.editor);
  86272. }
  86273. else if (this.widget && !shouldHaveWidget) {
  86274. this.widget.dispose();
  86275. this.widget = null;
  86276. }
  86277. };
  86278. IPadShowKeyboard.prototype.dispose = function () {
  86279. _super.prototype.dispose.call(this);
  86280. if (this.widget) {
  86281. this.widget.dispose();
  86282. this.widget = null;
  86283. }
  86284. };
  86285. IPadShowKeyboard.ID = 'editor.contrib.iPadShowKeyboard';
  86286. return IPadShowKeyboard;
  86287. }(lifecycle_1.Disposable));
  86288. exports.IPadShowKeyboard = IPadShowKeyboard;
  86289. var ShowKeyboardWidget = /** @class */ (function (_super) {
  86290. __extends(ShowKeyboardWidget, _super);
  86291. function ShowKeyboardWidget(editor) {
  86292. var _this = _super.call(this) || this;
  86293. _this.editor = editor;
  86294. _this._domNode = document.createElement('textarea');
  86295. _this._domNode.className = 'iPadShowKeyboard';
  86296. _this._register(dom.addDisposableListener(_this._domNode, 'touchstart', function (e) {
  86297. _this.editor.focus();
  86298. }));
  86299. _this._register(dom.addDisposableListener(_this._domNode, 'focus', function (e) {
  86300. _this.editor.focus();
  86301. }));
  86302. _this.editor.addOverlayWidget(_this);
  86303. return _this;
  86304. }
  86305. ShowKeyboardWidget.prototype.dispose = function () {
  86306. this.editor.removeOverlayWidget(this);
  86307. _super.prototype.dispose.call(this);
  86308. };
  86309. // ----- IOverlayWidget API
  86310. ShowKeyboardWidget.prototype.getId = function () {
  86311. return ShowKeyboardWidget.ID;
  86312. };
  86313. ShowKeyboardWidget.prototype.getDomNode = function () {
  86314. return this._domNode;
  86315. };
  86316. ShowKeyboardWidget.prototype.getPosition = function () {
  86317. return {
  86318. preference: 1 /* BOTTOM_RIGHT_CORNER */
  86319. };
  86320. };
  86321. ShowKeyboardWidget.ID = 'editor.contrib.ShowKeyboardWidget';
  86322. return ShowKeyboardWidget;
  86323. }(lifecycle_1.Disposable));
  86324. editorExtensions_1.registerEditorContribution(IPadShowKeyboard.ID, IPadShowKeyboard);
  86325. });
  86326. /*---------------------------------------------------------------------------------------------
  86327. * Copyright (c) Microsoft Corporation. All rights reserved.
  86328. * Licensed under the MIT License. See License.txt in the project root for license information.
  86329. *--------------------------------------------------------------------------------------------*/
  86330. define(__m[545/*vs/editor/standalone/browser/toggleHighContrast/toggleHighContrast*/], __M([0/*require*/,1/*exports*/,12/*vs/editor/browser/editorExtensions*/,94/*vs/editor/standalone/common/standaloneThemeService*/,59/*vs/editor/common/standaloneStrings*/]), function (require, exports, editorExtensions_1, standaloneThemeService_1, standaloneStrings_1) {
  86331. "use strict";
  86332. Object.defineProperty(exports, "__esModule", { value: true });
  86333. var ToggleHighContrast = /** @class */ (function (_super) {
  86334. __extends(ToggleHighContrast, _super);
  86335. function ToggleHighContrast() {
  86336. var _this = _super.call(this, {
  86337. id: 'editor.action.toggleHighContrast',
  86338. label: standaloneStrings_1.ToggleHighContrastNLS.toggleHighContrast,
  86339. alias: 'Toggle High Contrast Theme',
  86340. precondition: undefined
  86341. }) || this;
  86342. _this._originalThemeName = null;
  86343. return _this;
  86344. }
  86345. ToggleHighContrast.prototype.run = function (accessor, editor) {
  86346. var standaloneThemeService = accessor.get(standaloneThemeService_1.IStandaloneThemeService);
  86347. if (this._originalThemeName) {
  86348. // We must toggle back to the integrator's theme
  86349. standaloneThemeService.setTheme(this._originalThemeName);
  86350. this._originalThemeName = null;
  86351. }
  86352. else {
  86353. this._originalThemeName = standaloneThemeService.getTheme().themeName;
  86354. standaloneThemeService.setTheme('hc-black');
  86355. }
  86356. };
  86357. return ToggleHighContrast;
  86358. }(editorExtensions_1.EditorAction));
  86359. editorExtensions_1.registerEditorAction(ToggleHighContrast);
  86360. });
  86361. /*---------------------------------------------------------------------------------------------
  86362. * Copyright (c) Microsoft Corporation. All rights reserved.
  86363. * Licensed under the MIT License. See License.txt in the project root for license information.
  86364. *--------------------------------------------------------------------------------------------*/
  86365. define(__m[20/*vs/platform/theme/common/colorRegistry*/], __M([0/*require*/,1/*exports*/,42/*vs/platform/registry/common/platform*/,27/*vs/base/common/color*/,4/*vs/base/common/event*/,476/*vs/nls!vs/platform/theme/common/colorRegistry*/,220/*vs/platform/jsonschemas/common/jsonContributionRegistry*/,15/*vs/base/common/async*/]), function (require, exports, platform, color_1, event_1, nls, jsonContributionRegistry_1, async_1) {
  86366. "use strict";
  86367. Object.defineProperty(exports, "__esModule", { value: true });
  86368. // color registry
  86369. exports.Extensions = {
  86370. ColorContribution: 'base.contributions.colors'
  86371. };
  86372. var ColorRegistry = /** @class */ (function () {
  86373. function ColorRegistry() {
  86374. this._onDidChangeSchema = new event_1.Emitter();
  86375. this.onDidChangeSchema = this._onDidChangeSchema.event;
  86376. this.colorSchema = { type: 'object', properties: {} };
  86377. this.colorReferenceSchema = { type: 'string', enum: [], enumDescriptions: [] };
  86378. this.colorsById = {};
  86379. }
  86380. ColorRegistry.prototype.registerColor = function (id, defaults, description, needsTransparency, deprecationMessage) {
  86381. if (needsTransparency === void 0) { needsTransparency = false; }
  86382. var colorContribution = { id: id, description: description, defaults: defaults, needsTransparency: needsTransparency, deprecationMessage: deprecationMessage };
  86383. this.colorsById[id] = colorContribution;
  86384. var propertySchema = { type: 'string', description: description, format: 'color-hex', defaultSnippets: [{ body: '${1:#ff0000}' }] };
  86385. if (deprecationMessage) {
  86386. propertySchema.deprecationMessage = deprecationMessage;
  86387. }
  86388. this.colorSchema.properties[id] = propertySchema;
  86389. this.colorReferenceSchema.enum.push(id);
  86390. this.colorReferenceSchema.enumDescriptions.push(description);
  86391. this._onDidChangeSchema.fire();
  86392. return id;
  86393. };
  86394. ColorRegistry.prototype.resolveDefaultColor = function (id, theme) {
  86395. var colorDesc = this.colorsById[id];
  86396. if (colorDesc && colorDesc.defaults) {
  86397. var colorValue = colorDesc.defaults[theme.type];
  86398. return resolveColorValue(colorValue, theme);
  86399. }
  86400. return undefined;
  86401. };
  86402. ColorRegistry.prototype.getColorSchema = function () {
  86403. return this.colorSchema;
  86404. };
  86405. ColorRegistry.prototype.toString = function () {
  86406. var _this = this;
  86407. var sorter = function (a, b) {
  86408. var cat1 = a.indexOf('.') === -1 ? 0 : 1;
  86409. var cat2 = b.indexOf('.') === -1 ? 0 : 1;
  86410. if (cat1 !== cat2) {
  86411. return cat1 - cat2;
  86412. }
  86413. return a.localeCompare(b);
  86414. };
  86415. return Object.keys(this.colorsById).sort(sorter).map(function (k) { return "- `" + k + "`: " + _this.colorsById[k].description; }).join('\n');
  86416. };
  86417. return ColorRegistry;
  86418. }());
  86419. var colorRegistry = new ColorRegistry();
  86420. platform.Registry.add(exports.Extensions.ColorContribution, colorRegistry);
  86421. function registerColor(id, defaults, description, needsTransparency, deprecationMessage) {
  86422. return colorRegistry.registerColor(id, defaults, description, needsTransparency, deprecationMessage);
  86423. }
  86424. exports.registerColor = registerColor;
  86425. // ----- base colors
  86426. exports.foreground = registerColor('foreground', { dark: '#CCCCCC', light: '#616161', hc: '#FFFFFF' }, nls.localize(0, null));
  86427. exports.errorForeground = registerColor('errorForeground', { dark: '#F48771', light: '#A1260D', hc: '#F48771' }, nls.localize(1, null));
  86428. exports.focusBorder = registerColor('focusBorder', { dark: color_1.Color.fromHex('#0E639C').transparent(0.8), light: color_1.Color.fromHex('#007ACC').transparent(0.4), hc: '#F38518' }, nls.localize(2, null));
  86429. exports.contrastBorder = registerColor('contrastBorder', { light: null, dark: null, hc: '#6FC3DF' }, nls.localize(3, null));
  86430. exports.activeContrastBorder = registerColor('contrastActiveBorder', { light: null, dark: null, hc: exports.focusBorder }, nls.localize(4, null));
  86431. exports.textLinkForeground = registerColor('textLink.foreground', { light: '#006AB1', dark: '#3794FF', hc: '#3794FF' }, nls.localize(5, null));
  86432. exports.textCodeBlockBackground = registerColor('textCodeBlock.background', { light: '#dcdcdc66', dark: '#0a0a0a66', hc: color_1.Color.black }, nls.localize(6, null));
  86433. // ----- widgets
  86434. exports.widgetShadow = registerColor('widget.shadow', { dark: '#000000', light: '#A8A8A8', hc: null }, nls.localize(7, null));
  86435. exports.inputBackground = registerColor('input.background', { dark: '#3C3C3C', light: color_1.Color.white, hc: color_1.Color.black }, nls.localize(8, null));
  86436. exports.inputForeground = registerColor('input.foreground', { dark: exports.foreground, light: exports.foreground, hc: exports.foreground }, nls.localize(9, null));
  86437. exports.inputBorder = registerColor('input.border', { dark: null, light: null, hc: exports.contrastBorder }, nls.localize(10, null));
  86438. exports.inputActiveOptionBorder = registerColor('inputOption.activeBorder', { dark: '#007ACC00', light: '#007ACC00', hc: exports.contrastBorder }, nls.localize(11, null));
  86439. exports.inputActiveOptionBackground = registerColor('inputOption.activeBackground', { dark: transparent(exports.focusBorder, 0.5), light: transparent(exports.focusBorder, 0.3), hc: null }, nls.localize(12, null));
  86440. exports.inputValidationInfoBackground = registerColor('inputValidation.infoBackground', { dark: '#063B49', light: '#D6ECF2', hc: color_1.Color.black }, nls.localize(13, null));
  86441. exports.inputValidationInfoForeground = registerColor('inputValidation.infoForeground', { dark: null, light: null, hc: null }, nls.localize(14, null));
  86442. exports.inputValidationInfoBorder = registerColor('inputValidation.infoBorder', { dark: '#007acc', light: '#007acc', hc: exports.contrastBorder }, nls.localize(15, null));
  86443. exports.inputValidationWarningBackground = registerColor('inputValidation.warningBackground', { dark: '#352A05', light: '#F6F5D2', hc: color_1.Color.black }, nls.localize(16, null));
  86444. exports.inputValidationWarningForeground = registerColor('inputValidation.warningForeground', { dark: null, light: null, hc: null }, nls.localize(17, null));
  86445. exports.inputValidationWarningBorder = registerColor('inputValidation.warningBorder', { dark: '#B89500', light: '#B89500', hc: exports.contrastBorder }, nls.localize(18, null));
  86446. exports.inputValidationErrorBackground = registerColor('inputValidation.errorBackground', { dark: '#5A1D1D', light: '#F2DEDE', hc: color_1.Color.black }, nls.localize(19, null));
  86447. exports.inputValidationErrorForeground = registerColor('inputValidation.errorForeground', { dark: null, light: null, hc: null }, nls.localize(20, null));
  86448. exports.inputValidationErrorBorder = registerColor('inputValidation.errorBorder', { dark: '#BE1100', light: '#BE1100', hc: exports.contrastBorder }, nls.localize(21, null));
  86449. exports.selectBackground = registerColor('dropdown.background', { dark: '#3C3C3C', light: color_1.Color.white, hc: color_1.Color.black }, nls.localize(22, null));
  86450. exports.selectForeground = registerColor('dropdown.foreground', { dark: '#F0F0F0', light: null, hc: color_1.Color.white }, nls.localize(23, null));
  86451. exports.pickerGroupForeground = registerColor('pickerGroup.foreground', { dark: '#3794FF', light: '#0066BF', hc: color_1.Color.white }, nls.localize(24, null));
  86452. exports.pickerGroupBorder = registerColor('pickerGroup.border', { dark: '#3F3F46', light: '#CCCEDB', hc: color_1.Color.white }, nls.localize(25, null));
  86453. exports.badgeBackground = registerColor('badge.background', { dark: '#4D4D4D', light: '#C4C4C4', hc: color_1.Color.black }, nls.localize(26, null));
  86454. exports.badgeForeground = registerColor('badge.foreground', { dark: color_1.Color.white, light: '#333', hc: color_1.Color.white }, nls.localize(27, null));
  86455. exports.scrollbarShadow = registerColor('scrollbar.shadow', { dark: '#000000', light: '#DDDDDD', hc: null }, nls.localize(28, null));
  86456. exports.scrollbarSliderBackground = registerColor('scrollbarSlider.background', { dark: color_1.Color.fromHex('#797979').transparent(0.4), light: color_1.Color.fromHex('#646464').transparent(0.4), hc: transparent(exports.contrastBorder, 0.6) }, nls.localize(29, null));
  86457. exports.scrollbarSliderHoverBackground = registerColor('scrollbarSlider.hoverBackground', { dark: color_1.Color.fromHex('#646464').transparent(0.7), light: color_1.Color.fromHex('#646464').transparent(0.7), hc: transparent(exports.contrastBorder, 0.8) }, nls.localize(30, null));
  86458. exports.scrollbarSliderActiveBackground = registerColor('scrollbarSlider.activeBackground', { dark: color_1.Color.fromHex('#BFBFBF').transparent(0.4), light: color_1.Color.fromHex('#000000').transparent(0.6), hc: exports.contrastBorder }, nls.localize(31, null));
  86459. exports.progressBarBackground = registerColor('progressBar.background', { dark: color_1.Color.fromHex('#0E70C0'), light: color_1.Color.fromHex('#0E70C0'), hc: exports.contrastBorder }, nls.localize(32, null));
  86460. exports.editorErrorForeground = registerColor('editorError.foreground', { dark: '#F48771', light: '#E51400', hc: null }, nls.localize(33, null));
  86461. exports.editorErrorBorder = registerColor('editorError.border', { dark: null, light: null, hc: color_1.Color.fromHex('#E47777').transparent(0.8) }, nls.localize(34, null));
  86462. exports.editorWarningForeground = registerColor('editorWarning.foreground', { dark: '#CCA700', light: '#E9A700', hc: null }, nls.localize(35, null));
  86463. exports.editorWarningBorder = registerColor('editorWarning.border', { dark: null, light: null, hc: color_1.Color.fromHex('#FFCC00').transparent(0.8) }, nls.localize(36, null));
  86464. exports.editorInfoForeground = registerColor('editorInfo.foreground', { dark: '#75BEFF', light: '#75BEFF', hc: null }, nls.localize(37, null));
  86465. exports.editorInfoBorder = registerColor('editorInfo.border', { dark: null, light: null, hc: color_1.Color.fromHex('#75BEFF').transparent(0.8) }, nls.localize(38, null));
  86466. exports.editorHintForeground = registerColor('editorHint.foreground', { dark: color_1.Color.fromHex('#eeeeee').transparent(0.7), light: '#6c6c6c', hc: null }, nls.localize(39, null));
  86467. exports.editorHintBorder = registerColor('editorHint.border', { dark: null, light: null, hc: color_1.Color.fromHex('#eeeeee').transparent(0.8) }, nls.localize(40, null));
  86468. /**
  86469. * Editor background color.
  86470. * Because of bug https://monacotools.visualstudio.com/DefaultCollection/Monaco/_workitems/edit/13254
  86471. * we are *not* using the color white (or #ffffff, rgba(255,255,255)) but something very close to white.
  86472. */
  86473. exports.editorBackground = registerColor('editor.background', { light: '#fffffe', dark: '#1E1E1E', hc: color_1.Color.black }, nls.localize(41, null));
  86474. /**
  86475. * Editor foreground color.
  86476. */
  86477. exports.editorForeground = registerColor('editor.foreground', { light: '#333333', dark: '#BBBBBB', hc: color_1.Color.white }, nls.localize(42, null));
  86478. /**
  86479. * Editor widgets
  86480. */
  86481. exports.editorWidgetBackground = registerColor('editorWidget.background', { dark: '#252526', light: '#F3F3F3', hc: '#0C141F' }, nls.localize(43, null));
  86482. exports.editorWidgetForeground = registerColor('editorWidget.foreground', { dark: exports.foreground, light: exports.foreground, hc: exports.foreground }, nls.localize(44, null));
  86483. exports.editorWidgetBorder = registerColor('editorWidget.border', { dark: '#454545', light: '#C8C8C8', hc: exports.contrastBorder }, nls.localize(45, null));
  86484. exports.editorWidgetResizeBorder = registerColor('editorWidget.resizeBorder', { light: null, dark: null, hc: null }, nls.localize(46, null));
  86485. /**
  86486. * Editor selection colors.
  86487. */
  86488. exports.editorSelectionBackground = registerColor('editor.selectionBackground', { light: '#ADD6FF', dark: '#264F78', hc: '#f3f518' }, nls.localize(47, null));
  86489. exports.editorSelectionForeground = registerColor('editor.selectionForeground', { light: null, dark: null, hc: '#000000' }, nls.localize(48, null));
  86490. exports.editorInactiveSelection = registerColor('editor.inactiveSelectionBackground', { light: transparent(exports.editorSelectionBackground, 0.5), dark: transparent(exports.editorSelectionBackground, 0.5), hc: transparent(exports.editorSelectionBackground, 0.5) }, nls.localize(49, null), true);
  86491. exports.editorSelectionHighlight = registerColor('editor.selectionHighlightBackground', { light: lessProminent(exports.editorSelectionBackground, exports.editorBackground, 0.3, 0.6), dark: lessProminent(exports.editorSelectionBackground, exports.editorBackground, 0.3, 0.6), hc: null }, nls.localize(50, null), true);
  86492. exports.editorSelectionHighlightBorder = registerColor('editor.selectionHighlightBorder', { light: null, dark: null, hc: exports.activeContrastBorder }, nls.localize(51, null));
  86493. /**
  86494. * Editor find match colors.
  86495. */
  86496. exports.editorFindMatch = registerColor('editor.findMatchBackground', { light: '#A8AC94', dark: '#515C6A', hc: null }, nls.localize(52, null));
  86497. exports.editorFindMatchHighlight = registerColor('editor.findMatchHighlightBackground', { light: '#EA5C0055', dark: '#EA5C0055', hc: null }, nls.localize(53, null), true);
  86498. exports.editorFindRangeHighlight = registerColor('editor.findRangeHighlightBackground', { dark: '#3a3d4166', light: '#b4b4b44d', hc: null }, nls.localize(54, null), true);
  86499. exports.editorFindMatchBorder = registerColor('editor.findMatchBorder', { light: null, dark: null, hc: exports.activeContrastBorder }, nls.localize(55, null));
  86500. exports.editorFindMatchHighlightBorder = registerColor('editor.findMatchHighlightBorder', { light: null, dark: null, hc: exports.activeContrastBorder }, nls.localize(56, null));
  86501. exports.editorFindRangeHighlightBorder = registerColor('editor.findRangeHighlightBorder', { dark: null, light: null, hc: transparent(exports.activeContrastBorder, 0.4) }, nls.localize(57, null), true);
  86502. /**
  86503. * Editor hover
  86504. */
  86505. exports.editorHoverHighlight = registerColor('editor.hoverHighlightBackground', { light: '#ADD6FF26', dark: '#264f7840', hc: '#ADD6FF26' }, nls.localize(58, null), true);
  86506. exports.editorHoverBackground = registerColor('editorHoverWidget.background', { light: exports.editorWidgetBackground, dark: exports.editorWidgetBackground, hc: exports.editorWidgetBackground }, nls.localize(59, null));
  86507. exports.editorHoverForeground = registerColor('editorHoverWidget.foreground', { light: exports.editorWidgetForeground, dark: exports.editorWidgetForeground, hc: exports.editorWidgetForeground }, nls.localize(60, null));
  86508. exports.editorHoverBorder = registerColor('editorHoverWidget.border', { light: exports.editorWidgetBorder, dark: exports.editorWidgetBorder, hc: exports.editorWidgetBorder }, nls.localize(61, null));
  86509. exports.editorHoverStatusBarBackground = registerColor('editorHoverWidget.statusBarBackground', { dark: lighten(exports.editorHoverBackground, 0.2), light: darken(exports.editorHoverBackground, 0.05), hc: exports.editorWidgetBackground }, nls.localize(62, null));
  86510. /**
  86511. * Editor link colors
  86512. */
  86513. exports.editorActiveLinkForeground = registerColor('editorLink.activeForeground', { dark: '#4E94CE', light: color_1.Color.blue, hc: color_1.Color.cyan }, nls.localize(63, null));
  86514. /**
  86515. * Editor lighbulb icon colors
  86516. */
  86517. exports.editorLightBulbForeground = registerColor('editorLightBulb.foreground', { dark: '#FFCC00', light: '#DDB100', hc: '#FFCC00' }, nls.localize(64, null));
  86518. exports.editorLightBulbAutoFixForeground = registerColor('editorLightBulbAutoFix.foreground', { dark: '#75BEFF', light: '#007ACC', hc: '#75BEFF' }, nls.localize(65, null));
  86519. /**
  86520. * Diff Editor Colors
  86521. */
  86522. exports.defaultInsertColor = new color_1.Color(new color_1.RGBA(155, 185, 85, 0.2));
  86523. exports.defaultRemoveColor = new color_1.Color(new color_1.RGBA(255, 0, 0, 0.2));
  86524. exports.diffInserted = registerColor('diffEditor.insertedTextBackground', { dark: exports.defaultInsertColor, light: exports.defaultInsertColor, hc: null }, nls.localize(66, null), true);
  86525. exports.diffRemoved = registerColor('diffEditor.removedTextBackground', { dark: exports.defaultRemoveColor, light: exports.defaultRemoveColor, hc: null }, nls.localize(67, null), true);
  86526. exports.diffInsertedOutline = registerColor('diffEditor.insertedTextBorder', { dark: null, light: null, hc: '#33ff2eff' }, nls.localize(68, null));
  86527. exports.diffRemovedOutline = registerColor('diffEditor.removedTextBorder', { dark: null, light: null, hc: '#FF008F' }, nls.localize(69, null));
  86528. exports.diffBorder = registerColor('diffEditor.border', { dark: null, light: null, hc: exports.contrastBorder }, nls.localize(70, null));
  86529. /**
  86530. * List and tree colors
  86531. */
  86532. exports.listFocusBackground = registerColor('list.focusBackground', { dark: '#062F4A', light: '#D6EBFF', hc: null }, nls.localize(71, null));
  86533. exports.listFocusForeground = registerColor('list.focusForeground', { dark: null, light: null, hc: null }, nls.localize(72, null));
  86534. exports.listActiveSelectionBackground = registerColor('list.activeSelectionBackground', { dark: '#094771', light: '#0074E8', hc: null }, nls.localize(73, null));
  86535. exports.listActiveSelectionForeground = registerColor('list.activeSelectionForeground', { dark: color_1.Color.white, light: color_1.Color.white, hc: null }, nls.localize(74, null));
  86536. exports.listInactiveSelectionBackground = registerColor('list.inactiveSelectionBackground', { dark: '#37373D', light: '#E4E6F1', hc: null }, nls.localize(75, null));
  86537. exports.listInactiveSelectionForeground = registerColor('list.inactiveSelectionForeground', { dark: null, light: null, hc: null }, nls.localize(76, null));
  86538. exports.listInactiveFocusBackground = registerColor('list.inactiveFocusBackground', { dark: null, light: null, hc: null }, nls.localize(77, null));
  86539. exports.listHoverBackground = registerColor('list.hoverBackground', { dark: '#2A2D2E', light: '#F0F0F0', hc: null }, nls.localize(78, null));
  86540. exports.listHoverForeground = registerColor('list.hoverForeground', { dark: null, light: null, hc: null }, nls.localize(79, null));
  86541. exports.listDropBackground = registerColor('list.dropBackground', { dark: exports.listFocusBackground, light: exports.listFocusBackground, hc: null }, nls.localize(80, null));
  86542. exports.listHighlightForeground = registerColor('list.highlightForeground', { dark: '#0097fb', light: '#0066BF', hc: exports.focusBorder }, nls.localize(81, null));
  86543. exports.listFilterWidgetBackground = registerColor('listFilterWidget.background', { light: '#efc1ad', dark: '#653723', hc: color_1.Color.black }, nls.localize(82, null));
  86544. exports.listFilterWidgetOutline = registerColor('listFilterWidget.outline', { dark: color_1.Color.transparent, light: color_1.Color.transparent, hc: '#f38518' }, nls.localize(83, null));
  86545. exports.listFilterWidgetNoMatchesOutline = registerColor('listFilterWidget.noMatchesOutline', { dark: '#BE1100', light: '#BE1100', hc: exports.contrastBorder }, nls.localize(84, null));
  86546. exports.treeIndentGuidesStroke = registerColor('tree.indentGuidesStroke', { dark: '#585858', light: '#a9a9a9', hc: '#a9a9a9' }, nls.localize(85, null));
  86547. /**
  86548. * Menu colors
  86549. */
  86550. exports.menuBorder = registerColor('menu.border', { dark: null, light: null, hc: exports.contrastBorder }, nls.localize(86, null));
  86551. exports.menuForeground = registerColor('menu.foreground', { dark: exports.selectForeground, light: exports.foreground, hc: exports.selectForeground }, nls.localize(87, null));
  86552. exports.menuBackground = registerColor('menu.background', { dark: exports.selectBackground, light: exports.selectBackground, hc: exports.selectBackground }, nls.localize(88, null));
  86553. exports.menuSelectionForeground = registerColor('menu.selectionForeground', { dark: exports.listActiveSelectionForeground, light: exports.listActiveSelectionForeground, hc: exports.listActiveSelectionForeground }, nls.localize(89, null));
  86554. exports.menuSelectionBackground = registerColor('menu.selectionBackground', { dark: exports.listActiveSelectionBackground, light: exports.listActiveSelectionBackground, hc: exports.listActiveSelectionBackground }, nls.localize(90, null));
  86555. exports.menuSelectionBorder = registerColor('menu.selectionBorder', { dark: null, light: null, hc: exports.activeContrastBorder }, nls.localize(91, null));
  86556. exports.menuSeparatorBackground = registerColor('menu.separatorBackground', { dark: '#BBBBBB', light: '#888888', hc: exports.contrastBorder }, nls.localize(92, null));
  86557. /**
  86558. * Snippet placeholder colors
  86559. */
  86560. exports.snippetTabstopHighlightBackground = registerColor('editor.snippetTabstopHighlightBackground', { dark: new color_1.Color(new color_1.RGBA(124, 124, 124, 0.3)), light: new color_1.Color(new color_1.RGBA(10, 50, 100, 0.2)), hc: new color_1.Color(new color_1.RGBA(124, 124, 124, 0.3)) }, nls.localize(93, null));
  86561. exports.snippetTabstopHighlightBorder = registerColor('editor.snippetTabstopHighlightBorder', { dark: null, light: null, hc: null }, nls.localize(94, null));
  86562. exports.snippetFinalTabstopHighlightBackground = registerColor('editor.snippetFinalTabstopHighlightBackground', { dark: null, light: null, hc: null }, nls.localize(95, null));
  86563. exports.snippetFinalTabstopHighlightBorder = registerColor('editor.snippetFinalTabstopHighlightBorder', { dark: '#525252', light: new color_1.Color(new color_1.RGBA(10, 50, 100, 0.5)), hc: '#525252' }, nls.localize(96, null));
  86564. exports.overviewRulerFindMatchForeground = registerColor('editorOverviewRuler.findMatchForeground', { dark: '#d186167e', light: '#d186167e', hc: '#AB5A00' }, nls.localize(97, null), true);
  86565. exports.overviewRulerSelectionHighlightForeground = registerColor('editorOverviewRuler.selectionHighlightForeground', { dark: '#A0A0A0CC', light: '#A0A0A0CC', hc: '#A0A0A0CC' }, nls.localize(98, null), true);
  86566. exports.minimapFindMatch = registerColor('minimap.findMatchHighlight', { light: '#d18616', dark: '#d18616', hc: '#AB5A00' }, nls.localize(99, null), true);
  86567. exports.minimapSelection = registerColor('minimap.selectionHighlight', { light: '#ADD6FF', dark: '#264F78', hc: '#ffffff' }, nls.localize(100, null), true);
  86568. exports.minimapError = registerColor('minimap.errorHighlight', { dark: new color_1.Color(new color_1.RGBA(255, 18, 18, 0.7)), light: new color_1.Color(new color_1.RGBA(255, 18, 18, 0.7)), hc: new color_1.Color(new color_1.RGBA(255, 50, 50, 1)) }, nls.localize(101, null));
  86569. exports.minimapWarning = registerColor('minimap.warningHighlight', { dark: exports.editorWarningForeground, light: exports.editorWarningForeground, hc: exports.editorWarningBorder }, nls.localize(102, null));
  86570. exports.problemsErrorIconForeground = registerColor('problemsErrorIcon.foreground', { dark: exports.editorErrorForeground, light: exports.editorErrorForeground, hc: exports.editorErrorForeground }, nls.localize(103, null));
  86571. exports.problemsWarningIconForeground = registerColor('problemsWarningIcon.foreground', { dark: exports.editorWarningForeground, light: exports.editorWarningForeground, hc: exports.editorWarningForeground }, nls.localize(104, null));
  86572. exports.problemsInfoIconForeground = registerColor('problemsInfoIcon.foreground', { dark: exports.editorInfoForeground, light: exports.editorInfoForeground, hc: exports.editorInfoForeground }, nls.localize(105, null));
  86573. // ----- color functions
  86574. function darken(colorValue, factor) {
  86575. return function (theme) {
  86576. var color = resolveColorValue(colorValue, theme);
  86577. if (color) {
  86578. return color.darken(factor);
  86579. }
  86580. return undefined;
  86581. };
  86582. }
  86583. exports.darken = darken;
  86584. function lighten(colorValue, factor) {
  86585. return function (theme) {
  86586. var color = resolveColorValue(colorValue, theme);
  86587. if (color) {
  86588. return color.lighten(factor);
  86589. }
  86590. return undefined;
  86591. };
  86592. }
  86593. exports.lighten = lighten;
  86594. function transparent(colorValue, factor) {
  86595. return function (theme) {
  86596. var color = resolveColorValue(colorValue, theme);
  86597. if (color) {
  86598. return color.transparent(factor);
  86599. }
  86600. return undefined;
  86601. };
  86602. }
  86603. exports.transparent = transparent;
  86604. function oneOf() {
  86605. var colorValues = [];
  86606. for (var _i = 0; _i < arguments.length; _i++) {
  86607. colorValues[_i] = arguments[_i];
  86608. }
  86609. return function (theme) {
  86610. for (var _i = 0, colorValues_1 = colorValues; _i < colorValues_1.length; _i++) {
  86611. var colorValue = colorValues_1[_i];
  86612. var color = resolveColorValue(colorValue, theme);
  86613. if (color) {
  86614. return color;
  86615. }
  86616. }
  86617. return undefined;
  86618. };
  86619. }
  86620. exports.oneOf = oneOf;
  86621. function lessProminent(colorValue, backgroundColorValue, factor, transparency) {
  86622. return function (theme) {
  86623. var from = resolveColorValue(colorValue, theme);
  86624. if (from) {
  86625. var backgroundColor = resolveColorValue(backgroundColorValue, theme);
  86626. if (backgroundColor) {
  86627. if (from.isDarkerThan(backgroundColor)) {
  86628. return color_1.Color.getLighterColor(from, backgroundColor, factor).transparent(transparency);
  86629. }
  86630. return color_1.Color.getDarkerColor(from, backgroundColor, factor).transparent(transparency);
  86631. }
  86632. return from.transparent(factor * transparency);
  86633. }
  86634. return undefined;
  86635. };
  86636. }
  86637. // ----- implementation
  86638. /**
  86639. * @param colorValue Resolve a color value in the context of a theme
  86640. */
  86641. function resolveColorValue(colorValue, theme) {
  86642. if (colorValue === null) {
  86643. return undefined;
  86644. }
  86645. else if (typeof colorValue === 'string') {
  86646. if (colorValue[0] === '#') {
  86647. return color_1.Color.fromHex(colorValue);
  86648. }
  86649. return theme.getColor(colorValue);
  86650. }
  86651. else if (colorValue instanceof color_1.Color) {
  86652. return colorValue;
  86653. }
  86654. else if (typeof colorValue === 'function') {
  86655. return colorValue(theme);
  86656. }
  86657. return undefined;
  86658. }
  86659. exports.resolveColorValue = resolveColorValue;
  86660. exports.workbenchColorsSchemaId = 'vscode://schemas/workbench-colors';
  86661. var schemaRegistry = platform.Registry.as(jsonContributionRegistry_1.Extensions.JSONContribution);
  86662. schemaRegistry.registerSchema(exports.workbenchColorsSchemaId, colorRegistry.getColorSchema());
  86663. var delayer = new async_1.RunOnceScheduler(function () { return schemaRegistry.notifySchemaChanged(exports.workbenchColorsSchemaId); }, 200);
  86664. colorRegistry.onDidChangeSchema(function () {
  86665. if (!delayer.isScheduled()) {
  86666. delayer.schedule();
  86667. }
  86668. });
  86669. });
  86670. // setTimeout(_ => console.log(colorRegistry.toString()), 5000);
  86671. /*---------------------------------------------------------------------------------------------
  86672. * Copyright (c) Microsoft Corporation. All rights reserved.
  86673. * Licensed under the MIT License. See License.txt in the project root for license information.
  86674. *--------------------------------------------------------------------------------------------*/
  86675. define(__m[97/*vs/platform/theme/common/styler*/], __M([0/*require*/,1/*exports*/,20/*vs/platform/theme/common/colorRegistry*/]), function (require, exports, colorRegistry_1) {
  86676. "use strict";
  86677. Object.defineProperty(exports, "__esModule", { value: true });
  86678. function computeStyles(theme, styleMap) {
  86679. var styles = Object.create(null);
  86680. for (var key in styleMap) {
  86681. var value = styleMap[key];
  86682. if (value) {
  86683. styles[key] = colorRegistry_1.resolveColorValue(value, theme);
  86684. }
  86685. }
  86686. return styles;
  86687. }
  86688. exports.computeStyles = computeStyles;
  86689. function attachStyler(themeService, styleMap, widgetOrCallback) {
  86690. function applyStyles(theme) {
  86691. var styles = computeStyles(themeService.getTheme(), styleMap);
  86692. if (typeof widgetOrCallback === 'function') {
  86693. widgetOrCallback(styles);
  86694. }
  86695. else {
  86696. widgetOrCallback.style(styles);
  86697. }
  86698. }
  86699. applyStyles(themeService.getTheme());
  86700. return themeService.onThemeChange(applyStyles);
  86701. }
  86702. exports.attachStyler = attachStyler;
  86703. function attachBadgeStyler(widget, themeService, style) {
  86704. return attachStyler(themeService, {
  86705. badgeBackground: (style && style.badgeBackground) || colorRegistry_1.badgeBackground,
  86706. badgeForeground: (style && style.badgeForeground) || colorRegistry_1.badgeForeground,
  86707. badgeBorder: colorRegistry_1.contrastBorder
  86708. }, widget);
  86709. }
  86710. exports.attachBadgeStyler = attachBadgeStyler;
  86711. function attachQuickOpenStyler(widget, themeService, style) {
  86712. return attachStyler(themeService, {
  86713. foreground: (style && style.foreground) || colorRegistry_1.foreground,
  86714. background: (style && style.background) || colorRegistry_1.editorBackground,
  86715. borderColor: style && style.borderColor || colorRegistry_1.contrastBorder,
  86716. widgetShadow: style && style.widgetShadow || colorRegistry_1.widgetShadow,
  86717. progressBarBackground: style && style.progressBarBackground || colorRegistry_1.progressBarBackground,
  86718. pickerGroupForeground: style && style.pickerGroupForeground || colorRegistry_1.pickerGroupForeground,
  86719. pickerGroupBorder: style && style.pickerGroupBorder || colorRegistry_1.pickerGroupBorder,
  86720. inputBackground: (style && style.inputBackground) || colorRegistry_1.inputBackground,
  86721. inputForeground: (style && style.inputForeground) || colorRegistry_1.inputForeground,
  86722. inputBorder: (style && style.inputBorder) || colorRegistry_1.inputBorder,
  86723. inputValidationInfoBorder: (style && style.inputValidationInfoBorder) || colorRegistry_1.inputValidationInfoBorder,
  86724. inputValidationInfoBackground: (style && style.inputValidationInfoBackground) || colorRegistry_1.inputValidationInfoBackground,
  86725. inputValidationInfoForeground: (style && style.inputValidationInfoForeground) || colorRegistry_1.inputValidationInfoForeground,
  86726. inputValidationWarningBorder: (style && style.inputValidationWarningBorder) || colorRegistry_1.inputValidationWarningBorder,
  86727. inputValidationWarningBackground: (style && style.inputValidationWarningBackground) || colorRegistry_1.inputValidationWarningBackground,
  86728. inputValidationWarningForeground: (style && style.inputValidationWarningForeground) || colorRegistry_1.inputValidationWarningForeground,
  86729. inputValidationErrorBorder: (style && style.inputValidationErrorBorder) || colorRegistry_1.inputValidationErrorBorder,
  86730. inputValidationErrorBackground: (style && style.inputValidationErrorBackground) || colorRegistry_1.inputValidationErrorBackground,
  86731. inputValidationErrorForeground: (style && style.inputValidationErrorForeground) || colorRegistry_1.inputValidationErrorForeground,
  86732. listFocusBackground: (style && style.listFocusBackground) || colorRegistry_1.listFocusBackground,
  86733. listFocusForeground: (style && style.listFocusForeground) || colorRegistry_1.listFocusForeground,
  86734. listActiveSelectionBackground: (style && style.listActiveSelectionBackground) || colorRegistry_1.darken(colorRegistry_1.listActiveSelectionBackground, 0.1),
  86735. listActiveSelectionForeground: (style && style.listActiveSelectionForeground) || colorRegistry_1.listActiveSelectionForeground,
  86736. listFocusAndSelectionBackground: style && style.listFocusAndSelectionBackground || colorRegistry_1.listActiveSelectionBackground,
  86737. listFocusAndSelectionForeground: (style && style.listFocusAndSelectionForeground) || colorRegistry_1.listActiveSelectionForeground,
  86738. listInactiveSelectionBackground: (style && style.listInactiveSelectionBackground) || colorRegistry_1.listInactiveSelectionBackground,
  86739. listInactiveSelectionForeground: (style && style.listInactiveSelectionForeground) || colorRegistry_1.listInactiveSelectionForeground,
  86740. listInactiveFocusBackground: (style && style.listInactiveFocusBackground) || colorRegistry_1.listInactiveFocusBackground,
  86741. listHoverBackground: (style && style.listHoverBackground) || colorRegistry_1.listHoverBackground,
  86742. listHoverForeground: (style && style.listHoverForeground) || colorRegistry_1.listHoverForeground,
  86743. listDropBackground: (style && style.listDropBackground) || colorRegistry_1.listDropBackground,
  86744. listFocusOutline: (style && style.listFocusOutline) || colorRegistry_1.activeContrastBorder,
  86745. listSelectionOutline: (style && style.listSelectionOutline) || colorRegistry_1.activeContrastBorder,
  86746. listHoverOutline: (style && style.listHoverOutline) || colorRegistry_1.activeContrastBorder
  86747. }, widget);
  86748. }
  86749. exports.attachQuickOpenStyler = attachQuickOpenStyler;
  86750. function attachListStyler(widget, themeService, overrides) {
  86751. return attachStyler(themeService, __assign(__assign({}, exports.defaultListStyles), (overrides || {})), widget);
  86752. }
  86753. exports.attachListStyler = attachListStyler;
  86754. exports.defaultListStyles = {
  86755. listFocusBackground: colorRegistry_1.listFocusBackground,
  86756. listFocusForeground: colorRegistry_1.listFocusForeground,
  86757. listActiveSelectionBackground: colorRegistry_1.darken(colorRegistry_1.listActiveSelectionBackground, 0.1),
  86758. listActiveSelectionForeground: colorRegistry_1.listActiveSelectionForeground,
  86759. listFocusAndSelectionBackground: colorRegistry_1.listActiveSelectionBackground,
  86760. listFocusAndSelectionForeground: colorRegistry_1.listActiveSelectionForeground,
  86761. listInactiveSelectionBackground: colorRegistry_1.listInactiveSelectionBackground,
  86762. listInactiveSelectionForeground: colorRegistry_1.listInactiveSelectionForeground,
  86763. listInactiveFocusBackground: colorRegistry_1.listInactiveFocusBackground,
  86764. listHoverBackground: colorRegistry_1.listHoverBackground,
  86765. listHoverForeground: colorRegistry_1.listHoverForeground,
  86766. listDropBackground: colorRegistry_1.listDropBackground,
  86767. listFocusOutline: colorRegistry_1.activeContrastBorder,
  86768. listSelectionOutline: colorRegistry_1.activeContrastBorder,
  86769. listHoverOutline: colorRegistry_1.activeContrastBorder,
  86770. listFilterWidgetBackground: colorRegistry_1.listFilterWidgetBackground,
  86771. listFilterWidgetOutline: colorRegistry_1.listFilterWidgetOutline,
  86772. listFilterWidgetNoMatchesOutline: colorRegistry_1.listFilterWidgetNoMatchesOutline,
  86773. listMatchesShadow: colorRegistry_1.widgetShadow,
  86774. treeIndentGuidesStroke: colorRegistry_1.treeIndentGuidesStroke
  86775. };
  86776. exports.defaultMenuStyles = {
  86777. shadowColor: colorRegistry_1.widgetShadow,
  86778. borderColor: colorRegistry_1.menuBorder,
  86779. foregroundColor: colorRegistry_1.menuForeground,
  86780. backgroundColor: colorRegistry_1.menuBackground,
  86781. selectionForegroundColor: colorRegistry_1.menuSelectionForeground,
  86782. selectionBackgroundColor: colorRegistry_1.menuSelectionBackground,
  86783. selectionBorderColor: colorRegistry_1.menuSelectionBorder,
  86784. separatorColor: colorRegistry_1.menuSeparatorBackground
  86785. };
  86786. function attachMenuStyler(widget, themeService, style) {
  86787. return attachStyler(themeService, __assign(__assign({}, exports.defaultMenuStyles), style), widget);
  86788. }
  86789. exports.attachMenuStyler = attachMenuStyler;
  86790. });
  86791. /*---------------------------------------------------------------------------------------------
  86792. * Copyright (c) Microsoft Corporation. All rights reserved.
  86793. * Licensed under the MIT License. See License.txt in the project root for license information.
  86794. *--------------------------------------------------------------------------------------------*/
  86795. define(__m[546/*vs/editor/standalone/browser/quickOpen/quickOpenEditorWidget*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,414/*vs/base/parts/quickopen/browser/quickOpenWidget*/,20/*vs/platform/theme/common/colorRegistry*/,97/*vs/platform/theme/common/styler*/]), function (require, exports, dom_1, quickOpenWidget_1, colorRegistry_1, styler_1) {
  86796. "use strict";
  86797. Object.defineProperty(exports, "__esModule", { value: true });
  86798. var QuickOpenEditorWidget = /** @class */ (function () {
  86799. function QuickOpenEditorWidget(codeEditor, onOk, onCancel, onType, configuration, themeService) {
  86800. this.codeEditor = codeEditor;
  86801. this.themeService = themeService;
  86802. this.visible = false;
  86803. this.domNode = document.createElement('div');
  86804. this.quickOpenWidget = new quickOpenWidget_1.QuickOpenWidget(this.domNode, {
  86805. onOk: onOk,
  86806. onCancel: onCancel,
  86807. onType: onType
  86808. }, {
  86809. inputPlaceHolder: undefined,
  86810. inputAriaLabel: configuration.inputAriaLabel,
  86811. keyboardSupport: true
  86812. });
  86813. this.styler = styler_1.attachQuickOpenStyler(this.quickOpenWidget, this.themeService, {
  86814. pickerGroupForeground: colorRegistry_1.foreground
  86815. });
  86816. this.quickOpenWidget.create();
  86817. this.codeEditor.addOverlayWidget(this);
  86818. }
  86819. QuickOpenEditorWidget.prototype.setInput = function (model, focus) {
  86820. this.quickOpenWidget.setInput(model, focus);
  86821. };
  86822. QuickOpenEditorWidget.prototype.getId = function () {
  86823. return QuickOpenEditorWidget.ID;
  86824. };
  86825. QuickOpenEditorWidget.prototype.getDomNode = function () {
  86826. return this.domNode;
  86827. };
  86828. QuickOpenEditorWidget.prototype.destroy = function () {
  86829. this.codeEditor.removeOverlayWidget(this);
  86830. this.quickOpenWidget.dispose();
  86831. this.styler.dispose();
  86832. };
  86833. QuickOpenEditorWidget.prototype.show = function (value) {
  86834. this.visible = true;
  86835. var editorLayout = this.codeEditor.getLayoutInfo();
  86836. if (editorLayout) {
  86837. this.quickOpenWidget.layout(new dom_1.Dimension(editorLayout.width, editorLayout.height));
  86838. }
  86839. this.quickOpenWidget.show(value);
  86840. this.codeEditor.layoutOverlayWidget(this);
  86841. };
  86842. QuickOpenEditorWidget.prototype.getPosition = function () {
  86843. if (this.visible) {
  86844. return {
  86845. preference: 2 /* TOP_CENTER */
  86846. };
  86847. }
  86848. return null;
  86849. };
  86850. QuickOpenEditorWidget.ID = 'editor.contrib.quickOpenEditorWidget';
  86851. return QuickOpenEditorWidget;
  86852. }());
  86853. exports.QuickOpenEditorWidget = QuickOpenEditorWidget;
  86854. });
  86855. /*---------------------------------------------------------------------------------------------
  86856. * Copyright (c) Microsoft Corporation. All rights reserved.
  86857. * Licensed under the MIT License. See License.txt in the project root for license information.
  86858. *--------------------------------------------------------------------------------------------*/
  86859. define(__m[547/*vs/platform/contextview/browser/contextMenuHandler*/], __M([0/*require*/,1/*exports*/,55/*vs/base/common/actions*/,2/*vs/base/common/lifecycle*/,205/*vs/base/browser/ui/menu/menu*/,6/*vs/base/browser/dom*/,97/*vs/platform/theme/common/styler*/,52/*vs/base/browser/event*/,45/*vs/base/browser/mouseEvent*/,332/*vs/css!vs/platform/contextview/browser/contextMenuHandler*/]), function (require, exports, actions_1, lifecycle_1, menu_1, dom_1, styler_1, event_1, mouseEvent_1) {
  86860. "use strict";
  86861. Object.defineProperty(exports, "__esModule", { value: true });
  86862. var ContextMenuHandler = /** @class */ (function () {
  86863. function ContextMenuHandler(contextViewService, telemetryService, notificationService, keybindingService, themeService) {
  86864. this.contextViewService = contextViewService;
  86865. this.telemetryService = telemetryService;
  86866. this.notificationService = notificationService;
  86867. this.keybindingService = keybindingService;
  86868. this.themeService = themeService;
  86869. this.focusToReturn = null;
  86870. this.block = null;
  86871. this.options = { blockMouse: true };
  86872. }
  86873. ContextMenuHandler.prototype.configure = function (options) {
  86874. this.options = options;
  86875. };
  86876. ContextMenuHandler.prototype.showContextMenu = function (delegate) {
  86877. var _this = this;
  86878. var actions = delegate.getActions();
  86879. if (!actions.length) {
  86880. return; // Don't render an empty context menu
  86881. }
  86882. this.focusToReturn = document.activeElement;
  86883. var menu;
  86884. this.contextViewService.showContextView({
  86885. getAnchor: function () { return delegate.getAnchor(); },
  86886. canRelayout: false,
  86887. anchorAlignment: delegate.anchorAlignment,
  86888. render: function (container) {
  86889. var className = delegate.getMenuClassName ? delegate.getMenuClassName() : '';
  86890. if (className) {
  86891. container.className += ' ' + className;
  86892. }
  86893. // Render invisible div to block mouse interaction in the rest of the UI
  86894. if (_this.options.blockMouse) {
  86895. _this.block = container.appendChild(dom_1.$('.context-view-block'));
  86896. }
  86897. var menuDisposables = new lifecycle_1.DisposableStore();
  86898. var actionRunner = delegate.actionRunner || new actions_1.ActionRunner();
  86899. actionRunner.onDidBeforeRun(_this.onActionRun, _this, menuDisposables);
  86900. actionRunner.onDidRun(_this.onDidActionRun, _this, menuDisposables);
  86901. menu = new menu_1.Menu(container, actions, {
  86902. actionViewItemProvider: delegate.getActionViewItem,
  86903. context: delegate.getActionsContext ? delegate.getActionsContext() : null,
  86904. actionRunner: actionRunner,
  86905. getKeyBinding: delegate.getKeyBinding ? delegate.getKeyBinding : function (action) { return _this.keybindingService.lookupKeybinding(action.id); }
  86906. });
  86907. menuDisposables.add(styler_1.attachMenuStyler(menu, _this.themeService));
  86908. menu.onDidCancel(function () { return _this.contextViewService.hideContextView(true); }, null, menuDisposables);
  86909. menu.onDidBlur(function () { return _this.contextViewService.hideContextView(true); }, null, menuDisposables);
  86910. event_1.domEvent(window, dom_1.EventType.BLUR)(function () { _this.contextViewService.hideContextView(true); }, null, menuDisposables);
  86911. event_1.domEvent(window, dom_1.EventType.MOUSE_DOWN)(function (e) {
  86912. if (e.defaultPrevented) {
  86913. return;
  86914. }
  86915. var event = new mouseEvent_1.StandardMouseEvent(e);
  86916. var element = event.target;
  86917. // Don't do anything as we are likely creating a context menu
  86918. if (event.rightButton) {
  86919. return;
  86920. }
  86921. while (element) {
  86922. if (element === container) {
  86923. return;
  86924. }
  86925. element = element.parentElement;
  86926. }
  86927. _this.contextViewService.hideContextView(true);
  86928. }, null, menuDisposables);
  86929. return lifecycle_1.combinedDisposable(menuDisposables, menu);
  86930. },
  86931. focus: function () {
  86932. if (menu) {
  86933. menu.focus(!!delegate.autoSelectFirstItem);
  86934. }
  86935. },
  86936. onHide: function (didCancel) {
  86937. if (delegate.onHide) {
  86938. delegate.onHide(!!didCancel);
  86939. }
  86940. if (_this.block) {
  86941. dom_1.removeNode(_this.block);
  86942. _this.block = null;
  86943. }
  86944. if (_this.focusToReturn) {
  86945. _this.focusToReturn.focus();
  86946. }
  86947. }
  86948. });
  86949. };
  86950. ContextMenuHandler.prototype.onActionRun = function (e) {
  86951. if (this.telemetryService) {
  86952. this.telemetryService.publicLog2('workbenchActionExecuted', { id: e.action.id, from: 'contextMenu' });
  86953. }
  86954. this.contextViewService.hideContextView(false);
  86955. // Restore focus here
  86956. if (this.focusToReturn) {
  86957. this.focusToReturn.focus();
  86958. }
  86959. };
  86960. ContextMenuHandler.prototype.onDidActionRun = function (e) {
  86961. if (e.error && this.notificationService) {
  86962. this.notificationService.error(e.error);
  86963. }
  86964. };
  86965. return ContextMenuHandler;
  86966. }());
  86967. exports.ContextMenuHandler = ContextMenuHandler;
  86968. });
  86969. /*---------------------------------------------------------------------------------------------
  86970. * Copyright (c) Microsoft Corporation. All rights reserved.
  86971. * Licensed under the MIT License. See License.txt in the project root for license information.
  86972. *--------------------------------------------------------------------------------------------*/
  86973. define(__m[14/*vs/platform/theme/common/themeService*/], __M([0/*require*/,1/*exports*/,11/*vs/platform/instantiation/common/instantiation*/,2/*vs/base/common/lifecycle*/,42/*vs/platform/registry/common/platform*/,4/*vs/base/common/event*/]), function (require, exports, instantiation_1, lifecycle_1, platform, event_1) {
  86974. "use strict";
  86975. Object.defineProperty(exports, "__esModule", { value: true });
  86976. exports.IThemeService = instantiation_1.createDecorator('themeService');
  86977. function themeColorFromId(id) {
  86978. return { id: id };
  86979. }
  86980. exports.themeColorFromId = themeColorFromId;
  86981. // base themes
  86982. exports.DARK = 'dark';
  86983. exports.HIGH_CONTRAST = 'hc';
  86984. function getThemeTypeSelector(type) {
  86985. switch (type) {
  86986. case exports.DARK: return 'vs-dark';
  86987. case exports.HIGH_CONTRAST: return 'hc-black';
  86988. default: return 'vs';
  86989. }
  86990. }
  86991. exports.getThemeTypeSelector = getThemeTypeSelector;
  86992. // static theming participant
  86993. exports.Extensions = {
  86994. ThemingContribution: 'base.contributions.theming'
  86995. };
  86996. var ThemingRegistry = /** @class */ (function () {
  86997. function ThemingRegistry() {
  86998. this.themingParticipants = [];
  86999. this.themingParticipants = [];
  87000. this.onThemingParticipantAddedEmitter = new event_1.Emitter();
  87001. }
  87002. ThemingRegistry.prototype.onThemeChange = function (participant) {
  87003. var _this = this;
  87004. this.themingParticipants.push(participant);
  87005. this.onThemingParticipantAddedEmitter.fire(participant);
  87006. return lifecycle_1.toDisposable(function () {
  87007. var idx = _this.themingParticipants.indexOf(participant);
  87008. _this.themingParticipants.splice(idx, 1);
  87009. });
  87010. };
  87011. ThemingRegistry.prototype.getThemingParticipants = function () {
  87012. return this.themingParticipants;
  87013. };
  87014. return ThemingRegistry;
  87015. }());
  87016. var themingRegistry = new ThemingRegistry();
  87017. platform.Registry.add(exports.Extensions.ThemingContribution, themingRegistry);
  87018. function registerThemingParticipant(participant) {
  87019. return themingRegistry.onThemeChange(participant);
  87020. }
  87021. exports.registerThemingParticipant = registerThemingParticipant;
  87022. });
  87023. /*---------------------------------------------------------------------------------------------
  87024. * Copyright (c) Microsoft Corporation. All rights reserved.
  87025. * Licensed under the MIT License. See License.txt in the project root for license information.
  87026. *--------------------------------------------------------------------------------------------*/
  87027. define(__m[548/*vs/editor/browser/services/codeEditorServiceImpl*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,2/*vs/base/common/lifecycle*/,5/*vs/base/common/strings*/,25/*vs/base/common/uri*/,334/*vs/editor/browser/services/abstractCodeEditorService*/,68/*vs/editor/common/editorCommon*/,48/*vs/editor/common/model*/,14/*vs/platform/theme/common/themeService*/]), function (require, exports, dom, lifecycle_1, strings, uri_1, abstractCodeEditorService_1, editorCommon_1, model_1, themeService_1) {
  87028. "use strict";
  87029. Object.defineProperty(exports, "__esModule", { value: true });
  87030. var RefCountedStyleSheet = /** @class */ (function () {
  87031. function RefCountedStyleSheet(parent, editorId, styleSheet) {
  87032. this._parent = parent;
  87033. this._editorId = editorId;
  87034. this.styleSheet = styleSheet;
  87035. this._refCount = 0;
  87036. }
  87037. RefCountedStyleSheet.prototype.ref = function () {
  87038. this._refCount++;
  87039. };
  87040. RefCountedStyleSheet.prototype.unref = function () {
  87041. var _a;
  87042. this._refCount--;
  87043. if (this._refCount === 0) {
  87044. (_a = this.styleSheet.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(this.styleSheet);
  87045. this._parent._removeEditorStyleSheets(this._editorId);
  87046. }
  87047. };
  87048. return RefCountedStyleSheet;
  87049. }());
  87050. var GlobalStyleSheet = /** @class */ (function () {
  87051. function GlobalStyleSheet(styleSheet) {
  87052. this.styleSheet = styleSheet;
  87053. }
  87054. GlobalStyleSheet.prototype.ref = function () {
  87055. };
  87056. GlobalStyleSheet.prototype.unref = function () {
  87057. };
  87058. return GlobalStyleSheet;
  87059. }());
  87060. var CodeEditorServiceImpl = /** @class */ (function (_super) {
  87061. __extends(CodeEditorServiceImpl, _super);
  87062. function CodeEditorServiceImpl(themeService, styleSheet) {
  87063. if (styleSheet === void 0) { styleSheet = null; }
  87064. var _this = _super.call(this) || this;
  87065. _this._decorationOptionProviders = new Map();
  87066. _this._editorStyleSheets = new Map();
  87067. _this._globalStyleSheet = styleSheet ? new GlobalStyleSheet(styleSheet) : null;
  87068. _this._themeService = themeService;
  87069. return _this;
  87070. }
  87071. CodeEditorServiceImpl.prototype._getOrCreateGlobalStyleSheet = function () {
  87072. if (!this._globalStyleSheet) {
  87073. this._globalStyleSheet = new GlobalStyleSheet(dom.createStyleSheet());
  87074. }
  87075. return this._globalStyleSheet;
  87076. };
  87077. CodeEditorServiceImpl.prototype._getOrCreateStyleSheet = function (editor) {
  87078. if (!editor) {
  87079. return this._getOrCreateGlobalStyleSheet();
  87080. }
  87081. var domNode = editor.getContainerDomNode();
  87082. if (!dom.isInShadowDOM(domNode)) {
  87083. return this._getOrCreateGlobalStyleSheet();
  87084. }
  87085. var editorId = editor.getId();
  87086. if (!this._editorStyleSheets.has(editorId)) {
  87087. var refCountedStyleSheet = new RefCountedStyleSheet(this, editorId, dom.createStyleSheet(domNode));
  87088. this._editorStyleSheets.set(editorId, refCountedStyleSheet);
  87089. }
  87090. return this._editorStyleSheets.get(editorId);
  87091. };
  87092. CodeEditorServiceImpl.prototype._removeEditorStyleSheets = function (editorId) {
  87093. this._editorStyleSheets.delete(editorId);
  87094. };
  87095. CodeEditorServiceImpl.prototype.registerDecorationType = function (key, options, parentTypeKey, editor) {
  87096. var provider = this._decorationOptionProviders.get(key);
  87097. if (!provider) {
  87098. var styleSheet = this._getOrCreateStyleSheet(editor);
  87099. var providerArgs = {
  87100. styleSheet: styleSheet.styleSheet,
  87101. key: key,
  87102. parentTypeKey: parentTypeKey,
  87103. options: options || Object.create(null)
  87104. };
  87105. if (!parentTypeKey) {
  87106. provider = new DecorationTypeOptionsProvider(this._themeService, styleSheet, providerArgs);
  87107. }
  87108. else {
  87109. provider = new DecorationSubTypeOptionsProvider(this._themeService, styleSheet, providerArgs);
  87110. }
  87111. this._decorationOptionProviders.set(key, provider);
  87112. }
  87113. provider.refCount++;
  87114. };
  87115. CodeEditorServiceImpl.prototype.removeDecorationType = function (key) {
  87116. var provider = this._decorationOptionProviders.get(key);
  87117. if (provider) {
  87118. provider.refCount--;
  87119. if (provider.refCount <= 0) {
  87120. this._decorationOptionProviders.delete(key);
  87121. provider.dispose();
  87122. this.listCodeEditors().forEach(function (ed) { return ed.removeDecorations(key); });
  87123. }
  87124. }
  87125. };
  87126. CodeEditorServiceImpl.prototype.resolveDecorationOptions = function (decorationTypeKey, writable) {
  87127. var provider = this._decorationOptionProviders.get(decorationTypeKey);
  87128. if (!provider) {
  87129. throw new Error('Unknown decoration type key: ' + decorationTypeKey);
  87130. }
  87131. return provider.getOptions(this, writable);
  87132. };
  87133. CodeEditorServiceImpl = __decorate([
  87134. __param(0, themeService_1.IThemeService)
  87135. ], CodeEditorServiceImpl);
  87136. return CodeEditorServiceImpl;
  87137. }(abstractCodeEditorService_1.AbstractCodeEditorService));
  87138. exports.CodeEditorServiceImpl = CodeEditorServiceImpl;
  87139. var DecorationSubTypeOptionsProvider = /** @class */ (function () {
  87140. function DecorationSubTypeOptionsProvider(themeService, styleSheet, providerArgs) {
  87141. this._styleSheet = styleSheet;
  87142. this._styleSheet.ref();
  87143. this._parentTypeKey = providerArgs.parentTypeKey;
  87144. this.refCount = 0;
  87145. this._beforeContentRules = new DecorationCSSRules(3 /* BeforeContentClassName */, providerArgs, themeService);
  87146. this._afterContentRules = new DecorationCSSRules(4 /* AfterContentClassName */, providerArgs, themeService);
  87147. }
  87148. DecorationSubTypeOptionsProvider.prototype.getOptions = function (codeEditorService, writable) {
  87149. var options = codeEditorService.resolveDecorationOptions(this._parentTypeKey, true);
  87150. if (this._beforeContentRules) {
  87151. options.beforeContentClassName = this._beforeContentRules.className;
  87152. }
  87153. if (this._afterContentRules) {
  87154. options.afterContentClassName = this._afterContentRules.className;
  87155. }
  87156. return options;
  87157. };
  87158. DecorationSubTypeOptionsProvider.prototype.dispose = function () {
  87159. if (this._beforeContentRules) {
  87160. this._beforeContentRules.dispose();
  87161. this._beforeContentRules = null;
  87162. }
  87163. if (this._afterContentRules) {
  87164. this._afterContentRules.dispose();
  87165. this._afterContentRules = null;
  87166. }
  87167. this._styleSheet.unref();
  87168. };
  87169. return DecorationSubTypeOptionsProvider;
  87170. }());
  87171. var DecorationTypeOptionsProvider = /** @class */ (function () {
  87172. function DecorationTypeOptionsProvider(themeService, styleSheet, providerArgs) {
  87173. var _this = this;
  87174. this._disposables = new lifecycle_1.DisposableStore();
  87175. this._styleSheet = styleSheet;
  87176. this._styleSheet.ref();
  87177. this.refCount = 0;
  87178. var createCSSRules = function (type) {
  87179. var rules = new DecorationCSSRules(type, providerArgs, themeService);
  87180. _this._disposables.add(rules);
  87181. if (rules.hasContent) {
  87182. return rules.className;
  87183. }
  87184. return undefined;
  87185. };
  87186. var createInlineCSSRules = function (type) {
  87187. var rules = new DecorationCSSRules(type, providerArgs, themeService);
  87188. _this._disposables.add(rules);
  87189. if (rules.hasContent) {
  87190. return { className: rules.className, hasLetterSpacing: rules.hasLetterSpacing };
  87191. }
  87192. return null;
  87193. };
  87194. this.className = createCSSRules(0 /* ClassName */);
  87195. var inlineData = createInlineCSSRules(1 /* InlineClassName */);
  87196. if (inlineData) {
  87197. this.inlineClassName = inlineData.className;
  87198. this.inlineClassNameAffectsLetterSpacing = inlineData.hasLetterSpacing;
  87199. }
  87200. this.beforeContentClassName = createCSSRules(3 /* BeforeContentClassName */);
  87201. this.afterContentClassName = createCSSRules(4 /* AfterContentClassName */);
  87202. this.glyphMarginClassName = createCSSRules(2 /* GlyphMarginClassName */);
  87203. var options = providerArgs.options;
  87204. this.isWholeLine = Boolean(options.isWholeLine);
  87205. this.stickiness = options.rangeBehavior;
  87206. var lightOverviewRulerColor = options.light && options.light.overviewRulerColor || options.overviewRulerColor;
  87207. var darkOverviewRulerColor = options.dark && options.dark.overviewRulerColor || options.overviewRulerColor;
  87208. if (typeof lightOverviewRulerColor !== 'undefined'
  87209. || typeof darkOverviewRulerColor !== 'undefined') {
  87210. this.overviewRuler = {
  87211. color: lightOverviewRulerColor || darkOverviewRulerColor,
  87212. darkColor: darkOverviewRulerColor || lightOverviewRulerColor,
  87213. position: options.overviewRulerLane || model_1.OverviewRulerLane.Center
  87214. };
  87215. }
  87216. }
  87217. DecorationTypeOptionsProvider.prototype.getOptions = function (codeEditorService, writable) {
  87218. if (!writable) {
  87219. return this;
  87220. }
  87221. return {
  87222. inlineClassName: this.inlineClassName,
  87223. beforeContentClassName: this.beforeContentClassName,
  87224. afterContentClassName: this.afterContentClassName,
  87225. className: this.className,
  87226. glyphMarginClassName: this.glyphMarginClassName,
  87227. isWholeLine: this.isWholeLine,
  87228. overviewRuler: this.overviewRuler,
  87229. stickiness: this.stickiness
  87230. };
  87231. };
  87232. DecorationTypeOptionsProvider.prototype.dispose = function () {
  87233. this._disposables.dispose();
  87234. this._styleSheet.unref();
  87235. };
  87236. return DecorationTypeOptionsProvider;
  87237. }());
  87238. var _CSS_MAP = {
  87239. color: 'color:{0} !important;',
  87240. opacity: 'opacity:{0};',
  87241. backgroundColor: 'background-color:{0};',
  87242. outline: 'outline:{0};',
  87243. outlineColor: 'outline-color:{0};',
  87244. outlineStyle: 'outline-style:{0};',
  87245. outlineWidth: 'outline-width:{0};',
  87246. border: 'border:{0};',
  87247. borderColor: 'border-color:{0};',
  87248. borderRadius: 'border-radius:{0};',
  87249. borderSpacing: 'border-spacing:{0};',
  87250. borderStyle: 'border-style:{0};',
  87251. borderWidth: 'border-width:{0};',
  87252. fontStyle: 'font-style:{0};',
  87253. fontWeight: 'font-weight:{0};',
  87254. textDecoration: 'text-decoration:{0};',
  87255. cursor: 'cursor:{0};',
  87256. letterSpacing: 'letter-spacing:{0};',
  87257. gutterIconPath: 'background:{0} center center no-repeat;',
  87258. gutterIconSize: 'background-size:{0};',
  87259. contentText: 'content:\'{0}\';',
  87260. contentIconPath: 'content:{0};',
  87261. margin: 'margin:{0};',
  87262. width: 'width:{0};',
  87263. height: 'height:{0};'
  87264. };
  87265. var DecorationCSSRules = /** @class */ (function () {
  87266. function DecorationCSSRules(ruleType, providerArgs, themeService) {
  87267. var _this = this;
  87268. this._theme = themeService.getTheme();
  87269. this._ruleType = ruleType;
  87270. this._providerArgs = providerArgs;
  87271. this._usesThemeColors = false;
  87272. this._hasContent = false;
  87273. this._hasLetterSpacing = false;
  87274. var className = CSSNameHelper.getClassName(this._providerArgs.key, ruleType);
  87275. if (this._providerArgs.parentTypeKey) {
  87276. className = className + ' ' + CSSNameHelper.getClassName(this._providerArgs.parentTypeKey, ruleType);
  87277. }
  87278. this._className = className;
  87279. this._unThemedSelector = CSSNameHelper.getSelector(this._providerArgs.key, this._providerArgs.parentTypeKey, ruleType);
  87280. this._buildCSS();
  87281. if (this._usesThemeColors) {
  87282. this._themeListener = themeService.onThemeChange(function (theme) {
  87283. _this._theme = themeService.getTheme();
  87284. _this._removeCSS();
  87285. _this._buildCSS();
  87286. });
  87287. }
  87288. else {
  87289. this._themeListener = null;
  87290. }
  87291. }
  87292. DecorationCSSRules.prototype.dispose = function () {
  87293. if (this._hasContent) {
  87294. this._removeCSS();
  87295. this._hasContent = false;
  87296. }
  87297. if (this._themeListener) {
  87298. this._themeListener.dispose();
  87299. this._themeListener = null;
  87300. }
  87301. };
  87302. Object.defineProperty(DecorationCSSRules.prototype, "hasContent", {
  87303. get: function () {
  87304. return this._hasContent;
  87305. },
  87306. enumerable: true,
  87307. configurable: true
  87308. });
  87309. Object.defineProperty(DecorationCSSRules.prototype, "hasLetterSpacing", {
  87310. get: function () {
  87311. return this._hasLetterSpacing;
  87312. },
  87313. enumerable: true,
  87314. configurable: true
  87315. });
  87316. Object.defineProperty(DecorationCSSRules.prototype, "className", {
  87317. get: function () {
  87318. return this._className;
  87319. },
  87320. enumerable: true,
  87321. configurable: true
  87322. });
  87323. DecorationCSSRules.prototype._buildCSS = function () {
  87324. var options = this._providerArgs.options;
  87325. var unthemedCSS, lightCSS, darkCSS;
  87326. switch (this._ruleType) {
  87327. case 0 /* ClassName */:
  87328. unthemedCSS = this.getCSSTextForModelDecorationClassName(options);
  87329. lightCSS = this.getCSSTextForModelDecorationClassName(options.light);
  87330. darkCSS = this.getCSSTextForModelDecorationClassName(options.dark);
  87331. break;
  87332. case 1 /* InlineClassName */:
  87333. unthemedCSS = this.getCSSTextForModelDecorationInlineClassName(options);
  87334. lightCSS = this.getCSSTextForModelDecorationInlineClassName(options.light);
  87335. darkCSS = this.getCSSTextForModelDecorationInlineClassName(options.dark);
  87336. break;
  87337. case 2 /* GlyphMarginClassName */:
  87338. unthemedCSS = this.getCSSTextForModelDecorationGlyphMarginClassName(options);
  87339. lightCSS = this.getCSSTextForModelDecorationGlyphMarginClassName(options.light);
  87340. darkCSS = this.getCSSTextForModelDecorationGlyphMarginClassName(options.dark);
  87341. break;
  87342. case 3 /* BeforeContentClassName */:
  87343. unthemedCSS = this.getCSSTextForModelDecorationContentClassName(options.before);
  87344. lightCSS = this.getCSSTextForModelDecorationContentClassName(options.light && options.light.before);
  87345. darkCSS = this.getCSSTextForModelDecorationContentClassName(options.dark && options.dark.before);
  87346. break;
  87347. case 4 /* AfterContentClassName */:
  87348. unthemedCSS = this.getCSSTextForModelDecorationContentClassName(options.after);
  87349. lightCSS = this.getCSSTextForModelDecorationContentClassName(options.light && options.light.after);
  87350. darkCSS = this.getCSSTextForModelDecorationContentClassName(options.dark && options.dark.after);
  87351. break;
  87352. default:
  87353. throw new Error('Unknown rule type: ' + this._ruleType);
  87354. }
  87355. var sheet = this._providerArgs.styleSheet.sheet;
  87356. var hasContent = false;
  87357. if (unthemedCSS.length > 0) {
  87358. sheet.insertRule(this._unThemedSelector + " {" + unthemedCSS + "}", 0);
  87359. hasContent = true;
  87360. }
  87361. if (lightCSS.length > 0) {
  87362. sheet.insertRule(".vs" + this._unThemedSelector + " {" + lightCSS + "}", 0);
  87363. hasContent = true;
  87364. }
  87365. if (darkCSS.length > 0) {
  87366. sheet.insertRule(".vs-dark" + this._unThemedSelector + ", .hc-black" + this._unThemedSelector + " {" + darkCSS + "}", 0);
  87367. hasContent = true;
  87368. }
  87369. this._hasContent = hasContent;
  87370. };
  87371. DecorationCSSRules.prototype._removeCSS = function () {
  87372. dom.removeCSSRulesContainingSelector(this._unThemedSelector, this._providerArgs.styleSheet);
  87373. };
  87374. /**
  87375. * Build the CSS for decorations styled via `className`.
  87376. */
  87377. DecorationCSSRules.prototype.getCSSTextForModelDecorationClassName = function (opts) {
  87378. if (!opts) {
  87379. return '';
  87380. }
  87381. var cssTextArr = [];
  87382. this.collectCSSText(opts, ['backgroundColor'], cssTextArr);
  87383. this.collectCSSText(opts, ['outline', 'outlineColor', 'outlineStyle', 'outlineWidth'], cssTextArr);
  87384. this.collectBorderSettingsCSSText(opts, cssTextArr);
  87385. return cssTextArr.join('');
  87386. };
  87387. /**
  87388. * Build the CSS for decorations styled via `inlineClassName`.
  87389. */
  87390. DecorationCSSRules.prototype.getCSSTextForModelDecorationInlineClassName = function (opts) {
  87391. if (!opts) {
  87392. return '';
  87393. }
  87394. var cssTextArr = [];
  87395. this.collectCSSText(opts, ['fontStyle', 'fontWeight', 'textDecoration', 'cursor', 'color', 'opacity', 'letterSpacing'], cssTextArr);
  87396. if (opts.letterSpacing) {
  87397. this._hasLetterSpacing = true;
  87398. }
  87399. return cssTextArr.join('');
  87400. };
  87401. /**
  87402. * Build the CSS for decorations styled before or after content.
  87403. */
  87404. DecorationCSSRules.prototype.getCSSTextForModelDecorationContentClassName = function (opts) {
  87405. if (!opts) {
  87406. return '';
  87407. }
  87408. var cssTextArr = [];
  87409. if (typeof opts !== 'undefined') {
  87410. this.collectBorderSettingsCSSText(opts, cssTextArr);
  87411. if (typeof opts.contentIconPath !== 'undefined') {
  87412. cssTextArr.push(strings.format(_CSS_MAP.contentIconPath, dom.asCSSUrl(uri_1.URI.revive(opts.contentIconPath))));
  87413. }
  87414. if (typeof opts.contentText === 'string') {
  87415. var truncated = opts.contentText.match(/^.*$/m)[0]; // only take first line
  87416. var escaped = truncated.replace(/['\\]/g, '\\$&');
  87417. cssTextArr.push(strings.format(_CSS_MAP.contentText, escaped));
  87418. }
  87419. this.collectCSSText(opts, ['fontStyle', 'fontWeight', 'textDecoration', 'color', 'opacity', 'backgroundColor', 'margin'], cssTextArr);
  87420. if (this.collectCSSText(opts, ['width', 'height'], cssTextArr)) {
  87421. cssTextArr.push('display:inline-block;');
  87422. }
  87423. }
  87424. return cssTextArr.join('');
  87425. };
  87426. /**
  87427. * Build the CSS for decorations styled via `glpyhMarginClassName`.
  87428. */
  87429. DecorationCSSRules.prototype.getCSSTextForModelDecorationGlyphMarginClassName = function (opts) {
  87430. if (!opts) {
  87431. return '';
  87432. }
  87433. var cssTextArr = [];
  87434. if (typeof opts.gutterIconPath !== 'undefined') {
  87435. cssTextArr.push(strings.format(_CSS_MAP.gutterIconPath, dom.asCSSUrl(uri_1.URI.revive(opts.gutterIconPath))));
  87436. if (typeof opts.gutterIconSize !== 'undefined') {
  87437. cssTextArr.push(strings.format(_CSS_MAP.gutterIconSize, opts.gutterIconSize));
  87438. }
  87439. }
  87440. return cssTextArr.join('');
  87441. };
  87442. DecorationCSSRules.prototype.collectBorderSettingsCSSText = function (opts, cssTextArr) {
  87443. if (this.collectCSSText(opts, ['border', 'borderColor', 'borderRadius', 'borderSpacing', 'borderStyle', 'borderWidth'], cssTextArr)) {
  87444. cssTextArr.push(strings.format('box-sizing: border-box;'));
  87445. return true;
  87446. }
  87447. return false;
  87448. };
  87449. DecorationCSSRules.prototype.collectCSSText = function (opts, properties, cssTextArr) {
  87450. var lenBefore = cssTextArr.length;
  87451. for (var _i = 0, properties_1 = properties; _i < properties_1.length; _i++) {
  87452. var property = properties_1[_i];
  87453. var value = this.resolveValue(opts[property]);
  87454. if (typeof value === 'string') {
  87455. cssTextArr.push(strings.format(_CSS_MAP[property], value));
  87456. }
  87457. }
  87458. return cssTextArr.length !== lenBefore;
  87459. };
  87460. DecorationCSSRules.prototype.resolveValue = function (value) {
  87461. if (editorCommon_1.isThemeColor(value)) {
  87462. this._usesThemeColors = true;
  87463. var color = this._theme.getColor(value.id);
  87464. if (color) {
  87465. return color.toString();
  87466. }
  87467. return 'transparent';
  87468. }
  87469. return value;
  87470. };
  87471. return DecorationCSSRules;
  87472. }());
  87473. var CSSNameHelper = /** @class */ (function () {
  87474. function CSSNameHelper() {
  87475. }
  87476. CSSNameHelper.getClassName = function (key, type) {
  87477. return 'ced-' + key + '-' + type;
  87478. };
  87479. CSSNameHelper.getSelector = function (key, parentKey, ruleType) {
  87480. var selector = '.monaco-editor .' + this.getClassName(key, ruleType);
  87481. if (parentKey) {
  87482. selector = selector + '.' + this.getClassName(parentKey, ruleType);
  87483. }
  87484. if (ruleType === 3 /* BeforeContentClassName */) {
  87485. selector += '::before';
  87486. }
  87487. else if (ruleType === 4 /* AfterContentClassName */) {
  87488. selector += '::after';
  87489. }
  87490. return selector;
  87491. };
  87492. return CSSNameHelper;
  87493. }());
  87494. });
  87495. /*---------------------------------------------------------------------------------------------
  87496. * Copyright (c) Microsoft Corporation. All rights reserved.
  87497. * Licensed under the MIT License. See License.txt in the project root for license information.
  87498. *--------------------------------------------------------------------------------------------*/
  87499. define(__m[549/*vs/editor/browser/viewParts/editorScrollbar/editorScrollbar*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,28/*vs/base/browser/fastDomNode*/,53/*vs/base/browser/ui/scrollbar/scrollableElement*/,37/*vs/editor/browser/view/viewPart*/,14/*vs/platform/theme/common/themeService*/]), function (require, exports, dom, fastDomNode_1, scrollableElement_1, viewPart_1, themeService_1) {
  87500. "use strict";
  87501. Object.defineProperty(exports, "__esModule", { value: true });
  87502. var EditorScrollbar = /** @class */ (function (_super) {
  87503. __extends(EditorScrollbar, _super);
  87504. function EditorScrollbar(context, linesContent, viewDomNode, overflowGuardDomNode) {
  87505. var _this = _super.call(this, context) || this;
  87506. var options = _this._context.configuration.options;
  87507. var scrollbar = options.get(78 /* scrollbar */);
  87508. var mouseWheelScrollSensitivity = options.get(56 /* mouseWheelScrollSensitivity */);
  87509. var fastScrollSensitivity = options.get(27 /* fastScrollSensitivity */);
  87510. var scrollbarOptions = {
  87511. listenOnDomNode: viewDomNode.domNode,
  87512. className: 'editor-scrollable' + ' ' + themeService_1.getThemeTypeSelector(context.theme.type),
  87513. useShadows: false,
  87514. lazyRender: true,
  87515. vertical: scrollbar.vertical,
  87516. horizontal: scrollbar.horizontal,
  87517. verticalHasArrows: scrollbar.verticalHasArrows,
  87518. horizontalHasArrows: scrollbar.horizontalHasArrows,
  87519. verticalScrollbarSize: scrollbar.verticalScrollbarSize,
  87520. verticalSliderSize: scrollbar.verticalSliderSize,
  87521. horizontalScrollbarSize: scrollbar.horizontalScrollbarSize,
  87522. horizontalSliderSize: scrollbar.horizontalSliderSize,
  87523. handleMouseWheel: scrollbar.handleMouseWheel,
  87524. alwaysConsumeMouseWheel: scrollbar.alwaysConsumeMouseWheel,
  87525. arrowSize: scrollbar.arrowSize,
  87526. mouseWheelScrollSensitivity: mouseWheelScrollSensitivity,
  87527. fastScrollSensitivity: fastScrollSensitivity,
  87528. };
  87529. _this.scrollbar = _this._register(new scrollableElement_1.SmoothScrollableElement(linesContent.domNode, scrollbarOptions, _this._context.viewLayout.getScrollable()));
  87530. viewPart_1.PartFingerprints.write(_this.scrollbar.getDomNode(), 5 /* ScrollableElement */);
  87531. _this.scrollbarDomNode = fastDomNode_1.createFastDomNode(_this.scrollbar.getDomNode());
  87532. _this.scrollbarDomNode.setPosition('absolute');
  87533. _this._setLayout();
  87534. // When having a zone widget that calls .focus() on one of its dom elements,
  87535. // the browser will try desperately to reveal that dom node, unexpectedly
  87536. // changing the .scrollTop of this.linesContent
  87537. var onBrowserDesperateReveal = function (domNode, lookAtScrollTop, lookAtScrollLeft) {
  87538. var newScrollPosition = {};
  87539. if (lookAtScrollTop) {
  87540. var deltaTop = domNode.scrollTop;
  87541. if (deltaTop) {
  87542. newScrollPosition.scrollTop = _this._context.viewLayout.getCurrentScrollTop() + deltaTop;
  87543. domNode.scrollTop = 0;
  87544. }
  87545. }
  87546. if (lookAtScrollLeft) {
  87547. var deltaLeft = domNode.scrollLeft;
  87548. if (deltaLeft) {
  87549. newScrollPosition.scrollLeft = _this._context.viewLayout.getCurrentScrollLeft() + deltaLeft;
  87550. domNode.scrollLeft = 0;
  87551. }
  87552. }
  87553. _this._context.viewLayout.setScrollPositionNow(newScrollPosition);
  87554. };
  87555. // I've seen this happen both on the view dom node & on the lines content dom node.
  87556. _this._register(dom.addDisposableListener(viewDomNode.domNode, 'scroll', function (e) { return onBrowserDesperateReveal(viewDomNode.domNode, true, true); }));
  87557. _this._register(dom.addDisposableListener(linesContent.domNode, 'scroll', function (e) { return onBrowserDesperateReveal(linesContent.domNode, true, false); }));
  87558. _this._register(dom.addDisposableListener(overflowGuardDomNode.domNode, 'scroll', function (e) { return onBrowserDesperateReveal(overflowGuardDomNode.domNode, true, false); }));
  87559. _this._register(dom.addDisposableListener(_this.scrollbarDomNode.domNode, 'scroll', function (e) { return onBrowserDesperateReveal(_this.scrollbarDomNode.domNode, true, false); }));
  87560. return _this;
  87561. }
  87562. EditorScrollbar.prototype.dispose = function () {
  87563. _super.prototype.dispose.call(this);
  87564. };
  87565. EditorScrollbar.prototype._setLayout = function () {
  87566. var options = this._context.configuration.options;
  87567. var layoutInfo = options.get(107 /* layoutInfo */);
  87568. this.scrollbarDomNode.setLeft(layoutInfo.contentLeft);
  87569. var minimap = options.get(54 /* minimap */);
  87570. var side = minimap.side;
  87571. if (side === 'right') {
  87572. this.scrollbarDomNode.setWidth(layoutInfo.contentWidth + layoutInfo.minimapWidth);
  87573. }
  87574. else {
  87575. this.scrollbarDomNode.setWidth(layoutInfo.contentWidth);
  87576. }
  87577. this.scrollbarDomNode.setHeight(layoutInfo.height);
  87578. };
  87579. EditorScrollbar.prototype.getOverviewRulerLayoutInfo = function () {
  87580. return this.scrollbar.getOverviewRulerLayoutInfo();
  87581. };
  87582. EditorScrollbar.prototype.getDomNode = function () {
  87583. return this.scrollbarDomNode;
  87584. };
  87585. EditorScrollbar.prototype.delegateVerticalScrollbarMouseDown = function (browserEvent) {
  87586. this.scrollbar.delegateVerticalScrollbarMouseDown(browserEvent);
  87587. };
  87588. // --- begin event handlers
  87589. EditorScrollbar.prototype.onConfigurationChanged = function (e) {
  87590. if (e.hasChanged(78 /* scrollbar */)
  87591. || e.hasChanged(56 /* mouseWheelScrollSensitivity */)
  87592. || e.hasChanged(27 /* fastScrollSensitivity */)) {
  87593. var options = this._context.configuration.options;
  87594. var scrollbar = options.get(78 /* scrollbar */);
  87595. var mouseWheelScrollSensitivity = options.get(56 /* mouseWheelScrollSensitivity */);
  87596. var fastScrollSensitivity = options.get(27 /* fastScrollSensitivity */);
  87597. var newOpts = {
  87598. handleMouseWheel: scrollbar.handleMouseWheel,
  87599. mouseWheelScrollSensitivity: mouseWheelScrollSensitivity,
  87600. fastScrollSensitivity: fastScrollSensitivity
  87601. };
  87602. this.scrollbar.updateOptions(newOpts);
  87603. }
  87604. if (e.hasChanged(107 /* layoutInfo */)) {
  87605. this._setLayout();
  87606. }
  87607. return true;
  87608. };
  87609. EditorScrollbar.prototype.onScrollChanged = function (e) {
  87610. return true;
  87611. };
  87612. EditorScrollbar.prototype.onThemeChanged = function (e) {
  87613. this.scrollbar.updateClassName('editor-scrollable' + ' ' + themeService_1.getThemeTypeSelector(this._context.theme.type));
  87614. return true;
  87615. };
  87616. // --- end event handlers
  87617. EditorScrollbar.prototype.prepareRender = function (ctx) {
  87618. // Nothing to do
  87619. };
  87620. EditorScrollbar.prototype.render = function (ctx) {
  87621. this.scrollbar.renderNow();
  87622. };
  87623. return EditorScrollbar;
  87624. }(viewPart_1.ViewPart));
  87625. exports.EditorScrollbar = EditorScrollbar;
  87626. });
  87627. /*---------------------------------------------------------------------------------------------
  87628. * Copyright (c) Microsoft Corporation. All rights reserved.
  87629. * Licensed under the MIT License. See License.txt in the project root for license information.
  87630. *--------------------------------------------------------------------------------------------*/
  87631. define(__m[227/*vs/editor/browser/viewParts/lines/viewLine*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,28/*vs/base/browser/fastDomNode*/,16/*vs/base/common/platform*/,359/*vs/editor/browser/viewParts/lines/rangeUtil*/,91/*vs/editor/common/view/renderingContext*/,148/*vs/editor/common/viewLayout/lineDecorations*/,110/*vs/editor/common/viewLayout/viewLineRenderer*/,14/*vs/platform/theme/common/themeService*/,33/*vs/editor/common/config/editorOptions*/]), function (require, exports, browser, fastDomNode_1, platform, rangeUtil_1, renderingContext_1, lineDecorations_1, viewLineRenderer_1, themeService_1, editorOptions_1) {
  87632. "use strict";
  87633. Object.defineProperty(exports, "__esModule", { value: true });
  87634. var canUseFastRenderedViewLine = (function () {
  87635. if (platform.isNative) {
  87636. // In VSCode we know very well when the zoom level changes
  87637. return true;
  87638. }
  87639. if (platform.isLinux || browser.isFirefox || browser.isSafari) {
  87640. // On Linux, it appears that zooming affects char widths (in pixels), which is unexpected.
  87641. // --
  87642. // Even though we read character widths correctly, having read them at a specific zoom level
  87643. // does not mean they are the same at the current zoom level.
  87644. // --
  87645. // This could be improved if we ever figure out how to get an event when browsers zoom,
  87646. // but until then we have to stick with reading client rects.
  87647. // --
  87648. // The same has been observed with Firefox on Windows7
  87649. // --
  87650. // The same has been oversved with Safari
  87651. return false;
  87652. }
  87653. return true;
  87654. })();
  87655. var alwaysRenderInlineSelection = (browser.isEdgeOrIE);
  87656. var DomReadingContext = /** @class */ (function () {
  87657. function DomReadingContext(domNode, endNode) {
  87658. this._domNode = domNode;
  87659. this._clientRectDeltaLeft = 0;
  87660. this._clientRectDeltaLeftRead = false;
  87661. this.endNode = endNode;
  87662. }
  87663. Object.defineProperty(DomReadingContext.prototype, "clientRectDeltaLeft", {
  87664. get: function () {
  87665. if (!this._clientRectDeltaLeftRead) {
  87666. this._clientRectDeltaLeftRead = true;
  87667. this._clientRectDeltaLeft = this._domNode.getBoundingClientRect().left;
  87668. }
  87669. return this._clientRectDeltaLeft;
  87670. },
  87671. enumerable: true,
  87672. configurable: true
  87673. });
  87674. return DomReadingContext;
  87675. }());
  87676. exports.DomReadingContext = DomReadingContext;
  87677. var ViewLineOptions = /** @class */ (function () {
  87678. function ViewLineOptions(config, themeType) {
  87679. this.themeType = themeType;
  87680. var options = config.options;
  87681. var fontInfo = options.get(34 /* fontInfo */);
  87682. this.renderWhitespace = options.get(74 /* renderWhitespace */);
  87683. this.renderControlCharacters = options.get(69 /* renderControlCharacters */);
  87684. this.spaceWidth = fontInfo.spaceWidth;
  87685. this.middotWidth = fontInfo.middotWidth;
  87686. this.useMonospaceOptimizations = (fontInfo.isMonospace
  87687. && !options.get(23 /* disableMonospaceOptimizations */));
  87688. this.canUseHalfwidthRightwardsArrow = fontInfo.canUseHalfwidthRightwardsArrow;
  87689. this.lineHeight = options.get(49 /* lineHeight */);
  87690. this.stopRenderingLineAfter = options.get(88 /* stopRenderingLineAfter */);
  87691. this.fontLigatures = options.get(35 /* fontLigatures */);
  87692. }
  87693. ViewLineOptions.prototype.equals = function (other) {
  87694. return (this.themeType === other.themeType
  87695. && this.renderWhitespace === other.renderWhitespace
  87696. && this.renderControlCharacters === other.renderControlCharacters
  87697. && this.spaceWidth === other.spaceWidth
  87698. && this.middotWidth === other.middotWidth
  87699. && this.useMonospaceOptimizations === other.useMonospaceOptimizations
  87700. && this.canUseHalfwidthRightwardsArrow === other.canUseHalfwidthRightwardsArrow
  87701. && this.lineHeight === other.lineHeight
  87702. && this.stopRenderingLineAfter === other.stopRenderingLineAfter
  87703. && this.fontLigatures === other.fontLigatures);
  87704. };
  87705. return ViewLineOptions;
  87706. }());
  87707. exports.ViewLineOptions = ViewLineOptions;
  87708. var ViewLine = /** @class */ (function () {
  87709. function ViewLine(options) {
  87710. this._options = options;
  87711. this._isMaybeInvalid = true;
  87712. this._renderedViewLine = null;
  87713. }
  87714. // --- begin IVisibleLineData
  87715. ViewLine.prototype.getDomNode = function () {
  87716. if (this._renderedViewLine && this._renderedViewLine.domNode) {
  87717. return this._renderedViewLine.domNode.domNode;
  87718. }
  87719. return null;
  87720. };
  87721. ViewLine.prototype.setDomNode = function (domNode) {
  87722. if (this._renderedViewLine) {
  87723. this._renderedViewLine.domNode = fastDomNode_1.createFastDomNode(domNode);
  87724. }
  87725. else {
  87726. throw new Error('I have no rendered view line to set the dom node to...');
  87727. }
  87728. };
  87729. ViewLine.prototype.onContentChanged = function () {
  87730. this._isMaybeInvalid = true;
  87731. };
  87732. ViewLine.prototype.onTokensChanged = function () {
  87733. this._isMaybeInvalid = true;
  87734. };
  87735. ViewLine.prototype.onDecorationsChanged = function () {
  87736. this._isMaybeInvalid = true;
  87737. };
  87738. ViewLine.prototype.onOptionsChanged = function (newOptions) {
  87739. this._isMaybeInvalid = true;
  87740. this._options = newOptions;
  87741. };
  87742. ViewLine.prototype.onSelectionChanged = function () {
  87743. if (alwaysRenderInlineSelection || this._options.themeType === themeService_1.HIGH_CONTRAST || this._options.renderWhitespace === 'selection') {
  87744. this._isMaybeInvalid = true;
  87745. return true;
  87746. }
  87747. return false;
  87748. };
  87749. ViewLine.prototype.renderLine = function (lineNumber, deltaTop, viewportData, sb) {
  87750. if (this._isMaybeInvalid === false) {
  87751. // it appears that nothing relevant has changed
  87752. return false;
  87753. }
  87754. this._isMaybeInvalid = false;
  87755. var lineData = viewportData.getViewLineRenderingData(lineNumber);
  87756. var options = this._options;
  87757. var actualInlineDecorations = lineDecorations_1.LineDecoration.filter(lineData.inlineDecorations, lineNumber, lineData.minColumn, lineData.maxColumn);
  87758. // Only send selection information when needed for rendering whitespace
  87759. var selectionsOnLine = null;
  87760. if (alwaysRenderInlineSelection || options.themeType === themeService_1.HIGH_CONTRAST || this._options.renderWhitespace === 'selection') {
  87761. var selections = viewportData.selections;
  87762. for (var _i = 0, selections_1 = selections; _i < selections_1.length; _i++) {
  87763. var selection = selections_1[_i];
  87764. if (selection.endLineNumber < lineNumber || selection.startLineNumber > lineNumber) {
  87765. // Selection does not intersect line
  87766. continue;
  87767. }
  87768. var startColumn = (selection.startLineNumber === lineNumber ? selection.startColumn : lineData.minColumn);
  87769. var endColumn = (selection.endLineNumber === lineNumber ? selection.endColumn : lineData.maxColumn);
  87770. if (startColumn < endColumn) {
  87771. if (this._options.renderWhitespace !== 'selection') {
  87772. actualInlineDecorations.push(new lineDecorations_1.LineDecoration(startColumn, endColumn, 'inline-selected-text', 0 /* Regular */));
  87773. }
  87774. else {
  87775. if (!selectionsOnLine) {
  87776. selectionsOnLine = [];
  87777. }
  87778. selectionsOnLine.push(new viewLineRenderer_1.LineRange(startColumn - 1, endColumn - 1));
  87779. }
  87780. }
  87781. }
  87782. }
  87783. var renderLineInput = new viewLineRenderer_1.RenderLineInput(options.useMonospaceOptimizations, options.canUseHalfwidthRightwardsArrow, lineData.content, lineData.continuesWithWrappedLine, lineData.isBasicASCII, lineData.containsRTL, lineData.minColumn - 1, lineData.tokens, actualInlineDecorations, lineData.tabSize, lineData.startVisibleColumn, options.spaceWidth, options.middotWidth, options.stopRenderingLineAfter, options.renderWhitespace, options.renderControlCharacters, options.fontLigatures !== editorOptions_1.EditorFontLigatures.OFF, selectionsOnLine);
  87784. if (this._renderedViewLine && this._renderedViewLine.input.equals(renderLineInput)) {
  87785. // no need to do anything, we have the same render input
  87786. return false;
  87787. }
  87788. sb.appendASCIIString('<div style="top:');
  87789. sb.appendASCIIString(String(deltaTop));
  87790. sb.appendASCIIString('px;height:');
  87791. sb.appendASCIIString(String(this._options.lineHeight));
  87792. sb.appendASCIIString('px;" class="');
  87793. sb.appendASCIIString(ViewLine.CLASS_NAME);
  87794. sb.appendASCIIString('">');
  87795. var output = viewLineRenderer_1.renderViewLine(renderLineInput, sb);
  87796. sb.appendASCIIString('</div>');
  87797. var renderedViewLine = null;
  87798. if (canUseFastRenderedViewLine && lineData.isBasicASCII && options.useMonospaceOptimizations && output.containsForeignElements === 0 /* None */) {
  87799. if (lineData.content.length < 300 && renderLineInput.lineTokens.getCount() < 100) {
  87800. // Browser rounding errors have been observed in Chrome and IE, so using the fast
  87801. // view line only for short lines. Please test before removing the length check...
  87802. // ---
  87803. // Another rounding error has been observed on Linux in VSCode, where <span> width
  87804. // rounding errors add up to an observable large number...
  87805. // ---
  87806. // Also see another example of rounding errors on Windows in
  87807. // https://github.com/Microsoft/vscode/issues/33178
  87808. renderedViewLine = new FastRenderedViewLine(this._renderedViewLine ? this._renderedViewLine.domNode : null, renderLineInput, output.characterMapping);
  87809. }
  87810. }
  87811. if (!renderedViewLine) {
  87812. renderedViewLine = createRenderedLine(this._renderedViewLine ? this._renderedViewLine.domNode : null, renderLineInput, output.characterMapping, output.containsRTL, output.containsForeignElements);
  87813. }
  87814. this._renderedViewLine = renderedViewLine;
  87815. return true;
  87816. };
  87817. ViewLine.prototype.layoutLine = function (lineNumber, deltaTop) {
  87818. if (this._renderedViewLine && this._renderedViewLine.domNode) {
  87819. this._renderedViewLine.domNode.setTop(deltaTop);
  87820. this._renderedViewLine.domNode.setHeight(this._options.lineHeight);
  87821. }
  87822. };
  87823. // --- end IVisibleLineData
  87824. ViewLine.prototype.getWidth = function () {
  87825. if (!this._renderedViewLine) {
  87826. return 0;
  87827. }
  87828. return this._renderedViewLine.getWidth();
  87829. };
  87830. ViewLine.prototype.getWidthIsFast = function () {
  87831. if (!this._renderedViewLine) {
  87832. return true;
  87833. }
  87834. return this._renderedViewLine.getWidthIsFast();
  87835. };
  87836. ViewLine.prototype.getVisibleRangesForRange = function (startColumn, endColumn, context) {
  87837. if (!this._renderedViewLine) {
  87838. return null;
  87839. }
  87840. startColumn = startColumn | 0; // @perf
  87841. endColumn = endColumn | 0; // @perf
  87842. startColumn = Math.min(this._renderedViewLine.input.lineContent.length + 1, Math.max(1, startColumn));
  87843. endColumn = Math.min(this._renderedViewLine.input.lineContent.length + 1, Math.max(1, endColumn));
  87844. var stopRenderingLineAfter = this._renderedViewLine.input.stopRenderingLineAfter | 0; // @perf
  87845. var outsideRenderedLine = false;
  87846. if (stopRenderingLineAfter !== -1 && startColumn > stopRenderingLineAfter + 1 && endColumn > stopRenderingLineAfter + 1) {
  87847. // This range is obviously not visible
  87848. outsideRenderedLine = true;
  87849. }
  87850. if (stopRenderingLineAfter !== -1 && startColumn > stopRenderingLineAfter + 1) {
  87851. startColumn = stopRenderingLineAfter + 1;
  87852. }
  87853. if (stopRenderingLineAfter !== -1 && endColumn > stopRenderingLineAfter + 1) {
  87854. endColumn = stopRenderingLineAfter + 1;
  87855. }
  87856. var horizontalRanges = this._renderedViewLine.getVisibleRangesForRange(startColumn, endColumn, context);
  87857. if (horizontalRanges && horizontalRanges.length > 0) {
  87858. return new renderingContext_1.VisibleRanges(outsideRenderedLine, horizontalRanges);
  87859. }
  87860. return null;
  87861. };
  87862. ViewLine.prototype.getColumnOfNodeOffset = function (lineNumber, spanNode, offset) {
  87863. if (!this._renderedViewLine) {
  87864. return 1;
  87865. }
  87866. return this._renderedViewLine.getColumnOfNodeOffset(lineNumber, spanNode, offset);
  87867. };
  87868. ViewLine.CLASS_NAME = 'view-line';
  87869. return ViewLine;
  87870. }());
  87871. exports.ViewLine = ViewLine;
  87872. /**
  87873. * A rendered line which is guaranteed to contain only regular ASCII and is rendered with a monospace font.
  87874. */
  87875. var FastRenderedViewLine = /** @class */ (function () {
  87876. function FastRenderedViewLine(domNode, renderLineInput, characterMapping) {
  87877. this.domNode = domNode;
  87878. this.input = renderLineInput;
  87879. this._characterMapping = characterMapping;
  87880. this._charWidth = renderLineInput.spaceWidth;
  87881. }
  87882. FastRenderedViewLine.prototype.getWidth = function () {
  87883. return this._getCharPosition(this._characterMapping.length);
  87884. };
  87885. FastRenderedViewLine.prototype.getWidthIsFast = function () {
  87886. return true;
  87887. };
  87888. FastRenderedViewLine.prototype.getVisibleRangesForRange = function (startColumn, endColumn, context) {
  87889. var startPosition = this._getCharPosition(startColumn);
  87890. var endPosition = this._getCharPosition(endColumn);
  87891. return [new renderingContext_1.HorizontalRange(startPosition, endPosition - startPosition)];
  87892. };
  87893. FastRenderedViewLine.prototype._getCharPosition = function (column) {
  87894. var charOffset = this._characterMapping.getAbsoluteOffsets();
  87895. if (charOffset.length === 0) {
  87896. // No characters on this line
  87897. return 0;
  87898. }
  87899. return Math.round(this._charWidth * charOffset[column - 1]);
  87900. };
  87901. FastRenderedViewLine.prototype.getColumnOfNodeOffset = function (lineNumber, spanNode, offset) {
  87902. var spanNodeTextContentLength = spanNode.textContent.length;
  87903. var spanIndex = -1;
  87904. while (spanNode) {
  87905. spanNode = spanNode.previousSibling;
  87906. spanIndex++;
  87907. }
  87908. var charOffset = this._characterMapping.partDataToCharOffset(spanIndex, spanNodeTextContentLength, offset);
  87909. return charOffset + 1;
  87910. };
  87911. return FastRenderedViewLine;
  87912. }());
  87913. /**
  87914. * Every time we render a line, we save what we have rendered in an instance of this class.
  87915. */
  87916. var RenderedViewLine = /** @class */ (function () {
  87917. function RenderedViewLine(domNode, renderLineInput, characterMapping, containsRTL, containsForeignElements) {
  87918. this.domNode = domNode;
  87919. this.input = renderLineInput;
  87920. this._characterMapping = characterMapping;
  87921. this._isWhitespaceOnly = /^\s*$/.test(renderLineInput.lineContent);
  87922. this._containsForeignElements = containsForeignElements;
  87923. this._cachedWidth = -1;
  87924. this._pixelOffsetCache = null;
  87925. if (!containsRTL || this._characterMapping.length === 0 /* the line is empty */) {
  87926. this._pixelOffsetCache = new Int32Array(Math.max(2, this._characterMapping.length + 1));
  87927. for (var column = 0, len = this._characterMapping.length; column <= len; column++) {
  87928. this._pixelOffsetCache[column] = -1;
  87929. }
  87930. }
  87931. }
  87932. // --- Reading from the DOM methods
  87933. RenderedViewLine.prototype._getReadingTarget = function (myDomNode) {
  87934. return myDomNode.domNode.firstChild;
  87935. };
  87936. /**
  87937. * Width of the line in pixels
  87938. */
  87939. RenderedViewLine.prototype.getWidth = function () {
  87940. if (!this.domNode) {
  87941. return 0;
  87942. }
  87943. if (this._cachedWidth === -1) {
  87944. this._cachedWidth = this._getReadingTarget(this.domNode).offsetWidth;
  87945. }
  87946. return this._cachedWidth;
  87947. };
  87948. RenderedViewLine.prototype.getWidthIsFast = function () {
  87949. if (this._cachedWidth === -1) {
  87950. return false;
  87951. }
  87952. return true;
  87953. };
  87954. /**
  87955. * Visible ranges for a model range
  87956. */
  87957. RenderedViewLine.prototype.getVisibleRangesForRange = function (startColumn, endColumn, context) {
  87958. if (!this.domNode) {
  87959. return null;
  87960. }
  87961. if (this._pixelOffsetCache !== null) {
  87962. // the text is LTR
  87963. var startOffset = this._readPixelOffset(this.domNode, startColumn, context);
  87964. if (startOffset === -1) {
  87965. return null;
  87966. }
  87967. var endOffset = this._readPixelOffset(this.domNode, endColumn, context);
  87968. if (endOffset === -1) {
  87969. return null;
  87970. }
  87971. return [new renderingContext_1.HorizontalRange(startOffset, endOffset - startOffset)];
  87972. }
  87973. return this._readVisibleRangesForRange(this.domNode, startColumn, endColumn, context);
  87974. };
  87975. RenderedViewLine.prototype._readVisibleRangesForRange = function (domNode, startColumn, endColumn, context) {
  87976. if (startColumn === endColumn) {
  87977. var pixelOffset = this._readPixelOffset(domNode, startColumn, context);
  87978. if (pixelOffset === -1) {
  87979. return null;
  87980. }
  87981. else {
  87982. return [new renderingContext_1.HorizontalRange(pixelOffset, 0)];
  87983. }
  87984. }
  87985. else {
  87986. return this._readRawVisibleRangesForRange(domNode, startColumn, endColumn, context);
  87987. }
  87988. };
  87989. RenderedViewLine.prototype._readPixelOffset = function (domNode, column, context) {
  87990. if (this._characterMapping.length === 0) {
  87991. // This line has no content
  87992. if (this._containsForeignElements === 0 /* None */) {
  87993. // We can assume the line is really empty
  87994. return 0;
  87995. }
  87996. if (this._containsForeignElements === 2 /* After */) {
  87997. // We have foreign elements after the (empty) line
  87998. return 0;
  87999. }
  88000. if (this._containsForeignElements === 1 /* Before */) {
  88001. // We have foreign elements before the (empty) line
  88002. return this.getWidth();
  88003. }
  88004. // We have foreign elements before & after the (empty) line
  88005. var readingTarget = this._getReadingTarget(domNode);
  88006. if (readingTarget.firstChild) {
  88007. return readingTarget.firstChild.offsetWidth;
  88008. }
  88009. else {
  88010. return 0;
  88011. }
  88012. }
  88013. if (this._pixelOffsetCache !== null) {
  88014. // the text is LTR
  88015. var cachedPixelOffset = this._pixelOffsetCache[column];
  88016. if (cachedPixelOffset !== -1) {
  88017. return cachedPixelOffset;
  88018. }
  88019. var result = this._actualReadPixelOffset(domNode, column, context);
  88020. this._pixelOffsetCache[column] = result;
  88021. return result;
  88022. }
  88023. return this._actualReadPixelOffset(domNode, column, context);
  88024. };
  88025. RenderedViewLine.prototype._actualReadPixelOffset = function (domNode, column, context) {
  88026. if (this._characterMapping.length === 0) {
  88027. // This line has no content
  88028. var r_1 = rangeUtil_1.RangeUtil.readHorizontalRanges(this._getReadingTarget(domNode), 0, 0, 0, 0, context.clientRectDeltaLeft, context.endNode);
  88029. if (!r_1 || r_1.length === 0) {
  88030. return -1;
  88031. }
  88032. return r_1[0].left;
  88033. }
  88034. if (column === this._characterMapping.length && this._isWhitespaceOnly && this._containsForeignElements === 0 /* None */) {
  88035. // This branch helps in the case of whitespace only lines which have a width set
  88036. return this.getWidth();
  88037. }
  88038. var partData = this._characterMapping.charOffsetToPartData(column - 1);
  88039. var partIndex = viewLineRenderer_1.CharacterMapping.getPartIndex(partData);
  88040. var charOffsetInPart = viewLineRenderer_1.CharacterMapping.getCharIndex(partData);
  88041. var r = rangeUtil_1.RangeUtil.readHorizontalRanges(this._getReadingTarget(domNode), partIndex, charOffsetInPart, partIndex, charOffsetInPart, context.clientRectDeltaLeft, context.endNode);
  88042. if (!r || r.length === 0) {
  88043. return -1;
  88044. }
  88045. return r[0].left;
  88046. };
  88047. RenderedViewLine.prototype._readRawVisibleRangesForRange = function (domNode, startColumn, endColumn, context) {
  88048. if (startColumn === 1 && endColumn === this._characterMapping.length) {
  88049. // This branch helps IE with bidi text & gives a performance boost to other browsers when reading visible ranges for an entire line
  88050. return [new renderingContext_1.HorizontalRange(0, this.getWidth())];
  88051. }
  88052. var startPartData = this._characterMapping.charOffsetToPartData(startColumn - 1);
  88053. var startPartIndex = viewLineRenderer_1.CharacterMapping.getPartIndex(startPartData);
  88054. var startCharOffsetInPart = viewLineRenderer_1.CharacterMapping.getCharIndex(startPartData);
  88055. var endPartData = this._characterMapping.charOffsetToPartData(endColumn - 1);
  88056. var endPartIndex = viewLineRenderer_1.CharacterMapping.getPartIndex(endPartData);
  88057. var endCharOffsetInPart = viewLineRenderer_1.CharacterMapping.getCharIndex(endPartData);
  88058. return rangeUtil_1.RangeUtil.readHorizontalRanges(this._getReadingTarget(domNode), startPartIndex, startCharOffsetInPart, endPartIndex, endCharOffsetInPart, context.clientRectDeltaLeft, context.endNode);
  88059. };
  88060. /**
  88061. * Returns the column for the text found at a specific offset inside a rendered dom node
  88062. */
  88063. RenderedViewLine.prototype.getColumnOfNodeOffset = function (lineNumber, spanNode, offset) {
  88064. var spanNodeTextContentLength = spanNode.textContent.length;
  88065. var spanIndex = -1;
  88066. while (spanNode) {
  88067. spanNode = spanNode.previousSibling;
  88068. spanIndex++;
  88069. }
  88070. var charOffset = this._characterMapping.partDataToCharOffset(spanIndex, spanNodeTextContentLength, offset);
  88071. return charOffset + 1;
  88072. };
  88073. return RenderedViewLine;
  88074. }());
  88075. var WebKitRenderedViewLine = /** @class */ (function (_super) {
  88076. __extends(WebKitRenderedViewLine, _super);
  88077. function WebKitRenderedViewLine() {
  88078. return _super !== null && _super.apply(this, arguments) || this;
  88079. }
  88080. WebKitRenderedViewLine.prototype._readVisibleRangesForRange = function (domNode, startColumn, endColumn, context) {
  88081. var output = _super.prototype._readVisibleRangesForRange.call(this, domNode, startColumn, endColumn, context);
  88082. if (!output || output.length === 0 || startColumn === endColumn || (startColumn === 1 && endColumn === this._characterMapping.length)) {
  88083. return output;
  88084. }
  88085. // WebKit is buggy and returns an expanded range (to contain words in some cases)
  88086. // The last client rect is enlarged (I think)
  88087. if (!this.input.containsRTL) {
  88088. // This is an attempt to patch things up
  88089. // Find position of last column
  88090. var endPixelOffset = this._readPixelOffset(domNode, endColumn, context);
  88091. if (endPixelOffset !== -1) {
  88092. var lastRange = output[output.length - 1];
  88093. if (lastRange.left < endPixelOffset) {
  88094. // Trim down the width of the last visible range to not go after the last column's position
  88095. lastRange.width = endPixelOffset - lastRange.left;
  88096. }
  88097. }
  88098. }
  88099. return output;
  88100. };
  88101. return WebKitRenderedViewLine;
  88102. }(RenderedViewLine));
  88103. var createRenderedLine = (function () {
  88104. if (browser.isWebKit) {
  88105. return createWebKitRenderedLine;
  88106. }
  88107. return createNormalRenderedLine;
  88108. })();
  88109. function createWebKitRenderedLine(domNode, renderLineInput, characterMapping, containsRTL, containsForeignElements) {
  88110. return new WebKitRenderedViewLine(domNode, renderLineInput, characterMapping, containsRTL, containsForeignElements);
  88111. }
  88112. function createNormalRenderedLine(domNode, renderLineInput, characterMapping, containsRTL, containsForeignElements) {
  88113. return new RenderedViewLine(domNode, renderLineInput, characterMapping, containsRTL, containsForeignElements);
  88114. }
  88115. });
  88116. /*---------------------------------------------------------------------------------------------
  88117. * Copyright (c) Microsoft Corporation. All rights reserved.
  88118. * Licensed under the MIT License. See License.txt in the project root for license information.
  88119. *--------------------------------------------------------------------------------------------*/
  88120. define(__m[166/*vs/editor/browser/controller/mouseTarget*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,141/*vs/editor/browser/editorDom*/,37/*vs/editor/browser/view/viewPart*/,227/*vs/editor/browser/viewParts/lines/viewLine*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,40/*vs/editor/common/controller/cursorCommon*/,6/*vs/base/browser/dom*/]), function (require, exports, browser, editorDom_1, viewPart_1, viewLine_1, position_1, range_1, cursorCommon_1, dom) {
  88121. "use strict";
  88122. Object.defineProperty(exports, "__esModule", { value: true });
  88123. var PointerHandlerLastRenderData = /** @class */ (function () {
  88124. function PointerHandlerLastRenderData(lastViewCursorsRenderData, lastTextareaPosition) {
  88125. this.lastViewCursorsRenderData = lastViewCursorsRenderData;
  88126. this.lastTextareaPosition = lastTextareaPosition;
  88127. }
  88128. return PointerHandlerLastRenderData;
  88129. }());
  88130. exports.PointerHandlerLastRenderData = PointerHandlerLastRenderData;
  88131. var MouseTarget = /** @class */ (function () {
  88132. function MouseTarget(element, type, mouseColumn, position, range, detail) {
  88133. if (mouseColumn === void 0) { mouseColumn = 0; }
  88134. if (position === void 0) { position = null; }
  88135. if (range === void 0) { range = null; }
  88136. if (detail === void 0) { detail = null; }
  88137. this.element = element;
  88138. this.type = type;
  88139. this.mouseColumn = mouseColumn;
  88140. this.position = position;
  88141. if (!range && position) {
  88142. range = new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column);
  88143. }
  88144. this.range = range;
  88145. this.detail = detail;
  88146. }
  88147. MouseTarget._typeToString = function (type) {
  88148. if (type === 1 /* TEXTAREA */) {
  88149. return 'TEXTAREA';
  88150. }
  88151. if (type === 2 /* GUTTER_GLYPH_MARGIN */) {
  88152. return 'GUTTER_GLYPH_MARGIN';
  88153. }
  88154. if (type === 3 /* GUTTER_LINE_NUMBERS */) {
  88155. return 'GUTTER_LINE_NUMBERS';
  88156. }
  88157. if (type === 4 /* GUTTER_LINE_DECORATIONS */) {
  88158. return 'GUTTER_LINE_DECORATIONS';
  88159. }
  88160. if (type === 5 /* GUTTER_VIEW_ZONE */) {
  88161. return 'GUTTER_VIEW_ZONE';
  88162. }
  88163. if (type === 6 /* CONTENT_TEXT */) {
  88164. return 'CONTENT_TEXT';
  88165. }
  88166. if (type === 7 /* CONTENT_EMPTY */) {
  88167. return 'CONTENT_EMPTY';
  88168. }
  88169. if (type === 8 /* CONTENT_VIEW_ZONE */) {
  88170. return 'CONTENT_VIEW_ZONE';
  88171. }
  88172. if (type === 9 /* CONTENT_WIDGET */) {
  88173. return 'CONTENT_WIDGET';
  88174. }
  88175. if (type === 10 /* OVERVIEW_RULER */) {
  88176. return 'OVERVIEW_RULER';
  88177. }
  88178. if (type === 11 /* SCROLLBAR */) {
  88179. return 'SCROLLBAR';
  88180. }
  88181. if (type === 12 /* OVERLAY_WIDGET */) {
  88182. return 'OVERLAY_WIDGET';
  88183. }
  88184. return 'UNKNOWN';
  88185. };
  88186. MouseTarget.toString = function (target) {
  88187. return this._typeToString(target.type) + ': ' + target.position + ' - ' + target.range + ' - ' + target.detail;
  88188. };
  88189. MouseTarget.prototype.toString = function () {
  88190. return MouseTarget.toString(this);
  88191. };
  88192. return MouseTarget;
  88193. }());
  88194. exports.MouseTarget = MouseTarget;
  88195. var ElementPath = /** @class */ (function () {
  88196. function ElementPath() {
  88197. }
  88198. ElementPath.isTextArea = function (path) {
  88199. return (path.length === 2
  88200. && path[0] === 3 /* OverflowGuard */
  88201. && path[1] === 6 /* TextArea */);
  88202. };
  88203. ElementPath.isChildOfViewLines = function (path) {
  88204. return (path.length >= 4
  88205. && path[0] === 3 /* OverflowGuard */
  88206. && path[3] === 7 /* ViewLines */);
  88207. };
  88208. ElementPath.isStrictChildOfViewLines = function (path) {
  88209. return (path.length > 4
  88210. && path[0] === 3 /* OverflowGuard */
  88211. && path[3] === 7 /* ViewLines */);
  88212. };
  88213. ElementPath.isChildOfScrollableElement = function (path) {
  88214. return (path.length >= 2
  88215. && path[0] === 3 /* OverflowGuard */
  88216. && path[1] === 5 /* ScrollableElement */);
  88217. };
  88218. ElementPath.isChildOfMinimap = function (path) {
  88219. return (path.length >= 2
  88220. && path[0] === 3 /* OverflowGuard */
  88221. && path[1] === 8 /* Minimap */);
  88222. };
  88223. ElementPath.isChildOfContentWidgets = function (path) {
  88224. return (path.length >= 4
  88225. && path[0] === 3 /* OverflowGuard */
  88226. && path[3] === 1 /* ContentWidgets */);
  88227. };
  88228. ElementPath.isChildOfOverflowingContentWidgets = function (path) {
  88229. return (path.length >= 1
  88230. && path[0] === 2 /* OverflowingContentWidgets */);
  88231. };
  88232. ElementPath.isChildOfOverlayWidgets = function (path) {
  88233. return (path.length >= 2
  88234. && path[0] === 3 /* OverflowGuard */
  88235. && path[1] === 4 /* OverlayWidgets */);
  88236. };
  88237. return ElementPath;
  88238. }());
  88239. var HitTestContext = /** @class */ (function () {
  88240. function HitTestContext(context, viewHelper, lastRenderData) {
  88241. this.model = context.model;
  88242. var options = context.configuration.options;
  88243. this.layoutInfo = options.get(107 /* layoutInfo */);
  88244. this.viewDomNode = viewHelper.viewDomNode;
  88245. this.lineHeight = options.get(49 /* lineHeight */);
  88246. this.typicalHalfwidthCharacterWidth = options.get(34 /* fontInfo */).typicalHalfwidthCharacterWidth;
  88247. this.lastRenderData = lastRenderData;
  88248. this._context = context;
  88249. this._viewHelper = viewHelper;
  88250. }
  88251. HitTestContext.prototype.getZoneAtCoord = function (mouseVerticalOffset) {
  88252. return HitTestContext.getZoneAtCoord(this._context, mouseVerticalOffset);
  88253. };
  88254. HitTestContext.getZoneAtCoord = function (context, mouseVerticalOffset) {
  88255. // The target is either a view zone or the empty space after the last view-line
  88256. var viewZoneWhitespace = context.viewLayout.getWhitespaceAtVerticalOffset(mouseVerticalOffset);
  88257. if (viewZoneWhitespace) {
  88258. var viewZoneMiddle = viewZoneWhitespace.verticalOffset + viewZoneWhitespace.height / 2, lineCount = context.model.getLineCount(), positionBefore = null, position = void 0, positionAfter = null;
  88259. if (viewZoneWhitespace.afterLineNumber !== lineCount) {
  88260. // There are more lines after this view zone
  88261. positionAfter = new position_1.Position(viewZoneWhitespace.afterLineNumber + 1, 1);
  88262. }
  88263. if (viewZoneWhitespace.afterLineNumber > 0) {
  88264. // There are more lines above this view zone
  88265. positionBefore = new position_1.Position(viewZoneWhitespace.afterLineNumber, context.model.getLineMaxColumn(viewZoneWhitespace.afterLineNumber));
  88266. }
  88267. if (positionAfter === null) {
  88268. position = positionBefore;
  88269. }
  88270. else if (positionBefore === null) {
  88271. position = positionAfter;
  88272. }
  88273. else if (mouseVerticalOffset < viewZoneMiddle) {
  88274. position = positionBefore;
  88275. }
  88276. else {
  88277. position = positionAfter;
  88278. }
  88279. return {
  88280. viewZoneId: viewZoneWhitespace.id,
  88281. afterLineNumber: viewZoneWhitespace.afterLineNumber,
  88282. positionBefore: positionBefore,
  88283. positionAfter: positionAfter,
  88284. position: position
  88285. };
  88286. }
  88287. return null;
  88288. };
  88289. HitTestContext.prototype.getFullLineRangeAtCoord = function (mouseVerticalOffset) {
  88290. if (this._context.viewLayout.isAfterLines(mouseVerticalOffset)) {
  88291. // Below the last line
  88292. var lineNumber_1 = this._context.model.getLineCount();
  88293. var maxLineColumn_1 = this._context.model.getLineMaxColumn(lineNumber_1);
  88294. return {
  88295. range: new range_1.Range(lineNumber_1, maxLineColumn_1, lineNumber_1, maxLineColumn_1),
  88296. isAfterLines: true
  88297. };
  88298. }
  88299. var lineNumber = this._context.viewLayout.getLineNumberAtVerticalOffset(mouseVerticalOffset);
  88300. var maxLineColumn = this._context.model.getLineMaxColumn(lineNumber);
  88301. return {
  88302. range: new range_1.Range(lineNumber, 1, lineNumber, maxLineColumn),
  88303. isAfterLines: false
  88304. };
  88305. };
  88306. HitTestContext.prototype.getLineNumberAtVerticalOffset = function (mouseVerticalOffset) {
  88307. return this._context.viewLayout.getLineNumberAtVerticalOffset(mouseVerticalOffset);
  88308. };
  88309. HitTestContext.prototype.isAfterLines = function (mouseVerticalOffset) {
  88310. return this._context.viewLayout.isAfterLines(mouseVerticalOffset);
  88311. };
  88312. HitTestContext.prototype.getVerticalOffsetForLineNumber = function (lineNumber) {
  88313. return this._context.viewLayout.getVerticalOffsetForLineNumber(lineNumber);
  88314. };
  88315. HitTestContext.prototype.findAttribute = function (element, attr) {
  88316. return HitTestContext._findAttribute(element, attr, this._viewHelper.viewDomNode);
  88317. };
  88318. HitTestContext._findAttribute = function (element, attr, stopAt) {
  88319. while (element && element !== document.body) {
  88320. if (element.hasAttribute && element.hasAttribute(attr)) {
  88321. return element.getAttribute(attr);
  88322. }
  88323. if (element === stopAt) {
  88324. return null;
  88325. }
  88326. element = element.parentNode;
  88327. }
  88328. return null;
  88329. };
  88330. HitTestContext.prototype.getLineWidth = function (lineNumber) {
  88331. return this._viewHelper.getLineWidth(lineNumber);
  88332. };
  88333. HitTestContext.prototype.visibleRangeForPosition = function (lineNumber, column) {
  88334. return this._viewHelper.visibleRangeForPosition(lineNumber, column);
  88335. };
  88336. HitTestContext.prototype.getPositionFromDOMInfo = function (spanNode, offset) {
  88337. return this._viewHelper.getPositionFromDOMInfo(spanNode, offset);
  88338. };
  88339. HitTestContext.prototype.getCurrentScrollTop = function () {
  88340. return this._context.viewLayout.getCurrentScrollTop();
  88341. };
  88342. HitTestContext.prototype.getCurrentScrollLeft = function () {
  88343. return this._context.viewLayout.getCurrentScrollLeft();
  88344. };
  88345. return HitTestContext;
  88346. }());
  88347. exports.HitTestContext = HitTestContext;
  88348. var BareHitTestRequest = /** @class */ (function () {
  88349. function BareHitTestRequest(ctx, editorPos, pos) {
  88350. this.editorPos = editorPos;
  88351. this.pos = pos;
  88352. this.mouseVerticalOffset = Math.max(0, ctx.getCurrentScrollTop() + pos.y - editorPos.y);
  88353. this.mouseContentHorizontalOffset = ctx.getCurrentScrollLeft() + pos.x - editorPos.x - ctx.layoutInfo.contentLeft;
  88354. this.isInMarginArea = (pos.x - editorPos.x < ctx.layoutInfo.contentLeft && pos.x - editorPos.x >= ctx.layoutInfo.glyphMarginLeft);
  88355. this.isInContentArea = !this.isInMarginArea;
  88356. this.mouseColumn = Math.max(0, MouseTargetFactory._getMouseColumn(this.mouseContentHorizontalOffset, ctx.typicalHalfwidthCharacterWidth));
  88357. }
  88358. return BareHitTestRequest;
  88359. }());
  88360. var HitTestRequest = /** @class */ (function (_super) {
  88361. __extends(HitTestRequest, _super);
  88362. function HitTestRequest(ctx, editorPos, pos, target) {
  88363. var _this = _super.call(this, ctx, editorPos, pos) || this;
  88364. _this._ctx = ctx;
  88365. if (target) {
  88366. _this.target = target;
  88367. _this.targetPath = viewPart_1.PartFingerprints.collect(target, ctx.viewDomNode);
  88368. }
  88369. else {
  88370. _this.target = null;
  88371. _this.targetPath = new Uint8Array(0);
  88372. }
  88373. return _this;
  88374. }
  88375. HitTestRequest.prototype.toString = function () {
  88376. return "pos(" + this.pos.x + "," + this.pos.y + "), editorPos(" + this.editorPos.x + "," + this.editorPos.y + "), mouseVerticalOffset: " + this.mouseVerticalOffset + ", mouseContentHorizontalOffset: " + this.mouseContentHorizontalOffset + "\n\ttarget: " + (this.target ? this.target.outerHTML : null);
  88377. };
  88378. HitTestRequest.prototype.fulfill = function (type, position, range, detail) {
  88379. if (position === void 0) { position = null; }
  88380. if (range === void 0) { range = null; }
  88381. if (detail === void 0) { detail = null; }
  88382. var mouseColumn = this.mouseColumn;
  88383. if (position && position.column < this._ctx.model.getLineMaxColumn(position.lineNumber)) {
  88384. // Most likely, the line contains foreign decorations...
  88385. mouseColumn = cursorCommon_1.CursorColumns.visibleColumnFromColumn(this._ctx.model.getLineContent(position.lineNumber), position.column, this._ctx.model.getOptions().tabSize) + 1;
  88386. }
  88387. return new MouseTarget(this.target, type, mouseColumn, position, range, detail);
  88388. };
  88389. HitTestRequest.prototype.withTarget = function (target) {
  88390. return new HitTestRequest(this._ctx, this.editorPos, this.pos, target);
  88391. };
  88392. return HitTestRequest;
  88393. }(BareHitTestRequest));
  88394. var EMPTY_CONTENT_AFTER_LINES = { isAfterLines: true };
  88395. function createEmptyContentDataInLines(horizontalDistanceToText) {
  88396. return {
  88397. isAfterLines: false,
  88398. horizontalDistanceToText: horizontalDistanceToText
  88399. };
  88400. }
  88401. var MouseTargetFactory = /** @class */ (function () {
  88402. function MouseTargetFactory(context, viewHelper) {
  88403. this._context = context;
  88404. this._viewHelper = viewHelper;
  88405. }
  88406. MouseTargetFactory.prototype.mouseTargetIsWidget = function (e) {
  88407. var t = e.target;
  88408. var path = viewPart_1.PartFingerprints.collect(t, this._viewHelper.viewDomNode);
  88409. // Is it a content widget?
  88410. if (ElementPath.isChildOfContentWidgets(path) || ElementPath.isChildOfOverflowingContentWidgets(path)) {
  88411. return true;
  88412. }
  88413. // Is it an overlay widget?
  88414. if (ElementPath.isChildOfOverlayWidgets(path)) {
  88415. return true;
  88416. }
  88417. return false;
  88418. };
  88419. MouseTargetFactory.prototype.createMouseTarget = function (lastRenderData, editorPos, pos, target) {
  88420. var ctx = new HitTestContext(this._context, this._viewHelper, lastRenderData);
  88421. var request = new HitTestRequest(ctx, editorPos, pos, target);
  88422. try {
  88423. var r = MouseTargetFactory._createMouseTarget(ctx, request, false);
  88424. // console.log(r.toString());
  88425. return r;
  88426. }
  88427. catch (err) {
  88428. // console.log(err);
  88429. return request.fulfill(0 /* UNKNOWN */);
  88430. }
  88431. };
  88432. MouseTargetFactory._createMouseTarget = function (ctx, request, domHitTestExecuted) {
  88433. // console.log(`${domHitTestExecuted ? '=>' : ''}CAME IN REQUEST: ${request}`);
  88434. // First ensure the request has a target
  88435. if (request.target === null) {
  88436. if (domHitTestExecuted) {
  88437. // Still no target... and we have already executed hit test...
  88438. return request.fulfill(0 /* UNKNOWN */);
  88439. }
  88440. var hitTestResult = MouseTargetFactory._doHitTest(ctx, request);
  88441. if (hitTestResult.position) {
  88442. return MouseTargetFactory.createMouseTargetFromHitTestPosition(ctx, request, hitTestResult.position.lineNumber, hitTestResult.position.column);
  88443. }
  88444. return this._createMouseTarget(ctx, request.withTarget(hitTestResult.hitTarget), true);
  88445. }
  88446. // we know for a fact that request.target is not null
  88447. var resolvedRequest = request;
  88448. var result = null;
  88449. result = result || MouseTargetFactory._hitTestContentWidget(ctx, resolvedRequest);
  88450. result = result || MouseTargetFactory._hitTestOverlayWidget(ctx, resolvedRequest);
  88451. result = result || MouseTargetFactory._hitTestMinimap(ctx, resolvedRequest);
  88452. result = result || MouseTargetFactory._hitTestScrollbarSlider(ctx, resolvedRequest);
  88453. result = result || MouseTargetFactory._hitTestViewZone(ctx, resolvedRequest);
  88454. result = result || MouseTargetFactory._hitTestMargin(ctx, resolvedRequest);
  88455. result = result || MouseTargetFactory._hitTestViewCursor(ctx, resolvedRequest);
  88456. result = result || MouseTargetFactory._hitTestTextArea(ctx, resolvedRequest);
  88457. result = result || MouseTargetFactory._hitTestViewLines(ctx, resolvedRequest, domHitTestExecuted);
  88458. result = result || MouseTargetFactory._hitTestScrollbar(ctx, resolvedRequest);
  88459. return (result || request.fulfill(0 /* UNKNOWN */));
  88460. };
  88461. MouseTargetFactory._hitTestContentWidget = function (ctx, request) {
  88462. // Is it a content widget?
  88463. if (ElementPath.isChildOfContentWidgets(request.targetPath) || ElementPath.isChildOfOverflowingContentWidgets(request.targetPath)) {
  88464. var widgetId = ctx.findAttribute(request.target, 'widgetId');
  88465. if (widgetId) {
  88466. return request.fulfill(9 /* CONTENT_WIDGET */, null, null, widgetId);
  88467. }
  88468. else {
  88469. return request.fulfill(0 /* UNKNOWN */);
  88470. }
  88471. }
  88472. return null;
  88473. };
  88474. MouseTargetFactory._hitTestOverlayWidget = function (ctx, request) {
  88475. // Is it an overlay widget?
  88476. if (ElementPath.isChildOfOverlayWidgets(request.targetPath)) {
  88477. var widgetId = ctx.findAttribute(request.target, 'widgetId');
  88478. if (widgetId) {
  88479. return request.fulfill(12 /* OVERLAY_WIDGET */, null, null, widgetId);
  88480. }
  88481. else {
  88482. return request.fulfill(0 /* UNKNOWN */);
  88483. }
  88484. }
  88485. return null;
  88486. };
  88487. MouseTargetFactory._hitTestViewCursor = function (ctx, request) {
  88488. if (request.target) {
  88489. // Check if we've hit a painted cursor
  88490. var lastViewCursorsRenderData = ctx.lastRenderData.lastViewCursorsRenderData;
  88491. for (var _i = 0, lastViewCursorsRenderData_1 = lastViewCursorsRenderData; _i < lastViewCursorsRenderData_1.length; _i++) {
  88492. var d = lastViewCursorsRenderData_1[_i];
  88493. if (request.target === d.domNode) {
  88494. return request.fulfill(6 /* CONTENT_TEXT */, d.position);
  88495. }
  88496. }
  88497. }
  88498. if (request.isInContentArea) {
  88499. // Edge has a bug when hit-testing the exact position of a cursor,
  88500. // instead of returning the correct dom node, it returns the
  88501. // first or last rendered view line dom node, therefore help it out
  88502. // and first check if we are on top of a cursor
  88503. var lastViewCursorsRenderData = ctx.lastRenderData.lastViewCursorsRenderData;
  88504. var mouseContentHorizontalOffset = request.mouseContentHorizontalOffset;
  88505. var mouseVerticalOffset = request.mouseVerticalOffset;
  88506. for (var _a = 0, lastViewCursorsRenderData_2 = lastViewCursorsRenderData; _a < lastViewCursorsRenderData_2.length; _a++) {
  88507. var d = lastViewCursorsRenderData_2[_a];
  88508. if (mouseContentHorizontalOffset < d.contentLeft) {
  88509. // mouse position is to the left of the cursor
  88510. continue;
  88511. }
  88512. if (mouseContentHorizontalOffset > d.contentLeft + d.width) {
  88513. // mouse position is to the right of the cursor
  88514. continue;
  88515. }
  88516. var cursorVerticalOffset = ctx.getVerticalOffsetForLineNumber(d.position.lineNumber);
  88517. if (cursorVerticalOffset <= mouseVerticalOffset
  88518. && mouseVerticalOffset <= cursorVerticalOffset + d.height) {
  88519. return request.fulfill(6 /* CONTENT_TEXT */, d.position);
  88520. }
  88521. }
  88522. }
  88523. return null;
  88524. };
  88525. MouseTargetFactory._hitTestViewZone = function (ctx, request) {
  88526. var viewZoneData = ctx.getZoneAtCoord(request.mouseVerticalOffset);
  88527. if (viewZoneData) {
  88528. var mouseTargetType = (request.isInContentArea ? 8 /* CONTENT_VIEW_ZONE */ : 5 /* GUTTER_VIEW_ZONE */);
  88529. return request.fulfill(mouseTargetType, viewZoneData.position, null, viewZoneData);
  88530. }
  88531. return null;
  88532. };
  88533. MouseTargetFactory._hitTestTextArea = function (ctx, request) {
  88534. // Is it the textarea?
  88535. if (ElementPath.isTextArea(request.targetPath)) {
  88536. if (ctx.lastRenderData.lastTextareaPosition) {
  88537. return request.fulfill(6 /* CONTENT_TEXT */, ctx.lastRenderData.lastTextareaPosition);
  88538. }
  88539. return request.fulfill(1 /* TEXTAREA */, ctx.lastRenderData.lastTextareaPosition);
  88540. }
  88541. return null;
  88542. };
  88543. MouseTargetFactory._hitTestMargin = function (ctx, request) {
  88544. if (request.isInMarginArea) {
  88545. var res = ctx.getFullLineRangeAtCoord(request.mouseVerticalOffset);
  88546. var pos = res.range.getStartPosition();
  88547. var offset = Math.abs(request.pos.x - request.editorPos.x);
  88548. var detail = {
  88549. isAfterLines: res.isAfterLines,
  88550. glyphMarginLeft: ctx.layoutInfo.glyphMarginLeft,
  88551. glyphMarginWidth: ctx.layoutInfo.glyphMarginWidth,
  88552. lineNumbersWidth: ctx.layoutInfo.lineNumbersWidth,
  88553. offsetX: offset
  88554. };
  88555. offset -= ctx.layoutInfo.glyphMarginLeft;
  88556. if (offset <= ctx.layoutInfo.glyphMarginWidth) {
  88557. // On the glyph margin
  88558. return request.fulfill(2 /* GUTTER_GLYPH_MARGIN */, pos, res.range, detail);
  88559. }
  88560. offset -= ctx.layoutInfo.glyphMarginWidth;
  88561. if (offset <= ctx.layoutInfo.lineNumbersWidth) {
  88562. // On the line numbers
  88563. return request.fulfill(3 /* GUTTER_LINE_NUMBERS */, pos, res.range, detail);
  88564. }
  88565. offset -= ctx.layoutInfo.lineNumbersWidth;
  88566. // On the line decorations
  88567. return request.fulfill(4 /* GUTTER_LINE_DECORATIONS */, pos, res.range, detail);
  88568. }
  88569. return null;
  88570. };
  88571. MouseTargetFactory._hitTestViewLines = function (ctx, request, domHitTestExecuted) {
  88572. if (!ElementPath.isChildOfViewLines(request.targetPath)) {
  88573. return null;
  88574. }
  88575. // Check if it is below any lines and any view zones
  88576. if (ctx.isAfterLines(request.mouseVerticalOffset)) {
  88577. // This most likely indicates it happened after the last view-line
  88578. var lineCount = ctx.model.getLineCount();
  88579. var maxLineColumn = ctx.model.getLineMaxColumn(lineCount);
  88580. return request.fulfill(7 /* CONTENT_EMPTY */, new position_1.Position(lineCount, maxLineColumn), undefined, EMPTY_CONTENT_AFTER_LINES);
  88581. }
  88582. if (domHitTestExecuted) {
  88583. // Check if we are hitting a view-line (can happen in the case of inline decorations on empty lines)
  88584. // See https://github.com/Microsoft/vscode/issues/46942
  88585. if (ElementPath.isStrictChildOfViewLines(request.targetPath)) {
  88586. var lineNumber = ctx.getLineNumberAtVerticalOffset(request.mouseVerticalOffset);
  88587. if (ctx.model.getLineLength(lineNumber) === 0) {
  88588. var lineWidth_1 = ctx.getLineWidth(lineNumber);
  88589. var detail = createEmptyContentDataInLines(request.mouseContentHorizontalOffset - lineWidth_1);
  88590. return request.fulfill(7 /* CONTENT_EMPTY */, new position_1.Position(lineNumber, 1), undefined, detail);
  88591. }
  88592. var lineWidth = ctx.getLineWidth(lineNumber);
  88593. if (request.mouseContentHorizontalOffset >= lineWidth) {
  88594. var detail = createEmptyContentDataInLines(request.mouseContentHorizontalOffset - lineWidth);
  88595. var pos = new position_1.Position(lineNumber, ctx.model.getLineMaxColumn(lineNumber));
  88596. return request.fulfill(7 /* CONTENT_EMPTY */, pos, undefined, detail);
  88597. }
  88598. }
  88599. // We have already executed hit test...
  88600. return request.fulfill(0 /* UNKNOWN */);
  88601. }
  88602. var hitTestResult = MouseTargetFactory._doHitTest(ctx, request);
  88603. if (hitTestResult.position) {
  88604. return MouseTargetFactory.createMouseTargetFromHitTestPosition(ctx, request, hitTestResult.position.lineNumber, hitTestResult.position.column);
  88605. }
  88606. return this._createMouseTarget(ctx, request.withTarget(hitTestResult.hitTarget), true);
  88607. };
  88608. MouseTargetFactory._hitTestMinimap = function (ctx, request) {
  88609. if (ElementPath.isChildOfMinimap(request.targetPath)) {
  88610. var possibleLineNumber = ctx.getLineNumberAtVerticalOffset(request.mouseVerticalOffset);
  88611. var maxColumn = ctx.model.getLineMaxColumn(possibleLineNumber);
  88612. return request.fulfill(11 /* SCROLLBAR */, new position_1.Position(possibleLineNumber, maxColumn));
  88613. }
  88614. return null;
  88615. };
  88616. MouseTargetFactory._hitTestScrollbarSlider = function (ctx, request) {
  88617. if (ElementPath.isChildOfScrollableElement(request.targetPath)) {
  88618. if (request.target && request.target.nodeType === 1) {
  88619. var className = request.target.className;
  88620. if (className && /\b(slider|scrollbar)\b/.test(className)) {
  88621. var possibleLineNumber = ctx.getLineNumberAtVerticalOffset(request.mouseVerticalOffset);
  88622. var maxColumn = ctx.model.getLineMaxColumn(possibleLineNumber);
  88623. return request.fulfill(11 /* SCROLLBAR */, new position_1.Position(possibleLineNumber, maxColumn));
  88624. }
  88625. }
  88626. }
  88627. return null;
  88628. };
  88629. MouseTargetFactory._hitTestScrollbar = function (ctx, request) {
  88630. // Is it the overview ruler?
  88631. // Is it a child of the scrollable element?
  88632. if (ElementPath.isChildOfScrollableElement(request.targetPath)) {
  88633. var possibleLineNumber = ctx.getLineNumberAtVerticalOffset(request.mouseVerticalOffset);
  88634. var maxColumn = ctx.model.getLineMaxColumn(possibleLineNumber);
  88635. return request.fulfill(11 /* SCROLLBAR */, new position_1.Position(possibleLineNumber, maxColumn));
  88636. }
  88637. return null;
  88638. };
  88639. MouseTargetFactory.prototype.getMouseColumn = function (editorPos, pos) {
  88640. var options = this._context.configuration.options;
  88641. var layoutInfo = options.get(107 /* layoutInfo */);
  88642. var mouseContentHorizontalOffset = this._context.viewLayout.getCurrentScrollLeft() + pos.x - editorPos.x - layoutInfo.contentLeft;
  88643. return MouseTargetFactory._getMouseColumn(mouseContentHorizontalOffset, options.get(34 /* fontInfo */).typicalHalfwidthCharacterWidth);
  88644. };
  88645. MouseTargetFactory._getMouseColumn = function (mouseContentHorizontalOffset, typicalHalfwidthCharacterWidth) {
  88646. if (mouseContentHorizontalOffset < 0) {
  88647. return 1;
  88648. }
  88649. var chars = Math.round(mouseContentHorizontalOffset / typicalHalfwidthCharacterWidth);
  88650. return (chars + 1);
  88651. };
  88652. MouseTargetFactory.createMouseTargetFromHitTestPosition = function (ctx, request, lineNumber, column) {
  88653. var pos = new position_1.Position(lineNumber, column);
  88654. var lineWidth = ctx.getLineWidth(lineNumber);
  88655. if (request.mouseContentHorizontalOffset > lineWidth) {
  88656. if (browser.isEdge && pos.column === 1) {
  88657. // See https://github.com/Microsoft/vscode/issues/10875
  88658. var detail_1 = createEmptyContentDataInLines(request.mouseContentHorizontalOffset - lineWidth);
  88659. return request.fulfill(7 /* CONTENT_EMPTY */, new position_1.Position(lineNumber, ctx.model.getLineMaxColumn(lineNumber)), undefined, detail_1);
  88660. }
  88661. var detail = createEmptyContentDataInLines(request.mouseContentHorizontalOffset - lineWidth);
  88662. return request.fulfill(7 /* CONTENT_EMPTY */, pos, undefined, detail);
  88663. }
  88664. var visibleRange = ctx.visibleRangeForPosition(lineNumber, column);
  88665. if (!visibleRange) {
  88666. return request.fulfill(0 /* UNKNOWN */, pos);
  88667. }
  88668. var columnHorizontalOffset = visibleRange.left;
  88669. if (request.mouseContentHorizontalOffset === columnHorizontalOffset) {
  88670. return request.fulfill(6 /* CONTENT_TEXT */, pos);
  88671. }
  88672. var points = [];
  88673. points.push({ offset: visibleRange.left, column: column });
  88674. if (column > 1) {
  88675. var visibleRange_1 = ctx.visibleRangeForPosition(lineNumber, column - 1);
  88676. if (visibleRange_1) {
  88677. points.push({ offset: visibleRange_1.left, column: column - 1 });
  88678. }
  88679. }
  88680. var lineMaxColumn = ctx.model.getLineMaxColumn(lineNumber);
  88681. if (column < lineMaxColumn) {
  88682. var visibleRange_2 = ctx.visibleRangeForPosition(lineNumber, column + 1);
  88683. if (visibleRange_2) {
  88684. points.push({ offset: visibleRange_2.left, column: column + 1 });
  88685. }
  88686. }
  88687. points.sort(function (a, b) { return a.offset - b.offset; });
  88688. for (var i = 1; i < points.length; i++) {
  88689. var prev = points[i - 1];
  88690. var curr = points[i];
  88691. if (prev.offset <= request.mouseContentHorizontalOffset && request.mouseContentHorizontalOffset <= curr.offset) {
  88692. var rng = new range_1.Range(lineNumber, prev.column, lineNumber, curr.column);
  88693. return request.fulfill(6 /* CONTENT_TEXT */, pos, rng);
  88694. }
  88695. }
  88696. return request.fulfill(6 /* CONTENT_TEXT */, pos);
  88697. };
  88698. /**
  88699. * Most probably WebKit browsers and Edge
  88700. */
  88701. MouseTargetFactory._doHitTestWithCaretRangeFromPoint = function (ctx, request) {
  88702. // In Chrome, especially on Linux it is possible to click between lines,
  88703. // so try to adjust the `hity` below so that it lands in the center of a line
  88704. var lineNumber = ctx.getLineNumberAtVerticalOffset(request.mouseVerticalOffset);
  88705. var lineVerticalOffset = ctx.getVerticalOffsetForLineNumber(lineNumber);
  88706. var lineCenteredVerticalOffset = lineVerticalOffset + Math.floor(ctx.lineHeight / 2);
  88707. var adjustedPageY = request.pos.y + (lineCenteredVerticalOffset - request.mouseVerticalOffset);
  88708. if (adjustedPageY <= request.editorPos.y) {
  88709. adjustedPageY = request.editorPos.y + 1;
  88710. }
  88711. if (adjustedPageY >= request.editorPos.y + ctx.layoutInfo.height) {
  88712. adjustedPageY = request.editorPos.y + ctx.layoutInfo.height - 1;
  88713. }
  88714. var adjustedPage = new editorDom_1.PageCoordinates(request.pos.x, adjustedPageY);
  88715. var r = this._actualDoHitTestWithCaretRangeFromPoint(ctx, adjustedPage.toClientCoordinates());
  88716. if (r.position) {
  88717. return r;
  88718. }
  88719. // Also try to hit test without the adjustment (for the edge cases that we are near the top or bottom)
  88720. return this._actualDoHitTestWithCaretRangeFromPoint(ctx, request.pos.toClientCoordinates());
  88721. };
  88722. MouseTargetFactory._actualDoHitTestWithCaretRangeFromPoint = function (ctx, coords) {
  88723. var shadowRoot = dom.getShadowRoot(ctx.viewDomNode);
  88724. var range;
  88725. if (shadowRoot) {
  88726. if (typeof shadowRoot.caretRangeFromPoint === 'undefined') {
  88727. range = shadowCaretRangeFromPoint(shadowRoot, coords.clientX, coords.clientY);
  88728. }
  88729. else {
  88730. range = shadowRoot.caretRangeFromPoint(coords.clientX, coords.clientY);
  88731. }
  88732. }
  88733. else {
  88734. range = document.caretRangeFromPoint(coords.clientX, coords.clientY);
  88735. }
  88736. if (!range || !range.startContainer) {
  88737. return {
  88738. position: null,
  88739. hitTarget: null
  88740. };
  88741. }
  88742. // Chrome always hits a TEXT_NODE, while Edge sometimes hits a token span
  88743. var startContainer = range.startContainer;
  88744. var hitTarget = null;
  88745. if (startContainer.nodeType === startContainer.TEXT_NODE) {
  88746. // startContainer is expected to be the token text
  88747. var parent1 = startContainer.parentNode; // expected to be the token span
  88748. var parent2 = parent1 ? parent1.parentNode : null; // expected to be the view line container span
  88749. var parent3 = parent2 ? parent2.parentNode : null; // expected to be the view line div
  88750. var parent3ClassName = parent3 && parent3.nodeType === parent3.ELEMENT_NODE ? parent3.className : null;
  88751. if (parent3ClassName === viewLine_1.ViewLine.CLASS_NAME) {
  88752. var p = ctx.getPositionFromDOMInfo(parent1, range.startOffset);
  88753. return {
  88754. position: p,
  88755. hitTarget: null
  88756. };
  88757. }
  88758. else {
  88759. hitTarget = startContainer.parentNode;
  88760. }
  88761. }
  88762. else if (startContainer.nodeType === startContainer.ELEMENT_NODE) {
  88763. // startContainer is expected to be the token span
  88764. var parent1 = startContainer.parentNode; // expected to be the view line container span
  88765. var parent2 = parent1 ? parent1.parentNode : null; // expected to be the view line div
  88766. var parent2ClassName = parent2 && parent2.nodeType === parent2.ELEMENT_NODE ? parent2.className : null;
  88767. if (parent2ClassName === viewLine_1.ViewLine.CLASS_NAME) {
  88768. var p = ctx.getPositionFromDOMInfo(startContainer, startContainer.textContent.length);
  88769. return {
  88770. position: p,
  88771. hitTarget: null
  88772. };
  88773. }
  88774. else {
  88775. hitTarget = startContainer;
  88776. }
  88777. }
  88778. return {
  88779. position: null,
  88780. hitTarget: hitTarget
  88781. };
  88782. };
  88783. /**
  88784. * Most probably Gecko
  88785. */
  88786. MouseTargetFactory._doHitTestWithCaretPositionFromPoint = function (ctx, coords) {
  88787. var hitResult = document.caretPositionFromPoint(coords.clientX, coords.clientY);
  88788. if (hitResult.offsetNode.nodeType === hitResult.offsetNode.TEXT_NODE) {
  88789. // offsetNode is expected to be the token text
  88790. var parent1 = hitResult.offsetNode.parentNode; // expected to be the token span
  88791. var parent2 = parent1 ? parent1.parentNode : null; // expected to be the view line container span
  88792. var parent3 = parent2 ? parent2.parentNode : null; // expected to be the view line div
  88793. var parent3ClassName = parent3 && parent3.nodeType === parent3.ELEMENT_NODE ? parent3.className : null;
  88794. if (parent3ClassName === viewLine_1.ViewLine.CLASS_NAME) {
  88795. var p = ctx.getPositionFromDOMInfo(hitResult.offsetNode.parentNode, hitResult.offset);
  88796. return {
  88797. position: p,
  88798. hitTarget: null
  88799. };
  88800. }
  88801. else {
  88802. return {
  88803. position: null,
  88804. hitTarget: hitResult.offsetNode.parentNode
  88805. };
  88806. }
  88807. }
  88808. return {
  88809. position: null,
  88810. hitTarget: hitResult.offsetNode
  88811. };
  88812. };
  88813. /**
  88814. * Most probably IE
  88815. */
  88816. MouseTargetFactory._doHitTestWithMoveToPoint = function (ctx, coords) {
  88817. var resultPosition = null;
  88818. var resultHitTarget = null;
  88819. var textRange = document.body.createTextRange();
  88820. try {
  88821. textRange.moveToPoint(coords.clientX, coords.clientY);
  88822. }
  88823. catch (err) {
  88824. return {
  88825. position: null,
  88826. hitTarget: null
  88827. };
  88828. }
  88829. textRange.collapse(true);
  88830. // Now, let's do our best to figure out what we hit :)
  88831. var parentElement = textRange ? textRange.parentElement() : null;
  88832. var parent1 = parentElement ? parentElement.parentNode : null;
  88833. var parent2 = parent1 ? parent1.parentNode : null;
  88834. var parent2ClassName = parent2 && parent2.nodeType === parent2.ELEMENT_NODE ? parent2.className : '';
  88835. if (parent2ClassName === viewLine_1.ViewLine.CLASS_NAME) {
  88836. var rangeToContainEntireSpan = textRange.duplicate();
  88837. rangeToContainEntireSpan.moveToElementText(parentElement);
  88838. rangeToContainEntireSpan.setEndPoint('EndToStart', textRange);
  88839. resultPosition = ctx.getPositionFromDOMInfo(parentElement, rangeToContainEntireSpan.text.length);
  88840. // Move range out of the span node, IE doesn't like having many ranges in
  88841. // the same spot and will act badly for lines containing dashes ('-')
  88842. rangeToContainEntireSpan.moveToElementText(ctx.viewDomNode);
  88843. }
  88844. else {
  88845. // Looks like we've hit the hover or something foreign
  88846. resultHitTarget = parentElement;
  88847. }
  88848. // Move range out of the span node, IE doesn't like having many ranges in
  88849. // the same spot and will act badly for lines containing dashes ('-')
  88850. textRange.moveToElementText(ctx.viewDomNode);
  88851. return {
  88852. position: resultPosition,
  88853. hitTarget: resultHitTarget
  88854. };
  88855. };
  88856. MouseTargetFactory._doHitTest = function (ctx, request) {
  88857. // State of the art (18.10.2012):
  88858. // The spec says browsers should support document.caretPositionFromPoint, but nobody implemented it (http://dev.w3.org/csswg/cssom-view/)
  88859. // Gecko:
  88860. // - they tried to implement it once, but failed: https://bugzilla.mozilla.org/show_bug.cgi?id=654352
  88861. // - however, they do give out rangeParent/rangeOffset properties on mouse events
  88862. // Webkit:
  88863. // - they have implemented a previous version of the spec which was using document.caretRangeFromPoint
  88864. // IE:
  88865. // - they have a proprietary method on ranges, moveToPoint: https://msdn.microsoft.com/en-us/library/ie/ms536632(v=vs.85).aspx
  88866. // 24.08.2016: Edge has added WebKit's document.caretRangeFromPoint, but it is quite buggy
  88867. // - when hit testing the cursor it returns the first or the last line in the viewport
  88868. // - it inconsistently hits text nodes or span nodes, while WebKit only hits text nodes
  88869. // - when toggling render whitespace on, and hit testing in the empty content after a line, it always hits offset 0 of the first span of the line
  88870. // Thank you browsers for making this so 'easy' :)
  88871. if (typeof document.caretRangeFromPoint === 'function') {
  88872. return this._doHitTestWithCaretRangeFromPoint(ctx, request);
  88873. }
  88874. else if (document.caretPositionFromPoint) {
  88875. return this._doHitTestWithCaretPositionFromPoint(ctx, request.pos.toClientCoordinates());
  88876. }
  88877. else if (document.body.createTextRange) {
  88878. return this._doHitTestWithMoveToPoint(ctx, request.pos.toClientCoordinates());
  88879. }
  88880. return {
  88881. position: null,
  88882. hitTarget: null
  88883. };
  88884. };
  88885. return MouseTargetFactory;
  88886. }());
  88887. exports.MouseTargetFactory = MouseTargetFactory;
  88888. function shadowCaretRangeFromPoint(shadowRoot, x, y) {
  88889. var range = document.createRange();
  88890. // Get the element under the point
  88891. var el = shadowRoot.elementFromPoint(x, y);
  88892. if (el !== null) {
  88893. // Get the last child of the element until its firstChild is a text node
  88894. // This assumes that the pointer is on the right of the line, out of the tokens
  88895. // and that we want to get the offset of the last token of the line
  88896. while (el && el.firstChild && el.firstChild.nodeType !== el.firstChild.TEXT_NODE) {
  88897. el = el.lastChild;
  88898. }
  88899. // Grab its rect
  88900. var rect = el.getBoundingClientRect();
  88901. // And its font
  88902. var font = window.getComputedStyle(el, null).getPropertyValue('font');
  88903. // And also its txt content
  88904. var text = el.innerText;
  88905. // Position the pixel cursor at the left of the element
  88906. var pixelCursor = rect.left;
  88907. var offset = 0;
  88908. var step = void 0;
  88909. // If the point is on the right of the box put the cursor after the last character
  88910. if (x > rect.left + rect.width) {
  88911. offset = text.length;
  88912. }
  88913. else {
  88914. var charWidthReader = CharWidthReader.getInstance();
  88915. // Goes through all the characters of the innerText, and checks if the x of the point
  88916. // belongs to the character.
  88917. for (var i = 0; i < text.length + 1; i++) {
  88918. // The step is half the width of the character
  88919. step = charWidthReader.getCharWidth(text.charAt(i), font) / 2;
  88920. // Move to the center of the character
  88921. pixelCursor += step;
  88922. // If the x of the point is smaller that the position of the cursor, the point is over that character
  88923. if (x < pixelCursor) {
  88924. offset = i;
  88925. break;
  88926. }
  88927. // Move between the current character and the next
  88928. pixelCursor += step;
  88929. }
  88930. }
  88931. // Creates a range with the text node of the element and set the offset found
  88932. range.setStart(el.firstChild, offset);
  88933. range.setEnd(el.firstChild, offset);
  88934. }
  88935. return range;
  88936. }
  88937. exports.shadowCaretRangeFromPoint = shadowCaretRangeFromPoint;
  88938. var CharWidthReader = /** @class */ (function () {
  88939. function CharWidthReader() {
  88940. this._cache = {};
  88941. this._canvas = document.createElement('canvas');
  88942. }
  88943. CharWidthReader.getInstance = function () {
  88944. if (!CharWidthReader._INSTANCE) {
  88945. CharWidthReader._INSTANCE = new CharWidthReader();
  88946. }
  88947. return CharWidthReader._INSTANCE;
  88948. };
  88949. CharWidthReader.prototype.getCharWidth = function (char, font) {
  88950. var cacheKey = char + font;
  88951. if (this._cache[cacheKey]) {
  88952. return this._cache[cacheKey];
  88953. }
  88954. var context = this._canvas.getContext('2d');
  88955. context.font = font;
  88956. var metrics = context.measureText(char);
  88957. var width = metrics.width;
  88958. this._cache[cacheKey] = width;
  88959. return width;
  88960. };
  88961. CharWidthReader._INSTANCE = null;
  88962. return CharWidthReader;
  88963. }());
  88964. });
  88965. /*---------------------------------------------------------------------------------------------
  88966. * Copyright (c) Microsoft Corporation. All rights reserved.
  88967. * Licensed under the MIT License. See License.txt in the project root for license information.
  88968. *--------------------------------------------------------------------------------------------*/
  88969. define(__m[550/*vs/editor/browser/controller/mouseHandler*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,6/*vs/base/browser/dom*/,45/*vs/base/browser/mouseEvent*/,15/*vs/base/common/async*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,166/*vs/editor/browser/controller/mouseTarget*/,141/*vs/editor/browser/editorDom*/,105/*vs/editor/common/config/editorZoom*/,13/*vs/editor/common/core/position*/,22/*vs/editor/common/core/selection*/,92/*vs/editor/common/viewModel/viewEventHandler*/]), function (require, exports, browser, dom, mouseEvent_1, async_1, lifecycle_1, platform, mouseTarget_1, editorDom_1, editorZoom_1, position_1, selection_1, viewEventHandler_1) {
  88970. "use strict";
  88971. Object.defineProperty(exports, "__esModule", { value: true });
  88972. /**
  88973. * Merges mouse events when mouse move events are throttled
  88974. */
  88975. function createMouseMoveEventMerger(mouseTargetFactory) {
  88976. return function (lastEvent, currentEvent) {
  88977. var targetIsWidget = false;
  88978. if (mouseTargetFactory) {
  88979. targetIsWidget = mouseTargetFactory.mouseTargetIsWidget(currentEvent);
  88980. }
  88981. if (!targetIsWidget) {
  88982. currentEvent.preventDefault();
  88983. }
  88984. return currentEvent;
  88985. };
  88986. }
  88987. exports.createMouseMoveEventMerger = createMouseMoveEventMerger;
  88988. var MouseHandler = /** @class */ (function (_super) {
  88989. __extends(MouseHandler, _super);
  88990. function MouseHandler(context, viewController, viewHelper) {
  88991. var _this = _super.call(this) || this;
  88992. _this._isFocused = false;
  88993. _this._context = context;
  88994. _this.viewController = viewController;
  88995. _this.viewHelper = viewHelper;
  88996. _this.mouseTargetFactory = new mouseTarget_1.MouseTargetFactory(_this._context, viewHelper);
  88997. _this._mouseDownOperation = _this._register(new MouseDownOperation(_this._context, _this.viewController, _this.viewHelper, function (e, testEventTarget) { return _this._createMouseTarget(e, testEventTarget); }, function (e) { return _this._getMouseColumn(e); }));
  88998. _this._asyncFocus = _this._register(new async_1.RunOnceScheduler(function () { return _this.viewHelper.focusTextArea(); }, 0));
  88999. _this.lastMouseLeaveTime = -1;
  89000. var mouseEvents = new editorDom_1.EditorMouseEventFactory(_this.viewHelper.viewDomNode);
  89001. _this._register(mouseEvents.onContextMenu(_this.viewHelper.viewDomNode, function (e) { return _this._onContextMenu(e, true); }));
  89002. _this._register(mouseEvents.onMouseMoveThrottled(_this.viewHelper.viewDomNode, function (e) { return _this._onMouseMove(e); }, createMouseMoveEventMerger(_this.mouseTargetFactory), MouseHandler.MOUSE_MOVE_MINIMUM_TIME));
  89003. _this._register(mouseEvents.onMouseUp(_this.viewHelper.viewDomNode, function (e) { return _this._onMouseUp(e); }));
  89004. _this._register(mouseEvents.onMouseLeave(_this.viewHelper.viewDomNode, function (e) { return _this._onMouseLeave(e); }));
  89005. _this._register(mouseEvents.onMouseDown(_this.viewHelper.viewDomNode, function (e) { return _this._onMouseDown(e); }));
  89006. var onMouseWheel = function (browserEvent) {
  89007. _this.viewController.emitMouseWheel(browserEvent);
  89008. if (!_this._context.configuration.options.get(57 /* mouseWheelZoom */)) {
  89009. return;
  89010. }
  89011. var e = new mouseEvent_1.StandardWheelEvent(browserEvent);
  89012. if (e.browserEvent.ctrlKey || e.browserEvent.metaKey) {
  89013. var zoomLevel = editorZoom_1.EditorZoom.getZoomLevel();
  89014. var delta = e.deltaY > 0 ? 1 : -1;
  89015. editorZoom_1.EditorZoom.setZoomLevel(zoomLevel + delta);
  89016. e.preventDefault();
  89017. e.stopPropagation();
  89018. }
  89019. };
  89020. _this._register(dom.addDisposableListener(_this.viewHelper.viewDomNode, browser.isEdgeOrIE ? 'mousewheel' : 'wheel', onMouseWheel, { capture: true, passive: false }));
  89021. _this._context.addEventHandler(_this);
  89022. return _this;
  89023. }
  89024. MouseHandler.prototype.dispose = function () {
  89025. this._context.removeEventHandler(this);
  89026. _super.prototype.dispose.call(this);
  89027. };
  89028. // --- begin event handlers
  89029. MouseHandler.prototype.onCursorStateChanged = function (e) {
  89030. this._mouseDownOperation.onCursorStateChanged(e);
  89031. return false;
  89032. };
  89033. MouseHandler.prototype.onFocusChanged = function (e) {
  89034. this._isFocused = e.isFocused;
  89035. return false;
  89036. };
  89037. MouseHandler.prototype.onScrollChanged = function (e) {
  89038. this._mouseDownOperation.onScrollChanged();
  89039. return false;
  89040. };
  89041. // --- end event handlers
  89042. MouseHandler.prototype.getTargetAtClientPoint = function (clientX, clientY) {
  89043. var clientPos = new editorDom_1.ClientCoordinates(clientX, clientY);
  89044. var pos = clientPos.toPageCoordinates();
  89045. var editorPos = editorDom_1.createEditorPagePosition(this.viewHelper.viewDomNode);
  89046. if (pos.y < editorPos.y || pos.y > editorPos.y + editorPos.height || pos.x < editorPos.x || pos.x > editorPos.x + editorPos.width) {
  89047. return null;
  89048. }
  89049. return this.mouseTargetFactory.createMouseTarget(this.viewHelper.getLastRenderData(), editorPos, pos, null);
  89050. };
  89051. MouseHandler.prototype._createMouseTarget = function (e, testEventTarget) {
  89052. return this.mouseTargetFactory.createMouseTarget(this.viewHelper.getLastRenderData(), e.editorPos, e.pos, testEventTarget ? e.target : null);
  89053. };
  89054. MouseHandler.prototype._getMouseColumn = function (e) {
  89055. return this.mouseTargetFactory.getMouseColumn(e.editorPos, e.pos);
  89056. };
  89057. MouseHandler.prototype._onContextMenu = function (e, testEventTarget) {
  89058. this.viewController.emitContextMenu({
  89059. event: e,
  89060. target: this._createMouseTarget(e, testEventTarget)
  89061. });
  89062. };
  89063. MouseHandler.prototype._onMouseMove = function (e) {
  89064. if (this._mouseDownOperation.isActive()) {
  89065. // In selection/drag operation
  89066. return;
  89067. }
  89068. var actualMouseMoveTime = e.timestamp;
  89069. if (actualMouseMoveTime < this.lastMouseLeaveTime) {
  89070. // Due to throttling, this event occurred before the mouse left the editor, therefore ignore it.
  89071. return;
  89072. }
  89073. this.viewController.emitMouseMove({
  89074. event: e,
  89075. target: this._createMouseTarget(e, true)
  89076. });
  89077. };
  89078. MouseHandler.prototype._onMouseLeave = function (e) {
  89079. this.lastMouseLeaveTime = (new Date()).getTime();
  89080. this.viewController.emitMouseLeave({
  89081. event: e,
  89082. target: null
  89083. });
  89084. };
  89085. MouseHandler.prototype._onMouseUp = function (e) {
  89086. this.viewController.emitMouseUp({
  89087. event: e,
  89088. target: this._createMouseTarget(e, true)
  89089. });
  89090. };
  89091. MouseHandler.prototype._onMouseDown = function (e) {
  89092. var _this = this;
  89093. var t = this._createMouseTarget(e, true);
  89094. var targetIsContent = (t.type === 6 /* CONTENT_TEXT */ || t.type === 7 /* CONTENT_EMPTY */);
  89095. var targetIsGutter = (t.type === 2 /* GUTTER_GLYPH_MARGIN */ || t.type === 3 /* GUTTER_LINE_NUMBERS */ || t.type === 4 /* GUTTER_LINE_DECORATIONS */);
  89096. var targetIsLineNumbers = (t.type === 3 /* GUTTER_LINE_NUMBERS */);
  89097. var selectOnLineNumbers = this._context.configuration.options.get(83 /* selectOnLineNumbers */);
  89098. var targetIsViewZone = (t.type === 8 /* CONTENT_VIEW_ZONE */ || t.type === 5 /* GUTTER_VIEW_ZONE */);
  89099. var targetIsWidget = (t.type === 9 /* CONTENT_WIDGET */);
  89100. var shouldHandle = e.leftButton || e.middleButton;
  89101. if (platform.isMacintosh && e.leftButton && e.ctrlKey) {
  89102. shouldHandle = false;
  89103. }
  89104. var focus = function () {
  89105. // In IE11, if the focus is in the browser's address bar and
  89106. // then you click in the editor, calling preventDefault()
  89107. // will not move focus properly (focus remains the address bar)
  89108. if (browser.isIE && !_this._isFocused) {
  89109. _this._asyncFocus.schedule();
  89110. }
  89111. else {
  89112. e.preventDefault();
  89113. _this.viewHelper.focusTextArea();
  89114. }
  89115. };
  89116. if (shouldHandle && (targetIsContent || (targetIsLineNumbers && selectOnLineNumbers))) {
  89117. focus();
  89118. this._mouseDownOperation.start(t.type, e);
  89119. }
  89120. else if (targetIsGutter) {
  89121. // Do not steal focus
  89122. e.preventDefault();
  89123. }
  89124. else if (targetIsViewZone) {
  89125. var viewZoneData = t.detail;
  89126. if (this.viewHelper.shouldSuppressMouseDownOnViewZone(viewZoneData.viewZoneId)) {
  89127. focus();
  89128. this._mouseDownOperation.start(t.type, e);
  89129. e.preventDefault();
  89130. }
  89131. }
  89132. else if (targetIsWidget && this.viewHelper.shouldSuppressMouseDownOnWidget(t.detail)) {
  89133. focus();
  89134. e.preventDefault();
  89135. }
  89136. this.viewController.emitMouseDown({
  89137. event: e,
  89138. target: t
  89139. });
  89140. };
  89141. MouseHandler.MOUSE_MOVE_MINIMUM_TIME = 100; // ms
  89142. return MouseHandler;
  89143. }(viewEventHandler_1.ViewEventHandler));
  89144. exports.MouseHandler = MouseHandler;
  89145. var MouseDownOperation = /** @class */ (function (_super) {
  89146. __extends(MouseDownOperation, _super);
  89147. function MouseDownOperation(context, viewController, viewHelper, createMouseTarget, getMouseColumn) {
  89148. var _this = _super.call(this) || this;
  89149. _this._context = context;
  89150. _this._viewController = viewController;
  89151. _this._viewHelper = viewHelper;
  89152. _this._createMouseTarget = createMouseTarget;
  89153. _this._getMouseColumn = getMouseColumn;
  89154. _this._mouseMoveMonitor = _this._register(new editorDom_1.GlobalEditorMouseMoveMonitor(_this._viewHelper.viewDomNode));
  89155. _this._onScrollTimeout = _this._register(new async_1.TimeoutTimer());
  89156. _this._mouseState = new MouseDownState();
  89157. _this._currentSelection = new selection_1.Selection(1, 1, 1, 1);
  89158. _this._isActive = false;
  89159. _this._lastMouseEvent = null;
  89160. return _this;
  89161. }
  89162. MouseDownOperation.prototype.dispose = function () {
  89163. _super.prototype.dispose.call(this);
  89164. };
  89165. MouseDownOperation.prototype.isActive = function () {
  89166. return this._isActive;
  89167. };
  89168. MouseDownOperation.prototype._onMouseDownThenMove = function (e) {
  89169. this._lastMouseEvent = e;
  89170. this._mouseState.setModifiers(e);
  89171. var position = this._findMousePosition(e, true);
  89172. if (!position) {
  89173. // Ignoring because position is unknown
  89174. return;
  89175. }
  89176. if (this._mouseState.isDragAndDrop) {
  89177. this._viewController.emitMouseDrag({
  89178. event: e,
  89179. target: position
  89180. });
  89181. }
  89182. else {
  89183. this._dispatchMouse(position, true);
  89184. }
  89185. };
  89186. MouseDownOperation.prototype.start = function (targetType, e) {
  89187. var _this = this;
  89188. this._lastMouseEvent = e;
  89189. this._mouseState.setStartedOnLineNumbers(targetType === 3 /* GUTTER_LINE_NUMBERS */);
  89190. this._mouseState.setStartButtons(e);
  89191. this._mouseState.setModifiers(e);
  89192. var position = this._findMousePosition(e, true);
  89193. if (!position || !position.position) {
  89194. // Ignoring because position is unknown
  89195. return;
  89196. }
  89197. this._mouseState.trySetCount(e.detail, position.position);
  89198. // Overwrite the detail of the MouseEvent, as it will be sent out in an event and contributions might rely on it.
  89199. e.detail = this._mouseState.count;
  89200. var options = this._context.configuration.options;
  89201. if (!options.get(68 /* readOnly */)
  89202. && options.get(24 /* dragAndDrop */)
  89203. && !this._mouseState.altKey // we don't support multiple mouse
  89204. && e.detail < 2 // only single click on a selection can work
  89205. && !this._isActive // the mouse is not down yet
  89206. && !this._currentSelection.isEmpty() // we don't drag single cursor
  89207. && (position.type === 6 /* CONTENT_TEXT */) // single click on text
  89208. && position.position && this._currentSelection.containsPosition(position.position) // single click on a selection
  89209. ) {
  89210. this._mouseState.isDragAndDrop = true;
  89211. this._isActive = true;
  89212. this._mouseMoveMonitor.startMonitoring(e.target, e.buttons, createMouseMoveEventMerger(null), function (e) { return _this._onMouseDownThenMove(e); }, function () {
  89213. var position = _this._findMousePosition(_this._lastMouseEvent, true);
  89214. _this._viewController.emitMouseDrop({
  89215. event: _this._lastMouseEvent,
  89216. target: (position ? _this._createMouseTarget(_this._lastMouseEvent, true) : null) // Ignoring because position is unknown, e.g., Content View Zone
  89217. });
  89218. _this._stop();
  89219. });
  89220. return;
  89221. }
  89222. this._mouseState.isDragAndDrop = false;
  89223. this._dispatchMouse(position, e.shiftKey);
  89224. if (!this._isActive) {
  89225. this._isActive = true;
  89226. this._mouseMoveMonitor.startMonitoring(e.target, e.buttons, createMouseMoveEventMerger(null), function (e) { return _this._onMouseDownThenMove(e); }, function () { return _this._stop(); });
  89227. }
  89228. };
  89229. MouseDownOperation.prototype._stop = function () {
  89230. this._isActive = false;
  89231. this._onScrollTimeout.cancel();
  89232. };
  89233. MouseDownOperation.prototype.onScrollChanged = function () {
  89234. var _this = this;
  89235. if (!this._isActive) {
  89236. return;
  89237. }
  89238. this._onScrollTimeout.setIfNotSet(function () {
  89239. if (!_this._lastMouseEvent) {
  89240. return;
  89241. }
  89242. var position = _this._findMousePosition(_this._lastMouseEvent, false);
  89243. if (!position) {
  89244. // Ignoring because position is unknown
  89245. return;
  89246. }
  89247. if (_this._mouseState.isDragAndDrop) {
  89248. // Ignoring because users are dragging the text
  89249. return;
  89250. }
  89251. _this._dispatchMouse(position, true);
  89252. }, 10);
  89253. };
  89254. MouseDownOperation.prototype.onCursorStateChanged = function (e) {
  89255. this._currentSelection = e.selections[0];
  89256. };
  89257. MouseDownOperation.prototype._getPositionOutsideEditor = function (e) {
  89258. var editorContent = e.editorPos;
  89259. var model = this._context.model;
  89260. var viewLayout = this._context.viewLayout;
  89261. var mouseColumn = this._getMouseColumn(e);
  89262. if (e.posy < editorContent.y) {
  89263. var verticalOffset = Math.max(viewLayout.getCurrentScrollTop() - (editorContent.y - e.posy), 0);
  89264. var viewZoneData = mouseTarget_1.HitTestContext.getZoneAtCoord(this._context, verticalOffset);
  89265. if (viewZoneData) {
  89266. var newPosition = this._helpPositionJumpOverViewZone(viewZoneData);
  89267. if (newPosition) {
  89268. return new mouseTarget_1.MouseTarget(null, 13 /* OUTSIDE_EDITOR */, mouseColumn, newPosition);
  89269. }
  89270. }
  89271. var aboveLineNumber = viewLayout.getLineNumberAtVerticalOffset(verticalOffset);
  89272. return new mouseTarget_1.MouseTarget(null, 13 /* OUTSIDE_EDITOR */, mouseColumn, new position_1.Position(aboveLineNumber, 1));
  89273. }
  89274. if (e.posy > editorContent.y + editorContent.height) {
  89275. var verticalOffset = viewLayout.getCurrentScrollTop() + (e.posy - editorContent.y);
  89276. var viewZoneData = mouseTarget_1.HitTestContext.getZoneAtCoord(this._context, verticalOffset);
  89277. if (viewZoneData) {
  89278. var newPosition = this._helpPositionJumpOverViewZone(viewZoneData);
  89279. if (newPosition) {
  89280. return new mouseTarget_1.MouseTarget(null, 13 /* OUTSIDE_EDITOR */, mouseColumn, newPosition);
  89281. }
  89282. }
  89283. var belowLineNumber = viewLayout.getLineNumberAtVerticalOffset(verticalOffset);
  89284. return new mouseTarget_1.MouseTarget(null, 13 /* OUTSIDE_EDITOR */, mouseColumn, new position_1.Position(belowLineNumber, model.getLineMaxColumn(belowLineNumber)));
  89285. }
  89286. var possibleLineNumber = viewLayout.getLineNumberAtVerticalOffset(viewLayout.getCurrentScrollTop() + (e.posy - editorContent.y));
  89287. if (e.posx < editorContent.x) {
  89288. return new mouseTarget_1.MouseTarget(null, 13 /* OUTSIDE_EDITOR */, mouseColumn, new position_1.Position(possibleLineNumber, 1));
  89289. }
  89290. if (e.posx > editorContent.x + editorContent.width) {
  89291. return new mouseTarget_1.MouseTarget(null, 13 /* OUTSIDE_EDITOR */, mouseColumn, new position_1.Position(possibleLineNumber, model.getLineMaxColumn(possibleLineNumber)));
  89292. }
  89293. return null;
  89294. };
  89295. MouseDownOperation.prototype._findMousePosition = function (e, testEventTarget) {
  89296. var positionOutsideEditor = this._getPositionOutsideEditor(e);
  89297. if (positionOutsideEditor) {
  89298. return positionOutsideEditor;
  89299. }
  89300. var t = this._createMouseTarget(e, testEventTarget);
  89301. var hintedPosition = t.position;
  89302. if (!hintedPosition) {
  89303. return null;
  89304. }
  89305. if (t.type === 8 /* CONTENT_VIEW_ZONE */ || t.type === 5 /* GUTTER_VIEW_ZONE */) {
  89306. var newPosition = this._helpPositionJumpOverViewZone(t.detail);
  89307. if (newPosition) {
  89308. return new mouseTarget_1.MouseTarget(t.element, t.type, t.mouseColumn, newPosition, null, t.detail);
  89309. }
  89310. }
  89311. return t;
  89312. };
  89313. MouseDownOperation.prototype._helpPositionJumpOverViewZone = function (viewZoneData) {
  89314. // Force position on view zones to go above or below depending on where selection started from
  89315. var selectionStart = new position_1.Position(this._currentSelection.selectionStartLineNumber, this._currentSelection.selectionStartColumn);
  89316. var positionBefore = viewZoneData.positionBefore;
  89317. var positionAfter = viewZoneData.positionAfter;
  89318. if (positionBefore && positionAfter) {
  89319. if (positionBefore.isBefore(selectionStart)) {
  89320. return positionBefore;
  89321. }
  89322. else {
  89323. return positionAfter;
  89324. }
  89325. }
  89326. return null;
  89327. };
  89328. MouseDownOperation.prototype._dispatchMouse = function (position, inSelectionMode) {
  89329. if (!position.position) {
  89330. return;
  89331. }
  89332. this._viewController.dispatchMouse({
  89333. position: position.position,
  89334. mouseColumn: position.mouseColumn,
  89335. startedOnLineNumbers: this._mouseState.startedOnLineNumbers,
  89336. inSelectionMode: inSelectionMode,
  89337. mouseDownCount: this._mouseState.count,
  89338. altKey: this._mouseState.altKey,
  89339. ctrlKey: this._mouseState.ctrlKey,
  89340. metaKey: this._mouseState.metaKey,
  89341. shiftKey: this._mouseState.shiftKey,
  89342. leftButton: this._mouseState.leftButton,
  89343. middleButton: this._mouseState.middleButton,
  89344. });
  89345. };
  89346. return MouseDownOperation;
  89347. }(lifecycle_1.Disposable));
  89348. var MouseDownState = /** @class */ (function () {
  89349. function MouseDownState() {
  89350. this._altKey = false;
  89351. this._ctrlKey = false;
  89352. this._metaKey = false;
  89353. this._shiftKey = false;
  89354. this._leftButton = false;
  89355. this._middleButton = false;
  89356. this._startedOnLineNumbers = false;
  89357. this._lastMouseDownPosition = null;
  89358. this._lastMouseDownPositionEqualCount = 0;
  89359. this._lastMouseDownCount = 0;
  89360. this._lastSetMouseDownCountTime = 0;
  89361. this.isDragAndDrop = false;
  89362. }
  89363. Object.defineProperty(MouseDownState.prototype, "altKey", {
  89364. get: function () { return this._altKey; },
  89365. enumerable: true,
  89366. configurable: true
  89367. });
  89368. Object.defineProperty(MouseDownState.prototype, "ctrlKey", {
  89369. get: function () { return this._ctrlKey; },
  89370. enumerable: true,
  89371. configurable: true
  89372. });
  89373. Object.defineProperty(MouseDownState.prototype, "metaKey", {
  89374. get: function () { return this._metaKey; },
  89375. enumerable: true,
  89376. configurable: true
  89377. });
  89378. Object.defineProperty(MouseDownState.prototype, "shiftKey", {
  89379. get: function () { return this._shiftKey; },
  89380. enumerable: true,
  89381. configurable: true
  89382. });
  89383. Object.defineProperty(MouseDownState.prototype, "leftButton", {
  89384. get: function () { return this._leftButton; },
  89385. enumerable: true,
  89386. configurable: true
  89387. });
  89388. Object.defineProperty(MouseDownState.prototype, "middleButton", {
  89389. get: function () { return this._middleButton; },
  89390. enumerable: true,
  89391. configurable: true
  89392. });
  89393. Object.defineProperty(MouseDownState.prototype, "startedOnLineNumbers", {
  89394. get: function () { return this._startedOnLineNumbers; },
  89395. enumerable: true,
  89396. configurable: true
  89397. });
  89398. Object.defineProperty(MouseDownState.prototype, "count", {
  89399. get: function () {
  89400. return this._lastMouseDownCount;
  89401. },
  89402. enumerable: true,
  89403. configurable: true
  89404. });
  89405. MouseDownState.prototype.setModifiers = function (source) {
  89406. this._altKey = source.altKey;
  89407. this._ctrlKey = source.ctrlKey;
  89408. this._metaKey = source.metaKey;
  89409. this._shiftKey = source.shiftKey;
  89410. };
  89411. MouseDownState.prototype.setStartButtons = function (source) {
  89412. this._leftButton = source.leftButton;
  89413. this._middleButton = source.middleButton;
  89414. };
  89415. MouseDownState.prototype.setStartedOnLineNumbers = function (startedOnLineNumbers) {
  89416. this._startedOnLineNumbers = startedOnLineNumbers;
  89417. };
  89418. MouseDownState.prototype.trySetCount = function (setMouseDownCount, newMouseDownPosition) {
  89419. // a. Invalidate multiple clicking if too much time has passed (will be hit by IE because the detail field of mouse events contains garbage in IE10)
  89420. var currentTime = (new Date()).getTime();
  89421. if (currentTime - this._lastSetMouseDownCountTime > MouseDownState.CLEAR_MOUSE_DOWN_COUNT_TIME) {
  89422. setMouseDownCount = 1;
  89423. }
  89424. this._lastSetMouseDownCountTime = currentTime;
  89425. // b. Ensure that we don't jump from single click to triple click in one go (will be hit by IE because the detail field of mouse events contains garbage in IE10)
  89426. if (setMouseDownCount > this._lastMouseDownCount + 1) {
  89427. setMouseDownCount = this._lastMouseDownCount + 1;
  89428. }
  89429. // c. Invalidate multiple clicking if the logical position is different
  89430. if (this._lastMouseDownPosition && this._lastMouseDownPosition.equals(newMouseDownPosition)) {
  89431. this._lastMouseDownPositionEqualCount++;
  89432. }
  89433. else {
  89434. this._lastMouseDownPositionEqualCount = 1;
  89435. }
  89436. this._lastMouseDownPosition = newMouseDownPosition;
  89437. // Finally set the lastMouseDownCount
  89438. this._lastMouseDownCount = Math.min(setMouseDownCount, this._lastMouseDownPositionEqualCount);
  89439. };
  89440. MouseDownState.CLEAR_MOUSE_DOWN_COUNT_TIME = 400; // ms
  89441. return MouseDownState;
  89442. }());
  89443. });
  89444. /*---------------------------------------------------------------------------------------------
  89445. * Copyright (c) Microsoft Corporation. All rights reserved.
  89446. * Licensed under the MIT License. See License.txt in the project root for license information.
  89447. *--------------------------------------------------------------------------------------------*/
  89448. define(__m[551/*vs/editor/browser/controller/pointerHandler*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,16/*vs/base/common/platform*/,57/*vs/base/browser/touch*/,2/*vs/base/common/lifecycle*/,550/*vs/editor/browser/controller/mouseHandler*/,141/*vs/editor/browser/editorDom*/,88/*vs/base/browser/canIUse*/]), function (require, exports, dom, platform, touch_1, lifecycle_1, mouseHandler_1, editorDom_1, canIUse_1) {
  89449. "use strict";
  89450. Object.defineProperty(exports, "__esModule", { value: true });
  89451. function gestureChangeEventMerger(lastEvent, currentEvent) {
  89452. var r = {
  89453. translationY: currentEvent.translationY,
  89454. translationX: currentEvent.translationX
  89455. };
  89456. if (lastEvent) {
  89457. r.translationY += lastEvent.translationY;
  89458. r.translationX += lastEvent.translationX;
  89459. }
  89460. return r;
  89461. }
  89462. /**
  89463. * Basically IE10 and IE11
  89464. */
  89465. var MsPointerHandler = /** @class */ (function (_super) {
  89466. __extends(MsPointerHandler, _super);
  89467. function MsPointerHandler(context, viewController, viewHelper) {
  89468. var _this = _super.call(this, context, viewController, viewHelper) || this;
  89469. _this.viewHelper.linesContentDomNode.style.msTouchAction = 'none';
  89470. _this.viewHelper.linesContentDomNode.style.msContentZooming = 'none';
  89471. // TODO@Alex -> this expects that the view is added in 100 ms, might not be the case
  89472. // This handler should be added when the dom node is in the dom tree
  89473. _this._installGestureHandlerTimeout = window.setTimeout(function () {
  89474. _this._installGestureHandlerTimeout = -1;
  89475. if (window.MSGesture) {
  89476. var touchGesture_1 = new MSGesture();
  89477. var penGesture_1 = new MSGesture();
  89478. touchGesture_1.target = _this.viewHelper.linesContentDomNode;
  89479. penGesture_1.target = _this.viewHelper.linesContentDomNode;
  89480. _this.viewHelper.linesContentDomNode.addEventListener('MSPointerDown', function (e) {
  89481. // Circumvent IE11 breaking change in e.pointerType & TypeScript's stale definitions
  89482. var pointerType = e.pointerType;
  89483. if (pointerType === (e.MSPOINTER_TYPE_MOUSE || 'mouse')) {
  89484. _this._lastPointerType = 'mouse';
  89485. return;
  89486. }
  89487. else if (pointerType === (e.MSPOINTER_TYPE_TOUCH || 'touch')) {
  89488. _this._lastPointerType = 'touch';
  89489. touchGesture_1.addPointer(e.pointerId);
  89490. }
  89491. else {
  89492. _this._lastPointerType = 'pen';
  89493. penGesture_1.addPointer(e.pointerId);
  89494. }
  89495. });
  89496. _this._register(dom.addDisposableThrottledListener(_this.viewHelper.linesContentDomNode, 'MSGestureChange', function (e) { return _this._onGestureChange(e); }, gestureChangeEventMerger));
  89497. _this._register(dom.addDisposableListener(_this.viewHelper.linesContentDomNode, 'MSGestureTap', function (e) { return _this._onCaptureGestureTap(e); }, true));
  89498. }
  89499. }, 100);
  89500. _this._lastPointerType = 'mouse';
  89501. return _this;
  89502. }
  89503. MsPointerHandler.prototype._onMouseDown = function (e) {
  89504. if (this._lastPointerType === 'mouse') {
  89505. _super.prototype._onMouseDown.call(this, e);
  89506. }
  89507. };
  89508. MsPointerHandler.prototype._onCaptureGestureTap = function (rawEvent) {
  89509. var _this = this;
  89510. var e = new editorDom_1.EditorMouseEvent(rawEvent, this.viewHelper.viewDomNode);
  89511. var t = this._createMouseTarget(e, false);
  89512. if (t.position) {
  89513. this.viewController.moveTo(t.position);
  89514. }
  89515. // IE does not want to focus when coming in from the browser's address bar
  89516. if (e.browserEvent.fromElement) {
  89517. e.preventDefault();
  89518. this.viewHelper.focusTextArea();
  89519. }
  89520. else {
  89521. // TODO@Alex -> cancel this is focus is lost
  89522. setTimeout(function () {
  89523. _this.viewHelper.focusTextArea();
  89524. });
  89525. }
  89526. };
  89527. MsPointerHandler.prototype._onGestureChange = function (e) {
  89528. this._context.viewLayout.deltaScrollNow(-e.translationX, -e.translationY);
  89529. };
  89530. MsPointerHandler.prototype.dispose = function () {
  89531. window.clearTimeout(this._installGestureHandlerTimeout);
  89532. _super.prototype.dispose.call(this);
  89533. };
  89534. return MsPointerHandler;
  89535. }(mouseHandler_1.MouseHandler));
  89536. /**
  89537. * Basically Edge but should be modified to handle any pointerEnabled, even without support of MSGesture
  89538. */
  89539. var StandardPointerHandler = /** @class */ (function (_super) {
  89540. __extends(StandardPointerHandler, _super);
  89541. function StandardPointerHandler(context, viewController, viewHelper) {
  89542. var _this = _super.call(this, context, viewController, viewHelper) || this;
  89543. _this.viewHelper.linesContentDomNode.style.touchAction = 'none';
  89544. // TODO@Alex -> this expects that the view is added in 100 ms, might not be the case
  89545. // This handler should be added when the dom node is in the dom tree
  89546. _this._installGestureHandlerTimeout = window.setTimeout(function () {
  89547. _this._installGestureHandlerTimeout = -1;
  89548. // TODO@Alex: replace the usage of MSGesture here with something that works across all browsers
  89549. if (window.MSGesture) {
  89550. var touchGesture_2 = new MSGesture();
  89551. var penGesture_2 = new MSGesture();
  89552. touchGesture_2.target = _this.viewHelper.linesContentDomNode;
  89553. penGesture_2.target = _this.viewHelper.linesContentDomNode;
  89554. _this.viewHelper.linesContentDomNode.addEventListener('pointerdown', function (e) {
  89555. var pointerType = e.pointerType;
  89556. if (pointerType === 'mouse') {
  89557. _this._lastPointerType = 'mouse';
  89558. return;
  89559. }
  89560. else if (pointerType === 'touch') {
  89561. _this._lastPointerType = 'touch';
  89562. touchGesture_2.addPointer(e.pointerId);
  89563. }
  89564. else {
  89565. _this._lastPointerType = 'pen';
  89566. penGesture_2.addPointer(e.pointerId);
  89567. }
  89568. });
  89569. _this._register(dom.addDisposableThrottledListener(_this.viewHelper.linesContentDomNode, 'MSGestureChange', function (e) { return _this._onGestureChange(e); }, gestureChangeEventMerger));
  89570. _this._register(dom.addDisposableListener(_this.viewHelper.linesContentDomNode, 'MSGestureTap', function (e) { return _this._onCaptureGestureTap(e); }, true));
  89571. }
  89572. }, 100);
  89573. _this._lastPointerType = 'mouse';
  89574. return _this;
  89575. }
  89576. StandardPointerHandler.prototype._onMouseDown = function (e) {
  89577. if (this._lastPointerType === 'mouse') {
  89578. _super.prototype._onMouseDown.call(this, e);
  89579. }
  89580. };
  89581. StandardPointerHandler.prototype._onCaptureGestureTap = function (rawEvent) {
  89582. var _this = this;
  89583. var e = new editorDom_1.EditorMouseEvent(rawEvent, this.viewHelper.viewDomNode);
  89584. var t = this._createMouseTarget(e, false);
  89585. if (t.position) {
  89586. this.viewController.moveTo(t.position);
  89587. }
  89588. // IE does not want to focus when coming in from the browser's address bar
  89589. if (e.browserEvent.fromElement) {
  89590. e.preventDefault();
  89591. this.viewHelper.focusTextArea();
  89592. }
  89593. else {
  89594. // TODO@Alex -> cancel this is focus is lost
  89595. setTimeout(function () {
  89596. _this.viewHelper.focusTextArea();
  89597. });
  89598. }
  89599. };
  89600. StandardPointerHandler.prototype._onGestureChange = function (e) {
  89601. this._context.viewLayout.deltaScrollNow(-e.translationX, -e.translationY);
  89602. };
  89603. StandardPointerHandler.prototype.dispose = function () {
  89604. window.clearTimeout(this._installGestureHandlerTimeout);
  89605. _super.prototype.dispose.call(this);
  89606. };
  89607. return StandardPointerHandler;
  89608. }(mouseHandler_1.MouseHandler));
  89609. /**
  89610. * Currently only tested on iOS 13/ iPadOS.
  89611. */
  89612. var PointerEventHandler = /** @class */ (function (_super) {
  89613. __extends(PointerEventHandler, _super);
  89614. function PointerEventHandler(context, viewController, viewHelper) {
  89615. var _this = _super.call(this, context, viewController, viewHelper) || this;
  89616. _this._register(touch_1.Gesture.addTarget(_this.viewHelper.linesContentDomNode));
  89617. _this._register(dom.addDisposableListener(_this.viewHelper.linesContentDomNode, touch_1.EventType.Tap, function (e) { return _this.onTap(e); }));
  89618. _this._register(dom.addDisposableListener(_this.viewHelper.linesContentDomNode, touch_1.EventType.Change, function (e) { return _this.onChange(e); }));
  89619. _this._register(dom.addDisposableListener(_this.viewHelper.linesContentDomNode, touch_1.EventType.Contextmenu, function (e) { return _this._onContextMenu(new editorDom_1.EditorMouseEvent(e, _this.viewHelper.viewDomNode), false); }));
  89620. _this._lastPointerType = 'mouse';
  89621. _this._register(dom.addDisposableListener(_this.viewHelper.linesContentDomNode, 'pointerdown', function (e) {
  89622. var pointerType = e.pointerType;
  89623. if (pointerType === 'mouse') {
  89624. _this._lastPointerType = 'mouse';
  89625. return;
  89626. }
  89627. else if (pointerType === 'touch') {
  89628. _this._lastPointerType = 'touch';
  89629. }
  89630. else {
  89631. _this._lastPointerType = 'pen';
  89632. }
  89633. }));
  89634. // PonterEvents
  89635. var pointerEvents = new editorDom_1.EditorPointerEventFactory(_this.viewHelper.viewDomNode);
  89636. _this._register(pointerEvents.onPointerMoveThrottled(_this.viewHelper.viewDomNode, function (e) { return _this._onMouseMove(e); }, mouseHandler_1.createMouseMoveEventMerger(_this.mouseTargetFactory), mouseHandler_1.MouseHandler.MOUSE_MOVE_MINIMUM_TIME));
  89637. _this._register(pointerEvents.onPointerUp(_this.viewHelper.viewDomNode, function (e) { return _this._onMouseUp(e); }));
  89638. _this._register(pointerEvents.onPointerLeave(_this.viewHelper.viewDomNode, function (e) { return _this._onMouseLeave(e); }));
  89639. _this._register(pointerEvents.onPointerDown(_this.viewHelper.viewDomNode, function (e) { return _this._onMouseDown(e); }));
  89640. return _this;
  89641. }
  89642. PointerEventHandler.prototype.onTap = function (event) {
  89643. if (!event.initialTarget || !this.viewHelper.linesContentDomNode.contains(event.initialTarget)) {
  89644. return;
  89645. }
  89646. event.preventDefault();
  89647. this.viewHelper.focusTextArea();
  89648. var target = this._createMouseTarget(new editorDom_1.EditorMouseEvent(event, this.viewHelper.viewDomNode), false);
  89649. if (target.position) {
  89650. // this.viewController.moveTo(target.position);
  89651. this.viewController.dispatchMouse({
  89652. position: target.position,
  89653. mouseColumn: target.position.column,
  89654. startedOnLineNumbers: false,
  89655. mouseDownCount: event.tapCount,
  89656. inSelectionMode: false,
  89657. altKey: false,
  89658. ctrlKey: false,
  89659. metaKey: false,
  89660. shiftKey: false,
  89661. leftButton: false,
  89662. middleButton: false,
  89663. });
  89664. }
  89665. };
  89666. PointerEventHandler.prototype.onChange = function (e) {
  89667. if (this._lastPointerType === 'touch') {
  89668. this._context.viewLayout.deltaScrollNow(-e.translationX, -e.translationY);
  89669. }
  89670. };
  89671. PointerEventHandler.prototype._onMouseDown = function (e) {
  89672. if (e.target && this.viewHelper.linesContentDomNode.contains(e.target) && this._lastPointerType === 'touch') {
  89673. return;
  89674. }
  89675. _super.prototype._onMouseDown.call(this, e);
  89676. };
  89677. return PointerEventHandler;
  89678. }(mouseHandler_1.MouseHandler));
  89679. exports.PointerEventHandler = PointerEventHandler;
  89680. var TouchHandler = /** @class */ (function (_super) {
  89681. __extends(TouchHandler, _super);
  89682. function TouchHandler(context, viewController, viewHelper) {
  89683. var _this = _super.call(this, context, viewController, viewHelper) || this;
  89684. _this._register(touch_1.Gesture.addTarget(_this.viewHelper.linesContentDomNode));
  89685. _this._register(dom.addDisposableListener(_this.viewHelper.linesContentDomNode, touch_1.EventType.Tap, function (e) { return _this.onTap(e); }));
  89686. _this._register(dom.addDisposableListener(_this.viewHelper.linesContentDomNode, touch_1.EventType.Change, function (e) { return _this.onChange(e); }));
  89687. _this._register(dom.addDisposableListener(_this.viewHelper.linesContentDomNode, touch_1.EventType.Contextmenu, function (e) { return _this._onContextMenu(new editorDom_1.EditorMouseEvent(e, _this.viewHelper.viewDomNode), false); }));
  89688. return _this;
  89689. }
  89690. TouchHandler.prototype.onTap = function (event) {
  89691. event.preventDefault();
  89692. this.viewHelper.focusTextArea();
  89693. var target = this._createMouseTarget(new editorDom_1.EditorMouseEvent(event, this.viewHelper.viewDomNode), false);
  89694. if (target.position) {
  89695. this.viewController.moveTo(target.position);
  89696. }
  89697. };
  89698. TouchHandler.prototype.onChange = function (e) {
  89699. this._context.viewLayout.deltaScrollNow(-e.translationX, -e.translationY);
  89700. };
  89701. return TouchHandler;
  89702. }(mouseHandler_1.MouseHandler));
  89703. var PointerHandler = /** @class */ (function (_super) {
  89704. __extends(PointerHandler, _super);
  89705. function PointerHandler(context, viewController, viewHelper) {
  89706. var _this = _super.call(this) || this;
  89707. if (window.navigator.msPointerEnabled) {
  89708. _this.handler = _this._register(new MsPointerHandler(context, viewController, viewHelper));
  89709. }
  89710. else if ((platform.isIOS && canIUse_1.BrowserFeatures.pointerEvents)) {
  89711. _this.handler = _this._register(new PointerEventHandler(context, viewController, viewHelper));
  89712. }
  89713. else if (window.TouchEvent) {
  89714. _this.handler = _this._register(new TouchHandler(context, viewController, viewHelper));
  89715. }
  89716. else if (window.navigator.pointerEnabled || window.PointerEvent) {
  89717. _this.handler = _this._register(new StandardPointerHandler(context, viewController, viewHelper));
  89718. }
  89719. else {
  89720. _this.handler = _this._register(new mouseHandler_1.MouseHandler(context, viewController, viewHelper));
  89721. }
  89722. return _this;
  89723. }
  89724. PointerHandler.prototype.getTargetAtClientPoint = function (clientX, clientY) {
  89725. return this.handler.getTargetAtClientPoint(clientX, clientY);
  89726. };
  89727. return PointerHandler;
  89728. }(lifecycle_1.Disposable));
  89729. exports.PointerHandler = PointerHandler;
  89730. });
  89731. /*---------------------------------------------------------------------------------------------
  89732. * Copyright (c) Microsoft Corporation. All rights reserved.
  89733. * Licensed under the MIT License. See License.txt in the project root for license information.
  89734. *--------------------------------------------------------------------------------------------*/
  89735. define(__m[228/*vs/editor/browser/view/viewOutgoingEvents*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,166/*vs/editor/browser/controller/mouseTarget*/]), function (require, exports, lifecycle_1, mouseTarget_1) {
  89736. "use strict";
  89737. Object.defineProperty(exports, "__esModule", { value: true });
  89738. var ViewOutgoingEvents = /** @class */ (function (_super) {
  89739. __extends(ViewOutgoingEvents, _super);
  89740. function ViewOutgoingEvents(viewModel) {
  89741. var _this = _super.call(this) || this;
  89742. _this.onDidContentSizeChange = null;
  89743. _this.onDidScroll = null;
  89744. _this.onDidGainFocus = null;
  89745. _this.onDidLoseFocus = null;
  89746. _this.onKeyDown = null;
  89747. _this.onKeyUp = null;
  89748. _this.onContextMenu = null;
  89749. _this.onMouseMove = null;
  89750. _this.onMouseLeave = null;
  89751. _this.onMouseUp = null;
  89752. _this.onMouseDown = null;
  89753. _this.onMouseDrag = null;
  89754. _this.onMouseDrop = null;
  89755. _this.onMouseWheel = null;
  89756. _this._viewModel = viewModel;
  89757. return _this;
  89758. }
  89759. ViewOutgoingEvents.prototype.emitContentSizeChange = function (e) {
  89760. if (this.onDidContentSizeChange) {
  89761. this.onDidContentSizeChange(e);
  89762. }
  89763. };
  89764. ViewOutgoingEvents.prototype.emitScrollChanged = function (e) {
  89765. if (this.onDidScroll) {
  89766. this.onDidScroll(e);
  89767. }
  89768. };
  89769. ViewOutgoingEvents.prototype.emitViewFocusGained = function () {
  89770. if (this.onDidGainFocus) {
  89771. this.onDidGainFocus(undefined);
  89772. }
  89773. };
  89774. ViewOutgoingEvents.prototype.emitViewFocusLost = function () {
  89775. if (this.onDidLoseFocus) {
  89776. this.onDidLoseFocus(undefined);
  89777. }
  89778. };
  89779. ViewOutgoingEvents.prototype.emitKeyDown = function (e) {
  89780. if (this.onKeyDown) {
  89781. this.onKeyDown(e);
  89782. }
  89783. };
  89784. ViewOutgoingEvents.prototype.emitKeyUp = function (e) {
  89785. if (this.onKeyUp) {
  89786. this.onKeyUp(e);
  89787. }
  89788. };
  89789. ViewOutgoingEvents.prototype.emitContextMenu = function (e) {
  89790. if (this.onContextMenu) {
  89791. this.onContextMenu(this._convertViewToModelMouseEvent(e));
  89792. }
  89793. };
  89794. ViewOutgoingEvents.prototype.emitMouseMove = function (e) {
  89795. if (this.onMouseMove) {
  89796. this.onMouseMove(this._convertViewToModelMouseEvent(e));
  89797. }
  89798. };
  89799. ViewOutgoingEvents.prototype.emitMouseLeave = function (e) {
  89800. if (this.onMouseLeave) {
  89801. this.onMouseLeave(this._convertViewToModelMouseEvent(e));
  89802. }
  89803. };
  89804. ViewOutgoingEvents.prototype.emitMouseUp = function (e) {
  89805. if (this.onMouseUp) {
  89806. this.onMouseUp(this._convertViewToModelMouseEvent(e));
  89807. }
  89808. };
  89809. ViewOutgoingEvents.prototype.emitMouseDown = function (e) {
  89810. if (this.onMouseDown) {
  89811. this.onMouseDown(this._convertViewToModelMouseEvent(e));
  89812. }
  89813. };
  89814. ViewOutgoingEvents.prototype.emitMouseDrag = function (e) {
  89815. if (this.onMouseDrag) {
  89816. this.onMouseDrag(this._convertViewToModelMouseEvent(e));
  89817. }
  89818. };
  89819. ViewOutgoingEvents.prototype.emitMouseDrop = function (e) {
  89820. if (this.onMouseDrop) {
  89821. this.onMouseDrop(this._convertViewToModelMouseEvent(e));
  89822. }
  89823. };
  89824. ViewOutgoingEvents.prototype.emitMouseWheel = function (e) {
  89825. if (this.onMouseWheel) {
  89826. this.onMouseWheel(e);
  89827. }
  89828. };
  89829. ViewOutgoingEvents.prototype._convertViewToModelMouseEvent = function (e) {
  89830. if (e.target) {
  89831. return {
  89832. event: e.event,
  89833. target: this._convertViewToModelMouseTarget(e.target)
  89834. };
  89835. }
  89836. return e;
  89837. };
  89838. ViewOutgoingEvents.prototype._convertViewToModelMouseTarget = function (target) {
  89839. return ViewOutgoingEvents.convertViewToModelMouseTarget(target, this._viewModel.coordinatesConverter);
  89840. };
  89841. ViewOutgoingEvents.convertViewToModelMouseTarget = function (target, coordinatesConverter) {
  89842. return new ExternalMouseTarget(target.element, target.type, target.mouseColumn, target.position ? coordinatesConverter.convertViewPositionToModelPosition(target.position) : null, target.range ? coordinatesConverter.convertViewRangeToModelRange(target.range) : null, target.detail);
  89843. };
  89844. return ViewOutgoingEvents;
  89845. }(lifecycle_1.Disposable));
  89846. exports.ViewOutgoingEvents = ViewOutgoingEvents;
  89847. var ExternalMouseTarget = /** @class */ (function () {
  89848. function ExternalMouseTarget(element, type, mouseColumn, position, range, detail) {
  89849. this.element = element;
  89850. this.type = type;
  89851. this.mouseColumn = mouseColumn;
  89852. this.position = position;
  89853. this.range = range;
  89854. this.detail = detail;
  89855. }
  89856. ExternalMouseTarget.prototype.toString = function () {
  89857. return mouseTarget_1.MouseTarget.toString(this);
  89858. };
  89859. return ExternalMouseTarget;
  89860. }());
  89861. });
  89862. /*---------------------------------------------------------------------------------------------
  89863. * Copyright (c) Microsoft Corporation. All rights reserved.
  89864. * Licensed under the MIT License. See License.txt in the project root for license information.
  89865. *--------------------------------------------------------------------------------------------*/
  89866. define(__m[552/*vs/editor/browser/viewParts/lines/viewLines*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,60/*vs/editor/browser/config/configuration*/,143/*vs/editor/browser/view/viewLayer*/,37/*vs/editor/browser/view/viewPart*/,227/*vs/editor/browser/viewParts/lines/viewLine*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,91/*vs/editor/common/view/renderingContext*/,290/*vs/css!vs/editor/browser/viewParts/lines/viewLines*/]), function (require, exports, async_1, configuration_1, viewLayer_1, viewPart_1, viewLine_1, position_1, range_1, renderingContext_1) {
  89867. "use strict";
  89868. Object.defineProperty(exports, "__esModule", { value: true });
  89869. var LastRenderedData = /** @class */ (function () {
  89870. function LastRenderedData() {
  89871. this._currentVisibleRange = new range_1.Range(1, 1, 1, 1);
  89872. }
  89873. LastRenderedData.prototype.getCurrentVisibleRange = function () {
  89874. return this._currentVisibleRange;
  89875. };
  89876. LastRenderedData.prototype.setCurrentVisibleRange = function (currentVisibleRange) {
  89877. this._currentVisibleRange = currentVisibleRange;
  89878. };
  89879. return LastRenderedData;
  89880. }());
  89881. var HorizontalRevealRequest = /** @class */ (function () {
  89882. function HorizontalRevealRequest(lineNumber, startColumn, endColumn, startScrollTop, stopScrollTop, scrollType) {
  89883. this.lineNumber = lineNumber;
  89884. this.startColumn = startColumn;
  89885. this.endColumn = endColumn;
  89886. this.startScrollTop = startScrollTop;
  89887. this.stopScrollTop = stopScrollTop;
  89888. this.scrollType = scrollType;
  89889. }
  89890. return HorizontalRevealRequest;
  89891. }());
  89892. var ViewLines = /** @class */ (function (_super) {
  89893. __extends(ViewLines, _super);
  89894. function ViewLines(context, linesContent) {
  89895. var _this = _super.call(this, context) || this;
  89896. _this._linesContent = linesContent;
  89897. _this._textRangeRestingSpot = document.createElement('div');
  89898. _this._visibleLines = new viewLayer_1.VisibleLinesCollection(_this);
  89899. _this.domNode = _this._visibleLines.domNode;
  89900. var conf = _this._context.configuration;
  89901. var options = _this._context.configuration.options;
  89902. var fontInfo = options.get(34 /* fontInfo */);
  89903. var wrappingInfo = options.get(108 /* wrappingInfo */);
  89904. _this._lineHeight = options.get(49 /* lineHeight */);
  89905. _this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
  89906. _this._isViewportWrapping = wrappingInfo.isViewportWrapping;
  89907. _this._revealHorizontalRightPadding = options.get(75 /* revealHorizontalRightPadding */);
  89908. _this._cursorSurroundingLines = options.get(19 /* cursorSurroundingLines */);
  89909. _this._cursorSurroundingLinesStyle = options.get(20 /* cursorSurroundingLinesStyle */);
  89910. _this._canUseLayerHinting = !options.get(22 /* disableLayerHinting */);
  89911. _this._viewLineOptions = new viewLine_1.ViewLineOptions(conf, _this._context.theme.type);
  89912. viewPart_1.PartFingerprints.write(_this.domNode, 7 /* ViewLines */);
  89913. _this.domNode.setClassName('view-lines');
  89914. configuration_1.Configuration.applyFontInfo(_this.domNode, fontInfo);
  89915. // --- width & height
  89916. _this._maxLineWidth = 0;
  89917. _this._asyncUpdateLineWidths = new async_1.RunOnceScheduler(function () {
  89918. _this._updateLineWidthsSlow();
  89919. }, 200);
  89920. _this._lastRenderedData = new LastRenderedData();
  89921. _this._horizontalRevealRequest = null;
  89922. return _this;
  89923. }
  89924. ViewLines.prototype.dispose = function () {
  89925. this._asyncUpdateLineWidths.dispose();
  89926. _super.prototype.dispose.call(this);
  89927. };
  89928. ViewLines.prototype.getDomNode = function () {
  89929. return this.domNode;
  89930. };
  89931. // ---- begin IVisibleLinesHost
  89932. ViewLines.prototype.createVisibleLine = function () {
  89933. return new viewLine_1.ViewLine(this._viewLineOptions);
  89934. };
  89935. // ---- end IVisibleLinesHost
  89936. // ---- begin view event handlers
  89937. ViewLines.prototype.onConfigurationChanged = function (e) {
  89938. this._visibleLines.onConfigurationChanged(e);
  89939. if (e.hasChanged(108 /* wrappingInfo */)) {
  89940. this._maxLineWidth = 0;
  89941. }
  89942. var options = this._context.configuration.options;
  89943. var fontInfo = options.get(34 /* fontInfo */);
  89944. var wrappingInfo = options.get(108 /* wrappingInfo */);
  89945. this._lineHeight = options.get(49 /* lineHeight */);
  89946. this._typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
  89947. this._isViewportWrapping = wrappingInfo.isViewportWrapping;
  89948. this._revealHorizontalRightPadding = options.get(75 /* revealHorizontalRightPadding */);
  89949. this._cursorSurroundingLines = options.get(19 /* cursorSurroundingLines */);
  89950. this._cursorSurroundingLinesStyle = options.get(20 /* cursorSurroundingLinesStyle */);
  89951. this._canUseLayerHinting = !options.get(22 /* disableLayerHinting */);
  89952. configuration_1.Configuration.applyFontInfo(this.domNode, fontInfo);
  89953. this._onOptionsMaybeChanged();
  89954. if (e.hasChanged(107 /* layoutInfo */)) {
  89955. this._maxLineWidth = 0;
  89956. }
  89957. return true;
  89958. };
  89959. ViewLines.prototype._onOptionsMaybeChanged = function () {
  89960. var conf = this._context.configuration;
  89961. var newViewLineOptions = new viewLine_1.ViewLineOptions(conf, this._context.theme.type);
  89962. if (!this._viewLineOptions.equals(newViewLineOptions)) {
  89963. this._viewLineOptions = newViewLineOptions;
  89964. var startLineNumber = this._visibleLines.getStartLineNumber();
  89965. var endLineNumber = this._visibleLines.getEndLineNumber();
  89966. for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
  89967. var line = this._visibleLines.getVisibleLine(lineNumber);
  89968. line.onOptionsChanged(this._viewLineOptions);
  89969. }
  89970. return true;
  89971. }
  89972. return false;
  89973. };
  89974. ViewLines.prototype.onCursorStateChanged = function (e) {
  89975. var rendStartLineNumber = this._visibleLines.getStartLineNumber();
  89976. var rendEndLineNumber = this._visibleLines.getEndLineNumber();
  89977. var r = false;
  89978. for (var lineNumber = rendStartLineNumber; lineNumber <= rendEndLineNumber; lineNumber++) {
  89979. r = this._visibleLines.getVisibleLine(lineNumber).onSelectionChanged() || r;
  89980. }
  89981. return r;
  89982. };
  89983. ViewLines.prototype.onDecorationsChanged = function (e) {
  89984. if (true /*e.inlineDecorationsChanged*/) {
  89985. var rendStartLineNumber = this._visibleLines.getStartLineNumber();
  89986. var rendEndLineNumber = this._visibleLines.getEndLineNumber();
  89987. for (var lineNumber = rendStartLineNumber; lineNumber <= rendEndLineNumber; lineNumber++) {
  89988. this._visibleLines.getVisibleLine(lineNumber).onDecorationsChanged();
  89989. }
  89990. }
  89991. return true;
  89992. };
  89993. ViewLines.prototype.onFlushed = function (e) {
  89994. var shouldRender = this._visibleLines.onFlushed(e);
  89995. this._maxLineWidth = 0;
  89996. return shouldRender;
  89997. };
  89998. ViewLines.prototype.onLinesChanged = function (e) {
  89999. return this._visibleLines.onLinesChanged(e);
  90000. };
  90001. ViewLines.prototype.onLinesDeleted = function (e) {
  90002. return this._visibleLines.onLinesDeleted(e);
  90003. };
  90004. ViewLines.prototype.onLinesInserted = function (e) {
  90005. return this._visibleLines.onLinesInserted(e);
  90006. };
  90007. ViewLines.prototype.onRevealRangeRequest = function (e) {
  90008. // Using the future viewport here in order to handle multiple
  90009. // incoming reveal range requests that might all desire to be animated
  90010. var desiredScrollTop = this._computeScrollTopToRevealRange(this._context.viewLayout.getFutureViewport(), e.source, e.range, e.verticalType);
  90011. // validate the new desired scroll top
  90012. var newScrollPosition = this._context.viewLayout.validateScrollPosition({ scrollTop: desiredScrollTop });
  90013. if (e.revealHorizontal) {
  90014. if (e.range.startLineNumber !== e.range.endLineNumber) {
  90015. // Two or more lines? => scroll to base (That's how you see most of the two lines)
  90016. newScrollPosition = {
  90017. scrollTop: newScrollPosition.scrollTop,
  90018. scrollLeft: 0
  90019. };
  90020. }
  90021. else {
  90022. // We don't necessarily know the horizontal offset of this range since the line might not be in the view...
  90023. this._horizontalRevealRequest = new HorizontalRevealRequest(e.range.startLineNumber, e.range.startColumn, e.range.endColumn, this._context.viewLayout.getCurrentScrollTop(), newScrollPosition.scrollTop, e.scrollType);
  90024. }
  90025. }
  90026. else {
  90027. this._horizontalRevealRequest = null;
  90028. }
  90029. var scrollTopDelta = Math.abs(this._context.viewLayout.getCurrentScrollTop() - newScrollPosition.scrollTop);
  90030. if (e.scrollType === 0 /* Smooth */ && scrollTopDelta > this._lineHeight) {
  90031. this._context.viewLayout.setScrollPositionSmooth(newScrollPosition);
  90032. }
  90033. else {
  90034. this._context.viewLayout.setScrollPositionNow(newScrollPosition);
  90035. }
  90036. return true;
  90037. };
  90038. ViewLines.prototype.onScrollChanged = function (e) {
  90039. if (this._horizontalRevealRequest && e.scrollLeftChanged) {
  90040. // cancel any outstanding horizontal reveal request if someone else scrolls horizontally.
  90041. this._horizontalRevealRequest = null;
  90042. }
  90043. if (this._horizontalRevealRequest && e.scrollTopChanged) {
  90044. var min = Math.min(this._horizontalRevealRequest.startScrollTop, this._horizontalRevealRequest.stopScrollTop);
  90045. var max = Math.max(this._horizontalRevealRequest.startScrollTop, this._horizontalRevealRequest.stopScrollTop);
  90046. if (e.scrollTop < min || e.scrollTop > max) {
  90047. // cancel any outstanding horizontal reveal request if someone else scrolls vertically.
  90048. this._horizontalRevealRequest = null;
  90049. }
  90050. }
  90051. this.domNode.setWidth(e.scrollWidth);
  90052. return this._visibleLines.onScrollChanged(e) || true;
  90053. };
  90054. ViewLines.prototype.onTokensChanged = function (e) {
  90055. return this._visibleLines.onTokensChanged(e);
  90056. };
  90057. ViewLines.prototype.onZonesChanged = function (e) {
  90058. this._context.viewLayout.onMaxLineWidthChanged(this._maxLineWidth);
  90059. return this._visibleLines.onZonesChanged(e);
  90060. };
  90061. ViewLines.prototype.onThemeChanged = function (e) {
  90062. return this._onOptionsMaybeChanged();
  90063. };
  90064. // ---- end view event handlers
  90065. // ----------- HELPERS FOR OTHERS
  90066. ViewLines.prototype.getPositionFromDOMInfo = function (spanNode, offset) {
  90067. var viewLineDomNode = this._getViewLineDomNode(spanNode);
  90068. if (viewLineDomNode === null) {
  90069. // Couldn't find view line node
  90070. return null;
  90071. }
  90072. var lineNumber = this._getLineNumberFor(viewLineDomNode);
  90073. if (lineNumber === -1) {
  90074. // Couldn't find view line node
  90075. return null;
  90076. }
  90077. if (lineNumber < 1 || lineNumber > this._context.model.getLineCount()) {
  90078. // lineNumber is outside range
  90079. return null;
  90080. }
  90081. if (this._context.model.getLineMaxColumn(lineNumber) === 1) {
  90082. // Line is empty
  90083. return new position_1.Position(lineNumber, 1);
  90084. }
  90085. var rendStartLineNumber = this._visibleLines.getStartLineNumber();
  90086. var rendEndLineNumber = this._visibleLines.getEndLineNumber();
  90087. if (lineNumber < rendStartLineNumber || lineNumber > rendEndLineNumber) {
  90088. // Couldn't find line
  90089. return null;
  90090. }
  90091. var column = this._visibleLines.getVisibleLine(lineNumber).getColumnOfNodeOffset(lineNumber, spanNode, offset);
  90092. var minColumn = this._context.model.getLineMinColumn(lineNumber);
  90093. if (column < minColumn) {
  90094. column = minColumn;
  90095. }
  90096. return new position_1.Position(lineNumber, column);
  90097. };
  90098. ViewLines.prototype._getViewLineDomNode = function (node) {
  90099. while (node && node.nodeType === 1) {
  90100. if (node.className === viewLine_1.ViewLine.CLASS_NAME) {
  90101. return node;
  90102. }
  90103. node = node.parentElement;
  90104. }
  90105. return null;
  90106. };
  90107. /**
  90108. * @returns the line number of this view line dom node.
  90109. */
  90110. ViewLines.prototype._getLineNumberFor = function (domNode) {
  90111. var startLineNumber = this._visibleLines.getStartLineNumber();
  90112. var endLineNumber = this._visibleLines.getEndLineNumber();
  90113. for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
  90114. var line = this._visibleLines.getVisibleLine(lineNumber);
  90115. if (domNode === line.getDomNode()) {
  90116. return lineNumber;
  90117. }
  90118. }
  90119. return -1;
  90120. };
  90121. ViewLines.prototype.getLineWidth = function (lineNumber) {
  90122. var rendStartLineNumber = this._visibleLines.getStartLineNumber();
  90123. var rendEndLineNumber = this._visibleLines.getEndLineNumber();
  90124. if (lineNumber < rendStartLineNumber || lineNumber > rendEndLineNumber) {
  90125. // Couldn't find line
  90126. return -1;
  90127. }
  90128. return this._visibleLines.getVisibleLine(lineNumber).getWidth();
  90129. };
  90130. ViewLines.prototype.linesVisibleRangesForRange = function (_range, includeNewLines) {
  90131. if (this.shouldRender()) {
  90132. // Cannot read from the DOM because it is dirty
  90133. // i.e. the model & the dom are out of sync, so I'd be reading something stale
  90134. return null;
  90135. }
  90136. var originalEndLineNumber = _range.endLineNumber;
  90137. var range = range_1.Range.intersectRanges(_range, this._lastRenderedData.getCurrentVisibleRange());
  90138. if (!range) {
  90139. return null;
  90140. }
  90141. var visibleRanges = [], visibleRangesLen = 0;
  90142. var domReadingContext = new viewLine_1.DomReadingContext(this.domNode.domNode, this._textRangeRestingSpot);
  90143. var nextLineModelLineNumber = 0;
  90144. if (includeNewLines) {
  90145. nextLineModelLineNumber = this._context.model.coordinatesConverter.convertViewPositionToModelPosition(new position_1.Position(range.startLineNumber, 1)).lineNumber;
  90146. }
  90147. var rendStartLineNumber = this._visibleLines.getStartLineNumber();
  90148. var rendEndLineNumber = this._visibleLines.getEndLineNumber();
  90149. for (var lineNumber = range.startLineNumber; lineNumber <= range.endLineNumber; lineNumber++) {
  90150. if (lineNumber < rendStartLineNumber || lineNumber > rendEndLineNumber) {
  90151. continue;
  90152. }
  90153. var startColumn = lineNumber === range.startLineNumber ? range.startColumn : 1;
  90154. var endColumn = lineNumber === range.endLineNumber ? range.endColumn : this._context.model.getLineMaxColumn(lineNumber);
  90155. var visibleRangesForLine = this._visibleLines.getVisibleLine(lineNumber).getVisibleRangesForRange(startColumn, endColumn, domReadingContext);
  90156. if (!visibleRangesForLine) {
  90157. continue;
  90158. }
  90159. if (includeNewLines && lineNumber < originalEndLineNumber) {
  90160. var currentLineModelLineNumber = nextLineModelLineNumber;
  90161. nextLineModelLineNumber = this._context.model.coordinatesConverter.convertViewPositionToModelPosition(new position_1.Position(lineNumber + 1, 1)).lineNumber;
  90162. if (currentLineModelLineNumber !== nextLineModelLineNumber) {
  90163. visibleRangesForLine.ranges[visibleRangesForLine.ranges.length - 1].width += this._typicalHalfwidthCharacterWidth;
  90164. }
  90165. }
  90166. visibleRanges[visibleRangesLen++] = new renderingContext_1.LineVisibleRanges(visibleRangesForLine.outsideRenderedLine, lineNumber, visibleRangesForLine.ranges);
  90167. }
  90168. if (visibleRangesLen === 0) {
  90169. return null;
  90170. }
  90171. return visibleRanges;
  90172. };
  90173. ViewLines.prototype._visibleRangesForLineRange = function (lineNumber, startColumn, endColumn) {
  90174. if (this.shouldRender()) {
  90175. // Cannot read from the DOM because it is dirty
  90176. // i.e. the model & the dom are out of sync, so I'd be reading something stale
  90177. return null;
  90178. }
  90179. if (lineNumber < this._visibleLines.getStartLineNumber() || lineNumber > this._visibleLines.getEndLineNumber()) {
  90180. return null;
  90181. }
  90182. return this._visibleLines.getVisibleLine(lineNumber).getVisibleRangesForRange(startColumn, endColumn, new viewLine_1.DomReadingContext(this.domNode.domNode, this._textRangeRestingSpot));
  90183. };
  90184. ViewLines.prototype.visibleRangeForPosition = function (position) {
  90185. var visibleRanges = this._visibleRangesForLineRange(position.lineNumber, position.column, position.column);
  90186. if (!visibleRanges) {
  90187. return null;
  90188. }
  90189. return new renderingContext_1.HorizontalPosition(visibleRanges.outsideRenderedLine, visibleRanges.ranges[0].left);
  90190. };
  90191. // --- implementation
  90192. ViewLines.prototype.updateLineWidths = function () {
  90193. this._updateLineWidths(false);
  90194. };
  90195. /**
  90196. * Updates the max line width if it is fast to compute.
  90197. * Returns true if all lines were taken into account.
  90198. * Returns false if some lines need to be reevaluated (in a slow fashion).
  90199. */
  90200. ViewLines.prototype._updateLineWidthsFast = function () {
  90201. return this._updateLineWidths(true);
  90202. };
  90203. ViewLines.prototype._updateLineWidthsSlow = function () {
  90204. this._updateLineWidths(false);
  90205. };
  90206. ViewLines.prototype._updateLineWidths = function (fast) {
  90207. var rendStartLineNumber = this._visibleLines.getStartLineNumber();
  90208. var rendEndLineNumber = this._visibleLines.getEndLineNumber();
  90209. var localMaxLineWidth = 1;
  90210. var allWidthsComputed = true;
  90211. for (var lineNumber = rendStartLineNumber; lineNumber <= rendEndLineNumber; lineNumber++) {
  90212. var visibleLine = this._visibleLines.getVisibleLine(lineNumber);
  90213. if (fast && !visibleLine.getWidthIsFast()) {
  90214. // Cannot compute width in a fast way for this line
  90215. allWidthsComputed = false;
  90216. continue;
  90217. }
  90218. localMaxLineWidth = Math.max(localMaxLineWidth, visibleLine.getWidth());
  90219. }
  90220. if (allWidthsComputed && rendStartLineNumber === 1 && rendEndLineNumber === this._context.model.getLineCount()) {
  90221. // we know the max line width for all the lines
  90222. this._maxLineWidth = 0;
  90223. }
  90224. this._ensureMaxLineWidth(localMaxLineWidth);
  90225. return allWidthsComputed;
  90226. };
  90227. ViewLines.prototype.prepareRender = function () {
  90228. throw new Error('Not supported');
  90229. };
  90230. ViewLines.prototype.render = function () {
  90231. throw new Error('Not supported');
  90232. };
  90233. ViewLines.prototype.renderText = function (viewportData) {
  90234. // (1) render lines - ensures lines are in the DOM
  90235. this._visibleLines.renderLines(viewportData);
  90236. this._lastRenderedData.setCurrentVisibleRange(viewportData.visibleRange);
  90237. this.domNode.setWidth(this._context.viewLayout.getScrollWidth());
  90238. this.domNode.setHeight(Math.min(this._context.viewLayout.getScrollHeight(), 1000000));
  90239. // (2) compute horizontal scroll position:
  90240. // - this must happen after the lines are in the DOM since it might need a line that rendered just now
  90241. // - it might change `scrollWidth` and `scrollLeft`
  90242. if (this._horizontalRevealRequest) {
  90243. var revealLineNumber = this._horizontalRevealRequest.lineNumber;
  90244. var revealStartColumn = this._horizontalRevealRequest.startColumn;
  90245. var revealEndColumn = this._horizontalRevealRequest.endColumn;
  90246. var scrollType = this._horizontalRevealRequest.scrollType;
  90247. // Check that we have the line that contains the horizontal range in the viewport
  90248. if (viewportData.startLineNumber <= revealLineNumber && revealLineNumber <= viewportData.endLineNumber) {
  90249. this._horizontalRevealRequest = null;
  90250. // allow `visibleRangesForRange2` to work
  90251. this.onDidRender();
  90252. // compute new scroll position
  90253. var newScrollLeft = this._computeScrollLeftToRevealRange(revealLineNumber, revealStartColumn, revealEndColumn);
  90254. var isViewportWrapping = this._isViewportWrapping;
  90255. if (!isViewportWrapping) {
  90256. // ensure `scrollWidth` is large enough
  90257. this._ensureMaxLineWidth(newScrollLeft.maxHorizontalOffset);
  90258. }
  90259. // set `scrollLeft`
  90260. if (scrollType === 0 /* Smooth */) {
  90261. this._context.viewLayout.setScrollPositionSmooth({
  90262. scrollLeft: newScrollLeft.scrollLeft
  90263. });
  90264. }
  90265. else {
  90266. this._context.viewLayout.setScrollPositionNow({
  90267. scrollLeft: newScrollLeft.scrollLeft
  90268. });
  90269. }
  90270. }
  90271. }
  90272. // Update max line width (not so important, it is just so the horizontal scrollbar doesn't get too small)
  90273. if (!this._updateLineWidthsFast()) {
  90274. // Computing the width of some lines would be slow => delay it
  90275. this._asyncUpdateLineWidths.schedule();
  90276. }
  90277. // (3) handle scrolling
  90278. this._linesContent.setLayerHinting(this._canUseLayerHinting);
  90279. this._linesContent.setContain('strict');
  90280. var adjustedScrollTop = this._context.viewLayout.getCurrentScrollTop() - viewportData.bigNumbersDelta;
  90281. this._linesContent.setTop(-adjustedScrollTop);
  90282. this._linesContent.setLeft(-this._context.viewLayout.getCurrentScrollLeft());
  90283. };
  90284. // --- width
  90285. ViewLines.prototype._ensureMaxLineWidth = function (lineWidth) {
  90286. var iLineWidth = Math.ceil(lineWidth);
  90287. if (this._maxLineWidth < iLineWidth) {
  90288. this._maxLineWidth = iLineWidth;
  90289. this._context.viewLayout.onMaxLineWidthChanged(this._maxLineWidth);
  90290. }
  90291. };
  90292. ViewLines.prototype._computeScrollTopToRevealRange = function (viewport, source, range, verticalType) {
  90293. var viewportStartY = viewport.top;
  90294. var viewportHeight = viewport.height;
  90295. var viewportEndY = viewportStartY + viewportHeight;
  90296. var boxStartY;
  90297. var boxEndY;
  90298. // Have a box that includes one extra line height (for the horizontal scrollbar)
  90299. boxStartY = this._context.viewLayout.getVerticalOffsetForLineNumber(range.startLineNumber);
  90300. boxEndY = this._context.viewLayout.getVerticalOffsetForLineNumber(range.endLineNumber) + this._lineHeight;
  90301. var shouldIgnoreScrollOff = source === 'mouse' && this._cursorSurroundingLinesStyle === 'default';
  90302. if (!shouldIgnoreScrollOff) {
  90303. var context = Math.min((viewportHeight / this._lineHeight) / 2, this._cursorSurroundingLines);
  90304. boxStartY -= context * this._lineHeight;
  90305. boxEndY += Math.max(0, (context - 1)) * this._lineHeight;
  90306. }
  90307. if (verticalType === 0 /* Simple */ || verticalType === 4 /* Bottom */) {
  90308. // Reveal one line more when the last line would be covered by the scrollbar - arrow down case or revealing a line explicitly at bottom
  90309. boxEndY += this._lineHeight;
  90310. }
  90311. var newScrollTop;
  90312. if (boxEndY - boxStartY > viewportHeight) {
  90313. // the box is larger than the viewport ... scroll to its top
  90314. newScrollTop = boxStartY;
  90315. }
  90316. else if (verticalType === 1 /* Center */ || verticalType === 2 /* CenterIfOutsideViewport */) {
  90317. if (verticalType === 2 /* CenterIfOutsideViewport */ && viewportStartY <= boxStartY && boxEndY <= viewportEndY) {
  90318. // Box is already in the viewport... do nothing
  90319. newScrollTop = viewportStartY;
  90320. }
  90321. else {
  90322. // Box is outside the viewport... center it
  90323. var boxMiddleY = (boxStartY + boxEndY) / 2;
  90324. newScrollTop = Math.max(0, boxMiddleY - viewportHeight / 2);
  90325. }
  90326. }
  90327. else {
  90328. newScrollTop = this._computeMinimumScrolling(viewportStartY, viewportEndY, boxStartY, boxEndY, verticalType === 3 /* Top */, verticalType === 4 /* Bottom */);
  90329. }
  90330. return newScrollTop;
  90331. };
  90332. ViewLines.prototype._computeScrollLeftToRevealRange = function (lineNumber, startColumn, endColumn) {
  90333. var maxHorizontalOffset = 0;
  90334. var viewport = this._context.viewLayout.getCurrentViewport();
  90335. var viewportStartX = viewport.left;
  90336. var viewportEndX = viewportStartX + viewport.width;
  90337. var visibleRanges = this._visibleRangesForLineRange(lineNumber, startColumn, endColumn);
  90338. var boxStartX = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  90339. var boxEndX = 0;
  90340. if (!visibleRanges) {
  90341. // Unknown
  90342. return {
  90343. scrollLeft: viewportStartX,
  90344. maxHorizontalOffset: maxHorizontalOffset
  90345. };
  90346. }
  90347. for (var _i = 0, _a = visibleRanges.ranges; _i < _a.length; _i++) {
  90348. var visibleRange = _a[_i];
  90349. if (visibleRange.left < boxStartX) {
  90350. boxStartX = visibleRange.left;
  90351. }
  90352. if (visibleRange.left + visibleRange.width > boxEndX) {
  90353. boxEndX = visibleRange.left + visibleRange.width;
  90354. }
  90355. }
  90356. maxHorizontalOffset = boxEndX;
  90357. boxStartX = Math.max(0, boxStartX - ViewLines.HORIZONTAL_EXTRA_PX);
  90358. boxEndX += this._revealHorizontalRightPadding;
  90359. var newScrollLeft = this._computeMinimumScrolling(viewportStartX, viewportEndX, boxStartX, boxEndX);
  90360. return {
  90361. scrollLeft: newScrollLeft,
  90362. maxHorizontalOffset: maxHorizontalOffset
  90363. };
  90364. };
  90365. ViewLines.prototype._computeMinimumScrolling = function (viewportStart, viewportEnd, boxStart, boxEnd, revealAtStart, revealAtEnd) {
  90366. viewportStart = viewportStart | 0;
  90367. viewportEnd = viewportEnd | 0;
  90368. boxStart = boxStart | 0;
  90369. boxEnd = boxEnd | 0;
  90370. revealAtStart = !!revealAtStart;
  90371. revealAtEnd = !!revealAtEnd;
  90372. var viewportLength = viewportEnd - viewportStart;
  90373. var boxLength = boxEnd - boxStart;
  90374. if (boxLength < viewportLength) {
  90375. // The box would fit in the viewport
  90376. if (revealAtStart) {
  90377. return boxStart;
  90378. }
  90379. if (revealAtEnd) {
  90380. return Math.max(0, boxEnd - viewportLength);
  90381. }
  90382. if (boxStart < viewportStart) {
  90383. // The box is above the viewport
  90384. return boxStart;
  90385. }
  90386. else if (boxEnd > viewportEnd) {
  90387. // The box is below the viewport
  90388. return Math.max(0, boxEnd - viewportLength);
  90389. }
  90390. }
  90391. else {
  90392. // The box would not fit in the viewport
  90393. // Reveal the beginning of the box
  90394. return boxStart;
  90395. }
  90396. return viewportStart;
  90397. };
  90398. /**
  90399. * Adds this amount of pixels to the right of lines (no-one wants to type near the edge of the viewport)
  90400. */
  90401. ViewLines.HORIZONTAL_EXTRA_PX = 30;
  90402. return ViewLines;
  90403. }(viewPart_1.ViewPart));
  90404. exports.ViewLines = ViewLines;
  90405. });
  90406. /*---------------------------------------------------------------------------------------------
  90407. * Copyright (c) Microsoft Corporation. All rights reserved.
  90408. * Licensed under the MIT License. See License.txt in the project root for license information.
  90409. *--------------------------------------------------------------------------------------------*/
  90410. define(__m[553/*vs/editor/browser/viewParts/minimap/minimap*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,28/*vs/base/browser/fastDomNode*/,78/*vs/base/browser/globalMouseMoveMonitor*/,16/*vs/base/common/platform*/,5/*vs/base/common/strings*/,143/*vs/editor/browser/view/viewLayer*/,37/*vs/editor/browser/view/viewPart*/,33/*vs/editor/common/config/editorOptions*/,3/*vs/editor/common/core/range*/,215/*vs/editor/common/viewModel/minimapTokensColorTracker*/,81/*vs/editor/common/view/viewEvents*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,57/*vs/base/browser/touch*/,337/*vs/editor/browser/viewParts/minimap/minimapCharRendererFactory*/,48/*vs/editor/common/model*/,102/*vs/base/common/functional*/,293/*vs/css!vs/editor/browser/viewParts/minimap/minimap*/]), function (require, exports, dom, fastDomNode_1, globalMouseMoveMonitor_1, platform, strings, viewLayer_1, viewPart_1, editorOptions_1, range_1, minimapTokensColorTracker_1, viewEvents, colorRegistry_1, themeService_1, touch_1, minimapCharRendererFactory_1, model_1, functional_1) {
  90411. "use strict";
  90412. Object.defineProperty(exports, "__esModule", { value: true });
  90413. function getMinimapLineHeight(renderMinimap, scale) {
  90414. if (renderMinimap === 1 /* Text */) {
  90415. return 2 /* BASE_CHAR_HEIGHT */ * scale;
  90416. }
  90417. // RenderMinimap.Blocks
  90418. return (2 /* BASE_CHAR_HEIGHT */ + 1) * scale;
  90419. }
  90420. function getMinimapCharWidth(renderMinimap, scale) {
  90421. if (renderMinimap === 1 /* Text */) {
  90422. return 1 /* BASE_CHAR_WIDTH */ * scale;
  90423. }
  90424. // RenderMinimap.Blocks
  90425. return 1 /* BASE_CHAR_WIDTH */ * scale;
  90426. }
  90427. /**
  90428. * The orthogonal distance to the slider at which dragging "resets". This implements "snapping"
  90429. */
  90430. var MOUSE_DRAG_RESET_DISTANCE = 140;
  90431. var GUTTER_DECORATION_WIDTH = 2;
  90432. var MinimapOptions = /** @class */ (function () {
  90433. function MinimapOptions(configuration) {
  90434. var _this = this;
  90435. var options = configuration.options;
  90436. var pixelRatio = options.get(105 /* pixelRatio */);
  90437. var layoutInfo = options.get(107 /* layoutInfo */);
  90438. var fontInfo = options.get(34 /* fontInfo */);
  90439. this.renderMinimap = layoutInfo.renderMinimap | 0;
  90440. this.scrollBeyondLastLine = options.get(80 /* scrollBeyondLastLine */);
  90441. var minimapOpts = options.get(54 /* minimap */);
  90442. this.showSlider = minimapOpts.showSlider;
  90443. this.fontScale = Math.round(minimapOpts.scale * pixelRatio);
  90444. this.charRenderer = functional_1.once(function () { return minimapCharRendererFactory_1.MinimapCharRendererFactory.create(_this.fontScale, fontInfo.fontFamily); });
  90445. this.pixelRatio = pixelRatio;
  90446. this.typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
  90447. this.lineHeight = options.get(49 /* lineHeight */);
  90448. this.minimapLeft = layoutInfo.minimapLeft;
  90449. this.minimapWidth = layoutInfo.minimapWidth;
  90450. this.minimapHeight = layoutInfo.height;
  90451. this.canvasInnerWidth = Math.floor(pixelRatio * this.minimapWidth);
  90452. this.canvasInnerHeight = Math.floor(pixelRatio * this.minimapHeight);
  90453. this.canvasOuterWidth = this.canvasInnerWidth / pixelRatio;
  90454. this.canvasOuterHeight = this.canvasInnerHeight / pixelRatio;
  90455. }
  90456. MinimapOptions.prototype.equals = function (other) {
  90457. return (this.renderMinimap === other.renderMinimap
  90458. && this.scrollBeyondLastLine === other.scrollBeyondLastLine
  90459. && this.showSlider === other.showSlider
  90460. && this.pixelRatio === other.pixelRatio
  90461. && this.typicalHalfwidthCharacterWidth === other.typicalHalfwidthCharacterWidth
  90462. && this.lineHeight === other.lineHeight
  90463. && this.fontScale === other.fontScale
  90464. && this.minimapLeft === other.minimapLeft
  90465. && this.minimapWidth === other.minimapWidth
  90466. && this.minimapHeight === other.minimapHeight
  90467. && this.canvasInnerWidth === other.canvasInnerWidth
  90468. && this.canvasInnerHeight === other.canvasInnerHeight
  90469. && this.canvasOuterWidth === other.canvasOuterWidth
  90470. && this.canvasOuterHeight === other.canvasOuterHeight);
  90471. };
  90472. return MinimapOptions;
  90473. }());
  90474. var MinimapLayout = /** @class */ (function () {
  90475. function MinimapLayout(scrollTop, scrollHeight, computedSliderRatio, sliderTop, sliderHeight, startLineNumber, endLineNumber) {
  90476. this.scrollTop = scrollTop;
  90477. this.scrollHeight = scrollHeight;
  90478. this._computedSliderRatio = computedSliderRatio;
  90479. this.sliderTop = sliderTop;
  90480. this.sliderHeight = sliderHeight;
  90481. this.startLineNumber = startLineNumber;
  90482. this.endLineNumber = endLineNumber;
  90483. }
  90484. /**
  90485. * Compute a desired `scrollPosition` such that the slider moves by `delta`.
  90486. */
  90487. MinimapLayout.prototype.getDesiredScrollTopFromDelta = function (delta) {
  90488. var desiredSliderPosition = this.sliderTop + delta;
  90489. return Math.round(desiredSliderPosition / this._computedSliderRatio);
  90490. };
  90491. MinimapLayout.prototype.getDesiredScrollTopFromTouchLocation = function (pageY) {
  90492. return Math.round((pageY - this.sliderHeight / 2) / this._computedSliderRatio);
  90493. };
  90494. MinimapLayout.create = function (options, viewportStartLineNumber, viewportEndLineNumber, viewportHeight, viewportContainsWhitespaceGaps, lineCount, scrollTop, scrollHeight, previousLayout) {
  90495. var pixelRatio = options.pixelRatio;
  90496. var minimapLineHeight = getMinimapLineHeight(options.renderMinimap, options.fontScale);
  90497. var minimapLinesFitting = Math.floor(options.canvasInnerHeight / minimapLineHeight);
  90498. var lineHeight = options.lineHeight;
  90499. // The visible line count in a viewport can change due to a number of reasons:
  90500. // a) with the same viewport width, different scroll positions can result in partial lines being visible:
  90501. // e.g. for a line height of 20, and a viewport height of 600
  90502. // * scrollTop = 0 => visible lines are [1, 30]
  90503. // * scrollTop = 10 => visible lines are [1, 31] (with lines 1 and 31 partially visible)
  90504. // * scrollTop = 20 => visible lines are [2, 31]
  90505. // b) whitespace gaps might make their way in the viewport (which results in a decrease in the visible line count)
  90506. // c) we could be in the scroll beyond last line case (which also results in a decrease in the visible line count, down to possibly only one line being visible)
  90507. // We must first establish a desirable slider height.
  90508. var sliderHeight;
  90509. if (viewportContainsWhitespaceGaps && viewportEndLineNumber !== lineCount) {
  90510. // case b) from above: there are whitespace gaps in the viewport.
  90511. // In this case, the height of the slider directly reflects the visible line count.
  90512. var viewportLineCount = viewportEndLineNumber - viewportStartLineNumber + 1;
  90513. sliderHeight = Math.floor(viewportLineCount * minimapLineHeight / pixelRatio);
  90514. }
  90515. else {
  90516. // The slider has a stable height
  90517. var expectedViewportLineCount = viewportHeight / lineHeight;
  90518. sliderHeight = Math.floor(expectedViewportLineCount * minimapLineHeight / pixelRatio);
  90519. }
  90520. var maxMinimapSliderTop;
  90521. if (options.scrollBeyondLastLine) {
  90522. // The minimap slider, when dragged all the way down, will contain the last line at its top
  90523. maxMinimapSliderTop = (lineCount - 1) * minimapLineHeight / pixelRatio;
  90524. }
  90525. else {
  90526. // The minimap slider, when dragged all the way down, will contain the last line at its bottom
  90527. maxMinimapSliderTop = Math.max(0, lineCount * minimapLineHeight / pixelRatio - sliderHeight);
  90528. }
  90529. maxMinimapSliderTop = Math.min(options.minimapHeight - sliderHeight, maxMinimapSliderTop);
  90530. // The slider can move from 0 to `maxMinimapSliderTop`
  90531. // in the same way `scrollTop` can move from 0 to `scrollHeight` - `viewportHeight`.
  90532. var computedSliderRatio = (maxMinimapSliderTop) / (scrollHeight - viewportHeight);
  90533. var sliderTop = (scrollTop * computedSliderRatio);
  90534. var extraLinesAtTheBottom = 0;
  90535. if (options.scrollBeyondLastLine) {
  90536. var expectedViewportLineCount = viewportHeight / lineHeight;
  90537. extraLinesAtTheBottom = expectedViewportLineCount;
  90538. }
  90539. if (minimapLinesFitting >= lineCount + extraLinesAtTheBottom) {
  90540. // All lines fit in the minimap
  90541. var startLineNumber = 1;
  90542. var endLineNumber = lineCount;
  90543. return new MinimapLayout(scrollTop, scrollHeight, computedSliderRatio, sliderTop, sliderHeight, startLineNumber, endLineNumber);
  90544. }
  90545. else {
  90546. var startLineNumber = Math.max(1, Math.floor(viewportStartLineNumber - sliderTop * pixelRatio / minimapLineHeight));
  90547. // Avoid flickering caused by a partial viewport start line
  90548. // by being consistent w.r.t. the previous layout decision
  90549. if (previousLayout && previousLayout.scrollHeight === scrollHeight) {
  90550. if (previousLayout.scrollTop > scrollTop) {
  90551. // Scrolling up => never increase `startLineNumber`
  90552. startLineNumber = Math.min(startLineNumber, previousLayout.startLineNumber);
  90553. }
  90554. if (previousLayout.scrollTop < scrollTop) {
  90555. // Scrolling down => never decrease `startLineNumber`
  90556. startLineNumber = Math.max(startLineNumber, previousLayout.startLineNumber);
  90557. }
  90558. }
  90559. var endLineNumber = Math.min(lineCount, startLineNumber + minimapLinesFitting - 1);
  90560. return new MinimapLayout(scrollTop, scrollHeight, computedSliderRatio, sliderTop, sliderHeight, startLineNumber, endLineNumber);
  90561. }
  90562. };
  90563. return MinimapLayout;
  90564. }());
  90565. var MinimapLine = /** @class */ (function () {
  90566. function MinimapLine(dy) {
  90567. this.dy = dy;
  90568. }
  90569. MinimapLine.prototype.onContentChanged = function () {
  90570. this.dy = -1;
  90571. };
  90572. MinimapLine.prototype.onTokensChanged = function () {
  90573. this.dy = -1;
  90574. };
  90575. MinimapLine.INVALID = new MinimapLine(-1);
  90576. return MinimapLine;
  90577. }());
  90578. var RenderData = /** @class */ (function () {
  90579. function RenderData(renderedLayout, imageData, lines) {
  90580. this.renderedLayout = renderedLayout;
  90581. this._imageData = imageData;
  90582. this._renderedLines = new viewLayer_1.RenderedLinesCollection(function () { return MinimapLine.INVALID; });
  90583. this._renderedLines._set(renderedLayout.startLineNumber, lines);
  90584. }
  90585. /**
  90586. * Check if the current RenderData matches accurately the new desired layout and no painting is needed.
  90587. */
  90588. RenderData.prototype.linesEquals = function (layout) {
  90589. if (!this.scrollEquals(layout)) {
  90590. return false;
  90591. }
  90592. var tmp = this._renderedLines._get();
  90593. var lines = tmp.lines;
  90594. for (var i = 0, len = lines.length; i < len; i++) {
  90595. if (lines[i].dy === -1) {
  90596. // This line is invalid
  90597. return false;
  90598. }
  90599. }
  90600. return true;
  90601. };
  90602. /**
  90603. * Check if the current RenderData matches the new layout's scroll position
  90604. */
  90605. RenderData.prototype.scrollEquals = function (layout) {
  90606. return this.renderedLayout.startLineNumber === layout.startLineNumber
  90607. && this.renderedLayout.endLineNumber === layout.endLineNumber;
  90608. };
  90609. RenderData.prototype._get = function () {
  90610. var tmp = this._renderedLines._get();
  90611. return {
  90612. imageData: this._imageData,
  90613. rendLineNumberStart: tmp.rendLineNumberStart,
  90614. lines: tmp.lines
  90615. };
  90616. };
  90617. RenderData.prototype.onLinesChanged = function (e) {
  90618. return this._renderedLines.onLinesChanged(e.fromLineNumber, e.toLineNumber);
  90619. };
  90620. RenderData.prototype.onLinesDeleted = function (e) {
  90621. this._renderedLines.onLinesDeleted(e.fromLineNumber, e.toLineNumber);
  90622. };
  90623. RenderData.prototype.onLinesInserted = function (e) {
  90624. this._renderedLines.onLinesInserted(e.fromLineNumber, e.toLineNumber);
  90625. };
  90626. RenderData.prototype.onTokensChanged = function (e) {
  90627. return this._renderedLines.onTokensChanged(e.ranges);
  90628. };
  90629. return RenderData;
  90630. }());
  90631. /**
  90632. * Some sort of double buffering.
  90633. *
  90634. * Keeps two buffers around that will be rotated for painting.
  90635. * Always gives a buffer that is filled with the background color.
  90636. */
  90637. var MinimapBuffers = /** @class */ (function () {
  90638. function MinimapBuffers(ctx, WIDTH, HEIGHT, background) {
  90639. this._backgroundFillData = MinimapBuffers._createBackgroundFillData(WIDTH, HEIGHT, background);
  90640. this._buffers = [
  90641. ctx.createImageData(WIDTH, HEIGHT),
  90642. ctx.createImageData(WIDTH, HEIGHT)
  90643. ];
  90644. this._lastUsedBuffer = 0;
  90645. }
  90646. MinimapBuffers.prototype.getBuffer = function () {
  90647. // rotate buffers
  90648. this._lastUsedBuffer = 1 - this._lastUsedBuffer;
  90649. var result = this._buffers[this._lastUsedBuffer];
  90650. // fill with background color
  90651. result.data.set(this._backgroundFillData);
  90652. return result;
  90653. };
  90654. MinimapBuffers._createBackgroundFillData = function (WIDTH, HEIGHT, background) {
  90655. var backgroundR = background.r;
  90656. var backgroundG = background.g;
  90657. var backgroundB = background.b;
  90658. var result = new Uint8ClampedArray(WIDTH * HEIGHT * 4);
  90659. var offset = 0;
  90660. for (var i = 0; i < HEIGHT; i++) {
  90661. for (var j = 0; j < WIDTH; j++) {
  90662. result[offset] = backgroundR;
  90663. result[offset + 1] = backgroundG;
  90664. result[offset + 2] = backgroundB;
  90665. result[offset + 3] = 255;
  90666. offset += 4;
  90667. }
  90668. }
  90669. return result;
  90670. };
  90671. return MinimapBuffers;
  90672. }());
  90673. var Minimap = /** @class */ (function (_super) {
  90674. __extends(Minimap, _super);
  90675. function Minimap(context) {
  90676. var _this = _super.call(this, context) || this;
  90677. _this._selections = [];
  90678. _this._renderDecorations = false;
  90679. _this._gestureInProgress = false;
  90680. _this._options = new MinimapOptions(_this._context.configuration);
  90681. _this._lastRenderData = null;
  90682. _this._buffers = null;
  90683. _this._selectionColor = _this._context.theme.getColor(colorRegistry_1.minimapSelection);
  90684. _this._domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  90685. viewPart_1.PartFingerprints.write(_this._domNode, 8 /* Minimap */);
  90686. _this._domNode.setClassName(_this._getMinimapDomNodeClassName());
  90687. _this._domNode.setPosition('absolute');
  90688. _this._domNode.setAttribute('role', 'presentation');
  90689. _this._domNode.setAttribute('aria-hidden', 'true');
  90690. _this._shadow = fastDomNode_1.createFastDomNode(document.createElement('div'));
  90691. _this._shadow.setClassName('minimap-shadow-hidden');
  90692. _this._domNode.appendChild(_this._shadow);
  90693. _this._canvas = fastDomNode_1.createFastDomNode(document.createElement('canvas'));
  90694. _this._canvas.setPosition('absolute');
  90695. _this._canvas.setLeft(0);
  90696. _this._domNode.appendChild(_this._canvas);
  90697. _this._decorationsCanvas = fastDomNode_1.createFastDomNode(document.createElement('canvas'));
  90698. _this._decorationsCanvas.setPosition('absolute');
  90699. _this._decorationsCanvas.setClassName('minimap-decorations-layer');
  90700. _this._decorationsCanvas.setLeft(0);
  90701. _this._domNode.appendChild(_this._decorationsCanvas);
  90702. _this._slider = fastDomNode_1.createFastDomNode(document.createElement('div'));
  90703. _this._slider.setPosition('absolute');
  90704. _this._slider.setClassName('minimap-slider');
  90705. _this._slider.setLayerHinting(true);
  90706. _this._slider.setContain('strict');
  90707. _this._domNode.appendChild(_this._slider);
  90708. _this._sliderHorizontal = fastDomNode_1.createFastDomNode(document.createElement('div'));
  90709. _this._sliderHorizontal.setPosition('absolute');
  90710. _this._sliderHorizontal.setClassName('minimap-slider-horizontal');
  90711. _this._slider.appendChild(_this._sliderHorizontal);
  90712. _this._tokensColorTracker = minimapTokensColorTracker_1.MinimapTokensColorTracker.getInstance();
  90713. _this._applyLayout();
  90714. _this._mouseDownListener = dom.addStandardDisposableListener(_this._domNode.domNode, 'mousedown', function (e) {
  90715. e.preventDefault();
  90716. var renderMinimap = _this._options.renderMinimap;
  90717. if (renderMinimap === 0 /* None */) {
  90718. return;
  90719. }
  90720. if (!_this._lastRenderData) {
  90721. return;
  90722. }
  90723. var minimapLineHeight = getMinimapLineHeight(renderMinimap, _this._options.fontScale);
  90724. var internalOffsetY = _this._options.pixelRatio * e.browserEvent.offsetY;
  90725. var lineIndex = Math.floor(internalOffsetY / minimapLineHeight);
  90726. var lineNumber = lineIndex + _this._lastRenderData.renderedLayout.startLineNumber;
  90727. lineNumber = Math.min(lineNumber, _this._context.model.getLineCount());
  90728. _this._context.privateViewEventBus.emit(new viewEvents.ViewRevealRangeRequestEvent('mouse', new range_1.Range(lineNumber, 1, lineNumber, 1), 1 /* Center */, false, 0 /* Smooth */));
  90729. });
  90730. _this._sliderMouseMoveMonitor = new globalMouseMoveMonitor_1.GlobalMouseMoveMonitor();
  90731. _this._sliderMouseDownListener = dom.addStandardDisposableListener(_this._slider.domNode, 'mousedown', function (e) {
  90732. e.preventDefault();
  90733. e.stopPropagation();
  90734. if (e.leftButton && _this._lastRenderData) {
  90735. var initialMousePosition_1 = e.posy;
  90736. var initialMouseOrthogonalPosition_1 = e.posx;
  90737. var initialSliderState_1 = _this._lastRenderData.renderedLayout;
  90738. _this._slider.toggleClassName('active', true);
  90739. _this._sliderMouseMoveMonitor.startMonitoring(e.target, e.buttons, globalMouseMoveMonitor_1.standardMouseMoveMerger, function (mouseMoveData) {
  90740. var mouseOrthogonalDelta = Math.abs(mouseMoveData.posx - initialMouseOrthogonalPosition_1);
  90741. if (platform.isWindows && mouseOrthogonalDelta > MOUSE_DRAG_RESET_DISTANCE) {
  90742. // The mouse has wondered away from the scrollbar => reset dragging
  90743. _this._context.viewLayout.setScrollPositionNow({
  90744. scrollTop: initialSliderState_1.scrollTop
  90745. });
  90746. return;
  90747. }
  90748. var mouseDelta = mouseMoveData.posy - initialMousePosition_1;
  90749. _this._context.viewLayout.setScrollPositionNow({
  90750. scrollTop: initialSliderState_1.getDesiredScrollTopFromDelta(mouseDelta)
  90751. });
  90752. }, function () {
  90753. _this._slider.toggleClassName('active', false);
  90754. });
  90755. }
  90756. });
  90757. _this._gestureDisposable = touch_1.Gesture.addTarget(_this._domNode.domNode);
  90758. _this._sliderTouchStartListener = dom.addDisposableListener(_this._domNode.domNode, touch_1.EventType.Start, function (e) {
  90759. e.preventDefault();
  90760. e.stopPropagation();
  90761. if (_this._lastRenderData) {
  90762. _this._slider.toggleClassName('active', true);
  90763. _this._gestureInProgress = true;
  90764. _this.scrollDueToTouchEvent(e);
  90765. }
  90766. });
  90767. _this._sliderTouchMoveListener = dom.addStandardDisposableListener(_this._domNode.domNode, touch_1.EventType.Change, function (e) {
  90768. e.preventDefault();
  90769. e.stopPropagation();
  90770. if (_this._lastRenderData && _this._gestureInProgress) {
  90771. _this.scrollDueToTouchEvent(e);
  90772. }
  90773. });
  90774. _this._sliderTouchEndListener = dom.addStandardDisposableListener(_this._domNode.domNode, touch_1.EventType.End, function (e) {
  90775. e.preventDefault();
  90776. e.stopPropagation();
  90777. _this._gestureInProgress = false;
  90778. _this._slider.toggleClassName('active', false);
  90779. });
  90780. return _this;
  90781. }
  90782. Minimap.prototype.scrollDueToTouchEvent = function (touch) {
  90783. var startY = this._domNode.domNode.getBoundingClientRect().top;
  90784. var scrollTop = this._lastRenderData.renderedLayout.getDesiredScrollTopFromTouchLocation(touch.pageY - startY);
  90785. this._context.viewLayout.setScrollPositionNow({
  90786. scrollTop: scrollTop
  90787. });
  90788. };
  90789. Minimap.prototype.dispose = function () {
  90790. this._mouseDownListener.dispose();
  90791. this._sliderMouseMoveMonitor.dispose();
  90792. this._sliderMouseDownListener.dispose();
  90793. this._gestureDisposable.dispose();
  90794. this._sliderTouchStartListener.dispose();
  90795. this._sliderTouchMoveListener.dispose();
  90796. this._sliderTouchEndListener.dispose();
  90797. _super.prototype.dispose.call(this);
  90798. };
  90799. Minimap.prototype._getMinimapDomNodeClassName = function () {
  90800. if (this._options.showSlider === 'always') {
  90801. return 'minimap slider-always';
  90802. }
  90803. return 'minimap slider-mouseover';
  90804. };
  90805. Minimap.prototype.getDomNode = function () {
  90806. return this._domNode;
  90807. };
  90808. Minimap.prototype._applyLayout = function () {
  90809. this._domNode.setLeft(this._options.minimapLeft);
  90810. this._domNode.setWidth(this._options.minimapWidth);
  90811. this._domNode.setHeight(this._options.minimapHeight);
  90812. this._shadow.setHeight(this._options.minimapHeight);
  90813. this._canvas.setWidth(this._options.canvasOuterWidth);
  90814. this._canvas.setHeight(this._options.canvasOuterHeight);
  90815. this._canvas.domNode.width = this._options.canvasInnerWidth;
  90816. this._canvas.domNode.height = this._options.canvasInnerHeight;
  90817. this._decorationsCanvas.setWidth(this._options.canvasOuterWidth);
  90818. this._decorationsCanvas.setHeight(this._options.canvasOuterHeight);
  90819. this._decorationsCanvas.domNode.width = this._options.canvasInnerWidth;
  90820. this._decorationsCanvas.domNode.height = this._options.canvasInnerHeight;
  90821. this._slider.setWidth(this._options.minimapWidth);
  90822. };
  90823. Minimap.prototype._getBuffer = function () {
  90824. if (!this._buffers) {
  90825. if (this._options.canvasInnerWidth > 0 && this._options.canvasInnerHeight > 0) {
  90826. this._buffers = new MinimapBuffers(this._canvas.domNode.getContext('2d'), this._options.canvasInnerWidth, this._options.canvasInnerHeight, this._tokensColorTracker.getColor(2 /* DefaultBackground */));
  90827. }
  90828. }
  90829. return this._buffers ? this._buffers.getBuffer() : null;
  90830. };
  90831. Minimap.prototype._onOptionsMaybeChanged = function () {
  90832. var opts = new MinimapOptions(this._context.configuration);
  90833. if (this._options.equals(opts)) {
  90834. return false;
  90835. }
  90836. this._options = opts;
  90837. this._lastRenderData = null;
  90838. this._buffers = null;
  90839. this._applyLayout();
  90840. this._domNode.setClassName(this._getMinimapDomNodeClassName());
  90841. return true;
  90842. };
  90843. // ---- begin view event handlers
  90844. Minimap.prototype.onConfigurationChanged = function (e) {
  90845. return this._onOptionsMaybeChanged();
  90846. };
  90847. Minimap.prototype.onCursorStateChanged = function (e) {
  90848. this._selections = e.selections;
  90849. this._renderDecorations = true;
  90850. return true;
  90851. };
  90852. Minimap.prototype.onFlushed = function (e) {
  90853. this._lastRenderData = null;
  90854. return true;
  90855. };
  90856. Minimap.prototype.onLinesChanged = function (e) {
  90857. if (this._lastRenderData) {
  90858. return this._lastRenderData.onLinesChanged(e);
  90859. }
  90860. return false;
  90861. };
  90862. Minimap.prototype.onLinesDeleted = function (e) {
  90863. if (this._lastRenderData) {
  90864. this._lastRenderData.onLinesDeleted(e);
  90865. }
  90866. return true;
  90867. };
  90868. Minimap.prototype.onLinesInserted = function (e) {
  90869. if (this._lastRenderData) {
  90870. this._lastRenderData.onLinesInserted(e);
  90871. }
  90872. return true;
  90873. };
  90874. Minimap.prototype.onScrollChanged = function (e) {
  90875. this._renderDecorations = true;
  90876. return true;
  90877. };
  90878. Minimap.prototype.onTokensChanged = function (e) {
  90879. if (this._lastRenderData) {
  90880. return this._lastRenderData.onTokensChanged(e);
  90881. }
  90882. return false;
  90883. };
  90884. Minimap.prototype.onTokensColorsChanged = function (e) {
  90885. this._lastRenderData = null;
  90886. this._buffers = null;
  90887. return true;
  90888. };
  90889. Minimap.prototype.onZonesChanged = function (e) {
  90890. this._lastRenderData = null;
  90891. return true;
  90892. };
  90893. Minimap.prototype.onDecorationsChanged = function (e) {
  90894. this._renderDecorations = true;
  90895. return true;
  90896. };
  90897. Minimap.prototype.onThemeChanged = function (e) {
  90898. this._context.model.invalidateMinimapColorCache();
  90899. this._selectionColor = this._context.theme.getColor(colorRegistry_1.minimapSelection);
  90900. this._renderDecorations = true;
  90901. return true;
  90902. };
  90903. // --- end event handlers
  90904. Minimap.prototype.prepareRender = function (ctx) {
  90905. // Nothing to read
  90906. };
  90907. Minimap.prototype.render = function (renderingCtx) {
  90908. var renderMinimap = this._options.renderMinimap;
  90909. if (renderMinimap === 0 /* None */) {
  90910. this._shadow.setClassName('minimap-shadow-hidden');
  90911. this._sliderHorizontal.setWidth(0);
  90912. this._sliderHorizontal.setHeight(0);
  90913. return;
  90914. }
  90915. if (renderingCtx.scrollLeft + renderingCtx.viewportWidth >= renderingCtx.scrollWidth) {
  90916. this._shadow.setClassName('minimap-shadow-hidden');
  90917. }
  90918. else {
  90919. this._shadow.setClassName('minimap-shadow-visible');
  90920. }
  90921. var layout = MinimapLayout.create(this._options, renderingCtx.visibleRange.startLineNumber, renderingCtx.visibleRange.endLineNumber, renderingCtx.viewportHeight, (renderingCtx.viewportData.whitespaceViewportData.length > 0), this._context.model.getLineCount(), renderingCtx.scrollTop, renderingCtx.scrollHeight, this._lastRenderData ? this._lastRenderData.renderedLayout : null);
  90922. this._slider.setTop(layout.sliderTop);
  90923. this._slider.setHeight(layout.sliderHeight);
  90924. // Compute horizontal slider coordinates
  90925. var scrollLeftChars = renderingCtx.scrollLeft / this._options.typicalHalfwidthCharacterWidth;
  90926. var horizontalSliderLeft = Math.min(this._options.minimapWidth, Math.round(scrollLeftChars * getMinimapCharWidth(this._options.renderMinimap, this._options.fontScale) / this._options.pixelRatio));
  90927. this._sliderHorizontal.setLeft(horizontalSliderLeft);
  90928. this._sliderHorizontal.setWidth(this._options.minimapWidth - horizontalSliderLeft);
  90929. this._sliderHorizontal.setTop(0);
  90930. this._sliderHorizontal.setHeight(layout.sliderHeight);
  90931. this.renderDecorations(layout);
  90932. this._lastRenderData = this.renderLines(layout);
  90933. };
  90934. Minimap.prototype.renderDecorations = function (layout) {
  90935. if (this._renderDecorations) {
  90936. this._renderDecorations = false;
  90937. var decorations = this._context.model.getDecorationsInViewport(new range_1.Range(layout.startLineNumber, 1, layout.endLineNumber, this._context.model.getLineMaxColumn(layout.endLineNumber)));
  90938. var _a = this._options, renderMinimap = _a.renderMinimap, canvasInnerWidth = _a.canvasInnerWidth, canvasInnerHeight = _a.canvasInnerHeight;
  90939. var lineHeight = getMinimapLineHeight(renderMinimap, this._options.fontScale);
  90940. var characterWidth = getMinimapCharWidth(renderMinimap, this._options.fontScale);
  90941. var tabSize = this._context.model.getOptions().tabSize;
  90942. var canvasContext = this._decorationsCanvas.domNode.getContext('2d');
  90943. canvasContext.clearRect(0, 0, canvasInnerWidth, canvasInnerHeight);
  90944. var lineOffsetMap = new Map();
  90945. for (var i = 0; i < this._selections.length; i++) {
  90946. var selection = this._selections[i];
  90947. for (var line = selection.startLineNumber; line <= selection.endLineNumber; line++) {
  90948. this.renderDecorationOnLine(canvasContext, lineOffsetMap, selection, this._selectionColor, layout, line, lineHeight, lineHeight, tabSize, characterWidth);
  90949. }
  90950. }
  90951. // Loop over decorations, ignoring those that don't have the minimap property set and rendering rectangles for each line the decoration spans
  90952. for (var i = 0; i < decorations.length; i++) {
  90953. var decoration = decorations[i];
  90954. if (!decoration.options.minimap) {
  90955. continue;
  90956. }
  90957. var decorationColor = decoration.options.minimap.getColor(this._context.theme);
  90958. for (var line = decoration.range.startLineNumber; line <= decoration.range.endLineNumber; line++) {
  90959. switch (decoration.options.minimap.position) {
  90960. case model_1.MinimapPosition.Inline:
  90961. this.renderDecorationOnLine(canvasContext, lineOffsetMap, decoration.range, decorationColor, layout, line, lineHeight, lineHeight, tabSize, characterWidth);
  90962. continue;
  90963. case model_1.MinimapPosition.Gutter:
  90964. var y = (line - layout.startLineNumber) * lineHeight;
  90965. var x = 2;
  90966. this.renderDecoration(canvasContext, decorationColor, x, y, GUTTER_DECORATION_WIDTH, lineHeight);
  90967. continue;
  90968. }
  90969. }
  90970. }
  90971. }
  90972. };
  90973. Minimap.prototype.renderDecorationOnLine = function (canvasContext, lineOffsetMap, decorationRange, decorationColor, layout, lineNumber, height, lineHeight, tabSize, charWidth) {
  90974. var y = (lineNumber - layout.startLineNumber) * lineHeight;
  90975. // Skip rendering the line if it's vertically outside our viewport
  90976. if (y + height < 0 || y > this._options.canvasInnerHeight) {
  90977. return;
  90978. }
  90979. // Cache line offset data so that it is only read once per line
  90980. var lineIndexToXOffset = lineOffsetMap.get(lineNumber);
  90981. var isFirstDecorationForLine = !lineIndexToXOffset;
  90982. if (!lineIndexToXOffset) {
  90983. var lineData = this._context.model.getLineContent(lineNumber);
  90984. lineIndexToXOffset = [editorOptions_1.MINIMAP_GUTTER_WIDTH];
  90985. for (var i = 1; i < lineData.length + 1; i++) {
  90986. var charCode = lineData.charCodeAt(i - 1);
  90987. var dx = charCode === 9 /* Tab */
  90988. ? tabSize * charWidth
  90989. : strings.isFullWidthCharacter(charCode)
  90990. ? 2 * charWidth
  90991. : charWidth;
  90992. lineIndexToXOffset[i] = lineIndexToXOffset[i - 1] + dx;
  90993. }
  90994. lineOffsetMap.set(lineNumber, lineIndexToXOffset);
  90995. }
  90996. var startColumn = decorationRange.startColumn, endColumn = decorationRange.endColumn, startLineNumber = decorationRange.startLineNumber, endLineNumber = decorationRange.endLineNumber;
  90997. var x = startLineNumber === lineNumber ? lineIndexToXOffset[startColumn - 1] : editorOptions_1.MINIMAP_GUTTER_WIDTH;
  90998. var endColumnForLine = endLineNumber > lineNumber ? lineIndexToXOffset.length - 1 : endColumn - 1;
  90999. if (endColumnForLine > 0) {
  91000. // If the decoration starts at the last character of the column and spans over it, ensure it has a width
  91001. var width = lineIndexToXOffset[endColumnForLine] - x || 2;
  91002. this.renderDecoration(canvasContext, decorationColor, x, y, width, height);
  91003. }
  91004. if (isFirstDecorationForLine) {
  91005. this.renderLineHighlight(canvasContext, decorationColor, y, height);
  91006. }
  91007. };
  91008. Minimap.prototype.renderLineHighlight = function (canvasContext, decorationColor, y, height) {
  91009. canvasContext.fillStyle = decorationColor && decorationColor.transparent(0.5).toString() || '';
  91010. canvasContext.fillRect(editorOptions_1.MINIMAP_GUTTER_WIDTH, y, canvasContext.canvas.width, height);
  91011. };
  91012. Minimap.prototype.renderDecoration = function (canvasContext, decorationColor, x, y, width, height) {
  91013. canvasContext.fillStyle = decorationColor && decorationColor.toString() || '';
  91014. canvasContext.fillRect(x, y, width, height);
  91015. };
  91016. Minimap.prototype.renderLines = function (layout) {
  91017. var renderMinimap = this._options.renderMinimap;
  91018. var charRenderer = this._options.charRenderer();
  91019. var startLineNumber = layout.startLineNumber;
  91020. var endLineNumber = layout.endLineNumber;
  91021. var minimapLineHeight = getMinimapLineHeight(renderMinimap, this._options.fontScale);
  91022. // Check if nothing changed w.r.t. lines from last frame
  91023. if (this._lastRenderData && this._lastRenderData.linesEquals(layout)) {
  91024. var _lastData = this._lastRenderData._get();
  91025. // Nice!! Nothing changed from last frame
  91026. return new RenderData(layout, _lastData.imageData, _lastData.lines);
  91027. }
  91028. // Oh well!! We need to repaint some lines...
  91029. var imageData = this._getBuffer();
  91030. if (!imageData) {
  91031. // 0 width or 0 height canvas, nothing to do
  91032. return null;
  91033. }
  91034. // Render untouched lines by using last rendered data.
  91035. var _a = Minimap._renderUntouchedLines(imageData, startLineNumber, endLineNumber, minimapLineHeight, this._lastRenderData), _dirtyY1 = _a[0], _dirtyY2 = _a[1], needed = _a[2];
  91036. // Fetch rendering info from view model for rest of lines that need rendering.
  91037. var lineInfo = this._context.model.getMinimapLinesRenderingData(startLineNumber, endLineNumber, needed);
  91038. var tabSize = lineInfo.tabSize;
  91039. var background = this._tokensColorTracker.getColor(2 /* DefaultBackground */);
  91040. var useLighterFont = this._tokensColorTracker.backgroundIsLight();
  91041. // Render the rest of lines
  91042. var dy = 0;
  91043. var renderedLines = [];
  91044. for (var lineIndex = 0, lineCount = endLineNumber - startLineNumber + 1; lineIndex < lineCount; lineIndex++) {
  91045. if (needed[lineIndex]) {
  91046. Minimap._renderLine(imageData, background, useLighterFont, renderMinimap, this._tokensColorTracker, charRenderer, dy, tabSize, lineInfo.data[lineIndex], this._options.fontScale);
  91047. }
  91048. renderedLines[lineIndex] = new MinimapLine(dy);
  91049. dy += minimapLineHeight;
  91050. }
  91051. var dirtyY1 = (_dirtyY1 === -1 ? 0 : _dirtyY1);
  91052. var dirtyY2 = (_dirtyY2 === -1 ? imageData.height : _dirtyY2);
  91053. var dirtyHeight = dirtyY2 - dirtyY1;
  91054. // Finally, paint to the canvas
  91055. var ctx = this._canvas.domNode.getContext('2d');
  91056. ctx.putImageData(imageData, 0, 0, 0, dirtyY1, imageData.width, dirtyHeight);
  91057. // Save rendered data for reuse on next frame if possible
  91058. return new RenderData(layout, imageData, renderedLines);
  91059. };
  91060. Minimap._renderUntouchedLines = function (target, startLineNumber, endLineNumber, minimapLineHeight, lastRenderData) {
  91061. var needed = [];
  91062. if (!lastRenderData) {
  91063. for (var i = 0, len = endLineNumber - startLineNumber + 1; i < len; i++) {
  91064. needed[i] = true;
  91065. }
  91066. return [-1, -1, needed];
  91067. }
  91068. var _lastData = lastRenderData._get();
  91069. var lastTargetData = _lastData.imageData.data;
  91070. var lastStartLineNumber = _lastData.rendLineNumberStart;
  91071. var lastLines = _lastData.lines;
  91072. var lastLinesLength = lastLines.length;
  91073. var WIDTH = target.width;
  91074. var targetData = target.data;
  91075. var maxDestPixel = (endLineNumber - startLineNumber + 1) * minimapLineHeight * WIDTH * 4;
  91076. var dirtyPixel1 = -1; // the pixel offset up to which all the data is equal to the prev frame
  91077. var dirtyPixel2 = -1; // the pixel offset after which all the data is equal to the prev frame
  91078. var copySourceStart = -1;
  91079. var copySourceEnd = -1;
  91080. var copyDestStart = -1;
  91081. var copyDestEnd = -1;
  91082. var dest_dy = 0;
  91083. for (var lineNumber = startLineNumber; lineNumber <= endLineNumber; lineNumber++) {
  91084. var lineIndex = lineNumber - startLineNumber;
  91085. var lastLineIndex = lineNumber - lastStartLineNumber;
  91086. var source_dy = (lastLineIndex >= 0 && lastLineIndex < lastLinesLength ? lastLines[lastLineIndex].dy : -1);
  91087. if (source_dy === -1) {
  91088. needed[lineIndex] = true;
  91089. dest_dy += minimapLineHeight;
  91090. continue;
  91091. }
  91092. var sourceStart = source_dy * WIDTH * 4;
  91093. var sourceEnd = (source_dy + minimapLineHeight) * WIDTH * 4;
  91094. var destStart = dest_dy * WIDTH * 4;
  91095. var destEnd = (dest_dy + minimapLineHeight) * WIDTH * 4;
  91096. if (copySourceEnd === sourceStart && copyDestEnd === destStart) {
  91097. // contiguous zone => extend copy request
  91098. copySourceEnd = sourceEnd;
  91099. copyDestEnd = destEnd;
  91100. }
  91101. else {
  91102. if (copySourceStart !== -1) {
  91103. // flush existing copy request
  91104. targetData.set(lastTargetData.subarray(copySourceStart, copySourceEnd), copyDestStart);
  91105. if (dirtyPixel1 === -1 && copySourceStart === 0 && copySourceStart === copyDestStart) {
  91106. dirtyPixel1 = copySourceEnd;
  91107. }
  91108. if (dirtyPixel2 === -1 && copySourceEnd === maxDestPixel && copySourceStart === copyDestStart) {
  91109. dirtyPixel2 = copySourceStart;
  91110. }
  91111. }
  91112. copySourceStart = sourceStart;
  91113. copySourceEnd = sourceEnd;
  91114. copyDestStart = destStart;
  91115. copyDestEnd = destEnd;
  91116. }
  91117. needed[lineIndex] = false;
  91118. dest_dy += minimapLineHeight;
  91119. }
  91120. if (copySourceStart !== -1) {
  91121. // flush existing copy request
  91122. targetData.set(lastTargetData.subarray(copySourceStart, copySourceEnd), copyDestStart);
  91123. if (dirtyPixel1 === -1 && copySourceStart === 0 && copySourceStart === copyDestStart) {
  91124. dirtyPixel1 = copySourceEnd;
  91125. }
  91126. if (dirtyPixel2 === -1 && copySourceEnd === maxDestPixel && copySourceStart === copyDestStart) {
  91127. dirtyPixel2 = copySourceStart;
  91128. }
  91129. }
  91130. var dirtyY1 = (dirtyPixel1 === -1 ? -1 : dirtyPixel1 / (WIDTH * 4));
  91131. var dirtyY2 = (dirtyPixel2 === -1 ? -1 : dirtyPixel2 / (WIDTH * 4));
  91132. return [dirtyY1, dirtyY2, needed];
  91133. };
  91134. Minimap._renderLine = function (target, backgroundColor, useLighterFont, renderMinimap, colorTracker, minimapCharRenderer, dy, tabSize, lineData, fontScale) {
  91135. var content = lineData.content;
  91136. var tokens = lineData.tokens;
  91137. var charWidth = getMinimapCharWidth(renderMinimap, fontScale);
  91138. var maxDx = target.width - charWidth;
  91139. var dx = editorOptions_1.MINIMAP_GUTTER_WIDTH;
  91140. var charIndex = 0;
  91141. var tabsCharDelta = 0;
  91142. for (var tokenIndex = 0, tokensLen = tokens.getCount(); tokenIndex < tokensLen; tokenIndex++) {
  91143. var tokenEndIndex = tokens.getEndOffset(tokenIndex);
  91144. var tokenColorId = tokens.getForeground(tokenIndex);
  91145. var tokenColor = colorTracker.getColor(tokenColorId);
  91146. for (; charIndex < tokenEndIndex; charIndex++) {
  91147. if (dx > maxDx) {
  91148. // hit edge of minimap
  91149. return;
  91150. }
  91151. var charCode = content.charCodeAt(charIndex);
  91152. if (charCode === 9 /* Tab */) {
  91153. var insertSpacesCount = tabSize - (charIndex + tabsCharDelta) % tabSize;
  91154. tabsCharDelta += insertSpacesCount - 1;
  91155. // No need to render anything since tab is invisible
  91156. dx += insertSpacesCount * charWidth;
  91157. }
  91158. else if (charCode === 32 /* Space */) {
  91159. // No need to render anything since space is invisible
  91160. dx += charWidth;
  91161. }
  91162. else {
  91163. // Render twice for a full width character
  91164. var count = strings.isFullWidthCharacter(charCode) ? 2 : 1;
  91165. for (var i = 0; i < count; i++) {
  91166. if (renderMinimap === 2 /* Blocks */) {
  91167. minimapCharRenderer.blockRenderChar(target, dx, dy, tokenColor, backgroundColor, useLighterFont);
  91168. }
  91169. else { // RenderMinimap.Text
  91170. minimapCharRenderer.renderChar(target, dx, dy, charCode, tokenColor, backgroundColor, fontScale, useLighterFont);
  91171. }
  91172. dx += charWidth;
  91173. if (dx > maxDx) {
  91174. // hit edge of minimap
  91175. return;
  91176. }
  91177. }
  91178. }
  91179. }
  91180. }
  91181. };
  91182. return Minimap;
  91183. }(viewPart_1.ViewPart));
  91184. exports.Minimap = Minimap;
  91185. themeService_1.registerThemingParticipant(function (theme, collector) {
  91186. var sliderBackground = theme.getColor(colorRegistry_1.scrollbarSliderBackground);
  91187. if (sliderBackground) {
  91188. var halfSliderBackground = sliderBackground.transparent(0.5);
  91189. collector.addRule(".monaco-editor .minimap-slider, .monaco-editor .minimap-slider .minimap-slider-horizontal { background: " + halfSliderBackground + "; }");
  91190. }
  91191. var sliderHoverBackground = theme.getColor(colorRegistry_1.scrollbarSliderHoverBackground);
  91192. if (sliderHoverBackground) {
  91193. var halfSliderHoverBackground = sliderHoverBackground.transparent(0.5);
  91194. collector.addRule(".monaco-editor .minimap-slider:hover, .monaco-editor .minimap-slider:hover .minimap-slider-horizontal { background: " + halfSliderHoverBackground + "; }");
  91195. }
  91196. var sliderActiveBackground = theme.getColor(colorRegistry_1.scrollbarSliderActiveBackground);
  91197. if (sliderActiveBackground) {
  91198. var halfSliderActiveBackground = sliderActiveBackground.transparent(0.5);
  91199. collector.addRule(".monaco-editor .minimap-slider.active, .monaco-editor .minimap-slider.active .minimap-slider-horizontal { background: " + halfSliderActiveBackground + "; }");
  91200. }
  91201. var shadow = theme.getColor(colorRegistry_1.scrollbarShadow);
  91202. if (shadow) {
  91203. collector.addRule(".monaco-editor .minimap-shadow-visible { box-shadow: " + shadow + " -6px 0 6px -6px inset; }");
  91204. }
  91205. });
  91206. });
  91207. /*---------------------------------------------------------------------------------------------
  91208. * Copyright (c) Microsoft Corporation. All rights reserved.
  91209. * Licensed under the MIT License. See License.txt in the project root for license information.
  91210. *--------------------------------------------------------------------------------------------*/
  91211. define(__m[554/*vs/editor/browser/viewParts/scrollDecoration/scrollDecoration*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,37/*vs/editor/browser/view/viewPart*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,296/*vs/css!vs/editor/browser/viewParts/scrollDecoration/scrollDecoration*/]), function (require, exports, fastDomNode_1, viewPart_1, colorRegistry_1, themeService_1) {
  91212. "use strict";
  91213. Object.defineProperty(exports, "__esModule", { value: true });
  91214. var ScrollDecorationViewPart = /** @class */ (function (_super) {
  91215. __extends(ScrollDecorationViewPart, _super);
  91216. function ScrollDecorationViewPart(context) {
  91217. var _this = _super.call(this, context) || this;
  91218. _this._scrollTop = 0;
  91219. _this._width = 0;
  91220. _this._updateWidth();
  91221. _this._shouldShow = false;
  91222. var options = _this._context.configuration.options;
  91223. var scrollbar = options.get(78 /* scrollbar */);
  91224. _this._useShadows = scrollbar.useShadows;
  91225. _this._domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  91226. _this._domNode.setAttribute('role', 'presentation');
  91227. _this._domNode.setAttribute('aria-hidden', 'true');
  91228. return _this;
  91229. }
  91230. ScrollDecorationViewPart.prototype.dispose = function () {
  91231. _super.prototype.dispose.call(this);
  91232. };
  91233. ScrollDecorationViewPart.prototype._updateShouldShow = function () {
  91234. var newShouldShow = (this._useShadows && this._scrollTop > 0);
  91235. if (this._shouldShow !== newShouldShow) {
  91236. this._shouldShow = newShouldShow;
  91237. return true;
  91238. }
  91239. return false;
  91240. };
  91241. ScrollDecorationViewPart.prototype.getDomNode = function () {
  91242. return this._domNode;
  91243. };
  91244. ScrollDecorationViewPart.prototype._updateWidth = function () {
  91245. var options = this._context.configuration.options;
  91246. var layoutInfo = options.get(107 /* layoutInfo */);
  91247. if (layoutInfo.renderMinimap === 0 || (layoutInfo.minimapWidth > 0 && layoutInfo.minimapLeft === 0)) {
  91248. this._width = layoutInfo.width;
  91249. }
  91250. else {
  91251. this._width = layoutInfo.width - layoutInfo.minimapWidth - layoutInfo.verticalScrollbarWidth;
  91252. }
  91253. };
  91254. // --- begin event handlers
  91255. ScrollDecorationViewPart.prototype.onConfigurationChanged = function (e) {
  91256. var options = this._context.configuration.options;
  91257. var scrollbar = options.get(78 /* scrollbar */);
  91258. this._useShadows = scrollbar.useShadows;
  91259. this._updateWidth();
  91260. this._updateShouldShow();
  91261. return true;
  91262. };
  91263. ScrollDecorationViewPart.prototype.onScrollChanged = function (e) {
  91264. this._scrollTop = e.scrollTop;
  91265. return this._updateShouldShow();
  91266. };
  91267. // --- end event handlers
  91268. ScrollDecorationViewPart.prototype.prepareRender = function (ctx) {
  91269. // Nothing to read
  91270. };
  91271. ScrollDecorationViewPart.prototype.render = function (ctx) {
  91272. this._domNode.setWidth(this._width);
  91273. this._domNode.setClassName(this._shouldShow ? 'scroll-decoration' : '');
  91274. };
  91275. return ScrollDecorationViewPart;
  91276. }(viewPart_1.ViewPart));
  91277. exports.ScrollDecorationViewPart = ScrollDecorationViewPart;
  91278. themeService_1.registerThemingParticipant(function (theme, collector) {
  91279. var shadow = theme.getColor(colorRegistry_1.scrollbarShadow);
  91280. if (shadow) {
  91281. collector.addRule(".monaco-editor .scroll-decoration { box-shadow: " + shadow + " 0 6px 6px -6px inset; }");
  91282. }
  91283. });
  91284. });
  91285. /*---------------------------------------------------------------------------------------------
  91286. * Copyright (c) Microsoft Corporation. All rights reserved.
  91287. * Licensed under the MIT License. See License.txt in the project root for license information.
  91288. *--------------------------------------------------------------------------------------------*/
  91289. define(__m[555/*vs/editor/browser/viewParts/selections/selections*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,82/*vs/editor/browser/view/dynamicViewOverlay*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,297/*vs/css!vs/editor/browser/viewParts/selections/selections*/]), function (require, exports, browser, dynamicViewOverlay_1, colorRegistry_1, themeService_1) {
  91290. "use strict";
  91291. Object.defineProperty(exports, "__esModule", { value: true });
  91292. var HorizontalRangeWithStyle = /** @class */ (function () {
  91293. function HorizontalRangeWithStyle(other) {
  91294. this.left = other.left;
  91295. this.width = other.width;
  91296. this.startStyle = null;
  91297. this.endStyle = null;
  91298. }
  91299. return HorizontalRangeWithStyle;
  91300. }());
  91301. var LineVisibleRangesWithStyle = /** @class */ (function () {
  91302. function LineVisibleRangesWithStyle(lineNumber, ranges) {
  91303. this.lineNumber = lineNumber;
  91304. this.ranges = ranges;
  91305. }
  91306. return LineVisibleRangesWithStyle;
  91307. }());
  91308. function toStyledRange(item) {
  91309. return new HorizontalRangeWithStyle(item);
  91310. }
  91311. function toStyled(item) {
  91312. return new LineVisibleRangesWithStyle(item.lineNumber, item.ranges.map(toStyledRange));
  91313. }
  91314. // TODO@Alex: Remove this once IE11 fixes Bug #524217
  91315. // The problem in IE11 is that it does some sort of auto-zooming to accomodate for displays with different pixel density.
  91316. // Unfortunately, this auto-zooming is buggy around dealing with rounded borders
  91317. var isIEWithZoomingIssuesNearRoundedBorders = browser.isEdgeOrIE;
  91318. var SelectionsOverlay = /** @class */ (function (_super) {
  91319. __extends(SelectionsOverlay, _super);
  91320. function SelectionsOverlay(context) {
  91321. var _this = _super.call(this) || this;
  91322. _this._previousFrameVisibleRangesWithStyle = [];
  91323. _this._context = context;
  91324. var options = _this._context.configuration.options;
  91325. _this._lineHeight = options.get(49 /* lineHeight */);
  91326. _this._roundedSelection = options.get(76 /* roundedSelection */);
  91327. _this._typicalHalfwidthCharacterWidth = options.get(34 /* fontInfo */).typicalHalfwidthCharacterWidth;
  91328. _this._selections = [];
  91329. _this._renderResult = null;
  91330. _this._context.addEventHandler(_this);
  91331. return _this;
  91332. }
  91333. SelectionsOverlay.prototype.dispose = function () {
  91334. this._context.removeEventHandler(this);
  91335. this._renderResult = null;
  91336. _super.prototype.dispose.call(this);
  91337. };
  91338. // --- begin event handlers
  91339. SelectionsOverlay.prototype.onConfigurationChanged = function (e) {
  91340. var options = this._context.configuration.options;
  91341. this._lineHeight = options.get(49 /* lineHeight */);
  91342. this._roundedSelection = options.get(76 /* roundedSelection */);
  91343. this._typicalHalfwidthCharacterWidth = options.get(34 /* fontInfo */).typicalHalfwidthCharacterWidth;
  91344. return true;
  91345. };
  91346. SelectionsOverlay.prototype.onCursorStateChanged = function (e) {
  91347. this._selections = e.selections.slice(0);
  91348. return true;
  91349. };
  91350. SelectionsOverlay.prototype.onDecorationsChanged = function (e) {
  91351. // true for inline decorations that can end up relayouting text
  91352. return true; //e.inlineDecorationsChanged;
  91353. };
  91354. SelectionsOverlay.prototype.onFlushed = function (e) {
  91355. return true;
  91356. };
  91357. SelectionsOverlay.prototype.onLinesChanged = function (e) {
  91358. return true;
  91359. };
  91360. SelectionsOverlay.prototype.onLinesDeleted = function (e) {
  91361. return true;
  91362. };
  91363. SelectionsOverlay.prototype.onLinesInserted = function (e) {
  91364. return true;
  91365. };
  91366. SelectionsOverlay.prototype.onScrollChanged = function (e) {
  91367. return e.scrollTopChanged;
  91368. };
  91369. SelectionsOverlay.prototype.onZonesChanged = function (e) {
  91370. return true;
  91371. };
  91372. // --- end event handlers
  91373. SelectionsOverlay.prototype._visibleRangesHaveGaps = function (linesVisibleRanges) {
  91374. for (var i = 0, len = linesVisibleRanges.length; i < len; i++) {
  91375. var lineVisibleRanges = linesVisibleRanges[i];
  91376. if (lineVisibleRanges.ranges.length > 1) {
  91377. // There are two ranges on the same line
  91378. return true;
  91379. }
  91380. }
  91381. return false;
  91382. };
  91383. SelectionsOverlay.prototype._enrichVisibleRangesWithStyle = function (viewport, linesVisibleRanges, previousFrame) {
  91384. var epsilon = this._typicalHalfwidthCharacterWidth / 4;
  91385. var previousFrameTop = null;
  91386. var previousFrameBottom = null;
  91387. if (previousFrame && previousFrame.length > 0 && linesVisibleRanges.length > 0) {
  91388. var topLineNumber = linesVisibleRanges[0].lineNumber;
  91389. if (topLineNumber === viewport.startLineNumber) {
  91390. for (var i = 0; !previousFrameTop && i < previousFrame.length; i++) {
  91391. if (previousFrame[i].lineNumber === topLineNumber) {
  91392. previousFrameTop = previousFrame[i].ranges[0];
  91393. }
  91394. }
  91395. }
  91396. var bottomLineNumber = linesVisibleRanges[linesVisibleRanges.length - 1].lineNumber;
  91397. if (bottomLineNumber === viewport.endLineNumber) {
  91398. for (var i = previousFrame.length - 1; !previousFrameBottom && i >= 0; i--) {
  91399. if (previousFrame[i].lineNumber === bottomLineNumber) {
  91400. previousFrameBottom = previousFrame[i].ranges[0];
  91401. }
  91402. }
  91403. }
  91404. if (previousFrameTop && !previousFrameTop.startStyle) {
  91405. previousFrameTop = null;
  91406. }
  91407. if (previousFrameBottom && !previousFrameBottom.startStyle) {
  91408. previousFrameBottom = null;
  91409. }
  91410. }
  91411. for (var i = 0, len = linesVisibleRanges.length; i < len; i++) {
  91412. // We know for a fact that there is precisely one range on each line
  91413. var curLineRange = linesVisibleRanges[i].ranges[0];
  91414. var curLeft = curLineRange.left;
  91415. var curRight = curLineRange.left + curLineRange.width;
  91416. var startStyle = {
  91417. top: 0 /* EXTERN */,
  91418. bottom: 0 /* EXTERN */
  91419. };
  91420. var endStyle = {
  91421. top: 0 /* EXTERN */,
  91422. bottom: 0 /* EXTERN */
  91423. };
  91424. if (i > 0) {
  91425. // Look above
  91426. var prevLeft = linesVisibleRanges[i - 1].ranges[0].left;
  91427. var prevRight = linesVisibleRanges[i - 1].ranges[0].left + linesVisibleRanges[i - 1].ranges[0].width;
  91428. if (abs(curLeft - prevLeft) < epsilon) {
  91429. startStyle.top = 2 /* FLAT */;
  91430. }
  91431. else if (curLeft > prevLeft) {
  91432. startStyle.top = 1 /* INTERN */;
  91433. }
  91434. if (abs(curRight - prevRight) < epsilon) {
  91435. endStyle.top = 2 /* FLAT */;
  91436. }
  91437. else if (prevLeft < curRight && curRight < prevRight) {
  91438. endStyle.top = 1 /* INTERN */;
  91439. }
  91440. }
  91441. else if (previousFrameTop) {
  91442. // Accept some hick-ups near the viewport edges to save on repaints
  91443. startStyle.top = previousFrameTop.startStyle.top;
  91444. endStyle.top = previousFrameTop.endStyle.top;
  91445. }
  91446. if (i + 1 < len) {
  91447. // Look below
  91448. var nextLeft = linesVisibleRanges[i + 1].ranges[0].left;
  91449. var nextRight = linesVisibleRanges[i + 1].ranges[0].left + linesVisibleRanges[i + 1].ranges[0].width;
  91450. if (abs(curLeft - nextLeft) < epsilon) {
  91451. startStyle.bottom = 2 /* FLAT */;
  91452. }
  91453. else if (nextLeft < curLeft && curLeft < nextRight) {
  91454. startStyle.bottom = 1 /* INTERN */;
  91455. }
  91456. if (abs(curRight - nextRight) < epsilon) {
  91457. endStyle.bottom = 2 /* FLAT */;
  91458. }
  91459. else if (curRight < nextRight) {
  91460. endStyle.bottom = 1 /* INTERN */;
  91461. }
  91462. }
  91463. else if (previousFrameBottom) {
  91464. // Accept some hick-ups near the viewport edges to save on repaints
  91465. startStyle.bottom = previousFrameBottom.startStyle.bottom;
  91466. endStyle.bottom = previousFrameBottom.endStyle.bottom;
  91467. }
  91468. curLineRange.startStyle = startStyle;
  91469. curLineRange.endStyle = endStyle;
  91470. }
  91471. };
  91472. SelectionsOverlay.prototype._getVisibleRangesWithStyle = function (selection, ctx, previousFrame) {
  91473. var _linesVisibleRanges = ctx.linesVisibleRangesForRange(selection, true) || [];
  91474. var linesVisibleRanges = _linesVisibleRanges.map(toStyled);
  91475. var visibleRangesHaveGaps = this._visibleRangesHaveGaps(linesVisibleRanges);
  91476. if (!isIEWithZoomingIssuesNearRoundedBorders && !visibleRangesHaveGaps && this._roundedSelection) {
  91477. this._enrichVisibleRangesWithStyle(ctx.visibleRange, linesVisibleRanges, previousFrame);
  91478. }
  91479. // The visible ranges are sorted TOP-BOTTOM and LEFT-RIGHT
  91480. return linesVisibleRanges;
  91481. };
  91482. SelectionsOverlay.prototype._createSelectionPiece = function (top, height, className, left, width) {
  91483. return ('<div class="cslr '
  91484. + className
  91485. + '" style="top:'
  91486. + top.toString()
  91487. + 'px;left:'
  91488. + left.toString()
  91489. + 'px;width:'
  91490. + width.toString()
  91491. + 'px;height:'
  91492. + height
  91493. + 'px;"></div>');
  91494. };
  91495. SelectionsOverlay.prototype._actualRenderOneSelection = function (output2, visibleStartLineNumber, hasMultipleSelections, visibleRanges) {
  91496. if (visibleRanges.length === 0) {
  91497. return;
  91498. }
  91499. var visibleRangesHaveStyle = !!visibleRanges[0].ranges[0].startStyle;
  91500. var fullLineHeight = (this._lineHeight).toString();
  91501. var reducedLineHeight = (this._lineHeight - 1).toString();
  91502. var firstLineNumber = visibleRanges[0].lineNumber;
  91503. var lastLineNumber = visibleRanges[visibleRanges.length - 1].lineNumber;
  91504. for (var i = 0, len = visibleRanges.length; i < len; i++) {
  91505. var lineVisibleRanges = visibleRanges[i];
  91506. var lineNumber = lineVisibleRanges.lineNumber;
  91507. var lineIndex = lineNumber - visibleStartLineNumber;
  91508. var lineHeight = hasMultipleSelections ? (lineNumber === lastLineNumber || lineNumber === firstLineNumber ? reducedLineHeight : fullLineHeight) : fullLineHeight;
  91509. var top_1 = hasMultipleSelections ? (lineNumber === firstLineNumber ? 1 : 0) : 0;
  91510. var innerCornerOutput = '';
  91511. var restOfSelectionOutput = '';
  91512. for (var j = 0, lenJ = lineVisibleRanges.ranges.length; j < lenJ; j++) {
  91513. var visibleRange = lineVisibleRanges.ranges[j];
  91514. if (visibleRangesHaveStyle) {
  91515. var startStyle = visibleRange.startStyle;
  91516. var endStyle = visibleRange.endStyle;
  91517. if (startStyle.top === 1 /* INTERN */ || startStyle.bottom === 1 /* INTERN */) {
  91518. // Reverse rounded corner to the left
  91519. // First comes the selection (blue layer)
  91520. innerCornerOutput += this._createSelectionPiece(top_1, lineHeight, SelectionsOverlay.SELECTION_CLASS_NAME, visibleRange.left - SelectionsOverlay.ROUNDED_PIECE_WIDTH, SelectionsOverlay.ROUNDED_PIECE_WIDTH);
  91521. // Second comes the background (white layer) with inverse border radius
  91522. var className_1 = SelectionsOverlay.EDITOR_BACKGROUND_CLASS_NAME;
  91523. if (startStyle.top === 1 /* INTERN */) {
  91524. className_1 += ' ' + SelectionsOverlay.SELECTION_TOP_RIGHT;
  91525. }
  91526. if (startStyle.bottom === 1 /* INTERN */) {
  91527. className_1 += ' ' + SelectionsOverlay.SELECTION_BOTTOM_RIGHT;
  91528. }
  91529. innerCornerOutput += this._createSelectionPiece(top_1, lineHeight, className_1, visibleRange.left - SelectionsOverlay.ROUNDED_PIECE_WIDTH, SelectionsOverlay.ROUNDED_PIECE_WIDTH);
  91530. }
  91531. if (endStyle.top === 1 /* INTERN */ || endStyle.bottom === 1 /* INTERN */) {
  91532. // Reverse rounded corner to the right
  91533. // First comes the selection (blue layer)
  91534. innerCornerOutput += this._createSelectionPiece(top_1, lineHeight, SelectionsOverlay.SELECTION_CLASS_NAME, visibleRange.left + visibleRange.width, SelectionsOverlay.ROUNDED_PIECE_WIDTH);
  91535. // Second comes the background (white layer) with inverse border radius
  91536. var className_2 = SelectionsOverlay.EDITOR_BACKGROUND_CLASS_NAME;
  91537. if (endStyle.top === 1 /* INTERN */) {
  91538. className_2 += ' ' + SelectionsOverlay.SELECTION_TOP_LEFT;
  91539. }
  91540. if (endStyle.bottom === 1 /* INTERN */) {
  91541. className_2 += ' ' + SelectionsOverlay.SELECTION_BOTTOM_LEFT;
  91542. }
  91543. innerCornerOutput += this._createSelectionPiece(top_1, lineHeight, className_2, visibleRange.left + visibleRange.width, SelectionsOverlay.ROUNDED_PIECE_WIDTH);
  91544. }
  91545. }
  91546. var className = SelectionsOverlay.SELECTION_CLASS_NAME;
  91547. if (visibleRangesHaveStyle) {
  91548. var startStyle = visibleRange.startStyle;
  91549. var endStyle = visibleRange.endStyle;
  91550. if (startStyle.top === 0 /* EXTERN */) {
  91551. className += ' ' + SelectionsOverlay.SELECTION_TOP_LEFT;
  91552. }
  91553. if (startStyle.bottom === 0 /* EXTERN */) {
  91554. className += ' ' + SelectionsOverlay.SELECTION_BOTTOM_LEFT;
  91555. }
  91556. if (endStyle.top === 0 /* EXTERN */) {
  91557. className += ' ' + SelectionsOverlay.SELECTION_TOP_RIGHT;
  91558. }
  91559. if (endStyle.bottom === 0 /* EXTERN */) {
  91560. className += ' ' + SelectionsOverlay.SELECTION_BOTTOM_RIGHT;
  91561. }
  91562. }
  91563. restOfSelectionOutput += this._createSelectionPiece(top_1, lineHeight, className, visibleRange.left, visibleRange.width);
  91564. }
  91565. output2[lineIndex][0] += innerCornerOutput;
  91566. output2[lineIndex][1] += restOfSelectionOutput;
  91567. }
  91568. };
  91569. SelectionsOverlay.prototype.prepareRender = function (ctx) {
  91570. // Build HTML for inner corners separate from HTML for the rest of selections,
  91571. // as the inner corner HTML can interfere with that of other selections.
  91572. // In final render, make sure to place the inner corner HTML before the rest of selection HTML. See issue #77777.
  91573. var output = [];
  91574. var visibleStartLineNumber = ctx.visibleRange.startLineNumber;
  91575. var visibleEndLineNumber = ctx.visibleRange.endLineNumber;
  91576. for (var lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
  91577. var lineIndex = lineNumber - visibleStartLineNumber;
  91578. output[lineIndex] = ['', ''];
  91579. }
  91580. var thisFrameVisibleRangesWithStyle = [];
  91581. for (var i = 0, len = this._selections.length; i < len; i++) {
  91582. var selection = this._selections[i];
  91583. if (selection.isEmpty()) {
  91584. thisFrameVisibleRangesWithStyle[i] = null;
  91585. continue;
  91586. }
  91587. var visibleRangesWithStyle = this._getVisibleRangesWithStyle(selection, ctx, this._previousFrameVisibleRangesWithStyle[i]);
  91588. thisFrameVisibleRangesWithStyle[i] = visibleRangesWithStyle;
  91589. this._actualRenderOneSelection(output, visibleStartLineNumber, this._selections.length > 1, visibleRangesWithStyle);
  91590. }
  91591. this._previousFrameVisibleRangesWithStyle = thisFrameVisibleRangesWithStyle;
  91592. this._renderResult = output.map(function (_a) {
  91593. var internalCorners = _a[0], restOfSelection = _a[1];
  91594. return internalCorners + restOfSelection;
  91595. });
  91596. };
  91597. SelectionsOverlay.prototype.render = function (startLineNumber, lineNumber) {
  91598. if (!this._renderResult) {
  91599. return '';
  91600. }
  91601. var lineIndex = lineNumber - startLineNumber;
  91602. if (lineIndex < 0 || lineIndex >= this._renderResult.length) {
  91603. return '';
  91604. }
  91605. return this._renderResult[lineIndex];
  91606. };
  91607. SelectionsOverlay.SELECTION_CLASS_NAME = 'selected-text';
  91608. SelectionsOverlay.SELECTION_TOP_LEFT = 'top-left-radius';
  91609. SelectionsOverlay.SELECTION_BOTTOM_LEFT = 'bottom-left-radius';
  91610. SelectionsOverlay.SELECTION_TOP_RIGHT = 'top-right-radius';
  91611. SelectionsOverlay.SELECTION_BOTTOM_RIGHT = 'bottom-right-radius';
  91612. SelectionsOverlay.EDITOR_BACKGROUND_CLASS_NAME = 'monaco-editor-background';
  91613. SelectionsOverlay.ROUNDED_PIECE_WIDTH = 10;
  91614. return SelectionsOverlay;
  91615. }(dynamicViewOverlay_1.DynamicViewOverlay));
  91616. exports.SelectionsOverlay = SelectionsOverlay;
  91617. themeService_1.registerThemingParticipant(function (theme, collector) {
  91618. var editorSelectionColor = theme.getColor(colorRegistry_1.editorSelectionBackground);
  91619. if (editorSelectionColor) {
  91620. collector.addRule(".monaco-editor .focused .selected-text { background-color: " + editorSelectionColor + "; }");
  91621. }
  91622. var editorInactiveSelectionColor = theme.getColor(colorRegistry_1.editorInactiveSelection);
  91623. if (editorInactiveSelectionColor) {
  91624. collector.addRule(".monaco-editor .selected-text { background-color: " + editorInactiveSelectionColor + "; }");
  91625. }
  91626. var editorSelectionForegroundColor = theme.getColor(colorRegistry_1.editorSelectionForeground);
  91627. if (editorSelectionForegroundColor) {
  91628. collector.addRule(".monaco-editor .view-line span.inline-selected-text { color: " + editorSelectionForegroundColor + "; }");
  91629. }
  91630. });
  91631. function abs(n) {
  91632. return n < 0 ? -n : n;
  91633. }
  91634. });
  91635. /*---------------------------------------------------------------------------------------------
  91636. * Copyright (c) Microsoft Corporation. All rights reserved.
  91637. * Licensed under the MIT License. See License.txt in the project root for license information.
  91638. *--------------------------------------------------------------------------------------------*/
  91639. define(__m[556/*vs/editor/common/services/modelServiceImpl*/], __M([0/*require*/,1/*exports*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,10/*vs/base/common/errors*/,33/*vs/editor/common/config/editorOptions*/,30/*vs/editor/common/model/textModel*/,17/*vs/editor/common/modes*/,118/*vs/editor/common/modes/modesRegistry*/,114/*vs/editor/common/services/textResourceConfigurationService*/,43/*vs/platform/configuration/common/configuration*/,15/*vs/base/common/async*/,26/*vs/base/common/cancellation*/,157/*vs/editor/common/model/tokensStore*/,14/*vs/platform/theme/common/themeService*/,95/*vs/platform/log/common/log*/]), function (require, exports, event_1, lifecycle_1, platform, errors, editorOptions_1, textModel_1, modes_1, modesRegistry_1, textResourceConfigurationService_1, configuration_1, async_1, cancellation_1, tokensStore_1, themeService_1, log_1) {
  91640. "use strict";
  91641. Object.defineProperty(exports, "__esModule", { value: true });
  91642. function MODEL_ID(resource) {
  91643. return resource.toString();
  91644. }
  91645. var ModelData = /** @class */ (function () {
  91646. function ModelData(model, onWillDispose, onDidChangeLanguage) {
  91647. this._modelEventListeners = new lifecycle_1.DisposableStore();
  91648. this.model = model;
  91649. this._languageSelection = null;
  91650. this._languageSelectionListener = null;
  91651. this._modelEventListeners.add(model.onWillDispose(function () { return onWillDispose(model); }));
  91652. this._modelEventListeners.add(model.onDidChangeLanguage(function (e) { return onDidChangeLanguage(model, e); }));
  91653. }
  91654. ModelData.prototype._disposeLanguageSelection = function () {
  91655. if (this._languageSelectionListener) {
  91656. this._languageSelectionListener.dispose();
  91657. this._languageSelectionListener = null;
  91658. }
  91659. if (this._languageSelection) {
  91660. this._languageSelection.dispose();
  91661. this._languageSelection = null;
  91662. }
  91663. };
  91664. ModelData.prototype.dispose = function () {
  91665. this._modelEventListeners.dispose();
  91666. this._disposeLanguageSelection();
  91667. };
  91668. ModelData.prototype.setLanguage = function (languageSelection) {
  91669. var _this = this;
  91670. this._disposeLanguageSelection();
  91671. this._languageSelection = languageSelection;
  91672. this._languageSelectionListener = this._languageSelection.onDidChange(function () { return _this.model.setMode(languageSelection.languageIdentifier); });
  91673. this.model.setMode(languageSelection.languageIdentifier);
  91674. };
  91675. return ModelData;
  91676. }());
  91677. var DEFAULT_EOL = (platform.isLinux || platform.isMacintosh) ? 1 /* LF */ : 2 /* CRLF */;
  91678. var ModelServiceImpl = /** @class */ (function (_super) {
  91679. __extends(ModelServiceImpl, _super);
  91680. function ModelServiceImpl(configurationService, resourcePropertiesService, themeService, logService) {
  91681. var _this = _super.call(this) || this;
  91682. _this._onModelAdded = _this._register(new event_1.Emitter());
  91683. _this.onModelAdded = _this._onModelAdded.event;
  91684. _this._onModelRemoved = _this._register(new event_1.Emitter());
  91685. _this.onModelRemoved = _this._onModelRemoved.event;
  91686. _this._onModelModeChanged = _this._register(new event_1.Emitter());
  91687. _this.onModelModeChanged = _this._onModelModeChanged.event;
  91688. _this._configurationService = configurationService;
  91689. _this._resourcePropertiesService = resourcePropertiesService;
  91690. _this._models = {};
  91691. _this._modelCreationOptionsByLanguageAndResource = Object.create(null);
  91692. _this._configurationServiceSubscription = _this._configurationService.onDidChangeConfiguration(function (e) { return _this._updateModelOptions(); });
  91693. _this._updateModelOptions();
  91694. _this._register(new SemanticColoringFeature(_this, themeService, configurationService, logService));
  91695. return _this;
  91696. }
  91697. ModelServiceImpl._readModelOptions = function (config, isForSimpleWidget) {
  91698. var tabSize = editorOptions_1.EDITOR_MODEL_DEFAULTS.tabSize;
  91699. if (config.editor && typeof config.editor.tabSize !== 'undefined') {
  91700. var parsedTabSize = parseInt(config.editor.tabSize, 10);
  91701. if (!isNaN(parsedTabSize)) {
  91702. tabSize = parsedTabSize;
  91703. }
  91704. if (tabSize < 1) {
  91705. tabSize = 1;
  91706. }
  91707. }
  91708. var indentSize = tabSize;
  91709. if (config.editor && typeof config.editor.indentSize !== 'undefined' && config.editor.indentSize !== 'tabSize') {
  91710. var parsedIndentSize = parseInt(config.editor.indentSize, 10);
  91711. if (!isNaN(parsedIndentSize)) {
  91712. indentSize = parsedIndentSize;
  91713. }
  91714. if (indentSize < 1) {
  91715. indentSize = 1;
  91716. }
  91717. }
  91718. var insertSpaces = editorOptions_1.EDITOR_MODEL_DEFAULTS.insertSpaces;
  91719. if (config.editor && typeof config.editor.insertSpaces !== 'undefined') {
  91720. insertSpaces = (config.editor.insertSpaces === 'false' ? false : Boolean(config.editor.insertSpaces));
  91721. }
  91722. var newDefaultEOL = DEFAULT_EOL;
  91723. var eol = config.eol;
  91724. if (eol === '\r\n') {
  91725. newDefaultEOL = 2 /* CRLF */;
  91726. }
  91727. else if (eol === '\n') {
  91728. newDefaultEOL = 1 /* LF */;
  91729. }
  91730. var trimAutoWhitespace = editorOptions_1.EDITOR_MODEL_DEFAULTS.trimAutoWhitespace;
  91731. if (config.editor && typeof config.editor.trimAutoWhitespace !== 'undefined') {
  91732. trimAutoWhitespace = (config.editor.trimAutoWhitespace === 'false' ? false : Boolean(config.editor.trimAutoWhitespace));
  91733. }
  91734. var detectIndentation = editorOptions_1.EDITOR_MODEL_DEFAULTS.detectIndentation;
  91735. if (config.editor && typeof config.editor.detectIndentation !== 'undefined') {
  91736. detectIndentation = (config.editor.detectIndentation === 'false' ? false : Boolean(config.editor.detectIndentation));
  91737. }
  91738. var largeFileOptimizations = editorOptions_1.EDITOR_MODEL_DEFAULTS.largeFileOptimizations;
  91739. if (config.editor && typeof config.editor.largeFileOptimizations !== 'undefined') {
  91740. largeFileOptimizations = (config.editor.largeFileOptimizations === 'false' ? false : Boolean(config.editor.largeFileOptimizations));
  91741. }
  91742. return {
  91743. isForSimpleWidget: isForSimpleWidget,
  91744. tabSize: tabSize,
  91745. indentSize: indentSize,
  91746. insertSpaces: insertSpaces,
  91747. detectIndentation: detectIndentation,
  91748. defaultEOL: newDefaultEOL,
  91749. trimAutoWhitespace: trimAutoWhitespace,
  91750. largeFileOptimizations: largeFileOptimizations
  91751. };
  91752. };
  91753. ModelServiceImpl.prototype.getCreationOptions = function (language, resource, isForSimpleWidget) {
  91754. var creationOptions = this._modelCreationOptionsByLanguageAndResource[language + resource];
  91755. if (!creationOptions) {
  91756. var editor = this._configurationService.getValue('editor', { overrideIdentifier: language, resource: resource });
  91757. var eol = this._resourcePropertiesService.getEOL(resource, language);
  91758. creationOptions = ModelServiceImpl._readModelOptions({ editor: editor, eol: eol }, isForSimpleWidget);
  91759. this._modelCreationOptionsByLanguageAndResource[language + resource] = creationOptions;
  91760. }
  91761. return creationOptions;
  91762. };
  91763. ModelServiceImpl.prototype._updateModelOptions = function () {
  91764. var oldOptionsByLanguageAndResource = this._modelCreationOptionsByLanguageAndResource;
  91765. this._modelCreationOptionsByLanguageAndResource = Object.create(null);
  91766. // Update options on all models
  91767. var keys = Object.keys(this._models);
  91768. for (var i = 0, len = keys.length; i < len; i++) {
  91769. var modelId = keys[i];
  91770. var modelData = this._models[modelId];
  91771. var language = modelData.model.getLanguageIdentifier().language;
  91772. var uri = modelData.model.uri;
  91773. var oldOptions = oldOptionsByLanguageAndResource[language + uri];
  91774. var newOptions = this.getCreationOptions(language, uri, modelData.model.isForSimpleWidget);
  91775. ModelServiceImpl._setModelOptionsForModel(modelData.model, newOptions, oldOptions);
  91776. }
  91777. };
  91778. ModelServiceImpl._setModelOptionsForModel = function (model, newOptions, currentOptions) {
  91779. if (currentOptions && currentOptions.defaultEOL !== newOptions.defaultEOL && model.getLineCount() === 1) {
  91780. model.setEOL(newOptions.defaultEOL === 1 /* LF */ ? 0 /* LF */ : 1 /* CRLF */);
  91781. }
  91782. if (currentOptions
  91783. && (currentOptions.detectIndentation === newOptions.detectIndentation)
  91784. && (currentOptions.insertSpaces === newOptions.insertSpaces)
  91785. && (currentOptions.tabSize === newOptions.tabSize)
  91786. && (currentOptions.indentSize === newOptions.indentSize)
  91787. && (currentOptions.trimAutoWhitespace === newOptions.trimAutoWhitespace)) {
  91788. // Same indent opts, no need to touch the model
  91789. return;
  91790. }
  91791. if (newOptions.detectIndentation) {
  91792. model.detectIndentation(newOptions.insertSpaces, newOptions.tabSize);
  91793. model.updateOptions({
  91794. trimAutoWhitespace: newOptions.trimAutoWhitespace
  91795. });
  91796. }
  91797. else {
  91798. model.updateOptions({
  91799. insertSpaces: newOptions.insertSpaces,
  91800. tabSize: newOptions.tabSize,
  91801. indentSize: newOptions.indentSize,
  91802. trimAutoWhitespace: newOptions.trimAutoWhitespace
  91803. });
  91804. }
  91805. };
  91806. ModelServiceImpl.prototype.dispose = function () {
  91807. this._configurationServiceSubscription.dispose();
  91808. _super.prototype.dispose.call(this);
  91809. };
  91810. // --- begin IModelService
  91811. ModelServiceImpl.prototype._createModelData = function (value, languageIdentifier, resource, isForSimpleWidget) {
  91812. var _this = this;
  91813. // create & save the model
  91814. var options = this.getCreationOptions(languageIdentifier.language, resource, isForSimpleWidget);
  91815. var model = new textModel_1.TextModel(value, options, languageIdentifier, resource);
  91816. var modelId = MODEL_ID(model.uri);
  91817. if (this._models[modelId]) {
  91818. // There already exists a model with this id => this is a programmer error
  91819. throw new Error('ModelService: Cannot add model because it already exists!');
  91820. }
  91821. var modelData = new ModelData(model, function (model) { return _this._onWillDispose(model); }, function (model, e) { return _this._onDidChangeLanguage(model, e); });
  91822. this._models[modelId] = modelData;
  91823. return modelData;
  91824. };
  91825. ModelServiceImpl.prototype.createModel = function (value, languageSelection, resource, isForSimpleWidget) {
  91826. if (isForSimpleWidget === void 0) { isForSimpleWidget = false; }
  91827. var modelData;
  91828. if (languageSelection) {
  91829. modelData = this._createModelData(value, languageSelection.languageIdentifier, resource, isForSimpleWidget);
  91830. this.setMode(modelData.model, languageSelection);
  91831. }
  91832. else {
  91833. modelData = this._createModelData(value, modesRegistry_1.PLAINTEXT_LANGUAGE_IDENTIFIER, resource, isForSimpleWidget);
  91834. }
  91835. this._onModelAdded.fire(modelData.model);
  91836. return modelData.model;
  91837. };
  91838. ModelServiceImpl.prototype.setMode = function (model, languageSelection) {
  91839. if (!languageSelection) {
  91840. return;
  91841. }
  91842. var modelData = this._models[MODEL_ID(model.uri)];
  91843. if (!modelData) {
  91844. return;
  91845. }
  91846. modelData.setLanguage(languageSelection);
  91847. };
  91848. ModelServiceImpl.prototype.getModels = function () {
  91849. var ret = [];
  91850. var keys = Object.keys(this._models);
  91851. for (var i = 0, len = keys.length; i < len; i++) {
  91852. var modelId = keys[i];
  91853. ret.push(this._models[modelId].model);
  91854. }
  91855. return ret;
  91856. };
  91857. ModelServiceImpl.prototype.getModel = function (resource) {
  91858. var modelId = MODEL_ID(resource);
  91859. var modelData = this._models[modelId];
  91860. if (!modelData) {
  91861. return null;
  91862. }
  91863. return modelData.model;
  91864. };
  91865. // --- end IModelService
  91866. ModelServiceImpl.prototype._onWillDispose = function (model) {
  91867. var modelId = MODEL_ID(model.uri);
  91868. var modelData = this._models[modelId];
  91869. delete this._models[modelId];
  91870. modelData.dispose();
  91871. // clean up cache
  91872. delete this._modelCreationOptionsByLanguageAndResource[model.getLanguageIdentifier().language + model.uri];
  91873. this._onModelRemoved.fire(model);
  91874. };
  91875. ModelServiceImpl.prototype._onDidChangeLanguage = function (model, e) {
  91876. var oldModeId = e.oldLanguage;
  91877. var newModeId = model.getLanguageIdentifier().language;
  91878. var oldOptions = this.getCreationOptions(oldModeId, model.uri, model.isForSimpleWidget);
  91879. var newOptions = this.getCreationOptions(newModeId, model.uri, model.isForSimpleWidget);
  91880. ModelServiceImpl._setModelOptionsForModel(model, newOptions, oldOptions);
  91881. this._onModelModeChanged.fire({ model: model, oldModeId: oldModeId });
  91882. };
  91883. ModelServiceImpl = __decorate([
  91884. __param(0, configuration_1.IConfigurationService),
  91885. __param(1, textResourceConfigurationService_1.ITextResourcePropertiesService),
  91886. __param(2, themeService_1.IThemeService),
  91887. __param(3, log_1.ILogService)
  91888. ], ModelServiceImpl);
  91889. return ModelServiceImpl;
  91890. }(lifecycle_1.Disposable));
  91891. exports.ModelServiceImpl = ModelServiceImpl;
  91892. var SemanticColoringFeature = /** @class */ (function (_super) {
  91893. __extends(SemanticColoringFeature, _super);
  91894. function SemanticColoringFeature(modelService, themeService, configurationService, logService) {
  91895. var _this = _super.call(this) || this;
  91896. _this._configurationService = configurationService;
  91897. _this._watchers = Object.create(null);
  91898. _this._semanticStyling = _this._register(new SemanticStyling(themeService, logService));
  91899. var isSemanticColoringEnabled = function (model) {
  91900. var options = configurationService.getValue(SemanticColoringFeature.SETTING_ID, { overrideIdentifier: model.getLanguageIdentifier().language, resource: model.uri });
  91901. return options && options.enabled;
  91902. };
  91903. var register = function (model) {
  91904. _this._watchers[model.uri.toString()] = new ModelSemanticColoring(model, themeService, _this._semanticStyling);
  91905. };
  91906. var deregister = function (model, modelSemanticColoring) {
  91907. modelSemanticColoring.dispose();
  91908. delete _this._watchers[model.uri.toString()];
  91909. };
  91910. _this._register(modelService.onModelAdded(function (model) {
  91911. if (isSemanticColoringEnabled(model)) {
  91912. register(model);
  91913. }
  91914. }));
  91915. _this._register(modelService.onModelRemoved(function (model) {
  91916. var curr = _this._watchers[model.uri.toString()];
  91917. if (curr) {
  91918. deregister(model, curr);
  91919. }
  91920. }));
  91921. _this._configurationService.onDidChangeConfiguration(function (e) {
  91922. if (e.affectsConfiguration(SemanticColoringFeature.SETTING_ID)) {
  91923. for (var _i = 0, _a = modelService.getModels(); _i < _a.length; _i++) {
  91924. var model = _a[_i];
  91925. var curr = _this._watchers[model.uri.toString()];
  91926. if (isSemanticColoringEnabled(model)) {
  91927. if (!curr) {
  91928. register(model);
  91929. }
  91930. }
  91931. else {
  91932. if (curr) {
  91933. deregister(model, curr);
  91934. }
  91935. }
  91936. }
  91937. }
  91938. });
  91939. return _this;
  91940. }
  91941. SemanticColoringFeature.SETTING_ID = 'editor.semanticHighlighting';
  91942. return SemanticColoringFeature;
  91943. }(lifecycle_1.Disposable));
  91944. var SemanticStyling = /** @class */ (function (_super) {
  91945. __extends(SemanticStyling, _super);
  91946. function SemanticStyling(_themeService, _logService) {
  91947. var _this = _super.call(this) || this;
  91948. _this._themeService = _themeService;
  91949. _this._logService = _logService;
  91950. _this._caches = new WeakMap();
  91951. if (_this._themeService) {
  91952. // workaround for tests which use undefined... :/
  91953. _this._register(_this._themeService.onThemeChange(function () {
  91954. _this._caches = new WeakMap();
  91955. }));
  91956. }
  91957. return _this;
  91958. }
  91959. SemanticStyling.prototype.get = function (provider) {
  91960. if (!this._caches.has(provider)) {
  91961. this._caches.set(provider, new SemanticColoringProviderStyling(provider.getLegend(), this._themeService, this._logService));
  91962. }
  91963. return this._caches.get(provider);
  91964. };
  91965. return SemanticStyling;
  91966. }(lifecycle_1.Disposable));
  91967. var HashTableEntry = /** @class */ (function () {
  91968. function HashTableEntry(tokenTypeIndex, tokenModifierSet, metadata) {
  91969. this.tokenTypeIndex = tokenTypeIndex;
  91970. this.tokenModifierSet = tokenModifierSet;
  91971. this.metadata = metadata;
  91972. this.next = null;
  91973. }
  91974. return HashTableEntry;
  91975. }());
  91976. var HashTable = /** @class */ (function () {
  91977. function HashTable() {
  91978. this._elementsCount = 0;
  91979. this._currentLengthIndex = 0;
  91980. this._currentLength = HashTable._SIZES[this._currentLengthIndex];
  91981. this._growCount = Math.round(this._currentLengthIndex + 1 < HashTable._SIZES.length ? 2 / 3 * this._currentLength : 0);
  91982. this._elements = [];
  91983. HashTable._nullOutEntries(this._elements, this._currentLength);
  91984. }
  91985. HashTable._nullOutEntries = function (entries, length) {
  91986. for (var i = 0; i < length; i++) {
  91987. entries[i] = null;
  91988. }
  91989. };
  91990. HashTable.prototype._hashFunc = function (tokenTypeIndex, tokenModifierSet) {
  91991. return ((((tokenTypeIndex << 5) - tokenTypeIndex) + tokenModifierSet) | 0) % this._currentLength; // tokenTypeIndex * 31 + tokenModifierSet, keep as int32
  91992. };
  91993. HashTable.prototype.get = function (tokenTypeIndex, tokenModifierSet) {
  91994. var hash = this._hashFunc(tokenTypeIndex, tokenModifierSet);
  91995. var p = this._elements[hash];
  91996. while (p) {
  91997. if (p.tokenTypeIndex === tokenTypeIndex && p.tokenModifierSet === tokenModifierSet) {
  91998. return p;
  91999. }
  92000. p = p.next;
  92001. }
  92002. return null;
  92003. };
  92004. HashTable.prototype.add = function (tokenTypeIndex, tokenModifierSet, metadata) {
  92005. this._elementsCount++;
  92006. if (this._growCount !== 0 && this._elementsCount >= this._growCount) {
  92007. // expand!
  92008. var oldElements = this._elements;
  92009. this._currentLengthIndex++;
  92010. this._currentLength = HashTable._SIZES[this._currentLengthIndex];
  92011. this._growCount = Math.round(this._currentLengthIndex + 1 < HashTable._SIZES.length ? 2 / 3 * this._currentLength : 0);
  92012. this._elements = [];
  92013. HashTable._nullOutEntries(this._elements, this._currentLength);
  92014. for (var _i = 0, oldElements_1 = oldElements; _i < oldElements_1.length; _i++) {
  92015. var first = oldElements_1[_i];
  92016. var p = first;
  92017. while (p) {
  92018. var oldNext = p.next;
  92019. p.next = null;
  92020. this._add(p);
  92021. p = oldNext;
  92022. }
  92023. }
  92024. }
  92025. this._add(new HashTableEntry(tokenTypeIndex, tokenModifierSet, metadata));
  92026. };
  92027. HashTable.prototype._add = function (element) {
  92028. var hash = this._hashFunc(element.tokenTypeIndex, element.tokenModifierSet);
  92029. element.next = this._elements[hash];
  92030. this._elements[hash] = element;
  92031. };
  92032. HashTable._SIZES = [3, 7, 13, 31, 61, 127, 251, 509, 1021, 2039, 4093, 8191, 16381, 32749, 65521, 131071, 262139, 524287, 1048573, 2097143];
  92033. return HashTable;
  92034. }());
  92035. var SemanticColoringProviderStyling = /** @class */ (function () {
  92036. function SemanticColoringProviderStyling(_legend, _themeService, _logService) {
  92037. this._legend = _legend;
  92038. this._themeService = _themeService;
  92039. this._logService = _logService;
  92040. this._hashTable = new HashTable();
  92041. }
  92042. SemanticColoringProviderStyling.prototype.getMetadata = function (tokenTypeIndex, tokenModifierSet) {
  92043. var entry = this._hashTable.get(tokenTypeIndex, tokenModifierSet);
  92044. var metadata;
  92045. if (entry) {
  92046. metadata = entry.metadata;
  92047. }
  92048. else {
  92049. var tokenType = this._legend.tokenTypes[tokenTypeIndex];
  92050. var tokenModifiers = [];
  92051. var modifierSet = tokenModifierSet;
  92052. for (var modifierIndex = 0; modifierSet > 0 && modifierIndex < this._legend.tokenModifiers.length; modifierIndex++) {
  92053. if (modifierSet & 1) {
  92054. tokenModifiers.push(this._legend.tokenModifiers[modifierIndex]);
  92055. }
  92056. modifierSet = modifierSet >> 1;
  92057. }
  92058. var tokenStyle = this._themeService.getTheme().getTokenStyleMetadata(tokenType, tokenModifiers);
  92059. if (typeof tokenStyle === 'undefined') {
  92060. metadata = 2147483647 /* NO_STYLING */;
  92061. }
  92062. else {
  92063. metadata = 0;
  92064. if (typeof tokenStyle.italic !== 'undefined') {
  92065. var italicBit = (tokenStyle.italic ? 1 /* Italic */ : 0) << 11 /* FONT_STYLE_OFFSET */;
  92066. metadata |= italicBit | 1 /* SEMANTIC_USE_ITALIC */;
  92067. }
  92068. if (typeof tokenStyle.bold !== 'undefined') {
  92069. var boldBit = (tokenStyle.bold ? 2 /* Bold */ : 0) << 11 /* FONT_STYLE_OFFSET */;
  92070. metadata |= boldBit | 2 /* SEMANTIC_USE_BOLD */;
  92071. }
  92072. if (typeof tokenStyle.underline !== 'undefined') {
  92073. var underlineBit = (tokenStyle.underline ? 4 /* Underline */ : 0) << 11 /* FONT_STYLE_OFFSET */;
  92074. metadata |= underlineBit | 4 /* SEMANTIC_USE_UNDERLINE */;
  92075. }
  92076. if (tokenStyle.foreground) {
  92077. var foregroundBits = (tokenStyle.foreground) << 14 /* FOREGROUND_OFFSET */;
  92078. metadata |= foregroundBits | 8 /* SEMANTIC_USE_FOREGROUND */;
  92079. }
  92080. if (metadata === 0) {
  92081. // Nothing!
  92082. metadata = 2147483647 /* NO_STYLING */;
  92083. }
  92084. }
  92085. this._hashTable.add(tokenTypeIndex, tokenModifierSet, metadata);
  92086. }
  92087. if (this._logService.getLevel() === log_1.LogLevel.Trace) {
  92088. var type = this._legend.tokenTypes[tokenTypeIndex];
  92089. var modifiers = tokenModifierSet ? ' ' + this._legend.tokenModifiers.filter(function (_, i) { return tokenModifierSet & (1 << i); }).join(' ') : '';
  92090. this._logService.trace("tokenStyleMetadata " + (entry ? '[CACHED] ' : '') + type + modifiers + ": foreground " + modes_1.TokenMetadata.getForeground(metadata) + ", fontStyle " + modes_1.TokenMetadata.getFontStyle(metadata).toString(2));
  92091. }
  92092. return metadata;
  92093. };
  92094. return SemanticColoringProviderStyling;
  92095. }());
  92096. var SemanticTokensResponse = /** @class */ (function () {
  92097. function SemanticTokensResponse(_provider, resultId, data) {
  92098. this._provider = _provider;
  92099. this.resultId = resultId;
  92100. this.data = data;
  92101. }
  92102. SemanticTokensResponse.prototype.dispose = function () {
  92103. this._provider.releaseDocumentSemanticTokens(this.resultId);
  92104. };
  92105. return SemanticTokensResponse;
  92106. }());
  92107. var ModelSemanticColoring = /** @class */ (function (_super) {
  92108. __extends(ModelSemanticColoring, _super);
  92109. function ModelSemanticColoring(model, themeService, stylingProvider) {
  92110. var _this = _super.call(this) || this;
  92111. _this._isDisposed = false;
  92112. _this._model = model;
  92113. _this._semanticStyling = stylingProvider;
  92114. _this._fetchSemanticTokens = _this._register(new async_1.RunOnceScheduler(function () { return _this._fetchSemanticTokensNow(); }, 300));
  92115. _this._currentResponse = null;
  92116. _this._currentRequestCancellationTokenSource = null;
  92117. _this._register(_this._model.onDidChangeContent(function (e) {
  92118. if (!_this._fetchSemanticTokens.isScheduled()) {
  92119. _this._fetchSemanticTokens.schedule();
  92120. }
  92121. }));
  92122. _this._register(modes_1.DocumentSemanticTokensProviderRegistry.onDidChange(function (e) { return _this._fetchSemanticTokens.schedule(); }));
  92123. if (themeService) {
  92124. // workaround for tests which use undefined... :/
  92125. _this._register(themeService.onThemeChange(function (_) {
  92126. // clear out existing tokens
  92127. _this._setSemanticTokens(null, null, null, []);
  92128. _this._fetchSemanticTokens.schedule();
  92129. }));
  92130. }
  92131. _this._fetchSemanticTokens.schedule(0);
  92132. return _this;
  92133. }
  92134. ModelSemanticColoring.prototype.dispose = function () {
  92135. if (this._currentResponse) {
  92136. this._currentResponse.dispose();
  92137. this._currentResponse = null;
  92138. }
  92139. if (this._currentRequestCancellationTokenSource) {
  92140. this._currentRequestCancellationTokenSource.cancel();
  92141. this._currentRequestCancellationTokenSource = null;
  92142. }
  92143. this._setSemanticTokens(null, null, null, []);
  92144. this._isDisposed = true;
  92145. _super.prototype.dispose.call(this);
  92146. };
  92147. ModelSemanticColoring.prototype._fetchSemanticTokensNow = function () {
  92148. var _this = this;
  92149. if (this._currentRequestCancellationTokenSource) {
  92150. // there is already a request running, let it finish...
  92151. return;
  92152. }
  92153. var provider = this._getSemanticColoringProvider();
  92154. if (!provider) {
  92155. return;
  92156. }
  92157. this._currentRequestCancellationTokenSource = new cancellation_1.CancellationTokenSource();
  92158. var pendingChanges = [];
  92159. var contentChangeListener = this._model.onDidChangeContent(function (e) {
  92160. pendingChanges.push(e);
  92161. });
  92162. var styling = this._semanticStyling.get(provider);
  92163. var lastResultId = this._currentResponse ? this._currentResponse.resultId || null : null;
  92164. var request = Promise.resolve(provider.provideDocumentSemanticTokens(this._model, lastResultId, this._currentRequestCancellationTokenSource.token));
  92165. request.then(function (res) {
  92166. _this._currentRequestCancellationTokenSource = null;
  92167. contentChangeListener.dispose();
  92168. _this._setSemanticTokens(provider, res || null, styling, pendingChanges);
  92169. }, function (err) {
  92170. if (!err || typeof err.message !== 'string' || err.message.indexOf('busy') === -1) {
  92171. errors.onUnexpectedError(err);
  92172. }
  92173. // Semantic tokens eats up all errors and considers errors to mean that the result is temporarily not available
  92174. // The API does not have a special error kind to express this...
  92175. _this._currentRequestCancellationTokenSource = null;
  92176. contentChangeListener.dispose();
  92177. if (pendingChanges.length > 0) {
  92178. // More changes occurred while the request was running
  92179. if (!_this._fetchSemanticTokens.isScheduled()) {
  92180. _this._fetchSemanticTokens.schedule();
  92181. }
  92182. }
  92183. });
  92184. };
  92185. ModelSemanticColoring._isSemanticTokens = function (v) {
  92186. return v && !!(v.data);
  92187. };
  92188. ModelSemanticColoring._isSemanticTokensEdits = function (v) {
  92189. return v && Array.isArray(v.edits);
  92190. };
  92191. ModelSemanticColoring._copy = function (src, srcOffset, dest, destOffset, length) {
  92192. for (var i = 0; i < length; i++) {
  92193. dest[destOffset + i] = src[srcOffset + i];
  92194. }
  92195. };
  92196. ModelSemanticColoring.prototype._setSemanticTokens = function (provider, tokens, styling, pendingChanges) {
  92197. var currentResponse = this._currentResponse;
  92198. if (this._currentResponse) {
  92199. this._currentResponse.dispose();
  92200. this._currentResponse = null;
  92201. }
  92202. if (this._isDisposed) {
  92203. // disposed!
  92204. if (provider && tokens) {
  92205. provider.releaseDocumentSemanticTokens(tokens.resultId);
  92206. }
  92207. return;
  92208. }
  92209. if (!provider || !tokens || !styling) {
  92210. this._model.setSemanticTokens(null);
  92211. return;
  92212. }
  92213. if (ModelSemanticColoring._isSemanticTokensEdits(tokens)) {
  92214. if (!currentResponse) {
  92215. // not possible!
  92216. this._model.setSemanticTokens(null);
  92217. return;
  92218. }
  92219. if (tokens.edits.length === 0) {
  92220. // nothing to do!
  92221. tokens = {
  92222. resultId: tokens.resultId,
  92223. data: currentResponse.data
  92224. };
  92225. }
  92226. else {
  92227. var deltaLength = 0;
  92228. for (var _i = 0, _a = tokens.edits; _i < _a.length; _i++) {
  92229. var edit = _a[_i];
  92230. deltaLength += (edit.data ? edit.data.length : 0) - edit.deleteCount;
  92231. }
  92232. var srcData = currentResponse.data;
  92233. var destData = new Uint32Array(srcData.length + deltaLength);
  92234. var srcLastStart = srcData.length;
  92235. var destLastStart = destData.length;
  92236. for (var i = tokens.edits.length - 1; i >= 0; i--) {
  92237. var edit = tokens.edits[i];
  92238. var copyCount = srcLastStart - (edit.start + edit.deleteCount);
  92239. if (copyCount > 0) {
  92240. ModelSemanticColoring._copy(srcData, srcLastStart - copyCount, destData, destLastStart - copyCount, copyCount);
  92241. destLastStart -= copyCount;
  92242. }
  92243. if (edit.data) {
  92244. ModelSemanticColoring._copy(edit.data, 0, destData, destLastStart - edit.data.length, edit.data.length);
  92245. destLastStart -= edit.data.length;
  92246. }
  92247. srcLastStart = edit.start;
  92248. }
  92249. if (srcLastStart > 0) {
  92250. ModelSemanticColoring._copy(srcData, 0, destData, 0, srcLastStart);
  92251. }
  92252. tokens = {
  92253. resultId: tokens.resultId,
  92254. data: destData
  92255. };
  92256. }
  92257. }
  92258. if (ModelSemanticColoring._isSemanticTokens(tokens)) {
  92259. this._currentResponse = new SemanticTokensResponse(provider, tokens.resultId, tokens.data);
  92260. var srcData = tokens.data;
  92261. var tokenCount = (tokens.data.length / 5) | 0;
  92262. var tokensPerArea = Math.max(Math.ceil(tokenCount / 1024 /* DesiredMaxAreas */), 400 /* DesiredTokensPerArea */);
  92263. var result = [];
  92264. var tokenIndex = 0;
  92265. var lastLineNumber = 1;
  92266. var lastStartCharacter = 0;
  92267. while (tokenIndex < tokenCount) {
  92268. var tokenStartIndex = tokenIndex;
  92269. var tokenEndIndex = Math.min(tokenStartIndex + tokensPerArea, tokenCount);
  92270. // Keep tokens on the same line in the same area...
  92271. if (tokenEndIndex < tokenCount) {
  92272. var smallTokenEndIndex = tokenEndIndex;
  92273. while (smallTokenEndIndex - 1 > tokenStartIndex && srcData[5 * smallTokenEndIndex] === 0) {
  92274. smallTokenEndIndex--;
  92275. }
  92276. if (smallTokenEndIndex - 1 === tokenStartIndex) {
  92277. // there are so many tokens on this line that our area would be empty, we must now go right
  92278. var bigTokenEndIndex = tokenEndIndex;
  92279. while (bigTokenEndIndex + 1 < tokenCount && srcData[5 * bigTokenEndIndex] === 0) {
  92280. bigTokenEndIndex++;
  92281. }
  92282. tokenEndIndex = bigTokenEndIndex;
  92283. }
  92284. else {
  92285. tokenEndIndex = smallTokenEndIndex;
  92286. }
  92287. }
  92288. var destData = new Uint32Array((tokenEndIndex - tokenStartIndex) * 4);
  92289. var destOffset = 0;
  92290. var areaLine = 0;
  92291. while (tokenIndex < tokenEndIndex) {
  92292. var srcOffset = 5 * tokenIndex;
  92293. var deltaLine = srcData[srcOffset];
  92294. var deltaCharacter = srcData[srcOffset + 1];
  92295. var lineNumber = lastLineNumber + deltaLine;
  92296. var startCharacter = (deltaLine === 0 ? lastStartCharacter + deltaCharacter : deltaCharacter);
  92297. var length_1 = srcData[srcOffset + 2];
  92298. var tokenTypeIndex = srcData[srcOffset + 3];
  92299. var tokenModifierSet = srcData[srcOffset + 4];
  92300. var metadata = styling.getMetadata(tokenTypeIndex, tokenModifierSet);
  92301. if (metadata !== 2147483647 /* NO_STYLING */) {
  92302. if (areaLine === 0) {
  92303. areaLine = lineNumber;
  92304. }
  92305. destData[destOffset] = lineNumber - areaLine;
  92306. destData[destOffset + 1] = startCharacter;
  92307. destData[destOffset + 2] = startCharacter + length_1;
  92308. destData[destOffset + 3] = metadata;
  92309. destOffset += 4;
  92310. }
  92311. lastLineNumber = lineNumber;
  92312. lastStartCharacter = startCharacter;
  92313. tokenIndex++;
  92314. }
  92315. if (destOffset !== destData.length) {
  92316. destData = destData.subarray(0, destOffset);
  92317. }
  92318. var tokens_1 = new tokensStore_1.MultilineTokens2(areaLine, new tokensStore_1.SparseEncodedTokens(destData));
  92319. result.push(tokens_1);
  92320. }
  92321. // Adjust incoming semantic tokens
  92322. if (pendingChanges.length > 0) {
  92323. // More changes occurred while the request was running
  92324. // We need to:
  92325. // 1. Adjust incoming semantic tokens
  92326. // 2. Request them again
  92327. for (var _b = 0, pendingChanges_1 = pendingChanges; _b < pendingChanges_1.length; _b++) {
  92328. var change = pendingChanges_1[_b];
  92329. for (var _c = 0, result_1 = result; _c < result_1.length; _c++) {
  92330. var area = result_1[_c];
  92331. for (var _d = 0, _e = change.changes; _d < _e.length; _d++) {
  92332. var singleChange = _e[_d];
  92333. area.applyEdit(singleChange.range, singleChange.text);
  92334. }
  92335. }
  92336. }
  92337. if (!this._fetchSemanticTokens.isScheduled()) {
  92338. this._fetchSemanticTokens.schedule();
  92339. }
  92340. }
  92341. this._model.setSemanticTokens(result);
  92342. return;
  92343. }
  92344. this._model.setSemanticTokens(null);
  92345. };
  92346. ModelSemanticColoring.prototype._getSemanticColoringProvider = function () {
  92347. var result = modes_1.DocumentSemanticTokensProviderRegistry.ordered(this._model);
  92348. return (result.length > 0 ? result[0] : null);
  92349. };
  92350. return ModelSemanticColoring;
  92351. }(lifecycle_1.Disposable));
  92352. });
  92353. /*---------------------------------------------------------------------------------------------
  92354. * Copyright (c) Microsoft Corporation. All rights reserved.
  92355. * Licensed under the MIT License. See License.txt in the project root for license information.
  92356. *--------------------------------------------------------------------------------------------*/
  92357. define(__m[44/*vs/editor/common/view/editorColorRegistry*/], __M([0/*require*/,1/*exports*/,427/*vs/nls!vs/editor/common/view/editorColorRegistry*/,27/*vs/base/common/color*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/]), function (require, exports, nls, color_1, colorRegistry_1, themeService_1) {
  92358. "use strict";
  92359. Object.defineProperty(exports, "__esModule", { value: true });
  92360. /**
  92361. * Definition of the editor colors
  92362. */
  92363. exports.editorLineHighlight = colorRegistry_1.registerColor('editor.lineHighlightBackground', { dark: null, light: null, hc: null }, nls.localize(0, null));
  92364. exports.editorLineHighlightBorder = colorRegistry_1.registerColor('editor.lineHighlightBorder', { dark: '#282828', light: '#eeeeee', hc: '#f38518' }, nls.localize(1, null));
  92365. exports.editorRangeHighlight = colorRegistry_1.registerColor('editor.rangeHighlightBackground', { dark: '#ffffff0b', light: '#fdff0033', hc: null }, nls.localize(2, null), true);
  92366. exports.editorRangeHighlightBorder = colorRegistry_1.registerColor('editor.rangeHighlightBorder', { dark: null, light: null, hc: colorRegistry_1.activeContrastBorder }, nls.localize(3, null), true);
  92367. exports.editorSymbolHighlight = colorRegistry_1.registerColor('editor.symbolHighlightBackground', { dark: colorRegistry_1.editorFindMatchHighlight, light: colorRegistry_1.editorFindMatchHighlight, hc: null }, nls.localize(4, null), true);
  92368. exports.editorSymbolHighlightBorder = colorRegistry_1.registerColor('editor.symbolHighlightBorder', { dark: null, light: null, hc: colorRegistry_1.activeContrastBorder }, nls.localize(5, null), true);
  92369. exports.editorCursorForeground = colorRegistry_1.registerColor('editorCursor.foreground', { dark: '#AEAFAD', light: color_1.Color.black, hc: color_1.Color.white }, nls.localize(6, null));
  92370. exports.editorCursorBackground = colorRegistry_1.registerColor('editorCursor.background', null, nls.localize(7, null));
  92371. exports.editorWhitespaces = colorRegistry_1.registerColor('editorWhitespace.foreground', { dark: '#e3e4e229', light: '#33333333', hc: '#e3e4e229' }, nls.localize(8, null));
  92372. exports.editorIndentGuides = colorRegistry_1.registerColor('editorIndentGuide.background', { dark: exports.editorWhitespaces, light: exports.editorWhitespaces, hc: exports.editorWhitespaces }, nls.localize(9, null));
  92373. exports.editorActiveIndentGuides = colorRegistry_1.registerColor('editorIndentGuide.activeBackground', { dark: exports.editorWhitespaces, light: exports.editorWhitespaces, hc: exports.editorWhitespaces }, nls.localize(10, null));
  92374. exports.editorLineNumbers = colorRegistry_1.registerColor('editorLineNumber.foreground', { dark: '#858585', light: '#237893', hc: color_1.Color.white }, nls.localize(11, null));
  92375. var deprecatedEditorActiveLineNumber = colorRegistry_1.registerColor('editorActiveLineNumber.foreground', { dark: '#c6c6c6', light: '#0B216F', hc: colorRegistry_1.activeContrastBorder }, nls.localize(12, null), false, nls.localize(13, null));
  92376. exports.editorActiveLineNumber = colorRegistry_1.registerColor('editorLineNumber.activeForeground', { dark: deprecatedEditorActiveLineNumber, light: deprecatedEditorActiveLineNumber, hc: deprecatedEditorActiveLineNumber }, nls.localize(14, null));
  92377. exports.editorRuler = colorRegistry_1.registerColor('editorRuler.foreground', { dark: '#5A5A5A', light: color_1.Color.lightgrey, hc: color_1.Color.white }, nls.localize(15, null));
  92378. exports.editorCodeLensForeground = colorRegistry_1.registerColor('editorCodeLens.foreground', { dark: '#999999', light: '#999999', hc: '#999999' }, nls.localize(16, null));
  92379. exports.editorBracketMatchBackground = colorRegistry_1.registerColor('editorBracketMatch.background', { dark: '#0064001a', light: '#0064001a', hc: '#0064001a' }, nls.localize(17, null));
  92380. exports.editorBracketMatchBorder = colorRegistry_1.registerColor('editorBracketMatch.border', { dark: '#888', light: '#B9B9B9', hc: colorRegistry_1.contrastBorder }, nls.localize(18, null));
  92381. exports.editorOverviewRulerBorder = colorRegistry_1.registerColor('editorOverviewRuler.border', { dark: '#7f7f7f4d', light: '#7f7f7f4d', hc: '#7f7f7f4d' }, nls.localize(19, null));
  92382. exports.editorGutter = colorRegistry_1.registerColor('editorGutter.background', { dark: colorRegistry_1.editorBackground, light: colorRegistry_1.editorBackground, hc: colorRegistry_1.editorBackground }, nls.localize(20, null));
  92383. exports.editorUnnecessaryCodeBorder = colorRegistry_1.registerColor('editorUnnecessaryCode.border', { dark: null, light: null, hc: color_1.Color.fromHex('#fff').transparent(0.8) }, nls.localize(21, null));
  92384. exports.editorUnnecessaryCodeOpacity = colorRegistry_1.registerColor('editorUnnecessaryCode.opacity', { dark: color_1.Color.fromHex('#000a'), light: color_1.Color.fromHex('#0007'), hc: null }, nls.localize(22, null));
  92385. exports.overviewRulerError = colorRegistry_1.registerColor('editorOverviewRuler.errorForeground', { dark: new color_1.Color(new color_1.RGBA(255, 18, 18, 0.7)), light: new color_1.Color(new color_1.RGBA(255, 18, 18, 0.7)), hc: new color_1.Color(new color_1.RGBA(255, 50, 50, 1)) }, nls.localize(23, null));
  92386. exports.overviewRulerWarning = colorRegistry_1.registerColor('editorOverviewRuler.warningForeground', { dark: colorRegistry_1.editorWarningForeground, light: colorRegistry_1.editorWarningForeground, hc: colorRegistry_1.editorWarningBorder }, nls.localize(24, null));
  92387. exports.overviewRulerInfo = colorRegistry_1.registerColor('editorOverviewRuler.infoForeground', { dark: colorRegistry_1.editorInfoForeground, light: colorRegistry_1.editorInfoForeground, hc: colorRegistry_1.editorInfoBorder }, nls.localize(25, null));
  92388. // contains all color rules that used to defined in editor/browser/widget/editor.css
  92389. themeService_1.registerThemingParticipant(function (theme, collector) {
  92390. var background = theme.getColor(colorRegistry_1.editorBackground);
  92391. if (background) {
  92392. collector.addRule(".monaco-editor, .monaco-editor-background, .monaco-editor .inputarea.ime-input { background-color: " + background + "; }");
  92393. }
  92394. var foreground = theme.getColor(colorRegistry_1.editorForeground);
  92395. if (foreground) {
  92396. collector.addRule(".monaco-editor, .monaco-editor .inputarea.ime-input { color: " + foreground + "; }");
  92397. }
  92398. var gutter = theme.getColor(exports.editorGutter);
  92399. if (gutter) {
  92400. collector.addRule(".monaco-editor .margin { background-color: " + gutter + "; }");
  92401. }
  92402. var rangeHighlight = theme.getColor(exports.editorRangeHighlight);
  92403. if (rangeHighlight) {
  92404. collector.addRule(".monaco-editor .rangeHighlight { background-color: " + rangeHighlight + "; }");
  92405. }
  92406. var rangeHighlightBorder = theme.getColor(exports.editorRangeHighlightBorder);
  92407. if (rangeHighlightBorder) {
  92408. collector.addRule(".monaco-editor .rangeHighlight { border: 1px " + (theme.type === 'hc' ? 'dotted' : 'solid') + " " + rangeHighlightBorder + "; }");
  92409. }
  92410. var symbolHighlight = theme.getColor(exports.editorSymbolHighlight);
  92411. if (symbolHighlight) {
  92412. collector.addRule(".monaco-editor .symbolHighlight { background-color: " + symbolHighlight + "; }");
  92413. }
  92414. var symbolHighlightBorder = theme.getColor(exports.editorSymbolHighlightBorder);
  92415. if (symbolHighlightBorder) {
  92416. collector.addRule(".monaco-editor .symbolHighlight { border: 1px " + (theme.type === 'hc' ? 'dotted' : 'solid') + " " + symbolHighlightBorder + "; }");
  92417. }
  92418. var invisibles = theme.getColor(exports.editorWhitespaces);
  92419. if (invisibles) {
  92420. collector.addRule(".vs-whitespace { color: " + invisibles + " !important; }");
  92421. }
  92422. });
  92423. });
  92424. /*---------------------------------------------------------------------------------------------
  92425. * Copyright (c) Microsoft Corporation. All rights reserved.
  92426. * Licensed under the MIT License. See License.txt in the project root for license information.
  92427. *--------------------------------------------------------------------------------------------*/
  92428. define(__m[557/*vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight*/], __M([0/*require*/,1/*exports*/,82/*vs/editor/browser/view/dynamicViewOverlay*/,44/*vs/editor/common/view/editorColorRegistry*/,19/*vs/base/common/arrays*/,14/*vs/platform/theme/common/themeService*/,285/*vs/css!vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight*/]), function (require, exports, dynamicViewOverlay_1, editorColorRegistry_1, arrays, themeService_1) {
  92429. "use strict";
  92430. Object.defineProperty(exports, "__esModule", { value: true });
  92431. var isRenderedUsingBorder = true;
  92432. var AbstractLineHighlightOverlay = /** @class */ (function (_super) {
  92433. __extends(AbstractLineHighlightOverlay, _super);
  92434. function AbstractLineHighlightOverlay(context) {
  92435. var _this = _super.call(this) || this;
  92436. _this._context = context;
  92437. var options = _this._context.configuration.options;
  92438. var layoutInfo = options.get(107 /* layoutInfo */);
  92439. _this._lineHeight = options.get(49 /* lineHeight */);
  92440. _this._renderLineHighlight = options.get(72 /* renderLineHighlight */);
  92441. _this._contentLeft = layoutInfo.contentLeft;
  92442. _this._contentWidth = layoutInfo.contentWidth;
  92443. _this._selectionIsEmpty = true;
  92444. _this._cursorLineNumbers = [];
  92445. _this._selections = [];
  92446. _this._renderData = null;
  92447. _this._context.addEventHandler(_this);
  92448. return _this;
  92449. }
  92450. AbstractLineHighlightOverlay.prototype.dispose = function () {
  92451. this._context.removeEventHandler(this);
  92452. _super.prototype.dispose.call(this);
  92453. };
  92454. AbstractLineHighlightOverlay.prototype._readFromSelections = function () {
  92455. var hasChanged = false;
  92456. // Only render the first selection when using border
  92457. var renderSelections = isRenderedUsingBorder ? this._selections.slice(0, 1) : this._selections;
  92458. var cursorsLineNumbers = renderSelections.map(function (s) { return s.positionLineNumber; });
  92459. cursorsLineNumbers.sort(function (a, b) { return a - b; });
  92460. if (!arrays.equals(this._cursorLineNumbers, cursorsLineNumbers)) {
  92461. this._cursorLineNumbers = cursorsLineNumbers;
  92462. hasChanged = true;
  92463. }
  92464. var selectionIsEmpty = renderSelections.every(function (s) { return s.isEmpty(); });
  92465. if (this._selectionIsEmpty !== selectionIsEmpty) {
  92466. this._selectionIsEmpty = selectionIsEmpty;
  92467. hasChanged = true;
  92468. }
  92469. return hasChanged;
  92470. };
  92471. // --- begin event handlers
  92472. AbstractLineHighlightOverlay.prototype.onThemeChanged = function (e) {
  92473. return this._readFromSelections();
  92474. };
  92475. AbstractLineHighlightOverlay.prototype.onConfigurationChanged = function (e) {
  92476. var options = this._context.configuration.options;
  92477. var layoutInfo = options.get(107 /* layoutInfo */);
  92478. this._lineHeight = options.get(49 /* lineHeight */);
  92479. this._renderLineHighlight = options.get(72 /* renderLineHighlight */);
  92480. this._contentLeft = layoutInfo.contentLeft;
  92481. this._contentWidth = layoutInfo.contentWidth;
  92482. return true;
  92483. };
  92484. AbstractLineHighlightOverlay.prototype.onCursorStateChanged = function (e) {
  92485. this._selections = e.selections;
  92486. return this._readFromSelections();
  92487. };
  92488. AbstractLineHighlightOverlay.prototype.onFlushed = function (e) {
  92489. return true;
  92490. };
  92491. AbstractLineHighlightOverlay.prototype.onLinesDeleted = function (e) {
  92492. return true;
  92493. };
  92494. AbstractLineHighlightOverlay.prototype.onLinesInserted = function (e) {
  92495. return true;
  92496. };
  92497. AbstractLineHighlightOverlay.prototype.onScrollChanged = function (e) {
  92498. return e.scrollWidthChanged || e.scrollTopChanged;
  92499. };
  92500. AbstractLineHighlightOverlay.prototype.onZonesChanged = function (e) {
  92501. return true;
  92502. };
  92503. // --- end event handlers
  92504. AbstractLineHighlightOverlay.prototype.prepareRender = function (ctx) {
  92505. if (!this._shouldRenderThis()) {
  92506. this._renderData = null;
  92507. return;
  92508. }
  92509. var renderedLine = this._renderOne(ctx);
  92510. var visibleStartLineNumber = ctx.visibleRange.startLineNumber;
  92511. var visibleEndLineNumber = ctx.visibleRange.endLineNumber;
  92512. var len = this._cursorLineNumbers.length;
  92513. var index = 0;
  92514. var renderData = [];
  92515. for (var lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
  92516. var lineIndex = lineNumber - visibleStartLineNumber;
  92517. while (index < len && this._cursorLineNumbers[index] < lineNumber) {
  92518. index++;
  92519. }
  92520. if (index < len && this._cursorLineNumbers[index] === lineNumber) {
  92521. renderData[lineIndex] = renderedLine;
  92522. }
  92523. else {
  92524. renderData[lineIndex] = '';
  92525. }
  92526. }
  92527. this._renderData = renderData;
  92528. };
  92529. AbstractLineHighlightOverlay.prototype.render = function (startLineNumber, lineNumber) {
  92530. if (!this._renderData) {
  92531. return '';
  92532. }
  92533. var lineIndex = lineNumber - startLineNumber;
  92534. if (lineIndex >= this._renderData.length) {
  92535. return '';
  92536. }
  92537. return this._renderData[lineIndex];
  92538. };
  92539. return AbstractLineHighlightOverlay;
  92540. }(dynamicViewOverlay_1.DynamicViewOverlay));
  92541. exports.AbstractLineHighlightOverlay = AbstractLineHighlightOverlay;
  92542. var CurrentLineHighlightOverlay = /** @class */ (function (_super) {
  92543. __extends(CurrentLineHighlightOverlay, _super);
  92544. function CurrentLineHighlightOverlay() {
  92545. return _super !== null && _super.apply(this, arguments) || this;
  92546. }
  92547. CurrentLineHighlightOverlay.prototype._renderOne = function (ctx) {
  92548. var className = 'current-line' + (this._shouldRenderOther() ? ' current-line-both' : '');
  92549. return "<div class=\"" + className + "\" style=\"width:" + Math.max(ctx.scrollWidth, this._contentWidth) + "px; height:" + this._lineHeight + "px;\"></div>";
  92550. };
  92551. CurrentLineHighlightOverlay.prototype._shouldRenderThis = function () {
  92552. return ((this._renderLineHighlight === 'line' || this._renderLineHighlight === 'all')
  92553. && this._selectionIsEmpty);
  92554. };
  92555. CurrentLineHighlightOverlay.prototype._shouldRenderOther = function () {
  92556. return ((this._renderLineHighlight === 'gutter' || this._renderLineHighlight === 'all'));
  92557. };
  92558. return CurrentLineHighlightOverlay;
  92559. }(AbstractLineHighlightOverlay));
  92560. exports.CurrentLineHighlightOverlay = CurrentLineHighlightOverlay;
  92561. var CurrentLineMarginHighlightOverlay = /** @class */ (function (_super) {
  92562. __extends(CurrentLineMarginHighlightOverlay, _super);
  92563. function CurrentLineMarginHighlightOverlay() {
  92564. return _super !== null && _super.apply(this, arguments) || this;
  92565. }
  92566. CurrentLineMarginHighlightOverlay.prototype._renderOne = function (ctx) {
  92567. var className = 'current-line current-line-margin' + (this._shouldRenderOther() ? ' current-line-margin-both' : '');
  92568. return "<div class=\"" + className + "\" style=\"width:" + this._contentLeft + "px; height:" + this._lineHeight + "px;\"></div>";
  92569. };
  92570. CurrentLineMarginHighlightOverlay.prototype._shouldRenderThis = function () {
  92571. return ((this._renderLineHighlight === 'gutter' || this._renderLineHighlight === 'all'));
  92572. };
  92573. CurrentLineMarginHighlightOverlay.prototype._shouldRenderOther = function () {
  92574. return ((this._renderLineHighlight === 'line' || this._renderLineHighlight === 'all')
  92575. && this._selectionIsEmpty);
  92576. };
  92577. return CurrentLineMarginHighlightOverlay;
  92578. }(AbstractLineHighlightOverlay));
  92579. exports.CurrentLineMarginHighlightOverlay = CurrentLineMarginHighlightOverlay;
  92580. themeService_1.registerThemingParticipant(function (theme, collector) {
  92581. isRenderedUsingBorder = false;
  92582. var lineHighlight = theme.getColor(editorColorRegistry_1.editorLineHighlight);
  92583. if (lineHighlight) {
  92584. collector.addRule(".monaco-editor .view-overlays .current-line { background-color: " + lineHighlight + "; }");
  92585. collector.addRule(".monaco-editor .margin-view-overlays .current-line-margin { background-color: " + lineHighlight + "; border: none; }");
  92586. }
  92587. if (!lineHighlight || lineHighlight.isTransparent() || theme.defines(editorColorRegistry_1.editorLineHighlightBorder)) {
  92588. var lineHighlightBorder = theme.getColor(editorColorRegistry_1.editorLineHighlightBorder);
  92589. if (lineHighlightBorder) {
  92590. isRenderedUsingBorder = true;
  92591. collector.addRule(".monaco-editor .view-overlays .current-line { border: 2px solid " + lineHighlightBorder + "; }");
  92592. collector.addRule(".monaco-editor .margin-view-overlays .current-line-margin { border: 2px solid " + lineHighlightBorder + "; }");
  92593. if (theme.type === 'hc') {
  92594. collector.addRule(".monaco-editor .view-overlays .current-line { border-width: 1px; }");
  92595. collector.addRule(".monaco-editor .margin-view-overlays .current-line-margin { border-width: 1px; }");
  92596. }
  92597. }
  92598. }
  92599. });
  92600. });
  92601. /*---------------------------------------------------------------------------------------------
  92602. * Copyright (c) Microsoft Corporation. All rights reserved.
  92603. * Licensed under the MIT License. See License.txt in the project root for license information.
  92604. *--------------------------------------------------------------------------------------------*/
  92605. define(__m[558/*vs/editor/browser/viewParts/indentGuides/indentGuides*/], __M([0/*require*/,1/*exports*/,82/*vs/editor/browser/view/dynamicViewOverlay*/,13/*vs/editor/common/core/position*/,44/*vs/editor/common/view/editorColorRegistry*/,14/*vs/platform/theme/common/themeService*/,288/*vs/css!vs/editor/browser/viewParts/indentGuides/indentGuides*/]), function (require, exports, dynamicViewOverlay_1, position_1, editorColorRegistry_1, themeService_1) {
  92606. "use strict";
  92607. Object.defineProperty(exports, "__esModule", { value: true });
  92608. var IndentGuidesOverlay = /** @class */ (function (_super) {
  92609. __extends(IndentGuidesOverlay, _super);
  92610. function IndentGuidesOverlay(context) {
  92611. var _this = _super.call(this) || this;
  92612. _this._context = context;
  92613. _this._primaryLineNumber = 0;
  92614. var options = _this._context.configuration.options;
  92615. var wrappingInfo = options.get(108 /* wrappingInfo */);
  92616. var fontInfo = options.get(34 /* fontInfo */);
  92617. _this._lineHeight = options.get(49 /* lineHeight */);
  92618. _this._spaceWidth = fontInfo.spaceWidth;
  92619. _this._enabled = options.get(70 /* renderIndentGuides */);
  92620. _this._activeIndentEnabled = options.get(43 /* highlightActiveIndentGuide */);
  92621. _this._maxIndentLeft = wrappingInfo.wrappingColumn === -1 ? -1 : (wrappingInfo.wrappingColumn * fontInfo.typicalHalfwidthCharacterWidth);
  92622. _this._renderResult = null;
  92623. _this._context.addEventHandler(_this);
  92624. return _this;
  92625. }
  92626. IndentGuidesOverlay.prototype.dispose = function () {
  92627. this._context.removeEventHandler(this);
  92628. this._renderResult = null;
  92629. _super.prototype.dispose.call(this);
  92630. };
  92631. // --- begin event handlers
  92632. IndentGuidesOverlay.prototype.onConfigurationChanged = function (e) {
  92633. var options = this._context.configuration.options;
  92634. var wrappingInfo = options.get(108 /* wrappingInfo */);
  92635. var fontInfo = options.get(34 /* fontInfo */);
  92636. this._lineHeight = options.get(49 /* lineHeight */);
  92637. this._spaceWidth = fontInfo.spaceWidth;
  92638. this._enabled = options.get(70 /* renderIndentGuides */);
  92639. this._activeIndentEnabled = options.get(43 /* highlightActiveIndentGuide */);
  92640. this._maxIndentLeft = wrappingInfo.wrappingColumn === -1 ? -1 : (wrappingInfo.wrappingColumn * fontInfo.typicalHalfwidthCharacterWidth);
  92641. return true;
  92642. };
  92643. IndentGuidesOverlay.prototype.onCursorStateChanged = function (e) {
  92644. var selection = e.selections[0];
  92645. var newPrimaryLineNumber = selection.isEmpty() ? selection.positionLineNumber : 0;
  92646. if (this._primaryLineNumber !== newPrimaryLineNumber) {
  92647. this._primaryLineNumber = newPrimaryLineNumber;
  92648. return true;
  92649. }
  92650. return false;
  92651. };
  92652. IndentGuidesOverlay.prototype.onDecorationsChanged = function (e) {
  92653. // true for inline decorations
  92654. return true;
  92655. };
  92656. IndentGuidesOverlay.prototype.onFlushed = function (e) {
  92657. return true;
  92658. };
  92659. IndentGuidesOverlay.prototype.onLinesChanged = function (e) {
  92660. return true;
  92661. };
  92662. IndentGuidesOverlay.prototype.onLinesDeleted = function (e) {
  92663. return true;
  92664. };
  92665. IndentGuidesOverlay.prototype.onLinesInserted = function (e) {
  92666. return true;
  92667. };
  92668. IndentGuidesOverlay.prototype.onScrollChanged = function (e) {
  92669. return e.scrollTopChanged; // || e.scrollWidthChanged;
  92670. };
  92671. IndentGuidesOverlay.prototype.onZonesChanged = function (e) {
  92672. return true;
  92673. };
  92674. IndentGuidesOverlay.prototype.onLanguageConfigurationChanged = function (e) {
  92675. return true;
  92676. };
  92677. // --- end event handlers
  92678. IndentGuidesOverlay.prototype.prepareRender = function (ctx) {
  92679. if (!this._enabled) {
  92680. this._renderResult = null;
  92681. return;
  92682. }
  92683. var visibleStartLineNumber = ctx.visibleRange.startLineNumber;
  92684. var visibleEndLineNumber = ctx.visibleRange.endLineNumber;
  92685. var indentSize = this._context.model.getOptions().indentSize;
  92686. var indentWidth = indentSize * this._spaceWidth;
  92687. var scrollWidth = ctx.scrollWidth;
  92688. var lineHeight = this._lineHeight;
  92689. var indents = this._context.model.getLinesIndentGuides(visibleStartLineNumber, visibleEndLineNumber);
  92690. var activeIndentStartLineNumber = 0;
  92691. var activeIndentEndLineNumber = 0;
  92692. var activeIndentLevel = 0;
  92693. if (this._activeIndentEnabled && this._primaryLineNumber) {
  92694. var activeIndentInfo = this._context.model.getActiveIndentGuide(this._primaryLineNumber, visibleStartLineNumber, visibleEndLineNumber);
  92695. activeIndentStartLineNumber = activeIndentInfo.startLineNumber;
  92696. activeIndentEndLineNumber = activeIndentInfo.endLineNumber;
  92697. activeIndentLevel = activeIndentInfo.indent;
  92698. }
  92699. var output = [];
  92700. for (var lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
  92701. var containsActiveIndentGuide = (activeIndentStartLineNumber <= lineNumber && lineNumber <= activeIndentEndLineNumber);
  92702. var lineIndex = lineNumber - visibleStartLineNumber;
  92703. var indent = indents[lineIndex];
  92704. var result = '';
  92705. if (indent >= 1) {
  92706. var leftMostVisiblePosition = ctx.visibleRangeForPosition(new position_1.Position(lineNumber, 1));
  92707. var left = leftMostVisiblePosition ? leftMostVisiblePosition.left : 0;
  92708. for (var i = 1; i <= indent; i++) {
  92709. var className = (containsActiveIndentGuide && i === activeIndentLevel ? 'cigra' : 'cigr');
  92710. result += "<div class=\"" + className + "\" style=\"left:" + left + "px;height:" + lineHeight + "px;width:" + indentWidth + "px\"></div>";
  92711. left += indentWidth;
  92712. if (left > scrollWidth || (this._maxIndentLeft > 0 && left > this._maxIndentLeft)) {
  92713. break;
  92714. }
  92715. }
  92716. }
  92717. output[lineIndex] = result;
  92718. }
  92719. this._renderResult = output;
  92720. };
  92721. IndentGuidesOverlay.prototype.render = function (startLineNumber, lineNumber) {
  92722. if (!this._renderResult) {
  92723. return '';
  92724. }
  92725. var lineIndex = lineNumber - startLineNumber;
  92726. if (lineIndex < 0 || lineIndex >= this._renderResult.length) {
  92727. return '';
  92728. }
  92729. return this._renderResult[lineIndex];
  92730. };
  92731. return IndentGuidesOverlay;
  92732. }(dynamicViewOverlay_1.DynamicViewOverlay));
  92733. exports.IndentGuidesOverlay = IndentGuidesOverlay;
  92734. themeService_1.registerThemingParticipant(function (theme, collector) {
  92735. var editorIndentGuidesColor = theme.getColor(editorColorRegistry_1.editorIndentGuides);
  92736. if (editorIndentGuidesColor) {
  92737. collector.addRule(".monaco-editor .lines-content .cigr { box-shadow: 1px 0 0 0 " + editorIndentGuidesColor + " inset; }");
  92738. }
  92739. var editorActiveIndentGuidesColor = theme.getColor(editorColorRegistry_1.editorActiveIndentGuides) || editorIndentGuidesColor;
  92740. if (editorActiveIndentGuidesColor) {
  92741. collector.addRule(".monaco-editor .lines-content .cigra { box-shadow: 1px 0 0 0 " + editorActiveIndentGuidesColor + " inset; }");
  92742. }
  92743. });
  92744. });
  92745. /*---------------------------------------------------------------------------------------------
  92746. * Copyright (c) Microsoft Corporation. All rights reserved.
  92747. * Licensed under the MIT License. See License.txt in the project root for license information.
  92748. *--------------------------------------------------------------------------------------------*/
  92749. define(__m[229/*vs/editor/browser/viewParts/lineNumbers/lineNumbers*/], __M([0/*require*/,1/*exports*/,16/*vs/base/common/platform*/,82/*vs/editor/browser/view/dynamicViewOverlay*/,13/*vs/editor/common/core/position*/,44/*vs/editor/common/view/editorColorRegistry*/,14/*vs/platform/theme/common/themeService*/,289/*vs/css!vs/editor/browser/viewParts/lineNumbers/lineNumbers*/]), function (require, exports, platform, dynamicViewOverlay_1, position_1, editorColorRegistry_1, themeService_1) {
  92750. "use strict";
  92751. Object.defineProperty(exports, "__esModule", { value: true });
  92752. var LineNumbersOverlay = /** @class */ (function (_super) {
  92753. __extends(LineNumbersOverlay, _super);
  92754. function LineNumbersOverlay(context) {
  92755. var _this = _super.call(this) || this;
  92756. _this._context = context;
  92757. _this._readConfig();
  92758. _this._lastCursorModelPosition = new position_1.Position(1, 1);
  92759. _this._renderResult = null;
  92760. _this._context.addEventHandler(_this);
  92761. return _this;
  92762. }
  92763. LineNumbersOverlay.prototype._readConfig = function () {
  92764. var options = this._context.configuration.options;
  92765. this._lineHeight = options.get(49 /* lineHeight */);
  92766. var lineNumbers = options.get(50 /* lineNumbers */);
  92767. this._renderLineNumbers = lineNumbers.renderType;
  92768. this._renderCustomLineNumbers = lineNumbers.renderFn;
  92769. this._renderFinalNewline = options.get(71 /* renderFinalNewline */);
  92770. var layoutInfo = options.get(107 /* layoutInfo */);
  92771. this._lineNumbersLeft = layoutInfo.lineNumbersLeft;
  92772. this._lineNumbersWidth = layoutInfo.lineNumbersWidth;
  92773. };
  92774. LineNumbersOverlay.prototype.dispose = function () {
  92775. this._context.removeEventHandler(this);
  92776. this._renderResult = null;
  92777. _super.prototype.dispose.call(this);
  92778. };
  92779. // --- begin event handlers
  92780. LineNumbersOverlay.prototype.onConfigurationChanged = function (e) {
  92781. this._readConfig();
  92782. return true;
  92783. };
  92784. LineNumbersOverlay.prototype.onCursorStateChanged = function (e) {
  92785. var primaryViewPosition = e.selections[0].getPosition();
  92786. this._lastCursorModelPosition = this._context.model.coordinatesConverter.convertViewPositionToModelPosition(primaryViewPosition);
  92787. if (this._renderLineNumbers === 2 /* Relative */ || this._renderLineNumbers === 3 /* Interval */) {
  92788. return true;
  92789. }
  92790. return false;
  92791. };
  92792. LineNumbersOverlay.prototype.onFlushed = function (e) {
  92793. return true;
  92794. };
  92795. LineNumbersOverlay.prototype.onLinesChanged = function (e) {
  92796. return true;
  92797. };
  92798. LineNumbersOverlay.prototype.onLinesDeleted = function (e) {
  92799. return true;
  92800. };
  92801. LineNumbersOverlay.prototype.onLinesInserted = function (e) {
  92802. return true;
  92803. };
  92804. LineNumbersOverlay.prototype.onScrollChanged = function (e) {
  92805. return e.scrollTopChanged;
  92806. };
  92807. LineNumbersOverlay.prototype.onZonesChanged = function (e) {
  92808. return true;
  92809. };
  92810. // --- end event handlers
  92811. LineNumbersOverlay.prototype._getLineRenderLineNumber = function (viewLineNumber) {
  92812. var modelPosition = this._context.model.coordinatesConverter.convertViewPositionToModelPosition(new position_1.Position(viewLineNumber, 1));
  92813. if (modelPosition.column !== 1) {
  92814. return '';
  92815. }
  92816. var modelLineNumber = modelPosition.lineNumber;
  92817. if (this._renderCustomLineNumbers) {
  92818. return this._renderCustomLineNumbers(modelLineNumber);
  92819. }
  92820. if (this._renderLineNumbers === 2 /* Relative */) {
  92821. var diff = Math.abs(this._lastCursorModelPosition.lineNumber - modelLineNumber);
  92822. if (diff === 0) {
  92823. return '<span class="relative-current-line-number">' + modelLineNumber + '</span>';
  92824. }
  92825. return String(diff);
  92826. }
  92827. if (this._renderLineNumbers === 3 /* Interval */) {
  92828. if (this._lastCursorModelPosition.lineNumber === modelLineNumber) {
  92829. return String(modelLineNumber);
  92830. }
  92831. if (modelLineNumber % 10 === 0) {
  92832. return String(modelLineNumber);
  92833. }
  92834. return '';
  92835. }
  92836. return String(modelLineNumber);
  92837. };
  92838. LineNumbersOverlay.prototype.prepareRender = function (ctx) {
  92839. if (this._renderLineNumbers === 0 /* Off */) {
  92840. this._renderResult = null;
  92841. return;
  92842. }
  92843. var lineHeightClassName = (platform.isLinux ? (this._lineHeight % 2 === 0 ? ' lh-even' : ' lh-odd') : '');
  92844. var visibleStartLineNumber = ctx.visibleRange.startLineNumber;
  92845. var visibleEndLineNumber = ctx.visibleRange.endLineNumber;
  92846. var common = '<div class="' + LineNumbersOverlay.CLASS_NAME + lineHeightClassName + '" style="left:' + this._lineNumbersLeft.toString() + 'px;width:' + this._lineNumbersWidth.toString() + 'px;">';
  92847. var lineCount = this._context.model.getLineCount();
  92848. var output = [];
  92849. for (var lineNumber = visibleStartLineNumber; lineNumber <= visibleEndLineNumber; lineNumber++) {
  92850. var lineIndex = lineNumber - visibleStartLineNumber;
  92851. if (!this._renderFinalNewline) {
  92852. if (lineNumber === lineCount && this._context.model.getLineLength(lineNumber) === 0) {
  92853. // Do not render last (empty) line
  92854. output[lineIndex] = '';
  92855. continue;
  92856. }
  92857. }
  92858. var renderLineNumber = this._getLineRenderLineNumber(lineNumber);
  92859. if (renderLineNumber) {
  92860. output[lineIndex] = (common
  92861. + renderLineNumber
  92862. + '</div>');
  92863. }
  92864. else {
  92865. output[lineIndex] = '';
  92866. }
  92867. }
  92868. this._renderResult = output;
  92869. };
  92870. LineNumbersOverlay.prototype.render = function (startLineNumber, lineNumber) {
  92871. if (!this._renderResult) {
  92872. return '';
  92873. }
  92874. var lineIndex = lineNumber - startLineNumber;
  92875. if (lineIndex < 0 || lineIndex >= this._renderResult.length) {
  92876. return '';
  92877. }
  92878. return this._renderResult[lineIndex];
  92879. };
  92880. LineNumbersOverlay.CLASS_NAME = 'line-numbers';
  92881. return LineNumbersOverlay;
  92882. }(dynamicViewOverlay_1.DynamicViewOverlay));
  92883. exports.LineNumbersOverlay = LineNumbersOverlay;
  92884. // theming
  92885. themeService_1.registerThemingParticipant(function (theme, collector) {
  92886. var lineNumbers = theme.getColor(editorColorRegistry_1.editorLineNumbers);
  92887. if (lineNumbers) {
  92888. collector.addRule(".monaco-editor .line-numbers { color: " + lineNumbers + "; }");
  92889. }
  92890. var activeLineNumber = theme.getColor(editorColorRegistry_1.editorActiveLineNumber);
  92891. if (activeLineNumber) {
  92892. collector.addRule(".monaco-editor .current-line ~ .line-numbers { color: " + activeLineNumber + "; }");
  92893. }
  92894. });
  92895. });
  92896. /*---------------------------------------------------------------------------------------------
  92897. * Copyright (c) Microsoft Corporation. All rights reserved.
  92898. * Licensed under the MIT License. See License.txt in the project root for license information.
  92899. *--------------------------------------------------------------------------------------------*/
  92900. define(__m[559/*vs/editor/browser/controller/textAreaHandler*/], __M([0/*require*/,1/*exports*/,416/*vs/nls!vs/editor/browser/controller/textAreaHandler*/,24/*vs/base/browser/browser*/,28/*vs/base/browser/fastDomNode*/,16/*vs/base/common/platform*/,5/*vs/base/common/strings*/,60/*vs/editor/browser/config/configuration*/,189/*vs/editor/browser/controller/textAreaInput*/,187/*vs/editor/browser/controller/textAreaState*/,37/*vs/editor/browser/view/viewPart*/,229/*vs/editor/browser/viewParts/lineNumbers/lineNumbers*/,195/*vs/editor/browser/viewParts/margin/margin*/,33/*vs/editor/common/config/editorOptions*/,89/*vs/editor/common/controller/wordCharacterClassifier*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,81/*vs/editor/common/view/viewEvents*/,284/*vs/css!vs/editor/browser/controller/textAreaHandler*/]), function (require, exports, nls, browser, fastDomNode_1, platform, strings, configuration_1, textAreaInput_1, textAreaState_1, viewPart_1, lineNumbers_1, margin_1, editorOptions_1, wordCharacterClassifier_1, position_1, range_1, selection_1, viewEvents) {
  92901. "use strict";
  92902. Object.defineProperty(exports, "__esModule", { value: true });
  92903. var VisibleTextAreaData = /** @class */ (function () {
  92904. function VisibleTextAreaData(top, left, width) {
  92905. this.top = top;
  92906. this.left = left;
  92907. this.width = width;
  92908. }
  92909. VisibleTextAreaData.prototype.setWidth = function (width) {
  92910. return new VisibleTextAreaData(this.top, this.left, width);
  92911. };
  92912. return VisibleTextAreaData;
  92913. }());
  92914. var canUseZeroSizeTextarea = (browser.isEdgeOrIE || browser.isFirefox);
  92915. var TextAreaHandler = /** @class */ (function (_super) {
  92916. __extends(TextAreaHandler, _super);
  92917. function TextAreaHandler(context, viewController, viewHelper) {
  92918. var _this = _super.call(this, context) || this;
  92919. // --- end view API
  92920. _this._primaryCursorPosition = new position_1.Position(1, 1);
  92921. _this._primaryCursorVisibleRange = null;
  92922. _this._viewController = viewController;
  92923. _this._viewHelper = viewHelper;
  92924. _this._scrollLeft = 0;
  92925. _this._scrollTop = 0;
  92926. var options = _this._context.configuration.options;
  92927. var layoutInfo = options.get(107 /* layoutInfo */);
  92928. _this._setAccessibilityOptions(options);
  92929. _this._contentLeft = layoutInfo.contentLeft;
  92930. _this._contentWidth = layoutInfo.contentWidth;
  92931. _this._contentHeight = layoutInfo.height;
  92932. _this._fontInfo = options.get(34 /* fontInfo */);
  92933. _this._lineHeight = options.get(49 /* lineHeight */);
  92934. _this._emptySelectionClipboard = options.get(25 /* emptySelectionClipboard */);
  92935. _this._copyWithSyntaxHighlighting = options.get(15 /* copyWithSyntaxHighlighting */);
  92936. _this._visibleTextArea = null;
  92937. _this._selections = [new selection_1.Selection(1, 1, 1, 1)];
  92938. _this._modelSelections = [new selection_1.Selection(1, 1, 1, 1)];
  92939. _this._lastRenderPosition = null;
  92940. // Text Area (The focus will always be in the textarea when the cursor is blinking)
  92941. _this.textArea = fastDomNode_1.createFastDomNode(document.createElement('textarea'));
  92942. viewPart_1.PartFingerprints.write(_this.textArea, 6 /* TextArea */);
  92943. _this.textArea.setClassName('inputarea');
  92944. _this.textArea.setAttribute('wrap', 'off');
  92945. _this.textArea.setAttribute('autocorrect', 'off');
  92946. _this.textArea.setAttribute('autocapitalize', 'off');
  92947. _this.textArea.setAttribute('autocomplete', 'off');
  92948. _this.textArea.setAttribute('spellcheck', 'false');
  92949. _this.textArea.setAttribute('aria-label', _this._getAriaLabel(options));
  92950. _this.textArea.setAttribute('role', 'textbox');
  92951. _this.textArea.setAttribute('aria-multiline', 'true');
  92952. _this.textArea.setAttribute('aria-haspopup', 'false');
  92953. _this.textArea.setAttribute('aria-autocomplete', 'both');
  92954. if (platform.isWeb && options.get(68 /* readOnly */)) {
  92955. _this.textArea.setAttribute('readonly', 'true');
  92956. }
  92957. _this.textAreaCover = fastDomNode_1.createFastDomNode(document.createElement('div'));
  92958. _this.textAreaCover.setPosition('absolute');
  92959. var simpleModel = {
  92960. getLineCount: function () {
  92961. return _this._context.model.getLineCount();
  92962. },
  92963. getLineMaxColumn: function (lineNumber) {
  92964. return _this._context.model.getLineMaxColumn(lineNumber);
  92965. },
  92966. getValueInRange: function (range, eol) {
  92967. return _this._context.model.getValueInRange(range, eol);
  92968. }
  92969. };
  92970. var textAreaInputHost = {
  92971. getDataToCopy: function (generateHTML) {
  92972. var rawTextToCopy = _this._context.model.getPlainTextToCopy(_this._modelSelections, _this._emptySelectionClipboard, platform.isWindows);
  92973. var newLineCharacter = _this._context.model.getEOL();
  92974. var isFromEmptySelection = (_this._emptySelectionClipboard && _this._modelSelections.length === 1 && _this._modelSelections[0].isEmpty());
  92975. var multicursorText = (Array.isArray(rawTextToCopy) ? rawTextToCopy : null);
  92976. var text = (Array.isArray(rawTextToCopy) ? rawTextToCopy.join(newLineCharacter) : rawTextToCopy);
  92977. var html = undefined;
  92978. var mode = null;
  92979. if (generateHTML) {
  92980. if (textAreaInput_1.CopyOptions.forceCopyWithSyntaxHighlighting || (_this._copyWithSyntaxHighlighting && text.length < 65536)) {
  92981. var richText = _this._context.model.getRichTextToCopy(_this._modelSelections, _this._emptySelectionClipboard);
  92982. if (richText) {
  92983. html = richText.html;
  92984. mode = richText.mode;
  92985. }
  92986. }
  92987. }
  92988. return {
  92989. isFromEmptySelection: isFromEmptySelection,
  92990. multicursorText: multicursorText,
  92991. text: text,
  92992. html: html,
  92993. mode: mode
  92994. };
  92995. },
  92996. getScreenReaderContent: function (currentState) {
  92997. if (browser.isIPad) {
  92998. // Do not place anything in the textarea for the iPad
  92999. return textAreaState_1.TextAreaState.EMPTY;
  93000. }
  93001. if (_this._accessibilitySupport === 1 /* Disabled */) {
  93002. // We know for a fact that a screen reader is not attached
  93003. // On OSX, we write the character before the cursor to allow for "long-press" composition
  93004. // Also on OSX, we write the word before the cursor to allow for the Accessibility Keyboard to give good hints
  93005. if (platform.isMacintosh) {
  93006. var selection = _this._selections[0];
  93007. if (selection.isEmpty()) {
  93008. var position = selection.getStartPosition();
  93009. var textBefore = _this._getWordBeforePosition(position);
  93010. if (textBefore.length === 0) {
  93011. textBefore = _this._getCharacterBeforePosition(position);
  93012. }
  93013. if (textBefore.length > 0) {
  93014. return new textAreaState_1.TextAreaState(textBefore, textBefore.length, textBefore.length, position, position);
  93015. }
  93016. }
  93017. }
  93018. return textAreaState_1.TextAreaState.EMPTY;
  93019. }
  93020. return textAreaState_1.PagedScreenReaderStrategy.fromEditorSelection(currentState, simpleModel, _this._selections[0], _this._accessibilityPageSize, _this._accessibilitySupport === 0 /* Unknown */);
  93021. },
  93022. deduceModelPosition: function (viewAnchorPosition, deltaOffset, lineFeedCnt) {
  93023. return _this._context.model.deduceModelPositionRelativeToViewPosition(viewAnchorPosition, deltaOffset, lineFeedCnt);
  93024. }
  93025. };
  93026. _this._textAreaInput = _this._register(new textAreaInput_1.TextAreaInput(textAreaInputHost, _this.textArea));
  93027. _this._register(_this._textAreaInput.onKeyDown(function (e) {
  93028. _this._viewController.emitKeyDown(e);
  93029. }));
  93030. _this._register(_this._textAreaInput.onKeyUp(function (e) {
  93031. _this._viewController.emitKeyUp(e);
  93032. }));
  93033. _this._register(_this._textAreaInput.onPaste(function (e) {
  93034. var pasteOnNewLine = false;
  93035. var multicursorText = null;
  93036. var mode = null;
  93037. if (e.metadata) {
  93038. pasteOnNewLine = (_this._emptySelectionClipboard && !!e.metadata.isFromEmptySelection);
  93039. multicursorText = (typeof e.metadata.multicursorText !== 'undefined' ? e.metadata.multicursorText : null);
  93040. mode = e.metadata.mode;
  93041. }
  93042. _this._viewController.paste('keyboard', e.text, pasteOnNewLine, multicursorText, mode);
  93043. }));
  93044. _this._register(_this._textAreaInput.onCut(function () {
  93045. _this._viewController.cut('keyboard');
  93046. }));
  93047. _this._register(_this._textAreaInput.onType(function (e) {
  93048. if (e.replaceCharCnt) {
  93049. _this._viewController.replacePreviousChar('keyboard', e.text, e.replaceCharCnt);
  93050. }
  93051. else {
  93052. _this._viewController.type('keyboard', e.text);
  93053. }
  93054. }));
  93055. _this._register(_this._textAreaInput.onSelectionChangeRequest(function (modelSelection) {
  93056. _this._viewController.setSelection('keyboard', modelSelection);
  93057. }));
  93058. _this._register(_this._textAreaInput.onCompositionStart(function () {
  93059. var lineNumber = _this._selections[0].startLineNumber;
  93060. var column = _this._selections[0].startColumn;
  93061. _this._context.privateViewEventBus.emit(new viewEvents.ViewRevealRangeRequestEvent('keyboard', new range_1.Range(lineNumber, column, lineNumber, column), 0 /* Simple */, true, 1 /* Immediate */));
  93062. // Find range pixel position
  93063. var visibleRange = _this._viewHelper.visibleRangeForPositionRelativeToEditor(lineNumber, column);
  93064. if (visibleRange) {
  93065. _this._visibleTextArea = new VisibleTextAreaData(_this._context.viewLayout.getVerticalOffsetForLineNumber(lineNumber), visibleRange.left, canUseZeroSizeTextarea ? 0 : 1);
  93066. _this._render();
  93067. }
  93068. // Show the textarea
  93069. _this.textArea.setClassName('inputarea ime-input');
  93070. _this._viewController.compositionStart('keyboard');
  93071. }));
  93072. _this._register(_this._textAreaInput.onCompositionUpdate(function (e) {
  93073. if (browser.isEdgeOrIE) {
  93074. // Due to isEdgeOrIE (where the textarea was not cleared initially)
  93075. // we cannot assume the text consists only of the composited text
  93076. _this._visibleTextArea = _this._visibleTextArea.setWidth(0);
  93077. }
  93078. else {
  93079. // adjust width by its size
  93080. _this._visibleTextArea = _this._visibleTextArea.setWidth(measureText(e.data, _this._fontInfo));
  93081. }
  93082. _this._render();
  93083. }));
  93084. _this._register(_this._textAreaInput.onCompositionEnd(function () {
  93085. _this._visibleTextArea = null;
  93086. _this._render();
  93087. _this.textArea.setClassName('inputarea');
  93088. _this._viewController.compositionEnd('keyboard');
  93089. }));
  93090. _this._register(_this._textAreaInput.onFocus(function () {
  93091. _this._context.privateViewEventBus.emit(new viewEvents.ViewFocusChangedEvent(true));
  93092. }));
  93093. _this._register(_this._textAreaInput.onBlur(function () {
  93094. _this._context.privateViewEventBus.emit(new viewEvents.ViewFocusChangedEvent(false));
  93095. }));
  93096. return _this;
  93097. }
  93098. TextAreaHandler.prototype.dispose = function () {
  93099. _super.prototype.dispose.call(this);
  93100. };
  93101. TextAreaHandler.prototype._getWordBeforePosition = function (position) {
  93102. var lineContent = this._context.model.getLineContent(position.lineNumber);
  93103. var wordSeparators = wordCharacterClassifier_1.getMapForWordSeparators(this._context.configuration.options.get(96 /* wordSeparators */));
  93104. var column = position.column;
  93105. var distance = 0;
  93106. while (column > 1) {
  93107. var charCode = lineContent.charCodeAt(column - 2);
  93108. var charClass = wordSeparators.get(charCode);
  93109. if (charClass !== 0 /* Regular */ || distance > 50) {
  93110. return lineContent.substring(column - 1, position.column - 1);
  93111. }
  93112. distance++;
  93113. column--;
  93114. }
  93115. return lineContent.substring(0, position.column - 1);
  93116. };
  93117. TextAreaHandler.prototype._getCharacterBeforePosition = function (position) {
  93118. if (position.column > 1) {
  93119. var lineContent = this._context.model.getLineContent(position.lineNumber);
  93120. var charBefore = lineContent.charAt(position.column - 2);
  93121. if (!strings.isHighSurrogate(charBefore.charCodeAt(0))) {
  93122. return charBefore;
  93123. }
  93124. }
  93125. return '';
  93126. };
  93127. TextAreaHandler.prototype._getAriaLabel = function (options) {
  93128. var accessibilitySupport = options.get(2 /* accessibilitySupport */);
  93129. if (accessibilitySupport === 1 /* Disabled */) {
  93130. return nls.localize(0, null);
  93131. }
  93132. return options.get(4 /* ariaLabel */);
  93133. };
  93134. TextAreaHandler.prototype._setAccessibilityOptions = function (options) {
  93135. this._accessibilitySupport = options.get(2 /* accessibilitySupport */);
  93136. var accessibilityPageSize = options.get(3 /* accessibilityPageSize */);
  93137. if (this._accessibilitySupport === 2 /* Enabled */ && accessibilityPageSize === editorOptions_1.EditorOptions.accessibilityPageSize.defaultValue) {
  93138. // If a screen reader is attached and the default value is not set we shuold automatically increase the page size to 160 for a better experience
  93139. // If we put more than 160 lines the nvda can not handle this https://github.com/microsoft/vscode/issues/89717
  93140. this._accessibilityPageSize = 160;
  93141. }
  93142. else {
  93143. this._accessibilityPageSize = accessibilityPageSize;
  93144. }
  93145. };
  93146. // --- begin event handlers
  93147. TextAreaHandler.prototype.onConfigurationChanged = function (e) {
  93148. var options = this._context.configuration.options;
  93149. var layoutInfo = options.get(107 /* layoutInfo */);
  93150. this._setAccessibilityOptions(options);
  93151. this._contentLeft = layoutInfo.contentLeft;
  93152. this._contentWidth = layoutInfo.contentWidth;
  93153. this._contentHeight = layoutInfo.height;
  93154. this._fontInfo = options.get(34 /* fontInfo */);
  93155. this._lineHeight = options.get(49 /* lineHeight */);
  93156. this._emptySelectionClipboard = options.get(25 /* emptySelectionClipboard */);
  93157. this._copyWithSyntaxHighlighting = options.get(15 /* copyWithSyntaxHighlighting */);
  93158. this.textArea.setAttribute('aria-label', this._getAriaLabel(options));
  93159. if (platform.isWeb && e.hasChanged(68 /* readOnly */)) {
  93160. if (options.get(68 /* readOnly */)) {
  93161. this.textArea.setAttribute('readonly', 'true');
  93162. }
  93163. else {
  93164. this.textArea.removeAttribute('readonly');
  93165. }
  93166. }
  93167. if (e.hasChanged(2 /* accessibilitySupport */)) {
  93168. this._textAreaInput.writeScreenReaderContent('strategy changed');
  93169. }
  93170. return true;
  93171. };
  93172. TextAreaHandler.prototype.onCursorStateChanged = function (e) {
  93173. this._selections = e.selections.slice(0);
  93174. this._modelSelections = e.modelSelections.slice(0);
  93175. this._textAreaInput.writeScreenReaderContent('selection changed');
  93176. return true;
  93177. };
  93178. TextAreaHandler.prototype.onDecorationsChanged = function (e) {
  93179. // true for inline decorations that can end up relayouting text
  93180. return true;
  93181. };
  93182. TextAreaHandler.prototype.onFlushed = function (e) {
  93183. return true;
  93184. };
  93185. TextAreaHandler.prototype.onLinesChanged = function (e) {
  93186. return true;
  93187. };
  93188. TextAreaHandler.prototype.onLinesDeleted = function (e) {
  93189. return true;
  93190. };
  93191. TextAreaHandler.prototype.onLinesInserted = function (e) {
  93192. return true;
  93193. };
  93194. TextAreaHandler.prototype.onScrollChanged = function (e) {
  93195. this._scrollLeft = e.scrollLeft;
  93196. this._scrollTop = e.scrollTop;
  93197. return true;
  93198. };
  93199. TextAreaHandler.prototype.onZonesChanged = function (e) {
  93200. return true;
  93201. };
  93202. // --- end event handlers
  93203. // --- begin view API
  93204. TextAreaHandler.prototype.isFocused = function () {
  93205. return this._textAreaInput.isFocused();
  93206. };
  93207. TextAreaHandler.prototype.focusTextArea = function () {
  93208. this._textAreaInput.focusTextArea();
  93209. };
  93210. TextAreaHandler.prototype.getLastRenderData = function () {
  93211. return this._lastRenderPosition;
  93212. };
  93213. TextAreaHandler.prototype.setAriaOptions = function (options) {
  93214. if (options.activeDescendant) {
  93215. this.textArea.setAttribute('aria-haspopup', 'true');
  93216. this.textArea.setAttribute('aria-autocomplete', 'list');
  93217. this.textArea.setAttribute('aria-activedescendant', options.activeDescendant);
  93218. }
  93219. else {
  93220. this.textArea.setAttribute('aria-haspopup', 'false');
  93221. this.textArea.setAttribute('aria-autocomplete', 'both');
  93222. this.textArea.removeAttribute('aria-activedescendant');
  93223. }
  93224. };
  93225. TextAreaHandler.prototype.prepareRender = function (ctx) {
  93226. this._primaryCursorPosition = new position_1.Position(this._selections[0].positionLineNumber, this._selections[0].positionColumn);
  93227. this._primaryCursorVisibleRange = ctx.visibleRangeForPosition(this._primaryCursorPosition);
  93228. };
  93229. TextAreaHandler.prototype.render = function (ctx) {
  93230. this._textAreaInput.writeScreenReaderContent('render');
  93231. this._render();
  93232. };
  93233. TextAreaHandler.prototype._render = function () {
  93234. if (this._visibleTextArea) {
  93235. // The text area is visible for composition reasons
  93236. this._renderInsideEditor(null, this._visibleTextArea.top - this._scrollTop, this._contentLeft + this._visibleTextArea.left - this._scrollLeft, this._visibleTextArea.width, this._lineHeight);
  93237. return;
  93238. }
  93239. if (!this._primaryCursorVisibleRange) {
  93240. // The primary cursor is outside the viewport => place textarea to the top left
  93241. this._renderAtTopLeft();
  93242. return;
  93243. }
  93244. var left = this._contentLeft + this._primaryCursorVisibleRange.left - this._scrollLeft;
  93245. if (left < this._contentLeft || left > this._contentLeft + this._contentWidth) {
  93246. // cursor is outside the viewport
  93247. this._renderAtTopLeft();
  93248. return;
  93249. }
  93250. var top = this._context.viewLayout.getVerticalOffsetForLineNumber(this._selections[0].positionLineNumber) - this._scrollTop;
  93251. if (top < 0 || top > this._contentHeight) {
  93252. // cursor is outside the viewport
  93253. this._renderAtTopLeft();
  93254. return;
  93255. }
  93256. // The primary cursor is in the viewport (at least vertically) => place textarea on the cursor
  93257. if (platform.isMacintosh) {
  93258. // For the popup emoji input, we will make the text area as high as the line height
  93259. // We will also make the fontSize and lineHeight the correct dimensions to help with the placement of these pickers
  93260. this._renderInsideEditor(this._primaryCursorPosition, top, left, canUseZeroSizeTextarea ? 0 : 1, this._lineHeight);
  93261. return;
  93262. }
  93263. this._renderInsideEditor(this._primaryCursorPosition, top, left, canUseZeroSizeTextarea ? 0 : 1, canUseZeroSizeTextarea ? 0 : 1);
  93264. };
  93265. TextAreaHandler.prototype._renderInsideEditor = function (renderedPosition, top, left, width, height) {
  93266. this._lastRenderPosition = renderedPosition;
  93267. var ta = this.textArea;
  93268. var tac = this.textAreaCover;
  93269. configuration_1.Configuration.applyFontInfo(ta, this._fontInfo);
  93270. ta.setTop(top);
  93271. ta.setLeft(left);
  93272. ta.setWidth(width);
  93273. ta.setHeight(height);
  93274. tac.setTop(0);
  93275. tac.setLeft(0);
  93276. tac.setWidth(0);
  93277. tac.setHeight(0);
  93278. };
  93279. TextAreaHandler.prototype._renderAtTopLeft = function () {
  93280. this._lastRenderPosition = null;
  93281. var ta = this.textArea;
  93282. var tac = this.textAreaCover;
  93283. configuration_1.Configuration.applyFontInfo(ta, this._fontInfo);
  93284. ta.setTop(0);
  93285. ta.setLeft(0);
  93286. tac.setTop(0);
  93287. tac.setLeft(0);
  93288. if (canUseZeroSizeTextarea) {
  93289. ta.setWidth(0);
  93290. ta.setHeight(0);
  93291. tac.setWidth(0);
  93292. tac.setHeight(0);
  93293. return;
  93294. }
  93295. // (in WebKit the textarea is 1px by 1px because it cannot handle input to a 0x0 textarea)
  93296. // specifically, when doing Korean IME, setting the textarea to 0x0 breaks IME badly.
  93297. ta.setWidth(1);
  93298. ta.setHeight(1);
  93299. tac.setWidth(1);
  93300. tac.setHeight(1);
  93301. var options = this._context.configuration.options;
  93302. if (options.get(40 /* glyphMargin */)) {
  93303. tac.setClassName('monaco-editor-background textAreaCover ' + margin_1.Margin.OUTER_CLASS_NAME);
  93304. }
  93305. else {
  93306. if (options.get(50 /* lineNumbers */).renderType !== 0 /* Off */) {
  93307. tac.setClassName('monaco-editor-background textAreaCover ' + lineNumbers_1.LineNumbersOverlay.CLASS_NAME);
  93308. }
  93309. else {
  93310. tac.setClassName('monaco-editor-background textAreaCover');
  93311. }
  93312. }
  93313. };
  93314. return TextAreaHandler;
  93315. }(viewPart_1.ViewPart));
  93316. exports.TextAreaHandler = TextAreaHandler;
  93317. function measureText(text, fontInfo) {
  93318. // adjust width by its size
  93319. var canvasElem = document.createElement('canvas');
  93320. var context = canvasElem.getContext('2d');
  93321. context.font = createFontString(fontInfo);
  93322. var metrics = context.measureText(text);
  93323. if (browser.isFirefox) {
  93324. return metrics.width + 2; // +2 for Japanese...
  93325. }
  93326. else {
  93327. return metrics.width;
  93328. }
  93329. }
  93330. function createFontString(bareFontInfo) {
  93331. return doCreateFontString('normal', bareFontInfo.fontWeight, bareFontInfo.fontSize, bareFontInfo.lineHeight, bareFontInfo.fontFamily);
  93332. }
  93333. function doCreateFontString(fontStyle, fontWeight, fontSize, lineHeight, fontFamily) {
  93334. // The full font syntax is:
  93335. // style | variant | weight | stretch | size/line-height | fontFamily
  93336. // (https://developer.mozilla.org/en-US/docs/Web/CSS/font)
  93337. // But it appears Edge and IE11 cannot properly parse `stretch`.
  93338. return fontStyle + " normal " + fontWeight + " " + fontSize + "px / " + lineHeight + "px " + fontFamily;
  93339. }
  93340. });
  93341. /*---------------------------------------------------------------------------------------------
  93342. * Copyright (c) Microsoft Corporation. All rights reserved.
  93343. * Licensed under the MIT License. See License.txt in the project root for license information.
  93344. *--------------------------------------------------------------------------------------------*/
  93345. define(__m[560/*vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,27/*vs/base/common/color*/,37/*vs/editor/browser/view/viewPart*/,13/*vs/editor/common/core/position*/,17/*vs/editor/common/modes*/,44/*vs/editor/common/view/editorColorRegistry*/]), function (require, exports, fastDomNode_1, color_1, viewPart_1, position_1, modes_1, editorColorRegistry_1) {
  93346. "use strict";
  93347. Object.defineProperty(exports, "__esModule", { value: true });
  93348. var Settings = /** @class */ (function () {
  93349. function Settings(config, theme) {
  93350. var options = config.options;
  93351. this.lineHeight = options.get(49 /* lineHeight */);
  93352. this.pixelRatio = options.get(105 /* pixelRatio */);
  93353. this.overviewRulerLanes = options.get(63 /* overviewRulerLanes */);
  93354. this.renderBorder = options.get(62 /* overviewRulerBorder */);
  93355. var borderColor = theme.getColor(editorColorRegistry_1.editorOverviewRulerBorder);
  93356. this.borderColor = borderColor ? borderColor.toString() : null;
  93357. this.hideCursor = options.get(42 /* hideCursorInOverviewRuler */);
  93358. var cursorColor = theme.getColor(editorColorRegistry_1.editorCursorForeground);
  93359. this.cursorColor = cursorColor ? cursorColor.transparent(0.7).toString() : null;
  93360. this.themeType = theme.type;
  93361. var minimapOpts = options.get(54 /* minimap */);
  93362. var minimapEnabled = minimapOpts.enabled;
  93363. var minimapSide = minimapOpts.side;
  93364. var backgroundColor = (minimapEnabled ? modes_1.TokenizationRegistry.getDefaultBackground() : null);
  93365. if (backgroundColor === null || minimapSide === 'left') {
  93366. this.backgroundColor = null;
  93367. }
  93368. else {
  93369. this.backgroundColor = color_1.Color.Format.CSS.formatHex(backgroundColor);
  93370. }
  93371. var layoutInfo = options.get(107 /* layoutInfo */);
  93372. var position = layoutInfo.overviewRuler;
  93373. this.top = position.top;
  93374. this.right = position.right;
  93375. this.domWidth = position.width;
  93376. this.domHeight = position.height;
  93377. if (this.overviewRulerLanes === 0) {
  93378. // overview ruler is off
  93379. this.canvasWidth = 0;
  93380. this.canvasHeight = 0;
  93381. }
  93382. else {
  93383. this.canvasWidth = (this.domWidth * this.pixelRatio) | 0;
  93384. this.canvasHeight = (this.domHeight * this.pixelRatio) | 0;
  93385. }
  93386. var _a = this._initLanes(1, this.canvasWidth, this.overviewRulerLanes), x = _a[0], w = _a[1];
  93387. this.x = x;
  93388. this.w = w;
  93389. }
  93390. Settings.prototype._initLanes = function (canvasLeftOffset, canvasWidth, laneCount) {
  93391. var remainingWidth = canvasWidth - canvasLeftOffset;
  93392. if (laneCount >= 3) {
  93393. var leftWidth = Math.floor(remainingWidth / 3);
  93394. var rightWidth = Math.floor(remainingWidth / 3);
  93395. var centerWidth = remainingWidth - leftWidth - rightWidth;
  93396. var leftOffset = canvasLeftOffset;
  93397. var centerOffset = leftOffset + leftWidth;
  93398. var rightOffset = leftOffset + leftWidth + centerWidth;
  93399. return [
  93400. [
  93401. 0,
  93402. leftOffset,
  93403. centerOffset,
  93404. leftOffset,
  93405. rightOffset,
  93406. leftOffset,
  93407. centerOffset,
  93408. leftOffset,
  93409. ], [
  93410. 0,
  93411. leftWidth,
  93412. centerWidth,
  93413. leftWidth + centerWidth,
  93414. rightWidth,
  93415. leftWidth + centerWidth + rightWidth,
  93416. centerWidth + rightWidth,
  93417. leftWidth + centerWidth + rightWidth,
  93418. ]
  93419. ];
  93420. }
  93421. else if (laneCount === 2) {
  93422. var leftWidth = Math.floor(remainingWidth / 2);
  93423. var rightWidth = remainingWidth - leftWidth;
  93424. var leftOffset = canvasLeftOffset;
  93425. var rightOffset = leftOffset + leftWidth;
  93426. return [
  93427. [
  93428. 0,
  93429. leftOffset,
  93430. leftOffset,
  93431. leftOffset,
  93432. rightOffset,
  93433. leftOffset,
  93434. leftOffset,
  93435. leftOffset,
  93436. ], [
  93437. 0,
  93438. leftWidth,
  93439. leftWidth,
  93440. leftWidth,
  93441. rightWidth,
  93442. leftWidth + rightWidth,
  93443. leftWidth + rightWidth,
  93444. leftWidth + rightWidth,
  93445. ]
  93446. ];
  93447. }
  93448. else {
  93449. var offset = canvasLeftOffset;
  93450. var width = remainingWidth;
  93451. return [
  93452. [
  93453. 0,
  93454. offset,
  93455. offset,
  93456. offset,
  93457. offset,
  93458. offset,
  93459. offset,
  93460. offset,
  93461. ], [
  93462. 0,
  93463. width,
  93464. width,
  93465. width,
  93466. width,
  93467. width,
  93468. width,
  93469. width,
  93470. ]
  93471. ];
  93472. }
  93473. };
  93474. Settings.prototype.equals = function (other) {
  93475. return (this.lineHeight === other.lineHeight
  93476. && this.pixelRatio === other.pixelRatio
  93477. && this.overviewRulerLanes === other.overviewRulerLanes
  93478. && this.renderBorder === other.renderBorder
  93479. && this.borderColor === other.borderColor
  93480. && this.hideCursor === other.hideCursor
  93481. && this.cursorColor === other.cursorColor
  93482. && this.themeType === other.themeType
  93483. && this.backgroundColor === other.backgroundColor
  93484. && this.top === other.top
  93485. && this.right === other.right
  93486. && this.domWidth === other.domWidth
  93487. && this.domHeight === other.domHeight
  93488. && this.canvasWidth === other.canvasWidth
  93489. && this.canvasHeight === other.canvasHeight);
  93490. };
  93491. return Settings;
  93492. }());
  93493. var DecorationsOverviewRuler = /** @class */ (function (_super) {
  93494. __extends(DecorationsOverviewRuler, _super);
  93495. function DecorationsOverviewRuler(context) {
  93496. var _this = _super.call(this, context) || this;
  93497. _this._domNode = fastDomNode_1.createFastDomNode(document.createElement('canvas'));
  93498. _this._domNode.setClassName('decorationsOverviewRuler');
  93499. _this._domNode.setPosition('absolute');
  93500. _this._domNode.setLayerHinting(true);
  93501. _this._domNode.setContain('strict');
  93502. _this._domNode.setAttribute('aria-hidden', 'true');
  93503. _this._updateSettings(false);
  93504. _this._tokensColorTrackerListener = modes_1.TokenizationRegistry.onDidChange(function (e) {
  93505. if (e.changedColorMap) {
  93506. _this._updateSettings(true);
  93507. }
  93508. });
  93509. _this._cursorPositions = [];
  93510. return _this;
  93511. }
  93512. DecorationsOverviewRuler.prototype.dispose = function () {
  93513. _super.prototype.dispose.call(this);
  93514. this._tokensColorTrackerListener.dispose();
  93515. };
  93516. DecorationsOverviewRuler.prototype._updateSettings = function (renderNow) {
  93517. var newSettings = new Settings(this._context.configuration, this._context.theme);
  93518. if (this._settings && this._settings.equals(newSettings)) {
  93519. // nothing to do
  93520. return false;
  93521. }
  93522. this._settings = newSettings;
  93523. this._domNode.setTop(this._settings.top);
  93524. this._domNode.setRight(this._settings.right);
  93525. this._domNode.setWidth(this._settings.domWidth);
  93526. this._domNode.setHeight(this._settings.domHeight);
  93527. this._domNode.domNode.width = this._settings.canvasWidth;
  93528. this._domNode.domNode.height = this._settings.canvasHeight;
  93529. if (renderNow) {
  93530. this._render();
  93531. }
  93532. return true;
  93533. };
  93534. // ---- begin view event handlers
  93535. DecorationsOverviewRuler.prototype.onConfigurationChanged = function (e) {
  93536. return this._updateSettings(false);
  93537. };
  93538. DecorationsOverviewRuler.prototype.onCursorStateChanged = function (e) {
  93539. this._cursorPositions = [];
  93540. for (var i = 0, len = e.selections.length; i < len; i++) {
  93541. this._cursorPositions[i] = e.selections[i].getPosition();
  93542. }
  93543. this._cursorPositions.sort(position_1.Position.compare);
  93544. return true;
  93545. };
  93546. DecorationsOverviewRuler.prototype.onDecorationsChanged = function (e) {
  93547. return true;
  93548. };
  93549. DecorationsOverviewRuler.prototype.onFlushed = function (e) {
  93550. return true;
  93551. };
  93552. DecorationsOverviewRuler.prototype.onScrollChanged = function (e) {
  93553. return e.scrollHeightChanged;
  93554. };
  93555. DecorationsOverviewRuler.prototype.onZonesChanged = function (e) {
  93556. return true;
  93557. };
  93558. DecorationsOverviewRuler.prototype.onThemeChanged = function (e) {
  93559. // invalidate color cache
  93560. this._context.model.invalidateOverviewRulerColorCache();
  93561. return this._updateSettings(false);
  93562. };
  93563. // ---- end view event handlers
  93564. DecorationsOverviewRuler.prototype.getDomNode = function () {
  93565. return this._domNode.domNode;
  93566. };
  93567. DecorationsOverviewRuler.prototype.prepareRender = function (ctx) {
  93568. // Nothing to read
  93569. };
  93570. DecorationsOverviewRuler.prototype.render = function (editorCtx) {
  93571. this._render();
  93572. };
  93573. DecorationsOverviewRuler.prototype._render = function () {
  93574. if (this._settings.overviewRulerLanes === 0) {
  93575. // overview ruler is off
  93576. this._domNode.setBackgroundColor(this._settings.backgroundColor ? this._settings.backgroundColor : '');
  93577. return;
  93578. }
  93579. var canvasWidth = this._settings.canvasWidth;
  93580. var canvasHeight = this._settings.canvasHeight;
  93581. var lineHeight = this._settings.lineHeight;
  93582. var viewLayout = this._context.viewLayout;
  93583. var outerHeight = this._context.viewLayout.getScrollHeight();
  93584. var heightRatio = canvasHeight / outerHeight;
  93585. var decorations = this._context.model.getAllOverviewRulerDecorations(this._context.theme);
  93586. var minDecorationHeight = (6 /* MIN_DECORATION_HEIGHT */ * this._settings.pixelRatio) | 0;
  93587. var halfMinDecorationHeight = (minDecorationHeight / 2) | 0;
  93588. var canvasCtx = this._domNode.domNode.getContext('2d');
  93589. if (this._settings.backgroundColor === null) {
  93590. canvasCtx.clearRect(0, 0, canvasWidth, canvasHeight);
  93591. }
  93592. else {
  93593. canvasCtx.fillStyle = this._settings.backgroundColor;
  93594. canvasCtx.fillRect(0, 0, canvasWidth, canvasHeight);
  93595. }
  93596. var x = this._settings.x;
  93597. var w = this._settings.w;
  93598. // Avoid flickering by always rendering the colors in the same order
  93599. // colors that don't use transparency will be sorted last (they start with #)
  93600. var colors = Object.keys(decorations);
  93601. colors.sort();
  93602. for (var cIndex = 0, cLen = colors.length; cIndex < cLen; cIndex++) {
  93603. var color = colors[cIndex];
  93604. var colorDecorations = decorations[color];
  93605. canvasCtx.fillStyle = color;
  93606. var prevLane = 0;
  93607. var prevY1 = 0;
  93608. var prevY2 = 0;
  93609. for (var i = 0, len = colorDecorations.length; i < len; i++) {
  93610. var lane = colorDecorations[3 * i];
  93611. var startLineNumber = colorDecorations[3 * i + 1];
  93612. var endLineNumber = colorDecorations[3 * i + 2];
  93613. var y1 = (viewLayout.getVerticalOffsetForLineNumber(startLineNumber) * heightRatio) | 0;
  93614. var y2 = ((viewLayout.getVerticalOffsetForLineNumber(endLineNumber) + lineHeight) * heightRatio) | 0;
  93615. var height = y2 - y1;
  93616. if (height < minDecorationHeight) {
  93617. var yCenter = ((y1 + y2) / 2) | 0;
  93618. if (yCenter < halfMinDecorationHeight) {
  93619. yCenter = halfMinDecorationHeight;
  93620. }
  93621. else if (yCenter + halfMinDecorationHeight > canvasHeight) {
  93622. yCenter = canvasHeight - halfMinDecorationHeight;
  93623. }
  93624. y1 = yCenter - halfMinDecorationHeight;
  93625. y2 = yCenter + halfMinDecorationHeight;
  93626. }
  93627. if (y1 > prevY2 + 1 || lane !== prevLane) {
  93628. // flush prev
  93629. if (i !== 0) {
  93630. canvasCtx.fillRect(x[prevLane], prevY1, w[prevLane], prevY2 - prevY1);
  93631. }
  93632. prevLane = lane;
  93633. prevY1 = y1;
  93634. prevY2 = y2;
  93635. }
  93636. else {
  93637. // merge into prev
  93638. if (y2 > prevY2) {
  93639. prevY2 = y2;
  93640. }
  93641. }
  93642. }
  93643. canvasCtx.fillRect(x[prevLane], prevY1, w[prevLane], prevY2 - prevY1);
  93644. }
  93645. // Draw cursors
  93646. if (!this._settings.hideCursor && this._settings.cursorColor) {
  93647. var cursorHeight = (2 * this._settings.pixelRatio) | 0;
  93648. var halfCursorHeight = (cursorHeight / 2) | 0;
  93649. var cursorX = this._settings.x[7 /* Full */];
  93650. var cursorW = this._settings.w[7 /* Full */];
  93651. canvasCtx.fillStyle = this._settings.cursorColor;
  93652. var prevY1 = -100;
  93653. var prevY2 = -100;
  93654. for (var i = 0, len = this._cursorPositions.length; i < len; i++) {
  93655. var cursor = this._cursorPositions[i];
  93656. var yCenter = (viewLayout.getVerticalOffsetForLineNumber(cursor.lineNumber) * heightRatio) | 0;
  93657. if (yCenter < halfCursorHeight) {
  93658. yCenter = halfCursorHeight;
  93659. }
  93660. else if (yCenter + halfCursorHeight > canvasHeight) {
  93661. yCenter = canvasHeight - halfCursorHeight;
  93662. }
  93663. var y1 = yCenter - halfCursorHeight;
  93664. var y2 = y1 + cursorHeight;
  93665. if (y1 > prevY2 + 1) {
  93666. // flush prev
  93667. if (i !== 0) {
  93668. canvasCtx.fillRect(cursorX, prevY1, cursorW, prevY2 - prevY1);
  93669. }
  93670. prevY1 = y1;
  93671. prevY2 = y2;
  93672. }
  93673. else {
  93674. // merge into prev
  93675. if (y2 > prevY2) {
  93676. prevY2 = y2;
  93677. }
  93678. }
  93679. }
  93680. canvasCtx.fillRect(cursorX, prevY1, cursorW, prevY2 - prevY1);
  93681. }
  93682. if (this._settings.renderBorder && this._settings.borderColor && this._settings.overviewRulerLanes > 0) {
  93683. canvasCtx.beginPath();
  93684. canvasCtx.lineWidth = 1;
  93685. canvasCtx.strokeStyle = this._settings.borderColor;
  93686. canvasCtx.moveTo(0, 0);
  93687. canvasCtx.lineTo(0, canvasHeight);
  93688. canvasCtx.stroke();
  93689. canvasCtx.moveTo(0, 0);
  93690. canvasCtx.lineTo(canvasWidth, 0);
  93691. canvasCtx.stroke();
  93692. }
  93693. };
  93694. return DecorationsOverviewRuler;
  93695. }(viewPart_1.ViewPart));
  93696. exports.DecorationsOverviewRuler = DecorationsOverviewRuler;
  93697. });
  93698. /*---------------------------------------------------------------------------------------------
  93699. * Copyright (c) Microsoft Corporation. All rights reserved.
  93700. * Licensed under the MIT License. See License.txt in the project root for license information.
  93701. *--------------------------------------------------------------------------------------------*/
  93702. define(__m[561/*vs/editor/browser/viewParts/rulers/rulers*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,37/*vs/editor/browser/view/viewPart*/,44/*vs/editor/common/view/editorColorRegistry*/,14/*vs/platform/theme/common/themeService*/,295/*vs/css!vs/editor/browser/viewParts/rulers/rulers*/]), function (require, exports, fastDomNode_1, viewPart_1, editorColorRegistry_1, themeService_1) {
  93703. "use strict";
  93704. Object.defineProperty(exports, "__esModule", { value: true });
  93705. var Rulers = /** @class */ (function (_super) {
  93706. __extends(Rulers, _super);
  93707. function Rulers(context) {
  93708. var _this = _super.call(this, context) || this;
  93709. _this.domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  93710. _this.domNode.setAttribute('role', 'presentation');
  93711. _this.domNode.setAttribute('aria-hidden', 'true');
  93712. _this.domNode.setClassName('view-rulers');
  93713. _this._renderedRulers = [];
  93714. var options = _this._context.configuration.options;
  93715. _this._rulers = options.get(77 /* rulers */);
  93716. _this._typicalHalfwidthCharacterWidth = options.get(34 /* fontInfo */).typicalHalfwidthCharacterWidth;
  93717. return _this;
  93718. }
  93719. Rulers.prototype.dispose = function () {
  93720. _super.prototype.dispose.call(this);
  93721. };
  93722. // --- begin event handlers
  93723. Rulers.prototype.onConfigurationChanged = function (e) {
  93724. var options = this._context.configuration.options;
  93725. this._rulers = options.get(77 /* rulers */);
  93726. this._typicalHalfwidthCharacterWidth = options.get(34 /* fontInfo */).typicalHalfwidthCharacterWidth;
  93727. return true;
  93728. };
  93729. Rulers.prototype.onScrollChanged = function (e) {
  93730. return e.scrollHeightChanged;
  93731. };
  93732. // --- end event handlers
  93733. Rulers.prototype.prepareRender = function (ctx) {
  93734. // Nothing to read
  93735. };
  93736. Rulers.prototype._ensureRulersCount = function () {
  93737. var currentCount = this._renderedRulers.length;
  93738. var desiredCount = this._rulers.length;
  93739. if (currentCount === desiredCount) {
  93740. // Nothing to do
  93741. return;
  93742. }
  93743. if (currentCount < desiredCount) {
  93744. var tabSize = this._context.model.getOptions().tabSize;
  93745. var rulerWidth = tabSize;
  93746. var addCount = desiredCount - currentCount;
  93747. while (addCount > 0) {
  93748. var node = fastDomNode_1.createFastDomNode(document.createElement('div'));
  93749. node.setClassName('view-ruler');
  93750. node.setWidth(rulerWidth);
  93751. this.domNode.appendChild(node);
  93752. this._renderedRulers.push(node);
  93753. addCount--;
  93754. }
  93755. return;
  93756. }
  93757. var removeCount = currentCount - desiredCount;
  93758. while (removeCount > 0) {
  93759. var node = this._renderedRulers.pop();
  93760. this.domNode.removeChild(node);
  93761. removeCount--;
  93762. }
  93763. };
  93764. Rulers.prototype.render = function (ctx) {
  93765. this._ensureRulersCount();
  93766. for (var i = 0, len = this._rulers.length; i < len; i++) {
  93767. var node = this._renderedRulers[i];
  93768. node.setHeight(Math.min(ctx.scrollHeight, 1000000));
  93769. node.setLeft(this._rulers[i] * this._typicalHalfwidthCharacterWidth);
  93770. }
  93771. };
  93772. return Rulers;
  93773. }(viewPart_1.ViewPart));
  93774. exports.Rulers = Rulers;
  93775. themeService_1.registerThemingParticipant(function (theme, collector) {
  93776. var rulerColor = theme.getColor(editorColorRegistry_1.editorRuler);
  93777. if (rulerColor) {
  93778. collector.addRule(".monaco-editor .view-ruler { box-shadow: 1px 0 0 0 " + rulerColor + " inset; }");
  93779. }
  93780. });
  93781. });
  93782. /*---------------------------------------------------------------------------------------------
  93783. * Copyright (c) Microsoft Corporation. All rights reserved.
  93784. * Licensed under the MIT License. See License.txt in the project root for license information.
  93785. *--------------------------------------------------------------------------------------------*/
  93786. define(__m[562/*vs/editor/browser/viewParts/viewCursors/viewCursors*/], __M([0/*require*/,1/*exports*/,28/*vs/base/browser/fastDomNode*/,15/*vs/base/common/async*/,37/*vs/editor/browser/view/viewPart*/,514/*vs/editor/browser/viewParts/viewCursors/viewCursor*/,33/*vs/editor/common/config/editorOptions*/,44/*vs/editor/common/view/editorColorRegistry*/,14/*vs/platform/theme/common/themeService*/,298/*vs/css!vs/editor/browser/viewParts/viewCursors/viewCursors*/]), function (require, exports, fastDomNode_1, async_1, viewPart_1, viewCursor_1, editorOptions_1, editorColorRegistry_1, themeService_1) {
  93787. "use strict";
  93788. Object.defineProperty(exports, "__esModule", { value: true });
  93789. var ViewCursors = /** @class */ (function (_super) {
  93790. __extends(ViewCursors, _super);
  93791. function ViewCursors(context) {
  93792. var _this = _super.call(this, context) || this;
  93793. var options = _this._context.configuration.options;
  93794. _this._readOnly = options.get(68 /* readOnly */);
  93795. _this._cursorBlinking = options.get(16 /* cursorBlinking */);
  93796. _this._cursorStyle = options.get(18 /* cursorStyle */);
  93797. _this._cursorSmoothCaretAnimation = options.get(17 /* cursorSmoothCaretAnimation */);
  93798. _this._selectionIsEmpty = true;
  93799. _this._isVisible = false;
  93800. _this._primaryCursor = new viewCursor_1.ViewCursor(_this._context);
  93801. _this._secondaryCursors = [];
  93802. _this._renderData = [];
  93803. _this._domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  93804. _this._domNode.setAttribute('role', 'presentation');
  93805. _this._domNode.setAttribute('aria-hidden', 'true');
  93806. _this._updateDomClassName();
  93807. _this._domNode.appendChild(_this._primaryCursor.getDomNode());
  93808. _this._startCursorBlinkAnimation = new async_1.TimeoutTimer();
  93809. _this._cursorFlatBlinkInterval = new async_1.IntervalTimer();
  93810. _this._blinkingEnabled = false;
  93811. _this._editorHasFocus = false;
  93812. _this._updateBlinking();
  93813. return _this;
  93814. }
  93815. ViewCursors.prototype.dispose = function () {
  93816. _super.prototype.dispose.call(this);
  93817. this._startCursorBlinkAnimation.dispose();
  93818. this._cursorFlatBlinkInterval.dispose();
  93819. };
  93820. ViewCursors.prototype.getDomNode = function () {
  93821. return this._domNode;
  93822. };
  93823. // --- begin event handlers
  93824. ViewCursors.prototype.onConfigurationChanged = function (e) {
  93825. var options = this._context.configuration.options;
  93826. this._readOnly = options.get(68 /* readOnly */);
  93827. this._cursorBlinking = options.get(16 /* cursorBlinking */);
  93828. this._cursorStyle = options.get(18 /* cursorStyle */);
  93829. this._cursorSmoothCaretAnimation = options.get(17 /* cursorSmoothCaretAnimation */);
  93830. this._updateBlinking();
  93831. this._updateDomClassName();
  93832. this._primaryCursor.onConfigurationChanged(e);
  93833. for (var i = 0, len = this._secondaryCursors.length; i < len; i++) {
  93834. this._secondaryCursors[i].onConfigurationChanged(e);
  93835. }
  93836. return true;
  93837. };
  93838. ViewCursors.prototype._onCursorPositionChanged = function (position, secondaryPositions) {
  93839. this._primaryCursor.onCursorPositionChanged(position);
  93840. this._updateBlinking();
  93841. if (this._secondaryCursors.length < secondaryPositions.length) {
  93842. // Create new cursors
  93843. var addCnt = secondaryPositions.length - this._secondaryCursors.length;
  93844. for (var i = 0; i < addCnt; i++) {
  93845. var newCursor = new viewCursor_1.ViewCursor(this._context);
  93846. this._domNode.domNode.insertBefore(newCursor.getDomNode().domNode, this._primaryCursor.getDomNode().domNode.nextSibling);
  93847. this._secondaryCursors.push(newCursor);
  93848. }
  93849. }
  93850. else if (this._secondaryCursors.length > secondaryPositions.length) {
  93851. // Remove some cursors
  93852. var removeCnt = this._secondaryCursors.length - secondaryPositions.length;
  93853. for (var i = 0; i < removeCnt; i++) {
  93854. this._domNode.removeChild(this._secondaryCursors[0].getDomNode());
  93855. this._secondaryCursors.splice(0, 1);
  93856. }
  93857. }
  93858. for (var i = 0; i < secondaryPositions.length; i++) {
  93859. this._secondaryCursors[i].onCursorPositionChanged(secondaryPositions[i]);
  93860. }
  93861. };
  93862. ViewCursors.prototype.onCursorStateChanged = function (e) {
  93863. var positions = [];
  93864. for (var i = 0, len = e.selections.length; i < len; i++) {
  93865. positions[i] = e.selections[i].getPosition();
  93866. }
  93867. this._onCursorPositionChanged(positions[0], positions.slice(1));
  93868. var selectionIsEmpty = e.selections[0].isEmpty();
  93869. if (this._selectionIsEmpty !== selectionIsEmpty) {
  93870. this._selectionIsEmpty = selectionIsEmpty;
  93871. this._updateDomClassName();
  93872. }
  93873. return true;
  93874. };
  93875. ViewCursors.prototype.onDecorationsChanged = function (e) {
  93876. // true for inline decorations that can end up relayouting text
  93877. return true;
  93878. };
  93879. ViewCursors.prototype.onFlushed = function (e) {
  93880. return true;
  93881. };
  93882. ViewCursors.prototype.onFocusChanged = function (e) {
  93883. this._editorHasFocus = e.isFocused;
  93884. this._updateBlinking();
  93885. return false;
  93886. };
  93887. ViewCursors.prototype.onLinesChanged = function (e) {
  93888. return true;
  93889. };
  93890. ViewCursors.prototype.onLinesDeleted = function (e) {
  93891. return true;
  93892. };
  93893. ViewCursors.prototype.onLinesInserted = function (e) {
  93894. return true;
  93895. };
  93896. ViewCursors.prototype.onScrollChanged = function (e) {
  93897. return true;
  93898. };
  93899. ViewCursors.prototype.onTokensChanged = function (e) {
  93900. var shouldRender = function (position) {
  93901. for (var i = 0, len = e.ranges.length; i < len; i++) {
  93902. if (e.ranges[i].fromLineNumber <= position.lineNumber && position.lineNumber <= e.ranges[i].toLineNumber) {
  93903. return true;
  93904. }
  93905. }
  93906. return false;
  93907. };
  93908. if (shouldRender(this._primaryCursor.getPosition())) {
  93909. return true;
  93910. }
  93911. for (var _i = 0, _a = this._secondaryCursors; _i < _a.length; _i++) {
  93912. var secondaryCursor = _a[_i];
  93913. if (shouldRender(secondaryCursor.getPosition())) {
  93914. return true;
  93915. }
  93916. }
  93917. return false;
  93918. };
  93919. ViewCursors.prototype.onZonesChanged = function (e) {
  93920. return true;
  93921. };
  93922. // --- end event handlers
  93923. // ---- blinking logic
  93924. ViewCursors.prototype._getCursorBlinking = function () {
  93925. if (!this._editorHasFocus) {
  93926. return 0 /* Hidden */;
  93927. }
  93928. if (this._readOnly) {
  93929. return 5 /* Solid */;
  93930. }
  93931. return this._cursorBlinking;
  93932. };
  93933. ViewCursors.prototype._updateBlinking = function () {
  93934. var _this = this;
  93935. this._startCursorBlinkAnimation.cancel();
  93936. this._cursorFlatBlinkInterval.cancel();
  93937. var blinkingStyle = this._getCursorBlinking();
  93938. // hidden and solid are special as they involve no animations
  93939. var isHidden = (blinkingStyle === 0 /* Hidden */);
  93940. var isSolid = (blinkingStyle === 5 /* Solid */);
  93941. if (isHidden) {
  93942. this._hide();
  93943. }
  93944. else {
  93945. this._show();
  93946. }
  93947. this._blinkingEnabled = false;
  93948. this._updateDomClassName();
  93949. if (!isHidden && !isSolid) {
  93950. if (blinkingStyle === 1 /* Blink */) {
  93951. // flat blinking is handled by JavaScript to save battery life due to Chromium step timing issue https://bugs.chromium.org/p/chromium/issues/detail?id=361587
  93952. this._cursorFlatBlinkInterval.cancelAndSet(function () {
  93953. if (_this._isVisible) {
  93954. _this._hide();
  93955. }
  93956. else {
  93957. _this._show();
  93958. }
  93959. }, ViewCursors.BLINK_INTERVAL);
  93960. }
  93961. else {
  93962. this._startCursorBlinkAnimation.setIfNotSet(function () {
  93963. _this._blinkingEnabled = true;
  93964. _this._updateDomClassName();
  93965. }, ViewCursors.BLINK_INTERVAL);
  93966. }
  93967. }
  93968. };
  93969. // --- end blinking logic
  93970. ViewCursors.prototype._updateDomClassName = function () {
  93971. this._domNode.setClassName(this._getClassName());
  93972. };
  93973. ViewCursors.prototype._getClassName = function () {
  93974. var result = 'cursors-layer';
  93975. if (!this._selectionIsEmpty) {
  93976. result += ' has-selection';
  93977. }
  93978. switch (this._cursorStyle) {
  93979. case editorOptions_1.TextEditorCursorStyle.Line:
  93980. result += ' cursor-line-style';
  93981. break;
  93982. case editorOptions_1.TextEditorCursorStyle.Block:
  93983. result += ' cursor-block-style';
  93984. break;
  93985. case editorOptions_1.TextEditorCursorStyle.Underline:
  93986. result += ' cursor-underline-style';
  93987. break;
  93988. case editorOptions_1.TextEditorCursorStyle.LineThin:
  93989. result += ' cursor-line-thin-style';
  93990. break;
  93991. case editorOptions_1.TextEditorCursorStyle.BlockOutline:
  93992. result += ' cursor-block-outline-style';
  93993. break;
  93994. case editorOptions_1.TextEditorCursorStyle.UnderlineThin:
  93995. result += ' cursor-underline-thin-style';
  93996. break;
  93997. default:
  93998. result += ' cursor-line-style';
  93999. }
  94000. if (this._blinkingEnabled) {
  94001. switch (this._getCursorBlinking()) {
  94002. case 1 /* Blink */:
  94003. result += ' cursor-blink';
  94004. break;
  94005. case 2 /* Smooth */:
  94006. result += ' cursor-smooth';
  94007. break;
  94008. case 3 /* Phase */:
  94009. result += ' cursor-phase';
  94010. break;
  94011. case 4 /* Expand */:
  94012. result += ' cursor-expand';
  94013. break;
  94014. case 5 /* Solid */:
  94015. result += ' cursor-solid';
  94016. break;
  94017. default:
  94018. result += ' cursor-solid';
  94019. }
  94020. }
  94021. else {
  94022. result += ' cursor-solid';
  94023. }
  94024. if (this._cursorSmoothCaretAnimation) {
  94025. result += ' cursor-smooth-caret-animation';
  94026. }
  94027. return result;
  94028. };
  94029. ViewCursors.prototype._show = function () {
  94030. this._primaryCursor.show();
  94031. for (var i = 0, len = this._secondaryCursors.length; i < len; i++) {
  94032. this._secondaryCursors[i].show();
  94033. }
  94034. this._isVisible = true;
  94035. };
  94036. ViewCursors.prototype._hide = function () {
  94037. this._primaryCursor.hide();
  94038. for (var i = 0, len = this._secondaryCursors.length; i < len; i++) {
  94039. this._secondaryCursors[i].hide();
  94040. }
  94041. this._isVisible = false;
  94042. };
  94043. // ---- IViewPart implementation
  94044. ViewCursors.prototype.prepareRender = function (ctx) {
  94045. this._primaryCursor.prepareRender(ctx);
  94046. for (var i = 0, len = this._secondaryCursors.length; i < len; i++) {
  94047. this._secondaryCursors[i].prepareRender(ctx);
  94048. }
  94049. };
  94050. ViewCursors.prototype.render = function (ctx) {
  94051. var renderData = [], renderDataLen = 0;
  94052. var primaryRenderData = this._primaryCursor.render(ctx);
  94053. if (primaryRenderData) {
  94054. renderData[renderDataLen++] = primaryRenderData;
  94055. }
  94056. for (var i = 0, len = this._secondaryCursors.length; i < len; i++) {
  94057. var secondaryRenderData = this._secondaryCursors[i].render(ctx);
  94058. if (secondaryRenderData) {
  94059. renderData[renderDataLen++] = secondaryRenderData;
  94060. }
  94061. }
  94062. this._renderData = renderData;
  94063. };
  94064. ViewCursors.prototype.getLastRenderData = function () {
  94065. return this._renderData;
  94066. };
  94067. ViewCursors.BLINK_INTERVAL = 500;
  94068. return ViewCursors;
  94069. }(viewPart_1.ViewPart));
  94070. exports.ViewCursors = ViewCursors;
  94071. themeService_1.registerThemingParticipant(function (theme, collector) {
  94072. var caret = theme.getColor(editorColorRegistry_1.editorCursorForeground);
  94073. if (caret) {
  94074. var caretBackground = theme.getColor(editorColorRegistry_1.editorCursorBackground);
  94075. if (!caretBackground) {
  94076. caretBackground = caret.opposite();
  94077. }
  94078. collector.addRule(".monaco-editor .cursor { background-color: " + caret + "; border-color: " + caret + "; color: " + caretBackground + "; }");
  94079. if (theme.type === 'hc') {
  94080. collector.addRule(".monaco-editor .cursors-layer.has-selection .cursor { border-left: 1px solid " + caretBackground + "; border-right: 1px solid " + caretBackground + "; }");
  94081. }
  94082. }
  94083. });
  94084. });
  94085. /*---------------------------------------------------------------------------------------------
  94086. * Copyright (c) Microsoft Corporation. All rights reserved.
  94087. * Licensed under the MIT License. See License.txt in the project root for license information.
  94088. *--------------------------------------------------------------------------------------------*/
  94089. define(__m[563/*vs/editor/browser/view/viewImpl*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,28/*vs/base/browser/fastDomNode*/,10/*vs/base/common/errors*/,551/*vs/editor/browser/controller/pointerHandler*/,559/*vs/editor/browser/controller/textAreaHandler*/,523/*vs/editor/browser/view/viewController*/,228/*vs/editor/browser/view/viewOutgoingEvents*/,513/*vs/editor/browser/view/viewOverlays*/,37/*vs/editor/browser/view/viewPart*/,366/*vs/editor/browser/viewParts/contentWidgets/contentWidgets*/,557/*vs/editor/browser/viewParts/currentLineHighlight/currentLineHighlight*/,367/*vs/editor/browser/viewParts/decorations/decorations*/,549/*vs/editor/browser/viewParts/editorScrollbar/editorScrollbar*/,149/*vs/editor/browser/viewParts/glyphMargin/glyphMargin*/,558/*vs/editor/browser/viewParts/indentGuides/indentGuides*/,229/*vs/editor/browser/viewParts/lineNumbers/lineNumbers*/,552/*vs/editor/browser/viewParts/lines/viewLines*/,368/*vs/editor/browser/viewParts/linesDecorations/linesDecorations*/,195/*vs/editor/browser/viewParts/margin/margin*/,369/*vs/editor/browser/viewParts/marginDecorations/marginDecorations*/,553/*vs/editor/browser/viewParts/minimap/minimap*/,370/*vs/editor/browser/viewParts/overlayWidgets/overlayWidgets*/,560/*vs/editor/browser/viewParts/overviewRuler/decorationsOverviewRuler*/,371/*vs/editor/browser/viewParts/overviewRuler/overviewRuler*/,561/*vs/editor/browser/viewParts/rulers/rulers*/,554/*vs/editor/browser/viewParts/scrollDecoration/scrollDecoration*/,555/*vs/editor/browser/viewParts/selections/selections*/,562/*vs/editor/browser/viewParts/viewCursors/viewCursors*/,372/*vs/editor/browser/viewParts/viewZones/viewZones*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,91/*vs/editor/common/view/renderingContext*/,360/*vs/editor/common/view/viewContext*/,361/*vs/editor/common/view/viewEventDispatcher*/,81/*vs/editor/common/view/viewEvents*/,363/*vs/editor/common/viewLayout/viewLinesViewportData*/,92/*vs/editor/common/viewModel/viewEventHandler*/,14/*vs/platform/theme/common/themeService*/,166/*vs/editor/browser/controller/mouseTarget*/]), function (require, exports, dom, fastDomNode_1, errors_1, pointerHandler_1, textAreaHandler_1, viewController_1, viewOutgoingEvents_1, viewOverlays_1, viewPart_1, contentWidgets_1, currentLineHighlight_1, decorations_1, editorScrollbar_1, glyphMargin_1, indentGuides_1, lineNumbers_1, viewLines_1, linesDecorations_1, margin_1, marginDecorations_1, minimap_1, overlayWidgets_1, decorationsOverviewRuler_1, overviewRuler_1, rulers_1, scrollDecoration_1, selections_1, viewCursors_1, viewZones_1, position_1, range_1, renderingContext_1, viewContext_1, viewEventDispatcher_1, viewEvents, viewLinesViewportData_1, viewEventHandler_1, themeService_1, mouseTarget_1) {
  94090. "use strict";
  94091. Object.defineProperty(exports, "__esModule", { value: true });
  94092. var View = /** @class */ (function (_super) {
  94093. __extends(View, _super);
  94094. function View(commandDelegate, configuration, themeService, model, cursor, outgoingEvents) {
  94095. var _this = _super.call(this) || this;
  94096. _this._cursor = cursor;
  94097. _this._renderAnimationFrame = null;
  94098. _this.outgoingEvents = outgoingEvents;
  94099. var viewController = new viewController_1.ViewController(configuration, model, _this.outgoingEvents, commandDelegate);
  94100. // The event dispatcher will always go through _renderOnce before dispatching any events
  94101. _this.eventDispatcher = new viewEventDispatcher_1.ViewEventDispatcher(function (callback) { return _this._renderOnce(callback); });
  94102. // Ensure the view is the first event handler in order to update the layout
  94103. _this.eventDispatcher.addEventHandler(_this);
  94104. // The view context is passed on to most classes (basically to reduce param. counts in ctors)
  94105. _this._context = new viewContext_1.ViewContext(configuration, themeService.getTheme(), model, _this.eventDispatcher);
  94106. _this._register(themeService.onThemeChange(function (theme) {
  94107. _this._context.theme = theme;
  94108. _this.eventDispatcher.emit(new viewEvents.ViewThemeChangedEvent());
  94109. _this.render(true, false);
  94110. }));
  94111. _this.viewParts = [];
  94112. // Keyboard handler
  94113. _this._textAreaHandler = new textAreaHandler_1.TextAreaHandler(_this._context, viewController, _this.createTextAreaHandlerHelper());
  94114. _this.viewParts.push(_this._textAreaHandler);
  94115. // These two dom nodes must be constructed up front, since references are needed in the layout provider (scrolling & co.)
  94116. _this.linesContent = fastDomNode_1.createFastDomNode(document.createElement('div'));
  94117. _this.linesContent.setClassName('lines-content' + ' monaco-editor-background');
  94118. _this.linesContent.setPosition('absolute');
  94119. _this.domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  94120. _this.domNode.setClassName(_this.getEditorClassName());
  94121. _this.overflowGuardContainer = fastDomNode_1.createFastDomNode(document.createElement('div'));
  94122. viewPart_1.PartFingerprints.write(_this.overflowGuardContainer, 3 /* OverflowGuard */);
  94123. _this.overflowGuardContainer.setClassName('overflow-guard');
  94124. _this._scrollbar = new editorScrollbar_1.EditorScrollbar(_this._context, _this.linesContent, _this.domNode, _this.overflowGuardContainer);
  94125. _this.viewParts.push(_this._scrollbar);
  94126. // View Lines
  94127. _this.viewLines = new viewLines_1.ViewLines(_this._context, _this.linesContent);
  94128. // View Zones
  94129. _this.viewZones = new viewZones_1.ViewZones(_this._context);
  94130. _this.viewParts.push(_this.viewZones);
  94131. // Decorations overview ruler
  94132. var decorationsOverviewRuler = new decorationsOverviewRuler_1.DecorationsOverviewRuler(_this._context);
  94133. _this.viewParts.push(decorationsOverviewRuler);
  94134. var scrollDecoration = new scrollDecoration_1.ScrollDecorationViewPart(_this._context);
  94135. _this.viewParts.push(scrollDecoration);
  94136. var contentViewOverlays = new viewOverlays_1.ContentViewOverlays(_this._context);
  94137. _this.viewParts.push(contentViewOverlays);
  94138. contentViewOverlays.addDynamicOverlay(new currentLineHighlight_1.CurrentLineHighlightOverlay(_this._context));
  94139. contentViewOverlays.addDynamicOverlay(new selections_1.SelectionsOverlay(_this._context));
  94140. contentViewOverlays.addDynamicOverlay(new indentGuides_1.IndentGuidesOverlay(_this._context));
  94141. contentViewOverlays.addDynamicOverlay(new decorations_1.DecorationsOverlay(_this._context));
  94142. var marginViewOverlays = new viewOverlays_1.MarginViewOverlays(_this._context);
  94143. _this.viewParts.push(marginViewOverlays);
  94144. marginViewOverlays.addDynamicOverlay(new currentLineHighlight_1.CurrentLineMarginHighlightOverlay(_this._context));
  94145. marginViewOverlays.addDynamicOverlay(new glyphMargin_1.GlyphMarginOverlay(_this._context));
  94146. marginViewOverlays.addDynamicOverlay(new marginDecorations_1.MarginViewLineDecorationsOverlay(_this._context));
  94147. marginViewOverlays.addDynamicOverlay(new linesDecorations_1.LinesDecorationsOverlay(_this._context));
  94148. marginViewOverlays.addDynamicOverlay(new lineNumbers_1.LineNumbersOverlay(_this._context));
  94149. var margin = new margin_1.Margin(_this._context);
  94150. margin.getDomNode().appendChild(_this.viewZones.marginDomNode);
  94151. margin.getDomNode().appendChild(marginViewOverlays.getDomNode());
  94152. _this.viewParts.push(margin);
  94153. // Content widgets
  94154. _this.contentWidgets = new contentWidgets_1.ViewContentWidgets(_this._context, _this.domNode);
  94155. _this.viewParts.push(_this.contentWidgets);
  94156. _this.viewCursors = new viewCursors_1.ViewCursors(_this._context);
  94157. _this.viewParts.push(_this.viewCursors);
  94158. // Overlay widgets
  94159. _this.overlayWidgets = new overlayWidgets_1.ViewOverlayWidgets(_this._context);
  94160. _this.viewParts.push(_this.overlayWidgets);
  94161. var rulers = new rulers_1.Rulers(_this._context);
  94162. _this.viewParts.push(rulers);
  94163. var minimap = new minimap_1.Minimap(_this._context);
  94164. _this.viewParts.push(minimap);
  94165. // -------------- Wire dom nodes up
  94166. if (decorationsOverviewRuler) {
  94167. var overviewRulerData = _this._scrollbar.getOverviewRulerLayoutInfo();
  94168. overviewRulerData.parent.insertBefore(decorationsOverviewRuler.getDomNode(), overviewRulerData.insertBefore);
  94169. }
  94170. _this.linesContent.appendChild(contentViewOverlays.getDomNode());
  94171. _this.linesContent.appendChild(rulers.domNode);
  94172. _this.linesContent.appendChild(_this.viewZones.domNode);
  94173. _this.linesContent.appendChild(_this.viewLines.getDomNode());
  94174. _this.linesContent.appendChild(_this.contentWidgets.domNode);
  94175. _this.linesContent.appendChild(_this.viewCursors.getDomNode());
  94176. _this.overflowGuardContainer.appendChild(margin.getDomNode());
  94177. _this.overflowGuardContainer.appendChild(_this._scrollbar.getDomNode());
  94178. _this.overflowGuardContainer.appendChild(scrollDecoration.getDomNode());
  94179. _this.overflowGuardContainer.appendChild(_this._textAreaHandler.textArea);
  94180. _this.overflowGuardContainer.appendChild(_this._textAreaHandler.textAreaCover);
  94181. _this.overflowGuardContainer.appendChild(_this.overlayWidgets.getDomNode());
  94182. _this.overflowGuardContainer.appendChild(minimap.getDomNode());
  94183. _this.domNode.appendChild(_this.overflowGuardContainer);
  94184. _this.domNode.appendChild(_this.contentWidgets.overflowingContentWidgetsDomNode);
  94185. _this._applyLayout();
  94186. // Pointer handler
  94187. _this.pointerHandler = _this._register(new pointerHandler_1.PointerHandler(_this._context, viewController, _this.createPointerHandlerHelper()));
  94188. _this._register(model.addEventListener(function (events) {
  94189. _this.eventDispatcher.emitMany(events);
  94190. }));
  94191. _this._register(_this._cursor.addEventListener(function (events) {
  94192. _this.eventDispatcher.emitMany(events);
  94193. }));
  94194. return _this;
  94195. }
  94196. View.prototype._flushAccumulatedAndRenderNow = function () {
  94197. this._renderNow();
  94198. };
  94199. View.prototype.createPointerHandlerHelper = function () {
  94200. var _this = this;
  94201. return {
  94202. viewDomNode: this.domNode.domNode,
  94203. linesContentDomNode: this.linesContent.domNode,
  94204. focusTextArea: function () {
  94205. _this.focus();
  94206. },
  94207. getLastRenderData: function () {
  94208. var lastViewCursorsRenderData = _this.viewCursors.getLastRenderData() || [];
  94209. var lastTextareaPosition = _this._textAreaHandler.getLastRenderData();
  94210. return new mouseTarget_1.PointerHandlerLastRenderData(lastViewCursorsRenderData, lastTextareaPosition);
  94211. },
  94212. shouldSuppressMouseDownOnViewZone: function (viewZoneId) {
  94213. return _this.viewZones.shouldSuppressMouseDownOnViewZone(viewZoneId);
  94214. },
  94215. shouldSuppressMouseDownOnWidget: function (widgetId) {
  94216. return _this.contentWidgets.shouldSuppressMouseDownOnWidget(widgetId);
  94217. },
  94218. getPositionFromDOMInfo: function (spanNode, offset) {
  94219. _this._flushAccumulatedAndRenderNow();
  94220. return _this.viewLines.getPositionFromDOMInfo(spanNode, offset);
  94221. },
  94222. visibleRangeForPosition: function (lineNumber, column) {
  94223. _this._flushAccumulatedAndRenderNow();
  94224. return _this.viewLines.visibleRangeForPosition(new position_1.Position(lineNumber, column));
  94225. },
  94226. getLineWidth: function (lineNumber) {
  94227. _this._flushAccumulatedAndRenderNow();
  94228. return _this.viewLines.getLineWidth(lineNumber);
  94229. }
  94230. };
  94231. };
  94232. View.prototype.createTextAreaHandlerHelper = function () {
  94233. var _this = this;
  94234. return {
  94235. visibleRangeForPositionRelativeToEditor: function (lineNumber, column) {
  94236. _this._flushAccumulatedAndRenderNow();
  94237. return _this.viewLines.visibleRangeForPosition(new position_1.Position(lineNumber, column));
  94238. }
  94239. };
  94240. };
  94241. View.prototype._applyLayout = function () {
  94242. var options = this._context.configuration.options;
  94243. var layoutInfo = options.get(107 /* layoutInfo */);
  94244. this.domNode.setWidth(layoutInfo.width);
  94245. this.domNode.setHeight(layoutInfo.height);
  94246. this.overflowGuardContainer.setWidth(layoutInfo.width);
  94247. this.overflowGuardContainer.setHeight(layoutInfo.height);
  94248. this.linesContent.setWidth(1000000);
  94249. this.linesContent.setHeight(1000000);
  94250. };
  94251. View.prototype.getEditorClassName = function () {
  94252. var focused = this._textAreaHandler.isFocused() ? ' focused' : '';
  94253. return this._context.configuration.options.get(104 /* editorClassName */) + ' ' + themeService_1.getThemeTypeSelector(this._context.theme.type) + focused;
  94254. };
  94255. // --- begin event handlers
  94256. View.prototype.onConfigurationChanged = function (e) {
  94257. this.domNode.setClassName(this.getEditorClassName());
  94258. this._applyLayout();
  94259. return false;
  94260. };
  94261. View.prototype.onContentSizeChanged = function (e) {
  94262. this.outgoingEvents.emitContentSizeChange(e);
  94263. return false;
  94264. };
  94265. View.prototype.onFocusChanged = function (e) {
  94266. this.domNode.setClassName(this.getEditorClassName());
  94267. this._context.model.setHasFocus(e.isFocused);
  94268. if (e.isFocused) {
  94269. this.outgoingEvents.emitViewFocusGained();
  94270. }
  94271. else {
  94272. this.outgoingEvents.emitViewFocusLost();
  94273. }
  94274. return false;
  94275. };
  94276. View.prototype.onScrollChanged = function (e) {
  94277. this.outgoingEvents.emitScrollChanged(e);
  94278. return false;
  94279. };
  94280. View.prototype.onThemeChanged = function (e) {
  94281. this.domNode.setClassName(this.getEditorClassName());
  94282. return false;
  94283. };
  94284. // --- end event handlers
  94285. View.prototype.dispose = function () {
  94286. if (this._renderAnimationFrame !== null) {
  94287. this._renderAnimationFrame.dispose();
  94288. this._renderAnimationFrame = null;
  94289. }
  94290. this.eventDispatcher.removeEventHandler(this);
  94291. this.outgoingEvents.dispose();
  94292. this.viewLines.dispose();
  94293. // Destroy view parts
  94294. for (var i = 0, len = this.viewParts.length; i < len; i++) {
  94295. this.viewParts[i].dispose();
  94296. }
  94297. this.viewParts = [];
  94298. _super.prototype.dispose.call(this);
  94299. };
  94300. View.prototype._renderOnce = function (callback) {
  94301. var r = safeInvokeNoArg(callback);
  94302. this._scheduleRender();
  94303. return r;
  94304. };
  94305. View.prototype._scheduleRender = function () {
  94306. if (this._renderAnimationFrame === null) {
  94307. this._renderAnimationFrame = dom.runAtThisOrScheduleAtNextAnimationFrame(this._onRenderScheduled.bind(this), 100);
  94308. }
  94309. };
  94310. View.prototype._onRenderScheduled = function () {
  94311. this._renderAnimationFrame = null;
  94312. this._flushAccumulatedAndRenderNow();
  94313. };
  94314. View.prototype._renderNow = function () {
  94315. var _this = this;
  94316. safeInvokeNoArg(function () { return _this._actualRender(); });
  94317. };
  94318. View.prototype._getViewPartsToRender = function () {
  94319. var result = [], resultLen = 0;
  94320. for (var i = 0, len = this.viewParts.length; i < len; i++) {
  94321. var viewPart = this.viewParts[i];
  94322. if (viewPart.shouldRender()) {
  94323. result[resultLen++] = viewPart;
  94324. }
  94325. }
  94326. return result;
  94327. };
  94328. View.prototype._actualRender = function () {
  94329. if (!dom.isInDOM(this.domNode.domNode)) {
  94330. return;
  94331. }
  94332. var viewPartsToRender = this._getViewPartsToRender();
  94333. if (!this.viewLines.shouldRender() && viewPartsToRender.length === 0) {
  94334. // Nothing to render
  94335. return;
  94336. }
  94337. var partialViewportData = this._context.viewLayout.getLinesViewportData();
  94338. this._context.model.setViewport(partialViewportData.startLineNumber, partialViewportData.endLineNumber, partialViewportData.centeredLineNumber);
  94339. var viewportData = new viewLinesViewportData_1.ViewportData(this._cursor.getViewSelections(), partialViewportData, this._context.viewLayout.getWhitespaceViewportData(), this._context.model);
  94340. if (this.contentWidgets.shouldRender()) {
  94341. // Give the content widgets a chance to set their max width before a possible synchronous layout
  94342. this.contentWidgets.onBeforeRender(viewportData);
  94343. }
  94344. if (this.viewLines.shouldRender()) {
  94345. this.viewLines.renderText(viewportData);
  94346. this.viewLines.onDidRender();
  94347. // Rendering of viewLines might cause scroll events to occur, so collect view parts to render again
  94348. viewPartsToRender = this._getViewPartsToRender();
  94349. }
  94350. var renderingContext = new renderingContext_1.RenderingContext(this._context.viewLayout, viewportData, this.viewLines);
  94351. // Render the rest of the parts
  94352. for (var i = 0, len = viewPartsToRender.length; i < len; i++) {
  94353. var viewPart = viewPartsToRender[i];
  94354. viewPart.prepareRender(renderingContext);
  94355. }
  94356. for (var i = 0, len = viewPartsToRender.length; i < len; i++) {
  94357. var viewPart = viewPartsToRender[i];
  94358. viewPart.render(renderingContext);
  94359. viewPart.onDidRender();
  94360. }
  94361. };
  94362. // --- BEGIN CodeEditor helpers
  94363. View.prototype.delegateVerticalScrollbarMouseDown = function (browserEvent) {
  94364. this._scrollbar.delegateVerticalScrollbarMouseDown(browserEvent);
  94365. };
  94366. View.prototype.restoreState = function (scrollPosition) {
  94367. this._context.viewLayout.setScrollPositionNow({ scrollTop: scrollPosition.scrollTop });
  94368. this._context.model.tokenizeViewport();
  94369. this._renderNow();
  94370. this.viewLines.updateLineWidths();
  94371. this._context.viewLayout.setScrollPositionNow({ scrollLeft: scrollPosition.scrollLeft });
  94372. };
  94373. View.prototype.getOffsetForColumn = function (modelLineNumber, modelColumn) {
  94374. var modelPosition = this._context.model.validateModelPosition({
  94375. lineNumber: modelLineNumber,
  94376. column: modelColumn
  94377. });
  94378. var viewPosition = this._context.model.coordinatesConverter.convertModelPositionToViewPosition(modelPosition);
  94379. this._flushAccumulatedAndRenderNow();
  94380. var visibleRange = this.viewLines.visibleRangeForPosition(new position_1.Position(viewPosition.lineNumber, viewPosition.column));
  94381. if (!visibleRange) {
  94382. return -1;
  94383. }
  94384. return visibleRange.left;
  94385. };
  94386. View.prototype.getTargetAtClientPoint = function (clientX, clientY) {
  94387. var mouseTarget = this.pointerHandler.getTargetAtClientPoint(clientX, clientY);
  94388. if (!mouseTarget) {
  94389. return null;
  94390. }
  94391. return viewOutgoingEvents_1.ViewOutgoingEvents.convertViewToModelMouseTarget(mouseTarget, this._context.model.coordinatesConverter);
  94392. };
  94393. View.prototype.createOverviewRuler = function (cssClassName) {
  94394. return new overviewRuler_1.OverviewRuler(this._context, cssClassName);
  94395. };
  94396. View.prototype.change = function (callback) {
  94397. var _this = this;
  94398. return this._renderOnce(function () {
  94399. var zonesHaveChanged = _this.viewZones.changeViewZones(callback);
  94400. if (zonesHaveChanged) {
  94401. _this._context.viewLayout.onHeightMaybeChanged();
  94402. _this._context.privateViewEventBus.emit(new viewEvents.ViewZonesChangedEvent());
  94403. }
  94404. return zonesHaveChanged;
  94405. });
  94406. };
  94407. View.prototype.render = function (now, everything) {
  94408. if (everything) {
  94409. // Force everything to render...
  94410. this.viewLines.forceShouldRender();
  94411. for (var i = 0, len = this.viewParts.length; i < len; i++) {
  94412. var viewPart = this.viewParts[i];
  94413. viewPart.forceShouldRender();
  94414. }
  94415. }
  94416. if (now) {
  94417. this._flushAccumulatedAndRenderNow();
  94418. }
  94419. else {
  94420. this._scheduleRender();
  94421. }
  94422. };
  94423. View.prototype.focus = function () {
  94424. this._textAreaHandler.focusTextArea();
  94425. };
  94426. View.prototype.isFocused = function () {
  94427. return this._textAreaHandler.isFocused();
  94428. };
  94429. View.prototype.setAriaOptions = function (options) {
  94430. this._textAreaHandler.setAriaOptions(options);
  94431. };
  94432. View.prototype.addContentWidget = function (widgetData) {
  94433. this.contentWidgets.addWidget(widgetData.widget);
  94434. this.layoutContentWidget(widgetData);
  94435. this._scheduleRender();
  94436. };
  94437. View.prototype.layoutContentWidget = function (widgetData) {
  94438. var newRange = widgetData.position ? widgetData.position.range || null : null;
  94439. if (newRange === null) {
  94440. var newPosition = widgetData.position ? widgetData.position.position : null;
  94441. if (newPosition !== null) {
  94442. newRange = new range_1.Range(newPosition.lineNumber, newPosition.column, newPosition.lineNumber, newPosition.column);
  94443. }
  94444. }
  94445. var newPreference = widgetData.position ? widgetData.position.preference : null;
  94446. this.contentWidgets.setWidgetPosition(widgetData.widget, newRange, newPreference);
  94447. this._scheduleRender();
  94448. };
  94449. View.prototype.removeContentWidget = function (widgetData) {
  94450. this.contentWidgets.removeWidget(widgetData.widget);
  94451. this._scheduleRender();
  94452. };
  94453. View.prototype.addOverlayWidget = function (widgetData) {
  94454. this.overlayWidgets.addWidget(widgetData.widget);
  94455. this.layoutOverlayWidget(widgetData);
  94456. this._scheduleRender();
  94457. };
  94458. View.prototype.layoutOverlayWidget = function (widgetData) {
  94459. var newPreference = widgetData.position ? widgetData.position.preference : null;
  94460. var shouldRender = this.overlayWidgets.setWidgetPosition(widgetData.widget, newPreference);
  94461. if (shouldRender) {
  94462. this._scheduleRender();
  94463. }
  94464. };
  94465. View.prototype.removeOverlayWidget = function (widgetData) {
  94466. this.overlayWidgets.removeWidget(widgetData.widget);
  94467. this._scheduleRender();
  94468. };
  94469. return View;
  94470. }(viewEventHandler_1.ViewEventHandler));
  94471. exports.View = View;
  94472. function safeInvokeNoArg(func) {
  94473. try {
  94474. return func();
  94475. }
  94476. catch (e) {
  94477. errors_1.onUnexpectedError(e);
  94478. }
  94479. }
  94480. });
  94481. /*---------------------------------------------------------------------------------------------
  94482. * Copyright (c) Microsoft Corporation. All rights reserved.
  94483. * Licensed under the MIT License. See License.txt in the project root for license information.
  94484. *--------------------------------------------------------------------------------------------*/
  94485. define(__m[121/*vs/editor/browser/widget/codeEditorWidget*/], __M([0/*require*/,1/*exports*/,417/*vs/nls!vs/editor/browser/widget/codeEditorWidget*/,6/*vs/base/browser/dom*/,10/*vs/base/common/errors*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,46/*vs/base/common/network*/,60/*vs/editor/browser/config/configuration*/,12/*vs/editor/browser/editorExtensions*/,32/*vs/editor/browser/services/codeEditorService*/,563/*vs/editor/browser/view/viewImpl*/,228/*vs/editor/browser/view/viewOutgoingEvents*/,33/*vs/editor/common/config/editorOptions*/,486/*vs/editor/common/controller/cursor*/,40/*vs/editor/common/controller/cursorCommon*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,190/*vs/editor/common/editorAction*/,68/*vs/editor/common/editorCommon*/,23/*vs/editor/common/editorContextKeys*/,17/*vs/editor/common/modes*/,44/*vs/editor/common/view/editorColorRegistry*/,20/*vs/platform/theme/common/colorRegistry*/,488/*vs/editor/common/viewModel/viewModelImpl*/,29/*vs/platform/commands/common/commands*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,115/*vs/platform/instantiation/common/serviceCollection*/,35/*vs/platform/notification/common/notification*/,14/*vs/platform/theme/common/themeService*/,64/*vs/platform/accessibility/common/accessibility*/,21/*vs/base/common/types*/,487/*vs/editor/common/viewModel/monospaceLineBreaksComputer*/,512/*vs/editor/browser/view/domLineBreaksComputer*/,301/*vs/css!vs/editor/browser/widget/media/editor*/]), function (require, exports, nls, dom, errors_1, event_1, lifecycle_1, network_1, configuration_1, editorExtensions_1, codeEditorService_1, viewImpl_1, viewOutgoingEvents_1, editorOptions_1, cursor_1, cursorCommon_1, position_1, range_1, selection_1, editorAction_1, editorCommon, editorContextKeys_1, modes, editorColorRegistry_1, colorRegistry_1, viewModelImpl_1, commands_1, contextkey_1, instantiation_1, serviceCollection_1, notification_1, themeService_1, accessibility_1, types_1, monospaceLineBreaksComputer_1, domLineBreaksComputer_1) {
  94486. "use strict";
  94487. Object.defineProperty(exports, "__esModule", { value: true });
  94488. var EDITOR_ID = 0;
  94489. var ModelData = /** @class */ (function () {
  94490. function ModelData(model, viewModel, cursor, view, hasRealView, listenersToRemove) {
  94491. this.model = model;
  94492. this.viewModel = viewModel;
  94493. this.cursor = cursor;
  94494. this.view = view;
  94495. this.hasRealView = hasRealView;
  94496. this.listenersToRemove = listenersToRemove;
  94497. }
  94498. ModelData.prototype.dispose = function () {
  94499. lifecycle_1.dispose(this.listenersToRemove);
  94500. this.model.onBeforeDetached();
  94501. if (this.hasRealView) {
  94502. this.view.dispose();
  94503. }
  94504. this.cursor.dispose();
  94505. this.viewModel.dispose();
  94506. };
  94507. return ModelData;
  94508. }());
  94509. var CodeEditorWidget = /** @class */ (function (_super) {
  94510. __extends(CodeEditorWidget, _super);
  94511. function CodeEditorWidget(domElement, options, codeEditorWidgetOptions, instantiationService, codeEditorService, commandService, contextKeyService, themeService, notificationService, accessibilityService) {
  94512. var _this = _super.call(this) || this;
  94513. //#region Eventing
  94514. _this._onDidDispose = _this._register(new event_1.Emitter());
  94515. _this.onDidDispose = _this._onDidDispose.event;
  94516. _this._onDidChangeModelContent = _this._register(new event_1.Emitter());
  94517. _this.onDidChangeModelContent = _this._onDidChangeModelContent.event;
  94518. _this._onDidChangeModelLanguage = _this._register(new event_1.Emitter());
  94519. _this.onDidChangeModelLanguage = _this._onDidChangeModelLanguage.event;
  94520. _this._onDidChangeModelLanguageConfiguration = _this._register(new event_1.Emitter());
  94521. _this.onDidChangeModelLanguageConfiguration = _this._onDidChangeModelLanguageConfiguration.event;
  94522. _this._onDidChangeModelOptions = _this._register(new event_1.Emitter());
  94523. _this.onDidChangeModelOptions = _this._onDidChangeModelOptions.event;
  94524. _this._onDidChangeModelDecorations = _this._register(new event_1.Emitter());
  94525. _this.onDidChangeModelDecorations = _this._onDidChangeModelDecorations.event;
  94526. _this._onDidChangeConfiguration = _this._register(new event_1.Emitter());
  94527. _this.onDidChangeConfiguration = _this._onDidChangeConfiguration.event;
  94528. _this._onDidChangeModel = _this._register(new event_1.Emitter());
  94529. _this.onDidChangeModel = _this._onDidChangeModel.event;
  94530. _this._onDidChangeCursorPosition = _this._register(new event_1.Emitter());
  94531. _this.onDidChangeCursorPosition = _this._onDidChangeCursorPosition.event;
  94532. _this._onDidChangeCursorSelection = _this._register(new event_1.Emitter());
  94533. _this.onDidChangeCursorSelection = _this._onDidChangeCursorSelection.event;
  94534. _this._onDidAttemptReadOnlyEdit = _this._register(new event_1.Emitter());
  94535. _this.onDidAttemptReadOnlyEdit = _this._onDidAttemptReadOnlyEdit.event;
  94536. _this._onDidLayoutChange = _this._register(new event_1.Emitter());
  94537. _this.onDidLayoutChange = _this._onDidLayoutChange.event;
  94538. _this._editorTextFocus = _this._register(new BooleanEventEmitter());
  94539. _this.onDidFocusEditorText = _this._editorTextFocus.onDidChangeToTrue;
  94540. _this.onDidBlurEditorText = _this._editorTextFocus.onDidChangeToFalse;
  94541. _this._editorWidgetFocus = _this._register(new BooleanEventEmitter());
  94542. _this.onDidFocusEditorWidget = _this._editorWidgetFocus.onDidChangeToTrue;
  94543. _this.onDidBlurEditorWidget = _this._editorWidgetFocus.onDidChangeToFalse;
  94544. _this._onWillType = _this._register(new event_1.Emitter());
  94545. _this.onWillType = _this._onWillType.event;
  94546. _this._onDidType = _this._register(new event_1.Emitter());
  94547. _this.onDidType = _this._onDidType.event;
  94548. _this._onDidCompositionStart = _this._register(new event_1.Emitter());
  94549. _this.onDidCompositionStart = _this._onDidCompositionStart.event;
  94550. _this._onDidCompositionEnd = _this._register(new event_1.Emitter());
  94551. _this.onDidCompositionEnd = _this._onDidCompositionEnd.event;
  94552. _this._onDidPaste = _this._register(new event_1.Emitter());
  94553. _this.onDidPaste = _this._onDidPaste.event;
  94554. _this._onMouseUp = _this._register(new event_1.Emitter());
  94555. _this.onMouseUp = _this._onMouseUp.event;
  94556. _this._onMouseDown = _this._register(new event_1.Emitter());
  94557. _this.onMouseDown = _this._onMouseDown.event;
  94558. _this._onMouseDrag = _this._register(new event_1.Emitter());
  94559. _this.onMouseDrag = _this._onMouseDrag.event;
  94560. _this._onMouseDrop = _this._register(new event_1.Emitter());
  94561. _this.onMouseDrop = _this._onMouseDrop.event;
  94562. _this._onContextMenu = _this._register(new event_1.Emitter());
  94563. _this.onContextMenu = _this._onContextMenu.event;
  94564. _this._onMouseMove = _this._register(new event_1.Emitter());
  94565. _this.onMouseMove = _this._onMouseMove.event;
  94566. _this._onMouseLeave = _this._register(new event_1.Emitter());
  94567. _this.onMouseLeave = _this._onMouseLeave.event;
  94568. _this._onMouseWheel = _this._register(new event_1.Emitter());
  94569. _this.onMouseWheel = _this._onMouseWheel.event;
  94570. _this._onKeyUp = _this._register(new event_1.Emitter());
  94571. _this.onKeyUp = _this._onKeyUp.event;
  94572. _this._onKeyDown = _this._register(new event_1.Emitter());
  94573. _this.onKeyDown = _this._onKeyDown.event;
  94574. _this._onDidContentSizeChange = _this._register(new event_1.Emitter());
  94575. _this.onDidContentSizeChange = _this._onDidContentSizeChange.event;
  94576. _this._onDidScrollChange = _this._register(new event_1.Emitter());
  94577. _this.onDidScrollChange = _this._onDidScrollChange.event;
  94578. _this._onDidChangeViewZones = _this._register(new event_1.Emitter());
  94579. _this.onDidChangeViewZones = _this._onDidChangeViewZones.event;
  94580. _this._domElement = domElement;
  94581. _this._id = (++EDITOR_ID);
  94582. _this._decorationTypeKeysToIds = {};
  94583. _this._decorationTypeSubtypes = {};
  94584. _this.isSimpleWidget = codeEditorWidgetOptions.isSimpleWidget || false;
  94585. _this._telemetryData = codeEditorWidgetOptions.telemetryData;
  94586. options = options || {};
  94587. _this._configuration = _this._register(_this._createConfiguration(options, accessibilityService));
  94588. _this._register(_this._configuration.onDidChange(function (e) {
  94589. _this._onDidChangeConfiguration.fire(e);
  94590. var options = _this._configuration.options;
  94591. if (e.hasChanged(107 /* layoutInfo */)) {
  94592. var layoutInfo = options.get(107 /* layoutInfo */);
  94593. _this._onDidLayoutChange.fire(layoutInfo);
  94594. }
  94595. }));
  94596. _this._contextKeyService = _this._register(contextKeyService.createScoped(_this._domElement));
  94597. _this._notificationService = notificationService;
  94598. _this._codeEditorService = codeEditorService;
  94599. _this._commandService = commandService;
  94600. _this._themeService = themeService;
  94601. _this._register(new EditorContextKeysManager(_this, _this._contextKeyService));
  94602. _this._register(new EditorModeContext(_this, _this._contextKeyService));
  94603. _this._instantiationService = instantiationService.createChild(new serviceCollection_1.ServiceCollection([contextkey_1.IContextKeyService, _this._contextKeyService]));
  94604. _this._modelData = null;
  94605. _this._contributions = {};
  94606. _this._actions = {};
  94607. _this._focusTracker = new CodeEditorWidgetFocusTracker(domElement);
  94608. _this._focusTracker.onChange(function () {
  94609. _this._editorWidgetFocus.setValue(_this._focusTracker.hasFocus());
  94610. });
  94611. _this._contentWidgets = {};
  94612. _this._overlayWidgets = {};
  94613. var contributions;
  94614. if (Array.isArray(codeEditorWidgetOptions.contributions)) {
  94615. contributions = codeEditorWidgetOptions.contributions;
  94616. }
  94617. else {
  94618. contributions = editorExtensions_1.EditorExtensionsRegistry.getEditorContributions();
  94619. }
  94620. for (var _i = 0, contributions_1 = contributions; _i < contributions_1.length; _i++) {
  94621. var desc = contributions_1[_i];
  94622. try {
  94623. var contribution = _this._instantiationService.createInstance(desc.ctor, _this);
  94624. _this._contributions[desc.id] = contribution;
  94625. }
  94626. catch (err) {
  94627. errors_1.onUnexpectedError(err);
  94628. }
  94629. }
  94630. editorExtensions_1.EditorExtensionsRegistry.getEditorActions().forEach(function (action) {
  94631. var internalAction = new editorAction_1.InternalEditorAction(action.id, action.label, action.alias, types_1.withNullAsUndefined(action.precondition), function () {
  94632. return _this._instantiationService.invokeFunction(function (accessor) {
  94633. return Promise.resolve(action.runEditorCommand(accessor, _this, null));
  94634. });
  94635. }, _this._contextKeyService);
  94636. _this._actions[internalAction.id] = internalAction;
  94637. });
  94638. _this._codeEditorService.addCodeEditor(_this);
  94639. return _this;
  94640. }
  94641. CodeEditorWidget.prototype._createConfiguration = function (options, accessibilityService) {
  94642. return new configuration_1.Configuration(this.isSimpleWidget, options, this._domElement, accessibilityService);
  94643. };
  94644. CodeEditorWidget.prototype.getId = function () {
  94645. return this.getEditorType() + ':' + this._id;
  94646. };
  94647. CodeEditorWidget.prototype.getEditorType = function () {
  94648. return editorCommon.EditorType.ICodeEditor;
  94649. };
  94650. CodeEditorWidget.prototype.dispose = function () {
  94651. this._codeEditorService.removeCodeEditor(this);
  94652. this._focusTracker.dispose();
  94653. var keys = Object.keys(this._contributions);
  94654. for (var i = 0, len = keys.length; i < len; i++) {
  94655. var contributionId = keys[i];
  94656. this._contributions[contributionId].dispose();
  94657. }
  94658. this._removeDecorationTypes();
  94659. this._postDetachModelCleanup(this._detachModel());
  94660. this._onDidDispose.fire();
  94661. _super.prototype.dispose.call(this);
  94662. };
  94663. CodeEditorWidget.prototype.invokeWithinContext = function (fn) {
  94664. return this._instantiationService.invokeFunction(fn);
  94665. };
  94666. CodeEditorWidget.prototype.updateOptions = function (newOptions) {
  94667. this._configuration.updateOptions(newOptions);
  94668. };
  94669. CodeEditorWidget.prototype.getOptions = function () {
  94670. return this._configuration.options;
  94671. };
  94672. CodeEditorWidget.prototype.getOption = function (id) {
  94673. return this._configuration.options.get(id);
  94674. };
  94675. CodeEditorWidget.prototype.getRawOptions = function () {
  94676. return this._configuration.getRawOptions();
  94677. };
  94678. CodeEditorWidget.prototype.getValue = function (options) {
  94679. if (options === void 0) { options = null; }
  94680. if (!this._modelData) {
  94681. return '';
  94682. }
  94683. var preserveBOM = (options && options.preserveBOM) ? true : false;
  94684. var eolPreference = 0 /* TextDefined */;
  94685. if (options && options.lineEnding && options.lineEnding === '\n') {
  94686. eolPreference = 1 /* LF */;
  94687. }
  94688. else if (options && options.lineEnding && options.lineEnding === '\r\n') {
  94689. eolPreference = 2 /* CRLF */;
  94690. }
  94691. return this._modelData.model.getValue(eolPreference, preserveBOM);
  94692. };
  94693. CodeEditorWidget.prototype.setValue = function (newValue) {
  94694. if (!this._modelData) {
  94695. return;
  94696. }
  94697. this._modelData.model.setValue(newValue);
  94698. };
  94699. CodeEditorWidget.prototype.getModel = function () {
  94700. if (!this._modelData) {
  94701. return null;
  94702. }
  94703. return this._modelData.model;
  94704. };
  94705. CodeEditorWidget.prototype.setModel = function (_model) {
  94706. if (_model === void 0) { _model = null; }
  94707. var model = _model;
  94708. if (this._modelData === null && model === null) {
  94709. // Current model is the new model
  94710. return;
  94711. }
  94712. if (this._modelData && this._modelData.model === model) {
  94713. // Current model is the new model
  94714. return;
  94715. }
  94716. var hasTextFocus = this.hasTextFocus();
  94717. var detachedModel = this._detachModel();
  94718. this._attachModel(model);
  94719. if (hasTextFocus && this.hasModel()) {
  94720. this.focus();
  94721. }
  94722. var e = {
  94723. oldModelUrl: detachedModel ? detachedModel.uri : null,
  94724. newModelUrl: model ? model.uri : null
  94725. };
  94726. this._removeDecorationTypes();
  94727. this._onDidChangeModel.fire(e);
  94728. this._postDetachModelCleanup(detachedModel);
  94729. };
  94730. CodeEditorWidget.prototype._removeDecorationTypes = function () {
  94731. this._decorationTypeKeysToIds = {};
  94732. if (this._decorationTypeSubtypes) {
  94733. for (var decorationType in this._decorationTypeSubtypes) {
  94734. var subTypes = this._decorationTypeSubtypes[decorationType];
  94735. for (var subType in subTypes) {
  94736. this._removeDecorationType(decorationType + '-' + subType);
  94737. }
  94738. }
  94739. this._decorationTypeSubtypes = {};
  94740. }
  94741. };
  94742. CodeEditorWidget.prototype.getVisibleRanges = function () {
  94743. if (!this._modelData) {
  94744. return [];
  94745. }
  94746. return this._modelData.viewModel.getVisibleRanges();
  94747. };
  94748. CodeEditorWidget.prototype.getWhitespaces = function () {
  94749. if (!this._modelData) {
  94750. return [];
  94751. }
  94752. return this._modelData.viewModel.viewLayout.getWhitespaces();
  94753. };
  94754. CodeEditorWidget._getVerticalOffsetForPosition = function (modelData, modelLineNumber, modelColumn) {
  94755. var modelPosition = modelData.model.validatePosition({
  94756. lineNumber: modelLineNumber,
  94757. column: modelColumn
  94758. });
  94759. var viewPosition = modelData.viewModel.coordinatesConverter.convertModelPositionToViewPosition(modelPosition);
  94760. return modelData.viewModel.viewLayout.getVerticalOffsetForLineNumber(viewPosition.lineNumber);
  94761. };
  94762. CodeEditorWidget.prototype.getTopForLineNumber = function (lineNumber) {
  94763. if (!this._modelData) {
  94764. return -1;
  94765. }
  94766. return CodeEditorWidget._getVerticalOffsetForPosition(this._modelData, lineNumber, 1);
  94767. };
  94768. CodeEditorWidget.prototype.getTopForPosition = function (lineNumber, column) {
  94769. if (!this._modelData) {
  94770. return -1;
  94771. }
  94772. return CodeEditorWidget._getVerticalOffsetForPosition(this._modelData, lineNumber, column);
  94773. };
  94774. CodeEditorWidget.prototype.setHiddenAreas = function (ranges) {
  94775. if (this._modelData) {
  94776. this._modelData.viewModel.setHiddenAreas(ranges.map(function (r) { return range_1.Range.lift(r); }));
  94777. }
  94778. };
  94779. CodeEditorWidget.prototype.getVisibleColumnFromPosition = function (rawPosition) {
  94780. if (!this._modelData) {
  94781. return rawPosition.column;
  94782. }
  94783. var position = this._modelData.model.validatePosition(rawPosition);
  94784. var tabSize = this._modelData.model.getOptions().tabSize;
  94785. return cursorCommon_1.CursorColumns.visibleColumnFromColumn(this._modelData.model.getLineContent(position.lineNumber), position.column, tabSize) + 1;
  94786. };
  94787. CodeEditorWidget.prototype.getPosition = function () {
  94788. if (!this._modelData) {
  94789. return null;
  94790. }
  94791. return this._modelData.cursor.getPosition();
  94792. };
  94793. CodeEditorWidget.prototype.setPosition = function (position) {
  94794. if (!this._modelData) {
  94795. return;
  94796. }
  94797. if (!position_1.Position.isIPosition(position)) {
  94798. throw new Error('Invalid arguments');
  94799. }
  94800. this._modelData.cursor.setSelections('api', [{
  94801. selectionStartLineNumber: position.lineNumber,
  94802. selectionStartColumn: position.column,
  94803. positionLineNumber: position.lineNumber,
  94804. positionColumn: position.column
  94805. }]);
  94806. };
  94807. CodeEditorWidget.prototype._sendRevealRange = function (modelRange, verticalType, revealHorizontal, scrollType) {
  94808. if (!this._modelData) {
  94809. return;
  94810. }
  94811. if (!range_1.Range.isIRange(modelRange)) {
  94812. throw new Error('Invalid arguments');
  94813. }
  94814. var validatedModelRange = this._modelData.model.validateRange(modelRange);
  94815. var viewRange = this._modelData.viewModel.coordinatesConverter.convertModelRangeToViewRange(validatedModelRange);
  94816. this._modelData.cursor.emitCursorRevealRange('api', viewRange, verticalType, revealHorizontal, scrollType);
  94817. };
  94818. CodeEditorWidget.prototype.revealLine = function (lineNumber, scrollType) {
  94819. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94820. this._revealLine(lineNumber, 0 /* Simple */, scrollType);
  94821. };
  94822. CodeEditorWidget.prototype.revealLineInCenter = function (lineNumber, scrollType) {
  94823. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94824. this._revealLine(lineNumber, 1 /* Center */, scrollType);
  94825. };
  94826. CodeEditorWidget.prototype.revealLineInCenterIfOutsideViewport = function (lineNumber, scrollType) {
  94827. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94828. this._revealLine(lineNumber, 2 /* CenterIfOutsideViewport */, scrollType);
  94829. };
  94830. CodeEditorWidget.prototype._revealLine = function (lineNumber, revealType, scrollType) {
  94831. if (typeof lineNumber !== 'number') {
  94832. throw new Error('Invalid arguments');
  94833. }
  94834. this._sendRevealRange(new range_1.Range(lineNumber, 1, lineNumber, 1), revealType, false, scrollType);
  94835. };
  94836. CodeEditorWidget.prototype.revealPosition = function (position, scrollType) {
  94837. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94838. this._revealPosition(position, 0 /* Simple */, true, scrollType);
  94839. };
  94840. CodeEditorWidget.prototype.revealPositionInCenter = function (position, scrollType) {
  94841. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94842. this._revealPosition(position, 1 /* Center */, true, scrollType);
  94843. };
  94844. CodeEditorWidget.prototype.revealPositionInCenterIfOutsideViewport = function (position, scrollType) {
  94845. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94846. this._revealPosition(position, 2 /* CenterIfOutsideViewport */, true, scrollType);
  94847. };
  94848. CodeEditorWidget.prototype._revealPosition = function (position, verticalType, revealHorizontal, scrollType) {
  94849. if (!position_1.Position.isIPosition(position)) {
  94850. throw new Error('Invalid arguments');
  94851. }
  94852. this._sendRevealRange(new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column), verticalType, revealHorizontal, scrollType);
  94853. };
  94854. CodeEditorWidget.prototype.getSelection = function () {
  94855. if (!this._modelData) {
  94856. return null;
  94857. }
  94858. return this._modelData.cursor.getSelection();
  94859. };
  94860. CodeEditorWidget.prototype.getSelections = function () {
  94861. if (!this._modelData) {
  94862. return null;
  94863. }
  94864. return this._modelData.cursor.getSelections();
  94865. };
  94866. CodeEditorWidget.prototype.setSelection = function (something) {
  94867. var isSelection = selection_1.Selection.isISelection(something);
  94868. var isRange = range_1.Range.isIRange(something);
  94869. if (!isSelection && !isRange) {
  94870. throw new Error('Invalid arguments');
  94871. }
  94872. if (isSelection) {
  94873. this._setSelectionImpl(something);
  94874. }
  94875. else if (isRange) {
  94876. // act as if it was an IRange
  94877. var selection = {
  94878. selectionStartLineNumber: something.startLineNumber,
  94879. selectionStartColumn: something.startColumn,
  94880. positionLineNumber: something.endLineNumber,
  94881. positionColumn: something.endColumn
  94882. };
  94883. this._setSelectionImpl(selection);
  94884. }
  94885. };
  94886. CodeEditorWidget.prototype._setSelectionImpl = function (sel) {
  94887. if (!this._modelData) {
  94888. return;
  94889. }
  94890. var selection = new selection_1.Selection(sel.selectionStartLineNumber, sel.selectionStartColumn, sel.positionLineNumber, sel.positionColumn);
  94891. this._modelData.cursor.setSelections('api', [selection]);
  94892. };
  94893. CodeEditorWidget.prototype.revealLines = function (startLineNumber, endLineNumber, scrollType) {
  94894. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94895. this._revealLines(startLineNumber, endLineNumber, 0 /* Simple */, scrollType);
  94896. };
  94897. CodeEditorWidget.prototype.revealLinesInCenter = function (startLineNumber, endLineNumber, scrollType) {
  94898. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94899. this._revealLines(startLineNumber, endLineNumber, 1 /* Center */, scrollType);
  94900. };
  94901. CodeEditorWidget.prototype.revealLinesInCenterIfOutsideViewport = function (startLineNumber, endLineNumber, scrollType) {
  94902. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94903. this._revealLines(startLineNumber, endLineNumber, 2 /* CenterIfOutsideViewport */, scrollType);
  94904. };
  94905. CodeEditorWidget.prototype._revealLines = function (startLineNumber, endLineNumber, verticalType, scrollType) {
  94906. if (typeof startLineNumber !== 'number' || typeof endLineNumber !== 'number') {
  94907. throw new Error('Invalid arguments');
  94908. }
  94909. this._sendRevealRange(new range_1.Range(startLineNumber, 1, endLineNumber, 1), verticalType, false, scrollType);
  94910. };
  94911. CodeEditorWidget.prototype.revealRange = function (range, scrollType, revealVerticalInCenter, revealHorizontal) {
  94912. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94913. if (revealVerticalInCenter === void 0) { revealVerticalInCenter = false; }
  94914. if (revealHorizontal === void 0) { revealHorizontal = true; }
  94915. this._revealRange(range, revealVerticalInCenter ? 1 /* Center */ : 0 /* Simple */, revealHorizontal, scrollType);
  94916. };
  94917. CodeEditorWidget.prototype.revealRangeInCenter = function (range, scrollType) {
  94918. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94919. this._revealRange(range, 1 /* Center */, true, scrollType);
  94920. };
  94921. CodeEditorWidget.prototype.revealRangeInCenterIfOutsideViewport = function (range, scrollType) {
  94922. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94923. this._revealRange(range, 2 /* CenterIfOutsideViewport */, true, scrollType);
  94924. };
  94925. CodeEditorWidget.prototype.revealRangeAtTop = function (range, scrollType) {
  94926. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  94927. this._revealRange(range, 3 /* Top */, true, scrollType);
  94928. };
  94929. CodeEditorWidget.prototype._revealRange = function (range, verticalType, revealHorizontal, scrollType) {
  94930. if (!range_1.Range.isIRange(range)) {
  94931. throw new Error('Invalid arguments');
  94932. }
  94933. this._sendRevealRange(range_1.Range.lift(range), verticalType, revealHorizontal, scrollType);
  94934. };
  94935. CodeEditorWidget.prototype.setSelections = function (ranges, source) {
  94936. if (source === void 0) { source = 'api'; }
  94937. if (!this._modelData) {
  94938. return;
  94939. }
  94940. if (!ranges || ranges.length === 0) {
  94941. throw new Error('Invalid arguments');
  94942. }
  94943. for (var i = 0, len = ranges.length; i < len; i++) {
  94944. if (!selection_1.Selection.isISelection(ranges[i])) {
  94945. throw new Error('Invalid arguments');
  94946. }
  94947. }
  94948. this._modelData.cursor.setSelections(source, ranges);
  94949. };
  94950. CodeEditorWidget.prototype.getContentWidth = function () {
  94951. if (!this._modelData) {
  94952. return -1;
  94953. }
  94954. return this._modelData.viewModel.viewLayout.getContentWidth();
  94955. };
  94956. CodeEditorWidget.prototype.getScrollWidth = function () {
  94957. if (!this._modelData) {
  94958. return -1;
  94959. }
  94960. return this._modelData.viewModel.viewLayout.getScrollWidth();
  94961. };
  94962. CodeEditorWidget.prototype.getScrollLeft = function () {
  94963. if (!this._modelData) {
  94964. return -1;
  94965. }
  94966. return this._modelData.viewModel.viewLayout.getCurrentScrollLeft();
  94967. };
  94968. CodeEditorWidget.prototype.getContentHeight = function () {
  94969. if (!this._modelData) {
  94970. return -1;
  94971. }
  94972. return this._modelData.viewModel.viewLayout.getContentHeight();
  94973. };
  94974. CodeEditorWidget.prototype.getScrollHeight = function () {
  94975. if (!this._modelData) {
  94976. return -1;
  94977. }
  94978. return this._modelData.viewModel.viewLayout.getScrollHeight();
  94979. };
  94980. CodeEditorWidget.prototype.getScrollTop = function () {
  94981. if (!this._modelData) {
  94982. return -1;
  94983. }
  94984. return this._modelData.viewModel.viewLayout.getCurrentScrollTop();
  94985. };
  94986. CodeEditorWidget.prototype.setScrollLeft = function (newScrollLeft) {
  94987. if (!this._modelData) {
  94988. return;
  94989. }
  94990. if (typeof newScrollLeft !== 'number') {
  94991. throw new Error('Invalid arguments');
  94992. }
  94993. this._modelData.viewModel.viewLayout.setScrollPositionNow({
  94994. scrollLeft: newScrollLeft
  94995. });
  94996. };
  94997. CodeEditorWidget.prototype.setScrollTop = function (newScrollTop) {
  94998. if (!this._modelData) {
  94999. return;
  95000. }
  95001. if (typeof newScrollTop !== 'number') {
  95002. throw new Error('Invalid arguments');
  95003. }
  95004. this._modelData.viewModel.viewLayout.setScrollPositionNow({
  95005. scrollTop: newScrollTop
  95006. });
  95007. };
  95008. CodeEditorWidget.prototype.setScrollPosition = function (position) {
  95009. if (!this._modelData) {
  95010. return;
  95011. }
  95012. this._modelData.viewModel.viewLayout.setScrollPositionNow(position);
  95013. };
  95014. CodeEditorWidget.prototype.saveViewState = function () {
  95015. if (!this._modelData) {
  95016. return null;
  95017. }
  95018. var contributionsState = {};
  95019. var keys = Object.keys(this._contributions);
  95020. for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
  95021. var id = keys_1[_i];
  95022. var contribution = this._contributions[id];
  95023. if (typeof contribution.saveViewState === 'function') {
  95024. contributionsState[id] = contribution.saveViewState();
  95025. }
  95026. }
  95027. var cursorState = this._modelData.cursor.saveState();
  95028. var viewState = this._modelData.viewModel.saveState();
  95029. return {
  95030. cursorState: cursorState,
  95031. viewState: viewState,
  95032. contributionsState: contributionsState
  95033. };
  95034. };
  95035. CodeEditorWidget.prototype.restoreViewState = function (s) {
  95036. if (!this._modelData || !this._modelData.hasRealView) {
  95037. return;
  95038. }
  95039. var codeEditorState = s;
  95040. if (codeEditorState && codeEditorState.cursorState && codeEditorState.viewState) {
  95041. var cursorState = codeEditorState.cursorState;
  95042. if (Array.isArray(cursorState)) {
  95043. this._modelData.cursor.restoreState(cursorState);
  95044. }
  95045. else {
  95046. // Backwards compatibility
  95047. this._modelData.cursor.restoreState([cursorState]);
  95048. }
  95049. var contributionsState = codeEditorState.contributionsState || {};
  95050. var keys = Object.keys(this._contributions);
  95051. for (var i = 0, len = keys.length; i < len; i++) {
  95052. var id = keys[i];
  95053. var contribution = this._contributions[id];
  95054. if (typeof contribution.restoreViewState === 'function') {
  95055. contribution.restoreViewState(contributionsState[id]);
  95056. }
  95057. }
  95058. var reducedState = this._modelData.viewModel.reduceRestoreState(codeEditorState.viewState);
  95059. this._modelData.view.restoreState(reducedState);
  95060. }
  95061. };
  95062. CodeEditorWidget.prototype.getContribution = function (id) {
  95063. return (this._contributions[id] || null);
  95064. };
  95065. CodeEditorWidget.prototype.getActions = function () {
  95066. var result = [];
  95067. var keys = Object.keys(this._actions);
  95068. for (var i = 0, len = keys.length; i < len; i++) {
  95069. var id = keys[i];
  95070. result.push(this._actions[id]);
  95071. }
  95072. return result;
  95073. };
  95074. CodeEditorWidget.prototype.getSupportedActions = function () {
  95075. var result = this.getActions();
  95076. result = result.filter(function (action) { return action.isSupported(); });
  95077. return result;
  95078. };
  95079. CodeEditorWidget.prototype.getAction = function (id) {
  95080. return this._actions[id] || null;
  95081. };
  95082. CodeEditorWidget.prototype.trigger = function (source, handlerId, payload) {
  95083. payload = payload || {};
  95084. // Special case for typing
  95085. if (handlerId === editorCommon.Handler.Type) {
  95086. if (!this._modelData || typeof payload.text !== 'string' || payload.text.length === 0) {
  95087. // nothing to do
  95088. return;
  95089. }
  95090. if (source === 'keyboard') {
  95091. this._onWillType.fire(payload.text);
  95092. }
  95093. this._modelData.cursor.trigger(source, handlerId, payload);
  95094. if (source === 'keyboard') {
  95095. this._onDidType.fire(payload.text);
  95096. }
  95097. return;
  95098. }
  95099. // Special case for pasting
  95100. if (handlerId === editorCommon.Handler.Paste) {
  95101. if (!this._modelData || typeof payload.text !== 'string' || payload.text.length === 0) {
  95102. // nothing to do
  95103. return;
  95104. }
  95105. var startPosition = this._modelData.cursor.getSelection().getStartPosition();
  95106. this._modelData.cursor.trigger(source, handlerId, payload);
  95107. var endPosition = this._modelData.cursor.getSelection().getStartPosition();
  95108. if (source === 'keyboard') {
  95109. this._onDidPaste.fire({
  95110. range: new range_1.Range(startPosition.lineNumber, startPosition.column, endPosition.lineNumber, endPosition.column),
  95111. mode: payload.mode
  95112. });
  95113. }
  95114. return;
  95115. }
  95116. var action = this.getAction(handlerId);
  95117. if (action) {
  95118. Promise.resolve(action.run()).then(undefined, errors_1.onUnexpectedError);
  95119. return;
  95120. }
  95121. if (!this._modelData) {
  95122. return;
  95123. }
  95124. if (this._triggerEditorCommand(source, handlerId, payload)) {
  95125. return;
  95126. }
  95127. this._modelData.cursor.trigger(source, handlerId, payload);
  95128. if (handlerId === editorCommon.Handler.CompositionStart) {
  95129. this._onDidCompositionStart.fire();
  95130. }
  95131. if (handlerId === editorCommon.Handler.CompositionEnd) {
  95132. this._onDidCompositionEnd.fire();
  95133. }
  95134. };
  95135. CodeEditorWidget.prototype._triggerEditorCommand = function (source, handlerId, payload) {
  95136. var _this = this;
  95137. var command = editorExtensions_1.EditorExtensionsRegistry.getEditorCommand(handlerId);
  95138. if (command) {
  95139. payload = payload || {};
  95140. payload.source = source;
  95141. this._instantiationService.invokeFunction(function (accessor) {
  95142. Promise.resolve(command.runEditorCommand(accessor, _this, payload)).then(undefined, errors_1.onUnexpectedError);
  95143. });
  95144. return true;
  95145. }
  95146. return false;
  95147. };
  95148. CodeEditorWidget.prototype._getCursors = function () {
  95149. if (!this._modelData) {
  95150. return null;
  95151. }
  95152. return this._modelData.cursor;
  95153. };
  95154. CodeEditorWidget.prototype.pushUndoStop = function () {
  95155. if (!this._modelData) {
  95156. return false;
  95157. }
  95158. if (this._configuration.options.get(68 /* readOnly */)) {
  95159. // read only editor => sorry!
  95160. return false;
  95161. }
  95162. this._modelData.model.pushStackElement();
  95163. return true;
  95164. };
  95165. CodeEditorWidget.prototype.executeEdits = function (source, edits, endCursorState) {
  95166. if (!this._modelData) {
  95167. return false;
  95168. }
  95169. if (this._configuration.options.get(68 /* readOnly */)) {
  95170. // read only editor => sorry!
  95171. return false;
  95172. }
  95173. var cursorStateComputer;
  95174. if (!endCursorState) {
  95175. cursorStateComputer = function () { return null; };
  95176. }
  95177. else if (Array.isArray(endCursorState)) {
  95178. cursorStateComputer = function () { return endCursorState; };
  95179. }
  95180. else {
  95181. cursorStateComputer = endCursorState;
  95182. }
  95183. this._modelData.cursor.executeEdits(source, edits, cursorStateComputer);
  95184. return true;
  95185. };
  95186. CodeEditorWidget.prototype.executeCommand = function (source, command) {
  95187. if (!this._modelData) {
  95188. return;
  95189. }
  95190. this._modelData.cursor.trigger(source, editorCommon.Handler.ExecuteCommand, command);
  95191. };
  95192. CodeEditorWidget.prototype.executeCommands = function (source, commands) {
  95193. if (!this._modelData) {
  95194. return;
  95195. }
  95196. this._modelData.cursor.trigger(source, editorCommon.Handler.ExecuteCommands, commands);
  95197. };
  95198. CodeEditorWidget.prototype.changeDecorations = function (callback) {
  95199. if (!this._modelData) {
  95200. // callback will not be called
  95201. return null;
  95202. }
  95203. return this._modelData.model.changeDecorations(callback, this._id);
  95204. };
  95205. CodeEditorWidget.prototype.getLineDecorations = function (lineNumber) {
  95206. if (!this._modelData) {
  95207. return null;
  95208. }
  95209. return this._modelData.model.getLineDecorations(lineNumber, this._id, editorOptions_1.filterValidationDecorations(this._configuration.options));
  95210. };
  95211. CodeEditorWidget.prototype.deltaDecorations = function (oldDecorations, newDecorations) {
  95212. if (!this._modelData) {
  95213. return [];
  95214. }
  95215. if (oldDecorations.length === 0 && newDecorations.length === 0) {
  95216. return oldDecorations;
  95217. }
  95218. return this._modelData.model.deltaDecorations(oldDecorations, newDecorations, this._id);
  95219. };
  95220. CodeEditorWidget.prototype.removeDecorations = function (decorationTypeKey) {
  95221. // remove decorations for type and sub type
  95222. var oldDecorationsIds = this._decorationTypeKeysToIds[decorationTypeKey];
  95223. if (oldDecorationsIds) {
  95224. this.deltaDecorations(oldDecorationsIds, []);
  95225. }
  95226. if (this._decorationTypeKeysToIds.hasOwnProperty(decorationTypeKey)) {
  95227. delete this._decorationTypeKeysToIds[decorationTypeKey];
  95228. }
  95229. if (this._decorationTypeSubtypes.hasOwnProperty(decorationTypeKey)) {
  95230. delete this._decorationTypeSubtypes[decorationTypeKey];
  95231. }
  95232. };
  95233. CodeEditorWidget.prototype.getLayoutInfo = function () {
  95234. var options = this._configuration.options;
  95235. var layoutInfo = options.get(107 /* layoutInfo */);
  95236. return layoutInfo;
  95237. };
  95238. CodeEditorWidget.prototype.createOverviewRuler = function (cssClassName) {
  95239. if (!this._modelData || !this._modelData.hasRealView) {
  95240. return null;
  95241. }
  95242. return this._modelData.view.createOverviewRuler(cssClassName);
  95243. };
  95244. CodeEditorWidget.prototype.getContainerDomNode = function () {
  95245. return this._domElement;
  95246. };
  95247. CodeEditorWidget.prototype.getDomNode = function () {
  95248. if (!this._modelData || !this._modelData.hasRealView) {
  95249. return null;
  95250. }
  95251. return this._modelData.view.domNode.domNode;
  95252. };
  95253. CodeEditorWidget.prototype.delegateVerticalScrollbarMouseDown = function (browserEvent) {
  95254. if (!this._modelData || !this._modelData.hasRealView) {
  95255. return;
  95256. }
  95257. this._modelData.view.delegateVerticalScrollbarMouseDown(browserEvent);
  95258. };
  95259. CodeEditorWidget.prototype.layout = function (dimension) {
  95260. this._configuration.observeReferenceElement(dimension);
  95261. this.render();
  95262. };
  95263. CodeEditorWidget.prototype.focus = function () {
  95264. if (!this._modelData || !this._modelData.hasRealView) {
  95265. return;
  95266. }
  95267. this._modelData.view.focus();
  95268. };
  95269. CodeEditorWidget.prototype.hasTextFocus = function () {
  95270. if (!this._modelData || !this._modelData.hasRealView) {
  95271. return false;
  95272. }
  95273. return this._modelData.view.isFocused();
  95274. };
  95275. CodeEditorWidget.prototype.hasWidgetFocus = function () {
  95276. return this._focusTracker && this._focusTracker.hasFocus();
  95277. };
  95278. CodeEditorWidget.prototype.addContentWidget = function (widget) {
  95279. var widgetData = {
  95280. widget: widget,
  95281. position: widget.getPosition()
  95282. };
  95283. if (this._contentWidgets.hasOwnProperty(widget.getId())) {
  95284. console.warn('Overwriting a content widget with the same id.');
  95285. }
  95286. this._contentWidgets[widget.getId()] = widgetData;
  95287. if (this._modelData && this._modelData.hasRealView) {
  95288. this._modelData.view.addContentWidget(widgetData);
  95289. }
  95290. };
  95291. CodeEditorWidget.prototype.layoutContentWidget = function (widget) {
  95292. var widgetId = widget.getId();
  95293. if (this._contentWidgets.hasOwnProperty(widgetId)) {
  95294. var widgetData = this._contentWidgets[widgetId];
  95295. widgetData.position = widget.getPosition();
  95296. if (this._modelData && this._modelData.hasRealView) {
  95297. this._modelData.view.layoutContentWidget(widgetData);
  95298. }
  95299. }
  95300. };
  95301. CodeEditorWidget.prototype.removeContentWidget = function (widget) {
  95302. var widgetId = widget.getId();
  95303. if (this._contentWidgets.hasOwnProperty(widgetId)) {
  95304. var widgetData = this._contentWidgets[widgetId];
  95305. delete this._contentWidgets[widgetId];
  95306. if (this._modelData && this._modelData.hasRealView) {
  95307. this._modelData.view.removeContentWidget(widgetData);
  95308. }
  95309. }
  95310. };
  95311. CodeEditorWidget.prototype.addOverlayWidget = function (widget) {
  95312. var widgetData = {
  95313. widget: widget,
  95314. position: widget.getPosition()
  95315. };
  95316. if (this._overlayWidgets.hasOwnProperty(widget.getId())) {
  95317. console.warn('Overwriting an overlay widget with the same id.');
  95318. }
  95319. this._overlayWidgets[widget.getId()] = widgetData;
  95320. if (this._modelData && this._modelData.hasRealView) {
  95321. this._modelData.view.addOverlayWidget(widgetData);
  95322. }
  95323. };
  95324. CodeEditorWidget.prototype.layoutOverlayWidget = function (widget) {
  95325. var widgetId = widget.getId();
  95326. if (this._overlayWidgets.hasOwnProperty(widgetId)) {
  95327. var widgetData = this._overlayWidgets[widgetId];
  95328. widgetData.position = widget.getPosition();
  95329. if (this._modelData && this._modelData.hasRealView) {
  95330. this._modelData.view.layoutOverlayWidget(widgetData);
  95331. }
  95332. }
  95333. };
  95334. CodeEditorWidget.prototype.removeOverlayWidget = function (widget) {
  95335. var widgetId = widget.getId();
  95336. if (this._overlayWidgets.hasOwnProperty(widgetId)) {
  95337. var widgetData = this._overlayWidgets[widgetId];
  95338. delete this._overlayWidgets[widgetId];
  95339. if (this._modelData && this._modelData.hasRealView) {
  95340. this._modelData.view.removeOverlayWidget(widgetData);
  95341. }
  95342. }
  95343. };
  95344. CodeEditorWidget.prototype.changeViewZones = function (callback) {
  95345. if (!this._modelData || !this._modelData.hasRealView) {
  95346. return;
  95347. }
  95348. var hasChanges = this._modelData.view.change(callback);
  95349. if (hasChanges) {
  95350. this._onDidChangeViewZones.fire();
  95351. }
  95352. };
  95353. CodeEditorWidget.prototype.getTargetAtClientPoint = function (clientX, clientY) {
  95354. if (!this._modelData || !this._modelData.hasRealView) {
  95355. return null;
  95356. }
  95357. return this._modelData.view.getTargetAtClientPoint(clientX, clientY);
  95358. };
  95359. CodeEditorWidget.prototype.getScrolledVisiblePosition = function (rawPosition) {
  95360. if (!this._modelData || !this._modelData.hasRealView) {
  95361. return null;
  95362. }
  95363. var position = this._modelData.model.validatePosition(rawPosition);
  95364. var options = this._configuration.options;
  95365. var layoutInfo = options.get(107 /* layoutInfo */);
  95366. var top = CodeEditorWidget._getVerticalOffsetForPosition(this._modelData, position.lineNumber, position.column) - this.getScrollTop();
  95367. var left = this._modelData.view.getOffsetForColumn(position.lineNumber, position.column) + layoutInfo.glyphMarginWidth + layoutInfo.lineNumbersWidth + layoutInfo.decorationsWidth - this.getScrollLeft();
  95368. return {
  95369. top: top,
  95370. left: left,
  95371. height: options.get(49 /* lineHeight */)
  95372. };
  95373. };
  95374. CodeEditorWidget.prototype.getOffsetForColumn = function (lineNumber, column) {
  95375. if (!this._modelData || !this._modelData.hasRealView) {
  95376. return -1;
  95377. }
  95378. return this._modelData.view.getOffsetForColumn(lineNumber, column);
  95379. };
  95380. CodeEditorWidget.prototype.render = function (forceRedraw) {
  95381. if (forceRedraw === void 0) { forceRedraw = false; }
  95382. if (!this._modelData || !this._modelData.hasRealView) {
  95383. return;
  95384. }
  95385. this._modelData.view.render(true, forceRedraw);
  95386. };
  95387. CodeEditorWidget.prototype.setAriaOptions = function (options) {
  95388. if (!this._modelData || !this._modelData.hasRealView) {
  95389. return;
  95390. }
  95391. this._modelData.view.setAriaOptions(options);
  95392. };
  95393. CodeEditorWidget.prototype.applyFontInfo = function (target) {
  95394. configuration_1.Configuration.applyFontInfoSlow(target, this._configuration.options.get(34 /* fontInfo */));
  95395. };
  95396. CodeEditorWidget.prototype._attachModel = function (model) {
  95397. var _this = this;
  95398. if (!model) {
  95399. this._modelData = null;
  95400. return;
  95401. }
  95402. var listenersToRemove = [];
  95403. this._domElement.setAttribute('data-mode-id', model.getLanguageIdentifier().language);
  95404. this._configuration.setIsDominatedByLongLines(model.isDominatedByLongLines());
  95405. this._configuration.setMaxLineNumber(model.getLineCount());
  95406. model.onBeforeAttached();
  95407. var viewModel = new viewModelImpl_1.ViewModel(this._id, this._configuration, model, domLineBreaksComputer_1.DOMLineBreaksComputerFactory.create(), monospaceLineBreaksComputer_1.MonospaceLineBreaksComputerFactory.create(this._configuration.options), function (callback) { return dom.scheduleAtNextAnimationFrame(callback); });
  95408. listenersToRemove.push(model.onDidChangeDecorations(function (e) { return _this._onDidChangeModelDecorations.fire(e); }));
  95409. listenersToRemove.push(model.onDidChangeLanguage(function (e) {
  95410. _this._domElement.setAttribute('data-mode-id', model.getLanguageIdentifier().language);
  95411. _this._onDidChangeModelLanguage.fire(e);
  95412. }));
  95413. listenersToRemove.push(model.onDidChangeLanguageConfiguration(function (e) { return _this._onDidChangeModelLanguageConfiguration.fire(e); }));
  95414. listenersToRemove.push(model.onDidChangeContent(function (e) { return _this._onDidChangeModelContent.fire(e); }));
  95415. listenersToRemove.push(model.onDidChangeOptions(function (e) { return _this._onDidChangeModelOptions.fire(e); }));
  95416. // Someone might destroy the model from under the editor, so prevent any exceptions by setting a null model
  95417. listenersToRemove.push(model.onWillDispose(function () { return _this.setModel(null); }));
  95418. var cursor = new cursor_1.Cursor(this._configuration, model, viewModel);
  95419. listenersToRemove.push(cursor.onDidReachMaxCursorCount(function () {
  95420. _this._notificationService.warn(nls.localize(0, null, cursor_1.Cursor.MAX_CURSOR_COUNT));
  95421. }));
  95422. listenersToRemove.push(cursor.onDidAttemptReadOnlyEdit(function () {
  95423. _this._onDidAttemptReadOnlyEdit.fire(undefined);
  95424. }));
  95425. listenersToRemove.push(cursor.onDidChange(function (e) {
  95426. var positions = [];
  95427. for (var i = 0, len = e.selections.length; i < len; i++) {
  95428. positions[i] = e.selections[i].getPosition();
  95429. }
  95430. var e1 = {
  95431. position: positions[0],
  95432. secondaryPositions: positions.slice(1),
  95433. reason: e.reason,
  95434. source: e.source
  95435. };
  95436. _this._onDidChangeCursorPosition.fire(e1);
  95437. var e2 = {
  95438. selection: e.selections[0],
  95439. secondarySelections: e.selections.slice(1),
  95440. modelVersionId: e.modelVersionId,
  95441. oldSelections: e.oldSelections,
  95442. oldModelVersionId: e.oldModelVersionId,
  95443. source: e.source,
  95444. reason: e.reason
  95445. };
  95446. _this._onDidChangeCursorSelection.fire(e2);
  95447. }));
  95448. var _a = this._createView(viewModel, cursor), view = _a[0], hasRealView = _a[1];
  95449. if (hasRealView) {
  95450. this._domElement.appendChild(view.domNode.domNode);
  95451. var keys = Object.keys(this._contentWidgets);
  95452. for (var i = 0, len = keys.length; i < len; i++) {
  95453. var widgetId = keys[i];
  95454. view.addContentWidget(this._contentWidgets[widgetId]);
  95455. }
  95456. keys = Object.keys(this._overlayWidgets);
  95457. for (var i = 0, len = keys.length; i < len; i++) {
  95458. var widgetId = keys[i];
  95459. view.addOverlayWidget(this._overlayWidgets[widgetId]);
  95460. }
  95461. view.render(false, true);
  95462. view.domNode.domNode.setAttribute('data-uri', model.uri.toString());
  95463. }
  95464. this._modelData = new ModelData(model, viewModel, cursor, view, hasRealView, listenersToRemove);
  95465. };
  95466. CodeEditorWidget.prototype._createView = function (viewModel, cursor) {
  95467. var _this = this;
  95468. var commandDelegate;
  95469. if (this.isSimpleWidget) {
  95470. commandDelegate = {
  95471. executeEditorCommand: function (editorCommand, args) {
  95472. editorCommand.runCoreEditorCommand(cursor, args);
  95473. },
  95474. paste: function (source, text, pasteOnNewLine, multicursorText, mode) {
  95475. _this.trigger(source, editorCommon.Handler.Paste, { text: text, pasteOnNewLine: pasteOnNewLine, multicursorText: multicursorText, mode: mode });
  95476. },
  95477. type: function (source, text) {
  95478. _this.trigger(source, editorCommon.Handler.Type, { text: text });
  95479. },
  95480. replacePreviousChar: function (source, text, replaceCharCnt) {
  95481. _this.trigger(source, editorCommon.Handler.ReplacePreviousChar, { text: text, replaceCharCnt: replaceCharCnt });
  95482. },
  95483. compositionStart: function (source) {
  95484. _this.trigger(source, editorCommon.Handler.CompositionStart, undefined);
  95485. },
  95486. compositionEnd: function (source) {
  95487. _this.trigger(source, editorCommon.Handler.CompositionEnd, undefined);
  95488. },
  95489. cut: function (source) {
  95490. _this.trigger(source, editorCommon.Handler.Cut, undefined);
  95491. }
  95492. };
  95493. }
  95494. else {
  95495. commandDelegate = {
  95496. executeEditorCommand: function (editorCommand, args) {
  95497. editorCommand.runCoreEditorCommand(cursor, args);
  95498. },
  95499. paste: function (source, text, pasteOnNewLine, multicursorText, mode) {
  95500. _this._commandService.executeCommand(editorCommon.Handler.Paste, {
  95501. text: text,
  95502. pasteOnNewLine: pasteOnNewLine,
  95503. multicursorText: multicursorText,
  95504. mode: mode
  95505. });
  95506. },
  95507. type: function (source, text) {
  95508. _this._commandService.executeCommand(editorCommon.Handler.Type, {
  95509. text: text
  95510. });
  95511. },
  95512. replacePreviousChar: function (source, text, replaceCharCnt) {
  95513. _this._commandService.executeCommand(editorCommon.Handler.ReplacePreviousChar, {
  95514. text: text,
  95515. replaceCharCnt: replaceCharCnt
  95516. });
  95517. },
  95518. compositionStart: function (source) {
  95519. _this._commandService.executeCommand(editorCommon.Handler.CompositionStart, {});
  95520. },
  95521. compositionEnd: function (source) {
  95522. _this._commandService.executeCommand(editorCommon.Handler.CompositionEnd, {});
  95523. },
  95524. cut: function (source) {
  95525. _this._commandService.executeCommand(editorCommon.Handler.Cut, {});
  95526. }
  95527. };
  95528. }
  95529. var viewOutgoingEvents = new viewOutgoingEvents_1.ViewOutgoingEvents(viewModel);
  95530. viewOutgoingEvents.onDidContentSizeChange = function (e) { return _this._onDidContentSizeChange.fire(e); };
  95531. viewOutgoingEvents.onDidScroll = function (e) { return _this._onDidScrollChange.fire(e); };
  95532. viewOutgoingEvents.onDidGainFocus = function () { return _this._editorTextFocus.setValue(true); };
  95533. viewOutgoingEvents.onDidLoseFocus = function () { return _this._editorTextFocus.setValue(false); };
  95534. viewOutgoingEvents.onContextMenu = function (e) { return _this._onContextMenu.fire(e); };
  95535. viewOutgoingEvents.onMouseDown = function (e) { return _this._onMouseDown.fire(e); };
  95536. viewOutgoingEvents.onMouseUp = function (e) { return _this._onMouseUp.fire(e); };
  95537. viewOutgoingEvents.onMouseDrag = function (e) { return _this._onMouseDrag.fire(e); };
  95538. viewOutgoingEvents.onMouseDrop = function (e) { return _this._onMouseDrop.fire(e); };
  95539. viewOutgoingEvents.onKeyUp = function (e) { return _this._onKeyUp.fire(e); };
  95540. viewOutgoingEvents.onMouseMove = function (e) { return _this._onMouseMove.fire(e); };
  95541. viewOutgoingEvents.onMouseLeave = function (e) { return _this._onMouseLeave.fire(e); };
  95542. viewOutgoingEvents.onMouseWheel = function (e) { return _this._onMouseWheel.fire(e); };
  95543. viewOutgoingEvents.onKeyDown = function (e) { return _this._onKeyDown.fire(e); };
  95544. var view = new viewImpl_1.View(commandDelegate, this._configuration, this._themeService, viewModel, cursor, viewOutgoingEvents);
  95545. return [view, true];
  95546. };
  95547. CodeEditorWidget.prototype._postDetachModelCleanup = function (detachedModel) {
  95548. if (detachedModel) {
  95549. detachedModel.removeAllDecorationsWithOwnerId(this._id);
  95550. }
  95551. };
  95552. CodeEditorWidget.prototype._detachModel = function () {
  95553. if (!this._modelData) {
  95554. return null;
  95555. }
  95556. var model = this._modelData.model;
  95557. var removeDomNode = this._modelData.hasRealView ? this._modelData.view.domNode.domNode : null;
  95558. this._modelData.dispose();
  95559. this._modelData = null;
  95560. this._domElement.removeAttribute('data-mode-id');
  95561. if (removeDomNode) {
  95562. this._domElement.removeChild(removeDomNode);
  95563. }
  95564. return model;
  95565. };
  95566. CodeEditorWidget.prototype._removeDecorationType = function (key) {
  95567. this._codeEditorService.removeDecorationType(key);
  95568. };
  95569. CodeEditorWidget.prototype.hasModel = function () {
  95570. return (this._modelData !== null);
  95571. };
  95572. CodeEditorWidget = __decorate([
  95573. __param(3, instantiation_1.IInstantiationService),
  95574. __param(4, codeEditorService_1.ICodeEditorService),
  95575. __param(5, commands_1.ICommandService),
  95576. __param(6, contextkey_1.IContextKeyService),
  95577. __param(7, themeService_1.IThemeService),
  95578. __param(8, notification_1.INotificationService),
  95579. __param(9, accessibility_1.IAccessibilityService)
  95580. ], CodeEditorWidget);
  95581. return CodeEditorWidget;
  95582. }(lifecycle_1.Disposable));
  95583. exports.CodeEditorWidget = CodeEditorWidget;
  95584. var BooleanEventEmitter = /** @class */ (function (_super) {
  95585. __extends(BooleanEventEmitter, _super);
  95586. function BooleanEventEmitter() {
  95587. var _this = _super.call(this) || this;
  95588. _this._onDidChangeToTrue = _this._register(new event_1.Emitter());
  95589. _this.onDidChangeToTrue = _this._onDidChangeToTrue.event;
  95590. _this._onDidChangeToFalse = _this._register(new event_1.Emitter());
  95591. _this.onDidChangeToFalse = _this._onDidChangeToFalse.event;
  95592. _this._value = 0 /* NotSet */;
  95593. return _this;
  95594. }
  95595. BooleanEventEmitter.prototype.setValue = function (_value) {
  95596. var value = (_value ? 2 /* True */ : 1 /* False */);
  95597. if (this._value === value) {
  95598. return;
  95599. }
  95600. this._value = value;
  95601. if (this._value === 2 /* True */) {
  95602. this._onDidChangeToTrue.fire();
  95603. }
  95604. else if (this._value === 1 /* False */) {
  95605. this._onDidChangeToFalse.fire();
  95606. }
  95607. };
  95608. return BooleanEventEmitter;
  95609. }(lifecycle_1.Disposable));
  95610. exports.BooleanEventEmitter = BooleanEventEmitter;
  95611. var EditorContextKeysManager = /** @class */ (function (_super) {
  95612. __extends(EditorContextKeysManager, _super);
  95613. function EditorContextKeysManager(editor, contextKeyService) {
  95614. var _this = _super.call(this) || this;
  95615. _this._editor = editor;
  95616. contextKeyService.createKey('editorId', editor.getId());
  95617. _this._editorSimpleInput = editorContextKeys_1.EditorContextKeys.editorSimpleInput.bindTo(contextKeyService);
  95618. _this._editorFocus = editorContextKeys_1.EditorContextKeys.focus.bindTo(contextKeyService);
  95619. _this._textInputFocus = editorContextKeys_1.EditorContextKeys.textInputFocus.bindTo(contextKeyService);
  95620. _this._editorTextFocus = editorContextKeys_1.EditorContextKeys.editorTextFocus.bindTo(contextKeyService);
  95621. _this._editorTabMovesFocus = editorContextKeys_1.EditorContextKeys.tabMovesFocus.bindTo(contextKeyService);
  95622. _this._editorReadonly = editorContextKeys_1.EditorContextKeys.readOnly.bindTo(contextKeyService);
  95623. _this._hasMultipleSelections = editorContextKeys_1.EditorContextKeys.hasMultipleSelections.bindTo(contextKeyService);
  95624. _this._hasNonEmptySelection = editorContextKeys_1.EditorContextKeys.hasNonEmptySelection.bindTo(contextKeyService);
  95625. _this._canUndo = editorContextKeys_1.EditorContextKeys.canUndo.bindTo(contextKeyService);
  95626. _this._canRedo = editorContextKeys_1.EditorContextKeys.canRedo.bindTo(contextKeyService);
  95627. _this._register(_this._editor.onDidChangeConfiguration(function () { return _this._updateFromConfig(); }));
  95628. _this._register(_this._editor.onDidChangeCursorSelection(function () { return _this._updateFromSelection(); }));
  95629. _this._register(_this._editor.onDidFocusEditorWidget(function () { return _this._updateFromFocus(); }));
  95630. _this._register(_this._editor.onDidBlurEditorWidget(function () { return _this._updateFromFocus(); }));
  95631. _this._register(_this._editor.onDidFocusEditorText(function () { return _this._updateFromFocus(); }));
  95632. _this._register(_this._editor.onDidBlurEditorText(function () { return _this._updateFromFocus(); }));
  95633. _this._register(_this._editor.onDidChangeModel(function () { return _this._updateFromModel(); }));
  95634. _this._register(_this._editor.onDidChangeConfiguration(function () { return _this._updateFromModel(); }));
  95635. _this._updateFromConfig();
  95636. _this._updateFromSelection();
  95637. _this._updateFromFocus();
  95638. _this._updateFromModel();
  95639. _this._editorSimpleInput.set(_this._editor.isSimpleWidget);
  95640. return _this;
  95641. }
  95642. EditorContextKeysManager.prototype._updateFromConfig = function () {
  95643. var options = this._editor.getOptions();
  95644. this._editorTabMovesFocus.set(options.get(106 /* tabFocusMode */));
  95645. this._editorReadonly.set(options.get(68 /* readOnly */));
  95646. };
  95647. EditorContextKeysManager.prototype._updateFromSelection = function () {
  95648. var selections = this._editor.getSelections();
  95649. if (!selections) {
  95650. this._hasMultipleSelections.reset();
  95651. this._hasNonEmptySelection.reset();
  95652. }
  95653. else {
  95654. this._hasMultipleSelections.set(selections.length > 1);
  95655. this._hasNonEmptySelection.set(selections.some(function (s) { return !s.isEmpty(); }));
  95656. }
  95657. };
  95658. EditorContextKeysManager.prototype._updateFromFocus = function () {
  95659. this._editorFocus.set(this._editor.hasWidgetFocus() && !this._editor.isSimpleWidget);
  95660. this._editorTextFocus.set(this._editor.hasTextFocus() && !this._editor.isSimpleWidget);
  95661. this._textInputFocus.set(this._editor.hasTextFocus());
  95662. };
  95663. EditorContextKeysManager.prototype._updateFromModel = function () {
  95664. var model = this._editor.getModel();
  95665. this._canUndo.set(Boolean(model && model.canUndo()));
  95666. this._canRedo.set(Boolean(model && model.canRedo()));
  95667. };
  95668. return EditorContextKeysManager;
  95669. }(lifecycle_1.Disposable));
  95670. var EditorModeContext = /** @class */ (function (_super) {
  95671. __extends(EditorModeContext, _super);
  95672. function EditorModeContext(_editor, _contextKeyService) {
  95673. var _this = _super.call(this) || this;
  95674. _this._editor = _editor;
  95675. _this._contextKeyService = _contextKeyService;
  95676. _this._langId = editorContextKeys_1.EditorContextKeys.languageId.bindTo(_contextKeyService);
  95677. _this._hasCompletionItemProvider = editorContextKeys_1.EditorContextKeys.hasCompletionItemProvider.bindTo(_contextKeyService);
  95678. _this._hasCodeActionsProvider = editorContextKeys_1.EditorContextKeys.hasCodeActionsProvider.bindTo(_contextKeyService);
  95679. _this._hasCodeLensProvider = editorContextKeys_1.EditorContextKeys.hasCodeLensProvider.bindTo(_contextKeyService);
  95680. _this._hasDefinitionProvider = editorContextKeys_1.EditorContextKeys.hasDefinitionProvider.bindTo(_contextKeyService);
  95681. _this._hasDeclarationProvider = editorContextKeys_1.EditorContextKeys.hasDeclarationProvider.bindTo(_contextKeyService);
  95682. _this._hasImplementationProvider = editorContextKeys_1.EditorContextKeys.hasImplementationProvider.bindTo(_contextKeyService);
  95683. _this._hasTypeDefinitionProvider = editorContextKeys_1.EditorContextKeys.hasTypeDefinitionProvider.bindTo(_contextKeyService);
  95684. _this._hasHoverProvider = editorContextKeys_1.EditorContextKeys.hasHoverProvider.bindTo(_contextKeyService);
  95685. _this._hasDocumentHighlightProvider = editorContextKeys_1.EditorContextKeys.hasDocumentHighlightProvider.bindTo(_contextKeyService);
  95686. _this._hasDocumentSymbolProvider = editorContextKeys_1.EditorContextKeys.hasDocumentSymbolProvider.bindTo(_contextKeyService);
  95687. _this._hasReferenceProvider = editorContextKeys_1.EditorContextKeys.hasReferenceProvider.bindTo(_contextKeyService);
  95688. _this._hasRenameProvider = editorContextKeys_1.EditorContextKeys.hasRenameProvider.bindTo(_contextKeyService);
  95689. _this._hasSignatureHelpProvider = editorContextKeys_1.EditorContextKeys.hasSignatureHelpProvider.bindTo(_contextKeyService);
  95690. _this._hasDocumentFormattingProvider = editorContextKeys_1.EditorContextKeys.hasDocumentFormattingProvider.bindTo(_contextKeyService);
  95691. _this._hasDocumentSelectionFormattingProvider = editorContextKeys_1.EditorContextKeys.hasDocumentSelectionFormattingProvider.bindTo(_contextKeyService);
  95692. _this._hasMultipleDocumentFormattingProvider = editorContextKeys_1.EditorContextKeys.hasMultipleDocumentFormattingProvider.bindTo(_contextKeyService);
  95693. _this._hasMultipleDocumentSelectionFormattingProvider = editorContextKeys_1.EditorContextKeys.hasMultipleDocumentSelectionFormattingProvider.bindTo(_contextKeyService);
  95694. _this._isInWalkThrough = editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.bindTo(_contextKeyService);
  95695. var update = function () { return _this._update(); };
  95696. // update when model/mode changes
  95697. _this._register(_editor.onDidChangeModel(update));
  95698. _this._register(_editor.onDidChangeModelLanguage(update));
  95699. // update when registries change
  95700. _this._register(modes.CompletionProviderRegistry.onDidChange(update));
  95701. _this._register(modes.CodeActionProviderRegistry.onDidChange(update));
  95702. _this._register(modes.CodeLensProviderRegistry.onDidChange(update));
  95703. _this._register(modes.DefinitionProviderRegistry.onDidChange(update));
  95704. _this._register(modes.DeclarationProviderRegistry.onDidChange(update));
  95705. _this._register(modes.ImplementationProviderRegistry.onDidChange(update));
  95706. _this._register(modes.TypeDefinitionProviderRegistry.onDidChange(update));
  95707. _this._register(modes.HoverProviderRegistry.onDidChange(update));
  95708. _this._register(modes.DocumentHighlightProviderRegistry.onDidChange(update));
  95709. _this._register(modes.DocumentSymbolProviderRegistry.onDidChange(update));
  95710. _this._register(modes.ReferenceProviderRegistry.onDidChange(update));
  95711. _this._register(modes.RenameProviderRegistry.onDidChange(update));
  95712. _this._register(modes.DocumentFormattingEditProviderRegistry.onDidChange(update));
  95713. _this._register(modes.DocumentRangeFormattingEditProviderRegistry.onDidChange(update));
  95714. _this._register(modes.SignatureHelpProviderRegistry.onDidChange(update));
  95715. update();
  95716. return _this;
  95717. }
  95718. EditorModeContext.prototype.dispose = function () {
  95719. _super.prototype.dispose.call(this);
  95720. };
  95721. EditorModeContext.prototype.reset = function () {
  95722. var _this = this;
  95723. this._contextKeyService.bufferChangeEvents(function () {
  95724. _this._langId.reset();
  95725. _this._hasCompletionItemProvider.reset();
  95726. _this._hasCodeActionsProvider.reset();
  95727. _this._hasCodeLensProvider.reset();
  95728. _this._hasDefinitionProvider.reset();
  95729. _this._hasDeclarationProvider.reset();
  95730. _this._hasImplementationProvider.reset();
  95731. _this._hasTypeDefinitionProvider.reset();
  95732. _this._hasHoverProvider.reset();
  95733. _this._hasDocumentHighlightProvider.reset();
  95734. _this._hasDocumentSymbolProvider.reset();
  95735. _this._hasReferenceProvider.reset();
  95736. _this._hasRenameProvider.reset();
  95737. _this._hasDocumentFormattingProvider.reset();
  95738. _this._hasDocumentSelectionFormattingProvider.reset();
  95739. _this._hasSignatureHelpProvider.reset();
  95740. _this._isInWalkThrough.reset();
  95741. });
  95742. };
  95743. EditorModeContext.prototype._update = function () {
  95744. var _this = this;
  95745. var model = this._editor.getModel();
  95746. if (!model) {
  95747. this.reset();
  95748. return;
  95749. }
  95750. this._contextKeyService.bufferChangeEvents(function () {
  95751. _this._langId.set(model.getLanguageIdentifier().language);
  95752. _this._hasCompletionItemProvider.set(modes.CompletionProviderRegistry.has(model));
  95753. _this._hasCodeActionsProvider.set(modes.CodeActionProviderRegistry.has(model));
  95754. _this._hasCodeLensProvider.set(modes.CodeLensProviderRegistry.has(model));
  95755. _this._hasDefinitionProvider.set(modes.DefinitionProviderRegistry.has(model));
  95756. _this._hasDeclarationProvider.set(modes.DeclarationProviderRegistry.has(model));
  95757. _this._hasImplementationProvider.set(modes.ImplementationProviderRegistry.has(model));
  95758. _this._hasTypeDefinitionProvider.set(modes.TypeDefinitionProviderRegistry.has(model));
  95759. _this._hasHoverProvider.set(modes.HoverProviderRegistry.has(model));
  95760. _this._hasDocumentHighlightProvider.set(modes.DocumentHighlightProviderRegistry.has(model));
  95761. _this._hasDocumentSymbolProvider.set(modes.DocumentSymbolProviderRegistry.has(model));
  95762. _this._hasReferenceProvider.set(modes.ReferenceProviderRegistry.has(model));
  95763. _this._hasRenameProvider.set(modes.RenameProviderRegistry.has(model));
  95764. _this._hasSignatureHelpProvider.set(modes.SignatureHelpProviderRegistry.has(model));
  95765. _this._hasDocumentFormattingProvider.set(modes.DocumentFormattingEditProviderRegistry.has(model) || modes.DocumentRangeFormattingEditProviderRegistry.has(model));
  95766. _this._hasDocumentSelectionFormattingProvider.set(modes.DocumentRangeFormattingEditProviderRegistry.has(model));
  95767. _this._hasMultipleDocumentFormattingProvider.set(modes.DocumentFormattingEditProviderRegistry.all(model).length + modes.DocumentRangeFormattingEditProviderRegistry.all(model).length > 1);
  95768. _this._hasMultipleDocumentSelectionFormattingProvider.set(modes.DocumentRangeFormattingEditProviderRegistry.all(model).length > 1);
  95769. _this._isInWalkThrough.set(model.uri.scheme === network_1.Schemas.walkThroughSnippet);
  95770. });
  95771. };
  95772. return EditorModeContext;
  95773. }(lifecycle_1.Disposable));
  95774. exports.EditorModeContext = EditorModeContext;
  95775. var CodeEditorWidgetFocusTracker = /** @class */ (function (_super) {
  95776. __extends(CodeEditorWidgetFocusTracker, _super);
  95777. function CodeEditorWidgetFocusTracker(domElement) {
  95778. var _this = _super.call(this) || this;
  95779. _this._onChange = _this._register(new event_1.Emitter());
  95780. _this.onChange = _this._onChange.event;
  95781. _this._hasFocus = false;
  95782. _this._domFocusTracker = _this._register(dom.trackFocus(domElement));
  95783. _this._register(_this._domFocusTracker.onDidFocus(function () {
  95784. _this._hasFocus = true;
  95785. _this._onChange.fire(undefined);
  95786. }));
  95787. _this._register(_this._domFocusTracker.onDidBlur(function () {
  95788. _this._hasFocus = false;
  95789. _this._onChange.fire(undefined);
  95790. }));
  95791. return _this;
  95792. }
  95793. CodeEditorWidgetFocusTracker.prototype.hasFocus = function () {
  95794. return this._hasFocus;
  95795. };
  95796. return CodeEditorWidgetFocusTracker;
  95797. }(lifecycle_1.Disposable));
  95798. var squigglyStart = encodeURIComponent("<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 6 3' enable-background='new 0 0 6 3' height='3' width='6'><g fill='");
  95799. var squigglyEnd = encodeURIComponent("'><polygon points='5.5,0 2.5,3 1.1,3 4.1,0'/><polygon points='4,0 6,2 6,0.6 5.4,0'/><polygon points='0,2 1,3 2.4,3 0,0.6'/></g></svg>");
  95800. function getSquigglySVGData(color) {
  95801. return squigglyStart + encodeURIComponent(color.toString()) + squigglyEnd;
  95802. }
  95803. var dotdotdotStart = encodeURIComponent("<svg xmlns=\"http://www.w3.org/2000/svg\" height=\"3\" width=\"12\"><g fill=\"");
  95804. var dotdotdotEnd = encodeURIComponent("\"><circle cx=\"1\" cy=\"1\" r=\"1\"/><circle cx=\"5\" cy=\"1\" r=\"1\"/><circle cx=\"9\" cy=\"1\" r=\"1\"/></g></svg>");
  95805. function getDotDotDotSVGData(color) {
  95806. return dotdotdotStart + encodeURIComponent(color.toString()) + dotdotdotEnd;
  95807. }
  95808. themeService_1.registerThemingParticipant(function (theme, collector) {
  95809. var errorBorderColor = theme.getColor(colorRegistry_1.editorErrorBorder);
  95810. if (errorBorderColor) {
  95811. collector.addRule(".monaco-editor ." + "squiggly-error" /* EditorErrorDecoration */ + " { border-bottom: 4px double " + errorBorderColor + "; }");
  95812. }
  95813. var errorForeground = theme.getColor(colorRegistry_1.editorErrorForeground);
  95814. if (errorForeground) {
  95815. collector.addRule(".monaco-editor ." + "squiggly-error" /* EditorErrorDecoration */ + " { background: url(\"data:image/svg+xml," + getSquigglySVGData(errorForeground) + "\") repeat-x bottom left; }");
  95816. }
  95817. var warningBorderColor = theme.getColor(colorRegistry_1.editorWarningBorder);
  95818. if (warningBorderColor) {
  95819. collector.addRule(".monaco-editor ." + "squiggly-warning" /* EditorWarningDecoration */ + " { border-bottom: 4px double " + warningBorderColor + "; }");
  95820. }
  95821. var warningForeground = theme.getColor(colorRegistry_1.editorWarningForeground);
  95822. if (warningForeground) {
  95823. collector.addRule(".monaco-editor ." + "squiggly-warning" /* EditorWarningDecoration */ + " { background: url(\"data:image/svg+xml," + getSquigglySVGData(warningForeground) + "\") repeat-x bottom left; }");
  95824. }
  95825. var infoBorderColor = theme.getColor(colorRegistry_1.editorInfoBorder);
  95826. if (infoBorderColor) {
  95827. collector.addRule(".monaco-editor ." + "squiggly-info" /* EditorInfoDecoration */ + " { border-bottom: 4px double " + infoBorderColor + "; }");
  95828. }
  95829. var infoForeground = theme.getColor(colorRegistry_1.editorInfoForeground);
  95830. if (infoForeground) {
  95831. collector.addRule(".monaco-editor ." + "squiggly-info" /* EditorInfoDecoration */ + " { background: url(\"data:image/svg+xml," + getSquigglySVGData(infoForeground) + "\") repeat-x bottom left; }");
  95832. }
  95833. var hintBorderColor = theme.getColor(colorRegistry_1.editorHintBorder);
  95834. if (hintBorderColor) {
  95835. collector.addRule(".monaco-editor ." + "squiggly-hint" /* EditorHintDecoration */ + " { border-bottom: 2px dotted " + hintBorderColor + "; }");
  95836. }
  95837. var hintForeground = theme.getColor(colorRegistry_1.editorHintForeground);
  95838. if (hintForeground) {
  95839. collector.addRule(".monaco-editor ." + "squiggly-hint" /* EditorHintDecoration */ + " { background: url(\"data:image/svg+xml," + getDotDotDotSVGData(hintForeground) + "\") no-repeat bottom left; }");
  95840. }
  95841. var unnecessaryForeground = theme.getColor(editorColorRegistry_1.editorUnnecessaryCodeOpacity);
  95842. if (unnecessaryForeground) {
  95843. collector.addRule(".monaco-editor.showUnused ." + "squiggly-inline-unnecessary" /* EditorUnnecessaryInlineDecoration */ + " { opacity: " + unnecessaryForeground.rgba.a + "; }");
  95844. }
  95845. var unnecessaryBorder = theme.getColor(editorColorRegistry_1.editorUnnecessaryCodeBorder);
  95846. if (unnecessaryBorder) {
  95847. collector.addRule(".monaco-editor.showUnused ." + "squiggly-unnecessary" /* EditorUnnecessaryDecoration */ + " { border-bottom: 2px dashed " + unnecessaryBorder + "; }");
  95848. }
  95849. var deprecatedForeground = theme.getColor(colorRegistry_1.editorForeground) || 'inherit';
  95850. collector.addRule(".monaco-editor ." + "squiggly-inline-deprecated" /* EditorDeprecatedInlineDecoration */ + " { text-decoration: line-through; text-decoration-color: " + deprecatedForeground + "}");
  95851. });
  95852. });
  95853. /*---------------------------------------------------------------------------------------------
  95854. * Copyright (c) Microsoft Corporation. All rights reserved.
  95855. * Licensed under the MIT License. See License.txt in the project root for license information.
  95856. *--------------------------------------------------------------------------------------------*/
  95857. define(__m[564/*vs/editor/browser/widget/diffReview*/], __M([0/*require*/,1/*exports*/,419/*vs/nls!vs/editor/browser/widget/diffReview*/,6/*vs/base/browser/dom*/,28/*vs/base/browser/fastDomNode*/,70/*vs/base/browser/ui/actionbar/actionbar*/,53/*vs/base/browser/ui/scrollbar/scrollableElement*/,55/*vs/base/common/actions*/,2/*vs/base/common/lifecycle*/,60/*vs/editor/browser/config/configuration*/,12/*vs/editor/browser/editorExtensions*/,32/*vs/editor/browser/services/codeEditorService*/,33/*vs/editor/common/config/editorOptions*/,93/*vs/editor/common/core/lineTokens*/,13/*vs/editor/common/core/position*/,44/*vs/editor/common/view/editorColorRegistry*/,110/*vs/editor/common/viewLayout/viewLineRenderer*/,69/*vs/editor/common/viewModel/viewModel*/,18/*vs/platform/contextkey/common/contextkey*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,300/*vs/css!vs/editor/browser/widget/media/diffReview*/]), function (require, exports, nls, dom, fastDomNode_1, actionbar_1, scrollableElement_1, actions_1, lifecycle_1, configuration_1, editorExtensions_1, codeEditorService_1, editorOptions_1, lineTokens_1, position_1, editorColorRegistry_1, viewLineRenderer_1, viewModel_1, contextkey_1, colorRegistry_1, themeService_1) {
  95858. "use strict";
  95859. Object.defineProperty(exports, "__esModule", { value: true });
  95860. var DIFF_LINES_PADDING = 3;
  95861. var DiffEntry = /** @class */ (function () {
  95862. function DiffEntry(originalLineStart, originalLineEnd, modifiedLineStart, modifiedLineEnd) {
  95863. this.originalLineStart = originalLineStart;
  95864. this.originalLineEnd = originalLineEnd;
  95865. this.modifiedLineStart = modifiedLineStart;
  95866. this.modifiedLineEnd = modifiedLineEnd;
  95867. }
  95868. DiffEntry.prototype.getType = function () {
  95869. if (this.originalLineStart === 0) {
  95870. return 1 /* Insert */;
  95871. }
  95872. if (this.modifiedLineStart === 0) {
  95873. return 2 /* Delete */;
  95874. }
  95875. return 0 /* Equal */;
  95876. };
  95877. return DiffEntry;
  95878. }());
  95879. var Diff = /** @class */ (function () {
  95880. function Diff(entries) {
  95881. this.entries = entries;
  95882. }
  95883. return Diff;
  95884. }());
  95885. var DiffReview = /** @class */ (function (_super) {
  95886. __extends(DiffReview, _super);
  95887. function DiffReview(diffEditor) {
  95888. var _this = _super.call(this) || this;
  95889. _this._width = 0;
  95890. _this._diffEditor = diffEditor;
  95891. _this._isVisible = false;
  95892. _this.shadow = fastDomNode_1.createFastDomNode(document.createElement('div'));
  95893. _this.shadow.setClassName('diff-review-shadow');
  95894. _this.actionBarContainer = fastDomNode_1.createFastDomNode(document.createElement('div'));
  95895. _this.actionBarContainer.setClassName('diff-review-actions');
  95896. _this._actionBar = _this._register(new actionbar_1.ActionBar(_this.actionBarContainer.domNode));
  95897. _this._actionBar.push(new actions_1.Action('diffreview.close', nls.localize(0, null), 'close-diff-review', true, function () {
  95898. _this.hide();
  95899. return Promise.resolve(null);
  95900. }), { label: false, icon: true });
  95901. _this.domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  95902. _this.domNode.setClassName('diff-review monaco-editor-background');
  95903. _this._content = fastDomNode_1.createFastDomNode(document.createElement('div'));
  95904. _this._content.setClassName('diff-review-content');
  95905. _this.scrollbar = _this._register(new scrollableElement_1.DomScrollableElement(_this._content.domNode, {}));
  95906. _this.domNode.domNode.appendChild(_this.scrollbar.getDomNode());
  95907. _this._register(diffEditor.onDidUpdateDiff(function () {
  95908. if (!_this._isVisible) {
  95909. return;
  95910. }
  95911. _this._diffs = _this._compute();
  95912. _this._render();
  95913. }));
  95914. _this._register(diffEditor.getModifiedEditor().onDidChangeCursorPosition(function () {
  95915. if (!_this._isVisible) {
  95916. return;
  95917. }
  95918. _this._render();
  95919. }));
  95920. _this._register(diffEditor.getOriginalEditor().onDidFocusEditorWidget(function () {
  95921. if (_this._isVisible) {
  95922. _this.hide();
  95923. }
  95924. }));
  95925. _this._register(diffEditor.getModifiedEditor().onDidFocusEditorWidget(function () {
  95926. if (_this._isVisible) {
  95927. _this.hide();
  95928. }
  95929. }));
  95930. _this._register(dom.addStandardDisposableListener(_this.domNode.domNode, 'click', function (e) {
  95931. e.preventDefault();
  95932. var row = dom.findParentWithClass(e.target, 'diff-review-row');
  95933. if (row) {
  95934. _this._goToRow(row);
  95935. }
  95936. }));
  95937. _this._register(dom.addStandardDisposableListener(_this.domNode.domNode, 'keydown', function (e) {
  95938. if (e.equals(18 /* DownArrow */)
  95939. || e.equals(2048 /* CtrlCmd */ | 18 /* DownArrow */)
  95940. || e.equals(512 /* Alt */ | 18 /* DownArrow */)) {
  95941. e.preventDefault();
  95942. _this._goToRow(_this._getNextRow());
  95943. }
  95944. if (e.equals(16 /* UpArrow */)
  95945. || e.equals(2048 /* CtrlCmd */ | 16 /* UpArrow */)
  95946. || e.equals(512 /* Alt */ | 16 /* UpArrow */)) {
  95947. e.preventDefault();
  95948. _this._goToRow(_this._getPrevRow());
  95949. }
  95950. if (e.equals(9 /* Escape */)
  95951. || e.equals(2048 /* CtrlCmd */ | 9 /* Escape */)
  95952. || e.equals(512 /* Alt */ | 9 /* Escape */)
  95953. || e.equals(1024 /* Shift */ | 9 /* Escape */)) {
  95954. e.preventDefault();
  95955. _this.hide();
  95956. }
  95957. if (e.equals(10 /* Space */)
  95958. || e.equals(3 /* Enter */)) {
  95959. e.preventDefault();
  95960. _this.accept();
  95961. }
  95962. }));
  95963. _this._diffs = [];
  95964. _this._currentDiff = null;
  95965. return _this;
  95966. }
  95967. DiffReview.prototype.prev = function () {
  95968. var index = 0;
  95969. if (!this._isVisible) {
  95970. this._diffs = this._compute();
  95971. }
  95972. if (this._isVisible) {
  95973. var currentIndex = -1;
  95974. for (var i = 0, len = this._diffs.length; i < len; i++) {
  95975. if (this._diffs[i] === this._currentDiff) {
  95976. currentIndex = i;
  95977. break;
  95978. }
  95979. }
  95980. index = (this._diffs.length + currentIndex - 1);
  95981. }
  95982. else {
  95983. index = this._findDiffIndex(this._diffEditor.getPosition());
  95984. }
  95985. if (this._diffs.length === 0) {
  95986. // Nothing to do
  95987. return;
  95988. }
  95989. index = index % this._diffs.length;
  95990. this._diffEditor.setPosition(new position_1.Position(this._diffs[index].entries[0].modifiedLineStart, 1));
  95991. this._isVisible = true;
  95992. this._diffEditor.doLayout();
  95993. this._render();
  95994. this._goToRow(this._getNextRow());
  95995. };
  95996. DiffReview.prototype.next = function () {
  95997. var index = 0;
  95998. if (!this._isVisible) {
  95999. this._diffs = this._compute();
  96000. }
  96001. if (this._isVisible) {
  96002. var currentIndex = -1;
  96003. for (var i = 0, len = this._diffs.length; i < len; i++) {
  96004. if (this._diffs[i] === this._currentDiff) {
  96005. currentIndex = i;
  96006. break;
  96007. }
  96008. }
  96009. index = (currentIndex + 1);
  96010. }
  96011. else {
  96012. index = this._findDiffIndex(this._diffEditor.getPosition());
  96013. }
  96014. if (this._diffs.length === 0) {
  96015. // Nothing to do
  96016. return;
  96017. }
  96018. index = index % this._diffs.length;
  96019. this._diffEditor.setPosition(new position_1.Position(this._diffs[index].entries[0].modifiedLineStart, 1));
  96020. this._isVisible = true;
  96021. this._diffEditor.doLayout();
  96022. this._render();
  96023. this._goToRow(this._getNextRow());
  96024. };
  96025. DiffReview.prototype.accept = function () {
  96026. var jumpToLineNumber = -1;
  96027. var current = this._getCurrentFocusedRow();
  96028. if (current) {
  96029. var lineNumber = parseInt(current.getAttribute('data-line'), 10);
  96030. if (!isNaN(lineNumber)) {
  96031. jumpToLineNumber = lineNumber;
  96032. }
  96033. }
  96034. this.hide();
  96035. if (jumpToLineNumber !== -1) {
  96036. this._diffEditor.setPosition(new position_1.Position(jumpToLineNumber, 1));
  96037. this._diffEditor.revealPosition(new position_1.Position(jumpToLineNumber, 1), 1 /* Immediate */);
  96038. }
  96039. };
  96040. DiffReview.prototype.hide = function () {
  96041. this._isVisible = false;
  96042. this._diffEditor.focus();
  96043. this._diffEditor.doLayout();
  96044. this._render();
  96045. };
  96046. DiffReview.prototype._getPrevRow = function () {
  96047. var current = this._getCurrentFocusedRow();
  96048. if (!current) {
  96049. return this._getFirstRow();
  96050. }
  96051. if (current.previousElementSibling) {
  96052. return current.previousElementSibling;
  96053. }
  96054. return current;
  96055. };
  96056. DiffReview.prototype._getNextRow = function () {
  96057. var current = this._getCurrentFocusedRow();
  96058. if (!current) {
  96059. return this._getFirstRow();
  96060. }
  96061. if (current.nextElementSibling) {
  96062. return current.nextElementSibling;
  96063. }
  96064. return current;
  96065. };
  96066. DiffReview.prototype._getFirstRow = function () {
  96067. return this.domNode.domNode.querySelector('.diff-review-row');
  96068. };
  96069. DiffReview.prototype._getCurrentFocusedRow = function () {
  96070. var result = document.activeElement;
  96071. if (result && /diff-review-row/.test(result.className)) {
  96072. return result;
  96073. }
  96074. return null;
  96075. };
  96076. DiffReview.prototype._goToRow = function (row) {
  96077. var prev = this._getCurrentFocusedRow();
  96078. row.tabIndex = 0;
  96079. row.focus();
  96080. if (prev && prev !== row) {
  96081. prev.tabIndex = -1;
  96082. }
  96083. this.scrollbar.scanDomNode();
  96084. };
  96085. DiffReview.prototype.isVisible = function () {
  96086. return this._isVisible;
  96087. };
  96088. DiffReview.prototype.layout = function (top, width, height) {
  96089. this._width = width;
  96090. this.shadow.setTop(top - 6);
  96091. this.shadow.setWidth(width);
  96092. this.shadow.setHeight(this._isVisible ? 6 : 0);
  96093. this.domNode.setTop(top);
  96094. this.domNode.setWidth(width);
  96095. this.domNode.setHeight(height);
  96096. this._content.setHeight(height);
  96097. this._content.setWidth(width);
  96098. if (this._isVisible) {
  96099. this.actionBarContainer.setAttribute('aria-hidden', 'false');
  96100. this.actionBarContainer.setDisplay('block');
  96101. }
  96102. else {
  96103. this.actionBarContainer.setAttribute('aria-hidden', 'true');
  96104. this.actionBarContainer.setDisplay('none');
  96105. }
  96106. };
  96107. DiffReview.prototype._compute = function () {
  96108. var lineChanges = this._diffEditor.getLineChanges();
  96109. if (!lineChanges || lineChanges.length === 0) {
  96110. return [];
  96111. }
  96112. var originalModel = this._diffEditor.getOriginalEditor().getModel();
  96113. var modifiedModel = this._diffEditor.getModifiedEditor().getModel();
  96114. if (!originalModel || !modifiedModel) {
  96115. return [];
  96116. }
  96117. return DiffReview._mergeAdjacent(lineChanges, originalModel.getLineCount(), modifiedModel.getLineCount());
  96118. };
  96119. DiffReview._mergeAdjacent = function (lineChanges, originalLineCount, modifiedLineCount) {
  96120. if (!lineChanges || lineChanges.length === 0) {
  96121. return [];
  96122. }
  96123. var diffs = [], diffsLength = 0;
  96124. for (var i = 0, len = lineChanges.length; i < len; i++) {
  96125. var lineChange = lineChanges[i];
  96126. var originalStart = lineChange.originalStartLineNumber;
  96127. var originalEnd = lineChange.originalEndLineNumber;
  96128. var modifiedStart = lineChange.modifiedStartLineNumber;
  96129. var modifiedEnd = lineChange.modifiedEndLineNumber;
  96130. var r_1 = [], rLength_1 = 0;
  96131. // Emit before anchors
  96132. {
  96133. var originalEqualAbove = (originalEnd === 0 ? originalStart : originalStart - 1);
  96134. var modifiedEqualAbove = (modifiedEnd === 0 ? modifiedStart : modifiedStart - 1);
  96135. // Make sure we don't step into the previous diff
  96136. var minOriginal = 1;
  96137. var minModified = 1;
  96138. if (i > 0) {
  96139. var prevLineChange = lineChanges[i - 1];
  96140. if (prevLineChange.originalEndLineNumber === 0) {
  96141. minOriginal = prevLineChange.originalStartLineNumber + 1;
  96142. }
  96143. else {
  96144. minOriginal = prevLineChange.originalEndLineNumber + 1;
  96145. }
  96146. if (prevLineChange.modifiedEndLineNumber === 0) {
  96147. minModified = prevLineChange.modifiedStartLineNumber + 1;
  96148. }
  96149. else {
  96150. minModified = prevLineChange.modifiedEndLineNumber + 1;
  96151. }
  96152. }
  96153. var fromOriginal = originalEqualAbove - DIFF_LINES_PADDING + 1;
  96154. var fromModified = modifiedEqualAbove - DIFF_LINES_PADDING + 1;
  96155. if (fromOriginal < minOriginal) {
  96156. var delta = minOriginal - fromOriginal;
  96157. fromOriginal = fromOriginal + delta;
  96158. fromModified = fromModified + delta;
  96159. }
  96160. if (fromModified < minModified) {
  96161. var delta = minModified - fromModified;
  96162. fromOriginal = fromOriginal + delta;
  96163. fromModified = fromModified + delta;
  96164. }
  96165. r_1[rLength_1++] = new DiffEntry(fromOriginal, originalEqualAbove, fromModified, modifiedEqualAbove);
  96166. }
  96167. // Emit deleted lines
  96168. {
  96169. if (originalEnd !== 0) {
  96170. r_1[rLength_1++] = new DiffEntry(originalStart, originalEnd, 0, 0);
  96171. }
  96172. }
  96173. // Emit inserted lines
  96174. {
  96175. if (modifiedEnd !== 0) {
  96176. r_1[rLength_1++] = new DiffEntry(0, 0, modifiedStart, modifiedEnd);
  96177. }
  96178. }
  96179. // Emit after anchors
  96180. {
  96181. var originalEqualBelow = (originalEnd === 0 ? originalStart + 1 : originalEnd + 1);
  96182. var modifiedEqualBelow = (modifiedEnd === 0 ? modifiedStart + 1 : modifiedEnd + 1);
  96183. // Make sure we don't step into the next diff
  96184. var maxOriginal = originalLineCount;
  96185. var maxModified = modifiedLineCount;
  96186. if (i + 1 < len) {
  96187. var nextLineChange = lineChanges[i + 1];
  96188. if (nextLineChange.originalEndLineNumber === 0) {
  96189. maxOriginal = nextLineChange.originalStartLineNumber;
  96190. }
  96191. else {
  96192. maxOriginal = nextLineChange.originalStartLineNumber - 1;
  96193. }
  96194. if (nextLineChange.modifiedEndLineNumber === 0) {
  96195. maxModified = nextLineChange.modifiedStartLineNumber;
  96196. }
  96197. else {
  96198. maxModified = nextLineChange.modifiedStartLineNumber - 1;
  96199. }
  96200. }
  96201. var toOriginal = originalEqualBelow + DIFF_LINES_PADDING - 1;
  96202. var toModified = modifiedEqualBelow + DIFF_LINES_PADDING - 1;
  96203. if (toOriginal > maxOriginal) {
  96204. var delta = maxOriginal - toOriginal;
  96205. toOriginal = toOriginal + delta;
  96206. toModified = toModified + delta;
  96207. }
  96208. if (toModified > maxModified) {
  96209. var delta = maxModified - toModified;
  96210. toOriginal = toOriginal + delta;
  96211. toModified = toModified + delta;
  96212. }
  96213. r_1[rLength_1++] = new DiffEntry(originalEqualBelow, toOriginal, modifiedEqualBelow, toModified);
  96214. }
  96215. diffs[diffsLength++] = new Diff(r_1);
  96216. }
  96217. // Merge adjacent diffs
  96218. var curr = diffs[0].entries;
  96219. var r = [], rLength = 0;
  96220. for (var i = 1, len = diffs.length; i < len; i++) {
  96221. var thisDiff = diffs[i].entries;
  96222. var currLast = curr[curr.length - 1];
  96223. var thisFirst = thisDiff[0];
  96224. if (currLast.getType() === 0 /* Equal */
  96225. && thisFirst.getType() === 0 /* Equal */
  96226. && thisFirst.originalLineStart <= currLast.originalLineEnd) {
  96227. // We are dealing with equal lines that overlap
  96228. curr[curr.length - 1] = new DiffEntry(currLast.originalLineStart, thisFirst.originalLineEnd, currLast.modifiedLineStart, thisFirst.modifiedLineEnd);
  96229. curr = curr.concat(thisDiff.slice(1));
  96230. continue;
  96231. }
  96232. r[rLength++] = new Diff(curr);
  96233. curr = thisDiff;
  96234. }
  96235. r[rLength++] = new Diff(curr);
  96236. return r;
  96237. };
  96238. DiffReview.prototype._findDiffIndex = function (pos) {
  96239. var lineNumber = pos.lineNumber;
  96240. for (var i = 0, len = this._diffs.length; i < len; i++) {
  96241. var diff = this._diffs[i].entries;
  96242. var lastModifiedLine = diff[diff.length - 1].modifiedLineEnd;
  96243. if (lineNumber <= lastModifiedLine) {
  96244. return i;
  96245. }
  96246. }
  96247. return 0;
  96248. };
  96249. DiffReview.prototype._render = function () {
  96250. var originalOptions = this._diffEditor.getOriginalEditor().getOptions();
  96251. var modifiedOptions = this._diffEditor.getModifiedEditor().getOptions();
  96252. var originalModel = this._diffEditor.getOriginalEditor().getModel();
  96253. var modifiedModel = this._diffEditor.getModifiedEditor().getModel();
  96254. var originalModelOpts = originalModel.getOptions();
  96255. var modifiedModelOpts = modifiedModel.getOptions();
  96256. if (!this._isVisible || !originalModel || !modifiedModel) {
  96257. dom.clearNode(this._content.domNode);
  96258. this._currentDiff = null;
  96259. this.scrollbar.scanDomNode();
  96260. return;
  96261. }
  96262. var diffIndex = this._findDiffIndex(this._diffEditor.getPosition());
  96263. if (this._diffs[diffIndex] === this._currentDiff) {
  96264. return;
  96265. }
  96266. this._currentDiff = this._diffs[diffIndex];
  96267. var diffs = this._diffs[diffIndex].entries;
  96268. var container = document.createElement('div');
  96269. container.className = 'diff-review-table';
  96270. container.setAttribute('role', 'list');
  96271. configuration_1.Configuration.applyFontInfoSlow(container, modifiedOptions.get(34 /* fontInfo */));
  96272. var minOriginalLine = 0;
  96273. var maxOriginalLine = 0;
  96274. var minModifiedLine = 0;
  96275. var maxModifiedLine = 0;
  96276. for (var i = 0, len = diffs.length; i < len; i++) {
  96277. var diffEntry = diffs[i];
  96278. var originalLineStart = diffEntry.originalLineStart;
  96279. var originalLineEnd = diffEntry.originalLineEnd;
  96280. var modifiedLineStart = diffEntry.modifiedLineStart;
  96281. var modifiedLineEnd = diffEntry.modifiedLineEnd;
  96282. if (originalLineStart !== 0 && ((minOriginalLine === 0 || originalLineStart < minOriginalLine))) {
  96283. minOriginalLine = originalLineStart;
  96284. }
  96285. if (originalLineEnd !== 0 && ((maxOriginalLine === 0 || originalLineEnd > maxOriginalLine))) {
  96286. maxOriginalLine = originalLineEnd;
  96287. }
  96288. if (modifiedLineStart !== 0 && ((minModifiedLine === 0 || modifiedLineStart < minModifiedLine))) {
  96289. minModifiedLine = modifiedLineStart;
  96290. }
  96291. if (modifiedLineEnd !== 0 && ((maxModifiedLine === 0 || modifiedLineEnd > maxModifiedLine))) {
  96292. maxModifiedLine = modifiedLineEnd;
  96293. }
  96294. }
  96295. var header = document.createElement('div');
  96296. header.className = 'diff-review-row';
  96297. var cell = document.createElement('div');
  96298. cell.className = 'diff-review-cell diff-review-summary';
  96299. var originalChangedLinesCnt = maxOriginalLine - minOriginalLine + 1;
  96300. var modifiedChangedLinesCnt = maxModifiedLine - minModifiedLine + 1;
  96301. cell.appendChild(document.createTextNode(diffIndex + 1 + "/" + this._diffs.length + ": @@ -" + minOriginalLine + "," + originalChangedLinesCnt + " +" + minModifiedLine + "," + modifiedChangedLinesCnt + " @@"));
  96302. header.setAttribute('data-line', String(minModifiedLine));
  96303. var getAriaLines = function (lines) {
  96304. if (lines === 0) {
  96305. return nls.localize(1, null);
  96306. }
  96307. else if (lines === 1) {
  96308. return nls.localize(2, null);
  96309. }
  96310. else {
  96311. return nls.localize(3, null, lines);
  96312. }
  96313. };
  96314. var originalChangedLinesCntAria = getAriaLines(originalChangedLinesCnt);
  96315. var modifiedChangedLinesCntAria = getAriaLines(modifiedChangedLinesCnt);
  96316. header.setAttribute('aria-label', nls.localize(4, null, (diffIndex + 1), this._diffs.length, minOriginalLine, originalChangedLinesCntAria, minModifiedLine, modifiedChangedLinesCntAria));
  96317. header.appendChild(cell);
  96318. // @@ -504,7 +517,7 @@
  96319. header.setAttribute('role', 'listitem');
  96320. container.appendChild(header);
  96321. var modLine = minModifiedLine;
  96322. for (var i = 0, len = diffs.length; i < len; i++) {
  96323. var diffEntry = diffs[i];
  96324. DiffReview._renderSection(container, diffEntry, modLine, this._width, originalOptions, originalModel, originalModelOpts, modifiedOptions, modifiedModel, modifiedModelOpts);
  96325. if (diffEntry.modifiedLineStart !== 0) {
  96326. modLine = diffEntry.modifiedLineEnd;
  96327. }
  96328. }
  96329. dom.clearNode(this._content.domNode);
  96330. this._content.domNode.appendChild(container);
  96331. this.scrollbar.scanDomNode();
  96332. };
  96333. DiffReview._renderSection = function (dest, diffEntry, modLine, width, originalOptions, originalModel, originalModelOpts, modifiedOptions, modifiedModel, modifiedModelOpts) {
  96334. var type = diffEntry.getType();
  96335. var rowClassName = 'diff-review-row';
  96336. var lineNumbersExtraClassName = '';
  96337. var spacerClassName = 'diff-review-spacer';
  96338. switch (type) {
  96339. case 1 /* Insert */:
  96340. rowClassName = 'diff-review-row line-insert';
  96341. lineNumbersExtraClassName = ' char-insert';
  96342. spacerClassName = 'diff-review-spacer insert-sign';
  96343. break;
  96344. case 2 /* Delete */:
  96345. rowClassName = 'diff-review-row line-delete';
  96346. lineNumbersExtraClassName = ' char-delete';
  96347. spacerClassName = 'diff-review-spacer delete-sign';
  96348. break;
  96349. }
  96350. var originalLineStart = diffEntry.originalLineStart;
  96351. var originalLineEnd = diffEntry.originalLineEnd;
  96352. var modifiedLineStart = diffEntry.modifiedLineStart;
  96353. var modifiedLineEnd = diffEntry.modifiedLineEnd;
  96354. var cnt = Math.max(modifiedLineEnd - modifiedLineStart, originalLineEnd - originalLineStart);
  96355. var originalLayoutInfo = originalOptions.get(107 /* layoutInfo */);
  96356. var originalLineNumbersWidth = originalLayoutInfo.glyphMarginWidth + originalLayoutInfo.lineNumbersWidth;
  96357. var modifiedLayoutInfo = modifiedOptions.get(107 /* layoutInfo */);
  96358. var modifiedLineNumbersWidth = 10 + modifiedLayoutInfo.glyphMarginWidth + modifiedLayoutInfo.lineNumbersWidth;
  96359. for (var i = 0; i <= cnt; i++) {
  96360. var originalLine = (originalLineStart === 0 ? 0 : originalLineStart + i);
  96361. var modifiedLine = (modifiedLineStart === 0 ? 0 : modifiedLineStart + i);
  96362. var row = document.createElement('div');
  96363. row.style.minWidth = width + 'px';
  96364. row.className = rowClassName;
  96365. row.setAttribute('role', 'listitem');
  96366. if (modifiedLine !== 0) {
  96367. modLine = modifiedLine;
  96368. }
  96369. row.setAttribute('data-line', String(modLine));
  96370. var cell = document.createElement('div');
  96371. cell.className = 'diff-review-cell';
  96372. row.appendChild(cell);
  96373. var originalLineNumber = document.createElement('span');
  96374. originalLineNumber.style.width = (originalLineNumbersWidth + 'px');
  96375. originalLineNumber.style.minWidth = (originalLineNumbersWidth + 'px');
  96376. originalLineNumber.className = 'diff-review-line-number' + lineNumbersExtraClassName;
  96377. if (originalLine !== 0) {
  96378. originalLineNumber.appendChild(document.createTextNode(String(originalLine)));
  96379. }
  96380. else {
  96381. originalLineNumber.innerHTML = '&#160;';
  96382. }
  96383. cell.appendChild(originalLineNumber);
  96384. var modifiedLineNumber = document.createElement('span');
  96385. modifiedLineNumber.style.width = (modifiedLineNumbersWidth + 'px');
  96386. modifiedLineNumber.style.minWidth = (modifiedLineNumbersWidth + 'px');
  96387. modifiedLineNumber.style.paddingRight = '10px';
  96388. modifiedLineNumber.className = 'diff-review-line-number' + lineNumbersExtraClassName;
  96389. if (modifiedLine !== 0) {
  96390. modifiedLineNumber.appendChild(document.createTextNode(String(modifiedLine)));
  96391. }
  96392. else {
  96393. modifiedLineNumber.innerHTML = '&#160;';
  96394. }
  96395. cell.appendChild(modifiedLineNumber);
  96396. var spacer = document.createElement('span');
  96397. spacer.className = spacerClassName;
  96398. spacer.innerHTML = '&#160;&#160;';
  96399. cell.appendChild(spacer);
  96400. var lineContent = void 0;
  96401. if (modifiedLine !== 0) {
  96402. cell.insertAdjacentHTML('beforeend', this._renderLine(modifiedModel, modifiedOptions, modifiedModelOpts.tabSize, modifiedLine));
  96403. lineContent = modifiedModel.getLineContent(modifiedLine);
  96404. }
  96405. else {
  96406. cell.insertAdjacentHTML('beforeend', this._renderLine(originalModel, originalOptions, originalModelOpts.tabSize, originalLine));
  96407. lineContent = originalModel.getLineContent(originalLine);
  96408. }
  96409. if (lineContent.length === 0) {
  96410. lineContent = nls.localize(5, null);
  96411. }
  96412. var ariaLabel = '';
  96413. switch (type) {
  96414. case 0 /* Equal */:
  96415. ariaLabel = nls.localize(6, null, originalLine, modifiedLine, lineContent);
  96416. break;
  96417. case 1 /* Insert */:
  96418. ariaLabel = nls.localize(7, null, modifiedLine, lineContent);
  96419. break;
  96420. case 2 /* Delete */:
  96421. ariaLabel = nls.localize(8, null, originalLine, lineContent);
  96422. break;
  96423. }
  96424. row.setAttribute('aria-label', ariaLabel);
  96425. dest.appendChild(row);
  96426. }
  96427. };
  96428. DiffReview._renderLine = function (model, options, tabSize, lineNumber) {
  96429. var lineContent = model.getLineContent(lineNumber);
  96430. var fontInfo = options.get(34 /* fontInfo */);
  96431. var defaultMetadata = ((0 /* None */ << 11 /* FONT_STYLE_OFFSET */)
  96432. | (1 /* DefaultForeground */ << 14 /* FOREGROUND_OFFSET */)
  96433. | (2 /* DefaultBackground */ << 23 /* BACKGROUND_OFFSET */)) >>> 0;
  96434. var tokens = new Uint32Array(2);
  96435. tokens[0] = lineContent.length;
  96436. tokens[1] = defaultMetadata;
  96437. var lineTokens = new lineTokens_1.LineTokens(tokens, lineContent);
  96438. var isBasicASCII = viewModel_1.ViewLineRenderingData.isBasicASCII(lineContent, model.mightContainNonBasicASCII());
  96439. var containsRTL = viewModel_1.ViewLineRenderingData.containsRTL(lineContent, isBasicASCII, model.mightContainRTL());
  96440. var r = viewLineRenderer_1.renderViewLine2(new viewLineRenderer_1.RenderLineInput((fontInfo.isMonospace && !options.get(23 /* disableMonospaceOptimizations */)), fontInfo.canUseHalfwidthRightwardsArrow, lineContent, false, isBasicASCII, containsRTL, 0, lineTokens, [], tabSize, 0, fontInfo.spaceWidth, fontInfo.middotWidth, options.get(88 /* stopRenderingLineAfter */), options.get(74 /* renderWhitespace */), options.get(69 /* renderControlCharacters */), options.get(35 /* fontLigatures */) !== editorOptions_1.EditorFontLigatures.OFF, null));
  96441. return r.html;
  96442. };
  96443. return DiffReview;
  96444. }(lifecycle_1.Disposable));
  96445. exports.DiffReview = DiffReview;
  96446. // theming
  96447. themeService_1.registerThemingParticipant(function (theme, collector) {
  96448. var lineNumbers = theme.getColor(editorColorRegistry_1.editorLineNumbers);
  96449. if (lineNumbers) {
  96450. collector.addRule(".monaco-diff-editor .diff-review-line-number { color: " + lineNumbers + "; }");
  96451. }
  96452. var shadow = theme.getColor(colorRegistry_1.scrollbarShadow);
  96453. if (shadow) {
  96454. collector.addRule(".monaco-diff-editor .diff-review-shadow { box-shadow: " + shadow + " 0 -6px 6px -6px inset; }");
  96455. }
  96456. });
  96457. var DiffReviewNext = /** @class */ (function (_super) {
  96458. __extends(DiffReviewNext, _super);
  96459. function DiffReviewNext() {
  96460. return _super.call(this, {
  96461. id: 'editor.action.diffReview.next',
  96462. label: nls.localize(9, null),
  96463. alias: 'Go to Next Difference',
  96464. precondition: contextkey_1.ContextKeyExpr.has('isInDiffEditor'),
  96465. kbOpts: {
  96466. kbExpr: null,
  96467. primary: 65 /* F7 */,
  96468. weight: 100 /* EditorContrib */
  96469. }
  96470. }) || this;
  96471. }
  96472. DiffReviewNext.prototype.run = function (accessor, editor) {
  96473. var diffEditor = findFocusedDiffEditor(accessor);
  96474. if (diffEditor) {
  96475. diffEditor.diffReviewNext();
  96476. }
  96477. };
  96478. return DiffReviewNext;
  96479. }(editorExtensions_1.EditorAction));
  96480. var DiffReviewPrev = /** @class */ (function (_super) {
  96481. __extends(DiffReviewPrev, _super);
  96482. function DiffReviewPrev() {
  96483. return _super.call(this, {
  96484. id: 'editor.action.diffReview.prev',
  96485. label: nls.localize(10, null),
  96486. alias: 'Go to Previous Difference',
  96487. precondition: contextkey_1.ContextKeyExpr.has('isInDiffEditor'),
  96488. kbOpts: {
  96489. kbExpr: null,
  96490. primary: 1024 /* Shift */ | 65 /* F7 */,
  96491. weight: 100 /* EditorContrib */
  96492. }
  96493. }) || this;
  96494. }
  96495. DiffReviewPrev.prototype.run = function (accessor, editor) {
  96496. var diffEditor = findFocusedDiffEditor(accessor);
  96497. if (diffEditor) {
  96498. diffEditor.diffReviewPrev();
  96499. }
  96500. };
  96501. return DiffReviewPrev;
  96502. }(editorExtensions_1.EditorAction));
  96503. function findFocusedDiffEditor(accessor) {
  96504. var codeEditorService = accessor.get(codeEditorService_1.ICodeEditorService);
  96505. var diffEditors = codeEditorService.listDiffEditors();
  96506. for (var i = 0, len = diffEditors.length; i < len; i++) {
  96507. var diffEditor = diffEditors[i];
  96508. if (diffEditor.hasWidgetFocus()) {
  96509. return diffEditor;
  96510. }
  96511. }
  96512. return null;
  96513. }
  96514. editorExtensions_1.registerEditorAction(DiffReviewNext);
  96515. editorExtensions_1.registerEditorAction(DiffReviewPrev);
  96516. });
  96517. /*---------------------------------------------------------------------------------------------
  96518. * Copyright (c) Microsoft Corporation. All rights reserved.
  96519. * Licensed under the MIT License. See License.txt in the project root for license information.
  96520. *--------------------------------------------------------------------------------------------*/
  96521. define(__m[230/*vs/editor/browser/widget/diffEditorWidget*/], __M([0/*require*/,1/*exports*/,418/*vs/nls!vs/editor/browser/widget/diffEditorWidget*/,6/*vs/base/browser/dom*/,28/*vs/base/browser/fastDomNode*/,104/*vs/base/browser/ui/sash/sash*/,15/*vs/base/common/async*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,31/*vs/base/common/objects*/,60/*vs/editor/browser/config/configuration*/,67/*vs/editor/browser/core/editorState*/,32/*vs/editor/browser/services/codeEditorService*/,121/*vs/editor/browser/widget/codeEditorWidget*/,564/*vs/editor/browser/widget/diffReview*/,33/*vs/editor/common/config/editorOptions*/,3/*vs/editor/common/core/range*/,106/*vs/editor/common/core/stringBuilder*/,68/*vs/editor/common/editorCommon*/,30/*vs/editor/common/model/textModel*/,62/*vs/editor/common/services/editorWorkerService*/,193/*vs/editor/common/view/overviewZoneManager*/,148/*vs/editor/common/viewLayout/lineDecorations*/,110/*vs/editor/common/viewLayout/viewLineRenderer*/,69/*vs/editor/common/viewModel/viewModel*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,115/*vs/platform/instantiation/common/serviceCollection*/,35/*vs/platform/notification/common/notification*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,66/*vs/platform/contextview/browser/contextView*/,421/*vs/editor/browser/widget/inlineDiffMargin*/,12/*vs/editor/browser/editorExtensions*/,10/*vs/base/common/errors*/,73/*vs/platform/progress/common/progress*/,185/*vs/editor/browser/config/elementSizeObserver*/,299/*vs/css!vs/editor/browser/widget/media/diffEditor*/]), function (require, exports, nls, dom, fastDomNode_1, sash_1, async_1, event_1, lifecycle_1, objects, configuration_1, editorState_1, codeEditorService_1, codeEditorWidget_1, diffReview_1, editorOptions_1, range_1, stringBuilder_1, editorCommon, textModel_1, editorWorkerService_1, overviewZoneManager_1, lineDecorations_1, viewLineRenderer_1, viewModel_1, contextkey_1, instantiation_1, serviceCollection_1, notification_1, colorRegistry_1, themeService_1, contextView_1, inlineDiffMargin_1, editorExtensions_1, errors_1, progress_1, elementSizeObserver_1) {
  96522. "use strict";
  96523. Object.defineProperty(exports, "__esModule", { value: true });
  96524. var VisualEditorState = /** @class */ (function () {
  96525. function VisualEditorState(_contextMenuService, _clipboardService) {
  96526. this._contextMenuService = _contextMenuService;
  96527. this._clipboardService = _clipboardService;
  96528. this._zones = [];
  96529. this.inlineDiffMargins = [];
  96530. this._zonesMap = {};
  96531. this._decorations = [];
  96532. }
  96533. VisualEditorState.prototype.getForeignViewZones = function (allViewZones) {
  96534. var _this = this;
  96535. return allViewZones.filter(function (z) { return !_this._zonesMap[String(z.id)]; });
  96536. };
  96537. VisualEditorState.prototype.clean = function (editor) {
  96538. var _this = this;
  96539. // (1) View zones
  96540. if (this._zones.length > 0) {
  96541. editor.changeViewZones(function (viewChangeAccessor) {
  96542. for (var i = 0, length_1 = _this._zones.length; i < length_1; i++) {
  96543. viewChangeAccessor.removeZone(_this._zones[i]);
  96544. }
  96545. });
  96546. }
  96547. this._zones = [];
  96548. this._zonesMap = {};
  96549. // (2) Model decorations
  96550. this._decorations = editor.deltaDecorations(this._decorations, []);
  96551. };
  96552. VisualEditorState.prototype.apply = function (editor, overviewRuler, newDecorations, restoreScrollState) {
  96553. var _this = this;
  96554. var scrollState = restoreScrollState ? editorState_1.StableEditorScrollState.capture(editor) : null;
  96555. // view zones
  96556. editor.changeViewZones(function (viewChangeAccessor) {
  96557. for (var i = 0, length_2 = _this._zones.length; i < length_2; i++) {
  96558. viewChangeAccessor.removeZone(_this._zones[i]);
  96559. }
  96560. for (var i = 0, length_3 = _this.inlineDiffMargins.length; i < length_3; i++) {
  96561. _this.inlineDiffMargins[i].dispose();
  96562. }
  96563. _this._zones = [];
  96564. _this._zonesMap = {};
  96565. _this.inlineDiffMargins = [];
  96566. for (var i = 0, length_4 = newDecorations.zones.length; i < length_4; i++) {
  96567. var viewZone = newDecorations.zones[i];
  96568. viewZone.suppressMouseDown = true;
  96569. var zoneId = viewChangeAccessor.addZone(viewZone);
  96570. _this._zones.push(zoneId);
  96571. _this._zonesMap[String(zoneId)] = true;
  96572. if (newDecorations.zones[i].diff && viewZone.marginDomNode && _this._clipboardService) {
  96573. viewZone.suppressMouseDown = false;
  96574. _this.inlineDiffMargins.push(new inlineDiffMargin_1.InlineDiffMargin(zoneId, viewZone.marginDomNode, editor, newDecorations.zones[i].diff, _this._contextMenuService, _this._clipboardService));
  96575. }
  96576. }
  96577. });
  96578. if (scrollState) {
  96579. scrollState.restore(editor);
  96580. }
  96581. // decorations
  96582. this._decorations = editor.deltaDecorations(this._decorations, newDecorations.decorations);
  96583. // overview ruler
  96584. if (overviewRuler) {
  96585. overviewRuler.setZones(newDecorations.overviewZones);
  96586. }
  96587. };
  96588. return VisualEditorState;
  96589. }());
  96590. var DIFF_EDITOR_ID = 0;
  96591. var DiffEditorWidget = /** @class */ (function (_super) {
  96592. __extends(DiffEditorWidget, _super);
  96593. function DiffEditorWidget(domElement, options, clipboardService, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService, contextMenuService, _editorProgressService) {
  96594. var _this = _super.call(this) || this;
  96595. _this._editorProgressService = _editorProgressService;
  96596. _this._onDidDispose = _this._register(new event_1.Emitter());
  96597. _this.onDidDispose = _this._onDidDispose.event;
  96598. _this._onDidUpdateDiff = _this._register(new event_1.Emitter());
  96599. _this.onDidUpdateDiff = _this._onDidUpdateDiff.event;
  96600. _this._lastOriginalWarning = null;
  96601. _this._lastModifiedWarning = null;
  96602. _this._editorWorkerService = editorWorkerService;
  96603. _this._codeEditorService = codeEditorService;
  96604. _this._contextKeyService = _this._register(contextKeyService.createScoped(domElement));
  96605. _this._contextKeyService.createKey('isInDiffEditor', true);
  96606. _this._themeService = themeService;
  96607. _this._notificationService = notificationService;
  96608. _this.id = (++DIFF_EDITOR_ID);
  96609. _this._state = 0 /* Idle */;
  96610. _this._updatingDiffProgress = null;
  96611. _this._domElement = domElement;
  96612. options = options || {};
  96613. // renderSideBySide
  96614. _this._renderSideBySide = true;
  96615. if (typeof options.renderSideBySide !== 'undefined') {
  96616. _this._renderSideBySide = options.renderSideBySide;
  96617. }
  96618. // maxComputationTime
  96619. _this._maxComputationTime = 5000;
  96620. if (typeof options.maxComputationTime !== 'undefined') {
  96621. _this._maxComputationTime = options.maxComputationTime;
  96622. }
  96623. // ignoreTrimWhitespace
  96624. _this._ignoreTrimWhitespace = true;
  96625. if (typeof options.ignoreTrimWhitespace !== 'undefined') {
  96626. _this._ignoreTrimWhitespace = options.ignoreTrimWhitespace;
  96627. }
  96628. // renderIndicators
  96629. _this._renderIndicators = true;
  96630. if (typeof options.renderIndicators !== 'undefined') {
  96631. _this._renderIndicators = options.renderIndicators;
  96632. }
  96633. _this._originalIsEditable = false;
  96634. if (typeof options.originalEditable !== 'undefined') {
  96635. _this._originalIsEditable = Boolean(options.originalEditable);
  96636. }
  96637. _this._updateDecorationsRunner = _this._register(new async_1.RunOnceScheduler(function () { return _this._updateDecorations(); }, 0));
  96638. _this._containerDomElement = document.createElement('div');
  96639. _this._containerDomElement.className = DiffEditorWidget._getClassName(_this._themeService.getTheme(), _this._renderSideBySide);
  96640. _this._containerDomElement.style.position = 'relative';
  96641. _this._containerDomElement.style.height = '100%';
  96642. _this._domElement.appendChild(_this._containerDomElement);
  96643. _this._overviewViewportDomElement = fastDomNode_1.createFastDomNode(document.createElement('div'));
  96644. _this._overviewViewportDomElement.setClassName('diffViewport');
  96645. _this._overviewViewportDomElement.setPosition('absolute');
  96646. _this._overviewDomElement = document.createElement('div');
  96647. _this._overviewDomElement.className = 'diffOverview';
  96648. _this._overviewDomElement.style.position = 'absolute';
  96649. _this._overviewDomElement.appendChild(_this._overviewViewportDomElement.domNode);
  96650. _this._register(dom.addStandardDisposableListener(_this._overviewDomElement, 'mousedown', function (e) {
  96651. _this.modifiedEditor.delegateVerticalScrollbarMouseDown(e);
  96652. }));
  96653. _this._containerDomElement.appendChild(_this._overviewDomElement);
  96654. // Create left side
  96655. _this._originalDomNode = document.createElement('div');
  96656. _this._originalDomNode.className = 'editor original';
  96657. _this._originalDomNode.style.position = 'absolute';
  96658. _this._originalDomNode.style.height = '100%';
  96659. _this._containerDomElement.appendChild(_this._originalDomNode);
  96660. // Create right side
  96661. _this._modifiedDomNode = document.createElement('div');
  96662. _this._modifiedDomNode.className = 'editor modified';
  96663. _this._modifiedDomNode.style.position = 'absolute';
  96664. _this._modifiedDomNode.style.height = '100%';
  96665. _this._containerDomElement.appendChild(_this._modifiedDomNode);
  96666. _this._beginUpdateDecorationsTimeout = -1;
  96667. _this._currentlyChangingViewZones = false;
  96668. _this._diffComputationToken = 0;
  96669. _this._originalEditorState = new VisualEditorState(contextMenuService, clipboardService);
  96670. _this._modifiedEditorState = new VisualEditorState(contextMenuService, clipboardService);
  96671. _this._isVisible = true;
  96672. _this._isHandlingScrollEvent = false;
  96673. _this._elementSizeObserver = _this._register(new elementSizeObserver_1.ElementSizeObserver(_this._containerDomElement, undefined, function () { return _this._onDidContainerSizeChanged(); }));
  96674. if (options.automaticLayout) {
  96675. _this._elementSizeObserver.startObserving();
  96676. }
  96677. _this._diffComputationResult = null;
  96678. var leftContextKeyService = _this._contextKeyService.createScoped();
  96679. leftContextKeyService.createKey('isInDiffLeftEditor', true);
  96680. var leftServices = new serviceCollection_1.ServiceCollection();
  96681. leftServices.set(contextkey_1.IContextKeyService, leftContextKeyService);
  96682. var leftScopedInstantiationService = instantiationService.createChild(leftServices);
  96683. var rightContextKeyService = _this._contextKeyService.createScoped();
  96684. rightContextKeyService.createKey('isInDiffRightEditor', true);
  96685. var rightServices = new serviceCollection_1.ServiceCollection();
  96686. rightServices.set(contextkey_1.IContextKeyService, rightContextKeyService);
  96687. var rightScopedInstantiationService = instantiationService.createChild(rightServices);
  96688. _this.originalEditor = _this._createLeftHandSideEditor(options, leftScopedInstantiationService);
  96689. _this.modifiedEditor = _this._createRightHandSideEditor(options, rightScopedInstantiationService);
  96690. _this._originalOverviewRuler = null;
  96691. _this._modifiedOverviewRuler = null;
  96692. _this._reviewPane = new diffReview_1.DiffReview(_this);
  96693. _this._containerDomElement.appendChild(_this._reviewPane.domNode.domNode);
  96694. _this._containerDomElement.appendChild(_this._reviewPane.shadow.domNode);
  96695. _this._containerDomElement.appendChild(_this._reviewPane.actionBarContainer.domNode);
  96696. // enableSplitViewResizing
  96697. _this._enableSplitViewResizing = true;
  96698. if (typeof options.enableSplitViewResizing !== 'undefined') {
  96699. _this._enableSplitViewResizing = options.enableSplitViewResizing;
  96700. }
  96701. if (_this._renderSideBySide) {
  96702. _this._setStrategy(new DiffEditorWidgetSideBySide(_this._createDataSource(), _this._enableSplitViewResizing));
  96703. }
  96704. else {
  96705. _this._setStrategy(new DiffEditorWidgetInline(_this._createDataSource(), _this._enableSplitViewResizing));
  96706. }
  96707. _this._register(themeService.onThemeChange(function (t) {
  96708. if (_this._strategy && _this._strategy.applyColors(t)) {
  96709. _this._updateDecorationsRunner.schedule();
  96710. }
  96711. _this._containerDomElement.className = DiffEditorWidget._getClassName(_this._themeService.getTheme(), _this._renderSideBySide);
  96712. }));
  96713. var contributions = editorExtensions_1.EditorExtensionsRegistry.getDiffEditorContributions();
  96714. for (var _i = 0, contributions_1 = contributions; _i < contributions_1.length; _i++) {
  96715. var desc = contributions_1[_i];
  96716. try {
  96717. _this._register(instantiationService.createInstance(desc.ctor, _this));
  96718. }
  96719. catch (err) {
  96720. errors_1.onUnexpectedError(err);
  96721. }
  96722. }
  96723. _this._codeEditorService.addDiffEditor(_this);
  96724. return _this;
  96725. }
  96726. DiffEditorWidget.prototype._setState = function (newState) {
  96727. if (this._state === newState) {
  96728. return;
  96729. }
  96730. this._state = newState;
  96731. if (this._updatingDiffProgress) {
  96732. this._updatingDiffProgress.done();
  96733. this._updatingDiffProgress = null;
  96734. }
  96735. if (this._state === 1 /* ComputingDiff */) {
  96736. this._updatingDiffProgress = this._editorProgressService.show(true, 1000);
  96737. }
  96738. };
  96739. DiffEditorWidget.prototype.hasWidgetFocus = function () {
  96740. return dom.isAncestor(document.activeElement, this._domElement);
  96741. };
  96742. DiffEditorWidget.prototype.diffReviewNext = function () {
  96743. this._reviewPane.next();
  96744. };
  96745. DiffEditorWidget.prototype.diffReviewPrev = function () {
  96746. this._reviewPane.prev();
  96747. };
  96748. DiffEditorWidget._getClassName = function (theme, renderSideBySide) {
  96749. var result = 'monaco-diff-editor monaco-editor-background ';
  96750. if (renderSideBySide) {
  96751. result += 'side-by-side ';
  96752. }
  96753. result += themeService_1.getThemeTypeSelector(theme.type);
  96754. return result;
  96755. };
  96756. DiffEditorWidget.prototype._recreateOverviewRulers = function () {
  96757. if (this._originalOverviewRuler) {
  96758. this._overviewDomElement.removeChild(this._originalOverviewRuler.getDomNode());
  96759. this._originalOverviewRuler.dispose();
  96760. }
  96761. if (this.originalEditor.hasModel()) {
  96762. this._originalOverviewRuler = this.originalEditor.createOverviewRuler('original diffOverviewRuler');
  96763. this._overviewDomElement.appendChild(this._originalOverviewRuler.getDomNode());
  96764. }
  96765. if (this._modifiedOverviewRuler) {
  96766. this._overviewDomElement.removeChild(this._modifiedOverviewRuler.getDomNode());
  96767. this._modifiedOverviewRuler.dispose();
  96768. }
  96769. if (this.modifiedEditor.hasModel()) {
  96770. this._modifiedOverviewRuler = this.modifiedEditor.createOverviewRuler('modified diffOverviewRuler');
  96771. this._overviewDomElement.appendChild(this._modifiedOverviewRuler.getDomNode());
  96772. }
  96773. this._layoutOverviewRulers();
  96774. };
  96775. DiffEditorWidget.prototype._createLeftHandSideEditor = function (options, instantiationService) {
  96776. var _this = this;
  96777. var editor = this._createInnerEditor(instantiationService, this._originalDomNode, this._adjustOptionsForLeftHandSide(options, this._originalIsEditable));
  96778. this._register(editor.onDidScrollChange(function (e) {
  96779. if (_this._isHandlingScrollEvent) {
  96780. return;
  96781. }
  96782. if (!e.scrollTopChanged && !e.scrollLeftChanged && !e.scrollHeightChanged) {
  96783. return;
  96784. }
  96785. _this._isHandlingScrollEvent = true;
  96786. _this.modifiedEditor.setScrollPosition({
  96787. scrollLeft: e.scrollLeft,
  96788. scrollTop: e.scrollTop
  96789. });
  96790. _this._isHandlingScrollEvent = false;
  96791. _this._layoutOverviewViewport();
  96792. }));
  96793. this._register(editor.onDidChangeViewZones(function () {
  96794. _this._onViewZonesChanged();
  96795. }));
  96796. this._register(editor.onDidChangeModelContent(function () {
  96797. if (_this._isVisible) {
  96798. _this._beginUpdateDecorationsSoon();
  96799. }
  96800. }));
  96801. return editor;
  96802. };
  96803. DiffEditorWidget.prototype._createRightHandSideEditor = function (options, instantiationService) {
  96804. var _this = this;
  96805. var editor = this._createInnerEditor(instantiationService, this._modifiedDomNode, this._adjustOptionsForRightHandSide(options));
  96806. this._register(editor.onDidScrollChange(function (e) {
  96807. if (_this._isHandlingScrollEvent) {
  96808. return;
  96809. }
  96810. if (!e.scrollTopChanged && !e.scrollLeftChanged && !e.scrollHeightChanged) {
  96811. return;
  96812. }
  96813. _this._isHandlingScrollEvent = true;
  96814. _this.originalEditor.setScrollPosition({
  96815. scrollLeft: e.scrollLeft,
  96816. scrollTop: e.scrollTop
  96817. });
  96818. _this._isHandlingScrollEvent = false;
  96819. _this._layoutOverviewViewport();
  96820. }));
  96821. this._register(editor.onDidChangeViewZones(function () {
  96822. _this._onViewZonesChanged();
  96823. }));
  96824. this._register(editor.onDidChangeConfiguration(function (e) {
  96825. if (e.hasChanged(34 /* fontInfo */) && editor.getModel()) {
  96826. _this._onViewZonesChanged();
  96827. }
  96828. }));
  96829. this._register(editor.onDidChangeModelContent(function () {
  96830. if (_this._isVisible) {
  96831. _this._beginUpdateDecorationsSoon();
  96832. }
  96833. }));
  96834. this._register(editor.onDidChangeModelOptions(function (e) {
  96835. if (e.tabSize) {
  96836. _this._updateDecorationsRunner.schedule();
  96837. }
  96838. }));
  96839. return editor;
  96840. };
  96841. DiffEditorWidget.prototype._createInnerEditor = function (instantiationService, container, options) {
  96842. return instantiationService.createInstance(codeEditorWidget_1.CodeEditorWidget, container, options, {});
  96843. };
  96844. DiffEditorWidget.prototype.dispose = function () {
  96845. this._codeEditorService.removeDiffEditor(this);
  96846. if (this._beginUpdateDecorationsTimeout !== -1) {
  96847. window.clearTimeout(this._beginUpdateDecorationsTimeout);
  96848. this._beginUpdateDecorationsTimeout = -1;
  96849. }
  96850. this._cleanViewZonesAndDecorations();
  96851. if (this._originalOverviewRuler) {
  96852. this._overviewDomElement.removeChild(this._originalOverviewRuler.getDomNode());
  96853. this._originalOverviewRuler.dispose();
  96854. }
  96855. if (this._modifiedOverviewRuler) {
  96856. this._overviewDomElement.removeChild(this._modifiedOverviewRuler.getDomNode());
  96857. this._modifiedOverviewRuler.dispose();
  96858. }
  96859. this._overviewDomElement.removeChild(this._overviewViewportDomElement.domNode);
  96860. this._containerDomElement.removeChild(this._overviewDomElement);
  96861. this._containerDomElement.removeChild(this._originalDomNode);
  96862. this.originalEditor.dispose();
  96863. this._containerDomElement.removeChild(this._modifiedDomNode);
  96864. this.modifiedEditor.dispose();
  96865. this._strategy.dispose();
  96866. this._containerDomElement.removeChild(this._reviewPane.domNode.domNode);
  96867. this._containerDomElement.removeChild(this._reviewPane.shadow.domNode);
  96868. this._containerDomElement.removeChild(this._reviewPane.actionBarContainer.domNode);
  96869. this._reviewPane.dispose();
  96870. this._domElement.removeChild(this._containerDomElement);
  96871. this._onDidDispose.fire();
  96872. _super.prototype.dispose.call(this);
  96873. };
  96874. //------------ begin IDiffEditor methods
  96875. DiffEditorWidget.prototype.getId = function () {
  96876. return this.getEditorType() + ':' + this.id;
  96877. };
  96878. DiffEditorWidget.prototype.getEditorType = function () {
  96879. return editorCommon.EditorType.IDiffEditor;
  96880. };
  96881. DiffEditorWidget.prototype.getLineChanges = function () {
  96882. if (!this._diffComputationResult) {
  96883. return null;
  96884. }
  96885. return this._diffComputationResult.changes;
  96886. };
  96887. DiffEditorWidget.prototype.getOriginalEditor = function () {
  96888. return this.originalEditor;
  96889. };
  96890. DiffEditorWidget.prototype.getModifiedEditor = function () {
  96891. return this.modifiedEditor;
  96892. };
  96893. DiffEditorWidget.prototype.updateOptions = function (newOptions) {
  96894. // Handle side by side
  96895. var renderSideBySideChanged = false;
  96896. if (typeof newOptions.renderSideBySide !== 'undefined') {
  96897. if (this._renderSideBySide !== newOptions.renderSideBySide) {
  96898. this._renderSideBySide = newOptions.renderSideBySide;
  96899. renderSideBySideChanged = true;
  96900. }
  96901. }
  96902. if (typeof newOptions.maxComputationTime !== 'undefined') {
  96903. this._maxComputationTime = newOptions.maxComputationTime;
  96904. if (this._isVisible) {
  96905. this._beginUpdateDecorationsSoon();
  96906. }
  96907. }
  96908. var beginUpdateDecorations = false;
  96909. if (typeof newOptions.ignoreTrimWhitespace !== 'undefined') {
  96910. if (this._ignoreTrimWhitespace !== newOptions.ignoreTrimWhitespace) {
  96911. this._ignoreTrimWhitespace = newOptions.ignoreTrimWhitespace;
  96912. // Begin comparing
  96913. beginUpdateDecorations = true;
  96914. }
  96915. }
  96916. if (typeof newOptions.renderIndicators !== 'undefined') {
  96917. if (this._renderIndicators !== newOptions.renderIndicators) {
  96918. this._renderIndicators = newOptions.renderIndicators;
  96919. beginUpdateDecorations = true;
  96920. }
  96921. }
  96922. if (beginUpdateDecorations) {
  96923. this._beginUpdateDecorations();
  96924. }
  96925. if (typeof newOptions.originalEditable !== 'undefined') {
  96926. this._originalIsEditable = Boolean(newOptions.originalEditable);
  96927. }
  96928. this.modifiedEditor.updateOptions(this._adjustOptionsForRightHandSide(newOptions));
  96929. this.originalEditor.updateOptions(this._adjustOptionsForLeftHandSide(newOptions, this._originalIsEditable));
  96930. // enableSplitViewResizing
  96931. if (typeof newOptions.enableSplitViewResizing !== 'undefined') {
  96932. this._enableSplitViewResizing = newOptions.enableSplitViewResizing;
  96933. }
  96934. this._strategy.setEnableSplitViewResizing(this._enableSplitViewResizing);
  96935. // renderSideBySide
  96936. if (renderSideBySideChanged) {
  96937. if (this._renderSideBySide) {
  96938. this._setStrategy(new DiffEditorWidgetSideBySide(this._createDataSource(), this._enableSplitViewResizing));
  96939. }
  96940. else {
  96941. this._setStrategy(new DiffEditorWidgetInline(this._createDataSource(), this._enableSplitViewResizing));
  96942. }
  96943. // Update class name
  96944. this._containerDomElement.className = DiffEditorWidget._getClassName(this._themeService.getTheme(), this._renderSideBySide);
  96945. }
  96946. };
  96947. DiffEditorWidget.prototype.getModel = function () {
  96948. return {
  96949. original: this.originalEditor.getModel(),
  96950. modified: this.modifiedEditor.getModel()
  96951. };
  96952. };
  96953. DiffEditorWidget.prototype.setModel = function (model) {
  96954. // Guard us against partial null model
  96955. if (model && (!model.original || !model.modified)) {
  96956. throw new Error(!model.original ? 'DiffEditorWidget.setModel: Original model is null' : 'DiffEditorWidget.setModel: Modified model is null');
  96957. }
  96958. // Remove all view zones & decorations
  96959. this._cleanViewZonesAndDecorations();
  96960. // Update code editor models
  96961. this.originalEditor.setModel(model ? model.original : null);
  96962. this.modifiedEditor.setModel(model ? model.modified : null);
  96963. this._updateDecorationsRunner.cancel();
  96964. // this.originalEditor.onDidChangeModelOptions
  96965. if (model) {
  96966. this.originalEditor.setScrollTop(0);
  96967. this.modifiedEditor.setScrollTop(0);
  96968. }
  96969. // Disable any diff computations that will come in
  96970. this._diffComputationResult = null;
  96971. this._diffComputationToken++;
  96972. this._setState(0 /* Idle */);
  96973. if (model) {
  96974. this._recreateOverviewRulers();
  96975. // Begin comparing
  96976. this._beginUpdateDecorations();
  96977. }
  96978. this._layoutOverviewViewport();
  96979. };
  96980. DiffEditorWidget.prototype.getDomNode = function () {
  96981. return this._domElement;
  96982. };
  96983. DiffEditorWidget.prototype.getVisibleColumnFromPosition = function (position) {
  96984. return this.modifiedEditor.getVisibleColumnFromPosition(position);
  96985. };
  96986. DiffEditorWidget.prototype.getPosition = function () {
  96987. return this.modifiedEditor.getPosition();
  96988. };
  96989. DiffEditorWidget.prototype.setPosition = function (position) {
  96990. this.modifiedEditor.setPosition(position);
  96991. };
  96992. DiffEditorWidget.prototype.revealLine = function (lineNumber, scrollType) {
  96993. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  96994. this.modifiedEditor.revealLine(lineNumber, scrollType);
  96995. };
  96996. DiffEditorWidget.prototype.revealLineInCenter = function (lineNumber, scrollType) {
  96997. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  96998. this.modifiedEditor.revealLineInCenter(lineNumber, scrollType);
  96999. };
  97000. DiffEditorWidget.prototype.revealLineInCenterIfOutsideViewport = function (lineNumber, scrollType) {
  97001. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97002. this.modifiedEditor.revealLineInCenterIfOutsideViewport(lineNumber, scrollType);
  97003. };
  97004. DiffEditorWidget.prototype.revealPosition = function (position, scrollType) {
  97005. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97006. this.modifiedEditor.revealPosition(position, scrollType);
  97007. };
  97008. DiffEditorWidget.prototype.revealPositionInCenter = function (position, scrollType) {
  97009. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97010. this.modifiedEditor.revealPositionInCenter(position, scrollType);
  97011. };
  97012. DiffEditorWidget.prototype.revealPositionInCenterIfOutsideViewport = function (position, scrollType) {
  97013. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97014. this.modifiedEditor.revealPositionInCenterIfOutsideViewport(position, scrollType);
  97015. };
  97016. DiffEditorWidget.prototype.getSelection = function () {
  97017. return this.modifiedEditor.getSelection();
  97018. };
  97019. DiffEditorWidget.prototype.getSelections = function () {
  97020. return this.modifiedEditor.getSelections();
  97021. };
  97022. DiffEditorWidget.prototype.setSelection = function (something) {
  97023. this.modifiedEditor.setSelection(something);
  97024. };
  97025. DiffEditorWidget.prototype.setSelections = function (ranges) {
  97026. this.modifiedEditor.setSelections(ranges);
  97027. };
  97028. DiffEditorWidget.prototype.revealLines = function (startLineNumber, endLineNumber, scrollType) {
  97029. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97030. this.modifiedEditor.revealLines(startLineNumber, endLineNumber, scrollType);
  97031. };
  97032. DiffEditorWidget.prototype.revealLinesInCenter = function (startLineNumber, endLineNumber, scrollType) {
  97033. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97034. this.modifiedEditor.revealLinesInCenter(startLineNumber, endLineNumber, scrollType);
  97035. };
  97036. DiffEditorWidget.prototype.revealLinesInCenterIfOutsideViewport = function (startLineNumber, endLineNumber, scrollType) {
  97037. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97038. this.modifiedEditor.revealLinesInCenterIfOutsideViewport(startLineNumber, endLineNumber, scrollType);
  97039. };
  97040. DiffEditorWidget.prototype.revealRange = function (range, scrollType, revealVerticalInCenter, revealHorizontal) {
  97041. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97042. if (revealVerticalInCenter === void 0) { revealVerticalInCenter = false; }
  97043. if (revealHorizontal === void 0) { revealHorizontal = true; }
  97044. this.modifiedEditor.revealRange(range, scrollType, revealVerticalInCenter, revealHorizontal);
  97045. };
  97046. DiffEditorWidget.prototype.revealRangeInCenter = function (range, scrollType) {
  97047. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97048. this.modifiedEditor.revealRangeInCenter(range, scrollType);
  97049. };
  97050. DiffEditorWidget.prototype.revealRangeInCenterIfOutsideViewport = function (range, scrollType) {
  97051. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97052. this.modifiedEditor.revealRangeInCenterIfOutsideViewport(range, scrollType);
  97053. };
  97054. DiffEditorWidget.prototype.revealRangeAtTop = function (range, scrollType) {
  97055. if (scrollType === void 0) { scrollType = 0 /* Smooth */; }
  97056. this.modifiedEditor.revealRangeAtTop(range, scrollType);
  97057. };
  97058. DiffEditorWidget.prototype.getSupportedActions = function () {
  97059. return this.modifiedEditor.getSupportedActions();
  97060. };
  97061. DiffEditorWidget.prototype.saveViewState = function () {
  97062. var originalViewState = this.originalEditor.saveViewState();
  97063. var modifiedViewState = this.modifiedEditor.saveViewState();
  97064. return {
  97065. original: originalViewState,
  97066. modified: modifiedViewState
  97067. };
  97068. };
  97069. DiffEditorWidget.prototype.restoreViewState = function (s) {
  97070. if (s.original && s.modified) {
  97071. var diffEditorState = s;
  97072. this.originalEditor.restoreViewState(diffEditorState.original);
  97073. this.modifiedEditor.restoreViewState(diffEditorState.modified);
  97074. }
  97075. };
  97076. DiffEditorWidget.prototype.layout = function (dimension) {
  97077. this._elementSizeObserver.observe(dimension);
  97078. };
  97079. DiffEditorWidget.prototype.focus = function () {
  97080. this.modifiedEditor.focus();
  97081. };
  97082. DiffEditorWidget.prototype.hasTextFocus = function () {
  97083. return this.originalEditor.hasTextFocus() || this.modifiedEditor.hasTextFocus();
  97084. };
  97085. DiffEditorWidget.prototype.trigger = function (source, handlerId, payload) {
  97086. this.modifiedEditor.trigger(source, handlerId, payload);
  97087. };
  97088. DiffEditorWidget.prototype.changeDecorations = function (callback) {
  97089. return this.modifiedEditor.changeDecorations(callback);
  97090. };
  97091. //------------ end IDiffEditor methods
  97092. //------------ begin layouting methods
  97093. DiffEditorWidget.prototype._onDidContainerSizeChanged = function () {
  97094. this._doLayout();
  97095. };
  97096. DiffEditorWidget.prototype._getReviewHeight = function () {
  97097. return this._reviewPane.isVisible() ? this._elementSizeObserver.getHeight() : 0;
  97098. };
  97099. DiffEditorWidget.prototype._layoutOverviewRulers = function () {
  97100. if (!this._originalOverviewRuler || !this._modifiedOverviewRuler) {
  97101. return;
  97102. }
  97103. var height = this._elementSizeObserver.getHeight();
  97104. var reviewHeight = this._getReviewHeight();
  97105. var freeSpace = DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH - 2 * DiffEditorWidget.ONE_OVERVIEW_WIDTH;
  97106. var layoutInfo = this.modifiedEditor.getLayoutInfo();
  97107. if (layoutInfo) {
  97108. this._originalOverviewRuler.setLayout({
  97109. top: 0,
  97110. width: DiffEditorWidget.ONE_OVERVIEW_WIDTH,
  97111. right: freeSpace + DiffEditorWidget.ONE_OVERVIEW_WIDTH,
  97112. height: (height - reviewHeight)
  97113. });
  97114. this._modifiedOverviewRuler.setLayout({
  97115. top: 0,
  97116. right: 0,
  97117. width: DiffEditorWidget.ONE_OVERVIEW_WIDTH,
  97118. height: (height - reviewHeight)
  97119. });
  97120. }
  97121. };
  97122. //------------ end layouting methods
  97123. DiffEditorWidget.prototype._onViewZonesChanged = function () {
  97124. if (this._currentlyChangingViewZones) {
  97125. return;
  97126. }
  97127. this._updateDecorationsRunner.schedule();
  97128. };
  97129. DiffEditorWidget.prototype._beginUpdateDecorationsSoon = function () {
  97130. var _this = this;
  97131. // Clear previous timeout if necessary
  97132. if (this._beginUpdateDecorationsTimeout !== -1) {
  97133. window.clearTimeout(this._beginUpdateDecorationsTimeout);
  97134. this._beginUpdateDecorationsTimeout = -1;
  97135. }
  97136. this._beginUpdateDecorationsTimeout = window.setTimeout(function () { return _this._beginUpdateDecorations(); }, DiffEditorWidget.UPDATE_DIFF_DECORATIONS_DELAY);
  97137. };
  97138. DiffEditorWidget._equals = function (a, b) {
  97139. if (!a && !b) {
  97140. return true;
  97141. }
  97142. if (!a || !b) {
  97143. return false;
  97144. }
  97145. return (a.toString() === b.toString());
  97146. };
  97147. DiffEditorWidget.prototype._beginUpdateDecorations = function () {
  97148. var _this = this;
  97149. this._beginUpdateDecorationsTimeout = -1;
  97150. var currentOriginalModel = this.originalEditor.getModel();
  97151. var currentModifiedModel = this.modifiedEditor.getModel();
  97152. if (!currentOriginalModel || !currentModifiedModel) {
  97153. return;
  97154. }
  97155. // Prevent old diff requests to come if a new request has been initiated
  97156. // The best method would be to call cancel on the Promise, but this is not
  97157. // yet supported, so using tokens for now.
  97158. this._diffComputationToken++;
  97159. var currentToken = this._diffComputationToken;
  97160. this._setState(1 /* ComputingDiff */);
  97161. if (!this._editorWorkerService.canComputeDiff(currentOriginalModel.uri, currentModifiedModel.uri)) {
  97162. if (!DiffEditorWidget._equals(currentOriginalModel.uri, this._lastOriginalWarning)
  97163. || !DiffEditorWidget._equals(currentModifiedModel.uri, this._lastModifiedWarning)) {
  97164. this._lastOriginalWarning = currentOriginalModel.uri;
  97165. this._lastModifiedWarning = currentModifiedModel.uri;
  97166. this._notificationService.warn(nls.localize(0, null));
  97167. }
  97168. return;
  97169. }
  97170. this._editorWorkerService.computeDiff(currentOriginalModel.uri, currentModifiedModel.uri, this._ignoreTrimWhitespace, this._maxComputationTime).then(function (result) {
  97171. if (currentToken === _this._diffComputationToken
  97172. && currentOriginalModel === _this.originalEditor.getModel()
  97173. && currentModifiedModel === _this.modifiedEditor.getModel()) {
  97174. _this._setState(2 /* DiffComputed */);
  97175. _this._diffComputationResult = result;
  97176. _this._updateDecorationsRunner.schedule();
  97177. _this._onDidUpdateDiff.fire();
  97178. }
  97179. }, function (error) {
  97180. if (currentToken === _this._diffComputationToken
  97181. && currentOriginalModel === _this.originalEditor.getModel()
  97182. && currentModifiedModel === _this.modifiedEditor.getModel()) {
  97183. _this._setState(2 /* DiffComputed */);
  97184. _this._diffComputationResult = null;
  97185. _this._updateDecorationsRunner.schedule();
  97186. }
  97187. });
  97188. };
  97189. DiffEditorWidget.prototype._cleanViewZonesAndDecorations = function () {
  97190. this._originalEditorState.clean(this.originalEditor);
  97191. this._modifiedEditorState.clean(this.modifiedEditor);
  97192. };
  97193. DiffEditorWidget.prototype._updateDecorations = function () {
  97194. if (!this.originalEditor.getModel() || !this.modifiedEditor.getModel() || !this._originalOverviewRuler || !this._modifiedOverviewRuler) {
  97195. return;
  97196. }
  97197. var lineChanges = (this._diffComputationResult ? this._diffComputationResult.changes : []);
  97198. var foreignOriginal = this._originalEditorState.getForeignViewZones(this.originalEditor.getWhitespaces());
  97199. var foreignModified = this._modifiedEditorState.getForeignViewZones(this.modifiedEditor.getWhitespaces());
  97200. var diffDecorations = this._strategy.getEditorsDiffDecorations(lineChanges, this._ignoreTrimWhitespace, this._renderIndicators, foreignOriginal, foreignModified, this.originalEditor, this.modifiedEditor);
  97201. try {
  97202. this._currentlyChangingViewZones = true;
  97203. this._originalEditorState.apply(this.originalEditor, this._originalOverviewRuler, diffDecorations.original, false);
  97204. this._modifiedEditorState.apply(this.modifiedEditor, this._modifiedOverviewRuler, diffDecorations.modified, true);
  97205. }
  97206. finally {
  97207. this._currentlyChangingViewZones = false;
  97208. }
  97209. };
  97210. DiffEditorWidget.prototype._adjustOptionsForSubEditor = function (options) {
  97211. var clonedOptions = objects.deepClone(options || {});
  97212. clonedOptions.inDiffEditor = true;
  97213. clonedOptions.wordWrap = 'off';
  97214. clonedOptions.wordWrapMinified = false;
  97215. clonedOptions.automaticLayout = false;
  97216. clonedOptions.scrollbar = clonedOptions.scrollbar || {};
  97217. clonedOptions.scrollbar.vertical = 'visible';
  97218. clonedOptions.folding = false;
  97219. clonedOptions.codeLens = false;
  97220. clonedOptions.fixedOverflowWidgets = true;
  97221. // clonedOptions.lineDecorationsWidth = '2ch';
  97222. if (!clonedOptions.minimap) {
  97223. clonedOptions.minimap = {};
  97224. }
  97225. clonedOptions.minimap.enabled = false;
  97226. return clonedOptions;
  97227. };
  97228. DiffEditorWidget.prototype._adjustOptionsForLeftHandSide = function (options, isEditable) {
  97229. var result = this._adjustOptionsForSubEditor(options);
  97230. result.readOnly = !isEditable;
  97231. result.extraEditorClassName = 'original-in-monaco-diff-editor';
  97232. return result;
  97233. };
  97234. DiffEditorWidget.prototype._adjustOptionsForRightHandSide = function (options) {
  97235. var result = this._adjustOptionsForSubEditor(options);
  97236. result.revealHorizontalRightPadding = editorOptions_1.EditorOptions.revealHorizontalRightPadding.defaultValue + DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH;
  97237. result.scrollbar.verticalHasArrows = false;
  97238. result.extraEditorClassName = 'modified-in-monaco-diff-editor';
  97239. return result;
  97240. };
  97241. DiffEditorWidget.prototype.doLayout = function () {
  97242. this._elementSizeObserver.observe();
  97243. this._doLayout();
  97244. };
  97245. DiffEditorWidget.prototype._doLayout = function () {
  97246. var width = this._elementSizeObserver.getWidth();
  97247. var height = this._elementSizeObserver.getHeight();
  97248. var reviewHeight = this._getReviewHeight();
  97249. var splitPoint = this._strategy.layout();
  97250. this._originalDomNode.style.width = splitPoint + 'px';
  97251. this._originalDomNode.style.left = '0px';
  97252. this._modifiedDomNode.style.width = (width - splitPoint) + 'px';
  97253. this._modifiedDomNode.style.left = splitPoint + 'px';
  97254. this._overviewDomElement.style.top = '0px';
  97255. this._overviewDomElement.style.height = (height - reviewHeight) + 'px';
  97256. this._overviewDomElement.style.width = DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH + 'px';
  97257. this._overviewDomElement.style.left = (width - DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH) + 'px';
  97258. this._overviewViewportDomElement.setWidth(DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH);
  97259. this._overviewViewportDomElement.setHeight(30);
  97260. this.originalEditor.layout({ width: splitPoint, height: (height - reviewHeight) });
  97261. this.modifiedEditor.layout({ width: width - splitPoint - DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH, height: (height - reviewHeight) });
  97262. if (this._originalOverviewRuler || this._modifiedOverviewRuler) {
  97263. this._layoutOverviewRulers();
  97264. }
  97265. this._reviewPane.layout(height - reviewHeight, width, reviewHeight);
  97266. this._layoutOverviewViewport();
  97267. };
  97268. DiffEditorWidget.prototype._layoutOverviewViewport = function () {
  97269. var layout = this._computeOverviewViewport();
  97270. if (!layout) {
  97271. this._overviewViewportDomElement.setTop(0);
  97272. this._overviewViewportDomElement.setHeight(0);
  97273. }
  97274. else {
  97275. this._overviewViewportDomElement.setTop(layout.top);
  97276. this._overviewViewportDomElement.setHeight(layout.height);
  97277. }
  97278. };
  97279. DiffEditorWidget.prototype._computeOverviewViewport = function () {
  97280. var layoutInfo = this.modifiedEditor.getLayoutInfo();
  97281. if (!layoutInfo) {
  97282. return null;
  97283. }
  97284. var scrollTop = this.modifiedEditor.getScrollTop();
  97285. var scrollHeight = this.modifiedEditor.getScrollHeight();
  97286. var computedAvailableSize = Math.max(0, layoutInfo.height);
  97287. var computedRepresentableSize = Math.max(0, computedAvailableSize - 2 * 0);
  97288. var computedRatio = scrollHeight > 0 ? (computedRepresentableSize / scrollHeight) : 0;
  97289. var computedSliderSize = Math.max(0, Math.floor(layoutInfo.height * computedRatio));
  97290. var computedSliderPosition = Math.floor(scrollTop * computedRatio);
  97291. return {
  97292. height: computedSliderSize,
  97293. top: computedSliderPosition
  97294. };
  97295. };
  97296. DiffEditorWidget.prototype._createDataSource = function () {
  97297. var _this = this;
  97298. return {
  97299. getWidth: function () {
  97300. return _this._elementSizeObserver.getWidth();
  97301. },
  97302. getHeight: function () {
  97303. return (_this._elementSizeObserver.getHeight() - _this._getReviewHeight());
  97304. },
  97305. getContainerDomNode: function () {
  97306. return _this._containerDomElement;
  97307. },
  97308. relayoutEditors: function () {
  97309. _this._doLayout();
  97310. },
  97311. getOriginalEditor: function () {
  97312. return _this.originalEditor;
  97313. },
  97314. getModifiedEditor: function () {
  97315. return _this.modifiedEditor;
  97316. }
  97317. };
  97318. };
  97319. DiffEditorWidget.prototype._setStrategy = function (newStrategy) {
  97320. if (this._strategy) {
  97321. this._strategy.dispose();
  97322. }
  97323. this._strategy = newStrategy;
  97324. newStrategy.applyColors(this._themeService.getTheme());
  97325. if (this._diffComputationResult) {
  97326. this._updateDecorations();
  97327. }
  97328. // Just do a layout, the strategy might need it
  97329. this._doLayout();
  97330. };
  97331. DiffEditorWidget.prototype._getLineChangeAtOrBeforeLineNumber = function (lineNumber, startLineNumberExtractor) {
  97332. var lineChanges = (this._diffComputationResult ? this._diffComputationResult.changes : []);
  97333. if (lineChanges.length === 0 || lineNumber < startLineNumberExtractor(lineChanges[0])) {
  97334. // There are no changes or `lineNumber` is before the first change
  97335. return null;
  97336. }
  97337. var min = 0, max = lineChanges.length - 1;
  97338. while (min < max) {
  97339. var mid = Math.floor((min + max) / 2);
  97340. var midStart = startLineNumberExtractor(lineChanges[mid]);
  97341. var midEnd = (mid + 1 <= max ? startLineNumberExtractor(lineChanges[mid + 1]) : 1073741824 /* MAX_SAFE_SMALL_INTEGER */);
  97342. if (lineNumber < midStart) {
  97343. max = mid - 1;
  97344. }
  97345. else if (lineNumber >= midEnd) {
  97346. min = mid + 1;
  97347. }
  97348. else {
  97349. // HIT!
  97350. min = mid;
  97351. max = mid;
  97352. }
  97353. }
  97354. return lineChanges[min];
  97355. };
  97356. DiffEditorWidget.prototype._getEquivalentLineForOriginalLineNumber = function (lineNumber) {
  97357. var lineChange = this._getLineChangeAtOrBeforeLineNumber(lineNumber, function (lineChange) { return lineChange.originalStartLineNumber; });
  97358. if (!lineChange) {
  97359. return lineNumber;
  97360. }
  97361. var originalEquivalentLineNumber = lineChange.originalStartLineNumber + (lineChange.originalEndLineNumber > 0 ? -1 : 0);
  97362. var modifiedEquivalentLineNumber = lineChange.modifiedStartLineNumber + (lineChange.modifiedEndLineNumber > 0 ? -1 : 0);
  97363. var lineChangeOriginalLength = (lineChange.originalEndLineNumber > 0 ? (lineChange.originalEndLineNumber - lineChange.originalStartLineNumber + 1) : 0);
  97364. var lineChangeModifiedLength = (lineChange.modifiedEndLineNumber > 0 ? (lineChange.modifiedEndLineNumber - lineChange.modifiedStartLineNumber + 1) : 0);
  97365. var delta = lineNumber - originalEquivalentLineNumber;
  97366. if (delta <= lineChangeOriginalLength) {
  97367. return modifiedEquivalentLineNumber + Math.min(delta, lineChangeModifiedLength);
  97368. }
  97369. return modifiedEquivalentLineNumber + lineChangeModifiedLength - lineChangeOriginalLength + delta;
  97370. };
  97371. DiffEditorWidget.prototype._getEquivalentLineForModifiedLineNumber = function (lineNumber) {
  97372. var lineChange = this._getLineChangeAtOrBeforeLineNumber(lineNumber, function (lineChange) { return lineChange.modifiedStartLineNumber; });
  97373. if (!lineChange) {
  97374. return lineNumber;
  97375. }
  97376. var originalEquivalentLineNumber = lineChange.originalStartLineNumber + (lineChange.originalEndLineNumber > 0 ? -1 : 0);
  97377. var modifiedEquivalentLineNumber = lineChange.modifiedStartLineNumber + (lineChange.modifiedEndLineNumber > 0 ? -1 : 0);
  97378. var lineChangeOriginalLength = (lineChange.originalEndLineNumber > 0 ? (lineChange.originalEndLineNumber - lineChange.originalStartLineNumber + 1) : 0);
  97379. var lineChangeModifiedLength = (lineChange.modifiedEndLineNumber > 0 ? (lineChange.modifiedEndLineNumber - lineChange.modifiedStartLineNumber + 1) : 0);
  97380. var delta = lineNumber - modifiedEquivalentLineNumber;
  97381. if (delta <= lineChangeModifiedLength) {
  97382. return originalEquivalentLineNumber + Math.min(delta, lineChangeOriginalLength);
  97383. }
  97384. return originalEquivalentLineNumber + lineChangeOriginalLength - lineChangeModifiedLength + delta;
  97385. };
  97386. DiffEditorWidget.prototype.getDiffLineInformationForOriginal = function (lineNumber) {
  97387. if (!this._diffComputationResult) {
  97388. // Cannot answer that which I don't know
  97389. return null;
  97390. }
  97391. return {
  97392. equivalentLineNumber: this._getEquivalentLineForOriginalLineNumber(lineNumber)
  97393. };
  97394. };
  97395. DiffEditorWidget.prototype.getDiffLineInformationForModified = function (lineNumber) {
  97396. if (!this._diffComputationResult) {
  97397. // Cannot answer that which I don't know
  97398. return null;
  97399. }
  97400. return {
  97401. equivalentLineNumber: this._getEquivalentLineForModifiedLineNumber(lineNumber)
  97402. };
  97403. };
  97404. DiffEditorWidget.ONE_OVERVIEW_WIDTH = 15;
  97405. DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH = 30;
  97406. DiffEditorWidget.UPDATE_DIFF_DECORATIONS_DELAY = 200; // ms
  97407. DiffEditorWidget = __decorate([
  97408. __param(3, editorWorkerService_1.IEditorWorkerService),
  97409. __param(4, contextkey_1.IContextKeyService),
  97410. __param(5, instantiation_1.IInstantiationService),
  97411. __param(6, codeEditorService_1.ICodeEditorService),
  97412. __param(7, themeService_1.IThemeService),
  97413. __param(8, notification_1.INotificationService),
  97414. __param(9, contextView_1.IContextMenuService),
  97415. __param(10, progress_1.IEditorProgressService)
  97416. ], DiffEditorWidget);
  97417. return DiffEditorWidget;
  97418. }(lifecycle_1.Disposable));
  97419. exports.DiffEditorWidget = DiffEditorWidget;
  97420. var DiffEditorWidgetStyle = /** @class */ (function (_super) {
  97421. __extends(DiffEditorWidgetStyle, _super);
  97422. function DiffEditorWidgetStyle(dataSource) {
  97423. var _this = _super.call(this) || this;
  97424. _this._dataSource = dataSource;
  97425. _this._insertColor = null;
  97426. _this._removeColor = null;
  97427. return _this;
  97428. }
  97429. DiffEditorWidgetStyle.prototype.applyColors = function (theme) {
  97430. var newInsertColor = (theme.getColor(colorRegistry_1.diffInserted) || colorRegistry_1.defaultInsertColor).transparent(2);
  97431. var newRemoveColor = (theme.getColor(colorRegistry_1.diffRemoved) || colorRegistry_1.defaultRemoveColor).transparent(2);
  97432. var hasChanges = !newInsertColor.equals(this._insertColor) || !newRemoveColor.equals(this._removeColor);
  97433. this._insertColor = newInsertColor;
  97434. this._removeColor = newRemoveColor;
  97435. return hasChanges;
  97436. };
  97437. DiffEditorWidgetStyle.prototype.getEditorsDiffDecorations = function (lineChanges, ignoreTrimWhitespace, renderIndicators, originalWhitespaces, modifiedWhitespaces, originalEditor, modifiedEditor) {
  97438. // Get view zones
  97439. modifiedWhitespaces = modifiedWhitespaces.sort(function (a, b) {
  97440. return a.afterLineNumber - b.afterLineNumber;
  97441. });
  97442. originalWhitespaces = originalWhitespaces.sort(function (a, b) {
  97443. return a.afterLineNumber - b.afterLineNumber;
  97444. });
  97445. var zones = this._getViewZones(lineChanges, originalWhitespaces, modifiedWhitespaces, originalEditor, modifiedEditor, renderIndicators);
  97446. // Get decorations & overview ruler zones
  97447. var originalDecorations = this._getOriginalEditorDecorations(lineChanges, ignoreTrimWhitespace, renderIndicators, originalEditor, modifiedEditor);
  97448. var modifiedDecorations = this._getModifiedEditorDecorations(lineChanges, ignoreTrimWhitespace, renderIndicators, originalEditor, modifiedEditor);
  97449. return {
  97450. original: {
  97451. decorations: originalDecorations.decorations,
  97452. overviewZones: originalDecorations.overviewZones,
  97453. zones: zones.original
  97454. },
  97455. modified: {
  97456. decorations: modifiedDecorations.decorations,
  97457. overviewZones: modifiedDecorations.overviewZones,
  97458. zones: zones.modified
  97459. }
  97460. };
  97461. };
  97462. return DiffEditorWidgetStyle;
  97463. }(lifecycle_1.Disposable));
  97464. var ForeignViewZonesIterator = /** @class */ (function () {
  97465. function ForeignViewZonesIterator(source) {
  97466. this._source = source;
  97467. this._index = -1;
  97468. this.current = null;
  97469. this.advance();
  97470. }
  97471. ForeignViewZonesIterator.prototype.advance = function () {
  97472. this._index++;
  97473. if (this._index < this._source.length) {
  97474. this.current = this._source[this._index];
  97475. }
  97476. else {
  97477. this.current = null;
  97478. }
  97479. };
  97480. return ForeignViewZonesIterator;
  97481. }());
  97482. var ViewZonesComputer = /** @class */ (function () {
  97483. function ViewZonesComputer(lineChanges, originalForeignVZ, originalLineHeight, modifiedForeignVZ, modifiedLineHeight) {
  97484. this.lineChanges = lineChanges;
  97485. this.originalForeignVZ = originalForeignVZ;
  97486. this.originalLineHeight = originalLineHeight;
  97487. this.modifiedForeignVZ = modifiedForeignVZ;
  97488. this.modifiedLineHeight = modifiedLineHeight;
  97489. }
  97490. ViewZonesComputer.prototype.getViewZones = function () {
  97491. var result = {
  97492. original: [],
  97493. modified: []
  97494. };
  97495. var lineChangeModifiedLength = 0;
  97496. var lineChangeOriginalLength = 0;
  97497. var originalEquivalentLineNumber = 0;
  97498. var modifiedEquivalentLineNumber = 0;
  97499. var originalEndEquivalentLineNumber = 0;
  97500. var modifiedEndEquivalentLineNumber = 0;
  97501. var sortMyViewZones = function (a, b) {
  97502. return a.afterLineNumber - b.afterLineNumber;
  97503. };
  97504. var addAndCombineIfPossible = function (destination, item) {
  97505. if (item.domNode === null && destination.length > 0) {
  97506. var lastItem = destination[destination.length - 1];
  97507. if (lastItem.afterLineNumber === item.afterLineNumber && lastItem.domNode === null) {
  97508. lastItem.heightInLines += item.heightInLines;
  97509. return;
  97510. }
  97511. }
  97512. destination.push(item);
  97513. };
  97514. var modifiedForeignVZ = new ForeignViewZonesIterator(this.modifiedForeignVZ);
  97515. var originalForeignVZ = new ForeignViewZonesIterator(this.originalForeignVZ);
  97516. // In order to include foreign view zones after the last line change, the for loop will iterate once more after the end of the `lineChanges` array
  97517. for (var i = 0, length_5 = this.lineChanges.length; i <= length_5; i++) {
  97518. var lineChange = (i < length_5 ? this.lineChanges[i] : null);
  97519. if (lineChange !== null) {
  97520. originalEquivalentLineNumber = lineChange.originalStartLineNumber + (lineChange.originalEndLineNumber > 0 ? -1 : 0);
  97521. modifiedEquivalentLineNumber = lineChange.modifiedStartLineNumber + (lineChange.modifiedEndLineNumber > 0 ? -1 : 0);
  97522. lineChangeOriginalLength = (lineChange.originalEndLineNumber > 0 ? (lineChange.originalEndLineNumber - lineChange.originalStartLineNumber + 1) : 0);
  97523. lineChangeModifiedLength = (lineChange.modifiedEndLineNumber > 0 ? (lineChange.modifiedEndLineNumber - lineChange.modifiedStartLineNumber + 1) : 0);
  97524. originalEndEquivalentLineNumber = Math.max(lineChange.originalStartLineNumber, lineChange.originalEndLineNumber);
  97525. modifiedEndEquivalentLineNumber = Math.max(lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber);
  97526. }
  97527. else {
  97528. // Increase to very large value to get the producing tests of foreign view zones running
  97529. originalEquivalentLineNumber += 10000000 + lineChangeOriginalLength;
  97530. modifiedEquivalentLineNumber += 10000000 + lineChangeModifiedLength;
  97531. originalEndEquivalentLineNumber = originalEquivalentLineNumber;
  97532. modifiedEndEquivalentLineNumber = modifiedEquivalentLineNumber;
  97533. }
  97534. // Each step produces view zones, and after producing them, we try to cancel them out, to avoid empty-empty view zone cases
  97535. var stepOriginal = [];
  97536. var stepModified = [];
  97537. // ---------------------------- PRODUCE VIEW ZONES
  97538. // [PRODUCE] View zone(s) in original-side due to foreign view zone(s) in modified-side
  97539. while (modifiedForeignVZ.current && modifiedForeignVZ.current.afterLineNumber <= modifiedEndEquivalentLineNumber) {
  97540. var viewZoneLineNumber = void 0;
  97541. if (modifiedForeignVZ.current.afterLineNumber <= modifiedEquivalentLineNumber) {
  97542. viewZoneLineNumber = originalEquivalentLineNumber - modifiedEquivalentLineNumber + modifiedForeignVZ.current.afterLineNumber;
  97543. }
  97544. else {
  97545. viewZoneLineNumber = originalEndEquivalentLineNumber;
  97546. }
  97547. var marginDomNode = null;
  97548. if (lineChange && lineChange.modifiedStartLineNumber <= modifiedForeignVZ.current.afterLineNumber && modifiedForeignVZ.current.afterLineNumber <= lineChange.modifiedEndLineNumber) {
  97549. marginDomNode = this._createOriginalMarginDomNodeForModifiedForeignViewZoneInAddedRegion();
  97550. }
  97551. stepOriginal.push({
  97552. afterLineNumber: viewZoneLineNumber,
  97553. heightInLines: modifiedForeignVZ.current.height / this.modifiedLineHeight,
  97554. domNode: null,
  97555. marginDomNode: marginDomNode
  97556. });
  97557. modifiedForeignVZ.advance();
  97558. }
  97559. // [PRODUCE] View zone(s) in modified-side due to foreign view zone(s) in original-side
  97560. while (originalForeignVZ.current && originalForeignVZ.current.afterLineNumber <= originalEndEquivalentLineNumber) {
  97561. var viewZoneLineNumber = void 0;
  97562. if (originalForeignVZ.current.afterLineNumber <= originalEquivalentLineNumber) {
  97563. viewZoneLineNumber = modifiedEquivalentLineNumber - originalEquivalentLineNumber + originalForeignVZ.current.afterLineNumber;
  97564. }
  97565. else {
  97566. viewZoneLineNumber = modifiedEndEquivalentLineNumber;
  97567. }
  97568. stepModified.push({
  97569. afterLineNumber: viewZoneLineNumber,
  97570. heightInLines: originalForeignVZ.current.height / this.originalLineHeight,
  97571. domNode: null
  97572. });
  97573. originalForeignVZ.advance();
  97574. }
  97575. if (lineChange !== null && isChangeOrInsert(lineChange)) {
  97576. var r = this._produceOriginalFromDiff(lineChange, lineChangeOriginalLength, lineChangeModifiedLength);
  97577. if (r) {
  97578. stepOriginal.push(r);
  97579. }
  97580. }
  97581. if (lineChange !== null && isChangeOrDelete(lineChange)) {
  97582. var r = this._produceModifiedFromDiff(lineChange, lineChangeOriginalLength, lineChangeModifiedLength);
  97583. if (r) {
  97584. stepModified.push(r);
  97585. }
  97586. }
  97587. // ---------------------------- END PRODUCE VIEW ZONES
  97588. // ---------------------------- EMIT MINIMAL VIEW ZONES
  97589. // [CANCEL & EMIT] Try to cancel view zones out
  97590. var stepOriginalIndex = 0;
  97591. var stepModifiedIndex = 0;
  97592. stepOriginal = stepOriginal.sort(sortMyViewZones);
  97593. stepModified = stepModified.sort(sortMyViewZones);
  97594. while (stepOriginalIndex < stepOriginal.length && stepModifiedIndex < stepModified.length) {
  97595. var original = stepOriginal[stepOriginalIndex];
  97596. var modified = stepModified[stepModifiedIndex];
  97597. var originalDelta = original.afterLineNumber - originalEquivalentLineNumber;
  97598. var modifiedDelta = modified.afterLineNumber - modifiedEquivalentLineNumber;
  97599. if (originalDelta < modifiedDelta) {
  97600. addAndCombineIfPossible(result.original, original);
  97601. stepOriginalIndex++;
  97602. }
  97603. else if (modifiedDelta < originalDelta) {
  97604. addAndCombineIfPossible(result.modified, modified);
  97605. stepModifiedIndex++;
  97606. }
  97607. else if (original.shouldNotShrink) {
  97608. addAndCombineIfPossible(result.original, original);
  97609. stepOriginalIndex++;
  97610. }
  97611. else if (modified.shouldNotShrink) {
  97612. addAndCombineIfPossible(result.modified, modified);
  97613. stepModifiedIndex++;
  97614. }
  97615. else {
  97616. if (original.heightInLines >= modified.heightInLines) {
  97617. // modified view zone gets removed
  97618. original.heightInLines -= modified.heightInLines;
  97619. stepModifiedIndex++;
  97620. }
  97621. else {
  97622. // original view zone gets removed
  97623. modified.heightInLines -= original.heightInLines;
  97624. stepOriginalIndex++;
  97625. }
  97626. }
  97627. }
  97628. // [EMIT] Remaining original view zones
  97629. while (stepOriginalIndex < stepOriginal.length) {
  97630. addAndCombineIfPossible(result.original, stepOriginal[stepOriginalIndex]);
  97631. stepOriginalIndex++;
  97632. }
  97633. // [EMIT] Remaining modified view zones
  97634. while (stepModifiedIndex < stepModified.length) {
  97635. addAndCombineIfPossible(result.modified, stepModified[stepModifiedIndex]);
  97636. stepModifiedIndex++;
  97637. }
  97638. // ---------------------------- END EMIT MINIMAL VIEW ZONES
  97639. }
  97640. return {
  97641. original: ViewZonesComputer._ensureDomNodes(result.original),
  97642. modified: ViewZonesComputer._ensureDomNodes(result.modified),
  97643. };
  97644. };
  97645. ViewZonesComputer._ensureDomNodes = function (zones) {
  97646. return zones.map(function (z) {
  97647. if (!z.domNode) {
  97648. z.domNode = createFakeLinesDiv();
  97649. }
  97650. return z;
  97651. });
  97652. };
  97653. return ViewZonesComputer;
  97654. }());
  97655. function createDecoration(startLineNumber, startColumn, endLineNumber, endColumn, options) {
  97656. return {
  97657. range: new range_1.Range(startLineNumber, startColumn, endLineNumber, endColumn),
  97658. options: options
  97659. };
  97660. }
  97661. var DECORATIONS = {
  97662. charDelete: textModel_1.ModelDecorationOptions.register({
  97663. className: 'char-delete'
  97664. }),
  97665. charDeleteWholeLine: textModel_1.ModelDecorationOptions.register({
  97666. className: 'char-delete',
  97667. isWholeLine: true
  97668. }),
  97669. charInsert: textModel_1.ModelDecorationOptions.register({
  97670. className: 'char-insert'
  97671. }),
  97672. charInsertWholeLine: textModel_1.ModelDecorationOptions.register({
  97673. className: 'char-insert',
  97674. isWholeLine: true
  97675. }),
  97676. lineInsert: textModel_1.ModelDecorationOptions.register({
  97677. className: 'line-insert',
  97678. marginClassName: 'line-insert',
  97679. isWholeLine: true
  97680. }),
  97681. lineInsertWithSign: textModel_1.ModelDecorationOptions.register({
  97682. className: 'line-insert',
  97683. linesDecorationsClassName: 'insert-sign codicon codicon-add',
  97684. marginClassName: 'line-insert',
  97685. isWholeLine: true
  97686. }),
  97687. lineDelete: textModel_1.ModelDecorationOptions.register({
  97688. className: 'line-delete',
  97689. marginClassName: 'line-delete',
  97690. isWholeLine: true
  97691. }),
  97692. lineDeleteWithSign: textModel_1.ModelDecorationOptions.register({
  97693. className: 'line-delete',
  97694. linesDecorationsClassName: 'delete-sign codicon codicon-remove',
  97695. marginClassName: 'line-delete',
  97696. isWholeLine: true
  97697. }),
  97698. lineDeleteMargin: textModel_1.ModelDecorationOptions.register({
  97699. marginClassName: 'line-delete',
  97700. })
  97701. };
  97702. var DiffEditorWidgetSideBySide = /** @class */ (function (_super) {
  97703. __extends(DiffEditorWidgetSideBySide, _super);
  97704. function DiffEditorWidgetSideBySide(dataSource, enableSplitViewResizing) {
  97705. var _this = _super.call(this, dataSource) || this;
  97706. _this._disableSash = (enableSplitViewResizing === false);
  97707. _this._sashRatio = null;
  97708. _this._sashPosition = null;
  97709. _this._startSashPosition = null;
  97710. _this._sash = _this._register(new sash_1.Sash(_this._dataSource.getContainerDomNode(), _this));
  97711. if (_this._disableSash) {
  97712. _this._sash.state = 0 /* Disabled */;
  97713. }
  97714. _this._sash.onDidStart(function () { return _this.onSashDragStart(); });
  97715. _this._sash.onDidChange(function (e) { return _this.onSashDrag(e); });
  97716. _this._sash.onDidEnd(function () { return _this.onSashDragEnd(); });
  97717. _this._sash.onDidReset(function () { return _this.onSashReset(); });
  97718. return _this;
  97719. }
  97720. DiffEditorWidgetSideBySide.prototype.setEnableSplitViewResizing = function (enableSplitViewResizing) {
  97721. var newDisableSash = (enableSplitViewResizing === false);
  97722. if (this._disableSash !== newDisableSash) {
  97723. this._disableSash = newDisableSash;
  97724. this._sash.state = this._disableSash ? 0 /* Disabled */ : 3 /* Enabled */;
  97725. }
  97726. };
  97727. DiffEditorWidgetSideBySide.prototype.layout = function (sashRatio) {
  97728. if (sashRatio === void 0) { sashRatio = this._sashRatio; }
  97729. var w = this._dataSource.getWidth();
  97730. var contentWidth = w - DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH;
  97731. var sashPosition = Math.floor((sashRatio || 0.5) * contentWidth);
  97732. var midPoint = Math.floor(0.5 * contentWidth);
  97733. sashPosition = this._disableSash ? midPoint : sashPosition || midPoint;
  97734. if (contentWidth > DiffEditorWidgetSideBySide.MINIMUM_EDITOR_WIDTH * 2) {
  97735. if (sashPosition < DiffEditorWidgetSideBySide.MINIMUM_EDITOR_WIDTH) {
  97736. sashPosition = DiffEditorWidgetSideBySide.MINIMUM_EDITOR_WIDTH;
  97737. }
  97738. if (sashPosition > contentWidth - DiffEditorWidgetSideBySide.MINIMUM_EDITOR_WIDTH) {
  97739. sashPosition = contentWidth - DiffEditorWidgetSideBySide.MINIMUM_EDITOR_WIDTH;
  97740. }
  97741. }
  97742. else {
  97743. sashPosition = midPoint;
  97744. }
  97745. if (this._sashPosition !== sashPosition) {
  97746. this._sashPosition = sashPosition;
  97747. this._sash.layout();
  97748. }
  97749. return this._sashPosition;
  97750. };
  97751. DiffEditorWidgetSideBySide.prototype.onSashDragStart = function () {
  97752. this._startSashPosition = this._sashPosition;
  97753. };
  97754. DiffEditorWidgetSideBySide.prototype.onSashDrag = function (e) {
  97755. var w = this._dataSource.getWidth();
  97756. var contentWidth = w - DiffEditorWidget.ENTIRE_DIFF_OVERVIEW_WIDTH;
  97757. var sashPosition = this.layout((this._startSashPosition + (e.currentX - e.startX)) / contentWidth);
  97758. this._sashRatio = sashPosition / contentWidth;
  97759. this._dataSource.relayoutEditors();
  97760. };
  97761. DiffEditorWidgetSideBySide.prototype.onSashDragEnd = function () {
  97762. this._sash.layout();
  97763. };
  97764. DiffEditorWidgetSideBySide.prototype.onSashReset = function () {
  97765. this._sashRatio = 0.5;
  97766. this._dataSource.relayoutEditors();
  97767. this._sash.layout();
  97768. };
  97769. DiffEditorWidgetSideBySide.prototype.getVerticalSashTop = function (sash) {
  97770. return 0;
  97771. };
  97772. DiffEditorWidgetSideBySide.prototype.getVerticalSashLeft = function (sash) {
  97773. return this._sashPosition;
  97774. };
  97775. DiffEditorWidgetSideBySide.prototype.getVerticalSashHeight = function (sash) {
  97776. return this._dataSource.getHeight();
  97777. };
  97778. DiffEditorWidgetSideBySide.prototype._getViewZones = function (lineChanges, originalForeignVZ, modifiedForeignVZ, originalEditor, modifiedEditor) {
  97779. var c = new SideBySideViewZonesComputer(lineChanges, originalForeignVZ, originalEditor.getOption(49 /* lineHeight */), modifiedForeignVZ, modifiedEditor.getOption(49 /* lineHeight */));
  97780. return c.getViewZones();
  97781. };
  97782. DiffEditorWidgetSideBySide.prototype._getOriginalEditorDecorations = function (lineChanges, ignoreTrimWhitespace, renderIndicators, originalEditor, modifiedEditor) {
  97783. var overviewZoneColor = String(this._removeColor);
  97784. var result = {
  97785. decorations: [],
  97786. overviewZones: []
  97787. };
  97788. var originalModel = originalEditor.getModel();
  97789. for (var i = 0, length_6 = lineChanges.length; i < length_6; i++) {
  97790. var lineChange = lineChanges[i];
  97791. if (isChangeOrDelete(lineChange)) {
  97792. result.decorations.push({
  97793. range: new range_1.Range(lineChange.originalStartLineNumber, 1, lineChange.originalEndLineNumber, 1073741824 /* MAX_SAFE_SMALL_INTEGER */),
  97794. options: (renderIndicators ? DECORATIONS.lineDeleteWithSign : DECORATIONS.lineDelete)
  97795. });
  97796. if (!isChangeOrInsert(lineChange) || !lineChange.charChanges) {
  97797. result.decorations.push(createDecoration(lineChange.originalStartLineNumber, 1, lineChange.originalEndLineNumber, 1073741824 /* MAX_SAFE_SMALL_INTEGER */, DECORATIONS.charDeleteWholeLine));
  97798. }
  97799. result.overviewZones.push(new overviewZoneManager_1.OverviewRulerZone(lineChange.originalStartLineNumber, lineChange.originalEndLineNumber, overviewZoneColor));
  97800. if (lineChange.charChanges) {
  97801. for (var j = 0, lengthJ = lineChange.charChanges.length; j < lengthJ; j++) {
  97802. var charChange = lineChange.charChanges[j];
  97803. if (isChangeOrDelete(charChange)) {
  97804. if (ignoreTrimWhitespace) {
  97805. for (var lineNumber = charChange.originalStartLineNumber; lineNumber <= charChange.originalEndLineNumber; lineNumber++) {
  97806. var startColumn = void 0;
  97807. var endColumn = void 0;
  97808. if (lineNumber === charChange.originalStartLineNumber) {
  97809. startColumn = charChange.originalStartColumn;
  97810. }
  97811. else {
  97812. startColumn = originalModel.getLineFirstNonWhitespaceColumn(lineNumber);
  97813. }
  97814. if (lineNumber === charChange.originalEndLineNumber) {
  97815. endColumn = charChange.originalEndColumn;
  97816. }
  97817. else {
  97818. endColumn = originalModel.getLineLastNonWhitespaceColumn(lineNumber);
  97819. }
  97820. result.decorations.push(createDecoration(lineNumber, startColumn, lineNumber, endColumn, DECORATIONS.charDelete));
  97821. }
  97822. }
  97823. else {
  97824. result.decorations.push(createDecoration(charChange.originalStartLineNumber, charChange.originalStartColumn, charChange.originalEndLineNumber, charChange.originalEndColumn, DECORATIONS.charDelete));
  97825. }
  97826. }
  97827. }
  97828. }
  97829. }
  97830. }
  97831. return result;
  97832. };
  97833. DiffEditorWidgetSideBySide.prototype._getModifiedEditorDecorations = function (lineChanges, ignoreTrimWhitespace, renderIndicators, originalEditor, modifiedEditor) {
  97834. var overviewZoneColor = String(this._insertColor);
  97835. var result = {
  97836. decorations: [],
  97837. overviewZones: []
  97838. };
  97839. var modifiedModel = modifiedEditor.getModel();
  97840. for (var i = 0, length_7 = lineChanges.length; i < length_7; i++) {
  97841. var lineChange = lineChanges[i];
  97842. if (isChangeOrInsert(lineChange)) {
  97843. result.decorations.push({
  97844. range: new range_1.Range(lineChange.modifiedStartLineNumber, 1, lineChange.modifiedEndLineNumber, 1073741824 /* MAX_SAFE_SMALL_INTEGER */),
  97845. options: (renderIndicators ? DECORATIONS.lineInsertWithSign : DECORATIONS.lineInsert)
  97846. });
  97847. if (!isChangeOrDelete(lineChange) || !lineChange.charChanges) {
  97848. result.decorations.push(createDecoration(lineChange.modifiedStartLineNumber, 1, lineChange.modifiedEndLineNumber, 1073741824 /* MAX_SAFE_SMALL_INTEGER */, DECORATIONS.charInsertWholeLine));
  97849. }
  97850. result.overviewZones.push(new overviewZoneManager_1.OverviewRulerZone(lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber, overviewZoneColor));
  97851. if (lineChange.charChanges) {
  97852. for (var j = 0, lengthJ = lineChange.charChanges.length; j < lengthJ; j++) {
  97853. var charChange = lineChange.charChanges[j];
  97854. if (isChangeOrInsert(charChange)) {
  97855. if (ignoreTrimWhitespace) {
  97856. for (var lineNumber = charChange.modifiedStartLineNumber; lineNumber <= charChange.modifiedEndLineNumber; lineNumber++) {
  97857. var startColumn = void 0;
  97858. var endColumn = void 0;
  97859. if (lineNumber === charChange.modifiedStartLineNumber) {
  97860. startColumn = charChange.modifiedStartColumn;
  97861. }
  97862. else {
  97863. startColumn = modifiedModel.getLineFirstNonWhitespaceColumn(lineNumber);
  97864. }
  97865. if (lineNumber === charChange.modifiedEndLineNumber) {
  97866. endColumn = charChange.modifiedEndColumn;
  97867. }
  97868. else {
  97869. endColumn = modifiedModel.getLineLastNonWhitespaceColumn(lineNumber);
  97870. }
  97871. result.decorations.push(createDecoration(lineNumber, startColumn, lineNumber, endColumn, DECORATIONS.charInsert));
  97872. }
  97873. }
  97874. else {
  97875. result.decorations.push(createDecoration(charChange.modifiedStartLineNumber, charChange.modifiedStartColumn, charChange.modifiedEndLineNumber, charChange.modifiedEndColumn, DECORATIONS.charInsert));
  97876. }
  97877. }
  97878. }
  97879. }
  97880. }
  97881. }
  97882. return result;
  97883. };
  97884. DiffEditorWidgetSideBySide.MINIMUM_EDITOR_WIDTH = 100;
  97885. return DiffEditorWidgetSideBySide;
  97886. }(DiffEditorWidgetStyle));
  97887. var SideBySideViewZonesComputer = /** @class */ (function (_super) {
  97888. __extends(SideBySideViewZonesComputer, _super);
  97889. function SideBySideViewZonesComputer(lineChanges, originalForeignVZ, originalLineHeight, modifiedForeignVZ, modifiedLineHeight) {
  97890. return _super.call(this, lineChanges, originalForeignVZ, originalLineHeight, modifiedForeignVZ, modifiedLineHeight) || this;
  97891. }
  97892. SideBySideViewZonesComputer.prototype._createOriginalMarginDomNodeForModifiedForeignViewZoneInAddedRegion = function () {
  97893. return null;
  97894. };
  97895. SideBySideViewZonesComputer.prototype._produceOriginalFromDiff = function (lineChange, lineChangeOriginalLength, lineChangeModifiedLength) {
  97896. if (lineChangeModifiedLength > lineChangeOriginalLength) {
  97897. return {
  97898. afterLineNumber: Math.max(lineChange.originalStartLineNumber, lineChange.originalEndLineNumber),
  97899. heightInLines: (lineChangeModifiedLength - lineChangeOriginalLength),
  97900. domNode: null
  97901. };
  97902. }
  97903. return null;
  97904. };
  97905. SideBySideViewZonesComputer.prototype._produceModifiedFromDiff = function (lineChange, lineChangeOriginalLength, lineChangeModifiedLength) {
  97906. if (lineChangeOriginalLength > lineChangeModifiedLength) {
  97907. return {
  97908. afterLineNumber: Math.max(lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber),
  97909. heightInLines: (lineChangeOriginalLength - lineChangeModifiedLength),
  97910. domNode: null
  97911. };
  97912. }
  97913. return null;
  97914. };
  97915. return SideBySideViewZonesComputer;
  97916. }(ViewZonesComputer));
  97917. var DiffEditorWidgetInline = /** @class */ (function (_super) {
  97918. __extends(DiffEditorWidgetInline, _super);
  97919. function DiffEditorWidgetInline(dataSource, enableSplitViewResizing) {
  97920. var _this = _super.call(this, dataSource) || this;
  97921. _this.decorationsLeft = dataSource.getOriginalEditor().getLayoutInfo().decorationsLeft;
  97922. _this._register(dataSource.getOriginalEditor().onDidLayoutChange(function (layoutInfo) {
  97923. if (_this.decorationsLeft !== layoutInfo.decorationsLeft) {
  97924. _this.decorationsLeft = layoutInfo.decorationsLeft;
  97925. dataSource.relayoutEditors();
  97926. }
  97927. }));
  97928. return _this;
  97929. }
  97930. DiffEditorWidgetInline.prototype.setEnableSplitViewResizing = function (enableSplitViewResizing) {
  97931. // Nothing to do..
  97932. };
  97933. DiffEditorWidgetInline.prototype._getViewZones = function (lineChanges, originalForeignVZ, modifiedForeignVZ, originalEditor, modifiedEditor, renderIndicators) {
  97934. var computer = new InlineViewZonesComputer(lineChanges, originalForeignVZ, modifiedForeignVZ, originalEditor, modifiedEditor, renderIndicators);
  97935. return computer.getViewZones();
  97936. };
  97937. DiffEditorWidgetInline.prototype._getOriginalEditorDecorations = function (lineChanges, ignoreTrimWhitespace, renderIndicators, originalEditor, modifiedEditor) {
  97938. var overviewZoneColor = String(this._removeColor);
  97939. var result = {
  97940. decorations: [],
  97941. overviewZones: []
  97942. };
  97943. for (var i = 0, length_8 = lineChanges.length; i < length_8; i++) {
  97944. var lineChange = lineChanges[i];
  97945. // Add overview zones in the overview ruler
  97946. if (isChangeOrDelete(lineChange)) {
  97947. result.decorations.push({
  97948. range: new range_1.Range(lineChange.originalStartLineNumber, 1, lineChange.originalEndLineNumber, 1073741824 /* MAX_SAFE_SMALL_INTEGER */),
  97949. options: DECORATIONS.lineDeleteMargin
  97950. });
  97951. result.overviewZones.push(new overviewZoneManager_1.OverviewRulerZone(lineChange.originalStartLineNumber, lineChange.originalEndLineNumber, overviewZoneColor));
  97952. }
  97953. }
  97954. return result;
  97955. };
  97956. DiffEditorWidgetInline.prototype._getModifiedEditorDecorations = function (lineChanges, ignoreTrimWhitespace, renderIndicators, originalEditor, modifiedEditor) {
  97957. var overviewZoneColor = String(this._insertColor);
  97958. var result = {
  97959. decorations: [],
  97960. overviewZones: []
  97961. };
  97962. var modifiedModel = modifiedEditor.getModel();
  97963. for (var i = 0, length_9 = lineChanges.length; i < length_9; i++) {
  97964. var lineChange = lineChanges[i];
  97965. // Add decorations & overview zones
  97966. if (isChangeOrInsert(lineChange)) {
  97967. result.decorations.push({
  97968. range: new range_1.Range(lineChange.modifiedStartLineNumber, 1, lineChange.modifiedEndLineNumber, 1073741824 /* MAX_SAFE_SMALL_INTEGER */),
  97969. options: (renderIndicators ? DECORATIONS.lineInsertWithSign : DECORATIONS.lineInsert)
  97970. });
  97971. result.overviewZones.push(new overviewZoneManager_1.OverviewRulerZone(lineChange.modifiedStartLineNumber, lineChange.modifiedEndLineNumber, overviewZoneColor));
  97972. if (lineChange.charChanges) {
  97973. for (var j = 0, lengthJ = lineChange.charChanges.length; j < lengthJ; j++) {
  97974. var charChange = lineChange.charChanges[j];
  97975. if (isChangeOrInsert(charChange)) {
  97976. if (ignoreTrimWhitespace) {
  97977. for (var lineNumber = charChange.modifiedStartLineNumber; lineNumber <= charChange.modifiedEndLineNumber; lineNumber++) {
  97978. var startColumn = void 0;
  97979. var endColumn = void 0;
  97980. if (lineNumber === charChange.modifiedStartLineNumber) {
  97981. startColumn = charChange.modifiedStartColumn;
  97982. }
  97983. else {
  97984. startColumn = modifiedModel.getLineFirstNonWhitespaceColumn(lineNumber);
  97985. }
  97986. if (lineNumber === charChange.modifiedEndLineNumber) {
  97987. endColumn = charChange.modifiedEndColumn;
  97988. }
  97989. else {
  97990. endColumn = modifiedModel.getLineLastNonWhitespaceColumn(lineNumber);
  97991. }
  97992. result.decorations.push(createDecoration(lineNumber, startColumn, lineNumber, endColumn, DECORATIONS.charInsert));
  97993. }
  97994. }
  97995. else {
  97996. result.decorations.push(createDecoration(charChange.modifiedStartLineNumber, charChange.modifiedStartColumn, charChange.modifiedEndLineNumber, charChange.modifiedEndColumn, DECORATIONS.charInsert));
  97997. }
  97998. }
  97999. }
  98000. }
  98001. else {
  98002. result.decorations.push(createDecoration(lineChange.modifiedStartLineNumber, 1, lineChange.modifiedEndLineNumber, 1073741824 /* MAX_SAFE_SMALL_INTEGER */, DECORATIONS.charInsertWholeLine));
  98003. }
  98004. }
  98005. }
  98006. return result;
  98007. };
  98008. DiffEditorWidgetInline.prototype.layout = function () {
  98009. // An editor should not be smaller than 5px
  98010. return Math.max(5, this.decorationsLeft);
  98011. };
  98012. return DiffEditorWidgetInline;
  98013. }(DiffEditorWidgetStyle));
  98014. var InlineViewZonesComputer = /** @class */ (function (_super) {
  98015. __extends(InlineViewZonesComputer, _super);
  98016. function InlineViewZonesComputer(lineChanges, originalForeignVZ, modifiedForeignVZ, originalEditor, modifiedEditor, renderIndicators) {
  98017. var _this = _super.call(this, lineChanges, originalForeignVZ, originalEditor.getOption(49 /* lineHeight */), modifiedForeignVZ, modifiedEditor.getOption(49 /* lineHeight */)) || this;
  98018. _this.originalModel = originalEditor.getModel();
  98019. _this.modifiedEditorOptions = modifiedEditor.getOptions();
  98020. _this.modifiedEditorTabSize = modifiedEditor.getModel().getOptions().tabSize;
  98021. _this.renderIndicators = renderIndicators;
  98022. return _this;
  98023. }
  98024. InlineViewZonesComputer.prototype._createOriginalMarginDomNodeForModifiedForeignViewZoneInAddedRegion = function () {
  98025. var result = document.createElement('div');
  98026. result.className = 'inline-added-margin-view-zone';
  98027. return result;
  98028. };
  98029. InlineViewZonesComputer.prototype._produceOriginalFromDiff = function (lineChange, lineChangeOriginalLength, lineChangeModifiedLength) {
  98030. var marginDomNode = document.createElement('div');
  98031. marginDomNode.className = 'inline-added-margin-view-zone';
  98032. return {
  98033. afterLineNumber: Math.max(lineChange.originalStartLineNumber, lineChange.originalEndLineNumber),
  98034. heightInLines: lineChangeModifiedLength,
  98035. domNode: document.createElement('div'),
  98036. marginDomNode: marginDomNode
  98037. };
  98038. };
  98039. InlineViewZonesComputer.prototype._produceModifiedFromDiff = function (lineChange, lineChangeOriginalLength, lineChangeModifiedLength) {
  98040. var decorations = [];
  98041. if (lineChange.charChanges) {
  98042. for (var j = 0, lengthJ = lineChange.charChanges.length; j < lengthJ; j++) {
  98043. var charChange = lineChange.charChanges[j];
  98044. if (isChangeOrDelete(charChange)) {
  98045. decorations.push(new viewModel_1.InlineDecoration(new range_1.Range(charChange.originalStartLineNumber, charChange.originalStartColumn, charChange.originalEndLineNumber, charChange.originalEndColumn), 'char-delete', 0 /* Regular */));
  98046. }
  98047. }
  98048. }
  98049. var sb = stringBuilder_1.createStringBuilder(10000);
  98050. var marginHTML = [];
  98051. var layoutInfo = this.modifiedEditorOptions.get(107 /* layoutInfo */);
  98052. var fontInfo = this.modifiedEditorOptions.get(34 /* fontInfo */);
  98053. var lineDecorationsWidth = layoutInfo.decorationsWidth;
  98054. var lineHeight = this.modifiedEditorOptions.get(49 /* lineHeight */);
  98055. var typicalHalfwidthCharacterWidth = fontInfo.typicalHalfwidthCharacterWidth;
  98056. var maxCharsPerLine = 0;
  98057. var originalContent = [];
  98058. for (var lineNumber = lineChange.originalStartLineNumber; lineNumber <= lineChange.originalEndLineNumber; lineNumber++) {
  98059. maxCharsPerLine = Math.max(maxCharsPerLine, this._renderOriginalLine(lineNumber - lineChange.originalStartLineNumber, this.originalModel, this.modifiedEditorOptions, this.modifiedEditorTabSize, lineNumber, decorations, sb));
  98060. originalContent.push(this.originalModel.getLineContent(lineNumber));
  98061. if (this.renderIndicators) {
  98062. var index = lineNumber - lineChange.originalStartLineNumber;
  98063. marginHTML = marginHTML.concat([
  98064. "<div class=\"delete-sign codicon codicon-remove\" style=\"position:absolute;top:" + index * lineHeight + "px;width:" + lineDecorationsWidth + "px;height:" + lineHeight + "px;right:0;\"></div>"
  98065. ]);
  98066. }
  98067. }
  98068. maxCharsPerLine += this.modifiedEditorOptions.get(79 /* scrollBeyondLastColumn */);
  98069. var domNode = document.createElement('div');
  98070. domNode.className = 'view-lines line-delete';
  98071. domNode.innerHTML = sb.build();
  98072. configuration_1.Configuration.applyFontInfoSlow(domNode, fontInfo);
  98073. var marginDomNode = document.createElement('div');
  98074. marginDomNode.className = 'inline-deleted-margin-view-zone';
  98075. marginDomNode.innerHTML = marginHTML.join('');
  98076. configuration_1.Configuration.applyFontInfoSlow(marginDomNode, fontInfo);
  98077. return {
  98078. shouldNotShrink: true,
  98079. afterLineNumber: (lineChange.modifiedEndLineNumber === 0 ? lineChange.modifiedStartLineNumber : lineChange.modifiedStartLineNumber - 1),
  98080. heightInLines: lineChangeOriginalLength,
  98081. minWidthInPx: (maxCharsPerLine * typicalHalfwidthCharacterWidth),
  98082. domNode: domNode,
  98083. marginDomNode: marginDomNode,
  98084. diff: {
  98085. originalStartLineNumber: lineChange.originalStartLineNumber,
  98086. originalEndLineNumber: lineChange.originalEndLineNumber,
  98087. modifiedStartLineNumber: lineChange.modifiedStartLineNumber,
  98088. modifiedEndLineNumber: lineChange.modifiedEndLineNumber,
  98089. originalContent: originalContent
  98090. }
  98091. };
  98092. };
  98093. InlineViewZonesComputer.prototype._renderOriginalLine = function (count, originalModel, options, tabSize, lineNumber, decorations, sb) {
  98094. var lineTokens = originalModel.getLineTokens(lineNumber);
  98095. var lineContent = lineTokens.getLineContent();
  98096. var fontInfo = options.get(34 /* fontInfo */);
  98097. var actualDecorations = lineDecorations_1.LineDecoration.filter(decorations, lineNumber, 1, lineContent.length + 1);
  98098. sb.appendASCIIString('<div class="view-line');
  98099. if (decorations.length === 0) {
  98100. // No char changes
  98101. sb.appendASCIIString(' char-delete');
  98102. }
  98103. sb.appendASCIIString('" style="top:');
  98104. sb.appendASCIIString(String(count * options.get(49 /* lineHeight */)));
  98105. sb.appendASCIIString('px;width:1000000px;">');
  98106. var isBasicASCII = viewModel_1.ViewLineRenderingData.isBasicASCII(lineContent, originalModel.mightContainNonBasicASCII());
  98107. var containsRTL = viewModel_1.ViewLineRenderingData.containsRTL(lineContent, isBasicASCII, originalModel.mightContainRTL());
  98108. var output = viewLineRenderer_1.renderViewLine(new viewLineRenderer_1.RenderLineInput((fontInfo.isMonospace && !options.get(23 /* disableMonospaceOptimizations */)), fontInfo.canUseHalfwidthRightwardsArrow, lineContent, false, isBasicASCII, containsRTL, 0, lineTokens, actualDecorations, tabSize, 0, fontInfo.spaceWidth, fontInfo.middotWidth, options.get(88 /* stopRenderingLineAfter */), options.get(74 /* renderWhitespace */), options.get(69 /* renderControlCharacters */), options.get(35 /* fontLigatures */) !== editorOptions_1.EditorFontLigatures.OFF, null // Send no selections, original line cannot be selected
  98109. ), sb);
  98110. sb.appendASCIIString('</div>');
  98111. var absoluteOffsets = output.characterMapping.getAbsoluteOffsets();
  98112. return absoluteOffsets.length > 0 ? absoluteOffsets[absoluteOffsets.length - 1] : 0;
  98113. };
  98114. return InlineViewZonesComputer;
  98115. }(ViewZonesComputer));
  98116. function isChangeOrInsert(lineChange) {
  98117. return lineChange.modifiedEndLineNumber > 0;
  98118. }
  98119. function isChangeOrDelete(lineChange) {
  98120. return lineChange.originalEndLineNumber > 0;
  98121. }
  98122. function createFakeLinesDiv() {
  98123. var r = document.createElement('div');
  98124. r.className = 'diagonal-fill';
  98125. return r;
  98126. }
  98127. themeService_1.registerThemingParticipant(function (theme, collector) {
  98128. var added = theme.getColor(colorRegistry_1.diffInserted);
  98129. if (added) {
  98130. collector.addRule(".monaco-editor .line-insert, .monaco-editor .char-insert { background-color: " + added + "; }");
  98131. collector.addRule(".monaco-diff-editor .line-insert, .monaco-diff-editor .char-insert { background-color: " + added + "; }");
  98132. collector.addRule(".monaco-editor .inline-added-margin-view-zone { background-color: " + added + "; }");
  98133. }
  98134. var removed = theme.getColor(colorRegistry_1.diffRemoved);
  98135. if (removed) {
  98136. collector.addRule(".monaco-editor .line-delete, .monaco-editor .char-delete { background-color: " + removed + "; }");
  98137. collector.addRule(".monaco-diff-editor .line-delete, .monaco-diff-editor .char-delete { background-color: " + removed + "; }");
  98138. collector.addRule(".monaco-editor .inline-deleted-margin-view-zone { background-color: " + removed + "; }");
  98139. }
  98140. var addedOutline = theme.getColor(colorRegistry_1.diffInsertedOutline);
  98141. if (addedOutline) {
  98142. collector.addRule(".monaco-editor .line-insert, .monaco-editor .char-insert { border: 1px " + (theme.type === 'hc' ? 'dashed' : 'solid') + " " + addedOutline + "; }");
  98143. }
  98144. var removedOutline = theme.getColor(colorRegistry_1.diffRemovedOutline);
  98145. if (removedOutline) {
  98146. collector.addRule(".monaco-editor .line-delete, .monaco-editor .char-delete { border: 1px " + (theme.type === 'hc' ? 'dashed' : 'solid') + " " + removedOutline + "; }");
  98147. }
  98148. var shadow = theme.getColor(colorRegistry_1.scrollbarShadow);
  98149. if (shadow) {
  98150. collector.addRule(".monaco-diff-editor.side-by-side .editor.modified { box-shadow: -6px 0 5px -5px " + shadow + "; }");
  98151. }
  98152. var border = theme.getColor(colorRegistry_1.diffBorder);
  98153. if (border) {
  98154. collector.addRule(".monaco-diff-editor.side-by-side .editor.modified { border-left: 1px solid " + border + "; }");
  98155. }
  98156. });
  98157. });
  98158. /*---------------------------------------------------------------------------------------------
  98159. * Copyright (c) Microsoft Corporation. All rights reserved.
  98160. * Licensed under the MIT License. See License.txt in the project root for license information.
  98161. *--------------------------------------------------------------------------------------------*/
  98162. define(__m[167/*vs/editor/browser/widget/embeddedCodeEditorWidget*/], __M([0/*require*/,1/*exports*/,31/*vs/base/common/objects*/,32/*vs/editor/browser/services/codeEditorService*/,121/*vs/editor/browser/widget/codeEditorWidget*/,29/*vs/platform/commands/common/commands*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,35/*vs/platform/notification/common/notification*/,14/*vs/platform/theme/common/themeService*/,64/*vs/platform/accessibility/common/accessibility*/]), function (require, exports, objects, codeEditorService_1, codeEditorWidget_1, commands_1, contextkey_1, instantiation_1, notification_1, themeService_1, accessibility_1) {
  98163. "use strict";
  98164. Object.defineProperty(exports, "__esModule", { value: true });
  98165. var EmbeddedCodeEditorWidget = /** @class */ (function (_super) {
  98166. __extends(EmbeddedCodeEditorWidget, _super);
  98167. function EmbeddedCodeEditorWidget(domElement, options, parentEditor, instantiationService, codeEditorService, commandService, contextKeyService, themeService, notificationService, accessibilityService) {
  98168. var _this = _super.call(this, domElement, parentEditor.getRawOptions(), {}, instantiationService, codeEditorService, commandService, contextKeyService, themeService, notificationService, accessibilityService) || this;
  98169. _this._parentEditor = parentEditor;
  98170. _this._overwriteOptions = options;
  98171. // Overwrite parent's options
  98172. _super.prototype.updateOptions.call(_this, _this._overwriteOptions);
  98173. _this._register(parentEditor.onDidChangeConfiguration(function (e) { return _this._onParentConfigurationChanged(e); }));
  98174. return _this;
  98175. }
  98176. EmbeddedCodeEditorWidget.prototype.getParentEditor = function () {
  98177. return this._parentEditor;
  98178. };
  98179. EmbeddedCodeEditorWidget.prototype._onParentConfigurationChanged = function (e) {
  98180. _super.prototype.updateOptions.call(this, this._parentEditor.getRawOptions());
  98181. _super.prototype.updateOptions.call(this, this._overwriteOptions);
  98182. };
  98183. EmbeddedCodeEditorWidget.prototype.updateOptions = function (newOptions) {
  98184. objects.mixin(this._overwriteOptions, newOptions, true);
  98185. _super.prototype.updateOptions.call(this, this._overwriteOptions);
  98186. };
  98187. EmbeddedCodeEditorWidget = __decorate([
  98188. __param(3, instantiation_1.IInstantiationService),
  98189. __param(4, codeEditorService_1.ICodeEditorService),
  98190. __param(5, commands_1.ICommandService),
  98191. __param(6, contextkey_1.IContextKeyService),
  98192. __param(7, themeService_1.IThemeService),
  98193. __param(8, notification_1.INotificationService),
  98194. __param(9, accessibility_1.IAccessibilityService)
  98195. ], EmbeddedCodeEditorWidget);
  98196. return EmbeddedCodeEditorWidget;
  98197. }(codeEditorWidget_1.CodeEditorWidget));
  98198. exports.EmbeddedCodeEditorWidget = EmbeddedCodeEditorWidget;
  98199. });
  98200. /*---------------------------------------------------------------------------------------------
  98201. * Copyright (c) Microsoft Corporation. All rights reserved.
  98202. * Licensed under the MIT License. See License.txt in the project root for license information.
  98203. *--------------------------------------------------------------------------------------------*/
  98204. define(__m[565/*vs/editor/common/services/markerDecorationsServiceImpl*/], __M([0/*require*/,1/*exports*/,72/*vs/platform/markers/common/markers*/,2/*vs/base/common/lifecycle*/,48/*vs/editor/common/model*/,14/*vs/platform/theme/common/themeService*/,44/*vs/editor/common/view/editorColorRegistry*/,49/*vs/editor/common/services/modelService*/,3/*vs/editor/common/core/range*/,38/*vs/base/common/map*/,46/*vs/base/common/network*/,4/*vs/base/common/event*/,21/*vs/base/common/types*/,20/*vs/platform/theme/common/colorRegistry*/]), function (require, exports, markers_1, lifecycle_1, model_1, themeService_1, editorColorRegistry_1, modelService_1, range_1, map_1, network_1, event_1, types_1, colorRegistry_1) {
  98205. "use strict";
  98206. Object.defineProperty(exports, "__esModule", { value: true });
  98207. function MODEL_ID(resource) {
  98208. return resource.toString();
  98209. }
  98210. var MarkerDecorations = /** @class */ (function (_super) {
  98211. __extends(MarkerDecorations, _super);
  98212. function MarkerDecorations(model) {
  98213. var _this = _super.call(this) || this;
  98214. _this.model = model;
  98215. _this._markersData = new Map();
  98216. _this._register(lifecycle_1.toDisposable(function () {
  98217. _this.model.deltaDecorations(map_1.keys(_this._markersData), []);
  98218. _this._markersData.clear();
  98219. }));
  98220. return _this;
  98221. }
  98222. MarkerDecorations.prototype.update = function (markers, newDecorations) {
  98223. var oldIds = map_1.keys(this._markersData);
  98224. this._markersData.clear();
  98225. var ids = this.model.deltaDecorations(oldIds, newDecorations);
  98226. for (var index = 0; index < ids.length; index++) {
  98227. this._markersData.set(ids[index], markers[index]);
  98228. }
  98229. };
  98230. MarkerDecorations.prototype.getMarker = function (decoration) {
  98231. return this._markersData.get(decoration.id);
  98232. };
  98233. return MarkerDecorations;
  98234. }(lifecycle_1.Disposable));
  98235. var MarkerDecorationsService = /** @class */ (function (_super) {
  98236. __extends(MarkerDecorationsService, _super);
  98237. function MarkerDecorationsService(modelService, _markerService) {
  98238. var _this = _super.call(this) || this;
  98239. _this._markerService = _markerService;
  98240. _this._onDidChangeMarker = _this._register(new event_1.Emitter());
  98241. _this._markerDecorations = new Map();
  98242. modelService.getModels().forEach(function (model) { return _this._onModelAdded(model); });
  98243. _this._register(modelService.onModelAdded(_this._onModelAdded, _this));
  98244. _this._register(modelService.onModelRemoved(_this._onModelRemoved, _this));
  98245. _this._register(_this._markerService.onMarkerChanged(_this._handleMarkerChange, _this));
  98246. return _this;
  98247. }
  98248. MarkerDecorationsService.prototype.dispose = function () {
  98249. _super.prototype.dispose.call(this);
  98250. this._markerDecorations.forEach(function (value) { return value.dispose(); });
  98251. this._markerDecorations.clear();
  98252. };
  98253. MarkerDecorationsService.prototype.getMarker = function (model, decoration) {
  98254. var markerDecorations = this._markerDecorations.get(MODEL_ID(model.uri));
  98255. return markerDecorations ? types_1.withUndefinedAsNull(markerDecorations.getMarker(decoration)) : null;
  98256. };
  98257. MarkerDecorationsService.prototype._handleMarkerChange = function (changedResources) {
  98258. var _this = this;
  98259. changedResources.forEach(function (resource) {
  98260. var markerDecorations = _this._markerDecorations.get(MODEL_ID(resource));
  98261. if (markerDecorations) {
  98262. _this._updateDecorations(markerDecorations);
  98263. }
  98264. });
  98265. };
  98266. MarkerDecorationsService.prototype._onModelAdded = function (model) {
  98267. var markerDecorations = new MarkerDecorations(model);
  98268. this._markerDecorations.set(MODEL_ID(model.uri), markerDecorations);
  98269. this._updateDecorations(markerDecorations);
  98270. };
  98271. MarkerDecorationsService.prototype._onModelRemoved = function (model) {
  98272. var _this = this;
  98273. var markerDecorations = this._markerDecorations.get(MODEL_ID(model.uri));
  98274. if (markerDecorations) {
  98275. markerDecorations.dispose();
  98276. this._markerDecorations.delete(MODEL_ID(model.uri));
  98277. }
  98278. // clean up markers for internal, transient models
  98279. if (model.uri.scheme === network_1.Schemas.inMemory
  98280. || model.uri.scheme === network_1.Schemas.internal
  98281. || model.uri.scheme === network_1.Schemas.vscode) {
  98282. if (this._markerService) {
  98283. this._markerService.read({ resource: model.uri }).map(function (marker) { return marker.owner; }).forEach(function (owner) { return _this._markerService.remove(owner, [model.uri]); });
  98284. }
  98285. }
  98286. };
  98287. MarkerDecorationsService.prototype._updateDecorations = function (markerDecorations) {
  98288. var _this = this;
  98289. // Limit to the first 500 errors/warnings
  98290. var markers = this._markerService.read({ resource: markerDecorations.model.uri, take: 500 });
  98291. var newModelDecorations = markers.map(function (marker) {
  98292. return {
  98293. range: _this._createDecorationRange(markerDecorations.model, marker),
  98294. options: _this._createDecorationOption(marker)
  98295. };
  98296. });
  98297. markerDecorations.update(markers, newModelDecorations);
  98298. this._onDidChangeMarker.fire(markerDecorations.model);
  98299. };
  98300. MarkerDecorationsService.prototype._createDecorationRange = function (model, rawMarker) {
  98301. var ret = range_1.Range.lift(rawMarker);
  98302. if (rawMarker.severity === markers_1.MarkerSeverity.Hint && !this._hasMarkerTag(rawMarker, 1 /* Unnecessary */) && !this._hasMarkerTag(rawMarker, 2 /* Deprecated */)) {
  98303. // * never render hints on multiple lines
  98304. // * make enough space for three dots
  98305. ret = ret.setEndPosition(ret.startLineNumber, ret.startColumn + 2);
  98306. }
  98307. ret = model.validateRange(ret);
  98308. if (ret.isEmpty()) {
  98309. var word = model.getWordAtPosition(ret.getStartPosition());
  98310. if (word) {
  98311. ret = new range_1.Range(ret.startLineNumber, word.startColumn, ret.endLineNumber, word.endColumn);
  98312. }
  98313. else {
  98314. var maxColumn = model.getLineLastNonWhitespaceColumn(ret.startLineNumber) ||
  98315. model.getLineMaxColumn(ret.startLineNumber);
  98316. if (maxColumn === 1) {
  98317. // empty line
  98318. // console.warn('marker on empty line:', marker);
  98319. }
  98320. else if (ret.endColumn >= maxColumn) {
  98321. // behind eol
  98322. ret = new range_1.Range(ret.startLineNumber, maxColumn - 1, ret.endLineNumber, maxColumn);
  98323. }
  98324. else {
  98325. // extend marker to width = 1
  98326. ret = new range_1.Range(ret.startLineNumber, ret.startColumn, ret.endLineNumber, ret.endColumn + 1);
  98327. }
  98328. }
  98329. }
  98330. else if (rawMarker.endColumn === Number.MAX_VALUE && rawMarker.startColumn === 1 && ret.startLineNumber === ret.endLineNumber) {
  98331. var minColumn = model.getLineFirstNonWhitespaceColumn(rawMarker.startLineNumber);
  98332. if (minColumn < ret.endColumn) {
  98333. ret = new range_1.Range(ret.startLineNumber, minColumn, ret.endLineNumber, ret.endColumn);
  98334. rawMarker.startColumn = minColumn;
  98335. }
  98336. }
  98337. return ret;
  98338. };
  98339. MarkerDecorationsService.prototype._createDecorationOption = function (marker) {
  98340. var className;
  98341. var color = undefined;
  98342. var zIndex;
  98343. var inlineClassName = undefined;
  98344. var minimap;
  98345. switch (marker.severity) {
  98346. case markers_1.MarkerSeverity.Hint:
  98347. if (this._hasMarkerTag(marker, 2 /* Deprecated */)) {
  98348. className = undefined;
  98349. }
  98350. else if (this._hasMarkerTag(marker, 1 /* Unnecessary */)) {
  98351. className = "squiggly-unnecessary" /* EditorUnnecessaryDecoration */;
  98352. }
  98353. else {
  98354. className = "squiggly-hint" /* EditorHintDecoration */;
  98355. }
  98356. zIndex = 0;
  98357. break;
  98358. case markers_1.MarkerSeverity.Warning:
  98359. className = "squiggly-warning" /* EditorWarningDecoration */;
  98360. color = themeService_1.themeColorFromId(editorColorRegistry_1.overviewRulerWarning);
  98361. zIndex = 20;
  98362. minimap = {
  98363. color: themeService_1.themeColorFromId(colorRegistry_1.minimapWarning),
  98364. position: model_1.MinimapPosition.Inline
  98365. };
  98366. break;
  98367. case markers_1.MarkerSeverity.Info:
  98368. className = "squiggly-info" /* EditorInfoDecoration */;
  98369. color = themeService_1.themeColorFromId(editorColorRegistry_1.overviewRulerInfo);
  98370. zIndex = 10;
  98371. break;
  98372. case markers_1.MarkerSeverity.Error:
  98373. default:
  98374. className = "squiggly-error" /* EditorErrorDecoration */;
  98375. color = themeService_1.themeColorFromId(editorColorRegistry_1.overviewRulerError);
  98376. zIndex = 30;
  98377. minimap = {
  98378. color: themeService_1.themeColorFromId(colorRegistry_1.minimapError),
  98379. position: model_1.MinimapPosition.Inline
  98380. };
  98381. break;
  98382. }
  98383. if (marker.tags) {
  98384. if (marker.tags.indexOf(1 /* Unnecessary */) !== -1) {
  98385. inlineClassName = "squiggly-inline-unnecessary" /* EditorUnnecessaryInlineDecoration */;
  98386. }
  98387. if (marker.tags.indexOf(2 /* Deprecated */) !== -1) {
  98388. inlineClassName = "squiggly-inline-deprecated" /* EditorDeprecatedInlineDecoration */;
  98389. }
  98390. }
  98391. return {
  98392. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  98393. className: className,
  98394. showIfCollapsed: true,
  98395. overviewRuler: {
  98396. color: color,
  98397. position: model_1.OverviewRulerLane.Right
  98398. },
  98399. minimap: minimap,
  98400. zIndex: zIndex,
  98401. inlineClassName: inlineClassName,
  98402. };
  98403. };
  98404. MarkerDecorationsService.prototype._hasMarkerTag = function (marker, tag) {
  98405. if (marker.tags) {
  98406. return marker.tags.indexOf(tag) >= 0;
  98407. }
  98408. return false;
  98409. };
  98410. MarkerDecorationsService = __decorate([
  98411. __param(0, modelService_1.IModelService),
  98412. __param(1, markers_1.IMarkerService)
  98413. ], MarkerDecorationsService);
  98414. return MarkerDecorationsService;
  98415. }(lifecycle_1.Disposable));
  98416. exports.MarkerDecorationsService = MarkerDecorationsService;
  98417. });
  98418. /*---------------------------------------------------------------------------------------------
  98419. * Copyright (c) Microsoft Corporation. All rights reserved.
  98420. * Licensed under the MIT License. See License.txt in the project root for license information.
  98421. *--------------------------------------------------------------------------------------------*/
  98422. define(__m[566/*vs/editor/contrib/bracketMatching/bracketMatching*/], __M([0/*require*/,1/*exports*/,428/*vs/nls!vs/editor/contrib/bracketMatching/bracketMatching*/,15/*vs/base/common/async*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,23/*vs/editor/common/editorContextKeys*/,48/*vs/editor/common/model*/,30/*vs/editor/common/model/textModel*/,44/*vs/editor/common/view/editorColorRegistry*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,65/*vs/platform/actions/common/actions*/,302/*vs/css!vs/editor/contrib/bracketMatching/bracketMatching*/]), function (require, exports, nls, async_1, lifecycle_1, editorExtensions_1, position_1, range_1, selection_1, editorContextKeys_1, model_1, textModel_1, editorColorRegistry_1, colorRegistry_1, themeService_1, actions_1) {
  98423. "use strict";
  98424. Object.defineProperty(exports, "__esModule", { value: true });
  98425. var overviewRulerBracketMatchForeground = colorRegistry_1.registerColor('editorOverviewRuler.bracketMatchForeground', { dark: '#A0A0A0', light: '#A0A0A0', hc: '#A0A0A0' }, nls.localize(0, null));
  98426. var JumpToBracketAction = /** @class */ (function (_super) {
  98427. __extends(JumpToBracketAction, _super);
  98428. function JumpToBracketAction() {
  98429. return _super.call(this, {
  98430. id: 'editor.action.jumpToBracket',
  98431. label: nls.localize(1, null),
  98432. alias: 'Go to Bracket',
  98433. precondition: undefined,
  98434. kbOpts: {
  98435. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  98436. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 88 /* US_BACKSLASH */,
  98437. weight: 100 /* EditorContrib */
  98438. }
  98439. }) || this;
  98440. }
  98441. JumpToBracketAction.prototype.run = function (accessor, editor) {
  98442. var controller = BracketMatchingController.get(editor);
  98443. if (!controller) {
  98444. return;
  98445. }
  98446. controller.jumpToBracket();
  98447. };
  98448. return JumpToBracketAction;
  98449. }(editorExtensions_1.EditorAction));
  98450. var SelectToBracketAction = /** @class */ (function (_super) {
  98451. __extends(SelectToBracketAction, _super);
  98452. function SelectToBracketAction() {
  98453. return _super.call(this, {
  98454. id: 'editor.action.selectToBracket',
  98455. label: nls.localize(2, null),
  98456. alias: 'Select to Bracket',
  98457. precondition: undefined,
  98458. description: {
  98459. description: "Select to Bracket",
  98460. args: [{
  98461. name: 'args',
  98462. schema: {
  98463. type: 'object',
  98464. properties: {
  98465. 'selectBrackets': {
  98466. type: 'boolean',
  98467. default: true
  98468. }
  98469. },
  98470. }
  98471. }]
  98472. }
  98473. }) || this;
  98474. }
  98475. SelectToBracketAction.prototype.run = function (accessor, editor, args) {
  98476. var controller = BracketMatchingController.get(editor);
  98477. if (!controller) {
  98478. return;
  98479. }
  98480. var selectBrackets = true;
  98481. if (args && args.selectBrackets === false) {
  98482. selectBrackets = false;
  98483. }
  98484. controller.selectToBracket(selectBrackets);
  98485. };
  98486. return SelectToBracketAction;
  98487. }(editorExtensions_1.EditorAction));
  98488. var BracketsData = /** @class */ (function () {
  98489. function BracketsData(position, brackets, options) {
  98490. this.position = position;
  98491. this.brackets = brackets;
  98492. this.options = options;
  98493. }
  98494. return BracketsData;
  98495. }());
  98496. var BracketMatchingController = /** @class */ (function (_super) {
  98497. __extends(BracketMatchingController, _super);
  98498. function BracketMatchingController(editor) {
  98499. var _this = _super.call(this) || this;
  98500. _this._editor = editor;
  98501. _this._lastBracketsData = [];
  98502. _this._lastVersionId = 0;
  98503. _this._decorations = [];
  98504. _this._updateBracketsSoon = _this._register(new async_1.RunOnceScheduler(function () { return _this._updateBrackets(); }, 50));
  98505. _this._matchBrackets = _this._editor.getOption(53 /* matchBrackets */);
  98506. _this._updateBracketsSoon.schedule();
  98507. _this._register(editor.onDidChangeCursorPosition(function (e) {
  98508. if (_this._matchBrackets === 'never') {
  98509. // Early exit if nothing needs to be done!
  98510. // Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
  98511. return;
  98512. }
  98513. _this._updateBracketsSoon.schedule();
  98514. }));
  98515. _this._register(editor.onDidChangeModelContent(function (e) {
  98516. _this._updateBracketsSoon.schedule();
  98517. }));
  98518. _this._register(editor.onDidChangeModel(function (e) {
  98519. _this._lastBracketsData = [];
  98520. _this._decorations = [];
  98521. _this._updateBracketsSoon.schedule();
  98522. }));
  98523. _this._register(editor.onDidChangeModelLanguageConfiguration(function (e) {
  98524. _this._lastBracketsData = [];
  98525. _this._updateBracketsSoon.schedule();
  98526. }));
  98527. _this._register(editor.onDidChangeConfiguration(function (e) {
  98528. if (e.hasChanged(53 /* matchBrackets */)) {
  98529. _this._matchBrackets = _this._editor.getOption(53 /* matchBrackets */);
  98530. _this._decorations = _this._editor.deltaDecorations(_this._decorations, []);
  98531. _this._lastBracketsData = [];
  98532. _this._lastVersionId = 0;
  98533. _this._updateBracketsSoon.schedule();
  98534. }
  98535. }));
  98536. return _this;
  98537. }
  98538. BracketMatchingController.get = function (editor) {
  98539. return editor.getContribution(BracketMatchingController.ID);
  98540. };
  98541. BracketMatchingController.prototype.jumpToBracket = function () {
  98542. if (!this._editor.hasModel()) {
  98543. return;
  98544. }
  98545. var model = this._editor.getModel();
  98546. var newSelections = this._editor.getSelections().map(function (selection) {
  98547. var position = selection.getStartPosition();
  98548. // find matching brackets if position is on a bracket
  98549. var brackets = model.matchBracket(position);
  98550. var newCursorPosition = null;
  98551. if (brackets) {
  98552. if (brackets[0].containsPosition(position)) {
  98553. newCursorPosition = brackets[1].getStartPosition();
  98554. }
  98555. else if (brackets[1].containsPosition(position)) {
  98556. newCursorPosition = brackets[0].getStartPosition();
  98557. }
  98558. }
  98559. else {
  98560. // find the enclosing brackets if the position isn't on a matching bracket
  98561. var enclosingBrackets = model.findEnclosingBrackets(position);
  98562. if (enclosingBrackets) {
  98563. newCursorPosition = enclosingBrackets[0].getStartPosition();
  98564. }
  98565. else {
  98566. // no enclosing brackets, try the very first next bracket
  98567. var nextBracket = model.findNextBracket(position);
  98568. if (nextBracket && nextBracket.range) {
  98569. newCursorPosition = nextBracket.range.getStartPosition();
  98570. }
  98571. }
  98572. }
  98573. if (newCursorPosition) {
  98574. return new selection_1.Selection(newCursorPosition.lineNumber, newCursorPosition.column, newCursorPosition.lineNumber, newCursorPosition.column);
  98575. }
  98576. return new selection_1.Selection(position.lineNumber, position.column, position.lineNumber, position.column);
  98577. });
  98578. this._editor.setSelections(newSelections);
  98579. this._editor.revealRange(newSelections[0]);
  98580. };
  98581. BracketMatchingController.prototype.selectToBracket = function (selectBrackets) {
  98582. if (!this._editor.hasModel()) {
  98583. return;
  98584. }
  98585. var model = this._editor.getModel();
  98586. var newSelections = [];
  98587. this._editor.getSelections().forEach(function (selection) {
  98588. var position = selection.getStartPosition();
  98589. var brackets = model.matchBracket(position);
  98590. if (!brackets) {
  98591. brackets = model.findEnclosingBrackets(position);
  98592. if (!brackets) {
  98593. var nextBracket = model.findNextBracket(position);
  98594. if (nextBracket && nextBracket.range) {
  98595. brackets = model.matchBracket(nextBracket.range.getStartPosition());
  98596. }
  98597. }
  98598. }
  98599. var selectFrom = null;
  98600. var selectTo = null;
  98601. if (brackets) {
  98602. brackets.sort(range_1.Range.compareRangesUsingStarts);
  98603. var open_1 = brackets[0], close_1 = brackets[1];
  98604. selectFrom = selectBrackets ? open_1.getStartPosition() : open_1.getEndPosition();
  98605. selectTo = selectBrackets ? close_1.getEndPosition() : close_1.getStartPosition();
  98606. }
  98607. if (selectFrom && selectTo) {
  98608. newSelections.push(new selection_1.Selection(selectFrom.lineNumber, selectFrom.column, selectTo.lineNumber, selectTo.column));
  98609. }
  98610. });
  98611. if (newSelections.length > 0) {
  98612. this._editor.setSelections(newSelections);
  98613. this._editor.revealRange(newSelections[0]);
  98614. }
  98615. };
  98616. BracketMatchingController.prototype._updateBrackets = function () {
  98617. if (this._matchBrackets === 'never') {
  98618. return;
  98619. }
  98620. this._recomputeBrackets();
  98621. var newDecorations = [], newDecorationsLen = 0;
  98622. for (var _i = 0, _a = this._lastBracketsData; _i < _a.length; _i++) {
  98623. var bracketData = _a[_i];
  98624. var brackets = bracketData.brackets;
  98625. if (brackets) {
  98626. newDecorations[newDecorationsLen++] = { range: brackets[0], options: bracketData.options };
  98627. newDecorations[newDecorationsLen++] = { range: brackets[1], options: bracketData.options };
  98628. }
  98629. }
  98630. this._decorations = this._editor.deltaDecorations(this._decorations, newDecorations);
  98631. };
  98632. BracketMatchingController.prototype._recomputeBrackets = function () {
  98633. if (!this._editor.hasModel()) {
  98634. // no model => no brackets!
  98635. this._lastBracketsData = [];
  98636. this._lastVersionId = 0;
  98637. return;
  98638. }
  98639. var selections = this._editor.getSelections();
  98640. if (selections.length > 100) {
  98641. // no bracket matching for high numbers of selections
  98642. this._lastBracketsData = [];
  98643. this._lastVersionId = 0;
  98644. return;
  98645. }
  98646. var model = this._editor.getModel();
  98647. var versionId = model.getVersionId();
  98648. var previousData = [];
  98649. if (this._lastVersionId === versionId) {
  98650. // use the previous data only if the model is at the same version id
  98651. previousData = this._lastBracketsData;
  98652. }
  98653. var positions = [], positionsLen = 0;
  98654. for (var i = 0, len = selections.length; i < len; i++) {
  98655. var selection = selections[i];
  98656. if (selection.isEmpty()) {
  98657. // will bracket match a cursor only if the selection is collapsed
  98658. positions[positionsLen++] = selection.getStartPosition();
  98659. }
  98660. }
  98661. // sort positions for `previousData` cache hits
  98662. if (positions.length > 1) {
  98663. positions.sort(position_1.Position.compare);
  98664. }
  98665. var newData = [], newDataLen = 0;
  98666. var previousIndex = 0, previousLen = previousData.length;
  98667. for (var i = 0, len = positions.length; i < len; i++) {
  98668. var position = positions[i];
  98669. while (previousIndex < previousLen && previousData[previousIndex].position.isBefore(position)) {
  98670. previousIndex++;
  98671. }
  98672. if (previousIndex < previousLen && previousData[previousIndex].position.equals(position)) {
  98673. newData[newDataLen++] = previousData[previousIndex];
  98674. }
  98675. else {
  98676. var brackets = model.matchBracket(position);
  98677. var options = BracketMatchingController._DECORATION_OPTIONS_WITH_OVERVIEW_RULER;
  98678. if (!brackets && this._matchBrackets === 'always') {
  98679. brackets = model.findEnclosingBrackets(position, 20 /* give at most 20ms to compute */);
  98680. options = BracketMatchingController._DECORATION_OPTIONS_WITHOUT_OVERVIEW_RULER;
  98681. }
  98682. newData[newDataLen++] = new BracketsData(position, brackets, options);
  98683. }
  98684. }
  98685. this._lastBracketsData = newData;
  98686. this._lastVersionId = versionId;
  98687. };
  98688. BracketMatchingController.ID = 'editor.contrib.bracketMatchingController';
  98689. BracketMatchingController._DECORATION_OPTIONS_WITH_OVERVIEW_RULER = textModel_1.ModelDecorationOptions.register({
  98690. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  98691. className: 'bracket-match',
  98692. overviewRuler: {
  98693. color: themeService_1.themeColorFromId(overviewRulerBracketMatchForeground),
  98694. position: model_1.OverviewRulerLane.Center
  98695. }
  98696. });
  98697. BracketMatchingController._DECORATION_OPTIONS_WITHOUT_OVERVIEW_RULER = textModel_1.ModelDecorationOptions.register({
  98698. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  98699. className: 'bracket-match'
  98700. });
  98701. return BracketMatchingController;
  98702. }(lifecycle_1.Disposable));
  98703. exports.BracketMatchingController = BracketMatchingController;
  98704. editorExtensions_1.registerEditorContribution(BracketMatchingController.ID, BracketMatchingController);
  98705. editorExtensions_1.registerEditorAction(SelectToBracketAction);
  98706. editorExtensions_1.registerEditorAction(JumpToBracketAction);
  98707. themeService_1.registerThemingParticipant(function (theme, collector) {
  98708. var bracketMatchBackground = theme.getColor(editorColorRegistry_1.editorBracketMatchBackground);
  98709. if (bracketMatchBackground) {
  98710. collector.addRule(".monaco-editor .bracket-match { background-color: " + bracketMatchBackground + "; }");
  98711. }
  98712. var bracketMatchBorder = theme.getColor(editorColorRegistry_1.editorBracketMatchBorder);
  98713. if (bracketMatchBorder) {
  98714. collector.addRule(".monaco-editor .bracket-match { border: 1px solid " + bracketMatchBorder + "; }");
  98715. }
  98716. });
  98717. // Go to menu
  98718. actions_1.MenuRegistry.appendMenuItem(19 /* MenubarGoMenu */, {
  98719. group: '5_infile_nav',
  98720. command: {
  98721. id: 'editor.action.jumpToBracket',
  98722. title: nls.localize(3, null)
  98723. },
  98724. order: 2
  98725. });
  98726. });
  98727. /*---------------------------------------------------------------------------------------------
  98728. * Copyright (c) Microsoft Corporation. All rights reserved.
  98729. * Licensed under the MIT License. See License.txt in the project root for license information.
  98730. *--------------------------------------------------------------------------------------------*/
  98731. define(__m[567/*vs/editor/contrib/codeAction/lightBulbWidget*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,78/*vs/base/browser/globalMouseMoveMonitor*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,30/*vs/editor/common/model/textModel*/,433/*vs/nls!vs/editor/contrib/codeAction/lightBulbWidget*/,34/*vs/platform/keybinding/common/keybinding*/,14/*vs/platform/theme/common/themeService*/,20/*vs/platform/theme/common/colorRegistry*/,57/*vs/base/browser/touch*/,304/*vs/css!vs/editor/contrib/codeAction/lightBulbWidget*/]), function (require, exports, dom, globalMouseMoveMonitor_1, event_1, lifecycle_1, textModel_1, nls, keybinding_1, themeService_1, colorRegistry_1, touch_1) {
  98732. "use strict";
  98733. Object.defineProperty(exports, "__esModule", { value: true });
  98734. var LightBulbState;
  98735. (function (LightBulbState) {
  98736. LightBulbState.Hidden = { type: 0 /* Hidden */ };
  98737. var Showing = /** @class */ (function () {
  98738. function Showing(actions, trigger, editorPosition, widgetPosition) {
  98739. this.actions = actions;
  98740. this.trigger = trigger;
  98741. this.editorPosition = editorPosition;
  98742. this.widgetPosition = widgetPosition;
  98743. this.type = 1 /* Showing */;
  98744. }
  98745. return Showing;
  98746. }());
  98747. LightBulbState.Showing = Showing;
  98748. })(LightBulbState || (LightBulbState = {}));
  98749. var LightBulbWidget = /** @class */ (function (_super) {
  98750. __extends(LightBulbWidget, _super);
  98751. function LightBulbWidget(_editor, _quickFixActionId, _preferredFixActionId, _keybindingService) {
  98752. var _this = _super.call(this) || this;
  98753. _this._editor = _editor;
  98754. _this._quickFixActionId = _quickFixActionId;
  98755. _this._preferredFixActionId = _preferredFixActionId;
  98756. _this._keybindingService = _keybindingService;
  98757. _this._onClick = _this._register(new event_1.Emitter());
  98758. _this.onClick = _this._onClick.event;
  98759. _this._state = LightBulbState.Hidden;
  98760. _this._domNode = document.createElement('div');
  98761. _this._domNode.className = 'codicon codicon-lightbulb';
  98762. _this._editor.addContentWidget(_this);
  98763. _this._register(_this._editor.onDidChangeModelContent(function (_) {
  98764. // cancel when the line in question has been removed
  98765. var editorModel = _this._editor.getModel();
  98766. if (_this.state.type !== 1 /* Showing */ || !editorModel || _this.state.editorPosition.lineNumber >= editorModel.getLineCount()) {
  98767. _this.hide();
  98768. }
  98769. }));
  98770. touch_1.Gesture.ignoreTarget(_this._domNode);
  98771. _this._register(dom.addStandardDisposableGenericMouseDownListner(_this._domNode, function (e) {
  98772. if (_this.state.type !== 1 /* Showing */) {
  98773. return;
  98774. }
  98775. // Make sure that focus / cursor location is not lost when clicking widget icon
  98776. _this._editor.focus();
  98777. e.preventDefault();
  98778. // a bit of extra work to make sure the menu
  98779. // doesn't cover the line-text
  98780. var _a = dom.getDomNodePagePosition(_this._domNode), top = _a.top, height = _a.height;
  98781. var lineHeight = _this._editor.getOption(49 /* lineHeight */);
  98782. var pad = Math.floor(lineHeight / 3);
  98783. if (_this.state.widgetPosition.position !== null && _this.state.widgetPosition.position.lineNumber < _this.state.editorPosition.lineNumber) {
  98784. pad += lineHeight;
  98785. }
  98786. _this._onClick.fire({
  98787. x: e.posx,
  98788. y: top + height + pad,
  98789. actions: _this.state.actions,
  98790. trigger: _this.state.trigger,
  98791. });
  98792. }));
  98793. _this._register(dom.addDisposableListener(_this._domNode, 'mouseenter', function (e) {
  98794. if ((e.buttons & 1) !== 1) {
  98795. return;
  98796. }
  98797. // mouse enters lightbulb while the primary/left button
  98798. // is being pressed -> hide the lightbulb and block future
  98799. // showings until mouse is released
  98800. _this.hide();
  98801. var monitor = new globalMouseMoveMonitor_1.GlobalMouseMoveMonitor();
  98802. monitor.startMonitoring(e.target, e.buttons, globalMouseMoveMonitor_1.standardMouseMoveMerger, function () { }, function () {
  98803. monitor.dispose();
  98804. });
  98805. }));
  98806. _this._register(_this._editor.onDidChangeConfiguration(function (e) {
  98807. // hide when told to do so
  98808. if (e.hasChanged(47 /* lightbulb */) && !_this._editor.getOption(47 /* lightbulb */).enabled) {
  98809. _this.hide();
  98810. }
  98811. }));
  98812. _this._updateLightBulbTitle();
  98813. _this._register(_this._keybindingService.onDidUpdateKeybindings(_this._updateLightBulbTitle, _this));
  98814. return _this;
  98815. }
  98816. LightBulbWidget.prototype.dispose = function () {
  98817. _super.prototype.dispose.call(this);
  98818. this._editor.removeContentWidget(this);
  98819. };
  98820. LightBulbWidget.prototype.getId = function () {
  98821. return 'LightBulbWidget';
  98822. };
  98823. LightBulbWidget.prototype.getDomNode = function () {
  98824. return this._domNode;
  98825. };
  98826. LightBulbWidget.prototype.getPosition = function () {
  98827. return this._state.type === 1 /* Showing */ ? this._state.widgetPosition : null;
  98828. };
  98829. LightBulbWidget.prototype.update = function (actions, trigger, atPosition) {
  98830. var _this = this;
  98831. if (actions.validActions.length <= 0) {
  98832. return this.hide();
  98833. }
  98834. var options = this._editor.getOptions();
  98835. if (!options.get(47 /* lightbulb */).enabled) {
  98836. return this.hide();
  98837. }
  98838. var lineNumber = atPosition.lineNumber, column = atPosition.column;
  98839. var model = this._editor.getModel();
  98840. if (!model) {
  98841. return this.hide();
  98842. }
  98843. var tabSize = model.getOptions().tabSize;
  98844. var fontInfo = options.get(34 /* fontInfo */);
  98845. var lineContent = model.getLineContent(lineNumber);
  98846. var indent = textModel_1.TextModel.computeIndentLevel(lineContent, tabSize);
  98847. var lineHasSpace = fontInfo.spaceWidth * indent > 22;
  98848. var isFolded = function (lineNumber) {
  98849. return lineNumber > 2 && _this._editor.getTopForLineNumber(lineNumber) === _this._editor.getTopForLineNumber(lineNumber - 1);
  98850. };
  98851. var effectiveLineNumber = lineNumber;
  98852. if (!lineHasSpace) {
  98853. if (lineNumber > 1 && !isFolded(lineNumber - 1)) {
  98854. effectiveLineNumber -= 1;
  98855. }
  98856. else if (!isFolded(lineNumber + 1)) {
  98857. effectiveLineNumber += 1;
  98858. }
  98859. else if (column * fontInfo.spaceWidth < 22) {
  98860. // cannot show lightbulb above/below and showing
  98861. // it inline would overlay the cursor...
  98862. return this.hide();
  98863. }
  98864. }
  98865. this.state = new LightBulbState.Showing(actions, trigger, atPosition, {
  98866. position: { lineNumber: effectiveLineNumber, column: 1 },
  98867. preference: LightBulbWidget._posPref
  98868. });
  98869. dom.toggleClass(this._domNode, 'codicon-lightbulb-autofix', actions.hasAutoFix);
  98870. this._editor.layoutContentWidget(this);
  98871. };
  98872. LightBulbWidget.prototype.hide = function () {
  98873. this.state = LightBulbState.Hidden;
  98874. this._editor.layoutContentWidget(this);
  98875. };
  98876. Object.defineProperty(LightBulbWidget.prototype, "state", {
  98877. get: function () { return this._state; },
  98878. set: function (value) {
  98879. this._state = value;
  98880. this._updateLightBulbTitle();
  98881. },
  98882. enumerable: true,
  98883. configurable: true
  98884. });
  98885. LightBulbWidget.prototype._updateLightBulbTitle = function () {
  98886. if (this.state.type === 1 /* Showing */ && this.state.actions.hasAutoFix) {
  98887. var preferredKb = this._keybindingService.lookupKeybinding(this._preferredFixActionId);
  98888. if (preferredKb) {
  98889. this.title = nls.localize(0, null, preferredKb.getLabel());
  98890. return;
  98891. }
  98892. }
  98893. var kb = this._keybindingService.lookupKeybinding(this._quickFixActionId);
  98894. if (kb) {
  98895. this.title = nls.localize(1, null, kb.getLabel());
  98896. }
  98897. else {
  98898. this.title = nls.localize(2, null);
  98899. }
  98900. };
  98901. Object.defineProperty(LightBulbWidget.prototype, "title", {
  98902. set: function (value) {
  98903. this._domNode.title = value;
  98904. },
  98905. enumerable: true,
  98906. configurable: true
  98907. });
  98908. LightBulbWidget._posPref = [0 /* EXACT */];
  98909. LightBulbWidget = __decorate([
  98910. __param(3, keybinding_1.IKeybindingService)
  98911. ], LightBulbWidget);
  98912. return LightBulbWidget;
  98913. }(lifecycle_1.Disposable));
  98914. exports.LightBulbWidget = LightBulbWidget;
  98915. themeService_1.registerThemingParticipant(function (theme, collector) {
  98916. // Lightbulb Icon
  98917. var editorLightBulbForegroundColor = theme.getColor(colorRegistry_1.editorLightBulbForeground);
  98918. if (editorLightBulbForegroundColor) {
  98919. collector.addRule("\n\t\t.monaco-editor .contentWidgets .codicon-lightbulb {\n\t\t\tcolor: " + editorLightBulbForegroundColor + ";\n\t\t}");
  98920. }
  98921. // Lightbulb Auto Fix Icon
  98922. var editorLightBulbAutoFixForegroundColor = theme.getColor(colorRegistry_1.editorLightBulbAutoFixForeground);
  98923. if (editorLightBulbAutoFixForegroundColor) {
  98924. collector.addRule("\n\t\t.monaco-editor .contentWidgets .codicon-lightbulb-autofix {\n\t\t\tcolor: " + editorLightBulbAutoFixForegroundColor + ";\n\t\t}");
  98925. }
  98926. });
  98927. });
  98928. /*---------------------------------------------------------------------------------------------
  98929. * Copyright (c) Microsoft Corporation. All rights reserved.
  98930. * Licensed under the MIT License. See License.txt in the project root for license information.
  98931. *--------------------------------------------------------------------------------------------*/
  98932. define(__m[568/*vs/editor/contrib/codelens/codelensWidget*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,100/*vs/base/common/codicons*/,5/*vs/base/common/strings*/,3/*vs/editor/common/core/range*/,30/*vs/editor/common/model/textModel*/,44/*vs/editor/common/view/editorColorRegistry*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,305/*vs/css!vs/editor/contrib/codelens/codelensWidget*/]), function (require, exports, dom, codicons_1, strings_1, range_1, textModel_1, editorColorRegistry_1, colorRegistry_1, themeService_1) {
  98933. "use strict";
  98934. Object.defineProperty(exports, "__esModule", { value: true });
  98935. var CodeLensViewZone = /** @class */ (function () {
  98936. function CodeLensViewZone(afterLineNumber, onHeight) {
  98937. this.afterLineNumber = afterLineNumber;
  98938. this._onHeight = onHeight;
  98939. this.heightInLines = 1;
  98940. this.suppressMouseDown = true;
  98941. this.domNode = document.createElement('div');
  98942. }
  98943. CodeLensViewZone.prototype.onComputedHeight = function (height) {
  98944. if (this._lastHeight === undefined) {
  98945. this._lastHeight = height;
  98946. }
  98947. else if (this._lastHeight !== height) {
  98948. this._lastHeight = height;
  98949. this._onHeight();
  98950. }
  98951. };
  98952. return CodeLensViewZone;
  98953. }());
  98954. var CodeLensContentWidget = /** @class */ (function () {
  98955. function CodeLensContentWidget(editor, className, line) {
  98956. // Editor.IContentWidget.allowEditorOverflow
  98957. this.allowEditorOverflow = false;
  98958. this.suppressMouseDown = true;
  98959. this._commands = new Map();
  98960. this._isEmpty = true;
  98961. this._editor = editor;
  98962. this._id = "codelens.widget-" + (CodeLensContentWidget._idPool++);
  98963. this.updatePosition(line);
  98964. this._domNode = document.createElement('span');
  98965. this._domNode.className = "codelens-decoration " + className;
  98966. }
  98967. CodeLensContentWidget.prototype.withCommands = function (lenses, animate) {
  98968. this._commands.clear();
  98969. var innerHtml = '';
  98970. var hasSymbol = false;
  98971. for (var i = 0; i < lenses.length; i++) {
  98972. var lens = lenses[i];
  98973. if (!lens) {
  98974. continue;
  98975. }
  98976. hasSymbol = true;
  98977. if (lens.command) {
  98978. var title = codicons_1.renderCodicons(strings_1.escape(lens.command.title));
  98979. if (lens.command.id) {
  98980. innerHtml += "<a id=" + i + ">" + title + "</a>";
  98981. this._commands.set(String(i), lens.command);
  98982. }
  98983. else {
  98984. innerHtml += "<span>" + title + "</span>";
  98985. }
  98986. if (i + 1 < lenses.length) {
  98987. innerHtml += '<span>&#160;|&#160;</span>';
  98988. }
  98989. }
  98990. }
  98991. if (!hasSymbol) {
  98992. // symbols but no commands
  98993. this._domNode.innerHTML = '<span>no commands</span>';
  98994. }
  98995. else {
  98996. // symbols and commands
  98997. if (!innerHtml) {
  98998. innerHtml = '&#160;';
  98999. }
  99000. this._domNode.innerHTML = innerHtml;
  99001. if (this._isEmpty && animate) {
  99002. dom.addClass(this._domNode, 'fadein');
  99003. }
  99004. this._isEmpty = false;
  99005. }
  99006. };
  99007. CodeLensContentWidget.prototype.getCommand = function (link) {
  99008. return link.parentElement === this._domNode
  99009. ? this._commands.get(link.id)
  99010. : undefined;
  99011. };
  99012. CodeLensContentWidget.prototype.getId = function () {
  99013. return this._id;
  99014. };
  99015. CodeLensContentWidget.prototype.getDomNode = function () {
  99016. return this._domNode;
  99017. };
  99018. CodeLensContentWidget.prototype.updatePosition = function (line) {
  99019. var column = this._editor.getModel().getLineFirstNonWhitespaceColumn(line);
  99020. this._widgetPosition = {
  99021. position: { lineNumber: line, column: column },
  99022. preference: [1 /* ABOVE */]
  99023. };
  99024. };
  99025. CodeLensContentWidget.prototype.getPosition = function () {
  99026. return this._widgetPosition || null;
  99027. };
  99028. CodeLensContentWidget._idPool = 0;
  99029. return CodeLensContentWidget;
  99030. }());
  99031. var CodeLensHelper = /** @class */ (function () {
  99032. function CodeLensHelper() {
  99033. this._removeDecorations = [];
  99034. this._addDecorations = [];
  99035. this._addDecorationsCallbacks = [];
  99036. }
  99037. CodeLensHelper.prototype.addDecoration = function (decoration, callback) {
  99038. this._addDecorations.push(decoration);
  99039. this._addDecorationsCallbacks.push(callback);
  99040. };
  99041. CodeLensHelper.prototype.removeDecoration = function (decorationId) {
  99042. this._removeDecorations.push(decorationId);
  99043. };
  99044. CodeLensHelper.prototype.commit = function (changeAccessor) {
  99045. var resultingDecorations = changeAccessor.deltaDecorations(this._removeDecorations, this._addDecorations);
  99046. for (var i = 0, len = resultingDecorations.length; i < len; i++) {
  99047. this._addDecorationsCallbacks[i](resultingDecorations[i]);
  99048. }
  99049. };
  99050. return CodeLensHelper;
  99051. }());
  99052. exports.CodeLensHelper = CodeLensHelper;
  99053. var CodeLensWidget = /** @class */ (function () {
  99054. function CodeLensWidget(data, editor, className, helper, viewZoneChangeAccessor, updateCallback) {
  99055. var _this = this;
  99056. this._isDisposed = false;
  99057. this._editor = editor;
  99058. this._className = className;
  99059. this._data = data;
  99060. // create combined range, track all ranges with decorations,
  99061. // check if there is already something to render
  99062. this._decorationIds = [];
  99063. var range;
  99064. var lenses = [];
  99065. this._data.forEach(function (codeLensData, i) {
  99066. if (codeLensData.symbol.command) {
  99067. lenses.push(codeLensData.symbol);
  99068. }
  99069. helper.addDecoration({
  99070. range: codeLensData.symbol.range,
  99071. options: textModel_1.ModelDecorationOptions.EMPTY
  99072. }, function (id) { return _this._decorationIds[i] = id; });
  99073. // the range contains all lenses on this line
  99074. if (!range) {
  99075. range = range_1.Range.lift(codeLensData.symbol.range);
  99076. }
  99077. else {
  99078. range = range_1.Range.plusRange(range, codeLensData.symbol.range);
  99079. }
  99080. });
  99081. this._viewZone = new CodeLensViewZone(range.startLineNumber - 1, updateCallback);
  99082. this._viewZoneId = viewZoneChangeAccessor.addZone(this._viewZone);
  99083. if (lenses.length > 0) {
  99084. this._createContentWidgetIfNecessary();
  99085. this._contentWidget.withCommands(lenses, false);
  99086. }
  99087. }
  99088. CodeLensWidget.prototype._createContentWidgetIfNecessary = function () {
  99089. if (!this._contentWidget) {
  99090. this._contentWidget = new CodeLensContentWidget(this._editor, this._className, this._viewZone.afterLineNumber + 1);
  99091. this._editor.addContentWidget(this._contentWidget);
  99092. }
  99093. };
  99094. CodeLensWidget.prototype.dispose = function (helper, viewZoneChangeAccessor) {
  99095. this._decorationIds.forEach(helper.removeDecoration, helper);
  99096. this._decorationIds = [];
  99097. if (viewZoneChangeAccessor) {
  99098. viewZoneChangeAccessor.removeZone(this._viewZoneId);
  99099. }
  99100. if (this._contentWidget) {
  99101. this._editor.removeContentWidget(this._contentWidget);
  99102. this._contentWidget = undefined;
  99103. }
  99104. this._isDisposed = true;
  99105. };
  99106. CodeLensWidget.prototype.isDisposed = function () {
  99107. return this._isDisposed;
  99108. };
  99109. CodeLensWidget.prototype.isValid = function () {
  99110. var _this = this;
  99111. return this._decorationIds.some(function (id, i) {
  99112. var range = _this._editor.getModel().getDecorationRange(id);
  99113. var symbol = _this._data[i].symbol;
  99114. return !!(range && range_1.Range.isEmpty(symbol.range) === range.isEmpty());
  99115. });
  99116. };
  99117. CodeLensWidget.prototype.updateCodeLensSymbols = function (data, helper) {
  99118. var _this = this;
  99119. this._decorationIds.forEach(helper.removeDecoration, helper);
  99120. this._decorationIds = [];
  99121. this._data = data;
  99122. this._data.forEach(function (codeLensData, i) {
  99123. helper.addDecoration({
  99124. range: codeLensData.symbol.range,
  99125. options: textModel_1.ModelDecorationOptions.EMPTY
  99126. }, function (id) { return _this._decorationIds[i] = id; });
  99127. });
  99128. };
  99129. CodeLensWidget.prototype.computeIfNecessary = function (model) {
  99130. if (!this._viewZone.domNode.hasAttribute('monaco-visible-view-zone')) {
  99131. return null;
  99132. }
  99133. // Read editor current state
  99134. for (var i = 0; i < this._decorationIds.length; i++) {
  99135. var range = model.getDecorationRange(this._decorationIds[i]);
  99136. if (range) {
  99137. this._data[i].symbol.range = range;
  99138. }
  99139. }
  99140. return this._data;
  99141. };
  99142. CodeLensWidget.prototype.updateCommands = function (symbols) {
  99143. this._createContentWidgetIfNecessary();
  99144. this._contentWidget.withCommands(symbols, true);
  99145. for (var i = 0; i < this._data.length; i++) {
  99146. var resolved = symbols[i];
  99147. if (resolved) {
  99148. var symbol = this._data[i].symbol;
  99149. symbol.command = resolved.command || symbol.command;
  99150. }
  99151. }
  99152. };
  99153. CodeLensWidget.prototype.getCommand = function (link) {
  99154. var _a;
  99155. return (_a = this._contentWidget) === null || _a === void 0 ? void 0 : _a.getCommand(link);
  99156. };
  99157. CodeLensWidget.prototype.getLineNumber = function () {
  99158. var range = this._editor.getModel().getDecorationRange(this._decorationIds[0]);
  99159. if (range) {
  99160. return range.startLineNumber;
  99161. }
  99162. return -1;
  99163. };
  99164. CodeLensWidget.prototype.update = function (viewZoneChangeAccessor) {
  99165. if (this.isValid()) {
  99166. var range = this._editor.getModel().getDecorationRange(this._decorationIds[0]);
  99167. if (range) {
  99168. this._viewZone.afterLineNumber = range.startLineNumber - 1;
  99169. viewZoneChangeAccessor.layoutZone(this._viewZoneId);
  99170. if (this._contentWidget) {
  99171. this._contentWidget.updatePosition(range.startLineNumber);
  99172. this._editor.layoutContentWidget(this._contentWidget);
  99173. }
  99174. }
  99175. }
  99176. };
  99177. return CodeLensWidget;
  99178. }());
  99179. exports.CodeLensWidget = CodeLensWidget;
  99180. themeService_1.registerThemingParticipant(function (theme, collector) {
  99181. var codeLensForeground = theme.getColor(editorColorRegistry_1.editorCodeLensForeground);
  99182. if (codeLensForeground) {
  99183. collector.addRule(".monaco-editor .codelens-decoration { color: " + codeLensForeground + "; }");
  99184. collector.addRule(".monaco-editor .codelens-decoration .codicon { color: " + codeLensForeground + "; }");
  99185. }
  99186. var activeLinkForeground = theme.getColor(colorRegistry_1.editorActiveLinkForeground);
  99187. if (activeLinkForeground) {
  99188. collector.addRule(".monaco-editor .codelens-decoration > a:hover { color: " + activeLinkForeground + " !important; }");
  99189. collector.addRule(".monaco-editor .codelens-decoration > a:hover .codicon { color: " + activeLinkForeground + " !important; }");
  99190. }
  99191. });
  99192. });
  99193. /*---------------------------------------------------------------------------------------------
  99194. * Copyright (c) Microsoft Corporation. All rights reserved.
  99195. * Licensed under the MIT License. See License.txt in the project root for license information.
  99196. *--------------------------------------------------------------------------------------------*/
  99197. var __spreadArrays = (this && this.__spreadArrays) || function () {
  99198. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  99199. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  99200. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  99201. r[k] = a[j];
  99202. return r;
  99203. };
  99204. define(__m[569/*vs/editor/contrib/codelens/codelensController*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,10/*vs/base/common/errors*/,2/*vs/base/common/lifecycle*/,67/*vs/editor/browser/core/editorState*/,12/*vs/editor/browser/editorExtensions*/,17/*vs/editor/common/modes*/,221/*vs/editor/contrib/codelens/codelens*/,568/*vs/editor/contrib/codelens/codelensWidget*/,29/*vs/platform/commands/common/commands*/,35/*vs/platform/notification/common/notification*/,529/*vs/editor/contrib/codelens/codeLensCache*/,6/*vs/base/browser/dom*/,125/*vs/base/common/hash*/]), function (require, exports, async_1, errors_1, lifecycle_1, editorState_1, editorExtensions_1, modes_1, codelens_1, codelensWidget_1, commands_1, notification_1, codeLensCache_1, dom, hash_1) {
  99205. "use strict";
  99206. Object.defineProperty(exports, "__esModule", { value: true });
  99207. var CodeLensContribution = /** @class */ (function () {
  99208. function CodeLensContribution(_editor, _commandService, _notificationService, _codeLensCache) {
  99209. var _this = this;
  99210. this._editor = _editor;
  99211. this._commandService = _commandService;
  99212. this._notificationService = _notificationService;
  99213. this._codeLensCache = _codeLensCache;
  99214. this._globalToDispose = new lifecycle_1.DisposableStore();
  99215. this._localToDispose = new lifecycle_1.DisposableStore();
  99216. this._lenses = [];
  99217. this._oldCodeLensModels = new lifecycle_1.DisposableStore();
  99218. this._modelChangeCounter = 0;
  99219. this._isEnabled = this._editor.getOption(11 /* codeLens */);
  99220. this._globalToDispose.add(this._editor.onDidChangeModel(function () { return _this._onModelChange(); }));
  99221. this._globalToDispose.add(this._editor.onDidChangeModelLanguage(function () { return _this._onModelChange(); }));
  99222. this._globalToDispose.add(this._editor.onDidChangeConfiguration(function () {
  99223. var prevIsEnabled = _this._isEnabled;
  99224. _this._isEnabled = _this._editor.getOption(11 /* codeLens */);
  99225. if (prevIsEnabled !== _this._isEnabled) {
  99226. _this._onModelChange();
  99227. }
  99228. }));
  99229. this._globalToDispose.add(modes_1.CodeLensProviderRegistry.onDidChange(this._onModelChange, this));
  99230. this._globalToDispose.add(this._editor.onDidChangeConfiguration(function (e) {
  99231. if (e.hasChanged(34 /* fontInfo */)) {
  99232. _this._updateLensStyle();
  99233. }
  99234. }));
  99235. this._onModelChange();
  99236. this._styleClassName = hash_1.hash(this._editor.getId()).toString(16);
  99237. this._styleElement = dom.createStyleSheet(dom.isInShadowDOM(this._editor.getContainerDomNode())
  99238. ? this._editor.getContainerDomNode()
  99239. : undefined);
  99240. this._updateLensStyle();
  99241. }
  99242. CodeLensContribution.prototype.dispose = function () {
  99243. this._localDispose();
  99244. this._globalToDispose.dispose();
  99245. this._oldCodeLensModels.dispose();
  99246. lifecycle_1.dispose(this._currentCodeLensModel);
  99247. };
  99248. CodeLensContribution.prototype._updateLensStyle = function () {
  99249. var options = this._editor.getOptions();
  99250. var fontInfo = options.get(34 /* fontInfo */);
  99251. var lineHeight = options.get(49 /* lineHeight */);
  99252. var height = Math.round(lineHeight * 1.1);
  99253. var fontSize = Math.round(fontInfo.fontSize * 0.9);
  99254. var newStyle = "\n\t\t.monaco-editor .codelens-decoration." + this._styleClassName + " { height: " + height + "px; line-height: " + lineHeight + "px; font-size: " + fontSize + "px; padding-right: " + Math.round(fontInfo.fontSize * 0.45) + "px;}\n\t\t.monaco-editor .codelens-decoration." + this._styleClassName + " > a > .codicon { line-height: " + lineHeight + "px; font-size: " + fontSize + "px; }\n\t\t";
  99255. this._styleElement.innerHTML = newStyle;
  99256. };
  99257. CodeLensContribution.prototype._localDispose = function () {
  99258. if (this._currentFindCodeLensSymbolsPromise) {
  99259. this._currentFindCodeLensSymbolsPromise.cancel();
  99260. this._currentFindCodeLensSymbolsPromise = undefined;
  99261. this._modelChangeCounter++;
  99262. }
  99263. if (this._currentResolveCodeLensSymbolsPromise) {
  99264. this._currentResolveCodeLensSymbolsPromise.cancel();
  99265. this._currentResolveCodeLensSymbolsPromise = undefined;
  99266. }
  99267. this._localToDispose.clear();
  99268. this._oldCodeLensModels.clear();
  99269. lifecycle_1.dispose(this._currentCodeLensModel);
  99270. };
  99271. CodeLensContribution.prototype._onModelChange = function () {
  99272. var _this = this;
  99273. this._localDispose();
  99274. var model = this._editor.getModel();
  99275. if (!model) {
  99276. return;
  99277. }
  99278. if (!this._isEnabled) {
  99279. return;
  99280. }
  99281. var cachedLenses = this._codeLensCache.get(model);
  99282. if (cachedLenses) {
  99283. this._renderCodeLensSymbols(cachedLenses);
  99284. }
  99285. if (!modes_1.CodeLensProviderRegistry.has(model)) {
  99286. // no provider -> return but check with
  99287. // cached lenses. they expire after 30 seconds
  99288. if (cachedLenses) {
  99289. this._localToDispose.add(async_1.disposableTimeout(function () {
  99290. var cachedLensesNow = _this._codeLensCache.get(model);
  99291. if (cachedLenses === cachedLensesNow) {
  99292. _this._codeLensCache.delete(model);
  99293. _this._onModelChange();
  99294. }
  99295. }, 30 * 1000));
  99296. }
  99297. return;
  99298. }
  99299. for (var _i = 0, _a = modes_1.CodeLensProviderRegistry.all(model); _i < _a.length; _i++) {
  99300. var provider = _a[_i];
  99301. if (typeof provider.onDidChange === 'function') {
  99302. var registration = provider.onDidChange(function () { return scheduler.schedule(); });
  99303. this._localToDispose.add(registration);
  99304. }
  99305. }
  99306. var detectVisibleLenses = this._detectVisibleLenses = new async_1.RunOnceScheduler(function () { return _this._onViewportChanged(); }, 250);
  99307. var scheduler = new async_1.RunOnceScheduler(function () {
  99308. var counterValue = ++_this._modelChangeCounter;
  99309. if (_this._currentFindCodeLensSymbolsPromise) {
  99310. _this._currentFindCodeLensSymbolsPromise.cancel();
  99311. }
  99312. _this._currentFindCodeLensSymbolsPromise = async_1.createCancelablePromise(function (token) { return codelens_1.getCodeLensData(model, token); });
  99313. _this._currentFindCodeLensSymbolsPromise.then(function (result) {
  99314. if (counterValue === _this._modelChangeCounter) { // only the last one wins
  99315. if (_this._currentCodeLensModel) {
  99316. _this._oldCodeLensModels.add(_this._currentCodeLensModel);
  99317. }
  99318. _this._currentCodeLensModel = result;
  99319. // cache model to reduce flicker
  99320. _this._codeLensCache.put(model, result);
  99321. // render lenses
  99322. _this._renderCodeLensSymbols(result);
  99323. detectVisibleLenses.schedule();
  99324. }
  99325. }, errors_1.onUnexpectedError);
  99326. }, 250);
  99327. this._localToDispose.add(scheduler);
  99328. this._localToDispose.add(detectVisibleLenses);
  99329. this._localToDispose.add(this._editor.onDidChangeModelContent(function () {
  99330. _this._editor.changeDecorations(function (decorationsAccessor) {
  99331. _this._editor.changeViewZones(function (viewZonesAccessor) {
  99332. var toDispose = [];
  99333. var lastLensLineNumber = -1;
  99334. _this._lenses.forEach(function (lens) {
  99335. if (!lens.isValid() || lastLensLineNumber === lens.getLineNumber()) {
  99336. // invalid -> lens collapsed, attach range doesn't exist anymore
  99337. // line_number -> lenses should never be on the same line
  99338. toDispose.push(lens);
  99339. }
  99340. else {
  99341. lens.update(viewZonesAccessor);
  99342. lastLensLineNumber = lens.getLineNumber();
  99343. }
  99344. });
  99345. var helper = new codelensWidget_1.CodeLensHelper();
  99346. toDispose.forEach(function (l) {
  99347. l.dispose(helper, viewZonesAccessor);
  99348. _this._lenses.splice(_this._lenses.indexOf(l), 1);
  99349. });
  99350. helper.commit(decorationsAccessor);
  99351. });
  99352. });
  99353. // Compute new `visible` code lenses
  99354. detectVisibleLenses.schedule();
  99355. // Ask for all references again
  99356. scheduler.schedule();
  99357. }));
  99358. this._localToDispose.add(this._editor.onDidScrollChange(function (e) {
  99359. if (e.scrollTopChanged && _this._lenses.length > 0) {
  99360. detectVisibleLenses.schedule();
  99361. }
  99362. }));
  99363. this._localToDispose.add(this._editor.onDidLayoutChange(function () {
  99364. detectVisibleLenses.schedule();
  99365. }));
  99366. this._localToDispose.add(lifecycle_1.toDisposable(function () {
  99367. if (_this._editor.getModel()) {
  99368. var scrollState = editorState_1.StableEditorScrollState.capture(_this._editor);
  99369. _this._editor.changeDecorations(function (decorationsAccessor) {
  99370. _this._editor.changeViewZones(function (viewZonesAccessor) {
  99371. _this._disposeAllLenses(decorationsAccessor, viewZonesAccessor);
  99372. });
  99373. });
  99374. scrollState.restore(_this._editor);
  99375. }
  99376. else {
  99377. // No accessors available
  99378. _this._disposeAllLenses(undefined, undefined);
  99379. }
  99380. }));
  99381. this._localToDispose.add(this._editor.onMouseUp(function (e) {
  99382. var _a;
  99383. if (e.target.type !== 9 /* CONTENT_WIDGET */) {
  99384. return;
  99385. }
  99386. var target = e.target.element;
  99387. if ((target === null || target === void 0 ? void 0 : target.tagName) === 'SPAN') {
  99388. target = target.parentElement;
  99389. }
  99390. if ((target === null || target === void 0 ? void 0 : target.tagName) === 'A') {
  99391. for (var _i = 0, _b = _this._lenses; _i < _b.length; _i++) {
  99392. var lens = _b[_i];
  99393. var command = lens.getCommand(target);
  99394. if (command) {
  99395. (_a = _this._commandService).executeCommand.apply(_a, __spreadArrays([command.id], (command.arguments || []))).catch(function (err) { return _this._notificationService.error(err); });
  99396. break;
  99397. }
  99398. }
  99399. }
  99400. }));
  99401. scheduler.schedule();
  99402. };
  99403. CodeLensContribution.prototype._disposeAllLenses = function (decChangeAccessor, viewZoneChangeAccessor) {
  99404. var helper = new codelensWidget_1.CodeLensHelper();
  99405. for (var _i = 0, _a = this._lenses; _i < _a.length; _i++) {
  99406. var lens = _a[_i];
  99407. lens.dispose(helper, viewZoneChangeAccessor);
  99408. }
  99409. if (decChangeAccessor) {
  99410. helper.commit(decChangeAccessor);
  99411. }
  99412. this._lenses = [];
  99413. };
  99414. CodeLensContribution.prototype._renderCodeLensSymbols = function (symbols) {
  99415. var _this = this;
  99416. if (!this._editor.hasModel()) {
  99417. return;
  99418. }
  99419. var maxLineNumber = this._editor.getModel().getLineCount();
  99420. var groups = [];
  99421. var lastGroup;
  99422. for (var _i = 0, _a = symbols.lenses; _i < _a.length; _i++) {
  99423. var symbol = _a[_i];
  99424. var line = symbol.symbol.range.startLineNumber;
  99425. if (line < 1 || line > maxLineNumber) {
  99426. // invalid code lens
  99427. continue;
  99428. }
  99429. else if (lastGroup && lastGroup[lastGroup.length - 1].symbol.range.startLineNumber === line) {
  99430. // on same line as previous
  99431. lastGroup.push(symbol);
  99432. }
  99433. else {
  99434. // on later line as previous
  99435. lastGroup = [symbol];
  99436. groups.push(lastGroup);
  99437. }
  99438. }
  99439. var scrollState = editorState_1.StableEditorScrollState.capture(this._editor);
  99440. this._editor.changeDecorations(function (decorationsAccessor) {
  99441. _this._editor.changeViewZones(function (viewZoneAccessor) {
  99442. var helper = new codelensWidget_1.CodeLensHelper();
  99443. var codeLensIndex = 0;
  99444. var groupsIndex = 0;
  99445. while (groupsIndex < groups.length && codeLensIndex < _this._lenses.length) {
  99446. var symbolsLineNumber = groups[groupsIndex][0].symbol.range.startLineNumber;
  99447. var codeLensLineNumber = _this._lenses[codeLensIndex].getLineNumber();
  99448. if (codeLensLineNumber < symbolsLineNumber) {
  99449. _this._lenses[codeLensIndex].dispose(helper, viewZoneAccessor);
  99450. _this._lenses.splice(codeLensIndex, 1);
  99451. }
  99452. else if (codeLensLineNumber === symbolsLineNumber) {
  99453. _this._lenses[codeLensIndex].updateCodeLensSymbols(groups[groupsIndex], helper);
  99454. groupsIndex++;
  99455. codeLensIndex++;
  99456. }
  99457. else {
  99458. _this._lenses.splice(codeLensIndex, 0, new codelensWidget_1.CodeLensWidget(groups[groupsIndex], _this._editor, _this._styleClassName, helper, viewZoneAccessor, function () { return _this._detectVisibleLenses && _this._detectVisibleLenses.schedule(); }));
  99459. codeLensIndex++;
  99460. groupsIndex++;
  99461. }
  99462. }
  99463. // Delete extra code lenses
  99464. while (codeLensIndex < _this._lenses.length) {
  99465. _this._lenses[codeLensIndex].dispose(helper, viewZoneAccessor);
  99466. _this._lenses.splice(codeLensIndex, 1);
  99467. }
  99468. // Create extra symbols
  99469. while (groupsIndex < groups.length) {
  99470. _this._lenses.push(new codelensWidget_1.CodeLensWidget(groups[groupsIndex], _this._editor, _this._styleClassName, helper, viewZoneAccessor, function () { return _this._detectVisibleLenses && _this._detectVisibleLenses.schedule(); }));
  99471. groupsIndex++;
  99472. }
  99473. helper.commit(decorationsAccessor);
  99474. });
  99475. });
  99476. scrollState.restore(this._editor);
  99477. };
  99478. CodeLensContribution.prototype._onViewportChanged = function () {
  99479. var _this = this;
  99480. if (this._currentResolveCodeLensSymbolsPromise) {
  99481. this._currentResolveCodeLensSymbolsPromise.cancel();
  99482. this._currentResolveCodeLensSymbolsPromise = undefined;
  99483. }
  99484. var model = this._editor.getModel();
  99485. if (!model) {
  99486. return;
  99487. }
  99488. var toResolve = [];
  99489. var lenses = [];
  99490. this._lenses.forEach(function (lens) {
  99491. var request = lens.computeIfNecessary(model);
  99492. if (request) {
  99493. toResolve.push(request);
  99494. lenses.push(lens);
  99495. }
  99496. });
  99497. if (toResolve.length === 0) {
  99498. return;
  99499. }
  99500. var resolvePromise = async_1.createCancelablePromise(function (token) {
  99501. var promises = toResolve.map(function (request, i) {
  99502. var resolvedSymbols = new Array(request.length);
  99503. var promises = request.map(function (request, i) {
  99504. if (!request.symbol.command && typeof request.provider.resolveCodeLens === 'function') {
  99505. return Promise.resolve(request.provider.resolveCodeLens(model, request.symbol, token)).then(function (symbol) {
  99506. resolvedSymbols[i] = symbol;
  99507. }, errors_1.onUnexpectedExternalError);
  99508. }
  99509. else {
  99510. resolvedSymbols[i] = request.symbol;
  99511. return Promise.resolve(undefined);
  99512. }
  99513. });
  99514. return Promise.all(promises).then(function () {
  99515. if (!token.isCancellationRequested && !lenses[i].isDisposed()) {
  99516. lenses[i].updateCommands(resolvedSymbols);
  99517. }
  99518. });
  99519. });
  99520. return Promise.all(promises);
  99521. });
  99522. this._currentResolveCodeLensSymbolsPromise = resolvePromise;
  99523. this._currentResolveCodeLensSymbolsPromise.then(function () {
  99524. if (_this._currentCodeLensModel) { // update the cached state with new resolved items
  99525. _this._codeLensCache.put(model, _this._currentCodeLensModel);
  99526. }
  99527. _this._oldCodeLensModels.clear(); // dispose old models once we have updated the UI with the current model
  99528. if (resolvePromise === _this._currentResolveCodeLensSymbolsPromise) {
  99529. _this._currentResolveCodeLensSymbolsPromise = undefined;
  99530. }
  99531. }, function (err) {
  99532. errors_1.onUnexpectedError(err); // can also be cancellation!
  99533. if (resolvePromise === _this._currentResolveCodeLensSymbolsPromise) {
  99534. _this._currentResolveCodeLensSymbolsPromise = undefined;
  99535. }
  99536. });
  99537. };
  99538. CodeLensContribution.ID = 'css.editor.codeLens';
  99539. CodeLensContribution = __decorate([
  99540. __param(1, commands_1.ICommandService),
  99541. __param(2, notification_1.INotificationService),
  99542. __param(3, codeLensCache_1.ICodeLensCache)
  99543. ], CodeLensContribution);
  99544. return CodeLensContribution;
  99545. }());
  99546. exports.CodeLensContribution = CodeLensContribution;
  99547. editorExtensions_1.registerEditorContribution(CodeLensContribution.ID, CodeLensContribution);
  99548. });
  99549. /*---------------------------------------------------------------------------------------------
  99550. * Copyright (c) Microsoft Corporation. All rights reserved.
  99551. * Licensed under the MIT License. See License.txt in the project root for license information.
  99552. *--------------------------------------------------------------------------------------------*/
  99553. define(__m[570/*vs/editor/contrib/colorPicker/colorPickerWidget*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,6/*vs/base/browser/dom*/,78/*vs/base/browser/globalMouseMoveMonitor*/,47/*vs/base/browser/ui/widget*/,27/*vs/base/common/color*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,306/*vs/css!vs/editor/contrib/colorPicker/colorPicker*/]), function (require, exports, browser_1, dom, globalMouseMoveMonitor_1, widget_1, color_1, event_1, lifecycle_1, colorRegistry_1, themeService_1) {
  99554. "use strict";
  99555. Object.defineProperty(exports, "__esModule", { value: true });
  99556. var $ = dom.$;
  99557. var ColorPickerHeader = /** @class */ (function (_super) {
  99558. __extends(ColorPickerHeader, _super);
  99559. function ColorPickerHeader(container, model, themeService) {
  99560. var _this = _super.call(this) || this;
  99561. _this.model = model;
  99562. _this.domNode = $('.colorpicker-header');
  99563. dom.append(container, _this.domNode);
  99564. _this.pickedColorNode = dom.append(_this.domNode, $('.picked-color'));
  99565. var colorBox = dom.append(_this.domNode, $('.original-color'));
  99566. colorBox.style.backgroundColor = color_1.Color.Format.CSS.format(_this.model.originalColor) || '';
  99567. _this.backgroundColor = themeService.getTheme().getColor(colorRegistry_1.editorHoverBackground) || color_1.Color.white;
  99568. _this._register(themeService_1.registerThemingParticipant(function (theme, collector) {
  99569. _this.backgroundColor = theme.getColor(colorRegistry_1.editorHoverBackground) || color_1.Color.white;
  99570. }));
  99571. _this._register(dom.addDisposableListener(_this.pickedColorNode, dom.EventType.CLICK, function () { return _this.model.selectNextColorPresentation(); }));
  99572. _this._register(dom.addDisposableListener(colorBox, dom.EventType.CLICK, function () {
  99573. _this.model.color = _this.model.originalColor;
  99574. _this.model.flushColor();
  99575. }));
  99576. _this._register(model.onDidChangeColor(_this.onDidChangeColor, _this));
  99577. _this._register(model.onDidChangePresentation(_this.onDidChangePresentation, _this));
  99578. _this.pickedColorNode.style.backgroundColor = color_1.Color.Format.CSS.format(model.color) || '';
  99579. dom.toggleClass(_this.pickedColorNode, 'light', model.color.rgba.a < 0.5 ? _this.backgroundColor.isLighter() : model.color.isLighter());
  99580. return _this;
  99581. }
  99582. ColorPickerHeader.prototype.onDidChangeColor = function (color) {
  99583. this.pickedColorNode.style.backgroundColor = color_1.Color.Format.CSS.format(color) || '';
  99584. dom.toggleClass(this.pickedColorNode, 'light', color.rgba.a < 0.5 ? this.backgroundColor.isLighter() : color.isLighter());
  99585. this.onDidChangePresentation();
  99586. };
  99587. ColorPickerHeader.prototype.onDidChangePresentation = function () {
  99588. this.pickedColorNode.textContent = this.model.presentation ? this.model.presentation.label : '';
  99589. };
  99590. return ColorPickerHeader;
  99591. }(lifecycle_1.Disposable));
  99592. exports.ColorPickerHeader = ColorPickerHeader;
  99593. var ColorPickerBody = /** @class */ (function (_super) {
  99594. __extends(ColorPickerBody, _super);
  99595. function ColorPickerBody(container, model, pixelRatio) {
  99596. var _this = _super.call(this) || this;
  99597. _this.model = model;
  99598. _this.pixelRatio = pixelRatio;
  99599. _this.domNode = $('.colorpicker-body');
  99600. dom.append(container, _this.domNode);
  99601. _this.saturationBox = new SaturationBox(_this.domNode, _this.model, _this.pixelRatio);
  99602. _this._register(_this.saturationBox);
  99603. _this._register(_this.saturationBox.onDidChange(_this.onDidSaturationValueChange, _this));
  99604. _this._register(_this.saturationBox.onColorFlushed(_this.flushColor, _this));
  99605. _this.opacityStrip = new OpacityStrip(_this.domNode, _this.model);
  99606. _this._register(_this.opacityStrip);
  99607. _this._register(_this.opacityStrip.onDidChange(_this.onDidOpacityChange, _this));
  99608. _this._register(_this.opacityStrip.onColorFlushed(_this.flushColor, _this));
  99609. _this.hueStrip = new HueStrip(_this.domNode, _this.model);
  99610. _this._register(_this.hueStrip);
  99611. _this._register(_this.hueStrip.onDidChange(_this.onDidHueChange, _this));
  99612. _this._register(_this.hueStrip.onColorFlushed(_this.flushColor, _this));
  99613. return _this;
  99614. }
  99615. ColorPickerBody.prototype.flushColor = function () {
  99616. this.model.flushColor();
  99617. };
  99618. ColorPickerBody.prototype.onDidSaturationValueChange = function (_a) {
  99619. var s = _a.s, v = _a.v;
  99620. var hsva = this.model.color.hsva;
  99621. this.model.color = new color_1.Color(new color_1.HSVA(hsva.h, s, v, hsva.a));
  99622. };
  99623. ColorPickerBody.prototype.onDidOpacityChange = function (a) {
  99624. var hsva = this.model.color.hsva;
  99625. this.model.color = new color_1.Color(new color_1.HSVA(hsva.h, hsva.s, hsva.v, a));
  99626. };
  99627. ColorPickerBody.prototype.onDidHueChange = function (value) {
  99628. var hsva = this.model.color.hsva;
  99629. var h = (1 - value) * 360;
  99630. this.model.color = new color_1.Color(new color_1.HSVA(h === 360 ? 0 : h, hsva.s, hsva.v, hsva.a));
  99631. };
  99632. ColorPickerBody.prototype.layout = function () {
  99633. this.saturationBox.layout();
  99634. this.opacityStrip.layout();
  99635. this.hueStrip.layout();
  99636. };
  99637. return ColorPickerBody;
  99638. }(lifecycle_1.Disposable));
  99639. exports.ColorPickerBody = ColorPickerBody;
  99640. var SaturationBox = /** @class */ (function (_super) {
  99641. __extends(SaturationBox, _super);
  99642. function SaturationBox(container, model, pixelRatio) {
  99643. var _this = _super.call(this) || this;
  99644. _this.model = model;
  99645. _this.pixelRatio = pixelRatio;
  99646. _this._onDidChange = new event_1.Emitter();
  99647. _this.onDidChange = _this._onDidChange.event;
  99648. _this._onColorFlushed = new event_1.Emitter();
  99649. _this.onColorFlushed = _this._onColorFlushed.event;
  99650. _this.domNode = $('.saturation-wrap');
  99651. dom.append(container, _this.domNode);
  99652. // Create canvas, draw selected color
  99653. _this.canvas = document.createElement('canvas');
  99654. _this.canvas.className = 'saturation-box';
  99655. dom.append(_this.domNode, _this.canvas);
  99656. // Add selection circle
  99657. _this.selection = $('.saturation-selection');
  99658. dom.append(_this.domNode, _this.selection);
  99659. _this.layout();
  99660. _this._register(dom.addDisposableGenericMouseDownListner(_this.domNode, function (e) { return _this.onMouseDown(e); }));
  99661. _this._register(_this.model.onDidChangeColor(_this.onDidChangeColor, _this));
  99662. _this.monitor = null;
  99663. return _this;
  99664. }
  99665. SaturationBox.prototype.onMouseDown = function (e) {
  99666. var _this = this;
  99667. this.monitor = this._register(new globalMouseMoveMonitor_1.GlobalMouseMoveMonitor());
  99668. var origin = dom.getDomNodePagePosition(this.domNode);
  99669. if (e.target !== this.selection) {
  99670. this.onDidChangePosition(e.offsetX, e.offsetY);
  99671. }
  99672. this.monitor.startMonitoring(e.target, e.buttons, globalMouseMoveMonitor_1.standardMouseMoveMerger, function (event) { return _this.onDidChangePosition(event.posx - origin.left, event.posy - origin.top); }, function () { return null; });
  99673. var mouseUpListener = dom.addDisposableGenericMouseUpListner(document, function () {
  99674. _this._onColorFlushed.fire();
  99675. mouseUpListener.dispose();
  99676. if (_this.monitor) {
  99677. _this.monitor.stopMonitoring(true);
  99678. _this.monitor = null;
  99679. }
  99680. }, true);
  99681. };
  99682. SaturationBox.prototype.onDidChangePosition = function (left, top) {
  99683. var s = Math.max(0, Math.min(1, left / this.width));
  99684. var v = Math.max(0, Math.min(1, 1 - (top / this.height)));
  99685. this.paintSelection(s, v);
  99686. this._onDidChange.fire({ s: s, v: v });
  99687. };
  99688. SaturationBox.prototype.layout = function () {
  99689. this.width = this.domNode.offsetWidth;
  99690. this.height = this.domNode.offsetHeight;
  99691. this.canvas.width = this.width * this.pixelRatio;
  99692. this.canvas.height = this.height * this.pixelRatio;
  99693. this.paint();
  99694. var hsva = this.model.color.hsva;
  99695. this.paintSelection(hsva.s, hsva.v);
  99696. };
  99697. SaturationBox.prototype.paint = function () {
  99698. var hsva = this.model.color.hsva;
  99699. var saturatedColor = new color_1.Color(new color_1.HSVA(hsva.h, 1, 1, 1));
  99700. var ctx = this.canvas.getContext('2d');
  99701. var whiteGradient = ctx.createLinearGradient(0, 0, this.canvas.width, 0);
  99702. whiteGradient.addColorStop(0, 'rgba(255, 255, 255, 1)');
  99703. whiteGradient.addColorStop(0.5, 'rgba(255, 255, 255, 0.5)');
  99704. whiteGradient.addColorStop(1, 'rgba(255, 255, 255, 0)');
  99705. var blackGradient = ctx.createLinearGradient(0, 0, 0, this.canvas.height);
  99706. blackGradient.addColorStop(0, 'rgba(0, 0, 0, 0)');
  99707. blackGradient.addColorStop(1, 'rgba(0, 0, 0, 1)');
  99708. ctx.rect(0, 0, this.canvas.width, this.canvas.height);
  99709. ctx.fillStyle = color_1.Color.Format.CSS.format(saturatedColor);
  99710. ctx.fill();
  99711. ctx.fillStyle = whiteGradient;
  99712. ctx.fill();
  99713. ctx.fillStyle = blackGradient;
  99714. ctx.fill();
  99715. };
  99716. SaturationBox.prototype.paintSelection = function (s, v) {
  99717. this.selection.style.left = s * this.width + "px";
  99718. this.selection.style.top = this.height - v * this.height + "px";
  99719. };
  99720. SaturationBox.prototype.onDidChangeColor = function () {
  99721. if (this.monitor && this.monitor.isMonitoring()) {
  99722. return;
  99723. }
  99724. this.paint();
  99725. };
  99726. return SaturationBox;
  99727. }(lifecycle_1.Disposable));
  99728. var Strip = /** @class */ (function (_super) {
  99729. __extends(Strip, _super);
  99730. function Strip(container, model) {
  99731. var _this = _super.call(this) || this;
  99732. _this.model = model;
  99733. _this._onDidChange = new event_1.Emitter();
  99734. _this.onDidChange = _this._onDidChange.event;
  99735. _this._onColorFlushed = new event_1.Emitter();
  99736. _this.onColorFlushed = _this._onColorFlushed.event;
  99737. _this.domNode = dom.append(container, $('.strip'));
  99738. _this.overlay = dom.append(_this.domNode, $('.overlay'));
  99739. _this.slider = dom.append(_this.domNode, $('.slider'));
  99740. _this.slider.style.top = "0px";
  99741. _this._register(dom.addDisposableGenericMouseDownListner(_this.domNode, function (e) { return _this.onMouseDown(e); }));
  99742. _this.layout();
  99743. return _this;
  99744. }
  99745. Strip.prototype.layout = function () {
  99746. this.height = this.domNode.offsetHeight - this.slider.offsetHeight;
  99747. var value = this.getValue(this.model.color);
  99748. this.updateSliderPosition(value);
  99749. };
  99750. Strip.prototype.onMouseDown = function (e) {
  99751. var _this = this;
  99752. var monitor = this._register(new globalMouseMoveMonitor_1.GlobalMouseMoveMonitor());
  99753. var origin = dom.getDomNodePagePosition(this.domNode);
  99754. dom.addClass(this.domNode, 'grabbing');
  99755. if (e.target !== this.slider) {
  99756. this.onDidChangeTop(e.offsetY);
  99757. }
  99758. monitor.startMonitoring(e.target, e.buttons, globalMouseMoveMonitor_1.standardMouseMoveMerger, function (event) { return _this.onDidChangeTop(event.posy - origin.top); }, function () { return null; });
  99759. var mouseUpListener = dom.addDisposableGenericMouseUpListner(document, function () {
  99760. _this._onColorFlushed.fire();
  99761. mouseUpListener.dispose();
  99762. monitor.stopMonitoring(true);
  99763. dom.removeClass(_this.domNode, 'grabbing');
  99764. }, true);
  99765. };
  99766. Strip.prototype.onDidChangeTop = function (top) {
  99767. var value = Math.max(0, Math.min(1, 1 - (top / this.height)));
  99768. this.updateSliderPosition(value);
  99769. this._onDidChange.fire(value);
  99770. };
  99771. Strip.prototype.updateSliderPosition = function (value) {
  99772. this.slider.style.top = (1 - value) * this.height + "px";
  99773. };
  99774. return Strip;
  99775. }(lifecycle_1.Disposable));
  99776. var OpacityStrip = /** @class */ (function (_super) {
  99777. __extends(OpacityStrip, _super);
  99778. function OpacityStrip(container, model) {
  99779. var _this = _super.call(this, container, model) || this;
  99780. dom.addClass(_this.domNode, 'opacity-strip');
  99781. _this._register(model.onDidChangeColor(_this.onDidChangeColor, _this));
  99782. _this.onDidChangeColor(_this.model.color);
  99783. return _this;
  99784. }
  99785. OpacityStrip.prototype.onDidChangeColor = function (color) {
  99786. var _a = color.rgba, r = _a.r, g = _a.g, b = _a.b;
  99787. var opaque = new color_1.Color(new color_1.RGBA(r, g, b, 1));
  99788. var transparent = new color_1.Color(new color_1.RGBA(r, g, b, 0));
  99789. this.overlay.style.background = "linear-gradient(to bottom, " + opaque + " 0%, " + transparent + " 100%)";
  99790. };
  99791. OpacityStrip.prototype.getValue = function (color) {
  99792. return color.hsva.a;
  99793. };
  99794. return OpacityStrip;
  99795. }(Strip));
  99796. var HueStrip = /** @class */ (function (_super) {
  99797. __extends(HueStrip, _super);
  99798. function HueStrip(container, model) {
  99799. var _this = _super.call(this, container, model) || this;
  99800. dom.addClass(_this.domNode, 'hue-strip');
  99801. return _this;
  99802. }
  99803. HueStrip.prototype.getValue = function (color) {
  99804. return 1 - (color.hsva.h / 360);
  99805. };
  99806. return HueStrip;
  99807. }(Strip));
  99808. var ColorPickerWidget = /** @class */ (function (_super) {
  99809. __extends(ColorPickerWidget, _super);
  99810. function ColorPickerWidget(container, model, pixelRatio, themeService) {
  99811. var _this = _super.call(this) || this;
  99812. _this.model = model;
  99813. _this.pixelRatio = pixelRatio;
  99814. _this._register(browser_1.onDidChangeZoomLevel(function () { return _this.layout(); }));
  99815. var element = $('.colorpicker-widget');
  99816. container.appendChild(element);
  99817. var header = new ColorPickerHeader(element, _this.model, themeService);
  99818. _this.body = new ColorPickerBody(element, _this.model, _this.pixelRatio);
  99819. _this._register(header);
  99820. _this._register(_this.body);
  99821. return _this;
  99822. }
  99823. ColorPickerWidget.prototype.layout = function () {
  99824. this.body.layout();
  99825. };
  99826. return ColorPickerWidget;
  99827. }(widget_1.Widget));
  99828. exports.ColorPickerWidget = ColorPickerWidget;
  99829. });
  99830. define(__m[231/*vs/editor/contrib/documentSymbols/outlineTree*/], __M([0/*require*/,1/*exports*/,437/*vs/nls!vs/editor/contrib/documentSymbols/outlineTree*/,14/*vs/platform/theme/common/themeService*/,20/*vs/platform/theme/common/colorRegistry*/,308/*vs/css!vs/editor/contrib/documentSymbols/media/outlineTree*/,309/*vs/css!vs/editor/contrib/documentSymbols/media/symbol-icons*/]), function (require, exports, nls_1, themeService_1, colorRegistry_1) {
  99831. "use strict";
  99832. Object.defineProperty(exports, "__esModule", { value: true });
  99833. exports.SYMBOL_ICON_ARRAY_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.arrayForeground', {
  99834. dark: colorRegistry_1.foreground,
  99835. light: colorRegistry_1.foreground,
  99836. hc: colorRegistry_1.foreground
  99837. }, nls_1.localize(0, null));
  99838. exports.SYMBOL_ICON_BOOLEAN_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.booleanForeground', {
  99839. dark: colorRegistry_1.foreground,
  99840. light: colorRegistry_1.foreground,
  99841. hc: colorRegistry_1.foreground
  99842. }, nls_1.localize(1, null));
  99843. exports.SYMBOL_ICON_CLASS_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.classForeground', {
  99844. dark: '#EE9D28',
  99845. light: '#D67E00',
  99846. hc: '#EE9D28'
  99847. }, nls_1.localize(2, null));
  99848. exports.SYMBOL_ICON_COLOR_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.colorForeground', {
  99849. dark: colorRegistry_1.foreground,
  99850. light: colorRegistry_1.foreground,
  99851. hc: colorRegistry_1.foreground
  99852. }, nls_1.localize(3, null));
  99853. exports.SYMBOL_ICON_CONSTANT_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.constantForeground', {
  99854. dark: colorRegistry_1.foreground,
  99855. light: colorRegistry_1.foreground,
  99856. hc: colorRegistry_1.foreground
  99857. }, nls_1.localize(4, null));
  99858. exports.SYMBOL_ICON_CONSTRUCTOR_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.constructorForeground', {
  99859. dark: '#B180D7',
  99860. light: '#652D90',
  99861. hc: '#B180D7'
  99862. }, nls_1.localize(5, null));
  99863. exports.SYMBOL_ICON_ENUMERATOR_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.enumeratorForeground', {
  99864. dark: '#EE9D28',
  99865. light: '#D67E00',
  99866. hc: '#EE9D28'
  99867. }, nls_1.localize(6, null));
  99868. exports.SYMBOL_ICON_ENUMERATOR_MEMBER_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.enumeratorMemberForeground', {
  99869. dark: '#75BEFF',
  99870. light: '#007ACC',
  99871. hc: '#75BEFF'
  99872. }, nls_1.localize(7, null));
  99873. exports.SYMBOL_ICON_EVENT_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.eventForeground', {
  99874. dark: '#EE9D28',
  99875. light: '#D67E00',
  99876. hc: '#EE9D28'
  99877. }, nls_1.localize(8, null));
  99878. exports.SYMBOL_ICON_FIELD_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.fieldForeground', {
  99879. dark: '#75BEFF',
  99880. light: '#007ACC',
  99881. hc: '#75BEFF'
  99882. }, nls_1.localize(9, null));
  99883. exports.SYMBOL_ICON_FILE_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.fileForeground', {
  99884. dark: colorRegistry_1.foreground,
  99885. light: colorRegistry_1.foreground,
  99886. hc: colorRegistry_1.foreground
  99887. }, nls_1.localize(10, null));
  99888. exports.SYMBOL_ICON_FOLDER_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.folderForeground', {
  99889. dark: colorRegistry_1.foreground,
  99890. light: colorRegistry_1.foreground,
  99891. hc: colorRegistry_1.foreground
  99892. }, nls_1.localize(11, null));
  99893. exports.SYMBOL_ICON_FUNCTION_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.functionForeground', {
  99894. dark: '#B180D7',
  99895. light: '#652D90',
  99896. hc: '#B180D7'
  99897. }, nls_1.localize(12, null));
  99898. exports.SYMBOL_ICON_INTERFACE_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.interfaceForeground', {
  99899. dark: '#75BEFF',
  99900. light: '#007ACC',
  99901. hc: '#75BEFF'
  99902. }, nls_1.localize(13, null));
  99903. exports.SYMBOL_ICON_KEY_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.keyForeground', {
  99904. dark: colorRegistry_1.foreground,
  99905. light: colorRegistry_1.foreground,
  99906. hc: colorRegistry_1.foreground
  99907. }, nls_1.localize(14, null));
  99908. exports.SYMBOL_ICON_KEYWORD_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.keywordForeground', {
  99909. dark: colorRegistry_1.foreground,
  99910. light: colorRegistry_1.foreground,
  99911. hc: colorRegistry_1.foreground
  99912. }, nls_1.localize(15, null));
  99913. exports.SYMBOL_ICON_METHOD_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.methodForeground', {
  99914. dark: '#B180D7',
  99915. light: '#652D90',
  99916. hc: '#B180D7'
  99917. }, nls_1.localize(16, null));
  99918. exports.SYMBOL_ICON_MODULE_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.moduleForeground', {
  99919. dark: colorRegistry_1.foreground,
  99920. light: colorRegistry_1.foreground,
  99921. hc: colorRegistry_1.foreground
  99922. }, nls_1.localize(17, null));
  99923. exports.SYMBOL_ICON_NAMESPACE_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.namespaceForeground', {
  99924. dark: colorRegistry_1.foreground,
  99925. light: colorRegistry_1.foreground,
  99926. hc: colorRegistry_1.foreground
  99927. }, nls_1.localize(18, null));
  99928. exports.SYMBOL_ICON_NULL_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.nullForeground', {
  99929. dark: colorRegistry_1.foreground,
  99930. light: colorRegistry_1.foreground,
  99931. hc: colorRegistry_1.foreground
  99932. }, nls_1.localize(19, null));
  99933. exports.SYMBOL_ICON_NUMBER_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.numberForeground', {
  99934. dark: colorRegistry_1.foreground,
  99935. light: colorRegistry_1.foreground,
  99936. hc: colorRegistry_1.foreground
  99937. }, nls_1.localize(20, null));
  99938. exports.SYMBOL_ICON_OBJECT_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.objectForeground', {
  99939. dark: colorRegistry_1.foreground,
  99940. light: colorRegistry_1.foreground,
  99941. hc: colorRegistry_1.foreground
  99942. }, nls_1.localize(21, null));
  99943. exports.SYMBOL_ICON_OPERATOR_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.operatorForeground', {
  99944. dark: colorRegistry_1.foreground,
  99945. light: colorRegistry_1.foreground,
  99946. hc: colorRegistry_1.foreground
  99947. }, nls_1.localize(22, null));
  99948. exports.SYMBOL_ICON_PACKAGE_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.packageForeground', {
  99949. dark: colorRegistry_1.foreground,
  99950. light: colorRegistry_1.foreground,
  99951. hc: colorRegistry_1.foreground
  99952. }, nls_1.localize(23, null));
  99953. exports.SYMBOL_ICON_PROPERTY_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.propertyForeground', {
  99954. dark: colorRegistry_1.foreground,
  99955. light: colorRegistry_1.foreground,
  99956. hc: colorRegistry_1.foreground
  99957. }, nls_1.localize(24, null));
  99958. exports.SYMBOL_ICON_REFERENCE_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.referenceForeground', {
  99959. dark: colorRegistry_1.foreground,
  99960. light: colorRegistry_1.foreground,
  99961. hc: colorRegistry_1.foreground
  99962. }, nls_1.localize(25, null));
  99963. exports.SYMBOL_ICON_SNIPPET_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.snippetForeground', {
  99964. dark: colorRegistry_1.foreground,
  99965. light: colorRegistry_1.foreground,
  99966. hc: colorRegistry_1.foreground
  99967. }, nls_1.localize(26, null));
  99968. exports.SYMBOL_ICON_STRING_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.stringForeground', {
  99969. dark: colorRegistry_1.foreground,
  99970. light: colorRegistry_1.foreground,
  99971. hc: colorRegistry_1.foreground
  99972. }, nls_1.localize(27, null));
  99973. exports.SYMBOL_ICON_STRUCT_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.structForeground', {
  99974. dark: colorRegistry_1.foreground,
  99975. light: colorRegistry_1.foreground,
  99976. hc: colorRegistry_1.foreground
  99977. }, nls_1.localize(28, null));
  99978. exports.SYMBOL_ICON_TEXT_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.textForeground', {
  99979. dark: colorRegistry_1.foreground,
  99980. light: colorRegistry_1.foreground,
  99981. hc: colorRegistry_1.foreground
  99982. }, nls_1.localize(29, null));
  99983. exports.SYMBOL_ICON_TYPEPARAMETER_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.typeParameterForeground', {
  99984. dark: colorRegistry_1.foreground,
  99985. light: colorRegistry_1.foreground,
  99986. hc: colorRegistry_1.foreground
  99987. }, nls_1.localize(30, null));
  99988. exports.SYMBOL_ICON_UNIT_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.unitForeground', {
  99989. dark: colorRegistry_1.foreground,
  99990. light: colorRegistry_1.foreground,
  99991. hc: colorRegistry_1.foreground
  99992. }, nls_1.localize(31, null));
  99993. exports.SYMBOL_ICON_VARIABLE_FOREGROUND = colorRegistry_1.registerColor('symbolIcon.variableForeground', {
  99994. dark: '#75BEFF',
  99995. light: '#007ACC',
  99996. hc: '#75BEFF'
  99997. }, nls_1.localize(32, null));
  99998. themeService_1.registerThemingParticipant(function (theme, collector) {
  99999. var symbolIconArrayColor = theme.getColor(exports.SYMBOL_ICON_ARRAY_FOREGROUND);
  100000. if (symbolIconArrayColor) {
  100001. collector.addRule(".codicon-symbol-array { color: " + symbolIconArrayColor + " !important; }");
  100002. }
  100003. var symbolIconBooleanColor = theme.getColor(exports.SYMBOL_ICON_BOOLEAN_FOREGROUND);
  100004. if (symbolIconBooleanColor) {
  100005. collector.addRule(".codicon-symbol-boolean { color: " + symbolIconBooleanColor + " !important; }");
  100006. }
  100007. var symbolIconClassColor = theme.getColor(exports.SYMBOL_ICON_CLASS_FOREGROUND);
  100008. if (symbolIconClassColor) {
  100009. collector.addRule(".codicon-symbol-class { color: " + symbolIconClassColor + " !important; }");
  100010. }
  100011. var symbolIconMethodColor = theme.getColor(exports.SYMBOL_ICON_METHOD_FOREGROUND);
  100012. if (symbolIconMethodColor) {
  100013. collector.addRule(".codicon-symbol-method { color: " + symbolIconMethodColor + " !important; }");
  100014. }
  100015. var symbolIconColorColor = theme.getColor(exports.SYMBOL_ICON_COLOR_FOREGROUND);
  100016. if (symbolIconColorColor) {
  100017. collector.addRule(".codicon-symbol-color { color: " + symbolIconColorColor + " !important; }");
  100018. }
  100019. var symbolIconConstantColor = theme.getColor(exports.SYMBOL_ICON_CONSTANT_FOREGROUND);
  100020. if (symbolIconConstantColor) {
  100021. collector.addRule(".codicon-symbol-constant { color: " + symbolIconConstantColor + " !important; }");
  100022. }
  100023. var symbolIconConstructorColor = theme.getColor(exports.SYMBOL_ICON_CONSTRUCTOR_FOREGROUND);
  100024. if (symbolIconConstructorColor) {
  100025. collector.addRule(".codicon-symbol-constructor { color: " + symbolIconConstructorColor + " !important; }");
  100026. }
  100027. var symbolIconEnumeratorColor = theme.getColor(exports.SYMBOL_ICON_ENUMERATOR_FOREGROUND);
  100028. if (symbolIconEnumeratorColor) {
  100029. collector.addRule("\n\t\t\t.codicon-symbol-value,.codicon-symbol-enum { color: " + symbolIconEnumeratorColor + " !important; }");
  100030. }
  100031. var symbolIconEnumeratorMemberColor = theme.getColor(exports.SYMBOL_ICON_ENUMERATOR_MEMBER_FOREGROUND);
  100032. if (symbolIconEnumeratorMemberColor) {
  100033. collector.addRule(".codicon-symbol-enum-member { color: " + symbolIconEnumeratorMemberColor + " !important; }");
  100034. }
  100035. var symbolIconEventColor = theme.getColor(exports.SYMBOL_ICON_EVENT_FOREGROUND);
  100036. if (symbolIconEventColor) {
  100037. collector.addRule(".codicon-symbol-event { color: " + symbolIconEventColor + " !important; }");
  100038. }
  100039. var symbolIconFieldColor = theme.getColor(exports.SYMBOL_ICON_FIELD_FOREGROUND);
  100040. if (symbolIconFieldColor) {
  100041. collector.addRule(".codicon-symbol-field { color: " + symbolIconFieldColor + " !important; }");
  100042. }
  100043. var symbolIconFileColor = theme.getColor(exports.SYMBOL_ICON_FILE_FOREGROUND);
  100044. if (symbolIconFileColor) {
  100045. collector.addRule(".codicon-symbol-file { color: " + symbolIconFileColor + " !important; }");
  100046. }
  100047. var symbolIconFolderColor = theme.getColor(exports.SYMBOL_ICON_FOLDER_FOREGROUND);
  100048. if (symbolIconFolderColor) {
  100049. collector.addRule(".codicon-symbol-folder { color: " + symbolIconFolderColor + " !important; }");
  100050. }
  100051. var symbolIconFunctionColor = theme.getColor(exports.SYMBOL_ICON_FUNCTION_FOREGROUND);
  100052. if (symbolIconFunctionColor) {
  100053. collector.addRule(".codicon-symbol-function { color: " + symbolIconFunctionColor + " !important; }");
  100054. }
  100055. var symbolIconInterfaceColor = theme.getColor(exports.SYMBOL_ICON_INTERFACE_FOREGROUND);
  100056. if (symbolIconInterfaceColor) {
  100057. collector.addRule(".codicon-symbol-interface { color: " + symbolIconInterfaceColor + " !important; }");
  100058. }
  100059. var symbolIconKeyColor = theme.getColor(exports.SYMBOL_ICON_KEY_FOREGROUND);
  100060. if (symbolIconKeyColor) {
  100061. collector.addRule(".codicon-symbol-key { color: " + symbolIconKeyColor + " !important; }");
  100062. }
  100063. var symbolIconKeywordColor = theme.getColor(exports.SYMBOL_ICON_KEYWORD_FOREGROUND);
  100064. if (symbolIconKeywordColor) {
  100065. collector.addRule(".codicon-symbol-keyword { color: " + symbolIconKeywordColor + " !important; }");
  100066. }
  100067. var symbolIconModuleColor = theme.getColor(exports.SYMBOL_ICON_MODULE_FOREGROUND);
  100068. if (symbolIconModuleColor) {
  100069. collector.addRule(".codicon-symbol-module { color: " + symbolIconModuleColor + " !important; }");
  100070. }
  100071. var outlineNamespaceColor = theme.getColor(exports.SYMBOL_ICON_NAMESPACE_FOREGROUND);
  100072. if (outlineNamespaceColor) {
  100073. collector.addRule(".codicon-symbol-namespace { color: " + outlineNamespaceColor + " !important; }");
  100074. }
  100075. var symbolIconNullColor = theme.getColor(exports.SYMBOL_ICON_NULL_FOREGROUND);
  100076. if (symbolIconNullColor) {
  100077. collector.addRule(".codicon-symbol-null { color: " + symbolIconNullColor + " !important; }");
  100078. }
  100079. var symbolIconNumberColor = theme.getColor(exports.SYMBOL_ICON_NUMBER_FOREGROUND);
  100080. if (symbolIconNumberColor) {
  100081. collector.addRule(".codicon-symbol-number { color: " + symbolIconNumberColor + " !important; }");
  100082. }
  100083. var symbolIconObjectColor = theme.getColor(exports.SYMBOL_ICON_OBJECT_FOREGROUND);
  100084. if (symbolIconObjectColor) {
  100085. collector.addRule(".codicon-symbol-object { color: " + symbolIconObjectColor + " !important; }");
  100086. }
  100087. var symbolIconOperatorColor = theme.getColor(exports.SYMBOL_ICON_OPERATOR_FOREGROUND);
  100088. if (symbolIconOperatorColor) {
  100089. collector.addRule(".codicon-symbol-operator { color: " + symbolIconOperatorColor + " !important; }");
  100090. }
  100091. var symbolIconPackageColor = theme.getColor(exports.SYMBOL_ICON_PACKAGE_FOREGROUND);
  100092. if (symbolIconPackageColor) {
  100093. collector.addRule(".codicon-symbol-package { color: " + symbolIconPackageColor + " !important; }");
  100094. }
  100095. var symbolIconPropertyColor = theme.getColor(exports.SYMBOL_ICON_PROPERTY_FOREGROUND);
  100096. if (symbolIconPropertyColor) {
  100097. collector.addRule(".codicon-symbol-property { color: " + symbolIconPropertyColor + " !important; }");
  100098. }
  100099. var symbolIconReferenceColor = theme.getColor(exports.SYMBOL_ICON_REFERENCE_FOREGROUND);
  100100. if (symbolIconReferenceColor) {
  100101. collector.addRule(".codicon-symbol-reference { color: " + symbolIconReferenceColor + " !important; }");
  100102. }
  100103. var symbolIconSnippetColor = theme.getColor(exports.SYMBOL_ICON_SNIPPET_FOREGROUND);
  100104. if (symbolIconSnippetColor) {
  100105. collector.addRule(".codicon-symbol-snippet { color: " + symbolIconSnippetColor + " !important; }");
  100106. }
  100107. var symbolIconStringColor = theme.getColor(exports.SYMBOL_ICON_STRING_FOREGROUND);
  100108. if (symbolIconStringColor) {
  100109. collector.addRule(".codicon-symbol-string { color: " + symbolIconStringColor + " !important; }");
  100110. }
  100111. var symbolIconStructColor = theme.getColor(exports.SYMBOL_ICON_STRUCT_FOREGROUND);
  100112. if (symbolIconStructColor) {
  100113. collector.addRule(".codicon-symbol-struct { color: " + symbolIconStructColor + " !important; }");
  100114. }
  100115. var symbolIconTextColor = theme.getColor(exports.SYMBOL_ICON_TEXT_FOREGROUND);
  100116. if (symbolIconTextColor) {
  100117. collector.addRule(".codicon-symbol-text { color: " + symbolIconTextColor + " !important; }");
  100118. }
  100119. var symbolIconTypeParameterColor = theme.getColor(exports.SYMBOL_ICON_TYPEPARAMETER_FOREGROUND);
  100120. if (symbolIconTypeParameterColor) {
  100121. collector.addRule(".codicon-symbol-type-parameter { color: " + symbolIconTypeParameterColor + " !important; }");
  100122. }
  100123. var symbolIconUnitColor = theme.getColor(exports.SYMBOL_ICON_UNIT_FOREGROUND);
  100124. if (symbolIconUnitColor) {
  100125. collector.addRule(".codicon-symbol-unit { color: " + symbolIconUnitColor + " !important; }");
  100126. }
  100127. var symbolIconVariableColor = theme.getColor(exports.SYMBOL_ICON_VARIABLE_FOREGROUND);
  100128. if (symbolIconVariableColor) {
  100129. collector.addRule(".codicon-symbol-variable { color: " + symbolIconVariableColor + " !important; }");
  100130. }
  100131. });
  100132. });
  100133. /*---------------------------------------------------------------------------------------------
  100134. * Copyright (c) Microsoft Corporation. All rights reserved.
  100135. * Licensed under the MIT License. See License.txt in the project root for license information.
  100136. *--------------------------------------------------------------------------------------------*/
  100137. define(__m[571/*vs/editor/contrib/find/findDecorations*/], __M([0/*require*/,1/*exports*/,3/*vs/editor/common/core/range*/,48/*vs/editor/common/model*/,30/*vs/editor/common/model/textModel*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/]), function (require, exports, range_1, model_1, textModel_1, colorRegistry_1, themeService_1) {
  100138. "use strict";
  100139. Object.defineProperty(exports, "__esModule", { value: true });
  100140. var FindDecorations = /** @class */ (function () {
  100141. function FindDecorations(editor) {
  100142. this._editor = editor;
  100143. this._decorations = [];
  100144. this._overviewRulerApproximateDecorations = [];
  100145. this._findScopeDecorationId = null;
  100146. this._rangeHighlightDecorationId = null;
  100147. this._highlightedDecorationId = null;
  100148. this._startPosition = this._editor.getPosition();
  100149. }
  100150. FindDecorations.prototype.dispose = function () {
  100151. this._editor.deltaDecorations(this._allDecorations(), []);
  100152. this._decorations = [];
  100153. this._overviewRulerApproximateDecorations = [];
  100154. this._findScopeDecorationId = null;
  100155. this._rangeHighlightDecorationId = null;
  100156. this._highlightedDecorationId = null;
  100157. };
  100158. FindDecorations.prototype.reset = function () {
  100159. this._decorations = [];
  100160. this._overviewRulerApproximateDecorations = [];
  100161. this._findScopeDecorationId = null;
  100162. this._rangeHighlightDecorationId = null;
  100163. this._highlightedDecorationId = null;
  100164. };
  100165. FindDecorations.prototype.getCount = function () {
  100166. return this._decorations.length;
  100167. };
  100168. FindDecorations.prototype.getFindScope = function () {
  100169. if (this._findScopeDecorationId) {
  100170. return this._editor.getModel().getDecorationRange(this._findScopeDecorationId);
  100171. }
  100172. return null;
  100173. };
  100174. FindDecorations.prototype.getStartPosition = function () {
  100175. return this._startPosition;
  100176. };
  100177. FindDecorations.prototype.setStartPosition = function (newStartPosition) {
  100178. this._startPosition = newStartPosition;
  100179. this.setCurrentFindMatch(null);
  100180. };
  100181. FindDecorations.prototype._getDecorationIndex = function (decorationId) {
  100182. var index = this._decorations.indexOf(decorationId);
  100183. if (index >= 0) {
  100184. return index + 1;
  100185. }
  100186. return 1;
  100187. };
  100188. FindDecorations.prototype.getCurrentMatchesPosition = function (desiredRange) {
  100189. var candidates = this._editor.getModel().getDecorationsInRange(desiredRange);
  100190. for (var _i = 0, candidates_1 = candidates; _i < candidates_1.length; _i++) {
  100191. var candidate = candidates_1[_i];
  100192. var candidateOpts = candidate.options;
  100193. if (candidateOpts === FindDecorations._FIND_MATCH_DECORATION || candidateOpts === FindDecorations._CURRENT_FIND_MATCH_DECORATION) {
  100194. return this._getDecorationIndex(candidate.id);
  100195. }
  100196. }
  100197. return 1;
  100198. };
  100199. FindDecorations.prototype.setCurrentFindMatch = function (nextMatch) {
  100200. var _this = this;
  100201. var newCurrentDecorationId = null;
  100202. var matchPosition = 0;
  100203. if (nextMatch) {
  100204. for (var i = 0, len = this._decorations.length; i < len; i++) {
  100205. var range = this._editor.getModel().getDecorationRange(this._decorations[i]);
  100206. if (nextMatch.equalsRange(range)) {
  100207. newCurrentDecorationId = this._decorations[i];
  100208. matchPosition = (i + 1);
  100209. break;
  100210. }
  100211. }
  100212. }
  100213. if (this._highlightedDecorationId !== null || newCurrentDecorationId !== null) {
  100214. this._editor.changeDecorations(function (changeAccessor) {
  100215. if (_this._highlightedDecorationId !== null) {
  100216. changeAccessor.changeDecorationOptions(_this._highlightedDecorationId, FindDecorations._FIND_MATCH_DECORATION);
  100217. _this._highlightedDecorationId = null;
  100218. }
  100219. if (newCurrentDecorationId !== null) {
  100220. _this._highlightedDecorationId = newCurrentDecorationId;
  100221. changeAccessor.changeDecorationOptions(_this._highlightedDecorationId, FindDecorations._CURRENT_FIND_MATCH_DECORATION);
  100222. }
  100223. if (_this._rangeHighlightDecorationId !== null) {
  100224. changeAccessor.removeDecoration(_this._rangeHighlightDecorationId);
  100225. _this._rangeHighlightDecorationId = null;
  100226. }
  100227. if (newCurrentDecorationId !== null) {
  100228. var rng = _this._editor.getModel().getDecorationRange(newCurrentDecorationId);
  100229. if (rng.startLineNumber !== rng.endLineNumber && rng.endColumn === 1) {
  100230. var lineBeforeEnd = rng.endLineNumber - 1;
  100231. var lineBeforeEndMaxColumn = _this._editor.getModel().getLineMaxColumn(lineBeforeEnd);
  100232. rng = new range_1.Range(rng.startLineNumber, rng.startColumn, lineBeforeEnd, lineBeforeEndMaxColumn);
  100233. }
  100234. _this._rangeHighlightDecorationId = changeAccessor.addDecoration(rng, FindDecorations._RANGE_HIGHLIGHT_DECORATION);
  100235. }
  100236. });
  100237. }
  100238. return matchPosition;
  100239. };
  100240. FindDecorations.prototype.set = function (findMatches, findScope) {
  100241. var _this = this;
  100242. this._editor.changeDecorations(function (accessor) {
  100243. var findMatchesOptions = FindDecorations._FIND_MATCH_DECORATION;
  100244. var newOverviewRulerApproximateDecorations = [];
  100245. if (findMatches.length > 1000) {
  100246. // we go into a mode where the overview ruler gets "approximate" decorations
  100247. // the reason is that the overview ruler paints all the decorations in the file and we don't want to cause freezes
  100248. findMatchesOptions = FindDecorations._FIND_MATCH_NO_OVERVIEW_DECORATION;
  100249. // approximate a distance in lines where matches should be merged
  100250. var lineCount = _this._editor.getModel().getLineCount();
  100251. var height = _this._editor.getLayoutInfo().height;
  100252. var approxPixelsPerLine = height / lineCount;
  100253. var mergeLinesDelta = Math.max(2, Math.ceil(3 / approxPixelsPerLine));
  100254. // merge decorations as much as possible
  100255. var prevStartLineNumber = findMatches[0].range.startLineNumber;
  100256. var prevEndLineNumber = findMatches[0].range.endLineNumber;
  100257. for (var i = 1, len = findMatches.length; i < len; i++) {
  100258. var range = findMatches[i].range;
  100259. if (prevEndLineNumber + mergeLinesDelta >= range.startLineNumber) {
  100260. if (range.endLineNumber > prevEndLineNumber) {
  100261. prevEndLineNumber = range.endLineNumber;
  100262. }
  100263. }
  100264. else {
  100265. newOverviewRulerApproximateDecorations.push({
  100266. range: new range_1.Range(prevStartLineNumber, 1, prevEndLineNumber, 1),
  100267. options: FindDecorations._FIND_MATCH_ONLY_OVERVIEW_DECORATION
  100268. });
  100269. prevStartLineNumber = range.startLineNumber;
  100270. prevEndLineNumber = range.endLineNumber;
  100271. }
  100272. }
  100273. newOverviewRulerApproximateDecorations.push({
  100274. range: new range_1.Range(prevStartLineNumber, 1, prevEndLineNumber, 1),
  100275. options: FindDecorations._FIND_MATCH_ONLY_OVERVIEW_DECORATION
  100276. });
  100277. }
  100278. // Find matches
  100279. var newFindMatchesDecorations = new Array(findMatches.length);
  100280. for (var i = 0, len = findMatches.length; i < len; i++) {
  100281. newFindMatchesDecorations[i] = {
  100282. range: findMatches[i].range,
  100283. options: findMatchesOptions
  100284. };
  100285. }
  100286. _this._decorations = accessor.deltaDecorations(_this._decorations, newFindMatchesDecorations);
  100287. // Overview ruler approximate decorations
  100288. _this._overviewRulerApproximateDecorations = accessor.deltaDecorations(_this._overviewRulerApproximateDecorations, newOverviewRulerApproximateDecorations);
  100289. // Range highlight
  100290. if (_this._rangeHighlightDecorationId) {
  100291. accessor.removeDecoration(_this._rangeHighlightDecorationId);
  100292. _this._rangeHighlightDecorationId = null;
  100293. }
  100294. // Find scope
  100295. if (_this._findScopeDecorationId) {
  100296. accessor.removeDecoration(_this._findScopeDecorationId);
  100297. _this._findScopeDecorationId = null;
  100298. }
  100299. if (findScope) {
  100300. _this._findScopeDecorationId = accessor.addDecoration(findScope, FindDecorations._FIND_SCOPE_DECORATION);
  100301. }
  100302. });
  100303. };
  100304. FindDecorations.prototype.matchBeforePosition = function (position) {
  100305. if (this._decorations.length === 0) {
  100306. return null;
  100307. }
  100308. for (var i = this._decorations.length - 1; i >= 0; i--) {
  100309. var decorationId = this._decorations[i];
  100310. var r = this._editor.getModel().getDecorationRange(decorationId);
  100311. if (!r || r.endLineNumber > position.lineNumber) {
  100312. continue;
  100313. }
  100314. if (r.endLineNumber < position.lineNumber) {
  100315. return r;
  100316. }
  100317. if (r.endColumn > position.column) {
  100318. continue;
  100319. }
  100320. return r;
  100321. }
  100322. return this._editor.getModel().getDecorationRange(this._decorations[this._decorations.length - 1]);
  100323. };
  100324. FindDecorations.prototype.matchAfterPosition = function (position) {
  100325. if (this._decorations.length === 0) {
  100326. return null;
  100327. }
  100328. for (var i = 0, len = this._decorations.length; i < len; i++) {
  100329. var decorationId = this._decorations[i];
  100330. var r = this._editor.getModel().getDecorationRange(decorationId);
  100331. if (!r || r.startLineNumber < position.lineNumber) {
  100332. continue;
  100333. }
  100334. if (r.startLineNumber > position.lineNumber) {
  100335. return r;
  100336. }
  100337. if (r.startColumn < position.column) {
  100338. continue;
  100339. }
  100340. return r;
  100341. }
  100342. return this._editor.getModel().getDecorationRange(this._decorations[0]);
  100343. };
  100344. FindDecorations.prototype._allDecorations = function () {
  100345. var result = [];
  100346. result = result.concat(this._decorations);
  100347. result = result.concat(this._overviewRulerApproximateDecorations);
  100348. if (this._findScopeDecorationId) {
  100349. result.push(this._findScopeDecorationId);
  100350. }
  100351. if (this._rangeHighlightDecorationId) {
  100352. result.push(this._rangeHighlightDecorationId);
  100353. }
  100354. return result;
  100355. };
  100356. FindDecorations._CURRENT_FIND_MATCH_DECORATION = textModel_1.ModelDecorationOptions.register({
  100357. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  100358. zIndex: 13,
  100359. className: 'currentFindMatch',
  100360. showIfCollapsed: true,
  100361. overviewRuler: {
  100362. color: themeService_1.themeColorFromId(colorRegistry_1.overviewRulerFindMatchForeground),
  100363. position: model_1.OverviewRulerLane.Center
  100364. },
  100365. minimap: {
  100366. color: themeService_1.themeColorFromId(colorRegistry_1.minimapFindMatch),
  100367. position: model_1.MinimapPosition.Inline
  100368. }
  100369. });
  100370. FindDecorations._FIND_MATCH_DECORATION = textModel_1.ModelDecorationOptions.register({
  100371. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  100372. className: 'findMatch',
  100373. showIfCollapsed: true,
  100374. overviewRuler: {
  100375. color: themeService_1.themeColorFromId(colorRegistry_1.overviewRulerFindMatchForeground),
  100376. position: model_1.OverviewRulerLane.Center
  100377. },
  100378. minimap: {
  100379. color: themeService_1.themeColorFromId(colorRegistry_1.minimapFindMatch),
  100380. position: model_1.MinimapPosition.Inline
  100381. }
  100382. });
  100383. FindDecorations._FIND_MATCH_NO_OVERVIEW_DECORATION = textModel_1.ModelDecorationOptions.register({
  100384. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  100385. className: 'findMatch',
  100386. showIfCollapsed: true
  100387. });
  100388. FindDecorations._FIND_MATCH_ONLY_OVERVIEW_DECORATION = textModel_1.ModelDecorationOptions.register({
  100389. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  100390. overviewRuler: {
  100391. color: themeService_1.themeColorFromId(colorRegistry_1.overviewRulerFindMatchForeground),
  100392. position: model_1.OverviewRulerLane.Center
  100393. }
  100394. });
  100395. FindDecorations._RANGE_HIGHLIGHT_DECORATION = textModel_1.ModelDecorationOptions.register({
  100396. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  100397. className: 'rangeHighlight',
  100398. isWholeLine: true
  100399. });
  100400. FindDecorations._FIND_SCOPE_DECORATION = textModel_1.ModelDecorationOptions.register({
  100401. className: 'findScope',
  100402. isWholeLine: true
  100403. });
  100404. return FindDecorations;
  100405. }());
  100406. exports.FindDecorations = FindDecorations;
  100407. });
  100408. /*---------------------------------------------------------------------------------------------
  100409. * Copyright (c) Microsoft Corporation. All rights reserved.
  100410. * Licensed under the MIT License. See License.txt in the project root for license information.
  100411. *--------------------------------------------------------------------------------------------*/
  100412. define(__m[168/*vs/editor/contrib/find/findModel*/], __M([0/*require*/,1/*exports*/,15/*vs/base/common/async*/,2/*vs/base/common/lifecycle*/,80/*vs/editor/common/commands/replaceCommand*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,144/*vs/editor/common/model/textModelSearch*/,571/*vs/editor/contrib/find/findDecorations*/,379/*vs/editor/contrib/find/replaceAllCommand*/,380/*vs/editor/contrib/find/replacePattern*/,18/*vs/platform/contextkey/common/contextkey*/]), function (require, exports, async_1, lifecycle_1, replaceCommand_1, position_1, range_1, selection_1, textModelSearch_1, findDecorations_1, replaceAllCommand_1, replacePattern_1, contextkey_1) {
  100413. "use strict";
  100414. Object.defineProperty(exports, "__esModule", { value: true });
  100415. exports.CONTEXT_FIND_WIDGET_VISIBLE = new contextkey_1.RawContextKey('findWidgetVisible', false);
  100416. // Keep ContextKey use of 'Focussed' to not break when clauses
  100417. exports.CONTEXT_FIND_INPUT_FOCUSED = new contextkey_1.RawContextKey('findInputFocussed', false);
  100418. exports.CONTEXT_REPLACE_INPUT_FOCUSED = new contextkey_1.RawContextKey('replaceInputFocussed', false);
  100419. exports.ToggleCaseSensitiveKeybinding = {
  100420. primary: 512 /* Alt */ | 33 /* KEY_C */,
  100421. mac: { primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 33 /* KEY_C */ }
  100422. };
  100423. exports.ToggleWholeWordKeybinding = {
  100424. primary: 512 /* Alt */ | 53 /* KEY_W */,
  100425. mac: { primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 53 /* KEY_W */ }
  100426. };
  100427. exports.ToggleRegexKeybinding = {
  100428. primary: 512 /* Alt */ | 48 /* KEY_R */,
  100429. mac: { primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 48 /* KEY_R */ }
  100430. };
  100431. exports.ToggleSearchScopeKeybinding = {
  100432. primary: 512 /* Alt */ | 42 /* KEY_L */,
  100433. mac: { primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 42 /* KEY_L */ }
  100434. };
  100435. exports.FIND_IDS = {
  100436. StartFindAction: 'actions.find',
  100437. StartFindWithSelection: 'actions.findWithSelection',
  100438. NextMatchFindAction: 'editor.action.nextMatchFindAction',
  100439. PreviousMatchFindAction: 'editor.action.previousMatchFindAction',
  100440. NextSelectionMatchFindAction: 'editor.action.nextSelectionMatchFindAction',
  100441. PreviousSelectionMatchFindAction: 'editor.action.previousSelectionMatchFindAction',
  100442. StartFindReplaceAction: 'editor.action.startFindReplaceAction',
  100443. CloseFindWidgetCommand: 'closeFindWidget',
  100444. ToggleCaseSensitiveCommand: 'toggleFindCaseSensitive',
  100445. ToggleWholeWordCommand: 'toggleFindWholeWord',
  100446. ToggleRegexCommand: 'toggleFindRegex',
  100447. ToggleSearchScopeCommand: 'toggleFindInSelection',
  100448. TogglePreserveCaseCommand: 'togglePreserveCase',
  100449. ReplaceOneAction: 'editor.action.replaceOne',
  100450. ReplaceAllAction: 'editor.action.replaceAll',
  100451. SelectAllMatchesAction: 'editor.action.selectAllMatches'
  100452. };
  100453. exports.MATCHES_LIMIT = 19999;
  100454. var RESEARCH_DELAY = 240;
  100455. var FindModelBoundToEditorModel = /** @class */ (function () {
  100456. function FindModelBoundToEditorModel(editor, state) {
  100457. var _this = this;
  100458. this._toDispose = new lifecycle_1.DisposableStore();
  100459. this._editor = editor;
  100460. this._state = state;
  100461. this._isDisposed = false;
  100462. this._startSearchingTimer = new async_1.TimeoutTimer();
  100463. this._decorations = new findDecorations_1.FindDecorations(editor);
  100464. this._toDispose.add(this._decorations);
  100465. this._updateDecorationsScheduler = new async_1.RunOnceScheduler(function () { return _this.research(false); }, 100);
  100466. this._toDispose.add(this._updateDecorationsScheduler);
  100467. this._toDispose.add(this._editor.onDidChangeCursorPosition(function (e) {
  100468. if (e.reason === 3 /* Explicit */
  100469. || e.reason === 5 /* Undo */
  100470. || e.reason === 6 /* Redo */) {
  100471. _this._decorations.setStartPosition(_this._editor.getPosition());
  100472. }
  100473. }));
  100474. this._ignoreModelContentChanged = false;
  100475. this._toDispose.add(this._editor.onDidChangeModelContent(function (e) {
  100476. if (_this._ignoreModelContentChanged) {
  100477. return;
  100478. }
  100479. if (e.isFlush) {
  100480. // a model.setValue() was called
  100481. _this._decorations.reset();
  100482. }
  100483. _this._decorations.setStartPosition(_this._editor.getPosition());
  100484. _this._updateDecorationsScheduler.schedule();
  100485. }));
  100486. this._toDispose.add(this._state.onFindReplaceStateChange(function (e) { return _this._onStateChanged(e); }));
  100487. this.research(false, this._state.searchScope);
  100488. }
  100489. FindModelBoundToEditorModel.prototype.dispose = function () {
  100490. this._isDisposed = true;
  100491. lifecycle_1.dispose(this._startSearchingTimer);
  100492. this._toDispose.dispose();
  100493. };
  100494. FindModelBoundToEditorModel.prototype._onStateChanged = function (e) {
  100495. var _this = this;
  100496. if (this._isDisposed) {
  100497. // The find model is disposed during a find state changed event
  100498. return;
  100499. }
  100500. if (!this._editor.hasModel()) {
  100501. // The find model will be disposed momentarily
  100502. return;
  100503. }
  100504. if (e.searchString || e.isReplaceRevealed || e.isRegex || e.wholeWord || e.matchCase || e.searchScope) {
  100505. var model = this._editor.getModel();
  100506. if (model.isTooLargeForSyncing()) {
  100507. this._startSearchingTimer.cancel();
  100508. this._startSearchingTimer.setIfNotSet(function () {
  100509. if (e.searchScope) {
  100510. _this.research(e.moveCursor, _this._state.searchScope);
  100511. }
  100512. else {
  100513. _this.research(e.moveCursor);
  100514. }
  100515. }, RESEARCH_DELAY);
  100516. }
  100517. else {
  100518. if (e.searchScope) {
  100519. this.research(e.moveCursor, this._state.searchScope);
  100520. }
  100521. else {
  100522. this.research(e.moveCursor);
  100523. }
  100524. }
  100525. }
  100526. };
  100527. FindModelBoundToEditorModel._getSearchRange = function (model, findScope) {
  100528. // If we have set now or before a find scope, use it for computing the search range
  100529. if (findScope) {
  100530. return findScope;
  100531. }
  100532. return model.getFullModelRange();
  100533. };
  100534. FindModelBoundToEditorModel.prototype.research = function (moveCursor, newFindScope) {
  100535. var findScope = null;
  100536. if (typeof newFindScope !== 'undefined') {
  100537. findScope = newFindScope;
  100538. }
  100539. else {
  100540. findScope = this._decorations.getFindScope();
  100541. }
  100542. if (findScope !== null) {
  100543. if (findScope.startLineNumber !== findScope.endLineNumber) {
  100544. if (findScope.endColumn === 1) {
  100545. findScope = new range_1.Range(findScope.startLineNumber, 1, findScope.endLineNumber - 1, this._editor.getModel().getLineMaxColumn(findScope.endLineNumber - 1));
  100546. }
  100547. else {
  100548. // multiline find scope => expand to line starts / ends
  100549. findScope = new range_1.Range(findScope.startLineNumber, 1, findScope.endLineNumber, this._editor.getModel().getLineMaxColumn(findScope.endLineNumber));
  100550. }
  100551. }
  100552. }
  100553. var findMatches = this._findMatches(findScope, false, exports.MATCHES_LIMIT);
  100554. this._decorations.set(findMatches, findScope);
  100555. this._state.changeMatchInfo(this._decorations.getCurrentMatchesPosition(this._editor.getSelection()), this._decorations.getCount(), undefined);
  100556. if (moveCursor) {
  100557. this._moveToNextMatch(this._decorations.getStartPosition());
  100558. }
  100559. };
  100560. FindModelBoundToEditorModel.prototype._hasMatches = function () {
  100561. return (this._state.matchesCount > 0);
  100562. };
  100563. FindModelBoundToEditorModel.prototype._cannotFind = function () {
  100564. if (!this._hasMatches()) {
  100565. var findScope = this._decorations.getFindScope();
  100566. if (findScope) {
  100567. // Reveal the selection so user is reminded that 'selection find' is on.
  100568. this._editor.revealRangeInCenterIfOutsideViewport(findScope, 0 /* Smooth */);
  100569. }
  100570. return true;
  100571. }
  100572. return false;
  100573. };
  100574. FindModelBoundToEditorModel.prototype._setCurrentFindMatch = function (match) {
  100575. var matchesPosition = this._decorations.setCurrentFindMatch(match);
  100576. this._state.changeMatchInfo(matchesPosition, this._decorations.getCount(), match);
  100577. this._editor.setSelection(match);
  100578. this._editor.revealRangeInCenterIfOutsideViewport(match, 0 /* Smooth */);
  100579. };
  100580. FindModelBoundToEditorModel.prototype._prevSearchPosition = function (before) {
  100581. var isUsingLineStops = this._state.isRegex && (this._state.searchString.indexOf('^') >= 0
  100582. || this._state.searchString.indexOf('$') >= 0);
  100583. var lineNumber = before.lineNumber, column = before.column;
  100584. var model = this._editor.getModel();
  100585. if (isUsingLineStops || column === 1) {
  100586. if (lineNumber === 1) {
  100587. lineNumber = model.getLineCount();
  100588. }
  100589. else {
  100590. lineNumber--;
  100591. }
  100592. column = model.getLineMaxColumn(lineNumber);
  100593. }
  100594. else {
  100595. column--;
  100596. }
  100597. return new position_1.Position(lineNumber, column);
  100598. };
  100599. FindModelBoundToEditorModel.prototype._moveToPrevMatch = function (before, isRecursed) {
  100600. if (isRecursed === void 0) { isRecursed = false; }
  100601. if (this._decorations.getCount() < exports.MATCHES_LIMIT) {
  100602. var prevMatchRange = this._decorations.matchBeforePosition(before);
  100603. if (prevMatchRange && prevMatchRange.isEmpty() && prevMatchRange.getStartPosition().equals(before)) {
  100604. before = this._prevSearchPosition(before);
  100605. prevMatchRange = this._decorations.matchBeforePosition(before);
  100606. }
  100607. if (prevMatchRange) {
  100608. this._setCurrentFindMatch(prevMatchRange);
  100609. }
  100610. return;
  100611. }
  100612. if (this._cannotFind()) {
  100613. return;
  100614. }
  100615. var findScope = this._decorations.getFindScope();
  100616. var searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), findScope);
  100617. // ...(----)...|...
  100618. if (searchRange.getEndPosition().isBefore(before)) {
  100619. before = searchRange.getEndPosition();
  100620. }
  100621. // ...|...(----)...
  100622. if (before.isBefore(searchRange.getStartPosition())) {
  100623. before = searchRange.getEndPosition();
  100624. }
  100625. var lineNumber = before.lineNumber, column = before.column;
  100626. var model = this._editor.getModel();
  100627. var position = new position_1.Position(lineNumber, column);
  100628. var prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(96 /* wordSeparators */) : null, false);
  100629. if (prevMatch && prevMatch.range.isEmpty() && prevMatch.range.getStartPosition().equals(position)) {
  100630. // Looks like we're stuck at this position, unacceptable!
  100631. position = this._prevSearchPosition(position);
  100632. prevMatch = model.findPreviousMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(96 /* wordSeparators */) : null, false);
  100633. }
  100634. if (!prevMatch) {
  100635. // there is precisely one match and selection is on top of it
  100636. return;
  100637. }
  100638. if (!isRecursed && !searchRange.containsRange(prevMatch.range)) {
  100639. return this._moveToPrevMatch(prevMatch.range.getStartPosition(), true);
  100640. }
  100641. this._setCurrentFindMatch(prevMatch.range);
  100642. };
  100643. FindModelBoundToEditorModel.prototype.moveToPrevMatch = function () {
  100644. this._moveToPrevMatch(this._editor.getSelection().getStartPosition());
  100645. };
  100646. FindModelBoundToEditorModel.prototype._nextSearchPosition = function (after) {
  100647. var isUsingLineStops = this._state.isRegex && (this._state.searchString.indexOf('^') >= 0
  100648. || this._state.searchString.indexOf('$') >= 0);
  100649. var lineNumber = after.lineNumber, column = after.column;
  100650. var model = this._editor.getModel();
  100651. if (isUsingLineStops || column === model.getLineMaxColumn(lineNumber)) {
  100652. if (lineNumber === model.getLineCount()) {
  100653. lineNumber = 1;
  100654. }
  100655. else {
  100656. lineNumber++;
  100657. }
  100658. column = 1;
  100659. }
  100660. else {
  100661. column++;
  100662. }
  100663. return new position_1.Position(lineNumber, column);
  100664. };
  100665. FindModelBoundToEditorModel.prototype._moveToNextMatch = function (after) {
  100666. if (this._decorations.getCount() < exports.MATCHES_LIMIT) {
  100667. var nextMatchRange = this._decorations.matchAfterPosition(after);
  100668. if (nextMatchRange && nextMatchRange.isEmpty() && nextMatchRange.getStartPosition().equals(after)) {
  100669. // Looks like we're stuck at this position, unacceptable!
  100670. after = this._nextSearchPosition(after);
  100671. nextMatchRange = this._decorations.matchAfterPosition(after);
  100672. }
  100673. if (nextMatchRange) {
  100674. this._setCurrentFindMatch(nextMatchRange);
  100675. }
  100676. return;
  100677. }
  100678. var nextMatch = this._getNextMatch(after, false, true);
  100679. if (nextMatch) {
  100680. this._setCurrentFindMatch(nextMatch.range);
  100681. }
  100682. };
  100683. FindModelBoundToEditorModel.prototype._getNextMatch = function (after, captureMatches, forceMove, isRecursed) {
  100684. if (isRecursed === void 0) { isRecursed = false; }
  100685. if (this._cannotFind()) {
  100686. return null;
  100687. }
  100688. var findScope = this._decorations.getFindScope();
  100689. var searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), findScope);
  100690. // ...(----)...|...
  100691. if (searchRange.getEndPosition().isBefore(after)) {
  100692. after = searchRange.getStartPosition();
  100693. }
  100694. // ...|...(----)...
  100695. if (after.isBefore(searchRange.getStartPosition())) {
  100696. after = searchRange.getStartPosition();
  100697. }
  100698. var lineNumber = after.lineNumber, column = after.column;
  100699. var model = this._editor.getModel();
  100700. var position = new position_1.Position(lineNumber, column);
  100701. var nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(96 /* wordSeparators */) : null, captureMatches);
  100702. if (forceMove && nextMatch && nextMatch.range.isEmpty() && nextMatch.range.getStartPosition().equals(position)) {
  100703. // Looks like we're stuck at this position, unacceptable!
  100704. position = this._nextSearchPosition(position);
  100705. nextMatch = model.findNextMatch(this._state.searchString, position, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(96 /* wordSeparators */) : null, captureMatches);
  100706. }
  100707. if (!nextMatch) {
  100708. // there is precisely one match and selection is on top of it
  100709. return null;
  100710. }
  100711. if (!isRecursed && !searchRange.containsRange(nextMatch.range)) {
  100712. return this._getNextMatch(nextMatch.range.getEndPosition(), captureMatches, forceMove, true);
  100713. }
  100714. return nextMatch;
  100715. };
  100716. FindModelBoundToEditorModel.prototype.moveToNextMatch = function () {
  100717. this._moveToNextMatch(this._editor.getSelection().getEndPosition());
  100718. };
  100719. FindModelBoundToEditorModel.prototype._getReplacePattern = function () {
  100720. if (this._state.isRegex) {
  100721. return replacePattern_1.parseReplaceString(this._state.replaceString);
  100722. }
  100723. return replacePattern_1.ReplacePattern.fromStaticValue(this._state.replaceString);
  100724. };
  100725. FindModelBoundToEditorModel.prototype.replace = function () {
  100726. if (!this._hasMatches()) {
  100727. return;
  100728. }
  100729. var replacePattern = this._getReplacePattern();
  100730. var selection = this._editor.getSelection();
  100731. var nextMatch = this._getNextMatch(selection.getStartPosition(), true, false);
  100732. if (nextMatch) {
  100733. if (selection.equalsRange(nextMatch.range)) {
  100734. // selection sits on a find match => replace it!
  100735. var replaceString = replacePattern.buildReplaceString(nextMatch.matches, this._state.preserveCase);
  100736. var command = new replaceCommand_1.ReplaceCommand(selection, replaceString);
  100737. this._executeEditorCommand('replace', command);
  100738. this._decorations.setStartPosition(new position_1.Position(selection.startLineNumber, selection.startColumn + replaceString.length));
  100739. this.research(true);
  100740. }
  100741. else {
  100742. this._decorations.setStartPosition(this._editor.getPosition());
  100743. this._setCurrentFindMatch(nextMatch.range);
  100744. }
  100745. }
  100746. };
  100747. FindModelBoundToEditorModel.prototype._findMatches = function (findScope, captureMatches, limitResultCount) {
  100748. var searchRange = FindModelBoundToEditorModel._getSearchRange(this._editor.getModel(), findScope);
  100749. return this._editor.getModel().findMatches(this._state.searchString, searchRange, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(96 /* wordSeparators */) : null, captureMatches, limitResultCount);
  100750. };
  100751. FindModelBoundToEditorModel.prototype.replaceAll = function () {
  100752. if (!this._hasMatches()) {
  100753. return;
  100754. }
  100755. var findScope = this._decorations.getFindScope();
  100756. if (findScope === null && this._state.matchesCount >= exports.MATCHES_LIMIT) {
  100757. // Doing a replace on the entire file that is over ${MATCHES_LIMIT} matches
  100758. this._largeReplaceAll();
  100759. }
  100760. else {
  100761. this._regularReplaceAll(findScope);
  100762. }
  100763. this.research(false);
  100764. };
  100765. FindModelBoundToEditorModel.prototype._largeReplaceAll = function () {
  100766. var searchParams = new textModelSearch_1.SearchParams(this._state.searchString, this._state.isRegex, this._state.matchCase, this._state.wholeWord ? this._editor.getOption(96 /* wordSeparators */) : null);
  100767. var searchData = searchParams.parseSearchRequest();
  100768. if (!searchData) {
  100769. return;
  100770. }
  100771. var searchRegex = searchData.regex;
  100772. if (!searchRegex.multiline) {
  100773. var mod = 'mu';
  100774. if (searchRegex.ignoreCase) {
  100775. mod += 'i';
  100776. }
  100777. if (searchRegex.global) {
  100778. mod += 'g';
  100779. }
  100780. searchRegex = new RegExp(searchRegex.source, mod);
  100781. }
  100782. var model = this._editor.getModel();
  100783. var modelText = model.getValue(1 /* LF */);
  100784. var fullModelRange = model.getFullModelRange();
  100785. var replacePattern = this._getReplacePattern();
  100786. var resultText;
  100787. var preserveCase = this._state.preserveCase;
  100788. if (replacePattern.hasReplacementPatterns || preserveCase) {
  100789. resultText = modelText.replace(searchRegex, function () {
  100790. return replacePattern.buildReplaceString(arguments, preserveCase);
  100791. });
  100792. }
  100793. else {
  100794. resultText = modelText.replace(searchRegex, replacePattern.buildReplaceString(null, preserveCase));
  100795. }
  100796. var command = new replaceCommand_1.ReplaceCommandThatPreservesSelection(fullModelRange, resultText, this._editor.getSelection());
  100797. this._executeEditorCommand('replaceAll', command);
  100798. };
  100799. FindModelBoundToEditorModel.prototype._regularReplaceAll = function (findScope) {
  100800. var replacePattern = this._getReplacePattern();
  100801. // Get all the ranges (even more than the highlighted ones)
  100802. var matches = this._findMatches(findScope, replacePattern.hasReplacementPatterns || this._state.preserveCase, 1073741824 /* MAX_SAFE_SMALL_INTEGER */);
  100803. var replaceStrings = [];
  100804. for (var i = 0, len = matches.length; i < len; i++) {
  100805. replaceStrings[i] = replacePattern.buildReplaceString(matches[i].matches, this._state.preserveCase);
  100806. }
  100807. var command = new replaceAllCommand_1.ReplaceAllCommand(this._editor.getSelection(), matches.map(function (m) { return m.range; }), replaceStrings);
  100808. this._executeEditorCommand('replaceAll', command);
  100809. };
  100810. FindModelBoundToEditorModel.prototype.selectAllMatches = function () {
  100811. if (!this._hasMatches()) {
  100812. return;
  100813. }
  100814. var findScope = this._decorations.getFindScope();
  100815. // Get all the ranges (even more than the highlighted ones)
  100816. var matches = this._findMatches(findScope, false, 1073741824 /* MAX_SAFE_SMALL_INTEGER */);
  100817. var selections = matches.map(function (m) { return new selection_1.Selection(m.range.startLineNumber, m.range.startColumn, m.range.endLineNumber, m.range.endColumn); });
  100818. // If one of the ranges is the editor selection, then maintain it as primary
  100819. var editorSelection = this._editor.getSelection();
  100820. for (var i = 0, len = selections.length; i < len; i++) {
  100821. var sel = selections[i];
  100822. if (sel.equalsRange(editorSelection)) {
  100823. selections = [editorSelection].concat(selections.slice(0, i)).concat(selections.slice(i + 1));
  100824. break;
  100825. }
  100826. }
  100827. this._editor.setSelections(selections);
  100828. };
  100829. FindModelBoundToEditorModel.prototype._executeEditorCommand = function (source, command) {
  100830. try {
  100831. this._ignoreModelContentChanged = true;
  100832. this._editor.pushUndoStop();
  100833. this._editor.executeCommand(source, command);
  100834. this._editor.pushUndoStop();
  100835. }
  100836. finally {
  100837. this._ignoreModelContentChanged = false;
  100838. }
  100839. };
  100840. return FindModelBoundToEditorModel;
  100841. }());
  100842. exports.FindModelBoundToEditorModel = FindModelBoundToEditorModel;
  100843. });
  100844. /*---------------------------------------------------------------------------------------------
  100845. * Copyright (c) Microsoft Corporation. All rights reserved.
  100846. * Licensed under the MIT License. See License.txt in the project root for license information.
  100847. *--------------------------------------------------------------------------------------------*/
  100848. define(__m[572/*vs/editor/contrib/find/findOptionsWidget*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,204/*vs/base/browser/ui/findinput/findInputCheckboxes*/,47/*vs/base/browser/ui/widget*/,15/*vs/base/common/async*/,168/*vs/editor/contrib/find/findModel*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/]), function (require, exports, dom, findInputCheckboxes_1, widget_1, async_1, findModel_1, colorRegistry_1, themeService_1) {
  100849. "use strict";
  100850. Object.defineProperty(exports, "__esModule", { value: true });
  100851. var FindOptionsWidget = /** @class */ (function (_super) {
  100852. __extends(FindOptionsWidget, _super);
  100853. function FindOptionsWidget(editor, state, keybindingService, themeService) {
  100854. var _this = _super.call(this) || this;
  100855. _this._hideSoon = _this._register(new async_1.RunOnceScheduler(function () { return _this._hide(); }, 2000));
  100856. _this._isVisible = false;
  100857. _this._editor = editor;
  100858. _this._state = state;
  100859. _this._keybindingService = keybindingService;
  100860. _this._domNode = document.createElement('div');
  100861. _this._domNode.className = 'findOptionsWidget';
  100862. _this._domNode.style.display = 'none';
  100863. _this._domNode.style.top = '10px';
  100864. _this._domNode.setAttribute('role', 'presentation');
  100865. _this._domNode.setAttribute('aria-hidden', 'true');
  100866. var inputActiveOptionBorderColor = themeService.getTheme().getColor(colorRegistry_1.inputActiveOptionBorder);
  100867. var inputActiveOptionBackgroundColor = themeService.getTheme().getColor(colorRegistry_1.inputActiveOptionBackground);
  100868. _this.caseSensitive = _this._register(new findInputCheckboxes_1.CaseSensitiveCheckbox({
  100869. appendTitle: _this._keybindingLabelFor(findModel_1.FIND_IDS.ToggleCaseSensitiveCommand),
  100870. isChecked: _this._state.matchCase,
  100871. inputActiveOptionBorder: inputActiveOptionBorderColor,
  100872. inputActiveOptionBackground: inputActiveOptionBackgroundColor
  100873. }));
  100874. _this._domNode.appendChild(_this.caseSensitive.domNode);
  100875. _this._register(_this.caseSensitive.onChange(function () {
  100876. _this._state.change({
  100877. matchCase: _this.caseSensitive.checked
  100878. }, false);
  100879. }));
  100880. _this.wholeWords = _this._register(new findInputCheckboxes_1.WholeWordsCheckbox({
  100881. appendTitle: _this._keybindingLabelFor(findModel_1.FIND_IDS.ToggleWholeWordCommand),
  100882. isChecked: _this._state.wholeWord,
  100883. inputActiveOptionBorder: inputActiveOptionBorderColor,
  100884. inputActiveOptionBackground: inputActiveOptionBackgroundColor
  100885. }));
  100886. _this._domNode.appendChild(_this.wholeWords.domNode);
  100887. _this._register(_this.wholeWords.onChange(function () {
  100888. _this._state.change({
  100889. wholeWord: _this.wholeWords.checked
  100890. }, false);
  100891. }));
  100892. _this.regex = _this._register(new findInputCheckboxes_1.RegexCheckbox({
  100893. appendTitle: _this._keybindingLabelFor(findModel_1.FIND_IDS.ToggleRegexCommand),
  100894. isChecked: _this._state.isRegex,
  100895. inputActiveOptionBorder: inputActiveOptionBorderColor,
  100896. inputActiveOptionBackground: inputActiveOptionBackgroundColor
  100897. }));
  100898. _this._domNode.appendChild(_this.regex.domNode);
  100899. _this._register(_this.regex.onChange(function () {
  100900. _this._state.change({
  100901. isRegex: _this.regex.checked
  100902. }, false);
  100903. }));
  100904. _this._editor.addOverlayWidget(_this);
  100905. _this._register(_this._state.onFindReplaceStateChange(function (e) {
  100906. var somethingChanged = false;
  100907. if (e.isRegex) {
  100908. _this.regex.checked = _this._state.isRegex;
  100909. somethingChanged = true;
  100910. }
  100911. if (e.wholeWord) {
  100912. _this.wholeWords.checked = _this._state.wholeWord;
  100913. somethingChanged = true;
  100914. }
  100915. if (e.matchCase) {
  100916. _this.caseSensitive.checked = _this._state.matchCase;
  100917. somethingChanged = true;
  100918. }
  100919. if (!_this._state.isRevealed && somethingChanged) {
  100920. _this._revealTemporarily();
  100921. }
  100922. }));
  100923. _this._register(dom.addDisposableNonBubblingMouseOutListener(_this._domNode, function (e) { return _this._onMouseOut(); }));
  100924. _this._register(dom.addDisposableListener(_this._domNode, 'mouseover', function (e) { return _this._onMouseOver(); }));
  100925. _this._applyTheme(themeService.getTheme());
  100926. _this._register(themeService.onThemeChange(_this._applyTheme.bind(_this)));
  100927. return _this;
  100928. }
  100929. FindOptionsWidget.prototype._keybindingLabelFor = function (actionId) {
  100930. var kb = this._keybindingService.lookupKeybinding(actionId);
  100931. if (!kb) {
  100932. return '';
  100933. }
  100934. return " (" + kb.getLabel() + ")";
  100935. };
  100936. FindOptionsWidget.prototype.dispose = function () {
  100937. this._editor.removeOverlayWidget(this);
  100938. _super.prototype.dispose.call(this);
  100939. };
  100940. // ----- IOverlayWidget API
  100941. FindOptionsWidget.prototype.getId = function () {
  100942. return FindOptionsWidget.ID;
  100943. };
  100944. FindOptionsWidget.prototype.getDomNode = function () {
  100945. return this._domNode;
  100946. };
  100947. FindOptionsWidget.prototype.getPosition = function () {
  100948. return {
  100949. preference: 0 /* TOP_RIGHT_CORNER */
  100950. };
  100951. };
  100952. FindOptionsWidget.prototype.highlightFindOptions = function () {
  100953. this._revealTemporarily();
  100954. };
  100955. FindOptionsWidget.prototype._revealTemporarily = function () {
  100956. this._show();
  100957. this._hideSoon.schedule();
  100958. };
  100959. FindOptionsWidget.prototype._onMouseOut = function () {
  100960. this._hideSoon.schedule();
  100961. };
  100962. FindOptionsWidget.prototype._onMouseOver = function () {
  100963. this._hideSoon.cancel();
  100964. };
  100965. FindOptionsWidget.prototype._show = function () {
  100966. if (this._isVisible) {
  100967. return;
  100968. }
  100969. this._isVisible = true;
  100970. this._domNode.style.display = 'block';
  100971. };
  100972. FindOptionsWidget.prototype._hide = function () {
  100973. if (!this._isVisible) {
  100974. return;
  100975. }
  100976. this._isVisible = false;
  100977. this._domNode.style.display = 'none';
  100978. };
  100979. FindOptionsWidget.prototype._applyTheme = function (theme) {
  100980. var inputStyles = {
  100981. inputActiveOptionBorder: theme.getColor(colorRegistry_1.inputActiveOptionBorder),
  100982. inputActiveOptionBackground: theme.getColor(colorRegistry_1.inputActiveOptionBackground)
  100983. };
  100984. this.caseSensitive.style(inputStyles);
  100985. this.wholeWords.style(inputStyles);
  100986. this.regex.style(inputStyles);
  100987. };
  100988. FindOptionsWidget.ID = 'editor.contrib.findOptionsWidget';
  100989. return FindOptionsWidget;
  100990. }(widget_1.Widget));
  100991. exports.FindOptionsWidget = FindOptionsWidget;
  100992. themeService_1.registerThemingParticipant(function (theme, collector) {
  100993. var widgetBackground = theme.getColor(colorRegistry_1.editorWidgetBackground);
  100994. if (widgetBackground) {
  100995. collector.addRule(".monaco-editor .findOptionsWidget { background-color: " + widgetBackground + "; }");
  100996. }
  100997. var widgetForeground = theme.getColor(colorRegistry_1.editorWidgetForeground);
  100998. if (widgetForeground) {
  100999. collector.addRule(".monaco-editor .findOptionsWidget { color: " + widgetForeground + "; }");
  101000. }
  101001. var widgetShadowColor = theme.getColor(colorRegistry_1.widgetShadow);
  101002. if (widgetShadowColor) {
  101003. collector.addRule(".monaco-editor .findOptionsWidget { box-shadow: 0 2px 8px " + widgetShadowColor + "; }");
  101004. }
  101005. var hcBorder = theme.getColor(colorRegistry_1.contrastBorder);
  101006. if (hcBorder) {
  101007. collector.addRule(".monaco-editor .findOptionsWidget { border: 2px solid " + hcBorder + "; }");
  101008. }
  101009. });
  101010. });
  101011. /*---------------------------------------------------------------------------------------------
  101012. * Copyright (c) Microsoft Corporation. All rights reserved.
  101013. * Licensed under the MIT License. See License.txt in the project root for license information.
  101014. *--------------------------------------------------------------------------------------------*/
  101015. define(__m[573/*vs/editor/contrib/find/findWidget*/], __M([0/*require*/,1/*exports*/,439/*vs/nls!vs/editor/contrib/find/findWidget*/,6/*vs/base/browser/dom*/,50/*vs/base/browser/ui/aria/aria*/,138/*vs/base/browser/ui/checkbox/checkbox*/,104/*vs/base/browser/ui/sash/sash*/,47/*vs/base/browser/ui/widget*/,15/*vs/base/common/async*/,10/*vs/base/common/errors*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,5/*vs/base/common/strings*/,3/*vs/editor/common/core/range*/,168/*vs/editor/contrib/find/findModel*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,520/*vs/platform/browser/contextScopedHistoryWidget*/,310/*vs/css!vs/editor/contrib/find/findWidget*/]), function (require, exports, nls, dom, aria_1, checkbox_1, sash_1, widget_1, async_1, errors_1, lifecycle_1, platform, strings, range_1, findModel_1, colorRegistry_1, themeService_1, contextScopedHistoryWidget_1) {
  101016. "use strict";
  101017. Object.defineProperty(exports, "__esModule", { value: true });
  101018. var NLS_FIND_INPUT_LABEL = nls.localize(0, null);
  101019. var NLS_FIND_INPUT_PLACEHOLDER = nls.localize(1, null);
  101020. var NLS_PREVIOUS_MATCH_BTN_LABEL = nls.localize(2, null);
  101021. var NLS_NEXT_MATCH_BTN_LABEL = nls.localize(3, null);
  101022. var NLS_TOGGLE_SELECTION_FIND_TITLE = nls.localize(4, null);
  101023. var NLS_CLOSE_BTN_LABEL = nls.localize(5, null);
  101024. var NLS_REPLACE_INPUT_LABEL = nls.localize(6, null);
  101025. var NLS_REPLACE_INPUT_PLACEHOLDER = nls.localize(7, null);
  101026. var NLS_REPLACE_BTN_LABEL = nls.localize(8, null);
  101027. var NLS_REPLACE_ALL_BTN_LABEL = nls.localize(9, null);
  101028. var NLS_TOGGLE_REPLACE_MODE_BTN_LABEL = nls.localize(10, null);
  101029. var NLS_MATCHES_COUNT_LIMIT_TITLE = nls.localize(11, null, findModel_1.MATCHES_LIMIT);
  101030. var NLS_MATCHES_LOCATION = nls.localize(12, null);
  101031. var NLS_NO_RESULTS = nls.localize(13, null);
  101032. var FIND_WIDGET_INITIAL_WIDTH = 419;
  101033. var PART_WIDTH = 275;
  101034. var FIND_INPUT_AREA_WIDTH = PART_WIDTH - 54;
  101035. var MAX_MATCHES_COUNT_WIDTH = 69;
  101036. // let FIND_ALL_CONTROLS_WIDTH = 17/** Find Input margin-left */ + (MAX_MATCHES_COUNT_WIDTH + 3 + 1) /** Match Results */ + 23 /** Button */ * 4 + 2/** sash */;
  101037. var FIND_INPUT_AREA_HEIGHT = 33; // The height of Find Widget when Replace Input is not visible.
  101038. var ctrlEnterReplaceAllWarningPromptedKey = 'ctrlEnterReplaceAll.windows.donotask';
  101039. var ctrlKeyMod = (platform.isMacintosh ? 256 /* WinCtrl */ : 2048 /* CtrlCmd */);
  101040. var FindWidgetViewZone = /** @class */ (function () {
  101041. function FindWidgetViewZone(afterLineNumber) {
  101042. this.afterLineNumber = afterLineNumber;
  101043. this.heightInPx = FIND_INPUT_AREA_HEIGHT;
  101044. this.suppressMouseDown = false;
  101045. this.domNode = document.createElement('div');
  101046. this.domNode.className = 'dock-find-viewzone';
  101047. }
  101048. return FindWidgetViewZone;
  101049. }());
  101050. exports.FindWidgetViewZone = FindWidgetViewZone;
  101051. function stopPropagationForMultiLineUpwards(event, value, textarea) {
  101052. var isMultiline = !!value.match(/\n/);
  101053. if (textarea && isMultiline && textarea.selectionStart > 0) {
  101054. event.stopPropagation();
  101055. return;
  101056. }
  101057. }
  101058. function stopPropagationForMultiLineDownwards(event, value, textarea) {
  101059. var isMultiline = !!value.match(/\n/);
  101060. if (textarea && isMultiline && textarea.selectionEnd < textarea.value.length) {
  101061. event.stopPropagation();
  101062. return;
  101063. }
  101064. }
  101065. var FindWidget = /** @class */ (function (_super) {
  101066. __extends(FindWidget, _super);
  101067. function FindWidget(codeEditor, controller, state, contextViewProvider, keybindingService, contextKeyService, themeService, storageService, notificationService) {
  101068. var _this = _super.call(this) || this;
  101069. _this._cachedHeight = null;
  101070. _this._codeEditor = codeEditor;
  101071. _this._controller = controller;
  101072. _this._state = state;
  101073. _this._contextViewProvider = contextViewProvider;
  101074. _this._keybindingService = keybindingService;
  101075. _this._contextKeyService = contextKeyService;
  101076. _this._storageService = storageService;
  101077. _this._notificationService = notificationService;
  101078. _this._ctrlEnterReplaceAllWarningPrompted = !!storageService.getBoolean(ctrlEnterReplaceAllWarningPromptedKey, 0 /* GLOBAL */);
  101079. _this._isVisible = false;
  101080. _this._isReplaceVisible = false;
  101081. _this._ignoreChangeEvent = false;
  101082. _this._updateHistoryDelayer = new async_1.Delayer(500);
  101083. _this._register(lifecycle_1.toDisposable(function () { return _this._updateHistoryDelayer.cancel(); }));
  101084. _this._register(_this._state.onFindReplaceStateChange(function (e) { return _this._onStateChanged(e); }));
  101085. _this._buildDomNode();
  101086. _this._updateButtons();
  101087. _this._tryUpdateWidgetWidth();
  101088. _this._findInput.inputBox.layout();
  101089. _this._register(_this._codeEditor.onDidChangeConfiguration(function (e) {
  101090. if (e.hasChanged(68 /* readOnly */)) {
  101091. if (_this._codeEditor.getOption(68 /* readOnly */)) {
  101092. // Hide replace part if editor becomes read only
  101093. _this._state.change({ isReplaceRevealed: false }, false);
  101094. }
  101095. _this._updateButtons();
  101096. }
  101097. if (e.hasChanged(107 /* layoutInfo */)) {
  101098. _this._tryUpdateWidgetWidth();
  101099. }
  101100. if (e.hasChanged(2 /* accessibilitySupport */)) {
  101101. _this.updateAccessibilitySupport();
  101102. }
  101103. if (e.hasChanged(28 /* find */)) {
  101104. var addExtraSpaceOnTop = _this._codeEditor.getOption(28 /* find */).addExtraSpaceOnTop;
  101105. if (addExtraSpaceOnTop && !_this._viewZone) {
  101106. _this._viewZone = new FindWidgetViewZone(0);
  101107. _this._showViewZone();
  101108. }
  101109. if (!addExtraSpaceOnTop && _this._viewZone) {
  101110. _this._removeViewZone();
  101111. }
  101112. }
  101113. }));
  101114. _this.updateAccessibilitySupport();
  101115. _this._register(_this._codeEditor.onDidChangeCursorSelection(function () {
  101116. if (_this._isVisible) {
  101117. _this._updateToggleSelectionFindButton();
  101118. }
  101119. }));
  101120. _this._register(_this._codeEditor.onDidFocusEditorWidget(function () {
  101121. if (_this._isVisible) {
  101122. var globalBufferTerm = _this._controller.getGlobalBufferTerm();
  101123. if (globalBufferTerm && globalBufferTerm !== _this._state.searchString) {
  101124. _this._state.change({ searchString: globalBufferTerm }, true);
  101125. _this._findInput.select();
  101126. }
  101127. }
  101128. }));
  101129. _this._findInputFocused = findModel_1.CONTEXT_FIND_INPUT_FOCUSED.bindTo(contextKeyService);
  101130. _this._findFocusTracker = _this._register(dom.trackFocus(_this._findInput.inputBox.inputElement));
  101131. _this._register(_this._findFocusTracker.onDidFocus(function () {
  101132. _this._findInputFocused.set(true);
  101133. _this._updateSearchScope();
  101134. }));
  101135. _this._register(_this._findFocusTracker.onDidBlur(function () {
  101136. _this._findInputFocused.set(false);
  101137. }));
  101138. _this._replaceInputFocused = findModel_1.CONTEXT_REPLACE_INPUT_FOCUSED.bindTo(contextKeyService);
  101139. _this._replaceFocusTracker = _this._register(dom.trackFocus(_this._replaceInput.inputBox.inputElement));
  101140. _this._register(_this._replaceFocusTracker.onDidFocus(function () {
  101141. _this._replaceInputFocused.set(true);
  101142. _this._updateSearchScope();
  101143. }));
  101144. _this._register(_this._replaceFocusTracker.onDidBlur(function () {
  101145. _this._replaceInputFocused.set(false);
  101146. }));
  101147. _this._codeEditor.addOverlayWidget(_this);
  101148. if (_this._codeEditor.getOption(28 /* find */).addExtraSpaceOnTop) {
  101149. _this._viewZone = new FindWidgetViewZone(0); // Put it before the first line then users can scroll beyond the first line.
  101150. }
  101151. _this._applyTheme(themeService.getTheme());
  101152. _this._register(themeService.onThemeChange(_this._applyTheme.bind(_this)));
  101153. _this._register(_this._codeEditor.onDidChangeModel(function () {
  101154. if (!_this._isVisible) {
  101155. return;
  101156. }
  101157. _this._viewZoneId = undefined;
  101158. }));
  101159. _this._register(_this._codeEditor.onDidScrollChange(function (e) {
  101160. if (e.scrollTopChanged) {
  101161. _this._layoutViewZone();
  101162. return;
  101163. }
  101164. // for other scroll changes, layout the viewzone in next tick to avoid ruining current rendering.
  101165. setTimeout(function () {
  101166. _this._layoutViewZone();
  101167. }, 0);
  101168. }));
  101169. return _this;
  101170. }
  101171. // ----- IOverlayWidget API
  101172. FindWidget.prototype.getId = function () {
  101173. return FindWidget.ID;
  101174. };
  101175. FindWidget.prototype.getDomNode = function () {
  101176. return this._domNode;
  101177. };
  101178. FindWidget.prototype.getPosition = function () {
  101179. if (this._isVisible) {
  101180. return {
  101181. preference: 0 /* TOP_RIGHT_CORNER */
  101182. };
  101183. }
  101184. return null;
  101185. };
  101186. // ----- React to state changes
  101187. FindWidget.prototype._onStateChanged = function (e) {
  101188. if (e.searchString) {
  101189. try {
  101190. this._ignoreChangeEvent = true;
  101191. this._findInput.setValue(this._state.searchString);
  101192. }
  101193. finally {
  101194. this._ignoreChangeEvent = false;
  101195. }
  101196. this._updateButtons();
  101197. }
  101198. if (e.replaceString) {
  101199. this._replaceInput.inputBox.value = this._state.replaceString;
  101200. }
  101201. if (e.isRevealed) {
  101202. if (this._state.isRevealed) {
  101203. this._reveal();
  101204. }
  101205. else {
  101206. this._hide(true);
  101207. }
  101208. }
  101209. if (e.isReplaceRevealed) {
  101210. if (this._state.isReplaceRevealed) {
  101211. if (!this._codeEditor.getOption(68 /* readOnly */) && !this._isReplaceVisible) {
  101212. this._isReplaceVisible = true;
  101213. this._replaceInput.width = dom.getTotalWidth(this._findInput.domNode);
  101214. this._updateButtons();
  101215. this._replaceInput.inputBox.layout();
  101216. }
  101217. }
  101218. else {
  101219. if (this._isReplaceVisible) {
  101220. this._isReplaceVisible = false;
  101221. this._updateButtons();
  101222. }
  101223. }
  101224. }
  101225. if ((e.isRevealed || e.isReplaceRevealed) && (this._state.isRevealed || this._state.isReplaceRevealed)) {
  101226. if (this._tryUpdateHeight()) {
  101227. this._showViewZone();
  101228. }
  101229. }
  101230. if (e.isRegex) {
  101231. this._findInput.setRegex(this._state.isRegex);
  101232. }
  101233. if (e.wholeWord) {
  101234. this._findInput.setWholeWords(this._state.wholeWord);
  101235. }
  101236. if (e.matchCase) {
  101237. this._findInput.setCaseSensitive(this._state.matchCase);
  101238. }
  101239. if (e.searchScope) {
  101240. if (this._state.searchScope) {
  101241. this._toggleSelectionFind.checked = true;
  101242. }
  101243. else {
  101244. this._toggleSelectionFind.checked = false;
  101245. }
  101246. this._updateToggleSelectionFindButton();
  101247. }
  101248. if (e.searchString || e.matchesCount || e.matchesPosition) {
  101249. var showRedOutline = (this._state.searchString.length > 0 && this._state.matchesCount === 0);
  101250. dom.toggleClass(this._domNode, 'no-results', showRedOutline);
  101251. this._updateMatchesCount();
  101252. this._updateButtons();
  101253. }
  101254. if (e.searchString || e.currentMatch) {
  101255. this._layoutViewZone();
  101256. }
  101257. if (e.updateHistory) {
  101258. this._delayedUpdateHistory();
  101259. }
  101260. };
  101261. FindWidget.prototype._delayedUpdateHistory = function () {
  101262. this._updateHistoryDelayer.trigger(this._updateHistory.bind(this));
  101263. };
  101264. FindWidget.prototype._updateHistory = function () {
  101265. if (this._state.searchString) {
  101266. this._findInput.inputBox.addToHistory();
  101267. }
  101268. if (this._state.replaceString) {
  101269. this._replaceInput.inputBox.addToHistory();
  101270. }
  101271. };
  101272. FindWidget.prototype._updateMatchesCount = function () {
  101273. this._matchesCount.style.minWidth = MAX_MATCHES_COUNT_WIDTH + 'px';
  101274. if (this._state.matchesCount >= findModel_1.MATCHES_LIMIT) {
  101275. this._matchesCount.title = NLS_MATCHES_COUNT_LIMIT_TITLE;
  101276. }
  101277. else {
  101278. this._matchesCount.title = '';
  101279. }
  101280. // remove previous content
  101281. if (this._matchesCount.firstChild) {
  101282. this._matchesCount.removeChild(this._matchesCount.firstChild);
  101283. }
  101284. var label;
  101285. if (this._state.matchesCount > 0) {
  101286. var matchesCount = String(this._state.matchesCount);
  101287. if (this._state.matchesCount >= findModel_1.MATCHES_LIMIT) {
  101288. matchesCount += '+';
  101289. }
  101290. var matchesPosition = String(this._state.matchesPosition);
  101291. if (matchesPosition === '0') {
  101292. matchesPosition = '?';
  101293. }
  101294. label = strings.format(NLS_MATCHES_LOCATION, matchesPosition, matchesCount);
  101295. }
  101296. else {
  101297. label = NLS_NO_RESULTS;
  101298. }
  101299. this._matchesCount.appendChild(document.createTextNode(label));
  101300. aria_1.alert(this._getAriaLabel(label, this._state.currentMatch, this._state.searchString), true);
  101301. MAX_MATCHES_COUNT_WIDTH = Math.max(MAX_MATCHES_COUNT_WIDTH, this._matchesCount.clientWidth);
  101302. };
  101303. // ----- actions
  101304. FindWidget.prototype._getAriaLabel = function (label, currentMatch, searchString) {
  101305. if (label === NLS_NO_RESULTS) {
  101306. return searchString === ''
  101307. ? nls.localize(14, null, label)
  101308. : nls.localize(15, null, label, searchString);
  101309. }
  101310. return currentMatch
  101311. ? nls.localize(16, null, label, searchString, currentMatch.startLineNumber + ':' + currentMatch.startColumn)
  101312. : nls.localize(17, null, label, searchString);
  101313. };
  101314. /**
  101315. * If 'selection find' is ON we should not disable the button (its function is to cancel 'selection find').
  101316. * If 'selection find' is OFF we enable the button only if there is a selection.
  101317. */
  101318. FindWidget.prototype._updateToggleSelectionFindButton = function () {
  101319. var selection = this._codeEditor.getSelection();
  101320. var isSelection = selection ? (selection.startLineNumber !== selection.endLineNumber || selection.startColumn !== selection.endColumn) : false;
  101321. var isChecked = this._toggleSelectionFind.checked;
  101322. if (this._isVisible && (isChecked || isSelection)) {
  101323. this._toggleSelectionFind.enable();
  101324. }
  101325. else {
  101326. this._toggleSelectionFind.disable();
  101327. }
  101328. };
  101329. FindWidget.prototype._updateButtons = function () {
  101330. this._findInput.setEnabled(this._isVisible);
  101331. this._replaceInput.setEnabled(this._isVisible && this._isReplaceVisible);
  101332. this._updateToggleSelectionFindButton();
  101333. this._closeBtn.setEnabled(this._isVisible);
  101334. var findInputIsNonEmpty = (this._state.searchString.length > 0);
  101335. var matchesCount = this._state.matchesCount ? true : false;
  101336. this._prevBtn.setEnabled(this._isVisible && findInputIsNonEmpty && matchesCount);
  101337. this._nextBtn.setEnabled(this._isVisible && findInputIsNonEmpty && matchesCount);
  101338. this._replaceBtn.setEnabled(this._isVisible && this._isReplaceVisible && findInputIsNonEmpty);
  101339. this._replaceAllBtn.setEnabled(this._isVisible && this._isReplaceVisible && findInputIsNonEmpty);
  101340. dom.toggleClass(this._domNode, 'replaceToggled', this._isReplaceVisible);
  101341. this._toggleReplaceBtn.toggleClass('codicon-chevron-right', !this._isReplaceVisible);
  101342. this._toggleReplaceBtn.toggleClass('codicon-chevron-down', this._isReplaceVisible);
  101343. this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);
  101344. var canReplace = !this._codeEditor.getOption(68 /* readOnly */);
  101345. this._toggleReplaceBtn.setEnabled(this._isVisible && canReplace);
  101346. };
  101347. FindWidget.prototype._reveal = function () {
  101348. var _this = this;
  101349. if (!this._isVisible) {
  101350. this._isVisible = true;
  101351. var selection = this._codeEditor.getSelection();
  101352. switch (this._codeEditor.getOption(28 /* find */).autoFindInSelection) {
  101353. case 'always':
  101354. this._toggleSelectionFind.checked = true;
  101355. break;
  101356. case 'never':
  101357. this._toggleSelectionFind.checked = false;
  101358. break;
  101359. case 'multiline':
  101360. var isSelectionMultipleLine = !!selection && selection.startLineNumber !== selection.endLineNumber;
  101361. this._toggleSelectionFind.checked = isSelectionMultipleLine;
  101362. break;
  101363. default:
  101364. break;
  101365. }
  101366. this._tryUpdateWidgetWidth();
  101367. this._updateButtons();
  101368. setTimeout(function () {
  101369. dom.addClass(_this._domNode, 'visible');
  101370. _this._domNode.setAttribute('aria-hidden', 'false');
  101371. }, 0);
  101372. // validate query again as it's being dismissed when we hide the find widget.
  101373. setTimeout(function () {
  101374. _this._findInput.validate();
  101375. }, 200);
  101376. this._codeEditor.layoutOverlayWidget(this);
  101377. var adjustEditorScrollTop = true;
  101378. if (this._codeEditor.getOption(28 /* find */).seedSearchStringFromSelection && selection) {
  101379. var domNode = this._codeEditor.getDomNode();
  101380. if (domNode) {
  101381. var editorCoords = dom.getDomNodePagePosition(domNode);
  101382. var startCoords = this._codeEditor.getScrolledVisiblePosition(selection.getStartPosition());
  101383. var startLeft = editorCoords.left + (startCoords ? startCoords.left : 0);
  101384. var startTop = startCoords ? startCoords.top : 0;
  101385. if (this._viewZone && startTop < this._viewZone.heightInPx) {
  101386. if (selection.endLineNumber > selection.startLineNumber) {
  101387. adjustEditorScrollTop = false;
  101388. }
  101389. var leftOfFindWidget = dom.getTopLeftOffset(this._domNode).left;
  101390. if (startLeft > leftOfFindWidget) {
  101391. adjustEditorScrollTop = false;
  101392. }
  101393. var endCoords = this._codeEditor.getScrolledVisiblePosition(selection.getEndPosition());
  101394. var endLeft = editorCoords.left + (endCoords ? endCoords.left : 0);
  101395. if (endLeft > leftOfFindWidget) {
  101396. adjustEditorScrollTop = false;
  101397. }
  101398. }
  101399. }
  101400. }
  101401. this._showViewZone(adjustEditorScrollTop);
  101402. }
  101403. };
  101404. FindWidget.prototype._hide = function (focusTheEditor) {
  101405. if (this._isVisible) {
  101406. this._isVisible = false;
  101407. this._updateButtons();
  101408. dom.removeClass(this._domNode, 'visible');
  101409. this._domNode.setAttribute('aria-hidden', 'true');
  101410. this._findInput.clearMessage();
  101411. if (focusTheEditor) {
  101412. this._codeEditor.focus();
  101413. }
  101414. this._codeEditor.layoutOverlayWidget(this);
  101415. this._removeViewZone();
  101416. }
  101417. };
  101418. FindWidget.prototype._layoutViewZone = function () {
  101419. var _this = this;
  101420. var addExtraSpaceOnTop = this._codeEditor.getOption(28 /* find */).addExtraSpaceOnTop;
  101421. if (!addExtraSpaceOnTop) {
  101422. this._removeViewZone();
  101423. return;
  101424. }
  101425. if (!this._isVisible) {
  101426. return;
  101427. }
  101428. var viewZone = this._viewZone;
  101429. if (this._viewZoneId !== undefined || !viewZone) {
  101430. return;
  101431. }
  101432. this._codeEditor.changeViewZones(function (accessor) {
  101433. viewZone.heightInPx = _this._getHeight();
  101434. _this._viewZoneId = accessor.addZone(viewZone);
  101435. // scroll top adjust to make sure the editor doesn't scroll when adding viewzone at the beginning.
  101436. _this._codeEditor.setScrollTop(_this._codeEditor.getScrollTop() + viewZone.heightInPx);
  101437. });
  101438. };
  101439. FindWidget.prototype._showViewZone = function (adjustScroll) {
  101440. var _this = this;
  101441. if (adjustScroll === void 0) { adjustScroll = true; }
  101442. if (!this._isVisible) {
  101443. return;
  101444. }
  101445. var addExtraSpaceOnTop = this._codeEditor.getOption(28 /* find */).addExtraSpaceOnTop;
  101446. if (!addExtraSpaceOnTop) {
  101447. return;
  101448. }
  101449. if (this._viewZone === undefined) {
  101450. this._viewZone = new FindWidgetViewZone(0);
  101451. }
  101452. var viewZone = this._viewZone;
  101453. this._codeEditor.changeViewZones(function (accessor) {
  101454. if (_this._viewZoneId !== undefined) {
  101455. // the view zone already exists, we need to update the height
  101456. var newHeight = _this._getHeight();
  101457. if (newHeight === viewZone.heightInPx) {
  101458. return;
  101459. }
  101460. var scrollAdjustment = newHeight - viewZone.heightInPx;
  101461. viewZone.heightInPx = newHeight;
  101462. accessor.layoutZone(_this._viewZoneId);
  101463. if (adjustScroll) {
  101464. _this._codeEditor.setScrollTop(_this._codeEditor.getScrollTop() + scrollAdjustment);
  101465. }
  101466. return;
  101467. }
  101468. else {
  101469. var scrollAdjustment = _this._getHeight();
  101470. viewZone.heightInPx = scrollAdjustment;
  101471. _this._viewZoneId = accessor.addZone(viewZone);
  101472. if (adjustScroll) {
  101473. _this._codeEditor.setScrollTop(_this._codeEditor.getScrollTop() + scrollAdjustment);
  101474. }
  101475. }
  101476. });
  101477. };
  101478. FindWidget.prototype._removeViewZone = function () {
  101479. var _this = this;
  101480. this._codeEditor.changeViewZones(function (accessor) {
  101481. if (_this._viewZoneId !== undefined) {
  101482. accessor.removeZone(_this._viewZoneId);
  101483. _this._viewZoneId = undefined;
  101484. if (_this._viewZone) {
  101485. _this._codeEditor.setScrollTop(_this._codeEditor.getScrollTop() - _this._viewZone.heightInPx);
  101486. _this._viewZone = undefined;
  101487. }
  101488. }
  101489. });
  101490. };
  101491. FindWidget.prototype._applyTheme = function (theme) {
  101492. var inputStyles = {
  101493. inputActiveOptionBorder: theme.getColor(colorRegistry_1.inputActiveOptionBorder),
  101494. inputActiveOptionBackground: theme.getColor(colorRegistry_1.inputActiveOptionBackground),
  101495. inputBackground: theme.getColor(colorRegistry_1.inputBackground),
  101496. inputForeground: theme.getColor(colorRegistry_1.inputForeground),
  101497. inputBorder: theme.getColor(colorRegistry_1.inputBorder),
  101498. inputValidationInfoBackground: theme.getColor(colorRegistry_1.inputValidationInfoBackground),
  101499. inputValidationInfoForeground: theme.getColor(colorRegistry_1.inputValidationInfoForeground),
  101500. inputValidationInfoBorder: theme.getColor(colorRegistry_1.inputValidationInfoBorder),
  101501. inputValidationWarningBackground: theme.getColor(colorRegistry_1.inputValidationWarningBackground),
  101502. inputValidationWarningForeground: theme.getColor(colorRegistry_1.inputValidationWarningForeground),
  101503. inputValidationWarningBorder: theme.getColor(colorRegistry_1.inputValidationWarningBorder),
  101504. inputValidationErrorBackground: theme.getColor(colorRegistry_1.inputValidationErrorBackground),
  101505. inputValidationErrorForeground: theme.getColor(colorRegistry_1.inputValidationErrorForeground),
  101506. inputValidationErrorBorder: theme.getColor(colorRegistry_1.inputValidationErrorBorder),
  101507. };
  101508. this._findInput.style(inputStyles);
  101509. this._replaceInput.style(inputStyles);
  101510. this._toggleSelectionFind.style(inputStyles);
  101511. };
  101512. FindWidget.prototype._tryUpdateWidgetWidth = function () {
  101513. if (!this._isVisible) {
  101514. return;
  101515. }
  101516. if (!dom.isInDOM(this._domNode)) {
  101517. // the widget is not in the DOM
  101518. return;
  101519. }
  101520. var layoutInfo = this._codeEditor.getLayoutInfo();
  101521. var editorContentWidth = layoutInfo.contentWidth;
  101522. if (editorContentWidth <= 0) {
  101523. // for example, diff view original editor
  101524. dom.addClass(this._domNode, 'hiddenEditor');
  101525. return;
  101526. }
  101527. else if (dom.hasClass(this._domNode, 'hiddenEditor')) {
  101528. dom.removeClass(this._domNode, 'hiddenEditor');
  101529. }
  101530. var editorWidth = layoutInfo.width;
  101531. var minimapWidth = layoutInfo.minimapWidth;
  101532. var collapsedFindWidget = false;
  101533. var reducedFindWidget = false;
  101534. var narrowFindWidget = false;
  101535. if (this._resized) {
  101536. var widgetWidth = dom.getTotalWidth(this._domNode);
  101537. if (widgetWidth > FIND_WIDGET_INITIAL_WIDTH) {
  101538. // as the widget is resized by users, we may need to change the max width of the widget as the editor width changes.
  101539. this._domNode.style.maxWidth = editorWidth - 28 - minimapWidth - 15 + "px";
  101540. this._replaceInput.width = dom.getTotalWidth(this._findInput.domNode);
  101541. return;
  101542. }
  101543. }
  101544. if (FIND_WIDGET_INITIAL_WIDTH + 28 + minimapWidth >= editorWidth) {
  101545. reducedFindWidget = true;
  101546. }
  101547. if (FIND_WIDGET_INITIAL_WIDTH + 28 + minimapWidth - MAX_MATCHES_COUNT_WIDTH >= editorWidth) {
  101548. narrowFindWidget = true;
  101549. }
  101550. if (FIND_WIDGET_INITIAL_WIDTH + 28 + minimapWidth - MAX_MATCHES_COUNT_WIDTH >= editorWidth + 50) {
  101551. collapsedFindWidget = true;
  101552. }
  101553. dom.toggleClass(this._domNode, 'collapsed-find-widget', collapsedFindWidget);
  101554. dom.toggleClass(this._domNode, 'narrow-find-widget', narrowFindWidget);
  101555. dom.toggleClass(this._domNode, 'reduced-find-widget', reducedFindWidget);
  101556. if (!narrowFindWidget && !collapsedFindWidget) {
  101557. // the minimal left offset of findwidget is 15px.
  101558. this._domNode.style.maxWidth = editorWidth - 28 - minimapWidth - 15 + "px";
  101559. }
  101560. if (this._resized) {
  101561. this._findInput.inputBox.layout();
  101562. var findInputWidth = this._findInput.inputBox.element.clientWidth;
  101563. if (findInputWidth > 0) {
  101564. this._replaceInput.width = findInputWidth;
  101565. }
  101566. }
  101567. else if (this._isReplaceVisible) {
  101568. this._replaceInput.width = dom.getTotalWidth(this._findInput.domNode);
  101569. }
  101570. };
  101571. FindWidget.prototype._getHeight = function () {
  101572. var totalheight = 0;
  101573. // find input margin top
  101574. totalheight += 4;
  101575. // find input height
  101576. totalheight += this._findInput.inputBox.height + 2 /** input box border */;
  101577. if (this._isReplaceVisible) {
  101578. // replace input margin
  101579. totalheight += 4;
  101580. totalheight += this._replaceInput.inputBox.height + 2 /** input box border */;
  101581. }
  101582. // margin bottom
  101583. totalheight += 4;
  101584. return totalheight;
  101585. };
  101586. FindWidget.prototype._tryUpdateHeight = function () {
  101587. var totalHeight = this._getHeight();
  101588. if (this._cachedHeight !== null && this._cachedHeight === totalHeight) {
  101589. return false;
  101590. }
  101591. this._cachedHeight = totalHeight;
  101592. this._domNode.style.height = totalHeight + "px";
  101593. return true;
  101594. };
  101595. // ----- Public
  101596. FindWidget.prototype.focusFindInput = function () {
  101597. this._findInput.select();
  101598. // Edge browser requires focus() in addition to select()
  101599. this._findInput.focus();
  101600. };
  101601. FindWidget.prototype.focusReplaceInput = function () {
  101602. this._replaceInput.select();
  101603. // Edge browser requires focus() in addition to select()
  101604. this._replaceInput.focus();
  101605. };
  101606. FindWidget.prototype.highlightFindOptions = function () {
  101607. this._findInput.highlightFindOptions();
  101608. };
  101609. FindWidget.prototype._updateSearchScope = function () {
  101610. if (!this._codeEditor.hasModel()) {
  101611. return;
  101612. }
  101613. if (this._toggleSelectionFind.checked) {
  101614. var selection = this._codeEditor.getSelection();
  101615. if (selection.endColumn === 1 && selection.endLineNumber > selection.startLineNumber) {
  101616. selection = selection.setEndPosition(selection.endLineNumber - 1, this._codeEditor.getModel().getLineMaxColumn(selection.endLineNumber - 1));
  101617. }
  101618. var currentMatch = this._state.currentMatch;
  101619. if (selection.startLineNumber !== selection.endLineNumber) {
  101620. if (!range_1.Range.equalsRange(selection, currentMatch)) {
  101621. // Reseed find scope
  101622. this._state.change({ searchScope: selection }, true);
  101623. }
  101624. }
  101625. }
  101626. };
  101627. FindWidget.prototype._onFindInputMouseDown = function (e) {
  101628. // on linux, middle key does pasting.
  101629. if (e.middleButton) {
  101630. e.stopPropagation();
  101631. }
  101632. };
  101633. FindWidget.prototype._onFindInputKeyDown = function (e) {
  101634. if (e.equals(ctrlKeyMod | 3 /* Enter */)) {
  101635. this._findInput.inputBox.insertAtCursor('\n');
  101636. e.preventDefault();
  101637. return;
  101638. }
  101639. if (e.equals(2 /* Tab */)) {
  101640. if (this._isReplaceVisible) {
  101641. this._replaceInput.focus();
  101642. }
  101643. else {
  101644. this._findInput.focusOnCaseSensitive();
  101645. }
  101646. e.preventDefault();
  101647. return;
  101648. }
  101649. if (e.equals(2048 /* CtrlCmd */ | 18 /* DownArrow */)) {
  101650. this._codeEditor.focus();
  101651. e.preventDefault();
  101652. return;
  101653. }
  101654. if (e.equals(16 /* UpArrow */)) {
  101655. return stopPropagationForMultiLineUpwards(e, this._findInput.getValue(), this._findInput.domNode.querySelector('textarea'));
  101656. }
  101657. if (e.equals(18 /* DownArrow */)) {
  101658. return stopPropagationForMultiLineDownwards(e, this._findInput.getValue(), this._findInput.domNode.querySelector('textarea'));
  101659. }
  101660. };
  101661. FindWidget.prototype._onReplaceInputKeyDown = function (e) {
  101662. if (e.equals(ctrlKeyMod | 3 /* Enter */)) {
  101663. if (platform.isWindows && platform.isNative && !this._ctrlEnterReplaceAllWarningPrompted) {
  101664. // this is the first time when users press Ctrl + Enter to replace all
  101665. this._notificationService.info(nls.localize(18, null));
  101666. this._ctrlEnterReplaceAllWarningPrompted = true;
  101667. this._storageService.store(ctrlEnterReplaceAllWarningPromptedKey, true, 0 /* GLOBAL */);
  101668. }
  101669. this._replaceInput.inputBox.insertAtCursor('\n');
  101670. e.preventDefault();
  101671. return;
  101672. }
  101673. if (e.equals(2 /* Tab */)) {
  101674. this._findInput.focusOnCaseSensitive();
  101675. e.preventDefault();
  101676. return;
  101677. }
  101678. if (e.equals(1024 /* Shift */ | 2 /* Tab */)) {
  101679. this._findInput.focus();
  101680. e.preventDefault();
  101681. return;
  101682. }
  101683. if (e.equals(2048 /* CtrlCmd */ | 18 /* DownArrow */)) {
  101684. this._codeEditor.focus();
  101685. e.preventDefault();
  101686. return;
  101687. }
  101688. if (e.equals(16 /* UpArrow */)) {
  101689. return stopPropagationForMultiLineUpwards(e, this._replaceInput.inputBox.value, this._replaceInput.inputBox.element.querySelector('textarea'));
  101690. }
  101691. if (e.equals(18 /* DownArrow */)) {
  101692. return stopPropagationForMultiLineDownwards(e, this._replaceInput.inputBox.value, this._replaceInput.inputBox.element.querySelector('textarea'));
  101693. }
  101694. };
  101695. // ----- sash
  101696. FindWidget.prototype.getHorizontalSashTop = function (_sash) {
  101697. return 0;
  101698. };
  101699. FindWidget.prototype.getHorizontalSashLeft = function (_sash) {
  101700. return 0;
  101701. };
  101702. FindWidget.prototype.getHorizontalSashWidth = function (_sash) {
  101703. return 500;
  101704. };
  101705. // ----- initialization
  101706. FindWidget.prototype._keybindingLabelFor = function (actionId) {
  101707. var kb = this._keybindingService.lookupKeybinding(actionId);
  101708. if (!kb) {
  101709. return '';
  101710. }
  101711. return " (" + kb.getLabel() + ")";
  101712. };
  101713. FindWidget.prototype._buildDomNode = function () {
  101714. var _this = this;
  101715. var flexibleHeight = true;
  101716. var flexibleWidth = true;
  101717. // Find input
  101718. this._findInput = this._register(new contextScopedHistoryWidget_1.ContextScopedFindInput(null, this._contextViewProvider, {
  101719. width: FIND_INPUT_AREA_WIDTH,
  101720. label: NLS_FIND_INPUT_LABEL,
  101721. placeholder: NLS_FIND_INPUT_PLACEHOLDER,
  101722. appendCaseSensitiveLabel: this._keybindingLabelFor(findModel_1.FIND_IDS.ToggleCaseSensitiveCommand),
  101723. appendWholeWordsLabel: this._keybindingLabelFor(findModel_1.FIND_IDS.ToggleWholeWordCommand),
  101724. appendRegexLabel: this._keybindingLabelFor(findModel_1.FIND_IDS.ToggleRegexCommand),
  101725. validation: function (value) {
  101726. if (value.length === 0 || !_this._findInput.getRegex()) {
  101727. return null;
  101728. }
  101729. try {
  101730. new RegExp(value);
  101731. return null;
  101732. }
  101733. catch (e) {
  101734. return { content: e.message };
  101735. }
  101736. },
  101737. flexibleHeight: flexibleHeight,
  101738. flexibleWidth: flexibleWidth,
  101739. flexibleMaxHeight: 118
  101740. }, this._contextKeyService, true));
  101741. this._findInput.setRegex(!!this._state.isRegex);
  101742. this._findInput.setCaseSensitive(!!this._state.matchCase);
  101743. this._findInput.setWholeWords(!!this._state.wholeWord);
  101744. this._register(this._findInput.onKeyDown(function (e) { return _this._onFindInputKeyDown(e); }));
  101745. this._register(this._findInput.inputBox.onDidChange(function () {
  101746. if (_this._ignoreChangeEvent) {
  101747. return;
  101748. }
  101749. _this._state.change({ searchString: _this._findInput.getValue() }, true);
  101750. }));
  101751. this._register(this._findInput.onDidOptionChange(function () {
  101752. _this._state.change({
  101753. isRegex: _this._findInput.getRegex(),
  101754. wholeWord: _this._findInput.getWholeWords(),
  101755. matchCase: _this._findInput.getCaseSensitive()
  101756. }, true);
  101757. }));
  101758. this._register(this._findInput.onCaseSensitiveKeyDown(function (e) {
  101759. if (e.equals(1024 /* Shift */ | 2 /* Tab */)) {
  101760. if (_this._isReplaceVisible) {
  101761. _this._replaceInput.focus();
  101762. e.preventDefault();
  101763. }
  101764. }
  101765. }));
  101766. this._register(this._findInput.onRegexKeyDown(function (e) {
  101767. if (e.equals(2 /* Tab */)) {
  101768. if (_this._isReplaceVisible) {
  101769. _this._replaceInput.focusOnPreserve();
  101770. e.preventDefault();
  101771. }
  101772. }
  101773. }));
  101774. this._register(this._findInput.inputBox.onDidHeightChange(function (e) {
  101775. if (_this._tryUpdateHeight()) {
  101776. _this._showViewZone();
  101777. }
  101778. }));
  101779. if (platform.isLinux) {
  101780. this._register(this._findInput.onMouseDown(function (e) { return _this._onFindInputMouseDown(e); }));
  101781. }
  101782. this._matchesCount = document.createElement('div');
  101783. this._matchesCount.className = 'matchesCount';
  101784. this._updateMatchesCount();
  101785. // Previous button
  101786. this._prevBtn = this._register(new SimpleButton({
  101787. label: NLS_PREVIOUS_MATCH_BTN_LABEL + this._keybindingLabelFor(findModel_1.FIND_IDS.PreviousMatchFindAction),
  101788. className: 'codicon codicon-arrow-up',
  101789. onTrigger: function () {
  101790. _this._codeEditor.getAction(findModel_1.FIND_IDS.PreviousMatchFindAction).run().then(undefined, errors_1.onUnexpectedError);
  101791. }
  101792. }));
  101793. // Next button
  101794. this._nextBtn = this._register(new SimpleButton({
  101795. label: NLS_NEXT_MATCH_BTN_LABEL + this._keybindingLabelFor(findModel_1.FIND_IDS.NextMatchFindAction),
  101796. className: 'codicon codicon-arrow-down',
  101797. onTrigger: function () {
  101798. _this._codeEditor.getAction(findModel_1.FIND_IDS.NextMatchFindAction).run().then(undefined, errors_1.onUnexpectedError);
  101799. }
  101800. }));
  101801. var findPart = document.createElement('div');
  101802. findPart.className = 'find-part';
  101803. findPart.appendChild(this._findInput.domNode);
  101804. var actionsContainer = document.createElement('div');
  101805. actionsContainer.className = 'find-actions';
  101806. findPart.appendChild(actionsContainer);
  101807. actionsContainer.appendChild(this._matchesCount);
  101808. actionsContainer.appendChild(this._prevBtn.domNode);
  101809. actionsContainer.appendChild(this._nextBtn.domNode);
  101810. // Toggle selection button
  101811. this._toggleSelectionFind = this._register(new checkbox_1.Checkbox({
  101812. actionClassName: 'codicon codicon-selection',
  101813. title: NLS_TOGGLE_SELECTION_FIND_TITLE + this._keybindingLabelFor(findModel_1.FIND_IDS.ToggleSearchScopeCommand),
  101814. isChecked: false
  101815. }));
  101816. this._register(this._toggleSelectionFind.onChange(function () {
  101817. if (_this._toggleSelectionFind.checked) {
  101818. if (_this._codeEditor.hasModel()) {
  101819. var selection = _this._codeEditor.getSelection();
  101820. if (selection.endColumn === 1 && selection.endLineNumber > selection.startLineNumber) {
  101821. selection = selection.setEndPosition(selection.endLineNumber - 1, _this._codeEditor.getModel().getLineMaxColumn(selection.endLineNumber - 1));
  101822. }
  101823. if (!selection.isEmpty()) {
  101824. _this._state.change({ searchScope: selection }, true);
  101825. }
  101826. }
  101827. }
  101828. else {
  101829. _this._state.change({ searchScope: null }, true);
  101830. }
  101831. }));
  101832. actionsContainer.appendChild(this._toggleSelectionFind.domNode);
  101833. // Close button
  101834. this._closeBtn = this._register(new SimpleButton({
  101835. label: NLS_CLOSE_BTN_LABEL + this._keybindingLabelFor(findModel_1.FIND_IDS.CloseFindWidgetCommand),
  101836. className: 'codicon codicon-close',
  101837. onTrigger: function () {
  101838. _this._state.change({ isRevealed: false, searchScope: null }, false);
  101839. },
  101840. onKeyDown: function (e) {
  101841. if (e.equals(2 /* Tab */)) {
  101842. if (_this._isReplaceVisible) {
  101843. if (_this._replaceBtn.isEnabled()) {
  101844. _this._replaceBtn.focus();
  101845. }
  101846. else {
  101847. _this._codeEditor.focus();
  101848. }
  101849. e.preventDefault();
  101850. }
  101851. }
  101852. }
  101853. }));
  101854. actionsContainer.appendChild(this._closeBtn.domNode);
  101855. // Replace input
  101856. this._replaceInput = this._register(new contextScopedHistoryWidget_1.ContextScopedReplaceInput(null, undefined, {
  101857. label: NLS_REPLACE_INPUT_LABEL,
  101858. placeholder: NLS_REPLACE_INPUT_PLACEHOLDER,
  101859. history: [],
  101860. flexibleHeight: flexibleHeight,
  101861. flexibleWidth: flexibleWidth,
  101862. flexibleMaxHeight: 118
  101863. }, this._contextKeyService, true));
  101864. this._replaceInput.setPreserveCase(!!this._state.preserveCase);
  101865. this._register(this._replaceInput.onKeyDown(function (e) { return _this._onReplaceInputKeyDown(e); }));
  101866. this._register(this._replaceInput.inputBox.onDidChange(function () {
  101867. _this._state.change({ replaceString: _this._replaceInput.inputBox.value }, false);
  101868. }));
  101869. this._register(this._replaceInput.inputBox.onDidHeightChange(function (e) {
  101870. if (_this._isReplaceVisible && _this._tryUpdateHeight()) {
  101871. _this._showViewZone();
  101872. }
  101873. }));
  101874. this._register(this._replaceInput.onDidOptionChange(function () {
  101875. _this._state.change({
  101876. preserveCase: _this._replaceInput.getPreserveCase()
  101877. }, true);
  101878. }));
  101879. this._register(this._replaceInput.onPreserveCaseKeyDown(function (e) {
  101880. if (e.equals(2 /* Tab */)) {
  101881. if (_this._prevBtn.isEnabled()) {
  101882. _this._prevBtn.focus();
  101883. }
  101884. else if (_this._nextBtn.isEnabled()) {
  101885. _this._nextBtn.focus();
  101886. }
  101887. else if (_this._toggleSelectionFind.enabled) {
  101888. _this._toggleSelectionFind.focus();
  101889. }
  101890. else if (_this._closeBtn.isEnabled()) {
  101891. _this._closeBtn.focus();
  101892. }
  101893. e.preventDefault();
  101894. }
  101895. }));
  101896. // Replace one button
  101897. this._replaceBtn = this._register(new SimpleButton({
  101898. label: NLS_REPLACE_BTN_LABEL + this._keybindingLabelFor(findModel_1.FIND_IDS.ReplaceOneAction),
  101899. className: 'codicon codicon-replace',
  101900. onTrigger: function () {
  101901. _this._controller.replace();
  101902. },
  101903. onKeyDown: function (e) {
  101904. if (e.equals(1024 /* Shift */ | 2 /* Tab */)) {
  101905. _this._closeBtn.focus();
  101906. e.preventDefault();
  101907. }
  101908. }
  101909. }));
  101910. // Replace all button
  101911. this._replaceAllBtn = this._register(new SimpleButton({
  101912. label: NLS_REPLACE_ALL_BTN_LABEL + this._keybindingLabelFor(findModel_1.FIND_IDS.ReplaceAllAction),
  101913. className: 'codicon codicon-replace-all',
  101914. onTrigger: function () {
  101915. _this._controller.replaceAll();
  101916. }
  101917. }));
  101918. var replacePart = document.createElement('div');
  101919. replacePart.className = 'replace-part';
  101920. replacePart.appendChild(this._replaceInput.domNode);
  101921. var replaceActionsContainer = document.createElement('div');
  101922. replaceActionsContainer.className = 'replace-actions';
  101923. replacePart.appendChild(replaceActionsContainer);
  101924. replaceActionsContainer.appendChild(this._replaceBtn.domNode);
  101925. replaceActionsContainer.appendChild(this._replaceAllBtn.domNode);
  101926. // Toggle replace button
  101927. this._toggleReplaceBtn = this._register(new SimpleButton({
  101928. label: NLS_TOGGLE_REPLACE_MODE_BTN_LABEL,
  101929. className: 'codicon toggle left',
  101930. onTrigger: function () {
  101931. _this._state.change({ isReplaceRevealed: !_this._isReplaceVisible }, false);
  101932. if (_this._isReplaceVisible) {
  101933. _this._replaceInput.width = dom.getTotalWidth(_this._findInput.domNode);
  101934. _this._replaceInput.inputBox.layout();
  101935. }
  101936. _this._showViewZone();
  101937. }
  101938. }));
  101939. this._toggleReplaceBtn.toggleClass('codicon-chevron-down', this._isReplaceVisible);
  101940. this._toggleReplaceBtn.toggleClass('codicon-chevron-right', !this._isReplaceVisible);
  101941. this._toggleReplaceBtn.setExpanded(this._isReplaceVisible);
  101942. // Widget
  101943. this._domNode = document.createElement('div');
  101944. this._domNode.className = 'editor-widget find-widget';
  101945. this._domNode.setAttribute('aria-hidden', 'true');
  101946. // We need to set this explicitly, otherwise on IE11, the width inheritence of flex doesn't work.
  101947. this._domNode.style.width = FIND_WIDGET_INITIAL_WIDTH + "px";
  101948. this._domNode.appendChild(this._toggleReplaceBtn.domNode);
  101949. this._domNode.appendChild(findPart);
  101950. this._domNode.appendChild(replacePart);
  101951. this._resizeSash = new sash_1.Sash(this._domNode, this, { orientation: 0 /* VERTICAL */ });
  101952. this._resized = false;
  101953. var originalWidth = FIND_WIDGET_INITIAL_WIDTH;
  101954. this._register(this._resizeSash.onDidStart(function () {
  101955. originalWidth = dom.getTotalWidth(_this._domNode);
  101956. }));
  101957. this._register(this._resizeSash.onDidChange(function (evt) {
  101958. _this._resized = true;
  101959. var width = originalWidth + evt.startX - evt.currentX;
  101960. if (width < FIND_WIDGET_INITIAL_WIDTH) {
  101961. // narrow down the find widget should be handled by CSS.
  101962. return;
  101963. }
  101964. var maxWidth = parseFloat(dom.getComputedStyle(_this._domNode).maxWidth) || 0;
  101965. if (width > maxWidth) {
  101966. return;
  101967. }
  101968. _this._domNode.style.width = width + "px";
  101969. if (_this._isReplaceVisible) {
  101970. _this._replaceInput.width = dom.getTotalWidth(_this._findInput.domNode);
  101971. }
  101972. _this._findInput.inputBox.layout();
  101973. _this._tryUpdateHeight();
  101974. }));
  101975. this._register(this._resizeSash.onDidReset(function () {
  101976. // users double click on the sash
  101977. var currentWidth = dom.getTotalWidth(_this._domNode);
  101978. if (currentWidth < FIND_WIDGET_INITIAL_WIDTH) {
  101979. // The editor is narrow and the width of the find widget is controlled fully by CSS.
  101980. return;
  101981. }
  101982. var width = FIND_WIDGET_INITIAL_WIDTH;
  101983. if (!_this._resized || currentWidth === FIND_WIDGET_INITIAL_WIDTH) {
  101984. // 1. never resized before, double click should maximizes it
  101985. // 2. users resized it already but its width is the same as default
  101986. var layoutInfo = _this._codeEditor.getLayoutInfo();
  101987. width = layoutInfo.width - 28 - layoutInfo.minimapWidth - 15;
  101988. _this._resized = true;
  101989. }
  101990. else {
  101991. /**
  101992. * no op, the find widget should be shrinked to its default size.
  101993. */
  101994. }
  101995. _this._domNode.style.width = width + "px";
  101996. if (_this._isReplaceVisible) {
  101997. _this._replaceInput.width = dom.getTotalWidth(_this._findInput.domNode);
  101998. }
  101999. _this._findInput.inputBox.layout();
  102000. }));
  102001. };
  102002. FindWidget.prototype.updateAccessibilitySupport = function () {
  102003. var value = this._codeEditor.getOption(2 /* accessibilitySupport */);
  102004. this._findInput.setFocusInputOnOptionClick(value !== 2 /* Enabled */);
  102005. };
  102006. FindWidget.ID = 'editor.contrib.findWidget';
  102007. return FindWidget;
  102008. }(widget_1.Widget));
  102009. exports.FindWidget = FindWidget;
  102010. var SimpleButton = /** @class */ (function (_super) {
  102011. __extends(SimpleButton, _super);
  102012. function SimpleButton(opts) {
  102013. var _this = _super.call(this) || this;
  102014. _this._opts = opts;
  102015. _this._domNode = document.createElement('div');
  102016. _this._domNode.title = _this._opts.label;
  102017. _this._domNode.tabIndex = 0;
  102018. _this._domNode.className = 'button ' + _this._opts.className;
  102019. _this._domNode.setAttribute('role', 'button');
  102020. _this._domNode.setAttribute('aria-label', _this._opts.label);
  102021. _this.onclick(_this._domNode, function (e) {
  102022. _this._opts.onTrigger();
  102023. e.preventDefault();
  102024. });
  102025. _this.onkeydown(_this._domNode, function (e) {
  102026. if (e.equals(10 /* Space */) || e.equals(3 /* Enter */)) {
  102027. _this._opts.onTrigger();
  102028. e.preventDefault();
  102029. return;
  102030. }
  102031. if (_this._opts.onKeyDown) {
  102032. _this._opts.onKeyDown(e);
  102033. }
  102034. });
  102035. return _this;
  102036. }
  102037. Object.defineProperty(SimpleButton.prototype, "domNode", {
  102038. get: function () {
  102039. return this._domNode;
  102040. },
  102041. enumerable: true,
  102042. configurable: true
  102043. });
  102044. SimpleButton.prototype.isEnabled = function () {
  102045. return (this._domNode.tabIndex >= 0);
  102046. };
  102047. SimpleButton.prototype.focus = function () {
  102048. this._domNode.focus();
  102049. };
  102050. SimpleButton.prototype.setEnabled = function (enabled) {
  102051. dom.toggleClass(this._domNode, 'disabled', !enabled);
  102052. this._domNode.setAttribute('aria-disabled', String(!enabled));
  102053. this._domNode.tabIndex = enabled ? 0 : -1;
  102054. };
  102055. SimpleButton.prototype.setExpanded = function (expanded) {
  102056. this._domNode.setAttribute('aria-expanded', String(!!expanded));
  102057. };
  102058. SimpleButton.prototype.toggleClass = function (className, shouldHaveIt) {
  102059. dom.toggleClass(this._domNode, className, shouldHaveIt);
  102060. };
  102061. return SimpleButton;
  102062. }(widget_1.Widget));
  102063. exports.SimpleButton = SimpleButton;
  102064. // theming
  102065. themeService_1.registerThemingParticipant(function (theme, collector) {
  102066. var addBackgroundColorRule = function (selector, color) {
  102067. if (color) {
  102068. collector.addRule(".monaco-editor " + selector + " { background-color: " + color + "; }");
  102069. }
  102070. };
  102071. addBackgroundColorRule('.findMatch', theme.getColor(colorRegistry_1.editorFindMatchHighlight));
  102072. addBackgroundColorRule('.currentFindMatch', theme.getColor(colorRegistry_1.editorFindMatch));
  102073. addBackgroundColorRule('.findScope', theme.getColor(colorRegistry_1.editorFindRangeHighlight));
  102074. var widgetBackground = theme.getColor(colorRegistry_1.editorWidgetBackground);
  102075. addBackgroundColorRule('.find-widget', widgetBackground);
  102076. var widgetShadowColor = theme.getColor(colorRegistry_1.widgetShadow);
  102077. if (widgetShadowColor) {
  102078. collector.addRule(".monaco-editor .find-widget { box-shadow: 0 2px 8px " + widgetShadowColor + "; }");
  102079. }
  102080. var findMatchHighlightBorder = theme.getColor(colorRegistry_1.editorFindMatchHighlightBorder);
  102081. if (findMatchHighlightBorder) {
  102082. collector.addRule(".monaco-editor .findMatch { border: 1px " + (theme.type === 'hc' ? 'dotted' : 'solid') + " " + findMatchHighlightBorder + "; box-sizing: border-box; }");
  102083. }
  102084. var findMatchBorder = theme.getColor(colorRegistry_1.editorFindMatchBorder);
  102085. if (findMatchBorder) {
  102086. collector.addRule(".monaco-editor .currentFindMatch { border: 2px solid " + findMatchBorder + "; padding: 1px; box-sizing: border-box; }");
  102087. }
  102088. var findRangeHighlightBorder = theme.getColor(colorRegistry_1.editorFindRangeHighlightBorder);
  102089. if (findRangeHighlightBorder) {
  102090. collector.addRule(".monaco-editor .findScope { border: 1px " + (theme.type === 'hc' ? 'dashed' : 'solid') + " " + findRangeHighlightBorder + "; }");
  102091. }
  102092. var hcBorder = theme.getColor(colorRegistry_1.contrastBorder);
  102093. if (hcBorder) {
  102094. collector.addRule(".monaco-editor .find-widget { border: 1px solid " + hcBorder + "; }");
  102095. }
  102096. var foreground = theme.getColor(colorRegistry_1.editorWidgetForeground);
  102097. if (foreground) {
  102098. collector.addRule(".monaco-editor .find-widget { color: " + foreground + "; }");
  102099. }
  102100. var error = theme.getColor(colorRegistry_1.errorForeground);
  102101. if (error) {
  102102. collector.addRule(".monaco-editor .find-widget.no-results .matchesCount { color: " + error + "; }");
  102103. }
  102104. var resizeBorderBackground = theme.getColor(colorRegistry_1.editorWidgetResizeBorder);
  102105. if (resizeBorderBackground) {
  102106. collector.addRule(".monaco-editor .find-widget .monaco-sash { background-color: " + resizeBorderBackground + "; width: 3px !important; margin-left: -4px;}");
  102107. }
  102108. else {
  102109. var border = theme.getColor(colorRegistry_1.editorWidgetBorder);
  102110. if (border) {
  102111. collector.addRule(".monaco-editor .find-widget .monaco-sash { background-color: " + border + "; width: 3px !important; margin-left: -4px;}");
  102112. }
  102113. }
  102114. // This rule is used to override the outline color for synthetic-focus find input.
  102115. var focusOutline = theme.getColor(colorRegistry_1.focusBorder);
  102116. if (focusOutline) {
  102117. collector.addRule(".monaco-editor .find-widget .monaco-inputbox.synthetic-focus { outline-color: " + focusOutline + "; }");
  102118. }
  102119. });
  102120. });
  102121. /*---------------------------------------------------------------------------------------------
  102122. * Copyright (c) Microsoft Corporation. All rights reserved.
  102123. * Licensed under the MIT License. See License.txt in the project root for license information.
  102124. *--------------------------------------------------------------------------------------------*/
  102125. define(__m[232/*vs/editor/contrib/find/findController*/], __M([0/*require*/,1/*exports*/,438/*vs/nls!vs/editor/contrib/find/findController*/,15/*vs/base/common/async*/,2/*vs/base/common/lifecycle*/,5/*vs/base/common/strings*/,12/*vs/editor/browser/editorExtensions*/,23/*vs/editor/common/editorContextKeys*/,168/*vs/editor/contrib/find/findModel*/,572/*vs/editor/contrib/find/findOptionsWidget*/,378/*vs/editor/contrib/find/findState*/,573/*vs/editor/contrib/find/findWidget*/,162/*vs/platform/clipboard/common/clipboardService*/,18/*vs/platform/contextkey/common/contextkey*/,66/*vs/platform/contextview/browser/contextView*/,11/*vs/platform/instantiation/common/instantiation*/,34/*vs/platform/keybinding/common/keybinding*/,74/*vs/platform/storage/common/storage*/,14/*vs/platform/theme/common/themeService*/,35/*vs/platform/notification/common/notification*/]), function (require, exports, nls, async_1, lifecycle_1, strings, editorExtensions_1, editorContextKeys_1, findModel_1, findOptionsWidget_1, findState_1, findWidget_1, clipboardService_1, contextkey_1, contextView_1, instantiation_1, keybinding_1, storage_1, themeService_1, notification_1) {
  102126. "use strict";
  102127. Object.defineProperty(exports, "__esModule", { value: true });
  102128. var SEARCH_STRING_MAX_LENGTH = 524288;
  102129. function getSelectionSearchString(editor) {
  102130. if (!editor.hasModel()) {
  102131. return null;
  102132. }
  102133. var selection = editor.getSelection();
  102134. // if selection spans multiple lines, default search string to empty
  102135. if (selection.startLineNumber === selection.endLineNumber) {
  102136. if (selection.isEmpty()) {
  102137. var wordAtPosition = editor.getModel().getWordAtPosition(selection.getStartPosition());
  102138. if (wordAtPosition) {
  102139. return wordAtPosition.word;
  102140. }
  102141. }
  102142. else {
  102143. if (editor.getModel().getValueLengthInRange(selection) < SEARCH_STRING_MAX_LENGTH) {
  102144. return editor.getModel().getValueInRange(selection);
  102145. }
  102146. }
  102147. }
  102148. return null;
  102149. }
  102150. exports.getSelectionSearchString = getSelectionSearchString;
  102151. var CommonFindController = /** @class */ (function (_super) {
  102152. __extends(CommonFindController, _super);
  102153. function CommonFindController(editor, contextKeyService, storageService, clipboardService) {
  102154. var _this = _super.call(this) || this;
  102155. _this._editor = editor;
  102156. _this._findWidgetVisible = findModel_1.CONTEXT_FIND_WIDGET_VISIBLE.bindTo(contextKeyService);
  102157. _this._contextKeyService = contextKeyService;
  102158. _this._storageService = storageService;
  102159. _this._clipboardService = clipboardService;
  102160. _this._updateHistoryDelayer = new async_1.Delayer(500);
  102161. _this._state = _this._register(new findState_1.FindReplaceState());
  102162. _this.loadQueryState();
  102163. _this._register(_this._state.onFindReplaceStateChange(function (e) { return _this._onStateChanged(e); }));
  102164. _this._model = null;
  102165. _this._register(_this._editor.onDidChangeModel(function () {
  102166. var shouldRestartFind = (_this._editor.getModel() && _this._state.isRevealed);
  102167. _this.disposeModel();
  102168. _this._state.change({
  102169. searchScope: null,
  102170. matchCase: _this._storageService.getBoolean('editor.matchCase', 1 /* WORKSPACE */, false),
  102171. wholeWord: _this._storageService.getBoolean('editor.wholeWord', 1 /* WORKSPACE */, false),
  102172. isRegex: _this._storageService.getBoolean('editor.isRegex', 1 /* WORKSPACE */, false),
  102173. preserveCase: _this._storageService.getBoolean('editor.preserveCase', 1 /* WORKSPACE */, false)
  102174. }, false);
  102175. if (shouldRestartFind) {
  102176. _this._start({
  102177. forceRevealReplace: false,
  102178. seedSearchStringFromSelection: false && _this._editor.getOption(28 /* find */).seedSearchStringFromSelection,
  102179. seedSearchStringFromGlobalClipboard: false,
  102180. shouldFocus: 0 /* NoFocusChange */,
  102181. shouldAnimate: false,
  102182. updateSearchScope: false
  102183. });
  102184. }
  102185. }));
  102186. return _this;
  102187. }
  102188. CommonFindController.get = function (editor) {
  102189. return editor.getContribution(CommonFindController.ID);
  102190. };
  102191. CommonFindController.prototype.dispose = function () {
  102192. this.disposeModel();
  102193. _super.prototype.dispose.call(this);
  102194. };
  102195. CommonFindController.prototype.disposeModel = function () {
  102196. if (this._model) {
  102197. this._model.dispose();
  102198. this._model = null;
  102199. }
  102200. };
  102201. CommonFindController.prototype._onStateChanged = function (e) {
  102202. this.saveQueryState(e);
  102203. if (e.isRevealed) {
  102204. if (this._state.isRevealed) {
  102205. this._findWidgetVisible.set(true);
  102206. }
  102207. else {
  102208. this._findWidgetVisible.reset();
  102209. this.disposeModel();
  102210. }
  102211. }
  102212. if (e.searchString) {
  102213. this.setGlobalBufferTerm(this._state.searchString);
  102214. }
  102215. };
  102216. CommonFindController.prototype.saveQueryState = function (e) {
  102217. if (e.isRegex) {
  102218. this._storageService.store('editor.isRegex', this._state.actualIsRegex, 1 /* WORKSPACE */);
  102219. }
  102220. if (e.wholeWord) {
  102221. this._storageService.store('editor.wholeWord', this._state.actualWholeWord, 1 /* WORKSPACE */);
  102222. }
  102223. if (e.matchCase) {
  102224. this._storageService.store('editor.matchCase', this._state.actualMatchCase, 1 /* WORKSPACE */);
  102225. }
  102226. if (e.preserveCase) {
  102227. this._storageService.store('editor.preserveCase', this._state.actualPreserveCase, 1 /* WORKSPACE */);
  102228. }
  102229. };
  102230. CommonFindController.prototype.loadQueryState = function () {
  102231. this._state.change({
  102232. matchCase: this._storageService.getBoolean('editor.matchCase', 1 /* WORKSPACE */, this._state.matchCase),
  102233. wholeWord: this._storageService.getBoolean('editor.wholeWord', 1 /* WORKSPACE */, this._state.wholeWord),
  102234. isRegex: this._storageService.getBoolean('editor.isRegex', 1 /* WORKSPACE */, this._state.isRegex),
  102235. preserveCase: this._storageService.getBoolean('editor.preserveCase', 1 /* WORKSPACE */, this._state.preserveCase)
  102236. }, false);
  102237. };
  102238. CommonFindController.prototype.isFindInputFocused = function () {
  102239. return !!findModel_1.CONTEXT_FIND_INPUT_FOCUSED.getValue(this._contextKeyService);
  102240. };
  102241. CommonFindController.prototype.getState = function () {
  102242. return this._state;
  102243. };
  102244. CommonFindController.prototype.closeFindWidget = function () {
  102245. this._state.change({
  102246. isRevealed: false,
  102247. searchScope: null
  102248. }, false);
  102249. this._editor.focus();
  102250. };
  102251. CommonFindController.prototype.toggleCaseSensitive = function () {
  102252. this._state.change({ matchCase: !this._state.matchCase }, false);
  102253. if (!this._state.isRevealed) {
  102254. this.highlightFindOptions();
  102255. }
  102256. };
  102257. CommonFindController.prototype.toggleWholeWords = function () {
  102258. this._state.change({ wholeWord: !this._state.wholeWord }, false);
  102259. if (!this._state.isRevealed) {
  102260. this.highlightFindOptions();
  102261. }
  102262. };
  102263. CommonFindController.prototype.toggleRegex = function () {
  102264. this._state.change({ isRegex: !this._state.isRegex }, false);
  102265. if (!this._state.isRevealed) {
  102266. this.highlightFindOptions();
  102267. }
  102268. };
  102269. CommonFindController.prototype.toggleSearchScope = function () {
  102270. if (this._state.searchScope) {
  102271. this._state.change({ searchScope: null }, true);
  102272. }
  102273. else {
  102274. if (this._editor.hasModel()) {
  102275. var selection = this._editor.getSelection();
  102276. if (selection.endColumn === 1 && selection.endLineNumber > selection.startLineNumber) {
  102277. selection = selection.setEndPosition(selection.endLineNumber - 1, this._editor.getModel().getLineMaxColumn(selection.endLineNumber - 1));
  102278. }
  102279. if (!selection.isEmpty()) {
  102280. this._state.change({ searchScope: selection }, true);
  102281. }
  102282. }
  102283. }
  102284. };
  102285. CommonFindController.prototype.setSearchString = function (searchString) {
  102286. if (this._state.isRegex) {
  102287. searchString = strings.escapeRegExpCharacters(searchString);
  102288. }
  102289. this._state.change({ searchString: searchString }, false);
  102290. };
  102291. CommonFindController.prototype.highlightFindOptions = function () {
  102292. // overwritten in subclass
  102293. };
  102294. CommonFindController.prototype._start = function (opts) {
  102295. this.disposeModel();
  102296. if (!this._editor.hasModel()) {
  102297. // cannot do anything with an editor that doesn't have a model...
  102298. return;
  102299. }
  102300. var stateChanges = {
  102301. isRevealed: true
  102302. };
  102303. if (opts.seedSearchStringFromSelection) {
  102304. var selectionSearchString = getSelectionSearchString(this._editor);
  102305. if (selectionSearchString) {
  102306. if (this._state.isRegex) {
  102307. stateChanges.searchString = strings.escapeRegExpCharacters(selectionSearchString);
  102308. }
  102309. else {
  102310. stateChanges.searchString = selectionSearchString;
  102311. }
  102312. }
  102313. }
  102314. if (!stateChanges.searchString && opts.seedSearchStringFromGlobalClipboard) {
  102315. var selectionSearchString = this.getGlobalBufferTerm();
  102316. if (selectionSearchString) {
  102317. stateChanges.searchString = selectionSearchString;
  102318. }
  102319. }
  102320. // Overwrite isReplaceRevealed
  102321. if (opts.forceRevealReplace) {
  102322. stateChanges.isReplaceRevealed = true;
  102323. }
  102324. else if (!this._findWidgetVisible.get()) {
  102325. stateChanges.isReplaceRevealed = false;
  102326. }
  102327. if (opts.updateSearchScope) {
  102328. var currentSelection = this._editor.getSelection();
  102329. if (!currentSelection.isEmpty()) {
  102330. stateChanges.searchScope = currentSelection;
  102331. }
  102332. }
  102333. this._state.change(stateChanges, false);
  102334. if (!this._model) {
  102335. this._model = new findModel_1.FindModelBoundToEditorModel(this._editor, this._state);
  102336. }
  102337. };
  102338. CommonFindController.prototype.start = function (opts) {
  102339. this._start(opts);
  102340. };
  102341. CommonFindController.prototype.moveToNextMatch = function () {
  102342. if (this._model) {
  102343. this._model.moveToNextMatch();
  102344. return true;
  102345. }
  102346. return false;
  102347. };
  102348. CommonFindController.prototype.moveToPrevMatch = function () {
  102349. if (this._model) {
  102350. this._model.moveToPrevMatch();
  102351. return true;
  102352. }
  102353. return false;
  102354. };
  102355. CommonFindController.prototype.replace = function () {
  102356. if (this._model) {
  102357. this._model.replace();
  102358. return true;
  102359. }
  102360. return false;
  102361. };
  102362. CommonFindController.prototype.replaceAll = function () {
  102363. if (this._model) {
  102364. this._model.replaceAll();
  102365. return true;
  102366. }
  102367. return false;
  102368. };
  102369. CommonFindController.prototype.selectAllMatches = function () {
  102370. if (this._model) {
  102371. this._model.selectAllMatches();
  102372. this._editor.focus();
  102373. return true;
  102374. }
  102375. return false;
  102376. };
  102377. CommonFindController.prototype.getGlobalBufferTerm = function () {
  102378. if (this._editor.getOption(28 /* find */).globalFindClipboard
  102379. && this._clipboardService
  102380. && this._editor.hasModel()
  102381. && !this._editor.getModel().isTooLargeForSyncing()) {
  102382. return this._clipboardService.readFindText();
  102383. }
  102384. return '';
  102385. };
  102386. CommonFindController.prototype.setGlobalBufferTerm = function (text) {
  102387. if (this._editor.getOption(28 /* find */).globalFindClipboard
  102388. && this._clipboardService
  102389. && this._editor.hasModel()
  102390. && !this._editor.getModel().isTooLargeForSyncing()) {
  102391. this._clipboardService.writeFindText(text);
  102392. }
  102393. };
  102394. CommonFindController.ID = 'editor.contrib.findController';
  102395. CommonFindController = __decorate([
  102396. __param(1, contextkey_1.IContextKeyService),
  102397. __param(2, storage_1.IStorageService),
  102398. __param(3, clipboardService_1.IClipboardService)
  102399. ], CommonFindController);
  102400. return CommonFindController;
  102401. }(lifecycle_1.Disposable));
  102402. exports.CommonFindController = CommonFindController;
  102403. var FindController = /** @class */ (function (_super) {
  102404. __extends(FindController, _super);
  102405. function FindController(editor, _contextViewService, _contextKeyService, _keybindingService, _themeService, _notificationService, _storageService, clipboardService) {
  102406. var _this = _super.call(this, editor, _contextKeyService, _storageService, clipboardService) || this;
  102407. _this._contextViewService = _contextViewService;
  102408. _this._keybindingService = _keybindingService;
  102409. _this._themeService = _themeService;
  102410. _this._notificationService = _notificationService;
  102411. _this._widget = null;
  102412. _this._findOptionsWidget = null;
  102413. return _this;
  102414. }
  102415. FindController.prototype._start = function (opts) {
  102416. if (!this._widget) {
  102417. this._createFindWidget();
  102418. }
  102419. var selection = this._editor.getSelection();
  102420. var updateSearchScope = false;
  102421. switch (this._editor.getOption(28 /* find */).autoFindInSelection) {
  102422. case 'always':
  102423. updateSearchScope = true;
  102424. break;
  102425. case 'never':
  102426. updateSearchScope = false;
  102427. break;
  102428. case 'multiline':
  102429. var isSelectionMultipleLine = !!selection && selection.startLineNumber !== selection.endLineNumber;
  102430. updateSearchScope = isSelectionMultipleLine;
  102431. break;
  102432. default:
  102433. break;
  102434. }
  102435. opts.updateSearchScope = updateSearchScope;
  102436. _super.prototype._start.call(this, opts);
  102437. if (opts.shouldFocus === 2 /* FocusReplaceInput */) {
  102438. this._widget.focusReplaceInput();
  102439. }
  102440. else if (opts.shouldFocus === 1 /* FocusFindInput */) {
  102441. this._widget.focusFindInput();
  102442. }
  102443. };
  102444. FindController.prototype.highlightFindOptions = function () {
  102445. if (!this._widget) {
  102446. this._createFindWidget();
  102447. }
  102448. if (this._state.isRevealed) {
  102449. this._widget.highlightFindOptions();
  102450. }
  102451. else {
  102452. this._findOptionsWidget.highlightFindOptions();
  102453. }
  102454. };
  102455. FindController.prototype._createFindWidget = function () {
  102456. this._widget = this._register(new findWidget_1.FindWidget(this._editor, this, this._state, this._contextViewService, this._keybindingService, this._contextKeyService, this._themeService, this._storageService, this._notificationService));
  102457. this._findOptionsWidget = this._register(new findOptionsWidget_1.FindOptionsWidget(this._editor, this._state, this._keybindingService, this._themeService));
  102458. };
  102459. FindController = __decorate([
  102460. __param(1, contextView_1.IContextViewService),
  102461. __param(2, contextkey_1.IContextKeyService),
  102462. __param(3, keybinding_1.IKeybindingService),
  102463. __param(4, themeService_1.IThemeService),
  102464. __param(5, notification_1.INotificationService),
  102465. __param(6, storage_1.IStorageService),
  102466. __param(7, instantiation_1.optional(clipboardService_1.IClipboardService))
  102467. ], FindController);
  102468. return FindController;
  102469. }(CommonFindController));
  102470. exports.FindController = FindController;
  102471. var StartFindAction = /** @class */ (function (_super) {
  102472. __extends(StartFindAction, _super);
  102473. function StartFindAction() {
  102474. return _super.call(this, {
  102475. id: findModel_1.FIND_IDS.StartFindAction,
  102476. label: nls.localize(0, null),
  102477. alias: 'Find',
  102478. precondition: undefined,
  102479. kbOpts: {
  102480. kbExpr: null,
  102481. primary: 2048 /* CtrlCmd */ | 36 /* KEY_F */,
  102482. weight: 100 /* EditorContrib */
  102483. },
  102484. menuOpts: {
  102485. menuId: 17 /* MenubarEditMenu */,
  102486. group: '3_find',
  102487. title: nls.localize(1, null),
  102488. order: 1
  102489. }
  102490. }) || this;
  102491. }
  102492. StartFindAction.prototype.run = function (accessor, editor) {
  102493. var controller = CommonFindController.get(editor);
  102494. if (controller) {
  102495. controller.start({
  102496. forceRevealReplace: false,
  102497. seedSearchStringFromSelection: editor.getOption(28 /* find */).seedSearchStringFromSelection,
  102498. seedSearchStringFromGlobalClipboard: editor.getOption(28 /* find */).globalFindClipboard,
  102499. shouldFocus: 1 /* FocusFindInput */,
  102500. shouldAnimate: true,
  102501. updateSearchScope: false
  102502. });
  102503. }
  102504. };
  102505. return StartFindAction;
  102506. }(editorExtensions_1.EditorAction));
  102507. exports.StartFindAction = StartFindAction;
  102508. var StartFindWithSelectionAction = /** @class */ (function (_super) {
  102509. __extends(StartFindWithSelectionAction, _super);
  102510. function StartFindWithSelectionAction() {
  102511. return _super.call(this, {
  102512. id: findModel_1.FIND_IDS.StartFindWithSelection,
  102513. label: nls.localize(2, null),
  102514. alias: 'Find With Selection',
  102515. precondition: undefined,
  102516. kbOpts: {
  102517. kbExpr: null,
  102518. primary: 0,
  102519. mac: {
  102520. primary: 2048 /* CtrlCmd */ | 35 /* KEY_E */,
  102521. },
  102522. weight: 100 /* EditorContrib */
  102523. }
  102524. }) || this;
  102525. }
  102526. StartFindWithSelectionAction.prototype.run = function (accessor, editor) {
  102527. var controller = CommonFindController.get(editor);
  102528. if (controller) {
  102529. controller.start({
  102530. forceRevealReplace: false,
  102531. seedSearchStringFromSelection: true,
  102532. seedSearchStringFromGlobalClipboard: false,
  102533. shouldFocus: 0 /* NoFocusChange */,
  102534. shouldAnimate: true,
  102535. updateSearchScope: false
  102536. });
  102537. controller.setGlobalBufferTerm(controller.getState().searchString);
  102538. }
  102539. };
  102540. return StartFindWithSelectionAction;
  102541. }(editorExtensions_1.EditorAction));
  102542. exports.StartFindWithSelectionAction = StartFindWithSelectionAction;
  102543. var MatchFindAction = /** @class */ (function (_super) {
  102544. __extends(MatchFindAction, _super);
  102545. function MatchFindAction() {
  102546. return _super !== null && _super.apply(this, arguments) || this;
  102547. }
  102548. MatchFindAction.prototype.run = function (accessor, editor) {
  102549. var controller = CommonFindController.get(editor);
  102550. if (controller && !this._run(controller)) {
  102551. controller.start({
  102552. forceRevealReplace: false,
  102553. seedSearchStringFromSelection: (controller.getState().searchString.length === 0) && editor.getOption(28 /* find */).seedSearchStringFromSelection,
  102554. seedSearchStringFromGlobalClipboard: true,
  102555. shouldFocus: 0 /* NoFocusChange */,
  102556. shouldAnimate: true,
  102557. updateSearchScope: false
  102558. });
  102559. this._run(controller);
  102560. }
  102561. };
  102562. return MatchFindAction;
  102563. }(editorExtensions_1.EditorAction));
  102564. exports.MatchFindAction = MatchFindAction;
  102565. var NextMatchFindAction = /** @class */ (function (_super) {
  102566. __extends(NextMatchFindAction, _super);
  102567. function NextMatchFindAction() {
  102568. return _super.call(this, {
  102569. id: findModel_1.FIND_IDS.NextMatchFindAction,
  102570. label: nls.localize(3, null),
  102571. alias: 'Find Next',
  102572. precondition: undefined,
  102573. kbOpts: {
  102574. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102575. primary: 61 /* F3 */,
  102576. mac: { primary: 2048 /* CtrlCmd */ | 37 /* KEY_G */, secondary: [61 /* F3 */] },
  102577. weight: 100 /* EditorContrib */
  102578. }
  102579. }) || this;
  102580. }
  102581. NextMatchFindAction.prototype._run = function (controller) {
  102582. return controller.moveToNextMatch();
  102583. };
  102584. return NextMatchFindAction;
  102585. }(MatchFindAction));
  102586. exports.NextMatchFindAction = NextMatchFindAction;
  102587. var NextMatchFindAction2 = /** @class */ (function (_super) {
  102588. __extends(NextMatchFindAction2, _super);
  102589. function NextMatchFindAction2() {
  102590. return _super.call(this, {
  102591. id: findModel_1.FIND_IDS.NextMatchFindAction,
  102592. label: nls.localize(4, null),
  102593. alias: 'Find Next',
  102594. precondition: undefined,
  102595. kbOpts: {
  102596. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.focus, findModel_1.CONTEXT_FIND_INPUT_FOCUSED),
  102597. primary: 3 /* Enter */,
  102598. weight: 100 /* EditorContrib */
  102599. }
  102600. }) || this;
  102601. }
  102602. NextMatchFindAction2.prototype._run = function (controller) {
  102603. return controller.moveToNextMatch();
  102604. };
  102605. return NextMatchFindAction2;
  102606. }(MatchFindAction));
  102607. exports.NextMatchFindAction2 = NextMatchFindAction2;
  102608. var PreviousMatchFindAction = /** @class */ (function (_super) {
  102609. __extends(PreviousMatchFindAction, _super);
  102610. function PreviousMatchFindAction() {
  102611. return _super.call(this, {
  102612. id: findModel_1.FIND_IDS.PreviousMatchFindAction,
  102613. label: nls.localize(5, null),
  102614. alias: 'Find Previous',
  102615. precondition: undefined,
  102616. kbOpts: {
  102617. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102618. primary: 1024 /* Shift */ | 61 /* F3 */,
  102619. mac: { primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 37 /* KEY_G */, secondary: [1024 /* Shift */ | 61 /* F3 */] },
  102620. weight: 100 /* EditorContrib */
  102621. }
  102622. }) || this;
  102623. }
  102624. PreviousMatchFindAction.prototype._run = function (controller) {
  102625. return controller.moveToPrevMatch();
  102626. };
  102627. return PreviousMatchFindAction;
  102628. }(MatchFindAction));
  102629. exports.PreviousMatchFindAction = PreviousMatchFindAction;
  102630. var PreviousMatchFindAction2 = /** @class */ (function (_super) {
  102631. __extends(PreviousMatchFindAction2, _super);
  102632. function PreviousMatchFindAction2() {
  102633. return _super.call(this, {
  102634. id: findModel_1.FIND_IDS.PreviousMatchFindAction,
  102635. label: nls.localize(6, null),
  102636. alias: 'Find Previous',
  102637. precondition: undefined,
  102638. kbOpts: {
  102639. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.focus, findModel_1.CONTEXT_FIND_INPUT_FOCUSED),
  102640. primary: 1024 /* Shift */ | 3 /* Enter */,
  102641. weight: 100 /* EditorContrib */
  102642. }
  102643. }) || this;
  102644. }
  102645. PreviousMatchFindAction2.prototype._run = function (controller) {
  102646. return controller.moveToPrevMatch();
  102647. };
  102648. return PreviousMatchFindAction2;
  102649. }(MatchFindAction));
  102650. exports.PreviousMatchFindAction2 = PreviousMatchFindAction2;
  102651. var SelectionMatchFindAction = /** @class */ (function (_super) {
  102652. __extends(SelectionMatchFindAction, _super);
  102653. function SelectionMatchFindAction() {
  102654. return _super !== null && _super.apply(this, arguments) || this;
  102655. }
  102656. SelectionMatchFindAction.prototype.run = function (accessor, editor) {
  102657. var controller = CommonFindController.get(editor);
  102658. if (!controller) {
  102659. return;
  102660. }
  102661. var selectionSearchString = getSelectionSearchString(editor);
  102662. if (selectionSearchString) {
  102663. controller.setSearchString(selectionSearchString);
  102664. }
  102665. if (!this._run(controller)) {
  102666. controller.start({
  102667. forceRevealReplace: false,
  102668. seedSearchStringFromSelection: editor.getOption(28 /* find */).seedSearchStringFromSelection,
  102669. seedSearchStringFromGlobalClipboard: false,
  102670. shouldFocus: 0 /* NoFocusChange */,
  102671. shouldAnimate: true,
  102672. updateSearchScope: false
  102673. });
  102674. this._run(controller);
  102675. }
  102676. };
  102677. return SelectionMatchFindAction;
  102678. }(editorExtensions_1.EditorAction));
  102679. exports.SelectionMatchFindAction = SelectionMatchFindAction;
  102680. var NextSelectionMatchFindAction = /** @class */ (function (_super) {
  102681. __extends(NextSelectionMatchFindAction, _super);
  102682. function NextSelectionMatchFindAction() {
  102683. return _super.call(this, {
  102684. id: findModel_1.FIND_IDS.NextSelectionMatchFindAction,
  102685. label: nls.localize(7, null),
  102686. alias: 'Find Next Selection',
  102687. precondition: undefined,
  102688. kbOpts: {
  102689. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102690. primary: 2048 /* CtrlCmd */ | 61 /* F3 */,
  102691. weight: 100 /* EditorContrib */
  102692. }
  102693. }) || this;
  102694. }
  102695. NextSelectionMatchFindAction.prototype._run = function (controller) {
  102696. return controller.moveToNextMatch();
  102697. };
  102698. return NextSelectionMatchFindAction;
  102699. }(SelectionMatchFindAction));
  102700. exports.NextSelectionMatchFindAction = NextSelectionMatchFindAction;
  102701. var PreviousSelectionMatchFindAction = /** @class */ (function (_super) {
  102702. __extends(PreviousSelectionMatchFindAction, _super);
  102703. function PreviousSelectionMatchFindAction() {
  102704. return _super.call(this, {
  102705. id: findModel_1.FIND_IDS.PreviousSelectionMatchFindAction,
  102706. label: nls.localize(8, null),
  102707. alias: 'Find Previous Selection',
  102708. precondition: undefined,
  102709. kbOpts: {
  102710. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102711. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 61 /* F3 */,
  102712. weight: 100 /* EditorContrib */
  102713. }
  102714. }) || this;
  102715. }
  102716. PreviousSelectionMatchFindAction.prototype._run = function (controller) {
  102717. return controller.moveToPrevMatch();
  102718. };
  102719. return PreviousSelectionMatchFindAction;
  102720. }(SelectionMatchFindAction));
  102721. exports.PreviousSelectionMatchFindAction = PreviousSelectionMatchFindAction;
  102722. var StartFindReplaceAction = /** @class */ (function (_super) {
  102723. __extends(StartFindReplaceAction, _super);
  102724. function StartFindReplaceAction() {
  102725. return _super.call(this, {
  102726. id: findModel_1.FIND_IDS.StartFindReplaceAction,
  102727. label: nls.localize(9, null),
  102728. alias: 'Replace',
  102729. precondition: undefined,
  102730. kbOpts: {
  102731. kbExpr: null,
  102732. primary: 2048 /* CtrlCmd */ | 38 /* KEY_H */,
  102733. mac: { primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 36 /* KEY_F */ },
  102734. weight: 100 /* EditorContrib */
  102735. },
  102736. menuOpts: {
  102737. menuId: 17 /* MenubarEditMenu */,
  102738. group: '3_find',
  102739. title: nls.localize(10, null),
  102740. order: 2
  102741. }
  102742. }) || this;
  102743. }
  102744. StartFindReplaceAction.prototype.run = function (accessor, editor) {
  102745. if (!editor.hasModel() || editor.getOption(68 /* readOnly */)) {
  102746. return;
  102747. }
  102748. var controller = CommonFindController.get(editor);
  102749. var currentSelection = editor.getSelection();
  102750. var findInputFocused = controller.isFindInputFocused();
  102751. // we only seed search string from selection when the current selection is single line and not empty,
  102752. // + the find input is not focused
  102753. var seedSearchStringFromSelection = !currentSelection.isEmpty()
  102754. && currentSelection.startLineNumber === currentSelection.endLineNumber && editor.getOption(28 /* find */).seedSearchStringFromSelection
  102755. && !findInputFocused;
  102756. /*
  102757. * if the existing search string in find widget is empty and we don't seed search string from selection, it means the Find Input is still empty, so we should focus the Find Input instead of Replace Input.
  102758. * findInputFocused true -> seedSearchStringFromSelection false, FocusReplaceInput
  102759. * findInputFocused false, seedSearchStringFromSelection true FocusReplaceInput
  102760. * findInputFocused false seedSearchStringFromSelection false FocusFindInput
  102761. */
  102762. var shouldFocus = (findInputFocused || seedSearchStringFromSelection) ?
  102763. 2 /* FocusReplaceInput */ : 1 /* FocusFindInput */;
  102764. if (controller) {
  102765. controller.start({
  102766. forceRevealReplace: true,
  102767. seedSearchStringFromSelection: seedSearchStringFromSelection,
  102768. seedSearchStringFromGlobalClipboard: editor.getOption(28 /* find */).seedSearchStringFromSelection,
  102769. shouldFocus: shouldFocus,
  102770. shouldAnimate: true,
  102771. updateSearchScope: false
  102772. });
  102773. }
  102774. };
  102775. return StartFindReplaceAction;
  102776. }(editorExtensions_1.EditorAction));
  102777. exports.StartFindReplaceAction = StartFindReplaceAction;
  102778. editorExtensions_1.registerEditorContribution(CommonFindController.ID, FindController);
  102779. editorExtensions_1.registerEditorAction(StartFindAction);
  102780. editorExtensions_1.registerEditorAction(StartFindWithSelectionAction);
  102781. editorExtensions_1.registerEditorAction(NextMatchFindAction);
  102782. editorExtensions_1.registerEditorAction(NextMatchFindAction2);
  102783. editorExtensions_1.registerEditorAction(PreviousMatchFindAction);
  102784. editorExtensions_1.registerEditorAction(PreviousMatchFindAction2);
  102785. editorExtensions_1.registerEditorAction(NextSelectionMatchFindAction);
  102786. editorExtensions_1.registerEditorAction(PreviousSelectionMatchFindAction);
  102787. editorExtensions_1.registerEditorAction(StartFindReplaceAction);
  102788. var FindCommand = editorExtensions_1.EditorCommand.bindToContribution(CommonFindController.get);
  102789. editorExtensions_1.registerEditorCommand(new FindCommand({
  102790. id: findModel_1.FIND_IDS.CloseFindWidgetCommand,
  102791. precondition: findModel_1.CONTEXT_FIND_WIDGET_VISIBLE,
  102792. handler: function (x) { return x.closeFindWidget(); },
  102793. kbOpts: {
  102794. weight: 100 /* EditorContrib */ + 5,
  102795. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102796. primary: 9 /* Escape */,
  102797. secondary: [1024 /* Shift */ | 9 /* Escape */]
  102798. }
  102799. }));
  102800. editorExtensions_1.registerEditorCommand(new FindCommand({
  102801. id: findModel_1.FIND_IDS.ToggleCaseSensitiveCommand,
  102802. precondition: undefined,
  102803. handler: function (x) { return x.toggleCaseSensitive(); },
  102804. kbOpts: {
  102805. weight: 100 /* EditorContrib */ + 5,
  102806. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102807. primary: findModel_1.ToggleCaseSensitiveKeybinding.primary,
  102808. mac: findModel_1.ToggleCaseSensitiveKeybinding.mac,
  102809. win: findModel_1.ToggleCaseSensitiveKeybinding.win,
  102810. linux: findModel_1.ToggleCaseSensitiveKeybinding.linux
  102811. }
  102812. }));
  102813. editorExtensions_1.registerEditorCommand(new FindCommand({
  102814. id: findModel_1.FIND_IDS.ToggleWholeWordCommand,
  102815. precondition: undefined,
  102816. handler: function (x) { return x.toggleWholeWords(); },
  102817. kbOpts: {
  102818. weight: 100 /* EditorContrib */ + 5,
  102819. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102820. primary: findModel_1.ToggleWholeWordKeybinding.primary,
  102821. mac: findModel_1.ToggleWholeWordKeybinding.mac,
  102822. win: findModel_1.ToggleWholeWordKeybinding.win,
  102823. linux: findModel_1.ToggleWholeWordKeybinding.linux
  102824. }
  102825. }));
  102826. editorExtensions_1.registerEditorCommand(new FindCommand({
  102827. id: findModel_1.FIND_IDS.ToggleRegexCommand,
  102828. precondition: undefined,
  102829. handler: function (x) { return x.toggleRegex(); },
  102830. kbOpts: {
  102831. weight: 100 /* EditorContrib */ + 5,
  102832. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102833. primary: findModel_1.ToggleRegexKeybinding.primary,
  102834. mac: findModel_1.ToggleRegexKeybinding.mac,
  102835. win: findModel_1.ToggleRegexKeybinding.win,
  102836. linux: findModel_1.ToggleRegexKeybinding.linux
  102837. }
  102838. }));
  102839. editorExtensions_1.registerEditorCommand(new FindCommand({
  102840. id: findModel_1.FIND_IDS.ToggleSearchScopeCommand,
  102841. precondition: undefined,
  102842. handler: function (x) { return x.toggleSearchScope(); },
  102843. kbOpts: {
  102844. weight: 100 /* EditorContrib */ + 5,
  102845. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102846. primary: findModel_1.ToggleSearchScopeKeybinding.primary,
  102847. mac: findModel_1.ToggleSearchScopeKeybinding.mac,
  102848. win: findModel_1.ToggleSearchScopeKeybinding.win,
  102849. linux: findModel_1.ToggleSearchScopeKeybinding.linux
  102850. }
  102851. }));
  102852. editorExtensions_1.registerEditorCommand(new FindCommand({
  102853. id: findModel_1.FIND_IDS.ReplaceOneAction,
  102854. precondition: findModel_1.CONTEXT_FIND_WIDGET_VISIBLE,
  102855. handler: function (x) { return x.replace(); },
  102856. kbOpts: {
  102857. weight: 100 /* EditorContrib */ + 5,
  102858. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102859. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 22 /* KEY_1 */
  102860. }
  102861. }));
  102862. editorExtensions_1.registerEditorCommand(new FindCommand({
  102863. id: findModel_1.FIND_IDS.ReplaceOneAction,
  102864. precondition: findModel_1.CONTEXT_FIND_WIDGET_VISIBLE,
  102865. handler: function (x) { return x.replace(); },
  102866. kbOpts: {
  102867. weight: 100 /* EditorContrib */ + 5,
  102868. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.focus, findModel_1.CONTEXT_REPLACE_INPUT_FOCUSED),
  102869. primary: 3 /* Enter */
  102870. }
  102871. }));
  102872. editorExtensions_1.registerEditorCommand(new FindCommand({
  102873. id: findModel_1.FIND_IDS.ReplaceAllAction,
  102874. precondition: findModel_1.CONTEXT_FIND_WIDGET_VISIBLE,
  102875. handler: function (x) { return x.replaceAll(); },
  102876. kbOpts: {
  102877. weight: 100 /* EditorContrib */ + 5,
  102878. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102879. primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 3 /* Enter */
  102880. }
  102881. }));
  102882. editorExtensions_1.registerEditorCommand(new FindCommand({
  102883. id: findModel_1.FIND_IDS.ReplaceAllAction,
  102884. precondition: findModel_1.CONTEXT_FIND_WIDGET_VISIBLE,
  102885. handler: function (x) { return x.replaceAll(); },
  102886. kbOpts: {
  102887. weight: 100 /* EditorContrib */ + 5,
  102888. kbExpr: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.focus, findModel_1.CONTEXT_REPLACE_INPUT_FOCUSED),
  102889. primary: undefined,
  102890. mac: {
  102891. primary: 2048 /* CtrlCmd */ | 3 /* Enter */,
  102892. }
  102893. }
  102894. }));
  102895. editorExtensions_1.registerEditorCommand(new FindCommand({
  102896. id: findModel_1.FIND_IDS.SelectAllMatchesAction,
  102897. precondition: findModel_1.CONTEXT_FIND_WIDGET_VISIBLE,
  102898. handler: function (x) { return x.selectAllMatches(); },
  102899. kbOpts: {
  102900. weight: 100 /* EditorContrib */ + 5,
  102901. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  102902. primary: 512 /* Alt */ | 3 /* Enter */
  102903. }
  102904. }));
  102905. });
  102906. /*---------------------------------------------------------------------------------------------
  102907. * Copyright (c) Microsoft Corporation. All rights reserved.
  102908. * Licensed under the MIT License. See License.txt in the project root for license information.
  102909. *--------------------------------------------------------------------------------------------*/
  102910. define(__m[574/*vs/editor/contrib/folding/folding*/], __M([0/*require*/,1/*exports*/,440/*vs/nls!vs/editor/contrib/folding/folding*/,21/*vs/base/common/types*/,5/*vs/base/common/strings*/,15/*vs/base/common/async*/,36/*vs/base/common/keyCodes*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,381/*vs/editor/contrib/folding/foldingModel*/,490/*vs/editor/contrib/folding/foldingDecorations*/,23/*vs/editor/common/editorContextKeys*/,382/*vs/editor/contrib/folding/hiddenRangeModel*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/,491/*vs/editor/contrib/folding/indentRangeProvider*/,17/*vs/editor/common/modes*/,197/*vs/editor/contrib/folding/syntaxRangeProvider*/,383/*vs/editor/contrib/folding/intializingRangeProvider*/,10/*vs/base/common/errors*/,18/*vs/platform/contextkey/common/contextkey*/,14/*vs/platform/theme/common/themeService*/,20/*vs/platform/theme/common/colorRegistry*/,311/*vs/css!vs/editor/contrib/folding/folding*/]), function (require, exports, nls, types, strings_1, async_1, keyCodes_1, lifecycle_1, editorExtensions_1, foldingModel_1, foldingDecorations_1, editorContextKeys_1, hiddenRangeModel_1, languageConfigurationRegistry_1, indentRangeProvider_1, modes_1, syntaxRangeProvider_1, intializingRangeProvider_1, errors_1, contextkey_1, themeService_1, colorRegistry_1) {
  102911. "use strict";
  102912. Object.defineProperty(exports, "__esModule", { value: true });
  102913. var CONTEXT_FOLDING_ENABLED = new contextkey_1.RawContextKey('foldingEnabled', false);
  102914. var FoldingController = /** @class */ (function (_super) {
  102915. __extends(FoldingController, _super);
  102916. function FoldingController(editor, contextKeyService) {
  102917. var _this = _super.call(this) || this;
  102918. _this.contextKeyService = contextKeyService;
  102919. _this.localToDispose = _this._register(new lifecycle_1.DisposableStore());
  102920. _this.editor = editor;
  102921. var options = _this.editor.getOptions();
  102922. _this._isEnabled = options.get(30 /* folding */);
  102923. _this._useFoldingProviders = options.get(31 /* foldingStrategy */) !== 'indentation';
  102924. _this.foldingModel = null;
  102925. _this.hiddenRangeModel = null;
  102926. _this.rangeProvider = null;
  102927. _this.foldingRegionPromise = null;
  102928. _this.foldingStateMemento = null;
  102929. _this.foldingModelPromise = null;
  102930. _this.updateScheduler = null;
  102931. _this.cursorChangedScheduler = null;
  102932. _this.mouseDownInfo = null;
  102933. _this.foldingDecorationProvider = new foldingDecorations_1.FoldingDecorationProvider(editor);
  102934. _this.foldingDecorationProvider.autoHideFoldingControls = options.get(84 /* showFoldingControls */) === 'mouseover';
  102935. _this.foldingDecorationProvider.showFoldingHighlights = options.get(32 /* foldingHighlight */);
  102936. _this.foldingEnabled = CONTEXT_FOLDING_ENABLED.bindTo(_this.contextKeyService);
  102937. _this.foldingEnabled.set(_this._isEnabled);
  102938. _this._register(_this.editor.onDidChangeModel(function () { return _this.onModelChanged(); }));
  102939. _this._register(_this.editor.onDidChangeConfiguration(function (e) {
  102940. if (e.hasChanged(30 /* folding */)) {
  102941. var options_1 = _this.editor.getOptions();
  102942. _this._isEnabled = options_1.get(30 /* folding */);
  102943. _this.foldingEnabled.set(_this._isEnabled);
  102944. _this.onModelChanged();
  102945. }
  102946. if (e.hasChanged(84 /* showFoldingControls */) || e.hasChanged(32 /* foldingHighlight */)) {
  102947. var options_2 = _this.editor.getOptions();
  102948. _this.foldingDecorationProvider.autoHideFoldingControls = options_2.get(84 /* showFoldingControls */) === 'mouseover';
  102949. _this.foldingDecorationProvider.showFoldingHighlights = options_2.get(32 /* foldingHighlight */);
  102950. _this.onModelContentChanged();
  102951. }
  102952. if (e.hasChanged(31 /* foldingStrategy */)) {
  102953. var options_3 = _this.editor.getOptions();
  102954. _this._useFoldingProviders = options_3.get(31 /* foldingStrategy */) !== 'indentation';
  102955. _this.onFoldingStrategyChanged();
  102956. }
  102957. }));
  102958. _this.onModelChanged();
  102959. return _this;
  102960. }
  102961. FoldingController.get = function (editor) {
  102962. return editor.getContribution(FoldingController.ID);
  102963. };
  102964. /**
  102965. * Store view state.
  102966. */
  102967. FoldingController.prototype.saveViewState = function () {
  102968. var model = this.editor.getModel();
  102969. if (!model || !this._isEnabled || model.isTooLargeForTokenization()) {
  102970. return {};
  102971. }
  102972. if (this.foldingModel) { // disposed ?
  102973. var collapsedRegions = this.foldingModel.isInitialized ? this.foldingModel.getMemento() : this.hiddenRangeModel.getMemento();
  102974. var provider = this.rangeProvider ? this.rangeProvider.id : undefined;
  102975. return { collapsedRegions: collapsedRegions, lineCount: model.getLineCount(), provider: provider };
  102976. }
  102977. return undefined;
  102978. };
  102979. /**
  102980. * Restore view state.
  102981. */
  102982. FoldingController.prototype.restoreViewState = function (state) {
  102983. var model = this.editor.getModel();
  102984. if (!model || !this._isEnabled || model.isTooLargeForTokenization() || !this.hiddenRangeModel) {
  102985. return;
  102986. }
  102987. if (!state || !state.collapsedRegions || state.lineCount !== model.getLineCount()) {
  102988. return;
  102989. }
  102990. if (state.provider === syntaxRangeProvider_1.ID_SYNTAX_PROVIDER || state.provider === intializingRangeProvider_1.ID_INIT_PROVIDER) {
  102991. this.foldingStateMemento = state;
  102992. }
  102993. var collapsedRegions = state.collapsedRegions;
  102994. // set the hidden ranges right away, before waiting for the folding model.
  102995. if (this.hiddenRangeModel.applyMemento(collapsedRegions)) {
  102996. var foldingModel = this.getFoldingModel();
  102997. if (foldingModel) {
  102998. foldingModel.then(function (foldingModel) {
  102999. if (foldingModel) {
  103000. foldingModel.applyMemento(collapsedRegions);
  103001. }
  103002. }).then(undefined, errors_1.onUnexpectedError);
  103003. }
  103004. }
  103005. };
  103006. FoldingController.prototype.onModelChanged = function () {
  103007. var _this = this;
  103008. this.localToDispose.clear();
  103009. var model = this.editor.getModel();
  103010. if (!this._isEnabled || !model || model.isTooLargeForTokenization()) {
  103011. // huge files get no view model, so they cannot support hidden areas
  103012. return;
  103013. }
  103014. this.foldingModel = new foldingModel_1.FoldingModel(model, this.foldingDecorationProvider);
  103015. this.localToDispose.add(this.foldingModel);
  103016. this.hiddenRangeModel = new hiddenRangeModel_1.HiddenRangeModel(this.foldingModel);
  103017. this.localToDispose.add(this.hiddenRangeModel);
  103018. this.localToDispose.add(this.hiddenRangeModel.onDidChange(function (hr) { return _this.onHiddenRangesChanges(hr); }));
  103019. this.updateScheduler = new async_1.Delayer(200);
  103020. this.cursorChangedScheduler = new async_1.RunOnceScheduler(function () { return _this.revealCursor(); }, 200);
  103021. this.localToDispose.add(this.cursorChangedScheduler);
  103022. this.localToDispose.add(modes_1.FoldingRangeProviderRegistry.onDidChange(function () { return _this.onFoldingStrategyChanged(); }));
  103023. this.localToDispose.add(this.editor.onDidChangeModelLanguageConfiguration(function () { return _this.onFoldingStrategyChanged(); })); // covers model language changes as well
  103024. this.localToDispose.add(this.editor.onDidChangeModelContent(function () { return _this.onModelContentChanged(); }));
  103025. this.localToDispose.add(this.editor.onDidChangeCursorPosition(function () { return _this.onCursorPositionChanged(); }));
  103026. this.localToDispose.add(this.editor.onMouseDown(function (e) { return _this.onEditorMouseDown(e); }));
  103027. this.localToDispose.add(this.editor.onMouseUp(function (e) { return _this.onEditorMouseUp(e); }));
  103028. this.localToDispose.add({
  103029. dispose: function () {
  103030. if (_this.foldingRegionPromise) {
  103031. _this.foldingRegionPromise.cancel();
  103032. _this.foldingRegionPromise = null;
  103033. }
  103034. if (_this.updateScheduler) {
  103035. _this.updateScheduler.cancel();
  103036. }
  103037. _this.updateScheduler = null;
  103038. _this.foldingModel = null;
  103039. _this.foldingModelPromise = null;
  103040. _this.hiddenRangeModel = null;
  103041. _this.cursorChangedScheduler = null;
  103042. _this.foldingStateMemento = null;
  103043. if (_this.rangeProvider) {
  103044. _this.rangeProvider.dispose();
  103045. }
  103046. _this.rangeProvider = null;
  103047. }
  103048. });
  103049. this.onModelContentChanged();
  103050. };
  103051. FoldingController.prototype.onFoldingStrategyChanged = function () {
  103052. if (this.rangeProvider) {
  103053. this.rangeProvider.dispose();
  103054. }
  103055. this.rangeProvider = null;
  103056. this.onModelContentChanged();
  103057. };
  103058. FoldingController.prototype.getRangeProvider = function (editorModel) {
  103059. var _this = this;
  103060. if (this.rangeProvider) {
  103061. return this.rangeProvider;
  103062. }
  103063. this.rangeProvider = new indentRangeProvider_1.IndentRangeProvider(editorModel); // fallback
  103064. if (this._useFoldingProviders && this.foldingModel) {
  103065. var foldingProviders = modes_1.FoldingRangeProviderRegistry.ordered(this.foldingModel.textModel);
  103066. if (foldingProviders.length === 0 && this.foldingStateMemento && this.foldingStateMemento.collapsedRegions) {
  103067. var rangeProvider = this.rangeProvider = new intializingRangeProvider_1.InitializingRangeProvider(editorModel, this.foldingStateMemento.collapsedRegions, function () {
  103068. // if after 30 the InitializingRangeProvider is still not replaced, force a refresh
  103069. _this.foldingStateMemento = null;
  103070. _this.onFoldingStrategyChanged();
  103071. }, 30000);
  103072. return rangeProvider; // keep memento in case there are still no foldingProviders on the next request.
  103073. }
  103074. else if (foldingProviders.length > 0) {
  103075. this.rangeProvider = new syntaxRangeProvider_1.SyntaxRangeProvider(editorModel, foldingProviders);
  103076. }
  103077. }
  103078. this.foldingStateMemento = null;
  103079. return this.rangeProvider;
  103080. };
  103081. FoldingController.prototype.getFoldingModel = function () {
  103082. return this.foldingModelPromise;
  103083. };
  103084. FoldingController.prototype.onModelContentChanged = function () {
  103085. var _this = this;
  103086. if (this.updateScheduler) {
  103087. if (this.foldingRegionPromise) {
  103088. this.foldingRegionPromise.cancel();
  103089. this.foldingRegionPromise = null;
  103090. }
  103091. this.foldingModelPromise = this.updateScheduler.trigger(function () {
  103092. var foldingModel = _this.foldingModel;
  103093. if (!foldingModel) { // null if editor has been disposed, or folding turned off
  103094. return null;
  103095. }
  103096. var foldingRegionPromise = _this.foldingRegionPromise = async_1.createCancelablePromise(function (token) { return _this.getRangeProvider(foldingModel.textModel).compute(token); });
  103097. return foldingRegionPromise.then(function (foldingRanges) {
  103098. if (foldingRanges && foldingRegionPromise === _this.foldingRegionPromise) { // new request or cancelled in the meantime?
  103099. // some cursors might have moved into hidden regions, make sure they are in expanded regions
  103100. var selections = _this.editor.getSelections();
  103101. var selectionLineNumbers = selections ? selections.map(function (s) { return s.startLineNumber; }) : [];
  103102. foldingModel.update(foldingRanges, selectionLineNumbers);
  103103. }
  103104. return foldingModel;
  103105. });
  103106. }).then(undefined, function (err) {
  103107. errors_1.onUnexpectedError(err);
  103108. return null;
  103109. });
  103110. }
  103111. };
  103112. FoldingController.prototype.onHiddenRangesChanges = function (hiddenRanges) {
  103113. if (this.hiddenRangeModel && hiddenRanges.length) {
  103114. var selections = this.editor.getSelections();
  103115. if (selections) {
  103116. if (this.hiddenRangeModel.adjustSelections(selections)) {
  103117. this.editor.setSelections(selections);
  103118. }
  103119. }
  103120. }
  103121. this.editor.setHiddenAreas(hiddenRanges);
  103122. };
  103123. FoldingController.prototype.onCursorPositionChanged = function () {
  103124. if (this.hiddenRangeModel && this.hiddenRangeModel.hasRanges()) {
  103125. this.cursorChangedScheduler.schedule();
  103126. }
  103127. };
  103128. FoldingController.prototype.revealCursor = function () {
  103129. var _this = this;
  103130. var foldingModel = this.getFoldingModel();
  103131. if (!foldingModel) {
  103132. return;
  103133. }
  103134. foldingModel.then(function (foldingModel) {
  103135. if (foldingModel) {
  103136. var selections = _this.editor.getSelections();
  103137. if (selections && selections.length > 0) {
  103138. var toToggle = [];
  103139. var _loop_1 = function (selection) {
  103140. var lineNumber = selection.selectionStartLineNumber;
  103141. if (_this.hiddenRangeModel && _this.hiddenRangeModel.isHidden(lineNumber)) {
  103142. toToggle.push.apply(toToggle, foldingModel.getAllRegionsAtLine(lineNumber, function (r) { return r.isCollapsed && lineNumber > r.startLineNumber; }));
  103143. }
  103144. };
  103145. for (var _i = 0, selections_1 = selections; _i < selections_1.length; _i++) {
  103146. var selection = selections_1[_i];
  103147. _loop_1(selection);
  103148. }
  103149. if (toToggle.length) {
  103150. foldingModel.toggleCollapseState(toToggle);
  103151. _this.reveal(selections[0].getPosition());
  103152. }
  103153. }
  103154. }
  103155. }).then(undefined, errors_1.onUnexpectedError);
  103156. };
  103157. FoldingController.prototype.onEditorMouseDown = function (e) {
  103158. this.mouseDownInfo = null;
  103159. if (!this.hiddenRangeModel || !e.target || !e.target.range) {
  103160. return;
  103161. }
  103162. if (!e.event.leftButton && !e.event.middleButton) {
  103163. return;
  103164. }
  103165. var range = e.target.range;
  103166. var iconClicked = false;
  103167. switch (e.target.type) {
  103168. case 4 /* GUTTER_LINE_DECORATIONS */:
  103169. var data = e.target.detail;
  103170. var offsetLeftInGutter = e.target.element.offsetLeft;
  103171. var gutterOffsetX = data.offsetX - offsetLeftInGutter;
  103172. // const gutterOffsetX = data.offsetX - data.glyphMarginWidth - data.lineNumbersWidth - data.glyphMarginLeft;
  103173. // TODO@joao TODO@alex TODO@martin this is such that we don't collide with dirty diff
  103174. if (gutterOffsetX < 5) { // the whitespace between the border and the real folding icon border is 5px
  103175. return;
  103176. }
  103177. iconClicked = true;
  103178. break;
  103179. case 6 /* CONTENT_TEXT */: {
  103180. if (this.hiddenRangeModel.hasRanges()) {
  103181. var model = this.editor.getModel();
  103182. if (model && range.startColumn === model.getLineMaxColumn(range.startLineNumber)) {
  103183. break;
  103184. }
  103185. }
  103186. return;
  103187. }
  103188. default:
  103189. return;
  103190. }
  103191. this.mouseDownInfo = { lineNumber: range.startLineNumber, iconClicked: iconClicked };
  103192. };
  103193. FoldingController.prototype.onEditorMouseUp = function (e) {
  103194. var _this = this;
  103195. var foldingModel = this.getFoldingModel();
  103196. if (!foldingModel || !this.mouseDownInfo || !e.target) {
  103197. return;
  103198. }
  103199. var lineNumber = this.mouseDownInfo.lineNumber;
  103200. var iconClicked = this.mouseDownInfo.iconClicked;
  103201. var range = e.target.range;
  103202. if (!range || range.startLineNumber !== lineNumber) {
  103203. return;
  103204. }
  103205. if (iconClicked) {
  103206. if (e.target.type !== 4 /* GUTTER_LINE_DECORATIONS */) {
  103207. return;
  103208. }
  103209. }
  103210. else {
  103211. var model = this.editor.getModel();
  103212. if (!model || range.startColumn !== model.getLineMaxColumn(lineNumber)) {
  103213. return;
  103214. }
  103215. }
  103216. foldingModel.then(function (foldingModel) {
  103217. if (foldingModel) {
  103218. var region = foldingModel.getRegionAtLine(lineNumber);
  103219. if (region && region.startLineNumber === lineNumber) {
  103220. var isCollapsed = region.isCollapsed;
  103221. if (iconClicked || isCollapsed) {
  103222. var toToggle = [];
  103223. var recursive = e.event.middleButton || e.event.shiftKey;
  103224. if (recursive) {
  103225. for (var _i = 0, _a = foldingModel.getRegionsInside(region); _i < _a.length; _i++) {
  103226. var r = _a[_i];
  103227. if (r.isCollapsed === isCollapsed) {
  103228. toToggle.push(r);
  103229. }
  103230. }
  103231. }
  103232. // when recursive, first only collapse all children. If all are already folded or there are no children, also fold parent.
  103233. if (isCollapsed || !recursive || toToggle.length === 0) {
  103234. toToggle.push(region);
  103235. }
  103236. foldingModel.toggleCollapseState(toToggle);
  103237. _this.reveal({ lineNumber: lineNumber, column: 1 });
  103238. }
  103239. }
  103240. }
  103241. }).then(undefined, errors_1.onUnexpectedError);
  103242. };
  103243. FoldingController.prototype.reveal = function (position) {
  103244. this.editor.revealPositionInCenterIfOutsideViewport(position, 0 /* Smooth */);
  103245. };
  103246. FoldingController.ID = 'editor.contrib.folding';
  103247. FoldingController = __decorate([
  103248. __param(1, contextkey_1.IContextKeyService)
  103249. ], FoldingController);
  103250. return FoldingController;
  103251. }(lifecycle_1.Disposable));
  103252. exports.FoldingController = FoldingController;
  103253. var FoldingAction = /** @class */ (function (_super) {
  103254. __extends(FoldingAction, _super);
  103255. function FoldingAction() {
  103256. return _super !== null && _super.apply(this, arguments) || this;
  103257. }
  103258. FoldingAction.prototype.runEditorCommand = function (accessor, editor, args) {
  103259. var _this = this;
  103260. var foldingController = FoldingController.get(editor);
  103261. if (!foldingController) {
  103262. return;
  103263. }
  103264. var foldingModelPromise = foldingController.getFoldingModel();
  103265. if (foldingModelPromise) {
  103266. this.reportTelemetry(accessor, editor);
  103267. return foldingModelPromise.then(function (foldingModel) {
  103268. if (foldingModel) {
  103269. _this.invoke(foldingController, foldingModel, editor, args);
  103270. var selection = editor.getSelection();
  103271. if (selection) {
  103272. foldingController.reveal(selection.getStartPosition());
  103273. }
  103274. }
  103275. });
  103276. }
  103277. };
  103278. FoldingAction.prototype.getSelectedLines = function (editor) {
  103279. var selections = editor.getSelections();
  103280. return selections ? selections.map(function (s) { return s.startLineNumber; }) : [];
  103281. };
  103282. FoldingAction.prototype.getLineNumbers = function (args, editor) {
  103283. if (args && args.selectionLines) {
  103284. return args.selectionLines.map(function (l) { return l + 1; }); // to 0-bases line numbers
  103285. }
  103286. return this.getSelectedLines(editor);
  103287. };
  103288. FoldingAction.prototype.run = function (_accessor, _editor) {
  103289. };
  103290. return FoldingAction;
  103291. }(editorExtensions_1.EditorAction));
  103292. function foldingArgumentsConstraint(args) {
  103293. if (!types.isUndefined(args)) {
  103294. if (!types.isObject(args)) {
  103295. return false;
  103296. }
  103297. var foldingArgs = args;
  103298. if (!types.isUndefined(foldingArgs.levels) && !types.isNumber(foldingArgs.levels)) {
  103299. return false;
  103300. }
  103301. if (!types.isUndefined(foldingArgs.direction) && !types.isString(foldingArgs.direction)) {
  103302. return false;
  103303. }
  103304. if (!types.isUndefined(foldingArgs.selectionLines) && (!types.isArray(foldingArgs.selectionLines) || !foldingArgs.selectionLines.every(types.isNumber))) {
  103305. return false;
  103306. }
  103307. }
  103308. return true;
  103309. }
  103310. var UnfoldAction = /** @class */ (function (_super) {
  103311. __extends(UnfoldAction, _super);
  103312. function UnfoldAction() {
  103313. return _super.call(this, {
  103314. id: 'editor.unfold',
  103315. label: nls.localize(0, null),
  103316. alias: 'Unfold',
  103317. precondition: CONTEXT_FOLDING_ENABLED,
  103318. kbOpts: {
  103319. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103320. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 89 /* US_CLOSE_SQUARE_BRACKET */,
  103321. mac: {
  103322. primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 89 /* US_CLOSE_SQUARE_BRACKET */
  103323. },
  103324. weight: 100 /* EditorContrib */
  103325. },
  103326. description: {
  103327. description: 'Unfold the content in the editor',
  103328. args: [
  103329. {
  103330. name: 'Unfold editor argument',
  103331. description: "Property-value pairs that can be passed through this argument:\n\t\t\t\t\t\t* 'levels': Number of levels to unfold. If not set, defaults to 1.\n\t\t\t\t\t\t* 'direction': If 'up', unfold given number of levels up otherwise unfolds down.\n\t\t\t\t\t\t* 'selectionLines': The start lines (0-based) of the editor selections to apply the unfold action to. If not set, the active selection(s) will be used.\n\t\t\t\t\t\t",
  103332. constraint: foldingArgumentsConstraint,
  103333. schema: {
  103334. 'type': 'object',
  103335. 'properties': {
  103336. 'levels': {
  103337. 'type': 'number',
  103338. 'default': 1
  103339. },
  103340. 'direction': {
  103341. 'type': 'string',
  103342. 'enum': ['up', 'down'],
  103343. 'default': 'down'
  103344. },
  103345. 'selectionLines': {
  103346. 'type': 'array',
  103347. 'items': {
  103348. 'type': 'number'
  103349. }
  103350. }
  103351. }
  103352. }
  103353. }
  103354. ]
  103355. }
  103356. }) || this;
  103357. }
  103358. UnfoldAction.prototype.invoke = function (_foldingController, foldingModel, editor, args) {
  103359. var levels = args && args.levels || 1;
  103360. var lineNumbers = this.getLineNumbers(args, editor);
  103361. if (args && args.direction === 'up') {
  103362. foldingModel_1.setCollapseStateLevelsUp(foldingModel, false, levels, lineNumbers);
  103363. }
  103364. else {
  103365. foldingModel_1.setCollapseStateLevelsDown(foldingModel, false, levels, lineNumbers);
  103366. }
  103367. };
  103368. return UnfoldAction;
  103369. }(FoldingAction));
  103370. var UnFoldRecursivelyAction = /** @class */ (function (_super) {
  103371. __extends(UnFoldRecursivelyAction, _super);
  103372. function UnFoldRecursivelyAction() {
  103373. return _super.call(this, {
  103374. id: 'editor.unfoldRecursively',
  103375. label: nls.localize(1, null),
  103376. alias: 'Unfold Recursively',
  103377. precondition: CONTEXT_FOLDING_ENABLED,
  103378. kbOpts: {
  103379. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103380. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 89 /* US_CLOSE_SQUARE_BRACKET */),
  103381. weight: 100 /* EditorContrib */
  103382. }
  103383. }) || this;
  103384. }
  103385. UnFoldRecursivelyAction.prototype.invoke = function (_foldingController, foldingModel, editor, _args) {
  103386. foldingModel_1.setCollapseStateLevelsDown(foldingModel, false, Number.MAX_VALUE, this.getSelectedLines(editor));
  103387. };
  103388. return UnFoldRecursivelyAction;
  103389. }(FoldingAction));
  103390. var FoldAction = /** @class */ (function (_super) {
  103391. __extends(FoldAction, _super);
  103392. function FoldAction() {
  103393. return _super.call(this, {
  103394. id: 'editor.fold',
  103395. label: nls.localize(2, null),
  103396. alias: 'Fold',
  103397. precondition: CONTEXT_FOLDING_ENABLED,
  103398. kbOpts: {
  103399. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103400. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 87 /* US_OPEN_SQUARE_BRACKET */,
  103401. mac: {
  103402. primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 87 /* US_OPEN_SQUARE_BRACKET */
  103403. },
  103404. weight: 100 /* EditorContrib */
  103405. },
  103406. description: {
  103407. description: 'Fold the content in the editor',
  103408. args: [
  103409. {
  103410. name: 'Fold editor argument',
  103411. description: "Property-value pairs that can be passed through this argument:\n\t\t\t\t\t\t\t* 'levels': Number of levels to fold.\n\t\t\t\t\t\t\t* 'direction': If 'up', folds given number of levels up otherwise folds down.\n\t\t\t\t\t\t\t* 'selectionLines': The start lines (0-based) of the editor selections to apply the fold action to. If not set, the active selection(s) will be used.\n\t\t\t\t\t\t\tIf no levels or direction is set, folds the region at the locations or if already collapsed, the first uncollapsed parent instead.\n\t\t\t\t\t\t",
  103412. constraint: foldingArgumentsConstraint,
  103413. schema: {
  103414. 'type': 'object',
  103415. 'properties': {
  103416. 'levels': {
  103417. 'type': 'number',
  103418. },
  103419. 'direction': {
  103420. 'type': 'string',
  103421. 'enum': ['up', 'down'],
  103422. },
  103423. 'selectionLines': {
  103424. 'type': 'array',
  103425. 'items': {
  103426. 'type': 'number'
  103427. }
  103428. }
  103429. }
  103430. }
  103431. }
  103432. ]
  103433. }
  103434. }) || this;
  103435. }
  103436. FoldAction.prototype.invoke = function (_foldingController, foldingModel, editor, args) {
  103437. var lineNumbers = this.getLineNumbers(args, editor);
  103438. var levels = args && args.levels;
  103439. var direction = args && args.direction;
  103440. if (typeof levels !== 'number' && typeof direction !== 'string') {
  103441. // fold the region at the location or if already collapsed, the first uncollapsed parent instead.
  103442. foldingModel_1.setCollapseStateUp(foldingModel, true, lineNumbers);
  103443. }
  103444. else {
  103445. if (direction === 'up') {
  103446. foldingModel_1.setCollapseStateLevelsUp(foldingModel, true, levels || 1, lineNumbers);
  103447. }
  103448. else {
  103449. foldingModel_1.setCollapseStateLevelsDown(foldingModel, true, levels || 1, lineNumbers);
  103450. }
  103451. }
  103452. };
  103453. return FoldAction;
  103454. }(FoldingAction));
  103455. var ToggleFoldAction = /** @class */ (function (_super) {
  103456. __extends(ToggleFoldAction, _super);
  103457. function ToggleFoldAction() {
  103458. return _super.call(this, {
  103459. id: 'editor.toggleFold',
  103460. label: nls.localize(3, null),
  103461. alias: 'Toggle Fold',
  103462. precondition: CONTEXT_FOLDING_ENABLED,
  103463. kbOpts: {
  103464. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103465. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 42 /* KEY_L */),
  103466. weight: 100 /* EditorContrib */
  103467. }
  103468. }) || this;
  103469. }
  103470. ToggleFoldAction.prototype.invoke = function (_foldingController, foldingModel, editor) {
  103471. var selectedLines = this.getSelectedLines(editor);
  103472. foldingModel_1.toggleCollapseState(foldingModel, 1, selectedLines);
  103473. };
  103474. return ToggleFoldAction;
  103475. }(FoldingAction));
  103476. var FoldRecursivelyAction = /** @class */ (function (_super) {
  103477. __extends(FoldRecursivelyAction, _super);
  103478. function FoldRecursivelyAction() {
  103479. return _super.call(this, {
  103480. id: 'editor.foldRecursively',
  103481. label: nls.localize(4, null),
  103482. alias: 'Fold Recursively',
  103483. precondition: CONTEXT_FOLDING_ENABLED,
  103484. kbOpts: {
  103485. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103486. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 87 /* US_OPEN_SQUARE_BRACKET */),
  103487. weight: 100 /* EditorContrib */
  103488. }
  103489. }) || this;
  103490. }
  103491. FoldRecursivelyAction.prototype.invoke = function (_foldingController, foldingModel, editor) {
  103492. var selectedLines = this.getSelectedLines(editor);
  103493. foldingModel_1.setCollapseStateLevelsDown(foldingModel, true, Number.MAX_VALUE, selectedLines);
  103494. };
  103495. return FoldRecursivelyAction;
  103496. }(FoldingAction));
  103497. var FoldAllBlockCommentsAction = /** @class */ (function (_super) {
  103498. __extends(FoldAllBlockCommentsAction, _super);
  103499. function FoldAllBlockCommentsAction() {
  103500. return _super.call(this, {
  103501. id: 'editor.foldAllBlockComments',
  103502. label: nls.localize(5, null),
  103503. alias: 'Fold All Block Comments',
  103504. precondition: CONTEXT_FOLDING_ENABLED,
  103505. kbOpts: {
  103506. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103507. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 85 /* US_SLASH */),
  103508. weight: 100 /* EditorContrib */
  103509. }
  103510. }) || this;
  103511. }
  103512. FoldAllBlockCommentsAction.prototype.invoke = function (_foldingController, foldingModel, editor) {
  103513. if (foldingModel.regions.hasTypes()) {
  103514. foldingModel_1.setCollapseStateForType(foldingModel, modes_1.FoldingRangeKind.Comment.value, true);
  103515. }
  103516. else {
  103517. var editorModel = editor.getModel();
  103518. if (!editorModel) {
  103519. return;
  103520. }
  103521. var comments = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getComments(editorModel.getLanguageIdentifier().id);
  103522. if (comments && comments.blockCommentStartToken) {
  103523. var regExp = new RegExp('^\\s*' + strings_1.escapeRegExpCharacters(comments.blockCommentStartToken));
  103524. foldingModel_1.setCollapseStateForMatchingLines(foldingModel, regExp, true);
  103525. }
  103526. }
  103527. };
  103528. return FoldAllBlockCommentsAction;
  103529. }(FoldingAction));
  103530. var FoldAllRegionsAction = /** @class */ (function (_super) {
  103531. __extends(FoldAllRegionsAction, _super);
  103532. function FoldAllRegionsAction() {
  103533. return _super.call(this, {
  103534. id: 'editor.foldAllMarkerRegions',
  103535. label: nls.localize(6, null),
  103536. alias: 'Fold All Regions',
  103537. precondition: CONTEXT_FOLDING_ENABLED,
  103538. kbOpts: {
  103539. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103540. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 29 /* KEY_8 */),
  103541. weight: 100 /* EditorContrib */
  103542. }
  103543. }) || this;
  103544. }
  103545. FoldAllRegionsAction.prototype.invoke = function (_foldingController, foldingModel, editor) {
  103546. if (foldingModel.regions.hasTypes()) {
  103547. foldingModel_1.setCollapseStateForType(foldingModel, modes_1.FoldingRangeKind.Region.value, true);
  103548. }
  103549. else {
  103550. var editorModel = editor.getModel();
  103551. if (!editorModel) {
  103552. return;
  103553. }
  103554. var foldingRules = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getFoldingRules(editorModel.getLanguageIdentifier().id);
  103555. if (foldingRules && foldingRules.markers && foldingRules.markers.start) {
  103556. var regExp = new RegExp(foldingRules.markers.start);
  103557. foldingModel_1.setCollapseStateForMatchingLines(foldingModel, regExp, true);
  103558. }
  103559. }
  103560. };
  103561. return FoldAllRegionsAction;
  103562. }(FoldingAction));
  103563. var UnfoldAllRegionsAction = /** @class */ (function (_super) {
  103564. __extends(UnfoldAllRegionsAction, _super);
  103565. function UnfoldAllRegionsAction() {
  103566. return _super.call(this, {
  103567. id: 'editor.unfoldAllMarkerRegions',
  103568. label: nls.localize(7, null),
  103569. alias: 'Unfold All Regions',
  103570. precondition: CONTEXT_FOLDING_ENABLED,
  103571. kbOpts: {
  103572. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103573. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 30 /* KEY_9 */),
  103574. weight: 100 /* EditorContrib */
  103575. }
  103576. }) || this;
  103577. }
  103578. UnfoldAllRegionsAction.prototype.invoke = function (_foldingController, foldingModel, editor) {
  103579. if (foldingModel.regions.hasTypes()) {
  103580. foldingModel_1.setCollapseStateForType(foldingModel, modes_1.FoldingRangeKind.Region.value, false);
  103581. }
  103582. else {
  103583. var editorModel = editor.getModel();
  103584. if (!editorModel) {
  103585. return;
  103586. }
  103587. var foldingRules = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getFoldingRules(editorModel.getLanguageIdentifier().id);
  103588. if (foldingRules && foldingRules.markers && foldingRules.markers.start) {
  103589. var regExp = new RegExp(foldingRules.markers.start);
  103590. foldingModel_1.setCollapseStateForMatchingLines(foldingModel, regExp, false);
  103591. }
  103592. }
  103593. };
  103594. return UnfoldAllRegionsAction;
  103595. }(FoldingAction));
  103596. var FoldAllAction = /** @class */ (function (_super) {
  103597. __extends(FoldAllAction, _super);
  103598. function FoldAllAction() {
  103599. return _super.call(this, {
  103600. id: 'editor.foldAll',
  103601. label: nls.localize(8, null),
  103602. alias: 'Fold All',
  103603. precondition: CONTEXT_FOLDING_ENABLED,
  103604. kbOpts: {
  103605. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103606. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 21 /* KEY_0 */),
  103607. weight: 100 /* EditorContrib */
  103608. }
  103609. }) || this;
  103610. }
  103611. FoldAllAction.prototype.invoke = function (_foldingController, foldingModel, _editor) {
  103612. foldingModel_1.setCollapseStateLevelsDown(foldingModel, true);
  103613. };
  103614. return FoldAllAction;
  103615. }(FoldingAction));
  103616. var UnfoldAllAction = /** @class */ (function (_super) {
  103617. __extends(UnfoldAllAction, _super);
  103618. function UnfoldAllAction() {
  103619. return _super.call(this, {
  103620. id: 'editor.unfoldAll',
  103621. label: nls.localize(9, null),
  103622. alias: 'Unfold All',
  103623. precondition: CONTEXT_FOLDING_ENABLED,
  103624. kbOpts: {
  103625. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103626. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 40 /* KEY_J */),
  103627. weight: 100 /* EditorContrib */
  103628. }
  103629. }) || this;
  103630. }
  103631. UnfoldAllAction.prototype.invoke = function (_foldingController, foldingModel, _editor) {
  103632. foldingModel_1.setCollapseStateLevelsDown(foldingModel, false);
  103633. };
  103634. return UnfoldAllAction;
  103635. }(FoldingAction));
  103636. var FoldLevelAction = /** @class */ (function (_super) {
  103637. __extends(FoldLevelAction, _super);
  103638. function FoldLevelAction() {
  103639. return _super !== null && _super.apply(this, arguments) || this;
  103640. }
  103641. FoldLevelAction.prototype.getFoldingLevel = function () {
  103642. return parseInt(this.id.substr(FoldLevelAction.ID_PREFIX.length));
  103643. };
  103644. FoldLevelAction.prototype.invoke = function (_foldingController, foldingModel, editor) {
  103645. foldingModel_1.setCollapseStateAtLevel(foldingModel, this.getFoldingLevel(), true, this.getSelectedLines(editor));
  103646. };
  103647. FoldLevelAction.ID_PREFIX = 'editor.foldLevel';
  103648. FoldLevelAction.ID = function (level) { return FoldLevelAction.ID_PREFIX + level; };
  103649. return FoldLevelAction;
  103650. }(FoldingAction));
  103651. editorExtensions_1.registerEditorContribution(FoldingController.ID, FoldingController);
  103652. editorExtensions_1.registerEditorAction(UnfoldAction);
  103653. editorExtensions_1.registerEditorAction(UnFoldRecursivelyAction);
  103654. editorExtensions_1.registerEditorAction(FoldAction);
  103655. editorExtensions_1.registerEditorAction(FoldRecursivelyAction);
  103656. editorExtensions_1.registerEditorAction(FoldAllAction);
  103657. editorExtensions_1.registerEditorAction(UnfoldAllAction);
  103658. editorExtensions_1.registerEditorAction(FoldAllBlockCommentsAction);
  103659. editorExtensions_1.registerEditorAction(FoldAllRegionsAction);
  103660. editorExtensions_1.registerEditorAction(UnfoldAllRegionsAction);
  103661. editorExtensions_1.registerEditorAction(ToggleFoldAction);
  103662. for (var i = 1; i <= 7; i++) {
  103663. editorExtensions_1.registerInstantiatedEditorAction(new FoldLevelAction({
  103664. id: FoldLevelAction.ID(i),
  103665. label: nls.localize(10, null, i),
  103666. alias: "Fold Level " + i,
  103667. precondition: CONTEXT_FOLDING_ENABLED,
  103668. kbOpts: {
  103669. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103670. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | (21 /* KEY_0 */ + i)),
  103671. weight: 100 /* EditorContrib */
  103672. }
  103673. }));
  103674. }
  103675. exports.foldBackgroundBackground = colorRegistry_1.registerColor('editor.foldBackground', { light: colorRegistry_1.transparent(colorRegistry_1.editorSelectionBackground, 0.3), dark: colorRegistry_1.transparent(colorRegistry_1.editorSelectionBackground, 0.3), hc: null }, nls.localize(11, null));
  103676. themeService_1.registerThemingParticipant(function (theme, collector) {
  103677. var foldBackground = theme.getColor(exports.foldBackgroundBackground);
  103678. if (foldBackground) {
  103679. collector.addRule(".monaco-editor .folded-background { background-color: " + foldBackground + "; }");
  103680. }
  103681. });
  103682. });
  103683. /*---------------------------------------------------------------------------------------------
  103684. * Copyright (c) Microsoft Corporation. All rights reserved.
  103685. * Licensed under the MIT License. See License.txt in the project root for license information.
  103686. *--------------------------------------------------------------------------------------------*/
  103687. define(__m[575/*vs/editor/contrib/gotoSymbol/peek/referencesTree*/], __M([0/*require*/,1/*exports*/,113/*vs/editor/contrib/gotoSymbol/referencesModel*/,84/*vs/editor/common/services/resolverService*/,139/*vs/base/browser/ui/iconLabel/iconLabel*/,267/*vs/base/browser/ui/countBadge/countBadge*/,116/*vs/platform/label/common/label*/,14/*vs/platform/theme/common/themeService*/,97/*vs/platform/theme/common/styler*/,6/*vs/base/browser/dom*/,449/*vs/nls!vs/editor/contrib/gotoSymbol/peek/referencesTree*/,136/*vs/base/common/labels*/,39/*vs/base/common/resources*/,2/*vs/base/common/lifecycle*/,11/*vs/platform/instantiation/common/instantiation*/,34/*vs/platform/keybinding/common/keybinding*/,61/*vs/base/common/filters*/,133/*vs/base/browser/ui/highlightedlabel/highlightedLabel*/]), function (require, exports, referencesModel_1, resolverService_1, iconLabel_1, countBadge_1, label_1, themeService_1, styler_1, dom, nls_1, labels_1, resources_1, lifecycle_1, instantiation_1, keybinding_1, filters_1, highlightedLabel_1) {
  103688. "use strict";
  103689. Object.defineProperty(exports, "__esModule", { value: true });
  103690. var DataSource = /** @class */ (function () {
  103691. function DataSource(_resolverService) {
  103692. this._resolverService = _resolverService;
  103693. }
  103694. DataSource.prototype.hasChildren = function (element) {
  103695. if (element instanceof referencesModel_1.ReferencesModel) {
  103696. return true;
  103697. }
  103698. if (element instanceof referencesModel_1.FileReferences && !element.failure) {
  103699. return true;
  103700. }
  103701. return false;
  103702. };
  103703. DataSource.prototype.getChildren = function (element) {
  103704. if (element instanceof referencesModel_1.ReferencesModel) {
  103705. return element.groups;
  103706. }
  103707. if (element instanceof referencesModel_1.FileReferences) {
  103708. return element.resolve(this._resolverService).then(function (val) {
  103709. // if (element.failure) {
  103710. // // refresh the element on failure so that
  103711. // // we can update its rendering
  103712. // return tree.refresh(element).then(() => val.children);
  103713. // }
  103714. return val.children;
  103715. });
  103716. }
  103717. throw new Error('bad tree');
  103718. };
  103719. DataSource = __decorate([
  103720. __param(0, resolverService_1.ITextModelService)
  103721. ], DataSource);
  103722. return DataSource;
  103723. }());
  103724. exports.DataSource = DataSource;
  103725. //#endregion
  103726. var Delegate = /** @class */ (function () {
  103727. function Delegate() {
  103728. }
  103729. Delegate.prototype.getHeight = function () {
  103730. return 23;
  103731. };
  103732. Delegate.prototype.getTemplateId = function (element) {
  103733. if (element instanceof referencesModel_1.FileReferences) {
  103734. return FileReferencesRenderer.id;
  103735. }
  103736. else {
  103737. return OneReferenceRenderer.id;
  103738. }
  103739. };
  103740. return Delegate;
  103741. }());
  103742. exports.Delegate = Delegate;
  103743. var StringRepresentationProvider = /** @class */ (function () {
  103744. function StringRepresentationProvider(_keybindingService) {
  103745. this._keybindingService = _keybindingService;
  103746. }
  103747. StringRepresentationProvider.prototype.getKeyboardNavigationLabel = function (element) {
  103748. if (element instanceof referencesModel_1.OneReference) {
  103749. var preview = element.parent.preview;
  103750. var parts = preview && preview.preview(element.range);
  103751. if (parts) {
  103752. return parts.value;
  103753. }
  103754. }
  103755. // FileReferences or unresolved OneReference
  103756. return resources_1.basename(element.uri);
  103757. };
  103758. StringRepresentationProvider = __decorate([
  103759. __param(0, keybinding_1.IKeybindingService)
  103760. ], StringRepresentationProvider);
  103761. return StringRepresentationProvider;
  103762. }());
  103763. exports.StringRepresentationProvider = StringRepresentationProvider;
  103764. var IdentityProvider = /** @class */ (function () {
  103765. function IdentityProvider() {
  103766. }
  103767. IdentityProvider.prototype.getId = function (element) {
  103768. return element instanceof referencesModel_1.OneReference ? element.id : element.uri;
  103769. };
  103770. return IdentityProvider;
  103771. }());
  103772. exports.IdentityProvider = IdentityProvider;
  103773. //#region render: File
  103774. var FileReferencesTemplate = /** @class */ (function (_super) {
  103775. __extends(FileReferencesTemplate, _super);
  103776. function FileReferencesTemplate(container, _uriLabel, themeService) {
  103777. var _this = _super.call(this) || this;
  103778. _this._uriLabel = _uriLabel;
  103779. var parent = document.createElement('div');
  103780. dom.addClass(parent, 'reference-file');
  103781. _this.file = _this._register(new iconLabel_1.IconLabel(parent, { supportHighlights: true }));
  103782. _this.badge = new countBadge_1.CountBadge(dom.append(parent, dom.$('.count')));
  103783. _this._register(styler_1.attachBadgeStyler(_this.badge, themeService));
  103784. container.appendChild(parent);
  103785. return _this;
  103786. }
  103787. FileReferencesTemplate.prototype.set = function (element, matches) {
  103788. var parent = resources_1.dirname(element.uri);
  103789. this.file.setLabel(labels_1.getBaseLabel(element.uri), this._uriLabel.getUriLabel(parent, { relative: true }), { title: this._uriLabel.getUriLabel(element.uri), matches: matches });
  103790. var len = element.children.length;
  103791. this.badge.setCount(len);
  103792. if (element.failure) {
  103793. this.badge.setTitleFormat(nls_1.localize(0, null));
  103794. }
  103795. else if (len > 1) {
  103796. this.badge.setTitleFormat(nls_1.localize(1, null, len));
  103797. }
  103798. else {
  103799. this.badge.setTitleFormat(nls_1.localize(2, null, len));
  103800. }
  103801. };
  103802. FileReferencesTemplate = __decorate([
  103803. __param(1, label_1.ILabelService),
  103804. __param(2, themeService_1.IThemeService)
  103805. ], FileReferencesTemplate);
  103806. return FileReferencesTemplate;
  103807. }(lifecycle_1.Disposable));
  103808. var FileReferencesRenderer = /** @class */ (function () {
  103809. function FileReferencesRenderer(_instantiationService) {
  103810. this._instantiationService = _instantiationService;
  103811. this.templateId = FileReferencesRenderer.id;
  103812. }
  103813. FileReferencesRenderer.prototype.renderTemplate = function (container) {
  103814. return this._instantiationService.createInstance(FileReferencesTemplate, container);
  103815. };
  103816. FileReferencesRenderer.prototype.renderElement = function (node, index, template) {
  103817. template.set(node.element, filters_1.createMatches(node.filterData));
  103818. };
  103819. FileReferencesRenderer.prototype.disposeTemplate = function (templateData) {
  103820. templateData.dispose();
  103821. };
  103822. FileReferencesRenderer.id = 'FileReferencesRenderer';
  103823. FileReferencesRenderer = __decorate([
  103824. __param(0, instantiation_1.IInstantiationService)
  103825. ], FileReferencesRenderer);
  103826. return FileReferencesRenderer;
  103827. }());
  103828. exports.FileReferencesRenderer = FileReferencesRenderer;
  103829. //#endregion
  103830. //#region render: Reference
  103831. var OneReferenceTemplate = /** @class */ (function () {
  103832. function OneReferenceTemplate(container) {
  103833. this.label = new highlightedLabel_1.HighlightedLabel(container, false);
  103834. }
  103835. OneReferenceTemplate.prototype.set = function (element, score) {
  103836. var filePreview = element.parent.preview;
  103837. var preview = filePreview && filePreview.preview(element.range);
  103838. if (!preview) {
  103839. // this means we FAILED to resolve the document...
  103840. this.label.set(resources_1.basename(element.uri) + ":" + (element.range.startLineNumber + 1) + ":" + (element.range.startColumn + 1));
  103841. }
  103842. else {
  103843. // render search match as highlight unless
  103844. // we have score, then render the score
  103845. var value = preview.value, highlight = preview.highlight;
  103846. if (score && !filters_1.FuzzyScore.isDefault(score)) {
  103847. dom.toggleClass(this.label.element, 'referenceMatch', false);
  103848. this.label.set(value, filters_1.createMatches(score));
  103849. }
  103850. else {
  103851. dom.toggleClass(this.label.element, 'referenceMatch', true);
  103852. this.label.set(value, [highlight]);
  103853. }
  103854. }
  103855. };
  103856. return OneReferenceTemplate;
  103857. }());
  103858. var OneReferenceRenderer = /** @class */ (function () {
  103859. function OneReferenceRenderer() {
  103860. this.templateId = OneReferenceRenderer.id;
  103861. }
  103862. OneReferenceRenderer.prototype.renderTemplate = function (container) {
  103863. return new OneReferenceTemplate(container);
  103864. };
  103865. OneReferenceRenderer.prototype.renderElement = function (node, index, templateData) {
  103866. templateData.set(node.element, node.filterData);
  103867. };
  103868. OneReferenceRenderer.prototype.disposeTemplate = function () {
  103869. };
  103870. OneReferenceRenderer.id = 'OneReferenceRenderer';
  103871. return OneReferenceRenderer;
  103872. }());
  103873. exports.OneReferenceRenderer = OneReferenceRenderer;
  103874. //#endregion
  103875. var AriaProvider = /** @class */ (function () {
  103876. function AriaProvider() {
  103877. }
  103878. AriaProvider.prototype.getAriaLabel = function (element) {
  103879. return element.ariaMessage;
  103880. };
  103881. return AriaProvider;
  103882. }());
  103883. exports.AriaProvider = AriaProvider;
  103884. });
  103885. /*---------------------------------------------------------------------------------------------
  103886. * Copyright (c) Microsoft Corporation. All rights reserved.
  103887. * Licensed under the MIT License. See License.txt in the project root for license information.
  103888. *--------------------------------------------------------------------------------------------*/
  103889. define(__m[576/*vs/editor/contrib/inPlaceReplace/inPlaceReplace*/], __M([0/*require*/,1/*exports*/,455/*vs/nls!vs/editor/contrib/inPlaceReplace/inPlaceReplace*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,23/*vs/editor/common/editorContextKeys*/,12/*vs/editor/browser/editorExtensions*/,62/*vs/editor/common/services/editorWorkerService*/,384/*vs/editor/contrib/inPlaceReplace/inPlaceReplaceCommand*/,67/*vs/editor/browser/core/editorState*/,14/*vs/platform/theme/common/themeService*/,44/*vs/editor/common/view/editorColorRegistry*/,30/*vs/editor/common/model/textModel*/,15/*vs/base/common/async*/,10/*vs/base/common/errors*/]), function (require, exports, nls, range_1, selection_1, editorContextKeys_1, editorExtensions_1, editorWorkerService_1, inPlaceReplaceCommand_1, editorState_1, themeService_1, editorColorRegistry_1, textModel_1, async_1, errors_1) {
  103890. "use strict";
  103891. Object.defineProperty(exports, "__esModule", { value: true });
  103892. var InPlaceReplaceController = /** @class */ (function () {
  103893. function InPlaceReplaceController(editor, editorWorkerService) {
  103894. this.decorationIds = [];
  103895. this.editor = editor;
  103896. this.editorWorkerService = editorWorkerService;
  103897. }
  103898. InPlaceReplaceController.get = function (editor) {
  103899. return editor.getContribution(InPlaceReplaceController.ID);
  103900. };
  103901. InPlaceReplaceController.prototype.dispose = function () {
  103902. };
  103903. InPlaceReplaceController.prototype.run = function (source, up) {
  103904. var _this = this;
  103905. // cancel any pending request
  103906. if (this.currentRequest) {
  103907. this.currentRequest.cancel();
  103908. }
  103909. var editorSelection = this.editor.getSelection();
  103910. var model = this.editor.getModel();
  103911. if (!model || !editorSelection) {
  103912. return undefined;
  103913. }
  103914. var selection = editorSelection;
  103915. if (selection.startLineNumber !== selection.endLineNumber) {
  103916. // Can't accept multiline selection
  103917. return undefined;
  103918. }
  103919. var state = new editorState_1.EditorState(this.editor, 1 /* Value */ | 4 /* Position */);
  103920. var modelURI = model.uri;
  103921. if (!this.editorWorkerService.canNavigateValueSet(modelURI)) {
  103922. return Promise.resolve(undefined);
  103923. }
  103924. this.currentRequest = async_1.createCancelablePromise(function (token) { return _this.editorWorkerService.navigateValueSet(modelURI, selection, up); });
  103925. return this.currentRequest.then(function (result) {
  103926. if (!result || !result.range || !result.value) {
  103927. // No proper result
  103928. return;
  103929. }
  103930. if (!state.validate(_this.editor)) {
  103931. // state has changed
  103932. return;
  103933. }
  103934. // Selection
  103935. var editRange = range_1.Range.lift(result.range);
  103936. var highlightRange = result.range;
  103937. var diff = result.value.length - (selection.endColumn - selection.startColumn);
  103938. // highlight
  103939. highlightRange = {
  103940. startLineNumber: highlightRange.startLineNumber,
  103941. startColumn: highlightRange.startColumn,
  103942. endLineNumber: highlightRange.endLineNumber,
  103943. endColumn: highlightRange.startColumn + result.value.length
  103944. };
  103945. if (diff > 1) {
  103946. selection = new selection_1.Selection(selection.startLineNumber, selection.startColumn, selection.endLineNumber, selection.endColumn + diff - 1);
  103947. }
  103948. // Insert new text
  103949. var command = new inPlaceReplaceCommand_1.InPlaceReplaceCommand(editRange, selection, result.value);
  103950. _this.editor.pushUndoStop();
  103951. _this.editor.executeCommand(source, command);
  103952. _this.editor.pushUndoStop();
  103953. // add decoration
  103954. _this.decorationIds = _this.editor.deltaDecorations(_this.decorationIds, [{
  103955. range: highlightRange,
  103956. options: InPlaceReplaceController.DECORATION
  103957. }]);
  103958. // remove decoration after delay
  103959. if (_this.decorationRemover) {
  103960. _this.decorationRemover.cancel();
  103961. }
  103962. _this.decorationRemover = async_1.timeout(350);
  103963. _this.decorationRemover.then(function () { return _this.decorationIds = _this.editor.deltaDecorations(_this.decorationIds, []); }).catch(errors_1.onUnexpectedError);
  103964. }).catch(errors_1.onUnexpectedError);
  103965. };
  103966. InPlaceReplaceController.ID = 'editor.contrib.inPlaceReplaceController';
  103967. InPlaceReplaceController.DECORATION = textModel_1.ModelDecorationOptions.register({
  103968. className: 'valueSetReplacement'
  103969. });
  103970. InPlaceReplaceController = __decorate([
  103971. __param(1, editorWorkerService_1.IEditorWorkerService)
  103972. ], InPlaceReplaceController);
  103973. return InPlaceReplaceController;
  103974. }());
  103975. var InPlaceReplaceUp = /** @class */ (function (_super) {
  103976. __extends(InPlaceReplaceUp, _super);
  103977. function InPlaceReplaceUp() {
  103978. return _super.call(this, {
  103979. id: 'editor.action.inPlaceReplace.up',
  103980. label: nls.localize(0, null),
  103981. alias: 'Replace with Previous Value',
  103982. precondition: editorContextKeys_1.EditorContextKeys.writable,
  103983. kbOpts: {
  103984. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  103985. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 82 /* US_COMMA */,
  103986. weight: 100 /* EditorContrib */
  103987. }
  103988. }) || this;
  103989. }
  103990. InPlaceReplaceUp.prototype.run = function (accessor, editor) {
  103991. var controller = InPlaceReplaceController.get(editor);
  103992. if (!controller) {
  103993. return Promise.resolve(undefined);
  103994. }
  103995. return controller.run(this.id, true);
  103996. };
  103997. return InPlaceReplaceUp;
  103998. }(editorExtensions_1.EditorAction));
  103999. var InPlaceReplaceDown = /** @class */ (function (_super) {
  104000. __extends(InPlaceReplaceDown, _super);
  104001. function InPlaceReplaceDown() {
  104002. return _super.call(this, {
  104003. id: 'editor.action.inPlaceReplace.down',
  104004. label: nls.localize(1, null),
  104005. alias: 'Replace with Next Value',
  104006. precondition: editorContextKeys_1.EditorContextKeys.writable,
  104007. kbOpts: {
  104008. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  104009. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 84 /* US_DOT */,
  104010. weight: 100 /* EditorContrib */
  104011. }
  104012. }) || this;
  104013. }
  104014. InPlaceReplaceDown.prototype.run = function (accessor, editor) {
  104015. var controller = InPlaceReplaceController.get(editor);
  104016. if (!controller) {
  104017. return Promise.resolve(undefined);
  104018. }
  104019. return controller.run(this.id, false);
  104020. };
  104021. return InPlaceReplaceDown;
  104022. }(editorExtensions_1.EditorAction));
  104023. editorExtensions_1.registerEditorContribution(InPlaceReplaceController.ID, InPlaceReplaceController);
  104024. editorExtensions_1.registerEditorAction(InPlaceReplaceUp);
  104025. editorExtensions_1.registerEditorAction(InPlaceReplaceDown);
  104026. themeService_1.registerThemingParticipant(function (theme, collector) {
  104027. var border = theme.getColor(editorColorRegistry_1.editorBracketMatchBorder);
  104028. if (border) {
  104029. collector.addRule(".monaco-editor.vs .valueSetReplacement { outline: solid 2px " + border + "; }");
  104030. }
  104031. });
  104032. });
  104033. /*---------------------------------------------------------------------------------------------
  104034. * Copyright (c) Microsoft Corporation. All rights reserved.
  104035. * Licensed under the MIT License. See License.txt in the project root for license information.
  104036. *--------------------------------------------------------------------------------------------*/
  104037. define(__m[577/*vs/editor/contrib/links/links*/], __M([0/*require*/,1/*exports*/,457/*vs/nls!vs/editor/contrib/links/links*/,15/*vs/base/common/async*/,26/*vs/base/common/cancellation*/,10/*vs/base/common/errors*/,75/*vs/base/common/htmlContent*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,12/*vs/editor/browser/editorExtensions*/,30/*vs/editor/common/model/textModel*/,17/*vs/editor/common/modes*/,199/*vs/editor/contrib/gotoSymbol/link/clickLinkGesture*/,495/*vs/editor/contrib/links/getLinks*/,35/*vs/platform/notification/common/notification*/,51/*vs/platform/opener/common/opener*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,316/*vs/css!vs/editor/contrib/links/links*/]), function (require, exports, nls, async, cancellation_1, errors_1, htmlContent_1, lifecycle_1, platform, editorExtensions_1, textModel_1, modes_1, clickLinkGesture_1, getLinks_1, notification_1, opener_1, colorRegistry_1, themeService_1) {
  104038. "use strict";
  104039. Object.defineProperty(exports, "__esModule", { value: true });
  104040. function getHoverMessage(link, useMetaKey) {
  104041. var executeCmd = link.url && /^command:/i.test(link.url.toString());
  104042. var label = link.tooltip
  104043. ? link.tooltip
  104044. : executeCmd
  104045. ? nls.localize(0, null)
  104046. : nls.localize(1, null);
  104047. var kb = useMetaKey
  104048. ? platform.isMacintosh
  104049. ? nls.localize(2, null)
  104050. : nls.localize(3, null)
  104051. : platform.isMacintosh
  104052. ? nls.localize(4, null)
  104053. : nls.localize(5, null);
  104054. if (link.url) {
  104055. var hoverMessage = new htmlContent_1.MarkdownString('', true).appendMarkdown("[" + label + "](" + link.url.toString() + ") (" + kb + ")");
  104056. return hoverMessage;
  104057. }
  104058. else {
  104059. return new htmlContent_1.MarkdownString().appendText(label + " (" + kb + ")");
  104060. }
  104061. }
  104062. var decoration = {
  104063. general: textModel_1.ModelDecorationOptions.register({
  104064. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  104065. collapseOnReplaceEdit: true,
  104066. inlineClassName: 'detected-link'
  104067. }),
  104068. active: textModel_1.ModelDecorationOptions.register({
  104069. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  104070. collapseOnReplaceEdit: true,
  104071. inlineClassName: 'detected-link-active'
  104072. })
  104073. };
  104074. var LinkOccurrence = /** @class */ (function () {
  104075. function LinkOccurrence(link, decorationId) {
  104076. this.link = link;
  104077. this.decorationId = decorationId;
  104078. }
  104079. LinkOccurrence.decoration = function (link, useMetaKey) {
  104080. return {
  104081. range: link.range,
  104082. options: LinkOccurrence._getOptions(link, useMetaKey, false)
  104083. };
  104084. };
  104085. LinkOccurrence._getOptions = function (link, useMetaKey, isActive) {
  104086. var options = __assign({}, (isActive ? decoration.active : decoration.general));
  104087. options.hoverMessage = getHoverMessage(link, useMetaKey);
  104088. return options;
  104089. };
  104090. LinkOccurrence.prototype.activate = function (changeAccessor, useMetaKey) {
  104091. changeAccessor.changeDecorationOptions(this.decorationId, LinkOccurrence._getOptions(this.link, useMetaKey, true));
  104092. };
  104093. LinkOccurrence.prototype.deactivate = function (changeAccessor, useMetaKey) {
  104094. changeAccessor.changeDecorationOptions(this.decorationId, LinkOccurrence._getOptions(this.link, useMetaKey, false));
  104095. };
  104096. return LinkOccurrence;
  104097. }());
  104098. var LinkDetector = /** @class */ (function () {
  104099. function LinkDetector(editor, openerService, notificationService) {
  104100. var _this = this;
  104101. this.listenersToRemove = new lifecycle_1.DisposableStore();
  104102. this.editor = editor;
  104103. this.openerService = openerService;
  104104. this.notificationService = notificationService;
  104105. var clickLinkGesture = new clickLinkGesture_1.ClickLinkGesture(editor);
  104106. this.listenersToRemove.add(clickLinkGesture);
  104107. this.listenersToRemove.add(clickLinkGesture.onMouseMoveOrRelevantKeyDown(function (_a) {
  104108. var mouseEvent = _a[0], keyboardEvent = _a[1];
  104109. _this._onEditorMouseMove(mouseEvent, keyboardEvent);
  104110. }));
  104111. this.listenersToRemove.add(clickLinkGesture.onExecute(function (e) {
  104112. _this.onEditorMouseUp(e);
  104113. }));
  104114. this.listenersToRemove.add(clickLinkGesture.onCancel(function (e) {
  104115. _this.cleanUpActiveLinkDecoration();
  104116. }));
  104117. this.enabled = editor.getOption(52 /* links */);
  104118. this.listenersToRemove.add(editor.onDidChangeConfiguration(function (e) {
  104119. var enabled = editor.getOption(52 /* links */);
  104120. if (_this.enabled === enabled) {
  104121. // No change in our configuration option
  104122. return;
  104123. }
  104124. _this.enabled = enabled;
  104125. // Remove any links (for the getting disabled case)
  104126. _this.updateDecorations([]);
  104127. // Stop any computation (for the getting disabled case)
  104128. _this.stop();
  104129. // Start computing (for the getting enabled case)
  104130. _this.beginCompute();
  104131. }));
  104132. this.listenersToRemove.add(editor.onDidChangeModelContent(function (e) { return _this.onChange(); }));
  104133. this.listenersToRemove.add(editor.onDidChangeModel(function (e) { return _this.onModelChanged(); }));
  104134. this.listenersToRemove.add(editor.onDidChangeModelLanguage(function (e) { return _this.onModelModeChanged(); }));
  104135. this.listenersToRemove.add(modes_1.LinkProviderRegistry.onDidChange(function (e) { return _this.onModelModeChanged(); }));
  104136. this.timeout = new async.TimeoutTimer();
  104137. this.computePromise = null;
  104138. this.activeLinksList = null;
  104139. this.currentOccurrences = {};
  104140. this.activeLinkDecorationId = null;
  104141. this.beginCompute();
  104142. }
  104143. LinkDetector.get = function (editor) {
  104144. return editor.getContribution(LinkDetector.ID);
  104145. };
  104146. LinkDetector.prototype.onModelChanged = function () {
  104147. this.currentOccurrences = {};
  104148. this.activeLinkDecorationId = null;
  104149. this.stop();
  104150. this.beginCompute();
  104151. };
  104152. LinkDetector.prototype.onModelModeChanged = function () {
  104153. this.stop();
  104154. this.beginCompute();
  104155. };
  104156. LinkDetector.prototype.onChange = function () {
  104157. var _this = this;
  104158. this.timeout.setIfNotSet(function () { return _this.beginCompute(); }, LinkDetector.RECOMPUTE_TIME);
  104159. };
  104160. LinkDetector.prototype.beginCompute = function () {
  104161. return __awaiter(this, void 0, void 0, function () {
  104162. var model, _a, err_1;
  104163. return __generator(this, function (_b) {
  104164. switch (_b.label) {
  104165. case 0:
  104166. if (!this.editor.hasModel() || !this.enabled) {
  104167. return [2 /*return*/];
  104168. }
  104169. model = this.editor.getModel();
  104170. if (!modes_1.LinkProviderRegistry.has(model)) {
  104171. return [2 /*return*/];
  104172. }
  104173. if (this.activeLinksList) {
  104174. this.activeLinksList.dispose();
  104175. this.activeLinksList = null;
  104176. }
  104177. this.computePromise = async.createCancelablePromise(function (token) { return getLinks_1.getLinks(model, token); });
  104178. _b.label = 1;
  104179. case 1:
  104180. _b.trys.push([1, 3, 4, 5]);
  104181. _a = this;
  104182. return [4 /*yield*/, this.computePromise];
  104183. case 2:
  104184. _a.activeLinksList = _b.sent();
  104185. this.updateDecorations(this.activeLinksList.links);
  104186. return [3 /*break*/, 5];
  104187. case 3:
  104188. err_1 = _b.sent();
  104189. errors_1.onUnexpectedError(err_1);
  104190. return [3 /*break*/, 5];
  104191. case 4:
  104192. this.computePromise = null;
  104193. return [7 /*endfinally*/];
  104194. case 5: return [2 /*return*/];
  104195. }
  104196. });
  104197. });
  104198. };
  104199. LinkDetector.prototype.updateDecorations = function (links) {
  104200. var useMetaKey = (this.editor.getOption(59 /* multiCursorModifier */) === 'altKey');
  104201. var oldDecorations = [];
  104202. var keys = Object.keys(this.currentOccurrences);
  104203. for (var i = 0, len = keys.length; i < len; i++) {
  104204. var decorationId = keys[i];
  104205. var occurance = this.currentOccurrences[decorationId];
  104206. oldDecorations.push(occurance.decorationId);
  104207. }
  104208. var newDecorations = [];
  104209. if (links) {
  104210. // Not sure why this is sometimes null
  104211. for (var _i = 0, links_1 = links; _i < links_1.length; _i++) {
  104212. var link = links_1[_i];
  104213. newDecorations.push(LinkOccurrence.decoration(link, useMetaKey));
  104214. }
  104215. }
  104216. var decorations = this.editor.deltaDecorations(oldDecorations, newDecorations);
  104217. this.currentOccurrences = {};
  104218. this.activeLinkDecorationId = null;
  104219. for (var i = 0, len = decorations.length; i < len; i++) {
  104220. var occurance = new LinkOccurrence(links[i], decorations[i]);
  104221. this.currentOccurrences[occurance.decorationId] = occurance;
  104222. }
  104223. };
  104224. LinkDetector.prototype._onEditorMouseMove = function (mouseEvent, withKey) {
  104225. var _this = this;
  104226. var useMetaKey = (this.editor.getOption(59 /* multiCursorModifier */) === 'altKey');
  104227. if (this.isEnabled(mouseEvent, withKey)) {
  104228. this.cleanUpActiveLinkDecoration(); // always remove previous link decoration as their can only be one
  104229. var occurrence_1 = this.getLinkOccurrence(mouseEvent.target.position);
  104230. if (occurrence_1) {
  104231. this.editor.changeDecorations(function (changeAccessor) {
  104232. occurrence_1.activate(changeAccessor, useMetaKey);
  104233. _this.activeLinkDecorationId = occurrence_1.decorationId;
  104234. });
  104235. }
  104236. }
  104237. else {
  104238. this.cleanUpActiveLinkDecoration();
  104239. }
  104240. };
  104241. LinkDetector.prototype.cleanUpActiveLinkDecoration = function () {
  104242. var useMetaKey = (this.editor.getOption(59 /* multiCursorModifier */) === 'altKey');
  104243. if (this.activeLinkDecorationId) {
  104244. var occurrence_2 = this.currentOccurrences[this.activeLinkDecorationId];
  104245. if (occurrence_2) {
  104246. this.editor.changeDecorations(function (changeAccessor) {
  104247. occurrence_2.deactivate(changeAccessor, useMetaKey);
  104248. });
  104249. }
  104250. this.activeLinkDecorationId = null;
  104251. }
  104252. };
  104253. LinkDetector.prototype.onEditorMouseUp = function (mouseEvent) {
  104254. if (!this.isEnabled(mouseEvent)) {
  104255. return;
  104256. }
  104257. var occurrence = this.getLinkOccurrence(mouseEvent.target.position);
  104258. if (!occurrence) {
  104259. return;
  104260. }
  104261. this.openLinkOccurrence(occurrence, mouseEvent.hasSideBySideModifier, true /* from user gesture */);
  104262. };
  104263. LinkDetector.prototype.openLinkOccurrence = function (occurrence, openToSide, fromUserGesture) {
  104264. var _this = this;
  104265. if (fromUserGesture === void 0) { fromUserGesture = false; }
  104266. if (!this.openerService) {
  104267. return;
  104268. }
  104269. var link = occurrence.link;
  104270. link.resolve(cancellation_1.CancellationToken.None).then(function (uri) {
  104271. // open the uri
  104272. return _this.openerService.open(uri, { openToSide: openToSide, fromUserGesture: fromUserGesture });
  104273. }, function (err) {
  104274. var messageOrError = err instanceof Error ? err.message : err;
  104275. // different error cases
  104276. if (messageOrError === 'invalid') {
  104277. _this.notificationService.warn(nls.localize(6, null, link.url.toString()));
  104278. }
  104279. else if (messageOrError === 'missing') {
  104280. _this.notificationService.warn(nls.localize(7, null));
  104281. }
  104282. else {
  104283. errors_1.onUnexpectedError(err);
  104284. }
  104285. });
  104286. };
  104287. LinkDetector.prototype.getLinkOccurrence = function (position) {
  104288. if (!this.editor.hasModel() || !position) {
  104289. return null;
  104290. }
  104291. var decorations = this.editor.getModel().getDecorationsInRange({
  104292. startLineNumber: position.lineNumber,
  104293. startColumn: position.column,
  104294. endLineNumber: position.lineNumber,
  104295. endColumn: position.column
  104296. }, 0, true);
  104297. for (var _i = 0, decorations_1 = decorations; _i < decorations_1.length; _i++) {
  104298. var decoration_1 = decorations_1[_i];
  104299. var currentOccurrence = this.currentOccurrences[decoration_1.id];
  104300. if (currentOccurrence) {
  104301. return currentOccurrence;
  104302. }
  104303. }
  104304. return null;
  104305. };
  104306. LinkDetector.prototype.isEnabled = function (mouseEvent, withKey) {
  104307. return Boolean((mouseEvent.target.type === 6 /* CONTENT_TEXT */)
  104308. && (mouseEvent.hasTriggerModifier || (withKey && withKey.keyCodeIsTriggerKey)));
  104309. };
  104310. LinkDetector.prototype.stop = function () {
  104311. this.timeout.cancel();
  104312. if (this.activeLinksList) {
  104313. this.activeLinksList.dispose();
  104314. }
  104315. if (this.computePromise) {
  104316. this.computePromise.cancel();
  104317. this.computePromise = null;
  104318. }
  104319. };
  104320. LinkDetector.prototype.dispose = function () {
  104321. this.listenersToRemove.dispose();
  104322. this.stop();
  104323. this.timeout.dispose();
  104324. };
  104325. LinkDetector.ID = 'editor.linkDetector';
  104326. LinkDetector.RECOMPUTE_TIME = 1000; // ms
  104327. LinkDetector = __decorate([
  104328. __param(1, opener_1.IOpenerService),
  104329. __param(2, notification_1.INotificationService)
  104330. ], LinkDetector);
  104331. return LinkDetector;
  104332. }());
  104333. var OpenLinkAction = /** @class */ (function (_super) {
  104334. __extends(OpenLinkAction, _super);
  104335. function OpenLinkAction() {
  104336. return _super.call(this, {
  104337. id: 'editor.action.openLink',
  104338. label: nls.localize(8, null),
  104339. alias: 'Open Link',
  104340. precondition: undefined
  104341. }) || this;
  104342. }
  104343. OpenLinkAction.prototype.run = function (accessor, editor) {
  104344. var linkDetector = LinkDetector.get(editor);
  104345. if (!linkDetector) {
  104346. return;
  104347. }
  104348. if (!editor.hasModel()) {
  104349. return;
  104350. }
  104351. var selections = editor.getSelections();
  104352. for (var _i = 0, selections_1 = selections; _i < selections_1.length; _i++) {
  104353. var sel = selections_1[_i];
  104354. var link = linkDetector.getLinkOccurrence(sel.getEndPosition());
  104355. if (link) {
  104356. linkDetector.openLinkOccurrence(link, false);
  104357. }
  104358. }
  104359. };
  104360. return OpenLinkAction;
  104361. }(editorExtensions_1.EditorAction));
  104362. editorExtensions_1.registerEditorContribution(LinkDetector.ID, LinkDetector);
  104363. editorExtensions_1.registerEditorAction(OpenLinkAction);
  104364. themeService_1.registerThemingParticipant(function (theme, collector) {
  104365. var activeLinkForeground = theme.getColor(colorRegistry_1.editorActiveLinkForeground);
  104366. if (activeLinkForeground) {
  104367. collector.addRule(".monaco-editor .detected-link-active { color: " + activeLinkForeground + " !important; }");
  104368. }
  104369. });
  104370. });
  104371. /*---------------------------------------------------------------------------------------------
  104372. * Copyright (c) Microsoft Corporation. All rights reserved.
  104373. * Licensed under the MIT License. See License.txt in the project root for license information.
  104374. *--------------------------------------------------------------------------------------------*/
  104375. define(__m[122/*vs/editor/contrib/message/messageController*/], __M([0/*require*/,1/*exports*/,458/*vs/nls!vs/editor/contrib/message/messageController*/,15/*vs/base/common/async*/,2/*vs/base/common/lifecycle*/,50/*vs/base/browser/ui/aria/aria*/,3/*vs/editor/common/core/range*/,12/*vs/editor/browser/editorExtensions*/,18/*vs/platform/contextkey/common/contextkey*/,14/*vs/platform/theme/common/themeService*/,20/*vs/platform/theme/common/colorRegistry*/,317/*vs/css!vs/editor/contrib/message/messageController*/]), function (require, exports, nls, async_1, lifecycle_1, aria_1, range_1, editorExtensions_1, contextkey_1, themeService_1, colorRegistry_1) {
  104376. "use strict";
  104377. Object.defineProperty(exports, "__esModule", { value: true });
  104378. var MessageController = /** @class */ (function (_super) {
  104379. __extends(MessageController, _super);
  104380. function MessageController(editor, contextKeyService) {
  104381. var _this = _super.call(this) || this;
  104382. _this.closeTimeout = 3000; // close after 3s
  104383. _this._messageWidget = _this._register(new lifecycle_1.MutableDisposable());
  104384. _this._messageListeners = _this._register(new lifecycle_1.DisposableStore());
  104385. _this._editor = editor;
  104386. _this._visible = MessageController.MESSAGE_VISIBLE.bindTo(contextKeyService);
  104387. _this._register(_this._editor.onDidAttemptReadOnlyEdit(function () { return _this._onDidAttemptReadOnlyEdit(); }));
  104388. return _this;
  104389. }
  104390. MessageController.get = function (editor) {
  104391. return editor.getContribution(MessageController.ID);
  104392. };
  104393. MessageController.prototype.dispose = function () {
  104394. _super.prototype.dispose.call(this);
  104395. this._visible.reset();
  104396. };
  104397. MessageController.prototype.showMessage = function (message, position) {
  104398. var _this = this;
  104399. aria_1.alert(message);
  104400. this._visible.set(true);
  104401. this._messageWidget.clear();
  104402. this._messageListeners.clear();
  104403. this._messageWidget.value = new MessageWidget(this._editor, position, message);
  104404. // close on blur, cursor, model change, dispose
  104405. this._messageListeners.add(this._editor.onDidBlurEditorText(function () { return _this.closeMessage(); }));
  104406. this._messageListeners.add(this._editor.onDidChangeCursorPosition(function () { return _this.closeMessage(); }));
  104407. this._messageListeners.add(this._editor.onDidDispose(function () { return _this.closeMessage(); }));
  104408. this._messageListeners.add(this._editor.onDidChangeModel(function () { return _this.closeMessage(); }));
  104409. this._messageListeners.add(new async_1.TimeoutTimer(function () { return _this.closeMessage(); }, this.closeTimeout));
  104410. // close on mouse move
  104411. var bounds;
  104412. this._messageListeners.add(this._editor.onMouseMove(function (e) {
  104413. // outside the text area
  104414. if (!e.target.position) {
  104415. return;
  104416. }
  104417. if (!bounds) {
  104418. // define bounding box around position and first mouse occurance
  104419. bounds = new range_1.Range(position.lineNumber - 3, 1, e.target.position.lineNumber + 3, 1);
  104420. }
  104421. else if (!bounds.containsPosition(e.target.position)) {
  104422. // check if position is still in bounds
  104423. _this.closeMessage();
  104424. }
  104425. }));
  104426. };
  104427. MessageController.prototype.closeMessage = function () {
  104428. this._visible.reset();
  104429. this._messageListeners.clear();
  104430. if (this._messageWidget.value) {
  104431. this._messageListeners.add(MessageWidget.fadeOut(this._messageWidget.value));
  104432. }
  104433. };
  104434. MessageController.prototype._onDidAttemptReadOnlyEdit = function () {
  104435. if (this._editor.hasModel()) {
  104436. this.showMessage(nls.localize(0, null), this._editor.getPosition());
  104437. }
  104438. };
  104439. MessageController.ID = 'editor.contrib.messageController';
  104440. MessageController.MESSAGE_VISIBLE = new contextkey_1.RawContextKey('messageVisible', false);
  104441. MessageController = __decorate([
  104442. __param(1, contextkey_1.IContextKeyService)
  104443. ], MessageController);
  104444. return MessageController;
  104445. }(lifecycle_1.Disposable));
  104446. exports.MessageController = MessageController;
  104447. var MessageCommand = editorExtensions_1.EditorCommand.bindToContribution(MessageController.get);
  104448. editorExtensions_1.registerEditorCommand(new MessageCommand({
  104449. id: 'leaveEditorMessage',
  104450. precondition: MessageController.MESSAGE_VISIBLE,
  104451. handler: function (c) { return c.closeMessage(); },
  104452. kbOpts: {
  104453. weight: 100 /* EditorContrib */ + 30,
  104454. primary: 9 /* Escape */
  104455. }
  104456. }));
  104457. var MessageWidget = /** @class */ (function () {
  104458. function MessageWidget(editor, _a, text) {
  104459. var lineNumber = _a.lineNumber, column = _a.column;
  104460. // Editor.IContentWidget.allowEditorOverflow
  104461. this.allowEditorOverflow = true;
  104462. this.suppressMouseDown = false;
  104463. this._editor = editor;
  104464. this._editor.revealLinesInCenterIfOutsideViewport(lineNumber, lineNumber, 0 /* Smooth */);
  104465. this._position = { lineNumber: lineNumber, column: column - 1 };
  104466. this._domNode = document.createElement('div');
  104467. this._domNode.classList.add('monaco-editor-overlaymessage');
  104468. var message = document.createElement('div');
  104469. message.classList.add('message');
  104470. message.textContent = text;
  104471. this._domNode.appendChild(message);
  104472. var anchor = document.createElement('div');
  104473. anchor.classList.add('anchor');
  104474. this._domNode.appendChild(anchor);
  104475. this._editor.addContentWidget(this);
  104476. this._domNode.classList.add('fadeIn');
  104477. }
  104478. MessageWidget.fadeOut = function (messageWidget) {
  104479. var handle;
  104480. var dispose = function () {
  104481. messageWidget.dispose();
  104482. clearTimeout(handle);
  104483. messageWidget.getDomNode().removeEventListener('animationend', dispose);
  104484. };
  104485. handle = setTimeout(dispose, 110);
  104486. messageWidget.getDomNode().addEventListener('animationend', dispose);
  104487. messageWidget.getDomNode().classList.add('fadeOut');
  104488. return { dispose: dispose };
  104489. };
  104490. MessageWidget.prototype.dispose = function () {
  104491. this._editor.removeContentWidget(this);
  104492. };
  104493. MessageWidget.prototype.getId = function () {
  104494. return 'messageoverlay';
  104495. };
  104496. MessageWidget.prototype.getDomNode = function () {
  104497. return this._domNode;
  104498. };
  104499. MessageWidget.prototype.getPosition = function () {
  104500. return { position: this._position, preference: [1 /* ABOVE */, 2 /* BELOW */] };
  104501. };
  104502. return MessageWidget;
  104503. }());
  104504. editorExtensions_1.registerEditorContribution(MessageController.ID, MessageController);
  104505. themeService_1.registerThemingParticipant(function (theme, collector) {
  104506. var border = theme.getColor(colorRegistry_1.inputValidationInfoBorder);
  104507. if (border) {
  104508. var borderWidth = theme.type === themeService_1.HIGH_CONTRAST ? 2 : 1;
  104509. collector.addRule(".monaco-editor .monaco-editor-overlaymessage .anchor { border-top-color: " + border + "; }");
  104510. collector.addRule(".monaco-editor .monaco-editor-overlaymessage .message { border: " + borderWidth + "px solid " + border + "; }");
  104511. }
  104512. var background = theme.getColor(colorRegistry_1.inputValidationInfoBackground);
  104513. if (background) {
  104514. collector.addRule(".monaco-editor .monaco-editor-overlaymessage .message { background-color: " + background + "; }");
  104515. }
  104516. var foreground = theme.getColor(colorRegistry_1.inputValidationInfoForeground);
  104517. if (foreground) {
  104518. collector.addRule(".monaco-editor .monaco-editor-overlaymessage .message { color: " + foreground + "; }");
  104519. }
  104520. });
  104521. });
  104522. /*---------------------------------------------------------------------------------------------
  104523. * Copyright (c) Microsoft Corporation. All rights reserved.
  104524. * Licensed under the MIT License. See License.txt in the project root for license information.
  104525. *--------------------------------------------------------------------------------------------*/
  104526. define(__m[578/*vs/editor/contrib/codeAction/codeActionUi*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,10/*vs/base/common/errors*/,128/*vs/base/common/lazy*/,2/*vs/base/common/lifecycle*/,122/*vs/editor/contrib/message/messageController*/,11/*vs/platform/instantiation/common/instantiation*/,527/*vs/editor/contrib/codeAction/codeActionMenu*/,567/*vs/editor/contrib/codeAction/lightBulbWidget*/]), function (require, exports, arrays_1, errors_1, lazy_1, lifecycle_1, messageController_1, instantiation_1, codeActionMenu_1, lightBulbWidget_1) {
  104527. "use strict";
  104528. Object.defineProperty(exports, "__esModule", { value: true });
  104529. var CodeActionUi = /** @class */ (function (_super) {
  104530. __extends(CodeActionUi, _super);
  104531. function CodeActionUi(_editor, quickFixActionId, preferredFixActionId, delegate, instantiationService) {
  104532. var _this = _super.call(this) || this;
  104533. _this._editor = _editor;
  104534. _this.delegate = delegate;
  104535. _this._activeCodeActions = _this._register(new lifecycle_1.MutableDisposable());
  104536. _this._codeActionWidget = new lazy_1.Lazy(function () {
  104537. return _this._register(instantiationService.createInstance(codeActionMenu_1.CodeActionMenu, _this._editor, {
  104538. onSelectCodeAction: function (action) { return __awaiter(_this, void 0, void 0, function () {
  104539. return __generator(this, function (_a) {
  104540. this.delegate.applyCodeAction(action, /* retrigger */ true);
  104541. return [2 /*return*/];
  104542. });
  104543. }); }
  104544. }));
  104545. });
  104546. _this._lightBulbWidget = new lazy_1.Lazy(function () {
  104547. var widget = _this._register(instantiationService.createInstance(lightBulbWidget_1.LightBulbWidget, _this._editor, quickFixActionId, preferredFixActionId));
  104548. _this._register(widget.onClick(function (e) { return _this.showCodeActionList(e.trigger, e.actions, e, { includeDisabledActions: false }); }));
  104549. return widget;
  104550. });
  104551. return _this;
  104552. }
  104553. CodeActionUi.prototype.update = function (newState) {
  104554. var _a, _b, _c;
  104555. return __awaiter(this, void 0, void 0, function () {
  104556. var actions, e_1, validActionToApply, invalidAction, includeDisabledActions;
  104557. return __generator(this, function (_d) {
  104558. switch (_d.label) {
  104559. case 0:
  104560. if (newState.type !== 1 /* Triggered */) {
  104561. (_a = this._lightBulbWidget.rawValue) === null || _a === void 0 ? void 0 : _a.hide();
  104562. return [2 /*return*/];
  104563. }
  104564. _d.label = 1;
  104565. case 1:
  104566. _d.trys.push([1, 3, , 4]);
  104567. return [4 /*yield*/, newState.actions];
  104568. case 2:
  104569. actions = _d.sent();
  104570. return [3 /*break*/, 4];
  104571. case 3:
  104572. e_1 = _d.sent();
  104573. errors_1.onUnexpectedError(e_1);
  104574. return [2 /*return*/];
  104575. case 4:
  104576. this._lightBulbWidget.getValue().update(actions, newState.trigger, newState.position);
  104577. if (!(newState.trigger.type === 2 /* Manual */)) return [3 /*break*/, 11];
  104578. if (!((_b = newState.trigger.filter) === null || _b === void 0 ? void 0 : _b.include)) return [3 /*break*/, 10];
  104579. validActionToApply = this.tryGetValidActionToApply(newState.trigger, actions);
  104580. if (!validActionToApply) return [3 /*break*/, 9];
  104581. _d.label = 5;
  104582. case 5:
  104583. _d.trys.push([5, , 7, 8]);
  104584. return [4 /*yield*/, this.delegate.applyCodeAction(validActionToApply, false)];
  104585. case 6:
  104586. _d.sent();
  104587. return [3 /*break*/, 8];
  104588. case 7:
  104589. actions.dispose();
  104590. return [7 /*endfinally*/];
  104591. case 8: return [2 /*return*/];
  104592. case 9:
  104593. // Check to see if there is an action that we would have applied were it not invalid
  104594. if (newState.trigger.context) {
  104595. invalidAction = this.getInvalidActionThatWouldHaveBeenApplied(newState.trigger, actions);
  104596. if (invalidAction && invalidAction.disabled) {
  104597. messageController_1.MessageController.get(this._editor).showMessage(invalidAction.disabled, newState.trigger.context.position);
  104598. actions.dispose();
  104599. return [2 /*return*/];
  104600. }
  104601. }
  104602. _d.label = 10;
  104603. case 10:
  104604. includeDisabledActions = !!((_c = newState.trigger.filter) === null || _c === void 0 ? void 0 : _c.include);
  104605. if (newState.trigger.context) {
  104606. if (!actions.allActions.length || !includeDisabledActions && !actions.validActions.length) {
  104607. messageController_1.MessageController.get(this._editor).showMessage(newState.trigger.context.notAvailableMessage, newState.trigger.context.position);
  104608. this._activeCodeActions.value = actions;
  104609. actions.dispose();
  104610. return [2 /*return*/];
  104611. }
  104612. }
  104613. this._activeCodeActions.value = actions;
  104614. this._codeActionWidget.getValue().show(newState.trigger, actions, newState.position, { includeDisabledActions: includeDisabledActions });
  104615. return [3 /*break*/, 12];
  104616. case 11:
  104617. // auto magically triggered
  104618. if (this._codeActionWidget.getValue().isVisible) {
  104619. // TODO: Figure out if we should update the showing menu?
  104620. actions.dispose();
  104621. }
  104622. else {
  104623. this._activeCodeActions.value = actions;
  104624. }
  104625. _d.label = 12;
  104626. case 12: return [2 /*return*/];
  104627. }
  104628. });
  104629. });
  104630. };
  104631. CodeActionUi.prototype.getInvalidActionThatWouldHaveBeenApplied = function (trigger, actions) {
  104632. if (!actions.allActions.length) {
  104633. return undefined;
  104634. }
  104635. if ((trigger.autoApply === "first" /* First */ && actions.validActions.length === 0)
  104636. || (trigger.autoApply === "ifSingle" /* IfSingle */ && actions.allActions.length === 1)) {
  104637. return arrays_1.find(actions.allActions, function (action) { return action.disabled; });
  104638. }
  104639. return undefined;
  104640. };
  104641. CodeActionUi.prototype.tryGetValidActionToApply = function (trigger, actions) {
  104642. if (!actions.validActions.length) {
  104643. return undefined;
  104644. }
  104645. if ((trigger.autoApply === "first" /* First */ && actions.validActions.length > 0)
  104646. || (trigger.autoApply === "ifSingle" /* IfSingle */ && actions.validActions.length === 1)) {
  104647. return actions.validActions[0];
  104648. }
  104649. return undefined;
  104650. };
  104651. CodeActionUi.prototype.showCodeActionList = function (trigger, actions, at, options) {
  104652. return __awaiter(this, void 0, void 0, function () {
  104653. return __generator(this, function (_a) {
  104654. this._codeActionWidget.getValue().show(trigger, actions, at, options);
  104655. return [2 /*return*/];
  104656. });
  104657. });
  104658. };
  104659. CodeActionUi = __decorate([
  104660. __param(4, instantiation_1.IInstantiationService)
  104661. ], CodeActionUi);
  104662. return CodeActionUi;
  104663. }(lifecycle_1.Disposable));
  104664. exports.CodeActionUi = CodeActionUi;
  104665. });
  104666. /*---------------------------------------------------------------------------------------------
  104667. * Copyright (c) Microsoft Corporation. All rights reserved.
  104668. * Licensed under the MIT License. See License.txt in the project root for license information.
  104669. *--------------------------------------------------------------------------------------------*/
  104670. var __spreadArrays = (this && this.__spreadArrays) || function () {
  104671. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  104672. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  104673. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  104674. r[k] = a[j];
  104675. return r;
  104676. };
  104677. define(__m[233/*vs/editor/contrib/codeAction/codeActionCommands*/], __M([0/*require*/,1/*exports*/,128/*vs/base/common/lazy*/,2/*vs/base/common/lifecycle*/,5/*vs/base/common/strings*/,12/*vs/editor/browser/editorExtensions*/,156/*vs/editor/browser/services/bulkEditService*/,23/*vs/editor/common/editorContextKeys*/,119/*vs/editor/contrib/codeAction/codeAction*/,578/*vs/editor/contrib/codeAction/codeActionUi*/,122/*vs/editor/contrib/message/messageController*/,432/*vs/nls!vs/editor/contrib/codeAction/codeActionCommands*/,29/*vs/platform/commands/common/commands*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,72/*vs/platform/markers/common/markers*/,35/*vs/platform/notification/common/notification*/,73/*vs/platform/progress/common/progress*/,96/*vs/platform/telemetry/common/telemetry*/,528/*vs/editor/contrib/codeAction/codeActionModel*/,111/*vs/editor/contrib/codeAction/types*/]), function (require, exports, lazy_1, lifecycle_1, strings_1, editorExtensions_1, bulkEditService_1, editorContextKeys_1, codeAction_1, codeActionUi_1, messageController_1, nls, commands_1, contextkey_1, instantiation_1, markers_1, notification_1, progress_1, telemetry_1, codeActionModel_1, types_1) {
  104678. "use strict";
  104679. Object.defineProperty(exports, "__esModule", { value: true });
  104680. function contextKeyForSupportedActions(kind) {
  104681. return contextkey_1.ContextKeyExpr.regex(codeActionModel_1.SUPPORTED_CODE_ACTIONS.keys()[0], new RegExp('(\\s|^)' + strings_1.escapeRegExpCharacters(kind.value) + '\\b'));
  104682. }
  104683. var argsSchema = {
  104684. type: 'object',
  104685. required: ['kind'],
  104686. defaultSnippets: [{ body: { kind: '' } }],
  104687. properties: {
  104688. 'kind': {
  104689. type: 'string',
  104690. description: nls.localize(0, null),
  104691. },
  104692. 'apply': {
  104693. type: 'string',
  104694. description: nls.localize(1, null),
  104695. default: "ifSingle" /* IfSingle */,
  104696. enum: ["first" /* First */, "ifSingle" /* IfSingle */, "never" /* Never */],
  104697. enumDescriptions: [
  104698. nls.localize(2, null),
  104699. nls.localize(3, null),
  104700. nls.localize(4, null),
  104701. ]
  104702. },
  104703. 'preferred': {
  104704. type: 'boolean',
  104705. default: false,
  104706. description: nls.localize(5, null),
  104707. }
  104708. }
  104709. };
  104710. var QuickFixController = /** @class */ (function (_super) {
  104711. __extends(QuickFixController, _super);
  104712. function QuickFixController(editor, markerService, contextKeyService, progressService, _instantiationService) {
  104713. var _this = _super.call(this) || this;
  104714. _this._instantiationService = _instantiationService;
  104715. _this._editor = editor;
  104716. _this._model = _this._register(new codeActionModel_1.CodeActionModel(_this._editor, markerService, contextKeyService, progressService));
  104717. _this._register(_this._model.onDidChangeState(function (newState) { return _this.update(newState); }));
  104718. _this._ui = new lazy_1.Lazy(function () {
  104719. return _this._register(new codeActionUi_1.CodeActionUi(editor, QuickFixAction.Id, AutoFixAction.Id, {
  104720. applyCodeAction: function (action, retrigger) { return __awaiter(_this, void 0, void 0, function () {
  104721. return __generator(this, function (_a) {
  104722. switch (_a.label) {
  104723. case 0:
  104724. _a.trys.push([0, , 2, 3]);
  104725. return [4 /*yield*/, this._applyCodeAction(action)];
  104726. case 1:
  104727. _a.sent();
  104728. return [3 /*break*/, 3];
  104729. case 2:
  104730. if (retrigger) {
  104731. this._trigger({ type: 1 /* Auto */, filter: {} });
  104732. }
  104733. return [7 /*endfinally*/];
  104734. case 3: return [2 /*return*/];
  104735. }
  104736. });
  104737. }); }
  104738. }, _this._instantiationService));
  104739. });
  104740. return _this;
  104741. }
  104742. QuickFixController.get = function (editor) {
  104743. return editor.getContribution(QuickFixController.ID);
  104744. };
  104745. QuickFixController.prototype.update = function (newState) {
  104746. this._ui.getValue().update(newState);
  104747. };
  104748. QuickFixController.prototype.showCodeActions = function (trigger, actions, at) {
  104749. return this._ui.getValue().showCodeActionList(trigger, actions, at, { includeDisabledActions: false });
  104750. };
  104751. QuickFixController.prototype.manualTriggerAtCurrentPosition = function (notAvailableMessage, filter, autoApply) {
  104752. if (!this._editor.hasModel()) {
  104753. return;
  104754. }
  104755. messageController_1.MessageController.get(this._editor).closeMessage();
  104756. var triggerPosition = this._editor.getPosition();
  104757. this._trigger({ type: 2 /* Manual */, filter: filter, autoApply: autoApply, context: { notAvailableMessage: notAvailableMessage, position: triggerPosition } });
  104758. };
  104759. QuickFixController.prototype._trigger = function (trigger) {
  104760. return this._model.trigger(trigger);
  104761. };
  104762. QuickFixController.prototype._applyCodeAction = function (action) {
  104763. return this._instantiationService.invokeFunction(applyCodeAction, action, this._editor);
  104764. };
  104765. QuickFixController.ID = 'editor.contrib.quickFixController';
  104766. QuickFixController = __decorate([
  104767. __param(1, markers_1.IMarkerService),
  104768. __param(2, contextkey_1.IContextKeyService),
  104769. __param(3, progress_1.IEditorProgressService),
  104770. __param(4, instantiation_1.IInstantiationService)
  104771. ], QuickFixController);
  104772. return QuickFixController;
  104773. }(lifecycle_1.Disposable));
  104774. exports.QuickFixController = QuickFixController;
  104775. function applyCodeAction(accessor, action, editor) {
  104776. return __awaiter(this, void 0, void 0, function () {
  104777. var bulkEditService, commandService, telemetryService, notificationService, err_1, message;
  104778. return __generator(this, function (_a) {
  104779. switch (_a.label) {
  104780. case 0:
  104781. bulkEditService = accessor.get(bulkEditService_1.IBulkEditService);
  104782. commandService = accessor.get(commands_1.ICommandService);
  104783. telemetryService = accessor.get(telemetry_1.ITelemetryService);
  104784. notificationService = accessor.get(notification_1.INotificationService);
  104785. telemetryService.publicLog2('codeAction.applyCodeAction', {
  104786. codeActionTitle: action.title,
  104787. codeActionKind: action.kind,
  104788. codeActionIsPreferred: !!action.isPreferred,
  104789. });
  104790. if (!action.edit) return [3 /*break*/, 2];
  104791. return [4 /*yield*/, bulkEditService.apply(action.edit, { editor: editor })];
  104792. case 1:
  104793. _a.sent();
  104794. _a.label = 2;
  104795. case 2:
  104796. if (!action.command) return [3 /*break*/, 6];
  104797. _a.label = 3;
  104798. case 3:
  104799. _a.trys.push([3, 5, , 6]);
  104800. return [4 /*yield*/, commandService.executeCommand.apply(commandService, __spreadArrays([action.command.id], (action.command.arguments || [])))];
  104801. case 4:
  104802. _a.sent();
  104803. return [3 /*break*/, 6];
  104804. case 5:
  104805. err_1 = _a.sent();
  104806. message = asMessage(err_1);
  104807. notificationService.error(typeof message === 'string'
  104808. ? message
  104809. : nls.localize(6, null));
  104810. return [3 /*break*/, 6];
  104811. case 6: return [2 /*return*/];
  104812. }
  104813. });
  104814. });
  104815. }
  104816. exports.applyCodeAction = applyCodeAction;
  104817. function asMessage(err) {
  104818. if (typeof err === 'string') {
  104819. return err;
  104820. }
  104821. else if (err instanceof Error && typeof err.message === 'string') {
  104822. return err.message;
  104823. }
  104824. else {
  104825. return undefined;
  104826. }
  104827. }
  104828. function triggerCodeActionsForEditorSelection(editor, notAvailableMessage, filter, autoApply) {
  104829. if (editor.hasModel()) {
  104830. var controller = QuickFixController.get(editor);
  104831. if (controller) {
  104832. controller.manualTriggerAtCurrentPosition(notAvailableMessage, filter, autoApply);
  104833. }
  104834. }
  104835. }
  104836. var QuickFixAction = /** @class */ (function (_super) {
  104837. __extends(QuickFixAction, _super);
  104838. function QuickFixAction() {
  104839. return _super.call(this, {
  104840. id: QuickFixAction.Id,
  104841. label: nls.localize(7, null),
  104842. alias: 'Quick Fix...',
  104843. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, editorContextKeys_1.EditorContextKeys.hasCodeActionsProvider),
  104844. kbOpts: {
  104845. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  104846. primary: 2048 /* CtrlCmd */ | 84 /* US_DOT */,
  104847. weight: 100 /* EditorContrib */
  104848. }
  104849. }) || this;
  104850. }
  104851. QuickFixAction.prototype.run = function (_accessor, editor) {
  104852. return triggerCodeActionsForEditorSelection(editor, nls.localize(8, null), undefined, undefined);
  104853. };
  104854. QuickFixAction.Id = 'editor.action.quickFix';
  104855. return QuickFixAction;
  104856. }(editorExtensions_1.EditorAction));
  104857. exports.QuickFixAction = QuickFixAction;
  104858. var CodeActionCommand = /** @class */ (function (_super) {
  104859. __extends(CodeActionCommand, _super);
  104860. function CodeActionCommand() {
  104861. return _super.call(this, {
  104862. id: codeAction_1.codeActionCommandId,
  104863. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, editorContextKeys_1.EditorContextKeys.hasCodeActionsProvider),
  104864. description: {
  104865. description: 'Trigger a code action',
  104866. args: [{ name: 'args', schema: argsSchema, }]
  104867. }
  104868. }) || this;
  104869. }
  104870. CodeActionCommand.prototype.runEditorCommand = function (_accessor, editor, userArgs) {
  104871. var args = types_1.CodeActionCommandArgs.fromUser(userArgs, {
  104872. kind: types_1.CodeActionKind.Empty,
  104873. apply: "ifSingle" /* IfSingle */,
  104874. });
  104875. return triggerCodeActionsForEditorSelection(editor, typeof (userArgs === null || userArgs === void 0 ? void 0 : userArgs.kind) === 'string'
  104876. ? args.preferred
  104877. ? nls.localize(9, null, userArgs.kind)
  104878. : nls.localize(10, null, userArgs.kind)
  104879. : args.preferred
  104880. ? nls.localize(11, null)
  104881. : nls.localize(12, null), {
  104882. include: args.kind,
  104883. includeSourceActions: true,
  104884. onlyIncludePreferredActions: args.preferred,
  104885. }, args.apply);
  104886. };
  104887. return CodeActionCommand;
  104888. }(editorExtensions_1.EditorCommand));
  104889. exports.CodeActionCommand = CodeActionCommand;
  104890. var RefactorAction = /** @class */ (function (_super) {
  104891. __extends(RefactorAction, _super);
  104892. function RefactorAction() {
  104893. return _super.call(this, {
  104894. id: codeAction_1.refactorCommandId,
  104895. label: nls.localize(13, null),
  104896. alias: 'Refactor...',
  104897. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, editorContextKeys_1.EditorContextKeys.hasCodeActionsProvider),
  104898. kbOpts: {
  104899. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  104900. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 48 /* KEY_R */,
  104901. mac: {
  104902. primary: 256 /* WinCtrl */ | 1024 /* Shift */ | 48 /* KEY_R */
  104903. },
  104904. weight: 100 /* EditorContrib */
  104905. },
  104906. contextMenuOpts: {
  104907. group: '1_modification',
  104908. order: 2,
  104909. when: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, contextKeyForSupportedActions(types_1.CodeActionKind.Refactor)),
  104910. },
  104911. description: {
  104912. description: 'Refactor...',
  104913. args: [{ name: 'args', schema: argsSchema }]
  104914. }
  104915. }) || this;
  104916. }
  104917. RefactorAction.prototype.run = function (_accessor, editor, userArgs) {
  104918. var args = types_1.CodeActionCommandArgs.fromUser(userArgs, {
  104919. kind: types_1.CodeActionKind.Refactor,
  104920. apply: "never" /* Never */
  104921. });
  104922. return triggerCodeActionsForEditorSelection(editor, typeof (userArgs === null || userArgs === void 0 ? void 0 : userArgs.kind) === 'string'
  104923. ? args.preferred
  104924. ? nls.localize(14, null, userArgs.kind)
  104925. : nls.localize(15, null, userArgs.kind)
  104926. : args.preferred
  104927. ? nls.localize(16, null)
  104928. : nls.localize(17, null), {
  104929. include: types_1.CodeActionKind.Refactor.contains(args.kind) ? args.kind : types_1.CodeActionKind.None,
  104930. onlyIncludePreferredActions: args.preferred,
  104931. }, args.apply);
  104932. };
  104933. return RefactorAction;
  104934. }(editorExtensions_1.EditorAction));
  104935. exports.RefactorAction = RefactorAction;
  104936. var SourceAction = /** @class */ (function (_super) {
  104937. __extends(SourceAction, _super);
  104938. function SourceAction() {
  104939. return _super.call(this, {
  104940. id: codeAction_1.sourceActionCommandId,
  104941. label: nls.localize(18, null),
  104942. alias: 'Source Action...',
  104943. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, editorContextKeys_1.EditorContextKeys.hasCodeActionsProvider),
  104944. contextMenuOpts: {
  104945. group: '1_modification',
  104946. order: 2.1,
  104947. when: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, contextKeyForSupportedActions(types_1.CodeActionKind.Source)),
  104948. },
  104949. description: {
  104950. description: 'Source Action...',
  104951. args: [{ name: 'args', schema: argsSchema }]
  104952. }
  104953. }) || this;
  104954. }
  104955. SourceAction.prototype.run = function (_accessor, editor, userArgs) {
  104956. var args = types_1.CodeActionCommandArgs.fromUser(userArgs, {
  104957. kind: types_1.CodeActionKind.Source,
  104958. apply: "never" /* Never */
  104959. });
  104960. return triggerCodeActionsForEditorSelection(editor, typeof (userArgs === null || userArgs === void 0 ? void 0 : userArgs.kind) === 'string'
  104961. ? args.preferred
  104962. ? nls.localize(19, null, userArgs.kind)
  104963. : nls.localize(20, null, userArgs.kind)
  104964. : args.preferred
  104965. ? nls.localize(21, null)
  104966. : nls.localize(22, null), {
  104967. include: types_1.CodeActionKind.Source.contains(args.kind) ? args.kind : types_1.CodeActionKind.None,
  104968. includeSourceActions: true,
  104969. onlyIncludePreferredActions: args.preferred,
  104970. }, args.apply);
  104971. };
  104972. return SourceAction;
  104973. }(editorExtensions_1.EditorAction));
  104974. exports.SourceAction = SourceAction;
  104975. var OrganizeImportsAction = /** @class */ (function (_super) {
  104976. __extends(OrganizeImportsAction, _super);
  104977. function OrganizeImportsAction() {
  104978. return _super.call(this, {
  104979. id: codeAction_1.organizeImportsCommandId,
  104980. label: nls.localize(23, null),
  104981. alias: 'Organize Imports',
  104982. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, contextKeyForSupportedActions(types_1.CodeActionKind.SourceOrganizeImports)),
  104983. kbOpts: {
  104984. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  104985. primary: 1024 /* Shift */ | 512 /* Alt */ | 45 /* KEY_O */,
  104986. weight: 100 /* EditorContrib */
  104987. },
  104988. }) || this;
  104989. }
  104990. OrganizeImportsAction.prototype.run = function (_accessor, editor) {
  104991. return triggerCodeActionsForEditorSelection(editor, nls.localize(24, null), { include: types_1.CodeActionKind.SourceOrganizeImports, includeSourceActions: true }, "ifSingle" /* IfSingle */);
  104992. };
  104993. return OrganizeImportsAction;
  104994. }(editorExtensions_1.EditorAction));
  104995. exports.OrganizeImportsAction = OrganizeImportsAction;
  104996. var FixAllAction = /** @class */ (function (_super) {
  104997. __extends(FixAllAction, _super);
  104998. function FixAllAction() {
  104999. return _super.call(this, {
  105000. id: codeAction_1.fixAllCommandId,
  105001. label: nls.localize(25, null),
  105002. alias: 'Fix All',
  105003. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, contextKeyForSupportedActions(types_1.CodeActionKind.SourceFixAll))
  105004. }) || this;
  105005. }
  105006. FixAllAction.prototype.run = function (_accessor, editor) {
  105007. return triggerCodeActionsForEditorSelection(editor, nls.localize(26, null), { include: types_1.CodeActionKind.SourceFixAll, includeSourceActions: true }, "ifSingle" /* IfSingle */);
  105008. };
  105009. return FixAllAction;
  105010. }(editorExtensions_1.EditorAction));
  105011. exports.FixAllAction = FixAllAction;
  105012. var AutoFixAction = /** @class */ (function (_super) {
  105013. __extends(AutoFixAction, _super);
  105014. function AutoFixAction() {
  105015. return _super.call(this, {
  105016. id: AutoFixAction.Id,
  105017. label: nls.localize(27, null),
  105018. alias: 'Auto Fix...',
  105019. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, contextKeyForSupportedActions(types_1.CodeActionKind.QuickFix)),
  105020. kbOpts: {
  105021. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  105022. primary: 512 /* Alt */ | 1024 /* Shift */ | 84 /* US_DOT */,
  105023. mac: {
  105024. primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 84 /* US_DOT */
  105025. },
  105026. weight: 100 /* EditorContrib */
  105027. }
  105028. }) || this;
  105029. }
  105030. AutoFixAction.prototype.run = function (_accessor, editor) {
  105031. return triggerCodeActionsForEditorSelection(editor, nls.localize(28, null), {
  105032. include: types_1.CodeActionKind.QuickFix,
  105033. onlyIncludePreferredActions: true
  105034. }, "ifSingle" /* IfSingle */);
  105035. };
  105036. AutoFixAction.Id = 'editor.action.autoFix';
  105037. return AutoFixAction;
  105038. }(editorExtensions_1.EditorAction));
  105039. exports.AutoFixAction = AutoFixAction;
  105040. });
  105041. /*---------------------------------------------------------------------------------------------
  105042. * Copyright (c) Microsoft Corporation. All rights reserved.
  105043. * Licensed under the MIT License. See License.txt in the project root for license information.
  105044. *--------------------------------------------------------------------------------------------*/
  105045. define(__m[579/*vs/editor/contrib/codeAction/codeActionContributions*/], __M([0/*require*/,1/*exports*/,12/*vs/editor/browser/editorExtensions*/,233/*vs/editor/contrib/codeAction/codeActionCommands*/]), function (require, exports, editorExtensions_1, codeActionCommands_1) {
  105046. "use strict";
  105047. Object.defineProperty(exports, "__esModule", { value: true });
  105048. editorExtensions_1.registerEditorContribution(codeActionCommands_1.QuickFixController.ID, codeActionCommands_1.QuickFixController);
  105049. editorExtensions_1.registerEditorAction(codeActionCommands_1.QuickFixAction);
  105050. editorExtensions_1.registerEditorAction(codeActionCommands_1.RefactorAction);
  105051. editorExtensions_1.registerEditorAction(codeActionCommands_1.SourceAction);
  105052. editorExtensions_1.registerEditorAction(codeActionCommands_1.OrganizeImportsAction);
  105053. editorExtensions_1.registerEditorAction(codeActionCommands_1.AutoFixAction);
  105054. editorExtensions_1.registerEditorAction(codeActionCommands_1.FixAllAction);
  105055. editorExtensions_1.registerEditorCommand(new codeActionCommands_1.CodeActionCommand());
  105056. });
  105057. /*---------------------------------------------------------------------------------------------
  105058. * Copyright (c) Microsoft Corporation. All rights reserved.
  105059. * Licensed under the MIT License. See License.txt in the project root for license information.
  105060. *--------------------------------------------------------------------------------------------*/
  105061. define(__m[580/*vs/editor/contrib/multicursor/multicursor*/], __M([0/*require*/,1/*exports*/,459/*vs/nls!vs/editor/contrib/multicursor/multicursor*/,15/*vs/base/common/async*/,36/*vs/base/common/keyCodes*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,213/*vs/editor/common/controller/cursorMoveCommands*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,23/*vs/editor/common/editorContextKeys*/,48/*vs/editor/common/model*/,30/*vs/editor/common/model/textModel*/,17/*vs/editor/common/modes*/,232/*vs/editor/contrib/find/findController*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,18/*vs/platform/contextkey/common/contextkey*/]), function (require, exports, nls, async_1, keyCodes_1, lifecycle_1, editorExtensions_1, cursorMoveCommands_1, range_1, selection_1, editorContextKeys_1, model_1, textModel_1, modes_1, findController_1, colorRegistry_1, themeService_1, contextkey_1) {
  105062. "use strict";
  105063. Object.defineProperty(exports, "__esModule", { value: true });
  105064. var InsertCursorAbove = /** @class */ (function (_super) {
  105065. __extends(InsertCursorAbove, _super);
  105066. function InsertCursorAbove() {
  105067. return _super.call(this, {
  105068. id: 'editor.action.insertCursorAbove',
  105069. label: nls.localize(0, null),
  105070. alias: 'Add Cursor Above',
  105071. precondition: undefined,
  105072. kbOpts: {
  105073. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  105074. primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 16 /* UpArrow */,
  105075. linux: {
  105076. primary: 1024 /* Shift */ | 512 /* Alt */ | 16 /* UpArrow */,
  105077. secondary: [2048 /* CtrlCmd */ | 1024 /* Shift */ | 16 /* UpArrow */]
  105078. },
  105079. weight: 100 /* EditorContrib */
  105080. },
  105081. menuOpts: {
  105082. menuId: 25 /* MenubarSelectionMenu */,
  105083. group: '3_multi',
  105084. title: nls.localize(1, null),
  105085. order: 2
  105086. }
  105087. }) || this;
  105088. }
  105089. InsertCursorAbove.prototype.run = function (accessor, editor, args) {
  105090. if (!editor.hasModel()) {
  105091. return;
  105092. }
  105093. var useLogicalLine = (args && args.logicalLine === true);
  105094. var cursors = editor._getCursors();
  105095. var context = cursors.context;
  105096. if (context.config.readOnly) {
  105097. return;
  105098. }
  105099. context.model.pushStackElement();
  105100. cursors.setStates(args.source, 3 /* Explicit */, cursorMoveCommands_1.CursorMoveCommands.addCursorUp(context, cursors.getAll(), useLogicalLine));
  105101. cursors.reveal(args.source, true, 1 /* TopMost */, 0 /* Smooth */);
  105102. };
  105103. return InsertCursorAbove;
  105104. }(editorExtensions_1.EditorAction));
  105105. exports.InsertCursorAbove = InsertCursorAbove;
  105106. var InsertCursorBelow = /** @class */ (function (_super) {
  105107. __extends(InsertCursorBelow, _super);
  105108. function InsertCursorBelow() {
  105109. return _super.call(this, {
  105110. id: 'editor.action.insertCursorBelow',
  105111. label: nls.localize(2, null),
  105112. alias: 'Add Cursor Below',
  105113. precondition: undefined,
  105114. kbOpts: {
  105115. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  105116. primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 18 /* DownArrow */,
  105117. linux: {
  105118. primary: 1024 /* Shift */ | 512 /* Alt */ | 18 /* DownArrow */,
  105119. secondary: [2048 /* CtrlCmd */ | 1024 /* Shift */ | 18 /* DownArrow */]
  105120. },
  105121. weight: 100 /* EditorContrib */
  105122. },
  105123. menuOpts: {
  105124. menuId: 25 /* MenubarSelectionMenu */,
  105125. group: '3_multi',
  105126. title: nls.localize(3, null),
  105127. order: 3
  105128. }
  105129. }) || this;
  105130. }
  105131. InsertCursorBelow.prototype.run = function (accessor, editor, args) {
  105132. if (!editor.hasModel()) {
  105133. return;
  105134. }
  105135. var useLogicalLine = (args && args.logicalLine === true);
  105136. var cursors = editor._getCursors();
  105137. var context = cursors.context;
  105138. if (context.config.readOnly) {
  105139. return;
  105140. }
  105141. context.model.pushStackElement();
  105142. cursors.setStates(args.source, 3 /* Explicit */, cursorMoveCommands_1.CursorMoveCommands.addCursorDown(context, cursors.getAll(), useLogicalLine));
  105143. cursors.reveal(args.source, true, 2 /* BottomMost */, 0 /* Smooth */);
  105144. };
  105145. return InsertCursorBelow;
  105146. }(editorExtensions_1.EditorAction));
  105147. exports.InsertCursorBelow = InsertCursorBelow;
  105148. var InsertCursorAtEndOfEachLineSelected = /** @class */ (function (_super) {
  105149. __extends(InsertCursorAtEndOfEachLineSelected, _super);
  105150. function InsertCursorAtEndOfEachLineSelected() {
  105151. return _super.call(this, {
  105152. id: 'editor.action.insertCursorAtEndOfEachLineSelected',
  105153. label: nls.localize(4, null),
  105154. alias: 'Add Cursors to Line Ends',
  105155. precondition: undefined,
  105156. kbOpts: {
  105157. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  105158. primary: 1024 /* Shift */ | 512 /* Alt */ | 39 /* KEY_I */,
  105159. weight: 100 /* EditorContrib */
  105160. },
  105161. menuOpts: {
  105162. menuId: 25 /* MenubarSelectionMenu */,
  105163. group: '3_multi',
  105164. title: nls.localize(5, null),
  105165. order: 4
  105166. }
  105167. }) || this;
  105168. }
  105169. InsertCursorAtEndOfEachLineSelected.prototype.getCursorsForSelection = function (selection, model, result) {
  105170. if (selection.isEmpty()) {
  105171. return;
  105172. }
  105173. for (var i = selection.startLineNumber; i < selection.endLineNumber; i++) {
  105174. var currentLineMaxColumn = model.getLineMaxColumn(i);
  105175. result.push(new selection_1.Selection(i, currentLineMaxColumn, i, currentLineMaxColumn));
  105176. }
  105177. if (selection.endColumn > 1) {
  105178. result.push(new selection_1.Selection(selection.endLineNumber, selection.endColumn, selection.endLineNumber, selection.endColumn));
  105179. }
  105180. };
  105181. InsertCursorAtEndOfEachLineSelected.prototype.run = function (accessor, editor) {
  105182. var _this = this;
  105183. if (!editor.hasModel()) {
  105184. return;
  105185. }
  105186. var model = editor.getModel();
  105187. var selections = editor.getSelections();
  105188. var newSelections = [];
  105189. selections.forEach(function (sel) { return _this.getCursorsForSelection(sel, model, newSelections); });
  105190. if (newSelections.length > 0) {
  105191. editor.setSelections(newSelections);
  105192. }
  105193. };
  105194. return InsertCursorAtEndOfEachLineSelected;
  105195. }(editorExtensions_1.EditorAction));
  105196. var InsertCursorAtEndOfLineSelected = /** @class */ (function (_super) {
  105197. __extends(InsertCursorAtEndOfLineSelected, _super);
  105198. function InsertCursorAtEndOfLineSelected() {
  105199. return _super.call(this, {
  105200. id: 'editor.action.addCursorsToBottom',
  105201. label: nls.localize(6, null),
  105202. alias: 'Add Cursors To Bottom',
  105203. precondition: undefined
  105204. }) || this;
  105205. }
  105206. InsertCursorAtEndOfLineSelected.prototype.run = function (accessor, editor) {
  105207. if (!editor.hasModel()) {
  105208. return;
  105209. }
  105210. var selections = editor.getSelections();
  105211. var lineCount = editor.getModel().getLineCount();
  105212. var newSelections = [];
  105213. for (var i = selections[0].startLineNumber; i <= lineCount; i++) {
  105214. newSelections.push(new selection_1.Selection(i, selections[0].startColumn, i, selections[0].endColumn));
  105215. }
  105216. if (newSelections.length > 0) {
  105217. editor.setSelections(newSelections);
  105218. }
  105219. };
  105220. return InsertCursorAtEndOfLineSelected;
  105221. }(editorExtensions_1.EditorAction));
  105222. var InsertCursorAtTopOfLineSelected = /** @class */ (function (_super) {
  105223. __extends(InsertCursorAtTopOfLineSelected, _super);
  105224. function InsertCursorAtTopOfLineSelected() {
  105225. return _super.call(this, {
  105226. id: 'editor.action.addCursorsToTop',
  105227. label: nls.localize(7, null),
  105228. alias: 'Add Cursors To Top',
  105229. precondition: undefined
  105230. }) || this;
  105231. }
  105232. InsertCursorAtTopOfLineSelected.prototype.run = function (accessor, editor) {
  105233. if (!editor.hasModel()) {
  105234. return;
  105235. }
  105236. var selections = editor.getSelections();
  105237. var newSelections = [];
  105238. for (var i = selections[0].startLineNumber; i >= 1; i--) {
  105239. newSelections.push(new selection_1.Selection(i, selections[0].startColumn, i, selections[0].endColumn));
  105240. }
  105241. if (newSelections.length > 0) {
  105242. editor.setSelections(newSelections);
  105243. }
  105244. };
  105245. return InsertCursorAtTopOfLineSelected;
  105246. }(editorExtensions_1.EditorAction));
  105247. var MultiCursorSessionResult = /** @class */ (function () {
  105248. function MultiCursorSessionResult(selections, revealRange, revealScrollType) {
  105249. this.selections = selections;
  105250. this.revealRange = revealRange;
  105251. this.revealScrollType = revealScrollType;
  105252. }
  105253. return MultiCursorSessionResult;
  105254. }());
  105255. exports.MultiCursorSessionResult = MultiCursorSessionResult;
  105256. var MultiCursorSession = /** @class */ (function () {
  105257. function MultiCursorSession(_editor, findController, isDisconnectedFromFindController, searchText, wholeWord, matchCase, currentMatch) {
  105258. this._editor = _editor;
  105259. this.findController = findController;
  105260. this.isDisconnectedFromFindController = isDisconnectedFromFindController;
  105261. this.searchText = searchText;
  105262. this.wholeWord = wholeWord;
  105263. this.matchCase = matchCase;
  105264. this.currentMatch = currentMatch;
  105265. }
  105266. MultiCursorSession.create = function (editor, findController) {
  105267. if (!editor.hasModel()) {
  105268. return null;
  105269. }
  105270. var findState = findController.getState();
  105271. // Find widget owns entirely what we search for if:
  105272. // - focus is not in the editor (i.e. it is in the find widget)
  105273. // - and the search widget is visible
  105274. // - and the search string is non-empty
  105275. if (!editor.hasTextFocus() && findState.isRevealed && findState.searchString.length > 0) {
  105276. // Find widget owns what is searched for
  105277. return new MultiCursorSession(editor, findController, false, findState.searchString, findState.wholeWord, findState.matchCase, null);
  105278. }
  105279. // Otherwise, the selection gives the search text, and the find widget gives the search settings
  105280. // The exception is the find state disassociation case: when beginning with a single, collapsed selection
  105281. var isDisconnectedFromFindController = false;
  105282. var wholeWord;
  105283. var matchCase;
  105284. var selections = editor.getSelections();
  105285. if (selections.length === 1 && selections[0].isEmpty()) {
  105286. isDisconnectedFromFindController = true;
  105287. wholeWord = true;
  105288. matchCase = true;
  105289. }
  105290. else {
  105291. wholeWord = findState.wholeWord;
  105292. matchCase = findState.matchCase;
  105293. }
  105294. // Selection owns what is searched for
  105295. var s = editor.getSelection();
  105296. var searchText;
  105297. var currentMatch = null;
  105298. if (s.isEmpty()) {
  105299. // selection is empty => expand to current word
  105300. var word = editor.getModel().getWordAtPosition(s.getStartPosition());
  105301. if (!word) {
  105302. return null;
  105303. }
  105304. searchText = word.word;
  105305. currentMatch = new selection_1.Selection(s.startLineNumber, word.startColumn, s.startLineNumber, word.endColumn);
  105306. }
  105307. else {
  105308. searchText = editor.getModel().getValueInRange(s).replace(/\r\n/g, '\n');
  105309. }
  105310. return new MultiCursorSession(editor, findController, isDisconnectedFromFindController, searchText, wholeWord, matchCase, currentMatch);
  105311. };
  105312. MultiCursorSession.prototype.addSelectionToNextFindMatch = function () {
  105313. if (!this._editor.hasModel()) {
  105314. return null;
  105315. }
  105316. var nextMatch = this._getNextMatch();
  105317. if (!nextMatch) {
  105318. return null;
  105319. }
  105320. var allSelections = this._editor.getSelections();
  105321. return new MultiCursorSessionResult(allSelections.concat(nextMatch), nextMatch, 0 /* Smooth */);
  105322. };
  105323. MultiCursorSession.prototype.moveSelectionToNextFindMatch = function () {
  105324. if (!this._editor.hasModel()) {
  105325. return null;
  105326. }
  105327. var nextMatch = this._getNextMatch();
  105328. if (!nextMatch) {
  105329. return null;
  105330. }
  105331. var allSelections = this._editor.getSelections();
  105332. return new MultiCursorSessionResult(allSelections.slice(0, allSelections.length - 1).concat(nextMatch), nextMatch, 0 /* Smooth */);
  105333. };
  105334. MultiCursorSession.prototype._getNextMatch = function () {
  105335. if (!this._editor.hasModel()) {
  105336. return null;
  105337. }
  105338. if (this.currentMatch) {
  105339. var result = this.currentMatch;
  105340. this.currentMatch = null;
  105341. return result;
  105342. }
  105343. this.findController.highlightFindOptions();
  105344. var allSelections = this._editor.getSelections();
  105345. var lastAddedSelection = allSelections[allSelections.length - 1];
  105346. var nextMatch = this._editor.getModel().findNextMatch(this.searchText, lastAddedSelection.getEndPosition(), false, this.matchCase, this.wholeWord ? this._editor.getOption(96 /* wordSeparators */) : null, false);
  105347. if (!nextMatch) {
  105348. return null;
  105349. }
  105350. return new selection_1.Selection(nextMatch.range.startLineNumber, nextMatch.range.startColumn, nextMatch.range.endLineNumber, nextMatch.range.endColumn);
  105351. };
  105352. MultiCursorSession.prototype.addSelectionToPreviousFindMatch = function () {
  105353. if (!this._editor.hasModel()) {
  105354. return null;
  105355. }
  105356. var previousMatch = this._getPreviousMatch();
  105357. if (!previousMatch) {
  105358. return null;
  105359. }
  105360. var allSelections = this._editor.getSelections();
  105361. return new MultiCursorSessionResult(allSelections.concat(previousMatch), previousMatch, 0 /* Smooth */);
  105362. };
  105363. MultiCursorSession.prototype.moveSelectionToPreviousFindMatch = function () {
  105364. if (!this._editor.hasModel()) {
  105365. return null;
  105366. }
  105367. var previousMatch = this._getPreviousMatch();
  105368. if (!previousMatch) {
  105369. return null;
  105370. }
  105371. var allSelections = this._editor.getSelections();
  105372. return new MultiCursorSessionResult(allSelections.slice(0, allSelections.length - 1).concat(previousMatch), previousMatch, 0 /* Smooth */);
  105373. };
  105374. MultiCursorSession.prototype._getPreviousMatch = function () {
  105375. if (!this._editor.hasModel()) {
  105376. return null;
  105377. }
  105378. if (this.currentMatch) {
  105379. var result = this.currentMatch;
  105380. this.currentMatch = null;
  105381. return result;
  105382. }
  105383. this.findController.highlightFindOptions();
  105384. var allSelections = this._editor.getSelections();
  105385. var lastAddedSelection = allSelections[allSelections.length - 1];
  105386. var previousMatch = this._editor.getModel().findPreviousMatch(this.searchText, lastAddedSelection.getStartPosition(), false, this.matchCase, this.wholeWord ? this._editor.getOption(96 /* wordSeparators */) : null, false);
  105387. if (!previousMatch) {
  105388. return null;
  105389. }
  105390. return new selection_1.Selection(previousMatch.range.startLineNumber, previousMatch.range.startColumn, previousMatch.range.endLineNumber, previousMatch.range.endColumn);
  105391. };
  105392. MultiCursorSession.prototype.selectAll = function () {
  105393. if (!this._editor.hasModel()) {
  105394. return [];
  105395. }
  105396. this.findController.highlightFindOptions();
  105397. return this._editor.getModel().findMatches(this.searchText, true, false, this.matchCase, this.wholeWord ? this._editor.getOption(96 /* wordSeparators */) : null, false, 1073741824 /* MAX_SAFE_SMALL_INTEGER */);
  105398. };
  105399. return MultiCursorSession;
  105400. }());
  105401. exports.MultiCursorSession = MultiCursorSession;
  105402. var MultiCursorSelectionController = /** @class */ (function (_super) {
  105403. __extends(MultiCursorSelectionController, _super);
  105404. function MultiCursorSelectionController(editor) {
  105405. var _this = _super.call(this) || this;
  105406. _this._sessionDispose = _this._register(new lifecycle_1.DisposableStore());
  105407. _this._editor = editor;
  105408. _this._ignoreSelectionChange = false;
  105409. _this._session = null;
  105410. return _this;
  105411. }
  105412. MultiCursorSelectionController.get = function (editor) {
  105413. return editor.getContribution(MultiCursorSelectionController.ID);
  105414. };
  105415. MultiCursorSelectionController.prototype.dispose = function () {
  105416. this._endSession();
  105417. _super.prototype.dispose.call(this);
  105418. };
  105419. MultiCursorSelectionController.prototype._beginSessionIfNeeded = function (findController) {
  105420. var _this = this;
  105421. if (!this._session) {
  105422. // Create a new session
  105423. var session = MultiCursorSession.create(this._editor, findController);
  105424. if (!session) {
  105425. return;
  105426. }
  105427. this._session = session;
  105428. var newState = { searchString: this._session.searchText };
  105429. if (this._session.isDisconnectedFromFindController) {
  105430. newState.wholeWordOverride = 1 /* True */;
  105431. newState.matchCaseOverride = 1 /* True */;
  105432. newState.isRegexOverride = 2 /* False */;
  105433. }
  105434. findController.getState().change(newState, false);
  105435. this._sessionDispose.add(this._editor.onDidChangeCursorSelection(function (e) {
  105436. if (_this._ignoreSelectionChange) {
  105437. return;
  105438. }
  105439. _this._endSession();
  105440. }));
  105441. this._sessionDispose.add(this._editor.onDidBlurEditorText(function () {
  105442. _this._endSession();
  105443. }));
  105444. this._sessionDispose.add(findController.getState().onFindReplaceStateChange(function (e) {
  105445. if (e.matchCase || e.wholeWord) {
  105446. _this._endSession();
  105447. }
  105448. }));
  105449. }
  105450. };
  105451. MultiCursorSelectionController.prototype._endSession = function () {
  105452. this._sessionDispose.clear();
  105453. if (this._session && this._session.isDisconnectedFromFindController) {
  105454. var newState = {
  105455. wholeWordOverride: 0 /* NotSet */,
  105456. matchCaseOverride: 0 /* NotSet */,
  105457. isRegexOverride: 0 /* NotSet */,
  105458. };
  105459. this._session.findController.getState().change(newState, false);
  105460. }
  105461. this._session = null;
  105462. };
  105463. MultiCursorSelectionController.prototype._setSelections = function (selections) {
  105464. this._ignoreSelectionChange = true;
  105465. this._editor.setSelections(selections);
  105466. this._ignoreSelectionChange = false;
  105467. };
  105468. MultiCursorSelectionController.prototype._expandEmptyToWord = function (model, selection) {
  105469. if (!selection.isEmpty()) {
  105470. return selection;
  105471. }
  105472. var word = model.getWordAtPosition(selection.getStartPosition());
  105473. if (!word) {
  105474. return selection;
  105475. }
  105476. return new selection_1.Selection(selection.startLineNumber, word.startColumn, selection.startLineNumber, word.endColumn);
  105477. };
  105478. MultiCursorSelectionController.prototype._applySessionResult = function (result) {
  105479. if (!result) {
  105480. return;
  105481. }
  105482. this._setSelections(result.selections);
  105483. if (result.revealRange) {
  105484. this._editor.revealRangeInCenterIfOutsideViewport(result.revealRange, result.revealScrollType);
  105485. }
  105486. };
  105487. MultiCursorSelectionController.prototype.getSession = function (findController) {
  105488. return this._session;
  105489. };
  105490. MultiCursorSelectionController.prototype.addSelectionToNextFindMatch = function (findController) {
  105491. if (!this._editor.hasModel()) {
  105492. return;
  105493. }
  105494. if (!this._session) {
  105495. // If there are multiple cursors, handle the case where they do not all select the same text.
  105496. var allSelections = this._editor.getSelections();
  105497. if (allSelections.length > 1) {
  105498. var findState = findController.getState();
  105499. var matchCase = findState.matchCase;
  105500. var selectionsContainSameText = modelRangesContainSameText(this._editor.getModel(), allSelections, matchCase);
  105501. if (!selectionsContainSameText) {
  105502. var model = this._editor.getModel();
  105503. var resultingSelections = [];
  105504. for (var i = 0, len = allSelections.length; i < len; i++) {
  105505. resultingSelections[i] = this._expandEmptyToWord(model, allSelections[i]);
  105506. }
  105507. this._editor.setSelections(resultingSelections);
  105508. return;
  105509. }
  105510. }
  105511. }
  105512. this._beginSessionIfNeeded(findController);
  105513. if (this._session) {
  105514. this._applySessionResult(this._session.addSelectionToNextFindMatch());
  105515. }
  105516. };
  105517. MultiCursorSelectionController.prototype.addSelectionToPreviousFindMatch = function (findController) {
  105518. this._beginSessionIfNeeded(findController);
  105519. if (this._session) {
  105520. this._applySessionResult(this._session.addSelectionToPreviousFindMatch());
  105521. }
  105522. };
  105523. MultiCursorSelectionController.prototype.moveSelectionToNextFindMatch = function (findController) {
  105524. this._beginSessionIfNeeded(findController);
  105525. if (this._session) {
  105526. this._applySessionResult(this._session.moveSelectionToNextFindMatch());
  105527. }
  105528. };
  105529. MultiCursorSelectionController.prototype.moveSelectionToPreviousFindMatch = function (findController) {
  105530. this._beginSessionIfNeeded(findController);
  105531. if (this._session) {
  105532. this._applySessionResult(this._session.moveSelectionToPreviousFindMatch());
  105533. }
  105534. };
  105535. MultiCursorSelectionController.prototype.selectAll = function (findController) {
  105536. if (!this._editor.hasModel()) {
  105537. return;
  105538. }
  105539. var matches = null;
  105540. var findState = findController.getState();
  105541. // Special case: find widget owns entirely what we search for if:
  105542. // - focus is not in the editor (i.e. it is in the find widget)
  105543. // - and the search widget is visible
  105544. // - and the search string is non-empty
  105545. // - and we're searching for a regex
  105546. if (findState.isRevealed && findState.searchString.length > 0 && findState.isRegex) {
  105547. matches = this._editor.getModel().findMatches(findState.searchString, true, findState.isRegex, findState.matchCase, findState.wholeWord ? this._editor.getOption(96 /* wordSeparators */) : null, false, 1073741824 /* MAX_SAFE_SMALL_INTEGER */);
  105548. }
  105549. else {
  105550. this._beginSessionIfNeeded(findController);
  105551. if (!this._session) {
  105552. return;
  105553. }
  105554. matches = this._session.selectAll();
  105555. }
  105556. if (findState.searchScope) {
  105557. var state = findState.searchScope;
  105558. var inSelection = [];
  105559. for (var i = 0; i < matches.length; i++) {
  105560. if (matches[i].range.endLineNumber <= state.endLineNumber && matches[i].range.startLineNumber >= state.startLineNumber) {
  105561. inSelection.push(matches[i]);
  105562. }
  105563. }
  105564. matches = inSelection;
  105565. }
  105566. if (matches.length > 0) {
  105567. var editorSelection = this._editor.getSelection();
  105568. // Have the primary cursor remain the one where the action was invoked
  105569. for (var i = 0, len = matches.length; i < len; i++) {
  105570. var match = matches[i];
  105571. var intersection = match.range.intersectRanges(editorSelection);
  105572. if (intersection) {
  105573. // bingo!
  105574. matches[i] = matches[0];
  105575. matches[0] = match;
  105576. break;
  105577. }
  105578. }
  105579. this._setSelections(matches.map(function (m) { return new selection_1.Selection(m.range.startLineNumber, m.range.startColumn, m.range.endLineNumber, m.range.endColumn); }));
  105580. }
  105581. };
  105582. MultiCursorSelectionController.ID = 'editor.contrib.multiCursorController';
  105583. return MultiCursorSelectionController;
  105584. }(lifecycle_1.Disposable));
  105585. exports.MultiCursorSelectionController = MultiCursorSelectionController;
  105586. var MultiCursorSelectionControllerAction = /** @class */ (function (_super) {
  105587. __extends(MultiCursorSelectionControllerAction, _super);
  105588. function MultiCursorSelectionControllerAction() {
  105589. return _super !== null && _super.apply(this, arguments) || this;
  105590. }
  105591. MultiCursorSelectionControllerAction.prototype.run = function (accessor, editor) {
  105592. var multiCursorController = MultiCursorSelectionController.get(editor);
  105593. if (!multiCursorController) {
  105594. return;
  105595. }
  105596. var findController = findController_1.CommonFindController.get(editor);
  105597. if (!findController) {
  105598. return;
  105599. }
  105600. this._run(multiCursorController, findController);
  105601. };
  105602. return MultiCursorSelectionControllerAction;
  105603. }(editorExtensions_1.EditorAction));
  105604. exports.MultiCursorSelectionControllerAction = MultiCursorSelectionControllerAction;
  105605. var AddSelectionToNextFindMatchAction = /** @class */ (function (_super) {
  105606. __extends(AddSelectionToNextFindMatchAction, _super);
  105607. function AddSelectionToNextFindMatchAction() {
  105608. return _super.call(this, {
  105609. id: 'editor.action.addSelectionToNextFindMatch',
  105610. label: nls.localize(8, null),
  105611. alias: 'Add Selection To Next Find Match',
  105612. precondition: undefined,
  105613. kbOpts: {
  105614. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  105615. primary: 2048 /* CtrlCmd */ | 34 /* KEY_D */,
  105616. weight: 100 /* EditorContrib */
  105617. },
  105618. menuOpts: {
  105619. menuId: 25 /* MenubarSelectionMenu */,
  105620. group: '3_multi',
  105621. title: nls.localize(9, null),
  105622. order: 5
  105623. }
  105624. }) || this;
  105625. }
  105626. AddSelectionToNextFindMatchAction.prototype._run = function (multiCursorController, findController) {
  105627. multiCursorController.addSelectionToNextFindMatch(findController);
  105628. };
  105629. return AddSelectionToNextFindMatchAction;
  105630. }(MultiCursorSelectionControllerAction));
  105631. exports.AddSelectionToNextFindMatchAction = AddSelectionToNextFindMatchAction;
  105632. var AddSelectionToPreviousFindMatchAction = /** @class */ (function (_super) {
  105633. __extends(AddSelectionToPreviousFindMatchAction, _super);
  105634. function AddSelectionToPreviousFindMatchAction() {
  105635. return _super.call(this, {
  105636. id: 'editor.action.addSelectionToPreviousFindMatch',
  105637. label: nls.localize(10, null),
  105638. alias: 'Add Selection To Previous Find Match',
  105639. precondition: undefined,
  105640. menuOpts: {
  105641. menuId: 25 /* MenubarSelectionMenu */,
  105642. group: '3_multi',
  105643. title: nls.localize(11, null),
  105644. order: 6
  105645. }
  105646. }) || this;
  105647. }
  105648. AddSelectionToPreviousFindMatchAction.prototype._run = function (multiCursorController, findController) {
  105649. multiCursorController.addSelectionToPreviousFindMatch(findController);
  105650. };
  105651. return AddSelectionToPreviousFindMatchAction;
  105652. }(MultiCursorSelectionControllerAction));
  105653. exports.AddSelectionToPreviousFindMatchAction = AddSelectionToPreviousFindMatchAction;
  105654. var MoveSelectionToNextFindMatchAction = /** @class */ (function (_super) {
  105655. __extends(MoveSelectionToNextFindMatchAction, _super);
  105656. function MoveSelectionToNextFindMatchAction() {
  105657. return _super.call(this, {
  105658. id: 'editor.action.moveSelectionToNextFindMatch',
  105659. label: nls.localize(12, null),
  105660. alias: 'Move Last Selection To Next Find Match',
  105661. precondition: undefined,
  105662. kbOpts: {
  105663. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  105664. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 34 /* KEY_D */),
  105665. weight: 100 /* EditorContrib */
  105666. }
  105667. }) || this;
  105668. }
  105669. MoveSelectionToNextFindMatchAction.prototype._run = function (multiCursorController, findController) {
  105670. multiCursorController.moveSelectionToNextFindMatch(findController);
  105671. };
  105672. return MoveSelectionToNextFindMatchAction;
  105673. }(MultiCursorSelectionControllerAction));
  105674. exports.MoveSelectionToNextFindMatchAction = MoveSelectionToNextFindMatchAction;
  105675. var MoveSelectionToPreviousFindMatchAction = /** @class */ (function (_super) {
  105676. __extends(MoveSelectionToPreviousFindMatchAction, _super);
  105677. function MoveSelectionToPreviousFindMatchAction() {
  105678. return _super.call(this, {
  105679. id: 'editor.action.moveSelectionToPreviousFindMatch',
  105680. label: nls.localize(13, null),
  105681. alias: 'Move Last Selection To Previous Find Match',
  105682. precondition: undefined
  105683. }) || this;
  105684. }
  105685. MoveSelectionToPreviousFindMatchAction.prototype._run = function (multiCursorController, findController) {
  105686. multiCursorController.moveSelectionToPreviousFindMatch(findController);
  105687. };
  105688. return MoveSelectionToPreviousFindMatchAction;
  105689. }(MultiCursorSelectionControllerAction));
  105690. exports.MoveSelectionToPreviousFindMatchAction = MoveSelectionToPreviousFindMatchAction;
  105691. var SelectHighlightsAction = /** @class */ (function (_super) {
  105692. __extends(SelectHighlightsAction, _super);
  105693. function SelectHighlightsAction() {
  105694. return _super.call(this, {
  105695. id: 'editor.action.selectHighlights',
  105696. label: nls.localize(14, null),
  105697. alias: 'Select All Occurrences of Find Match',
  105698. precondition: undefined,
  105699. kbOpts: {
  105700. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  105701. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 42 /* KEY_L */,
  105702. weight: 100 /* EditorContrib */
  105703. },
  105704. menuOpts: {
  105705. menuId: 25 /* MenubarSelectionMenu */,
  105706. group: '3_multi',
  105707. title: nls.localize(15, null),
  105708. order: 7
  105709. }
  105710. }) || this;
  105711. }
  105712. SelectHighlightsAction.prototype._run = function (multiCursorController, findController) {
  105713. multiCursorController.selectAll(findController);
  105714. };
  105715. return SelectHighlightsAction;
  105716. }(MultiCursorSelectionControllerAction));
  105717. exports.SelectHighlightsAction = SelectHighlightsAction;
  105718. var CompatChangeAll = /** @class */ (function (_super) {
  105719. __extends(CompatChangeAll, _super);
  105720. function CompatChangeAll() {
  105721. return _super.call(this, {
  105722. id: 'editor.action.changeAll',
  105723. label: nls.localize(16, null),
  105724. alias: 'Change All Occurrences',
  105725. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, editorContextKeys_1.EditorContextKeys.editorTextFocus),
  105726. kbOpts: {
  105727. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  105728. primary: 2048 /* CtrlCmd */ | 60 /* F2 */,
  105729. weight: 100 /* EditorContrib */
  105730. },
  105731. contextMenuOpts: {
  105732. group: '1_modification',
  105733. order: 1.2
  105734. }
  105735. }) || this;
  105736. }
  105737. CompatChangeAll.prototype._run = function (multiCursorController, findController) {
  105738. multiCursorController.selectAll(findController);
  105739. };
  105740. return CompatChangeAll;
  105741. }(MultiCursorSelectionControllerAction));
  105742. exports.CompatChangeAll = CompatChangeAll;
  105743. var SelectionHighlighterState = /** @class */ (function () {
  105744. function SelectionHighlighterState(searchText, matchCase, wordSeparators) {
  105745. this.searchText = searchText;
  105746. this.matchCase = matchCase;
  105747. this.wordSeparators = wordSeparators;
  105748. }
  105749. /**
  105750. * Everything equals except for `lastWordUnderCursor`
  105751. */
  105752. SelectionHighlighterState.softEquals = function (a, b) {
  105753. if (!a && !b) {
  105754. return true;
  105755. }
  105756. if (!a || !b) {
  105757. return false;
  105758. }
  105759. return (a.searchText === b.searchText
  105760. && a.matchCase === b.matchCase
  105761. && a.wordSeparators === b.wordSeparators);
  105762. };
  105763. return SelectionHighlighterState;
  105764. }());
  105765. var SelectionHighlighter = /** @class */ (function (_super) {
  105766. __extends(SelectionHighlighter, _super);
  105767. function SelectionHighlighter(editor) {
  105768. var _this = _super.call(this) || this;
  105769. _this.editor = editor;
  105770. _this._isEnabled = editor.getOption(82 /* selectionHighlight */);
  105771. _this.decorations = [];
  105772. _this.updateSoon = _this._register(new async_1.RunOnceScheduler(function () { return _this._update(); }, 300));
  105773. _this.state = null;
  105774. _this._register(editor.onDidChangeConfiguration(function (e) {
  105775. _this._isEnabled = editor.getOption(82 /* selectionHighlight */);
  105776. }));
  105777. _this._register(editor.onDidChangeCursorSelection(function (e) {
  105778. if (!_this._isEnabled) {
  105779. // Early exit if nothing needs to be done!
  105780. // Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
  105781. return;
  105782. }
  105783. if (e.selection.isEmpty()) {
  105784. if (e.reason === 3 /* Explicit */) {
  105785. if (_this.state) {
  105786. // no longer valid
  105787. _this._setState(null);
  105788. }
  105789. _this.updateSoon.schedule();
  105790. }
  105791. else {
  105792. _this._setState(null);
  105793. }
  105794. }
  105795. else {
  105796. _this._update();
  105797. }
  105798. }));
  105799. _this._register(editor.onDidChangeModel(function (e) {
  105800. _this._setState(null);
  105801. }));
  105802. _this._register(findController_1.CommonFindController.get(editor).getState().onFindReplaceStateChange(function (e) {
  105803. _this._update();
  105804. }));
  105805. return _this;
  105806. }
  105807. SelectionHighlighter.prototype._update = function () {
  105808. this._setState(SelectionHighlighter._createState(this._isEnabled, this.editor));
  105809. };
  105810. SelectionHighlighter._createState = function (isEnabled, editor) {
  105811. if (!isEnabled) {
  105812. return null;
  105813. }
  105814. if (!editor.hasModel()) {
  105815. return null;
  105816. }
  105817. var s = editor.getSelection();
  105818. if (s.startLineNumber !== s.endLineNumber) {
  105819. // multiline forbidden for perf reasons
  105820. return null;
  105821. }
  105822. var multiCursorController = MultiCursorSelectionController.get(editor);
  105823. if (!multiCursorController) {
  105824. return null;
  105825. }
  105826. var findController = findController_1.CommonFindController.get(editor);
  105827. if (!findController) {
  105828. return null;
  105829. }
  105830. var r = multiCursorController.getSession(findController);
  105831. if (!r) {
  105832. var allSelections = editor.getSelections();
  105833. if (allSelections.length > 1) {
  105834. var findState_1 = findController.getState();
  105835. var matchCase = findState_1.matchCase;
  105836. var selectionsContainSameText = modelRangesContainSameText(editor.getModel(), allSelections, matchCase);
  105837. if (!selectionsContainSameText) {
  105838. return null;
  105839. }
  105840. }
  105841. r = MultiCursorSession.create(editor, findController);
  105842. }
  105843. if (!r) {
  105844. return null;
  105845. }
  105846. if (r.currentMatch) {
  105847. // This is an empty selection
  105848. // Do not interfere with semantic word highlighting in the no selection case
  105849. return null;
  105850. }
  105851. if (/^[ \t]+$/.test(r.searchText)) {
  105852. // whitespace only selection
  105853. return null;
  105854. }
  105855. if (r.searchText.length > 200) {
  105856. // very long selection
  105857. return null;
  105858. }
  105859. // TODO: better handling of this case
  105860. var findState = findController.getState();
  105861. var caseSensitive = findState.matchCase;
  105862. // Return early if the find widget shows the exact same matches
  105863. if (findState.isRevealed) {
  105864. var findStateSearchString = findState.searchString;
  105865. if (!caseSensitive) {
  105866. findStateSearchString = findStateSearchString.toLowerCase();
  105867. }
  105868. var mySearchString = r.searchText;
  105869. if (!caseSensitive) {
  105870. mySearchString = mySearchString.toLowerCase();
  105871. }
  105872. if (findStateSearchString === mySearchString && r.matchCase === findState.matchCase && r.wholeWord === findState.wholeWord && !findState.isRegex) {
  105873. return null;
  105874. }
  105875. }
  105876. return new SelectionHighlighterState(r.searchText, r.matchCase, r.wholeWord ? editor.getOption(96 /* wordSeparators */) : null);
  105877. };
  105878. SelectionHighlighter.prototype._setState = function (state) {
  105879. if (SelectionHighlighterState.softEquals(this.state, state)) {
  105880. this.state = state;
  105881. return;
  105882. }
  105883. this.state = state;
  105884. if (!this.state) {
  105885. this.decorations = this.editor.deltaDecorations(this.decorations, []);
  105886. return;
  105887. }
  105888. if (!this.editor.hasModel()) {
  105889. return;
  105890. }
  105891. var model = this.editor.getModel();
  105892. if (model.isTooLargeForTokenization()) {
  105893. // the file is too large, so searching word under cursor in the whole document takes is blocking the UI.
  105894. return;
  105895. }
  105896. var hasFindOccurrences = modes_1.DocumentHighlightProviderRegistry.has(model);
  105897. var allMatches = model.findMatches(this.state.searchText, true, false, this.state.matchCase, this.state.wordSeparators, false).map(function (m) { return m.range; });
  105898. allMatches.sort(range_1.Range.compareRangesUsingStarts);
  105899. var selections = this.editor.getSelections();
  105900. selections.sort(range_1.Range.compareRangesUsingStarts);
  105901. // do not overlap with selection (issue #64 and #512)
  105902. var matches = [];
  105903. for (var i = 0, j = 0, len = allMatches.length, lenJ = selections.length; i < len;) {
  105904. var match = allMatches[i];
  105905. if (j >= lenJ) {
  105906. // finished all editor selections
  105907. matches.push(match);
  105908. i++;
  105909. }
  105910. else {
  105911. var cmp = range_1.Range.compareRangesUsingStarts(match, selections[j]);
  105912. if (cmp < 0) {
  105913. // match is before sel
  105914. if (selections[j].isEmpty() || !range_1.Range.areIntersecting(match, selections[j])) {
  105915. matches.push(match);
  105916. }
  105917. i++;
  105918. }
  105919. else if (cmp > 0) {
  105920. // sel is before match
  105921. j++;
  105922. }
  105923. else {
  105924. // sel is equal to match
  105925. i++;
  105926. j++;
  105927. }
  105928. }
  105929. }
  105930. var decorations = matches.map(function (r) {
  105931. return {
  105932. range: r,
  105933. // Show in overviewRuler only if model has no semantic highlighting
  105934. options: (hasFindOccurrences ? SelectionHighlighter._SELECTION_HIGHLIGHT : SelectionHighlighter._SELECTION_HIGHLIGHT_OVERVIEW)
  105935. };
  105936. });
  105937. this.decorations = this.editor.deltaDecorations(this.decorations, decorations);
  105938. };
  105939. SelectionHighlighter.prototype.dispose = function () {
  105940. this._setState(null);
  105941. _super.prototype.dispose.call(this);
  105942. };
  105943. SelectionHighlighter.ID = 'editor.contrib.selectionHighlighter';
  105944. SelectionHighlighter._SELECTION_HIGHLIGHT_OVERVIEW = textModel_1.ModelDecorationOptions.register({
  105945. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  105946. className: 'selectionHighlight',
  105947. overviewRuler: {
  105948. color: themeService_1.themeColorFromId(colorRegistry_1.overviewRulerSelectionHighlightForeground),
  105949. position: model_1.OverviewRulerLane.Center
  105950. }
  105951. });
  105952. SelectionHighlighter._SELECTION_HIGHLIGHT = textModel_1.ModelDecorationOptions.register({
  105953. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  105954. className: 'selectionHighlight',
  105955. });
  105956. return SelectionHighlighter;
  105957. }(lifecycle_1.Disposable));
  105958. exports.SelectionHighlighter = SelectionHighlighter;
  105959. function modelRangesContainSameText(model, ranges, matchCase) {
  105960. var selectedText = getValueInRange(model, ranges[0], !matchCase);
  105961. for (var i = 1, len = ranges.length; i < len; i++) {
  105962. var range = ranges[i];
  105963. if (range.isEmpty()) {
  105964. return false;
  105965. }
  105966. var thisSelectedText = getValueInRange(model, range, !matchCase);
  105967. if (selectedText !== thisSelectedText) {
  105968. return false;
  105969. }
  105970. }
  105971. return true;
  105972. }
  105973. function getValueInRange(model, range, toLowerCase) {
  105974. var text = model.getValueInRange(range);
  105975. return (toLowerCase ? text.toLowerCase() : text);
  105976. }
  105977. editorExtensions_1.registerEditorContribution(MultiCursorSelectionController.ID, MultiCursorSelectionController);
  105978. editorExtensions_1.registerEditorContribution(SelectionHighlighter.ID, SelectionHighlighter);
  105979. editorExtensions_1.registerEditorAction(InsertCursorAbove);
  105980. editorExtensions_1.registerEditorAction(InsertCursorBelow);
  105981. editorExtensions_1.registerEditorAction(InsertCursorAtEndOfEachLineSelected);
  105982. editorExtensions_1.registerEditorAction(AddSelectionToNextFindMatchAction);
  105983. editorExtensions_1.registerEditorAction(AddSelectionToPreviousFindMatchAction);
  105984. editorExtensions_1.registerEditorAction(MoveSelectionToNextFindMatchAction);
  105985. editorExtensions_1.registerEditorAction(MoveSelectionToPreviousFindMatchAction);
  105986. editorExtensions_1.registerEditorAction(SelectHighlightsAction);
  105987. editorExtensions_1.registerEditorAction(CompatChangeAll);
  105988. editorExtensions_1.registerEditorAction(InsertCursorAtEndOfLineSelected);
  105989. editorExtensions_1.registerEditorAction(InsertCursorAtTopOfLineSelected);
  105990. });
  105991. /*---------------------------------------------------------------------------------------------
  105992. * Copyright (c) Microsoft Corporation. All rights reserved.
  105993. * Licensed under the MIT License. See License.txt in the project root for license information.
  105994. *--------------------------------------------------------------------------------------------*/
  105995. define(__m[581/*vs/editor/contrib/parameterHints/parameterHintsWidget*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,52/*vs/base/browser/event*/,50/*vs/base/browser/ui/aria/aria*/,53/*vs/base/browser/ui/scrollbar/scrollableElement*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,71/*vs/editor/common/services/modeService*/,117/*vs/editor/contrib/markdown/markdownRenderer*/,165/*vs/editor/contrib/parameterHints/provideSignatureHelp*/,461/*vs/nls!vs/editor/contrib/parameterHints/parameterHintsWidget*/,18/*vs/platform/contextkey/common/contextkey*/,51/*vs/platform/opener/common/opener*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,540/*vs/editor/contrib/parameterHints/parameterHintsModel*/,5/*vs/base/common/strings*/,318/*vs/css!vs/editor/contrib/parameterHints/parameterHints*/]), function (require, exports, dom, event_1, aria, scrollableElement_1, event_2, lifecycle_1, modeService_1, markdownRenderer_1, provideSignatureHelp_1, nls, contextkey_1, opener_1, colorRegistry_1, themeService_1, parameterHintsModel_1, strings_1) {
  105996. "use strict";
  105997. Object.defineProperty(exports, "__esModule", { value: true });
  105998. var $ = dom.$;
  105999. var ParameterHintsWidget = /** @class */ (function (_super) {
  106000. __extends(ParameterHintsWidget, _super);
  106001. function ParameterHintsWidget(editor, contextKeyService, openerService, modeService) {
  106002. var _this = _super.call(this) || this;
  106003. _this.editor = editor;
  106004. _this.renderDisposeables = _this._register(new lifecycle_1.DisposableStore());
  106005. _this.visible = false;
  106006. _this.announcedLabel = null;
  106007. // Editor.IContentWidget.allowEditorOverflow
  106008. _this.allowEditorOverflow = true;
  106009. _this.markdownRenderer = _this._register(new markdownRenderer_1.MarkdownRenderer(editor, modeService, openerService));
  106010. _this.model = _this._register(new parameterHintsModel_1.ParameterHintsModel(editor));
  106011. _this.keyVisible = provideSignatureHelp_1.Context.Visible.bindTo(contextKeyService);
  106012. _this.keyMultipleSignatures = provideSignatureHelp_1.Context.MultipleSignatures.bindTo(contextKeyService);
  106013. _this._register(_this.model.onChangedHints(function (newParameterHints) {
  106014. if (newParameterHints) {
  106015. _this.show();
  106016. _this.render(newParameterHints);
  106017. }
  106018. else {
  106019. _this.hide();
  106020. }
  106021. }));
  106022. return _this;
  106023. }
  106024. ParameterHintsWidget.prototype.createParamaterHintDOMNodes = function () {
  106025. var _this = this;
  106026. var element = $('.editor-widget.parameter-hints-widget');
  106027. var wrapper = dom.append(element, $('.wrapper'));
  106028. wrapper.tabIndex = -1;
  106029. var controls = dom.append(wrapper, $('.controls'));
  106030. var previous = dom.append(controls, $('.button.codicon.codicon-chevron-up'));
  106031. var overloads = dom.append(controls, $('.overloads'));
  106032. var next = dom.append(controls, $('.button.codicon.codicon-chevron-down'));
  106033. var onPreviousClick = event_1.stop(event_1.domEvent(previous, 'click'));
  106034. this._register(onPreviousClick(this.previous, this));
  106035. var onNextClick = event_1.stop(event_1.domEvent(next, 'click'));
  106036. this._register(onNextClick(this.next, this));
  106037. var body = $('.body');
  106038. var scrollbar = new scrollableElement_1.DomScrollableElement(body, {});
  106039. this._register(scrollbar);
  106040. wrapper.appendChild(scrollbar.getDomNode());
  106041. var signature = dom.append(body, $('.signature'));
  106042. var docs = dom.append(body, $('.docs'));
  106043. element.style.userSelect = 'text';
  106044. this.domNodes = {
  106045. element: element,
  106046. signature: signature,
  106047. overloads: overloads,
  106048. docs: docs,
  106049. scrollbar: scrollbar,
  106050. };
  106051. this.editor.addContentWidget(this);
  106052. this.hide();
  106053. this._register(this.editor.onDidChangeCursorSelection(function (e) {
  106054. if (_this.visible) {
  106055. _this.editor.layoutContentWidget(_this);
  106056. }
  106057. }));
  106058. var updateFont = function () {
  106059. if (!_this.domNodes) {
  106060. return;
  106061. }
  106062. var fontInfo = _this.editor.getOption(34 /* fontInfo */);
  106063. _this.domNodes.element.style.fontSize = fontInfo.fontSize + "px";
  106064. };
  106065. updateFont();
  106066. this._register(event_2.Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor))
  106067. .filter(function (e) { return e.hasChanged(34 /* fontInfo */); })
  106068. .on(updateFont, null));
  106069. this._register(this.editor.onDidLayoutChange(function (e) { return _this.updateMaxHeight(); }));
  106070. this.updateMaxHeight();
  106071. };
  106072. ParameterHintsWidget.prototype.show = function () {
  106073. var _this = this;
  106074. if (this.visible) {
  106075. return;
  106076. }
  106077. if (!this.domNodes) {
  106078. this.createParamaterHintDOMNodes();
  106079. }
  106080. this.keyVisible.set(true);
  106081. this.visible = true;
  106082. setTimeout(function () {
  106083. if (_this.domNodes) {
  106084. dom.addClass(_this.domNodes.element, 'visible');
  106085. }
  106086. }, 100);
  106087. this.editor.layoutContentWidget(this);
  106088. };
  106089. ParameterHintsWidget.prototype.hide = function () {
  106090. if (!this.visible) {
  106091. return;
  106092. }
  106093. this.keyVisible.reset();
  106094. this.visible = false;
  106095. this.announcedLabel = null;
  106096. if (this.domNodes) {
  106097. dom.removeClass(this.domNodes.element, 'visible');
  106098. }
  106099. this.editor.layoutContentWidget(this);
  106100. };
  106101. ParameterHintsWidget.prototype.getPosition = function () {
  106102. if (this.visible) {
  106103. return {
  106104. position: this.editor.getPosition(),
  106105. preference: [1 /* ABOVE */, 2 /* BELOW */]
  106106. };
  106107. }
  106108. return null;
  106109. };
  106110. ParameterHintsWidget.prototype.render = function (hints) {
  106111. if (!this.domNodes) {
  106112. return;
  106113. }
  106114. var multiple = hints.signatures.length > 1;
  106115. dom.toggleClass(this.domNodes.element, 'multiple', multiple);
  106116. this.keyMultipleSignatures.set(multiple);
  106117. this.domNodes.signature.innerHTML = '';
  106118. this.domNodes.docs.innerHTML = '';
  106119. var signature = hints.signatures[hints.activeSignature];
  106120. if (!signature) {
  106121. return;
  106122. }
  106123. var code = dom.append(this.domNodes.signature, $('.code'));
  106124. var hasParameters = signature.parameters.length > 0;
  106125. var fontInfo = this.editor.getOption(34 /* fontInfo */);
  106126. code.style.fontSize = fontInfo.fontSize + "px";
  106127. code.style.fontFamily = fontInfo.fontFamily;
  106128. if (!hasParameters) {
  106129. var label = dom.append(code, $('span'));
  106130. label.textContent = signature.label;
  106131. }
  106132. else {
  106133. this.renderParameters(code, signature, hints.activeParameter);
  106134. }
  106135. this.renderDisposeables.clear();
  106136. var activeParameter = signature.parameters[hints.activeParameter];
  106137. if (activeParameter && activeParameter.documentation) {
  106138. var documentation = $('span.documentation');
  106139. if (typeof activeParameter.documentation === 'string') {
  106140. documentation.textContent = activeParameter.documentation;
  106141. }
  106142. else {
  106143. var renderedContents = this.markdownRenderer.render(activeParameter.documentation);
  106144. dom.addClass(renderedContents.element, 'markdown-docs');
  106145. this.renderDisposeables.add(renderedContents);
  106146. documentation.appendChild(renderedContents.element);
  106147. }
  106148. dom.append(this.domNodes.docs, $('p', {}, documentation));
  106149. }
  106150. if (signature.documentation === undefined) { /** no op */ }
  106151. else if (typeof signature.documentation === 'string') {
  106152. dom.append(this.domNodes.docs, $('p', {}, signature.documentation));
  106153. }
  106154. else {
  106155. var renderedContents = this.markdownRenderer.render(signature.documentation);
  106156. dom.addClass(renderedContents.element, 'markdown-docs');
  106157. this.renderDisposeables.add(renderedContents);
  106158. dom.append(this.domNodes.docs, renderedContents.element);
  106159. }
  106160. var hasDocs = this.hasDocs(signature, activeParameter);
  106161. dom.toggleClass(this.domNodes.signature, 'has-docs', hasDocs);
  106162. dom.toggleClass(this.domNodes.docs, 'empty', !hasDocs);
  106163. this.domNodes.overloads.textContent =
  106164. strings_1.pad(hints.activeSignature + 1, hints.signatures.length.toString().length) + '/' + hints.signatures.length;
  106165. if (activeParameter) {
  106166. var labelToAnnounce = this.getParameterLabel(signature, hints.activeParameter);
  106167. // Select method gets called on every user type while parameter hints are visible.
  106168. // We do not want to spam the user with same announcements, so we only announce if the current parameter changed.
  106169. if (this.announcedLabel !== labelToAnnounce) {
  106170. aria.alert(nls.localize(0, null, labelToAnnounce));
  106171. this.announcedLabel = labelToAnnounce;
  106172. }
  106173. }
  106174. this.editor.layoutContentWidget(this);
  106175. this.domNodes.scrollbar.scanDomNode();
  106176. };
  106177. ParameterHintsWidget.prototype.hasDocs = function (signature, activeParameter) {
  106178. if (activeParameter && typeof (activeParameter.documentation) === 'string' && activeParameter.documentation.length > 0) {
  106179. return true;
  106180. }
  106181. if (activeParameter && typeof (activeParameter.documentation) === 'object' && activeParameter.documentation.value.length > 0) {
  106182. return true;
  106183. }
  106184. if (typeof (signature.documentation) === 'string' && signature.documentation.length > 0) {
  106185. return true;
  106186. }
  106187. if (typeof (signature.documentation) === 'object' && signature.documentation.value.length > 0) {
  106188. return true;
  106189. }
  106190. return false;
  106191. };
  106192. ParameterHintsWidget.prototype.renderParameters = function (parent, signature, currentParameter) {
  106193. var _a = this.getParameterLabelOffsets(signature, currentParameter), start = _a[0], end = _a[1];
  106194. var beforeSpan = document.createElement('span');
  106195. beforeSpan.textContent = signature.label.substring(0, start);
  106196. var paramSpan = document.createElement('span');
  106197. paramSpan.textContent = signature.label.substring(start, end);
  106198. paramSpan.className = 'parameter active';
  106199. var afterSpan = document.createElement('span');
  106200. afterSpan.textContent = signature.label.substring(end);
  106201. dom.append(parent, beforeSpan, paramSpan, afterSpan);
  106202. };
  106203. ParameterHintsWidget.prototype.getParameterLabel = function (signature, paramIdx) {
  106204. var param = signature.parameters[paramIdx];
  106205. if (typeof param.label === 'string') {
  106206. return param.label;
  106207. }
  106208. else {
  106209. return signature.label.substring(param.label[0], param.label[1]);
  106210. }
  106211. };
  106212. ParameterHintsWidget.prototype.getParameterLabelOffsets = function (signature, paramIdx) {
  106213. var param = signature.parameters[paramIdx];
  106214. if (!param) {
  106215. return [0, 0];
  106216. }
  106217. else if (Array.isArray(param.label)) {
  106218. return param.label;
  106219. }
  106220. else {
  106221. var idx = signature.label.lastIndexOf(param.label);
  106222. return idx >= 0
  106223. ? [idx, idx + param.label.length]
  106224. : [0, 0];
  106225. }
  106226. };
  106227. ParameterHintsWidget.prototype.next = function () {
  106228. this.editor.focus();
  106229. this.model.next();
  106230. };
  106231. ParameterHintsWidget.prototype.previous = function () {
  106232. this.editor.focus();
  106233. this.model.previous();
  106234. };
  106235. ParameterHintsWidget.prototype.cancel = function () {
  106236. this.model.cancel();
  106237. };
  106238. ParameterHintsWidget.prototype.getDomNode = function () {
  106239. if (!this.domNodes) {
  106240. this.createParamaterHintDOMNodes();
  106241. }
  106242. return this.domNodes.element;
  106243. };
  106244. ParameterHintsWidget.prototype.getId = function () {
  106245. return ParameterHintsWidget.ID;
  106246. };
  106247. ParameterHintsWidget.prototype.trigger = function (context) {
  106248. this.model.trigger(context, 0);
  106249. };
  106250. ParameterHintsWidget.prototype.updateMaxHeight = function () {
  106251. if (!this.domNodes) {
  106252. return;
  106253. }
  106254. var height = Math.max(this.editor.getLayoutInfo().height / 4, 250);
  106255. var maxHeight = height + "px";
  106256. this.domNodes.element.style.maxHeight = maxHeight;
  106257. var wrapper = this.domNodes.element.getElementsByClassName('wrapper');
  106258. if (wrapper.length) {
  106259. wrapper[0].style.maxHeight = maxHeight;
  106260. }
  106261. };
  106262. ParameterHintsWidget.ID = 'editor.widget.parameterHintsWidget';
  106263. ParameterHintsWidget = __decorate([
  106264. __param(1, contextkey_1.IContextKeyService),
  106265. __param(2, opener_1.IOpenerService),
  106266. __param(3, modeService_1.IModeService)
  106267. ], ParameterHintsWidget);
  106268. return ParameterHintsWidget;
  106269. }(lifecycle_1.Disposable));
  106270. exports.ParameterHintsWidget = ParameterHintsWidget;
  106271. themeService_1.registerThemingParticipant(function (theme, collector) {
  106272. var border = theme.getColor(colorRegistry_1.editorHoverBorder);
  106273. if (border) {
  106274. var borderWidth = theme.type === themeService_1.HIGH_CONTRAST ? 2 : 1;
  106275. collector.addRule(".monaco-editor .parameter-hints-widget { border: " + borderWidth + "px solid " + border + "; }");
  106276. collector.addRule(".monaco-editor .parameter-hints-widget.multiple .body { border-left: 1px solid " + border.transparent(0.5) + "; }");
  106277. collector.addRule(".monaco-editor .parameter-hints-widget .signature.has-docs { border-bottom: 1px solid " + border.transparent(0.5) + "; }");
  106278. }
  106279. var background = theme.getColor(colorRegistry_1.editorHoverBackground);
  106280. if (background) {
  106281. collector.addRule(".monaco-editor .parameter-hints-widget { background-color: " + background + "; }");
  106282. }
  106283. var link = theme.getColor(colorRegistry_1.textLinkForeground);
  106284. if (link) {
  106285. collector.addRule(".monaco-editor .parameter-hints-widget a { color: " + link + "; }");
  106286. }
  106287. var foreground = theme.getColor(colorRegistry_1.editorHoverForeground);
  106288. if (foreground) {
  106289. collector.addRule(".monaco-editor .parameter-hints-widget { color: " + foreground + "; }");
  106290. }
  106291. var codeBackground = theme.getColor(colorRegistry_1.textCodeBlockBackground);
  106292. if (codeBackground) {
  106293. collector.addRule(".monaco-editor .parameter-hints-widget code { background-color: " + codeBackground + "; }");
  106294. }
  106295. });
  106296. });
  106297. /*---------------------------------------------------------------------------------------------
  106298. * Copyright (c) Microsoft Corporation. All rights reserved.
  106299. * Licensed under the MIT License. See License.txt in the project root for license information.
  106300. *--------------------------------------------------------------------------------------------*/
  106301. define(__m[582/*vs/editor/contrib/parameterHints/parameterHints*/], __M([0/*require*/,1/*exports*/,460/*vs/nls!vs/editor/contrib/parameterHints/parameterHints*/,2/*vs/base/common/lifecycle*/,11/*vs/platform/instantiation/common/instantiation*/,23/*vs/editor/common/editorContextKeys*/,18/*vs/platform/contextkey/common/contextkey*/,12/*vs/editor/browser/editorExtensions*/,581/*vs/editor/contrib/parameterHints/parameterHintsWidget*/,165/*vs/editor/contrib/parameterHints/provideSignatureHelp*/,17/*vs/editor/common/modes*/]), function (require, exports, nls, lifecycle_1, instantiation_1, editorContextKeys_1, contextkey_1, editorExtensions_1, parameterHintsWidget_1, provideSignatureHelp_1, modes) {
  106302. "use strict";
  106303. Object.defineProperty(exports, "__esModule", { value: true });
  106304. var ParameterHintsController = /** @class */ (function (_super) {
  106305. __extends(ParameterHintsController, _super);
  106306. function ParameterHintsController(editor, instantiationService) {
  106307. var _this = _super.call(this) || this;
  106308. _this.editor = editor;
  106309. _this.widget = _this._register(instantiationService.createInstance(parameterHintsWidget_1.ParameterHintsWidget, _this.editor));
  106310. return _this;
  106311. }
  106312. ParameterHintsController.get = function (editor) {
  106313. return editor.getContribution(ParameterHintsController.ID);
  106314. };
  106315. ParameterHintsController.prototype.cancel = function () {
  106316. this.widget.cancel();
  106317. };
  106318. ParameterHintsController.prototype.previous = function () {
  106319. this.widget.previous();
  106320. };
  106321. ParameterHintsController.prototype.next = function () {
  106322. this.widget.next();
  106323. };
  106324. ParameterHintsController.prototype.trigger = function (context) {
  106325. this.widget.trigger(context);
  106326. };
  106327. ParameterHintsController.ID = 'editor.controller.parameterHints';
  106328. ParameterHintsController = __decorate([
  106329. __param(1, instantiation_1.IInstantiationService)
  106330. ], ParameterHintsController);
  106331. return ParameterHintsController;
  106332. }(lifecycle_1.Disposable));
  106333. var TriggerParameterHintsAction = /** @class */ (function (_super) {
  106334. __extends(TriggerParameterHintsAction, _super);
  106335. function TriggerParameterHintsAction() {
  106336. return _super.call(this, {
  106337. id: 'editor.action.triggerParameterHints',
  106338. label: nls.localize(0, null),
  106339. alias: 'Trigger Parameter Hints',
  106340. precondition: editorContextKeys_1.EditorContextKeys.hasSignatureHelpProvider,
  106341. kbOpts: {
  106342. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  106343. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 10 /* Space */,
  106344. weight: 100 /* EditorContrib */
  106345. }
  106346. }) || this;
  106347. }
  106348. TriggerParameterHintsAction.prototype.run = function (accessor, editor) {
  106349. var controller = ParameterHintsController.get(editor);
  106350. if (controller) {
  106351. controller.trigger({
  106352. triggerKind: modes.SignatureHelpTriggerKind.Invoke
  106353. });
  106354. }
  106355. };
  106356. return TriggerParameterHintsAction;
  106357. }(editorExtensions_1.EditorAction));
  106358. exports.TriggerParameterHintsAction = TriggerParameterHintsAction;
  106359. editorExtensions_1.registerEditorContribution(ParameterHintsController.ID, ParameterHintsController);
  106360. editorExtensions_1.registerEditorAction(TriggerParameterHintsAction);
  106361. var weight = 100 /* EditorContrib */ + 75;
  106362. var ParameterHintsCommand = editorExtensions_1.EditorCommand.bindToContribution(ParameterHintsController.get);
  106363. editorExtensions_1.registerEditorCommand(new ParameterHintsCommand({
  106364. id: 'closeParameterHints',
  106365. precondition: provideSignatureHelp_1.Context.Visible,
  106366. handler: function (x) { return x.cancel(); },
  106367. kbOpts: {
  106368. weight: weight,
  106369. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  106370. primary: 9 /* Escape */,
  106371. secondary: [1024 /* Shift */ | 9 /* Escape */]
  106372. }
  106373. }));
  106374. editorExtensions_1.registerEditorCommand(new ParameterHintsCommand({
  106375. id: 'showPrevParameterHint',
  106376. precondition: contextkey_1.ContextKeyExpr.and(provideSignatureHelp_1.Context.Visible, provideSignatureHelp_1.Context.MultipleSignatures),
  106377. handler: function (x) { return x.previous(); },
  106378. kbOpts: {
  106379. weight: weight,
  106380. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  106381. primary: 16 /* UpArrow */,
  106382. secondary: [512 /* Alt */ | 16 /* UpArrow */],
  106383. mac: { primary: 16 /* UpArrow */, secondary: [512 /* Alt */ | 16 /* UpArrow */, 256 /* WinCtrl */ | 46 /* KEY_P */] }
  106384. }
  106385. }));
  106386. editorExtensions_1.registerEditorCommand(new ParameterHintsCommand({
  106387. id: 'showNextParameterHint',
  106388. precondition: contextkey_1.ContextKeyExpr.and(provideSignatureHelp_1.Context.Visible, provideSignatureHelp_1.Context.MultipleSignatures),
  106389. handler: function (x) { return x.next(); },
  106390. kbOpts: {
  106391. weight: weight,
  106392. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  106393. primary: 18 /* DownArrow */,
  106394. secondary: [512 /* Alt */ | 18 /* DownArrow */],
  106395. mac: { primary: 18 /* DownArrow */, secondary: [512 /* Alt */ | 18 /* DownArrow */, 256 /* WinCtrl */ | 44 /* KEY_N */] }
  106396. }
  106397. }));
  106398. });
  106399. /*---------------------------------------------------------------------------------------------
  106400. * Copyright (c) Microsoft Corporation. All rights reserved.
  106401. * Licensed under the MIT License. See License.txt in the project root for license information.
  106402. *--------------------------------------------------------------------------------------------*/
  106403. define(__m[123/*vs/editor/contrib/peekView/peekView*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,70/*vs/base/browser/ui/actionbar/actionbar*/,55/*vs/base/common/actions*/,27/*vs/base/common/color*/,4/*vs/base/common/event*/,31/*vs/base/common/objects*/,5/*vs/base/common/strings*/,32/*vs/editor/browser/services/codeEditorService*/,167/*vs/editor/browser/widget/embeddedCodeEditorWidget*/,493/*vs/editor/contrib/zoneWidget/zoneWidget*/,462/*vs/nls!vs/editor/contrib/peekView/peekView*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,83/*vs/platform/instantiation/common/extensions*/,12/*vs/editor/browser/editorExtensions*/,20/*vs/platform/theme/common/colorRegistry*/,319/*vs/css!vs/editor/contrib/peekView/media/peekViewWidget*/]), function (require, exports, dom, actionbar_1, actions_1, color_1, event_1, objects, strings, codeEditorService_1, embeddedCodeEditorWidget_1, zoneWidget_1, nls, contextkey_1, instantiation_1, extensions_1, editorExtensions_1, colorRegistry_1) {
  106404. "use strict";
  106405. Object.defineProperty(exports, "__esModule", { value: true });
  106406. exports.IPeekViewService = instantiation_1.createDecorator('IPeekViewService');
  106407. extensions_1.registerSingleton(exports.IPeekViewService, /** @class */ (function () {
  106408. function class_1() {
  106409. this._widgets = new Map();
  106410. }
  106411. class_1.prototype.addExclusiveWidget = function (editor, widget) {
  106412. var _this = this;
  106413. var existing = this._widgets.get(editor);
  106414. if (existing) {
  106415. existing.listener.dispose();
  106416. existing.widget.dispose();
  106417. }
  106418. var remove = function () {
  106419. var data = _this._widgets.get(editor);
  106420. if (data && data.widget === widget) {
  106421. data.listener.dispose();
  106422. _this._widgets.delete(editor);
  106423. }
  106424. };
  106425. this._widgets.set(editor, { widget: widget, listener: widget.onDidClose(remove) });
  106426. };
  106427. return class_1;
  106428. }()));
  106429. var PeekContext;
  106430. (function (PeekContext) {
  106431. PeekContext.inPeekEditor = new contextkey_1.RawContextKey('inReferenceSearchEditor', true);
  106432. PeekContext.notInPeekEditor = PeekContext.inPeekEditor.toNegated();
  106433. })(PeekContext = exports.PeekContext || (exports.PeekContext = {}));
  106434. var PeekContextController = /** @class */ (function () {
  106435. function PeekContextController(editor, contextKeyService) {
  106436. if (editor instanceof embeddedCodeEditorWidget_1.EmbeddedCodeEditorWidget) {
  106437. PeekContext.inPeekEditor.bindTo(contextKeyService);
  106438. }
  106439. }
  106440. PeekContextController.prototype.dispose = function () { };
  106441. PeekContextController.ID = 'editor.contrib.referenceController';
  106442. PeekContextController = __decorate([
  106443. __param(1, contextkey_1.IContextKeyService)
  106444. ], PeekContextController);
  106445. return PeekContextController;
  106446. }());
  106447. editorExtensions_1.registerEditorContribution(PeekContextController.ID, PeekContextController);
  106448. function getOuterEditor(accessor) {
  106449. var editor = accessor.get(codeEditorService_1.ICodeEditorService).getFocusedCodeEditor();
  106450. if (editor instanceof embeddedCodeEditorWidget_1.EmbeddedCodeEditorWidget) {
  106451. return editor.getParentEditor();
  106452. }
  106453. return editor;
  106454. }
  106455. exports.getOuterEditor = getOuterEditor;
  106456. var defaultOptions = {
  106457. headerBackgroundColor: color_1.Color.white,
  106458. primaryHeadingColor: color_1.Color.fromHex('#333333'),
  106459. secondaryHeadingColor: color_1.Color.fromHex('#6c6c6cb3')
  106460. };
  106461. var PeekViewWidget = /** @class */ (function (_super) {
  106462. __extends(PeekViewWidget, _super);
  106463. function PeekViewWidget(editor, options) {
  106464. if (options === void 0) { options = {}; }
  106465. var _this = _super.call(this, editor, options) || this;
  106466. _this._onDidClose = new event_1.Emitter();
  106467. _this.onDidClose = _this._onDidClose.event;
  106468. objects.mixin(_this.options, defaultOptions, false);
  106469. return _this;
  106470. }
  106471. PeekViewWidget.prototype.dispose = function () {
  106472. _super.prototype.dispose.call(this);
  106473. this._onDidClose.fire(this);
  106474. };
  106475. PeekViewWidget.prototype.style = function (styles) {
  106476. var options = this.options;
  106477. if (styles.headerBackgroundColor) {
  106478. options.headerBackgroundColor = styles.headerBackgroundColor;
  106479. }
  106480. if (styles.primaryHeadingColor) {
  106481. options.primaryHeadingColor = styles.primaryHeadingColor;
  106482. }
  106483. if (styles.secondaryHeadingColor) {
  106484. options.secondaryHeadingColor = styles.secondaryHeadingColor;
  106485. }
  106486. _super.prototype.style.call(this, styles);
  106487. };
  106488. PeekViewWidget.prototype._applyStyles = function () {
  106489. _super.prototype._applyStyles.call(this);
  106490. var options = this.options;
  106491. if (this._headElement && options.headerBackgroundColor) {
  106492. this._headElement.style.backgroundColor = options.headerBackgroundColor.toString();
  106493. }
  106494. if (this._primaryHeading && options.primaryHeadingColor) {
  106495. this._primaryHeading.style.color = options.primaryHeadingColor.toString();
  106496. }
  106497. if (this._secondaryHeading && options.secondaryHeadingColor) {
  106498. this._secondaryHeading.style.color = options.secondaryHeadingColor.toString();
  106499. }
  106500. if (this._bodyElement && options.frameColor) {
  106501. this._bodyElement.style.borderColor = options.frameColor.toString();
  106502. }
  106503. };
  106504. PeekViewWidget.prototype._fillContainer = function (container) {
  106505. this.setCssClass('peekview-widget');
  106506. this._headElement = dom.$('.head');
  106507. this._bodyElement = dom.$('.body');
  106508. this._fillHead(this._headElement);
  106509. this._fillBody(this._bodyElement);
  106510. container.appendChild(this._headElement);
  106511. container.appendChild(this._bodyElement);
  106512. };
  106513. PeekViewWidget.prototype._fillHead = function (container) {
  106514. var _this = this;
  106515. var titleElement = dom.$('.peekview-title');
  106516. dom.append(this._headElement, titleElement);
  106517. dom.addStandardDisposableListener(titleElement, 'click', function (event) { return _this._onTitleClick(event); });
  106518. this._fillTitleIcon(titleElement);
  106519. this._primaryHeading = dom.$('span.filename');
  106520. this._secondaryHeading = dom.$('span.dirname');
  106521. this._metaHeading = dom.$('span.meta');
  106522. dom.append(titleElement, this._primaryHeading, this._secondaryHeading, this._metaHeading);
  106523. var actionsContainer = dom.$('.peekview-actions');
  106524. dom.append(this._headElement, actionsContainer);
  106525. var actionBarOptions = this._getActionBarOptions();
  106526. this._actionbarWidget = new actionbar_1.ActionBar(actionsContainer, actionBarOptions);
  106527. this._disposables.add(this._actionbarWidget);
  106528. this._actionbarWidget.push(new actions_1.Action('peekview.close', nls.localize(0, null), 'codicon-close', true, function () {
  106529. _this.dispose();
  106530. return Promise.resolve();
  106531. }), { label: false, icon: true });
  106532. };
  106533. PeekViewWidget.prototype._fillTitleIcon = function (container) {
  106534. };
  106535. PeekViewWidget.prototype._getActionBarOptions = function () {
  106536. return {};
  106537. };
  106538. PeekViewWidget.prototype._onTitleClick = function (event) {
  106539. // implement me
  106540. };
  106541. PeekViewWidget.prototype.setTitle = function (primaryHeading, secondaryHeading) {
  106542. if (this._primaryHeading && this._secondaryHeading) {
  106543. this._primaryHeading.innerHTML = strings.escape(primaryHeading);
  106544. this._primaryHeading.setAttribute('aria-label', primaryHeading);
  106545. if (secondaryHeading) {
  106546. this._secondaryHeading.innerHTML = strings.escape(secondaryHeading);
  106547. }
  106548. else {
  106549. dom.clearNode(this._secondaryHeading);
  106550. }
  106551. }
  106552. };
  106553. PeekViewWidget.prototype.setMetaTitle = function (value) {
  106554. if (this._metaHeading) {
  106555. if (value) {
  106556. this._metaHeading.innerHTML = strings.escape(value);
  106557. dom.show(this._metaHeading);
  106558. }
  106559. else {
  106560. dom.hide(this._metaHeading);
  106561. }
  106562. }
  106563. };
  106564. PeekViewWidget.prototype._doLayout = function (heightInPixel, widthInPixel) {
  106565. if (!this._isShowing && heightInPixel < 0) {
  106566. // Looks like the view zone got folded away!
  106567. this.dispose();
  106568. return;
  106569. }
  106570. var headHeight = Math.ceil(this.editor.getOption(49 /* lineHeight */) * 1.2);
  106571. var bodyHeight = Math.round(heightInPixel - (headHeight + 2 /* the border-top/bottom width*/));
  106572. this._doLayoutHead(headHeight, widthInPixel);
  106573. this._doLayoutBody(bodyHeight, widthInPixel);
  106574. };
  106575. PeekViewWidget.prototype._doLayoutHead = function (heightInPixel, widthInPixel) {
  106576. if (this._headElement) {
  106577. this._headElement.style.height = heightInPixel + "px";
  106578. this._headElement.style.lineHeight = this._headElement.style.height;
  106579. }
  106580. };
  106581. PeekViewWidget.prototype._doLayoutBody = function (heightInPixel, widthInPixel) {
  106582. if (this._bodyElement) {
  106583. this._bodyElement.style.height = heightInPixel + "px";
  106584. }
  106585. };
  106586. return PeekViewWidget;
  106587. }(zoneWidget_1.ZoneWidget));
  106588. exports.PeekViewWidget = PeekViewWidget;
  106589. exports.peekViewTitleBackground = colorRegistry_1.registerColor('peekViewTitle.background', { dark: '#1E1E1E', light: '#FFFFFF', hc: '#0C141F' }, nls.localize(1, null));
  106590. exports.peekViewTitleForeground = colorRegistry_1.registerColor('peekViewTitleLabel.foreground', { dark: '#FFFFFF', light: '#333333', hc: '#FFFFFF' }, nls.localize(2, null));
  106591. exports.peekViewTitleInfoForeground = colorRegistry_1.registerColor('peekViewTitleDescription.foreground', { dark: '#ccccccb3', light: '#616161e6', hc: '#FFFFFF99' }, nls.localize(3, null));
  106592. exports.peekViewBorder = colorRegistry_1.registerColor('peekView.border', { dark: '#007acc', light: '#007acc', hc: colorRegistry_1.contrastBorder }, nls.localize(4, null));
  106593. exports.peekViewResultsBackground = colorRegistry_1.registerColor('peekViewResult.background', { dark: '#252526', light: '#F3F3F3', hc: color_1.Color.black }, nls.localize(5, null));
  106594. exports.peekViewResultsMatchForeground = colorRegistry_1.registerColor('peekViewResult.lineForeground', { dark: '#bbbbbb', light: '#646465', hc: color_1.Color.white }, nls.localize(6, null));
  106595. exports.peekViewResultsFileForeground = colorRegistry_1.registerColor('peekViewResult.fileForeground', { dark: color_1.Color.white, light: '#1E1E1E', hc: color_1.Color.white }, nls.localize(7, null));
  106596. exports.peekViewResultsSelectionBackground = colorRegistry_1.registerColor('peekViewResult.selectionBackground', { dark: '#3399ff33', light: '#3399ff33', hc: null }, nls.localize(8, null));
  106597. exports.peekViewResultsSelectionForeground = colorRegistry_1.registerColor('peekViewResult.selectionForeground', { dark: color_1.Color.white, light: '#6C6C6C', hc: color_1.Color.white }, nls.localize(9, null));
  106598. exports.peekViewEditorBackground = colorRegistry_1.registerColor('peekViewEditor.background', { dark: '#001F33', light: '#F2F8FC', hc: color_1.Color.black }, nls.localize(10, null));
  106599. exports.peekViewEditorGutterBackground = colorRegistry_1.registerColor('peekViewEditorGutter.background', { dark: exports.peekViewEditorBackground, light: exports.peekViewEditorBackground, hc: exports.peekViewEditorBackground }, nls.localize(11, null));
  106600. exports.peekViewResultsMatchHighlight = colorRegistry_1.registerColor('peekViewResult.matchHighlightBackground', { dark: '#ea5c004d', light: '#ea5c004d', hc: null }, nls.localize(12, null));
  106601. exports.peekViewEditorMatchHighlight = colorRegistry_1.registerColor('peekViewEditor.matchHighlightBackground', { dark: '#ff8f0099', light: '#f5d802de', hc: null }, nls.localize(13, null));
  106602. exports.peekViewEditorMatchHighlightBorder = colorRegistry_1.registerColor('peekViewEditor.matchHighlightBorder', { dark: null, light: null, hc: colorRegistry_1.activeContrastBorder }, nls.localize(14, null));
  106603. });
  106604. /*---------------------------------------------------------------------------------------------
  106605. * Copyright (c) Microsoft Corporation. All rights reserved.
  106606. * Licensed under the MIT License. See License.txt in the project root for license information.
  106607. *--------------------------------------------------------------------------------------------*/
  106608. define(__m[583/*vs/editor/contrib/rename/renameInputField*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,464/*vs/nls!vs/editor/contrib/rename/renameInputField*/,18/*vs/platform/contextkey/common/contextkey*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,34/*vs/platform/keybinding/common/keybinding*/,6/*vs/base/browser/dom*/,320/*vs/css!vs/editor/contrib/rename/renameInputField*/]), function (require, exports, lifecycle_1, position_1, range_1, nls_1, contextkey_1, colorRegistry_1, themeService_1, keybinding_1, dom_1) {
  106609. "use strict";
  106610. Object.defineProperty(exports, "__esModule", { value: true });
  106611. exports.CONTEXT_RENAME_INPUT_VISIBLE = new contextkey_1.RawContextKey('renameInputVisible', false);
  106612. var RenameInputField = /** @class */ (function () {
  106613. function RenameInputField(_editor, _acceptKeybindings, _themeService, _keybindingService, contextKeyService) {
  106614. var _this = this;
  106615. this._editor = _editor;
  106616. this._acceptKeybindings = _acceptKeybindings;
  106617. this._themeService = _themeService;
  106618. this._keybindingService = _keybindingService;
  106619. this._disposables = new lifecycle_1.DisposableStore();
  106620. this.allowEditorOverflow = true;
  106621. this._visibleContextKey = exports.CONTEXT_RENAME_INPUT_VISIBLE.bindTo(contextKeyService);
  106622. this._editor.addContentWidget(this);
  106623. this._disposables.add(this._editor.onDidChangeConfiguration(function (e) {
  106624. if (e.hasChanged(34 /* fontInfo */)) {
  106625. _this._updateFont();
  106626. }
  106627. }));
  106628. this._disposables.add(_themeService.onThemeChange(this._updateStyles, this));
  106629. }
  106630. RenameInputField.prototype.dispose = function () {
  106631. this._disposables.dispose();
  106632. this._editor.removeContentWidget(this);
  106633. };
  106634. RenameInputField.prototype.getId = function () {
  106635. return '__renameInputWidget';
  106636. };
  106637. RenameInputField.prototype.getDomNode = function () {
  106638. var _this = this;
  106639. if (!this._domNode) {
  106640. this._domNode = document.createElement('div');
  106641. this._domNode.className = 'monaco-editor rename-box';
  106642. this._input = document.createElement('input');
  106643. this._input.className = 'rename-input';
  106644. this._input.type = 'text';
  106645. this._input.setAttribute('aria-label', nls_1.localize(0, null));
  106646. this._domNode.appendChild(this._input);
  106647. this._label = document.createElement('div');
  106648. this._label.className = 'rename-label';
  106649. this._domNode.appendChild(this._label);
  106650. var updateLabel = function () {
  106651. var _a, _b;
  106652. var _c = _this._acceptKeybindings, accept = _c[0], preview = _c[1];
  106653. _this._keybindingService.lookupKeybinding(accept);
  106654. _this._label.innerText = nls_1.localize(1, null, (_a = _this._keybindingService.lookupKeybinding(accept)) === null || _a === void 0 ? void 0 : _a.getLabel(), (_b = _this._keybindingService.lookupKeybinding(preview)) === null || _b === void 0 ? void 0 : _b.getLabel());
  106655. };
  106656. updateLabel();
  106657. this._disposables.add(this._keybindingService.onDidUpdateKeybindings(updateLabel));
  106658. this._updateFont();
  106659. this._updateStyles(this._themeService.getTheme());
  106660. }
  106661. return this._domNode;
  106662. };
  106663. RenameInputField.prototype._updateStyles = function (theme) {
  106664. var _a, _b, _c, _d;
  106665. if (!this._input || !this._domNode) {
  106666. return;
  106667. }
  106668. var widgetShadowColor = theme.getColor(colorRegistry_1.widgetShadow);
  106669. this._domNode.style.backgroundColor = String((_a = theme.getColor(colorRegistry_1.editorWidgetBackground)) !== null && _a !== void 0 ? _a : '');
  106670. this._domNode.style.boxShadow = widgetShadowColor ? " 0 2px 8px " + widgetShadowColor : '';
  106671. this._domNode.style.color = String((_b = theme.getColor(colorRegistry_1.inputForeground)) !== null && _b !== void 0 ? _b : '');
  106672. this._input.style.backgroundColor = String((_c = theme.getColor(colorRegistry_1.inputBackground)) !== null && _c !== void 0 ? _c : '');
  106673. // this._input.style.color = String(theme.getColor(inputForeground) ?? '');
  106674. var border = theme.getColor(colorRegistry_1.inputBorder);
  106675. this._input.style.borderWidth = border ? '1px' : '0px';
  106676. this._input.style.borderStyle = border ? 'solid' : 'none';
  106677. this._input.style.borderColor = (_d = border === null || border === void 0 ? void 0 : border.toString()) !== null && _d !== void 0 ? _d : 'none';
  106678. };
  106679. RenameInputField.prototype._updateFont = function () {
  106680. if (!this._input || !this._label) {
  106681. return;
  106682. }
  106683. var fontInfo = this._editor.getOption(34 /* fontInfo */);
  106684. this._input.style.fontFamily = fontInfo.fontFamily;
  106685. this._input.style.fontWeight = fontInfo.fontWeight;
  106686. this._input.style.fontSize = fontInfo.fontSize + "px";
  106687. this._label.style.fontSize = fontInfo.fontSize * 0.8 + "px";
  106688. };
  106689. RenameInputField.prototype.getPosition = function () {
  106690. if (!this._visible) {
  106691. return null;
  106692. }
  106693. return {
  106694. position: this._position,
  106695. preference: [2 /* BELOW */, 1 /* ABOVE */]
  106696. };
  106697. };
  106698. RenameInputField.prototype.acceptInput = function (wantsPreview) {
  106699. if (this._currentAcceptInput) {
  106700. this._currentAcceptInput(wantsPreview);
  106701. }
  106702. };
  106703. RenameInputField.prototype.cancelInput = function (focusEditor) {
  106704. if (this._currentCancelInput) {
  106705. this._currentCancelInput(focusEditor);
  106706. }
  106707. };
  106708. RenameInputField.prototype.getInput = function (where, value, selectionStart, selectionEnd, supportPreview) {
  106709. var _this = this;
  106710. dom_1.toggleClass(this._domNode, 'preview', supportPreview);
  106711. this._position = new position_1.Position(where.startLineNumber, where.startColumn);
  106712. this._input.value = value;
  106713. this._input.setAttribute('selectionStart', selectionStart.toString());
  106714. this._input.setAttribute('selectionEnd', selectionEnd.toString());
  106715. this._input.size = Math.max((where.endColumn - where.startColumn) * 1.1, 20);
  106716. var disposeOnDone = new lifecycle_1.DisposableStore();
  106717. return new Promise(function (resolve) {
  106718. _this._currentCancelInput = function (focusEditor) {
  106719. _this._currentAcceptInput = undefined;
  106720. _this._currentCancelInput = undefined;
  106721. resolve(focusEditor);
  106722. return true;
  106723. };
  106724. _this._currentAcceptInput = function (wantsPreview) {
  106725. if (_this._input.value.trim().length === 0 || _this._input.value === value) {
  106726. // empty or whitespace only or not changed
  106727. _this.cancelInput(true);
  106728. return;
  106729. }
  106730. _this._currentAcceptInput = undefined;
  106731. _this._currentCancelInput = undefined;
  106732. resolve({
  106733. newName: _this._input.value,
  106734. wantsPreview: supportPreview && wantsPreview
  106735. });
  106736. };
  106737. var onCursorChanged = function () {
  106738. var editorPosition = _this._editor.getPosition();
  106739. if (!editorPosition || !range_1.Range.containsPosition(where, editorPosition)) {
  106740. _this.cancelInput(true);
  106741. }
  106742. };
  106743. disposeOnDone.add(_this._editor.onDidChangeCursorSelection(onCursorChanged));
  106744. disposeOnDone.add(_this._editor.onDidBlurEditorWidget(function () { return _this.cancelInput(false); }));
  106745. _this._show();
  106746. }).finally(function () {
  106747. disposeOnDone.dispose();
  106748. _this._hide();
  106749. });
  106750. };
  106751. RenameInputField.prototype._show = function () {
  106752. var _this = this;
  106753. this._editor.revealLineInCenterIfOutsideViewport(this._position.lineNumber, 0 /* Smooth */);
  106754. this._visible = true;
  106755. this._visibleContextKey.set(true);
  106756. this._editor.layoutContentWidget(this);
  106757. setTimeout(function () {
  106758. _this._input.focus();
  106759. _this._input.setSelectionRange(parseInt(_this._input.getAttribute('selectionStart')), parseInt(_this._input.getAttribute('selectionEnd')));
  106760. }, 100);
  106761. };
  106762. RenameInputField.prototype._hide = function () {
  106763. this._visible = false;
  106764. this._visibleContextKey.reset();
  106765. this._editor.layoutContentWidget(this);
  106766. };
  106767. RenameInputField = __decorate([
  106768. __param(2, themeService_1.IThemeService),
  106769. __param(3, keybinding_1.IKeybindingService),
  106770. __param(4, contextkey_1.IContextKeyService)
  106771. ], RenameInputField);
  106772. return RenameInputField;
  106773. }());
  106774. exports.RenameInputField = RenameInputField;
  106775. });
  106776. /*---------------------------------------------------------------------------------------------
  106777. * Copyright (c) Microsoft Corporation. All rights reserved.
  106778. * Licensed under the MIT License. See License.txt in the project root for license information.
  106779. *--------------------------------------------------------------------------------------------*/
  106780. define(__m[584/*vs/editor/contrib/rename/rename*/], __M([0/*require*/,1/*exports*/,463/*vs/nls!vs/editor/contrib/rename/rename*/,10/*vs/base/common/errors*/,18/*vs/platform/contextkey/common/contextkey*/,73/*vs/platform/progress/common/progress*/,12/*vs/editor/browser/editorExtensions*/,23/*vs/editor/common/editorContextKeys*/,583/*vs/editor/contrib/rename/renameInputField*/,17/*vs/editor/common/modes*/,13/*vs/editor/common/core/position*/,50/*vs/base/browser/ui/aria/aria*/,3/*vs/editor/common/core/range*/,122/*vs/editor/contrib/message/messageController*/,67/*vs/editor/browser/core/editorState*/,35/*vs/platform/notification/common/notification*/,156/*vs/editor/browser/services/bulkEditService*/,25/*vs/base/common/uri*/,32/*vs/editor/browser/services/codeEditorService*/,26/*vs/base/common/cancellation*/,2/*vs/base/common/lifecycle*/,15/*vs/base/common/async*/,21/*vs/base/common/types*/,95/*vs/platform/log/common/log*/,11/*vs/platform/instantiation/common/instantiation*/,42/*vs/platform/registry/common/platform*/,85/*vs/platform/configuration/common/configurationRegistry*/,114/*vs/editor/common/services/textResourceConfigurationService*/]), function (require, exports, nls, errors_1, contextkey_1, progress_1, editorExtensions_1, editorContextKeys_1, renameInputField_1, modes_1, position_1, aria_1, range_1, messageController_1, editorState_1, notification_1, bulkEditService_1, uri_1, codeEditorService_1, cancellation_1, lifecycle_1, async_1, types_1, log_1, instantiation_1, platform_1, configurationRegistry_1, textResourceConfigurationService_1) {
  106781. "use strict";
  106782. Object.defineProperty(exports, "__esModule", { value: true });
  106783. var RenameSkeleton = /** @class */ (function () {
  106784. function RenameSkeleton(model, position) {
  106785. this.model = model;
  106786. this.position = position;
  106787. this._providers = modes_1.RenameProviderRegistry.ordered(model);
  106788. }
  106789. RenameSkeleton.prototype.hasProvider = function () {
  106790. return this._providers.length > 0;
  106791. };
  106792. RenameSkeleton.prototype.resolveRenameLocation = function (token) {
  106793. return __awaiter(this, void 0, void 0, function () {
  106794. var firstProvider, res, _a, word;
  106795. return __generator(this, function (_b) {
  106796. switch (_b.label) {
  106797. case 0:
  106798. firstProvider = this._providers[0];
  106799. if (!firstProvider) {
  106800. return [2 /*return*/, undefined];
  106801. }
  106802. if (!firstProvider.resolveRenameLocation) return [3 /*break*/, 2];
  106803. _a = types_1.withNullAsUndefined;
  106804. return [4 /*yield*/, firstProvider.resolveRenameLocation(this.model, this.position, token)];
  106805. case 1:
  106806. res = _a.apply(void 0, [_b.sent()]);
  106807. _b.label = 2;
  106808. case 2:
  106809. if (!res) {
  106810. word = this.model.getWordAtPosition(this.position);
  106811. if (word) {
  106812. return [2 /*return*/, {
  106813. range: new range_1.Range(this.position.lineNumber, word.startColumn, this.position.lineNumber, word.endColumn),
  106814. text: word.word
  106815. }];
  106816. }
  106817. }
  106818. return [2 /*return*/, res];
  106819. }
  106820. });
  106821. });
  106822. };
  106823. RenameSkeleton.prototype.provideRenameEdits = function (newName, i, rejects, token) {
  106824. return __awaiter(this, void 0, void 0, function () {
  106825. var provider, result;
  106826. return __generator(this, function (_a) {
  106827. switch (_a.label) {
  106828. case 0:
  106829. provider = this._providers[i];
  106830. if (!provider) {
  106831. return [2 /*return*/, {
  106832. edits: [],
  106833. rejectReason: rejects.join('\n')
  106834. }];
  106835. }
  106836. return [4 /*yield*/, provider.provideRenameEdits(this.model, this.position, newName, token)];
  106837. case 1:
  106838. result = _a.sent();
  106839. if (!result) {
  106840. return [2 /*return*/, this.provideRenameEdits(newName, i + 1, rejects.concat(nls.localize(0, null)), token)];
  106841. }
  106842. else if (result.rejectReason) {
  106843. return [2 /*return*/, this.provideRenameEdits(newName, i + 1, rejects.concat(result.rejectReason), token)];
  106844. }
  106845. return [2 /*return*/, result];
  106846. }
  106847. });
  106848. });
  106849. };
  106850. return RenameSkeleton;
  106851. }());
  106852. function rename(model, position, newName) {
  106853. return __awaiter(this, void 0, void 0, function () {
  106854. return __generator(this, function (_a) {
  106855. return [2 /*return*/, new RenameSkeleton(model, position).provideRenameEdits(newName, 0, [], cancellation_1.CancellationToken.None)];
  106856. });
  106857. });
  106858. }
  106859. exports.rename = rename;
  106860. // --- register actions and commands
  106861. var RenameController = /** @class */ (function () {
  106862. function RenameController(editor, _instaService, _notificationService, _bulkEditService, _progressService, _logService, _configService) {
  106863. var _this = this;
  106864. this.editor = editor;
  106865. this._instaService = _instaService;
  106866. this._notificationService = _notificationService;
  106867. this._bulkEditService = _bulkEditService;
  106868. this._progressService = _progressService;
  106869. this._logService = _logService;
  106870. this._configService = _configService;
  106871. this._dispoableStore = new lifecycle_1.DisposableStore();
  106872. this._cts = new cancellation_1.CancellationTokenSource();
  106873. this._renameInputField = this._dispoableStore.add(new async_1.IdleValue(function () { return _this._dispoableStore.add(_this._instaService.createInstance(renameInputField_1.RenameInputField, _this.editor, ['acceptRenameInput', 'acceptRenameInputWithPreview'])); }));
  106874. }
  106875. RenameController.get = function (editor) {
  106876. return editor.getContribution(RenameController.ID);
  106877. };
  106878. RenameController.prototype.dispose = function () {
  106879. this._dispoableStore.dispose();
  106880. this._cts.dispose(true);
  106881. };
  106882. RenameController.prototype.run = function () {
  106883. return __awaiter(this, void 0, void 0, function () {
  106884. var position, skeleton, loc, resolveLocationOperation, e_1, selection, selectionStart, selectionEnd, supportPreview, inputFieldResult, renameOperation;
  106885. var _this = this;
  106886. return __generator(this, function (_a) {
  106887. switch (_a.label) {
  106888. case 0:
  106889. this._cts.dispose(true);
  106890. if (!this.editor.hasModel()) {
  106891. return [2 /*return*/, undefined];
  106892. }
  106893. position = this.editor.getPosition();
  106894. skeleton = new RenameSkeleton(this.editor.getModel(), position);
  106895. if (!skeleton.hasProvider()) {
  106896. return [2 /*return*/, undefined];
  106897. }
  106898. this._cts = new editorState_1.EditorStateCancellationTokenSource(this.editor, 4 /* Position */ | 1 /* Value */);
  106899. _a.label = 1;
  106900. case 1:
  106901. _a.trys.push([1, 3, , 4]);
  106902. resolveLocationOperation = skeleton.resolveRenameLocation(this._cts.token);
  106903. this._progressService.showWhile(resolveLocationOperation, 250);
  106904. return [4 /*yield*/, resolveLocationOperation];
  106905. case 2:
  106906. loc = _a.sent();
  106907. return [3 /*break*/, 4];
  106908. case 3:
  106909. e_1 = _a.sent();
  106910. messageController_1.MessageController.get(this.editor).showMessage(e_1 || nls.localize(1, null), position);
  106911. return [2 /*return*/, undefined];
  106912. case 4:
  106913. if (!loc) {
  106914. return [2 /*return*/, undefined];
  106915. }
  106916. if (loc.rejectReason) {
  106917. messageController_1.MessageController.get(this.editor).showMessage(loc.rejectReason, position);
  106918. return [2 /*return*/, undefined];
  106919. }
  106920. if (this._cts.token.isCancellationRequested) {
  106921. return [2 /*return*/, undefined];
  106922. }
  106923. selection = this.editor.getSelection();
  106924. selectionStart = 0;
  106925. selectionEnd = loc.text.length;
  106926. if (!range_1.Range.isEmpty(selection) && !range_1.Range.spansMultipleLines(selection) && range_1.Range.containsRange(loc.range, selection)) {
  106927. selectionStart = Math.max(0, selection.startColumn - loc.range.startColumn);
  106928. selectionEnd = Math.min(loc.range.endColumn, selection.endColumn) - loc.range.startColumn;
  106929. }
  106930. supportPreview = this._bulkEditService.hasPreviewHandler() && this._configService.getValue(this.editor.getModel().uri, 'editor.rename.enablePreview');
  106931. return [4 /*yield*/, this._renameInputField.getValue().getInput(loc.range, loc.text, selectionStart, selectionEnd, supportPreview)];
  106932. case 5:
  106933. inputFieldResult = _a.sent();
  106934. // no result, only hint to focus the editor or not
  106935. if (typeof inputFieldResult === 'boolean') {
  106936. if (inputFieldResult) {
  106937. this.editor.focus();
  106938. }
  106939. return [2 /*return*/, undefined];
  106940. }
  106941. this.editor.focus();
  106942. renameOperation = async_1.raceCancellation(skeleton.provideRenameEdits(inputFieldResult.newName, 0, [], this._cts.token), this._cts.token).then(function (renameResult) { return __awaiter(_this, void 0, void 0, function () {
  106943. var _this = this;
  106944. return __generator(this, function (_a) {
  106945. if (!renameResult || !this.editor.hasModel()) {
  106946. return [2 /*return*/];
  106947. }
  106948. if (renameResult.rejectReason) {
  106949. this._notificationService.info(renameResult.rejectReason);
  106950. return [2 /*return*/];
  106951. }
  106952. this._bulkEditService.apply(renameResult, {
  106953. editor: this.editor,
  106954. showPreview: inputFieldResult.wantsPreview,
  106955. label: nls.localize(2, null, loc === null || loc === void 0 ? void 0 : loc.text)
  106956. }).then(function (result) {
  106957. if (result.ariaSummary) {
  106958. aria_1.alert(nls.localize(3, null, loc.text, inputFieldResult.newName, result.ariaSummary));
  106959. }
  106960. }).catch(function (err) {
  106961. _this._notificationService.error(nls.localize(4, null));
  106962. _this._logService.error(err);
  106963. });
  106964. return [2 /*return*/];
  106965. });
  106966. }); }, function (err) {
  106967. _this._notificationService.error(nls.localize(5, null));
  106968. _this._logService.error(err);
  106969. });
  106970. this._progressService.showWhile(renameOperation, 250);
  106971. return [2 /*return*/, renameOperation];
  106972. }
  106973. });
  106974. });
  106975. };
  106976. RenameController.prototype.acceptRenameInput = function (wantsPreview) {
  106977. this._renameInputField.getValue().acceptInput(wantsPreview);
  106978. };
  106979. RenameController.prototype.cancelRenameInput = function () {
  106980. this._renameInputField.getValue().cancelInput(true);
  106981. };
  106982. RenameController.ID = 'editor.contrib.renameController';
  106983. RenameController = __decorate([
  106984. __param(1, instantiation_1.IInstantiationService),
  106985. __param(2, notification_1.INotificationService),
  106986. __param(3, bulkEditService_1.IBulkEditService),
  106987. __param(4, progress_1.IEditorProgressService),
  106988. __param(5, log_1.ILogService),
  106989. __param(6, textResourceConfigurationService_1.ITextResourceConfigurationService)
  106990. ], RenameController);
  106991. return RenameController;
  106992. }());
  106993. // ---- action implementation
  106994. var RenameAction = /** @class */ (function (_super) {
  106995. __extends(RenameAction, _super);
  106996. function RenameAction() {
  106997. return _super.call(this, {
  106998. id: 'editor.action.rename',
  106999. label: nls.localize(6, null),
  107000. alias: 'Rename Symbol',
  107001. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, editorContextKeys_1.EditorContextKeys.hasRenameProvider),
  107002. kbOpts: {
  107003. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  107004. primary: 60 /* F2 */,
  107005. weight: 100 /* EditorContrib */
  107006. },
  107007. contextMenuOpts: {
  107008. group: '1_modification',
  107009. order: 1.1
  107010. }
  107011. }) || this;
  107012. }
  107013. RenameAction.prototype.runCommand = function (accessor, args) {
  107014. var _this = this;
  107015. var editorService = accessor.get(codeEditorService_1.ICodeEditorService);
  107016. var _a = Array.isArray(args) && args || [undefined, undefined], uri = _a[0], pos = _a[1];
  107017. if (uri_1.URI.isUri(uri) && position_1.Position.isIPosition(pos)) {
  107018. return editorService.openCodeEditor({ resource: uri }, editorService.getActiveCodeEditor()).then(function (editor) {
  107019. if (!editor) {
  107020. return;
  107021. }
  107022. editor.setPosition(pos);
  107023. editor.invokeWithinContext(function (accessor) {
  107024. _this.reportTelemetry(accessor, editor);
  107025. return _this.run(accessor, editor);
  107026. });
  107027. }, errors_1.onUnexpectedError);
  107028. }
  107029. return _super.prototype.runCommand.call(this, accessor, args);
  107030. };
  107031. RenameAction.prototype.run = function (accessor, editor) {
  107032. var controller = RenameController.get(editor);
  107033. if (controller) {
  107034. return controller.run();
  107035. }
  107036. return Promise.resolve();
  107037. };
  107038. return RenameAction;
  107039. }(editorExtensions_1.EditorAction));
  107040. exports.RenameAction = RenameAction;
  107041. editorExtensions_1.registerEditorContribution(RenameController.ID, RenameController);
  107042. editorExtensions_1.registerEditorAction(RenameAction);
  107043. var RenameCommand = editorExtensions_1.EditorCommand.bindToContribution(RenameController.get);
  107044. editorExtensions_1.registerEditorCommand(new RenameCommand({
  107045. id: 'acceptRenameInput',
  107046. precondition: renameInputField_1.CONTEXT_RENAME_INPUT_VISIBLE,
  107047. handler: function (x) { return x.acceptRenameInput(false); },
  107048. kbOpts: {
  107049. weight: 100 /* EditorContrib */ + 99,
  107050. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  107051. primary: 3 /* Enter */
  107052. }
  107053. }));
  107054. editorExtensions_1.registerEditorCommand(new RenameCommand({
  107055. id: 'acceptRenameInputWithPreview',
  107056. precondition: contextkey_1.ContextKeyExpr.and(renameInputField_1.CONTEXT_RENAME_INPUT_VISIBLE, contextkey_1.ContextKeyExpr.has('config.editor.rename.enablePreview')),
  107057. handler: function (x) { return x.acceptRenameInput(true); },
  107058. kbOpts: {
  107059. weight: 100 /* EditorContrib */ + 99,
  107060. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  107061. primary: 1024 /* Shift */ + 3 /* Enter */
  107062. }
  107063. }));
  107064. editorExtensions_1.registerEditorCommand(new RenameCommand({
  107065. id: 'cancelRenameInput',
  107066. precondition: renameInputField_1.CONTEXT_RENAME_INPUT_VISIBLE,
  107067. handler: function (x) { return x.cancelRenameInput(); },
  107068. kbOpts: {
  107069. weight: 100 /* EditorContrib */ + 99,
  107070. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  107071. primary: 9 /* Escape */,
  107072. secondary: [1024 /* Shift */ | 9 /* Escape */]
  107073. }
  107074. }));
  107075. // ---- api bridge command
  107076. editorExtensions_1.registerDefaultLanguageCommand('_executeDocumentRenameProvider', function (model, position, args) {
  107077. var newName = args.newName;
  107078. if (typeof newName !== 'string') {
  107079. throw errors_1.illegalArgument('newName');
  107080. }
  107081. return rename(model, position, newName);
  107082. });
  107083. //todo@joh use editor options world
  107084. platform_1.Registry.as(configurationRegistry_1.Extensions.Configuration).registerConfiguration({
  107085. id: 'editor',
  107086. properties: {
  107087. 'editor.rename.enablePreview': {
  107088. scope: 5 /* LANGUAGE_OVERRIDABLE */,
  107089. description: nls.localize(7, null),
  107090. default: true,
  107091. type: 'boolean'
  107092. }
  107093. }
  107094. });
  107095. });
  107096. /*---------------------------------------------------------------------------------------------
  107097. * Copyright (c) Microsoft Corporation. All rights reserved.
  107098. * Licensed under the MIT License. See License.txt in the project root for license information.
  107099. *--------------------------------------------------------------------------------------------*/
  107100. define(__m[585/*vs/editor/contrib/suggest/suggestWidget*/], __M([0/*require*/,1/*exports*/,468/*vs/nls!vs/editor/contrib/suggest/suggestWidget*/,61/*vs/base/common/filters*/,5/*vs/base/common/strings*/,4/*vs/base/common/event*/,10/*vs/base/common/errors*/,2/*vs/base/common/lifecycle*/,6/*vs/base/browser/dom*/,153/*vs/base/browser/ui/list/listWidget*/,53/*vs/base/browser/ui/scrollbar/scrollableElement*/,34/*vs/platform/keybinding/common/keybinding*/,18/*vs/platform/contextkey/common/contextkey*/,120/*vs/editor/contrib/suggest/suggest*/,96/*vs/platform/telemetry/common/telemetry*/,97/*vs/platform/theme/common/styler*/,14/*vs/platform/theme/common/themeService*/,20/*vs/platform/theme/common/colorRegistry*/,74/*vs/platform/storage/common/storage*/,117/*vs/editor/contrib/markdown/markdownRenderer*/,71/*vs/editor/common/services/modeService*/,51/*vs/platform/opener/common/opener*/,15/*vs/base/common/async*/,17/*vs/editor/common/modes*/,139/*vs/base/browser/ui/iconLabel/iconLabel*/,511/*vs/editor/common/services/getIconClasses*/,49/*vs/editor/common/services/modelService*/,25/*vs/base/common/uri*/,11/*vs/platform/instantiation/common/instantiation*/,208/*vs/platform/files/common/files*/,75/*vs/base/common/htmlContent*/,19/*vs/base/common/arrays*/,13/*vs/editor/common/core/position*/,322/*vs/css!vs/editor/contrib/suggest/media/suggest*/,323/*vs/css!vs/editor/contrib/suggest/media/suggestStatusBar*/,183/*vs/base/browser/ui/codiconLabel/codiconLabel*/,231/*vs/editor/contrib/documentSymbols/outlineTree*/]), function (require, exports, nls, filters_1, strings, event_1, errors_1, lifecycle_1, dom_1, listWidget_1, scrollableElement_1, keybinding_1, contextkey_1, suggest_1, telemetry_1, styler_1, themeService_1, colorRegistry_1, storage_1, markdownRenderer_1, modeService_1, opener_1, async_1, modes_1, iconLabel_1, getIconClasses_1, modelService_1, uri_1, instantiation_1, files_1, htmlContent_1, arrays_1, position_1) {
  107101. "use strict";
  107102. Object.defineProperty(exports, "__esModule", { value: true });
  107103. var expandSuggestionDocsByDefault = false;
  107104. /**
  107105. * Suggest widget colors
  107106. */
  107107. exports.editorSuggestWidgetBackground = colorRegistry_1.registerColor('editorSuggestWidget.background', { dark: colorRegistry_1.editorWidgetBackground, light: colorRegistry_1.editorWidgetBackground, hc: colorRegistry_1.editorWidgetBackground }, nls.localize(0, null));
  107108. exports.editorSuggestWidgetBorder = colorRegistry_1.registerColor('editorSuggestWidget.border', { dark: colorRegistry_1.editorWidgetBorder, light: colorRegistry_1.editorWidgetBorder, hc: colorRegistry_1.editorWidgetBorder }, nls.localize(1, null));
  107109. exports.editorSuggestWidgetForeground = colorRegistry_1.registerColor('editorSuggestWidget.foreground', { dark: colorRegistry_1.editorForeground, light: colorRegistry_1.editorForeground, hc: colorRegistry_1.editorForeground }, nls.localize(2, null));
  107110. exports.editorSuggestWidgetSelectedBackground = colorRegistry_1.registerColor('editorSuggestWidget.selectedBackground', { dark: colorRegistry_1.listFocusBackground, light: colorRegistry_1.listFocusBackground, hc: colorRegistry_1.listFocusBackground }, nls.localize(3, null));
  107111. exports.editorSuggestWidgetHighlightForeground = colorRegistry_1.registerColor('editorSuggestWidget.highlightForeground', { dark: colorRegistry_1.listHighlightForeground, light: colorRegistry_1.listHighlightForeground, hc: colorRegistry_1.listHighlightForeground }, nls.localize(4, null));
  107112. var colorRegExp = /^(#([\da-f]{3}){1,2}|(rgb|hsl)a\(\s*(\d{1,3}%?\s*,\s*){3}(1|0?\.\d+)\)|(rgb|hsl)\(\s*\d{1,3}%?(\s*,\s*\d{1,3}%?){2}\s*\))$/i;
  107113. function extractColor(item, out) {
  107114. var label = typeof item.completion.label === 'string'
  107115. ? item.completion.label
  107116. : item.completion.label.name;
  107117. if (label.match(colorRegExp)) {
  107118. out[0] = label;
  107119. return true;
  107120. }
  107121. if (typeof item.completion.documentation === 'string' && item.completion.documentation.match(colorRegExp)) {
  107122. out[0] = item.completion.documentation;
  107123. return true;
  107124. }
  107125. return false;
  107126. }
  107127. function canExpandCompletionItem(item) {
  107128. if (!item) {
  107129. return false;
  107130. }
  107131. var suggestion = item.completion;
  107132. if (suggestion.documentation) {
  107133. return true;
  107134. }
  107135. return (suggestion.detail && suggestion.detail !== suggestion.label);
  107136. }
  107137. function getAriaId(index) {
  107138. return "suggest-aria-id:" + index;
  107139. }
  107140. var ItemRenderer = /** @class */ (function () {
  107141. function ItemRenderer(widget, editor, triggerKeybindingLabel, _modelService, _modeService, _themeService) {
  107142. this.widget = widget;
  107143. this.editor = editor;
  107144. this.triggerKeybindingLabel = triggerKeybindingLabel;
  107145. this._modelService = _modelService;
  107146. this._modeService = _modeService;
  107147. this._themeService = _themeService;
  107148. }
  107149. Object.defineProperty(ItemRenderer.prototype, "templateId", {
  107150. get: function () {
  107151. return 'suggestion';
  107152. },
  107153. enumerable: true,
  107154. configurable: true
  107155. });
  107156. ItemRenderer.prototype.renderTemplate = function (container) {
  107157. var _this = this;
  107158. var data = Object.create(null);
  107159. data.disposables = new lifecycle_1.DisposableStore();
  107160. data.root = container;
  107161. dom_1.addClass(data.root, 'show-file-icons');
  107162. data.icon = dom_1.append(container, dom_1.$('.icon'));
  107163. data.colorspan = dom_1.append(data.icon, dom_1.$('span.colorspan'));
  107164. var text = dom_1.append(container, dom_1.$('.contents'));
  107165. var main = dom_1.append(text, dom_1.$('.main'));
  107166. data.left = dom_1.append(main, dom_1.$('span.left'));
  107167. data.right = dom_1.append(main, dom_1.$('span.right'));
  107168. data.iconContainer = dom_1.append(data.left, dom_1.$('.icon-label.codicon'));
  107169. data.iconLabel = new iconLabel_1.IconLabel(data.left, { supportHighlights: true, supportCodicons: true });
  107170. data.disposables.add(data.iconLabel);
  107171. data.signatureLabel = dom_1.append(data.left, dom_1.$('span.signature-label'));
  107172. data.qualifierLabel = dom_1.append(data.left, dom_1.$('span.qualifier-label'));
  107173. data.detailsLabel = dom_1.append(data.right, dom_1.$('span.details-label'));
  107174. data.readMore = dom_1.append(data.right, dom_1.$('span.readMore.codicon.codicon-info'));
  107175. data.readMore.title = nls.localize(5, null, this.triggerKeybindingLabel);
  107176. var configureFont = function () {
  107177. var options = _this.editor.getOptions();
  107178. var fontInfo = options.get(34 /* fontInfo */);
  107179. var fontFamily = fontInfo.fontFamily;
  107180. var fontFeatureSettings = fontInfo.fontFeatureSettings;
  107181. var fontSize = options.get(90 /* suggestFontSize */) || fontInfo.fontSize;
  107182. var lineHeight = options.get(91 /* suggestLineHeight */) || fontInfo.lineHeight;
  107183. var fontWeight = fontInfo.fontWeight;
  107184. var fontSizePx = fontSize + "px";
  107185. var lineHeightPx = lineHeight + "px";
  107186. data.root.style.fontSize = fontSizePx;
  107187. data.root.style.fontWeight = fontWeight;
  107188. main.style.fontFamily = fontFamily;
  107189. main.style.fontFeatureSettings = fontFeatureSettings;
  107190. main.style.lineHeight = lineHeightPx;
  107191. data.icon.style.height = lineHeightPx;
  107192. data.icon.style.width = lineHeightPx;
  107193. data.readMore.style.height = lineHeightPx;
  107194. data.readMore.style.width = lineHeightPx;
  107195. };
  107196. configureFont();
  107197. data.disposables.add(event_1.Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor))
  107198. .filter(function (e) { return e.hasChanged(34 /* fontInfo */) || e.hasChanged(90 /* suggestFontSize */) || e.hasChanged(91 /* suggestLineHeight */); })
  107199. .on(configureFont, null));
  107200. return data;
  107201. };
  107202. ItemRenderer.prototype.renderElement = function (element, index, templateData) {
  107203. var _this = this;
  107204. var data = templateData;
  107205. var suggestion = element.completion;
  107206. var textLabel = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;
  107207. data.root.id = getAriaId(index);
  107208. data.icon.className = 'icon ' + modes_1.completionKindToCssClass(suggestion.kind);
  107209. data.colorspan.style.backgroundColor = '';
  107210. var labelOptions = {
  107211. labelEscapeNewLines: true,
  107212. matches: filters_1.createMatches(element.score)
  107213. };
  107214. var color = [];
  107215. if (suggestion.kind === 19 /* Color */ && extractColor(element, color)) {
  107216. // special logic for 'color' completion items
  107217. data.icon.className = 'icon customcolor';
  107218. data.iconContainer.className = 'icon hide';
  107219. data.colorspan.style.backgroundColor = color[0];
  107220. }
  107221. else if (suggestion.kind === 20 /* File */ && this._themeService.getIconTheme().hasFileIcons) {
  107222. // special logic for 'file' completion items
  107223. data.icon.className = 'icon hide';
  107224. data.iconContainer.className = 'icon hide';
  107225. var labelClasses = getIconClasses_1.getIconClasses(this._modelService, this._modeService, uri_1.URI.from({ scheme: 'fake', path: textLabel }), files_1.FileKind.FILE);
  107226. var detailClasses = getIconClasses_1.getIconClasses(this._modelService, this._modeService, uri_1.URI.from({ scheme: 'fake', path: suggestion.detail }), files_1.FileKind.FILE);
  107227. labelOptions.extraClasses = labelClasses.length > detailClasses.length ? labelClasses : detailClasses;
  107228. }
  107229. else if (suggestion.kind === 23 /* Folder */ && this._themeService.getIconTheme().hasFolderIcons) {
  107230. // special logic for 'folder' completion items
  107231. data.icon.className = 'icon hide';
  107232. data.iconContainer.className = 'icon hide';
  107233. labelOptions.extraClasses = arrays_1.flatten([
  107234. getIconClasses_1.getIconClasses(this._modelService, this._modeService, uri_1.URI.from({ scheme: 'fake', path: textLabel }), files_1.FileKind.FOLDER),
  107235. getIconClasses_1.getIconClasses(this._modelService, this._modeService, uri_1.URI.from({ scheme: 'fake', path: suggestion.detail }), files_1.FileKind.FOLDER)
  107236. ]);
  107237. }
  107238. else {
  107239. // normal icon
  107240. data.icon.className = 'icon hide';
  107241. data.iconContainer.className = '';
  107242. dom_1.addClasses(data.iconContainer, "suggest-icon codicon codicon-symbol-" + modes_1.completionKindToCssClass(suggestion.kind));
  107243. }
  107244. if (suggestion.tags && suggestion.tags.indexOf(1 /* Deprecated */) >= 0) {
  107245. labelOptions.extraClasses = (labelOptions.extraClasses || []).concat(['deprecated']);
  107246. labelOptions.matches = [];
  107247. }
  107248. data.iconLabel.setLabel(textLabel, undefined, labelOptions);
  107249. if (typeof suggestion.label === 'string') {
  107250. data.signatureLabel.textContent = '';
  107251. data.qualifierLabel.textContent = '';
  107252. data.detailsLabel.textContent = (suggestion.detail || '').replace(/\n.*$/m, '');
  107253. dom_1.removeClass(data.right, 'always-show-details');
  107254. }
  107255. else {
  107256. data.signatureLabel.textContent = (suggestion.label.signature || '').replace(/\n.*$/m, '');
  107257. data.qualifierLabel.textContent = (suggestion.label.qualifier || '').replace(/\n.*$/m, '');
  107258. data.detailsLabel.textContent = (suggestion.label.type || '').replace(/\n.*$/m, '');
  107259. dom_1.addClass(data.right, 'always-show-details');
  107260. }
  107261. if (canExpandCompletionItem(element)) {
  107262. dom_1.addClass(data.right, 'can-expand-details');
  107263. dom_1.show(data.readMore);
  107264. data.readMore.onmousedown = function (e) {
  107265. e.stopPropagation();
  107266. e.preventDefault();
  107267. };
  107268. data.readMore.onclick = function (e) {
  107269. e.stopPropagation();
  107270. e.preventDefault();
  107271. _this.widget.toggleDetails();
  107272. };
  107273. }
  107274. else {
  107275. dom_1.removeClass(data.right, 'can-expand-details');
  107276. dom_1.hide(data.readMore);
  107277. data.readMore.onmousedown = null;
  107278. data.readMore.onclick = null;
  107279. }
  107280. };
  107281. ItemRenderer.prototype.disposeTemplate = function (templateData) {
  107282. templateData.disposables.dispose();
  107283. };
  107284. ItemRenderer = __decorate([
  107285. __param(3, modelService_1.IModelService),
  107286. __param(4, modeService_1.IModeService),
  107287. __param(5, themeService_1.IThemeService)
  107288. ], ItemRenderer);
  107289. return ItemRenderer;
  107290. }());
  107291. var SuggestionDetails = /** @class */ (function () {
  107292. function SuggestionDetails(container, widget, editor, markdownRenderer, kbToggleDetails) {
  107293. var _this = this;
  107294. this.widget = widget;
  107295. this.editor = editor;
  107296. this.markdownRenderer = markdownRenderer;
  107297. this.kbToggleDetails = kbToggleDetails;
  107298. this.borderWidth = 1;
  107299. this.disposables = new lifecycle_1.DisposableStore();
  107300. this.el = dom_1.append(container, dom_1.$('.details'));
  107301. this.disposables.add(lifecycle_1.toDisposable(function () { return container.removeChild(_this.el); }));
  107302. this.body = dom_1.$('.body');
  107303. this.scrollbar = new scrollableElement_1.DomScrollableElement(this.body, {});
  107304. dom_1.append(this.el, this.scrollbar.getDomNode());
  107305. this.disposables.add(this.scrollbar);
  107306. this.header = dom_1.append(this.body, dom_1.$('.header'));
  107307. this.close = dom_1.append(this.header, dom_1.$('span.codicon.codicon-close'));
  107308. this.close.title = nls.localize(6, null, this.kbToggleDetails);
  107309. this.type = dom_1.append(this.header, dom_1.$('p.type'));
  107310. this.docs = dom_1.append(this.body, dom_1.$('p.docs'));
  107311. this.configureFont();
  107312. event_1.Event.chain(this.editor.onDidChangeConfiguration.bind(this.editor))
  107313. .filter(function (e) { return e.hasChanged(34 /* fontInfo */); })
  107314. .on(this.configureFont, this, this.disposables);
  107315. markdownRenderer.onDidRenderCodeBlock(function () { return _this.scrollbar.scanDomNode(); }, this, this.disposables);
  107316. }
  107317. Object.defineProperty(SuggestionDetails.prototype, "element", {
  107318. get: function () {
  107319. return this.el;
  107320. },
  107321. enumerable: true,
  107322. configurable: true
  107323. });
  107324. SuggestionDetails.prototype.renderLoading = function () {
  107325. this.type.textContent = nls.localize(7, null);
  107326. this.docs.textContent = '';
  107327. };
  107328. SuggestionDetails.prototype.renderItem = function (item, explainMode) {
  107329. var _this = this;
  107330. this.renderDisposeable = lifecycle_1.dispose(this.renderDisposeable);
  107331. var _a = item.completion, documentation = _a.documentation, detail = _a.detail;
  107332. // --- documentation
  107333. if (explainMode) {
  107334. var md = '';
  107335. md += "score: " + item.score[0] + (item.word ? ", compared '" + (item.completion.filterText && (item.completion.filterText + ' (filterText)') || item.completion.label) + "' with '" + item.word + "'" : ' (no prefix)') + "\n";
  107336. md += "distance: " + item.distance + ", see localityBonus-setting\n";
  107337. md += "index: " + item.idx + ", based on " + (item.completion.sortText && "sortText: \"" + item.completion.sortText + "\"" || 'label') + "\n";
  107338. documentation = new htmlContent_1.MarkdownString().appendCodeblock('empty', md);
  107339. detail = "Provider: " + item.provider._debugDisplayName;
  107340. }
  107341. if (!explainMode && !canExpandCompletionItem(item)) {
  107342. this.type.textContent = '';
  107343. this.docs.textContent = '';
  107344. dom_1.addClass(this.el, 'no-docs');
  107345. return;
  107346. }
  107347. dom_1.removeClass(this.el, 'no-docs');
  107348. if (typeof documentation === 'string') {
  107349. dom_1.removeClass(this.docs, 'markdown-docs');
  107350. this.docs.textContent = documentation;
  107351. }
  107352. else {
  107353. dom_1.addClass(this.docs, 'markdown-docs');
  107354. this.docs.innerHTML = '';
  107355. var renderedContents = this.markdownRenderer.render(documentation);
  107356. this.renderDisposeable = renderedContents;
  107357. this.docs.appendChild(renderedContents.element);
  107358. }
  107359. // --- details
  107360. if (detail) {
  107361. this.type.innerText = detail;
  107362. dom_1.show(this.type);
  107363. }
  107364. else {
  107365. this.type.innerText = '';
  107366. dom_1.hide(this.type);
  107367. }
  107368. this.el.style.height = this.header.offsetHeight + this.docs.offsetHeight + (this.borderWidth * 2) + 'px';
  107369. this.el.style.userSelect = 'text';
  107370. this.el.tabIndex = -1;
  107371. this.close.onmousedown = function (e) {
  107372. e.preventDefault();
  107373. e.stopPropagation();
  107374. };
  107375. this.close.onclick = function (e) {
  107376. e.preventDefault();
  107377. e.stopPropagation();
  107378. _this.widget.toggleDetails();
  107379. };
  107380. this.body.scrollTop = 0;
  107381. this.scrollbar.scanDomNode();
  107382. };
  107383. SuggestionDetails.prototype.scrollDown = function (much) {
  107384. if (much === void 0) { much = 8; }
  107385. this.body.scrollTop += much;
  107386. };
  107387. SuggestionDetails.prototype.scrollUp = function (much) {
  107388. if (much === void 0) { much = 8; }
  107389. this.body.scrollTop -= much;
  107390. };
  107391. SuggestionDetails.prototype.scrollTop = function () {
  107392. this.body.scrollTop = 0;
  107393. };
  107394. SuggestionDetails.prototype.scrollBottom = function () {
  107395. this.body.scrollTop = this.body.scrollHeight;
  107396. };
  107397. SuggestionDetails.prototype.pageDown = function () {
  107398. this.scrollDown(80);
  107399. };
  107400. SuggestionDetails.prototype.pageUp = function () {
  107401. this.scrollUp(80);
  107402. };
  107403. SuggestionDetails.prototype.setBorderWidth = function (width) {
  107404. this.borderWidth = width;
  107405. };
  107406. SuggestionDetails.prototype.configureFont = function () {
  107407. var options = this.editor.getOptions();
  107408. var fontInfo = options.get(34 /* fontInfo */);
  107409. var fontFamily = fontInfo.fontFamily;
  107410. var fontSize = options.get(90 /* suggestFontSize */) || fontInfo.fontSize;
  107411. var lineHeight = options.get(91 /* suggestLineHeight */) || fontInfo.lineHeight;
  107412. var fontWeight = fontInfo.fontWeight;
  107413. var fontSizePx = fontSize + "px";
  107414. var lineHeightPx = lineHeight + "px";
  107415. this.el.style.fontSize = fontSizePx;
  107416. this.el.style.fontWeight = fontWeight;
  107417. this.el.style.fontFeatureSettings = fontInfo.fontFeatureSettings;
  107418. this.type.style.fontFamily = fontFamily;
  107419. this.close.style.height = lineHeightPx;
  107420. this.close.style.width = lineHeightPx;
  107421. };
  107422. SuggestionDetails.prototype.dispose = function () {
  107423. this.disposables.dispose();
  107424. this.renderDisposeable = lifecycle_1.dispose(this.renderDisposeable);
  107425. };
  107426. return SuggestionDetails;
  107427. }());
  107428. var SuggestWidget = /** @class */ (function () {
  107429. function SuggestWidget(editor, telemetryService, keybindingService, contextKeyService, themeService, storageService, modeService, openerService, instantiationService) {
  107430. var _this = this;
  107431. var _a, _b;
  107432. this.editor = editor;
  107433. this.telemetryService = telemetryService;
  107434. this.keybindingService = keybindingService;
  107435. // Editor.IContentWidget.allowEditorOverflow
  107436. this.allowEditorOverflow = true;
  107437. this.suppressMouseDown = false;
  107438. this.state = null;
  107439. this.isAuto = false;
  107440. this.loadingTimeout = lifecycle_1.Disposable.None;
  107441. this.currentSuggestionDetails = null;
  107442. this.ignoreFocusEvents = false;
  107443. this.completionModel = null;
  107444. this.showTimeout = new async_1.TimeoutTimer();
  107445. this.toDispose = new lifecycle_1.DisposableStore();
  107446. this.onDidSelectEmitter = new event_1.Emitter();
  107447. this.onDidFocusEmitter = new event_1.Emitter();
  107448. this.onDidHideEmitter = new event_1.Emitter();
  107449. this.onDidShowEmitter = new event_1.Emitter();
  107450. this.onDidSelect = this.onDidSelectEmitter.event;
  107451. this.onDidFocus = this.onDidFocusEmitter.event;
  107452. this.onDidHide = this.onDidHideEmitter.event;
  107453. this.onDidShow = this.onDidShowEmitter.event;
  107454. this.maxWidgetWidth = 660;
  107455. this.listWidth = 330;
  107456. this.firstFocusInCurrentList = false;
  107457. this.preferDocPositionTop = false;
  107458. this.docsPositionPreviousWidgetY = null;
  107459. this.explainMode = false;
  107460. this._onDetailsKeydown = new event_1.Emitter();
  107461. this.onDetailsKeyDown = this._onDetailsKeydown.event;
  107462. var markdownRenderer = this.toDispose.add(new markdownRenderer_1.MarkdownRenderer(editor, modeService, openerService));
  107463. var kbToggleDetails = (_b = (_a = keybindingService.lookupKeybinding('toggleSuggestionDetails')) === null || _a === void 0 ? void 0 : _a.getLabel()) !== null && _b !== void 0 ? _b : '';
  107464. this.msgDetailsLess = nls.localize(10, null, kbToggleDetails);
  107465. this.msgDetailMore = nls.localize(11, null, kbToggleDetails);
  107466. this.isAuto = false;
  107467. this.focusedItem = null;
  107468. this.storageService = storageService;
  107469. this.element = dom_1.$('.editor-widget.suggest-widget');
  107470. this.toDispose.add(dom_1.addDisposableListener(this.element, 'click', function (e) {
  107471. if (e.target === _this.element) {
  107472. _this.hideWidget();
  107473. }
  107474. }));
  107475. this.messageElement = dom_1.append(this.element, dom_1.$('.message'));
  107476. this.listElement = dom_1.append(this.element, dom_1.$('.tree'));
  107477. var applyStatusBarStyle = function () { return dom_1.toggleClass(_this.element, 'with-status-bar', !_this.editor.getOption(89 /* suggest */).hideStatusBar); };
  107478. applyStatusBarStyle();
  107479. this.statusBarElement = dom_1.append(this.element, dom_1.$('.suggest-status-bar'));
  107480. this.statusBarLeftSpan = dom_1.append(this.statusBarElement, dom_1.$('span'));
  107481. this.statusBarRightSpan = dom_1.append(this.statusBarElement, dom_1.$('span'));
  107482. this.setStatusBarLeftText('');
  107483. this.setStatusBarRightText('');
  107484. this.details = instantiationService.createInstance(SuggestionDetails, this.element, this, this.editor, markdownRenderer, kbToggleDetails);
  107485. var applyIconStyle = function () { return dom_1.toggleClass(_this.element, 'no-icons', !_this.editor.getOption(89 /* suggest */).showIcons); };
  107486. applyIconStyle();
  107487. var renderer = instantiationService.createInstance(ItemRenderer, this, this.editor, kbToggleDetails);
  107488. this.list = new listWidget_1.List('SuggestWidget', this.listElement, this, [renderer], {
  107489. useShadows: false,
  107490. openController: { shouldOpen: function () { return false; } },
  107491. mouseSupport: false,
  107492. accessibilityProvider: {
  107493. getAriaLabel: function (item) {
  107494. var textLabel = typeof item.completion.label === 'string' ? item.completion.label : item.completion.label.name;
  107495. if (item.isResolved && _this.expandDocsSettingFromStorage()) {
  107496. var _a = item.completion, documentation = _a.documentation, detail = _a.detail;
  107497. var docs = strings.format('{0}{1}', detail || '', documentation ? (typeof documentation === 'string' ? documentation : documentation.value) : '');
  107498. return nls.localize(12, null, textLabel, docs);
  107499. }
  107500. else {
  107501. return textLabel;
  107502. }
  107503. }
  107504. }
  107505. });
  107506. this.toDispose.add(styler_1.attachListStyler(this.list, themeService, {
  107507. listInactiveFocusBackground: exports.editorSuggestWidgetSelectedBackground,
  107508. listInactiveFocusOutline: colorRegistry_1.activeContrastBorder
  107509. }));
  107510. this.toDispose.add(themeService.onThemeChange(function (t) { return _this.onThemeChange(t); }));
  107511. this.toDispose.add(editor.onDidLayoutChange(function () { return _this.onEditorLayoutChange(); }));
  107512. this.toDispose.add(this.list.onMouseDown(function (e) { return _this.onListMouseDownOrTap(e); }));
  107513. this.toDispose.add(this.list.onTap(function (e) { return _this.onListMouseDownOrTap(e); }));
  107514. this.toDispose.add(this.list.onSelectionChange(function (e) { return _this.onListSelection(e); }));
  107515. this.toDispose.add(this.list.onFocusChange(function (e) { return _this.onListFocus(e); }));
  107516. this.toDispose.add(this.editor.onDidChangeCursorSelection(function () { return _this.onCursorSelectionChanged(); }));
  107517. this.toDispose.add(this.editor.onDidChangeConfiguration(function (e) {
  107518. if (e.hasChanged(89 /* suggest */)) {
  107519. applyStatusBarStyle();
  107520. applyIconStyle();
  107521. }
  107522. }));
  107523. this.suggestWidgetVisible = suggest_1.Context.Visible.bindTo(contextKeyService);
  107524. this.suggestWidgetMultipleSuggestions = suggest_1.Context.MultipleSuggestions.bindTo(contextKeyService);
  107525. this.editor.addContentWidget(this);
  107526. this.setState(0 /* Hidden */);
  107527. this.onThemeChange(themeService.getTheme());
  107528. this.toDispose.add(dom_1.addStandardDisposableListener(this.details.element, 'keydown', function (e) {
  107529. _this._onDetailsKeydown.fire(e);
  107530. }));
  107531. this.toDispose.add(this.editor.onMouseDown(function (e) { return _this.onEditorMouseDown(e); }));
  107532. }
  107533. SuggestWidget.prototype.onEditorMouseDown = function (mouseEvent) {
  107534. // Clicking inside details
  107535. if (this.details.element.contains(mouseEvent.target.element)) {
  107536. this.details.element.focus();
  107537. }
  107538. // Clicking outside details and inside suggest
  107539. else {
  107540. if (this.element.contains(mouseEvent.target.element)) {
  107541. this.editor.focus();
  107542. }
  107543. }
  107544. };
  107545. SuggestWidget.prototype.onCursorSelectionChanged = function () {
  107546. if (this.state === 0 /* Hidden */) {
  107547. return;
  107548. }
  107549. this.editor.layoutContentWidget(this);
  107550. };
  107551. SuggestWidget.prototype.onEditorLayoutChange = function () {
  107552. if ((this.state === 3 /* Open */ || this.state === 5 /* Details */) && this.expandDocsSettingFromStorage()) {
  107553. this.expandSideOrBelow();
  107554. }
  107555. };
  107556. SuggestWidget.prototype.onListMouseDownOrTap = function (e) {
  107557. if (typeof e.element === 'undefined' || typeof e.index === 'undefined') {
  107558. return;
  107559. }
  107560. // prevent stealing browser focus from the editor
  107561. e.browserEvent.preventDefault();
  107562. e.browserEvent.stopPropagation();
  107563. this.select(e.element, e.index);
  107564. };
  107565. SuggestWidget.prototype.onListSelection = function (e) {
  107566. if (!e.elements.length) {
  107567. return;
  107568. }
  107569. this.select(e.elements[0], e.indexes[0]);
  107570. };
  107571. SuggestWidget.prototype.select = function (item, index) {
  107572. var completionModel = this.completionModel;
  107573. if (!completionModel) {
  107574. return;
  107575. }
  107576. this.onDidSelectEmitter.fire({ item: item, index: index, model: completionModel });
  107577. this.editor.focus();
  107578. };
  107579. SuggestWidget.prototype.onThemeChange = function (theme) {
  107580. var backgroundColor = theme.getColor(exports.editorSuggestWidgetBackground);
  107581. if (backgroundColor) {
  107582. this.listElement.style.backgroundColor = backgroundColor.toString();
  107583. this.statusBarElement.style.backgroundColor = backgroundColor.toString();
  107584. this.details.element.style.backgroundColor = backgroundColor.toString();
  107585. this.messageElement.style.backgroundColor = backgroundColor.toString();
  107586. }
  107587. var borderColor = theme.getColor(exports.editorSuggestWidgetBorder);
  107588. if (borderColor) {
  107589. this.listElement.style.borderColor = borderColor.toString();
  107590. this.statusBarElement.style.borderColor = borderColor.toString();
  107591. this.details.element.style.borderColor = borderColor.toString();
  107592. this.messageElement.style.borderColor = borderColor.toString();
  107593. this.detailsBorderColor = borderColor.toString();
  107594. }
  107595. var focusBorderColor = theme.getColor(colorRegistry_1.focusBorder);
  107596. if (focusBorderColor) {
  107597. this.detailsFocusBorderColor = focusBorderColor.toString();
  107598. }
  107599. this.details.setBorderWidth(theme.type === 'hc' ? 2 : 1);
  107600. };
  107601. SuggestWidget.prototype.onListFocus = function (e) {
  107602. var _this = this;
  107603. var _a, _b;
  107604. if (this.ignoreFocusEvents) {
  107605. return;
  107606. }
  107607. if (!e.elements.length) {
  107608. if (this.currentSuggestionDetails) {
  107609. this.currentSuggestionDetails.cancel();
  107610. this.currentSuggestionDetails = null;
  107611. this.focusedItem = null;
  107612. }
  107613. this.editor.setAriaOptions({ activeDescendant: undefined });
  107614. return;
  107615. }
  107616. if (!this.completionModel) {
  107617. return;
  107618. }
  107619. var item = e.elements[0];
  107620. var index = e.indexes[0];
  107621. this.firstFocusInCurrentList = !this.focusedItem;
  107622. if (item !== this.focusedItem) {
  107623. // update statusbar
  107624. // todo@joh,pine -> this should a toolbar with actions so that these things become
  107625. // mouse clickable and fit for accessibility...
  107626. var wantsInsert = this.editor.getOption(89 /* suggest */).insertMode === 'insert';
  107627. var kbAccept = (_a = this.keybindingService.lookupKeybinding('acceptSelectedSuggestion')) === null || _a === void 0 ? void 0 : _a.getLabel();
  107628. var kbAcceptAlt = (_b = this.keybindingService.lookupKeybinding('acceptAlternativeSelectedSuggestion')) === null || _b === void 0 ? void 0 : _b.getLabel();
  107629. if (!position_1.Position.equals(item.editInsertEnd, item.editReplaceEnd)) {
  107630. // insert AND replace
  107631. if (wantsInsert) {
  107632. this.setStatusBarLeftText(nls.localize(13, null, kbAccept, kbAcceptAlt));
  107633. }
  107634. else {
  107635. this.setStatusBarLeftText(nls.localize(14, null, kbAccept, kbAcceptAlt));
  107636. }
  107637. }
  107638. else {
  107639. this.setStatusBarLeftText(nls.localize(15, null, kbAccept));
  107640. }
  107641. if (this.currentSuggestionDetails) {
  107642. this.currentSuggestionDetails.cancel();
  107643. this.currentSuggestionDetails = null;
  107644. }
  107645. this.focusedItem = item;
  107646. this.list.reveal(index);
  107647. this.currentSuggestionDetails = async_1.createCancelablePromise(function (token) { return __awaiter(_this, void 0, void 0, function () {
  107648. var loading, result;
  107649. var _this = this;
  107650. return __generator(this, function (_a) {
  107651. switch (_a.label) {
  107652. case 0:
  107653. loading = async_1.disposableTimeout(function () { return _this.showDetails(true); }, 250);
  107654. token.onCancellationRequested(function () { return loading.dispose(); });
  107655. return [4 /*yield*/, item.resolve(token)];
  107656. case 1:
  107657. result = _a.sent();
  107658. loading.dispose();
  107659. return [2 /*return*/, result];
  107660. }
  107661. });
  107662. }); });
  107663. this.currentSuggestionDetails.then(function () {
  107664. if (index >= _this.list.length || item !== _this.list.element(index)) {
  107665. return;
  107666. }
  107667. // item can have extra information, so re-render
  107668. _this.ignoreFocusEvents = true;
  107669. _this.list.splice(index, 1, [item]);
  107670. _this.list.setFocus([index]);
  107671. _this.ignoreFocusEvents = false;
  107672. if (_this.expandDocsSettingFromStorage()) {
  107673. _this.showDetails(false);
  107674. }
  107675. else {
  107676. dom_1.removeClass(_this.element, 'docs-side');
  107677. }
  107678. if (canExpandCompletionItem(_this.focusedItem)) {
  107679. if (_this.expandDocsSettingFromStorage()) {
  107680. _this.setStatusBarRightText(_this.msgDetailsLess);
  107681. }
  107682. else {
  107683. _this.setStatusBarRightText(_this.msgDetailMore);
  107684. }
  107685. }
  107686. else {
  107687. _this.statusBarRightSpan.innerText = '';
  107688. }
  107689. _this.editor.setAriaOptions({ activeDescendant: getAriaId(index) });
  107690. }).catch(errors_1.onUnexpectedError);
  107691. }
  107692. // emit an event
  107693. this.onDidFocusEmitter.fire({ item: item, index: index, model: this.completionModel });
  107694. };
  107695. SuggestWidget.prototype.setState = function (state) {
  107696. if (!this.element) {
  107697. return;
  107698. }
  107699. var stateChanged = this.state !== state;
  107700. this.state = state;
  107701. dom_1.toggleClass(this.element, 'frozen', state === 4 /* Frozen */);
  107702. switch (state) {
  107703. case 0 /* Hidden */:
  107704. dom_1.hide(this.messageElement, this.details.element, this.listElement, this.statusBarElement);
  107705. this.hide();
  107706. this.listHeight = 0;
  107707. if (stateChanged) {
  107708. this.list.splice(0, this.list.length);
  107709. }
  107710. this.focusedItem = null;
  107711. break;
  107712. case 1 /* Loading */:
  107713. this.messageElement.textContent = SuggestWidget.LOADING_MESSAGE;
  107714. dom_1.hide(this.listElement, this.details.element, this.statusBarElement);
  107715. dom_1.show(this.messageElement);
  107716. dom_1.removeClass(this.element, 'docs-side');
  107717. this.show();
  107718. this.focusedItem = null;
  107719. break;
  107720. case 2 /* Empty */:
  107721. this.messageElement.textContent = SuggestWidget.NO_SUGGESTIONS_MESSAGE;
  107722. dom_1.hide(this.listElement, this.details.element, this.statusBarElement);
  107723. dom_1.show(this.messageElement);
  107724. dom_1.removeClass(this.element, 'docs-side');
  107725. this.show();
  107726. this.focusedItem = null;
  107727. break;
  107728. case 3 /* Open */:
  107729. dom_1.hide(this.messageElement);
  107730. dom_1.show(this.listElement, this.statusBarElement);
  107731. this.show();
  107732. break;
  107733. case 4 /* Frozen */:
  107734. dom_1.hide(this.messageElement);
  107735. dom_1.show(this.listElement);
  107736. this.show();
  107737. break;
  107738. case 5 /* Details */:
  107739. dom_1.hide(this.messageElement);
  107740. dom_1.show(this.details.element, this.listElement, this.statusBarElement);
  107741. this.show();
  107742. break;
  107743. }
  107744. };
  107745. SuggestWidget.prototype.showTriggered = function (auto, delay) {
  107746. var _this = this;
  107747. if (this.state !== 0 /* Hidden */) {
  107748. return;
  107749. }
  107750. this.isAuto = !!auto;
  107751. if (!this.isAuto) {
  107752. this.loadingTimeout = async_1.disposableTimeout(function () { return _this.setState(1 /* Loading */); }, delay);
  107753. }
  107754. };
  107755. SuggestWidget.prototype.showSuggestions = function (completionModel, selectionIndex, isFrozen, isAuto) {
  107756. this.preferDocPositionTop = false;
  107757. this.docsPositionPreviousWidgetY = null;
  107758. this.loadingTimeout.dispose();
  107759. if (this.currentSuggestionDetails) {
  107760. this.currentSuggestionDetails.cancel();
  107761. this.currentSuggestionDetails = null;
  107762. }
  107763. if (this.completionModel !== completionModel) {
  107764. this.completionModel = completionModel;
  107765. }
  107766. if (isFrozen && this.state !== 2 /* Empty */ && this.state !== 0 /* Hidden */) {
  107767. this.setState(4 /* Frozen */);
  107768. return;
  107769. }
  107770. var visibleCount = this.completionModel.items.length;
  107771. var isEmpty = visibleCount === 0;
  107772. this.suggestWidgetMultipleSuggestions.set(visibleCount > 1);
  107773. if (isEmpty) {
  107774. if (isAuto) {
  107775. this.setState(0 /* Hidden */);
  107776. }
  107777. else {
  107778. this.setState(2 /* Empty */);
  107779. }
  107780. this.completionModel = null;
  107781. }
  107782. else {
  107783. if (this.state !== 3 /* Open */) {
  107784. var stats = this.completionModel.stats;
  107785. stats['wasAutomaticallyTriggered'] = !!isAuto;
  107786. /* __GDPR__
  107787. "suggestWidget" : {
  107788. "wasAutomaticallyTriggered" : { "classification": "SystemMetaData", "purpose": "FeatureInsight", "isMeasurement": true },
  107789. "${include}": [
  107790. "${ICompletionStats}"
  107791. ]
  107792. }
  107793. */
  107794. this.telemetryService.publicLog('suggestWidget', __assign({}, stats));
  107795. }
  107796. this.focusedItem = null;
  107797. this.list.splice(0, this.list.length, this.completionModel.items);
  107798. if (isFrozen) {
  107799. this.setState(4 /* Frozen */);
  107800. }
  107801. else {
  107802. this.setState(3 /* Open */);
  107803. }
  107804. this.list.reveal(selectionIndex, 0);
  107805. this.list.setFocus([selectionIndex]);
  107806. // Reset focus border
  107807. if (this.detailsBorderColor) {
  107808. this.details.element.style.borderColor = this.detailsBorderColor;
  107809. }
  107810. }
  107811. };
  107812. SuggestWidget.prototype.selectNextPage = function () {
  107813. switch (this.state) {
  107814. case 0 /* Hidden */:
  107815. return false;
  107816. case 5 /* Details */:
  107817. this.details.pageDown();
  107818. return true;
  107819. case 1 /* Loading */:
  107820. return !this.isAuto;
  107821. default:
  107822. this.list.focusNextPage();
  107823. return true;
  107824. }
  107825. };
  107826. SuggestWidget.prototype.selectNext = function () {
  107827. switch (this.state) {
  107828. case 0 /* Hidden */:
  107829. return false;
  107830. case 1 /* Loading */:
  107831. return !this.isAuto;
  107832. default:
  107833. this.list.focusNext(1, true);
  107834. return true;
  107835. }
  107836. };
  107837. SuggestWidget.prototype.selectLast = function () {
  107838. switch (this.state) {
  107839. case 0 /* Hidden */:
  107840. return false;
  107841. case 5 /* Details */:
  107842. this.details.scrollBottom();
  107843. return true;
  107844. case 1 /* Loading */:
  107845. return !this.isAuto;
  107846. default:
  107847. this.list.focusLast();
  107848. return true;
  107849. }
  107850. };
  107851. SuggestWidget.prototype.selectPreviousPage = function () {
  107852. switch (this.state) {
  107853. case 0 /* Hidden */:
  107854. return false;
  107855. case 5 /* Details */:
  107856. this.details.pageUp();
  107857. return true;
  107858. case 1 /* Loading */:
  107859. return !this.isAuto;
  107860. default:
  107861. this.list.focusPreviousPage();
  107862. return true;
  107863. }
  107864. };
  107865. SuggestWidget.prototype.selectPrevious = function () {
  107866. switch (this.state) {
  107867. case 0 /* Hidden */:
  107868. return false;
  107869. case 1 /* Loading */:
  107870. return !this.isAuto;
  107871. default:
  107872. this.list.focusPrevious(1, true);
  107873. return false;
  107874. }
  107875. };
  107876. SuggestWidget.prototype.selectFirst = function () {
  107877. switch (this.state) {
  107878. case 0 /* Hidden */:
  107879. return false;
  107880. case 5 /* Details */:
  107881. this.details.scrollTop();
  107882. return true;
  107883. case 1 /* Loading */:
  107884. return !this.isAuto;
  107885. default:
  107886. this.list.focusFirst();
  107887. return true;
  107888. }
  107889. };
  107890. SuggestWidget.prototype.getFocusedItem = function () {
  107891. if (this.state !== 0 /* Hidden */
  107892. && this.state !== 2 /* Empty */
  107893. && this.state !== 1 /* Loading */
  107894. && this.completionModel) {
  107895. return {
  107896. item: this.list.getFocusedElements()[0],
  107897. index: this.list.getFocus()[0],
  107898. model: this.completionModel
  107899. };
  107900. }
  107901. return undefined;
  107902. };
  107903. SuggestWidget.prototype.toggleDetailsFocus = function () {
  107904. if (this.state === 5 /* Details */) {
  107905. this.setState(3 /* Open */);
  107906. if (this.detailsBorderColor) {
  107907. this.details.element.style.borderColor = this.detailsBorderColor;
  107908. }
  107909. }
  107910. else if (this.state === 3 /* Open */ && this.expandDocsSettingFromStorage()) {
  107911. this.setState(5 /* Details */);
  107912. if (this.detailsFocusBorderColor) {
  107913. this.details.element.style.borderColor = this.detailsFocusBorderColor;
  107914. }
  107915. }
  107916. this.telemetryService.publicLog2('suggestWidget:toggleDetailsFocus');
  107917. };
  107918. SuggestWidget.prototype.toggleDetails = function () {
  107919. if (!canExpandCompletionItem(this.list.getFocusedElements()[0])) {
  107920. return;
  107921. }
  107922. if (this.expandDocsSettingFromStorage()) {
  107923. this.updateExpandDocsSetting(false);
  107924. dom_1.hide(this.details.element);
  107925. dom_1.removeClass(this.element, 'docs-side');
  107926. dom_1.removeClass(this.element, 'docs-below');
  107927. this.editor.layoutContentWidget(this);
  107928. this.setStatusBarRightText(this.msgDetailMore);
  107929. this.telemetryService.publicLog2('suggestWidget:collapseDetails');
  107930. }
  107931. else {
  107932. if (this.state !== 3 /* Open */ && this.state !== 5 /* Details */ && this.state !== 4 /* Frozen */) {
  107933. return;
  107934. }
  107935. this.updateExpandDocsSetting(true);
  107936. this.showDetails(false);
  107937. this.setStatusBarRightText(this.msgDetailsLess);
  107938. this.telemetryService.publicLog2('suggestWidget:expandDetails');
  107939. }
  107940. };
  107941. SuggestWidget.prototype.showDetails = function (loading) {
  107942. if (!loading) {
  107943. // When loading, don't re-layout docs, as item is not resolved yet #88731
  107944. this.expandSideOrBelow();
  107945. }
  107946. dom_1.show(this.details.element);
  107947. this.details.element.style.maxHeight = this.maxWidgetHeight + 'px';
  107948. if (loading) {
  107949. this.details.renderLoading();
  107950. }
  107951. else {
  107952. this.details.renderItem(this.list.getFocusedElements()[0], this.explainMode);
  107953. }
  107954. // Reset margin-top that was set as Fix for #26416
  107955. this.listElement.style.marginTop = '0px';
  107956. // with docs showing up widget width/height may change, so reposition the widget
  107957. this.editor.layoutContentWidget(this);
  107958. this.adjustDocsPosition();
  107959. this.editor.focus();
  107960. };
  107961. SuggestWidget.prototype.toggleExplainMode = function () {
  107962. if (this.list.getFocusedElements()[0] && this.expandDocsSettingFromStorage()) {
  107963. this.explainMode = !this.explainMode;
  107964. this.showDetails(false);
  107965. }
  107966. };
  107967. SuggestWidget.prototype.show = function () {
  107968. var _this = this;
  107969. var newHeight = this.updateListHeight();
  107970. if (newHeight !== this.listHeight) {
  107971. this.editor.layoutContentWidget(this);
  107972. this.listHeight = newHeight;
  107973. }
  107974. this.suggestWidgetVisible.set(true);
  107975. this.showTimeout.cancelAndSet(function () {
  107976. dom_1.addClass(_this.element, 'visible');
  107977. _this.onDidShowEmitter.fire(_this);
  107978. }, 100);
  107979. };
  107980. SuggestWidget.prototype.hide = function () {
  107981. this.suggestWidgetVisible.reset();
  107982. this.suggestWidgetMultipleSuggestions.reset();
  107983. dom_1.removeClass(this.element, 'visible');
  107984. };
  107985. SuggestWidget.prototype.hideWidget = function () {
  107986. this.loadingTimeout.dispose();
  107987. this.setState(0 /* Hidden */);
  107988. this.onDidHideEmitter.fire(this);
  107989. };
  107990. SuggestWidget.prototype.getPosition = function () {
  107991. if (this.state === 0 /* Hidden */) {
  107992. return null;
  107993. }
  107994. var preference = [2 /* BELOW */, 1 /* ABOVE */];
  107995. if (this.preferDocPositionTop) {
  107996. preference = [1 /* ABOVE */];
  107997. }
  107998. return {
  107999. position: this.editor.getPosition(),
  108000. preference: preference
  108001. };
  108002. };
  108003. SuggestWidget.prototype.getDomNode = function () {
  108004. return this.element;
  108005. };
  108006. SuggestWidget.prototype.getId = function () {
  108007. return SuggestWidget.ID;
  108008. };
  108009. SuggestWidget.prototype.isFrozen = function () {
  108010. return this.state === 4 /* Frozen */;
  108011. };
  108012. SuggestWidget.prototype.updateListHeight = function () {
  108013. var height = 0;
  108014. if (this.state === 2 /* Empty */ || this.state === 1 /* Loading */) {
  108015. height = this.unfocusedHeight;
  108016. }
  108017. else {
  108018. var suggestionCount = this.list.contentHeight / this.unfocusedHeight;
  108019. var maxVisibleSuggestions = this.editor.getOption(89 /* suggest */).maxVisibleSuggestions;
  108020. height = Math.min(suggestionCount, maxVisibleSuggestions) * this.unfocusedHeight;
  108021. }
  108022. this.element.style.lineHeight = this.unfocusedHeight + "px";
  108023. this.listElement.style.height = height + "px";
  108024. this.statusBarElement.style.top = height + "px";
  108025. this.list.layout(height);
  108026. return height;
  108027. };
  108028. /**
  108029. * Adds the propert classes, margins when positioning the docs to the side
  108030. */
  108031. SuggestWidget.prototype.adjustDocsPosition = function () {
  108032. if (!this.editor.hasModel()) {
  108033. return;
  108034. }
  108035. var lineHeight = this.editor.getOption(49 /* lineHeight */);
  108036. var cursorCoords = this.editor.getScrolledVisiblePosition(this.editor.getPosition());
  108037. var editorCoords = dom_1.getDomNodePagePosition(this.editor.getDomNode());
  108038. var cursorX = editorCoords.left + cursorCoords.left;
  108039. var cursorY = editorCoords.top + cursorCoords.top + cursorCoords.height;
  108040. var widgetCoords = dom_1.getDomNodePagePosition(this.element);
  108041. var widgetX = widgetCoords.left;
  108042. var widgetY = widgetCoords.top;
  108043. // Fixes #27649
  108044. // Check if the Y changed to the top of the cursor and keep the widget flagged to prefer top
  108045. if (this.docsPositionPreviousWidgetY &&
  108046. this.docsPositionPreviousWidgetY < widgetY &&
  108047. !this.preferDocPositionTop) {
  108048. this.preferDocPositionTop = true;
  108049. this.adjustDocsPosition();
  108050. return;
  108051. }
  108052. this.docsPositionPreviousWidgetY = widgetY;
  108053. if (widgetX < cursorX - this.listWidth) {
  108054. // Widget is too far to the left of cursor, swap list and docs
  108055. dom_1.addClass(this.element, 'list-right');
  108056. }
  108057. else {
  108058. dom_1.removeClass(this.element, 'list-right');
  108059. }
  108060. // Compare top of the cursor (cursorY - lineheight) with widgetTop to determine if
  108061. // margin-top needs to be applied on list to make it appear right above the cursor
  108062. // Cannot compare cursorY directly as it may be a few decimals off due to zoooming
  108063. if (dom_1.hasClass(this.element, 'docs-side')
  108064. && cursorY - lineHeight > widgetY
  108065. && this.details.element.offsetHeight > this.listElement.offsetHeight) {
  108066. // Fix for #26416
  108067. // Docs is bigger than list and widget is above cursor, apply margin-top so that list appears right above cursor
  108068. this.listElement.style.marginTop = this.details.element.offsetHeight - this.listElement.offsetHeight + "px";
  108069. }
  108070. };
  108071. /**
  108072. * Adds the proper classes for positioning the docs to the side or below depending on item
  108073. */
  108074. SuggestWidget.prototype.expandSideOrBelow = function () {
  108075. if (!canExpandCompletionItem(this.focusedItem) && this.firstFocusInCurrentList) {
  108076. dom_1.removeClass(this.element, 'docs-side');
  108077. dom_1.removeClass(this.element, 'docs-below');
  108078. return;
  108079. }
  108080. var matches = this.element.style.maxWidth.match(/(\d+)px/);
  108081. if (!matches || Number(matches[1]) < this.maxWidgetWidth) {
  108082. dom_1.addClass(this.element, 'docs-below');
  108083. dom_1.removeClass(this.element, 'docs-side');
  108084. }
  108085. else if (canExpandCompletionItem(this.focusedItem)) {
  108086. dom_1.addClass(this.element, 'docs-side');
  108087. dom_1.removeClass(this.element, 'docs-below');
  108088. }
  108089. };
  108090. Object.defineProperty(SuggestWidget.prototype, "maxWidgetHeight", {
  108091. // Heights
  108092. get: function () {
  108093. return this.unfocusedHeight * this.editor.getOption(89 /* suggest */).maxVisibleSuggestions;
  108094. },
  108095. enumerable: true,
  108096. configurable: true
  108097. });
  108098. Object.defineProperty(SuggestWidget.prototype, "unfocusedHeight", {
  108099. get: function () {
  108100. var options = this.editor.getOptions();
  108101. return options.get(91 /* suggestLineHeight */) || options.get(34 /* fontInfo */).lineHeight;
  108102. },
  108103. enumerable: true,
  108104. configurable: true
  108105. });
  108106. // IDelegate
  108107. SuggestWidget.prototype.getHeight = function (element) {
  108108. return this.unfocusedHeight;
  108109. };
  108110. SuggestWidget.prototype.getTemplateId = function (element) {
  108111. return 'suggestion';
  108112. };
  108113. SuggestWidget.prototype.expandDocsSettingFromStorage = function () {
  108114. return this.storageService.getBoolean('expandSuggestionDocs', 0 /* GLOBAL */, expandSuggestionDocsByDefault);
  108115. };
  108116. SuggestWidget.prototype.updateExpandDocsSetting = function (value) {
  108117. this.storageService.store('expandSuggestionDocs', value, 0 /* GLOBAL */);
  108118. };
  108119. SuggestWidget.prototype.setStatusBarLeftText = function (s) {
  108120. this.statusBarLeftSpan.innerText = s;
  108121. };
  108122. SuggestWidget.prototype.setStatusBarRightText = function (s) {
  108123. this.statusBarRightSpan.innerText = s;
  108124. };
  108125. SuggestWidget.prototype.dispose = function () {
  108126. this.details.dispose();
  108127. this.list.dispose();
  108128. this.toDispose.dispose();
  108129. this.loadingTimeout.dispose();
  108130. this.showTimeout.dispose();
  108131. };
  108132. SuggestWidget.ID = 'editor.widget.suggestWidget';
  108133. SuggestWidget.LOADING_MESSAGE = nls.localize(8, null);
  108134. SuggestWidget.NO_SUGGESTIONS_MESSAGE = nls.localize(9, null);
  108135. SuggestWidget = __decorate([
  108136. __param(1, telemetry_1.ITelemetryService),
  108137. __param(2, keybinding_1.IKeybindingService),
  108138. __param(3, contextkey_1.IContextKeyService),
  108139. __param(4, themeService_1.IThemeService),
  108140. __param(5, storage_1.IStorageService),
  108141. __param(6, modeService_1.IModeService),
  108142. __param(7, opener_1.IOpenerService),
  108143. __param(8, instantiation_1.IInstantiationService)
  108144. ], SuggestWidget);
  108145. return SuggestWidget;
  108146. }());
  108147. exports.SuggestWidget = SuggestWidget;
  108148. themeService_1.registerThemingParticipant(function (theme, collector) {
  108149. var matchHighlight = theme.getColor(exports.editorSuggestWidgetHighlightForeground);
  108150. if (matchHighlight) {
  108151. collector.addRule(".monaco-editor .suggest-widget .monaco-list .monaco-list-row .monaco-highlighted-label .highlight { color: " + matchHighlight + "; }");
  108152. }
  108153. var foreground = theme.getColor(exports.editorSuggestWidgetForeground);
  108154. if (foreground) {
  108155. collector.addRule(".monaco-editor .suggest-widget { color: " + foreground + "; }");
  108156. }
  108157. var link = theme.getColor(colorRegistry_1.textLinkForeground);
  108158. if (link) {
  108159. collector.addRule(".monaco-editor .suggest-widget a { color: " + link + "; }");
  108160. }
  108161. var codeBackground = theme.getColor(colorRegistry_1.textCodeBlockBackground);
  108162. if (codeBackground) {
  108163. collector.addRule(".monaco-editor .suggest-widget code { background-color: " + codeBackground + "; }");
  108164. }
  108165. });
  108166. });
  108167. /*---------------------------------------------------------------------------------------------
  108168. * Copyright (c) Microsoft Corporation. All rights reserved.
  108169. * Licensed under the MIT License. See License.txt in the project root for license information.
  108170. *--------------------------------------------------------------------------------------------*/
  108171. define(__m[586/*vs/editor/contrib/wordHighlighter/wordHighlighter*/], __M([0/*require*/,1/*exports*/,471/*vs/nls!vs/editor/contrib/wordHighlighter/wordHighlighter*/,19/*vs/base/common/arrays*/,15/*vs/base/common/async*/,26/*vs/base/common/cancellation*/,10/*vs/base/common/errors*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,3/*vs/editor/common/core/range*/,23/*vs/editor/common/editorContextKeys*/,48/*vs/editor/common/model*/,30/*vs/editor/common/model/textModel*/,17/*vs/editor/common/modes*/,18/*vs/platform/contextkey/common/contextkey*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/]), function (require, exports, nls, arrays, async_1, cancellation_1, errors_1, lifecycle_1, editorExtensions_1, range_1, editorContextKeys_1, model_1, textModel_1, modes_1, contextkey_1, colorRegistry_1, themeService_1) {
  108172. "use strict";
  108173. Object.defineProperty(exports, "__esModule", { value: true });
  108174. var editorWordHighlight = colorRegistry_1.registerColor('editor.wordHighlightBackground', { dark: '#575757B8', light: '#57575740', hc: null }, nls.localize(0, null), true);
  108175. var editorWordHighlightStrong = colorRegistry_1.registerColor('editor.wordHighlightStrongBackground', { dark: '#004972B8', light: '#0e639c40', hc: null }, nls.localize(1, null), true);
  108176. var editorWordHighlightBorder = colorRegistry_1.registerColor('editor.wordHighlightBorder', { light: null, dark: null, hc: colorRegistry_1.activeContrastBorder }, nls.localize(2, null));
  108177. var editorWordHighlightStrongBorder = colorRegistry_1.registerColor('editor.wordHighlightStrongBorder', { light: null, dark: null, hc: colorRegistry_1.activeContrastBorder }, nls.localize(3, null));
  108178. var overviewRulerWordHighlightForeground = colorRegistry_1.registerColor('editorOverviewRuler.wordHighlightForeground', { dark: '#A0A0A0CC', light: '#A0A0A0CC', hc: '#A0A0A0CC' }, nls.localize(4, null), true);
  108179. var overviewRulerWordHighlightStrongForeground = colorRegistry_1.registerColor('editorOverviewRuler.wordHighlightStrongForeground', { dark: '#C0A0C0CC', light: '#C0A0C0CC', hc: '#C0A0C0CC' }, nls.localize(5, null), true);
  108180. var ctxHasWordHighlights = new contextkey_1.RawContextKey('hasWordHighlights', false);
  108181. function getOccurrencesAtPosition(model, position, token) {
  108182. var orderedByScore = modes_1.DocumentHighlightProviderRegistry.ordered(model);
  108183. // in order of score ask the occurrences provider
  108184. // until someone response with a good result
  108185. // (good = none empty array)
  108186. return async_1.first(orderedByScore.map(function (provider) { return function () {
  108187. return Promise.resolve(provider.provideDocumentHighlights(model, position, token))
  108188. .then(undefined, errors_1.onUnexpectedExternalError);
  108189. }; }), arrays.isNonEmptyArray);
  108190. }
  108191. exports.getOccurrencesAtPosition = getOccurrencesAtPosition;
  108192. var OccurenceAtPositionRequest = /** @class */ (function () {
  108193. function OccurenceAtPositionRequest(model, selection, wordSeparators) {
  108194. var _this = this;
  108195. this._wordRange = this._getCurrentWordRange(model, selection);
  108196. this.result = async_1.createCancelablePromise(function (token) { return _this._compute(model, selection, wordSeparators, token); });
  108197. }
  108198. OccurenceAtPositionRequest.prototype._getCurrentWordRange = function (model, selection) {
  108199. var word = model.getWordAtPosition(selection.getPosition());
  108200. if (word) {
  108201. return new range_1.Range(selection.startLineNumber, word.startColumn, selection.startLineNumber, word.endColumn);
  108202. }
  108203. return null;
  108204. };
  108205. OccurenceAtPositionRequest.prototype.isValid = function (model, selection, decorationIds) {
  108206. var lineNumber = selection.startLineNumber;
  108207. var startColumn = selection.startColumn;
  108208. var endColumn = selection.endColumn;
  108209. var currentWordRange = this._getCurrentWordRange(model, selection);
  108210. var requestIsValid = Boolean(this._wordRange && this._wordRange.equalsRange(currentWordRange));
  108211. // Even if we are on a different word, if that word is in the decorations ranges, the request is still valid
  108212. // (Same symbol)
  108213. for (var i = 0, len = decorationIds.length; !requestIsValid && i < len; i++) {
  108214. var range = model.getDecorationRange(decorationIds[i]);
  108215. if (range && range.startLineNumber === lineNumber) {
  108216. if (range.startColumn <= startColumn && range.endColumn >= endColumn) {
  108217. requestIsValid = true;
  108218. }
  108219. }
  108220. }
  108221. return requestIsValid;
  108222. };
  108223. OccurenceAtPositionRequest.prototype.cancel = function () {
  108224. this.result.cancel();
  108225. };
  108226. return OccurenceAtPositionRequest;
  108227. }());
  108228. var SemanticOccurenceAtPositionRequest = /** @class */ (function (_super) {
  108229. __extends(SemanticOccurenceAtPositionRequest, _super);
  108230. function SemanticOccurenceAtPositionRequest() {
  108231. return _super !== null && _super.apply(this, arguments) || this;
  108232. }
  108233. SemanticOccurenceAtPositionRequest.prototype._compute = function (model, selection, wordSeparators, token) {
  108234. return getOccurrencesAtPosition(model, selection.getPosition(), token).then(function (value) { return value || []; });
  108235. };
  108236. return SemanticOccurenceAtPositionRequest;
  108237. }(OccurenceAtPositionRequest));
  108238. var TextualOccurenceAtPositionRequest = /** @class */ (function (_super) {
  108239. __extends(TextualOccurenceAtPositionRequest, _super);
  108240. function TextualOccurenceAtPositionRequest(model, selection, wordSeparators) {
  108241. var _this = _super.call(this, model, selection, wordSeparators) || this;
  108242. _this._selectionIsEmpty = selection.isEmpty();
  108243. return _this;
  108244. }
  108245. TextualOccurenceAtPositionRequest.prototype._compute = function (model, selection, wordSeparators, token) {
  108246. return async_1.timeout(250, token).then(function () {
  108247. if (!selection.isEmpty()) {
  108248. return [];
  108249. }
  108250. var word = model.getWordAtPosition(selection.getPosition());
  108251. if (!word) {
  108252. return [];
  108253. }
  108254. var matches = model.findMatches(word.word, true, false, true, wordSeparators, false);
  108255. return matches.map(function (m) {
  108256. return {
  108257. range: m.range,
  108258. kind: modes_1.DocumentHighlightKind.Text
  108259. };
  108260. });
  108261. });
  108262. };
  108263. TextualOccurenceAtPositionRequest.prototype.isValid = function (model, selection, decorationIds) {
  108264. var currentSelectionIsEmpty = selection.isEmpty();
  108265. if (this._selectionIsEmpty !== currentSelectionIsEmpty) {
  108266. return false;
  108267. }
  108268. return _super.prototype.isValid.call(this, model, selection, decorationIds);
  108269. };
  108270. return TextualOccurenceAtPositionRequest;
  108271. }(OccurenceAtPositionRequest));
  108272. function computeOccurencesAtPosition(model, selection, wordSeparators) {
  108273. if (modes_1.DocumentHighlightProviderRegistry.has(model)) {
  108274. return new SemanticOccurenceAtPositionRequest(model, selection, wordSeparators);
  108275. }
  108276. return new TextualOccurenceAtPositionRequest(model, selection, wordSeparators);
  108277. }
  108278. editorExtensions_1.registerModelAndPositionCommand('_executeDocumentHighlights', function (model, position) { return getOccurrencesAtPosition(model, position, cancellation_1.CancellationToken.None); });
  108279. var WordHighlighter = /** @class */ (function () {
  108280. function WordHighlighter(editor, contextKeyService) {
  108281. var _this = this;
  108282. this.toUnhook = new lifecycle_1.DisposableStore();
  108283. this.workerRequestTokenId = 0;
  108284. this.workerRequestCompleted = false;
  108285. this.workerRequestValue = [];
  108286. this.lastCursorPositionChangeTime = 0;
  108287. this.renderDecorationsTimer = -1;
  108288. this.editor = editor;
  108289. this._hasWordHighlights = ctxHasWordHighlights.bindTo(contextKeyService);
  108290. this._ignorePositionChangeEvent = false;
  108291. this.occurrencesHighlight = this.editor.getOption(61 /* occurrencesHighlight */);
  108292. this.model = this.editor.getModel();
  108293. this.toUnhook.add(editor.onDidChangeCursorPosition(function (e) {
  108294. if (_this._ignorePositionChangeEvent) {
  108295. // We are changing the position => ignore this event
  108296. return;
  108297. }
  108298. if (!_this.occurrencesHighlight) {
  108299. // Early exit if nothing needs to be done!
  108300. // Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
  108301. return;
  108302. }
  108303. _this._onPositionChanged(e);
  108304. }));
  108305. this.toUnhook.add(editor.onDidChangeModelContent(function (e) {
  108306. _this._stopAll();
  108307. }));
  108308. this.toUnhook.add(editor.onDidChangeConfiguration(function (e) {
  108309. var newValue = _this.editor.getOption(61 /* occurrencesHighlight */);
  108310. if (_this.occurrencesHighlight !== newValue) {
  108311. _this.occurrencesHighlight = newValue;
  108312. _this._stopAll();
  108313. }
  108314. }));
  108315. this._decorationIds = [];
  108316. this.workerRequestTokenId = 0;
  108317. this.workerRequest = null;
  108318. this.workerRequestCompleted = false;
  108319. this.lastCursorPositionChangeTime = 0;
  108320. this.renderDecorationsTimer = -1;
  108321. }
  108322. WordHighlighter.prototype.hasDecorations = function () {
  108323. return (this._decorationIds.length > 0);
  108324. };
  108325. WordHighlighter.prototype.restore = function () {
  108326. if (!this.occurrencesHighlight) {
  108327. return;
  108328. }
  108329. this._run();
  108330. };
  108331. WordHighlighter.prototype._getSortedHighlights = function () {
  108332. var _this = this;
  108333. return arrays.coalesce(this._decorationIds
  108334. .map(function (id) { return _this.model.getDecorationRange(id); })
  108335. .sort(range_1.Range.compareRangesUsingStarts));
  108336. };
  108337. WordHighlighter.prototype.moveNext = function () {
  108338. var _this = this;
  108339. var highlights = this._getSortedHighlights();
  108340. var index = arrays.firstIndex(highlights, function (range) { return range.containsPosition(_this.editor.getPosition()); });
  108341. var newIndex = ((index + 1) % highlights.length);
  108342. var dest = highlights[newIndex];
  108343. try {
  108344. this._ignorePositionChangeEvent = true;
  108345. this.editor.setPosition(dest.getStartPosition());
  108346. this.editor.revealRangeInCenterIfOutsideViewport(dest);
  108347. }
  108348. finally {
  108349. this._ignorePositionChangeEvent = false;
  108350. }
  108351. };
  108352. WordHighlighter.prototype.moveBack = function () {
  108353. var _this = this;
  108354. var highlights = this._getSortedHighlights();
  108355. var index = arrays.firstIndex(highlights, function (range) { return range.containsPosition(_this.editor.getPosition()); });
  108356. var newIndex = ((index - 1 + highlights.length) % highlights.length);
  108357. var dest = highlights[newIndex];
  108358. try {
  108359. this._ignorePositionChangeEvent = true;
  108360. this.editor.setPosition(dest.getStartPosition());
  108361. this.editor.revealRangeInCenterIfOutsideViewport(dest);
  108362. }
  108363. finally {
  108364. this._ignorePositionChangeEvent = false;
  108365. }
  108366. };
  108367. WordHighlighter.prototype._removeDecorations = function () {
  108368. if (this._decorationIds.length > 0) {
  108369. // remove decorations
  108370. this._decorationIds = this.editor.deltaDecorations(this._decorationIds, []);
  108371. this._hasWordHighlights.set(false);
  108372. }
  108373. };
  108374. WordHighlighter.prototype._stopAll = function () {
  108375. // Remove any existing decorations
  108376. this._removeDecorations();
  108377. // Cancel any renderDecorationsTimer
  108378. if (this.renderDecorationsTimer !== -1) {
  108379. clearTimeout(this.renderDecorationsTimer);
  108380. this.renderDecorationsTimer = -1;
  108381. }
  108382. // Cancel any worker request
  108383. if (this.workerRequest !== null) {
  108384. this.workerRequest.cancel();
  108385. this.workerRequest = null;
  108386. }
  108387. // Invalidate any worker request callback
  108388. if (!this.workerRequestCompleted) {
  108389. this.workerRequestTokenId++;
  108390. this.workerRequestCompleted = true;
  108391. }
  108392. };
  108393. WordHighlighter.prototype._onPositionChanged = function (e) {
  108394. // disabled
  108395. if (!this.occurrencesHighlight) {
  108396. this._stopAll();
  108397. return;
  108398. }
  108399. // ignore typing & other
  108400. if (e.reason !== 3 /* Explicit */) {
  108401. this._stopAll();
  108402. return;
  108403. }
  108404. this._run();
  108405. };
  108406. WordHighlighter.prototype._run = function () {
  108407. var _this = this;
  108408. var editorSelection = this.editor.getSelection();
  108409. // ignore multiline selection
  108410. if (editorSelection.startLineNumber !== editorSelection.endLineNumber) {
  108411. this._stopAll();
  108412. return;
  108413. }
  108414. var lineNumber = editorSelection.startLineNumber;
  108415. var startColumn = editorSelection.startColumn;
  108416. var endColumn = editorSelection.endColumn;
  108417. var word = this.model.getWordAtPosition({
  108418. lineNumber: lineNumber,
  108419. column: startColumn
  108420. });
  108421. // The selection must be inside a word or surround one word at most
  108422. if (!word || word.startColumn > startColumn || word.endColumn < endColumn) {
  108423. this._stopAll();
  108424. return;
  108425. }
  108426. // All the effort below is trying to achieve this:
  108427. // - when cursor is moved to a word, trigger immediately a findOccurrences request
  108428. // - 250ms later after the last cursor move event, render the occurrences
  108429. // - no flickering!
  108430. var workerRequestIsValid = (this.workerRequest && this.workerRequest.isValid(this.model, editorSelection, this._decorationIds));
  108431. // There are 4 cases:
  108432. // a) old workerRequest is valid & completed, renderDecorationsTimer fired
  108433. // b) old workerRequest is valid & completed, renderDecorationsTimer not fired
  108434. // c) old workerRequest is valid, but not completed
  108435. // d) old workerRequest is not valid
  108436. // For a) no action is needed
  108437. // For c), member 'lastCursorPositionChangeTime' will be used when installing the timer so no action is needed
  108438. this.lastCursorPositionChangeTime = (new Date()).getTime();
  108439. if (workerRequestIsValid) {
  108440. if (this.workerRequestCompleted && this.renderDecorationsTimer !== -1) {
  108441. // case b)
  108442. // Delay the firing of renderDecorationsTimer by an extra 250 ms
  108443. clearTimeout(this.renderDecorationsTimer);
  108444. this.renderDecorationsTimer = -1;
  108445. this._beginRenderDecorations();
  108446. }
  108447. }
  108448. else {
  108449. // case d)
  108450. // Stop all previous actions and start fresh
  108451. this._stopAll();
  108452. var myRequestId_1 = ++this.workerRequestTokenId;
  108453. this.workerRequestCompleted = false;
  108454. this.workerRequest = computeOccurencesAtPosition(this.model, this.editor.getSelection(), this.editor.getOption(96 /* wordSeparators */));
  108455. this.workerRequest.result.then(function (data) {
  108456. if (myRequestId_1 === _this.workerRequestTokenId) {
  108457. _this.workerRequestCompleted = true;
  108458. _this.workerRequestValue = data || [];
  108459. _this._beginRenderDecorations();
  108460. }
  108461. }, errors_1.onUnexpectedError);
  108462. }
  108463. };
  108464. WordHighlighter.prototype._beginRenderDecorations = function () {
  108465. var _this = this;
  108466. var currentTime = (new Date()).getTime();
  108467. var minimumRenderTime = this.lastCursorPositionChangeTime + 250;
  108468. if (currentTime >= minimumRenderTime) {
  108469. // Synchronous
  108470. this.renderDecorationsTimer = -1;
  108471. this.renderDecorations();
  108472. }
  108473. else {
  108474. // Asynchronous
  108475. this.renderDecorationsTimer = setTimeout(function () {
  108476. _this.renderDecorations();
  108477. }, (minimumRenderTime - currentTime));
  108478. }
  108479. };
  108480. WordHighlighter.prototype.renderDecorations = function () {
  108481. this.renderDecorationsTimer = -1;
  108482. var decorations = [];
  108483. for (var i = 0, len = this.workerRequestValue.length; i < len; i++) {
  108484. var info = this.workerRequestValue[i];
  108485. decorations.push({
  108486. range: info.range,
  108487. options: WordHighlighter._getDecorationOptions(info.kind)
  108488. });
  108489. }
  108490. this._decorationIds = this.editor.deltaDecorations(this._decorationIds, decorations);
  108491. this._hasWordHighlights.set(this.hasDecorations());
  108492. };
  108493. WordHighlighter._getDecorationOptions = function (kind) {
  108494. if (kind === modes_1.DocumentHighlightKind.Write) {
  108495. return this._WRITE_OPTIONS;
  108496. }
  108497. else if (kind === modes_1.DocumentHighlightKind.Text) {
  108498. return this._TEXT_OPTIONS;
  108499. }
  108500. else {
  108501. return this._REGULAR_OPTIONS;
  108502. }
  108503. };
  108504. WordHighlighter.prototype.dispose = function () {
  108505. this._stopAll();
  108506. this.toUnhook.dispose();
  108507. };
  108508. WordHighlighter._WRITE_OPTIONS = textModel_1.ModelDecorationOptions.register({
  108509. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  108510. className: 'wordHighlightStrong',
  108511. overviewRuler: {
  108512. color: themeService_1.themeColorFromId(overviewRulerWordHighlightStrongForeground),
  108513. position: model_1.OverviewRulerLane.Center
  108514. }
  108515. });
  108516. WordHighlighter._TEXT_OPTIONS = textModel_1.ModelDecorationOptions.register({
  108517. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  108518. className: 'selectionHighlight',
  108519. overviewRuler: {
  108520. color: themeService_1.themeColorFromId(colorRegistry_1.overviewRulerSelectionHighlightForeground),
  108521. position: model_1.OverviewRulerLane.Center
  108522. }
  108523. });
  108524. WordHighlighter._REGULAR_OPTIONS = textModel_1.ModelDecorationOptions.register({
  108525. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  108526. className: 'wordHighlight',
  108527. overviewRuler: {
  108528. color: themeService_1.themeColorFromId(overviewRulerWordHighlightForeground),
  108529. position: model_1.OverviewRulerLane.Center
  108530. }
  108531. });
  108532. return WordHighlighter;
  108533. }());
  108534. var WordHighlighterContribution = /** @class */ (function (_super) {
  108535. __extends(WordHighlighterContribution, _super);
  108536. function WordHighlighterContribution(editor, contextKeyService) {
  108537. var _this = _super.call(this) || this;
  108538. _this.wordHighligher = null;
  108539. var createWordHighlighterIfPossible = function () {
  108540. if (editor.hasModel()) {
  108541. _this.wordHighligher = new WordHighlighter(editor, contextKeyService);
  108542. }
  108543. };
  108544. _this._register(editor.onDidChangeModel(function (e) {
  108545. if (_this.wordHighligher) {
  108546. _this.wordHighligher.dispose();
  108547. _this.wordHighligher = null;
  108548. }
  108549. createWordHighlighterIfPossible();
  108550. }));
  108551. createWordHighlighterIfPossible();
  108552. return _this;
  108553. }
  108554. WordHighlighterContribution.get = function (editor) {
  108555. return editor.getContribution(WordHighlighterContribution.ID);
  108556. };
  108557. WordHighlighterContribution.prototype.saveViewState = function () {
  108558. if (this.wordHighligher && this.wordHighligher.hasDecorations()) {
  108559. return true;
  108560. }
  108561. return false;
  108562. };
  108563. WordHighlighterContribution.prototype.moveNext = function () {
  108564. if (this.wordHighligher) {
  108565. this.wordHighligher.moveNext();
  108566. }
  108567. };
  108568. WordHighlighterContribution.prototype.moveBack = function () {
  108569. if (this.wordHighligher) {
  108570. this.wordHighligher.moveBack();
  108571. }
  108572. };
  108573. WordHighlighterContribution.prototype.restoreViewState = function (state) {
  108574. if (this.wordHighligher && state) {
  108575. this.wordHighligher.restore();
  108576. }
  108577. };
  108578. WordHighlighterContribution.prototype.dispose = function () {
  108579. if (this.wordHighligher) {
  108580. this.wordHighligher.dispose();
  108581. this.wordHighligher = null;
  108582. }
  108583. _super.prototype.dispose.call(this);
  108584. };
  108585. WordHighlighterContribution.ID = 'editor.contrib.wordHighlighter';
  108586. WordHighlighterContribution = __decorate([
  108587. __param(1, contextkey_1.IContextKeyService)
  108588. ], WordHighlighterContribution);
  108589. return WordHighlighterContribution;
  108590. }(lifecycle_1.Disposable));
  108591. var WordHighlightNavigationAction = /** @class */ (function (_super) {
  108592. __extends(WordHighlightNavigationAction, _super);
  108593. function WordHighlightNavigationAction(next, opts) {
  108594. var _this = _super.call(this, opts) || this;
  108595. _this._isNext = next;
  108596. return _this;
  108597. }
  108598. WordHighlightNavigationAction.prototype.run = function (accessor, editor) {
  108599. var controller = WordHighlighterContribution.get(editor);
  108600. if (!controller) {
  108601. return;
  108602. }
  108603. if (this._isNext) {
  108604. controller.moveNext();
  108605. }
  108606. else {
  108607. controller.moveBack();
  108608. }
  108609. };
  108610. return WordHighlightNavigationAction;
  108611. }(editorExtensions_1.EditorAction));
  108612. var NextWordHighlightAction = /** @class */ (function (_super) {
  108613. __extends(NextWordHighlightAction, _super);
  108614. function NextWordHighlightAction() {
  108615. return _super.call(this, true, {
  108616. id: 'editor.action.wordHighlight.next',
  108617. label: nls.localize(6, null),
  108618. alias: 'Go to Next Symbol Highlight',
  108619. precondition: ctxHasWordHighlights,
  108620. kbOpts: {
  108621. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  108622. primary: 65 /* F7 */,
  108623. weight: 100 /* EditorContrib */
  108624. }
  108625. }) || this;
  108626. }
  108627. return NextWordHighlightAction;
  108628. }(WordHighlightNavigationAction));
  108629. var PrevWordHighlightAction = /** @class */ (function (_super) {
  108630. __extends(PrevWordHighlightAction, _super);
  108631. function PrevWordHighlightAction() {
  108632. return _super.call(this, false, {
  108633. id: 'editor.action.wordHighlight.prev',
  108634. label: nls.localize(7, null),
  108635. alias: 'Go to Previous Symbol Highlight',
  108636. precondition: ctxHasWordHighlights,
  108637. kbOpts: {
  108638. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  108639. primary: 1024 /* Shift */ | 65 /* F7 */,
  108640. weight: 100 /* EditorContrib */
  108641. }
  108642. }) || this;
  108643. }
  108644. return PrevWordHighlightAction;
  108645. }(WordHighlightNavigationAction));
  108646. var TriggerWordHighlightAction = /** @class */ (function (_super) {
  108647. __extends(TriggerWordHighlightAction, _super);
  108648. function TriggerWordHighlightAction() {
  108649. return _super.call(this, {
  108650. id: 'editor.action.wordHighlight.trigger',
  108651. label: nls.localize(8, null),
  108652. alias: 'Trigger Symbol Highlight',
  108653. precondition: ctxHasWordHighlights.toNegated(),
  108654. kbOpts: {
  108655. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  108656. primary: 0,
  108657. weight: 100 /* EditorContrib */
  108658. }
  108659. }) || this;
  108660. }
  108661. TriggerWordHighlightAction.prototype.run = function (accessor, editor, args) {
  108662. var controller = WordHighlighterContribution.get(editor);
  108663. if (!controller) {
  108664. return;
  108665. }
  108666. controller.restoreViewState(true);
  108667. };
  108668. return TriggerWordHighlightAction;
  108669. }(editorExtensions_1.EditorAction));
  108670. editorExtensions_1.registerEditorContribution(WordHighlighterContribution.ID, WordHighlighterContribution);
  108671. editorExtensions_1.registerEditorAction(NextWordHighlightAction);
  108672. editorExtensions_1.registerEditorAction(PrevWordHighlightAction);
  108673. editorExtensions_1.registerEditorAction(TriggerWordHighlightAction);
  108674. themeService_1.registerThemingParticipant(function (theme, collector) {
  108675. var selectionHighlight = theme.getColor(colorRegistry_1.editorSelectionHighlight);
  108676. if (selectionHighlight) {
  108677. collector.addRule(".monaco-editor .focused .selectionHighlight { background-color: " + selectionHighlight + "; }");
  108678. collector.addRule(".monaco-editor .selectionHighlight { background-color: " + selectionHighlight.transparent(0.5) + "; }");
  108679. }
  108680. var wordHighlight = theme.getColor(editorWordHighlight);
  108681. if (wordHighlight) {
  108682. collector.addRule(".monaco-editor .wordHighlight { background-color: " + wordHighlight + "; }");
  108683. }
  108684. var wordHighlightStrong = theme.getColor(editorWordHighlightStrong);
  108685. if (wordHighlightStrong) {
  108686. collector.addRule(".monaco-editor .wordHighlightStrong { background-color: " + wordHighlightStrong + "; }");
  108687. }
  108688. var selectionHighlightBorder = theme.getColor(colorRegistry_1.editorSelectionHighlightBorder);
  108689. if (selectionHighlightBorder) {
  108690. collector.addRule(".monaco-editor .selectionHighlight { border: 1px " + (theme.type === 'hc' ? 'dotted' : 'solid') + " " + selectionHighlightBorder + "; box-sizing: border-box; }");
  108691. }
  108692. var wordHighlightBorder = theme.getColor(editorWordHighlightBorder);
  108693. if (wordHighlightBorder) {
  108694. collector.addRule(".monaco-editor .wordHighlight { border: 1px " + (theme.type === 'hc' ? 'dashed' : 'solid') + " " + wordHighlightBorder + "; box-sizing: border-box; }");
  108695. }
  108696. var wordHighlightStrongBorder = theme.getColor(editorWordHighlightStrongBorder);
  108697. if (wordHighlightStrongBorder) {
  108698. collector.addRule(".monaco-editor .wordHighlightStrong { border: 1px " + (theme.type === 'hc' ? 'dashed' : 'solid') + " " + wordHighlightStrongBorder + "; box-sizing: border-box; }");
  108699. }
  108700. });
  108701. });
  108702. /*---------------------------------------------------------------------------------------------
  108703. * Copyright (c) Microsoft Corporation. All rights reserved.
  108704. * Licensed under the MIT License. See License.txt in the project root for license information.
  108705. *--------------------------------------------------------------------------------------------*/
  108706. define(__m[587/*vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,6/*vs/base/browser/dom*/,28/*vs/base/browser/fastDomNode*/,134/*vs/base/browser/formattedTextRenderer*/,50/*vs/base/browser/ui/aria/aria*/,47/*vs/base/browser/ui/widget*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,5/*vs/base/common/strings*/,25/*vs/base/common/uri*/,12/*vs/editor/browser/editorExtensions*/,23/*vs/editor/common/editorContextKeys*/,225/*vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,34/*vs/platform/keybinding/common/keybinding*/,51/*vs/platform/opener/common/opener*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,59/*vs/editor/common/standaloneStrings*/,325/*vs/css!vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp*/]), function (require, exports, browser, dom, fastDomNode_1, formattedTextRenderer_1, aria_1, widget_1, lifecycle_1, platform, strings, uri_1, editorExtensions_1, editorContextKeys_1, toggleTabFocusMode_1, contextkey_1, instantiation_1, keybinding_1, opener_1, colorRegistry_1, themeService_1, standaloneStrings_1) {
  108707. "use strict";
  108708. Object.defineProperty(exports, "__esModule", { value: true });
  108709. var CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE = new contextkey_1.RawContextKey('accessibilityHelpWidgetVisible', false);
  108710. var AccessibilityHelpController = /** @class */ (function (_super) {
  108711. __extends(AccessibilityHelpController, _super);
  108712. function AccessibilityHelpController(editor, instantiationService) {
  108713. var _this = _super.call(this) || this;
  108714. _this._editor = editor;
  108715. _this._widget = _this._register(instantiationService.createInstance(AccessibilityHelpWidget, _this._editor));
  108716. return _this;
  108717. }
  108718. AccessibilityHelpController.get = function (editor) {
  108719. return editor.getContribution(AccessibilityHelpController.ID);
  108720. };
  108721. AccessibilityHelpController.prototype.show = function () {
  108722. this._widget.show();
  108723. };
  108724. AccessibilityHelpController.prototype.hide = function () {
  108725. this._widget.hide();
  108726. };
  108727. AccessibilityHelpController.ID = 'editor.contrib.accessibilityHelpController';
  108728. AccessibilityHelpController = __decorate([
  108729. __param(1, instantiation_1.IInstantiationService)
  108730. ], AccessibilityHelpController);
  108731. return AccessibilityHelpController;
  108732. }(lifecycle_1.Disposable));
  108733. function getSelectionLabel(selections, charactersSelected) {
  108734. if (!selections || selections.length === 0) {
  108735. return standaloneStrings_1.AccessibilityHelpNLS.noSelection;
  108736. }
  108737. if (selections.length === 1) {
  108738. if (charactersSelected) {
  108739. return strings.format(standaloneStrings_1.AccessibilityHelpNLS.singleSelectionRange, selections[0].positionLineNumber, selections[0].positionColumn, charactersSelected);
  108740. }
  108741. return strings.format(standaloneStrings_1.AccessibilityHelpNLS.singleSelection, selections[0].positionLineNumber, selections[0].positionColumn);
  108742. }
  108743. if (charactersSelected) {
  108744. return strings.format(standaloneStrings_1.AccessibilityHelpNLS.multiSelectionRange, selections.length, charactersSelected);
  108745. }
  108746. if (selections.length > 0) {
  108747. return strings.format(standaloneStrings_1.AccessibilityHelpNLS.multiSelection, selections.length);
  108748. }
  108749. return '';
  108750. }
  108751. var AccessibilityHelpWidget = /** @class */ (function (_super) {
  108752. __extends(AccessibilityHelpWidget, _super);
  108753. function AccessibilityHelpWidget(editor, _contextKeyService, _keybindingService, _openerService) {
  108754. var _this = _super.call(this) || this;
  108755. _this._contextKeyService = _contextKeyService;
  108756. _this._keybindingService = _keybindingService;
  108757. _this._openerService = _openerService;
  108758. _this._editor = editor;
  108759. _this._isVisibleKey = CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE.bindTo(_this._contextKeyService);
  108760. _this._domNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  108761. _this._domNode.setClassName('accessibilityHelpWidget');
  108762. _this._domNode.setDisplay('none');
  108763. _this._domNode.setAttribute('role', 'dialog');
  108764. _this._domNode.setAttribute('aria-hidden', 'true');
  108765. _this._contentDomNode = fastDomNode_1.createFastDomNode(document.createElement('div'));
  108766. _this._contentDomNode.setAttribute('role', 'document');
  108767. _this._domNode.appendChild(_this._contentDomNode);
  108768. _this._isVisible = false;
  108769. _this._register(_this._editor.onDidLayoutChange(function () {
  108770. if (_this._isVisible) {
  108771. _this._layout();
  108772. }
  108773. }));
  108774. // Intentionally not configurable!
  108775. _this._register(dom.addStandardDisposableListener(_this._contentDomNode.domNode, 'keydown', function (e) {
  108776. if (!_this._isVisible) {
  108777. return;
  108778. }
  108779. if (e.equals(2048 /* CtrlCmd */ | 35 /* KEY_E */)) {
  108780. aria_1.alert(standaloneStrings_1.AccessibilityHelpNLS.emergencyConfOn);
  108781. _this._editor.updateOptions({
  108782. accessibilitySupport: 'on'
  108783. });
  108784. dom.clearNode(_this._contentDomNode.domNode);
  108785. _this._buildContent();
  108786. _this._contentDomNode.domNode.focus();
  108787. e.preventDefault();
  108788. e.stopPropagation();
  108789. }
  108790. if (e.equals(2048 /* CtrlCmd */ | 38 /* KEY_H */)) {
  108791. aria_1.alert(standaloneStrings_1.AccessibilityHelpNLS.openingDocs);
  108792. var url = _this._editor.getRawOptions().accessibilityHelpUrl;
  108793. if (typeof url === 'undefined') {
  108794. url = 'https://go.microsoft.com/fwlink/?linkid=852450';
  108795. }
  108796. _this._openerService.open(uri_1.URI.parse(url));
  108797. e.preventDefault();
  108798. e.stopPropagation();
  108799. }
  108800. }));
  108801. _this.onblur(_this._contentDomNode.domNode, function () {
  108802. _this.hide();
  108803. });
  108804. _this._editor.addOverlayWidget(_this);
  108805. return _this;
  108806. }
  108807. AccessibilityHelpWidget.prototype.dispose = function () {
  108808. this._editor.removeOverlayWidget(this);
  108809. _super.prototype.dispose.call(this);
  108810. };
  108811. AccessibilityHelpWidget.prototype.getId = function () {
  108812. return AccessibilityHelpWidget.ID;
  108813. };
  108814. AccessibilityHelpWidget.prototype.getDomNode = function () {
  108815. return this._domNode.domNode;
  108816. };
  108817. AccessibilityHelpWidget.prototype.getPosition = function () {
  108818. return {
  108819. preference: null
  108820. };
  108821. };
  108822. AccessibilityHelpWidget.prototype.show = function () {
  108823. if (this._isVisible) {
  108824. return;
  108825. }
  108826. this._isVisible = true;
  108827. this._isVisibleKey.set(true);
  108828. this._layout();
  108829. this._domNode.setDisplay('block');
  108830. this._domNode.setAttribute('aria-hidden', 'false');
  108831. this._contentDomNode.domNode.tabIndex = 0;
  108832. this._buildContent();
  108833. this._contentDomNode.domNode.focus();
  108834. };
  108835. AccessibilityHelpWidget.prototype._descriptionForCommand = function (commandId, msg, noKbMsg) {
  108836. var kb = this._keybindingService.lookupKeybinding(commandId);
  108837. if (kb) {
  108838. return strings.format(msg, kb.getAriaLabel());
  108839. }
  108840. return strings.format(noKbMsg, commandId);
  108841. };
  108842. AccessibilityHelpWidget.prototype._buildContent = function () {
  108843. var options = this._editor.getOptions();
  108844. var selections = this._editor.getSelections();
  108845. var charactersSelected = 0;
  108846. if (selections) {
  108847. var model_1 = this._editor.getModel();
  108848. if (model_1) {
  108849. selections.forEach(function (selection) {
  108850. charactersSelected += model_1.getValueLengthInRange(selection);
  108851. });
  108852. }
  108853. }
  108854. var text = getSelectionLabel(selections, charactersSelected);
  108855. if (options.get(45 /* inDiffEditor */)) {
  108856. if (options.get(68 /* readOnly */)) {
  108857. text += standaloneStrings_1.AccessibilityHelpNLS.readonlyDiffEditor;
  108858. }
  108859. else {
  108860. text += standaloneStrings_1.AccessibilityHelpNLS.editableDiffEditor;
  108861. }
  108862. }
  108863. else {
  108864. if (options.get(68 /* readOnly */)) {
  108865. text += standaloneStrings_1.AccessibilityHelpNLS.readonlyEditor;
  108866. }
  108867. else {
  108868. text += standaloneStrings_1.AccessibilityHelpNLS.editableEditor;
  108869. }
  108870. }
  108871. var turnOnMessage = (platform.isMacintosh
  108872. ? standaloneStrings_1.AccessibilityHelpNLS.changeConfigToOnMac
  108873. : standaloneStrings_1.AccessibilityHelpNLS.changeConfigToOnWinLinux);
  108874. switch (options.get(2 /* accessibilitySupport */)) {
  108875. case 0 /* Unknown */:
  108876. text += '\n\n - ' + turnOnMessage;
  108877. break;
  108878. case 2 /* Enabled */:
  108879. text += '\n\n - ' + standaloneStrings_1.AccessibilityHelpNLS.auto_on;
  108880. break;
  108881. case 1 /* Disabled */:
  108882. text += '\n\n - ' + standaloneStrings_1.AccessibilityHelpNLS.auto_off;
  108883. text += ' ' + turnOnMessage;
  108884. break;
  108885. }
  108886. if (options.get(106 /* tabFocusMode */)) {
  108887. text += '\n\n - ' + this._descriptionForCommand(toggleTabFocusMode_1.ToggleTabFocusModeAction.ID, standaloneStrings_1.AccessibilityHelpNLS.tabFocusModeOnMsg, standaloneStrings_1.AccessibilityHelpNLS.tabFocusModeOnMsgNoKb);
  108888. }
  108889. else {
  108890. text += '\n\n - ' + this._descriptionForCommand(toggleTabFocusMode_1.ToggleTabFocusModeAction.ID, standaloneStrings_1.AccessibilityHelpNLS.tabFocusModeOffMsg, standaloneStrings_1.AccessibilityHelpNLS.tabFocusModeOffMsgNoKb);
  108891. }
  108892. var openDocMessage = (platform.isMacintosh
  108893. ? standaloneStrings_1.AccessibilityHelpNLS.openDocMac
  108894. : standaloneStrings_1.AccessibilityHelpNLS.openDocWinLinux);
  108895. text += '\n\n - ' + openDocMessage;
  108896. text += '\n\n' + standaloneStrings_1.AccessibilityHelpNLS.outroMsg;
  108897. this._contentDomNode.domNode.appendChild(formattedTextRenderer_1.renderFormattedText(text));
  108898. // Per https://www.w3.org/TR/wai-aria/roles#document, Authors SHOULD provide a title or label for documents
  108899. this._contentDomNode.domNode.setAttribute('aria-label', text);
  108900. };
  108901. AccessibilityHelpWidget.prototype.hide = function () {
  108902. if (!this._isVisible) {
  108903. return;
  108904. }
  108905. this._isVisible = false;
  108906. this._isVisibleKey.reset();
  108907. this._domNode.setDisplay('none');
  108908. this._domNode.setAttribute('aria-hidden', 'true');
  108909. this._contentDomNode.domNode.tabIndex = -1;
  108910. dom.clearNode(this._contentDomNode.domNode);
  108911. this._editor.focus();
  108912. };
  108913. AccessibilityHelpWidget.prototype._layout = function () {
  108914. var editorLayout = this._editor.getLayoutInfo();
  108915. var w = Math.max(5, Math.min(AccessibilityHelpWidget.WIDTH, editorLayout.width - 40));
  108916. var h = Math.max(5, Math.min(AccessibilityHelpWidget.HEIGHT, editorLayout.height - 40));
  108917. this._domNode.setWidth(w);
  108918. this._domNode.setHeight(h);
  108919. var top = Math.round((editorLayout.height - h) / 2);
  108920. this._domNode.setTop(top);
  108921. var left = Math.round((editorLayout.width - w) / 2);
  108922. this._domNode.setLeft(left);
  108923. };
  108924. AccessibilityHelpWidget.ID = 'editor.contrib.accessibilityHelpWidget';
  108925. AccessibilityHelpWidget.WIDTH = 500;
  108926. AccessibilityHelpWidget.HEIGHT = 300;
  108927. AccessibilityHelpWidget = __decorate([
  108928. __param(1, contextkey_1.IContextKeyService),
  108929. __param(2, keybinding_1.IKeybindingService),
  108930. __param(3, opener_1.IOpenerService)
  108931. ], AccessibilityHelpWidget);
  108932. return AccessibilityHelpWidget;
  108933. }(widget_1.Widget));
  108934. var ShowAccessibilityHelpAction = /** @class */ (function (_super) {
  108935. __extends(ShowAccessibilityHelpAction, _super);
  108936. function ShowAccessibilityHelpAction() {
  108937. return _super.call(this, {
  108938. id: 'editor.action.showAccessibilityHelp',
  108939. label: standaloneStrings_1.AccessibilityHelpNLS.showAccessibilityHelpAction,
  108940. alias: 'Show Accessibility Help',
  108941. precondition: undefined,
  108942. kbOpts: {
  108943. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  108944. primary: (browser.isIE ? 2048 /* CtrlCmd */ | 59 /* F1 */ : 512 /* Alt */ | 59 /* F1 */),
  108945. weight: 100 /* EditorContrib */
  108946. }
  108947. }) || this;
  108948. }
  108949. ShowAccessibilityHelpAction.prototype.run = function (accessor, editor) {
  108950. var controller = AccessibilityHelpController.get(editor);
  108951. if (controller) {
  108952. controller.show();
  108953. }
  108954. };
  108955. return ShowAccessibilityHelpAction;
  108956. }(editorExtensions_1.EditorAction));
  108957. editorExtensions_1.registerEditorContribution(AccessibilityHelpController.ID, AccessibilityHelpController);
  108958. editorExtensions_1.registerEditorAction(ShowAccessibilityHelpAction);
  108959. var AccessibilityHelpCommand = editorExtensions_1.EditorCommand.bindToContribution(AccessibilityHelpController.get);
  108960. editorExtensions_1.registerEditorCommand(new AccessibilityHelpCommand({
  108961. id: 'closeAccessibilityHelp',
  108962. precondition: CONTEXT_ACCESSIBILITY_WIDGET_VISIBLE,
  108963. handler: function (x) { return x.hide(); },
  108964. kbOpts: {
  108965. weight: 100 /* EditorContrib */ + 100,
  108966. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  108967. primary: 9 /* Escape */,
  108968. secondary: [1024 /* Shift */ | 9 /* Escape */]
  108969. }
  108970. }));
  108971. themeService_1.registerThemingParticipant(function (theme, collector) {
  108972. var widgetBackground = theme.getColor(colorRegistry_1.editorWidgetBackground);
  108973. if (widgetBackground) {
  108974. collector.addRule(".monaco-editor .accessibilityHelpWidget { background-color: " + widgetBackground + "; }");
  108975. }
  108976. var widgetForeground = theme.getColor(colorRegistry_1.editorWidgetForeground);
  108977. if (widgetForeground) {
  108978. collector.addRule(".monaco-editor .accessibilityHelpWidget { color: " + widgetForeground + "; }");
  108979. }
  108980. var widgetShadowColor = theme.getColor(colorRegistry_1.widgetShadow);
  108981. if (widgetShadowColor) {
  108982. collector.addRule(".monaco-editor .accessibilityHelpWidget { box-shadow: 0 2px 8px " + widgetShadowColor + "; }");
  108983. }
  108984. var hcBorder = theme.getColor(colorRegistry_1.contrastBorder);
  108985. if (hcBorder) {
  108986. collector.addRule(".monaco-editor .accessibilityHelpWidget { border: 2px solid " + hcBorder + "; }");
  108987. }
  108988. });
  108989. });
  108990. /*---------------------------------------------------------------------------------------------
  108991. * Copyright (c) Microsoft Corporation. All rights reserved.
  108992. * Licensed under the MIT License. See License.txt in the project root for license information.
  108993. *--------------------------------------------------------------------------------------------*/
  108994. define(__m[588/*vs/editor/standalone/browser/inspectTokens/inspectTokens*/], __M([0/*require*/,1/*exports*/,27/*vs/base/common/color*/,2/*vs/base/common/lifecycle*/,5/*vs/base/common/strings*/,12/*vs/editor/browser/editorExtensions*/,17/*vs/editor/common/modes*/,63/*vs/editor/common/modes/nullMode*/,71/*vs/editor/common/services/modeService*/,94/*vs/editor/standalone/common/standaloneThemeService*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,59/*vs/editor/common/standaloneStrings*/,327/*vs/css!vs/editor/standalone/browser/inspectTokens/inspectTokens*/]), function (require, exports, color_1, lifecycle_1, strings_1, editorExtensions_1, modes_1, nullMode_1, modeService_1, standaloneThemeService_1, colorRegistry_1, themeService_1, standaloneStrings_1) {
  108995. "use strict";
  108996. Object.defineProperty(exports, "__esModule", { value: true });
  108997. var InspectTokensController = /** @class */ (function (_super) {
  108998. __extends(InspectTokensController, _super);
  108999. function InspectTokensController(editor, standaloneColorService, modeService) {
  109000. var _this = _super.call(this) || this;
  109001. _this._editor = editor;
  109002. _this._modeService = modeService;
  109003. _this._widget = null;
  109004. _this._register(_this._editor.onDidChangeModel(function (e) { return _this.stop(); }));
  109005. _this._register(_this._editor.onDidChangeModelLanguage(function (e) { return _this.stop(); }));
  109006. _this._register(modes_1.TokenizationRegistry.onDidChange(function (e) { return _this.stop(); }));
  109007. return _this;
  109008. }
  109009. InspectTokensController.get = function (editor) {
  109010. return editor.getContribution(InspectTokensController.ID);
  109011. };
  109012. InspectTokensController.prototype.dispose = function () {
  109013. this.stop();
  109014. _super.prototype.dispose.call(this);
  109015. };
  109016. InspectTokensController.prototype.launch = function () {
  109017. if (this._widget) {
  109018. return;
  109019. }
  109020. if (!this._editor.hasModel()) {
  109021. return;
  109022. }
  109023. this._widget = new InspectTokensWidget(this._editor, this._modeService);
  109024. };
  109025. InspectTokensController.prototype.stop = function () {
  109026. if (this._widget) {
  109027. this._widget.dispose();
  109028. this._widget = null;
  109029. }
  109030. };
  109031. InspectTokensController.ID = 'editor.contrib.inspectTokens';
  109032. InspectTokensController = __decorate([
  109033. __param(1, standaloneThemeService_1.IStandaloneThemeService),
  109034. __param(2, modeService_1.IModeService)
  109035. ], InspectTokensController);
  109036. return InspectTokensController;
  109037. }(lifecycle_1.Disposable));
  109038. var InspectTokens = /** @class */ (function (_super) {
  109039. __extends(InspectTokens, _super);
  109040. function InspectTokens() {
  109041. return _super.call(this, {
  109042. id: 'editor.action.inspectTokens',
  109043. label: standaloneStrings_1.InspectTokensNLS.inspectTokensAction,
  109044. alias: 'Developer: Inspect Tokens',
  109045. precondition: undefined
  109046. }) || this;
  109047. }
  109048. InspectTokens.prototype.run = function (accessor, editor) {
  109049. var controller = InspectTokensController.get(editor);
  109050. if (controller) {
  109051. controller.launch();
  109052. }
  109053. };
  109054. return InspectTokens;
  109055. }(editorExtensions_1.EditorAction));
  109056. function renderTokenText(tokenText) {
  109057. var result = '';
  109058. for (var charIndex = 0, len = tokenText.length; charIndex < len; charIndex++) {
  109059. var charCode = tokenText.charCodeAt(charIndex);
  109060. switch (charCode) {
  109061. case 9 /* Tab */:
  109062. result += '&rarr;';
  109063. break;
  109064. case 32 /* Space */:
  109065. result += '&middot;';
  109066. break;
  109067. case 60 /* LessThan */:
  109068. result += '&lt;';
  109069. break;
  109070. case 62 /* GreaterThan */:
  109071. result += '&gt;';
  109072. break;
  109073. case 38 /* Ampersand */:
  109074. result += '&amp;';
  109075. break;
  109076. default:
  109077. result += String.fromCharCode(charCode);
  109078. }
  109079. }
  109080. return result;
  109081. }
  109082. function getSafeTokenizationSupport(languageIdentifier) {
  109083. var tokenizationSupport = modes_1.TokenizationRegistry.get(languageIdentifier.language);
  109084. if (tokenizationSupport) {
  109085. return tokenizationSupport;
  109086. }
  109087. return {
  109088. getInitialState: function () { return nullMode_1.NULL_STATE; },
  109089. tokenize: function (line, state, deltaOffset) { return nullMode_1.nullTokenize(languageIdentifier.language, line, state, deltaOffset); },
  109090. tokenize2: function (line, state, deltaOffset) { return nullMode_1.nullTokenize2(languageIdentifier.id, line, state, deltaOffset); }
  109091. };
  109092. }
  109093. var InspectTokensWidget = /** @class */ (function (_super) {
  109094. __extends(InspectTokensWidget, _super);
  109095. function InspectTokensWidget(editor, modeService) {
  109096. var _this = _super.call(this) || this;
  109097. // Editor.IContentWidget.allowEditorOverflow
  109098. _this.allowEditorOverflow = true;
  109099. _this._editor = editor;
  109100. _this._modeService = modeService;
  109101. _this._model = _this._editor.getModel();
  109102. _this._domNode = document.createElement('div');
  109103. _this._domNode.className = 'tokens-inspect-widget';
  109104. _this._tokenizationSupport = getSafeTokenizationSupport(_this._model.getLanguageIdentifier());
  109105. _this._compute(_this._editor.getPosition());
  109106. _this._register(_this._editor.onDidChangeCursorPosition(function (e) { return _this._compute(_this._editor.getPosition()); }));
  109107. _this._editor.addContentWidget(_this);
  109108. return _this;
  109109. }
  109110. InspectTokensWidget.prototype.dispose = function () {
  109111. this._editor.removeContentWidget(this);
  109112. _super.prototype.dispose.call(this);
  109113. };
  109114. InspectTokensWidget.prototype.getId = function () {
  109115. return InspectTokensWidget._ID;
  109116. };
  109117. InspectTokensWidget.prototype._compute = function (position) {
  109118. var data = this._getTokensAtLine(position.lineNumber);
  109119. var token1Index = 0;
  109120. for (var i = data.tokens1.length - 1; i >= 0; i--) {
  109121. var t = data.tokens1[i];
  109122. if (position.column - 1 >= t.offset) {
  109123. token1Index = i;
  109124. break;
  109125. }
  109126. }
  109127. var token2Index = 0;
  109128. for (var i = (data.tokens2.length >>> 1); i >= 0; i--) {
  109129. if (position.column - 1 >= data.tokens2[(i << 1)]) {
  109130. token2Index = i;
  109131. break;
  109132. }
  109133. }
  109134. var result = '';
  109135. var lineContent = this._model.getLineContent(position.lineNumber);
  109136. var tokenText = '';
  109137. if (token1Index < data.tokens1.length) {
  109138. var tokenStartIndex = data.tokens1[token1Index].offset;
  109139. var tokenEndIndex = token1Index + 1 < data.tokens1.length ? data.tokens1[token1Index + 1].offset : lineContent.length;
  109140. tokenText = lineContent.substring(tokenStartIndex, tokenEndIndex);
  109141. }
  109142. result += "<h2 class=\"tm-token\">" + renderTokenText(tokenText) + "<span class=\"tm-token-length\">(" + tokenText.length + " " + (tokenText.length === 1 ? 'char' : 'chars') + ")</span></h2>";
  109143. result += "<hr class=\"tokens-inspect-separator\" style=\"clear:both\"/>";
  109144. var metadata = this._decodeMetadata(data.tokens2[(token2Index << 1) + 1]);
  109145. result += "<table class=\"tm-metadata-table\"><tbody>";
  109146. result += "<tr><td class=\"tm-metadata-key\">language</td><td class=\"tm-metadata-value\">" + strings_1.escape(metadata.languageIdentifier.language) + "</td>";
  109147. result += "<tr><td class=\"tm-metadata-key\">token type</td><td class=\"tm-metadata-value\">" + this._tokenTypeToString(metadata.tokenType) + "</td>";
  109148. result += "<tr><td class=\"tm-metadata-key\">font style</td><td class=\"tm-metadata-value\">" + this._fontStyleToString(metadata.fontStyle) + "</td>";
  109149. result += "<tr><td class=\"tm-metadata-key\">foreground</td><td class=\"tm-metadata-value\">" + color_1.Color.Format.CSS.formatHex(metadata.foreground) + "</td>";
  109150. result += "<tr><td class=\"tm-metadata-key\">background</td><td class=\"tm-metadata-value\">" + color_1.Color.Format.CSS.formatHex(metadata.background) + "</td>";
  109151. result += "</tbody></table>";
  109152. result += "<hr class=\"tokens-inspect-separator\"/>";
  109153. if (token1Index < data.tokens1.length) {
  109154. result += "<span class=\"tm-token-type\">" + strings_1.escape(data.tokens1[token1Index].type) + "</span>";
  109155. }
  109156. this._domNode.innerHTML = result;
  109157. this._editor.layoutContentWidget(this);
  109158. };
  109159. InspectTokensWidget.prototype._decodeMetadata = function (metadata) {
  109160. var colorMap = modes_1.TokenizationRegistry.getColorMap();
  109161. var languageId = modes_1.TokenMetadata.getLanguageId(metadata);
  109162. var tokenType = modes_1.TokenMetadata.getTokenType(metadata);
  109163. var fontStyle = modes_1.TokenMetadata.getFontStyle(metadata);
  109164. var foreground = modes_1.TokenMetadata.getForeground(metadata);
  109165. var background = modes_1.TokenMetadata.getBackground(metadata);
  109166. return {
  109167. languageIdentifier: this._modeService.getLanguageIdentifier(languageId),
  109168. tokenType: tokenType,
  109169. fontStyle: fontStyle,
  109170. foreground: colorMap[foreground],
  109171. background: colorMap[background]
  109172. };
  109173. };
  109174. InspectTokensWidget.prototype._tokenTypeToString = function (tokenType) {
  109175. switch (tokenType) {
  109176. case 0 /* Other */: return 'Other';
  109177. case 1 /* Comment */: return 'Comment';
  109178. case 2 /* String */: return 'String';
  109179. case 4 /* RegEx */: return 'RegEx';
  109180. }
  109181. return '??';
  109182. };
  109183. InspectTokensWidget.prototype._fontStyleToString = function (fontStyle) {
  109184. var r = '';
  109185. if (fontStyle & 1 /* Italic */) {
  109186. r += 'italic ';
  109187. }
  109188. if (fontStyle & 2 /* Bold */) {
  109189. r += 'bold ';
  109190. }
  109191. if (fontStyle & 4 /* Underline */) {
  109192. r += 'underline ';
  109193. }
  109194. if (r.length === 0) {
  109195. r = '---';
  109196. }
  109197. return r;
  109198. };
  109199. InspectTokensWidget.prototype._getTokensAtLine = function (lineNumber) {
  109200. var stateBeforeLine = this._getStateBeforeLine(lineNumber);
  109201. var tokenizationResult1 = this._tokenizationSupport.tokenize(this._model.getLineContent(lineNumber), stateBeforeLine, 0);
  109202. var tokenizationResult2 = this._tokenizationSupport.tokenize2(this._model.getLineContent(lineNumber), stateBeforeLine, 0);
  109203. return {
  109204. startState: stateBeforeLine,
  109205. tokens1: tokenizationResult1.tokens,
  109206. tokens2: tokenizationResult2.tokens,
  109207. endState: tokenizationResult1.endState
  109208. };
  109209. };
  109210. InspectTokensWidget.prototype._getStateBeforeLine = function (lineNumber) {
  109211. var state = this._tokenizationSupport.getInitialState();
  109212. for (var i = 1; i < lineNumber; i++) {
  109213. var tokenizationResult = this._tokenizationSupport.tokenize(this._model.getLineContent(i), state, 0);
  109214. state = tokenizationResult.endState;
  109215. }
  109216. return state;
  109217. };
  109218. InspectTokensWidget.prototype.getDomNode = function () {
  109219. return this._domNode;
  109220. };
  109221. InspectTokensWidget.prototype.getPosition = function () {
  109222. return {
  109223. position: this._editor.getPosition(),
  109224. preference: [2 /* BELOW */, 1 /* ABOVE */]
  109225. };
  109226. };
  109227. InspectTokensWidget._ID = 'editor.contrib.inspectTokensWidget';
  109228. return InspectTokensWidget;
  109229. }(lifecycle_1.Disposable));
  109230. editorExtensions_1.registerEditorContribution(InspectTokensController.ID, InspectTokensController);
  109231. editorExtensions_1.registerEditorAction(InspectTokens);
  109232. themeService_1.registerThemingParticipant(function (theme, collector) {
  109233. var border = theme.getColor(colorRegistry_1.editorHoverBorder);
  109234. if (border) {
  109235. var borderWidth = theme.type === themeService_1.HIGH_CONTRAST ? 2 : 1;
  109236. collector.addRule(".monaco-editor .tokens-inspect-widget { border: " + borderWidth + "px solid " + border + "; }");
  109237. collector.addRule(".monaco-editor .tokens-inspect-widget .tokens-inspect-separator { background-color: " + border + "; }");
  109238. }
  109239. var background = theme.getColor(colorRegistry_1.editorHoverBackground);
  109240. if (background) {
  109241. collector.addRule(".monaco-editor .tokens-inspect-widget { background-color: " + background + "; }");
  109242. }
  109243. var foreground = theme.getColor(colorRegistry_1.editorHoverForeground);
  109244. if (foreground) {
  109245. collector.addRule(".monaco-editor .tokens-inspect-widget { color: " + foreground + "; }");
  109246. }
  109247. });
  109248. });
  109249. /*---------------------------------------------------------------------------------------------
  109250. * Copyright (c) Microsoft Corporation. All rights reserved.
  109251. * Licensed under the MIT License. See License.txt in the project root for license information.
  109252. *--------------------------------------------------------------------------------------------*/
  109253. define(__m[169/*vs/editor/standalone/browser/quickOpen/editorQuickOpen*/], __M([0/*require*/,1/*exports*/,12/*vs/editor/browser/editorExtensions*/,30/*vs/editor/common/model/textModel*/,546/*vs/editor/standalone/browser/quickOpen/quickOpenEditorWidget*/,14/*vs/platform/theme/common/themeService*/,328/*vs/css!vs/editor/standalone/browser/quickOpen/editorQuickOpen*/]), function (require, exports, editorExtensions_1, textModel_1, quickOpenEditorWidget_1, themeService_1) {
  109254. "use strict";
  109255. Object.defineProperty(exports, "__esModule", { value: true });
  109256. var QuickOpenController = /** @class */ (function () {
  109257. function QuickOpenController(editor, themeService) {
  109258. this.themeService = themeService;
  109259. this.widget = null;
  109260. this.rangeHighlightDecorationId = null;
  109261. this.lastKnownEditorSelection = null;
  109262. this.editor = editor;
  109263. }
  109264. QuickOpenController.get = function (editor) {
  109265. return editor.getContribution(QuickOpenController.ID);
  109266. };
  109267. QuickOpenController.prototype.dispose = function () {
  109268. // Dispose widget
  109269. if (this.widget) {
  109270. this.widget.destroy();
  109271. this.widget = null;
  109272. }
  109273. };
  109274. QuickOpenController.prototype.run = function (opts) {
  109275. var _this = this;
  109276. if (this.widget) {
  109277. this.widget.destroy();
  109278. this.widget = null;
  109279. }
  109280. // Create goto line widget
  109281. var onClose = function (canceled) {
  109282. // Clear Highlight Decorations if present
  109283. _this.clearDecorations();
  109284. // Restore selection if canceled
  109285. if (canceled && _this.lastKnownEditorSelection) {
  109286. _this.editor.setSelection(_this.lastKnownEditorSelection);
  109287. _this.editor.revealRangeInCenterIfOutsideViewport(_this.lastKnownEditorSelection, 0 /* Smooth */);
  109288. }
  109289. _this.lastKnownEditorSelection = null;
  109290. // Return focus to the editor if
  109291. // - focus is back on the <body> element because no other focusable element was clicked
  109292. // - a command was picked from the picker which indicates the editor should get focused
  109293. if (document.activeElement === document.body || !canceled) {
  109294. _this.editor.focus();
  109295. }
  109296. };
  109297. this.widget = new quickOpenEditorWidget_1.QuickOpenEditorWidget(this.editor, function () { return onClose(false); }, function () { return onClose(true); }, function (value) {
  109298. _this.widget.setInput(opts.getModel(value), opts.getAutoFocus(value));
  109299. }, {
  109300. inputAriaLabel: opts.inputAriaLabel
  109301. }, this.themeService);
  109302. // Remember selection to be able to restore on cancel
  109303. if (!this.lastKnownEditorSelection) {
  109304. this.lastKnownEditorSelection = this.editor.getSelection();
  109305. }
  109306. // Show
  109307. this.widget.show('');
  109308. };
  109309. QuickOpenController.prototype.decorateLine = function (range, editor) {
  109310. var oldDecorations = [];
  109311. if (this.rangeHighlightDecorationId) {
  109312. oldDecorations.push(this.rangeHighlightDecorationId);
  109313. this.rangeHighlightDecorationId = null;
  109314. }
  109315. var newDecorations = [
  109316. {
  109317. range: range,
  109318. options: QuickOpenController._RANGE_HIGHLIGHT_DECORATION
  109319. }
  109320. ];
  109321. var decorations = editor.deltaDecorations(oldDecorations, newDecorations);
  109322. this.rangeHighlightDecorationId = decorations[0];
  109323. };
  109324. QuickOpenController.prototype.clearDecorations = function () {
  109325. if (this.rangeHighlightDecorationId) {
  109326. this.editor.deltaDecorations([this.rangeHighlightDecorationId], []);
  109327. this.rangeHighlightDecorationId = null;
  109328. }
  109329. };
  109330. QuickOpenController.ID = 'editor.controller.quickOpenController';
  109331. QuickOpenController._RANGE_HIGHLIGHT_DECORATION = textModel_1.ModelDecorationOptions.register({
  109332. className: 'rangeHighlight',
  109333. isWholeLine: true
  109334. });
  109335. QuickOpenController = __decorate([
  109336. __param(1, themeService_1.IThemeService)
  109337. ], QuickOpenController);
  109338. return QuickOpenController;
  109339. }());
  109340. exports.QuickOpenController = QuickOpenController;
  109341. /**
  109342. * Base class for providing quick open in the editor.
  109343. */
  109344. var BaseEditorQuickOpenAction = /** @class */ (function (_super) {
  109345. __extends(BaseEditorQuickOpenAction, _super);
  109346. function BaseEditorQuickOpenAction(inputAriaLabel, opts) {
  109347. var _this = _super.call(this, opts) || this;
  109348. _this._inputAriaLabel = inputAriaLabel;
  109349. return _this;
  109350. }
  109351. BaseEditorQuickOpenAction.prototype.getController = function (editor) {
  109352. return QuickOpenController.get(editor);
  109353. };
  109354. BaseEditorQuickOpenAction.prototype._show = function (controller, opts) {
  109355. controller.run({
  109356. inputAriaLabel: this._inputAriaLabel,
  109357. getModel: function (value) { return opts.getModel(value); },
  109358. getAutoFocus: function (searchValue) { return opts.getAutoFocus(searchValue); }
  109359. });
  109360. };
  109361. return BaseEditorQuickOpenAction;
  109362. }(editorExtensions_1.EditorAction));
  109363. exports.BaseEditorQuickOpenAction = BaseEditorQuickOpenAction;
  109364. editorExtensions_1.registerEditorContribution(QuickOpenController.ID, QuickOpenController);
  109365. });
  109366. /*---------------------------------------------------------------------------------------------
  109367. * Copyright (c) Microsoft Corporation. All rights reserved.
  109368. * Licensed under the MIT License. See License.txt in the project root for license information.
  109369. *--------------------------------------------------------------------------------------------*/
  109370. define(__m[589/*vs/editor/standalone/browser/quickOpen/gotoLine*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,155/*vs/base/parts/quickopen/browser/quickOpenModel*/,108/*vs/editor/browser/editorBrowser*/,12/*vs/editor/browser/editorExtensions*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,23/*vs/editor/common/editorContextKeys*/,169/*vs/editor/standalone/browser/quickOpen/editorQuickOpen*/,59/*vs/editor/common/standaloneStrings*/,329/*vs/css!vs/editor/standalone/browser/quickOpen/gotoLine*/]), function (require, exports, strings, quickOpenModel_1, editorBrowser_1, editorExtensions_1, position_1, range_1, editorContextKeys_1, editorQuickOpen_1, standaloneStrings_1) {
  109371. "use strict";
  109372. Object.defineProperty(exports, "__esModule", { value: true });
  109373. var GotoLineEntry = /** @class */ (function (_super) {
  109374. __extends(GotoLineEntry, _super);
  109375. function GotoLineEntry(line, editor, decorator) {
  109376. var _this = _super.call(this) || this;
  109377. _this.editor = editor;
  109378. _this.decorator = decorator;
  109379. _this.parseResult = _this.parseInput(line);
  109380. return _this;
  109381. }
  109382. GotoLineEntry.prototype.parseInput = function (line) {
  109383. var numbers = line.split(',').map(function (part) { return parseInt(part, 10); }).filter(function (part) { return !isNaN(part); });
  109384. var position;
  109385. if (numbers.length === 0) {
  109386. position = new position_1.Position(-1, -1);
  109387. }
  109388. else if (numbers.length === 1) {
  109389. position = new position_1.Position(numbers[0], 1);
  109390. }
  109391. else {
  109392. position = new position_1.Position(numbers[0], numbers[1]);
  109393. }
  109394. var model;
  109395. if (editorBrowser_1.isCodeEditor(this.editor)) {
  109396. model = this.editor.getModel();
  109397. }
  109398. else {
  109399. var diffModel = this.editor.getModel();
  109400. model = diffModel ? diffModel.modified : null;
  109401. }
  109402. var isValid = model ? model.validatePosition(position).equals(position) : false;
  109403. var label;
  109404. if (isValid) {
  109405. if (position.column && position.column > 1) {
  109406. label = strings.format(standaloneStrings_1.GoToLineNLS.gotoLineLabelValidLineAndColumn, position.lineNumber, position.column);
  109407. }
  109408. else {
  109409. label = strings.format(standaloneStrings_1.GoToLineNLS.gotoLineLabelValidLine, position.lineNumber);
  109410. }
  109411. }
  109412. else if (position.lineNumber < 1 || position.lineNumber > (model ? model.getLineCount() : 0)) {
  109413. label = strings.format(standaloneStrings_1.GoToLineNLS.gotoLineLabelEmptyWithLineLimit, model ? model.getLineCount() : 0);
  109414. }
  109415. else {
  109416. label = strings.format(standaloneStrings_1.GoToLineNLS.gotoLineLabelEmptyWithLineAndColumnLimit, model ? model.getLineMaxColumn(position.lineNumber) : 0);
  109417. }
  109418. return {
  109419. position: position,
  109420. isValid: isValid,
  109421. label: label
  109422. };
  109423. };
  109424. GotoLineEntry.prototype.getLabel = function () {
  109425. return this.parseResult.label;
  109426. };
  109427. GotoLineEntry.prototype.getAriaLabel = function () {
  109428. var position = this.editor.getPosition();
  109429. var currentLine = position ? position.lineNumber : 0;
  109430. return strings.format(standaloneStrings_1.GoToLineNLS.gotoLineAriaLabel, currentLine, this.parseResult.label);
  109431. };
  109432. GotoLineEntry.prototype.run = function (mode, _context) {
  109433. if (mode === 1 /* OPEN */) {
  109434. return this.runOpen();
  109435. }
  109436. return this.runPreview();
  109437. };
  109438. GotoLineEntry.prototype.runOpen = function () {
  109439. // No-op if range is not valid
  109440. if (!this.parseResult.isValid) {
  109441. return false;
  109442. }
  109443. // Apply selection and focus
  109444. var range = this.toSelection();
  109445. this.editor.setSelection(range);
  109446. this.editor.revealRangeInCenter(range, 0 /* Smooth */);
  109447. this.editor.focus();
  109448. return true;
  109449. };
  109450. GotoLineEntry.prototype.runPreview = function () {
  109451. // No-op if range is not valid
  109452. if (!this.parseResult.isValid) {
  109453. this.decorator.clearDecorations();
  109454. return false;
  109455. }
  109456. // Select Line Position
  109457. var range = this.toSelection();
  109458. this.editor.revealRangeInCenter(range, 0 /* Smooth */);
  109459. // Decorate if possible
  109460. this.decorator.decorateLine(range, this.editor);
  109461. return false;
  109462. };
  109463. GotoLineEntry.prototype.toSelection = function () {
  109464. return new range_1.Range(this.parseResult.position.lineNumber, this.parseResult.position.column, this.parseResult.position.lineNumber, this.parseResult.position.column);
  109465. };
  109466. return GotoLineEntry;
  109467. }(quickOpenModel_1.QuickOpenEntry));
  109468. exports.GotoLineEntry = GotoLineEntry;
  109469. var GotoLineAction = /** @class */ (function (_super) {
  109470. __extends(GotoLineAction, _super);
  109471. function GotoLineAction() {
  109472. return _super.call(this, standaloneStrings_1.GoToLineNLS.gotoLineActionInput, {
  109473. id: 'editor.action.gotoLine',
  109474. label: standaloneStrings_1.GoToLineNLS.gotoLineActionLabel,
  109475. alias: 'Go to Line...',
  109476. precondition: undefined,
  109477. kbOpts: {
  109478. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  109479. primary: 2048 /* CtrlCmd */ | 37 /* KEY_G */,
  109480. mac: { primary: 256 /* WinCtrl */ | 37 /* KEY_G */ },
  109481. weight: 100 /* EditorContrib */
  109482. }
  109483. }) || this;
  109484. }
  109485. GotoLineAction.prototype.run = function (accessor, editor) {
  109486. var _this = this;
  109487. this._show(this.getController(editor), {
  109488. getModel: function (value) {
  109489. return new quickOpenModel_1.QuickOpenModel([new GotoLineEntry(value, editor, _this.getController(editor))]);
  109490. },
  109491. getAutoFocus: function (searchValue) {
  109492. return {
  109493. autoFocusFirstEntry: searchValue.length > 0
  109494. };
  109495. }
  109496. });
  109497. };
  109498. return GotoLineAction;
  109499. }(editorQuickOpen_1.BaseEditorQuickOpenAction));
  109500. exports.GotoLineAction = GotoLineAction;
  109501. editorExtensions_1.registerEditorAction(GotoLineAction);
  109502. });
  109503. /*---------------------------------------------------------------------------------------------
  109504. * Copyright (c) Microsoft Corporation. All rights reserved.
  109505. * Licensed under the MIT License. See License.txt in the project root for license information.
  109506. *--------------------------------------------------------------------------------------------*/
  109507. define(__m[590/*vs/editor/standalone/browser/quickOpen/quickCommand*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,24/*vs/base/browser/browser*/,10/*vs/base/common/errors*/,61/*vs/base/common/filters*/,155/*vs/base/parts/quickopen/browser/quickOpenModel*/,12/*vs/editor/browser/editorExtensions*/,23/*vs/editor/common/editorContextKeys*/,169/*vs/editor/standalone/browser/quickOpen/editorQuickOpen*/,34/*vs/platform/keybinding/common/keybinding*/,59/*vs/editor/common/standaloneStrings*/]), function (require, exports, strings, browser, errors_1, filters_1, quickOpenModel_1, editorExtensions_1, editorContextKeys_1, editorQuickOpen_1, keybinding_1, standaloneStrings_1) {
  109508. "use strict";
  109509. Object.defineProperty(exports, "__esModule", { value: true });
  109510. var EditorActionCommandEntry = /** @class */ (function (_super) {
  109511. __extends(EditorActionCommandEntry, _super);
  109512. function EditorActionCommandEntry(key, keyAriaLabel, highlights, action, editor) {
  109513. var _this = _super.call(this) || this;
  109514. _this.key = key;
  109515. _this.keyAriaLabel = keyAriaLabel;
  109516. _this.setHighlights(highlights);
  109517. _this.action = action;
  109518. _this.editor = editor;
  109519. return _this;
  109520. }
  109521. EditorActionCommandEntry.prototype.getLabel = function () {
  109522. return this.action.label;
  109523. };
  109524. EditorActionCommandEntry.prototype.getAriaLabel = function () {
  109525. if (this.keyAriaLabel) {
  109526. return strings.format(standaloneStrings_1.QuickCommandNLS.ariaLabelEntryWithKey, this.getLabel(), this.keyAriaLabel);
  109527. }
  109528. return strings.format(standaloneStrings_1.QuickCommandNLS.ariaLabelEntry, this.getLabel());
  109529. };
  109530. EditorActionCommandEntry.prototype.getGroupLabel = function () {
  109531. return this.key;
  109532. };
  109533. EditorActionCommandEntry.prototype.run = function (mode, context) {
  109534. var _this = this;
  109535. if (mode === 1 /* OPEN */) {
  109536. // Use a timeout to give the quick open widget a chance to close itself first
  109537. setTimeout(function () {
  109538. // Some actions are enabled only when editor has focus
  109539. _this.editor.focus();
  109540. try {
  109541. var promise = _this.action.run() || Promise.resolve();
  109542. promise.then(undefined, errors_1.onUnexpectedError);
  109543. }
  109544. catch (error) {
  109545. errors_1.onUnexpectedError(error);
  109546. }
  109547. }, 50);
  109548. return true;
  109549. }
  109550. return false;
  109551. };
  109552. return EditorActionCommandEntry;
  109553. }(quickOpenModel_1.QuickOpenEntryGroup));
  109554. exports.EditorActionCommandEntry = EditorActionCommandEntry;
  109555. var QuickCommandAction = /** @class */ (function (_super) {
  109556. __extends(QuickCommandAction, _super);
  109557. function QuickCommandAction() {
  109558. return _super.call(this, standaloneStrings_1.QuickCommandNLS.quickCommandActionInput, {
  109559. id: 'editor.action.quickCommand',
  109560. label: standaloneStrings_1.QuickCommandNLS.quickCommandActionLabel,
  109561. alias: 'Command Palette',
  109562. precondition: undefined,
  109563. kbOpts: {
  109564. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  109565. primary: (browser.isIE ? 512 /* Alt */ | 59 /* F1 */ : 59 /* F1 */),
  109566. weight: 100 /* EditorContrib */
  109567. },
  109568. contextMenuOpts: {
  109569. group: 'z_commands',
  109570. order: 1
  109571. }
  109572. }) || this;
  109573. }
  109574. QuickCommandAction.prototype.run = function (accessor, editor) {
  109575. var _this = this;
  109576. var keybindingService = accessor.get(keybinding_1.IKeybindingService);
  109577. this._show(this.getController(editor), {
  109578. getModel: function (value) {
  109579. return new quickOpenModel_1.QuickOpenModel(_this._editorActionsToEntries(keybindingService, editor, value));
  109580. },
  109581. getAutoFocus: function (searchValue) {
  109582. return {
  109583. autoFocusFirstEntry: true,
  109584. autoFocusPrefixMatch: searchValue
  109585. };
  109586. }
  109587. });
  109588. };
  109589. QuickCommandAction.prototype._sort = function (elementA, elementB) {
  109590. var elementAName = (elementA.getLabel() || '').toLowerCase();
  109591. var elementBName = (elementB.getLabel() || '').toLowerCase();
  109592. return elementAName.localeCompare(elementBName);
  109593. };
  109594. QuickCommandAction.prototype._editorActionsToEntries = function (keybindingService, editor, searchValue) {
  109595. var actions = editor.getSupportedActions();
  109596. var entries = [];
  109597. for (var _i = 0, actions_1 = actions; _i < actions_1.length; _i++) {
  109598. var action = actions_1[_i];
  109599. var keybinding = keybindingService.lookupKeybinding(action.id);
  109600. if (action.label) {
  109601. var highlights = filters_1.matchesFuzzy(searchValue, action.label);
  109602. if (highlights) {
  109603. entries.push(new EditorActionCommandEntry(keybinding ? keybinding.getLabel() || '' : '', keybinding ? keybinding.getAriaLabel() || '' : '', highlights, action, editor));
  109604. }
  109605. }
  109606. }
  109607. // Sort by name
  109608. entries = entries.sort(this._sort);
  109609. return entries;
  109610. };
  109611. return QuickCommandAction;
  109612. }(editorQuickOpen_1.BaseEditorQuickOpenAction));
  109613. exports.QuickCommandAction = QuickCommandAction;
  109614. editorExtensions_1.registerEditorAction(QuickCommandAction);
  109615. });
  109616. /*---------------------------------------------------------------------------------------------
  109617. * Copyright (c) Microsoft Corporation. All rights reserved.
  109618. * Licensed under the MIT License. See License.txt in the project root for license information.
  109619. *--------------------------------------------------------------------------------------------*/
  109620. define(__m[591/*vs/editor/standalone/browser/quickOpen/quickOutline*/], __M([0/*require*/,1/*exports*/,26/*vs/base/common/cancellation*/,61/*vs/base/common/filters*/,5/*vs/base/common/strings*/,155/*vs/base/parts/quickopen/browser/quickOpenModel*/,12/*vs/editor/browser/editorExtensions*/,3/*vs/editor/common/core/range*/,23/*vs/editor/common/editorContextKeys*/,17/*vs/editor/common/modes*/,496/*vs/editor/contrib/quickOpen/quickOpen*/,169/*vs/editor/standalone/browser/quickOpen/editorQuickOpen*/,59/*vs/editor/common/standaloneStrings*/,330/*vs/css!vs/editor/standalone/browser/quickOpen/quickOutline*/,183/*vs/base/browser/ui/codiconLabel/codiconLabel*/,231/*vs/editor/contrib/documentSymbols/outlineTree*/]), function (require, exports, cancellation_1, filters_1, strings, quickOpenModel_1, editorExtensions_1, range_1, editorContextKeys_1, modes_1, quickOpen_1, editorQuickOpen_1, standaloneStrings_1) {
  109621. "use strict";
  109622. Object.defineProperty(exports, "__esModule", { value: true });
  109623. var SCOPE_PREFIX = ':';
  109624. var SymbolEntry = /** @class */ (function (_super) {
  109625. __extends(SymbolEntry, _super);
  109626. function SymbolEntry(name, type, description, range, highlights, editor, decorator) {
  109627. var _this = _super.call(this) || this;
  109628. _this.name = name;
  109629. _this.type = type;
  109630. _this.description = description;
  109631. _this.range = range;
  109632. _this.setHighlights(highlights);
  109633. _this.editor = editor;
  109634. _this.decorator = decorator;
  109635. return _this;
  109636. }
  109637. SymbolEntry.prototype.getLabel = function () {
  109638. return this.name;
  109639. };
  109640. SymbolEntry.prototype.getAriaLabel = function () {
  109641. return strings.format(standaloneStrings_1.QuickOutlineNLS.entryAriaLabel, this.name);
  109642. };
  109643. SymbolEntry.prototype.getIcon = function () {
  109644. return this.type;
  109645. };
  109646. SymbolEntry.prototype.getDescription = function () {
  109647. return this.description;
  109648. };
  109649. SymbolEntry.prototype.getType = function () {
  109650. return this.type;
  109651. };
  109652. SymbolEntry.prototype.getRange = function () {
  109653. return this.range;
  109654. };
  109655. SymbolEntry.prototype.run = function (mode, context) {
  109656. if (mode === 1 /* OPEN */) {
  109657. return this.runOpen(context);
  109658. }
  109659. return this.runPreview();
  109660. };
  109661. SymbolEntry.prototype.runOpen = function (_context) {
  109662. // Apply selection and focus
  109663. var range = this.toSelection();
  109664. this.editor.setSelection(range);
  109665. this.editor.revealRangeInCenter(range, 0 /* Smooth */);
  109666. this.editor.focus();
  109667. return true;
  109668. };
  109669. SymbolEntry.prototype.runPreview = function () {
  109670. // Select Outline Position
  109671. var range = this.toSelection();
  109672. this.editor.revealRangeInCenter(range, 0 /* Smooth */);
  109673. // Decorate if possible
  109674. this.decorator.decorateLine(this.range, this.editor);
  109675. return false;
  109676. };
  109677. SymbolEntry.prototype.toSelection = function () {
  109678. return new range_1.Range(this.range.startLineNumber, this.range.startColumn || 1, this.range.startLineNumber, this.range.startColumn || 1);
  109679. };
  109680. return SymbolEntry;
  109681. }(quickOpenModel_1.QuickOpenEntryGroup));
  109682. exports.SymbolEntry = SymbolEntry;
  109683. var QuickOutlineAction = /** @class */ (function (_super) {
  109684. __extends(QuickOutlineAction, _super);
  109685. function QuickOutlineAction() {
  109686. return _super.call(this, standaloneStrings_1.QuickOutlineNLS.quickOutlineActionInput, {
  109687. id: 'editor.action.quickOutline',
  109688. label: standaloneStrings_1.QuickOutlineNLS.quickOutlineActionLabel,
  109689. alias: 'Go to Symbol...',
  109690. precondition: editorContextKeys_1.EditorContextKeys.hasDocumentSymbolProvider,
  109691. kbOpts: {
  109692. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  109693. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 45 /* KEY_O */,
  109694. weight: 100 /* EditorContrib */
  109695. },
  109696. contextMenuOpts: {
  109697. group: 'navigation',
  109698. order: 3
  109699. }
  109700. }) || this;
  109701. }
  109702. QuickOutlineAction.prototype.run = function (accessor, editor) {
  109703. var _this = this;
  109704. if (!editor.hasModel()) {
  109705. return undefined;
  109706. }
  109707. var model = editor.getModel();
  109708. if (!modes_1.DocumentSymbolProviderRegistry.has(model)) {
  109709. return undefined;
  109710. }
  109711. // Resolve outline
  109712. return quickOpen_1.getDocumentSymbols(model, true, cancellation_1.CancellationToken.None).then(function (result) {
  109713. if (result.length === 0) {
  109714. return;
  109715. }
  109716. _this._run(editor, result);
  109717. });
  109718. };
  109719. QuickOutlineAction.prototype._run = function (editor, result) {
  109720. var _this = this;
  109721. this._show(this.getController(editor), {
  109722. getModel: function (value) {
  109723. return new quickOpenModel_1.QuickOpenModel(_this.toQuickOpenEntries(editor, result, value));
  109724. },
  109725. getAutoFocus: function (searchValue) {
  109726. // Remove any type pattern (:) from search value as needed
  109727. if (searchValue.indexOf(SCOPE_PREFIX) === 0) {
  109728. searchValue = searchValue.substr(SCOPE_PREFIX.length);
  109729. }
  109730. return {
  109731. autoFocusPrefixMatch: searchValue,
  109732. autoFocusFirstEntry: !!searchValue
  109733. };
  109734. }
  109735. });
  109736. };
  109737. QuickOutlineAction.prototype.symbolEntry = function (name, type, description, range, highlights, editor, decorator) {
  109738. return new SymbolEntry(name, type, description, range_1.Range.lift(range), highlights, editor, decorator);
  109739. };
  109740. QuickOutlineAction.prototype.toQuickOpenEntries = function (editor, flattened, searchValue) {
  109741. var controller = this.getController(editor);
  109742. var results = [];
  109743. // Convert to Entries
  109744. var normalizedSearchValue = searchValue;
  109745. if (searchValue.indexOf(SCOPE_PREFIX) === 0) {
  109746. normalizedSearchValue = normalizedSearchValue.substr(SCOPE_PREFIX.length);
  109747. }
  109748. for (var _i = 0, flattened_1 = flattened; _i < flattened_1.length; _i++) {
  109749. var element = flattened_1[_i];
  109750. var label = strings.trim(element.name);
  109751. // Check for meatch
  109752. var highlights = filters_1.matchesFuzzy(normalizedSearchValue, label);
  109753. if (highlights) {
  109754. // Show parent scope as description
  109755. var description = undefined;
  109756. if (element.containerName) {
  109757. description = element.containerName;
  109758. }
  109759. // Add
  109760. results.push(this.symbolEntry(label, modes_1.SymbolKinds.toCssClassName(element.kind), description, element.range, highlights, editor, controller));
  109761. }
  109762. }
  109763. // Sort properly if actually searching
  109764. if (searchValue) {
  109765. if (searchValue.indexOf(SCOPE_PREFIX) === 0) {
  109766. results = results.sort(this.sortScoped.bind(this, searchValue.toLowerCase()));
  109767. }
  109768. else {
  109769. results = results.sort(this.sortNormal.bind(this, searchValue.toLowerCase()));
  109770. }
  109771. }
  109772. // Mark all type groups
  109773. if (results.length > 0 && searchValue.indexOf(SCOPE_PREFIX) === 0) {
  109774. var currentType = null;
  109775. var currentResult = null;
  109776. var typeCounter = 0;
  109777. for (var i = 0; i < results.length; i++) {
  109778. var result = results[i];
  109779. // Found new type
  109780. if (currentType !== result.getType()) {
  109781. // Update previous result with count
  109782. if (currentResult) {
  109783. currentResult.setGroupLabel(this.typeToLabel(currentType || '', typeCounter));
  109784. }
  109785. currentType = result.getType();
  109786. currentResult = result;
  109787. typeCounter = 1;
  109788. result.setShowBorder(i > 0);
  109789. }
  109790. // Existing type, keep counting
  109791. else {
  109792. typeCounter++;
  109793. }
  109794. }
  109795. // Update previous result with count
  109796. if (currentResult) {
  109797. currentResult.setGroupLabel(this.typeToLabel(currentType || '', typeCounter));
  109798. }
  109799. }
  109800. // Mark first entry as outline
  109801. else if (results.length > 0) {
  109802. results[0].setGroupLabel(strings.format(standaloneStrings_1.QuickOutlineNLS._symbols_, results.length));
  109803. }
  109804. return results;
  109805. };
  109806. QuickOutlineAction.prototype.typeToLabel = function (type, count) {
  109807. switch (type) {
  109808. case 'module': return strings.format(standaloneStrings_1.QuickOutlineNLS._modules_, count);
  109809. case 'class': return strings.format(standaloneStrings_1.QuickOutlineNLS._class_, count);
  109810. case 'interface': return strings.format(standaloneStrings_1.QuickOutlineNLS._interface_, count);
  109811. case 'method': return strings.format(standaloneStrings_1.QuickOutlineNLS._method_, count);
  109812. case 'function': return strings.format(standaloneStrings_1.QuickOutlineNLS._function_, count);
  109813. case 'property': return strings.format(standaloneStrings_1.QuickOutlineNLS._property_, count);
  109814. case 'variable': return strings.format(standaloneStrings_1.QuickOutlineNLS._variable_, count);
  109815. case 'var': return strings.format(standaloneStrings_1.QuickOutlineNLS._variable2_, count);
  109816. case 'constructor': return strings.format(standaloneStrings_1.QuickOutlineNLS._constructor_, count);
  109817. case 'call': return strings.format(standaloneStrings_1.QuickOutlineNLS._call_, count);
  109818. }
  109819. return type;
  109820. };
  109821. QuickOutlineAction.prototype.sortNormal = function (searchValue, elementA, elementB) {
  109822. var elementAName = elementA.getLabel().toLowerCase();
  109823. var elementBName = elementB.getLabel().toLowerCase();
  109824. // Compare by name
  109825. var r = elementAName.localeCompare(elementBName);
  109826. if (r !== 0) {
  109827. return r;
  109828. }
  109829. // If name identical sort by range instead
  109830. var elementARange = elementA.getRange();
  109831. var elementBRange = elementB.getRange();
  109832. return elementARange.startLineNumber - elementBRange.startLineNumber;
  109833. };
  109834. QuickOutlineAction.prototype.sortScoped = function (searchValue, elementA, elementB) {
  109835. // Remove scope char
  109836. searchValue = searchValue.substr(SCOPE_PREFIX.length);
  109837. // Sort by type first if scoped search
  109838. var elementAType = elementA.getType();
  109839. var elementBType = elementB.getType();
  109840. var r = elementAType.localeCompare(elementBType);
  109841. if (r !== 0) {
  109842. return r;
  109843. }
  109844. // Special sort when searching in scoped mode
  109845. if (searchValue) {
  109846. var elementAName = elementA.getLabel().toLowerCase();
  109847. var elementBName = elementB.getLabel().toLowerCase();
  109848. // Compare by name
  109849. var r_1 = elementAName.localeCompare(elementBName);
  109850. if (r_1 !== 0) {
  109851. return r_1;
  109852. }
  109853. }
  109854. // Default to sort by range
  109855. var elementARange = elementA.getRange();
  109856. var elementBRange = elementB.getRange();
  109857. return elementARange.startLineNumber - elementBRange.startLineNumber;
  109858. };
  109859. return QuickOutlineAction;
  109860. }(editorQuickOpen_1.BaseEditorQuickOpenAction));
  109861. exports.QuickOutlineAction = QuickOutlineAction;
  109862. editorExtensions_1.registerEditorAction(QuickOutlineAction);
  109863. });
  109864. /*---------------------------------------------------------------------------------------------
  109865. * Copyright (c) Microsoft Corporation. All rights reserved.
  109866. * Licensed under the MIT License. See License.txt in the project root for license information.
  109867. *--------------------------------------------------------------------------------------------*/
  109868. define(__m[592/*vs/editor/standalone/browser/standaloneCodeServiceImpl*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,46/*vs/base/common/network*/,548/*vs/editor/browser/services/codeEditorServiceImpl*/]), function (require, exports, dom_1, network_1, codeEditorServiceImpl_1) {
  109869. "use strict";
  109870. Object.defineProperty(exports, "__esModule", { value: true });
  109871. var StandaloneCodeEditorServiceImpl = /** @class */ (function (_super) {
  109872. __extends(StandaloneCodeEditorServiceImpl, _super);
  109873. function StandaloneCodeEditorServiceImpl() {
  109874. return _super !== null && _super.apply(this, arguments) || this;
  109875. }
  109876. StandaloneCodeEditorServiceImpl.prototype.getActiveCodeEditor = function () {
  109877. return null; // not supported in the standalone case
  109878. };
  109879. StandaloneCodeEditorServiceImpl.prototype.openCodeEditor = function (input, source, sideBySide) {
  109880. if (!source) {
  109881. return Promise.resolve(null);
  109882. }
  109883. return Promise.resolve(this.doOpenEditor(source, input));
  109884. };
  109885. StandaloneCodeEditorServiceImpl.prototype.doOpenEditor = function (editor, input) {
  109886. var model = this.findModel(editor, input.resource);
  109887. if (!model) {
  109888. if (input.resource) {
  109889. var schema = input.resource.scheme;
  109890. if (schema === network_1.Schemas.http || schema === network_1.Schemas.https) {
  109891. // This is a fully qualified http or https URL
  109892. dom_1.windowOpenNoOpener(input.resource.toString());
  109893. return editor;
  109894. }
  109895. }
  109896. return null;
  109897. }
  109898. var selection = (input.options ? input.options.selection : null);
  109899. if (selection) {
  109900. if (typeof selection.endLineNumber === 'number' && typeof selection.endColumn === 'number') {
  109901. editor.setSelection(selection);
  109902. editor.revealRangeInCenter(selection, 1 /* Immediate */);
  109903. }
  109904. else {
  109905. var pos = {
  109906. lineNumber: selection.startLineNumber,
  109907. column: selection.startColumn
  109908. };
  109909. editor.setPosition(pos);
  109910. editor.revealPositionInCenter(pos, 1 /* Immediate */);
  109911. }
  109912. }
  109913. return editor;
  109914. };
  109915. StandaloneCodeEditorServiceImpl.prototype.findModel = function (editor, resource) {
  109916. var model = editor.getModel();
  109917. if (model && model.uri.toString() !== resource.toString()) {
  109918. return null;
  109919. }
  109920. return model;
  109921. };
  109922. return StandaloneCodeEditorServiceImpl;
  109923. }(codeEditorServiceImpl_1.CodeEditorServiceImpl));
  109924. exports.StandaloneCodeEditorServiceImpl = StandaloneCodeEditorServiceImpl;
  109925. });
  109926. /*---------------------------------------------------------------------------------------------
  109927. * Copyright (c) Microsoft Corporation. All rights reserved.
  109928. * Licensed under the MIT License. See License.txt in the project root for license information.
  109929. *--------------------------------------------------------------------------------------------*/
  109930. define(__m[593/*vs/editor/standalone/common/themes*/], __M([0/*require*/,1/*exports*/,44/*vs/editor/common/view/editorColorRegistry*/,20/*vs/platform/theme/common/colorRegistry*/]), function (require, exports, editorColorRegistry_1, colorRegistry_1) {
  109931. "use strict";
  109932. var _a, _b, _c;
  109933. Object.defineProperty(exports, "__esModule", { value: true });
  109934. /* -------------------------------- Begin vs theme -------------------------------- */
  109935. exports.vs = {
  109936. base: 'vs',
  109937. inherit: false,
  109938. rules: [
  109939. { token: '', foreground: '000000', background: 'fffffe' },
  109940. { token: 'invalid', foreground: 'cd3131' },
  109941. { token: 'emphasis', fontStyle: 'italic' },
  109942. { token: 'strong', fontStyle: 'bold' },
  109943. { token: 'variable', foreground: '001188' },
  109944. { token: 'variable.predefined', foreground: '4864AA' },
  109945. { token: 'constant', foreground: 'dd0000' },
  109946. { token: 'comment', foreground: '008000' },
  109947. { token: 'number', foreground: '098658' },
  109948. { token: 'number.hex', foreground: '3030c0' },
  109949. { token: 'regexp', foreground: '800000' },
  109950. { token: 'annotation', foreground: '808080' },
  109951. { token: 'type', foreground: '008080' },
  109952. { token: 'delimiter', foreground: '000000' },
  109953. { token: 'delimiter.html', foreground: '383838' },
  109954. { token: 'delimiter.xml', foreground: '0000FF' },
  109955. { token: 'tag', foreground: '800000' },
  109956. { token: 'tag.id.pug', foreground: '4F76AC' },
  109957. { token: 'tag.class.pug', foreground: '4F76AC' },
  109958. { token: 'meta.scss', foreground: '800000' },
  109959. { token: 'metatag', foreground: 'e00000' },
  109960. { token: 'metatag.content.html', foreground: 'FF0000' },
  109961. { token: 'metatag.html', foreground: '808080' },
  109962. { token: 'metatag.xml', foreground: '808080' },
  109963. { token: 'metatag.php', fontStyle: 'bold' },
  109964. { token: 'key', foreground: '863B00' },
  109965. { token: 'string.key.json', foreground: 'A31515' },
  109966. { token: 'string.value.json', foreground: '0451A5' },
  109967. { token: 'attribute.name', foreground: 'FF0000' },
  109968. { token: 'attribute.value', foreground: '0451A5' },
  109969. { token: 'attribute.value.number', foreground: '098658' },
  109970. { token: 'attribute.value.unit', foreground: '098658' },
  109971. { token: 'attribute.value.html', foreground: '0000FF' },
  109972. { token: 'attribute.value.xml', foreground: '0000FF' },
  109973. { token: 'string', foreground: 'A31515' },
  109974. { token: 'string.html', foreground: '0000FF' },
  109975. { token: 'string.sql', foreground: 'FF0000' },
  109976. { token: 'string.yaml', foreground: '0451A5' },
  109977. { token: 'keyword', foreground: '0000FF' },
  109978. { token: 'keyword.json', foreground: '0451A5' },
  109979. { token: 'keyword.flow', foreground: 'AF00DB' },
  109980. { token: 'keyword.flow.scss', foreground: '0000FF' },
  109981. { token: 'operator.scss', foreground: '666666' },
  109982. { token: 'operator.sql', foreground: '778899' },
  109983. { token: 'operator.swift', foreground: '666666' },
  109984. { token: 'predefined.sql', foreground: 'FF00FF' },
  109985. ],
  109986. colors: (_a = {},
  109987. _a[colorRegistry_1.editorBackground] = '#FFFFFE',
  109988. _a[colorRegistry_1.editorForeground] = '#000000',
  109989. _a[colorRegistry_1.editorInactiveSelection] = '#E5EBF1',
  109990. _a[editorColorRegistry_1.editorIndentGuides] = '#D3D3D3',
  109991. _a[editorColorRegistry_1.editorActiveIndentGuides] = '#939393',
  109992. _a[colorRegistry_1.editorSelectionHighlight] = '#ADD6FF4D',
  109993. _a)
  109994. };
  109995. /* -------------------------------- End vs theme -------------------------------- */
  109996. /* -------------------------------- Begin vs-dark theme -------------------------------- */
  109997. exports.vs_dark = {
  109998. base: 'vs-dark',
  109999. inherit: false,
  110000. rules: [
  110001. { token: '', foreground: 'D4D4D4', background: '1E1E1E' },
  110002. { token: 'invalid', foreground: 'f44747' },
  110003. { token: 'emphasis', fontStyle: 'italic' },
  110004. { token: 'strong', fontStyle: 'bold' },
  110005. { token: 'variable', foreground: '74B0DF' },
  110006. { token: 'variable.predefined', foreground: '4864AA' },
  110007. { token: 'variable.parameter', foreground: '9CDCFE' },
  110008. { token: 'constant', foreground: '569CD6' },
  110009. { token: 'comment', foreground: '608B4E' },
  110010. { token: 'number', foreground: 'B5CEA8' },
  110011. { token: 'number.hex', foreground: '5BB498' },
  110012. { token: 'regexp', foreground: 'B46695' },
  110013. { token: 'annotation', foreground: 'cc6666' },
  110014. { token: 'type', foreground: '3DC9B0' },
  110015. { token: 'delimiter', foreground: 'DCDCDC' },
  110016. { token: 'delimiter.html', foreground: '808080' },
  110017. { token: 'delimiter.xml', foreground: '808080' },
  110018. { token: 'tag', foreground: '569CD6' },
  110019. { token: 'tag.id.pug', foreground: '4F76AC' },
  110020. { token: 'tag.class.pug', foreground: '4F76AC' },
  110021. { token: 'meta.scss', foreground: 'A79873' },
  110022. { token: 'meta.tag', foreground: 'CE9178' },
  110023. { token: 'metatag', foreground: 'DD6A6F' },
  110024. { token: 'metatag.content.html', foreground: '9CDCFE' },
  110025. { token: 'metatag.html', foreground: '569CD6' },
  110026. { token: 'metatag.xml', foreground: '569CD6' },
  110027. { token: 'metatag.php', fontStyle: 'bold' },
  110028. { token: 'key', foreground: '9CDCFE' },
  110029. { token: 'string.key.json', foreground: '9CDCFE' },
  110030. { token: 'string.value.json', foreground: 'CE9178' },
  110031. { token: 'attribute.name', foreground: '9CDCFE' },
  110032. { token: 'attribute.value', foreground: 'CE9178' },
  110033. { token: 'attribute.value.number.css', foreground: 'B5CEA8' },
  110034. { token: 'attribute.value.unit.css', foreground: 'B5CEA8' },
  110035. { token: 'attribute.value.hex.css', foreground: 'D4D4D4' },
  110036. { token: 'string', foreground: 'CE9178' },
  110037. { token: 'string.sql', foreground: 'FF0000' },
  110038. { token: 'keyword', foreground: '569CD6' },
  110039. { token: 'keyword.flow', foreground: 'C586C0' },
  110040. { token: 'keyword.json', foreground: 'CE9178' },
  110041. { token: 'keyword.flow.scss', foreground: '569CD6' },
  110042. { token: 'operator.scss', foreground: '909090' },
  110043. { token: 'operator.sql', foreground: '778899' },
  110044. { token: 'operator.swift', foreground: '909090' },
  110045. { token: 'predefined.sql', foreground: 'FF00FF' },
  110046. ],
  110047. colors: (_b = {},
  110048. _b[colorRegistry_1.editorBackground] = '#1E1E1E',
  110049. _b[colorRegistry_1.editorForeground] = '#D4D4D4',
  110050. _b[colorRegistry_1.editorInactiveSelection] = '#3A3D41',
  110051. _b[editorColorRegistry_1.editorIndentGuides] = '#404040',
  110052. _b[editorColorRegistry_1.editorActiveIndentGuides] = '#707070',
  110053. _b[colorRegistry_1.editorSelectionHighlight] = '#ADD6FF26',
  110054. _b)
  110055. };
  110056. /* -------------------------------- End vs-dark theme -------------------------------- */
  110057. /* -------------------------------- Begin hc-black theme -------------------------------- */
  110058. exports.hc_black = {
  110059. base: 'hc-black',
  110060. inherit: false,
  110061. rules: [
  110062. { token: '', foreground: 'FFFFFF', background: '000000' },
  110063. { token: 'invalid', foreground: 'f44747' },
  110064. { token: 'emphasis', fontStyle: 'italic' },
  110065. { token: 'strong', fontStyle: 'bold' },
  110066. { token: 'variable', foreground: '1AEBFF' },
  110067. { token: 'variable.parameter', foreground: '9CDCFE' },
  110068. { token: 'constant', foreground: '569CD6' },
  110069. { token: 'comment', foreground: '608B4E' },
  110070. { token: 'number', foreground: 'FFFFFF' },
  110071. { token: 'regexp', foreground: 'C0C0C0' },
  110072. { token: 'annotation', foreground: '569CD6' },
  110073. { token: 'type', foreground: '3DC9B0' },
  110074. { token: 'delimiter', foreground: 'FFFF00' },
  110075. { token: 'delimiter.html', foreground: 'FFFF00' },
  110076. { token: 'tag', foreground: '569CD6' },
  110077. { token: 'tag.id.pug', foreground: '4F76AC' },
  110078. { token: 'tag.class.pug', foreground: '4F76AC' },
  110079. { token: 'meta', foreground: 'D4D4D4' },
  110080. { token: 'meta.tag', foreground: 'CE9178' },
  110081. { token: 'metatag', foreground: '569CD6' },
  110082. { token: 'metatag.content.html', foreground: '1AEBFF' },
  110083. { token: 'metatag.html', foreground: '569CD6' },
  110084. { token: 'metatag.xml', foreground: '569CD6' },
  110085. { token: 'metatag.php', fontStyle: 'bold' },
  110086. { token: 'key', foreground: '9CDCFE' },
  110087. { token: 'string.key', foreground: '9CDCFE' },
  110088. { token: 'string.value', foreground: 'CE9178' },
  110089. { token: 'attribute.name', foreground: '569CD6' },
  110090. { token: 'attribute.value', foreground: '3FF23F' },
  110091. { token: 'string', foreground: 'CE9178' },
  110092. { token: 'string.sql', foreground: 'FF0000' },
  110093. { token: 'keyword', foreground: '569CD6' },
  110094. { token: 'keyword.flow', foreground: 'C586C0' },
  110095. { token: 'operator.sql', foreground: '778899' },
  110096. { token: 'operator.swift', foreground: '909090' },
  110097. { token: 'predefined.sql', foreground: 'FF00FF' },
  110098. ],
  110099. colors: (_c = {},
  110100. _c[colorRegistry_1.editorBackground] = '#000000',
  110101. _c[colorRegistry_1.editorForeground] = '#FFFFFF',
  110102. _c[editorColorRegistry_1.editorIndentGuides] = '#FFFFFF',
  110103. _c[editorColorRegistry_1.editorActiveIndentGuides] = '#FFFFFF',
  110104. _c)
  110105. };
  110106. });
  110107. /* -------------------------------- End hc-black theme -------------------------------- */
  110108. /*---------------------------------------------------------------------------------------------
  110109. * Copyright (c) Microsoft Corporation. All rights reserved.
  110110. * Licensed under the MIT License. See License.txt in the project root for license information.
  110111. *--------------------------------------------------------------------------------------------*/
  110112. define(__m[594/*vs/editor/standalone/browser/standaloneThemeServiceImpl*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,27/*vs/base/common/color*/,4/*vs/base/common/event*/,17/*vs/editor/common/modes*/,357/*vs/editor/common/modes/supports/tokenization*/,593/*vs/editor/standalone/common/themes*/,42/*vs/platform/registry/common/platform*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,2/*vs/base/common/lifecycle*/]), function (require, exports, dom, color_1, event_1, modes_1, tokenization_1, themes_1, platform_1, colorRegistry_1, themeService_1, lifecycle_1) {
  110113. "use strict";
  110114. Object.defineProperty(exports, "__esModule", { value: true });
  110115. var VS_THEME_NAME = 'vs';
  110116. var VS_DARK_THEME_NAME = 'vs-dark';
  110117. var HC_BLACK_THEME_NAME = 'hc-black';
  110118. var colorRegistry = platform_1.Registry.as(colorRegistry_1.Extensions.ColorContribution);
  110119. var themingRegistry = platform_1.Registry.as(themeService_1.Extensions.ThemingContribution);
  110120. var StandaloneTheme = /** @class */ (function () {
  110121. function StandaloneTheme(name, standaloneThemeData) {
  110122. this.themeData = standaloneThemeData;
  110123. var base = standaloneThemeData.base;
  110124. if (name.length > 0) {
  110125. this.id = base + ' ' + name;
  110126. this.themeName = name;
  110127. }
  110128. else {
  110129. this.id = base;
  110130. this.themeName = base;
  110131. }
  110132. this.colors = null;
  110133. this.defaultColors = Object.create(null);
  110134. this._tokenTheme = null;
  110135. }
  110136. Object.defineProperty(StandaloneTheme.prototype, "base", {
  110137. get: function () {
  110138. return this.themeData.base;
  110139. },
  110140. enumerable: true,
  110141. configurable: true
  110142. });
  110143. StandaloneTheme.prototype.notifyBaseUpdated = function () {
  110144. if (this.themeData.inherit) {
  110145. this.colors = null;
  110146. this._tokenTheme = null;
  110147. }
  110148. };
  110149. StandaloneTheme.prototype.getColors = function () {
  110150. if (!this.colors) {
  110151. var colors = new Map();
  110152. for (var id in this.themeData.colors) {
  110153. colors.set(id, color_1.Color.fromHex(this.themeData.colors[id]));
  110154. }
  110155. if (this.themeData.inherit) {
  110156. var baseData = getBuiltinRules(this.themeData.base);
  110157. for (var id in baseData.colors) {
  110158. if (!colors.has(id)) {
  110159. colors.set(id, color_1.Color.fromHex(baseData.colors[id]));
  110160. }
  110161. }
  110162. }
  110163. this.colors = colors;
  110164. }
  110165. return this.colors;
  110166. };
  110167. StandaloneTheme.prototype.getColor = function (colorId, useDefault) {
  110168. var color = this.getColors().get(colorId);
  110169. if (color) {
  110170. return color;
  110171. }
  110172. if (useDefault !== false) {
  110173. return this.getDefault(colorId);
  110174. }
  110175. return undefined;
  110176. };
  110177. StandaloneTheme.prototype.getDefault = function (colorId) {
  110178. var color = this.defaultColors[colorId];
  110179. if (color) {
  110180. return color;
  110181. }
  110182. color = colorRegistry.resolveDefaultColor(colorId, this);
  110183. this.defaultColors[colorId] = color;
  110184. return color;
  110185. };
  110186. StandaloneTheme.prototype.defines = function (colorId) {
  110187. return Object.prototype.hasOwnProperty.call(this.getColors(), colorId);
  110188. };
  110189. Object.defineProperty(StandaloneTheme.prototype, "type", {
  110190. get: function () {
  110191. switch (this.base) {
  110192. case VS_THEME_NAME: return 'light';
  110193. case HC_BLACK_THEME_NAME: return 'hc';
  110194. default: return 'dark';
  110195. }
  110196. },
  110197. enumerable: true,
  110198. configurable: true
  110199. });
  110200. Object.defineProperty(StandaloneTheme.prototype, "tokenTheme", {
  110201. get: function () {
  110202. if (!this._tokenTheme) {
  110203. var rules = [];
  110204. var encodedTokensColors = [];
  110205. if (this.themeData.inherit) {
  110206. var baseData = getBuiltinRules(this.themeData.base);
  110207. rules = baseData.rules;
  110208. if (baseData.encodedTokensColors) {
  110209. encodedTokensColors = baseData.encodedTokensColors;
  110210. }
  110211. }
  110212. rules = rules.concat(this.themeData.rules);
  110213. if (this.themeData.encodedTokensColors) {
  110214. encodedTokensColors = this.themeData.encodedTokensColors;
  110215. }
  110216. this._tokenTheme = tokenization_1.TokenTheme.createFromRawTokenTheme(rules, encodedTokensColors);
  110217. }
  110218. return this._tokenTheme;
  110219. },
  110220. enumerable: true,
  110221. configurable: true
  110222. });
  110223. StandaloneTheme.prototype.getTokenStyleMetadata = function (type, modifiers) {
  110224. return undefined;
  110225. };
  110226. return StandaloneTheme;
  110227. }());
  110228. function isBuiltinTheme(themeName) {
  110229. return (themeName === VS_THEME_NAME
  110230. || themeName === VS_DARK_THEME_NAME
  110231. || themeName === HC_BLACK_THEME_NAME);
  110232. }
  110233. function getBuiltinRules(builtinTheme) {
  110234. switch (builtinTheme) {
  110235. case VS_THEME_NAME:
  110236. return themes_1.vs;
  110237. case VS_DARK_THEME_NAME:
  110238. return themes_1.vs_dark;
  110239. case HC_BLACK_THEME_NAME:
  110240. return themes_1.hc_black;
  110241. }
  110242. }
  110243. function newBuiltInTheme(builtinTheme) {
  110244. var themeData = getBuiltinRules(builtinTheme);
  110245. return new StandaloneTheme(builtinTheme, themeData);
  110246. }
  110247. var StandaloneThemeServiceImpl = /** @class */ (function (_super) {
  110248. __extends(StandaloneThemeServiceImpl, _super);
  110249. function StandaloneThemeServiceImpl() {
  110250. var _this = _super.call(this) || this;
  110251. _this._onThemeChange = _this._register(new event_1.Emitter());
  110252. _this.onThemeChange = _this._onThemeChange.event;
  110253. _this._environment = Object.create(null);
  110254. _this._knownThemes = new Map();
  110255. _this._knownThemes.set(VS_THEME_NAME, newBuiltInTheme(VS_THEME_NAME));
  110256. _this._knownThemes.set(VS_DARK_THEME_NAME, newBuiltInTheme(VS_DARK_THEME_NAME));
  110257. _this._knownThemes.set(HC_BLACK_THEME_NAME, newBuiltInTheme(HC_BLACK_THEME_NAME));
  110258. _this._css = '';
  110259. _this._globalStyleElement = null;
  110260. _this._styleElements = [];
  110261. _this.setTheme(VS_THEME_NAME);
  110262. return _this;
  110263. }
  110264. StandaloneThemeServiceImpl.prototype.registerEditorContainer = function (domNode) {
  110265. if (dom.isInShadowDOM(domNode)) {
  110266. return this._registerShadowDomContainer(domNode);
  110267. }
  110268. return this._registerRegularEditorContainer();
  110269. };
  110270. StandaloneThemeServiceImpl.prototype._registerRegularEditorContainer = function () {
  110271. if (!this._globalStyleElement) {
  110272. this._globalStyleElement = dom.createStyleSheet();
  110273. this._globalStyleElement.className = 'monaco-colors';
  110274. this._globalStyleElement.innerHTML = this._css;
  110275. this._styleElements.push(this._globalStyleElement);
  110276. }
  110277. return lifecycle_1.Disposable.None;
  110278. };
  110279. StandaloneThemeServiceImpl.prototype._registerShadowDomContainer = function (domNode) {
  110280. var _this = this;
  110281. var styleElement = dom.createStyleSheet(domNode);
  110282. styleElement.className = 'monaco-colors';
  110283. styleElement.innerHTML = this._css;
  110284. this._styleElements.push(styleElement);
  110285. return {
  110286. dispose: function () {
  110287. for (var i = 0; i < _this._styleElements.length; i++) {
  110288. if (_this._styleElements[i] === styleElement) {
  110289. _this._styleElements.splice(i, 1);
  110290. return;
  110291. }
  110292. }
  110293. }
  110294. };
  110295. };
  110296. StandaloneThemeServiceImpl.prototype.defineTheme = function (themeName, themeData) {
  110297. if (!/^[a-z0-9\-]+$/i.test(themeName)) {
  110298. throw new Error('Illegal theme name!');
  110299. }
  110300. if (!isBuiltinTheme(themeData.base) && !isBuiltinTheme(themeName)) {
  110301. throw new Error('Illegal theme base!');
  110302. }
  110303. // set or replace theme
  110304. this._knownThemes.set(themeName, new StandaloneTheme(themeName, themeData));
  110305. if (isBuiltinTheme(themeName)) {
  110306. this._knownThemes.forEach(function (theme) {
  110307. if (theme.base === themeName) {
  110308. theme.notifyBaseUpdated();
  110309. }
  110310. });
  110311. }
  110312. if (this._theme && this._theme.themeName === themeName) {
  110313. this.setTheme(themeName); // refresh theme
  110314. }
  110315. };
  110316. StandaloneThemeServiceImpl.prototype.getTheme = function () {
  110317. return this._theme;
  110318. };
  110319. StandaloneThemeServiceImpl.prototype.setTheme = function (themeName) {
  110320. var _this = this;
  110321. var theme;
  110322. if (this._knownThemes.has(themeName)) {
  110323. theme = this._knownThemes.get(themeName);
  110324. }
  110325. else {
  110326. theme = this._knownThemes.get(VS_THEME_NAME);
  110327. }
  110328. if (this._theme === theme) {
  110329. // Nothing to do
  110330. return theme.id;
  110331. }
  110332. this._theme = theme;
  110333. var cssRules = [];
  110334. var hasRule = {};
  110335. var ruleCollector = {
  110336. addRule: function (rule) {
  110337. if (!hasRule[rule]) {
  110338. cssRules.push(rule);
  110339. hasRule[rule] = true;
  110340. }
  110341. }
  110342. };
  110343. themingRegistry.getThemingParticipants().forEach(function (p) { return p(theme, ruleCollector, _this._environment); });
  110344. var tokenTheme = theme.tokenTheme;
  110345. var colorMap = tokenTheme.getColorMap();
  110346. ruleCollector.addRule(tokenization_1.generateTokensCSSForColorMap(colorMap));
  110347. this._css = cssRules.join('\n');
  110348. this._styleElements.forEach(function (styleElement) { return styleElement.innerHTML = _this._css; });
  110349. modes_1.TokenizationRegistry.setColorMap(colorMap);
  110350. this._onThemeChange.fire(theme);
  110351. return theme.id;
  110352. };
  110353. StandaloneThemeServiceImpl.prototype.getIconTheme = function () {
  110354. return {
  110355. hasFileIcons: false,
  110356. hasFolderIcons: false,
  110357. hidesExplorerArrows: false
  110358. };
  110359. };
  110360. return StandaloneThemeServiceImpl;
  110361. }(lifecycle_1.Disposable));
  110362. exports.StandaloneThemeServiceImpl = StandaloneThemeServiceImpl;
  110363. });
  110364. /*---------------------------------------------------------------------------------------------
  110365. * Copyright (c) Microsoft Corporation. All rights reserved.
  110366. * Licensed under the MIT License. See License.txt in the project root for license information.
  110367. *--------------------------------------------------------------------------------------------*/
  110368. define(__m[595/*vs/platform/contextview/browser/contextMenuService*/], __M([0/*require*/,1/*exports*/,547/*vs/platform/contextview/browser/contextMenuHandler*/,66/*vs/platform/contextview/browser/contextView*/,96/*vs/platform/telemetry/common/telemetry*/,4/*vs/base/common/event*/,35/*vs/platform/notification/common/notification*/,14/*vs/platform/theme/common/themeService*/,34/*vs/platform/keybinding/common/keybinding*/,2/*vs/base/common/lifecycle*/]), function (require, exports, contextMenuHandler_1, contextView_1, telemetry_1, event_1, notification_1, themeService_1, keybinding_1, lifecycle_1) {
  110369. "use strict";
  110370. Object.defineProperty(exports, "__esModule", { value: true });
  110371. var ContextMenuService = /** @class */ (function (_super) {
  110372. __extends(ContextMenuService, _super);
  110373. function ContextMenuService(telemetryService, notificationService, contextViewService, keybindingService, themeService) {
  110374. var _this = _super.call(this) || this;
  110375. _this._onDidContextMenu = _this._register(new event_1.Emitter());
  110376. _this.contextMenuHandler = new contextMenuHandler_1.ContextMenuHandler(contextViewService, telemetryService, notificationService, keybindingService, themeService);
  110377. return _this;
  110378. }
  110379. ContextMenuService.prototype.configure = function (options) {
  110380. this.contextMenuHandler.configure(options);
  110381. };
  110382. // ContextMenu
  110383. ContextMenuService.prototype.showContextMenu = function (delegate) {
  110384. this.contextMenuHandler.showContextMenu(delegate);
  110385. this._onDidContextMenu.fire();
  110386. };
  110387. ContextMenuService = __decorate([
  110388. __param(0, telemetry_1.ITelemetryService),
  110389. __param(1, notification_1.INotificationService),
  110390. __param(2, contextView_1.IContextViewService),
  110391. __param(3, keybinding_1.IKeybindingService),
  110392. __param(4, themeService_1.IThemeService)
  110393. ], ContextMenuService);
  110394. return ContextMenuService;
  110395. }(lifecycle_1.Disposable));
  110396. exports.ContextMenuService = ContextMenuService;
  110397. });
  110398. /*---------------------------------------------------------------------------------------------
  110399. * Copyright (c) Microsoft Corporation. All rights reserved.
  110400. * Licensed under the MIT License. See License.txt in the project root for license information.
  110401. *--------------------------------------------------------------------------------------------*/
  110402. define(__m[170/*vs/platform/list/browser/listService*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,153/*vs/base/browser/ui/list/listWidget*/,2/*vs/base/common/lifecycle*/,474/*vs/nls!vs/platform/list/browser/listService*/,43/*vs/platform/configuration/common/configuration*/,85/*vs/platform/configuration/common/configurationRegistry*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,34/*vs/platform/keybinding/common/keybinding*/,42/*vs/platform/registry/common/platform*/,97/*vs/platform/theme/common/styler*/,14/*vs/platform/theme/common/themeService*/,477/*vs/platform/contextkey/common/contextkeys*/,206/*vs/base/browser/ui/tree/objectTree*/,408/*vs/base/browser/ui/tree/asyncDataTree*/,407/*vs/base/browser/ui/tree/dataTree*/,64/*vs/platform/accessibility/common/accessibility*/]), function (require, exports, dom_1, listWidget_1, lifecycle_1, nls_1, configuration_1, configurationRegistry_1, contextkey_1, instantiation_1, keybinding_1, platform_1, styler_1, themeService_1, contextkeys_1, objectTree_1, asyncDataTree_1, dataTree_1, accessibility_1) {
  110403. "use strict";
  110404. var _a;
  110405. Object.defineProperty(exports, "__esModule", { value: true });
  110406. exports.IListService = instantiation_1.createDecorator('listService');
  110407. var ListService = /** @class */ (function () {
  110408. function ListService(_themeService) {
  110409. this._themeService = _themeService;
  110410. this.disposables = new lifecycle_1.DisposableStore();
  110411. this.lists = [];
  110412. this._lastFocusedWidget = undefined;
  110413. this._hasCreatedStyleController = false;
  110414. }
  110415. Object.defineProperty(ListService.prototype, "lastFocusedList", {
  110416. get: function () {
  110417. return this._lastFocusedWidget;
  110418. },
  110419. enumerable: true,
  110420. configurable: true
  110421. });
  110422. ListService.prototype.register = function (widget, extraContextKeys) {
  110423. var _this = this;
  110424. if (!this._hasCreatedStyleController) {
  110425. this._hasCreatedStyleController = true;
  110426. // create a shared default tree style sheet for performance reasons
  110427. var styleController = new listWidget_1.DefaultStyleController(dom_1.createStyleSheet(), '');
  110428. this.disposables.add(styler_1.attachListStyler(styleController, this._themeService));
  110429. }
  110430. if (this.lists.some(function (l) { return l.widget === widget; })) {
  110431. throw new Error('Cannot register the same widget multiple times');
  110432. }
  110433. // Keep in our lists list
  110434. var registeredList = { widget: widget, extraContextKeys: extraContextKeys };
  110435. this.lists.push(registeredList);
  110436. // Check for currently being focused
  110437. if (widget.getHTMLElement() === document.activeElement) {
  110438. this._lastFocusedWidget = widget;
  110439. }
  110440. return lifecycle_1.combinedDisposable(widget.onDidFocus(function () { return _this._lastFocusedWidget = widget; }), lifecycle_1.toDisposable(function () { return _this.lists.splice(_this.lists.indexOf(registeredList), 1); }), widget.onDidDispose(function () {
  110441. _this.lists = _this.lists.filter(function (l) { return l !== registeredList; });
  110442. if (_this._lastFocusedWidget === widget) {
  110443. _this._lastFocusedWidget = undefined;
  110444. }
  110445. }));
  110446. };
  110447. ListService.prototype.dispose = function () {
  110448. this.disposables.dispose();
  110449. };
  110450. ListService = __decorate([
  110451. __param(0, themeService_1.IThemeService)
  110452. ], ListService);
  110453. return ListService;
  110454. }());
  110455. exports.ListService = ListService;
  110456. var RawWorkbenchListFocusContextKey = new contextkey_1.RawContextKey('listFocus', true);
  110457. exports.WorkbenchListSupportsMultiSelectContextKey = new contextkey_1.RawContextKey('listSupportsMultiselect', true);
  110458. exports.WorkbenchListFocusContextKey = contextkey_1.ContextKeyExpr.and(RawWorkbenchListFocusContextKey, contextkey_1.ContextKeyExpr.not(contextkeys_1.InputFocusedContextKey));
  110459. exports.WorkbenchListHasSelectionOrFocus = new contextkey_1.RawContextKey('listHasSelectionOrFocus', false);
  110460. exports.WorkbenchListDoubleSelection = new contextkey_1.RawContextKey('listDoubleSelection', false);
  110461. exports.WorkbenchListMultiSelection = new contextkey_1.RawContextKey('listMultiSelection', false);
  110462. exports.WorkbenchListSupportsKeyboardNavigation = new contextkey_1.RawContextKey('listSupportsKeyboardNavigation', true);
  110463. exports.WorkbenchListAutomaticKeyboardNavigationKey = 'listAutomaticKeyboardNavigation';
  110464. exports.WorkbenchListAutomaticKeyboardNavigation = new contextkey_1.RawContextKey(exports.WorkbenchListAutomaticKeyboardNavigationKey, true);
  110465. exports.didBindWorkbenchListAutomaticKeyboardNavigation = false;
  110466. function createScopedContextKeyService(contextKeyService, widget) {
  110467. var result = contextKeyService.createScoped(widget.getHTMLElement());
  110468. RawWorkbenchListFocusContextKey.bindTo(result);
  110469. return result;
  110470. }
  110471. exports.multiSelectModifierSettingKey = 'workbench.list.multiSelectModifier';
  110472. exports.openModeSettingKey = 'workbench.list.openMode';
  110473. exports.horizontalScrollingKey = 'workbench.list.horizontalScrolling';
  110474. exports.keyboardNavigationSettingKey = 'workbench.list.keyboardNavigation';
  110475. exports.automaticKeyboardNavigationSettingKey = 'workbench.list.automaticKeyboardNavigation';
  110476. var treeIndentKey = 'workbench.tree.indent';
  110477. var treeRenderIndentGuidesKey = 'workbench.tree.renderIndentGuides';
  110478. function getHorizontalScrollingSetting(configurationService) {
  110479. return configuration_1.getMigratedSettingValue(configurationService, exports.horizontalScrollingKey, 'workbench.tree.horizontalScrolling');
  110480. }
  110481. function useAltAsMultipleSelectionModifier(configurationService) {
  110482. return configurationService.getValue(exports.multiSelectModifierSettingKey) === 'alt';
  110483. }
  110484. function useSingleClickToOpen(configurationService) {
  110485. return configurationService.getValue(exports.openModeSettingKey) !== 'doubleClick';
  110486. }
  110487. var MultipleSelectionController = /** @class */ (function (_super) {
  110488. __extends(MultipleSelectionController, _super);
  110489. function MultipleSelectionController(configurationService) {
  110490. var _this = _super.call(this) || this;
  110491. _this.configurationService = configurationService;
  110492. _this.useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  110493. _this.registerListeners();
  110494. return _this;
  110495. }
  110496. MultipleSelectionController.prototype.registerListeners = function () {
  110497. var _this = this;
  110498. this._register(this.configurationService.onDidChangeConfiguration(function (e) {
  110499. if (e.affectsConfiguration(exports.multiSelectModifierSettingKey)) {
  110500. _this.useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(_this.configurationService);
  110501. }
  110502. }));
  110503. };
  110504. MultipleSelectionController.prototype.isSelectionSingleChangeEvent = function (event) {
  110505. if (this.useAltAsMultipleSelectionModifier) {
  110506. return event.browserEvent.altKey;
  110507. }
  110508. return listWidget_1.isSelectionSingleChangeEvent(event);
  110509. };
  110510. MultipleSelectionController.prototype.isSelectionRangeChangeEvent = function (event) {
  110511. return listWidget_1.isSelectionRangeChangeEvent(event);
  110512. };
  110513. return MultipleSelectionController;
  110514. }(lifecycle_1.Disposable));
  110515. var WorkbenchOpenController = /** @class */ (function (_super) {
  110516. __extends(WorkbenchOpenController, _super);
  110517. function WorkbenchOpenController(configurationService, existingOpenController) {
  110518. var _this = _super.call(this) || this;
  110519. _this.configurationService = configurationService;
  110520. _this.existingOpenController = existingOpenController;
  110521. _this.openOnSingleClick = useSingleClickToOpen(configurationService);
  110522. _this.registerListeners();
  110523. return _this;
  110524. }
  110525. WorkbenchOpenController.prototype.registerListeners = function () {
  110526. var _this = this;
  110527. this._register(this.configurationService.onDidChangeConfiguration(function (e) {
  110528. if (e.affectsConfiguration(exports.openModeSettingKey)) {
  110529. _this.openOnSingleClick = useSingleClickToOpen(_this.configurationService);
  110530. }
  110531. }));
  110532. };
  110533. WorkbenchOpenController.prototype.shouldOpen = function (event) {
  110534. if (event instanceof MouseEvent) {
  110535. var isLeftButton = event.button === 0;
  110536. var isDoubleClick = event.detail === 2;
  110537. if (isLeftButton && !this.openOnSingleClick && !isDoubleClick) {
  110538. return false;
  110539. }
  110540. if (isLeftButton /* left mouse button */ || event.button === 1 /* middle mouse button */) {
  110541. return this.existingOpenController ? this.existingOpenController.shouldOpen(event) : true;
  110542. }
  110543. return false;
  110544. }
  110545. return this.existingOpenController ? this.existingOpenController.shouldOpen(event) : true;
  110546. };
  110547. return WorkbenchOpenController;
  110548. }(lifecycle_1.Disposable));
  110549. function toWorkbenchListOptions(options, configurationService, keybindingService) {
  110550. var disposables = new lifecycle_1.DisposableStore();
  110551. var result = __assign({}, options);
  110552. if (options.multipleSelectionSupport !== false && !options.multipleSelectionController) {
  110553. var multipleSelectionController = new MultipleSelectionController(configurationService);
  110554. result.multipleSelectionController = multipleSelectionController;
  110555. disposables.add(multipleSelectionController);
  110556. }
  110557. var openController = new WorkbenchOpenController(configurationService, options.openController);
  110558. result.openController = openController;
  110559. disposables.add(openController);
  110560. result.keyboardNavigationDelegate = {
  110561. mightProducePrintableCharacter: function (e) {
  110562. return keybindingService.mightProducePrintableCharacter(e);
  110563. }
  110564. };
  110565. return [result, disposables];
  110566. }
  110567. function createKeyboardNavigationEventFilter(container, keybindingService) {
  110568. var inChord = false;
  110569. return function (event) {
  110570. if (inChord) {
  110571. inChord = false;
  110572. return false;
  110573. }
  110574. var result = keybindingService.softDispatch(event, container);
  110575. if (result && result.enterChord) {
  110576. inChord = true;
  110577. return false;
  110578. }
  110579. inChord = false;
  110580. return true;
  110581. };
  110582. }
  110583. var WorkbenchObjectTree = /** @class */ (function (_super) {
  110584. __extends(WorkbenchObjectTree, _super);
  110585. function WorkbenchObjectTree(user, container, delegate, renderers, options, contextKeyService, listService, themeService, configurationService, keybindingService, accessibilityService) {
  110586. var _this = this;
  110587. var _a = workbenchTreeDataPreamble(container, options, contextKeyService, configurationService, keybindingService, accessibilityService), treeOptions = _a.options, getAutomaticKeyboardNavigation = _a.getAutomaticKeyboardNavigation, disposable = _a.disposable;
  110588. _this = _super.call(this, user, container, delegate, renderers, treeOptions) || this;
  110589. _this.disposables.add(disposable);
  110590. _this.internals = new WorkbenchTreeInternals(_this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
  110591. _this.disposables.add(_this.internals);
  110592. return _this;
  110593. }
  110594. WorkbenchObjectTree = __decorate([
  110595. __param(5, contextkey_1.IContextKeyService),
  110596. __param(6, exports.IListService),
  110597. __param(7, themeService_1.IThemeService),
  110598. __param(8, configuration_1.IConfigurationService),
  110599. __param(9, keybinding_1.IKeybindingService),
  110600. __param(10, accessibility_1.IAccessibilityService)
  110601. ], WorkbenchObjectTree);
  110602. return WorkbenchObjectTree;
  110603. }(objectTree_1.ObjectTree));
  110604. exports.WorkbenchObjectTree = WorkbenchObjectTree;
  110605. var WorkbenchDataTree = /** @class */ (function (_super) {
  110606. __extends(WorkbenchDataTree, _super);
  110607. function WorkbenchDataTree(user, container, delegate, renderers, dataSource, options, contextKeyService, listService, themeService, configurationService, keybindingService, accessibilityService) {
  110608. var _this = this;
  110609. var _a = workbenchTreeDataPreamble(container, options, contextKeyService, configurationService, keybindingService, accessibilityService), treeOptions = _a.options, getAutomaticKeyboardNavigation = _a.getAutomaticKeyboardNavigation, disposable = _a.disposable;
  110610. _this = _super.call(this, user, container, delegate, renderers, dataSource, treeOptions) || this;
  110611. _this.disposables.add(disposable);
  110612. _this.internals = new WorkbenchTreeInternals(_this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
  110613. _this.disposables.add(_this.internals);
  110614. return _this;
  110615. }
  110616. WorkbenchDataTree.prototype.updateOptions = function (options) {
  110617. if (options === void 0) { options = {}; }
  110618. _super.prototype.updateOptions.call(this, options);
  110619. if (options.overrideStyles) {
  110620. this.internals.updateStyleOverrides(options.overrideStyles);
  110621. }
  110622. };
  110623. WorkbenchDataTree = __decorate([
  110624. __param(6, contextkey_1.IContextKeyService),
  110625. __param(7, exports.IListService),
  110626. __param(8, themeService_1.IThemeService),
  110627. __param(9, configuration_1.IConfigurationService),
  110628. __param(10, keybinding_1.IKeybindingService),
  110629. __param(11, accessibility_1.IAccessibilityService)
  110630. ], WorkbenchDataTree);
  110631. return WorkbenchDataTree;
  110632. }(dataTree_1.DataTree));
  110633. exports.WorkbenchDataTree = WorkbenchDataTree;
  110634. var WorkbenchAsyncDataTree = /** @class */ (function (_super) {
  110635. __extends(WorkbenchAsyncDataTree, _super);
  110636. function WorkbenchAsyncDataTree(user, container, delegate, renderers, dataSource, options, contextKeyService, listService, themeService, configurationService, keybindingService, accessibilityService) {
  110637. var _this = this;
  110638. var _a = workbenchTreeDataPreamble(container, options, contextKeyService, configurationService, keybindingService, accessibilityService), treeOptions = _a.options, getAutomaticKeyboardNavigation = _a.getAutomaticKeyboardNavigation, disposable = _a.disposable;
  110639. _this = _super.call(this, user, container, delegate, renderers, dataSource, treeOptions) || this;
  110640. _this.disposables.add(disposable);
  110641. _this.internals = new WorkbenchTreeInternals(_this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
  110642. _this.disposables.add(_this.internals);
  110643. return _this;
  110644. }
  110645. WorkbenchAsyncDataTree.prototype.updateOptions = function (options) {
  110646. if (options === void 0) { options = {}; }
  110647. _super.prototype.updateOptions.call(this, options);
  110648. if (options.overrideStyles) {
  110649. this.internals.updateStyleOverrides(options.overrideStyles);
  110650. }
  110651. };
  110652. WorkbenchAsyncDataTree = __decorate([
  110653. __param(6, contextkey_1.IContextKeyService),
  110654. __param(7, exports.IListService),
  110655. __param(8, themeService_1.IThemeService),
  110656. __param(9, configuration_1.IConfigurationService),
  110657. __param(10, keybinding_1.IKeybindingService),
  110658. __param(11, accessibility_1.IAccessibilityService)
  110659. ], WorkbenchAsyncDataTree);
  110660. return WorkbenchAsyncDataTree;
  110661. }(asyncDataTree_1.AsyncDataTree));
  110662. exports.WorkbenchAsyncDataTree = WorkbenchAsyncDataTree;
  110663. var WorkbenchCompressibleAsyncDataTree = /** @class */ (function (_super) {
  110664. __extends(WorkbenchCompressibleAsyncDataTree, _super);
  110665. function WorkbenchCompressibleAsyncDataTree(user, container, virtualDelegate, compressionDelegate, renderers, dataSource, options, contextKeyService, listService, themeService, configurationService, keybindingService, accessibilityService) {
  110666. var _this = this;
  110667. var _a = workbenchTreeDataPreamble(container, options, contextKeyService, configurationService, keybindingService, accessibilityService), treeOptions = _a.options, getAutomaticKeyboardNavigation = _a.getAutomaticKeyboardNavigation, disposable = _a.disposable;
  110668. _this = _super.call(this, user, container, virtualDelegate, compressionDelegate, renderers, dataSource, treeOptions) || this;
  110669. _this.disposables.add(disposable);
  110670. _this.internals = new WorkbenchTreeInternals(_this, treeOptions, getAutomaticKeyboardNavigation, options.overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService);
  110671. _this.disposables.add(_this.internals);
  110672. return _this;
  110673. }
  110674. WorkbenchCompressibleAsyncDataTree = __decorate([
  110675. __param(7, contextkey_1.IContextKeyService),
  110676. __param(8, exports.IListService),
  110677. __param(9, themeService_1.IThemeService),
  110678. __param(10, configuration_1.IConfigurationService),
  110679. __param(11, keybinding_1.IKeybindingService),
  110680. __param(12, accessibility_1.IAccessibilityService)
  110681. ], WorkbenchCompressibleAsyncDataTree);
  110682. return WorkbenchCompressibleAsyncDataTree;
  110683. }(asyncDataTree_1.CompressibleAsyncDataTree));
  110684. exports.WorkbenchCompressibleAsyncDataTree = WorkbenchCompressibleAsyncDataTree;
  110685. function workbenchTreeDataPreamble(container, options, contextKeyService, configurationService, keybindingService, accessibilityService) {
  110686. exports.WorkbenchListSupportsKeyboardNavigation.bindTo(contextKeyService);
  110687. if (!exports.didBindWorkbenchListAutomaticKeyboardNavigation) {
  110688. exports.WorkbenchListAutomaticKeyboardNavigation.bindTo(contextKeyService);
  110689. exports.didBindWorkbenchListAutomaticKeyboardNavigation = true;
  110690. }
  110691. var getAutomaticKeyboardNavigation = function () {
  110692. // give priority to the context key value to disable this completely
  110693. var automaticKeyboardNavigation = contextKeyService.getContextKeyValue(exports.WorkbenchListAutomaticKeyboardNavigationKey);
  110694. if (automaticKeyboardNavigation) {
  110695. automaticKeyboardNavigation = configurationService.getValue(exports.automaticKeyboardNavigationSettingKey);
  110696. }
  110697. return automaticKeyboardNavigation;
  110698. };
  110699. var accessibilityOn = accessibilityService.isScreenReaderOptimized();
  110700. var keyboardNavigation = accessibilityOn ? 'simple' : configurationService.getValue(exports.keyboardNavigationSettingKey);
  110701. var horizontalScrolling = typeof options.horizontalScrolling !== 'undefined' ? options.horizontalScrolling : getHorizontalScrollingSetting(configurationService);
  110702. var openOnSingleClick = useSingleClickToOpen(configurationService);
  110703. var _a = toWorkbenchListOptions(options, configurationService, keybindingService), workbenchListOptions = _a[0], disposable = _a[1];
  110704. var additionalScrollHeight = options.additionalScrollHeight;
  110705. return {
  110706. getAutomaticKeyboardNavigation: getAutomaticKeyboardNavigation,
  110707. disposable: disposable,
  110708. options: __assign(__assign({
  110709. // ...options, // TODO@Joao why is this not splatted here?
  110710. keyboardSupport: false }, workbenchListOptions), { indent: configurationService.getValue(treeIndentKey), renderIndentGuides: configurationService.getValue(treeRenderIndentGuidesKey), automaticKeyboardNavigation: getAutomaticKeyboardNavigation(), simpleKeyboardNavigation: keyboardNavigation === 'simple', filterOnType: keyboardNavigation === 'filter', horizontalScrolling: horizontalScrolling,
  110711. openOnSingleClick: openOnSingleClick, keyboardNavigationEventFilter: createKeyboardNavigationEventFilter(container, keybindingService), additionalScrollHeight: additionalScrollHeight, hideTwistiesOfChildlessElements: options.hideTwistiesOfChildlessElements })
  110712. };
  110713. }
  110714. var WorkbenchTreeInternals = /** @class */ (function () {
  110715. function WorkbenchTreeInternals(tree, options, getAutomaticKeyboardNavigation, overrideStyles, contextKeyService, listService, themeService, configurationService, accessibilityService) {
  110716. var _this = this;
  110717. this.tree = tree;
  110718. this.themeService = themeService;
  110719. this.disposables = [];
  110720. this.contextKeyService = createScopedContextKeyService(contextKeyService, tree);
  110721. var listSupportsMultiSelect = exports.WorkbenchListSupportsMultiSelectContextKey.bindTo(this.contextKeyService);
  110722. listSupportsMultiSelect.set(!(options.multipleSelectionSupport === false));
  110723. this.hasSelectionOrFocus = exports.WorkbenchListHasSelectionOrFocus.bindTo(this.contextKeyService);
  110724. this.hasDoubleSelection = exports.WorkbenchListDoubleSelection.bindTo(this.contextKeyService);
  110725. this.hasMultiSelection = exports.WorkbenchListMultiSelection.bindTo(this.contextKeyService);
  110726. this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  110727. var interestingContextKeys = new Set();
  110728. interestingContextKeys.add(exports.WorkbenchListAutomaticKeyboardNavigationKey);
  110729. var updateKeyboardNavigation = function () {
  110730. var accessibilityOn = accessibilityService.isScreenReaderOptimized();
  110731. var keyboardNavigation = accessibilityOn ? 'simple' : configurationService.getValue(exports.keyboardNavigationSettingKey);
  110732. tree.updateOptions({
  110733. simpleKeyboardNavigation: keyboardNavigation === 'simple',
  110734. filterOnType: keyboardNavigation === 'filter'
  110735. });
  110736. };
  110737. this.updateStyleOverrides(overrideStyles);
  110738. this.disposables.push(this.contextKeyService, listService.register(tree), tree.onDidChangeSelection(function () {
  110739. var selection = tree.getSelection();
  110740. var focus = tree.getFocus();
  110741. _this.hasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
  110742. _this.hasMultiSelection.set(selection.length > 1);
  110743. _this.hasDoubleSelection.set(selection.length === 2);
  110744. }), tree.onDidChangeFocus(function () {
  110745. var selection = tree.getSelection();
  110746. var focus = tree.getFocus();
  110747. _this.hasSelectionOrFocus.set(selection.length > 0 || focus.length > 0);
  110748. }), configurationService.onDidChangeConfiguration(function (e) {
  110749. if (e.affectsConfiguration(exports.openModeSettingKey)) {
  110750. tree.updateOptions({ openOnSingleClick: useSingleClickToOpen(configurationService) });
  110751. }
  110752. if (e.affectsConfiguration(exports.multiSelectModifierSettingKey)) {
  110753. _this._useAltAsMultipleSelectionModifier = useAltAsMultipleSelectionModifier(configurationService);
  110754. }
  110755. if (e.affectsConfiguration(treeIndentKey)) {
  110756. var indent = configurationService.getValue(treeIndentKey);
  110757. tree.updateOptions({ indent: indent });
  110758. }
  110759. if (e.affectsConfiguration(treeRenderIndentGuidesKey)) {
  110760. var renderIndentGuides = configurationService.getValue(treeRenderIndentGuidesKey);
  110761. tree.updateOptions({ renderIndentGuides: renderIndentGuides });
  110762. }
  110763. if (e.affectsConfiguration(exports.keyboardNavigationSettingKey)) {
  110764. updateKeyboardNavigation();
  110765. }
  110766. if (e.affectsConfiguration(exports.automaticKeyboardNavigationSettingKey)) {
  110767. tree.updateOptions({ automaticKeyboardNavigation: getAutomaticKeyboardNavigation() });
  110768. }
  110769. }), this.contextKeyService.onDidChangeContext(function (e) {
  110770. if (e.affectsSome(interestingContextKeys)) {
  110771. tree.updateOptions({ automaticKeyboardNavigation: getAutomaticKeyboardNavigation() });
  110772. }
  110773. }), accessibilityService.onDidChangeScreenReaderOptimized(function () { return updateKeyboardNavigation(); }));
  110774. }
  110775. WorkbenchTreeInternals.prototype.updateStyleOverrides = function (overrideStyles) {
  110776. lifecycle_1.dispose(this.styler);
  110777. this.styler = overrideStyles ? styler_1.attachListStyler(this.tree, this.themeService, overrideStyles) : lifecycle_1.Disposable.None;
  110778. };
  110779. WorkbenchTreeInternals.prototype.dispose = function () {
  110780. this.disposables = lifecycle_1.dispose(this.disposables);
  110781. this.styler = lifecycle_1.dispose(this.styler);
  110782. };
  110783. WorkbenchTreeInternals = __decorate([
  110784. __param(4, contextkey_1.IContextKeyService),
  110785. __param(5, exports.IListService),
  110786. __param(6, themeService_1.IThemeService),
  110787. __param(7, configuration_1.IConfigurationService),
  110788. __param(8, accessibility_1.IAccessibilityService)
  110789. ], WorkbenchTreeInternals);
  110790. return WorkbenchTreeInternals;
  110791. }());
  110792. var configurationRegistry = platform_1.Registry.as(configurationRegistry_1.Extensions.Configuration);
  110793. configurationRegistry.registerConfiguration({
  110794. 'id': 'workbench',
  110795. 'order': 7,
  110796. 'title': nls_1.localize(0, null),
  110797. 'type': 'object',
  110798. 'properties': (_a = {},
  110799. _a[exports.multiSelectModifierSettingKey] = {
  110800. 'type': 'string',
  110801. 'enum': ['ctrlCmd', 'alt'],
  110802. 'enumDescriptions': [
  110803. nls_1.localize(1, null),
  110804. nls_1.localize(2, null)
  110805. ],
  110806. 'default': 'ctrlCmd',
  110807. 'description': nls_1.localize(3, null)
  110808. },
  110809. _a[exports.openModeSettingKey] = {
  110810. 'type': 'string',
  110811. 'enum': ['singleClick', 'doubleClick'],
  110812. 'default': 'singleClick',
  110813. 'description': nls_1.localize(4, null)
  110814. },
  110815. _a[exports.horizontalScrollingKey] = {
  110816. 'type': 'boolean',
  110817. 'default': false,
  110818. 'description': nls_1.localize(5, null)
  110819. },
  110820. _a['workbench.tree.horizontalScrolling'] = {
  110821. 'type': 'boolean',
  110822. 'default': false,
  110823. 'description': nls_1.localize(6, null),
  110824. 'deprecationMessage': nls_1.localize(7, null, exports.horizontalScrollingKey)
  110825. },
  110826. _a[treeIndentKey] = {
  110827. 'type': 'number',
  110828. 'default': 8,
  110829. minimum: 0,
  110830. maximum: 40,
  110831. 'description': nls_1.localize(8, null)
  110832. },
  110833. _a[treeRenderIndentGuidesKey] = {
  110834. type: 'string',
  110835. enum: ['none', 'onHover', 'always'],
  110836. default: 'onHover',
  110837. description: nls_1.localize(9, null)
  110838. },
  110839. _a[exports.keyboardNavigationSettingKey] = {
  110840. 'type': 'string',
  110841. 'enum': ['simple', 'highlight', 'filter'],
  110842. 'enumDescriptions': [
  110843. nls_1.localize(10, null),
  110844. nls_1.localize(11, null),
  110845. nls_1.localize(12, null)
  110846. ],
  110847. 'default': 'highlight',
  110848. 'description': nls_1.localize(13, null)
  110849. },
  110850. _a[exports.automaticKeyboardNavigationSettingKey] = {
  110851. 'type': 'boolean',
  110852. 'default': true,
  110853. markdownDescription: nls_1.localize(14, null)
  110854. },
  110855. _a)
  110856. });
  110857. });
  110858. /*---------------------------------------------------------------------------------------------
  110859. * Copyright (c) Microsoft Corporation. All rights reserved.
  110860. * Licensed under the MIT License. See License.txt in the project root for license information.
  110861. *--------------------------------------------------------------------------------------------*/
  110862. define(__m[596/*vs/editor/contrib/gotoSymbol/peek/referencesWidget*/], __M([0/*require*/,1/*exports*/,6/*vs/base/browser/dom*/,27/*vs/base/common/color*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,46/*vs/base/common/network*/,39/*vs/base/common/resources*/,167/*vs/editor/browser/widget/embeddedCodeEditorWidget*/,3/*vs/editor/common/core/range*/,30/*vs/editor/common/model/textModel*/,84/*vs/editor/common/services/resolverService*/,575/*vs/editor/contrib/gotoSymbol/peek/referencesTree*/,450/*vs/nls!vs/editor/contrib/gotoSymbol/peek/referencesWidget*/,11/*vs/platform/instantiation/common/instantiation*/,116/*vs/platform/label/common/label*/,170/*vs/platform/list/browser/listService*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,123/*vs/editor/contrib/peekView/peekView*/,113/*vs/editor/contrib/gotoSymbol/referencesModel*/,279/*vs/base/browser/ui/splitview/splitview*/,314/*vs/css!vs/editor/contrib/gotoSymbol/peek/referencesWidget*/]), function (require, exports, dom, color_1, event_1, lifecycle_1, network_1, resources_1, embeddedCodeEditorWidget_1, range_1, textModel_1, resolverService_1, referencesTree_1, nls, instantiation_1, label_1, listService_1, colorRegistry_1, themeService_1, peekView, referencesModel_1, splitview_1) {
  110863. "use strict";
  110864. Object.defineProperty(exports, "__esModule", { value: true });
  110865. var DecorationsManager = /** @class */ (function () {
  110866. function DecorationsManager(_editor, _model) {
  110867. var _this = this;
  110868. this._editor = _editor;
  110869. this._model = _model;
  110870. this._decorations = new Map();
  110871. this._decorationIgnoreSet = new Set();
  110872. this._callOnDispose = new lifecycle_1.DisposableStore();
  110873. this._callOnModelChange = new lifecycle_1.DisposableStore();
  110874. this._callOnDispose.add(this._editor.onDidChangeModel(function () { return _this._onModelChanged(); }));
  110875. this._onModelChanged();
  110876. }
  110877. DecorationsManager.prototype.dispose = function () {
  110878. this._callOnModelChange.dispose();
  110879. this._callOnDispose.dispose();
  110880. this.removeDecorations();
  110881. };
  110882. DecorationsManager.prototype._onModelChanged = function () {
  110883. this._callOnModelChange.clear();
  110884. var model = this._editor.getModel();
  110885. if (model) {
  110886. for (var _i = 0, _a = this._model.groups; _i < _a.length; _i++) {
  110887. var ref = _a[_i];
  110888. if (resources_1.isEqual(ref.uri, model.uri)) {
  110889. this._addDecorations(ref);
  110890. return;
  110891. }
  110892. }
  110893. }
  110894. };
  110895. DecorationsManager.prototype._addDecorations = function (reference) {
  110896. var _this = this;
  110897. if (!this._editor.hasModel()) {
  110898. return;
  110899. }
  110900. this._callOnModelChange.add(this._editor.getModel().onDidChangeDecorations(function (event) { return _this._onDecorationChanged(); }));
  110901. var newDecorations = [];
  110902. var newDecorationsActualIndex = [];
  110903. for (var i = 0, len = reference.children.length; i < len; i++) {
  110904. var oneReference = reference.children[i];
  110905. if (this._decorationIgnoreSet.has(oneReference.id)) {
  110906. continue;
  110907. }
  110908. newDecorations.push({
  110909. range: oneReference.range,
  110910. options: DecorationsManager.DecorationOptions
  110911. });
  110912. newDecorationsActualIndex.push(i);
  110913. }
  110914. var decorations = this._editor.deltaDecorations([], newDecorations);
  110915. for (var i = 0; i < decorations.length; i++) {
  110916. this._decorations.set(decorations[i], reference.children[newDecorationsActualIndex[i]]);
  110917. }
  110918. };
  110919. DecorationsManager.prototype._onDecorationChanged = function () {
  110920. var _this = this;
  110921. var toRemove = [];
  110922. var model = this._editor.getModel();
  110923. if (!model) {
  110924. return;
  110925. }
  110926. this._decorations.forEach(function (reference, decorationId) {
  110927. var newRange = model.getDecorationRange(decorationId);
  110928. if (!newRange) {
  110929. return;
  110930. }
  110931. var ignore = false;
  110932. if (range_1.Range.equalsRange(newRange, reference.range)) {
  110933. return;
  110934. }
  110935. else if (range_1.Range.spansMultipleLines(newRange)) {
  110936. ignore = true;
  110937. }
  110938. else {
  110939. var lineLength = reference.range.endColumn - reference.range.startColumn;
  110940. var newLineLength = newRange.endColumn - newRange.startColumn;
  110941. if (lineLength !== newLineLength) {
  110942. ignore = true;
  110943. }
  110944. }
  110945. if (ignore) {
  110946. _this._decorationIgnoreSet.add(reference.id);
  110947. toRemove.push(decorationId);
  110948. }
  110949. else {
  110950. reference.range = newRange;
  110951. }
  110952. });
  110953. for (var i = 0, len = toRemove.length; i < len; i++) {
  110954. this._decorations.delete(toRemove[i]);
  110955. }
  110956. this._editor.deltaDecorations(toRemove, []);
  110957. };
  110958. DecorationsManager.prototype.removeDecorations = function () {
  110959. var toRemove = [];
  110960. this._decorations.forEach(function (value, key) {
  110961. toRemove.push(key);
  110962. });
  110963. this._editor.deltaDecorations(toRemove, []);
  110964. this._decorations.clear();
  110965. };
  110966. DecorationsManager.DecorationOptions = textModel_1.ModelDecorationOptions.register({
  110967. stickiness: 1 /* NeverGrowsWhenTypingAtEdges */,
  110968. className: 'reference-decoration'
  110969. });
  110970. return DecorationsManager;
  110971. }());
  110972. var LayoutData = /** @class */ (function () {
  110973. function LayoutData() {
  110974. this.ratio = 0.7;
  110975. this.heightInLines = 18;
  110976. }
  110977. LayoutData.fromJSON = function (raw) {
  110978. var ratio;
  110979. var heightInLines;
  110980. try {
  110981. var data = JSON.parse(raw);
  110982. ratio = data.ratio;
  110983. heightInLines = data.heightInLines;
  110984. }
  110985. catch (_a) {
  110986. //
  110987. }
  110988. return {
  110989. ratio: ratio || 0.7,
  110990. heightInLines: heightInLines || 18
  110991. };
  110992. };
  110993. return LayoutData;
  110994. }());
  110995. exports.LayoutData = LayoutData;
  110996. /**
  110997. * ZoneWidget that is shown inside the editor
  110998. */
  110999. var ReferenceWidget = /** @class */ (function (_super) {
  111000. __extends(ReferenceWidget, _super);
  111001. function ReferenceWidget(editor, _defaultTreeKeyboardSupport, layoutData, themeService, _textModelResolverService, _instantiationService, _peekViewService, _uriLabel) {
  111002. var _this = _super.call(this, editor, { showFrame: false, showArrow: true, isResizeable: true, isAccessible: true }) || this;
  111003. _this._defaultTreeKeyboardSupport = _defaultTreeKeyboardSupport;
  111004. _this.layoutData = layoutData;
  111005. _this._textModelResolverService = _textModelResolverService;
  111006. _this._instantiationService = _instantiationService;
  111007. _this._peekViewService = _peekViewService;
  111008. _this._uriLabel = _uriLabel;
  111009. _this._disposeOnNewModel = new lifecycle_1.DisposableStore();
  111010. _this._callOnDispose = new lifecycle_1.DisposableStore();
  111011. _this._onDidSelectReference = new event_1.Emitter();
  111012. _this.onDidSelectReference = _this._onDidSelectReference.event;
  111013. _this._dim = { height: 0, width: 0 };
  111014. _this._applyTheme(themeService.getTheme());
  111015. _this._callOnDispose.add(themeService.onThemeChange(_this._applyTheme.bind(_this)));
  111016. _this._peekViewService.addExclusiveWidget(editor, _this);
  111017. _this.create();
  111018. return _this;
  111019. }
  111020. ReferenceWidget.prototype.dispose = function () {
  111021. this.setModel(undefined);
  111022. this._callOnDispose.dispose();
  111023. this._disposeOnNewModel.dispose();
  111024. lifecycle_1.dispose(this._preview);
  111025. lifecycle_1.dispose(this._previewNotAvailableMessage);
  111026. lifecycle_1.dispose(this._tree);
  111027. lifecycle_1.dispose(this._previewModelReference);
  111028. this._splitView.dispose();
  111029. _super.prototype.dispose.call(this);
  111030. };
  111031. ReferenceWidget.prototype._applyTheme = function (theme) {
  111032. var borderColor = theme.getColor(peekView.peekViewBorder) || color_1.Color.transparent;
  111033. this.style({
  111034. arrowColor: borderColor,
  111035. frameColor: borderColor,
  111036. headerBackgroundColor: theme.getColor(peekView.peekViewTitleBackground) || color_1.Color.transparent,
  111037. primaryHeadingColor: theme.getColor(peekView.peekViewTitleForeground),
  111038. secondaryHeadingColor: theme.getColor(peekView.peekViewTitleInfoForeground)
  111039. });
  111040. };
  111041. ReferenceWidget.prototype.show = function (where) {
  111042. this.editor.revealRangeInCenterIfOutsideViewport(where, 0 /* Smooth */);
  111043. _super.prototype.show.call(this, where, this.layoutData.heightInLines || 18);
  111044. };
  111045. ReferenceWidget.prototype.focusOnReferenceTree = function () {
  111046. this._tree.domFocus();
  111047. };
  111048. ReferenceWidget.prototype.focusOnPreviewEditor = function () {
  111049. this._preview.focus();
  111050. };
  111051. ReferenceWidget.prototype.isPreviewEditorFocused = function () {
  111052. return this._preview.hasTextFocus();
  111053. };
  111054. ReferenceWidget.prototype._onTitleClick = function (e) {
  111055. if (this._preview && this._preview.getModel()) {
  111056. this._onDidSelectReference.fire({
  111057. element: this._getFocusedReference(),
  111058. kind: e.ctrlKey || e.metaKey || e.altKey ? 'side' : 'open',
  111059. source: 'title'
  111060. });
  111061. }
  111062. };
  111063. ReferenceWidget.prototype._fillBody = function (containerElement) {
  111064. var _this = this;
  111065. this.setCssClass('reference-zone-widget');
  111066. // message pane
  111067. this._messageContainer = dom.append(containerElement, dom.$('div.messages'));
  111068. dom.hide(this._messageContainer);
  111069. this._splitView = new splitview_1.SplitView(containerElement, { orientation: 1 /* HORIZONTAL */ });
  111070. // editor
  111071. this._previewContainer = dom.append(containerElement, dom.$('div.preview.inline'));
  111072. var options = {
  111073. scrollBeyondLastLine: false,
  111074. scrollbar: {
  111075. verticalScrollbarSize: 14,
  111076. horizontal: 'auto',
  111077. useShadows: true,
  111078. verticalHasArrows: false,
  111079. horizontalHasArrows: false,
  111080. alwaysConsumeMouseWheel: false
  111081. },
  111082. overviewRulerLanes: 2,
  111083. fixedOverflowWidgets: true,
  111084. minimap: {
  111085. enabled: false
  111086. }
  111087. };
  111088. this._preview = this._instantiationService.createInstance(embeddedCodeEditorWidget_1.EmbeddedCodeEditorWidget, this._previewContainer, options, this.editor);
  111089. dom.hide(this._previewContainer);
  111090. this._previewNotAvailableMessage = textModel_1.TextModel.createFromString(nls.localize(0, null));
  111091. // tree
  111092. this._treeContainer = dom.append(containerElement, dom.$('div.ref-tree.inline'));
  111093. var treeOptions = {
  111094. ariaLabel: nls.localize(1, null),
  111095. keyboardSupport: this._defaultTreeKeyboardSupport,
  111096. accessibilityProvider: new referencesTree_1.AriaProvider(),
  111097. keyboardNavigationLabelProvider: this._instantiationService.createInstance(referencesTree_1.StringRepresentationProvider),
  111098. identityProvider: new referencesTree_1.IdentityProvider(),
  111099. overrideStyles: {
  111100. listBackground: peekView.peekViewResultsBackground
  111101. }
  111102. };
  111103. this._tree = this._instantiationService.createInstance(listService_1.WorkbenchAsyncDataTree, 'ReferencesWidget', this._treeContainer, new referencesTree_1.Delegate(), [
  111104. this._instantiationService.createInstance(referencesTree_1.FileReferencesRenderer),
  111105. this._instantiationService.createInstance(referencesTree_1.OneReferenceRenderer),
  111106. ], this._instantiationService.createInstance(referencesTree_1.DataSource), treeOptions);
  111107. // split stuff
  111108. this._splitView.addView({
  111109. onDidChange: event_1.Event.None,
  111110. element: this._previewContainer,
  111111. minimumSize: 200,
  111112. maximumSize: Number.MAX_VALUE,
  111113. layout: function (width) {
  111114. _this._preview.layout({ height: _this._dim.height, width: width });
  111115. }
  111116. }, splitview_1.Sizing.Distribute);
  111117. this._splitView.addView({
  111118. onDidChange: event_1.Event.None,
  111119. element: this._treeContainer,
  111120. minimumSize: 100,
  111121. maximumSize: Number.MAX_VALUE,
  111122. layout: function (width) {
  111123. _this._treeContainer.style.height = _this._dim.height + "px";
  111124. _this._treeContainer.style.width = width + "px";
  111125. _this._tree.layout(_this._dim.height, width);
  111126. }
  111127. }, splitview_1.Sizing.Distribute);
  111128. this._disposables.add(this._splitView.onDidSashChange(function () {
  111129. if (_this._dim.width) {
  111130. _this.layoutData.ratio = _this._splitView.getViewSize(0) / _this._dim.width;
  111131. }
  111132. }, undefined));
  111133. // listen on selection and focus
  111134. var onEvent = function (element, kind) {
  111135. if (element instanceof referencesModel_1.OneReference) {
  111136. if (kind === 'show') {
  111137. _this._revealReference(element, false);
  111138. }
  111139. _this._onDidSelectReference.fire({ element: element, kind: kind, source: 'tree' });
  111140. }
  111141. };
  111142. this._tree.onDidChangeFocus(function (e) {
  111143. onEvent(e.elements[0], 'show');
  111144. });
  111145. this._tree.onDidOpen(function (e) {
  111146. if (e.browserEvent instanceof MouseEvent && (e.browserEvent.ctrlKey || e.browserEvent.metaKey || e.browserEvent.altKey)) {
  111147. // modifier-click -> open to the side
  111148. onEvent(e.elements[0], 'side');
  111149. }
  111150. else if (e.browserEvent instanceof KeyboardEvent || (e.browserEvent instanceof MouseEvent && e.browserEvent.detail === 2) || e.browserEvent.tapCount === 2) {
  111151. // keybinding (list service command)
  111152. // OR double click
  111153. // OR double tap
  111154. // -> close widget and goto target
  111155. onEvent(e.elements[0], 'goto');
  111156. }
  111157. else {
  111158. // preview location
  111159. onEvent(e.elements[0], 'show');
  111160. }
  111161. });
  111162. dom.hide(this._treeContainer);
  111163. };
  111164. ReferenceWidget.prototype._onWidth = function (width) {
  111165. if (this._dim) {
  111166. this._doLayoutBody(this._dim.height, width);
  111167. }
  111168. };
  111169. ReferenceWidget.prototype._doLayoutBody = function (heightInPixel, widthInPixel) {
  111170. _super.prototype._doLayoutBody.call(this, heightInPixel, widthInPixel);
  111171. this._dim = { height: heightInPixel, width: widthInPixel };
  111172. this.layoutData.heightInLines = this._viewZone ? this._viewZone.heightInLines : this.layoutData.heightInLines;
  111173. this._splitView.layout(widthInPixel);
  111174. this._splitView.resizeView(0, widthInPixel * this.layoutData.ratio);
  111175. };
  111176. ReferenceWidget.prototype.setSelection = function (selection) {
  111177. var _this = this;
  111178. return this._revealReference(selection, true).then(function () {
  111179. if (!_this._model) {
  111180. // disposed
  111181. return;
  111182. }
  111183. // show in tree
  111184. _this._tree.setSelection([selection]);
  111185. _this._tree.setFocus([selection]);
  111186. });
  111187. };
  111188. ReferenceWidget.prototype.setModel = function (newModel) {
  111189. // clean up
  111190. this._disposeOnNewModel.clear();
  111191. this._model = newModel;
  111192. if (this._model) {
  111193. return this._onNewModel();
  111194. }
  111195. return Promise.resolve();
  111196. };
  111197. ReferenceWidget.prototype._onNewModel = function () {
  111198. var _this = this;
  111199. if (!this._model) {
  111200. return Promise.resolve(undefined);
  111201. }
  111202. if (this._model.isEmpty) {
  111203. this.setTitle('');
  111204. this._messageContainer.innerHTML = nls.localize(2, null);
  111205. dom.show(this._messageContainer);
  111206. return Promise.resolve(undefined);
  111207. }
  111208. dom.hide(this._messageContainer);
  111209. this._decorationsManager = new DecorationsManager(this._preview, this._model);
  111210. this._disposeOnNewModel.add(this._decorationsManager);
  111211. // listen on model changes
  111212. this._disposeOnNewModel.add(this._model.onDidChangeReferenceRange(function (reference) { return _this._tree.rerender(reference); }));
  111213. // listen on editor
  111214. this._disposeOnNewModel.add(this._preview.onMouseDown(function (e) {
  111215. var event = e.event, target = e.target;
  111216. if (event.detail !== 2) {
  111217. return;
  111218. }
  111219. var element = _this._getFocusedReference();
  111220. if (!element) {
  111221. return;
  111222. }
  111223. _this._onDidSelectReference.fire({
  111224. element: { uri: element.uri, range: target.range },
  111225. kind: (event.ctrlKey || event.metaKey || event.altKey) ? 'side' : 'open',
  111226. source: 'editor'
  111227. });
  111228. }));
  111229. // make sure things are rendered
  111230. dom.addClass(this.container, 'results-loaded');
  111231. dom.show(this._treeContainer);
  111232. dom.show(this._previewContainer);
  111233. this._splitView.layout(this._dim.width);
  111234. this.focusOnReferenceTree();
  111235. // pick input and a reference to begin with
  111236. return this._tree.setInput(this._model.groups.length === 1 ? this._model.groups[0] : this._model);
  111237. };
  111238. ReferenceWidget.prototype._getFocusedReference = function () {
  111239. var element = this._tree.getFocus()[0];
  111240. if (element instanceof referencesModel_1.OneReference) {
  111241. return element;
  111242. }
  111243. else if (element instanceof referencesModel_1.FileReferences) {
  111244. if (element.children.length > 0) {
  111245. return element.children[0];
  111246. }
  111247. }
  111248. return undefined;
  111249. };
  111250. ReferenceWidget.prototype._revealReference = function (reference, revealParent) {
  111251. return __awaiter(this, void 0, void 0, function () {
  111252. var promise, ref, model, scrollType, sel;
  111253. return __generator(this, function (_a) {
  111254. switch (_a.label) {
  111255. case 0:
  111256. // check if there is anything to do...
  111257. if (this._revealedReference === reference) {
  111258. return [2 /*return*/];
  111259. }
  111260. this._revealedReference = reference;
  111261. // Update widget header
  111262. if (reference.uri.scheme !== network_1.Schemas.inMemory) {
  111263. this.setTitle(resources_1.basenameOrAuthority(reference.uri), this._uriLabel.getUriLabel(resources_1.dirname(reference.uri)));
  111264. }
  111265. else {
  111266. this.setTitle(nls.localize(3, null));
  111267. }
  111268. promise = this._textModelResolverService.createModelReference(reference.uri);
  111269. if (!(this._tree.getInput() === reference.parent)) return [3 /*break*/, 1];
  111270. this._tree.reveal(reference);
  111271. return [3 /*break*/, 3];
  111272. case 1:
  111273. if (revealParent) {
  111274. this._tree.reveal(reference.parent);
  111275. }
  111276. return [4 /*yield*/, this._tree.expand(reference.parent)];
  111277. case 2:
  111278. _a.sent();
  111279. this._tree.reveal(reference);
  111280. _a.label = 3;
  111281. case 3: return [4 /*yield*/, promise];
  111282. case 4:
  111283. ref = _a.sent();
  111284. if (!this._model) {
  111285. // disposed
  111286. ref.dispose();
  111287. return [2 /*return*/];
  111288. }
  111289. lifecycle_1.dispose(this._previewModelReference);
  111290. model = ref.object;
  111291. if (model) {
  111292. scrollType = this._preview.getModel() === model.textEditorModel ? 0 /* Smooth */ : 1 /* Immediate */;
  111293. sel = range_1.Range.lift(reference.range).collapseToStart();
  111294. this._previewModelReference = ref;
  111295. this._preview.setModel(model.textEditorModel);
  111296. this._preview.setSelection(sel);
  111297. this._preview.revealRangeInCenter(sel, scrollType);
  111298. }
  111299. else {
  111300. this._preview.setModel(this._previewNotAvailableMessage);
  111301. ref.dispose();
  111302. }
  111303. return [2 /*return*/];
  111304. }
  111305. });
  111306. });
  111307. };
  111308. ReferenceWidget = __decorate([
  111309. __param(3, themeService_1.IThemeService),
  111310. __param(4, resolverService_1.ITextModelService),
  111311. __param(5, instantiation_1.IInstantiationService),
  111312. __param(6, peekView.IPeekViewService),
  111313. __param(7, label_1.ILabelService)
  111314. ], ReferenceWidget);
  111315. return ReferenceWidget;
  111316. }(peekView.PeekViewWidget));
  111317. exports.ReferenceWidget = ReferenceWidget;
  111318. // theming
  111319. themeService_1.registerThemingParticipant(function (theme, collector) {
  111320. var findMatchHighlightColor = theme.getColor(peekView.peekViewResultsMatchHighlight);
  111321. if (findMatchHighlightColor) {
  111322. collector.addRule(".monaco-editor .reference-zone-widget .ref-tree .referenceMatch .highlight { background-color: " + findMatchHighlightColor + "; }");
  111323. }
  111324. var referenceHighlightColor = theme.getColor(peekView.peekViewEditorMatchHighlight);
  111325. if (referenceHighlightColor) {
  111326. collector.addRule(".monaco-editor .reference-zone-widget .preview .reference-decoration { background-color: " + referenceHighlightColor + "; }");
  111327. }
  111328. var referenceHighlightBorder = theme.getColor(peekView.peekViewEditorMatchHighlightBorder);
  111329. if (referenceHighlightBorder) {
  111330. collector.addRule(".monaco-editor .reference-zone-widget .preview .reference-decoration { border: 2px solid " + referenceHighlightBorder + "; box-sizing: border-box; }");
  111331. }
  111332. var hcOutline = theme.getColor(colorRegistry_1.activeContrastBorder);
  111333. if (hcOutline) {
  111334. collector.addRule(".monaco-editor .reference-zone-widget .ref-tree .referenceMatch .highlight { border: 1px dotted " + hcOutline + "; box-sizing: border-box; }");
  111335. }
  111336. var resultsBackground = theme.getColor(peekView.peekViewResultsBackground);
  111337. if (resultsBackground) {
  111338. collector.addRule(".monaco-editor .reference-zone-widget .ref-tree { background-color: " + resultsBackground + "; }");
  111339. }
  111340. var resultsMatchForeground = theme.getColor(peekView.peekViewResultsMatchForeground);
  111341. if (resultsMatchForeground) {
  111342. collector.addRule(".monaco-editor .reference-zone-widget .ref-tree { color: " + resultsMatchForeground + "; }");
  111343. }
  111344. var resultsFileForeground = theme.getColor(peekView.peekViewResultsFileForeground);
  111345. if (resultsFileForeground) {
  111346. collector.addRule(".monaco-editor .reference-zone-widget .ref-tree .reference-file { color: " + resultsFileForeground + "; }");
  111347. }
  111348. var resultsSelectedBackground = theme.getColor(peekView.peekViewResultsSelectionBackground);
  111349. if (resultsSelectedBackground) {
  111350. collector.addRule(".monaco-editor .reference-zone-widget .ref-tree .monaco-list:focus .monaco-list-rows > .monaco-list-row.selected:not(.highlighted) { background-color: " + resultsSelectedBackground + "; }");
  111351. }
  111352. var resultsSelectedForeground = theme.getColor(peekView.peekViewResultsSelectionForeground);
  111353. if (resultsSelectedForeground) {
  111354. collector.addRule(".monaco-editor .reference-zone-widget .ref-tree .monaco-list:focus .monaco-list-rows > .monaco-list-row.selected:not(.highlighted) { color: " + resultsSelectedForeground + " !important; }");
  111355. }
  111356. var editorBackground = theme.getColor(peekView.peekViewEditorBackground);
  111357. if (editorBackground) {
  111358. collector.addRule(".monaco-editor .reference-zone-widget .preview .monaco-editor .monaco-editor-background," +
  111359. ".monaco-editor .reference-zone-widget .preview .monaco-editor .inputarea.ime-input {" +
  111360. ("\tbackground-color: " + editorBackground + ";") +
  111361. "}");
  111362. }
  111363. var editorGutterBackground = theme.getColor(peekView.peekViewEditorGutterBackground);
  111364. if (editorGutterBackground) {
  111365. collector.addRule(".monaco-editor .reference-zone-widget .preview .monaco-editor .margin {" +
  111366. ("\tbackground-color: " + editorGutterBackground + ";") +
  111367. "}");
  111368. }
  111369. });
  111370. });
  111371. /*---------------------------------------------------------------------------------------------
  111372. * Copyright (c) Microsoft Corporation. All rights reserved.
  111373. * Licensed under the MIT License. See License.txt in the project root for license information.
  111374. *--------------------------------------------------------------------------------------------*/
  111375. define(__m[234/*vs/editor/contrib/gotoSymbol/peek/referencesController*/], __M([0/*require*/,1/*exports*/,448/*vs/nls!vs/editor/contrib/gotoSymbol/peek/referencesController*/,10/*vs/base/common/errors*/,2/*vs/base/common/lifecycle*/,32/*vs/editor/browser/services/codeEditorService*/,11/*vs/platform/instantiation/common/instantiation*/,18/*vs/platform/contextkey/common/contextkey*/,43/*vs/platform/configuration/common/configuration*/,74/*vs/platform/storage/common/storage*/,113/*vs/editor/contrib/gotoSymbol/referencesModel*/,596/*vs/editor/contrib/gotoSymbol/peek/referencesWidget*/,3/*vs/editor/common/core/range*/,13/*vs/editor/common/core/position*/,35/*vs/platform/notification/common/notification*/,15/*vs/base/common/async*/,123/*vs/editor/contrib/peekView/peekView*/,170/*vs/platform/list/browser/listService*/,86/*vs/platform/keybinding/common/keybindingsRegistry*/,36/*vs/base/common/keyCodes*/,29/*vs/platform/commands/common/commands*/]), function (require, exports, nls, errors_1, lifecycle_1, codeEditorService_1, instantiation_1, contextkey_1, configuration_1, storage_1, referencesModel_1, referencesWidget_1, range_1, position_1, notification_1, async_1, peekView_1, listService_1, keybindingsRegistry_1, keyCodes_1, commands_1) {
  111376. "use strict";
  111377. Object.defineProperty(exports, "__esModule", { value: true });
  111378. exports.ctxReferenceSearchVisible = new contextkey_1.RawContextKey('referenceSearchVisible', false);
  111379. var ReferencesController = /** @class */ (function () {
  111380. function ReferencesController(_defaultTreeKeyboardSupport, _editor, contextKeyService, _editorService, _notificationService, _instantiationService, _storageService, _configurationService) {
  111381. this._defaultTreeKeyboardSupport = _defaultTreeKeyboardSupport;
  111382. this._editor = _editor;
  111383. this._editorService = _editorService;
  111384. this._notificationService = _notificationService;
  111385. this._instantiationService = _instantiationService;
  111386. this._storageService = _storageService;
  111387. this._configurationService = _configurationService;
  111388. this._disposables = new lifecycle_1.DisposableStore();
  111389. this._requestIdPool = 0;
  111390. this._ignoreModelChangeEvent = false;
  111391. this._referenceSearchVisible = exports.ctxReferenceSearchVisible.bindTo(contextKeyService);
  111392. }
  111393. ReferencesController.get = function (editor) {
  111394. return editor.getContribution(ReferencesController.ID);
  111395. };
  111396. ReferencesController.prototype.dispose = function () {
  111397. this._referenceSearchVisible.reset();
  111398. this._disposables.dispose();
  111399. lifecycle_1.dispose(this._widget);
  111400. lifecycle_1.dispose(this._model);
  111401. this._widget = undefined;
  111402. this._model = undefined;
  111403. };
  111404. ReferencesController.prototype.toggleWidget = function (range, modelPromise, peekMode) {
  111405. var _this = this;
  111406. // close current widget and return early is position didn't change
  111407. var widgetPosition;
  111408. if (this._widget) {
  111409. widgetPosition = this._widget.position;
  111410. }
  111411. this.closeWidget();
  111412. if (!!widgetPosition && range.containsPosition(widgetPosition)) {
  111413. return;
  111414. }
  111415. this._peekMode = peekMode;
  111416. this._referenceSearchVisible.set(true);
  111417. // close the widget on model/mode changes
  111418. this._disposables.add(this._editor.onDidChangeModelLanguage(function () { _this.closeWidget(); }));
  111419. this._disposables.add(this._editor.onDidChangeModel(function () {
  111420. if (!_this._ignoreModelChangeEvent) {
  111421. _this.closeWidget();
  111422. }
  111423. }));
  111424. var storageKey = 'peekViewLayout';
  111425. var data = referencesWidget_1.LayoutData.fromJSON(this._storageService.get(storageKey, 0 /* GLOBAL */, '{}'));
  111426. this._widget = this._instantiationService.createInstance(referencesWidget_1.ReferenceWidget, this._editor, this._defaultTreeKeyboardSupport, data);
  111427. this._widget.setTitle(nls.localize(0, null));
  111428. this._widget.show(range);
  111429. this._disposables.add(this._widget.onDidClose(function () {
  111430. modelPromise.cancel();
  111431. if (_this._widget) {
  111432. _this._storageService.store(storageKey, JSON.stringify(_this._widget.layoutData), 0 /* GLOBAL */);
  111433. _this._widget = undefined;
  111434. }
  111435. _this.closeWidget();
  111436. }));
  111437. this._disposables.add(this._widget.onDidSelectReference(function (event) {
  111438. var element = event.element, kind = event.kind;
  111439. if (!element) {
  111440. return;
  111441. }
  111442. switch (kind) {
  111443. case 'open':
  111444. if (event.source !== 'editor' || !_this._configurationService.getValue('editor.stablePeek')) {
  111445. // when stable peek is configured we don't close
  111446. // the peek window on selecting the editor
  111447. _this.openReference(element, false);
  111448. }
  111449. break;
  111450. case 'side':
  111451. _this.openReference(element, true);
  111452. break;
  111453. case 'goto':
  111454. if (peekMode) {
  111455. _this._gotoReference(element);
  111456. }
  111457. else {
  111458. _this.openReference(element, false);
  111459. }
  111460. break;
  111461. }
  111462. }));
  111463. var requestId = ++this._requestIdPool;
  111464. modelPromise.then(function (model) {
  111465. // still current request? widget still open?
  111466. if (requestId !== _this._requestIdPool || !_this._widget) {
  111467. return undefined;
  111468. }
  111469. if (_this._model) {
  111470. _this._model.dispose();
  111471. }
  111472. _this._model = model;
  111473. // show widget
  111474. return _this._widget.setModel(_this._model).then(function () {
  111475. if (_this._widget && _this._model && _this._editor.hasModel()) { // might have been closed
  111476. // set title
  111477. if (!_this._model.isEmpty) {
  111478. _this._widget.setMetaTitle(nls.localize(1, null, _this._model.title, _this._model.references.length));
  111479. }
  111480. else {
  111481. _this._widget.setMetaTitle('');
  111482. }
  111483. // set 'best' selection
  111484. var uri = _this._editor.getModel().uri;
  111485. var pos = new position_1.Position(range.startLineNumber, range.startColumn);
  111486. var selection = _this._model.nearestReference(uri, pos);
  111487. if (selection) {
  111488. return _this._widget.setSelection(selection).then(function () {
  111489. if (_this._widget && _this._editor.getOption(65 /* peekWidgetDefaultFocus */) === 'editor') {
  111490. _this._widget.focusOnPreviewEditor();
  111491. }
  111492. });
  111493. }
  111494. }
  111495. return undefined;
  111496. });
  111497. }, function (error) {
  111498. _this._notificationService.error(error);
  111499. });
  111500. };
  111501. ReferencesController.prototype.changeFocusBetweenPreviewAndReferences = function () {
  111502. if (!this._widget) {
  111503. // can be called while still resolving...
  111504. return;
  111505. }
  111506. if (this._widget.isPreviewEditorFocused()) {
  111507. this._widget.focusOnReferenceTree();
  111508. }
  111509. else {
  111510. this._widget.focusOnPreviewEditor();
  111511. }
  111512. };
  111513. ReferencesController.prototype.goToNextOrPreviousReference = function (fwd) {
  111514. return __awaiter(this, void 0, void 0, function () {
  111515. var currentPosition, source, target, editorFocus, previewEditorFocus;
  111516. return __generator(this, function (_a) {
  111517. switch (_a.label) {
  111518. case 0:
  111519. if (!this._editor.hasModel() || !this._model || !this._widget) {
  111520. // can be called while still resolving...
  111521. return [2 /*return*/];
  111522. }
  111523. currentPosition = this._widget.position;
  111524. if (!currentPosition) {
  111525. return [2 /*return*/];
  111526. }
  111527. source = this._model.nearestReference(this._editor.getModel().uri, currentPosition);
  111528. if (!source) {
  111529. return [2 /*return*/];
  111530. }
  111531. target = this._model.nextOrPreviousReference(source, fwd);
  111532. editorFocus = this._editor.hasTextFocus();
  111533. previewEditorFocus = this._widget.isPreviewEditorFocused();
  111534. return [4 /*yield*/, this._widget.setSelection(target)];
  111535. case 1:
  111536. _a.sent();
  111537. return [4 /*yield*/, this._gotoReference(target)];
  111538. case 2:
  111539. _a.sent();
  111540. if (editorFocus) {
  111541. this._editor.focus();
  111542. }
  111543. else if (this._widget && previewEditorFocus) {
  111544. this._widget.focusOnPreviewEditor();
  111545. }
  111546. return [2 /*return*/];
  111547. }
  111548. });
  111549. });
  111550. };
  111551. ReferencesController.prototype.closeWidget = function (focusEditor) {
  111552. if (focusEditor === void 0) { focusEditor = true; }
  111553. this._referenceSearchVisible.reset();
  111554. this._disposables.clear();
  111555. lifecycle_1.dispose(this._widget);
  111556. lifecycle_1.dispose(this._model);
  111557. this._widget = undefined;
  111558. this._model = undefined;
  111559. if (focusEditor) {
  111560. this._editor.focus();
  111561. }
  111562. this._requestIdPool += 1; // Cancel pending requests
  111563. };
  111564. ReferencesController.prototype._gotoReference = function (ref) {
  111565. var _this = this;
  111566. if (this._widget) {
  111567. this._widget.hide();
  111568. }
  111569. this._ignoreModelChangeEvent = true;
  111570. var range = range_1.Range.lift(ref.range).collapseToStart();
  111571. return this._editorService.openCodeEditor({
  111572. resource: ref.uri,
  111573. options: { selection: range }
  111574. }, this._editor).then(function (openedEditor) {
  111575. var _a;
  111576. _this._ignoreModelChangeEvent = false;
  111577. if (!openedEditor || !_this._widget) {
  111578. // something went wrong...
  111579. _this.closeWidget();
  111580. return;
  111581. }
  111582. if (_this._editor === openedEditor) {
  111583. //
  111584. _this._widget.show(range);
  111585. _this._widget.focusOnReferenceTree();
  111586. }
  111587. else {
  111588. // we opened a different editor instance which means a different controller instance.
  111589. // therefore we stop with this controller and continue with the other
  111590. var other = ReferencesController.get(openedEditor);
  111591. var model_1 = _this._model.clone();
  111592. _this.closeWidget();
  111593. openedEditor.focus();
  111594. other.toggleWidget(range, async_1.createCancelablePromise(function (_) { return Promise.resolve(model_1); }), (_a = _this._peekMode) !== null && _a !== void 0 ? _a : false);
  111595. }
  111596. }, function (err) {
  111597. _this._ignoreModelChangeEvent = false;
  111598. errors_1.onUnexpectedError(err);
  111599. });
  111600. };
  111601. ReferencesController.prototype.openReference = function (ref, sideBySide) {
  111602. // clear stage
  111603. if (!sideBySide) {
  111604. this.closeWidget();
  111605. }
  111606. var uri = ref.uri, range = ref.range;
  111607. this._editorService.openCodeEditor({
  111608. resource: uri,
  111609. options: { selection: range }
  111610. }, this._editor, sideBySide);
  111611. };
  111612. ReferencesController.ID = 'editor.contrib.referencesController';
  111613. ReferencesController = __decorate([
  111614. __param(2, contextkey_1.IContextKeyService),
  111615. __param(3, codeEditorService_1.ICodeEditorService),
  111616. __param(4, notification_1.INotificationService),
  111617. __param(5, instantiation_1.IInstantiationService),
  111618. __param(6, storage_1.IStorageService),
  111619. __param(7, configuration_1.IConfigurationService)
  111620. ], ReferencesController);
  111621. return ReferencesController;
  111622. }());
  111623. exports.ReferencesController = ReferencesController;
  111624. function withController(accessor, fn) {
  111625. var outerEditor = peekView_1.getOuterEditor(accessor);
  111626. if (!outerEditor) {
  111627. return;
  111628. }
  111629. var controller = ReferencesController.get(outerEditor);
  111630. if (controller) {
  111631. fn(controller);
  111632. }
  111633. }
  111634. keybindingsRegistry_1.KeybindingsRegistry.registerCommandAndKeybindingRule({
  111635. id: 'togglePeekWidgetFocus',
  111636. weight: 100 /* EditorContrib */,
  111637. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 60 /* F2 */),
  111638. when: contextkey_1.ContextKeyExpr.or(exports.ctxReferenceSearchVisible, peekView_1.PeekContext.inPeekEditor),
  111639. handler: function (accessor) {
  111640. withController(accessor, function (controller) {
  111641. controller.changeFocusBetweenPreviewAndReferences();
  111642. });
  111643. }
  111644. });
  111645. keybindingsRegistry_1.KeybindingsRegistry.registerCommandAndKeybindingRule({
  111646. id: 'goToNextReference',
  111647. weight: 100 /* EditorContrib */ - 10,
  111648. primary: 62 /* F4 */,
  111649. secondary: [70 /* F12 */],
  111650. when: contextkey_1.ContextKeyExpr.or(exports.ctxReferenceSearchVisible, peekView_1.PeekContext.inPeekEditor),
  111651. handler: function (accessor) {
  111652. withController(accessor, function (controller) {
  111653. controller.goToNextOrPreviousReference(true);
  111654. });
  111655. }
  111656. });
  111657. keybindingsRegistry_1.KeybindingsRegistry.registerCommandAndKeybindingRule({
  111658. id: 'goToPreviousReference',
  111659. weight: 100 /* EditorContrib */ - 10,
  111660. primary: 1024 /* Shift */ | 62 /* F4 */,
  111661. secondary: [1024 /* Shift */ | 70 /* F12 */],
  111662. when: contextkey_1.ContextKeyExpr.or(exports.ctxReferenceSearchVisible, peekView_1.PeekContext.inPeekEditor),
  111663. handler: function (accessor) {
  111664. withController(accessor, function (controller) {
  111665. controller.goToNextOrPreviousReference(false);
  111666. });
  111667. }
  111668. });
  111669. // commands that aren't needed anymore because there is now ContextKeyExpr.OR
  111670. commands_1.CommandsRegistry.registerCommandAlias('goToNextReferenceFromEmbeddedEditor', 'goToNextReference');
  111671. commands_1.CommandsRegistry.registerCommandAlias('goToPreviousReferenceFromEmbeddedEditor', 'goToPreviousReference');
  111672. // close
  111673. commands_1.CommandsRegistry.registerCommandAlias('closeReferenceSearchEditor', 'closeReferenceSearch');
  111674. commands_1.CommandsRegistry.registerCommand('closeReferenceSearch', function (accessor) { return withController(accessor, function (controller) { return controller.closeWidget(); }); });
  111675. keybindingsRegistry_1.KeybindingsRegistry.registerKeybindingRule({
  111676. id: 'closeReferenceSearch',
  111677. weight: 100 /* EditorContrib */ - 101,
  111678. primary: 9 /* Escape */,
  111679. secondary: [1024 /* Shift */ | 9 /* Escape */],
  111680. when: contextkey_1.ContextKeyExpr.and(peekView_1.PeekContext.inPeekEditor, contextkey_1.ContextKeyExpr.not('config.editor.stablePeek'))
  111681. });
  111682. keybindingsRegistry_1.KeybindingsRegistry.registerKeybindingRule({
  111683. id: 'closeReferenceSearch',
  111684. weight: 200 /* WorkbenchContrib */ + 50,
  111685. primary: 9 /* Escape */,
  111686. secondary: [1024 /* Shift */ | 9 /* Escape */],
  111687. when: contextkey_1.ContextKeyExpr.and(exports.ctxReferenceSearchVisible, contextkey_1.ContextKeyExpr.not('config.editor.stablePeek'))
  111688. });
  111689. keybindingsRegistry_1.KeybindingsRegistry.registerCommandAndKeybindingRule({
  111690. id: 'openReferenceToSide',
  111691. weight: 100 /* EditorContrib */,
  111692. primary: 2048 /* CtrlCmd */ | 3 /* Enter */,
  111693. mac: {
  111694. primary: 256 /* WinCtrl */ | 3 /* Enter */
  111695. },
  111696. when: contextkey_1.ContextKeyExpr.and(exports.ctxReferenceSearchVisible, listService_1.WorkbenchListFocusContextKey),
  111697. handler: function (accessor) {
  111698. var _a;
  111699. var listService = accessor.get(listService_1.IListService);
  111700. var focus = (_a = listService.lastFocusedList) === null || _a === void 0 ? void 0 : _a.getFocus();
  111701. if (Array.isArray(focus) && focus[0] instanceof referencesModel_1.OneReference) {
  111702. withController(accessor, function (controller) { return controller.openReference(focus[0], true); });
  111703. }
  111704. }
  111705. });
  111706. commands_1.CommandsRegistry.registerCommand('openReference', function (accessor) {
  111707. var _a;
  111708. var listService = accessor.get(listService_1.IListService);
  111709. var focus = (_a = listService.lastFocusedList) === null || _a === void 0 ? void 0 : _a.getFocus();
  111710. if (Array.isArray(focus) && focus[0] instanceof referencesModel_1.OneReference) {
  111711. withController(accessor, function (controller) { return controller.openReference(focus[0], false); });
  111712. }
  111713. });
  111714. });
  111715. /*---------------------------------------------------------------------------------------------
  111716. * Copyright (c) Microsoft Corporation. All rights reserved.
  111717. * Licensed under the MIT License. See License.txt in the project root for license information.
  111718. *--------------------------------------------------------------------------------------------*/
  111719. define(__m[235/*vs/editor/contrib/gotoSymbol/goToCommands*/], __M([0/*require*/,1/*exports*/,50/*vs/base/browser/ui/aria/aria*/,15/*vs/base/common/async*/,36/*vs/base/common/keyCodes*/,16/*vs/base/common/platform*/,108/*vs/editor/browser/editorBrowser*/,12/*vs/editor/browser/editorExtensions*/,32/*vs/editor/browser/services/codeEditorService*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,23/*vs/editor/common/editorContextKeys*/,17/*vs/editor/common/modes*/,122/*vs/editor/contrib/message/messageController*/,123/*vs/editor/contrib/peekView/peekView*/,234/*vs/editor/contrib/gotoSymbol/peek/referencesController*/,113/*vs/editor/contrib/gotoSymbol/referencesModel*/,446/*vs/nls!vs/editor/contrib/gotoSymbol/goToCommands*/,65/*vs/platform/actions/common/actions*/,18/*vs/platform/contextkey/common/contextkey*/,35/*vs/platform/notification/common/notification*/,73/*vs/platform/progress/common/progress*/,224/*vs/editor/contrib/gotoSymbol/goToSymbol*/,29/*vs/platform/commands/common/commands*/,67/*vs/editor/browser/core/editorState*/,537/*vs/editor/contrib/gotoSymbol/symbolNavigation*/,24/*vs/base/browser/browser*/,25/*vs/base/common/uri*/,11/*vs/platform/instantiation/common/instantiation*/,21/*vs/base/common/types*/,167/*vs/editor/browser/widget/embeddedCodeEditorWidget*/]), function (require, exports, aria_1, async_1, keyCodes_1, platform_1, editorBrowser_1, editorExtensions_1, codeEditorService_1, corePosition, range_1, editorContextKeys_1, modes_1, messageController_1, peekView_1, referencesController_1, referencesModel_1, nls, actions_1, contextkey_1, notification_1, progress_1, goToSymbol_1, commands_1, editorState_1, symbolNavigation_1, browser_1, uri_1, instantiation_1, types_1, embeddedCodeEditorWidget_1) {
  111720. "use strict";
  111721. var _a, _b, _c, _d, _e, _f, _g, _h;
  111722. Object.defineProperty(exports, "__esModule", { value: true });
  111723. actions_1.MenuRegistry.appendMenuItem(7 /* EditorContext */, {
  111724. submenu: 8 /* EditorContextPeek */,
  111725. title: nls.localize(0, null),
  111726. group: 'navigation',
  111727. order: 100
  111728. });
  111729. var SymbolNavigationAction = /** @class */ (function (_super) {
  111730. __extends(SymbolNavigationAction, _super);
  111731. function SymbolNavigationAction(configuration, opts) {
  111732. var _this = _super.call(this, opts) || this;
  111733. _this._configuration = configuration;
  111734. return _this;
  111735. }
  111736. SymbolNavigationAction.prototype.run = function (accessor, editor) {
  111737. var _this = this;
  111738. if (!editor.hasModel()) {
  111739. return Promise.resolve(undefined);
  111740. }
  111741. var notificationService = accessor.get(notification_1.INotificationService);
  111742. var editorService = accessor.get(codeEditorService_1.ICodeEditorService);
  111743. var progressService = accessor.get(progress_1.IEditorProgressService);
  111744. var symbolNavService = accessor.get(symbolNavigation_1.ISymbolNavigationService);
  111745. var model = editor.getModel();
  111746. var pos = editor.getPosition();
  111747. var cts = new editorState_1.EditorStateCancellationTokenSource(editor, 1 /* Value */ | 4 /* Position */);
  111748. var promise = async_1.raceCancellation(this._getLocationModel(model, pos, cts.token), cts.token).then(function (references) { return __awaiter(_this, void 0, void 0, function () {
  111749. var altAction, altActionId, referenceCount, info;
  111750. return __generator(this, function (_a) {
  111751. if (!references || cts.token.isCancellationRequested) {
  111752. return [2 /*return*/];
  111753. }
  111754. aria_1.alert(references.ariaMessage);
  111755. if (references.referenceAt(model.uri, pos)) {
  111756. altActionId = this._getAlternativeCommand(editor);
  111757. if (altActionId !== this.id) {
  111758. altAction = editor.getAction(altActionId);
  111759. }
  111760. }
  111761. referenceCount = references.references.length;
  111762. if (referenceCount === 0) {
  111763. // no result -> show message
  111764. if (!this._configuration.muteMessage) {
  111765. info = model.getWordAtPosition(pos);
  111766. messageController_1.MessageController.get(editor).showMessage(this._getNoResultFoundMessage(info), pos);
  111767. }
  111768. }
  111769. else if (referenceCount === 1 && altAction) {
  111770. // already at the only result, run alternative
  111771. altAction.run();
  111772. }
  111773. else {
  111774. // normal results handling
  111775. return [2 /*return*/, this._onResult(editorService, symbolNavService, editor, references)];
  111776. }
  111777. return [2 /*return*/];
  111778. });
  111779. }); }, function (err) {
  111780. // report an error
  111781. notificationService.error(err);
  111782. }).finally(function () {
  111783. cts.dispose();
  111784. });
  111785. progressService.showWhile(promise, 250);
  111786. return promise;
  111787. };
  111788. SymbolNavigationAction.prototype._onResult = function (editorService, symbolNavService, editor, model) {
  111789. return __awaiter(this, void 0, void 0, function () {
  111790. var gotoLocation, next, peek, targetEditor;
  111791. return __generator(this, function (_a) {
  111792. switch (_a.label) {
  111793. case 0:
  111794. gotoLocation = this._getGoToPreference(editor);
  111795. if (!(!(editor instanceof embeddedCodeEditorWidget_1.EmbeddedCodeEditorWidget) && (this._configuration.openInPeek || (gotoLocation === 'peek' && model.references.length > 1)))) return [3 /*break*/, 1];
  111796. this._openInPeek(editor, model);
  111797. return [3 /*break*/, 3];
  111798. case 1:
  111799. next = model.firstReference();
  111800. peek = model.references.length > 1 && gotoLocation === 'gotoAndPeek';
  111801. return [4 /*yield*/, this._openReference(editor, editorService, next, this._configuration.openToSide, !peek)];
  111802. case 2:
  111803. targetEditor = _a.sent();
  111804. if (peek && targetEditor) {
  111805. this._openInPeek(targetEditor, model);
  111806. }
  111807. else {
  111808. model.dispose();
  111809. }
  111810. // keep remaining locations around when using
  111811. // 'goto'-mode
  111812. if (gotoLocation === 'goto') {
  111813. symbolNavService.put(next);
  111814. }
  111815. _a.label = 3;
  111816. case 3: return [2 /*return*/];
  111817. }
  111818. });
  111819. });
  111820. };
  111821. SymbolNavigationAction.prototype._openReference = function (editor, editorService, reference, sideBySide, highlight) {
  111822. return __awaiter(this, void 0, void 0, function () {
  111823. var range, targetEditor, modelNow_1, ids_1;
  111824. return __generator(this, function (_a) {
  111825. switch (_a.label) {
  111826. case 0:
  111827. range = undefined;
  111828. if (modes_1.isLocationLink(reference)) {
  111829. range = reference.targetSelectionRange;
  111830. }
  111831. if (!range) {
  111832. range = reference.range;
  111833. }
  111834. return [4 /*yield*/, editorService.openCodeEditor({
  111835. resource: reference.uri,
  111836. options: {
  111837. selection: range_1.Range.collapseToStart(range),
  111838. revealInCenterIfOutsideViewport: true
  111839. }
  111840. }, editor, sideBySide)];
  111841. case 1:
  111842. targetEditor = _a.sent();
  111843. if (!targetEditor) {
  111844. return [2 /*return*/, undefined];
  111845. }
  111846. if (highlight) {
  111847. modelNow_1 = targetEditor.getModel();
  111848. ids_1 = targetEditor.deltaDecorations([], [{ range: range, options: { className: 'symbolHighlight' } }]);
  111849. setTimeout(function () {
  111850. if (targetEditor.getModel() === modelNow_1) {
  111851. targetEditor.deltaDecorations(ids_1, []);
  111852. }
  111853. }, 350);
  111854. }
  111855. return [2 /*return*/, targetEditor];
  111856. }
  111857. });
  111858. });
  111859. };
  111860. SymbolNavigationAction.prototype._openInPeek = function (target, model) {
  111861. var controller = referencesController_1.ReferencesController.get(target);
  111862. if (controller && target.hasModel()) {
  111863. controller.toggleWidget(target.getSelection(), async_1.createCancelablePromise(function (_) { return Promise.resolve(model); }), this._configuration.openInPeek);
  111864. }
  111865. else {
  111866. model.dispose();
  111867. }
  111868. };
  111869. return SymbolNavigationAction;
  111870. }(editorExtensions_1.EditorAction));
  111871. //#region --- DEFINITION
  111872. var DefinitionAction = /** @class */ (function (_super) {
  111873. __extends(DefinitionAction, _super);
  111874. function DefinitionAction() {
  111875. return _super !== null && _super.apply(this, arguments) || this;
  111876. }
  111877. DefinitionAction.prototype._getLocationModel = function (model, position, token) {
  111878. return __awaiter(this, void 0, void 0, function () {
  111879. var _a;
  111880. return __generator(this, function (_b) {
  111881. switch (_b.label) {
  111882. case 0:
  111883. _a = referencesModel_1.ReferencesModel.bind;
  111884. return [4 /*yield*/, goToSymbol_1.getDefinitionsAtPosition(model, position, token)];
  111885. case 1: return [2 /*return*/, new (_a.apply(referencesModel_1.ReferencesModel, [void 0, _b.sent(), nls.localize(1, null)]))()];
  111886. }
  111887. });
  111888. });
  111889. };
  111890. DefinitionAction.prototype._getNoResultFoundMessage = function (info) {
  111891. return info && info.word
  111892. ? nls.localize(2, null, info.word)
  111893. : nls.localize(3, null);
  111894. };
  111895. DefinitionAction.prototype._getAlternativeCommand = function (editor) {
  111896. return editor.getOption(41 /* gotoLocation */).alternativeDefinitionCommand;
  111897. };
  111898. DefinitionAction.prototype._getGoToPreference = function (editor) {
  111899. return editor.getOption(41 /* gotoLocation */).multipleDefinitions;
  111900. };
  111901. return DefinitionAction;
  111902. }(SymbolNavigationAction));
  111903. exports.DefinitionAction = DefinitionAction;
  111904. var goToDefinitionKb = platform_1.isWeb && !browser_1.isStandalone
  111905. ? 2048 /* CtrlCmd */ | 70 /* F12 */
  111906. : 70 /* F12 */;
  111907. editorExtensions_1.registerEditorAction((_a = /** @class */ (function (_super) {
  111908. __extends(GoToDefinitionAction, _super);
  111909. function GoToDefinitionAction() {
  111910. var _this = _super.call(this, {
  111911. openToSide: false,
  111912. openInPeek: false,
  111913. muteMessage: false
  111914. }, {
  111915. id: GoToDefinitionAction.id,
  111916. label: nls.localize(4, null),
  111917. alias: 'Go to Definition',
  111918. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasDefinitionProvider, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  111919. kbOpts: {
  111920. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  111921. primary: goToDefinitionKb,
  111922. weight: 100 /* EditorContrib */
  111923. },
  111924. contextMenuOpts: {
  111925. group: 'navigation',
  111926. order: 1.1
  111927. },
  111928. menuOpts: {
  111929. menuId: 19 /* MenubarGoMenu */,
  111930. group: '4_symbol_nav',
  111931. order: 2,
  111932. title: nls.localize(5, null)
  111933. }
  111934. }) || this;
  111935. commands_1.CommandsRegistry.registerCommandAlias('editor.action.goToDeclaration', GoToDefinitionAction.id);
  111936. return _this;
  111937. }
  111938. return GoToDefinitionAction;
  111939. }(DefinitionAction)),
  111940. _a.id = 'editor.action.revealDefinition',
  111941. _a));
  111942. editorExtensions_1.registerEditorAction((_b = /** @class */ (function (_super) {
  111943. __extends(OpenDefinitionToSideAction, _super);
  111944. function OpenDefinitionToSideAction() {
  111945. var _this = _super.call(this, {
  111946. openToSide: true,
  111947. openInPeek: false,
  111948. muteMessage: false
  111949. }, {
  111950. id: OpenDefinitionToSideAction.id,
  111951. label: nls.localize(6, null),
  111952. alias: 'Open Definition to the Side',
  111953. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasDefinitionProvider, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  111954. kbOpts: {
  111955. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  111956. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, goToDefinitionKb),
  111957. weight: 100 /* EditorContrib */
  111958. }
  111959. }) || this;
  111960. commands_1.CommandsRegistry.registerCommandAlias('editor.action.openDeclarationToTheSide', OpenDefinitionToSideAction.id);
  111961. return _this;
  111962. }
  111963. return OpenDefinitionToSideAction;
  111964. }(DefinitionAction)),
  111965. _b.id = 'editor.action.revealDefinitionAside',
  111966. _b));
  111967. editorExtensions_1.registerEditorAction((_c = /** @class */ (function (_super) {
  111968. __extends(PeekDefinitionAction, _super);
  111969. function PeekDefinitionAction() {
  111970. var _this = _super.call(this, {
  111971. openToSide: false,
  111972. openInPeek: true,
  111973. muteMessage: false
  111974. }, {
  111975. id: PeekDefinitionAction.id,
  111976. label: nls.localize(7, null),
  111977. alias: 'Peek Definition',
  111978. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasDefinitionProvider, peekView_1.PeekContext.notInPeekEditor, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  111979. kbOpts: {
  111980. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  111981. primary: 512 /* Alt */ | 70 /* F12 */,
  111982. linux: { primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 68 /* F10 */ },
  111983. weight: 100 /* EditorContrib */
  111984. },
  111985. contextMenuOpts: {
  111986. menuId: 8 /* EditorContextPeek */,
  111987. group: 'peek',
  111988. order: 2
  111989. }
  111990. }) || this;
  111991. commands_1.CommandsRegistry.registerCommandAlias('editor.action.previewDeclaration', PeekDefinitionAction.id);
  111992. return _this;
  111993. }
  111994. return PeekDefinitionAction;
  111995. }(DefinitionAction)),
  111996. _c.id = 'editor.action.peekDefinition',
  111997. _c));
  111998. //#endregion
  111999. //#region --- DECLARATION
  112000. var DeclarationAction = /** @class */ (function (_super) {
  112001. __extends(DeclarationAction, _super);
  112002. function DeclarationAction() {
  112003. return _super !== null && _super.apply(this, arguments) || this;
  112004. }
  112005. DeclarationAction.prototype._getLocationModel = function (model, position, token) {
  112006. return __awaiter(this, void 0, void 0, function () {
  112007. var _a;
  112008. return __generator(this, function (_b) {
  112009. switch (_b.label) {
  112010. case 0:
  112011. _a = referencesModel_1.ReferencesModel.bind;
  112012. return [4 /*yield*/, goToSymbol_1.getDeclarationsAtPosition(model, position, token)];
  112013. case 1: return [2 /*return*/, new (_a.apply(referencesModel_1.ReferencesModel, [void 0, _b.sent(), nls.localize(8, null)]))()];
  112014. }
  112015. });
  112016. });
  112017. };
  112018. DeclarationAction.prototype._getNoResultFoundMessage = function (info) {
  112019. return info && info.word
  112020. ? nls.localize(9, null, info.word)
  112021. : nls.localize(10, null);
  112022. };
  112023. DeclarationAction.prototype._getAlternativeCommand = function (editor) {
  112024. return editor.getOption(41 /* gotoLocation */).alternativeDeclarationCommand;
  112025. };
  112026. DeclarationAction.prototype._getGoToPreference = function (editor) {
  112027. return editor.getOption(41 /* gotoLocation */).multipleDeclarations;
  112028. };
  112029. return DeclarationAction;
  112030. }(SymbolNavigationAction));
  112031. editorExtensions_1.registerEditorAction((_d = /** @class */ (function (_super) {
  112032. __extends(GoToDeclarationAction, _super);
  112033. function GoToDeclarationAction() {
  112034. return _super.call(this, {
  112035. openToSide: false,
  112036. openInPeek: false,
  112037. muteMessage: false
  112038. }, {
  112039. id: GoToDeclarationAction.id,
  112040. label: nls.localize(11, null),
  112041. alias: 'Go to Declaration',
  112042. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasDeclarationProvider, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  112043. contextMenuOpts: {
  112044. group: 'navigation',
  112045. order: 1.3
  112046. },
  112047. menuOpts: {
  112048. menuId: 19 /* MenubarGoMenu */,
  112049. group: '4_symbol_nav',
  112050. order: 3,
  112051. title: nls.localize(12, null)
  112052. },
  112053. }) || this;
  112054. }
  112055. GoToDeclarationAction.prototype._getNoResultFoundMessage = function (info) {
  112056. return info && info.word
  112057. ? nls.localize(13, null, info.word)
  112058. : nls.localize(14, null);
  112059. };
  112060. return GoToDeclarationAction;
  112061. }(DeclarationAction)),
  112062. _d.id = 'editor.action.revealDeclaration',
  112063. _d));
  112064. editorExtensions_1.registerEditorAction(/** @class */ (function (_super) {
  112065. __extends(PeekDeclarationAction, _super);
  112066. function PeekDeclarationAction() {
  112067. return _super.call(this, {
  112068. openToSide: false,
  112069. openInPeek: true,
  112070. muteMessage: false
  112071. }, {
  112072. id: 'editor.action.peekDeclaration',
  112073. label: nls.localize(15, null),
  112074. alias: 'Peek Declaration',
  112075. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasDeclarationProvider, peekView_1.PeekContext.notInPeekEditor, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  112076. contextMenuOpts: {
  112077. menuId: 8 /* EditorContextPeek */,
  112078. group: 'peek',
  112079. order: 3
  112080. }
  112081. }) || this;
  112082. }
  112083. return PeekDeclarationAction;
  112084. }(DeclarationAction)));
  112085. //#endregion
  112086. //#region --- TYPE DEFINITION
  112087. var TypeDefinitionAction = /** @class */ (function (_super) {
  112088. __extends(TypeDefinitionAction, _super);
  112089. function TypeDefinitionAction() {
  112090. return _super !== null && _super.apply(this, arguments) || this;
  112091. }
  112092. TypeDefinitionAction.prototype._getLocationModel = function (model, position, token) {
  112093. return __awaiter(this, void 0, void 0, function () {
  112094. var _a;
  112095. return __generator(this, function (_b) {
  112096. switch (_b.label) {
  112097. case 0:
  112098. _a = referencesModel_1.ReferencesModel.bind;
  112099. return [4 /*yield*/, goToSymbol_1.getTypeDefinitionsAtPosition(model, position, token)];
  112100. case 1: return [2 /*return*/, new (_a.apply(referencesModel_1.ReferencesModel, [void 0, _b.sent(), nls.localize(16, null)]))()];
  112101. }
  112102. });
  112103. });
  112104. };
  112105. TypeDefinitionAction.prototype._getNoResultFoundMessage = function (info) {
  112106. return info && info.word
  112107. ? nls.localize(17, null, info.word)
  112108. : nls.localize(18, null);
  112109. };
  112110. TypeDefinitionAction.prototype._getAlternativeCommand = function (editor) {
  112111. return editor.getOption(41 /* gotoLocation */).alternativeTypeDefinitionCommand;
  112112. };
  112113. TypeDefinitionAction.prototype._getGoToPreference = function (editor) {
  112114. return editor.getOption(41 /* gotoLocation */).multipleTypeDefinitions;
  112115. };
  112116. return TypeDefinitionAction;
  112117. }(SymbolNavigationAction));
  112118. editorExtensions_1.registerEditorAction((_e = /** @class */ (function (_super) {
  112119. __extends(GoToTypeDefinitionAction, _super);
  112120. function GoToTypeDefinitionAction() {
  112121. return _super.call(this, {
  112122. openToSide: false,
  112123. openInPeek: false,
  112124. muteMessage: false
  112125. }, {
  112126. id: GoToTypeDefinitionAction.ID,
  112127. label: nls.localize(19, null),
  112128. alias: 'Go to Type Definition',
  112129. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasTypeDefinitionProvider, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  112130. kbOpts: {
  112131. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  112132. primary: 0,
  112133. weight: 100 /* EditorContrib */
  112134. },
  112135. contextMenuOpts: {
  112136. group: 'navigation',
  112137. order: 1.4
  112138. },
  112139. menuOpts: {
  112140. menuId: 19 /* MenubarGoMenu */,
  112141. group: '4_symbol_nav',
  112142. order: 3,
  112143. title: nls.localize(20, null)
  112144. }
  112145. }) || this;
  112146. }
  112147. return GoToTypeDefinitionAction;
  112148. }(TypeDefinitionAction)),
  112149. _e.ID = 'editor.action.goToTypeDefinition',
  112150. _e));
  112151. editorExtensions_1.registerEditorAction((_f = /** @class */ (function (_super) {
  112152. __extends(PeekTypeDefinitionAction, _super);
  112153. function PeekTypeDefinitionAction() {
  112154. return _super.call(this, {
  112155. openToSide: false,
  112156. openInPeek: true,
  112157. muteMessage: false
  112158. }, {
  112159. id: PeekTypeDefinitionAction.ID,
  112160. label: nls.localize(21, null),
  112161. alias: 'Peek Type Definition',
  112162. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasTypeDefinitionProvider, peekView_1.PeekContext.notInPeekEditor, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  112163. contextMenuOpts: {
  112164. menuId: 8 /* EditorContextPeek */,
  112165. group: 'peek',
  112166. order: 4
  112167. }
  112168. }) || this;
  112169. }
  112170. return PeekTypeDefinitionAction;
  112171. }(TypeDefinitionAction)),
  112172. _f.ID = 'editor.action.peekTypeDefinition',
  112173. _f));
  112174. //#endregion
  112175. //#region --- IMPLEMENTATION
  112176. var ImplementationAction = /** @class */ (function (_super) {
  112177. __extends(ImplementationAction, _super);
  112178. function ImplementationAction() {
  112179. return _super !== null && _super.apply(this, arguments) || this;
  112180. }
  112181. ImplementationAction.prototype._getLocationModel = function (model, position, token) {
  112182. return __awaiter(this, void 0, void 0, function () {
  112183. var _a;
  112184. return __generator(this, function (_b) {
  112185. switch (_b.label) {
  112186. case 0:
  112187. _a = referencesModel_1.ReferencesModel.bind;
  112188. return [4 /*yield*/, goToSymbol_1.getImplementationsAtPosition(model, position, token)];
  112189. case 1: return [2 /*return*/, new (_a.apply(referencesModel_1.ReferencesModel, [void 0, _b.sent(), nls.localize(22, null)]))()];
  112190. }
  112191. });
  112192. });
  112193. };
  112194. ImplementationAction.prototype._getNoResultFoundMessage = function (info) {
  112195. return info && info.word
  112196. ? nls.localize(23, null, info.word)
  112197. : nls.localize(24, null);
  112198. };
  112199. ImplementationAction.prototype._getAlternativeCommand = function (editor) {
  112200. return editor.getOption(41 /* gotoLocation */).alternativeImplementationCommand;
  112201. };
  112202. ImplementationAction.prototype._getGoToPreference = function (editor) {
  112203. return editor.getOption(41 /* gotoLocation */).multipleImplementations;
  112204. };
  112205. return ImplementationAction;
  112206. }(SymbolNavigationAction));
  112207. editorExtensions_1.registerEditorAction((_g = /** @class */ (function (_super) {
  112208. __extends(GoToImplementationAction, _super);
  112209. function GoToImplementationAction() {
  112210. return _super.call(this, {
  112211. openToSide: false,
  112212. openInPeek: false,
  112213. muteMessage: false
  112214. }, {
  112215. id: GoToImplementationAction.ID,
  112216. label: nls.localize(25, null),
  112217. alias: 'Go to Implementations',
  112218. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasImplementationProvider, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  112219. kbOpts: {
  112220. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  112221. primary: 2048 /* CtrlCmd */ | 70 /* F12 */,
  112222. weight: 100 /* EditorContrib */
  112223. },
  112224. menuOpts: {
  112225. menuId: 19 /* MenubarGoMenu */,
  112226. group: '4_symbol_nav',
  112227. order: 4,
  112228. title: nls.localize(26, null)
  112229. },
  112230. contextMenuOpts: {
  112231. group: 'navigation',
  112232. order: 1.45
  112233. }
  112234. }) || this;
  112235. }
  112236. return GoToImplementationAction;
  112237. }(ImplementationAction)),
  112238. _g.ID = 'editor.action.goToImplementation',
  112239. _g));
  112240. editorExtensions_1.registerEditorAction((_h = /** @class */ (function (_super) {
  112241. __extends(PeekImplementationAction, _super);
  112242. function PeekImplementationAction() {
  112243. return _super.call(this, {
  112244. openToSide: false,
  112245. openInPeek: true,
  112246. muteMessage: false
  112247. }, {
  112248. id: PeekImplementationAction.ID,
  112249. label: nls.localize(27, null),
  112250. alias: 'Peek Implementations',
  112251. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasImplementationProvider, peekView_1.PeekContext.notInPeekEditor, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  112252. kbOpts: {
  112253. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  112254. primary: 2048 /* CtrlCmd */ | 1024 /* Shift */ | 70 /* F12 */,
  112255. weight: 100 /* EditorContrib */
  112256. },
  112257. contextMenuOpts: {
  112258. menuId: 8 /* EditorContextPeek */,
  112259. group: 'peek',
  112260. order: 5
  112261. }
  112262. }) || this;
  112263. }
  112264. return PeekImplementationAction;
  112265. }(ImplementationAction)),
  112266. _h.ID = 'editor.action.peekImplementation',
  112267. _h));
  112268. //#endregion
  112269. //#region --- REFERENCES
  112270. var ReferencesAction = /** @class */ (function (_super) {
  112271. __extends(ReferencesAction, _super);
  112272. function ReferencesAction() {
  112273. return _super !== null && _super.apply(this, arguments) || this;
  112274. }
  112275. ReferencesAction.prototype._getNoResultFoundMessage = function (info) {
  112276. return info
  112277. ? nls.localize(28, null, info.word)
  112278. : nls.localize(29, null);
  112279. };
  112280. ReferencesAction.prototype._getAlternativeCommand = function (editor) {
  112281. return editor.getOption(41 /* gotoLocation */).alternativeReferenceCommand;
  112282. };
  112283. ReferencesAction.prototype._getGoToPreference = function (editor) {
  112284. return editor.getOption(41 /* gotoLocation */).multipleReferences;
  112285. };
  112286. return ReferencesAction;
  112287. }(SymbolNavigationAction));
  112288. editorExtensions_1.registerEditorAction(/** @class */ (function (_super) {
  112289. __extends(GoToReferencesAction, _super);
  112290. function GoToReferencesAction() {
  112291. return _super.call(this, {
  112292. openToSide: false,
  112293. openInPeek: false,
  112294. muteMessage: false
  112295. }, {
  112296. id: 'editor.action.goToReferences',
  112297. label: nls.localize(30, null),
  112298. alias: 'Go to References',
  112299. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasReferenceProvider, peekView_1.PeekContext.notInPeekEditor, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  112300. kbOpts: {
  112301. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  112302. primary: 1024 /* Shift */ | 70 /* F12 */,
  112303. weight: 100 /* EditorContrib */
  112304. },
  112305. contextMenuOpts: {
  112306. group: 'navigation',
  112307. order: 1.45
  112308. },
  112309. menuOpts: {
  112310. menuId: 19 /* MenubarGoMenu */,
  112311. group: '4_symbol_nav',
  112312. order: 5,
  112313. title: nls.localize(31, null)
  112314. },
  112315. }) || this;
  112316. }
  112317. GoToReferencesAction.prototype._getLocationModel = function (model, position, token) {
  112318. return __awaiter(this, void 0, void 0, function () {
  112319. var _a;
  112320. return __generator(this, function (_b) {
  112321. switch (_b.label) {
  112322. case 0:
  112323. _a = referencesModel_1.ReferencesModel.bind;
  112324. return [4 /*yield*/, goToSymbol_1.getReferencesAtPosition(model, position, true, token)];
  112325. case 1: return [2 /*return*/, new (_a.apply(referencesModel_1.ReferencesModel, [void 0, _b.sent(), nls.localize(32, null)]))()];
  112326. }
  112327. });
  112328. });
  112329. };
  112330. return GoToReferencesAction;
  112331. }(ReferencesAction)));
  112332. editorExtensions_1.registerEditorAction(/** @class */ (function (_super) {
  112333. __extends(PeekReferencesAction, _super);
  112334. function PeekReferencesAction() {
  112335. return _super.call(this, {
  112336. openToSide: false,
  112337. openInPeek: true,
  112338. muteMessage: false
  112339. }, {
  112340. id: 'editor.action.referenceSearch.trigger',
  112341. label: nls.localize(33, null),
  112342. alias: 'Peek References',
  112343. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.hasReferenceProvider, peekView_1.PeekContext.notInPeekEditor, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  112344. contextMenuOpts: {
  112345. menuId: 8 /* EditorContextPeek */,
  112346. group: 'peek',
  112347. order: 6
  112348. }
  112349. }) || this;
  112350. }
  112351. PeekReferencesAction.prototype._getLocationModel = function (model, position, token) {
  112352. return __awaiter(this, void 0, void 0, function () {
  112353. var _a;
  112354. return __generator(this, function (_b) {
  112355. switch (_b.label) {
  112356. case 0:
  112357. _a = referencesModel_1.ReferencesModel.bind;
  112358. return [4 /*yield*/, goToSymbol_1.getReferencesAtPosition(model, position, false, token)];
  112359. case 1: return [2 /*return*/, new (_a.apply(referencesModel_1.ReferencesModel, [void 0, _b.sent(), nls.localize(34, null)]))()];
  112360. }
  112361. });
  112362. });
  112363. };
  112364. return PeekReferencesAction;
  112365. }(ReferencesAction)));
  112366. //#endregion
  112367. //#region --- GENERIC goto symbols command
  112368. var GenericGoToLocationAction = /** @class */ (function (_super) {
  112369. __extends(GenericGoToLocationAction, _super);
  112370. function GenericGoToLocationAction(config, _references, _gotoMultipleBehaviour) {
  112371. var _this = _super.call(this, config, {
  112372. id: 'editor.action.goToLocation',
  112373. label: nls.localize(35, null),
  112374. alias: 'Go To Any Symbol',
  112375. precondition: contextkey_1.ContextKeyExpr.and(peekView_1.PeekContext.notInPeekEditor, editorContextKeys_1.EditorContextKeys.isInEmbeddedEditor.toNegated()),
  112376. }) || this;
  112377. _this._references = _references;
  112378. _this._gotoMultipleBehaviour = _gotoMultipleBehaviour;
  112379. return _this;
  112380. }
  112381. GenericGoToLocationAction.prototype._getLocationModel = function (_model, _position, _token) {
  112382. return __awaiter(this, void 0, void 0, function () {
  112383. return __generator(this, function (_a) {
  112384. return [2 /*return*/, new referencesModel_1.ReferencesModel(this._references, nls.localize(36, null))];
  112385. });
  112386. });
  112387. };
  112388. GenericGoToLocationAction.prototype._getNoResultFoundMessage = function (info) {
  112389. return info && nls.localize(37, null, info.word) || '';
  112390. };
  112391. GenericGoToLocationAction.prototype._getGoToPreference = function (editor) {
  112392. var _a;
  112393. return (_a = this._gotoMultipleBehaviour) !== null && _a !== void 0 ? _a : editor.getOption(41 /* gotoLocation */).multipleReferences;
  112394. };
  112395. GenericGoToLocationAction.prototype._getAlternativeCommand = function () { return ''; };
  112396. return GenericGoToLocationAction;
  112397. }(SymbolNavigationAction));
  112398. commands_1.CommandsRegistry.registerCommand({
  112399. id: 'editor.action.goToLocations',
  112400. description: {
  112401. description: 'Go to locations from a position in a file',
  112402. args: [
  112403. { name: 'uri', description: 'The text document in which to start', constraint: uri_1.URI },
  112404. { name: 'position', description: 'The position at which to start', constraint: corePosition.Position.isIPosition },
  112405. { name: 'locations', description: 'An array of locations.', constraint: Array },
  112406. { name: 'multiple', description: 'Define what to do when having multiple results, either `peek`, `gotoAndPeek`, or `goto' },
  112407. ]
  112408. },
  112409. handler: function (accessor, resource, position, references, multiple, openInPeek) { return __awaiter(void 0, void 0, void 0, function () {
  112410. var editorService, editor;
  112411. return __generator(this, function (_a) {
  112412. switch (_a.label) {
  112413. case 0:
  112414. types_1.assertType(uri_1.URI.isUri(resource));
  112415. types_1.assertType(corePosition.Position.isIPosition(position));
  112416. types_1.assertType(Array.isArray(references));
  112417. types_1.assertType(typeof multiple === 'undefined' || typeof multiple === 'string');
  112418. types_1.assertType(typeof openInPeek === 'undefined' || typeof openInPeek === 'boolean');
  112419. editorService = accessor.get(codeEditorService_1.ICodeEditorService);
  112420. return [4 /*yield*/, editorService.openCodeEditor({ resource: resource }, editorService.getFocusedCodeEditor())];
  112421. case 1:
  112422. editor = _a.sent();
  112423. if (editorBrowser_1.isCodeEditor(editor)) {
  112424. editor.setPosition(position);
  112425. editor.revealPositionInCenterIfOutsideViewport(position, 0 /* Smooth */);
  112426. return [2 /*return*/, editor.invokeWithinContext(function (accessor) {
  112427. var command = new GenericGoToLocationAction({ muteMessage: true, openInPeek: Boolean(openInPeek), openToSide: false }, references, multiple);
  112428. accessor.get(instantiation_1.IInstantiationService).invokeFunction(command.run.bind(command), editor);
  112429. })];
  112430. }
  112431. return [2 /*return*/];
  112432. }
  112433. });
  112434. }); }
  112435. });
  112436. commands_1.CommandsRegistry.registerCommand({
  112437. id: 'editor.action.peekLocations',
  112438. description: {
  112439. description: 'Peek locations from a position in a file',
  112440. args: [
  112441. { name: 'uri', description: 'The text document in which to start', constraint: uri_1.URI },
  112442. { name: 'position', description: 'The position at which to start', constraint: corePosition.Position.isIPosition },
  112443. { name: 'locations', description: 'An array of locations.', constraint: Array },
  112444. { name: 'multiple', description: 'Define what to do when having multiple results, either `peek`, `gotoAndPeek`, or `goto' },
  112445. ]
  112446. },
  112447. handler: function (accessor, resource, position, references, multiple) { return __awaiter(void 0, void 0, void 0, function () {
  112448. return __generator(this, function (_a) {
  112449. accessor.get(commands_1.ICommandService).executeCommand('editor.action.goToLocations', resource, position, references, multiple, true);
  112450. return [2 /*return*/];
  112451. });
  112452. }); }
  112453. });
  112454. //#endregion
  112455. //#region --- REFERENCE search special commands
  112456. commands_1.CommandsRegistry.registerCommand({
  112457. id: 'editor.action.findReferences',
  112458. handler: function (accessor, resource, position) {
  112459. types_1.assertType(uri_1.URI.isUri(resource));
  112460. types_1.assertType(corePosition.Position.isIPosition(position));
  112461. var codeEditorService = accessor.get(codeEditorService_1.ICodeEditorService);
  112462. return codeEditorService.openCodeEditor({ resource: resource }, codeEditorService.getFocusedCodeEditor()).then(function (control) {
  112463. if (!editorBrowser_1.isCodeEditor(control) || !control.hasModel()) {
  112464. return undefined;
  112465. }
  112466. var controller = referencesController_1.ReferencesController.get(control);
  112467. if (!controller) {
  112468. return undefined;
  112469. }
  112470. var references = async_1.createCancelablePromise(function (token) { return goToSymbol_1.getReferencesAtPosition(control.getModel(), corePosition.Position.lift(position), false, token).then(function (references) { return new referencesModel_1.ReferencesModel(references, nls.localize(38, null)); }); });
  112471. var range = new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column);
  112472. return Promise.resolve(controller.toggleWidget(range, references, false));
  112473. });
  112474. }
  112475. });
  112476. // use NEW command
  112477. commands_1.CommandsRegistry.registerCommandAlias('editor.action.showReferences', 'editor.action.peekLocations');
  112478. });
  112479. //#endregion
  112480. /*---------------------------------------------------------------------------------------------
  112481. * Copyright (c) Microsoft Corporation. All rights reserved.
  112482. * Licensed under the MIT License. See License.txt in the project root for license information.
  112483. *--------------------------------------------------------------------------------------------*/
  112484. define(__m[236/*vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition*/], __M([0/*require*/,1/*exports*/,447/*vs/nls!vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition*/,15/*vs/base/common/async*/,10/*vs/base/common/errors*/,75/*vs/base/common/htmlContent*/,71/*vs/editor/common/services/modeService*/,3/*vs/editor/common/core/range*/,17/*vs/editor/common/modes*/,12/*vs/editor/browser/editorExtensions*/,224/*vs/editor/contrib/gotoSymbol/goToSymbol*/,2/*vs/base/common/lifecycle*/,84/*vs/editor/common/services/resolverService*/,14/*vs/platform/theme/common/themeService*/,20/*vs/platform/theme/common/colorRegistry*/,67/*vs/editor/browser/core/editorState*/,235/*vs/editor/contrib/gotoSymbol/goToCommands*/,199/*vs/editor/contrib/gotoSymbol/link/clickLinkGesture*/,13/*vs/editor/common/core/position*/,21/*vs/base/common/types*/,313/*vs/css!vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition*/]), function (require, exports, nls, async_1, errors_1, htmlContent_1, modeService_1, range_1, modes_1, editorExtensions_1, goToSymbol_1, lifecycle_1, resolverService_1, themeService_1, colorRegistry_1, editorState_1, goToCommands_1, clickLinkGesture_1, position_1, types_1) {
  112485. "use strict";
  112486. Object.defineProperty(exports, "__esModule", { value: true });
  112487. var GotoDefinitionAtPositionEditorContribution = /** @class */ (function () {
  112488. function GotoDefinitionAtPositionEditorContribution(editor, textModelResolverService, modeService) {
  112489. var _this = this;
  112490. this.textModelResolverService = textModelResolverService;
  112491. this.modeService = modeService;
  112492. this.toUnhook = new lifecycle_1.DisposableStore();
  112493. this.toUnhookForKeyboard = new lifecycle_1.DisposableStore();
  112494. this.linkDecorations = [];
  112495. this.currentWordAtPosition = null;
  112496. this.previousPromise = null;
  112497. this.editor = editor;
  112498. var linkGesture = new clickLinkGesture_1.ClickLinkGesture(editor);
  112499. this.toUnhook.add(linkGesture);
  112500. this.toUnhook.add(linkGesture.onMouseMoveOrRelevantKeyDown(function (_a) {
  112501. var mouseEvent = _a[0], keyboardEvent = _a[1];
  112502. _this.startFindDefinitionFromMouse(mouseEvent, types_1.withNullAsUndefined(keyboardEvent));
  112503. }));
  112504. this.toUnhook.add(linkGesture.onExecute(function (mouseEvent) {
  112505. if (_this.isEnabled(mouseEvent)) {
  112506. _this.gotoDefinition(mouseEvent.target.position, mouseEvent.hasSideBySideModifier).then(function () {
  112507. _this.removeLinkDecorations();
  112508. }, function (error) {
  112509. _this.removeLinkDecorations();
  112510. errors_1.onUnexpectedError(error);
  112511. });
  112512. }
  112513. }));
  112514. this.toUnhook.add(linkGesture.onCancel(function () {
  112515. _this.removeLinkDecorations();
  112516. _this.currentWordAtPosition = null;
  112517. }));
  112518. }
  112519. GotoDefinitionAtPositionEditorContribution.get = function (editor) {
  112520. return editor.getContribution(GotoDefinitionAtPositionEditorContribution.ID);
  112521. };
  112522. GotoDefinitionAtPositionEditorContribution.prototype.startFindDefinitionFromCursor = function (position) {
  112523. // For issue: https://github.com/microsoft/vscode/issues/46257
  112524. // equivalent to mouse move with meta/ctrl key
  112525. var _this = this;
  112526. // First find the definition and add decorations
  112527. // to the editor to be shown with the content hover widget
  112528. return this.startFindDefinition(position).then(function () {
  112529. // Add listeners for editor cursor move and key down events
  112530. // Dismiss the "extended" editor decorations when the user hides
  112531. // the hover widget. There is no event for the widget itself so these
  112532. // serve as a best effort. After removing the link decorations, the hover
  112533. // widget is clean and will only show declarations per next request.
  112534. _this.toUnhookForKeyboard.add(_this.editor.onDidChangeCursorPosition(function () {
  112535. _this.currentWordAtPosition = null;
  112536. _this.removeLinkDecorations();
  112537. _this.toUnhookForKeyboard.clear();
  112538. }));
  112539. _this.toUnhookForKeyboard.add(_this.editor.onKeyDown(function (e) {
  112540. if (e) {
  112541. _this.currentWordAtPosition = null;
  112542. _this.removeLinkDecorations();
  112543. _this.toUnhookForKeyboard.clear();
  112544. }
  112545. }));
  112546. });
  112547. };
  112548. GotoDefinitionAtPositionEditorContribution.prototype.startFindDefinitionFromMouse = function (mouseEvent, withKey) {
  112549. // check if we are active and on a content widget
  112550. if (mouseEvent.target.type === 9 /* CONTENT_WIDGET */ && this.linkDecorations.length > 0) {
  112551. return;
  112552. }
  112553. if (!this.editor.hasModel() || !this.isEnabled(mouseEvent, withKey)) {
  112554. this.currentWordAtPosition = null;
  112555. this.removeLinkDecorations();
  112556. return;
  112557. }
  112558. var position = mouseEvent.target.position;
  112559. this.startFindDefinition(position);
  112560. };
  112561. GotoDefinitionAtPositionEditorContribution.prototype.startFindDefinition = function (position) {
  112562. var _this = this;
  112563. var _a;
  112564. // Dispose listeners for updating decorations when using keyboard to show definition hover
  112565. this.toUnhookForKeyboard.clear();
  112566. // Find word at mouse position
  112567. var word = position ? (_a = this.editor.getModel()) === null || _a === void 0 ? void 0 : _a.getWordAtPosition(position) : null;
  112568. if (!word) {
  112569. this.currentWordAtPosition = null;
  112570. this.removeLinkDecorations();
  112571. return Promise.resolve(0);
  112572. }
  112573. // Return early if word at position is still the same
  112574. if (this.currentWordAtPosition && this.currentWordAtPosition.startColumn === word.startColumn && this.currentWordAtPosition.endColumn === word.endColumn && this.currentWordAtPosition.word === word.word) {
  112575. return Promise.resolve(0);
  112576. }
  112577. this.currentWordAtPosition = word;
  112578. // Find definition and decorate word if found
  112579. var state = new editorState_1.EditorState(this.editor, 4 /* Position */ | 1 /* Value */ | 2 /* Selection */ | 8 /* Scroll */);
  112580. if (this.previousPromise) {
  112581. this.previousPromise.cancel();
  112582. this.previousPromise = null;
  112583. }
  112584. this.previousPromise = async_1.createCancelablePromise(function (token) { return _this.findDefinition(position, token); });
  112585. return this.previousPromise.then(function (results) {
  112586. if (!results || !results.length || !state.validate(_this.editor)) {
  112587. _this.removeLinkDecorations();
  112588. return;
  112589. }
  112590. // Multiple results
  112591. if (results.length > 1) {
  112592. _this.addDecoration(new range_1.Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn), new htmlContent_1.MarkdownString().appendText(nls.localize(0, null, results.length)));
  112593. }
  112594. // Single result
  112595. else {
  112596. var result_1 = results[0];
  112597. if (!result_1.uri) {
  112598. return;
  112599. }
  112600. _this.textModelResolverService.createModelReference(result_1.uri).then(function (ref) {
  112601. if (!ref.object || !ref.object.textEditorModel) {
  112602. ref.dispose();
  112603. return;
  112604. }
  112605. var textEditorModel = ref.object.textEditorModel;
  112606. var startLineNumber = result_1.range.startLineNumber;
  112607. if (startLineNumber < 1 || startLineNumber > textEditorModel.getLineCount()) {
  112608. // invalid range
  112609. ref.dispose();
  112610. return;
  112611. }
  112612. var previewValue = _this.getPreviewValue(textEditorModel, startLineNumber, result_1);
  112613. var wordRange;
  112614. if (result_1.originSelectionRange) {
  112615. wordRange = range_1.Range.lift(result_1.originSelectionRange);
  112616. }
  112617. else {
  112618. wordRange = new range_1.Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn);
  112619. }
  112620. var modeId = _this.modeService.getModeIdByFilepathOrFirstLine(textEditorModel.uri);
  112621. _this.addDecoration(wordRange, new htmlContent_1.MarkdownString().appendCodeblock(modeId ? modeId : '', previewValue));
  112622. ref.dispose();
  112623. });
  112624. }
  112625. }).then(undefined, errors_1.onUnexpectedError);
  112626. };
  112627. GotoDefinitionAtPositionEditorContribution.prototype.getPreviewValue = function (textEditorModel, startLineNumber, result) {
  112628. var rangeToUse = result.targetSelectionRange ? result.range : this.getPreviewRangeBasedOnBrackets(textEditorModel, startLineNumber);
  112629. var numberOfLinesInRange = rangeToUse.endLineNumber - rangeToUse.startLineNumber;
  112630. if (numberOfLinesInRange >= GotoDefinitionAtPositionEditorContribution.MAX_SOURCE_PREVIEW_LINES) {
  112631. rangeToUse = this.getPreviewRangeBasedOnIndentation(textEditorModel, startLineNumber);
  112632. }
  112633. var previewValue = this.stripIndentationFromPreviewRange(textEditorModel, startLineNumber, rangeToUse);
  112634. return previewValue;
  112635. };
  112636. GotoDefinitionAtPositionEditorContribution.prototype.stripIndentationFromPreviewRange = function (textEditorModel, startLineNumber, previewRange) {
  112637. var startIndent = textEditorModel.getLineFirstNonWhitespaceColumn(startLineNumber);
  112638. var minIndent = startIndent;
  112639. for (var endLineNumber = startLineNumber + 1; endLineNumber < previewRange.endLineNumber; endLineNumber++) {
  112640. var endIndent = textEditorModel.getLineFirstNonWhitespaceColumn(endLineNumber);
  112641. minIndent = Math.min(minIndent, endIndent);
  112642. }
  112643. var previewValue = textEditorModel.getValueInRange(previewRange).replace(new RegExp("^\\s{" + (minIndent - 1) + "}", 'gm'), '').trim();
  112644. return previewValue;
  112645. };
  112646. GotoDefinitionAtPositionEditorContribution.prototype.getPreviewRangeBasedOnIndentation = function (textEditorModel, startLineNumber) {
  112647. var startIndent = textEditorModel.getLineFirstNonWhitespaceColumn(startLineNumber);
  112648. var maxLineNumber = Math.min(textEditorModel.getLineCount(), startLineNumber + GotoDefinitionAtPositionEditorContribution.MAX_SOURCE_PREVIEW_LINES);
  112649. var endLineNumber = startLineNumber + 1;
  112650. for (; endLineNumber < maxLineNumber; endLineNumber++) {
  112651. var endIndent = textEditorModel.getLineFirstNonWhitespaceColumn(endLineNumber);
  112652. if (startIndent === endIndent) {
  112653. break;
  112654. }
  112655. }
  112656. return new range_1.Range(startLineNumber, 1, endLineNumber + 1, 1);
  112657. };
  112658. GotoDefinitionAtPositionEditorContribution.prototype.getPreviewRangeBasedOnBrackets = function (textEditorModel, startLineNumber) {
  112659. var maxLineNumber = Math.min(textEditorModel.getLineCount(), startLineNumber + GotoDefinitionAtPositionEditorContribution.MAX_SOURCE_PREVIEW_LINES);
  112660. var brackets = [];
  112661. var ignoreFirstEmpty = true;
  112662. var currentBracket = textEditorModel.findNextBracket(new position_1.Position(startLineNumber, 1));
  112663. while (currentBracket !== null) {
  112664. if (brackets.length === 0) {
  112665. brackets.push(currentBracket);
  112666. }
  112667. else {
  112668. var lastBracket = brackets[brackets.length - 1];
  112669. if (lastBracket.open[0] === currentBracket.open[0] && lastBracket.isOpen && !currentBracket.isOpen) {
  112670. brackets.pop();
  112671. }
  112672. else {
  112673. brackets.push(currentBracket);
  112674. }
  112675. if (brackets.length === 0) {
  112676. if (ignoreFirstEmpty) {
  112677. ignoreFirstEmpty = false;
  112678. }
  112679. else {
  112680. return new range_1.Range(startLineNumber, 1, currentBracket.range.endLineNumber + 1, 1);
  112681. }
  112682. }
  112683. }
  112684. var maxColumn = textEditorModel.getLineMaxColumn(startLineNumber);
  112685. var nextLineNumber = currentBracket.range.endLineNumber;
  112686. var nextColumn = currentBracket.range.endColumn;
  112687. if (maxColumn === currentBracket.range.endColumn) {
  112688. nextLineNumber++;
  112689. nextColumn = 1;
  112690. }
  112691. if (nextLineNumber > maxLineNumber) {
  112692. return new range_1.Range(startLineNumber, 1, maxLineNumber + 1, 1);
  112693. }
  112694. currentBracket = textEditorModel.findNextBracket(new position_1.Position(nextLineNumber, nextColumn));
  112695. }
  112696. return new range_1.Range(startLineNumber, 1, maxLineNumber + 1, 1);
  112697. };
  112698. GotoDefinitionAtPositionEditorContribution.prototype.addDecoration = function (range, hoverMessage) {
  112699. var newDecorations = {
  112700. range: range,
  112701. options: {
  112702. inlineClassName: 'goto-definition-link',
  112703. hoverMessage: hoverMessage
  112704. }
  112705. };
  112706. this.linkDecorations = this.editor.deltaDecorations(this.linkDecorations, [newDecorations]);
  112707. };
  112708. GotoDefinitionAtPositionEditorContribution.prototype.removeLinkDecorations = function () {
  112709. if (this.linkDecorations.length > 0) {
  112710. this.linkDecorations = this.editor.deltaDecorations(this.linkDecorations, []);
  112711. }
  112712. };
  112713. GotoDefinitionAtPositionEditorContribution.prototype.isEnabled = function (mouseEvent, withKey) {
  112714. return this.editor.hasModel() &&
  112715. mouseEvent.isNoneOrSingleMouseDown &&
  112716. (mouseEvent.target.type === 6 /* CONTENT_TEXT */) &&
  112717. (mouseEvent.hasTriggerModifier || (withKey ? withKey.keyCodeIsTriggerKey : false)) &&
  112718. modes_1.DefinitionProviderRegistry.has(this.editor.getModel());
  112719. };
  112720. GotoDefinitionAtPositionEditorContribution.prototype.findDefinition = function (position, token) {
  112721. var model = this.editor.getModel();
  112722. if (!model) {
  112723. return Promise.resolve(null);
  112724. }
  112725. return goToSymbol_1.getDefinitionsAtPosition(model, position, token);
  112726. };
  112727. GotoDefinitionAtPositionEditorContribution.prototype.gotoDefinition = function (position, openToSide) {
  112728. var _this = this;
  112729. this.editor.setPosition(position);
  112730. var action = new goToCommands_1.DefinitionAction({ openToSide: openToSide, openInPeek: false, muteMessage: true }, { alias: '', label: '', id: '', precondition: undefined });
  112731. return this.editor.invokeWithinContext(function (accessor) { return action.run(accessor, _this.editor); });
  112732. };
  112733. GotoDefinitionAtPositionEditorContribution.prototype.dispose = function () {
  112734. this.toUnhook.dispose();
  112735. };
  112736. GotoDefinitionAtPositionEditorContribution.ID = 'editor.contrib.gotodefinitionatposition';
  112737. GotoDefinitionAtPositionEditorContribution.MAX_SOURCE_PREVIEW_LINES = 8;
  112738. GotoDefinitionAtPositionEditorContribution = __decorate([
  112739. __param(1, resolverService_1.ITextModelService),
  112740. __param(2, modeService_1.IModeService)
  112741. ], GotoDefinitionAtPositionEditorContribution);
  112742. return GotoDefinitionAtPositionEditorContribution;
  112743. }());
  112744. exports.GotoDefinitionAtPositionEditorContribution = GotoDefinitionAtPositionEditorContribution;
  112745. editorExtensions_1.registerEditorContribution(GotoDefinitionAtPositionEditorContribution.ID, GotoDefinitionAtPositionEditorContribution);
  112746. themeService_1.registerThemingParticipant(function (theme, collector) {
  112747. var activeLinkForeground = theme.getColor(colorRegistry_1.editorActiveLinkForeground);
  112748. if (activeLinkForeground) {
  112749. collector.addRule(".monaco-editor .goto-definition-link { color: " + activeLinkForeground + " !important; }");
  112750. }
  112751. });
  112752. });
  112753. /*---------------------------------------------------------------------------------------------
  112754. * Copyright (c) Microsoft Corporation. All rights reserved.
  112755. * Licensed under the MIT License. See License.txt in the project root for license information.
  112756. *--------------------------------------------------------------------------------------------*/
  112757. define(__m[597/*vs/editor/standalone/browser/referenceSearch/standaloneReferenceSearch*/], __M([0/*require*/,1/*exports*/,12/*vs/editor/browser/editorExtensions*/,32/*vs/editor/browser/services/codeEditorService*/,234/*vs/editor/contrib/gotoSymbol/peek/referencesController*/,43/*vs/platform/configuration/common/configuration*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,35/*vs/platform/notification/common/notification*/,74/*vs/platform/storage/common/storage*/]), function (require, exports, editorExtensions_1, codeEditorService_1, referencesController_1, configuration_1, contextkey_1, instantiation_1, notification_1, storage_1) {
  112758. "use strict";
  112759. Object.defineProperty(exports, "__esModule", { value: true });
  112760. var StandaloneReferencesController = /** @class */ (function (_super) {
  112761. __extends(StandaloneReferencesController, _super);
  112762. function StandaloneReferencesController(editor, contextKeyService, editorService, notificationService, instantiationService, storageService, configurationService) {
  112763. return _super.call(this, true, editor, contextKeyService, editorService, notificationService, instantiationService, storageService, configurationService) || this;
  112764. }
  112765. StandaloneReferencesController = __decorate([
  112766. __param(1, contextkey_1.IContextKeyService),
  112767. __param(2, codeEditorService_1.ICodeEditorService),
  112768. __param(3, notification_1.INotificationService),
  112769. __param(4, instantiation_1.IInstantiationService),
  112770. __param(5, storage_1.IStorageService),
  112771. __param(6, configuration_1.IConfigurationService)
  112772. ], StandaloneReferencesController);
  112773. return StandaloneReferencesController;
  112774. }(referencesController_1.ReferencesController));
  112775. exports.StandaloneReferencesController = StandaloneReferencesController;
  112776. editorExtensions_1.registerEditorContribution(referencesController_1.ReferencesController.ID, StandaloneReferencesController);
  112777. });
  112778. /*---------------------------------------------------------------------------------------------
  112779. * Copyright (c) Microsoft Corporation. All rights reserved.
  112780. * Licensed under the MIT License. See License.txt in the project root for license information.
  112781. *--------------------------------------------------------------------------------------------*/
  112782. define(__m[598/*vs/platform/severityIcon/common/severityIcon*/], __M([0/*require*/,1/*exports*/,112/*vs/base/common/severity*/,14/*vs/platform/theme/common/themeService*/,20/*vs/platform/theme/common/colorRegistry*/]), function (require, exports, severity_1, themeService_1, colorRegistry_1) {
  112783. "use strict";
  112784. Object.defineProperty(exports, "__esModule", { value: true });
  112785. var SeverityIcon;
  112786. (function (SeverityIcon) {
  112787. function className(severity) {
  112788. switch (severity) {
  112789. case severity_1.default.Ignore:
  112790. return 'severity-ignore codicon-info';
  112791. case severity_1.default.Info:
  112792. return 'codicon-info';
  112793. case severity_1.default.Warning:
  112794. return 'codicon-warning';
  112795. case severity_1.default.Error:
  112796. return 'codicon-error';
  112797. }
  112798. return '';
  112799. }
  112800. SeverityIcon.className = className;
  112801. })(SeverityIcon = exports.SeverityIcon || (exports.SeverityIcon = {}));
  112802. themeService_1.registerThemingParticipant(function (theme, collector) {
  112803. var errorIconForeground = theme.getColor(colorRegistry_1.problemsErrorIconForeground);
  112804. if (errorIconForeground) {
  112805. collector.addRule("\n\t\t\t.monaco-editor .zone-widget .codicon-error,\n\t\t\t.markers-panel .marker-icon.codicon-error,\n\t\t\t.extensions-viewlet > .extensions .codicon-error,\n\t\t\t.monaco-dialog-box .dialog-message-row .codicon-error {\n\t\t\t\tcolor: " + errorIconForeground + ";\n\t\t\t}\n\t\t");
  112806. }
  112807. var warningIconForeground = theme.getColor(colorRegistry_1.problemsWarningIconForeground);
  112808. if (errorIconForeground) {
  112809. collector.addRule("\n\t\t\t.monaco-editor .zone-widget .codicon-warning,\n\t\t\t.markers-panel .marker-icon.codicon-warning,\n\t\t\t.extensions-viewlet > .extensions .codicon-warning,\n\t\t\t.extension-editor .codicon-warning,\n\t\t\t.monaco-dialog-box .dialog-message-row .codicon-warning {\n\t\t\t\tcolor: " + warningIconForeground + ";\n\t\t\t}\n\t\t");
  112810. }
  112811. var infoIconForeground = theme.getColor(colorRegistry_1.problemsInfoIconForeground);
  112812. if (errorIconForeground) {
  112813. collector.addRule("\n\t\t\t.monaco-editor .zone-widget .codicon-info,\n\t\t\t.markers-panel .marker-icon.codicon-info,\n\t\t\t.extensions-viewlet > .extensions .codicon-info,\n\t\t\t.extension-editor .codicon-info,\n\t\t\t.monaco-dialog-box .dialog-message-row .codicon-info {\n\t\t\t\tcolor: " + infoIconForeground + ";\n\t\t\t}\n\t\t");
  112814. }
  112815. });
  112816. });
  112817. /*---------------------------------------------------------------------------------------------
  112818. * Copyright (c) Microsoft Corporation. All rights reserved.
  112819. * Licensed under the MIT License. See License.txt in the project root for license information.
  112820. *--------------------------------------------------------------------------------------------*/
  112821. define(__m[599/*vs/editor/contrib/gotoError/gotoErrorWidget*/], __M([0/*require*/,1/*exports*/,445/*vs/nls!vs/editor/contrib/gotoError/gotoErrorWidget*/,6/*vs/base/browser/dom*/,2/*vs/base/common/lifecycle*/,72/*vs/platform/markers/common/markers*/,3/*vs/editor/common/core/range*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,27/*vs/base/common/color*/,53/*vs/base/browser/ui/scrollbar/scrollableElement*/,136/*vs/base/common/labels*/,19/*vs/base/common/arrays*/,4/*vs/base/common/event*/,123/*vs/editor/contrib/peekView/peekView*/,39/*vs/base/common/resources*/,598/*vs/platform/severityIcon/common/severityIcon*/,312/*vs/css!vs/editor/contrib/gotoError/media/gotoErrorWidget*/]), function (require, exports, nls, dom, lifecycle_1, markers_1, range_1, colorRegistry_1, themeService_1, color_1, scrollableElement_1, labels_1, arrays_1, event_1, peekView_1, resources_1, severityIcon_1) {
  112822. "use strict";
  112823. Object.defineProperty(exports, "__esModule", { value: true });
  112824. var MessageWidget = /** @class */ (function () {
  112825. function MessageWidget(parent, editor, onRelatedInformation, _openerService) {
  112826. var _this = this;
  112827. this._openerService = _openerService;
  112828. this._lines = 0;
  112829. this._longestLineLength = 0;
  112830. this._relatedDiagnostics = new WeakMap();
  112831. this._disposables = new lifecycle_1.DisposableStore();
  112832. this._editor = editor;
  112833. var domNode = document.createElement('div');
  112834. domNode.className = 'descriptioncontainer';
  112835. domNode.setAttribute('aria-live', 'assertive');
  112836. domNode.setAttribute('role', 'alert');
  112837. this._messageBlock = document.createElement('div');
  112838. dom.addClass(this._messageBlock, 'message');
  112839. domNode.appendChild(this._messageBlock);
  112840. this._relatedBlock = document.createElement('div');
  112841. domNode.appendChild(this._relatedBlock);
  112842. this._disposables.add(dom.addStandardDisposableListener(this._relatedBlock, 'click', function (event) {
  112843. event.preventDefault();
  112844. var related = _this._relatedDiagnostics.get(event.target);
  112845. if (related) {
  112846. onRelatedInformation(related);
  112847. }
  112848. }));
  112849. this._scrollable = new scrollableElement_1.ScrollableElement(domNode, {
  112850. horizontal: 1 /* Auto */,
  112851. vertical: 1 /* Auto */,
  112852. useShadows: false,
  112853. horizontalScrollbarSize: 3,
  112854. verticalScrollbarSize: 3
  112855. });
  112856. parent.appendChild(this._scrollable.getDomNode());
  112857. this._disposables.add(this._scrollable.onScroll(function (e) {
  112858. domNode.style.left = "-" + e.scrollLeft + "px";
  112859. domNode.style.top = "-" + e.scrollTop + "px";
  112860. }));
  112861. this._disposables.add(this._scrollable);
  112862. }
  112863. MessageWidget.prototype.dispose = function () {
  112864. lifecycle_1.dispose(this._disposables);
  112865. };
  112866. MessageWidget.prototype.update = function (_a) {
  112867. var _this = this;
  112868. var source = _a.source, message = _a.message, relatedInformation = _a.relatedInformation, code = _a.code;
  112869. var sourceAndCodeLength = ((source === null || source === void 0 ? void 0 : source.length) || 0) + '()'.length;
  112870. if (code) {
  112871. if (typeof code === 'string') {
  112872. sourceAndCodeLength += code.length;
  112873. }
  112874. else {
  112875. sourceAndCodeLength += code.value.length;
  112876. }
  112877. }
  112878. var lines = message.split(/\r\n|\r|\n/g);
  112879. this._lines = lines.length;
  112880. this._longestLineLength = 0;
  112881. for (var _i = 0, lines_1 = lines; _i < lines_1.length; _i++) {
  112882. var line = lines_1[_i];
  112883. this._longestLineLength = Math.max(line.length + sourceAndCodeLength, this._longestLineLength);
  112884. }
  112885. dom.clearNode(this._messageBlock);
  112886. this._editor.applyFontInfo(this._messageBlock);
  112887. var lastLineElement = this._messageBlock;
  112888. for (var _b = 0, lines_2 = lines; _b < lines_2.length; _b++) {
  112889. var line = lines_2[_b];
  112890. lastLineElement = document.createElement('div');
  112891. lastLineElement.innerText = line;
  112892. if (line === '') {
  112893. lastLineElement.style.height = this._messageBlock.style.lineHeight;
  112894. }
  112895. this._messageBlock.appendChild(lastLineElement);
  112896. }
  112897. if (source || code) {
  112898. var detailsElement = document.createElement('span');
  112899. dom.addClass(detailsElement, 'details');
  112900. lastLineElement.appendChild(detailsElement);
  112901. if (source) {
  112902. var sourceElement = document.createElement('span');
  112903. sourceElement.innerText = source;
  112904. dom.addClass(sourceElement, 'source');
  112905. detailsElement.appendChild(sourceElement);
  112906. }
  112907. if (code) {
  112908. if (typeof code === 'string') {
  112909. var codeElement = document.createElement('span');
  112910. codeElement.innerText = "(" + code + ")";
  112911. dom.addClass(codeElement, 'code');
  112912. detailsElement.appendChild(codeElement);
  112913. }
  112914. else {
  112915. this._codeLink = dom.$('a.code-link');
  112916. this._codeLink.setAttribute('href', "" + code.link.toString());
  112917. this._codeLink.onclick = function (e) {
  112918. _this._openerService.open(code.link);
  112919. e.preventDefault();
  112920. e.stopPropagation();
  112921. };
  112922. var codeElement = dom.append(this._codeLink, dom.$('span'));
  112923. codeElement.innerText = code.value;
  112924. detailsElement.appendChild(this._codeLink);
  112925. }
  112926. }
  112927. }
  112928. dom.clearNode(this._relatedBlock);
  112929. this._editor.applyFontInfo(this._relatedBlock);
  112930. if (arrays_1.isNonEmptyArray(relatedInformation)) {
  112931. var relatedInformationNode = this._relatedBlock.appendChild(document.createElement('div'));
  112932. relatedInformationNode.style.paddingTop = Math.floor(this._editor.getOption(49 /* lineHeight */) * 0.66) + "px";
  112933. this._lines += 1;
  112934. for (var _c = 0, relatedInformation_1 = relatedInformation; _c < relatedInformation_1.length; _c++) {
  112935. var related = relatedInformation_1[_c];
  112936. var container = document.createElement('div');
  112937. var relatedResource = document.createElement('a');
  112938. dom.addClass(relatedResource, 'filename');
  112939. relatedResource.innerHTML = labels_1.getBaseLabel(related.resource) + "(" + related.startLineNumber + ", " + related.startColumn + "): ";
  112940. relatedResource.title = labels_1.getPathLabel(related.resource, undefined);
  112941. this._relatedDiagnostics.set(relatedResource, related);
  112942. var relatedMessage = document.createElement('span');
  112943. relatedMessage.innerText = related.message;
  112944. container.appendChild(relatedResource);
  112945. container.appendChild(relatedMessage);
  112946. this._lines += 1;
  112947. relatedInformationNode.appendChild(container);
  112948. }
  112949. }
  112950. var fontInfo = this._editor.getOption(34 /* fontInfo */);
  112951. var scrollWidth = Math.ceil(fontInfo.typicalFullwidthCharacterWidth * this._longestLineLength * 0.75);
  112952. var scrollHeight = fontInfo.lineHeight * this._lines;
  112953. this._scrollable.setScrollDimensions({ scrollWidth: scrollWidth, scrollHeight: scrollHeight });
  112954. };
  112955. MessageWidget.prototype.layout = function (height, width) {
  112956. this._scrollable.getDomNode().style.height = height + "px";
  112957. this._scrollable.getDomNode().style.width = width + "px";
  112958. this._scrollable.setScrollDimensions({ width: width, height: height });
  112959. };
  112960. MessageWidget.prototype.getHeightInLines = function () {
  112961. return Math.min(17, this._lines);
  112962. };
  112963. return MessageWidget;
  112964. }());
  112965. var MarkerNavigationWidget = /** @class */ (function (_super) {
  112966. __extends(MarkerNavigationWidget, _super);
  112967. function MarkerNavigationWidget(editor, actions, _themeService, _openerService) {
  112968. var _this = _super.call(this, editor, { showArrow: true, showFrame: true, isAccessible: true }) || this;
  112969. _this.actions = actions;
  112970. _this._themeService = _themeService;
  112971. _this._openerService = _openerService;
  112972. _this._callOnDispose = new lifecycle_1.DisposableStore();
  112973. _this._onDidSelectRelatedInformation = new event_1.Emitter();
  112974. _this.onDidSelectRelatedInformation = _this._onDidSelectRelatedInformation.event;
  112975. _this._severity = markers_1.MarkerSeverity.Warning;
  112976. _this._backgroundColor = color_1.Color.white;
  112977. _this._applyTheme(_themeService.getTheme());
  112978. _this._callOnDispose.add(_themeService.onThemeChange(_this._applyTheme.bind(_this)));
  112979. _this.create();
  112980. return _this;
  112981. }
  112982. MarkerNavigationWidget.prototype._applyTheme = function (theme) {
  112983. this._backgroundColor = theme.getColor(exports.editorMarkerNavigationBackground);
  112984. var colorId = exports.editorMarkerNavigationError;
  112985. if (this._severity === markers_1.MarkerSeverity.Warning) {
  112986. colorId = exports.editorMarkerNavigationWarning;
  112987. }
  112988. else if (this._severity === markers_1.MarkerSeverity.Info) {
  112989. colorId = exports.editorMarkerNavigationInfo;
  112990. }
  112991. var frameColor = theme.getColor(colorId);
  112992. this.style({
  112993. arrowColor: frameColor,
  112994. frameColor: frameColor,
  112995. headerBackgroundColor: this._backgroundColor,
  112996. primaryHeadingColor: theme.getColor(peekView_1.peekViewTitleForeground),
  112997. secondaryHeadingColor: theme.getColor(peekView_1.peekViewTitleInfoForeground)
  112998. }); // style() will trigger _applyStyles
  112999. };
  113000. MarkerNavigationWidget.prototype._applyStyles = function () {
  113001. if (this._parentContainer) {
  113002. this._parentContainer.style.backgroundColor = this._backgroundColor ? this._backgroundColor.toString() : '';
  113003. }
  113004. _super.prototype._applyStyles.call(this);
  113005. };
  113006. MarkerNavigationWidget.prototype.dispose = function () {
  113007. this._callOnDispose.dispose();
  113008. _super.prototype.dispose.call(this);
  113009. };
  113010. MarkerNavigationWidget.prototype._fillHead = function (container) {
  113011. _super.prototype._fillHead.call(this, container);
  113012. this._actionbarWidget.push(this.actions, { label: false, icon: true, index: 0 });
  113013. };
  113014. MarkerNavigationWidget.prototype._fillTitleIcon = function (container) {
  113015. this._icon = dom.append(container, dom.$(''));
  113016. };
  113017. MarkerNavigationWidget.prototype._getActionBarOptions = function () {
  113018. return {
  113019. orientation: 0 /* HORIZONTAL */
  113020. };
  113021. };
  113022. MarkerNavigationWidget.prototype._fillBody = function (container) {
  113023. var _this = this;
  113024. this._parentContainer = container;
  113025. dom.addClass(container, 'marker-widget');
  113026. this._parentContainer.tabIndex = 0;
  113027. this._parentContainer.setAttribute('role', 'tooltip');
  113028. this._container = document.createElement('div');
  113029. container.appendChild(this._container);
  113030. this._message = new MessageWidget(this._container, this.editor, function (related) { return _this._onDidSelectRelatedInformation.fire(related); }, this._openerService);
  113031. this._disposables.add(this._message);
  113032. };
  113033. MarkerNavigationWidget.prototype.show = function (where, heightInLines) {
  113034. throw new Error('call showAtMarker');
  113035. };
  113036. MarkerNavigationWidget.prototype.showAtMarker = function (marker, markerIdx, markerCount) {
  113037. // update:
  113038. // * title
  113039. // * message
  113040. this._container.classList.remove('stale');
  113041. this._message.update(marker);
  113042. // update frame color (only applied on 'show')
  113043. this._severity = marker.severity;
  113044. this._applyTheme(this._themeService.getTheme());
  113045. // show
  113046. var range = range_1.Range.lift(marker);
  113047. var editorPosition = this.editor.getPosition();
  113048. var position = editorPosition && range.containsPosition(editorPosition) ? editorPosition : range.getStartPosition();
  113049. _super.prototype.show.call(this, position, this.computeRequiredHeight());
  113050. var model = this.editor.getModel();
  113051. if (model) {
  113052. var detail = markerCount > 1
  113053. ? nls.localize(0, null, markerIdx, markerCount)
  113054. : nls.localize(1, null, markerIdx, markerCount);
  113055. this.setTitle(resources_1.basename(model.uri), detail);
  113056. }
  113057. this._icon.className = "codicon " + severityIcon_1.SeverityIcon.className(markers_1.MarkerSeverity.toSeverity(this._severity));
  113058. this.editor.revealPositionInCenter(position, 0 /* Smooth */);
  113059. this.editor.focus();
  113060. };
  113061. MarkerNavigationWidget.prototype.updateMarker = function (marker) {
  113062. this._container.classList.remove('stale');
  113063. this._message.update(marker);
  113064. };
  113065. MarkerNavigationWidget.prototype.showStale = function () {
  113066. this._container.classList.add('stale');
  113067. this._relayout();
  113068. };
  113069. MarkerNavigationWidget.prototype._doLayoutBody = function (heightInPixel, widthInPixel) {
  113070. _super.prototype._doLayoutBody.call(this, heightInPixel, widthInPixel);
  113071. this._heightInPixel = heightInPixel;
  113072. this._message.layout(heightInPixel, widthInPixel);
  113073. this._container.style.height = heightInPixel + "px";
  113074. };
  113075. MarkerNavigationWidget.prototype._onWidth = function (widthInPixel) {
  113076. this._message.layout(this._heightInPixel, widthInPixel);
  113077. };
  113078. MarkerNavigationWidget.prototype._relayout = function () {
  113079. _super.prototype._relayout.call(this, this.computeRequiredHeight());
  113080. };
  113081. MarkerNavigationWidget.prototype.computeRequiredHeight = function () {
  113082. return 3 + this._message.getHeightInLines();
  113083. };
  113084. return MarkerNavigationWidget;
  113085. }(peekView_1.PeekViewWidget));
  113086. exports.MarkerNavigationWidget = MarkerNavigationWidget;
  113087. // theming
  113088. var errorDefault = colorRegistry_1.oneOf(colorRegistry_1.editorErrorForeground, colorRegistry_1.editorErrorBorder);
  113089. var warningDefault = colorRegistry_1.oneOf(colorRegistry_1.editorWarningForeground, colorRegistry_1.editorWarningBorder);
  113090. var infoDefault = colorRegistry_1.oneOf(colorRegistry_1.editorInfoForeground, colorRegistry_1.editorInfoBorder);
  113091. exports.editorMarkerNavigationError = colorRegistry_1.registerColor('editorMarkerNavigationError.background', { dark: errorDefault, light: errorDefault, hc: errorDefault }, nls.localize(2, null));
  113092. exports.editorMarkerNavigationWarning = colorRegistry_1.registerColor('editorMarkerNavigationWarning.background', { dark: warningDefault, light: warningDefault, hc: warningDefault }, nls.localize(3, null));
  113093. exports.editorMarkerNavigationInfo = colorRegistry_1.registerColor('editorMarkerNavigationInfo.background', { dark: infoDefault, light: infoDefault, hc: infoDefault }, nls.localize(4, null));
  113094. exports.editorMarkerNavigationBackground = colorRegistry_1.registerColor('editorMarkerNavigation.background', { dark: '#2D2D30', light: color_1.Color.white, hc: '#0C141F' }, nls.localize(5, null));
  113095. themeService_1.registerThemingParticipant(function (theme, collector) {
  113096. var linkFg = theme.getColor(colorRegistry_1.textLinkForeground);
  113097. if (linkFg) {
  113098. collector.addRule(".monaco-editor .marker-widget a { color: " + linkFg + "; }");
  113099. collector.addRule(".monaco-editor .marker-widget a.code-link span:hover { color: " + linkFg + "; }");
  113100. }
  113101. });
  113102. });
  113103. /*---------------------------------------------------------------------------------------------
  113104. * Copyright (c) Microsoft Corporation. All rights reserved.
  113105. * Licensed under the MIT License. See License.txt in the project root for license information.
  113106. *--------------------------------------------------------------------------------------------*/
  113107. define(__m[237/*vs/editor/contrib/gotoError/gotoError*/], __M([0/*require*/,1/*exports*/,444/*vs/nls!vs/editor/contrib/gotoError/gotoError*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,18/*vs/platform/contextkey/common/contextkey*/,72/*vs/platform/markers/common/markers*/,3/*vs/editor/common/core/range*/,12/*vs/editor/browser/editorExtensions*/,14/*vs/platform/theme/common/themeService*/,23/*vs/editor/common/editorContextKeys*/,599/*vs/editor/contrib/gotoError/gotoErrorWidget*/,5/*vs/base/common/strings*/,19/*vs/base/common/arrays*/,32/*vs/editor/browser/services/codeEditorService*/,10/*vs/base/common/errors*/,65/*vs/platform/actions/common/actions*/,55/*vs/base/common/actions*/,34/*vs/platform/keybinding/common/keybinding*/,39/*vs/base/common/resources*/,51/*vs/platform/opener/common/opener*/]), function (require, exports, nls, event_1, lifecycle_1, contextkey_1, markers_1, range_1, editorExtensions_1, themeService_1, editorContextKeys_1, gotoErrorWidget_1, strings_1, arrays_1, codeEditorService_1, errors_1, actions_1, actions_2, keybinding_1, resources_1, opener_1) {
  113108. "use strict";
  113109. Object.defineProperty(exports, "__esModule", { value: true });
  113110. var MarkerModel = /** @class */ (function () {
  113111. function MarkerModel(editor, markers) {
  113112. var _this = this;
  113113. this._toUnbind = new lifecycle_1.DisposableStore();
  113114. this._editor = editor;
  113115. this._markers = [];
  113116. this._nextIdx = -1;
  113117. this._ignoreSelectionChange = false;
  113118. this._onCurrentMarkerChanged = new event_1.Emitter();
  113119. this._onMarkerSetChanged = new event_1.Emitter();
  113120. this.setMarkers(markers);
  113121. // listen on editor
  113122. this._toUnbind.add(this._editor.onDidDispose(function () { return _this.dispose(); }));
  113123. this._toUnbind.add(this._editor.onDidChangeCursorPosition(function () {
  113124. if (_this._ignoreSelectionChange) {
  113125. return;
  113126. }
  113127. if (_this.currentMarker && _this._editor.getPosition() && range_1.Range.containsPosition(_this.currentMarker, _this._editor.getPosition())) {
  113128. return;
  113129. }
  113130. _this._nextIdx = -1;
  113131. }));
  113132. }
  113133. Object.defineProperty(MarkerModel.prototype, "onCurrentMarkerChanged", {
  113134. get: function () {
  113135. return this._onCurrentMarkerChanged.event;
  113136. },
  113137. enumerable: true,
  113138. configurable: true
  113139. });
  113140. Object.defineProperty(MarkerModel.prototype, "onMarkerSetChanged", {
  113141. get: function () {
  113142. return this._onMarkerSetChanged.event;
  113143. },
  113144. enumerable: true,
  113145. configurable: true
  113146. });
  113147. MarkerModel.prototype.setMarkers = function (markers) {
  113148. var oldMarker = this._nextIdx >= 0 ? this._markers[this._nextIdx] : undefined;
  113149. this._markers = markers || [];
  113150. this._markers.sort(MarkerNavigationAction.compareMarker);
  113151. if (!oldMarker) {
  113152. this._nextIdx = -1;
  113153. }
  113154. else {
  113155. this._nextIdx = Math.max(-1, arrays_1.binarySearch(this._markers, oldMarker, MarkerNavigationAction.compareMarker));
  113156. }
  113157. this._onMarkerSetChanged.fire(this);
  113158. };
  113159. MarkerModel.prototype.withoutWatchingEditorPosition = function (callback) {
  113160. this._ignoreSelectionChange = true;
  113161. try {
  113162. callback();
  113163. }
  113164. finally {
  113165. this._ignoreSelectionChange = false;
  113166. }
  113167. };
  113168. MarkerModel.prototype._initIdx = function (fwd) {
  113169. var found = false;
  113170. var position = this._editor.getPosition();
  113171. for (var i = 0; i < this._markers.length; i++) {
  113172. var range = range_1.Range.lift(this._markers[i]);
  113173. if (range.isEmpty() && this._editor.getModel()) {
  113174. var word = this._editor.getModel().getWordAtPosition(range.getStartPosition());
  113175. if (word) {
  113176. range = new range_1.Range(range.startLineNumber, word.startColumn, range.startLineNumber, word.endColumn);
  113177. }
  113178. }
  113179. if (position && (range.containsPosition(position) || position.isBeforeOrEqual(range.getStartPosition()))) {
  113180. this._nextIdx = i;
  113181. found = true;
  113182. break;
  113183. }
  113184. }
  113185. if (!found) {
  113186. // after the last change
  113187. this._nextIdx = fwd ? 0 : this._markers.length - 1;
  113188. }
  113189. if (this._nextIdx < 0) {
  113190. this._nextIdx = this._markers.length - 1;
  113191. }
  113192. };
  113193. Object.defineProperty(MarkerModel.prototype, "currentMarker", {
  113194. get: function () {
  113195. return this.canNavigate() ? this._markers[this._nextIdx] : undefined;
  113196. },
  113197. set: function (marker) {
  113198. var idx = this._nextIdx;
  113199. this._nextIdx = -1;
  113200. if (marker) {
  113201. this._nextIdx = this.indexOf(marker);
  113202. }
  113203. if (this._nextIdx !== idx) {
  113204. this._onCurrentMarkerChanged.fire(marker);
  113205. }
  113206. },
  113207. enumerable: true,
  113208. configurable: true
  113209. });
  113210. MarkerModel.prototype.move = function (fwd, inCircles) {
  113211. if (!this.canNavigate()) {
  113212. this._onCurrentMarkerChanged.fire(undefined);
  113213. return !inCircles;
  113214. }
  113215. var oldIdx = this._nextIdx;
  113216. var atEdge = false;
  113217. if (this._nextIdx === -1) {
  113218. this._initIdx(fwd);
  113219. }
  113220. else if (fwd) {
  113221. if (inCircles || this._nextIdx + 1 < this._markers.length) {
  113222. this._nextIdx = (this._nextIdx + 1) % this._markers.length;
  113223. }
  113224. else {
  113225. atEdge = true;
  113226. }
  113227. }
  113228. else if (!fwd) {
  113229. if (inCircles || this._nextIdx > 0) {
  113230. this._nextIdx = (this._nextIdx - 1 + this._markers.length) % this._markers.length;
  113231. }
  113232. else {
  113233. atEdge = true;
  113234. }
  113235. }
  113236. if (oldIdx !== this._nextIdx) {
  113237. var marker = this._markers[this._nextIdx];
  113238. this._onCurrentMarkerChanged.fire(marker);
  113239. }
  113240. return atEdge;
  113241. };
  113242. MarkerModel.prototype.canNavigate = function () {
  113243. return this._markers.length > 0;
  113244. };
  113245. MarkerModel.prototype.findMarkerAtPosition = function (pos) {
  113246. return arrays_1.find(this._markers, function (marker) { return range_1.Range.containsPosition(marker, pos); });
  113247. };
  113248. Object.defineProperty(MarkerModel.prototype, "total", {
  113249. get: function () {
  113250. return this._markers.length;
  113251. },
  113252. enumerable: true,
  113253. configurable: true
  113254. });
  113255. MarkerModel.prototype.indexOf = function (marker) {
  113256. return 1 + this._markers.indexOf(marker);
  113257. };
  113258. MarkerModel.prototype.dispose = function () {
  113259. this._toUnbind.dispose();
  113260. };
  113261. return MarkerModel;
  113262. }());
  113263. var MarkerController = /** @class */ (function () {
  113264. function MarkerController(editor, _markerService, _contextKeyService, _themeService, _editorService, _keybindingService, _openerService) {
  113265. this._markerService = _markerService;
  113266. this._contextKeyService = _contextKeyService;
  113267. this._themeService = _themeService;
  113268. this._editorService = _editorService;
  113269. this._keybindingService = _keybindingService;
  113270. this._openerService = _openerService;
  113271. this._model = null;
  113272. this._widget = null;
  113273. this._disposeOnClose = new lifecycle_1.DisposableStore();
  113274. this._editor = editor;
  113275. this._widgetVisible = CONTEXT_MARKERS_NAVIGATION_VISIBLE.bindTo(this._contextKeyService);
  113276. }
  113277. MarkerController.get = function (editor) {
  113278. return editor.getContribution(MarkerController.ID);
  113279. };
  113280. MarkerController.prototype.dispose = function () {
  113281. this._cleanUp();
  113282. this._disposeOnClose.dispose();
  113283. };
  113284. MarkerController.prototype._cleanUp = function () {
  113285. this._widgetVisible.reset();
  113286. this._disposeOnClose.clear();
  113287. this._widget = null;
  113288. this._model = null;
  113289. };
  113290. MarkerController.prototype.getOrCreateModel = function () {
  113291. var _this = this;
  113292. if (this._model) {
  113293. return this._model;
  113294. }
  113295. var markers = this._getMarkers();
  113296. this._model = new MarkerModel(this._editor, markers);
  113297. this._markerService.onMarkerChanged(this._onMarkerChanged, this, this._disposeOnClose);
  113298. var prevMarkerKeybinding = this._keybindingService.lookupKeybinding(PrevMarkerAction.ID);
  113299. var nextMarkerKeybinding = this._keybindingService.lookupKeybinding(NextMarkerAction.ID);
  113300. var actions = [
  113301. new actions_2.Action(NextMarkerAction.ID, NextMarkerAction.LABEL + (nextMarkerKeybinding ? " (" + nextMarkerKeybinding.getLabel() + ")" : ''), 'show-next-problem codicon-chevron-down', this._model.canNavigate(), function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
  113302. if (this._model) {
  113303. this._model.move(true, true);
  113304. }
  113305. return [2 /*return*/];
  113306. }); }); }),
  113307. new actions_2.Action(PrevMarkerAction.ID, PrevMarkerAction.LABEL + (prevMarkerKeybinding ? " (" + prevMarkerKeybinding.getLabel() + ")" : ''), 'show-previous-problem codicon-chevron-up', this._model.canNavigate(), function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
  113308. if (this._model) {
  113309. this._model.move(false, true);
  113310. }
  113311. return [2 /*return*/];
  113312. }); }); })
  113313. ];
  113314. this._widget = new gotoErrorWidget_1.MarkerNavigationWidget(this._editor, actions, this._themeService, this._openerService);
  113315. this._widgetVisible.set(true);
  113316. this._widget.onDidClose(function () { return _this.closeMarkersNavigation(); }, this, this._disposeOnClose);
  113317. this._disposeOnClose.add(this._model);
  113318. this._disposeOnClose.add(this._widget);
  113319. for (var _i = 0, actions_3 = actions; _i < actions_3.length; _i++) {
  113320. var action = actions_3[_i];
  113321. this._disposeOnClose.add(action);
  113322. }
  113323. this._disposeOnClose.add(this._widget.onDidSelectRelatedInformation(function (related) {
  113324. _this._editorService.openCodeEditor({
  113325. resource: related.resource,
  113326. options: { pinned: true, revealIfOpened: true, selection: range_1.Range.lift(related).collapseToStart() }
  113327. }, _this._editor).then(undefined, errors_1.onUnexpectedError);
  113328. _this.closeMarkersNavigation(false);
  113329. }));
  113330. this._disposeOnClose.add(this._editor.onDidChangeModel(function () { return _this._cleanUp(); }));
  113331. this._disposeOnClose.add(this._model.onCurrentMarkerChanged(function (marker) {
  113332. if (!marker || !_this._model) {
  113333. _this._cleanUp();
  113334. }
  113335. else {
  113336. _this._model.withoutWatchingEditorPosition(function () {
  113337. if (!_this._widget || !_this._model) {
  113338. return;
  113339. }
  113340. _this._widget.showAtMarker(marker, _this._model.indexOf(marker), _this._model.total);
  113341. });
  113342. }
  113343. }));
  113344. this._disposeOnClose.add(this._model.onMarkerSetChanged(function () {
  113345. if (!_this._widget || !_this._widget.position || !_this._model) {
  113346. return;
  113347. }
  113348. var marker = _this._model.findMarkerAtPosition(_this._widget.position);
  113349. if (marker) {
  113350. _this._widget.updateMarker(marker);
  113351. }
  113352. else {
  113353. _this._widget.showStale();
  113354. }
  113355. }));
  113356. return this._model;
  113357. };
  113358. MarkerController.prototype.closeMarkersNavigation = function (focusEditor) {
  113359. if (focusEditor === void 0) { focusEditor = true; }
  113360. this._cleanUp();
  113361. if (focusEditor) {
  113362. this._editor.focus();
  113363. }
  113364. };
  113365. MarkerController.prototype.show = function (marker) {
  113366. var model = this.getOrCreateModel();
  113367. model.currentMarker = marker;
  113368. };
  113369. MarkerController.prototype._onMarkerChanged = function (changedResources) {
  113370. var editorModel = this._editor.getModel();
  113371. if (!editorModel) {
  113372. return;
  113373. }
  113374. if (!this._model) {
  113375. return;
  113376. }
  113377. if (!changedResources.some(function (r) { return resources_1.isEqual(editorModel.uri, r); })) {
  113378. return;
  113379. }
  113380. this._model.setMarkers(this._getMarkers());
  113381. };
  113382. MarkerController.prototype._getMarkers = function () {
  113383. var model = this._editor.getModel();
  113384. if (!model) {
  113385. return [];
  113386. }
  113387. return this._markerService.read({
  113388. resource: model.uri,
  113389. severities: markers_1.MarkerSeverity.Error | markers_1.MarkerSeverity.Warning | markers_1.MarkerSeverity.Info
  113390. });
  113391. };
  113392. MarkerController.ID = 'editor.contrib.markerController';
  113393. MarkerController = __decorate([
  113394. __param(1, markers_1.IMarkerService),
  113395. __param(2, contextkey_1.IContextKeyService),
  113396. __param(3, themeService_1.IThemeService),
  113397. __param(4, codeEditorService_1.ICodeEditorService),
  113398. __param(5, keybinding_1.IKeybindingService),
  113399. __param(6, opener_1.IOpenerService)
  113400. ], MarkerController);
  113401. return MarkerController;
  113402. }());
  113403. exports.MarkerController = MarkerController;
  113404. var MarkerNavigationAction = /** @class */ (function (_super) {
  113405. __extends(MarkerNavigationAction, _super);
  113406. function MarkerNavigationAction(next, multiFile, opts) {
  113407. var _this = _super.call(this, opts) || this;
  113408. _this._isNext = next;
  113409. _this._multiFile = multiFile;
  113410. return _this;
  113411. }
  113412. MarkerNavigationAction.prototype.run = function (accessor, editor) {
  113413. var _this = this;
  113414. var markerService = accessor.get(markers_1.IMarkerService);
  113415. var editorService = accessor.get(codeEditorService_1.ICodeEditorService);
  113416. var controller = MarkerController.get(editor);
  113417. if (!controller) {
  113418. return Promise.resolve(undefined);
  113419. }
  113420. var model = controller.getOrCreateModel();
  113421. var atEdge = model.move(this._isNext, !this._multiFile);
  113422. if (!atEdge || !this._multiFile) {
  113423. return Promise.resolve(undefined);
  113424. }
  113425. // try with the next/prev file
  113426. var markers = markerService.read({ severities: markers_1.MarkerSeverity.Error | markers_1.MarkerSeverity.Warning | markers_1.MarkerSeverity.Info }).sort(MarkerNavigationAction.compareMarker);
  113427. if (markers.length === 0) {
  113428. return Promise.resolve(undefined);
  113429. }
  113430. var editorModel = editor.getModel();
  113431. if (!editorModel) {
  113432. return Promise.resolve(undefined);
  113433. }
  113434. var oldMarker = model.currentMarker || { resource: editorModel.uri, severity: markers_1.MarkerSeverity.Error, startLineNumber: 1, startColumn: 1, endLineNumber: 1, endColumn: 1 };
  113435. var idx = arrays_1.binarySearch(markers, oldMarker, MarkerNavigationAction.compareMarker);
  113436. if (idx < 0) {
  113437. // find best match...
  113438. idx = ~idx;
  113439. idx %= markers.length;
  113440. }
  113441. else if (this._isNext) {
  113442. idx = (idx + 1) % markers.length;
  113443. }
  113444. else {
  113445. idx = (idx + markers.length - 1) % markers.length;
  113446. }
  113447. var newMarker = markers[idx];
  113448. if (resources_1.isEqual(newMarker.resource, editorModel.uri)) {
  113449. // the next `resource` is this resource which
  113450. // means we cycle within this file
  113451. model.move(this._isNext, true);
  113452. return Promise.resolve(undefined);
  113453. }
  113454. // close the widget for this editor-instance, open the resource
  113455. // for the next marker and re-start marker navigation in there
  113456. controller.closeMarkersNavigation();
  113457. return editorService.openCodeEditor({
  113458. resource: newMarker.resource,
  113459. options: { pinned: false, revealIfOpened: true, revealInCenterIfOutsideViewport: true, selection: newMarker }
  113460. }, editor).then(function (editor) {
  113461. if (!editor) {
  113462. return undefined;
  113463. }
  113464. return editor.getAction(_this.id).run();
  113465. });
  113466. };
  113467. MarkerNavigationAction.compareMarker = function (a, b) {
  113468. var res = strings_1.compare(a.resource.toString(), b.resource.toString());
  113469. if (res === 0) {
  113470. res = markers_1.MarkerSeverity.compare(a.severity, b.severity);
  113471. }
  113472. if (res === 0) {
  113473. res = range_1.Range.compareRangesUsingStarts(a, b);
  113474. }
  113475. return res;
  113476. };
  113477. return MarkerNavigationAction;
  113478. }(editorExtensions_1.EditorAction));
  113479. var NextMarkerAction = /** @class */ (function (_super) {
  113480. __extends(NextMarkerAction, _super);
  113481. function NextMarkerAction() {
  113482. return _super.call(this, true, false, {
  113483. id: NextMarkerAction.ID,
  113484. label: NextMarkerAction.LABEL,
  113485. alias: 'Go to Next Problem (Error, Warning, Info)',
  113486. precondition: editorContextKeys_1.EditorContextKeys.writable,
  113487. kbOpts: { kbExpr: editorContextKeys_1.EditorContextKeys.focus, primary: 512 /* Alt */ | 66 /* F8 */, weight: 100 /* EditorContrib */ }
  113488. }) || this;
  113489. }
  113490. NextMarkerAction.ID = 'editor.action.marker.next';
  113491. NextMarkerAction.LABEL = nls.localize(0, null);
  113492. return NextMarkerAction;
  113493. }(MarkerNavigationAction));
  113494. exports.NextMarkerAction = NextMarkerAction;
  113495. var PrevMarkerAction = /** @class */ (function (_super) {
  113496. __extends(PrevMarkerAction, _super);
  113497. function PrevMarkerAction() {
  113498. return _super.call(this, false, false, {
  113499. id: PrevMarkerAction.ID,
  113500. label: PrevMarkerAction.LABEL,
  113501. alias: 'Go to Previous Problem (Error, Warning, Info)',
  113502. precondition: editorContextKeys_1.EditorContextKeys.writable,
  113503. kbOpts: { kbExpr: editorContextKeys_1.EditorContextKeys.focus, primary: 1024 /* Shift */ | 512 /* Alt */ | 66 /* F8 */, weight: 100 /* EditorContrib */ }
  113504. }) || this;
  113505. }
  113506. PrevMarkerAction.ID = 'editor.action.marker.prev';
  113507. PrevMarkerAction.LABEL = nls.localize(1, null);
  113508. return PrevMarkerAction;
  113509. }(MarkerNavigationAction));
  113510. var NextMarkerInFilesAction = /** @class */ (function (_super) {
  113511. __extends(NextMarkerInFilesAction, _super);
  113512. function NextMarkerInFilesAction() {
  113513. return _super.call(this, true, true, {
  113514. id: 'editor.action.marker.nextInFiles',
  113515. label: nls.localize(2, null),
  113516. alias: 'Go to Next Problem in Files (Error, Warning, Info)',
  113517. precondition: editorContextKeys_1.EditorContextKeys.writable,
  113518. kbOpts: {
  113519. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  113520. primary: 66 /* F8 */,
  113521. weight: 100 /* EditorContrib */
  113522. }
  113523. }) || this;
  113524. }
  113525. return NextMarkerInFilesAction;
  113526. }(MarkerNavigationAction));
  113527. var PrevMarkerInFilesAction = /** @class */ (function (_super) {
  113528. __extends(PrevMarkerInFilesAction, _super);
  113529. function PrevMarkerInFilesAction() {
  113530. return _super.call(this, false, true, {
  113531. id: 'editor.action.marker.prevInFiles',
  113532. label: nls.localize(3, null),
  113533. alias: 'Go to Previous Problem in Files (Error, Warning, Info)',
  113534. precondition: editorContextKeys_1.EditorContextKeys.writable,
  113535. kbOpts: {
  113536. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  113537. primary: 1024 /* Shift */ | 66 /* F8 */,
  113538. weight: 100 /* EditorContrib */
  113539. }
  113540. }) || this;
  113541. }
  113542. return PrevMarkerInFilesAction;
  113543. }(MarkerNavigationAction));
  113544. editorExtensions_1.registerEditorContribution(MarkerController.ID, MarkerController);
  113545. editorExtensions_1.registerEditorAction(NextMarkerAction);
  113546. editorExtensions_1.registerEditorAction(PrevMarkerAction);
  113547. editorExtensions_1.registerEditorAction(NextMarkerInFilesAction);
  113548. editorExtensions_1.registerEditorAction(PrevMarkerInFilesAction);
  113549. var CONTEXT_MARKERS_NAVIGATION_VISIBLE = new contextkey_1.RawContextKey('markersNavigationVisible', false);
  113550. var MarkerCommand = editorExtensions_1.EditorCommand.bindToContribution(MarkerController.get);
  113551. editorExtensions_1.registerEditorCommand(new MarkerCommand({
  113552. id: 'closeMarkersNavigation',
  113553. precondition: CONTEXT_MARKERS_NAVIGATION_VISIBLE,
  113554. handler: function (x) { return x.closeMarkersNavigation(); },
  113555. kbOpts: {
  113556. weight: 100 /* EditorContrib */ + 50,
  113557. kbExpr: editorContextKeys_1.EditorContextKeys.focus,
  113558. primary: 9 /* Escape */,
  113559. secondary: [1024 /* Shift */ | 9 /* Escape */]
  113560. }
  113561. }));
  113562. // Go to menu
  113563. actions_1.MenuRegistry.appendMenuItem(19 /* MenubarGoMenu */, {
  113564. group: '6_problem_nav',
  113565. command: {
  113566. id: 'editor.action.marker.nextInFiles',
  113567. title: nls.localize(4, null)
  113568. },
  113569. order: 1
  113570. });
  113571. actions_1.MenuRegistry.appendMenuItem(19 /* MenubarGoMenu */, {
  113572. group: '6_problem_nav',
  113573. command: {
  113574. id: 'editor.action.marker.prevInFiles',
  113575. title: nls.localize(5, null)
  113576. },
  113577. order: 2
  113578. });
  113579. });
  113580. /*---------------------------------------------------------------------------------------------
  113581. * Copyright (c) Microsoft Corporation. All rights reserved.
  113582. * Licensed under the MIT License. See License.txt in the project root for license information.
  113583. *--------------------------------------------------------------------------------------------*/
  113584. var __spreadArrays = (this && this.__spreadArrays) || function () {
  113585. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  113586. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  113587. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  113588. r[k] = a[j];
  113589. return r;
  113590. };
  113591. define(__m[600/*vs/editor/contrib/hover/modesContentHover*/], __M([0/*require*/,1/*exports*/,454/*vs/nls!vs/editor/contrib/hover/modesContentHover*/,6/*vs/base/browser/dom*/,26/*vs/base/common/cancellation*/,27/*vs/base/common/color*/,75/*vs/base/common/htmlContent*/,2/*vs/base/common/lifecycle*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,30/*vs/editor/common/model/textModel*/,17/*vs/editor/common/modes*/,222/*vs/editor/contrib/colorPicker/color*/,223/*vs/editor/contrib/colorPicker/colorDetector*/,375/*vs/editor/contrib/colorPicker/colorPickerModel*/,570/*vs/editor/contrib/colorPicker/colorPickerWidget*/,538/*vs/editor/contrib/hover/getHover*/,200/*vs/editor/contrib/hover/hoverOperation*/,201/*vs/editor/contrib/hover/hoverWidgets*/,117/*vs/editor/contrib/markdown/markdownRenderer*/,14/*vs/platform/theme/common/themeService*/,19/*vs/base/common/arrays*/,72/*vs/platform/markers/common/markers*/,39/*vs/base/common/resources*/,10/*vs/base/common/errors*/,51/*vs/platform/opener/common/opener*/,237/*vs/editor/contrib/gotoError/gotoError*/,15/*vs/base/common/async*/,119/*vs/editor/contrib/codeAction/codeAction*/,233/*vs/editor/contrib/codeAction/codeActionCommands*/,111/*vs/editor/contrib/codeAction/types*/,20/*vs/platform/theme/common/colorRegistry*/]), function (require, exports, nls, dom, cancellation_1, color_1, htmlContent_1, lifecycle_1, position_1, range_1, textModel_1, modes_1, color_2, colorDetector_1, colorPickerModel_1, colorPickerWidget_1, getHover_1, hoverOperation_1, hoverWidgets_1, markdownRenderer_1, themeService_1, arrays_1, markers_1, resources_1, errors_1, opener_1, gotoError_1, async_1, codeAction_1, codeActionCommands_1, types_1, colorRegistry_1) {
  113592. "use strict";
  113593. Object.defineProperty(exports, "__esModule", { value: true });
  113594. var $ = dom.$;
  113595. var ColorHover = /** @class */ (function () {
  113596. function ColorHover(range, color, provider) {
  113597. this.range = range;
  113598. this.color = color;
  113599. this.provider = provider;
  113600. }
  113601. return ColorHover;
  113602. }());
  113603. var MarkerHover = /** @class */ (function () {
  113604. function MarkerHover(range, marker) {
  113605. this.range = range;
  113606. this.marker = marker;
  113607. }
  113608. return MarkerHover;
  113609. }());
  113610. var ModesContentComputer = /** @class */ (function () {
  113611. function ModesContentComputer(editor, _markerDecorationsService) {
  113612. this._markerDecorationsService = _markerDecorationsService;
  113613. this._editor = editor;
  113614. this._result = [];
  113615. }
  113616. ModesContentComputer.prototype.setRange = function (range) {
  113617. this._range = range;
  113618. this._result = [];
  113619. };
  113620. ModesContentComputer.prototype.clearResult = function () {
  113621. this._result = [];
  113622. };
  113623. ModesContentComputer.prototype.computeAsync = function (token) {
  113624. if (!this._editor.hasModel() || !this._range) {
  113625. return Promise.resolve([]);
  113626. }
  113627. var model = this._editor.getModel();
  113628. if (!modes_1.HoverProviderRegistry.has(model)) {
  113629. return Promise.resolve([]);
  113630. }
  113631. return getHover_1.getHover(model, new position_1.Position(this._range.startLineNumber, this._range.startColumn), token);
  113632. };
  113633. ModesContentComputer.prototype.computeSync = function () {
  113634. var _this = this;
  113635. if (!this._editor.hasModel() || !this._range) {
  113636. return [];
  113637. }
  113638. var model = this._editor.getModel();
  113639. var lineNumber = this._range.startLineNumber;
  113640. if (lineNumber > this._editor.getModel().getLineCount()) {
  113641. // Illegal line number => no results
  113642. return [];
  113643. }
  113644. var colorDetector = colorDetector_1.ColorDetector.get(this._editor);
  113645. var maxColumn = model.getLineMaxColumn(lineNumber);
  113646. var lineDecorations = this._editor.getLineDecorations(lineNumber);
  113647. var didFindColor = false;
  113648. var hoverRange = this._range;
  113649. var result = lineDecorations.map(function (d) {
  113650. var startColumn = (d.range.startLineNumber === lineNumber) ? d.range.startColumn : 1;
  113651. var endColumn = (d.range.endLineNumber === lineNumber) ? d.range.endColumn : maxColumn;
  113652. if (startColumn > hoverRange.startColumn || hoverRange.endColumn > endColumn) {
  113653. return null;
  113654. }
  113655. var range = new range_1.Range(hoverRange.startLineNumber, startColumn, hoverRange.startLineNumber, endColumn);
  113656. var marker = _this._markerDecorationsService.getMarker(model, d);
  113657. if (marker) {
  113658. return new MarkerHover(range, marker);
  113659. }
  113660. var colorData = colorDetector.getColorData(d.range.getStartPosition());
  113661. if (!didFindColor && colorData) {
  113662. didFindColor = true;
  113663. var _a = colorData.colorInfo, color = _a.color, range_2 = _a.range;
  113664. return new ColorHover(range_2, color, colorData.provider);
  113665. }
  113666. else {
  113667. if (htmlContent_1.isEmptyMarkdownString(d.options.hoverMessage)) {
  113668. return null;
  113669. }
  113670. var contents = d.options.hoverMessage ? arrays_1.asArray(d.options.hoverMessage) : [];
  113671. return { contents: contents, range: range };
  113672. }
  113673. });
  113674. return arrays_1.coalesce(result);
  113675. };
  113676. ModesContentComputer.prototype.onResult = function (result, isFromSynchronousComputation) {
  113677. // Always put synchronous messages before asynchronous ones
  113678. if (isFromSynchronousComputation) {
  113679. this._result = result.concat(this._result.sort(function (a, b) {
  113680. if (a instanceof ColorHover) { // sort picker messages at to the top
  113681. return -1;
  113682. }
  113683. else if (b instanceof ColorHover) {
  113684. return 1;
  113685. }
  113686. return 0;
  113687. }));
  113688. }
  113689. else {
  113690. this._result = this._result.concat(result);
  113691. }
  113692. };
  113693. ModesContentComputer.prototype.getResult = function () {
  113694. return this._result.slice(0);
  113695. };
  113696. ModesContentComputer.prototype.getResultWithLoadingMessage = function () {
  113697. return this._result.slice(0).concat([this._getLoadingMessage()]);
  113698. };
  113699. ModesContentComputer.prototype._getLoadingMessage = function () {
  113700. return {
  113701. range: this._range,
  113702. contents: [new htmlContent_1.MarkdownString().appendText(nls.localize(0, null))]
  113703. };
  113704. };
  113705. return ModesContentComputer;
  113706. }());
  113707. var markerCodeActionTrigger = {
  113708. type: 2 /* Manual */,
  113709. filter: { include: types_1.CodeActionKind.QuickFix }
  113710. };
  113711. var ModesContentHoverWidget = /** @class */ (function (_super) {
  113712. __extends(ModesContentHoverWidget, _super);
  113713. function ModesContentHoverWidget(editor, markerDecorationsService, _themeService, _keybindingService, _modeService, _openerService) {
  113714. if (_openerService === void 0) { _openerService = opener_1.NullOpenerService; }
  113715. var _this = _super.call(this, ModesContentHoverWidget.ID, editor) || this;
  113716. _this._themeService = _themeService;
  113717. _this._keybindingService = _keybindingService;
  113718. _this._modeService = _modeService;
  113719. _this._openerService = _openerService;
  113720. _this.renderDisposable = _this._register(new lifecycle_1.MutableDisposable());
  113721. _this._messages = [];
  113722. _this._lastRange = null;
  113723. _this._computer = new ModesContentComputer(_this._editor, markerDecorationsService);
  113724. _this._highlightDecorations = [];
  113725. _this._isChangingDecorations = false;
  113726. _this._shouldFocus = false;
  113727. _this._colorPicker = null;
  113728. _this._hoverOperation = new hoverOperation_1.HoverOperation(_this._computer, function (result) { return _this._withResult(result, true); }, null, function (result) { return _this._withResult(result, false); }, _this._editor.getOption(44 /* hover */).delay);
  113729. _this._register(dom.addStandardDisposableListener(_this.getDomNode(), dom.EventType.FOCUS, function () {
  113730. if (_this._colorPicker) {
  113731. dom.addClass(_this.getDomNode(), 'colorpicker-hover');
  113732. }
  113733. }));
  113734. _this._register(dom.addStandardDisposableListener(_this.getDomNode(), dom.EventType.BLUR, function () {
  113735. dom.removeClass(_this.getDomNode(), 'colorpicker-hover');
  113736. }));
  113737. _this._register(editor.onDidChangeConfiguration(function (e) {
  113738. _this._hoverOperation.setHoverTime(_this._editor.getOption(44 /* hover */).delay);
  113739. }));
  113740. _this._register(modes_1.TokenizationRegistry.onDidChange(function (e) {
  113741. if (_this.isVisible && _this._lastRange && _this._messages.length > 0) {
  113742. _this._domNode.textContent = '';
  113743. _this._renderMessages(_this._lastRange, _this._messages);
  113744. }
  113745. }));
  113746. return _this;
  113747. }
  113748. ModesContentHoverWidget.prototype.dispose = function () {
  113749. this._hoverOperation.cancel();
  113750. _super.prototype.dispose.call(this);
  113751. };
  113752. ModesContentHoverWidget.prototype.onModelDecorationsChanged = function () {
  113753. if (this._isChangingDecorations) {
  113754. return;
  113755. }
  113756. if (this.isVisible) {
  113757. // The decorations have changed and the hover is visible,
  113758. // we need to recompute the displayed text
  113759. this._hoverOperation.cancel();
  113760. this._computer.clearResult();
  113761. if (!this._colorPicker) { // TODO@Michel ensure that displayed text for other decorations is computed even if color picker is in place
  113762. this._hoverOperation.start(0 /* Delayed */);
  113763. }
  113764. }
  113765. };
  113766. ModesContentHoverWidget.prototype.startShowingAt = function (range, mode, focus) {
  113767. if (this._lastRange && this._lastRange.equalsRange(range)) {
  113768. // We have to show the widget at the exact same range as before, so no work is needed
  113769. return;
  113770. }
  113771. this._hoverOperation.cancel();
  113772. if (this.isVisible) {
  113773. // The range might have changed, but the hover is visible
  113774. // Instead of hiding it completely, filter out messages that are still in the new range and
  113775. // kick off a new computation
  113776. if (!this._showAtPosition || this._showAtPosition.lineNumber !== range.startLineNumber) {
  113777. this.hide();
  113778. }
  113779. else {
  113780. var filteredMessages = [];
  113781. for (var i = 0, len = this._messages.length; i < len; i++) {
  113782. var msg = this._messages[i];
  113783. var rng = msg.range;
  113784. if (rng && rng.startColumn <= range.startColumn && rng.endColumn >= range.endColumn) {
  113785. filteredMessages.push(msg);
  113786. }
  113787. }
  113788. if (filteredMessages.length > 0) {
  113789. if (hoverContentsEquals(filteredMessages, this._messages)) {
  113790. return;
  113791. }
  113792. this._renderMessages(range, filteredMessages);
  113793. }
  113794. else {
  113795. this.hide();
  113796. }
  113797. }
  113798. }
  113799. this._lastRange = range;
  113800. this._computer.setRange(range);
  113801. this._shouldFocus = focus;
  113802. this._hoverOperation.start(mode);
  113803. };
  113804. ModesContentHoverWidget.prototype.hide = function () {
  113805. this._lastRange = null;
  113806. this._hoverOperation.cancel();
  113807. _super.prototype.hide.call(this);
  113808. this._isChangingDecorations = true;
  113809. this._highlightDecorations = this._editor.deltaDecorations(this._highlightDecorations, []);
  113810. this._isChangingDecorations = false;
  113811. this.renderDisposable.clear();
  113812. this._colorPicker = null;
  113813. };
  113814. ModesContentHoverWidget.prototype.isColorPickerVisible = function () {
  113815. if (this._colorPicker) {
  113816. return true;
  113817. }
  113818. return false;
  113819. };
  113820. ModesContentHoverWidget.prototype._withResult = function (result, complete) {
  113821. this._messages = result;
  113822. if (this._lastRange && this._messages.length > 0) {
  113823. this._renderMessages(this._lastRange, this._messages);
  113824. }
  113825. else if (complete) {
  113826. this.hide();
  113827. }
  113828. };
  113829. ModesContentHoverWidget.prototype._renderMessages = function (renderRange, messages) {
  113830. var _this = this;
  113831. this.renderDisposable.dispose();
  113832. this._colorPicker = null;
  113833. // update column from which to show
  113834. var renderColumn = 1073741824 /* MAX_SAFE_SMALL_INTEGER */;
  113835. var highlightRange = messages[0].range ? range_1.Range.lift(messages[0].range) : null;
  113836. var fragment = document.createDocumentFragment();
  113837. var isEmptyHoverContent = true;
  113838. var containColorPicker = false;
  113839. var markdownDisposeables = new lifecycle_1.DisposableStore();
  113840. var markerMessages = [];
  113841. messages.forEach(function (msg) {
  113842. if (!msg.range) {
  113843. return;
  113844. }
  113845. renderColumn = Math.min(renderColumn, msg.range.startColumn);
  113846. highlightRange = highlightRange ? range_1.Range.plusRange(highlightRange, msg.range) : range_1.Range.lift(msg.range);
  113847. if (msg instanceof ColorHover) {
  113848. containColorPicker = true;
  113849. var _a = msg.color, red = _a.red, green = _a.green, blue = _a.blue, alpha = _a.alpha;
  113850. var rgba = new color_1.RGBA(Math.round(red * 255), Math.round(green * 255), Math.round(blue * 255), alpha);
  113851. var color_3 = new color_1.Color(rgba);
  113852. if (!_this._editor.hasModel()) {
  113853. return;
  113854. }
  113855. var editorModel_1 = _this._editor.getModel();
  113856. var range_3 = new range_1.Range(msg.range.startLineNumber, msg.range.startColumn, msg.range.endLineNumber, msg.range.endColumn);
  113857. var colorInfo = { range: msg.range, color: msg.color };
  113858. // create blank olor picker model and widget first to ensure it's positioned correctly.
  113859. var model_1 = new colorPickerModel_1.ColorPickerModel(color_3, [], 0);
  113860. var widget_1 = new colorPickerWidget_1.ColorPickerWidget(fragment, model_1, _this._editor.getOption(105 /* pixelRatio */), _this._themeService);
  113861. color_2.getColorPresentations(editorModel_1, colorInfo, msg.provider, cancellation_1.CancellationToken.None).then(function (colorPresentations) {
  113862. model_1.colorPresentations = colorPresentations || [];
  113863. if (!_this._editor.hasModel()) {
  113864. // gone...
  113865. return;
  113866. }
  113867. var originalText = _this._editor.getModel().getValueInRange(msg.range);
  113868. model_1.guessColorPresentation(color_3, originalText);
  113869. var updateEditorModel = function () {
  113870. var textEdits;
  113871. var newRange;
  113872. if (model_1.presentation.textEdit) {
  113873. textEdits = [model_1.presentation.textEdit];
  113874. newRange = new range_1.Range(model_1.presentation.textEdit.range.startLineNumber, model_1.presentation.textEdit.range.startColumn, model_1.presentation.textEdit.range.endLineNumber, model_1.presentation.textEdit.range.endColumn);
  113875. newRange = newRange.setEndPosition(newRange.endLineNumber, newRange.startColumn + model_1.presentation.textEdit.text.length);
  113876. }
  113877. else {
  113878. textEdits = [{ identifier: null, range: range_3, text: model_1.presentation.label, forceMoveMarkers: false }];
  113879. newRange = range_3.setEndPosition(range_3.endLineNumber, range_3.startColumn + model_1.presentation.label.length);
  113880. }
  113881. _this._editor.pushUndoStop();
  113882. _this._editor.executeEdits('colorpicker', textEdits);
  113883. if (model_1.presentation.additionalTextEdits) {
  113884. textEdits = __spreadArrays(model_1.presentation.additionalTextEdits);
  113885. _this._editor.executeEdits('colorpicker', textEdits);
  113886. _this.hide();
  113887. }
  113888. _this._editor.pushUndoStop();
  113889. range_3 = newRange;
  113890. };
  113891. var updateColorPresentations = function (color) {
  113892. return color_2.getColorPresentations(editorModel_1, {
  113893. range: range_3,
  113894. color: {
  113895. red: color.rgba.r / 255,
  113896. green: color.rgba.g / 255,
  113897. blue: color.rgba.b / 255,
  113898. alpha: color.rgba.a
  113899. }
  113900. }, msg.provider, cancellation_1.CancellationToken.None).then(function (colorPresentations) {
  113901. model_1.colorPresentations = colorPresentations || [];
  113902. });
  113903. };
  113904. var colorListener = model_1.onColorFlushed(function (color) {
  113905. updateColorPresentations(color).then(updateEditorModel);
  113906. });
  113907. var colorChangeListener = model_1.onDidChangeColor(updateColorPresentations);
  113908. _this._colorPicker = widget_1;
  113909. _this.showAt(range_3.getStartPosition(), range_3, _this._shouldFocus);
  113910. _this.updateContents(fragment);
  113911. _this._colorPicker.layout();
  113912. _this.renderDisposable.value = lifecycle_1.combinedDisposable(colorListener, colorChangeListener, widget_1, markdownDisposeables);
  113913. });
  113914. }
  113915. else {
  113916. if (msg instanceof MarkerHover) {
  113917. markerMessages.push(msg);
  113918. isEmptyHoverContent = false;
  113919. }
  113920. else {
  113921. msg.contents
  113922. .filter(function (contents) { return !htmlContent_1.isEmptyMarkdownString(contents); })
  113923. .forEach(function (contents) {
  113924. var markdownHoverElement = $('div.hover-row.markdown-hover');
  113925. var hoverContentsElement = dom.append(markdownHoverElement, $('div.hover-contents'));
  113926. var renderer = markdownDisposeables.add(new markdownRenderer_1.MarkdownRenderer(_this._editor, _this._modeService, _this._openerService));
  113927. markdownDisposeables.add(renderer.onDidRenderCodeBlock(function () {
  113928. hoverContentsElement.className = 'hover-contents code-hover-contents';
  113929. _this.onContentsChange();
  113930. }));
  113931. var renderedContents = markdownDisposeables.add(renderer.render(contents));
  113932. hoverContentsElement.appendChild(renderedContents.element);
  113933. fragment.appendChild(markdownHoverElement);
  113934. isEmptyHoverContent = false;
  113935. });
  113936. }
  113937. }
  113938. });
  113939. if (markerMessages.length) {
  113940. markerMessages.forEach(function (msg) { return fragment.appendChild(_this.renderMarkerHover(msg)); });
  113941. var markerHoverForStatusbar = markerMessages.length === 1 ? markerMessages[0] : markerMessages.sort(function (a, b) { return markers_1.MarkerSeverity.compare(a.marker.severity, b.marker.severity); })[0];
  113942. fragment.appendChild(this.renderMarkerStatusbar(markerHoverForStatusbar));
  113943. }
  113944. // show
  113945. if (!containColorPicker && !isEmptyHoverContent) {
  113946. this.showAt(new position_1.Position(renderRange.startLineNumber, renderColumn), highlightRange, this._shouldFocus);
  113947. this.updateContents(fragment);
  113948. }
  113949. this._isChangingDecorations = true;
  113950. this._highlightDecorations = this._editor.deltaDecorations(this._highlightDecorations, highlightRange ? [{
  113951. range: highlightRange,
  113952. options: ModesContentHoverWidget._DECORATION_OPTIONS
  113953. }] : []);
  113954. this._isChangingDecorations = false;
  113955. };
  113956. ModesContentHoverWidget.prototype.renderMarkerHover = function (markerHover) {
  113957. var _this = this;
  113958. var hoverElement = $('div.hover-row');
  113959. var markerElement = dom.append(hoverElement, $('div.marker.hover-contents'));
  113960. var _a = markerHover.marker, source = _a.source, message = _a.message, code = _a.code, relatedInformation = _a.relatedInformation;
  113961. this._editor.applyFontInfo(markerElement);
  113962. var messageElement = dom.append(markerElement, $('span'));
  113963. messageElement.style.whiteSpace = 'pre-wrap';
  113964. messageElement.innerText = message;
  113965. if (source || code) {
  113966. if (typeof code === 'string') {
  113967. var detailsElement = dom.append(markerElement, $('span'));
  113968. detailsElement.style.opacity = '0.6';
  113969. detailsElement.style.paddingLeft = '6px';
  113970. detailsElement.innerText = source && code ? source + "(" + code + ")" : source ? source : "(" + code + ")";
  113971. }
  113972. else {
  113973. if (code) {
  113974. var sourceAndCodeElement = $('span');
  113975. if (source) {
  113976. var sourceElement = dom.append(sourceAndCodeElement, $('span'));
  113977. sourceElement.innerText = source;
  113978. }
  113979. this._codeLink = dom.append(sourceAndCodeElement, $('a.code-link'));
  113980. this._codeLink.setAttribute('href', code.link.toString());
  113981. this._codeLink.onclick = function (e) {
  113982. _this._openerService.open(code.link);
  113983. e.preventDefault();
  113984. e.stopPropagation();
  113985. };
  113986. var codeElement = dom.append(this._codeLink, $('span'));
  113987. codeElement.innerText = code.value;
  113988. var detailsElement = dom.append(markerElement, sourceAndCodeElement);
  113989. detailsElement.style.opacity = '0.6';
  113990. detailsElement.style.paddingLeft = '6px';
  113991. }
  113992. }
  113993. }
  113994. if (arrays_1.isNonEmptyArray(relatedInformation)) {
  113995. var _loop_1 = function (message_1, resource, startLineNumber, startColumn) {
  113996. var relatedInfoContainer = dom.append(markerElement, $('div'));
  113997. relatedInfoContainer.style.marginTop = '8px';
  113998. var a = dom.append(relatedInfoContainer, $('a'));
  113999. a.innerText = resources_1.basename(resource) + "(" + startLineNumber + ", " + startColumn + "): ";
  114000. a.style.cursor = 'pointer';
  114001. a.onclick = function (e) {
  114002. e.stopPropagation();
  114003. e.preventDefault();
  114004. if (_this._openerService) {
  114005. _this._openerService.open(resource.with({ fragment: startLineNumber + "," + startColumn }), { fromUserGesture: true }).catch(errors_1.onUnexpectedError);
  114006. }
  114007. };
  114008. var messageElement_1 = dom.append(relatedInfoContainer, $('span'));
  114009. messageElement_1.innerText = message_1;
  114010. this_1._editor.applyFontInfo(messageElement_1);
  114011. };
  114012. var this_1 = this;
  114013. for (var _i = 0, relatedInformation_1 = relatedInformation; _i < relatedInformation_1.length; _i++) {
  114014. var _b = relatedInformation_1[_i], message_1 = _b.message, resource = _b.resource, startLineNumber = _b.startLineNumber, startColumn = _b.startColumn;
  114015. _loop_1(message_1, resource, startLineNumber, startColumn);
  114016. }
  114017. }
  114018. return hoverElement;
  114019. };
  114020. ModesContentHoverWidget.prototype.renderMarkerStatusbar = function (markerHover) {
  114021. var _this = this;
  114022. var hoverElement = $('div.hover-row.status-bar');
  114023. var disposables = new lifecycle_1.DisposableStore();
  114024. var actionsElement = dom.append(hoverElement, $('div.actions'));
  114025. if (markerHover.marker.severity === markers_1.MarkerSeverity.Error || markerHover.marker.severity === markers_1.MarkerSeverity.Warning || markerHover.marker.severity === markers_1.MarkerSeverity.Info) {
  114026. disposables.add(this.renderAction(actionsElement, {
  114027. label: nls.localize(1, null),
  114028. commandId: gotoError_1.NextMarkerAction.ID,
  114029. run: function () {
  114030. _this.hide();
  114031. gotoError_1.MarkerController.get(_this._editor).show(markerHover.marker);
  114032. _this._editor.focus();
  114033. }
  114034. }));
  114035. }
  114036. var quickfixPlaceholderElement = dom.append(actionsElement, $('div'));
  114037. quickfixPlaceholderElement.style.opacity = '0';
  114038. quickfixPlaceholderElement.style.transition = 'opacity 0.2s';
  114039. setTimeout(function () { return quickfixPlaceholderElement.style.opacity = '1'; }, 200);
  114040. quickfixPlaceholderElement.textContent = nls.localize(2, null);
  114041. disposables.add(lifecycle_1.toDisposable(function () { return quickfixPlaceholderElement.remove(); }));
  114042. var codeActionsPromise = this.getCodeActions(markerHover.marker);
  114043. disposables.add(lifecycle_1.toDisposable(function () { return codeActionsPromise.cancel(); }));
  114044. codeActionsPromise.then(function (actions) {
  114045. quickfixPlaceholderElement.style.transition = '';
  114046. quickfixPlaceholderElement.style.opacity = '1';
  114047. if (!actions.validActions.length) {
  114048. actions.dispose();
  114049. quickfixPlaceholderElement.textContent = nls.localize(3, null);
  114050. return;
  114051. }
  114052. quickfixPlaceholderElement.remove();
  114053. var showing = false;
  114054. disposables.add(lifecycle_1.toDisposable(function () {
  114055. if (!showing) {
  114056. actions.dispose();
  114057. }
  114058. }));
  114059. disposables.add(_this.renderAction(actionsElement, {
  114060. label: nls.localize(4, null),
  114061. commandId: codeActionCommands_1.QuickFixAction.Id,
  114062. run: function (target) {
  114063. showing = true;
  114064. var controller = codeActionCommands_1.QuickFixController.get(_this._editor);
  114065. var elementPosition = dom.getDomNodePagePosition(target);
  114066. controller.showCodeActions(markerCodeActionTrigger, actions, {
  114067. x: elementPosition.left + 6,
  114068. y: elementPosition.top + elementPosition.height + 6
  114069. });
  114070. }
  114071. }));
  114072. });
  114073. this.renderDisposable.value = disposables;
  114074. return hoverElement;
  114075. };
  114076. ModesContentHoverWidget.prototype.getCodeActions = function (marker) {
  114077. var _this = this;
  114078. return async_1.createCancelablePromise(function (cancellationToken) {
  114079. return codeAction_1.getCodeActions(_this._editor.getModel(), new range_1.Range(marker.startLineNumber, marker.startColumn, marker.endLineNumber, marker.endColumn), markerCodeActionTrigger, cancellationToken);
  114080. });
  114081. };
  114082. ModesContentHoverWidget.prototype.renderAction = function (parent, actionOptions) {
  114083. var actionContainer = dom.append(parent, $('div.action-container'));
  114084. var action = dom.append(actionContainer, $('a.action'));
  114085. if (actionOptions.iconClass) {
  114086. dom.append(action, $("span.icon." + actionOptions.iconClass));
  114087. }
  114088. var label = dom.append(action, $('span'));
  114089. label.textContent = actionOptions.label;
  114090. var keybinding = this._keybindingService.lookupKeybinding(actionOptions.commandId);
  114091. if (keybinding) {
  114092. label.title = actionOptions.label + " (" + keybinding.getLabel() + ")";
  114093. }
  114094. return dom.addDisposableListener(actionContainer, dom.EventType.CLICK, function (e) {
  114095. e.stopPropagation();
  114096. e.preventDefault();
  114097. actionOptions.run(actionContainer);
  114098. });
  114099. };
  114100. ModesContentHoverWidget.ID = 'editor.contrib.modesContentHoverWidget';
  114101. ModesContentHoverWidget._DECORATION_OPTIONS = textModel_1.ModelDecorationOptions.register({
  114102. className: 'hoverHighlight'
  114103. });
  114104. return ModesContentHoverWidget;
  114105. }(hoverWidgets_1.ContentHoverWidget));
  114106. exports.ModesContentHoverWidget = ModesContentHoverWidget;
  114107. function hoverContentsEquals(first, second) {
  114108. if ((!first && second) || (first && !second) || first.length !== second.length) {
  114109. return false;
  114110. }
  114111. for (var i = 0; i < first.length; i++) {
  114112. var firstElement = first[i];
  114113. var secondElement = second[i];
  114114. if (firstElement instanceof MarkerHover && secondElement instanceof MarkerHover) {
  114115. return markers_1.IMarkerData.makeKey(firstElement.marker) === markers_1.IMarkerData.makeKey(secondElement.marker);
  114116. }
  114117. if (firstElement instanceof ColorHover || secondElement instanceof ColorHover) {
  114118. return false;
  114119. }
  114120. if (firstElement instanceof MarkerHover || secondElement instanceof MarkerHover) {
  114121. return false;
  114122. }
  114123. if (!htmlContent_1.markedStringsEquals(firstElement.contents, secondElement.contents)) {
  114124. return false;
  114125. }
  114126. }
  114127. return true;
  114128. }
  114129. themeService_1.registerThemingParticipant(function (theme, collector) {
  114130. var linkFg = theme.getColor(colorRegistry_1.textLinkForeground);
  114131. if (linkFg) {
  114132. collector.addRule(".monaco-editor-hover .hover-contents a.code-link span:hover { color: " + linkFg + "; }");
  114133. }
  114134. });
  114135. });
  114136. /*---------------------------------------------------------------------------------------------
  114137. * Copyright (c) Microsoft Corporation. All rights reserved.
  114138. * Licensed under the MIT License. See License.txt in the project root for license information.
  114139. *--------------------------------------------------------------------------------------------*/
  114140. define(__m[601/*vs/editor/contrib/hover/hover*/], __M([0/*require*/,1/*exports*/,453/*vs/nls!vs/editor/contrib/hover/hover*/,36/*vs/base/common/keyCodes*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,3/*vs/editor/common/core/range*/,23/*vs/editor/common/editorContextKeys*/,71/*vs/editor/common/services/modeService*/,600/*vs/editor/contrib/hover/modesContentHover*/,510/*vs/editor/contrib/hover/modesGlyphHover*/,51/*vs/platform/opener/common/opener*/,20/*vs/platform/theme/common/colorRegistry*/,14/*vs/platform/theme/common/themeService*/,210/*vs/editor/common/services/markersDecorationService*/,34/*vs/platform/keybinding/common/keybinding*/,236/*vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition*/,315/*vs/css!vs/editor/contrib/hover/hover*/]), function (require, exports, nls, keyCodes_1, lifecycle_1, editorExtensions_1, range_1, editorContextKeys_1, modeService_1, modesContentHover_1, modesGlyphHover_1, opener_1, colorRegistry_1, themeService_1, markersDecorationService_1, keybinding_1, goToDefinitionAtPosition_1) {
  114141. "use strict";
  114142. Object.defineProperty(exports, "__esModule", { value: true });
  114143. var ModesHoverController = /** @class */ (function () {
  114144. function ModesHoverController(_editor, _openerService, _modeService, _markerDecorationsService, _keybindingService, _themeService) {
  114145. var _this = this;
  114146. this._editor = _editor;
  114147. this._openerService = _openerService;
  114148. this._modeService = _modeService;
  114149. this._markerDecorationsService = _markerDecorationsService;
  114150. this._keybindingService = _keybindingService;
  114151. this._themeService = _themeService;
  114152. this._toUnhook = new lifecycle_1.DisposableStore();
  114153. this._contentWidget = new lifecycle_1.MutableDisposable();
  114154. this._glyphWidget = new lifecycle_1.MutableDisposable();
  114155. this._isMouseDown = false;
  114156. this._hoverClicked = false;
  114157. this._hookEvents();
  114158. this._didChangeConfigurationHandler = this._editor.onDidChangeConfiguration(function (e) {
  114159. if (e.hasChanged(44 /* hover */)) {
  114160. _this._hideWidgets();
  114161. _this._unhookEvents();
  114162. _this._hookEvents();
  114163. }
  114164. });
  114165. }
  114166. Object.defineProperty(ModesHoverController.prototype, "contentWidget", {
  114167. get: function () {
  114168. if (!this._contentWidget.value) {
  114169. this._createHoverWidgets();
  114170. }
  114171. return this._contentWidget.value;
  114172. },
  114173. enumerable: true,
  114174. configurable: true
  114175. });
  114176. Object.defineProperty(ModesHoverController.prototype, "glyphWidget", {
  114177. get: function () {
  114178. if (!this._glyphWidget.value) {
  114179. this._createHoverWidgets();
  114180. }
  114181. return this._glyphWidget.value;
  114182. },
  114183. enumerable: true,
  114184. configurable: true
  114185. });
  114186. ModesHoverController.get = function (editor) {
  114187. return editor.getContribution(ModesHoverController.ID);
  114188. };
  114189. ModesHoverController.prototype._hookEvents = function () {
  114190. var _this = this;
  114191. var hideWidgetsEventHandler = function () { return _this._hideWidgets(); };
  114192. var hoverOpts = this._editor.getOption(44 /* hover */);
  114193. this._isHoverEnabled = hoverOpts.enabled;
  114194. this._isHoverSticky = hoverOpts.sticky;
  114195. if (this._isHoverEnabled) {
  114196. this._toUnhook.add(this._editor.onMouseDown(function (e) { return _this._onEditorMouseDown(e); }));
  114197. this._toUnhook.add(this._editor.onMouseUp(function (e) { return _this._onEditorMouseUp(e); }));
  114198. this._toUnhook.add(this._editor.onMouseMove(function (e) { return _this._onEditorMouseMove(e); }));
  114199. this._toUnhook.add(this._editor.onKeyDown(function (e) { return _this._onKeyDown(e); }));
  114200. this._toUnhook.add(this._editor.onDidChangeModelDecorations(function () { return _this._onModelDecorationsChanged(); }));
  114201. }
  114202. else {
  114203. this._toUnhook.add(this._editor.onMouseMove(hideWidgetsEventHandler));
  114204. }
  114205. this._toUnhook.add(this._editor.onMouseLeave(hideWidgetsEventHandler));
  114206. this._toUnhook.add(this._editor.onDidChangeModel(hideWidgetsEventHandler));
  114207. this._toUnhook.add(this._editor.onDidScrollChange(function (e) { return _this._onEditorScrollChanged(e); }));
  114208. };
  114209. ModesHoverController.prototype._unhookEvents = function () {
  114210. this._toUnhook.clear();
  114211. };
  114212. ModesHoverController.prototype._onModelDecorationsChanged = function () {
  114213. this.contentWidget.onModelDecorationsChanged();
  114214. this.glyphWidget.onModelDecorationsChanged();
  114215. };
  114216. ModesHoverController.prototype._onEditorScrollChanged = function (e) {
  114217. if (e.scrollTopChanged || e.scrollLeftChanged) {
  114218. this._hideWidgets();
  114219. }
  114220. };
  114221. ModesHoverController.prototype._onEditorMouseDown = function (mouseEvent) {
  114222. this._isMouseDown = true;
  114223. var targetType = mouseEvent.target.type;
  114224. if (targetType === 9 /* CONTENT_WIDGET */ && mouseEvent.target.detail === modesContentHover_1.ModesContentHoverWidget.ID) {
  114225. this._hoverClicked = true;
  114226. // mouse down on top of content hover widget
  114227. return;
  114228. }
  114229. if (targetType === 12 /* OVERLAY_WIDGET */ && mouseEvent.target.detail === modesGlyphHover_1.ModesGlyphHoverWidget.ID) {
  114230. // mouse down on top of overlay hover widget
  114231. return;
  114232. }
  114233. if (targetType !== 12 /* OVERLAY_WIDGET */ && mouseEvent.target.detail !== modesGlyphHover_1.ModesGlyphHoverWidget.ID) {
  114234. this._hoverClicked = false;
  114235. }
  114236. this._hideWidgets();
  114237. };
  114238. ModesHoverController.prototype._onEditorMouseUp = function (mouseEvent) {
  114239. this._isMouseDown = false;
  114240. };
  114241. ModesHoverController.prototype._onEditorMouseMove = function (mouseEvent) {
  114242. var targetType = mouseEvent.target.type;
  114243. if (this._isMouseDown && this._hoverClicked && this.contentWidget.isColorPickerVisible()) {
  114244. return;
  114245. }
  114246. if (this._isHoverSticky && targetType === 9 /* CONTENT_WIDGET */ && mouseEvent.target.detail === modesContentHover_1.ModesContentHoverWidget.ID) {
  114247. // mouse moved on top of content hover widget
  114248. return;
  114249. }
  114250. if (this._isHoverSticky && targetType === 12 /* OVERLAY_WIDGET */ && mouseEvent.target.detail === modesGlyphHover_1.ModesGlyphHoverWidget.ID) {
  114251. // mouse moved on top of overlay hover widget
  114252. return;
  114253. }
  114254. if (targetType === 7 /* CONTENT_EMPTY */) {
  114255. var epsilon = this._editor.getOption(34 /* fontInfo */).typicalHalfwidthCharacterWidth / 2;
  114256. var data = mouseEvent.target.detail;
  114257. if (data && !data.isAfterLines && typeof data.horizontalDistanceToText === 'number' && data.horizontalDistanceToText < epsilon) {
  114258. // Let hover kick in even when the mouse is technically in the empty area after a line, given the distance is small enough
  114259. targetType = 6 /* CONTENT_TEXT */;
  114260. }
  114261. }
  114262. if (targetType === 6 /* CONTENT_TEXT */) {
  114263. this.glyphWidget.hide();
  114264. if (this._isHoverEnabled && mouseEvent.target.range) {
  114265. this.contentWidget.startShowingAt(mouseEvent.target.range, 0 /* Delayed */, false);
  114266. }
  114267. }
  114268. else if (targetType === 2 /* GUTTER_GLYPH_MARGIN */) {
  114269. this.contentWidget.hide();
  114270. if (this._isHoverEnabled && mouseEvent.target.position) {
  114271. this.glyphWidget.startShowingAt(mouseEvent.target.position.lineNumber);
  114272. }
  114273. }
  114274. else {
  114275. this._hideWidgets();
  114276. }
  114277. };
  114278. ModesHoverController.prototype._onKeyDown = function (e) {
  114279. if (e.keyCode !== 5 /* Ctrl */ && e.keyCode !== 6 /* Alt */ && e.keyCode !== 57 /* Meta */ && e.keyCode !== 4 /* Shift */) {
  114280. // Do not hide hover when a modifier key is pressed
  114281. this._hideWidgets();
  114282. }
  114283. };
  114284. ModesHoverController.prototype._hideWidgets = function () {
  114285. if (!this._glyphWidget.value || !this._contentWidget.value || (this._isMouseDown && this._hoverClicked && this._contentWidget.value.isColorPickerVisible())) {
  114286. return;
  114287. }
  114288. this._glyphWidget.value.hide();
  114289. this._contentWidget.value.hide();
  114290. };
  114291. ModesHoverController.prototype._createHoverWidgets = function () {
  114292. this._contentWidget.value = new modesContentHover_1.ModesContentHoverWidget(this._editor, this._markerDecorationsService, this._themeService, this._keybindingService, this._modeService, this._openerService);
  114293. this._glyphWidget.value = new modesGlyphHover_1.ModesGlyphHoverWidget(this._editor, this._modeService, this._openerService);
  114294. };
  114295. ModesHoverController.prototype.showContentHover = function (range, mode, focus) {
  114296. this.contentWidget.startShowingAt(range, mode, focus);
  114297. };
  114298. ModesHoverController.prototype.dispose = function () {
  114299. this._unhookEvents();
  114300. this._toUnhook.dispose();
  114301. this._didChangeConfigurationHandler.dispose();
  114302. this._glyphWidget.dispose();
  114303. this._contentWidget.dispose();
  114304. };
  114305. ModesHoverController.ID = 'editor.contrib.hover';
  114306. ModesHoverController = __decorate([
  114307. __param(1, opener_1.IOpenerService),
  114308. __param(2, modeService_1.IModeService),
  114309. __param(3, markersDecorationService_1.IMarkerDecorationsService),
  114310. __param(4, keybinding_1.IKeybindingService),
  114311. __param(5, themeService_1.IThemeService)
  114312. ], ModesHoverController);
  114313. return ModesHoverController;
  114314. }());
  114315. exports.ModesHoverController = ModesHoverController;
  114316. var ShowHoverAction = /** @class */ (function (_super) {
  114317. __extends(ShowHoverAction, _super);
  114318. function ShowHoverAction() {
  114319. return _super.call(this, {
  114320. id: 'editor.action.showHover',
  114321. label: nls.localize(0, null),
  114322. alias: 'Show Hover',
  114323. precondition: undefined,
  114324. kbOpts: {
  114325. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  114326. primary: keyCodes_1.KeyChord(2048 /* CtrlCmd */ | 41 /* KEY_K */, 2048 /* CtrlCmd */ | 39 /* KEY_I */),
  114327. weight: 100 /* EditorContrib */
  114328. }
  114329. }) || this;
  114330. }
  114331. ShowHoverAction.prototype.run = function (accessor, editor) {
  114332. if (!editor.hasModel()) {
  114333. return;
  114334. }
  114335. var controller = ModesHoverController.get(editor);
  114336. if (!controller) {
  114337. return;
  114338. }
  114339. var position = editor.getPosition();
  114340. var range = new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column);
  114341. var focus = editor.getOption(2 /* accessibilitySupport */) === 2 /* Enabled */;
  114342. controller.showContentHover(range, 1 /* Immediate */, focus);
  114343. };
  114344. return ShowHoverAction;
  114345. }(editorExtensions_1.EditorAction));
  114346. var ShowDefinitionPreviewHoverAction = /** @class */ (function (_super) {
  114347. __extends(ShowDefinitionPreviewHoverAction, _super);
  114348. function ShowDefinitionPreviewHoverAction() {
  114349. return _super.call(this, {
  114350. id: 'editor.action.showDefinitionPreviewHover',
  114351. label: nls.localize(1, null),
  114352. alias: 'Show Definition Preview Hover',
  114353. precondition: undefined
  114354. }) || this;
  114355. }
  114356. ShowDefinitionPreviewHoverAction.prototype.run = function (accessor, editor) {
  114357. var controller = ModesHoverController.get(editor);
  114358. if (!controller) {
  114359. return;
  114360. }
  114361. var position = editor.getPosition();
  114362. if (!position) {
  114363. return;
  114364. }
  114365. var range = new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column);
  114366. var goto = goToDefinitionAtPosition_1.GotoDefinitionAtPositionEditorContribution.get(editor);
  114367. var promise = goto.startFindDefinitionFromCursor(position);
  114368. if (promise) {
  114369. promise.then(function () {
  114370. controller.showContentHover(range, 1 /* Immediate */, true);
  114371. });
  114372. }
  114373. else {
  114374. controller.showContentHover(range, 1 /* Immediate */, true);
  114375. }
  114376. };
  114377. return ShowDefinitionPreviewHoverAction;
  114378. }(editorExtensions_1.EditorAction));
  114379. editorExtensions_1.registerEditorContribution(ModesHoverController.ID, ModesHoverController);
  114380. editorExtensions_1.registerEditorAction(ShowHoverAction);
  114381. editorExtensions_1.registerEditorAction(ShowDefinitionPreviewHoverAction);
  114382. // theming
  114383. themeService_1.registerThemingParticipant(function (theme, collector) {
  114384. var editorHoverHighlightColor = theme.getColor(colorRegistry_1.editorHoverHighlight);
  114385. if (editorHoverHighlightColor) {
  114386. collector.addRule(".monaco-editor .hoverHighlight { background-color: " + editorHoverHighlightColor + "; }");
  114387. }
  114388. var hoverBackground = theme.getColor(colorRegistry_1.editorHoverBackground);
  114389. if (hoverBackground) {
  114390. collector.addRule(".monaco-editor .monaco-editor-hover { background-color: " + hoverBackground + "; }");
  114391. }
  114392. var hoverBorder = theme.getColor(colorRegistry_1.editorHoverBorder);
  114393. if (hoverBorder) {
  114394. collector.addRule(".monaco-editor .monaco-editor-hover { border: 1px solid " + hoverBorder + "; }");
  114395. collector.addRule(".monaco-editor .monaco-editor-hover .hover-row:not(:first-child):not(:empty) { border-top: 1px solid " + hoverBorder.transparent(0.5) + "; }");
  114396. collector.addRule(".monaco-editor .monaco-editor-hover hr { border-top: 1px solid " + hoverBorder.transparent(0.5) + "; }");
  114397. collector.addRule(".monaco-editor .monaco-editor-hover hr { border-bottom: 0px solid " + hoverBorder.transparent(0.5) + "; }");
  114398. }
  114399. var link = theme.getColor(colorRegistry_1.textLinkForeground);
  114400. if (link) {
  114401. collector.addRule(".monaco-editor .monaco-editor-hover a { color: " + link + "; }");
  114402. }
  114403. var hoverForeground = theme.getColor(colorRegistry_1.editorHoverForeground);
  114404. if (hoverForeground) {
  114405. collector.addRule(".monaco-editor .monaco-editor-hover { color: " + hoverForeground + "; }");
  114406. }
  114407. var actionsBackground = theme.getColor(colorRegistry_1.editorHoverStatusBarBackground);
  114408. if (actionsBackground) {
  114409. collector.addRule(".monaco-editor .monaco-editor-hover .hover-row .actions { background-color: " + actionsBackground + "; }");
  114410. }
  114411. var codeBackground = theme.getColor(colorRegistry_1.textCodeBlockBackground);
  114412. if (codeBackground) {
  114413. collector.addRule(".monaco-editor .monaco-editor-hover code { background-color: " + codeBackground + "; }");
  114414. }
  114415. });
  114416. });
  114417. /*---------------------------------------------------------------------------------------------
  114418. * Copyright (c) Microsoft Corporation. All rights reserved.
  114419. * Licensed under the MIT License. See License.txt in the project root for license information.
  114420. *--------------------------------------------------------------------------------------------*/
  114421. define(__m[171/*vs/platform/workspace/common/workspace*/], __M([0/*require*/,1/*exports*/,25/*vs/base/common/uri*/,39/*vs/base/common/resources*/,11/*vs/platform/instantiation/common/instantiation*/,38/*vs/base/common/map*/]), function (require, exports, uri_1, resources, instantiation_1, map_1) {
  114422. "use strict";
  114423. Object.defineProperty(exports, "__esModule", { value: true });
  114424. exports.IWorkspaceContextService = instantiation_1.createDecorator('contextService');
  114425. var IWorkspace;
  114426. (function (IWorkspace) {
  114427. function isIWorkspace(thing) {
  114428. return thing && typeof thing === 'object'
  114429. && typeof thing.id === 'string'
  114430. && Array.isArray(thing.folders);
  114431. }
  114432. IWorkspace.isIWorkspace = isIWorkspace;
  114433. })(IWorkspace = exports.IWorkspace || (exports.IWorkspace = {}));
  114434. var IWorkspaceFolder;
  114435. (function (IWorkspaceFolder) {
  114436. function isIWorkspaceFolder(thing) {
  114437. return thing && typeof thing === 'object'
  114438. && uri_1.URI.isUri(thing.uri)
  114439. && typeof thing.name === 'string'
  114440. && typeof thing.toResource === 'function';
  114441. }
  114442. IWorkspaceFolder.isIWorkspaceFolder = isIWorkspaceFolder;
  114443. })(IWorkspaceFolder = exports.IWorkspaceFolder || (exports.IWorkspaceFolder = {}));
  114444. var Workspace = /** @class */ (function () {
  114445. function Workspace(_id, folders, _configuration) {
  114446. if (folders === void 0) { folders = []; }
  114447. if (_configuration === void 0) { _configuration = null; }
  114448. this._id = _id;
  114449. this._configuration = _configuration;
  114450. this._foldersMap = map_1.TernarySearchTree.forPaths();
  114451. this.folders = folders;
  114452. }
  114453. Object.defineProperty(Workspace.prototype, "folders", {
  114454. get: function () {
  114455. return this._folders;
  114456. },
  114457. set: function (folders) {
  114458. this._folders = folders;
  114459. this.updateFoldersMap();
  114460. },
  114461. enumerable: true,
  114462. configurable: true
  114463. });
  114464. Object.defineProperty(Workspace.prototype, "id", {
  114465. get: function () {
  114466. return this._id;
  114467. },
  114468. enumerable: true,
  114469. configurable: true
  114470. });
  114471. Object.defineProperty(Workspace.prototype, "configuration", {
  114472. get: function () {
  114473. return this._configuration;
  114474. },
  114475. set: function (configuration) {
  114476. this._configuration = configuration;
  114477. },
  114478. enumerable: true,
  114479. configurable: true
  114480. });
  114481. Workspace.prototype.getFolder = function (resource) {
  114482. if (!resource) {
  114483. return null;
  114484. }
  114485. return this._foldersMap.findSubstr(resource.with({
  114486. scheme: resource.scheme,
  114487. authority: resource.authority,
  114488. path: resource.path
  114489. }).toString()) || null;
  114490. };
  114491. Workspace.prototype.updateFoldersMap = function () {
  114492. this._foldersMap = map_1.TernarySearchTree.forPaths();
  114493. for (var _i = 0, _a = this.folders; _i < _a.length; _i++) {
  114494. var folder = _a[_i];
  114495. this._foldersMap.set(folder.uri.toString(), folder);
  114496. }
  114497. };
  114498. Workspace.prototype.toJSON = function () {
  114499. return { id: this.id, folders: this.folders, configuration: this.configuration };
  114500. };
  114501. return Workspace;
  114502. }());
  114503. exports.Workspace = Workspace;
  114504. var WorkspaceFolder = /** @class */ (function () {
  114505. function WorkspaceFolder(data, raw) {
  114506. this.raw = raw;
  114507. this.uri = data.uri;
  114508. this.index = data.index;
  114509. this.name = data.name;
  114510. }
  114511. WorkspaceFolder.prototype.toResource = function (relativePath) {
  114512. return resources.joinPath(this.uri, relativePath);
  114513. };
  114514. WorkspaceFolder.prototype.toJSON = function () {
  114515. return { uri: this.uri, name: this.name, index: this.index };
  114516. };
  114517. return WorkspaceFolder;
  114518. }());
  114519. exports.WorkspaceFolder = WorkspaceFolder;
  114520. });
  114521. /*---------------------------------------------------------------------------------------------
  114522. * Copyright (c) Microsoft Corporation. All rights reserved.
  114523. * Licensed under the MIT License. See License.txt in the project root for license information.
  114524. *--------------------------------------------------------------------------------------------*/
  114525. var __spreadArrays = (this && this.__spreadArrays) || function () {
  114526. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  114527. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  114528. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  114529. r[k] = a[j];
  114530. return r;
  114531. };
  114532. define(__m[172/*vs/editor/standalone/browser/simpleServices*/], __M([0/*require*/,1/*exports*/,5/*vs/base/common/strings*/,6/*vs/base/browser/dom*/,56/*vs/base/browser/keyboardEvent*/,4/*vs/base/common/event*/,36/*vs/base/common/keyCodes*/,2/*vs/base/common/lifecycle*/,16/*vs/base/common/platform*/,112/*vs/base/common/severity*/,25/*vs/base/common/uri*/,108/*vs/editor/browser/editorBrowser*/,163/*vs/editor/common/config/commonEditorConfig*/,58/*vs/editor/common/core/editOperation*/,13/*vs/editor/common/core/position*/,3/*vs/editor/common/core/range*/,17/*vs/editor/common/modes*/,29/*vs/platform/commands/common/commands*/,43/*vs/platform/configuration/common/configuration*/,518/*vs/platform/configuration/common/configurationModels*/,502/*vs/platform/keybinding/common/abstractKeybindingService*/,217/*vs/platform/keybinding/common/keybindingResolver*/,86/*vs/platform/keybinding/common/keybindingsRegistry*/,504/*vs/platform/keybinding/common/resolvedKeybindingItem*/,505/*vs/platform/keybinding/common/usLayoutResolvedKeybinding*/,35/*vs/platform/notification/common/notification*/,171/*vs/platform/workspace/common/workspace*/,59/*vs/editor/common/standaloneStrings*/]), function (require, exports, strings, dom, keyboardEvent_1, event_1, keyCodes_1, lifecycle_1, platform_1, severity_1, uri_1, editorBrowser_1, commonEditorConfig_1, editOperation_1, position_1, range_1, modes_1, commands_1, configuration_1, configurationModels_1, abstractKeybindingService_1, keybindingResolver_1, keybindingsRegistry_1, resolvedKeybindingItem_1, usLayoutResolvedKeybinding_1, notification_1, workspace_1, standaloneStrings_1) {
  114533. "use strict";
  114534. Object.defineProperty(exports, "__esModule", { value: true });
  114535. var SimpleModel = /** @class */ (function () {
  114536. function SimpleModel(model) {
  114537. this.model = model;
  114538. this._onDispose = new event_1.Emitter();
  114539. }
  114540. Object.defineProperty(SimpleModel.prototype, "textEditorModel", {
  114541. get: function () {
  114542. return this.model;
  114543. },
  114544. enumerable: true,
  114545. configurable: true
  114546. });
  114547. SimpleModel.prototype.dispose = function () {
  114548. this._onDispose.fire();
  114549. };
  114550. return SimpleModel;
  114551. }());
  114552. exports.SimpleModel = SimpleModel;
  114553. function withTypedEditor(widget, codeEditorCallback, diffEditorCallback) {
  114554. if (editorBrowser_1.isCodeEditor(widget)) {
  114555. // Single Editor
  114556. return codeEditorCallback(widget);
  114557. }
  114558. else {
  114559. // Diff Editor
  114560. return diffEditorCallback(widget);
  114561. }
  114562. }
  114563. var SimpleEditorModelResolverService = /** @class */ (function () {
  114564. function SimpleEditorModelResolverService(modelService) {
  114565. this.modelService = modelService;
  114566. }
  114567. SimpleEditorModelResolverService.prototype.setEditor = function (editor) {
  114568. this.editor = editor;
  114569. };
  114570. SimpleEditorModelResolverService.prototype.createModelReference = function (resource) {
  114571. var _this = this;
  114572. var model = null;
  114573. if (this.editor) {
  114574. model = withTypedEditor(this.editor, function (editor) { return _this.findModel(editor, resource); }, function (diffEditor) { return _this.findModel(diffEditor.getOriginalEditor(), resource) || _this.findModel(diffEditor.getModifiedEditor(), resource); });
  114575. }
  114576. if (!model) {
  114577. return Promise.reject(new Error("Model not found"));
  114578. }
  114579. return Promise.resolve(new lifecycle_1.ImmortalReference(new SimpleModel(model)));
  114580. };
  114581. SimpleEditorModelResolverService.prototype.findModel = function (editor, resource) {
  114582. var model = this.modelService ? this.modelService.getModel(resource) : editor.getModel();
  114583. if (model && model.uri.toString() !== resource.toString()) {
  114584. return null;
  114585. }
  114586. return model;
  114587. };
  114588. return SimpleEditorModelResolverService;
  114589. }());
  114590. exports.SimpleEditorModelResolverService = SimpleEditorModelResolverService;
  114591. var SimpleEditorProgressService = /** @class */ (function () {
  114592. function SimpleEditorProgressService() {
  114593. }
  114594. SimpleEditorProgressService.prototype.show = function () {
  114595. return SimpleEditorProgressService.NULL_PROGRESS_RUNNER;
  114596. };
  114597. SimpleEditorProgressService.prototype.showWhile = function (promise, delay) {
  114598. return Promise.resolve(undefined);
  114599. };
  114600. SimpleEditorProgressService.NULL_PROGRESS_RUNNER = {
  114601. done: function () { },
  114602. total: function () { },
  114603. worked: function () { }
  114604. };
  114605. return SimpleEditorProgressService;
  114606. }());
  114607. exports.SimpleEditorProgressService = SimpleEditorProgressService;
  114608. var SimpleDialogService = /** @class */ (function () {
  114609. function SimpleDialogService() {
  114610. }
  114611. return SimpleDialogService;
  114612. }());
  114613. exports.SimpleDialogService = SimpleDialogService;
  114614. var SimpleNotificationService = /** @class */ (function () {
  114615. function SimpleNotificationService() {
  114616. }
  114617. SimpleNotificationService.prototype.info = function (message) {
  114618. return this.notify({ severity: severity_1.default.Info, message: message });
  114619. };
  114620. SimpleNotificationService.prototype.warn = function (message) {
  114621. return this.notify({ severity: severity_1.default.Warning, message: message });
  114622. };
  114623. SimpleNotificationService.prototype.error = function (error) {
  114624. return this.notify({ severity: severity_1.default.Error, message: error });
  114625. };
  114626. SimpleNotificationService.prototype.notify = function (notification) {
  114627. switch (notification.severity) {
  114628. case severity_1.default.Error:
  114629. console.error(notification.message);
  114630. break;
  114631. case severity_1.default.Warning:
  114632. console.warn(notification.message);
  114633. break;
  114634. default:
  114635. console.log(notification.message);
  114636. break;
  114637. }
  114638. return SimpleNotificationService.NO_OP;
  114639. };
  114640. SimpleNotificationService.prototype.status = function (message, options) {
  114641. return lifecycle_1.Disposable.None;
  114642. };
  114643. SimpleNotificationService.NO_OP = new notification_1.NoOpNotification();
  114644. return SimpleNotificationService;
  114645. }());
  114646. exports.SimpleNotificationService = SimpleNotificationService;
  114647. var StandaloneCommandService = /** @class */ (function () {
  114648. function StandaloneCommandService(instantiationService) {
  114649. this._onWillExecuteCommand = new event_1.Emitter();
  114650. this._onDidExecuteCommand = new event_1.Emitter();
  114651. this._instantiationService = instantiationService;
  114652. this._dynamicCommands = Object.create(null);
  114653. }
  114654. StandaloneCommandService.prototype.addCommand = function (command) {
  114655. var _this = this;
  114656. var id = command.id;
  114657. this._dynamicCommands[id] = command;
  114658. return lifecycle_1.toDisposable(function () {
  114659. delete _this._dynamicCommands[id];
  114660. });
  114661. };
  114662. StandaloneCommandService.prototype.executeCommand = function (id) {
  114663. var args = [];
  114664. for (var _i = 1; _i < arguments.length; _i++) {
  114665. args[_i - 1] = arguments[_i];
  114666. }
  114667. var command = (commands_1.CommandsRegistry.getCommand(id) || this._dynamicCommands[id]);
  114668. if (!command) {
  114669. return Promise.reject(new Error("command '" + id + "' not found"));
  114670. }
  114671. try {
  114672. this._onWillExecuteCommand.fire({ commandId: id, args: args });
  114673. var result = this._instantiationService.invokeFunction.apply(this._instantiationService, __spreadArrays([command.handler], args));
  114674. this._onDidExecuteCommand.fire({ commandId: id, args: args });
  114675. return Promise.resolve(result);
  114676. }
  114677. catch (err) {
  114678. return Promise.reject(err);
  114679. }
  114680. };
  114681. return StandaloneCommandService;
  114682. }());
  114683. exports.StandaloneCommandService = StandaloneCommandService;
  114684. var StandaloneKeybindingService = /** @class */ (function (_super) {
  114685. __extends(StandaloneKeybindingService, _super);
  114686. function StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domNode) {
  114687. var _this = _super.call(this, contextKeyService, commandService, telemetryService, notificationService) || this;
  114688. _this._cachedResolver = null;
  114689. _this._dynamicKeybindings = [];
  114690. _this._register(dom.addDisposableListener(domNode, dom.EventType.KEY_DOWN, function (e) {
  114691. var keyEvent = new keyboardEvent_1.StandardKeyboardEvent(e);
  114692. var shouldPreventDefault = _this._dispatch(keyEvent, keyEvent.target);
  114693. if (shouldPreventDefault) {
  114694. keyEvent.preventDefault();
  114695. keyEvent.stopPropagation();
  114696. }
  114697. }));
  114698. return _this;
  114699. }
  114700. StandaloneKeybindingService.prototype.addDynamicKeybinding = function (commandId, _keybinding, handler, when) {
  114701. var _this = this;
  114702. var keybinding = keyCodes_1.createKeybinding(_keybinding, platform_1.OS);
  114703. var toDispose = new lifecycle_1.DisposableStore();
  114704. if (keybinding) {
  114705. this._dynamicKeybindings.push({
  114706. keybinding: keybinding,
  114707. command: commandId,
  114708. when: when,
  114709. weight1: 1000,
  114710. weight2: 0
  114711. });
  114712. toDispose.add(lifecycle_1.toDisposable(function () {
  114713. for (var i = 0; i < _this._dynamicKeybindings.length; i++) {
  114714. var kb = _this._dynamicKeybindings[i];
  114715. if (kb.command === commandId) {
  114716. _this._dynamicKeybindings.splice(i, 1);
  114717. _this.updateResolver({ source: 1 /* Default */ });
  114718. return;
  114719. }
  114720. }
  114721. }));
  114722. }
  114723. var commandService = this._commandService;
  114724. if (commandService instanceof StandaloneCommandService) {
  114725. toDispose.add(commandService.addCommand({
  114726. id: commandId,
  114727. handler: handler
  114728. }));
  114729. }
  114730. else {
  114731. throw new Error('Unknown command service!');
  114732. }
  114733. this.updateResolver({ source: 1 /* Default */ });
  114734. return toDispose;
  114735. };
  114736. StandaloneKeybindingService.prototype.updateResolver = function (event) {
  114737. this._cachedResolver = null;
  114738. this._onDidUpdateKeybindings.fire(event);
  114739. };
  114740. StandaloneKeybindingService.prototype._getResolver = function () {
  114741. if (!this._cachedResolver) {
  114742. var defaults = this._toNormalizedKeybindingItems(keybindingsRegistry_1.KeybindingsRegistry.getDefaultKeybindings(), true);
  114743. var overrides = this._toNormalizedKeybindingItems(this._dynamicKeybindings, false);
  114744. this._cachedResolver = new keybindingResolver_1.KeybindingResolver(defaults, overrides);
  114745. }
  114746. return this._cachedResolver;
  114747. };
  114748. StandaloneKeybindingService.prototype._documentHasFocus = function () {
  114749. return document.hasFocus();
  114750. };
  114751. StandaloneKeybindingService.prototype._toNormalizedKeybindingItems = function (items, isDefault) {
  114752. var result = [], resultLen = 0;
  114753. for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
  114754. var item = items_1[_i];
  114755. var when = item.when || undefined;
  114756. var keybinding = item.keybinding;
  114757. if (!keybinding) {
  114758. // This might be a removal keybinding item in user settings => accept it
  114759. result[resultLen++] = new resolvedKeybindingItem_1.ResolvedKeybindingItem(undefined, item.command, item.commandArgs, when, isDefault);
  114760. }
  114761. else {
  114762. var resolvedKeybindings = this.resolveKeybinding(keybinding);
  114763. for (var _a = 0, resolvedKeybindings_1 = resolvedKeybindings; _a < resolvedKeybindings_1.length; _a++) {
  114764. var resolvedKeybinding = resolvedKeybindings_1[_a];
  114765. result[resultLen++] = new resolvedKeybindingItem_1.ResolvedKeybindingItem(resolvedKeybinding, item.command, item.commandArgs, when, isDefault);
  114766. }
  114767. }
  114768. }
  114769. return result;
  114770. };
  114771. StandaloneKeybindingService.prototype.resolveKeybinding = function (keybinding) {
  114772. return [new usLayoutResolvedKeybinding_1.USLayoutResolvedKeybinding(keybinding, platform_1.OS)];
  114773. };
  114774. StandaloneKeybindingService.prototype.resolveKeyboardEvent = function (keyboardEvent) {
  114775. var keybinding = new keyCodes_1.SimpleKeybinding(keyboardEvent.ctrlKey, keyboardEvent.shiftKey, keyboardEvent.altKey, keyboardEvent.metaKey, keyboardEvent.keyCode).toChord();
  114776. return new usLayoutResolvedKeybinding_1.USLayoutResolvedKeybinding(keybinding, platform_1.OS);
  114777. };
  114778. return StandaloneKeybindingService;
  114779. }(abstractKeybindingService_1.AbstractKeybindingService));
  114780. exports.StandaloneKeybindingService = StandaloneKeybindingService;
  114781. function isConfigurationOverrides(thing) {
  114782. return thing
  114783. && typeof thing === 'object'
  114784. && (!thing.overrideIdentifier || typeof thing.overrideIdentifier === 'string')
  114785. && (!thing.resource || thing.resource instanceof uri_1.URI);
  114786. }
  114787. var SimpleConfigurationService = /** @class */ (function () {
  114788. function SimpleConfigurationService() {
  114789. this._onDidChangeConfiguration = new event_1.Emitter();
  114790. this.onDidChangeConfiguration = this._onDidChangeConfiguration.event;
  114791. this._configuration = new configurationModels_1.Configuration(new configurationModels_1.DefaultConfigurationModel(), new configurationModels_1.ConfigurationModel());
  114792. }
  114793. SimpleConfigurationService.prototype.configuration = function () {
  114794. return this._configuration;
  114795. };
  114796. SimpleConfigurationService.prototype.getValue = function (arg1, arg2) {
  114797. var section = typeof arg1 === 'string' ? arg1 : undefined;
  114798. var overrides = isConfigurationOverrides(arg1) ? arg1 : isConfigurationOverrides(arg2) ? arg2 : {};
  114799. return this.configuration().getValue(section, overrides, undefined);
  114800. };
  114801. SimpleConfigurationService.prototype.updateValue = function (key, value, arg3, arg4) {
  114802. this.configuration().updateValue(key, value);
  114803. return Promise.resolve();
  114804. };
  114805. SimpleConfigurationService.prototype.inspect = function (key, options) {
  114806. if (options === void 0) { options = {}; }
  114807. return this.configuration().inspect(key, options, undefined);
  114808. };
  114809. return SimpleConfigurationService;
  114810. }());
  114811. exports.SimpleConfigurationService = SimpleConfigurationService;
  114812. var SimpleResourceConfigurationService = /** @class */ (function () {
  114813. function SimpleResourceConfigurationService(configurationService) {
  114814. var _this = this;
  114815. this.configurationService = configurationService;
  114816. this._onDidChangeConfiguration = new event_1.Emitter();
  114817. this.configurationService.onDidChangeConfiguration(function (e) {
  114818. _this._onDidChangeConfiguration.fire({ affectedKeys: e.affectedKeys, affectsConfiguration: function (resource, configuration) { return e.affectsConfiguration(configuration); } });
  114819. });
  114820. }
  114821. SimpleResourceConfigurationService.prototype.getValue = function (resource, arg2, arg3) {
  114822. var position = position_1.Position.isIPosition(arg2) ? arg2 : null;
  114823. var section = position ? (typeof arg3 === 'string' ? arg3 : undefined) : (typeof arg2 === 'string' ? arg2 : undefined);
  114824. if (typeof section === 'undefined') {
  114825. return this.configurationService.getValue();
  114826. }
  114827. return this.configurationService.getValue(section);
  114828. };
  114829. return SimpleResourceConfigurationService;
  114830. }());
  114831. exports.SimpleResourceConfigurationService = SimpleResourceConfigurationService;
  114832. var SimpleResourcePropertiesService = /** @class */ (function () {
  114833. function SimpleResourcePropertiesService(configurationService) {
  114834. this.configurationService = configurationService;
  114835. }
  114836. SimpleResourcePropertiesService.prototype.getEOL = function (resource, language) {
  114837. var eol = this.configurationService.getValue('files.eol', { overrideIdentifier: language, resource: resource });
  114838. if (eol && eol !== 'auto') {
  114839. return eol;
  114840. }
  114841. return (platform_1.isLinux || platform_1.isMacintosh) ? '\n' : '\r\n';
  114842. };
  114843. SimpleResourcePropertiesService = __decorate([
  114844. __param(0, configuration_1.IConfigurationService)
  114845. ], SimpleResourcePropertiesService);
  114846. return SimpleResourcePropertiesService;
  114847. }());
  114848. exports.SimpleResourcePropertiesService = SimpleResourcePropertiesService;
  114849. var StandaloneTelemetryService = /** @class */ (function () {
  114850. function StandaloneTelemetryService() {
  114851. }
  114852. StandaloneTelemetryService.prototype.publicLog = function (eventName, data) {
  114853. return Promise.resolve(undefined);
  114854. };
  114855. StandaloneTelemetryService.prototype.publicLog2 = function (eventName, data) {
  114856. return this.publicLog(eventName, data);
  114857. };
  114858. return StandaloneTelemetryService;
  114859. }());
  114860. exports.StandaloneTelemetryService = StandaloneTelemetryService;
  114861. var SimpleWorkspaceContextService = /** @class */ (function () {
  114862. function SimpleWorkspaceContextService() {
  114863. var resource = uri_1.URI.from({ scheme: SimpleWorkspaceContextService.SCHEME, authority: 'model', path: '/' });
  114864. this.workspace = { id: '4064f6ec-cb38-4ad0-af64-ee6467e63c82', folders: [new workspace_1.WorkspaceFolder({ uri: resource, name: '', index: 0 })] };
  114865. }
  114866. SimpleWorkspaceContextService.prototype.getWorkspace = function () {
  114867. return this.workspace;
  114868. };
  114869. SimpleWorkspaceContextService.prototype.getWorkspaceFolder = function (resource) {
  114870. return resource && resource.scheme === SimpleWorkspaceContextService.SCHEME ? this.workspace.folders[0] : null;
  114871. };
  114872. SimpleWorkspaceContextService.SCHEME = 'inmemory';
  114873. return SimpleWorkspaceContextService;
  114874. }());
  114875. exports.SimpleWorkspaceContextService = SimpleWorkspaceContextService;
  114876. function applyConfigurationValues(configurationService, source, isDiffEditor) {
  114877. if (!source) {
  114878. return;
  114879. }
  114880. if (!(configurationService instanceof SimpleConfigurationService)) {
  114881. return;
  114882. }
  114883. Object.keys(source).forEach(function (key) {
  114884. if (commonEditorConfig_1.isEditorConfigurationKey(key)) {
  114885. configurationService.updateValue("editor." + key, source[key]);
  114886. }
  114887. if (isDiffEditor && commonEditorConfig_1.isDiffEditorConfigurationKey(key)) {
  114888. configurationService.updateValue("diffEditor." + key, source[key]);
  114889. }
  114890. });
  114891. }
  114892. exports.applyConfigurationValues = applyConfigurationValues;
  114893. var SimpleBulkEditService = /** @class */ (function () {
  114894. function SimpleBulkEditService(_modelService) {
  114895. this._modelService = _modelService;
  114896. //
  114897. }
  114898. SimpleBulkEditService.prototype.hasPreviewHandler = function () {
  114899. return false;
  114900. };
  114901. SimpleBulkEditService.prototype.apply = function (workspaceEdit, options) {
  114902. var edits = new Map();
  114903. if (workspaceEdit.edits) {
  114904. for (var _i = 0, _a = workspaceEdit.edits; _i < _a.length; _i++) {
  114905. var edit = _a[_i];
  114906. if (!modes_1.WorkspaceTextEdit.is(edit)) {
  114907. return Promise.reject(new Error('bad edit - only text edits are supported'));
  114908. }
  114909. var model = this._modelService.getModel(edit.resource);
  114910. if (!model) {
  114911. return Promise.reject(new Error('bad edit - model not found'));
  114912. }
  114913. var array = edits.get(model);
  114914. if (!array) {
  114915. array = [];
  114916. edits.set(model, array);
  114917. }
  114918. array.push(edit.edit);
  114919. }
  114920. }
  114921. var totalEdits = 0;
  114922. var totalFiles = 0;
  114923. edits.forEach(function (edits, model) {
  114924. model.pushStackElement();
  114925. model.pushEditOperations([], edits.map(function (e) { return editOperation_1.EditOperation.replaceMove(range_1.Range.lift(e.range), e.text); }), function () { return []; });
  114926. model.pushStackElement();
  114927. totalFiles += 1;
  114928. totalEdits += edits.length;
  114929. });
  114930. return Promise.resolve({
  114931. selection: undefined,
  114932. ariaSummary: strings.format(standaloneStrings_1.SimpleServicesNLS.bulkEditServiceSummary, totalEdits, totalFiles)
  114933. });
  114934. };
  114935. return SimpleBulkEditService;
  114936. }());
  114937. exports.SimpleBulkEditService = SimpleBulkEditService;
  114938. var SimpleUriLabelService = /** @class */ (function () {
  114939. function SimpleUriLabelService() {
  114940. }
  114941. SimpleUriLabelService.prototype.getUriLabel = function (resource, options) {
  114942. if (resource.scheme === 'file') {
  114943. return resource.fsPath;
  114944. }
  114945. return resource.path;
  114946. };
  114947. return SimpleUriLabelService;
  114948. }());
  114949. exports.SimpleUriLabelService = SimpleUriLabelService;
  114950. var SimpleLayoutService = /** @class */ (function () {
  114951. function SimpleLayoutService(_container) {
  114952. this._container = _container;
  114953. this.onLayout = event_1.Event.None;
  114954. }
  114955. Object.defineProperty(SimpleLayoutService.prototype, "container", {
  114956. get: function () {
  114957. return this._container;
  114958. },
  114959. enumerable: true,
  114960. configurable: true
  114961. });
  114962. return SimpleLayoutService;
  114963. }());
  114964. exports.SimpleLayoutService = SimpleLayoutService;
  114965. });
  114966. /*---------------------------------------------------------------------------------------------
  114967. * Copyright (c) Microsoft Corporation. All rights reserved.
  114968. * Licensed under the MIT License. See License.txt in the project root for license information.
  114969. *--------------------------------------------------------------------------------------------*/
  114970. var __spreadArrays = (this && this.__spreadArrays) || function () {
  114971. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  114972. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  114973. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  114974. r[k] = a[j];
  114975. return r;
  114976. };
  114977. define(__m[602/*vs/editor/standalone/browser/standaloneCodeEditor*/], __M([0/*require*/,1/*exports*/,24/*vs/base/browser/browser*/,50/*vs/base/browser/ui/aria/aria*/,2/*vs/base/common/lifecycle*/,32/*vs/editor/browser/services/codeEditorService*/,121/*vs/editor/browser/widget/codeEditorWidget*/,230/*vs/editor/browser/widget/diffEditorWidget*/,190/*vs/editor/common/editorAction*/,62/*vs/editor/common/services/editorWorkerService*/,172/*vs/editor/standalone/browser/simpleServices*/,94/*vs/editor/standalone/common/standaloneThemeService*/,65/*vs/platform/actions/common/actions*/,29/*vs/platform/commands/common/commands*/,43/*vs/platform/configuration/common/configuration*/,18/*vs/platform/contextkey/common/contextkey*/,66/*vs/platform/contextview/browser/contextView*/,11/*vs/platform/instantiation/common/instantiation*/,34/*vs/platform/keybinding/common/keybinding*/,35/*vs/platform/notification/common/notification*/,14/*vs/platform/theme/common/themeService*/,64/*vs/platform/accessibility/common/accessibility*/,59/*vs/editor/common/standaloneStrings*/,162/*vs/platform/clipboard/common/clipboardService*/,73/*vs/platform/progress/common/progress*/]), function (require, exports, browser, aria, lifecycle_1, codeEditorService_1, codeEditorWidget_1, diffEditorWidget_1, editorAction_1, editorWorkerService_1, simpleServices_1, standaloneThemeService_1, actions_1, commands_1, configuration_1, contextkey_1, contextView_1, instantiation_1, keybinding_1, notification_1, themeService_1, accessibility_1, standaloneStrings_1, clipboardService_1, progress_1) {
  114978. "use strict";
  114979. Object.defineProperty(exports, "__esModule", { value: true });
  114980. var LAST_GENERATED_COMMAND_ID = 0;
  114981. var ariaDomNodeCreated = false;
  114982. function createAriaDomNode() {
  114983. if (ariaDomNodeCreated) {
  114984. return;
  114985. }
  114986. ariaDomNodeCreated = true;
  114987. aria.setARIAContainer(document.body);
  114988. }
  114989. /**
  114990. * A code editor to be used both by the standalone editor and the standalone diff editor.
  114991. */
  114992. var StandaloneCodeEditor = /** @class */ (function (_super) {
  114993. __extends(StandaloneCodeEditor, _super);
  114994. function StandaloneCodeEditor(domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, themeService, notificationService, accessibilityService) {
  114995. var _this = this;
  114996. options = options || {};
  114997. options.ariaLabel = options.ariaLabel || standaloneStrings_1.StandaloneCodeEditorNLS.editorViewAccessibleLabel;
  114998. options.ariaLabel = options.ariaLabel + ';' + (browser.isIE
  114999. ? standaloneStrings_1.StandaloneCodeEditorNLS.accessibilityHelpMessageIE
  115000. : standaloneStrings_1.StandaloneCodeEditorNLS.accessibilityHelpMessage);
  115001. _this = _super.call(this, domElement, options, {}, instantiationService, codeEditorService, commandService, contextKeyService, themeService, notificationService, accessibilityService) || this;
  115002. if (keybindingService instanceof simpleServices_1.StandaloneKeybindingService) {
  115003. _this._standaloneKeybindingService = keybindingService;
  115004. }
  115005. else {
  115006. _this._standaloneKeybindingService = null;
  115007. }
  115008. // Create the ARIA dom node as soon as the first editor is instantiated
  115009. createAriaDomNode();
  115010. return _this;
  115011. }
  115012. StandaloneCodeEditor.prototype.addCommand = function (keybinding, handler, context) {
  115013. if (!this._standaloneKeybindingService) {
  115014. console.warn('Cannot add command because the editor is configured with an unrecognized KeybindingService');
  115015. return null;
  115016. }
  115017. var commandId = 'DYNAMIC_' + (++LAST_GENERATED_COMMAND_ID);
  115018. var whenExpression = contextkey_1.ContextKeyExpr.deserialize(context);
  115019. this._standaloneKeybindingService.addDynamicKeybinding(commandId, keybinding, handler, whenExpression);
  115020. return commandId;
  115021. };
  115022. StandaloneCodeEditor.prototype.createContextKey = function (key, defaultValue) {
  115023. return this._contextKeyService.createKey(key, defaultValue);
  115024. };
  115025. StandaloneCodeEditor.prototype.addAction = function (_descriptor) {
  115026. var _this = this;
  115027. if ((typeof _descriptor.id !== 'string') || (typeof _descriptor.label !== 'string') || (typeof _descriptor.run !== 'function')) {
  115028. throw new Error('Invalid action descriptor, `id`, `label` and `run` are required properties!');
  115029. }
  115030. if (!this._standaloneKeybindingService) {
  115031. console.warn('Cannot add keybinding because the editor is configured with an unrecognized KeybindingService');
  115032. return lifecycle_1.Disposable.None;
  115033. }
  115034. // Read descriptor options
  115035. var id = _descriptor.id;
  115036. var label = _descriptor.label;
  115037. var precondition = contextkey_1.ContextKeyExpr.and(contextkey_1.ContextKeyExpr.equals('editorId', this.getId()), contextkey_1.ContextKeyExpr.deserialize(_descriptor.precondition));
  115038. var keybindings = _descriptor.keybindings;
  115039. var keybindingsWhen = contextkey_1.ContextKeyExpr.and(precondition, contextkey_1.ContextKeyExpr.deserialize(_descriptor.keybindingContext));
  115040. var contextMenuGroupId = _descriptor.contextMenuGroupId || null;
  115041. var contextMenuOrder = _descriptor.contextMenuOrder || 0;
  115042. var run = function (accessor) {
  115043. var args = [];
  115044. for (var _i = 1; _i < arguments.length; _i++) {
  115045. args[_i - 1] = arguments[_i];
  115046. }
  115047. return Promise.resolve(_descriptor.run.apply(_descriptor, __spreadArrays([_this], args)));
  115048. };
  115049. var toDispose = new lifecycle_1.DisposableStore();
  115050. // Generate a unique id to allow the same descriptor.id across multiple editor instances
  115051. var uniqueId = this.getId() + ':' + id;
  115052. // Register the command
  115053. toDispose.add(commands_1.CommandsRegistry.registerCommand(uniqueId, run));
  115054. // Register the context menu item
  115055. if (contextMenuGroupId) {
  115056. var menuItem = {
  115057. command: {
  115058. id: uniqueId,
  115059. title: label
  115060. },
  115061. when: precondition,
  115062. group: contextMenuGroupId,
  115063. order: contextMenuOrder
  115064. };
  115065. toDispose.add(actions_1.MenuRegistry.appendMenuItem(7 /* EditorContext */, menuItem));
  115066. }
  115067. // Register the keybindings
  115068. if (Array.isArray(keybindings)) {
  115069. for (var _i = 0, keybindings_1 = keybindings; _i < keybindings_1.length; _i++) {
  115070. var kb = keybindings_1[_i];
  115071. toDispose.add(this._standaloneKeybindingService.addDynamicKeybinding(uniqueId, kb, run, keybindingsWhen));
  115072. }
  115073. }
  115074. // Finally, register an internal editor action
  115075. var internalAction = new editorAction_1.InternalEditorAction(uniqueId, label, label, precondition, run, this._contextKeyService);
  115076. // Store it under the original id, such that trigger with the original id will work
  115077. this._actions[id] = internalAction;
  115078. toDispose.add(lifecycle_1.toDisposable(function () {
  115079. delete _this._actions[id];
  115080. }));
  115081. return toDispose;
  115082. };
  115083. StandaloneCodeEditor = __decorate([
  115084. __param(2, instantiation_1.IInstantiationService),
  115085. __param(3, codeEditorService_1.ICodeEditorService),
  115086. __param(4, commands_1.ICommandService),
  115087. __param(5, contextkey_1.IContextKeyService),
  115088. __param(6, keybinding_1.IKeybindingService),
  115089. __param(7, themeService_1.IThemeService),
  115090. __param(8, notification_1.INotificationService),
  115091. __param(9, accessibility_1.IAccessibilityService)
  115092. ], StandaloneCodeEditor);
  115093. return StandaloneCodeEditor;
  115094. }(codeEditorWidget_1.CodeEditorWidget));
  115095. exports.StandaloneCodeEditor = StandaloneCodeEditor;
  115096. var StandaloneEditor = /** @class */ (function (_super) {
  115097. __extends(StandaloneEditor, _super);
  115098. function StandaloneEditor(domElement, options, toDispose, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, contextViewService, themeService, notificationService, configurationService, accessibilityService) {
  115099. var _this = this;
  115100. simpleServices_1.applyConfigurationValues(configurationService, options, false);
  115101. var themeDomRegistration = themeService.registerEditorContainer(domElement);
  115102. options = options || {};
  115103. if (typeof options.theme === 'string') {
  115104. themeService.setTheme(options.theme);
  115105. }
  115106. var _model = options.model;
  115107. delete options.model;
  115108. _this = _super.call(this, domElement, options, instantiationService, codeEditorService, commandService, contextKeyService, keybindingService, themeService, notificationService, accessibilityService) || this;
  115109. _this._contextViewService = contextViewService;
  115110. _this._configurationService = configurationService;
  115111. _this._register(toDispose);
  115112. _this._register(themeDomRegistration);
  115113. var model;
  115114. if (typeof _model === 'undefined') {
  115115. model = self.monaco.editor.createModel(options.value || '', options.language || 'text/plain');
  115116. _this._ownsModel = true;
  115117. }
  115118. else {
  115119. model = _model;
  115120. _this._ownsModel = false;
  115121. }
  115122. _this._attachModel(model);
  115123. if (model) {
  115124. var e = {
  115125. oldModelUrl: null,
  115126. newModelUrl: model.uri
  115127. };
  115128. _this._onDidChangeModel.fire(e);
  115129. }
  115130. return _this;
  115131. }
  115132. StandaloneEditor.prototype.dispose = function () {
  115133. _super.prototype.dispose.call(this);
  115134. };
  115135. StandaloneEditor.prototype.updateOptions = function (newOptions) {
  115136. simpleServices_1.applyConfigurationValues(this._configurationService, newOptions, false);
  115137. _super.prototype.updateOptions.call(this, newOptions);
  115138. };
  115139. StandaloneEditor.prototype._attachModel = function (model) {
  115140. _super.prototype._attachModel.call(this, model);
  115141. if (this._modelData) {
  115142. this._contextViewService.setContainer(this._modelData.view.domNode.domNode);
  115143. }
  115144. };
  115145. StandaloneEditor.prototype._postDetachModelCleanup = function (detachedModel) {
  115146. _super.prototype._postDetachModelCleanup.call(this, detachedModel);
  115147. if (detachedModel && this._ownsModel) {
  115148. detachedModel.dispose();
  115149. this._ownsModel = false;
  115150. }
  115151. };
  115152. StandaloneEditor = __decorate([
  115153. __param(3, instantiation_1.IInstantiationService),
  115154. __param(4, codeEditorService_1.ICodeEditorService),
  115155. __param(5, commands_1.ICommandService),
  115156. __param(6, contextkey_1.IContextKeyService),
  115157. __param(7, keybinding_1.IKeybindingService),
  115158. __param(8, contextView_1.IContextViewService),
  115159. __param(9, standaloneThemeService_1.IStandaloneThemeService),
  115160. __param(10, notification_1.INotificationService),
  115161. __param(11, configuration_1.IConfigurationService),
  115162. __param(12, accessibility_1.IAccessibilityService)
  115163. ], StandaloneEditor);
  115164. return StandaloneEditor;
  115165. }(StandaloneCodeEditor));
  115166. exports.StandaloneEditor = StandaloneEditor;
  115167. var StandaloneDiffEditor = /** @class */ (function (_super) {
  115168. __extends(StandaloneDiffEditor, _super);
  115169. function StandaloneDiffEditor(domElement, options, toDispose, instantiationService, contextKeyService, keybindingService, contextViewService, editorWorkerService, codeEditorService, themeService, notificationService, configurationService, contextMenuService, editorProgressService, clipboardService) {
  115170. var _this = this;
  115171. simpleServices_1.applyConfigurationValues(configurationService, options, true);
  115172. var themeDomRegistration = themeService.registerEditorContainer(domElement);
  115173. options = options || {};
  115174. if (typeof options.theme === 'string') {
  115175. options.theme = themeService.setTheme(options.theme);
  115176. }
  115177. _this = _super.call(this, domElement, options, clipboardService, editorWorkerService, contextKeyService, instantiationService, codeEditorService, themeService, notificationService, contextMenuService, editorProgressService) || this;
  115178. _this._contextViewService = contextViewService;
  115179. _this._configurationService = configurationService;
  115180. _this._register(toDispose);
  115181. _this._register(themeDomRegistration);
  115182. _this._contextViewService.setContainer(_this._containerDomElement);
  115183. return _this;
  115184. }
  115185. StandaloneDiffEditor.prototype.dispose = function () {
  115186. _super.prototype.dispose.call(this);
  115187. };
  115188. StandaloneDiffEditor.prototype.updateOptions = function (newOptions) {
  115189. simpleServices_1.applyConfigurationValues(this._configurationService, newOptions, true);
  115190. _super.prototype.updateOptions.call(this, newOptions);
  115191. };
  115192. StandaloneDiffEditor.prototype._createInnerEditor = function (instantiationService, container, options) {
  115193. return instantiationService.createInstance(StandaloneCodeEditor, container, options);
  115194. };
  115195. StandaloneDiffEditor.prototype.getOriginalEditor = function () {
  115196. return _super.prototype.getOriginalEditor.call(this);
  115197. };
  115198. StandaloneDiffEditor.prototype.getModifiedEditor = function () {
  115199. return _super.prototype.getModifiedEditor.call(this);
  115200. };
  115201. StandaloneDiffEditor.prototype.addCommand = function (keybinding, handler, context) {
  115202. return this.getModifiedEditor().addCommand(keybinding, handler, context);
  115203. };
  115204. StandaloneDiffEditor.prototype.createContextKey = function (key, defaultValue) {
  115205. return this.getModifiedEditor().createContextKey(key, defaultValue);
  115206. };
  115207. StandaloneDiffEditor.prototype.addAction = function (descriptor) {
  115208. return this.getModifiedEditor().addAction(descriptor);
  115209. };
  115210. StandaloneDiffEditor = __decorate([
  115211. __param(3, instantiation_1.IInstantiationService),
  115212. __param(4, contextkey_1.IContextKeyService),
  115213. __param(5, keybinding_1.IKeybindingService),
  115214. __param(6, contextView_1.IContextViewService),
  115215. __param(7, editorWorkerService_1.IEditorWorkerService),
  115216. __param(8, codeEditorService_1.ICodeEditorService),
  115217. __param(9, standaloneThemeService_1.IStandaloneThemeService),
  115218. __param(10, notification_1.INotificationService),
  115219. __param(11, configuration_1.IConfigurationService),
  115220. __param(12, contextView_1.IContextMenuService),
  115221. __param(13, progress_1.IEditorProgressService),
  115222. __param(14, instantiation_1.optional(clipboardService_1.IClipboardService))
  115223. ], StandaloneDiffEditor);
  115224. return StandaloneDiffEditor;
  115225. }(diffEditorWidget_1.DiffEditorWidget));
  115226. exports.StandaloneDiffEditor = StandaloneDiffEditor;
  115227. });
  115228. /*---------------------------------------------------------------------------------------------
  115229. * Copyright (c) Microsoft Corporation. All rights reserved.
  115230. * Licensed under the MIT License. See License.txt in the project root for license information.
  115231. *--------------------------------------------------------------------------------------------*/
  115232. define(__m[238/*vs/editor/standalone/browser/standaloneServices*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,156/*vs/editor/browser/services/bulkEditService*/,32/*vs/editor/browser/services/codeEditorService*/,62/*vs/editor/common/services/editorWorkerService*/,219/*vs/editor/common/services/editorWorkerServiceImpl*/,71/*vs/editor/common/services/modeService*/,516/*vs/editor/common/services/modeServiceImpl*/,49/*vs/editor/common/services/modelService*/,556/*vs/editor/common/services/modelServiceImpl*/,114/*vs/editor/common/services/textResourceConfigurationService*/,172/*vs/editor/standalone/browser/simpleServices*/,592/*vs/editor/standalone/browser/standaloneCodeServiceImpl*/,594/*vs/editor/standalone/browser/standaloneThemeServiceImpl*/,94/*vs/editor/standalone/common/standaloneThemeService*/,65/*vs/platform/actions/common/actions*/,29/*vs/platform/commands/common/commands*/,43/*vs/platform/configuration/common/configuration*/,519/*vs/platform/contextkey/browser/contextKeyService*/,18/*vs/platform/contextkey/common/contextkey*/,595/*vs/platform/contextview/browser/contextMenuService*/,66/*vs/platform/contextview/browser/contextView*/,506/*vs/platform/contextview/browser/contextViewService*/,500/*vs/platform/dialogs/common/dialogs*/,11/*vs/platform/instantiation/common/instantiation*/,501/*vs/platform/instantiation/common/instantiationService*/,115/*vs/platform/instantiation/common/serviceCollection*/,34/*vs/platform/keybinding/common/keybinding*/,116/*vs/platform/label/common/label*/,170/*vs/platform/list/browser/listService*/,95/*vs/platform/log/common/log*/,508/*vs/platform/markers/common/markerService*/,72/*vs/platform/markers/common/markers*/,35/*vs/platform/notification/common/notification*/,73/*vs/platform/progress/common/progress*/,74/*vs/platform/storage/common/storage*/,96/*vs/platform/telemetry/common/telemetry*/,14/*vs/platform/theme/common/themeService*/,171/*vs/platform/workspace/common/workspace*/,499/*vs/platform/actions/common/menuService*/,210/*vs/editor/common/services/markersDecorationService*/,565/*vs/editor/common/services/markerDecorationsServiceImpl*/,64/*vs/platform/accessibility/common/accessibility*/,218/*vs/platform/layout/browser/layoutService*/,83/*vs/platform/instantiation/common/extensions*/,517/*vs/platform/accessibility/common/accessibilityService*/]), function (require, exports, lifecycle_1, bulkEditService_1, codeEditorService_1, editorWorkerService_1, editorWorkerServiceImpl_1, modeService_1, modeServiceImpl_1, modelService_1, modelServiceImpl_1, textResourceConfigurationService_1, simpleServices_1, standaloneCodeServiceImpl_1, standaloneThemeServiceImpl_1, standaloneThemeService_1, actions_1, commands_1, configuration_1, contextKeyService_1, contextkey_1, contextMenuService_1, contextView_1, contextViewService_1, dialogs_1, instantiation_1, instantiationService_1, serviceCollection_1, keybinding_1, label_1, listService_1, log_1, markerService_1, markers_1, notification_1, progress_1, storage_1, telemetry_1, themeService_1, workspace_1, menuService_1, markersDecorationService_1, markerDecorationsServiceImpl_1, accessibility_1, layoutService_1, extensions_1, accessibilityService_1) {
  115233. "use strict";
  115234. Object.defineProperty(exports, "__esModule", { value: true });
  115235. var StaticServices;
  115236. (function (StaticServices) {
  115237. var _serviceCollection = new serviceCollection_1.ServiceCollection();
  115238. var LazyStaticService = /** @class */ (function () {
  115239. function LazyStaticService(serviceId, factory) {
  115240. this._serviceId = serviceId;
  115241. this._factory = factory;
  115242. this._value = null;
  115243. }
  115244. Object.defineProperty(LazyStaticService.prototype, "id", {
  115245. get: function () { return this._serviceId; },
  115246. enumerable: true,
  115247. configurable: true
  115248. });
  115249. LazyStaticService.prototype.get = function (overrides) {
  115250. if (!this._value) {
  115251. if (overrides) {
  115252. this._value = overrides[this._serviceId.toString()];
  115253. }
  115254. if (!this._value) {
  115255. this._value = this._factory(overrides);
  115256. }
  115257. if (!this._value) {
  115258. throw new Error('Service ' + this._serviceId + ' is missing!');
  115259. }
  115260. _serviceCollection.set(this._serviceId, this._value);
  115261. }
  115262. return this._value;
  115263. };
  115264. return LazyStaticService;
  115265. }());
  115266. StaticServices.LazyStaticService = LazyStaticService;
  115267. var _all = [];
  115268. function define(serviceId, factory) {
  115269. var r = new LazyStaticService(serviceId, factory);
  115270. _all.push(r);
  115271. return r;
  115272. }
  115273. function init(overrides) {
  115274. // Create a fresh service collection
  115275. var result = new serviceCollection_1.ServiceCollection();
  115276. // make sure to add all services that use `registerSingleton`
  115277. for (var _i = 0, _a = extensions_1.getSingletonServiceDescriptors(); _i < _a.length; _i++) {
  115278. var _b = _a[_i], id = _b[0], descriptor = _b[1];
  115279. result.set(id, descriptor);
  115280. }
  115281. // Initialize the service collection with the overrides
  115282. for (var serviceId in overrides) {
  115283. if (overrides.hasOwnProperty(serviceId)) {
  115284. result.set(instantiation_1.createDecorator(serviceId), overrides[serviceId]);
  115285. }
  115286. }
  115287. // Make sure the same static services are present in all service collections
  115288. _all.forEach(function (service) { return result.set(service.id, service.get(overrides)); });
  115289. // Ensure the collection gets the correct instantiation service
  115290. var instantiationService = new instantiationService_1.InstantiationService(result, true);
  115291. result.set(instantiation_1.IInstantiationService, instantiationService);
  115292. return [result, instantiationService];
  115293. }
  115294. StaticServices.init = init;
  115295. StaticServices.instantiationService = define(instantiation_1.IInstantiationService, function () { return new instantiationService_1.InstantiationService(_serviceCollection, true); });
  115296. var configurationServiceImpl = new simpleServices_1.SimpleConfigurationService();
  115297. StaticServices.configurationService = define(configuration_1.IConfigurationService, function () { return configurationServiceImpl; });
  115298. StaticServices.resourceConfigurationService = define(textResourceConfigurationService_1.ITextResourceConfigurationService, function () { return new simpleServices_1.SimpleResourceConfigurationService(configurationServiceImpl); });
  115299. StaticServices.resourcePropertiesService = define(textResourceConfigurationService_1.ITextResourcePropertiesService, function () { return new simpleServices_1.SimpleResourcePropertiesService(configurationServiceImpl); });
  115300. StaticServices.contextService = define(workspace_1.IWorkspaceContextService, function () { return new simpleServices_1.SimpleWorkspaceContextService(); });
  115301. StaticServices.labelService = define(label_1.ILabelService, function () { return new simpleServices_1.SimpleUriLabelService(); });
  115302. StaticServices.telemetryService = define(telemetry_1.ITelemetryService, function () { return new simpleServices_1.StandaloneTelemetryService(); });
  115303. StaticServices.dialogService = define(dialogs_1.IDialogService, function () { return new simpleServices_1.SimpleDialogService(); });
  115304. StaticServices.notificationService = define(notification_1.INotificationService, function () { return new simpleServices_1.SimpleNotificationService(); });
  115305. StaticServices.markerService = define(markers_1.IMarkerService, function () { return new markerService_1.MarkerService(); });
  115306. StaticServices.modeService = define(modeService_1.IModeService, function (o) { return new modeServiceImpl_1.ModeServiceImpl(); });
  115307. StaticServices.standaloneThemeService = define(standaloneThemeService_1.IStandaloneThemeService, function () { return new standaloneThemeServiceImpl_1.StandaloneThemeServiceImpl(); });
  115308. StaticServices.logService = define(log_1.ILogService, function () { return new log_1.NullLogService(); });
  115309. StaticServices.modelService = define(modelService_1.IModelService, function (o) { return new modelServiceImpl_1.ModelServiceImpl(StaticServices.configurationService.get(o), StaticServices.resourcePropertiesService.get(o), StaticServices.standaloneThemeService.get(o), StaticServices.logService.get(o)); });
  115310. StaticServices.markerDecorationsService = define(markersDecorationService_1.IMarkerDecorationsService, function (o) { return new markerDecorationsServiceImpl_1.MarkerDecorationsService(StaticServices.modelService.get(o), StaticServices.markerService.get(o)); });
  115311. StaticServices.codeEditorService = define(codeEditorService_1.ICodeEditorService, function (o) { return new standaloneCodeServiceImpl_1.StandaloneCodeEditorServiceImpl(StaticServices.standaloneThemeService.get(o)); });
  115312. StaticServices.editorProgressService = define(progress_1.IEditorProgressService, function () { return new simpleServices_1.SimpleEditorProgressService(); });
  115313. StaticServices.storageService = define(storage_1.IStorageService, function () { return new storage_1.InMemoryStorageService(); });
  115314. StaticServices.editorWorkerService = define(editorWorkerService_1.IEditorWorkerService, function (o) { return new editorWorkerServiceImpl_1.EditorWorkerServiceImpl(StaticServices.modelService.get(o), StaticServices.resourceConfigurationService.get(o), StaticServices.logService.get(o)); });
  115315. })(StaticServices = exports.StaticServices || (exports.StaticServices = {}));
  115316. var DynamicStandaloneServices = /** @class */ (function (_super) {
  115317. __extends(DynamicStandaloneServices, _super);
  115318. function DynamicStandaloneServices(domElement, overrides) {
  115319. var _this = _super.call(this) || this;
  115320. var _a = StaticServices.init(overrides), _serviceCollection = _a[0], _instantiationService = _a[1];
  115321. _this._serviceCollection = _serviceCollection;
  115322. _this._instantiationService = _instantiationService;
  115323. var configurationService = _this.get(configuration_1.IConfigurationService);
  115324. var notificationService = _this.get(notification_1.INotificationService);
  115325. var telemetryService = _this.get(telemetry_1.ITelemetryService);
  115326. var themeService = _this.get(themeService_1.IThemeService);
  115327. var ensure = function (serviceId, factory) {
  115328. var value = null;
  115329. if (overrides) {
  115330. value = overrides[serviceId.toString()];
  115331. }
  115332. if (!value) {
  115333. value = factory();
  115334. }
  115335. _this._serviceCollection.set(serviceId, value);
  115336. return value;
  115337. };
  115338. var contextKeyService = ensure(contextkey_1.IContextKeyService, function () { return _this._register(new contextKeyService_1.ContextKeyService(configurationService)); });
  115339. ensure(accessibility_1.IAccessibilityService, function () { return new accessibilityService_1.AccessibilityService(contextKeyService, configurationService); });
  115340. ensure(listService_1.IListService, function () { return new listService_1.ListService(themeService); });
  115341. var commandService = ensure(commands_1.ICommandService, function () { return new simpleServices_1.StandaloneCommandService(_this._instantiationService); });
  115342. var keybindingService = ensure(keybinding_1.IKeybindingService, function () { return _this._register(new simpleServices_1.StandaloneKeybindingService(contextKeyService, commandService, telemetryService, notificationService, domElement)); });
  115343. var layoutService = ensure(layoutService_1.ILayoutService, function () { return new simpleServices_1.SimpleLayoutService(domElement); });
  115344. var contextViewService = ensure(contextView_1.IContextViewService, function () { return _this._register(new contextViewService_1.ContextViewService(layoutService)); });
  115345. ensure(contextView_1.IContextMenuService, function () {
  115346. var contextMenuService = new contextMenuService_1.ContextMenuService(telemetryService, notificationService, contextViewService, keybindingService, themeService);
  115347. contextMenuService.configure({ blockMouse: false }); // we do not want that in the standalone editor
  115348. return _this._register(contextMenuService);
  115349. });
  115350. ensure(actions_1.IMenuService, function () { return new menuService_1.MenuService(commandService); });
  115351. ensure(bulkEditService_1.IBulkEditService, function () { return new simpleServices_1.SimpleBulkEditService(StaticServices.modelService.get(modelService_1.IModelService)); });
  115352. return _this;
  115353. }
  115354. DynamicStandaloneServices.prototype.get = function (serviceId) {
  115355. var r = this._serviceCollection.get(serviceId);
  115356. if (!r) {
  115357. throw new Error('Missing service ' + serviceId);
  115358. }
  115359. return r;
  115360. };
  115361. DynamicStandaloneServices.prototype.set = function (serviceId, instance) {
  115362. this._serviceCollection.set(serviceId, instance);
  115363. };
  115364. DynamicStandaloneServices.prototype.has = function (serviceId) {
  115365. return this._serviceCollection.has(serviceId);
  115366. };
  115367. return DynamicStandaloneServices;
  115368. }(lifecycle_1.Disposable));
  115369. exports.DynamicStandaloneServices = DynamicStandaloneServices;
  115370. });
  115371. /*---------------------------------------------------------------------------------------------
  115372. * Copyright (c) Microsoft Corporation. All rights reserved.
  115373. * Licensed under the MIT License. See License.txt in the project root for license information.
  115374. *--------------------------------------------------------------------------------------------*/
  115375. define(__m[603/*vs/editor/standalone/browser/standaloneEditor*/], __M([0/*require*/,1/*exports*/,32/*vs/editor/browser/services/codeEditorService*/,509/*vs/editor/browser/services/openerService*/,188/*vs/editor/browser/widget/diffNavigator*/,33/*vs/editor/common/config/editorOptions*/,142/*vs/editor/common/config/fontInfo*/,68/*vs/editor/common/editorCommon*/,48/*vs/editor/common/model*/,17/*vs/editor/common/modes*/,63/*vs/editor/common/modes/nullMode*/,62/*vs/editor/common/services/editorWorkerService*/,84/*vs/editor/common/services/resolverService*/,507/*vs/editor/common/services/webWorker*/,147/*vs/editor/common/standalone/standaloneEnums*/,494/*vs/editor/standalone/browser/colorizer*/,172/*vs/editor/standalone/browser/simpleServices*/,602/*vs/editor/standalone/browser/standaloneCodeEditor*/,238/*vs/editor/standalone/browser/standaloneServices*/,94/*vs/editor/standalone/common/standaloneThemeService*/,29/*vs/platform/commands/common/commands*/,43/*vs/platform/configuration/common/configuration*/,18/*vs/platform/contextkey/common/contextkey*/,66/*vs/platform/contextview/browser/contextView*/,11/*vs/platform/instantiation/common/instantiation*/,34/*vs/platform/keybinding/common/keybinding*/,35/*vs/platform/notification/common/notification*/,51/*vs/platform/opener/common/opener*/,64/*vs/platform/accessibility/common/accessibility*/,60/*vs/editor/browser/config/configuration*/,73/*vs/platform/progress/common/progress*/,331/*vs/css!vs/editor/standalone/browser/standalone-tokens*/]), function (require, exports, codeEditorService_1, openerService_1, diffNavigator_1, editorOptions_1, fontInfo_1, editorCommon_1, model_1, modes, nullMode_1, editorWorkerService_1, resolverService_1, webWorker_1, standaloneEnums, colorizer_1, simpleServices_1, standaloneCodeEditor_1, standaloneServices_1, standaloneThemeService_1, commands_1, configuration_1, contextkey_1, contextView_1, instantiation_1, keybinding_1, notification_1, opener_1, accessibility_1, configuration_2, progress_1) {
  115376. "use strict";
  115377. Object.defineProperty(exports, "__esModule", { value: true });
  115378. function withAllStandaloneServices(domElement, override, callback) {
  115379. var services = new standaloneServices_1.DynamicStandaloneServices(domElement, override);
  115380. var simpleEditorModelResolverService = null;
  115381. if (!services.has(resolverService_1.ITextModelService)) {
  115382. simpleEditorModelResolverService = new simpleServices_1.SimpleEditorModelResolverService(standaloneServices_1.StaticServices.modelService.get());
  115383. services.set(resolverService_1.ITextModelService, simpleEditorModelResolverService);
  115384. }
  115385. if (!services.has(opener_1.IOpenerService)) {
  115386. services.set(opener_1.IOpenerService, new openerService_1.OpenerService(services.get(codeEditorService_1.ICodeEditorService), services.get(commands_1.ICommandService)));
  115387. }
  115388. var result = callback(services);
  115389. if (simpleEditorModelResolverService) {
  115390. simpleEditorModelResolverService.setEditor(result);
  115391. }
  115392. return result;
  115393. }
  115394. /**
  115395. * Create a new editor under `domElement`.
  115396. * `domElement` should be empty (not contain other dom nodes).
  115397. * The editor will read the size of `domElement`.
  115398. */
  115399. function create(domElement, options, override) {
  115400. return withAllStandaloneServices(domElement, override || {}, function (services) {
  115401. return new standaloneCodeEditor_1.StandaloneEditor(domElement, options, services, services.get(instantiation_1.IInstantiationService), services.get(codeEditorService_1.ICodeEditorService), services.get(commands_1.ICommandService), services.get(contextkey_1.IContextKeyService), services.get(keybinding_1.IKeybindingService), services.get(contextView_1.IContextViewService), services.get(standaloneThemeService_1.IStandaloneThemeService), services.get(notification_1.INotificationService), services.get(configuration_1.IConfigurationService), services.get(accessibility_1.IAccessibilityService));
  115402. });
  115403. }
  115404. exports.create = create;
  115405. /**
  115406. * Emitted when an editor is created.
  115407. * Creating a diff editor might cause this listener to be invoked with the two editors.
  115408. * @event
  115409. */
  115410. function onDidCreateEditor(listener) {
  115411. return standaloneServices_1.StaticServices.codeEditorService.get().onCodeEditorAdd(function (editor) {
  115412. listener(editor);
  115413. });
  115414. }
  115415. exports.onDidCreateEditor = onDidCreateEditor;
  115416. /**
  115417. * Create a new diff editor under `domElement`.
  115418. * `domElement` should be empty (not contain other dom nodes).
  115419. * The editor will read the size of `domElement`.
  115420. */
  115421. function createDiffEditor(domElement, options, override) {
  115422. return withAllStandaloneServices(domElement, override || {}, function (services) {
  115423. return new standaloneCodeEditor_1.StandaloneDiffEditor(domElement, options, services, services.get(instantiation_1.IInstantiationService), services.get(contextkey_1.IContextKeyService), services.get(keybinding_1.IKeybindingService), services.get(contextView_1.IContextViewService), services.get(editorWorkerService_1.IEditorWorkerService), services.get(codeEditorService_1.ICodeEditorService), services.get(standaloneThemeService_1.IStandaloneThemeService), services.get(notification_1.INotificationService), services.get(configuration_1.IConfigurationService), services.get(contextView_1.IContextMenuService), services.get(progress_1.IEditorProgressService), null);
  115424. });
  115425. }
  115426. exports.createDiffEditor = createDiffEditor;
  115427. function createDiffNavigator(diffEditor, opts) {
  115428. return new diffNavigator_1.DiffNavigator(diffEditor, opts);
  115429. }
  115430. exports.createDiffNavigator = createDiffNavigator;
  115431. function doCreateModel(value, languageSelection, uri) {
  115432. return standaloneServices_1.StaticServices.modelService.get().createModel(value, languageSelection, uri);
  115433. }
  115434. /**
  115435. * Create a new editor model.
  115436. * You can specify the language that should be set for this model or let the language be inferred from the `uri`.
  115437. */
  115438. function createModel(value, language, uri) {
  115439. value = value || '';
  115440. if (!language) {
  115441. var firstLF = value.indexOf('\n');
  115442. var firstLine = value;
  115443. if (firstLF !== -1) {
  115444. firstLine = value.substring(0, firstLF);
  115445. }
  115446. return doCreateModel(value, standaloneServices_1.StaticServices.modeService.get().createByFilepathOrFirstLine(uri || null, firstLine), uri);
  115447. }
  115448. return doCreateModel(value, standaloneServices_1.StaticServices.modeService.get().create(language), uri);
  115449. }
  115450. exports.createModel = createModel;
  115451. /**
  115452. * Change the language for a model.
  115453. */
  115454. function setModelLanguage(model, languageId) {
  115455. standaloneServices_1.StaticServices.modelService.get().setMode(model, standaloneServices_1.StaticServices.modeService.get().create(languageId));
  115456. }
  115457. exports.setModelLanguage = setModelLanguage;
  115458. /**
  115459. * Set the markers for a model.
  115460. */
  115461. function setModelMarkers(model, owner, markers) {
  115462. if (model) {
  115463. standaloneServices_1.StaticServices.markerService.get().changeOne(owner, model.uri, markers);
  115464. }
  115465. }
  115466. exports.setModelMarkers = setModelMarkers;
  115467. /**
  115468. * Get markers for owner and/or resource
  115469. *
  115470. * @returns list of markers
  115471. */
  115472. function getModelMarkers(filter) {
  115473. return standaloneServices_1.StaticServices.markerService.get().read(filter);
  115474. }
  115475. exports.getModelMarkers = getModelMarkers;
  115476. /**
  115477. * Get the model that has `uri` if it exists.
  115478. */
  115479. function getModel(uri) {
  115480. return standaloneServices_1.StaticServices.modelService.get().getModel(uri);
  115481. }
  115482. exports.getModel = getModel;
  115483. /**
  115484. * Get all the created models.
  115485. */
  115486. function getModels() {
  115487. return standaloneServices_1.StaticServices.modelService.get().getModels();
  115488. }
  115489. exports.getModels = getModels;
  115490. /**
  115491. * Emitted when a model is created.
  115492. * @event
  115493. */
  115494. function onDidCreateModel(listener) {
  115495. return standaloneServices_1.StaticServices.modelService.get().onModelAdded(listener);
  115496. }
  115497. exports.onDidCreateModel = onDidCreateModel;
  115498. /**
  115499. * Emitted right before a model is disposed.
  115500. * @event
  115501. */
  115502. function onWillDisposeModel(listener) {
  115503. return standaloneServices_1.StaticServices.modelService.get().onModelRemoved(listener);
  115504. }
  115505. exports.onWillDisposeModel = onWillDisposeModel;
  115506. /**
  115507. * Emitted when a different language is set to a model.
  115508. * @event
  115509. */
  115510. function onDidChangeModelLanguage(listener) {
  115511. return standaloneServices_1.StaticServices.modelService.get().onModelModeChanged(function (e) {
  115512. listener({
  115513. model: e.model,
  115514. oldLanguage: e.oldModeId
  115515. });
  115516. });
  115517. }
  115518. exports.onDidChangeModelLanguage = onDidChangeModelLanguage;
  115519. /**
  115520. * Create a new web worker that has model syncing capabilities built in.
  115521. * Specify an AMD module to load that will `create` an object that will be proxied.
  115522. */
  115523. function createWebWorker(opts) {
  115524. return webWorker_1.createWebWorker(standaloneServices_1.StaticServices.modelService.get(), opts);
  115525. }
  115526. exports.createWebWorker = createWebWorker;
  115527. /**
  115528. * Colorize the contents of `domNode` using attribute `data-lang`.
  115529. */
  115530. function colorizeElement(domNode, options) {
  115531. return colorizer_1.Colorizer.colorizeElement(standaloneServices_1.StaticServices.standaloneThemeService.get(), standaloneServices_1.StaticServices.modeService.get(), domNode, options);
  115532. }
  115533. exports.colorizeElement = colorizeElement;
  115534. /**
  115535. * Colorize `text` using language `languageId`.
  115536. */
  115537. function colorize(text, languageId, options) {
  115538. return colorizer_1.Colorizer.colorize(standaloneServices_1.StaticServices.modeService.get(), text, languageId, options);
  115539. }
  115540. exports.colorize = colorize;
  115541. /**
  115542. * Colorize a line in a model.
  115543. */
  115544. function colorizeModelLine(model, lineNumber, tabSize) {
  115545. if (tabSize === void 0) { tabSize = 4; }
  115546. return colorizer_1.Colorizer.colorizeModelLine(model, lineNumber, tabSize);
  115547. }
  115548. exports.colorizeModelLine = colorizeModelLine;
  115549. /**
  115550. * @internal
  115551. */
  115552. function getSafeTokenizationSupport(language) {
  115553. var tokenizationSupport = modes.TokenizationRegistry.get(language);
  115554. if (tokenizationSupport) {
  115555. return tokenizationSupport;
  115556. }
  115557. return {
  115558. getInitialState: function () { return nullMode_1.NULL_STATE; },
  115559. tokenize: function (line, state, deltaOffset) { return nullMode_1.nullTokenize(language, line, state, deltaOffset); }
  115560. };
  115561. }
  115562. /**
  115563. * Tokenize `text` using language `languageId`
  115564. */
  115565. function tokenize(text, languageId) {
  115566. var modeService = standaloneServices_1.StaticServices.modeService.get();
  115567. // Needed in order to get the mode registered for subsequent look-ups
  115568. modeService.triggerMode(languageId);
  115569. var tokenizationSupport = getSafeTokenizationSupport(languageId);
  115570. var lines = text.split(/\r\n|\r|\n/);
  115571. var result = [];
  115572. var state = tokenizationSupport.getInitialState();
  115573. for (var i = 0, len = lines.length; i < len; i++) {
  115574. var line = lines[i];
  115575. var tokenizationResult = tokenizationSupport.tokenize(line, state, 0);
  115576. result[i] = tokenizationResult.tokens;
  115577. state = tokenizationResult.endState;
  115578. }
  115579. return result;
  115580. }
  115581. exports.tokenize = tokenize;
  115582. /**
  115583. * Define a new theme or update an existing theme.
  115584. */
  115585. function defineTheme(themeName, themeData) {
  115586. standaloneServices_1.StaticServices.standaloneThemeService.get().defineTheme(themeName, themeData);
  115587. }
  115588. exports.defineTheme = defineTheme;
  115589. /**
  115590. * Switches to a theme.
  115591. */
  115592. function setTheme(themeName) {
  115593. standaloneServices_1.StaticServices.standaloneThemeService.get().setTheme(themeName);
  115594. }
  115595. exports.setTheme = setTheme;
  115596. /**
  115597. * Clears all cached font measurements and triggers re-measurement.
  115598. */
  115599. function remeasureFonts() {
  115600. configuration_2.clearAllFontInfos();
  115601. }
  115602. exports.remeasureFonts = remeasureFonts;
  115603. /**
  115604. * @internal
  115605. */
  115606. function createMonacoEditorAPI() {
  115607. return {
  115608. // methods
  115609. create: create,
  115610. onDidCreateEditor: onDidCreateEditor,
  115611. createDiffEditor: createDiffEditor,
  115612. createDiffNavigator: createDiffNavigator,
  115613. createModel: createModel,
  115614. setModelLanguage: setModelLanguage,
  115615. setModelMarkers: setModelMarkers,
  115616. getModelMarkers: getModelMarkers,
  115617. getModels: getModels,
  115618. getModel: getModel,
  115619. onDidCreateModel: onDidCreateModel,
  115620. onWillDisposeModel: onWillDisposeModel,
  115621. onDidChangeModelLanguage: onDidChangeModelLanguage,
  115622. createWebWorker: createWebWorker,
  115623. colorizeElement: colorizeElement,
  115624. colorize: colorize,
  115625. colorizeModelLine: colorizeModelLine,
  115626. tokenize: tokenize,
  115627. defineTheme: defineTheme,
  115628. setTheme: setTheme,
  115629. remeasureFonts: remeasureFonts,
  115630. // enums
  115631. AccessibilitySupport: standaloneEnums.AccessibilitySupport,
  115632. ContentWidgetPositionPreference: standaloneEnums.ContentWidgetPositionPreference,
  115633. CursorChangeReason: standaloneEnums.CursorChangeReason,
  115634. DefaultEndOfLine: standaloneEnums.DefaultEndOfLine,
  115635. EditorAutoIndentStrategy: standaloneEnums.EditorAutoIndentStrategy,
  115636. EditorOption: standaloneEnums.EditorOption,
  115637. EndOfLinePreference: standaloneEnums.EndOfLinePreference,
  115638. EndOfLineSequence: standaloneEnums.EndOfLineSequence,
  115639. MinimapPosition: standaloneEnums.MinimapPosition,
  115640. MouseTargetType: standaloneEnums.MouseTargetType,
  115641. OverlayWidgetPositionPreference: standaloneEnums.OverlayWidgetPositionPreference,
  115642. OverviewRulerLane: standaloneEnums.OverviewRulerLane,
  115643. RenderLineNumbersType: standaloneEnums.RenderLineNumbersType,
  115644. RenderMinimap: standaloneEnums.RenderMinimap,
  115645. ScrollbarVisibility: standaloneEnums.ScrollbarVisibility,
  115646. ScrollType: standaloneEnums.ScrollType,
  115647. TextEditorCursorBlinkingStyle: standaloneEnums.TextEditorCursorBlinkingStyle,
  115648. TextEditorCursorStyle: standaloneEnums.TextEditorCursorStyle,
  115649. TrackedRangeStickiness: standaloneEnums.TrackedRangeStickiness,
  115650. WrappingIndent: standaloneEnums.WrappingIndent,
  115651. // classes
  115652. ConfigurationChangedEvent: editorOptions_1.ConfigurationChangedEvent,
  115653. BareFontInfo: fontInfo_1.BareFontInfo,
  115654. FontInfo: fontInfo_1.FontInfo,
  115655. TextModelResolvedOptions: model_1.TextModelResolvedOptions,
  115656. FindMatch: model_1.FindMatch,
  115657. // vars
  115658. EditorType: editorCommon_1.EditorType,
  115659. EditorOptions: editorOptions_1.EditorOptions
  115660. };
  115661. }
  115662. exports.createMonacoEditorAPI = createMonacoEditorAPI;
  115663. });
  115664. /*---------------------------------------------------------------------------------------------
  115665. * Copyright (c) Microsoft Corporation. All rights reserved.
  115666. * Licensed under the MIT License. See License.txt in the project root for license information.
  115667. *--------------------------------------------------------------------------------------------*/
  115668. define(__m[604/*vs/editor/standalone/browser/standaloneLanguages*/], __M([0/*require*/,1/*exports*/,3/*vs/editor/common/core/range*/,107/*vs/editor/common/core/token*/,17/*vs/editor/common/modes*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/,118/*vs/editor/common/modes/modesRegistry*/,147/*vs/editor/common/standalone/standaloneEnums*/,238/*vs/editor/standalone/browser/standaloneServices*/,393/*vs/editor/standalone/common/monarch/monarchCompile*/,216/*vs/editor/standalone/common/monarch/monarchLexer*/]), function (require, exports, range_1, token_1, modes, languageConfigurationRegistry_1, modesRegistry_1, standaloneEnums, standaloneServices_1, monarchCompile_1, monarchLexer_1) {
  115669. "use strict";
  115670. Object.defineProperty(exports, "__esModule", { value: true });
  115671. /**
  115672. * Register information about a new language.
  115673. */
  115674. function register(language) {
  115675. modesRegistry_1.ModesRegistry.registerLanguage(language);
  115676. }
  115677. exports.register = register;
  115678. /**
  115679. * Get the information of all the registered languages.
  115680. */
  115681. function getLanguages() {
  115682. var result = [];
  115683. result = result.concat(modesRegistry_1.ModesRegistry.getLanguages());
  115684. return result;
  115685. }
  115686. exports.getLanguages = getLanguages;
  115687. function getEncodedLanguageId(languageId) {
  115688. var lid = standaloneServices_1.StaticServices.modeService.get().getLanguageIdentifier(languageId);
  115689. return lid ? lid.id : 0;
  115690. }
  115691. exports.getEncodedLanguageId = getEncodedLanguageId;
  115692. /**
  115693. * An event emitted when a language is first time needed (e.g. a model has it set).
  115694. * @event
  115695. */
  115696. function onLanguage(languageId, callback) {
  115697. var disposable = standaloneServices_1.StaticServices.modeService.get().onDidCreateMode(function (mode) {
  115698. if (mode.getId() === languageId) {
  115699. // stop listening
  115700. disposable.dispose();
  115701. // invoke actual listener
  115702. callback();
  115703. }
  115704. });
  115705. return disposable;
  115706. }
  115707. exports.onLanguage = onLanguage;
  115708. /**
  115709. * Set the editing configuration for a language.
  115710. */
  115711. function setLanguageConfiguration(languageId, configuration) {
  115712. var languageIdentifier = standaloneServices_1.StaticServices.modeService.get().getLanguageIdentifier(languageId);
  115713. if (!languageIdentifier) {
  115714. throw new Error("Cannot set configuration for unknown language " + languageId);
  115715. }
  115716. return languageConfigurationRegistry_1.LanguageConfigurationRegistry.register(languageIdentifier, configuration);
  115717. }
  115718. exports.setLanguageConfiguration = setLanguageConfiguration;
  115719. /**
  115720. * @internal
  115721. */
  115722. var EncodedTokenizationSupport2Adapter = /** @class */ (function () {
  115723. function EncodedTokenizationSupport2Adapter(actual) {
  115724. this._actual = actual;
  115725. }
  115726. EncodedTokenizationSupport2Adapter.prototype.getInitialState = function () {
  115727. return this._actual.getInitialState();
  115728. };
  115729. EncodedTokenizationSupport2Adapter.prototype.tokenize = function (line, state, offsetDelta) {
  115730. throw new Error('Not supported!');
  115731. };
  115732. EncodedTokenizationSupport2Adapter.prototype.tokenize2 = function (line, state) {
  115733. var result = this._actual.tokenizeEncoded(line, state);
  115734. return new token_1.TokenizationResult2(result.tokens, result.endState);
  115735. };
  115736. return EncodedTokenizationSupport2Adapter;
  115737. }());
  115738. exports.EncodedTokenizationSupport2Adapter = EncodedTokenizationSupport2Adapter;
  115739. /**
  115740. * @internal
  115741. */
  115742. var TokenizationSupport2Adapter = /** @class */ (function () {
  115743. function TokenizationSupport2Adapter(standaloneThemeService, languageIdentifier, actual) {
  115744. this._standaloneThemeService = standaloneThemeService;
  115745. this._languageIdentifier = languageIdentifier;
  115746. this._actual = actual;
  115747. }
  115748. TokenizationSupport2Adapter.prototype.getInitialState = function () {
  115749. return this._actual.getInitialState();
  115750. };
  115751. TokenizationSupport2Adapter.prototype._toClassicTokens = function (tokens, language, offsetDelta) {
  115752. var result = [];
  115753. var previousStartIndex = 0;
  115754. for (var i = 0, len = tokens.length; i < len; i++) {
  115755. var t = tokens[i];
  115756. var startIndex = t.startIndex;
  115757. // Prevent issues stemming from a buggy external tokenizer.
  115758. if (i === 0) {
  115759. // Force first token to start at first index!
  115760. startIndex = 0;
  115761. }
  115762. else if (startIndex < previousStartIndex) {
  115763. // Force tokens to be after one another!
  115764. startIndex = previousStartIndex;
  115765. }
  115766. result[i] = new token_1.Token(startIndex + offsetDelta, t.scopes, language);
  115767. previousStartIndex = startIndex;
  115768. }
  115769. return result;
  115770. };
  115771. TokenizationSupport2Adapter.prototype.tokenize = function (line, state, offsetDelta) {
  115772. var actualResult = this._actual.tokenize(line, state);
  115773. var tokens = this._toClassicTokens(actualResult.tokens, this._languageIdentifier.language, offsetDelta);
  115774. var endState;
  115775. // try to save an object if possible
  115776. if (actualResult.endState.equals(state)) {
  115777. endState = state;
  115778. }
  115779. else {
  115780. endState = actualResult.endState;
  115781. }
  115782. return new token_1.TokenizationResult(tokens, endState);
  115783. };
  115784. TokenizationSupport2Adapter.prototype._toBinaryTokens = function (tokens, offsetDelta) {
  115785. var languageId = this._languageIdentifier.id;
  115786. var tokenTheme = this._standaloneThemeService.getTheme().tokenTheme;
  115787. var result = [], resultLen = 0;
  115788. var previousStartIndex = 0;
  115789. for (var i = 0, len = tokens.length; i < len; i++) {
  115790. var t = tokens[i];
  115791. var metadata = tokenTheme.match(languageId, t.scopes);
  115792. if (resultLen > 0 && result[resultLen - 1] === metadata) {
  115793. // same metadata
  115794. continue;
  115795. }
  115796. var startIndex = t.startIndex;
  115797. // Prevent issues stemming from a buggy external tokenizer.
  115798. if (i === 0) {
  115799. // Force first token to start at first index!
  115800. startIndex = 0;
  115801. }
  115802. else if (startIndex < previousStartIndex) {
  115803. // Force tokens to be after one another!
  115804. startIndex = previousStartIndex;
  115805. }
  115806. result[resultLen++] = startIndex + offsetDelta;
  115807. result[resultLen++] = metadata;
  115808. previousStartIndex = startIndex;
  115809. }
  115810. var actualResult = new Uint32Array(resultLen);
  115811. for (var i = 0; i < resultLen; i++) {
  115812. actualResult[i] = result[i];
  115813. }
  115814. return actualResult;
  115815. };
  115816. TokenizationSupport2Adapter.prototype.tokenize2 = function (line, state, offsetDelta) {
  115817. var actualResult = this._actual.tokenize(line, state);
  115818. var tokens = this._toBinaryTokens(actualResult.tokens, offsetDelta);
  115819. var endState;
  115820. // try to save an object if possible
  115821. if (actualResult.endState.equals(state)) {
  115822. endState = state;
  115823. }
  115824. else {
  115825. endState = actualResult.endState;
  115826. }
  115827. return new token_1.TokenizationResult2(tokens, endState);
  115828. };
  115829. return TokenizationSupport2Adapter;
  115830. }());
  115831. exports.TokenizationSupport2Adapter = TokenizationSupport2Adapter;
  115832. function isEncodedTokensProvider(provider) {
  115833. return 'tokenizeEncoded' in provider;
  115834. }
  115835. function isThenable(obj) {
  115836. return obj && typeof obj.then === 'function';
  115837. }
  115838. /**
  115839. * Set the tokens provider for a language (manual implementation).
  115840. */
  115841. function setTokensProvider(languageId, provider) {
  115842. var languageIdentifier = standaloneServices_1.StaticServices.modeService.get().getLanguageIdentifier(languageId);
  115843. if (!languageIdentifier) {
  115844. throw new Error("Cannot set tokens provider for unknown language " + languageId);
  115845. }
  115846. var create = function (provider) {
  115847. if (isEncodedTokensProvider(provider)) {
  115848. return new EncodedTokenizationSupport2Adapter(provider);
  115849. }
  115850. else {
  115851. return new TokenizationSupport2Adapter(standaloneServices_1.StaticServices.standaloneThemeService.get(), languageIdentifier, provider);
  115852. }
  115853. };
  115854. if (isThenable(provider)) {
  115855. return modes.TokenizationRegistry.registerPromise(languageId, provider.then(function (provider) { return create(provider); }));
  115856. }
  115857. return modes.TokenizationRegistry.register(languageId, create(provider));
  115858. }
  115859. exports.setTokensProvider = setTokensProvider;
  115860. /**
  115861. * Set the tokens provider for a language (monarch implementation).
  115862. */
  115863. function setMonarchTokensProvider(languageId, languageDef) {
  115864. var create = function (languageDef) {
  115865. return monarchLexer_1.createTokenizationSupport(standaloneServices_1.StaticServices.modeService.get(), standaloneServices_1.StaticServices.standaloneThemeService.get(), languageId, monarchCompile_1.compile(languageId, languageDef));
  115866. };
  115867. if (isThenable(languageDef)) {
  115868. return modes.TokenizationRegistry.registerPromise(languageId, languageDef.then(function (languageDef) { return create(languageDef); }));
  115869. }
  115870. return modes.TokenizationRegistry.register(languageId, create(languageDef));
  115871. }
  115872. exports.setMonarchTokensProvider = setMonarchTokensProvider;
  115873. /**
  115874. * Register a reference provider (used by e.g. reference search).
  115875. */
  115876. function registerReferenceProvider(languageId, provider) {
  115877. return modes.ReferenceProviderRegistry.register(languageId, provider);
  115878. }
  115879. exports.registerReferenceProvider = registerReferenceProvider;
  115880. /**
  115881. * Register a rename provider (used by e.g. rename symbol).
  115882. */
  115883. function registerRenameProvider(languageId, provider) {
  115884. return modes.RenameProviderRegistry.register(languageId, provider);
  115885. }
  115886. exports.registerRenameProvider = registerRenameProvider;
  115887. /**
  115888. * Register a signature help provider (used by e.g. parameter hints).
  115889. */
  115890. function registerSignatureHelpProvider(languageId, provider) {
  115891. return modes.SignatureHelpProviderRegistry.register(languageId, provider);
  115892. }
  115893. exports.registerSignatureHelpProvider = registerSignatureHelpProvider;
  115894. /**
  115895. * Register a hover provider (used by e.g. editor hover).
  115896. */
  115897. function registerHoverProvider(languageId, provider) {
  115898. return modes.HoverProviderRegistry.register(languageId, {
  115899. provideHover: function (model, position, token) {
  115900. var word = model.getWordAtPosition(position);
  115901. return Promise.resolve(provider.provideHover(model, position, token)).then(function (value) {
  115902. if (!value) {
  115903. return undefined;
  115904. }
  115905. if (!value.range && word) {
  115906. value.range = new range_1.Range(position.lineNumber, word.startColumn, position.lineNumber, word.endColumn);
  115907. }
  115908. if (!value.range) {
  115909. value.range = new range_1.Range(position.lineNumber, position.column, position.lineNumber, position.column);
  115910. }
  115911. return value;
  115912. });
  115913. }
  115914. });
  115915. }
  115916. exports.registerHoverProvider = registerHoverProvider;
  115917. /**
  115918. * Register a document symbol provider (used by e.g. outline).
  115919. */
  115920. function registerDocumentSymbolProvider(languageId, provider) {
  115921. return modes.DocumentSymbolProviderRegistry.register(languageId, provider);
  115922. }
  115923. exports.registerDocumentSymbolProvider = registerDocumentSymbolProvider;
  115924. /**
  115925. * Register a document highlight provider (used by e.g. highlight occurrences).
  115926. */
  115927. function registerDocumentHighlightProvider(languageId, provider) {
  115928. return modes.DocumentHighlightProviderRegistry.register(languageId, provider);
  115929. }
  115930. exports.registerDocumentHighlightProvider = registerDocumentHighlightProvider;
  115931. /**
  115932. * Register a definition provider (used by e.g. go to definition).
  115933. */
  115934. function registerDefinitionProvider(languageId, provider) {
  115935. return modes.DefinitionProviderRegistry.register(languageId, provider);
  115936. }
  115937. exports.registerDefinitionProvider = registerDefinitionProvider;
  115938. /**
  115939. * Register a implementation provider (used by e.g. go to implementation).
  115940. */
  115941. function registerImplementationProvider(languageId, provider) {
  115942. return modes.ImplementationProviderRegistry.register(languageId, provider);
  115943. }
  115944. exports.registerImplementationProvider = registerImplementationProvider;
  115945. /**
  115946. * Register a type definition provider (used by e.g. go to type definition).
  115947. */
  115948. function registerTypeDefinitionProvider(languageId, provider) {
  115949. return modes.TypeDefinitionProviderRegistry.register(languageId, provider);
  115950. }
  115951. exports.registerTypeDefinitionProvider = registerTypeDefinitionProvider;
  115952. /**
  115953. * Register a code lens provider (used by e.g. inline code lenses).
  115954. */
  115955. function registerCodeLensProvider(languageId, provider) {
  115956. return modes.CodeLensProviderRegistry.register(languageId, provider);
  115957. }
  115958. exports.registerCodeLensProvider = registerCodeLensProvider;
  115959. /**
  115960. * Register a code action provider (used by e.g. quick fix).
  115961. */
  115962. function registerCodeActionProvider(languageId, provider) {
  115963. return modes.CodeActionProviderRegistry.register(languageId, {
  115964. provideCodeActions: function (model, range, context, token) {
  115965. var markers = standaloneServices_1.StaticServices.markerService.get().read({ resource: model.uri }).filter(function (m) {
  115966. return range_1.Range.areIntersectingOrTouching(m, range);
  115967. });
  115968. return provider.provideCodeActions(model, range, { markers: markers, only: context.only }, token);
  115969. }
  115970. });
  115971. }
  115972. exports.registerCodeActionProvider = registerCodeActionProvider;
  115973. /**
  115974. * Register a formatter that can handle only entire models.
  115975. */
  115976. function registerDocumentFormattingEditProvider(languageId, provider) {
  115977. return modes.DocumentFormattingEditProviderRegistry.register(languageId, provider);
  115978. }
  115979. exports.registerDocumentFormattingEditProvider = registerDocumentFormattingEditProvider;
  115980. /**
  115981. * Register a formatter that can handle a range inside a model.
  115982. */
  115983. function registerDocumentRangeFormattingEditProvider(languageId, provider) {
  115984. return modes.DocumentRangeFormattingEditProviderRegistry.register(languageId, provider);
  115985. }
  115986. exports.registerDocumentRangeFormattingEditProvider = registerDocumentRangeFormattingEditProvider;
  115987. /**
  115988. * Register a formatter than can do formatting as the user types.
  115989. */
  115990. function registerOnTypeFormattingEditProvider(languageId, provider) {
  115991. return modes.OnTypeFormattingEditProviderRegistry.register(languageId, provider);
  115992. }
  115993. exports.registerOnTypeFormattingEditProvider = registerOnTypeFormattingEditProvider;
  115994. /**
  115995. * Register a link provider that can find links in text.
  115996. */
  115997. function registerLinkProvider(languageId, provider) {
  115998. return modes.LinkProviderRegistry.register(languageId, provider);
  115999. }
  116000. exports.registerLinkProvider = registerLinkProvider;
  116001. /**
  116002. * Register a completion item provider (use by e.g. suggestions).
  116003. */
  116004. function registerCompletionItemProvider(languageId, provider) {
  116005. return modes.CompletionProviderRegistry.register(languageId, provider);
  116006. }
  116007. exports.registerCompletionItemProvider = registerCompletionItemProvider;
  116008. /**
  116009. * Register a document color provider (used by Color Picker, Color Decorator).
  116010. */
  116011. function registerColorProvider(languageId, provider) {
  116012. return modes.ColorProviderRegistry.register(languageId, provider);
  116013. }
  116014. exports.registerColorProvider = registerColorProvider;
  116015. /**
  116016. * Register a folding range provider
  116017. */
  116018. function registerFoldingRangeProvider(languageId, provider) {
  116019. return modes.FoldingRangeProviderRegistry.register(languageId, provider);
  116020. }
  116021. exports.registerFoldingRangeProvider = registerFoldingRangeProvider;
  116022. /**
  116023. * Register a declaration provider
  116024. */
  116025. function registerDeclarationProvider(languageId, provider) {
  116026. return modes.DeclarationProviderRegistry.register(languageId, provider);
  116027. }
  116028. exports.registerDeclarationProvider = registerDeclarationProvider;
  116029. /**
  116030. * Register a selection range provider
  116031. */
  116032. function registerSelectionRangeProvider(languageId, provider) {
  116033. return modes.SelectionRangeRegistry.register(languageId, provider);
  116034. }
  116035. exports.registerSelectionRangeProvider = registerSelectionRangeProvider;
  116036. /**
  116037. * Register a document semantic tokens provider
  116038. */
  116039. function registerDocumentSemanticTokensProvider(languageId, provider) {
  116040. return modes.DocumentSemanticTokensProviderRegistry.register(languageId, provider);
  116041. }
  116042. exports.registerDocumentSemanticTokensProvider = registerDocumentSemanticTokensProvider;
  116043. /**
  116044. * Register a document range semantic tokens provider
  116045. */
  116046. function registerDocumentRangeSemanticTokensProvider(languageId, provider) {
  116047. return modes.DocumentRangeSemanticTokensProviderRegistry.register(languageId, provider);
  116048. }
  116049. exports.registerDocumentRangeSemanticTokensProvider = registerDocumentRangeSemanticTokensProvider;
  116050. /**
  116051. * @internal
  116052. */
  116053. function createMonacoLanguagesAPI() {
  116054. return {
  116055. register: register,
  116056. getLanguages: getLanguages,
  116057. onLanguage: onLanguage,
  116058. getEncodedLanguageId: getEncodedLanguageId,
  116059. // provider methods
  116060. setLanguageConfiguration: setLanguageConfiguration,
  116061. setTokensProvider: setTokensProvider,
  116062. setMonarchTokensProvider: setMonarchTokensProvider,
  116063. registerReferenceProvider: registerReferenceProvider,
  116064. registerRenameProvider: registerRenameProvider,
  116065. registerCompletionItemProvider: registerCompletionItemProvider,
  116066. registerSignatureHelpProvider: registerSignatureHelpProvider,
  116067. registerHoverProvider: registerHoverProvider,
  116068. registerDocumentSymbolProvider: registerDocumentSymbolProvider,
  116069. registerDocumentHighlightProvider: registerDocumentHighlightProvider,
  116070. registerDefinitionProvider: registerDefinitionProvider,
  116071. registerImplementationProvider: registerImplementationProvider,
  116072. registerTypeDefinitionProvider: registerTypeDefinitionProvider,
  116073. registerCodeLensProvider: registerCodeLensProvider,
  116074. registerCodeActionProvider: registerCodeActionProvider,
  116075. registerDocumentFormattingEditProvider: registerDocumentFormattingEditProvider,
  116076. registerDocumentRangeFormattingEditProvider: registerDocumentRangeFormattingEditProvider,
  116077. registerOnTypeFormattingEditProvider: registerOnTypeFormattingEditProvider,
  116078. registerLinkProvider: registerLinkProvider,
  116079. registerColorProvider: registerColorProvider,
  116080. registerFoldingRangeProvider: registerFoldingRangeProvider,
  116081. registerDeclarationProvider: registerDeclarationProvider,
  116082. registerSelectionRangeProvider: registerSelectionRangeProvider,
  116083. registerDocumentSemanticTokensProvider: registerDocumentSemanticTokensProvider,
  116084. registerDocumentRangeSemanticTokensProvider: registerDocumentRangeSemanticTokensProvider,
  116085. // enums
  116086. DocumentHighlightKind: standaloneEnums.DocumentHighlightKind,
  116087. CompletionItemKind: standaloneEnums.CompletionItemKind,
  116088. CompletionItemTag: standaloneEnums.CompletionItemTag,
  116089. CompletionItemInsertTextRule: standaloneEnums.CompletionItemInsertTextRule,
  116090. SymbolKind: standaloneEnums.SymbolKind,
  116091. SymbolTag: standaloneEnums.SymbolTag,
  116092. IndentAction: standaloneEnums.IndentAction,
  116093. CompletionTriggerKind: standaloneEnums.CompletionTriggerKind,
  116094. SignatureHelpTriggerKind: standaloneEnums.SignatureHelpTriggerKind,
  116095. // classes
  116096. FoldingRangeKind: modes.FoldingRangeKind,
  116097. };
  116098. }
  116099. exports.createMonacoLanguagesAPI = createMonacoLanguagesAPI;
  116100. });
  116101. /*---------------------------------------------------------------------------------------------
  116102. * Copyright (c) Microsoft Corporation. All rights reserved.
  116103. * Licensed under the MIT License. See License.txt in the project root for license information.
  116104. *--------------------------------------------------------------------------------------------*/
  116105. define(__m[605/*vs/editor/editor.api*/], __M([0/*require*/,1/*exports*/,33/*vs/editor/common/config/editorOptions*/,192/*vs/editor/common/standalone/standaloneBase*/,603/*vs/editor/standalone/browser/standaloneEditor*/,604/*vs/editor/standalone/browser/standaloneLanguages*/]), function (require, exports, editorOptions_1, standaloneBase_1, standaloneEditor_1, standaloneLanguages_1) {
  116106. "use strict";
  116107. Object.defineProperty(exports, "__esModule", { value: true });
  116108. var global = self;
  116109. // Set defaults for standalone editor
  116110. editorOptions_1.EditorOptions.wrappingIndent.defaultValue = 0 /* None */;
  116111. editorOptions_1.EditorOptions.glyphMargin.defaultValue = false;
  116112. editorOptions_1.EditorOptions.autoIndent.defaultValue = 3 /* Advanced */;
  116113. editorOptions_1.EditorOptions.overviewRulerLanes.defaultValue = 2;
  116114. var api = standaloneBase_1.createMonacoBaseAPI();
  116115. api.editor = standaloneEditor_1.createMonacoEditorAPI();
  116116. api.languages = standaloneLanguages_1.createMonacoLanguagesAPI();
  116117. exports.CancellationTokenSource = api.CancellationTokenSource;
  116118. exports.Emitter = api.Emitter;
  116119. exports.KeyCode = api.KeyCode;
  116120. exports.KeyMod = api.KeyMod;
  116121. exports.Position = api.Position;
  116122. exports.Range = api.Range;
  116123. exports.Selection = api.Selection;
  116124. exports.SelectionDirection = api.SelectionDirection;
  116125. exports.MarkerSeverity = api.MarkerSeverity;
  116126. exports.MarkerTag = api.MarkerTag;
  116127. exports.Uri = api.Uri;
  116128. exports.Token = api.Token;
  116129. exports.editor = api.editor;
  116130. exports.languages = api.languages;
  116131. global.monaco = api;
  116132. if (typeof global.require !== 'undefined' && typeof global.require.config === 'function') {
  116133. global.require.config({
  116134. ignoreDuplicateModules: [
  116135. 'vscode-languageserver-types',
  116136. 'vscode-languageserver-types/main',
  116137. 'vscode-nls',
  116138. 'vscode-nls/vscode-nls',
  116139. 'jsonc-parser',
  116140. 'jsonc-parser/main',
  116141. 'vscode-uri',
  116142. 'vscode-uri/index',
  116143. 'vs/basic-languages/typescript/typescript'
  116144. ]
  116145. });
  116146. }
  116147. });
  116148. define(__m[606/*vs/platform/workspaces/common/workspaces*/], __M([0/*require*/,1/*exports*/,25/*vs/base/common/uri*/]), function (require, exports, uri_1) {
  116149. "use strict";
  116150. Object.defineProperty(exports, "__esModule", { value: true });
  116151. exports.WORKSPACE_EXTENSION = 'code-workspace';
  116152. function isSingleFolderWorkspaceIdentifier(obj) {
  116153. return obj instanceof uri_1.URI;
  116154. }
  116155. exports.isSingleFolderWorkspaceIdentifier = isSingleFolderWorkspaceIdentifier;
  116156. function toWorkspaceIdentifier(workspace) {
  116157. if (workspace.configuration) {
  116158. return {
  116159. configPath: workspace.configuration,
  116160. id: workspace.id
  116161. };
  116162. }
  116163. if (workspace.folders.length === 1) {
  116164. return workspace.folders[0].uri;
  116165. }
  116166. // Empty workspace
  116167. return undefined;
  116168. }
  116169. exports.toWorkspaceIdentifier = toWorkspaceIdentifier;
  116170. });
  116171. //#endregion
  116172. /*---------------------------------------------------------------------------------------------
  116173. * Copyright (c) Microsoft Corporation. All rights reserved.
  116174. * Licensed under the MIT License. See License.txt in the project root for license information.
  116175. *--------------------------------------------------------------------------------------------*/
  116176. define(__m[607/*vs/editor/contrib/snippet/snippetVariables*/], __M([0/*require*/,1/*exports*/,466/*vs/nls!vs/editor/contrib/snippet/snippetVariables*/,77/*vs/base/common/path*/,39/*vs/base/common/resources*/,151/*vs/editor/contrib/snippet/snippetParser*/,41/*vs/editor/common/modes/languageConfigurationRegistry*/,5/*vs/base/common/strings*/,606/*vs/platform/workspaces/common/workspaces*/,136/*vs/base/common/labels*/]), function (require, exports, nls, path, resources_1, snippetParser_1, languageConfigurationRegistry_1, strings_1, workspaces_1, labels_1) {
  116177. "use strict";
  116178. Object.defineProperty(exports, "__esModule", { value: true });
  116179. var CompositeSnippetVariableResolver = /** @class */ (function () {
  116180. function CompositeSnippetVariableResolver(_delegates) {
  116181. this._delegates = _delegates;
  116182. //
  116183. }
  116184. CompositeSnippetVariableResolver.prototype.resolve = function (variable) {
  116185. for (var _i = 0, _a = this._delegates; _i < _a.length; _i++) {
  116186. var delegate = _a[_i];
  116187. var value = delegate.resolve(variable);
  116188. if (value !== undefined) {
  116189. return value;
  116190. }
  116191. }
  116192. return undefined;
  116193. };
  116194. return CompositeSnippetVariableResolver;
  116195. }());
  116196. exports.CompositeSnippetVariableResolver = CompositeSnippetVariableResolver;
  116197. var SelectionBasedVariableResolver = /** @class */ (function () {
  116198. function SelectionBasedVariableResolver(_model, _selection) {
  116199. this._model = _model;
  116200. this._selection = _selection;
  116201. //
  116202. }
  116203. SelectionBasedVariableResolver.prototype.resolve = function (variable) {
  116204. var name = variable.name;
  116205. if (name === 'SELECTION' || name === 'TM_SELECTED_TEXT') {
  116206. var value = this._model.getValueInRange(this._selection) || undefined;
  116207. if (value && this._selection.startLineNumber !== this._selection.endLineNumber && variable.snippet) {
  116208. // Selection is a multiline string which we indentation we now
  116209. // need to adjust. We compare the indentation of this variable
  116210. // with the indentation at the editor position and add potential
  116211. // extra indentation to the value
  116212. var line = this._model.getLineContent(this._selection.startLineNumber);
  116213. var lineLeadingWhitespace = strings_1.getLeadingWhitespace(line, 0, this._selection.startColumn - 1);
  116214. var varLeadingWhitespace_1 = lineLeadingWhitespace;
  116215. variable.snippet.walk(function (marker) {
  116216. if (marker === variable) {
  116217. return false;
  116218. }
  116219. if (marker instanceof snippetParser_1.Text) {
  116220. varLeadingWhitespace_1 = strings_1.getLeadingWhitespace(marker.value.split(/\r\n|\r|\n/).pop());
  116221. }
  116222. return true;
  116223. });
  116224. var whitespaceCommonLength_1 = strings_1.commonPrefixLength(varLeadingWhitespace_1, lineLeadingWhitespace);
  116225. value = value.replace(/(\r\n|\r|\n)(.*)/g, function (m, newline, rest) { return "" + newline + varLeadingWhitespace_1.substr(whitespaceCommonLength_1) + rest; });
  116226. }
  116227. return value;
  116228. }
  116229. else if (name === 'TM_CURRENT_LINE') {
  116230. return this._model.getLineContent(this._selection.positionLineNumber);
  116231. }
  116232. else if (name === 'TM_CURRENT_WORD') {
  116233. var info = this._model.getWordAtPosition({
  116234. lineNumber: this._selection.positionLineNumber,
  116235. column: this._selection.positionColumn
  116236. });
  116237. return info && info.word || undefined;
  116238. }
  116239. else if (name === 'TM_LINE_INDEX') {
  116240. return String(this._selection.positionLineNumber - 1);
  116241. }
  116242. else if (name === 'TM_LINE_NUMBER') {
  116243. return String(this._selection.positionLineNumber);
  116244. }
  116245. return undefined;
  116246. };
  116247. return SelectionBasedVariableResolver;
  116248. }());
  116249. exports.SelectionBasedVariableResolver = SelectionBasedVariableResolver;
  116250. var ModelBasedVariableResolver = /** @class */ (function () {
  116251. function ModelBasedVariableResolver(_labelService, _model) {
  116252. this._labelService = _labelService;
  116253. this._model = _model;
  116254. //
  116255. }
  116256. ModelBasedVariableResolver.prototype.resolve = function (variable) {
  116257. var name = variable.name;
  116258. if (name === 'TM_FILENAME') {
  116259. return path.basename(this._model.uri.fsPath);
  116260. }
  116261. else if (name === 'TM_FILENAME_BASE') {
  116262. var name_1 = path.basename(this._model.uri.fsPath);
  116263. var idx = name_1.lastIndexOf('.');
  116264. if (idx <= 0) {
  116265. return name_1;
  116266. }
  116267. else {
  116268. return name_1.slice(0, idx);
  116269. }
  116270. }
  116271. else if (name === 'TM_DIRECTORY' && this._labelService) {
  116272. if (path.dirname(this._model.uri.fsPath) === '.') {
  116273. return '';
  116274. }
  116275. return this._labelService.getUriLabel(resources_1.dirname(this._model.uri));
  116276. }
  116277. else if (name === 'TM_FILEPATH' && this._labelService) {
  116278. return this._labelService.getUriLabel(this._model.uri);
  116279. }
  116280. return undefined;
  116281. };
  116282. return ModelBasedVariableResolver;
  116283. }());
  116284. exports.ModelBasedVariableResolver = ModelBasedVariableResolver;
  116285. var ClipboardBasedVariableResolver = /** @class */ (function () {
  116286. function ClipboardBasedVariableResolver(_readClipboardText, _selectionIdx, _selectionCount, _spread) {
  116287. this._readClipboardText = _readClipboardText;
  116288. this._selectionIdx = _selectionIdx;
  116289. this._selectionCount = _selectionCount;
  116290. this._spread = _spread;
  116291. //
  116292. }
  116293. ClipboardBasedVariableResolver.prototype.resolve = function (variable) {
  116294. if (variable.name !== 'CLIPBOARD') {
  116295. return undefined;
  116296. }
  116297. var clipboardText = this._readClipboardText();
  116298. if (!clipboardText) {
  116299. return undefined;
  116300. }
  116301. // `spread` is assigning each cursor a line of the clipboard
  116302. // text whenever there the line count equals the cursor count
  116303. // and when enabled
  116304. if (this._spread) {
  116305. var lines = clipboardText.split(/\r\n|\n|\r/).filter(function (s) { return !strings_1.isFalsyOrWhitespace(s); });
  116306. if (lines.length === this._selectionCount) {
  116307. return lines[this._selectionIdx];
  116308. }
  116309. }
  116310. return clipboardText;
  116311. };
  116312. return ClipboardBasedVariableResolver;
  116313. }());
  116314. exports.ClipboardBasedVariableResolver = ClipboardBasedVariableResolver;
  116315. var CommentBasedVariableResolver = /** @class */ (function () {
  116316. function CommentBasedVariableResolver(_model) {
  116317. this._model = _model;
  116318. //
  116319. }
  116320. CommentBasedVariableResolver.prototype.resolve = function (variable) {
  116321. var name = variable.name;
  116322. var language = this._model.getLanguageIdentifier();
  116323. var config = languageConfigurationRegistry_1.LanguageConfigurationRegistry.getComments(language.id);
  116324. if (!config) {
  116325. return undefined;
  116326. }
  116327. if (name === 'LINE_COMMENT') {
  116328. return config.lineCommentToken || undefined;
  116329. }
  116330. else if (name === 'BLOCK_COMMENT_START') {
  116331. return config.blockCommentStartToken || undefined;
  116332. }
  116333. else if (name === 'BLOCK_COMMENT_END') {
  116334. return config.blockCommentEndToken || undefined;
  116335. }
  116336. return undefined;
  116337. };
  116338. return CommentBasedVariableResolver;
  116339. }());
  116340. exports.CommentBasedVariableResolver = CommentBasedVariableResolver;
  116341. var TimeBasedVariableResolver = /** @class */ (function () {
  116342. function TimeBasedVariableResolver() {
  116343. }
  116344. TimeBasedVariableResolver.prototype.resolve = function (variable) {
  116345. var name = variable.name;
  116346. if (name === 'CURRENT_YEAR') {
  116347. return String(new Date().getFullYear());
  116348. }
  116349. else if (name === 'CURRENT_YEAR_SHORT') {
  116350. return String(new Date().getFullYear()).slice(-2);
  116351. }
  116352. else if (name === 'CURRENT_MONTH') {
  116353. return strings_1.pad((new Date().getMonth().valueOf() + 1), 2);
  116354. }
  116355. else if (name === 'CURRENT_DATE') {
  116356. return strings_1.pad(new Date().getDate().valueOf(), 2);
  116357. }
  116358. else if (name === 'CURRENT_HOUR') {
  116359. return strings_1.pad(new Date().getHours().valueOf(), 2);
  116360. }
  116361. else if (name === 'CURRENT_MINUTE') {
  116362. return strings_1.pad(new Date().getMinutes().valueOf(), 2);
  116363. }
  116364. else if (name === 'CURRENT_SECOND') {
  116365. return strings_1.pad(new Date().getSeconds().valueOf(), 2);
  116366. }
  116367. else if (name === 'CURRENT_DAY_NAME') {
  116368. return TimeBasedVariableResolver.dayNames[new Date().getDay()];
  116369. }
  116370. else if (name === 'CURRENT_DAY_NAME_SHORT') {
  116371. return TimeBasedVariableResolver.dayNamesShort[new Date().getDay()];
  116372. }
  116373. else if (name === 'CURRENT_MONTH_NAME') {
  116374. return TimeBasedVariableResolver.monthNames[new Date().getMonth()];
  116375. }
  116376. else if (name === 'CURRENT_MONTH_NAME_SHORT') {
  116377. return TimeBasedVariableResolver.monthNamesShort[new Date().getMonth()];
  116378. }
  116379. else if (name === 'CURRENT_SECONDS_UNIX') {
  116380. return String(Math.floor(Date.now() / 1000));
  116381. }
  116382. return undefined;
  116383. };
  116384. TimeBasedVariableResolver.dayNames = [nls.localize(0, null), nls.localize(1, null), nls.localize(2, null), nls.localize(3, null), nls.localize(4, null), nls.localize(5, null), nls.localize(6, null)];
  116385. TimeBasedVariableResolver.dayNamesShort = [nls.localize(7, null), nls.localize(8, null), nls.localize(9, null), nls.localize(10, null), nls.localize(11, null), nls.localize(12, null), nls.localize(13, null)];
  116386. TimeBasedVariableResolver.monthNames = [nls.localize(14, null), nls.localize(15, null), nls.localize(16, null), nls.localize(17, null), nls.localize(18, null), nls.localize(19, null), nls.localize(20, null), nls.localize(21, null), nls.localize(22, null), nls.localize(23, null), nls.localize(24, null), nls.localize(25, null)];
  116387. TimeBasedVariableResolver.monthNamesShort = [nls.localize(26, null), nls.localize(27, null), nls.localize(28, null), nls.localize(29, null), nls.localize(30, null), nls.localize(31, null), nls.localize(32, null), nls.localize(33, null), nls.localize(34, null), nls.localize(35, null), nls.localize(36, null), nls.localize(37, null)];
  116388. return TimeBasedVariableResolver;
  116389. }());
  116390. exports.TimeBasedVariableResolver = TimeBasedVariableResolver;
  116391. var WorkspaceBasedVariableResolver = /** @class */ (function () {
  116392. function WorkspaceBasedVariableResolver(_workspaceService) {
  116393. this._workspaceService = _workspaceService;
  116394. //
  116395. }
  116396. WorkspaceBasedVariableResolver.prototype.resolve = function (variable) {
  116397. if (!this._workspaceService) {
  116398. return undefined;
  116399. }
  116400. var workspaceIdentifier = workspaces_1.toWorkspaceIdentifier(this._workspaceService.getWorkspace());
  116401. if (!workspaceIdentifier) {
  116402. return undefined;
  116403. }
  116404. if (variable.name === 'WORKSPACE_NAME') {
  116405. return this._resolveWorkspaceName(workspaceIdentifier);
  116406. }
  116407. else if (variable.name === 'WORKSPACE_FOLDER') {
  116408. return this._resoveWorkspacePath(workspaceIdentifier);
  116409. }
  116410. return undefined;
  116411. };
  116412. WorkspaceBasedVariableResolver.prototype._resolveWorkspaceName = function (workspaceIdentifier) {
  116413. if (workspaces_1.isSingleFolderWorkspaceIdentifier(workspaceIdentifier)) {
  116414. return path.basename(workspaceIdentifier.path);
  116415. }
  116416. var filename = path.basename(workspaceIdentifier.configPath.path);
  116417. if (strings_1.endsWith(filename, workspaces_1.WORKSPACE_EXTENSION)) {
  116418. filename = filename.substr(0, filename.length - workspaces_1.WORKSPACE_EXTENSION.length - 1);
  116419. }
  116420. return filename;
  116421. };
  116422. WorkspaceBasedVariableResolver.prototype._resoveWorkspacePath = function (workspaceIdentifier) {
  116423. if (workspaces_1.isSingleFolderWorkspaceIdentifier(workspaceIdentifier)) {
  116424. return labels_1.normalizeDriveLetter(workspaceIdentifier.fsPath);
  116425. }
  116426. var filename = path.basename(workspaceIdentifier.configPath.path);
  116427. var folderpath = workspaceIdentifier.configPath.fsPath;
  116428. if (strings_1.endsWith(folderpath, filename)) {
  116429. folderpath = folderpath.substr(0, folderpath.length - filename.length - 1);
  116430. }
  116431. return (folderpath ? labels_1.normalizeDriveLetter(folderpath) : '/');
  116432. };
  116433. return WorkspaceBasedVariableResolver;
  116434. }());
  116435. exports.WorkspaceBasedVariableResolver = WorkspaceBasedVariableResolver;
  116436. var RandomBasedVariableResolver = /** @class */ (function () {
  116437. function RandomBasedVariableResolver() {
  116438. }
  116439. RandomBasedVariableResolver.prototype.resolve = function (variable) {
  116440. var name = variable.name;
  116441. if (name === 'RANDOM') {
  116442. return Math.random().toString().slice(-6);
  116443. }
  116444. else if (name === 'RANDOM_HEX') {
  116445. return Math.random().toString(16).slice(-6);
  116446. }
  116447. return undefined;
  116448. };
  116449. return RandomBasedVariableResolver;
  116450. }());
  116451. exports.RandomBasedVariableResolver = RandomBasedVariableResolver;
  116452. });
  116453. /*---------------------------------------------------------------------------------------------
  116454. * Copyright (c) Microsoft Corporation. All rights reserved.
  116455. * Licensed under the MIT License. See License.txt in the project root for license information.
  116456. *--------------------------------------------------------------------------------------------*/
  116457. define(__m[608/*vs/editor/contrib/snippet/snippetSession*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,2/*vs/base/common/lifecycle*/,5/*vs/base/common/strings*/,58/*vs/editor/common/core/editOperation*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,30/*vs/editor/common/model/textModel*/,162/*vs/platform/clipboard/common/clipboardService*/,171/*vs/platform/workspace/common/workspace*/,11/*vs/platform/instantiation/common/instantiation*/,151/*vs/editor/contrib/snippet/snippetParser*/,607/*vs/editor/contrib/snippet/snippetVariables*/,14/*vs/platform/theme/common/themeService*/,20/*vs/platform/theme/common/colorRegistry*/,116/*vs/platform/label/common/label*/,321/*vs/css!vs/editor/contrib/snippet/snippetSession*/]), function (require, exports, arrays_1, lifecycle_1, strings_1, editOperation_1, range_1, selection_1, textModel_1, clipboardService_1, workspace_1, instantiation_1, snippetParser_1, snippetVariables_1, themeService_1, colors, label_1) {
  116458. "use strict";
  116459. Object.defineProperty(exports, "__esModule", { value: true });
  116460. themeService_1.registerThemingParticipant(function (theme, collector) {
  116461. function getColorGraceful(name) {
  116462. var color = theme.getColor(name);
  116463. return color ? color.toString() : 'transparent';
  116464. }
  116465. collector.addRule(".monaco-editor .snippet-placeholder { background-color: " + getColorGraceful(colors.snippetTabstopHighlightBackground) + "; outline-color: " + getColorGraceful(colors.snippetTabstopHighlightBorder) + "; }");
  116466. collector.addRule(".monaco-editor .finish-snippet-placeholder { background-color: " + getColorGraceful(colors.snippetFinalTabstopHighlightBackground) + "; outline-color: " + getColorGraceful(colors.snippetFinalTabstopHighlightBorder) + "; }");
  116467. });
  116468. var OneSnippet = /** @class */ (function () {
  116469. function OneSnippet(editor, snippet, offset) {
  116470. this._nestingLevel = 1;
  116471. this._editor = editor;
  116472. this._snippet = snippet;
  116473. this._offset = offset;
  116474. this._placeholderGroups = arrays_1.groupBy(snippet.placeholders, snippetParser_1.Placeholder.compareByIndex);
  116475. this._placeholderGroupsIdx = -1;
  116476. }
  116477. OneSnippet.prototype.dispose = function () {
  116478. if (this._placeholderDecorations) {
  116479. var toRemove_1 = [];
  116480. this._placeholderDecorations.forEach(function (handle) { return toRemove_1.push(handle); });
  116481. this._editor.deltaDecorations(toRemove_1, []);
  116482. }
  116483. this._placeholderGroups.length = 0;
  116484. };
  116485. OneSnippet.prototype._initDecorations = function () {
  116486. var _this = this;
  116487. if (this._placeholderDecorations) {
  116488. // already initialized
  116489. return;
  116490. }
  116491. this._placeholderDecorations = new Map();
  116492. var model = this._editor.getModel();
  116493. this._editor.changeDecorations(function (accessor) {
  116494. // create a decoration for each placeholder
  116495. for (var _i = 0, _a = _this._snippet.placeholders; _i < _a.length; _i++) {
  116496. var placeholder = _a[_i];
  116497. var placeholderOffset = _this._snippet.offset(placeholder);
  116498. var placeholderLen = _this._snippet.fullLen(placeholder);
  116499. var range = range_1.Range.fromPositions(model.getPositionAt(_this._offset + placeholderOffset), model.getPositionAt(_this._offset + placeholderOffset + placeholderLen));
  116500. var options = placeholder.isFinalTabstop ? OneSnippet._decor.inactiveFinal : OneSnippet._decor.inactive;
  116501. var handle = accessor.addDecoration(range, options);
  116502. _this._placeholderDecorations.set(placeholder, handle);
  116503. }
  116504. });
  116505. };
  116506. OneSnippet.prototype.move = function (fwd) {
  116507. var _this = this;
  116508. if (!this._editor.hasModel()) {
  116509. return [];
  116510. }
  116511. this._initDecorations();
  116512. // Transform placeholder text if necessary
  116513. if (this._placeholderGroupsIdx >= 0) {
  116514. var operations = [];
  116515. for (var _i = 0, _a = this._placeholderGroups[this._placeholderGroupsIdx]; _i < _a.length; _i++) {
  116516. var placeholder = _a[_i];
  116517. // Check if the placeholder has a transformation
  116518. if (placeholder.transform) {
  116519. var id = this._placeholderDecorations.get(placeholder);
  116520. var range = this._editor.getModel().getDecorationRange(id);
  116521. var currentValue = this._editor.getModel().getValueInRange(range);
  116522. operations.push(editOperation_1.EditOperation.replaceMove(range, placeholder.transform.resolve(currentValue)));
  116523. }
  116524. }
  116525. if (operations.length > 0) {
  116526. this._editor.executeEdits('snippet.placeholderTransform', operations);
  116527. }
  116528. }
  116529. var couldSkipThisPlaceholder = false;
  116530. if (fwd === true && this._placeholderGroupsIdx < this._placeholderGroups.length - 1) {
  116531. this._placeholderGroupsIdx += 1;
  116532. couldSkipThisPlaceholder = true;
  116533. }
  116534. else if (fwd === false && this._placeholderGroupsIdx > 0) {
  116535. this._placeholderGroupsIdx -= 1;
  116536. couldSkipThisPlaceholder = true;
  116537. }
  116538. else {
  116539. // the selection of the current placeholder might
  116540. // not acurate any more -> simply restore it
  116541. }
  116542. var newSelections = this._editor.getModel().changeDecorations(function (accessor) {
  116543. var activePlaceholders = new Set();
  116544. // change stickiness to always grow when typing at its edges
  116545. // because these decorations represent the currently active
  116546. // tabstop.
  116547. // Special case #1: reaching the final tabstop
  116548. // Special case #2: placeholders enclosing active placeholders
  116549. var selections = [];
  116550. for (var _i = 0, _a = _this._placeholderGroups[_this._placeholderGroupsIdx]; _i < _a.length; _i++) {
  116551. var placeholder = _a[_i];
  116552. var id = _this._placeholderDecorations.get(placeholder);
  116553. var range = _this._editor.getModel().getDecorationRange(id);
  116554. selections.push(new selection_1.Selection(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn));
  116555. // consider to skip this placeholder index when the decoration
  116556. // range is empty but when the placeholder wasn't. that's a strong
  116557. // hint that the placeholder has been deleted. (all placeholder must match this)
  116558. couldSkipThisPlaceholder = couldSkipThisPlaceholder && _this._hasPlaceholderBeenCollapsed(placeholder);
  116559. accessor.changeDecorationOptions(id, placeholder.isFinalTabstop ? OneSnippet._decor.activeFinal : OneSnippet._decor.active);
  116560. activePlaceholders.add(placeholder);
  116561. for (var _b = 0, _c = _this._snippet.enclosingPlaceholders(placeholder); _b < _c.length; _b++) {
  116562. var enclosingPlaceholder = _c[_b];
  116563. var id_1 = _this._placeholderDecorations.get(enclosingPlaceholder);
  116564. accessor.changeDecorationOptions(id_1, enclosingPlaceholder.isFinalTabstop ? OneSnippet._decor.activeFinal : OneSnippet._decor.active);
  116565. activePlaceholders.add(enclosingPlaceholder);
  116566. }
  116567. }
  116568. // change stickness to never grow when typing at its edges
  116569. // so that in-active tabstops never grow
  116570. _this._placeholderDecorations.forEach(function (id, placeholder) {
  116571. if (!activePlaceholders.has(placeholder)) {
  116572. accessor.changeDecorationOptions(id, placeholder.isFinalTabstop ? OneSnippet._decor.inactiveFinal : OneSnippet._decor.inactive);
  116573. }
  116574. });
  116575. return selections;
  116576. });
  116577. return !couldSkipThisPlaceholder ? newSelections : this.move(fwd);
  116578. };
  116579. OneSnippet.prototype._hasPlaceholderBeenCollapsed = function (placeholder) {
  116580. // A placeholder is empty when it wasn't empty when authored but
  116581. // when its tracking decoration is empty. This also applies to all
  116582. // potential parent placeholders
  116583. var marker = placeholder;
  116584. while (marker) {
  116585. if (marker instanceof snippetParser_1.Placeholder) {
  116586. var id = this._placeholderDecorations.get(marker);
  116587. var range = this._editor.getModel().getDecorationRange(id);
  116588. if (range.isEmpty() && marker.toString().length > 0) {
  116589. return true;
  116590. }
  116591. }
  116592. marker = marker.parent;
  116593. }
  116594. return false;
  116595. };
  116596. Object.defineProperty(OneSnippet.prototype, "isAtFirstPlaceholder", {
  116597. get: function () {
  116598. return this._placeholderGroupsIdx <= 0 || this._placeholderGroups.length === 0;
  116599. },
  116600. enumerable: true,
  116601. configurable: true
  116602. });
  116603. Object.defineProperty(OneSnippet.prototype, "isAtLastPlaceholder", {
  116604. get: function () {
  116605. return this._placeholderGroupsIdx === this._placeholderGroups.length - 1;
  116606. },
  116607. enumerable: true,
  116608. configurable: true
  116609. });
  116610. Object.defineProperty(OneSnippet.prototype, "hasPlaceholder", {
  116611. get: function () {
  116612. return this._snippet.placeholders.length > 0;
  116613. },
  116614. enumerable: true,
  116615. configurable: true
  116616. });
  116617. OneSnippet.prototype.computePossibleSelections = function () {
  116618. var result = new Map();
  116619. for (var _i = 0, _a = this._placeholderGroups; _i < _a.length; _i++) {
  116620. var placeholdersWithEqualIndex = _a[_i];
  116621. var ranges = void 0;
  116622. for (var _b = 0, placeholdersWithEqualIndex_1 = placeholdersWithEqualIndex; _b < placeholdersWithEqualIndex_1.length; _b++) {
  116623. var placeholder = placeholdersWithEqualIndex_1[_b];
  116624. if (placeholder.isFinalTabstop) {
  116625. // ignore those
  116626. break;
  116627. }
  116628. if (!ranges) {
  116629. ranges = [];
  116630. result.set(placeholder.index, ranges);
  116631. }
  116632. var id = this._placeholderDecorations.get(placeholder);
  116633. var range = this._editor.getModel().getDecorationRange(id);
  116634. if (!range) {
  116635. // one of the placeholder lost its decoration and
  116636. // therefore we bail out and pretend the placeholder
  116637. // (with its mirrors) doesn't exist anymore.
  116638. result.delete(placeholder.index);
  116639. break;
  116640. }
  116641. ranges.push(range);
  116642. }
  116643. }
  116644. return result;
  116645. };
  116646. Object.defineProperty(OneSnippet.prototype, "choice", {
  116647. get: function () {
  116648. return this._placeholderGroups[this._placeholderGroupsIdx][0].choice;
  116649. },
  116650. enumerable: true,
  116651. configurable: true
  116652. });
  116653. OneSnippet.prototype.merge = function (others) {
  116654. var _this = this;
  116655. var model = this._editor.getModel();
  116656. this._nestingLevel *= 10;
  116657. this._editor.changeDecorations(function (accessor) {
  116658. // For each active placeholder take one snippet and merge it
  116659. // in that the placeholder (can be many for `$1foo$1foo`). Because
  116660. // everything is sorted by editor selection we can simply remove
  116661. // elements from the beginning of the array
  116662. for (var _i = 0, _a = _this._placeholderGroups[_this._placeholderGroupsIdx]; _i < _a.length; _i++) {
  116663. var placeholder = _a[_i];
  116664. var nested = others.shift();
  116665. console.assert(!nested._placeholderDecorations);
  116666. // Massage placeholder-indicies of the nested snippet to be
  116667. // sorted right after the insertion point. This ensures we move
  116668. // through the placeholders in the correct order
  116669. var indexLastPlaceholder = nested._snippet.placeholderInfo.last.index;
  116670. for (var _b = 0, _c = nested._snippet.placeholderInfo.all; _b < _c.length; _b++) {
  116671. var nestedPlaceholder = _c[_b];
  116672. if (nestedPlaceholder.isFinalTabstop) {
  116673. nestedPlaceholder.index = placeholder.index + ((indexLastPlaceholder + 1) / _this._nestingLevel);
  116674. }
  116675. else {
  116676. nestedPlaceholder.index = placeholder.index + (nestedPlaceholder.index / _this._nestingLevel);
  116677. }
  116678. }
  116679. _this._snippet.replace(placeholder, nested._snippet.children);
  116680. // Remove the placeholder at which position are inserting
  116681. // the snippet and also remove its decoration.
  116682. var id = _this._placeholderDecorations.get(placeholder);
  116683. accessor.removeDecoration(id);
  116684. _this._placeholderDecorations.delete(placeholder);
  116685. // For each *new* placeholder we create decoration to monitor
  116686. // how and if it grows/shrinks.
  116687. for (var _d = 0, _e = nested._snippet.placeholders; _d < _e.length; _d++) {
  116688. var placeholder_1 = _e[_d];
  116689. var placeholderOffset = nested._snippet.offset(placeholder_1);
  116690. var placeholderLen = nested._snippet.fullLen(placeholder_1);
  116691. var range = range_1.Range.fromPositions(model.getPositionAt(nested._offset + placeholderOffset), model.getPositionAt(nested._offset + placeholderOffset + placeholderLen));
  116692. var handle = accessor.addDecoration(range, OneSnippet._decor.inactive);
  116693. _this._placeholderDecorations.set(placeholder_1, handle);
  116694. }
  116695. }
  116696. // Last, re-create the placeholder groups by sorting placeholders by their index.
  116697. _this._placeholderGroups = arrays_1.groupBy(_this._snippet.placeholders, snippetParser_1.Placeholder.compareByIndex);
  116698. });
  116699. };
  116700. OneSnippet._decor = {
  116701. active: textModel_1.ModelDecorationOptions.register({ stickiness: 0 /* AlwaysGrowsWhenTypingAtEdges */, className: 'snippet-placeholder' }),
  116702. inactive: textModel_1.ModelDecorationOptions.register({ stickiness: 1 /* NeverGrowsWhenTypingAtEdges */, className: 'snippet-placeholder' }),
  116703. activeFinal: textModel_1.ModelDecorationOptions.register({ stickiness: 1 /* NeverGrowsWhenTypingAtEdges */, className: 'finish-snippet-placeholder' }),
  116704. inactiveFinal: textModel_1.ModelDecorationOptions.register({ stickiness: 1 /* NeverGrowsWhenTypingAtEdges */, className: 'finish-snippet-placeholder' }),
  116705. };
  116706. return OneSnippet;
  116707. }());
  116708. exports.OneSnippet = OneSnippet;
  116709. var _defaultOptions = {
  116710. overwriteBefore: 0,
  116711. overwriteAfter: 0,
  116712. adjustWhitespace: true,
  116713. clipboardText: undefined
  116714. };
  116715. var SnippetSession = /** @class */ (function () {
  116716. function SnippetSession(editor, template, options) {
  116717. if (options === void 0) { options = _defaultOptions; }
  116718. this._templateMerges = [];
  116719. this._snippets = [];
  116720. this._editor = editor;
  116721. this._template = template;
  116722. this._options = options;
  116723. }
  116724. SnippetSession.adjustWhitespace = function (model, position, snippet, adjustIndentation, adjustNewlines) {
  116725. var line = model.getLineContent(position.lineNumber);
  116726. var lineLeadingWhitespace = strings_1.getLeadingWhitespace(line, 0, position.column - 1);
  116727. snippet.walk(function (marker) {
  116728. if (marker instanceof snippetParser_1.Text && !(marker.parent instanceof snippetParser_1.Choice)) {
  116729. // adjust indentation of text markers, except for choise elements
  116730. // which get adjusted when being selected
  116731. var lines = marker.value.split(/\r\n|\r|\n/);
  116732. if (adjustIndentation) {
  116733. for (var i = 1; i < lines.length; i++) {
  116734. var templateLeadingWhitespace = strings_1.getLeadingWhitespace(lines[i]);
  116735. lines[i] = model.normalizeIndentation(lineLeadingWhitespace + templateLeadingWhitespace) + lines[i].substr(templateLeadingWhitespace.length);
  116736. }
  116737. }
  116738. if (adjustNewlines) {
  116739. var newValue = lines.join(model.getEOL());
  116740. if (newValue !== marker.value) {
  116741. marker.parent.replace(marker, [new snippetParser_1.Text(newValue)]);
  116742. }
  116743. }
  116744. }
  116745. return true;
  116746. });
  116747. };
  116748. SnippetSession.adjustSelection = function (model, selection, overwriteBefore, overwriteAfter) {
  116749. if (overwriteBefore !== 0 || overwriteAfter !== 0) {
  116750. // overwrite[Before|After] is compute using the position, not the whole
  116751. // selection. therefore we adjust the selection around that position
  116752. var positionLineNumber = selection.positionLineNumber, positionColumn = selection.positionColumn;
  116753. var positionColumnBefore = positionColumn - overwriteBefore;
  116754. var positionColumnAfter = positionColumn + overwriteAfter;
  116755. var range = model.validateRange({
  116756. startLineNumber: positionLineNumber,
  116757. startColumn: positionColumnBefore,
  116758. endLineNumber: positionLineNumber,
  116759. endColumn: positionColumnAfter
  116760. });
  116761. selection = selection_1.Selection.createWithDirection(range.startLineNumber, range.startColumn, range.endLineNumber, range.endColumn, selection.getDirection());
  116762. }
  116763. return selection;
  116764. };
  116765. SnippetSession.createEditsAndSnippets = function (editor, template, overwriteBefore, overwriteAfter, enforceFinalTabstop, adjustWhitespace, clipboardText) {
  116766. var edits = [];
  116767. var snippets = [];
  116768. if (!editor.hasModel()) {
  116769. return { edits: edits, snippets: snippets };
  116770. }
  116771. var model = editor.getModel();
  116772. var workspaceService = editor.invokeWithinContext(function (accessor) { return accessor.get(workspace_1.IWorkspaceContextService, instantiation_1.optional); });
  116773. var modelBasedVariableResolver = editor.invokeWithinContext(function (accessor) { return new snippetVariables_1.ModelBasedVariableResolver(accessor.get(label_1.ILabelService, instantiation_1.optional), model); });
  116774. var clipboardService = editor.invokeWithinContext(function (accessor) { return accessor.get(clipboardService_1.IClipboardService, instantiation_1.optional); });
  116775. var readClipboardText = function () { return clipboardText || clipboardService && clipboardService.readTextSync(); };
  116776. var delta = 0;
  116777. // know what text the overwrite[Before|After] extensions
  116778. // of the primary curser have selected because only when
  116779. // secondary selections extend to the same text we can grow them
  116780. var firstBeforeText = model.getValueInRange(SnippetSession.adjustSelection(model, editor.getSelection(), overwriteBefore, 0));
  116781. var firstAfterText = model.getValueInRange(SnippetSession.adjustSelection(model, editor.getSelection(), 0, overwriteAfter));
  116782. // remember the first non-whitespace column to decide if
  116783. // `keepWhitespace` should be overruled for secondary selections
  116784. var firstLineFirstNonWhitespace = model.getLineFirstNonWhitespaceColumn(editor.getSelection().positionLineNumber);
  116785. // sort selections by their start position but remeber
  116786. // the original index. that allows you to create correct
  116787. // offset-based selection logic without changing the
  116788. // primary selection
  116789. var indexedSelections = editor.getSelections()
  116790. .map(function (selection, idx) { return ({ selection: selection, idx: idx }); })
  116791. .sort(function (a, b) { return range_1.Range.compareRangesUsingStarts(a.selection, b.selection); });
  116792. for (var _i = 0, indexedSelections_1 = indexedSelections; _i < indexedSelections_1.length; _i++) {
  116793. var _a = indexedSelections_1[_i], selection = _a.selection, idx = _a.idx;
  116794. // extend selection with the `overwriteBefore` and `overwriteAfter` and then
  116795. // compare if this matches the extensions of the primary selection
  116796. var extensionBefore = SnippetSession.adjustSelection(model, selection, overwriteBefore, 0);
  116797. var extensionAfter = SnippetSession.adjustSelection(model, selection, 0, overwriteAfter);
  116798. if (firstBeforeText !== model.getValueInRange(extensionBefore)) {
  116799. extensionBefore = selection;
  116800. }
  116801. if (firstAfterText !== model.getValueInRange(extensionAfter)) {
  116802. extensionAfter = selection;
  116803. }
  116804. // merge the before and after selection into one
  116805. var snippetSelection = selection
  116806. .setStartPosition(extensionBefore.startLineNumber, extensionBefore.startColumn)
  116807. .setEndPosition(extensionAfter.endLineNumber, extensionAfter.endColumn);
  116808. var snippet = new snippetParser_1.SnippetParser().parse(template, true, enforceFinalTabstop);
  116809. // adjust the template string to match the indentation and
  116810. // whitespace rules of this insert location (can be different for each cursor)
  116811. // happens when being asked for (default) or when this is a secondary
  116812. // cursor and the leading whitespace is different
  116813. var start = snippetSelection.getStartPosition();
  116814. SnippetSession.adjustWhitespace(model, start, snippet, adjustWhitespace || (idx > 0 && firstLineFirstNonWhitespace !== model.getLineFirstNonWhitespaceColumn(selection.positionLineNumber)), true);
  116815. snippet.resolveVariables(new snippetVariables_1.CompositeSnippetVariableResolver([
  116816. modelBasedVariableResolver,
  116817. new snippetVariables_1.ClipboardBasedVariableResolver(readClipboardText, idx, indexedSelections.length, editor.getOption(60 /* multiCursorPaste */) === 'spread'),
  116818. new snippetVariables_1.SelectionBasedVariableResolver(model, selection),
  116819. new snippetVariables_1.CommentBasedVariableResolver(model),
  116820. new snippetVariables_1.TimeBasedVariableResolver,
  116821. new snippetVariables_1.WorkspaceBasedVariableResolver(workspaceService),
  116822. new snippetVariables_1.RandomBasedVariableResolver,
  116823. ]));
  116824. var offset = model.getOffsetAt(start) + delta;
  116825. delta += snippet.toString().length - model.getValueLengthInRange(snippetSelection);
  116826. // store snippets with the index of their originating selection.
  116827. // that ensures the primiary cursor stays primary despite not being
  116828. // the one with lowest start position
  116829. edits[idx] = editOperation_1.EditOperation.replace(snippetSelection, snippet.toString());
  116830. snippets[idx] = new OneSnippet(editor, snippet, offset);
  116831. }
  116832. return { edits: edits, snippets: snippets };
  116833. };
  116834. SnippetSession.prototype.dispose = function () {
  116835. lifecycle_1.dispose(this._snippets);
  116836. };
  116837. SnippetSession.prototype._logInfo = function () {
  116838. return "template=\"" + this._template + "\", merged_templates=\"" + this._templateMerges.join(' -> ') + "\"";
  116839. };
  116840. SnippetSession.prototype.insert = function () {
  116841. var _this = this;
  116842. if (!this._editor.hasModel()) {
  116843. return;
  116844. }
  116845. // make insert edit and start with first selections
  116846. var _a = SnippetSession.createEditsAndSnippets(this._editor, this._template, this._options.overwriteBefore, this._options.overwriteAfter, false, this._options.adjustWhitespace, this._options.clipboardText), edits = _a.edits, snippets = _a.snippets;
  116847. this._snippets = snippets;
  116848. this._editor.executeEdits('snippet', edits, function (undoEdits) {
  116849. if (_this._snippets[0].hasPlaceholder) {
  116850. return _this._move(true);
  116851. }
  116852. else {
  116853. return undoEdits.map(function (edit) { return selection_1.Selection.fromPositions(edit.range.getEndPosition()); });
  116854. }
  116855. });
  116856. this._editor.revealRange(this._editor.getSelections()[0]);
  116857. };
  116858. SnippetSession.prototype.merge = function (template, options) {
  116859. var _this = this;
  116860. if (options === void 0) { options = _defaultOptions; }
  116861. if (!this._editor.hasModel()) {
  116862. return;
  116863. }
  116864. this._templateMerges.push([this._snippets[0]._nestingLevel, this._snippets[0]._placeholderGroupsIdx, template]);
  116865. var _a = SnippetSession.createEditsAndSnippets(this._editor, template, options.overwriteBefore, options.overwriteAfter, true, options.adjustWhitespace, options.clipboardText), edits = _a.edits, snippets = _a.snippets;
  116866. this._editor.executeEdits('snippet', edits, function (undoEdits) {
  116867. for (var _i = 0, _a = _this._snippets; _i < _a.length; _i++) {
  116868. var snippet = _a[_i];
  116869. snippet.merge(snippets);
  116870. }
  116871. console.assert(snippets.length === 0);
  116872. if (_this._snippets[0].hasPlaceholder) {
  116873. return _this._move(undefined);
  116874. }
  116875. else {
  116876. return undoEdits.map(function (edit) { return selection_1.Selection.fromPositions(edit.range.getEndPosition()); });
  116877. }
  116878. });
  116879. };
  116880. SnippetSession.prototype.next = function () {
  116881. var newSelections = this._move(true);
  116882. this._editor.setSelections(newSelections);
  116883. this._editor.revealPositionInCenterIfOutsideViewport(newSelections[0].getPosition());
  116884. };
  116885. SnippetSession.prototype.prev = function () {
  116886. var newSelections = this._move(false);
  116887. this._editor.setSelections(newSelections);
  116888. this._editor.revealPositionInCenterIfOutsideViewport(newSelections[0].getPosition());
  116889. };
  116890. SnippetSession.prototype._move = function (fwd) {
  116891. var selections = [];
  116892. for (var _i = 0, _a = this._snippets; _i < _a.length; _i++) {
  116893. var snippet = _a[_i];
  116894. var oneSelection = snippet.move(fwd);
  116895. selections.push.apply(selections, oneSelection);
  116896. }
  116897. return selections;
  116898. };
  116899. Object.defineProperty(SnippetSession.prototype, "isAtFirstPlaceholder", {
  116900. get: function () {
  116901. return this._snippets[0].isAtFirstPlaceholder;
  116902. },
  116903. enumerable: true,
  116904. configurable: true
  116905. });
  116906. Object.defineProperty(SnippetSession.prototype, "isAtLastPlaceholder", {
  116907. get: function () {
  116908. return this._snippets[0].isAtLastPlaceholder;
  116909. },
  116910. enumerable: true,
  116911. configurable: true
  116912. });
  116913. Object.defineProperty(SnippetSession.prototype, "hasPlaceholder", {
  116914. get: function () {
  116915. return this._snippets[0].hasPlaceholder;
  116916. },
  116917. enumerable: true,
  116918. configurable: true
  116919. });
  116920. Object.defineProperty(SnippetSession.prototype, "choice", {
  116921. get: function () {
  116922. return this._snippets[0].choice;
  116923. },
  116924. enumerable: true,
  116925. configurable: true
  116926. });
  116927. SnippetSession.prototype.isSelectionWithinPlaceholders = function () {
  116928. if (!this.hasPlaceholder) {
  116929. return false;
  116930. }
  116931. var selections = this._editor.getSelections();
  116932. if (selections.length < this._snippets.length) {
  116933. // this means we started snippet mode with N
  116934. // selections and have M (N > M) selections.
  116935. // So one snippet is without selection -> cancel
  116936. return false;
  116937. }
  116938. var allPossibleSelections = new Map();
  116939. var _loop_1 = function (snippet) {
  116940. var possibleSelections = snippet.computePossibleSelections();
  116941. // for the first snippet find the placeholder (and its ranges)
  116942. // that contain at least one selection. for all remaining snippets
  116943. // the same placeholder (and their ranges) must be used.
  116944. if (allPossibleSelections.size === 0) {
  116945. possibleSelections.forEach(function (ranges, index) {
  116946. ranges.sort(range_1.Range.compareRangesUsingStarts);
  116947. for (var _i = 0, selections_1 = selections; _i < selections_1.length; _i++) {
  116948. var selection = selections_1[_i];
  116949. if (ranges[0].containsRange(selection)) {
  116950. allPossibleSelections.set(index, []);
  116951. break;
  116952. }
  116953. }
  116954. });
  116955. }
  116956. if (allPossibleSelections.size === 0) {
  116957. return { value: false };
  116958. }
  116959. // add selections from 'this' snippet so that we know all
  116960. // selections for this placeholder
  116961. allPossibleSelections.forEach(function (array, index) {
  116962. array.push.apply(array, possibleSelections.get(index));
  116963. });
  116964. };
  116965. for (var _i = 0, _a = this._snippets; _i < _a.length; _i++) {
  116966. var snippet = _a[_i];
  116967. var state_1 = _loop_1(snippet);
  116968. if (typeof state_1 === "object")
  116969. return state_1.value;
  116970. }
  116971. // sort selections (and later placeholder-ranges). then walk both
  116972. // arrays and make sure the placeholder-ranges contain the corresponding
  116973. // selection
  116974. selections.sort(range_1.Range.compareRangesUsingStarts);
  116975. allPossibleSelections.forEach(function (ranges, index) {
  116976. if (ranges.length !== selections.length) {
  116977. allPossibleSelections.delete(index);
  116978. return;
  116979. }
  116980. ranges.sort(range_1.Range.compareRangesUsingStarts);
  116981. for (var i = 0; i < ranges.length; i++) {
  116982. if (!ranges[i].containsRange(selections[i])) {
  116983. allPossibleSelections.delete(index);
  116984. return;
  116985. }
  116986. }
  116987. });
  116988. // from all possible selections we have deleted those
  116989. // that don't match with the current selection. if we don't
  116990. // have any left, we don't have a selection anymore
  116991. return allPossibleSelections.size > 0;
  116992. };
  116993. return SnippetSession;
  116994. }());
  116995. exports.SnippetSession = SnippetSession;
  116996. });
  116997. /*---------------------------------------------------------------------------------------------
  116998. * Copyright (c) Microsoft Corporation. All rights reserved.
  116999. * Licensed under the MIT License. See License.txt in the project root for license information.
  117000. *--------------------------------------------------------------------------------------------*/
  117001. define(__m[173/*vs/editor/contrib/snippet/snippetController2*/], __M([0/*require*/,1/*exports*/,2/*vs/base/common/lifecycle*/,5/*vs/base/common/strings*/,12/*vs/editor/browser/editorExtensions*/,3/*vs/editor/common/core/range*/,22/*vs/editor/common/core/selection*/,23/*vs/editor/common/editorContextKeys*/,120/*vs/editor/contrib/suggest/suggest*/,18/*vs/platform/contextkey/common/contextkey*/,95/*vs/platform/log/common/log*/,608/*vs/editor/contrib/snippet/snippetSession*/]), function (require, exports, lifecycle_1, strings_1, editorExtensions_1, range_1, selection_1, editorContextKeys_1, suggest_1, contextkey_1, log_1, snippetSession_1) {
  117002. "use strict";
  117003. Object.defineProperty(exports, "__esModule", { value: true });
  117004. var _defaultOptions = {
  117005. overwriteBefore: 0,
  117006. overwriteAfter: 0,
  117007. undoStopBefore: true,
  117008. undoStopAfter: true,
  117009. adjustWhitespace: true,
  117010. clipboardText: undefined
  117011. };
  117012. var SnippetController2 = /** @class */ (function () {
  117013. function SnippetController2(_editor, _logService, contextKeyService) {
  117014. this._editor = _editor;
  117015. this._logService = _logService;
  117016. this._snippetListener = new lifecycle_1.DisposableStore();
  117017. this._modelVersionId = -1;
  117018. this._inSnippet = SnippetController2.InSnippetMode.bindTo(contextKeyService);
  117019. this._hasNextTabstop = SnippetController2.HasNextTabstop.bindTo(contextKeyService);
  117020. this._hasPrevTabstop = SnippetController2.HasPrevTabstop.bindTo(contextKeyService);
  117021. }
  117022. SnippetController2.get = function (editor) {
  117023. return editor.getContribution(SnippetController2.ID);
  117024. };
  117025. SnippetController2.prototype.dispose = function () {
  117026. this._inSnippet.reset();
  117027. this._hasPrevTabstop.reset();
  117028. this._hasNextTabstop.reset();
  117029. lifecycle_1.dispose(this._session);
  117030. this._snippetListener.dispose();
  117031. };
  117032. SnippetController2.prototype.insert = function (template, opts) {
  117033. // this is here to find out more about the yet-not-understood
  117034. // error that sometimes happens when we fail to inserted a nested
  117035. // snippet
  117036. try {
  117037. this._doInsert(template, typeof opts === 'undefined' ? _defaultOptions : __assign(__assign({}, _defaultOptions), opts));
  117038. }
  117039. catch (e) {
  117040. this.cancel();
  117041. this._logService.error(e);
  117042. this._logService.error('snippet_error');
  117043. this._logService.error('insert_template=', template);
  117044. this._logService.error('existing_template=', this._session ? this._session._logInfo() : '<no_session>');
  117045. }
  117046. };
  117047. SnippetController2.prototype._doInsert = function (template, opts) {
  117048. var _this = this;
  117049. if (!this._editor.hasModel()) {
  117050. return;
  117051. }
  117052. // don't listen while inserting the snippet
  117053. // as that is the inflight state causing cancelation
  117054. this._snippetListener.clear();
  117055. if (opts.undoStopBefore) {
  117056. this._editor.getModel().pushStackElement();
  117057. }
  117058. if (!this._session) {
  117059. this._modelVersionId = this._editor.getModel().getAlternativeVersionId();
  117060. this._session = new snippetSession_1.SnippetSession(this._editor, template, opts);
  117061. this._session.insert();
  117062. }
  117063. else {
  117064. this._session.merge(template, opts);
  117065. }
  117066. if (opts.undoStopAfter) {
  117067. this._editor.getModel().pushStackElement();
  117068. }
  117069. this._updateState();
  117070. this._snippetListener.add(this._editor.onDidChangeModelContent(function (e) { return e.isFlush && _this.cancel(); }));
  117071. this._snippetListener.add(this._editor.onDidChangeModel(function () { return _this.cancel(); }));
  117072. this._snippetListener.add(this._editor.onDidChangeCursorSelection(function () { return _this._updateState(); }));
  117073. };
  117074. SnippetController2.prototype._updateState = function () {
  117075. if (!this._session || !this._editor.hasModel()) {
  117076. // canceled in the meanwhile
  117077. return;
  117078. }
  117079. if (this._modelVersionId === this._editor.getModel().getAlternativeVersionId()) {
  117080. // undo until the 'before' state happened
  117081. // and makes use cancel snippet mode
  117082. return this.cancel();
  117083. }
  117084. if (!this._session.hasPlaceholder) {
  117085. // don't listen for selection changes and don't
  117086. // update context keys when the snippet is plain text
  117087. return this.cancel();
  117088. }
  117089. if (this._session.isAtLastPlaceholder || !this._session.isSelectionWithinPlaceholders()) {
  117090. return this.cancel();
  117091. }
  117092. this._inSnippet.set(true);
  117093. this._hasPrevTabstop.set(!this._session.isAtFirstPlaceholder);
  117094. this._hasNextTabstop.set(!this._session.isAtLastPlaceholder);
  117095. this._handleChoice();
  117096. };
  117097. SnippetController2.prototype._handleChoice = function () {
  117098. var _this = this;
  117099. if (!this._session || !this._editor.hasModel()) {
  117100. this._currentChoice = undefined;
  117101. return;
  117102. }
  117103. var choice = this._session.choice;
  117104. if (!choice) {
  117105. this._currentChoice = undefined;
  117106. return;
  117107. }
  117108. if (this._currentChoice !== choice) {
  117109. this._currentChoice = choice;
  117110. this._editor.setSelections(this._editor.getSelections()
  117111. .map(function (s) { return selection_1.Selection.fromPositions(s.getStartPosition()); }));
  117112. var first_1 = choice.options[0];
  117113. suggest_1.showSimpleSuggestions(this._editor, choice.options.map(function (option, i) {
  117114. // let before = choice.options.slice(0, i);
  117115. // let after = choice.options.slice(i);
  117116. return {
  117117. kind: 13 /* Value */,
  117118. label: option.value,
  117119. insertText: option.value,
  117120. // insertText: `\${1|${after.concat(before).join(',')}|}$0`,
  117121. // snippetType: 'textmate',
  117122. sortText: strings_1.repeat('a', i + 1),
  117123. range: range_1.Range.fromPositions(_this._editor.getPosition(), _this._editor.getPosition().delta(0, first_1.value.length))
  117124. };
  117125. }));
  117126. }
  117127. };
  117128. SnippetController2.prototype.finish = function () {
  117129. while (this._inSnippet.get()) {
  117130. this.next();
  117131. }
  117132. };
  117133. SnippetController2.prototype.cancel = function (resetSelection) {
  117134. if (resetSelection === void 0) { resetSelection = false; }
  117135. this._inSnippet.reset();
  117136. this._hasPrevTabstop.reset();
  117137. this._hasNextTabstop.reset();
  117138. this._snippetListener.clear();
  117139. lifecycle_1.dispose(this._session);
  117140. this._session = undefined;
  117141. this._modelVersionId = -1;
  117142. if (resetSelection) {
  117143. // reset selection to the primary cursor when being asked
  117144. // for. this happens when explicitly cancelling snippet mode,
  117145. // e.g. when pressing ESC
  117146. this._editor.setSelections([this._editor.getSelection()]);
  117147. }
  117148. };
  117149. SnippetController2.prototype.prev = function () {
  117150. if (this._session) {
  117151. this._session.prev();
  117152. }
  117153. this._updateState();
  117154. };
  117155. SnippetController2.prototype.next = function () {
  117156. if (this._session) {
  117157. this._session.next();
  117158. }
  117159. this._updateState();
  117160. };
  117161. SnippetController2.prototype.isInSnippet = function () {
  117162. return Boolean(this._inSnippet.get());
  117163. };
  117164. SnippetController2.ID = 'snippetController2';
  117165. SnippetController2.InSnippetMode = new contextkey_1.RawContextKey('inSnippetMode', false);
  117166. SnippetController2.HasNextTabstop = new contextkey_1.RawContextKey('hasNextTabstop', false);
  117167. SnippetController2.HasPrevTabstop = new contextkey_1.RawContextKey('hasPrevTabstop', false);
  117168. SnippetController2 = __decorate([
  117169. __param(1, log_1.ILogService),
  117170. __param(2, contextkey_1.IContextKeyService)
  117171. ], SnippetController2);
  117172. return SnippetController2;
  117173. }());
  117174. exports.SnippetController2 = SnippetController2;
  117175. editorExtensions_1.registerEditorContribution(SnippetController2.ID, SnippetController2);
  117176. var CommandCtor = editorExtensions_1.EditorCommand.bindToContribution(SnippetController2.get);
  117177. editorExtensions_1.registerEditorCommand(new CommandCtor({
  117178. id: 'jumpToNextSnippetPlaceholder',
  117179. precondition: contextkey_1.ContextKeyExpr.and(SnippetController2.InSnippetMode, SnippetController2.HasNextTabstop),
  117180. handler: function (ctrl) { return ctrl.next(); },
  117181. kbOpts: {
  117182. weight: 100 /* EditorContrib */ + 30,
  117183. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  117184. primary: 2 /* Tab */
  117185. }
  117186. }));
  117187. editorExtensions_1.registerEditorCommand(new CommandCtor({
  117188. id: 'jumpToPrevSnippetPlaceholder',
  117189. precondition: contextkey_1.ContextKeyExpr.and(SnippetController2.InSnippetMode, SnippetController2.HasPrevTabstop),
  117190. handler: function (ctrl) { return ctrl.prev(); },
  117191. kbOpts: {
  117192. weight: 100 /* EditorContrib */ + 30,
  117193. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  117194. primary: 1024 /* Shift */ | 2 /* Tab */
  117195. }
  117196. }));
  117197. editorExtensions_1.registerEditorCommand(new CommandCtor({
  117198. id: 'leaveSnippet',
  117199. precondition: SnippetController2.InSnippetMode,
  117200. handler: function (ctrl) { return ctrl.cancel(true); },
  117201. kbOpts: {
  117202. weight: 100 /* EditorContrib */ + 30,
  117203. kbExpr: editorContextKeys_1.EditorContextKeys.editorTextFocus,
  117204. primary: 9 /* Escape */,
  117205. secondary: [1024 /* Shift */ | 9 /* Escape */]
  117206. }
  117207. }));
  117208. editorExtensions_1.registerEditorCommand(new CommandCtor({
  117209. id: 'acceptSnippet',
  117210. precondition: SnippetController2.InSnippetMode,
  117211. handler: function (ctrl) { return ctrl.finish(); },
  117212. }));
  117213. });
  117214. /*---------------------------------------------------------------------------------------------
  117215. * Copyright (c) Microsoft Corporation. All rights reserved.
  117216. * Licensed under the MIT License. See License.txt in the project root for license information.
  117217. *--------------------------------------------------------------------------------------------*/
  117218. define(__m[609/*vs/editor/contrib/suggest/suggestModel*/], __M([0/*require*/,1/*exports*/,19/*vs/base/common/arrays*/,15/*vs/base/common/async*/,10/*vs/base/common/errors*/,4/*vs/base/common/event*/,2/*vs/base/common/lifecycle*/,22/*vs/editor/common/core/selection*/,17/*vs/editor/common/modes*/,389/*vs/editor/contrib/suggest/completionModel*/,120/*vs/editor/contrib/suggest/suggest*/,173/*vs/editor/contrib/snippet/snippetController2*/,26/*vs/base/common/cancellation*/,392/*vs/editor/contrib/suggest/wordDistance*/,5/*vs/base/common/strings*/]), function (require, exports, arrays_1, async_1, errors_1, event_1, lifecycle_1, selection_1, modes_1, completionModel_1, suggest_1, snippetController2_1, cancellation_1, wordDistance_1, strings_1) {
  117219. "use strict";
  117220. Object.defineProperty(exports, "__esModule", { value: true });
  117221. var LineContext = /** @class */ (function () {
  117222. function LineContext(model, position, auto, shy) {
  117223. this.leadingLineContent = model.getLineContent(position.lineNumber).substr(0, position.column - 1);
  117224. this.leadingWord = model.getWordUntilPosition(position);
  117225. this.lineNumber = position.lineNumber;
  117226. this.column = position.column;
  117227. this.auto = auto;
  117228. this.shy = shy;
  117229. }
  117230. LineContext.shouldAutoTrigger = function (editor) {
  117231. if (!editor.hasModel()) {
  117232. return false;
  117233. }
  117234. var model = editor.getModel();
  117235. var pos = editor.getPosition();
  117236. model.tokenizeIfCheap(pos.lineNumber);
  117237. var word = model.getWordAtPosition(pos);
  117238. if (!word) {
  117239. return false;
  117240. }
  117241. if (word.endColumn !== pos.column) {
  117242. return false;
  117243. }
  117244. if (!isNaN(Number(word.word))) {
  117245. return false;
  117246. }
  117247. return true;
  117248. };
  117249. return LineContext;
  117250. }());
  117251. exports.LineContext = LineContext;
  117252. var SuggestModel = /** @class */ (function () {
  117253. function SuggestModel(_editor, _editorWorker) {
  117254. var _this = this;
  117255. this._editor = _editor;
  117256. this._editorWorker = _editorWorker;
  117257. this._toDispose = new lifecycle_1.DisposableStore();
  117258. this._quickSuggestDelay = 10;
  117259. this._triggerCharacterListener = new lifecycle_1.DisposableStore();
  117260. this._triggerQuickSuggest = new async_1.TimeoutTimer();
  117261. this._state = 0 /* Idle */;
  117262. this._completionDisposables = new lifecycle_1.DisposableStore();
  117263. this._onDidCancel = new event_1.Emitter();
  117264. this._onDidTrigger = new event_1.Emitter();
  117265. this._onDidSuggest = new event_1.Emitter();
  117266. this.onDidCancel = this._onDidCancel.event;
  117267. this.onDidTrigger = this._onDidTrigger.event;
  117268. this.onDidSuggest = this._onDidSuggest.event;
  117269. this._currentSelection = this._editor.getSelection() || new selection_1.Selection(1, 1, 1, 1);
  117270. // wire up various listeners
  117271. this._toDispose.add(this._editor.onDidChangeModel(function () {
  117272. _this._updateTriggerCharacters();
  117273. _this.cancel();
  117274. }));
  117275. this._toDispose.add(this._editor.onDidChangeModelLanguage(function () {
  117276. _this._updateTriggerCharacters();
  117277. _this.cancel();
  117278. }));
  117279. this._toDispose.add(this._editor.onDidChangeConfiguration(function () {
  117280. _this._updateTriggerCharacters();
  117281. _this._updateQuickSuggest();
  117282. }));
  117283. this._toDispose.add(modes_1.CompletionProviderRegistry.onDidChange(function () {
  117284. _this._updateTriggerCharacters();
  117285. _this._updateActiveSuggestSession();
  117286. }));
  117287. this._toDispose.add(this._editor.onDidChangeCursorSelection(function (e) {
  117288. _this._onCursorChange(e);
  117289. }));
  117290. var editorIsComposing = false;
  117291. this._toDispose.add(this._editor.onDidCompositionStart(function () {
  117292. editorIsComposing = true;
  117293. }));
  117294. this._toDispose.add(this._editor.onDidCompositionEnd(function () {
  117295. // refilter when composition ends
  117296. editorIsComposing = false;
  117297. _this._refilterCompletionItems();
  117298. }));
  117299. this._toDispose.add(this._editor.onDidChangeModelContent(function () {
  117300. // only filter completions when the editor isn't
  117301. // composing a character, e.g. ¨ + u makes ü but just
  117302. // ¨ cannot be used for filtering
  117303. if (!editorIsComposing) {
  117304. _this._refilterCompletionItems();
  117305. }
  117306. }));
  117307. this._updateTriggerCharacters();
  117308. this._updateQuickSuggest();
  117309. }
  117310. SuggestModel.prototype.dispose = function () {
  117311. lifecycle_1.dispose(this._triggerCharacterListener);
  117312. lifecycle_1.dispose([this._onDidCancel, this._onDidSuggest, this._onDidTrigger, this._triggerQuickSuggest]);
  117313. this._toDispose.dispose();
  117314. this._completionDisposables.dispose();
  117315. this.cancel();
  117316. };
  117317. // --- handle configuration & precondition changes
  117318. SuggestModel.prototype._updateQuickSuggest = function () {
  117319. this._quickSuggestDelay = this._editor.getOption(67 /* quickSuggestionsDelay */);
  117320. if (isNaN(this._quickSuggestDelay) || (!this._quickSuggestDelay && this._quickSuggestDelay !== 0) || this._quickSuggestDelay < 0) {
  117321. this._quickSuggestDelay = 10;
  117322. }
  117323. };
  117324. SuggestModel.prototype._updateTriggerCharacters = function () {
  117325. var _this = this;
  117326. this._triggerCharacterListener.clear();
  117327. if (this._editor.getOption(68 /* readOnly */)
  117328. || !this._editor.hasModel()
  117329. || !this._editor.getOption(92 /* suggestOnTriggerCharacters */)) {
  117330. return;
  117331. }
  117332. var supportsByTriggerCharacter = new Map();
  117333. for (var _i = 0, _a = modes_1.CompletionProviderRegistry.all(this._editor.getModel()); _i < _a.length; _i++) {
  117334. var support = _a[_i];
  117335. for (var _b = 0, _c = support.triggerCharacters || []; _b < _c.length; _b++) {
  117336. var ch = _c[_b];
  117337. var set = supportsByTriggerCharacter.get(ch);
  117338. if (!set) {
  117339. set = new Set();
  117340. set.add(suggest_1.getSnippetSuggestSupport());
  117341. supportsByTriggerCharacter.set(ch, set);
  117342. }
  117343. set.add(support);
  117344. }
  117345. }
  117346. var checkTriggerCharacter = function (text) {
  117347. if (!text) {
  117348. // came here from the compositionEnd-event
  117349. var position = _this._editor.getPosition();
  117350. var model = _this._editor.getModel();
  117351. text = model.getLineContent(position.lineNumber).substr(0, position.column - 1);
  117352. }
  117353. var lastChar = '';
  117354. if (strings_1.isLowSurrogate(text.charCodeAt(text.length - 1))) {
  117355. if (strings_1.isHighSurrogate(text.charCodeAt(text.length - 2))) {
  117356. lastChar = text.substr(text.length - 2);
  117357. }
  117358. }
  117359. else {
  117360. lastChar = text.charAt(text.length - 1);
  117361. }
  117362. var supports = supportsByTriggerCharacter.get(lastChar);
  117363. if (supports) {
  117364. // keep existing items that where not computed by the
  117365. // supports/providers that want to trigger now
  117366. var items = _this._completionModel ? _this._completionModel.adopt(supports) : undefined;
  117367. _this.trigger({ auto: true, shy: false, triggerCharacter: lastChar }, Boolean(_this._completionModel), supports, items);
  117368. }
  117369. };
  117370. this._triggerCharacterListener.add(this._editor.onDidType(checkTriggerCharacter));
  117371. this._triggerCharacterListener.add(this._editor.onDidCompositionEnd(checkTriggerCharacter));
  117372. };
  117373. Object.defineProperty(SuggestModel.prototype, "state", {
  117374. // --- trigger/retrigger/cancel suggest
  117375. get: function () {
  117376. return this._state;
  117377. },
  117378. enumerable: true,
  117379. configurable: true
  117380. });
  117381. SuggestModel.prototype.cancel = function (retrigger) {
  117382. if (retrigger === void 0) { retrigger = false; }
  117383. if (this._state !== 0 /* Idle */) {
  117384. this._triggerQuickSuggest.cancel();
  117385. if (this._requestToken) {
  117386. this._requestToken.cancel();
  117387. this._requestToken = undefined;
  117388. }
  117389. this._state = 0 /* Idle */;
  117390. this._completionModel = undefined;
  117391. this._context = undefined;
  117392. this._onDidCancel.fire({ retrigger: retrigger });
  117393. }
  117394. };
  117395. SuggestModel.prototype.clear = function () {
  117396. this._completionDisposables.clear();
  117397. };
  117398. SuggestModel.prototype._updateActiveSuggestSession = function () {
  117399. if (this._state !== 0 /* Idle */) {
  117400. if (!this._editor.hasModel() || !modes_1.CompletionProviderRegistry.has(this._editor.getModel())) {
  117401. this.cancel();
  117402. }
  117403. else {
  117404. this.trigger({ auto: this._state === 2 /* Auto */, shy: false }, true);
  117405. }
  117406. }
  117407. };
  117408. SuggestModel.prototype._onCursorChange = function (e) {
  117409. var _this = this;
  117410. if (!this._editor.hasModel()) {
  117411. return;
  117412. }
  117413. var model = this._editor.getModel();
  117414. var prevSelection = this._currentSelection;
  117415. this._currentSelection = this._editor.getSelection();
  117416. if (!e.selection.isEmpty()
  117417. || e.reason !== 0 /* NotSet */
  117418. || (e.source !== 'keyboard' && e.source !== 'deleteLeft')) {
  117419. // Early exit if nothing needs to be done!
  117420. // Leave some form of early exit check here if you wish to continue being a cursor position change listener ;)
  117421. this.cancel();
  117422. return;
  117423. }
  117424. if (!modes_1.CompletionProviderRegistry.has(model)) {
  117425. return;
  117426. }
  117427. if (this._state === 0 /* Idle */) {
  117428. if (this._editor.getOption(66 /* quickSuggestions */) === false) {
  117429. // not enabled
  117430. return;
  117431. }
  117432. if (!prevSelection.containsRange(this._currentSelection) && !prevSelection.getEndPosition().isBeforeOrEqual(this._currentSelection.getPosition())) {
  117433. // cursor didn't move RIGHT
  117434. return;
  117435. }
  117436. if (this._editor.getOption(89 /* suggest */).snippetsPreventQuickSuggestions && snippetController2_1.SnippetController2.get(this._editor).isInSnippet()) {
  117437. // no quick suggestion when in snippet mode
  117438. return;
  117439. }
  117440. this.cancel();
  117441. this._triggerQuickSuggest.cancelAndSet(function () {
  117442. if (_this._state !== 0 /* Idle */) {
  117443. return;
  117444. }
  117445. if (!LineContext.shouldAutoTrigger(_this._editor)) {
  117446. return;
  117447. }
  117448. if (!_this._editor.hasModel()) {
  117449. return;
  117450. }
  117451. var model = _this._editor.getModel();
  117452. var pos = _this._editor.getPosition();
  117453. // validate enabled now
  117454. var quickSuggestions = _this._editor.getOption(66 /* quickSuggestions */);
  117455. if (quickSuggestions === false) {
  117456. return;
  117457. }
  117458. else if (quickSuggestions === true) {
  117459. // all good
  117460. }
  117461. else {
  117462. // Check the type of the token that triggered this
  117463. model.tokenizeIfCheap(pos.lineNumber);
  117464. var lineTokens = model.getLineTokens(pos.lineNumber);
  117465. var tokenType = lineTokens.getStandardTokenType(lineTokens.findTokenIndexAtOffset(Math.max(pos.column - 1 - 1, 0)));
  117466. var inValidScope = quickSuggestions.other && tokenType === 0 /* Other */
  117467. || quickSuggestions.comments && tokenType === 1 /* Comment */
  117468. || quickSuggestions.strings && tokenType === 2 /* String */;
  117469. if (!inValidScope) {
  117470. return;
  117471. }
  117472. }
  117473. // we made it till here -> trigger now
  117474. _this.trigger({ auto: true, shy: false });
  117475. }, this._quickSuggestDelay);
  117476. }
  117477. };
  117478. SuggestModel.prototype._refilterCompletionItems = function () {
  117479. var _this = this;
  117480. // Re-filter suggestions. This MUST run async because filtering/scoring
  117481. // uses the model content AND the cursor position. The latter is NOT
  117482. // updated when the document has changed (the event which drives this method)
  117483. // and therefore a little pause (next mirco task) is needed. See:
  117484. // https://stackoverflow.com/questions/25915634/difference-between-microtask-and-macrotask-within-an-event-loop-context#25933985
  117485. Promise.resolve().then(function () {
  117486. if (_this._state === 0 /* Idle */) {
  117487. return;
  117488. }
  117489. if (!_this._editor.hasModel()) {
  117490. return;
  117491. }
  117492. var model = _this._editor.getModel();
  117493. var position = _this._editor.getPosition();
  117494. var ctx = new LineContext(model, position, _this._state === 2 /* Auto */, false);
  117495. _this._onNewContext(ctx);
  117496. });
  117497. };
  117498. SuggestModel.prototype.trigger = function (context, retrigger, onlyFrom, existingItems) {
  117499. var _this = this;
  117500. if (retrigger === void 0) { retrigger = false; }
  117501. if (!this._editor.hasModel()) {
  117502. return;
  117503. }
  117504. var model = this._editor.getModel();
  117505. var auto = context.auto;
  117506. var ctx = new LineContext(model, this._editor.getPosition(), auto, context.shy);
  117507. // Cancel previous requests, change state & update UI
  117508. this.cancel(retrigger);
  117509. this._state = auto ? 2 /* Auto */ : 1 /* Manual */;
  117510. this._onDidTrigger.fire({ auto: auto, shy: context.shy, position: this._editor.getPosition() });
  117511. // Capture context when request was sent
  117512. this._context = ctx;
  117513. // Build context for request
  117514. var suggestCtx;
  117515. if (context.triggerCharacter) {
  117516. suggestCtx = {
  117517. triggerKind: 1 /* TriggerCharacter */,
  117518. triggerCharacter: context.triggerCharacter
  117519. };
  117520. }
  117521. else if (onlyFrom && onlyFrom.size > 0) {
  117522. suggestCtx = { triggerKind: 2 /* TriggerForIncompleteCompletions */ };
  117523. }
  117524. else {
  117525. suggestCtx = { triggerKind: 0 /* Invoke */ };
  117526. }
  117527. this._requestToken = new cancellation_1.CancellationTokenSource();
  117528. // kind filter and snippet sort rules
  117529. var snippetSuggestions = this._editor.getOption(86 /* snippetSuggestions */);
  117530. var snippetSortOrder = 1 /* Inline */;
  117531. switch (snippetSuggestions) {
  117532. case 'top':
  117533. snippetSortOrder = 0 /* Top */;
  117534. break;
  117535. // ↓ that's the default anyways...
  117536. // case 'inline':
  117537. // snippetSortOrder = SnippetSortOrder.Inline;
  117538. // break;
  117539. case 'bottom':
  117540. snippetSortOrder = 2 /* Bottom */;
  117541. break;
  117542. }
  117543. var itemKindFilter = SuggestModel._createItemKindFilter(this._editor);
  117544. var wordDistance = wordDistance_1.WordDistance.create(this._editorWorker, this._editor);
  117545. var items = suggest_1.provideSuggestionItems(model, this._editor.getPosition(), new suggest_1.CompletionOptions(snippetSortOrder, itemKindFilter, onlyFrom), suggestCtx, this._requestToken.token);
  117546. Promise.all([items, wordDistance]).then(function (_a) {
  117547. var items = _a[0], wordDistance = _a[1];
  117548. lifecycle_1.dispose(_this._requestToken);
  117549. if (_this._state === 0 /* Idle */) {
  117550. return;
  117551. }
  117552. if (!_this._editor.hasModel()) {
  117553. return;
  117554. }
  117555. var model = _this._editor.getModel();
  117556. if (arrays_1.isNonEmptyArray(existingItems)) {
  117557. var cmpFn = suggest_1.getSuggestionComparator(snippetSortOrder);
  117558. items = items.concat(existingItems).sort(cmpFn);
  117559. }
  117560. var ctx = new LineContext(model, _this._editor.getPosition(), auto, context.shy);
  117561. _this._completionModel = new completionModel_1.CompletionModel(items, _this._context.column, {
  117562. leadingLineContent: ctx.leadingLineContent,
  117563. characterCountDelta: ctx.column - _this._context.column
  117564. }, wordDistance, _this._editor.getOption(89 /* suggest */), _this._editor.getOption(86 /* snippetSuggestions */));
  117565. // store containers so that they can be disposed later
  117566. for (var _i = 0, items_1 = items; _i < items_1.length; _i++) {
  117567. var item = items_1[_i];
  117568. if (lifecycle_1.isDisposable(item.container)) {
  117569. _this._completionDisposables.add(item.container);
  117570. }
  117571. }
  117572. _this._onNewContext(ctx);
  117573. }).catch(errors_1.onUnexpectedError);
  117574. };
  117575. SuggestModel._createItemKindFilter = function (editor) {
  117576. // kind filter and snippet sort rules
  117577. var result = new Set();
  117578. // snippet setting
  117579. var snippetSuggestions = editor.getOption(86 /* snippetSuggestions */);
  117580. if (snippetSuggestions === 'none') {
  117581. result.add(25 /* Snippet */);
  117582. }
  117583. // type setting
  117584. var suggestOptions = editor.getOption(89 /* suggest */);
  117585. if (!suggestOptions.showMethods) {
  117586. result.add(0 /* Method */);
  117587. }
  117588. if (!suggestOptions.showFunctions) {
  117589. result.add(1 /* Function */);
  117590. }
  117591. if (!suggestOptions.showConstructors) {
  117592. result.add(2 /* Constructor */);
  117593. }
  117594. if (!suggestOptions.showFields) {
  117595. result.add(3 /* Field */);
  117596. }
  117597. if (!suggestOptions.showVariables) {
  117598. result.add(4 /* Variable */);
  117599. }
  117600. if (!suggestOptions.showClasses) {
  117601. result.add(5 /* Class */);
  117602. }
  117603. if (!suggestOptions.showStructs) {
  117604. result.add(6 /* Struct */);
  117605. }
  117606. if (!suggestOptions.showInterfaces) {
  117607. result.add(7 /* Interface */);
  117608. }
  117609. if (!suggestOptions.showModules) {
  117610. result.add(8 /* Module */);
  117611. }
  117612. if (!suggestOptions.showProperties) {
  117613. result.add(9 /* Property */);
  117614. }
  117615. if (!suggestOptions.showEvents) {
  117616. result.add(10 /* Event */);
  117617. }
  117618. if (!suggestOptions.showOperators) {
  117619. result.add(11 /* Operator */);
  117620. }
  117621. if (!suggestOptions.showUnits) {
  117622. result.add(12 /* Unit */);
  117623. }
  117624. if (!suggestOptions.showValues) {
  117625. result.add(13 /* Value */);
  117626. }
  117627. if (!suggestOptions.showConstants) {
  117628. result.add(14 /* Constant */);
  117629. }
  117630. if (!suggestOptions.showEnums) {
  117631. result.add(15 /* Enum */);
  117632. }
  117633. if (!suggestOptions.showEnumMembers) {
  117634. result.add(16 /* EnumMember */);
  117635. }
  117636. if (!suggestOptions.showKeywords) {
  117637. result.add(17 /* Keyword */);
  117638. }
  117639. if (!suggestOptions.showWords) {
  117640. result.add(18 /* Text */);
  117641. }
  117642. if (!suggestOptions.showColors) {
  117643. result.add(19 /* Color */);
  117644. }
  117645. if (!suggestOptions.showFiles) {
  117646. result.add(20 /* File */);
  117647. }
  117648. if (!suggestOptions.showReferences) {
  117649. result.add(21 /* Reference */);
  117650. }
  117651. if (!suggestOptions.showColors) {
  117652. result.add(22 /* Customcolor */);
  117653. }
  117654. if (!suggestOptions.showFolders) {
  117655. result.add(23 /* Folder */);
  117656. }
  117657. if (!suggestOptions.showTypeParameters) {
  117658. result.add(24 /* TypeParameter */);
  117659. }
  117660. if (!suggestOptions.showSnippets) {
  117661. result.add(25 /* Snippet */);
  117662. }
  117663. return result;
  117664. };
  117665. SuggestModel.prototype._onNewContext = function (ctx) {
  117666. if (!this._context) {
  117667. // happens when 24x7 IntelliSense is enabled and still in its delay
  117668. return;
  117669. }
  117670. if (ctx.lineNumber !== this._context.lineNumber) {
  117671. // e.g. happens when pressing Enter while IntelliSense is computed
  117672. this.cancel();
  117673. return;
  117674. }
  117675. if (ctx.leadingWord.startColumn < this._context.leadingWord.startColumn) {
  117676. // happens when the current word gets outdented
  117677. this.cancel();
  117678. return;
  117679. }
  117680. if (ctx.column < this._context.column) {
  117681. // typed -> moved cursor LEFT -> retrigger if still on a word
  117682. if (ctx.leadingWord.word) {
  117683. this.trigger({ auto: this._context.auto, shy: false }, true);
  117684. }
  117685. else {
  117686. this.cancel();
  117687. }
  117688. return;
  117689. }
  117690. if (!this._completionModel) {
  117691. // happens when IntelliSense is not yet computed
  117692. return;
  117693. }
  117694. if (ctx.column > this._context.column && this._completionModel.incomplete.size > 0 && ctx.leadingWord.word.length !== 0) {
  117695. // typed -> moved cursor RIGHT & incomple model & still on a word -> retrigger
  117696. var incomplete = this._completionModel.incomplete;
  117697. var adopted = this._completionModel.adopt(incomplete);
  117698. this.trigger({ auto: this._state === 2 /* Auto */, shy: false }, true, incomplete, adopted);
  117699. }
  117700. else {
  117701. // typed -> moved cursor RIGHT -> update UI
  117702. var oldLineContext = this._completionModel.lineContext;
  117703. var isFrozen = false;
  117704. this._completionModel.lineContext = {
  117705. leadingLineContent: ctx.leadingLineContent,
  117706. characterCountDelta: ctx.column - this._context.column
  117707. };
  117708. if (this._completionModel.items.length === 0) {
  117709. if (LineContext.shouldAutoTrigger(this._editor) && this._context.leadingWord.endColumn < ctx.leadingWord.startColumn) {
  117710. // retrigger when heading into a new word
  117711. this.trigger({ auto: this._context.auto, shy: false }, true);
  117712. return;
  117713. }
  117714. if (!this._context.auto) {
  117715. // freeze when IntelliSense was manually requested
  117716. this._completionModel.lineContext = oldLineContext;
  117717. isFrozen = this._completionModel.items.length > 0;
  117718. if (isFrozen && ctx.leadingWord.word.length === 0) {
  117719. // there were results before but now there aren't
  117720. // and also we are not on a word anymore -> cancel
  117721. this.cancel();
  117722. return;
  117723. }
  117724. }
  117725. else {
  117726. // nothing left
  117727. this.cancel();
  117728. return;
  117729. }
  117730. }
  117731. this._onDidSuggest.fire({
  117732. completionModel: this._completionModel,
  117733. auto: this._context.auto,
  117734. shy: this._context.shy,
  117735. isFrozen: isFrozen,
  117736. });
  117737. }
  117738. };
  117739. return SuggestModel;
  117740. }());
  117741. exports.SuggestModel = SuggestModel;
  117742. });
  117743. /*---------------------------------------------------------------------------------------------
  117744. * Copyright (c) Microsoft Corporation. All rights reserved.
  117745. * Licensed under the MIT License. See License.txt in the project root for license information.
  117746. *--------------------------------------------------------------------------------------------*/
  117747. var __spreadArrays = (this && this.__spreadArrays) || function () {
  117748. for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
  117749. for (var r = Array(s), k = 0, i = 0; i < il; i++)
  117750. for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
  117751. r[k] = a[j];
  117752. return r;
  117753. };
  117754. define(__m[610/*vs/editor/contrib/suggest/suggestController*/], __M([0/*require*/,1/*exports*/,50/*vs/base/browser/ui/aria/aria*/,19/*vs/base/common/arrays*/,10/*vs/base/common/errors*/,36/*vs/base/common/keyCodes*/,2/*vs/base/common/lifecycle*/,12/*vs/editor/browser/editorExtensions*/,58/*vs/editor/common/core/editOperation*/,3/*vs/editor/common/core/range*/,23/*vs/editor/common/editorContextKeys*/,173/*vs/editor/contrib/snippet/snippetController2*/,151/*vs/editor/contrib/snippet/snippetParser*/,521/*vs/editor/contrib/suggest/suggestMemory*/,467/*vs/nls!vs/editor/contrib/suggest/suggestController*/,29/*vs/platform/commands/common/commands*/,18/*vs/platform/contextkey/common/contextkey*/,11/*vs/platform/instantiation/common/instantiation*/,86/*vs/platform/keybinding/common/keybindingsRegistry*/,120/*vs/editor/contrib/suggest/suggest*/,497/*vs/editor/contrib/suggest/suggestAlternatives*/,609/*vs/editor/contrib/suggest/suggestModel*/,585/*vs/editor/contrib/suggest/suggestWidget*/,498/*vs/editor/contrib/suggest/wordContextKey*/,4/*vs/base/common/event*/,62/*vs/editor/common/services/editorWorkerService*/,15/*vs/base/common/async*/,21/*vs/base/common/types*/,390/*vs/editor/contrib/suggest/suggestCommitCharacters*/,16/*vs/base/common/platform*/,391/*vs/editor/contrib/suggest/suggestRangeHighlighter*/]), function (require, exports, aria_1, arrays_1, errors_1, keyCodes_1, lifecycle_1, editorExtensions_1, editOperation_1, range_1, editorContextKeys_1, snippetController2_1, snippetParser_1, suggestMemory_1, nls, commands_1, contextkey_1, instantiation_1, keybindingsRegistry_1, suggest_1, suggestAlternatives_1, suggestModel_1, suggestWidget_1, wordContextKey_1, event_1, editorWorkerService_1, async_1, types_1, suggestCommitCharacters_1, platform, suggestRangeHighlighter_1) {
  117755. "use strict";
  117756. Object.defineProperty(exports, "__esModule", { value: true });
  117757. /**
  117758. * Stop suggest widget from disappearing when clicking into other areas
  117759. * For development purpose only
  117760. */
  117761. var _sticky = false;
  117762. var LineSuffix = /** @class */ (function () {
  117763. function LineSuffix(_model, _position) {
  117764. this._model = _model;
  117765. this._position = _position;
  117766. // spy on what's happening right of the cursor. two cases:
  117767. // 1. end of line -> check that it's still end of line
  117768. // 2. mid of line -> add a marker and compute the delta
  117769. var maxColumn = _model.getLineMaxColumn(_position.lineNumber);
  117770. if (maxColumn !== _position.column) {
  117771. var offset = _model.getOffsetAt(_position);
  117772. var end = _model.getPositionAt(offset + 1);
  117773. this._marker = _model.deltaDecorations([], [{
  117774. range: range_1.Range.fromPositions(_position, end),
  117775. options: { stickiness: 1 /* NeverGrowsWhenTypingAtEdges */ }
  117776. }]);
  117777. }
  117778. }
  117779. LineSuffix.prototype.dispose = function () {
  117780. if (this._marker && !this._model.isDisposed()) {
  117781. this._model.deltaDecorations(this._marker, []);
  117782. }
  117783. };
  117784. LineSuffix.prototype.delta = function (position) {
  117785. if (this._model.isDisposed() || this._position.lineNumber !== position.lineNumber) {
  117786. // bail out early if things seems fishy
  117787. return 0;
  117788. }
  117789. // read the marker (in case suggest was triggered at line end) or compare
  117790. // the cursor to the line end.
  117791. if (this._marker) {
  117792. var range = this._model.getDecorationRange(this._marker[0]);
  117793. var end = this._model.getOffsetAt(range.getStartPosition());
  117794. return end - this._model.getOffsetAt(position);
  117795. }
  117796. else {
  117797. return this._model.getLineMaxColumn(position.lineNumber) - position.column;
  117798. }
  117799. };
  117800. return LineSuffix;
  117801. }());
  117802. var SuggestController = /** @class */ (function () {
  117803. function SuggestController(editor, editorWorker, _memoryService, _commandService, _contextKeyService, _instantiationService) {
  117804. var _this = this;
  117805. this._memoryService = _memoryService;
  117806. this._commandService = _commandService;
  117807. this._contextKeyService = _contextKeyService;
  117808. this._instantiationService = _instantiationService;
  117809. this._lineSuffix = new lifecycle_1.MutableDisposable();
  117810. this._toDispose = new lifecycle_1.DisposableStore();
  117811. this.editor = editor;
  117812. this.model = new suggestModel_1.SuggestModel(this.editor, editorWorker);
  117813. this.widget = this._toDispose.add(new async_1.IdleValue(function () {
  117814. var widget = _this._instantiationService.createInstance(suggestWidget_1.SuggestWidget, _this.editor);
  117815. _this._toDispose.add(widget);
  117816. _this._toDispose.add(widget.onDidSelect(function (item) { return _this._insertSuggestion(item, 0); }, _this));
  117817. // Wire up logic to accept a suggestion on certain characters
  117818. var commitCharacterController = new suggestCommitCharacters_1.CommitCharacterController(_this.editor, widget, function (item) { return _this._insertSuggestion(item, 2 /* NoAfterUndoStop */); });
  117819. _this._toDispose.add(commitCharacterController);
  117820. _this._toDispose.add(_this.model.onDidSuggest(function (e) {
  117821. if (e.completionModel.items.length === 0) {
  117822. commitCharacterController.reset();
  117823. }
  117824. }));
  117825. // Wire up makes text edit context key
  117826. var makesTextEdit = suggest_1.Context.MakesTextEdit.bindTo(_this._contextKeyService);
  117827. _this._toDispose.add(widget.onDidFocus(function (_a) {
  117828. var item = _a.item;
  117829. var position = _this.editor.getPosition();
  117830. var startColumn = item.editStart.column;
  117831. var endColumn = position.column;
  117832. var value = true;
  117833. if (_this.editor.getOption(1 /* acceptSuggestionOnEnter */) === 'smart'
  117834. && _this.model.state === 2 /* Auto */
  117835. && !item.completion.command
  117836. && !item.completion.additionalTextEdits
  117837. && !(item.completion.insertTextRules & 4 /* InsertAsSnippet */)
  117838. && endColumn - startColumn === item.completion.insertText.length) {
  117839. var oldText = _this.editor.getModel().getValueInRange({
  117840. startLineNumber: position.lineNumber,
  117841. startColumn: startColumn,
  117842. endLineNumber: position.lineNumber,
  117843. endColumn: endColumn
  117844. });
  117845. value = oldText !== item.completion.insertText;
  117846. }
  117847. makesTextEdit.set(value);
  117848. }));
  117849. _this._toDispose.add(lifecycle_1.toDisposable(function () { return makesTextEdit.reset(); }));
  117850. _this._toDispose.add(widget.onDetailsKeyDown(function (e) {
  117851. // cmd + c on macOS, ctrl + c on Win / Linux
  117852. if (e.toKeybinding().equals(new keyCodes_1.SimpleKeybinding(true, false, false, false, 33 /* KEY_C */)) ||
  117853. (platform.isMacintosh && e.toKeybinding().equals(new keyCodes_1.SimpleKeybinding(false, false, false, true, 33 /* KEY_C */)))) {
  117854. e.stopPropagation();
  117855. return;
  117856. }
  117857. if (!e.toKeybinding().isModifierKey()) {
  117858. _this.editor.focus();
  117859. }
  117860. }));
  117861. return widget;
  117862. }));
  117863. this._alternatives = this._toDispose.add(new async_1.IdleValue(function () {
  117864. return _this._toDispose.add(new suggestAlternatives_1.SuggestAlternatives(_this.editor, _this._contextKeyService));
  117865. }));
  117866. this._toDispose.add(_instantiationService.createInstance(wordContextKey_1.WordContextKey, editor));
  117867. this._toDispose.add(this.model.onDidTrigger(function (e) {
  117868. _this.widget.getValue().showTriggered(e.auto, e.shy ? 250 : 50);
  117869. _this._lineSuffix.value = new LineSuffix(_this.editor.getModel(), e.position);
  117870. }));
  117871. this._toDispose.add(this.model.onDidSuggest(function (e) {
  117872. if (!e.shy) {
  117873. var index = _this._memoryService.select(_this.editor.getModel(), _this.editor.getPosition(), e.completionModel.items);
  117874. _this.widget.getValue().showSuggestions(e.completionModel, index, e.isFrozen, e.auto);
  117875. }
  117876. }));
  117877. this._toDispose.add(this.model.onDidCancel(function (e) {
  117878. if (!e.retrigger) {
  117879. _this.widget.getValue().hideWidget();
  117880. }
  117881. }));
  117882. this._toDispose.add(this.editor.onDidBlurEditorWidget(function () {
  117883. if (!_sticky) {
  117884. _this.model.cancel();
  117885. _this.model.clear();
  117886. }
  117887. }));
  117888. // Manage the acceptSuggestionsOnEnter context key
  117889. var acceptSuggestionsOnEnter = suggest_1.Context.AcceptSuggestionsOnEnter.bindTo(_contextKeyService);
  117890. var updateFromConfig = function () {
  117891. var acceptSuggestionOnEnter = _this.editor.getOption(1 /* acceptSuggestionOnEnter */);
  117892. acceptSuggestionsOnEnter.set(acceptSuggestionOnEnter === 'on' || acceptSuggestionOnEnter === 'smart');
  117893. };
  117894. this._toDispose.add(this.editor.onDidChangeConfiguration(function () { return updateFromConfig(); }));
  117895. updateFromConfig();
  117896. // create range highlighter
  117897. this._toDispose.add(new suggestRangeHighlighter_1.SuggestRangeHighlighter(this));
  117898. }
  117899. SuggestController.get = function (editor) {
  117900. return editor.getContribution(SuggestController.ID);
  117901. };
  117902. SuggestController.prototype.dispose = function () {
  117903. this._alternatives.dispose();
  117904. this._toDispose.dispose();
  117905. this.widget.dispose();
  117906. this.model.dispose();
  117907. this._lineSuffix.dispose();
  117908. };
  117909. SuggestController.prototype._insertSuggestion = function (event, flags) {
  117910. var _a;
  117911. var _this = this;
  117912. if (!event || !event.item) {
  117913. this._alternatives.getValue().reset();
  117914. this.model.cancel();
  117915. this.model.clear();
  117916. return;
  117917. }
  117918. if (!this.editor.hasModel()) {
  117919. return;
  117920. }
  117921. var model = this.editor.getModel();
  117922. var modelVersionNow = model.getAlternativeVersionId();
  117923. var item = event.item;
  117924. var suggestion = item.completion;
  117925. // pushing undo stops *before* additional text edits and
  117926. // *after* the main edit
  117927. if (!(flags & 1 /* NoBeforeUndoStop */)) {
  117928. this.editor.pushUndoStop();
  117929. }
  117930. // compute overwrite[Before|After] deltas BEFORE applying extra edits
  117931. var info = this.getOverwriteInfo(item, Boolean(flags & 8 /* AlternativeOverwriteConfig */));
  117932. // keep item in memory
  117933. this._memoryService.memorize(model, this.editor.getPosition(), item);
  117934. if (Array.isArray(suggestion.additionalTextEdits)) {
  117935. this.editor.executeEdits('suggestController.additionalTextEdits', suggestion.additionalTextEdits.map(function (edit) { return editOperation_1.EditOperation.replace(range_1.Range.lift(edit.range), edit.text); }));
  117936. }
  117937. var insertText = suggestion.insertText;
  117938. if (!(suggestion.insertTextRules & 4 /* InsertAsSnippet */)) {
  117939. insertText = snippetParser_1.SnippetParser.escape(insertText);
  117940. }
  117941. snippetController2_1.SnippetController2.get(this.editor).insert(insertText, {
  117942. overwriteBefore: info.overwriteBefore,
  117943. overwriteAfter: info.overwriteAfter,
  117944. undoStopBefore: false,
  117945. undoStopAfter: false,
  117946. adjustWhitespace: !(suggestion.insertTextRules & 1 /* KeepWhitespace */)
  117947. });
  117948. if (!(flags & 2 /* NoAfterUndoStop */)) {
  117949. this.editor.pushUndoStop();
  117950. }
  117951. if (!suggestion.command) {
  117952. // done
  117953. this.model.cancel();
  117954. this.model.clear();
  117955. }
  117956. else if (suggestion.command.id === TriggerSuggestAction.id) {
  117957. // retigger
  117958. this.model.trigger({ auto: true, shy: false }, true);
  117959. }
  117960. else {
  117961. // exec command, done
  117962. (_a = this._commandService).executeCommand.apply(_a, __spreadArrays([suggestion.command.id], (suggestion.command.arguments ? __spreadArrays(suggestion.command.arguments) : []))).catch(errors_1.onUnexpectedError)
  117963. .finally(function () { return _this.model.clear(); }); // <- clear only now, keep commands alive
  117964. this.model.cancel();
  117965. }
  117966. if (flags & 4 /* KeepAlternativeSuggestions */) {
  117967. this._alternatives.getValue().set(event, function (next) {
  117968. // this is not so pretty. when inserting the 'next'
  117969. // suggestion we undo until we are at the state at
  117970. // which we were before inserting the previous suggestion...
  117971. while (model.canUndo()) {
  117972. if (modelVersionNow !== model.getAlternativeVersionId()) {
  117973. model.undo();
  117974. }
  117975. _this._insertSuggestion(next, 1 /* NoBeforeUndoStop */ | 2 /* NoAfterUndoStop */ | (flags & 8 /* AlternativeOverwriteConfig */ ? 8 /* AlternativeOverwriteConfig */ : 0));
  117976. break;
  117977. }
  117978. });
  117979. }
  117980. this._alertCompletionItem(event.item);
  117981. };
  117982. SuggestController.prototype.getOverwriteInfo = function (item, toggleMode) {
  117983. types_1.assertType(this.editor.hasModel());
  117984. var replace = this.editor.getOption(89 /* suggest */).insertMode === 'replace';
  117985. if (toggleMode) {
  117986. replace = !replace;
  117987. }
  117988. var overwriteBefore = item.position.column - item.editStart.column;
  117989. var overwriteAfter = (replace ? item.editReplaceEnd.column : item.editInsertEnd.column) - item.position.column;
  117990. var columnDelta = this.editor.getPosition().column - item.position.column;
  117991. var suffixDelta = this._lineSuffix.value ? this._lineSuffix.value.delta(this.editor.getPosition()) : 0;
  117992. return {
  117993. overwriteBefore: overwriteBefore + columnDelta,
  117994. overwriteAfter: overwriteAfter + suffixDelta
  117995. };
  117996. };
  117997. SuggestController.prototype._alertCompletionItem = function (_a) {
  117998. var suggestion = _a.completion;
  117999. var textLabel = typeof suggestion.label === 'string' ? suggestion.label : suggestion.label.name;
  118000. if (arrays_1.isNonEmptyArray(suggestion.additionalTextEdits)) {
  118001. var msg = nls.localize(0, null, textLabel, suggestion.additionalTextEdits.length);
  118002. aria_1.alert(msg);
  118003. }
  118004. };
  118005. SuggestController.prototype.triggerSuggest = function (onlyFrom) {
  118006. if (this.editor.hasModel()) {
  118007. this.model.trigger({ auto: false, shy: false }, false, onlyFrom);
  118008. this.editor.revealLine(this.editor.getPosition().lineNumber, 0 /* Smooth */);
  118009. this.editor.focus();
  118010. }
  118011. };
  118012. SuggestController.prototype.triggerSuggestAndAcceptBest = function (arg) {
  118013. var _this = this;
  118014. if (!this.editor.hasModel()) {
  118015. return;
  118016. }
  118017. var positionNow = this.editor.getPosition();
  118018. var fallback = function () {
  118019. if (positionNow.equals(_this.editor.getPosition())) {
  118020. _this._commandService.executeCommand(arg.fallback);
  118021. }
  118022. };
  118023. var makesTextEdit = function (item) {
  118024. if (item.completion.insertTextRules & 4 /* InsertAsSnippet */ || item.completion.additionalTextEdits) {
  118025. // snippet, other editor -> makes edit
  118026. return true;
  118027. }
  118028. var position = _this.editor.getPosition();
  118029. var startColumn = item.editStart.column;
  118030. var endColumn = position.column;
  118031. if (endColumn - startColumn !== item.completion.insertText.length) {
  118032. // unequal lengths -> makes edit
  118033. return true;
  118034. }
  118035. var textNow = _this.editor.getModel().getValueInRange({
  118036. startLineNumber: position.lineNumber,
  118037. startColumn: startColumn,
  118038. endLineNumber: position.lineNumber,
  118039. endColumn: endColumn
  118040. });
  118041. // unequal text -> makes edit
  118042. return textNow !== item.completion.insertText;
  118043. };
  118044. event_1.Event.once(this.model.onDidTrigger)(function (_) {
  118045. // wait for trigger because only then the cancel-event is trustworthy
  118046. var listener = [];
  118047. event_1.Event.any(_this.model.onDidTrigger, _this.model.onDidCancel)(function () {
  118048. // retrigger or cancel -> try to type default text
  118049. lifecycle_1.dispose(listener);
  118050. fallback();
  118051. }, undefined, listener);
  118052. _this.model.onDidSuggest(function (_a) {
  118053. var completionModel = _a.completionModel;
  118054. lifecycle_1.dispose(listener);
  118055. if (completionModel.items.length === 0) {
  118056. fallback();
  118057. return;
  118058. }
  118059. var index = _this._memoryService.select(_this.editor.getModel(), _this.editor.getPosition(), completionModel.items);
  118060. var item = completionModel.items[index];
  118061. if (!makesTextEdit(item)) {
  118062. fallback();
  118063. return;
  118064. }
  118065. _this.editor.pushUndoStop();
  118066. _this._insertSuggestion({ index: index, item: item, model: completionModel }, 4 /* KeepAlternativeSuggestions */ | 1 /* NoBeforeUndoStop */ | 2 /* NoAfterUndoStop */);
  118067. }, undefined, listener);
  118068. });
  118069. this.model.trigger({ auto: false, shy: true });
  118070. this.editor.revealLine(positionNow.lineNumber, 0 /* Smooth */);
  118071. this.editor.focus();
  118072. };
  118073. SuggestController.prototype.acceptSelectedSuggestion = function (keepAlternativeSuggestions, alternativeOverwriteConfig) {
  118074. var item = this.widget.getValue().getFocusedItem();
  118075. var flags = 0;
  118076. if (keepAlternativeSuggestions) {
  118077. flags |= 4 /* KeepAlternativeSuggestions */;
  118078. }
  118079. if (alternativeOverwriteConfig) {
  118080. flags |= 8 /* AlternativeOverwriteConfig */;
  118081. }
  118082. this._insertSuggestion(item, flags);
  118083. };
  118084. SuggestController.prototype.acceptNextSuggestion = function () {
  118085. this._alternatives.getValue().next();
  118086. };
  118087. SuggestController.prototype.acceptPrevSuggestion = function () {
  118088. this._alternatives.getValue().prev();
  118089. };
  118090. SuggestController.prototype.cancelSuggestWidget = function () {
  118091. this.model.cancel();
  118092. this.model.clear();
  118093. this.widget.getValue().hideWidget();
  118094. };
  118095. SuggestController.prototype.selectNextSuggestion = function () {
  118096. this.widget.getValue().selectNext();
  118097. };
  118098. SuggestController.prototype.selectNextPageSuggestion = function () {
  118099. this.widget.getValue().selectNextPage();
  118100. };
  118101. SuggestController.prototype.selectLastSuggestion = function () {
  118102. this.widget.getValue().selectLast();
  118103. };
  118104. SuggestController.prototype.selectPrevSuggestion = function () {
  118105. this.widget.getValue().selectPrevious();
  118106. };
  118107. SuggestController.prototype.selectPrevPageSuggestion = function () {
  118108. this.widget.getValue().selectPreviousPage();
  118109. };
  118110. SuggestController.prototype.selectFirstSuggestion = function () {
  118111. this.widget.getValue().selectFirst();
  118112. };
  118113. SuggestController.prototype.toggleSuggestionDetails = function () {
  118114. this.widget.getValue().toggleDetails();
  118115. };
  118116. SuggestController.prototype.toggleExplainMode = function () {
  118117. this.widget.getValue().toggleExplainMode();
  118118. };
  118119. SuggestController.prototype.toggleSuggestionFocus = function () {
  118120. this.widget.getValue().toggleDetailsFocus();
  118121. };
  118122. SuggestController.ID = 'editor.contrib.suggestController';
  118123. SuggestController = __decorate([
  118124. __param(1, editorWorkerService_1.IEditorWorkerService),
  118125. __param(2, suggestMemory_1.ISuggestMemoryService),
  118126. __param(3, commands_1.ICommandService),
  118127. __param(4, contextkey_1.IContextKeyService),
  118128. __param(5, instantiation_1.IInstantiationService)
  118129. ], SuggestController);
  118130. return SuggestController;
  118131. }());
  118132. exports.SuggestController = SuggestController;
  118133. var TriggerSuggestAction = /** @class */ (function (_super) {
  118134. __extends(TriggerSuggestAction, _super);
  118135. function TriggerSuggestAction() {
  118136. return _super.call(this, {
  118137. id: TriggerSuggestAction.id,
  118138. label: nls.localize(1, null),
  118139. alias: 'Trigger Suggest',
  118140. precondition: contextkey_1.ContextKeyExpr.and(editorContextKeys_1.EditorContextKeys.writable, editorContextKeys_1.EditorContextKeys.hasCompletionItemProvider),
  118141. kbOpts: {
  118142. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118143. primary: 2048 /* CtrlCmd */ | 10 /* Space */,
  118144. mac: { primary: 256 /* WinCtrl */ | 10 /* Space */, secondary: [512 /* Alt */ | 9 /* Escape */] },
  118145. weight: 100 /* EditorContrib */
  118146. }
  118147. }) || this;
  118148. }
  118149. TriggerSuggestAction.prototype.run = function (accessor, editor) {
  118150. var controller = SuggestController.get(editor);
  118151. if (!controller) {
  118152. return;
  118153. }
  118154. controller.triggerSuggest();
  118155. };
  118156. TriggerSuggestAction.id = 'editor.action.triggerSuggest';
  118157. return TriggerSuggestAction;
  118158. }(editorExtensions_1.EditorAction));
  118159. exports.TriggerSuggestAction = TriggerSuggestAction;
  118160. editorExtensions_1.registerEditorContribution(SuggestController.ID, SuggestController);
  118161. editorExtensions_1.registerEditorAction(TriggerSuggestAction);
  118162. var weight = 100 /* EditorContrib */ + 90;
  118163. var SuggestCommand = editorExtensions_1.EditorCommand.bindToContribution(SuggestController.get);
  118164. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118165. id: 'acceptSelectedSuggestion',
  118166. precondition: suggest_1.Context.Visible,
  118167. handler: function (x) {
  118168. x.acceptSelectedSuggestion(true, false);
  118169. }
  118170. }));
  118171. // normal tab
  118172. keybindingsRegistry_1.KeybindingsRegistry.registerKeybindingRule({
  118173. id: 'acceptSelectedSuggestion',
  118174. when: contextkey_1.ContextKeyExpr.and(suggest_1.Context.Visible, editorContextKeys_1.EditorContextKeys.textInputFocus),
  118175. primary: 2 /* Tab */,
  118176. weight: weight
  118177. });
  118178. // accept on enter has special rules
  118179. keybindingsRegistry_1.KeybindingsRegistry.registerKeybindingRule({
  118180. id: 'acceptSelectedSuggestion',
  118181. when: contextkey_1.ContextKeyExpr.and(suggest_1.Context.Visible, editorContextKeys_1.EditorContextKeys.textInputFocus, suggest_1.Context.AcceptSuggestionsOnEnter, suggest_1.Context.MakesTextEdit),
  118182. primary: 3 /* Enter */,
  118183. weight: weight
  118184. });
  118185. // todo@joh control enablement via context key
  118186. // shift+enter and shift+tab use the alternative-flag so that the suggest controller
  118187. // is doing the opposite of the editor.suggest.overwriteOnAccept-configuration
  118188. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118189. id: 'acceptAlternativeSelectedSuggestion',
  118190. precondition: contextkey_1.ContextKeyExpr.and(suggest_1.Context.Visible, editorContextKeys_1.EditorContextKeys.textInputFocus),
  118191. kbOpts: {
  118192. weight: weight,
  118193. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118194. primary: 1024 /* Shift */ | 3 /* Enter */,
  118195. secondary: [1024 /* Shift */ | 2 /* Tab */],
  118196. },
  118197. handler: function (x) {
  118198. x.acceptSelectedSuggestion(false, true);
  118199. },
  118200. }));
  118201. // continue to support the old command
  118202. commands_1.CommandsRegistry.registerCommandAlias('acceptSelectedSuggestionOnEnter', 'acceptSelectedSuggestion');
  118203. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118204. id: 'hideSuggestWidget',
  118205. precondition: suggest_1.Context.Visible,
  118206. handler: function (x) { return x.cancelSuggestWidget(); },
  118207. kbOpts: {
  118208. weight: weight,
  118209. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118210. primary: 9 /* Escape */,
  118211. secondary: [1024 /* Shift */ | 9 /* Escape */]
  118212. }
  118213. }));
  118214. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118215. id: 'selectNextSuggestion',
  118216. precondition: contextkey_1.ContextKeyExpr.and(suggest_1.Context.Visible, suggest_1.Context.MultipleSuggestions),
  118217. handler: function (c) { return c.selectNextSuggestion(); },
  118218. kbOpts: {
  118219. weight: weight,
  118220. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118221. primary: 18 /* DownArrow */,
  118222. secondary: [2048 /* CtrlCmd */ | 18 /* DownArrow */],
  118223. mac: { primary: 18 /* DownArrow */, secondary: [2048 /* CtrlCmd */ | 18 /* DownArrow */, 256 /* WinCtrl */ | 44 /* KEY_N */] }
  118224. }
  118225. }));
  118226. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118227. id: 'selectNextPageSuggestion',
  118228. precondition: contextkey_1.ContextKeyExpr.and(suggest_1.Context.Visible, suggest_1.Context.MultipleSuggestions),
  118229. handler: function (c) { return c.selectNextPageSuggestion(); },
  118230. kbOpts: {
  118231. weight: weight,
  118232. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118233. primary: 12 /* PageDown */,
  118234. secondary: [2048 /* CtrlCmd */ | 12 /* PageDown */]
  118235. }
  118236. }));
  118237. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118238. id: 'selectLastSuggestion',
  118239. precondition: contextkey_1.ContextKeyExpr.and(suggest_1.Context.Visible, suggest_1.Context.MultipleSuggestions),
  118240. handler: function (c) { return c.selectLastSuggestion(); }
  118241. }));
  118242. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118243. id: 'selectPrevSuggestion',
  118244. precondition: contextkey_1.ContextKeyExpr.and(suggest_1.Context.Visible, suggest_1.Context.MultipleSuggestions),
  118245. handler: function (c) { return c.selectPrevSuggestion(); },
  118246. kbOpts: {
  118247. weight: weight,
  118248. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118249. primary: 16 /* UpArrow */,
  118250. secondary: [2048 /* CtrlCmd */ | 16 /* UpArrow */],
  118251. mac: { primary: 16 /* UpArrow */, secondary: [2048 /* CtrlCmd */ | 16 /* UpArrow */, 256 /* WinCtrl */ | 46 /* KEY_P */] }
  118252. }
  118253. }));
  118254. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118255. id: 'selectPrevPageSuggestion',
  118256. precondition: contextkey_1.ContextKeyExpr.and(suggest_1.Context.Visible, suggest_1.Context.MultipleSuggestions),
  118257. handler: function (c) { return c.selectPrevPageSuggestion(); },
  118258. kbOpts: {
  118259. weight: weight,
  118260. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118261. primary: 11 /* PageUp */,
  118262. secondary: [2048 /* CtrlCmd */ | 11 /* PageUp */]
  118263. }
  118264. }));
  118265. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118266. id: 'selectFirstSuggestion',
  118267. precondition: contextkey_1.ContextKeyExpr.and(suggest_1.Context.Visible, suggest_1.Context.MultipleSuggestions),
  118268. handler: function (c) { return c.selectFirstSuggestion(); }
  118269. }));
  118270. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118271. id: 'toggleSuggestionDetails',
  118272. precondition: suggest_1.Context.Visible,
  118273. handler: function (x) { return x.toggleSuggestionDetails(); },
  118274. kbOpts: {
  118275. weight: weight,
  118276. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118277. primary: 2048 /* CtrlCmd */ | 10 /* Space */,
  118278. mac: { primary: 256 /* WinCtrl */ | 10 /* Space */ }
  118279. }
  118280. }));
  118281. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118282. id: 'toggleExplainMode',
  118283. precondition: suggest_1.Context.Visible,
  118284. handler: function (x) { return x.toggleExplainMode(); },
  118285. kbOpts: {
  118286. weight: 100 /* EditorContrib */,
  118287. primary: 2048 /* CtrlCmd */ | 85 /* US_SLASH */,
  118288. }
  118289. }));
  118290. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118291. id: 'toggleSuggestionFocus',
  118292. precondition: suggest_1.Context.Visible,
  118293. handler: function (x) { return x.toggleSuggestionFocus(); },
  118294. kbOpts: {
  118295. weight: weight,
  118296. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118297. primary: 2048 /* CtrlCmd */ | 512 /* Alt */ | 10 /* Space */,
  118298. mac: { primary: 256 /* WinCtrl */ | 512 /* Alt */ | 10 /* Space */ }
  118299. }
  118300. }));
  118301. //#region tab completions
  118302. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118303. id: 'insertBestCompletion',
  118304. precondition: contextkey_1.ContextKeyExpr.and(contextkey_1.ContextKeyExpr.equals('config.editor.tabCompletion', 'on'), wordContextKey_1.WordContextKey.AtEnd, suggest_1.Context.Visible.toNegated(), suggestAlternatives_1.SuggestAlternatives.OtherSuggestions.toNegated(), snippetController2_1.SnippetController2.InSnippetMode.toNegated()),
  118305. handler: function (x, arg) {
  118306. x.triggerSuggestAndAcceptBest(types_1.isObject(arg) ? __assign({ fallback: 'tab' }, arg) : { fallback: 'tab' });
  118307. },
  118308. kbOpts: {
  118309. weight: weight,
  118310. primary: 2 /* Tab */
  118311. }
  118312. }));
  118313. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118314. id: 'insertNextSuggestion',
  118315. precondition: contextkey_1.ContextKeyExpr.and(contextkey_1.ContextKeyExpr.equals('config.editor.tabCompletion', 'on'), suggestAlternatives_1.SuggestAlternatives.OtherSuggestions, suggest_1.Context.Visible.toNegated(), snippetController2_1.SnippetController2.InSnippetMode.toNegated()),
  118316. handler: function (x) { return x.acceptNextSuggestion(); },
  118317. kbOpts: {
  118318. weight: weight,
  118319. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118320. primary: 2 /* Tab */
  118321. }
  118322. }));
  118323. editorExtensions_1.registerEditorCommand(new SuggestCommand({
  118324. id: 'insertPrevSuggestion',
  118325. precondition: contextkey_1.ContextKeyExpr.and(contextkey_1.ContextKeyExpr.equals('config.editor.tabCompletion', 'on'), suggestAlternatives_1.SuggestAlternatives.OtherSuggestions, suggest_1.Context.Visible.toNegated(), snippetController2_1.SnippetController2.InSnippetMode.toNegated()),
  118326. handler: function (x) { return x.acceptPrevSuggestion(); },
  118327. kbOpts: {
  118328. weight: weight,
  118329. kbExpr: editorContextKeys_1.EditorContextKeys.textInputFocus,
  118330. primary: 1024 /* Shift */ | 2 /* Tab */
  118331. }
  118332. }));
  118333. });
  118334. /*---------------------------------------------------------------------------------------------
  118335. * Copyright (c) Microsoft Corporation. All rights reserved.
  118336. * Licensed under the MIT License. See License.txt in the project root for license information.
  118337. *--------------------------------------------------------------------------------------------*/
  118338. define(__m[611/*vs/editor/editor.all*/], __M([0/*require*/,1/*exports*/,164/*vs/editor/browser/controller/coreCommands*/,121/*vs/editor/browser/widget/codeEditorWidget*/,230/*vs/editor/browser/widget/diffEditorWidget*/,188/*vs/editor/browser/widget/diffNavigator*/,566/*vs/editor/contrib/bracketMatching/bracketMatching*/,524/*vs/editor/contrib/caretOperations/caretOperations*/,525/*vs/editor/contrib/caretOperations/transpose*/,526/*vs/editor/contrib/clipboard/clipboard*/,579/*vs/editor/contrib/codeAction/codeActionContributions*/,569/*vs/editor/contrib/codelens/codelensController*/,223/*vs/editor/contrib/colorPicker/colorDetector*/,530/*vs/editor/contrib/comment/comment*/,531/*vs/editor/contrib/contextmenu/contextmenu*/,532/*vs/editor/contrib/cursorUndo/cursorUndo*/,533/*vs/editor/contrib/dnd/dnd*/,232/*vs/editor/contrib/find/findController*/,574/*vs/editor/contrib/folding/folding*/,534/*vs/editor/contrib/fontZoom/fontZoom*/,536/*vs/editor/contrib/format/formatActions*/,235/*vs/editor/contrib/gotoSymbol/goToCommands*/,236/*vs/editor/contrib/gotoSymbol/link/goToDefinitionAtPosition*/,237/*vs/editor/contrib/gotoError/gotoError*/,601/*vs/editor/contrib/hover/hover*/,576/*vs/editor/contrib/inPlaceReplace/inPlaceReplace*/,539/*vs/editor/contrib/linesOperations/linesOperations*/,577/*vs/editor/contrib/links/links*/,580/*vs/editor/contrib/multicursor/multicursor*/,582/*vs/editor/contrib/parameterHints/parameterHints*/,584/*vs/editor/contrib/rename/rename*/,541/*vs/editor/contrib/smartSelect/smartSelect*/,173/*vs/editor/contrib/snippet/snippetController2*/,610/*vs/editor/contrib/suggest/suggestController*/,542/*vs/editor/contrib/tokenization/tokenization*/,225/*vs/editor/contrib/toggleTabFocusMode/toggleTabFocusMode*/,586/*vs/editor/contrib/wordHighlighter/wordHighlighter*/,226/*vs/editor/contrib/wordOperations/wordOperations*/,543/*vs/editor/contrib/wordPartOperations/wordPartOperations*/,59/*vs/editor/common/standaloneStrings*/]), function (require, exports) {
  118339. "use strict";
  118340. Object.defineProperty(exports, "__esModule", { value: true });
  118341. });
  118342. /*---------------------------------------------------------------------------------------------
  118343. * Copyright (c) Microsoft Corporation. All rights reserved.
  118344. * Licensed under the MIT License. See License.txt in the project root for license information.
  118345. *--------------------------------------------------------------------------------------------*/
  118346. define(__m[615/*vs/editor/editor.main*/], __M([0/*require*/,1/*exports*/,605/*vs/editor/editor.api*/,611/*vs/editor/editor.all*/,587/*vs/editor/standalone/browser/accessibilityHelp/accessibilityHelp*/,544/*vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard*/,588/*vs/editor/standalone/browser/inspectTokens/inspectTokens*/,589/*vs/editor/standalone/browser/quickOpen/gotoLine*/,590/*vs/editor/standalone/browser/quickOpen/quickCommand*/,591/*vs/editor/standalone/browser/quickOpen/quickOutline*/,597/*vs/editor/standalone/browser/referenceSearch/standaloneReferenceSearch*/,545/*vs/editor/standalone/browser/toggleHighContrast/toggleHighContrast*/]), function (require, exports, editor_api_1) {
  118347. "use strict";
  118348. function __export(m) {
  118349. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  118350. }
  118351. Object.defineProperty(exports, "__esModule", { value: true });
  118352. __export(editor_api_1);
  118353. });
  118354. }).call(this);
  118355. define("vs/language/typescript/monaco.contribution",["require", "exports", "./lib/typescriptServicesMetadata","vs/editor/editor.api"], function (require, exports, typescriptServicesMetadata_1) {
  118356. /*---------------------------------------------------------------------------------------------
  118357. * Copyright (c) Microsoft Corporation. All rights reserved.
  118358. * Licensed under the MIT License. See License.txt in the project root for license information.
  118359. *--------------------------------------------------------------------------------------------*/
  118360. 'use strict';
  118361. Object.defineProperty(exports, "__esModule", { value: true });
  118362. var Emitter = monaco.Emitter;
  118363. var LanguageServiceDefaultsImpl = /** @class */ (function () {
  118364. function LanguageServiceDefaultsImpl(compilerOptions, diagnosticsOptions) {
  118365. this._onDidChange = new Emitter();
  118366. this._onDidExtraLibsChange = new Emitter();
  118367. this._extraLibs = Object.create(null);
  118368. this._eagerModelSync = false;
  118369. this.setCompilerOptions(compilerOptions);
  118370. this.setDiagnosticsOptions(diagnosticsOptions);
  118371. this._onDidExtraLibsChangeTimeout = -1;
  118372. }
  118373. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "onDidChange", {
  118374. get: function () {
  118375. return this._onDidChange.event;
  118376. },
  118377. enumerable: true,
  118378. configurable: true
  118379. });
  118380. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "onDidExtraLibsChange", {
  118381. get: function () {
  118382. return this._onDidExtraLibsChange.event;
  118383. },
  118384. enumerable: true,
  118385. configurable: true
  118386. });
  118387. LanguageServiceDefaultsImpl.prototype.getExtraLibs = function () {
  118388. return this._extraLibs;
  118389. };
  118390. LanguageServiceDefaultsImpl.prototype.addExtraLib = function (content, _filePath) {
  118391. var _this = this;
  118392. var filePath;
  118393. if (typeof _filePath === 'undefined') {
  118394. filePath = "ts:extralib-" + Math.random().toString(36).substring(2, 15);
  118395. }
  118396. else {
  118397. filePath = _filePath;
  118398. }
  118399. if (this._extraLibs[filePath] && this._extraLibs[filePath].content === content) {
  118400. // no-op, there already exists an extra lib with this content
  118401. return {
  118402. dispose: function () { }
  118403. };
  118404. }
  118405. var myVersion = 1;
  118406. if (this._extraLibs[filePath]) {
  118407. myVersion = this._extraLibs[filePath].version + 1;
  118408. }
  118409. this._extraLibs[filePath] = {
  118410. content: content,
  118411. version: myVersion,
  118412. };
  118413. this._fireOnDidExtraLibsChangeSoon();
  118414. return {
  118415. dispose: function () {
  118416. var extraLib = _this._extraLibs[filePath];
  118417. if (!extraLib) {
  118418. return;
  118419. }
  118420. if (extraLib.version !== myVersion) {
  118421. return;
  118422. }
  118423. delete _this._extraLibs[filePath];
  118424. _this._fireOnDidExtraLibsChangeSoon();
  118425. }
  118426. };
  118427. };
  118428. LanguageServiceDefaultsImpl.prototype.setExtraLibs = function (libs) {
  118429. // clear out everything
  118430. this._extraLibs = Object.create(null);
  118431. if (libs && libs.length > 0) {
  118432. for (var _i = 0, libs_1 = libs; _i < libs_1.length; _i++) {
  118433. var lib = libs_1[_i];
  118434. var filePath = lib.filePath || "ts:extralib-" + Math.random().toString(36).substring(2, 15);
  118435. var content = lib.content;
  118436. this._extraLibs[filePath] = {
  118437. content: content,
  118438. version: 1
  118439. };
  118440. }
  118441. }
  118442. this._fireOnDidExtraLibsChangeSoon();
  118443. };
  118444. LanguageServiceDefaultsImpl.prototype._fireOnDidExtraLibsChangeSoon = function () {
  118445. var _this = this;
  118446. if (this._onDidExtraLibsChangeTimeout !== -1) {
  118447. // already scheduled
  118448. return;
  118449. }
  118450. this._onDidExtraLibsChangeTimeout = setTimeout(function () {
  118451. _this._onDidExtraLibsChangeTimeout = -1;
  118452. _this._onDidExtraLibsChange.fire(undefined);
  118453. }, 0);
  118454. };
  118455. LanguageServiceDefaultsImpl.prototype.getCompilerOptions = function () {
  118456. return this._compilerOptions;
  118457. };
  118458. LanguageServiceDefaultsImpl.prototype.setCompilerOptions = function (options) {
  118459. this._compilerOptions = options || Object.create(null);
  118460. this._onDidChange.fire(undefined);
  118461. };
  118462. LanguageServiceDefaultsImpl.prototype.getDiagnosticsOptions = function () {
  118463. return this._diagnosticsOptions;
  118464. };
  118465. LanguageServiceDefaultsImpl.prototype.setDiagnosticsOptions = function (options) {
  118466. this._diagnosticsOptions = options || Object.create(null);
  118467. this._onDidChange.fire(undefined);
  118468. };
  118469. LanguageServiceDefaultsImpl.prototype.setMaximumWorkerIdleTime = function (value) {
  118470. };
  118471. LanguageServiceDefaultsImpl.prototype.setEagerModelSync = function (value) {
  118472. // doesn't fire an event since no
  118473. // worker restart is required here
  118474. this._eagerModelSync = value;
  118475. };
  118476. LanguageServiceDefaultsImpl.prototype.getEagerModelSync = function () {
  118477. return this._eagerModelSync;
  118478. };
  118479. return LanguageServiceDefaultsImpl;
  118480. }());
  118481. exports.LanguageServiceDefaultsImpl = LanguageServiceDefaultsImpl;
  118482. //#region enums copied from typescript to prevent loading the entire typescriptServices ---
  118483. var ModuleKind;
  118484. (function (ModuleKind) {
  118485. ModuleKind[ModuleKind["None"] = 0] = "None";
  118486. ModuleKind[ModuleKind["CommonJS"] = 1] = "CommonJS";
  118487. ModuleKind[ModuleKind["AMD"] = 2] = "AMD";
  118488. ModuleKind[ModuleKind["UMD"] = 3] = "UMD";
  118489. ModuleKind[ModuleKind["System"] = 4] = "System";
  118490. ModuleKind[ModuleKind["ES2015"] = 5] = "ES2015";
  118491. ModuleKind[ModuleKind["ESNext"] = 99] = "ESNext";
  118492. })(ModuleKind || (ModuleKind = {}));
  118493. var JsxEmit;
  118494. (function (JsxEmit) {
  118495. JsxEmit[JsxEmit["None"] = 0] = "None";
  118496. JsxEmit[JsxEmit["Preserve"] = 1] = "Preserve";
  118497. JsxEmit[JsxEmit["React"] = 2] = "React";
  118498. JsxEmit[JsxEmit["ReactNative"] = 3] = "ReactNative";
  118499. })(JsxEmit || (JsxEmit = {}));
  118500. var NewLineKind;
  118501. (function (NewLineKind) {
  118502. NewLineKind[NewLineKind["CarriageReturnLineFeed"] = 0] = "CarriageReturnLineFeed";
  118503. NewLineKind[NewLineKind["LineFeed"] = 1] = "LineFeed";
  118504. })(NewLineKind || (NewLineKind = {}));
  118505. var ScriptTarget;
  118506. (function (ScriptTarget) {
  118507. ScriptTarget[ScriptTarget["ES3"] = 0] = "ES3";
  118508. ScriptTarget[ScriptTarget["ES5"] = 1] = "ES5";
  118509. ScriptTarget[ScriptTarget["ES2015"] = 2] = "ES2015";
  118510. ScriptTarget[ScriptTarget["ES2016"] = 3] = "ES2016";
  118511. ScriptTarget[ScriptTarget["ES2017"] = 4] = "ES2017";
  118512. ScriptTarget[ScriptTarget["ES2018"] = 5] = "ES2018";
  118513. ScriptTarget[ScriptTarget["ES2019"] = 6] = "ES2019";
  118514. ScriptTarget[ScriptTarget["ES2020"] = 7] = "ES2020";
  118515. ScriptTarget[ScriptTarget["ESNext"] = 99] = "ESNext";
  118516. ScriptTarget[ScriptTarget["JSON"] = 100] = "JSON";
  118517. ScriptTarget[ScriptTarget["Latest"] = 99] = "Latest";
  118518. })(ScriptTarget || (ScriptTarget = {}));
  118519. var ModuleResolutionKind;
  118520. (function (ModuleResolutionKind) {
  118521. ModuleResolutionKind[ModuleResolutionKind["Classic"] = 1] = "Classic";
  118522. ModuleResolutionKind[ModuleResolutionKind["NodeJs"] = 2] = "NodeJs";
  118523. })(ModuleResolutionKind || (ModuleResolutionKind = {}));
  118524. //#endregion
  118525. var typescriptDefaults = new LanguageServiceDefaultsImpl({ allowNonTsExtensions: true, target: ScriptTarget.Latest }, { noSemanticValidation: false, noSyntaxValidation: false });
  118526. var javascriptDefaults = new LanguageServiceDefaultsImpl({ allowNonTsExtensions: true, allowJs: true, target: ScriptTarget.Latest }, { noSemanticValidation: true, noSyntaxValidation: false });
  118527. function getTypeScriptWorker() {
  118528. return getMode().then(function (mode) { return mode.getTypeScriptWorker(); });
  118529. }
  118530. function getJavaScriptWorker() {
  118531. return getMode().then(function (mode) { return mode.getJavaScriptWorker(); });
  118532. }
  118533. // Export API
  118534. function createAPI() {
  118535. return {
  118536. ModuleKind: ModuleKind,
  118537. JsxEmit: JsxEmit,
  118538. NewLineKind: NewLineKind,
  118539. ScriptTarget: ScriptTarget,
  118540. ModuleResolutionKind: ModuleResolutionKind,
  118541. typescriptVersion: typescriptServicesMetadata_1.typescriptVersion,
  118542. typescriptDefaults: typescriptDefaults,
  118543. javascriptDefaults: javascriptDefaults,
  118544. getTypeScriptWorker: getTypeScriptWorker,
  118545. getJavaScriptWorker: getJavaScriptWorker
  118546. };
  118547. }
  118548. monaco.languages.typescript = createAPI();
  118549. // --- Registration to monaco editor ---
  118550. function getMode() {
  118551. return new Promise(function (resolve_1, reject_1) { require(['./tsMode'], resolve_1, reject_1); });
  118552. }
  118553. monaco.languages.onLanguage('typescript', function () {
  118554. return getMode().then(function (mode) { return mode.setupTypeScript(typescriptDefaults); });
  118555. });
  118556. monaco.languages.onLanguage('javascript', function () {
  118557. return getMode().then(function (mode) { return mode.setupJavaScript(javascriptDefaults); });
  118558. });
  118559. });
  118560. define('vs/language/css/monaco.contribution',["require", "exports","vs/editor/editor.api"], function (require, exports) {
  118561. /*---------------------------------------------------------------------------------------------
  118562. * Copyright (c) Microsoft Corporation. All rights reserved.
  118563. * Licensed under the MIT License. See License.txt in the project root for license information.
  118564. *--------------------------------------------------------------------------------------------*/
  118565. 'use strict';
  118566. Object.defineProperty(exports, "__esModule", { value: true });
  118567. var Emitter = monaco.Emitter;
  118568. // --- CSS configuration and defaults ---------
  118569. var LanguageServiceDefaultsImpl = /** @class */ (function () {
  118570. function LanguageServiceDefaultsImpl(languageId, diagnosticsOptions, modeConfiguration) {
  118571. this._onDidChange = new Emitter();
  118572. this._languageId = languageId;
  118573. this.setDiagnosticsOptions(diagnosticsOptions);
  118574. this.setModeConfiguration(modeConfiguration);
  118575. }
  118576. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "onDidChange", {
  118577. get: function () {
  118578. return this._onDidChange.event;
  118579. },
  118580. enumerable: true,
  118581. configurable: true
  118582. });
  118583. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "languageId", {
  118584. get: function () {
  118585. return this._languageId;
  118586. },
  118587. enumerable: true,
  118588. configurable: true
  118589. });
  118590. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "modeConfiguration", {
  118591. get: function () {
  118592. return this._modeConfiguration;
  118593. },
  118594. enumerable: true,
  118595. configurable: true
  118596. });
  118597. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "diagnosticsOptions", {
  118598. get: function () {
  118599. return this._diagnosticsOptions;
  118600. },
  118601. enumerable: true,
  118602. configurable: true
  118603. });
  118604. LanguageServiceDefaultsImpl.prototype.setDiagnosticsOptions = function (options) {
  118605. this._diagnosticsOptions = options || Object.create(null);
  118606. this._onDidChange.fire(this);
  118607. };
  118608. LanguageServiceDefaultsImpl.prototype.setModeConfiguration = function (modeConfiguration) {
  118609. this._modeConfiguration = modeConfiguration || Object.create(null);
  118610. this._onDidChange.fire(this);
  118611. };
  118612. ;
  118613. return LanguageServiceDefaultsImpl;
  118614. }());
  118615. exports.LanguageServiceDefaultsImpl = LanguageServiceDefaultsImpl;
  118616. var diagnosticDefault = {
  118617. validate: true,
  118618. lint: {
  118619. compatibleVendorPrefixes: 'ignore',
  118620. vendorPrefix: 'warning',
  118621. duplicateProperties: 'warning',
  118622. emptyRules: 'warning',
  118623. importStatement: 'ignore',
  118624. boxModel: 'ignore',
  118625. universalSelector: 'ignore',
  118626. zeroUnits: 'ignore',
  118627. fontFaceProperties: 'warning',
  118628. hexColorLength: 'error',
  118629. argumentsInColorFunction: 'error',
  118630. unknownProperties: 'warning',
  118631. ieHack: 'ignore',
  118632. unknownVendorSpecificProperties: 'ignore',
  118633. propertyIgnoredDueToDisplay: 'warning',
  118634. important: 'ignore',
  118635. float: 'ignore',
  118636. idSelector: 'ignore'
  118637. }
  118638. };
  118639. var modeConfigurationDefault = {
  118640. completionItems: true,
  118641. hovers: true,
  118642. documentSymbols: true,
  118643. definitions: true,
  118644. references: true,
  118645. documentHighlights: true,
  118646. rename: true,
  118647. colors: true,
  118648. foldingRanges: true,
  118649. diagnostics: true,
  118650. selectionRanges: true
  118651. };
  118652. var cssDefaults = new LanguageServiceDefaultsImpl('css', diagnosticDefault, modeConfigurationDefault);
  118653. var scssDefaults = new LanguageServiceDefaultsImpl('scss', diagnosticDefault, modeConfigurationDefault);
  118654. var lessDefaults = new LanguageServiceDefaultsImpl('less', diagnosticDefault, modeConfigurationDefault);
  118655. // Export API
  118656. function createAPI() {
  118657. return {
  118658. cssDefaults: cssDefaults,
  118659. lessDefaults: lessDefaults,
  118660. scssDefaults: scssDefaults
  118661. };
  118662. }
  118663. monaco.languages.css = createAPI();
  118664. // --- Registration to monaco editor ---
  118665. function getMode() {
  118666. return new Promise(function (resolve_1, reject_1) { require(['./cssMode'], resolve_1, reject_1); });
  118667. }
  118668. monaco.languages.onLanguage('less', function () {
  118669. getMode().then(function (mode) { return mode.setupMode(lessDefaults); });
  118670. });
  118671. monaco.languages.onLanguage('scss', function () {
  118672. getMode().then(function (mode) { return mode.setupMode(scssDefaults); });
  118673. });
  118674. monaco.languages.onLanguage('css', function () {
  118675. getMode().then(function (mode) { return mode.setupMode(cssDefaults); });
  118676. });
  118677. });
  118678. define('vs/language/json/monaco.contribution',["require", "exports","vs/editor/editor.api"], function (require, exports) {
  118679. /*---------------------------------------------------------------------------------------------
  118680. * Copyright (c) Microsoft Corporation. All rights reserved.
  118681. * Licensed under the MIT License. See License.txt in the project root for license information.
  118682. *--------------------------------------------------------------------------------------------*/
  118683. 'use strict';
  118684. Object.defineProperty(exports, "__esModule", { value: true });
  118685. var Emitter = monaco.Emitter;
  118686. // --- JSON configuration and defaults ---------
  118687. var LanguageServiceDefaultsImpl = /** @class */ (function () {
  118688. function LanguageServiceDefaultsImpl(languageId, diagnosticsOptions, modeConfiguration) {
  118689. this._onDidChange = new Emitter();
  118690. this._languageId = languageId;
  118691. this.setDiagnosticsOptions(diagnosticsOptions);
  118692. this.setModeConfiguration(modeConfiguration);
  118693. }
  118694. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "onDidChange", {
  118695. get: function () {
  118696. return this._onDidChange.event;
  118697. },
  118698. enumerable: true,
  118699. configurable: true
  118700. });
  118701. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "languageId", {
  118702. get: function () {
  118703. return this._languageId;
  118704. },
  118705. enumerable: true,
  118706. configurable: true
  118707. });
  118708. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "modeConfiguration", {
  118709. get: function () {
  118710. return this._modeConfiguration;
  118711. },
  118712. enumerable: true,
  118713. configurable: true
  118714. });
  118715. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "diagnosticsOptions", {
  118716. get: function () {
  118717. return this._diagnosticsOptions;
  118718. },
  118719. enumerable: true,
  118720. configurable: true
  118721. });
  118722. LanguageServiceDefaultsImpl.prototype.setDiagnosticsOptions = function (options) {
  118723. this._diagnosticsOptions = options || Object.create(null);
  118724. this._onDidChange.fire(this);
  118725. };
  118726. LanguageServiceDefaultsImpl.prototype.setModeConfiguration = function (modeConfiguration) {
  118727. this._modeConfiguration = modeConfiguration || Object.create(null);
  118728. this._onDidChange.fire(this);
  118729. };
  118730. ;
  118731. return LanguageServiceDefaultsImpl;
  118732. }());
  118733. exports.LanguageServiceDefaultsImpl = LanguageServiceDefaultsImpl;
  118734. var diagnosticDefault = {
  118735. validate: true,
  118736. allowComments: true,
  118737. schemas: [],
  118738. enableSchemaRequest: false
  118739. };
  118740. var modeConfigurationDefault = {
  118741. documentFormattingEdits: true,
  118742. documentRangeFormattingEdits: true,
  118743. completionItems: true,
  118744. hovers: true,
  118745. documentSymbols: true,
  118746. tokens: true,
  118747. colors: true,
  118748. foldingRanges: true,
  118749. diagnostics: true,
  118750. selectionRanges: true
  118751. };
  118752. var jsonDefaults = new LanguageServiceDefaultsImpl('json', diagnosticDefault, modeConfigurationDefault);
  118753. // Export API
  118754. function createAPI() {
  118755. return {
  118756. jsonDefaults: jsonDefaults
  118757. };
  118758. }
  118759. monaco.languages.json = createAPI();
  118760. // --- Registration to monaco editor ---
  118761. function getMode() {
  118762. return new Promise(function (resolve_1, reject_1) { require(['./jsonMode'], resolve_1, reject_1); });
  118763. }
  118764. monaco.languages.register({
  118765. id: 'json',
  118766. extensions: ['.json', '.bowerrc', '.jshintrc', '.jscsrc', '.eslintrc', '.babelrc', '.har'],
  118767. aliases: ['JSON', 'json'],
  118768. mimetypes: ['application/json'],
  118769. });
  118770. monaco.languages.onLanguage('json', function () {
  118771. getMode().then(function (mode) { return mode.setupMode(jsonDefaults); });
  118772. });
  118773. });
  118774. define('vs/language/html/monaco.contribution',["require", "exports","vs/editor/editor.api"], function (require, exports) {
  118775. /*---------------------------------------------------------------------------------------------
  118776. * Copyright (c) Microsoft Corporation. All rights reserved.
  118777. * Licensed under the MIT License. See License.txt in the project root for license information.
  118778. *--------------------------------------------------------------------------------------------*/
  118779. 'use strict';
  118780. Object.defineProperty(exports, "__esModule", { value: true });
  118781. var Emitter = monaco.Emitter;
  118782. // --- HTML configuration and defaults ---------
  118783. var LanguageServiceDefaultsImpl = /** @class */ (function () {
  118784. function LanguageServiceDefaultsImpl(languageId, options, modeConfiguration) {
  118785. this._onDidChange = new Emitter();
  118786. this._languageId = languageId;
  118787. this.setOptions(options);
  118788. this.setModeConfiguration(modeConfiguration);
  118789. }
  118790. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "onDidChange", {
  118791. get: function () {
  118792. return this._onDidChange.event;
  118793. },
  118794. enumerable: true,
  118795. configurable: true
  118796. });
  118797. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "languageId", {
  118798. get: function () {
  118799. return this._languageId;
  118800. },
  118801. enumerable: true,
  118802. configurable: true
  118803. });
  118804. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "options", {
  118805. get: function () {
  118806. return this._options;
  118807. },
  118808. enumerable: true,
  118809. configurable: true
  118810. });
  118811. Object.defineProperty(LanguageServiceDefaultsImpl.prototype, "modeConfiguration", {
  118812. get: function () {
  118813. return this._modeConfiguration;
  118814. },
  118815. enumerable: true,
  118816. configurable: true
  118817. });
  118818. LanguageServiceDefaultsImpl.prototype.setOptions = function (options) {
  118819. this._options = options || Object.create(null);
  118820. this._onDidChange.fire(this);
  118821. };
  118822. LanguageServiceDefaultsImpl.prototype.setModeConfiguration = function (modeConfiguration) {
  118823. this._modeConfiguration = modeConfiguration || Object.create(null);
  118824. this._onDidChange.fire(this);
  118825. };
  118826. ;
  118827. return LanguageServiceDefaultsImpl;
  118828. }());
  118829. exports.LanguageServiceDefaultsImpl = LanguageServiceDefaultsImpl;
  118830. var formatDefaults = {
  118831. tabSize: 4,
  118832. insertSpaces: false,
  118833. wrapLineLength: 120,
  118834. unformatted: 'default": "a, abbr, acronym, b, bdo, big, br, button, cite, code, dfn, em, i, img, input, kbd, label, map, object, q, samp, select, small, span, strong, sub, sup, textarea, tt, var',
  118835. contentUnformatted: 'pre',
  118836. indentInnerHtml: false,
  118837. preserveNewLines: true,
  118838. maxPreserveNewLines: null,
  118839. indentHandlebars: false,
  118840. endWithNewline: false,
  118841. extraLiners: 'head, body, /html',
  118842. wrapAttributes: 'auto'
  118843. };
  118844. var htmlOptionsDefault = {
  118845. format: formatDefaults,
  118846. suggest: { html5: true, angular1: true, ionic: true }
  118847. };
  118848. var handlebarOptionsDefault = {
  118849. format: formatDefaults,
  118850. suggest: { html5: true }
  118851. };
  118852. var razorOptionsDefault = {
  118853. format: formatDefaults,
  118854. suggest: { html5: true, razor: true }
  118855. };
  118856. function getConfigurationDefault(languageId) {
  118857. return {
  118858. completionItems: true,
  118859. hovers: true,
  118860. documentSymbols: true,
  118861. links: true,
  118862. documentHighlights: true,
  118863. rename: true,
  118864. colors: true,
  118865. foldingRanges: true,
  118866. selectionRanges: true,
  118867. diagnostics: languageId === htmlLanguageId,
  118868. documentFormattingEdits: languageId === htmlLanguageId,
  118869. documentRangeFormattingEdits: languageId === htmlLanguageId // turned off for Razor and Handlebar
  118870. };
  118871. }
  118872. var htmlLanguageId = 'html';
  118873. var handlebarsLanguageId = 'handlebars';
  118874. var razorLanguageId = 'razor';
  118875. var htmlDefaults = new LanguageServiceDefaultsImpl(htmlLanguageId, htmlOptionsDefault, getConfigurationDefault(htmlLanguageId));
  118876. var handlebarDefaults = new LanguageServiceDefaultsImpl(handlebarsLanguageId, handlebarOptionsDefault, getConfigurationDefault(handlebarsLanguageId));
  118877. var razorDefaults = new LanguageServiceDefaultsImpl(razorLanguageId, razorOptionsDefault, getConfigurationDefault(razorLanguageId));
  118878. // Export API
  118879. function createAPI() {
  118880. return {
  118881. htmlDefaults: htmlDefaults,
  118882. razorDefaults: razorDefaults,
  118883. handlebarDefaults: handlebarDefaults
  118884. };
  118885. }
  118886. monaco.languages.html = createAPI();
  118887. // --- Registration to monaco editor ---
  118888. function getMode() {
  118889. return new Promise(function (resolve_1, reject_1) { require(['./htmlMode'], resolve_1, reject_1); });
  118890. }
  118891. monaco.languages.onLanguage(htmlLanguageId, function () {
  118892. getMode().then(function (mode) { return mode.setupMode(htmlDefaults); });
  118893. });
  118894. monaco.languages.onLanguage(handlebarsLanguageId, function () {
  118895. getMode().then(function (mode) { return mode.setupMode(handlebarDefaults); });
  118896. });
  118897. monaco.languages.onLanguage(razorLanguageId, function () {
  118898. getMode().then(function (mode) { return mode.setupMode(razorDefaults); });
  118899. });
  118900. });
  118901. define("vs/basic-languages/monaco.contribution",["require", "exports", "./abap/abap.contribution", "./apex/apex.contribution", "./azcli/azcli.contribution", "./bat/bat.contribution", "./cameligo/cameligo.contribution", "./clojure/clojure.contribution", "./coffee/coffee.contribution", "./cpp/cpp.contribution", "./csharp/csharp.contribution", "./csp/csp.contribution", "./css/css.contribution", "./dockerfile/dockerfile.contribution", "./fsharp/fsharp.contribution", "./go/go.contribution", "./graphql/graphql.contribution", "./handlebars/handlebars.contribution", "./html/html.contribution", "./ini/ini.contribution", "./java/java.contribution", "./javascript/javascript.contribution", "./kotlin/kotlin.contribution", "./less/less.contribution", "./lua/lua.contribution", "./markdown/markdown.contribution", "./mips/mips.contribution", "./msdax/msdax.contribution", "./mysql/mysql.contribution", "./objective-c/objective-c.contribution", "./pascal/pascal.contribution", "./pascaligo/pascaligo.contribution", "./perl/perl.contribution", "./pgsql/pgsql.contribution", "./php/php.contribution", "./postiats/postiats.contribution", "./powerquery/powerquery.contribution", "./powershell/powershell.contribution", "./pug/pug.contribution", "./python/python.contribution", "./r/r.contribution", "./razor/razor.contribution", "./redis/redis.contribution", "./redshift/redshift.contribution", "./restructuredtext/restructuredtext.contribution", "./ruby/ruby.contribution", "./rust/rust.contribution", "./sb/sb.contribution", "./scheme/scheme.contribution", "./scss/scss.contribution", "./shell/shell.contribution", "./solidity/solidity.contribution", "./sophia/sophia.contribution", "./sql/sql.contribution", "./st/st.contribution", "./swift/swift.contribution", "./tcl/tcl.contribution", "./twig/twig.contribution", "./typescript/typescript.contribution", "./vb/vb.contribution", "./xml/xml.contribution", "./yaml/yaml.contribution","vs/editor/editor.api"], function (require, exports) {
  118902. /*---------------------------------------------------------------------------------------------
  118903. * Copyright (c) Microsoft Corporation. All rights reserved.
  118904. * Licensed under the MIT License. See License.txt in the project root for license information.
  118905. *--------------------------------------------------------------------------------------------*/
  118906. 'use strict';
  118907. Object.defineProperty(exports, "__esModule", { value: true });
  118908. });
  118909. define("vs/editor/editor.main", ["vs/editor/edcore.main","vs/language/typescript/monaco.contribution","vs/language/css/monaco.contribution","vs/language/json/monaco.contribution","vs/language/html/monaco.contribution","vs/basic-languages/monaco.contribution"], function(api) { return api; });
  118910. //# sourceMappingURL=editor.main.js.map