monaco.d.ts 230 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719
  1. /*---------------------------------------------------------------------------------------------
  2. * Copyright (c) Microsoft Corporation. All rights reserved.
  3. * Licensed under the MIT License. See License.txt in the project root for license information.
  4. *--------------------------------------------------------------------------------------------*/
  5. declare let MonacoEnvironment: monaco.Environment | undefined;
  6. interface Window {
  7. MonacoEnvironment?: monaco.Environment | undefined;
  8. }
  9. declare namespace monaco {
  10. export type Thenable<T> = PromiseLike<T>;
  11. export interface Environment {
  12. globalAPI?: boolean;
  13. baseUrl?: string;
  14. getWorker?(workerId: string, label: string): Promise<Worker> | Worker;
  15. getWorkerUrl?(workerId: string, label: string): string;
  16. }
  17. export interface IDisposable {
  18. dispose(): void;
  19. }
  20. export interface IEvent<T> {
  21. (listener: (e: T) => any, thisArg?: any): IDisposable;
  22. }
  23. /**
  24. * A helper that allows to emit and listen to typed events
  25. */
  26. export class Emitter<T> {
  27. constructor();
  28. readonly event: IEvent<T>;
  29. fire(event: T): void;
  30. dispose(): void;
  31. }
  32. export enum MarkerTag {
  33. Unnecessary = 1,
  34. Deprecated = 2
  35. }
  36. export enum MarkerSeverity {
  37. Hint = 1,
  38. Info = 2,
  39. Warning = 4,
  40. Error = 8
  41. }
  42. export class CancellationTokenSource {
  43. constructor(parent?: CancellationToken);
  44. get token(): CancellationToken;
  45. cancel(): void;
  46. dispose(cancel?: boolean): void;
  47. }
  48. export interface CancellationToken {
  49. /**
  50. * A flag signalling is cancellation has been requested.
  51. */
  52. readonly isCancellationRequested: boolean;
  53. /**
  54. * An event which fires when cancellation is requested. This event
  55. * only ever fires `once` as cancellation can only happen once. Listeners
  56. * that are registered after cancellation will be called (next event loop run),
  57. * but also only once.
  58. *
  59. * @event
  60. */
  61. readonly onCancellationRequested: (listener: (e: any) => any, thisArgs?: any, disposables?: IDisposable[]) => IDisposable;
  62. }
  63. /**
  64. * Uniform Resource Identifier (Uri) http://tools.ietf.org/html/rfc3986.
  65. * This class is a simple parser which creates the basic component parts
  66. * (http://tools.ietf.org/html/rfc3986#section-3) with minimal validation
  67. * and encoding.
  68. *
  69. * ```txt
  70. * foo://example.com:8042/over/there?name=ferret#nose
  71. * \_/ \______________/\_________/ \_________/ \__/
  72. * | | | | |
  73. * scheme authority path query fragment
  74. * | _____________________|__
  75. * / \ / \
  76. * urn:example:animal:ferret:nose
  77. * ```
  78. */
  79. export class Uri implements UriComponents {
  80. static isUri(thing: any): thing is Uri;
  81. /**
  82. * scheme is the 'http' part of 'http://www.example.com/some/path?query#fragment'.
  83. * The part before the first colon.
  84. */
  85. readonly scheme: string;
  86. /**
  87. * authority is the 'www.example.com' part of 'http://www.example.com/some/path?query#fragment'.
  88. * The part between the first double slashes and the next slash.
  89. */
  90. readonly authority: string;
  91. /**
  92. * path is the '/some/path' part of 'http://www.example.com/some/path?query#fragment'.
  93. */
  94. readonly path: string;
  95. /**
  96. * query is the 'query' part of 'http://www.example.com/some/path?query#fragment'.
  97. */
  98. readonly query: string;
  99. /**
  100. * fragment is the 'fragment' part of 'http://www.example.com/some/path?query#fragment'.
  101. */
  102. readonly fragment: string;
  103. /**
  104. * Returns a string representing the corresponding file system path of this Uri.
  105. * Will handle UNC paths, normalizes windows drive letters to lower-case, and uses the
  106. * platform specific path separator.
  107. *
  108. * * Will *not* validate the path for invalid characters and semantics.
  109. * * Will *not* look at the scheme of this Uri.
  110. * * The result shall *not* be used for display purposes but for accessing a file on disk.
  111. *
  112. *
  113. * The *difference* to `Uri#path` is the use of the platform specific separator and the handling
  114. * of UNC paths. See the below sample of a file-uri with an authority (UNC path).
  115. *
  116. * ```ts
  117. const u = Uri.parse('file://server/c$/folder/file.txt')
  118. u.authority === 'server'
  119. u.path === '/shares/c$/file.txt'
  120. u.fsPath === '\\server\c$\folder\file.txt'
  121. ```
  122. *
  123. * Using `Uri#path` to read a file (using fs-apis) would not be enough because parts of the path,
  124. * namely the server name, would be missing. Therefore `Uri#fsPath` exists - it's sugar to ease working
  125. * with URIs that represent files on disk (`file` scheme).
  126. */
  127. get fsPath(): string;
  128. with(change: {
  129. scheme?: string;
  130. authority?: string | null;
  131. path?: string | null;
  132. query?: string | null;
  133. fragment?: string | null;
  134. }): Uri;
  135. /**
  136. * Creates a new Uri from a string, e.g. `http://www.example.com/some/path`,
  137. * `file:///usr/home`, or `scheme:with/path`.
  138. *
  139. * @param value A string which represents an Uri (see `Uri#toString`).
  140. */
  141. static parse(value: string, _strict?: boolean): Uri;
  142. /**
  143. * Creates a new Uri from a file system path, e.g. `c:\my\files`,
  144. * `/usr/home`, or `\\server\share\some\path`.
  145. *
  146. * The *difference* between `Uri#parse` and `Uri#file` is that the latter treats the argument
  147. * as path, not as stringified-uri. E.g. `Uri.file(path)` is **not the same as**
  148. * `Uri.parse('file://' + path)` because the path might contain characters that are
  149. * interpreted (# and ?). See the following sample:
  150. * ```ts
  151. const good = Uri.file('/coding/c#/project1');
  152. good.scheme === 'file';
  153. good.path === '/coding/c#/project1';
  154. good.fragment === '';
  155. const bad = Uri.parse('file://' + '/coding/c#/project1');
  156. bad.scheme === 'file';
  157. bad.path === '/coding/c'; // path is now broken
  158. bad.fragment === '/project1';
  159. ```
  160. *
  161. * @param path A file system path (see `Uri#fsPath`)
  162. */
  163. static file(path: string): Uri;
  164. static from(components: {
  165. scheme: string;
  166. authority?: string;
  167. path?: string;
  168. query?: string;
  169. fragment?: string;
  170. }): Uri;
  171. /**
  172. * Join a Uri path with path fragments and normalizes the resulting path.
  173. *
  174. * @param uri The input Uri.
  175. * @param pathFragment The path fragment to add to the Uri path.
  176. * @returns The resulting Uri.
  177. */
  178. static joinPath(uri: Uri, ...pathFragment: string[]): Uri;
  179. /**
  180. * Creates a string representation for this Uri. It's guaranteed that calling
  181. * `Uri.parse` with the result of this function creates an Uri which is equal
  182. * to this Uri.
  183. *
  184. * * The result shall *not* be used for display purposes but for externalization or transport.
  185. * * The result will be encoded using the percentage encoding and encoding happens mostly
  186. * ignore the scheme-specific encoding rules.
  187. *
  188. * @param skipEncoding Do not encode the result, default is `false`
  189. */
  190. toString(skipEncoding?: boolean): string;
  191. toJSON(): UriComponents;
  192. static revive(data: UriComponents | Uri): Uri;
  193. static revive(data: UriComponents | Uri | undefined): Uri | undefined;
  194. static revive(data: UriComponents | Uri | null): Uri | null;
  195. static revive(data: UriComponents | Uri | undefined | null): Uri | undefined | null;
  196. }
  197. export interface UriComponents {
  198. scheme: string;
  199. authority: string;
  200. path: string;
  201. query: string;
  202. fragment: string;
  203. }
  204. /**
  205. * Virtual Key Codes, the value does not hold any inherent meaning.
  206. * Inspired somewhat from https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731(v=vs.85).aspx
  207. * But these are "more general", as they should work across browsers & OS`s.
  208. */
  209. export enum KeyCode {
  210. DependsOnKbLayout = -1,
  211. /**
  212. * Placed first to cover the 0 value of the enum.
  213. */
  214. Unknown = 0,
  215. Backspace = 1,
  216. Tab = 2,
  217. Enter = 3,
  218. Shift = 4,
  219. Ctrl = 5,
  220. Alt = 6,
  221. PauseBreak = 7,
  222. CapsLock = 8,
  223. Escape = 9,
  224. Space = 10,
  225. PageUp = 11,
  226. PageDown = 12,
  227. End = 13,
  228. Home = 14,
  229. LeftArrow = 15,
  230. UpArrow = 16,
  231. RightArrow = 17,
  232. DownArrow = 18,
  233. Insert = 19,
  234. Delete = 20,
  235. Digit0 = 21,
  236. Digit1 = 22,
  237. Digit2 = 23,
  238. Digit3 = 24,
  239. Digit4 = 25,
  240. Digit5 = 26,
  241. Digit6 = 27,
  242. Digit7 = 28,
  243. Digit8 = 29,
  244. Digit9 = 30,
  245. KeyA = 31,
  246. KeyB = 32,
  247. KeyC = 33,
  248. KeyD = 34,
  249. KeyE = 35,
  250. KeyF = 36,
  251. KeyG = 37,
  252. KeyH = 38,
  253. KeyI = 39,
  254. KeyJ = 40,
  255. KeyK = 41,
  256. KeyL = 42,
  257. KeyM = 43,
  258. KeyN = 44,
  259. KeyO = 45,
  260. KeyP = 46,
  261. KeyQ = 47,
  262. KeyR = 48,
  263. KeyS = 49,
  264. KeyT = 50,
  265. KeyU = 51,
  266. KeyV = 52,
  267. KeyW = 53,
  268. KeyX = 54,
  269. KeyY = 55,
  270. KeyZ = 56,
  271. Meta = 57,
  272. ContextMenu = 58,
  273. F1 = 59,
  274. F2 = 60,
  275. F3 = 61,
  276. F4 = 62,
  277. F5 = 63,
  278. F6 = 64,
  279. F7 = 65,
  280. F8 = 66,
  281. F9 = 67,
  282. F10 = 68,
  283. F11 = 69,
  284. F12 = 70,
  285. F13 = 71,
  286. F14 = 72,
  287. F15 = 73,
  288. F16 = 74,
  289. F17 = 75,
  290. F18 = 76,
  291. F19 = 77,
  292. NumLock = 78,
  293. ScrollLock = 79,
  294. /**
  295. * Used for miscellaneous characters; it can vary by keyboard.
  296. * For the US standard keyboard, the ';:' key
  297. */
  298. Semicolon = 80,
  299. /**
  300. * For any country/region, the '+' key
  301. * For the US standard keyboard, the '=+' key
  302. */
  303. Equal = 81,
  304. /**
  305. * For any country/region, the ',' key
  306. * For the US standard keyboard, the ',<' key
  307. */
  308. Comma = 82,
  309. /**
  310. * For any country/region, the '-' key
  311. * For the US standard keyboard, the '-_' key
  312. */
  313. Minus = 83,
  314. /**
  315. * For any country/region, the '.' key
  316. * For the US standard keyboard, the '.>' key
  317. */
  318. Period = 84,
  319. /**
  320. * Used for miscellaneous characters; it can vary by keyboard.
  321. * For the US standard keyboard, the '/?' key
  322. */
  323. Slash = 85,
  324. /**
  325. * Used for miscellaneous characters; it can vary by keyboard.
  326. * For the US standard keyboard, the '`~' key
  327. */
  328. Backquote = 86,
  329. /**
  330. * Used for miscellaneous characters; it can vary by keyboard.
  331. * For the US standard keyboard, the '[{' key
  332. */
  333. BracketLeft = 87,
  334. /**
  335. * Used for miscellaneous characters; it can vary by keyboard.
  336. * For the US standard keyboard, the '\|' key
  337. */
  338. Backslash = 88,
  339. /**
  340. * Used for miscellaneous characters; it can vary by keyboard.
  341. * For the US standard keyboard, the ']}' key
  342. */
  343. BracketRight = 89,
  344. /**
  345. * Used for miscellaneous characters; it can vary by keyboard.
  346. * For the US standard keyboard, the ''"' key
  347. */
  348. Quote = 90,
  349. /**
  350. * Used for miscellaneous characters; it can vary by keyboard.
  351. */
  352. OEM_8 = 91,
  353. /**
  354. * Either the angle bracket key or the backslash key on the RT 102-key keyboard.
  355. */
  356. IntlBackslash = 92,
  357. Numpad0 = 93,
  358. Numpad1 = 94,
  359. Numpad2 = 95,
  360. Numpad3 = 96,
  361. Numpad4 = 97,
  362. Numpad5 = 98,
  363. Numpad6 = 99,
  364. Numpad7 = 100,
  365. Numpad8 = 101,
  366. Numpad9 = 102,
  367. NumpadMultiply = 103,
  368. NumpadAdd = 104,
  369. NUMPAD_SEPARATOR = 105,
  370. NumpadSubtract = 106,
  371. NumpadDecimal = 107,
  372. NumpadDivide = 108,
  373. /**
  374. * Cover all key codes when IME is processing input.
  375. */
  376. KEY_IN_COMPOSITION = 109,
  377. ABNT_C1 = 110,
  378. ABNT_C2 = 111,
  379. AudioVolumeMute = 112,
  380. AudioVolumeUp = 113,
  381. AudioVolumeDown = 114,
  382. BrowserSearch = 115,
  383. BrowserHome = 116,
  384. BrowserBack = 117,
  385. BrowserForward = 118,
  386. MediaTrackNext = 119,
  387. MediaTrackPrevious = 120,
  388. MediaStop = 121,
  389. MediaPlayPause = 122,
  390. LaunchMediaPlayer = 123,
  391. LaunchMail = 124,
  392. LaunchApp2 = 125,
  393. /**
  394. * VK_CLEAR, 0x0C, CLEAR key
  395. */
  396. Clear = 126,
  397. /**
  398. * Placed last to cover the length of the enum.
  399. * Please do not depend on this value!
  400. */
  401. MAX_VALUE = 127
  402. }
  403. export class KeyMod {
  404. static readonly CtrlCmd: number;
  405. static readonly Shift: number;
  406. static readonly Alt: number;
  407. static readonly WinCtrl: number;
  408. static chord(firstPart: number, secondPart: number): number;
  409. }
  410. export interface IMarkdownString {
  411. readonly value: string;
  412. readonly isTrusted?: boolean | MarkdownStringTrustedOptions;
  413. readonly supportThemeIcons?: boolean;
  414. readonly supportHtml?: boolean;
  415. readonly baseUri?: UriComponents;
  416. uris?: {
  417. [href: string]: UriComponents;
  418. };
  419. }
  420. export interface MarkdownStringTrustedOptions {
  421. readonly enabledCommands: readonly string[];
  422. }
  423. export interface IKeyboardEvent {
  424. readonly _standardKeyboardEventBrand: true;
  425. readonly browserEvent: KeyboardEvent;
  426. readonly target: HTMLElement;
  427. readonly ctrlKey: boolean;
  428. readonly shiftKey: boolean;
  429. readonly altKey: boolean;
  430. readonly metaKey: boolean;
  431. readonly altGraphKey: boolean;
  432. readonly keyCode: KeyCode;
  433. readonly code: string;
  434. equals(keybinding: number): boolean;
  435. preventDefault(): void;
  436. stopPropagation(): void;
  437. }
  438. export interface IMouseEvent {
  439. readonly browserEvent: MouseEvent;
  440. readonly leftButton: boolean;
  441. readonly middleButton: boolean;
  442. readonly rightButton: boolean;
  443. readonly buttons: number;
  444. readonly target: HTMLElement;
  445. readonly detail: number;
  446. readonly posx: number;
  447. readonly posy: number;
  448. readonly ctrlKey: boolean;
  449. readonly shiftKey: boolean;
  450. readonly altKey: boolean;
  451. readonly metaKey: boolean;
  452. readonly timestamp: number;
  453. preventDefault(): void;
  454. stopPropagation(): void;
  455. }
  456. export interface IScrollEvent {
  457. readonly scrollTop: number;
  458. readonly scrollLeft: number;
  459. readonly scrollWidth: number;
  460. readonly scrollHeight: number;
  461. readonly scrollTopChanged: boolean;
  462. readonly scrollLeftChanged: boolean;
  463. readonly scrollWidthChanged: boolean;
  464. readonly scrollHeightChanged: boolean;
  465. }
  466. /**
  467. * A position in the editor. This interface is suitable for serialization.
  468. */
  469. export interface IPosition {
  470. /**
  471. * line number (starts at 1)
  472. */
  473. readonly lineNumber: number;
  474. /**
  475. * column (the first character in a line is between column 1 and column 2)
  476. */
  477. readonly column: number;
  478. }
  479. /**
  480. * A position in the editor.
  481. */
  482. export class Position {
  483. /**
  484. * line number (starts at 1)
  485. */
  486. readonly lineNumber: number;
  487. /**
  488. * column (the first character in a line is between column 1 and column 2)
  489. */
  490. readonly column: number;
  491. constructor(lineNumber: number, column: number);
  492. /**
  493. * Create a new position from this position.
  494. *
  495. * @param newLineNumber new line number
  496. * @param newColumn new column
  497. */
  498. with(newLineNumber?: number, newColumn?: number): Position;
  499. /**
  500. * Derive a new position from this position.
  501. *
  502. * @param deltaLineNumber line number delta
  503. * @param deltaColumn column delta
  504. */
  505. delta(deltaLineNumber?: number, deltaColumn?: number): Position;
  506. /**
  507. * Test if this position equals other position
  508. */
  509. equals(other: IPosition): boolean;
  510. /**
  511. * Test if position `a` equals position `b`
  512. */
  513. static equals(a: IPosition | null, b: IPosition | null): boolean;
  514. /**
  515. * Test if this position is before other position.
  516. * If the two positions are equal, the result will be false.
  517. */
  518. isBefore(other: IPosition): boolean;
  519. /**
  520. * Test if position `a` is before position `b`.
  521. * If the two positions are equal, the result will be false.
  522. */
  523. static isBefore(a: IPosition, b: IPosition): boolean;
  524. /**
  525. * Test if this position is before other position.
  526. * If the two positions are equal, the result will be true.
  527. */
  528. isBeforeOrEqual(other: IPosition): boolean;
  529. /**
  530. * Test if position `a` is before position `b`.
  531. * If the two positions are equal, the result will be true.
  532. */
  533. static isBeforeOrEqual(a: IPosition, b: IPosition): boolean;
  534. /**
  535. * A function that compares positions, useful for sorting
  536. */
  537. static compare(a: IPosition, b: IPosition): number;
  538. /**
  539. * Clone this position.
  540. */
  541. clone(): Position;
  542. /**
  543. * Convert to a human-readable representation.
  544. */
  545. toString(): string;
  546. /**
  547. * Create a `Position` from an `IPosition`.
  548. */
  549. static lift(pos: IPosition): Position;
  550. /**
  551. * Test if `obj` is an `IPosition`.
  552. */
  553. static isIPosition(obj: any): obj is IPosition;
  554. }
  555. /**
  556. * A range in the editor. This interface is suitable for serialization.
  557. */
  558. export interface IRange {
  559. /**
  560. * Line number on which the range starts (starts at 1).
  561. */
  562. readonly startLineNumber: number;
  563. /**
  564. * Column on which the range starts in line `startLineNumber` (starts at 1).
  565. */
  566. readonly startColumn: number;
  567. /**
  568. * Line number on which the range ends.
  569. */
  570. readonly endLineNumber: number;
  571. /**
  572. * Column on which the range ends in line `endLineNumber`.
  573. */
  574. readonly endColumn: number;
  575. }
  576. /**
  577. * A range in the editor. (startLineNumber,startColumn) is <= (endLineNumber,endColumn)
  578. */
  579. export class Range {
  580. /**
  581. * Line number on which the range starts (starts at 1).
  582. */
  583. readonly startLineNumber: number;
  584. /**
  585. * Column on which the range starts in line `startLineNumber` (starts at 1).
  586. */
  587. readonly startColumn: number;
  588. /**
  589. * Line number on which the range ends.
  590. */
  591. readonly endLineNumber: number;
  592. /**
  593. * Column on which the range ends in line `endLineNumber`.
  594. */
  595. readonly endColumn: number;
  596. constructor(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number);
  597. /**
  598. * Test if this range is empty.
  599. */
  600. isEmpty(): boolean;
  601. /**
  602. * Test if `range` is empty.
  603. */
  604. static isEmpty(range: IRange): boolean;
  605. /**
  606. * Test if position is in this range. If the position is at the edges, will return true.
  607. */
  608. containsPosition(position: IPosition): boolean;
  609. /**
  610. * Test if `position` is in `range`. If the position is at the edges, will return true.
  611. */
  612. static containsPosition(range: IRange, position: IPosition): boolean;
  613. /**
  614. * Test if range is in this range. If the range is equal to this range, will return true.
  615. */
  616. containsRange(range: IRange): boolean;
  617. /**
  618. * Test if `otherRange` is in `range`. If the ranges are equal, will return true.
  619. */
  620. static containsRange(range: IRange, otherRange: IRange): boolean;
  621. /**
  622. * Test if `range` is strictly in this range. `range` must start after and end before this range for the result to be true.
  623. */
  624. strictContainsRange(range: IRange): boolean;
  625. /**
  626. * Test if `otherRange` is strictly in `range` (must start after, and end before). If the ranges are equal, will return false.
  627. */
  628. static strictContainsRange(range: IRange, otherRange: IRange): boolean;
  629. /**
  630. * A reunion of the two ranges.
  631. * The smallest position will be used as the start point, and the largest one as the end point.
  632. */
  633. plusRange(range: IRange): Range;
  634. /**
  635. * A reunion of the two ranges.
  636. * The smallest position will be used as the start point, and the largest one as the end point.
  637. */
  638. static plusRange(a: IRange, b: IRange): Range;
  639. /**
  640. * A intersection of the two ranges.
  641. */
  642. intersectRanges(range: IRange): Range | null;
  643. /**
  644. * A intersection of the two ranges.
  645. */
  646. static intersectRanges(a: IRange, b: IRange): Range | null;
  647. /**
  648. * Test if this range equals other.
  649. */
  650. equalsRange(other: IRange | null | undefined): boolean;
  651. /**
  652. * Test if range `a` equals `b`.
  653. */
  654. static equalsRange(a: IRange | null | undefined, b: IRange | null | undefined): boolean;
  655. /**
  656. * Return the end position (which will be after or equal to the start position)
  657. */
  658. getEndPosition(): Position;
  659. /**
  660. * Return the end position (which will be after or equal to the start position)
  661. */
  662. static getEndPosition(range: IRange): Position;
  663. /**
  664. * Return the start position (which will be before or equal to the end position)
  665. */
  666. getStartPosition(): Position;
  667. /**
  668. * Return the start position (which will be before or equal to the end position)
  669. */
  670. static getStartPosition(range: IRange): Position;
  671. /**
  672. * Transform to a user presentable string representation.
  673. */
  674. toString(): string;
  675. /**
  676. * Create a new range using this range's start position, and using endLineNumber and endColumn as the end position.
  677. */
  678. setEndPosition(endLineNumber: number, endColumn: number): Range;
  679. /**
  680. * Create a new range using this range's end position, and using startLineNumber and startColumn as the start position.
  681. */
  682. setStartPosition(startLineNumber: number, startColumn: number): Range;
  683. /**
  684. * Create a new empty range using this range's start position.
  685. */
  686. collapseToStart(): Range;
  687. /**
  688. * Create a new empty range using this range's start position.
  689. */
  690. static collapseToStart(range: IRange): Range;
  691. /**
  692. * Create a new empty range using this range's end position.
  693. */
  694. collapseToEnd(): Range;
  695. /**
  696. * Create a new empty range using this range's end position.
  697. */
  698. static collapseToEnd(range: IRange): Range;
  699. /**
  700. * Moves the range by the given amount of lines.
  701. */
  702. delta(lineCount: number): Range;
  703. static fromPositions(start: IPosition, end?: IPosition): Range;
  704. /**
  705. * Create a `Range` from an `IRange`.
  706. */
  707. static lift(range: undefined | null): null;
  708. static lift(range: IRange): Range;
  709. static lift(range: IRange | undefined | null): Range | null;
  710. /**
  711. * Test if `obj` is an `IRange`.
  712. */
  713. static isIRange(obj: any): obj is IRange;
  714. /**
  715. * Test if the two ranges are touching in any way.
  716. */
  717. static areIntersectingOrTouching(a: IRange, b: IRange): boolean;
  718. /**
  719. * Test if the two ranges are intersecting. If the ranges are touching it returns true.
  720. */
  721. static areIntersecting(a: IRange, b: IRange): boolean;
  722. /**
  723. * A function that compares ranges, useful for sorting ranges
  724. * It will first compare ranges on the startPosition and then on the endPosition
  725. */
  726. static compareRangesUsingStarts(a: IRange | null | undefined, b: IRange | null | undefined): number;
  727. /**
  728. * A function that compares ranges, useful for sorting ranges
  729. * It will first compare ranges on the endPosition and then on the startPosition
  730. */
  731. static compareRangesUsingEnds(a: IRange, b: IRange): number;
  732. /**
  733. * Test if the range spans multiple lines.
  734. */
  735. static spansMultipleLines(range: IRange): boolean;
  736. toJSON(): IRange;
  737. }
  738. /**
  739. * A selection in the editor.
  740. * The selection is a range that has an orientation.
  741. */
  742. export interface ISelection {
  743. /**
  744. * The line number on which the selection has started.
  745. */
  746. readonly selectionStartLineNumber: number;
  747. /**
  748. * The column on `selectionStartLineNumber` where the selection has started.
  749. */
  750. readonly selectionStartColumn: number;
  751. /**
  752. * The line number on which the selection has ended.
  753. */
  754. readonly positionLineNumber: number;
  755. /**
  756. * The column on `positionLineNumber` where the selection has ended.
  757. */
  758. readonly positionColumn: number;
  759. }
  760. /**
  761. * A selection in the editor.
  762. * The selection is a range that has an orientation.
  763. */
  764. export class Selection extends Range {
  765. /**
  766. * The line number on which the selection has started.
  767. */
  768. readonly selectionStartLineNumber: number;
  769. /**
  770. * The column on `selectionStartLineNumber` where the selection has started.
  771. */
  772. readonly selectionStartColumn: number;
  773. /**
  774. * The line number on which the selection has ended.
  775. */
  776. readonly positionLineNumber: number;
  777. /**
  778. * The column on `positionLineNumber` where the selection has ended.
  779. */
  780. readonly positionColumn: number;
  781. constructor(selectionStartLineNumber: number, selectionStartColumn: number, positionLineNumber: number, positionColumn: number);
  782. /**
  783. * Transform to a human-readable representation.
  784. */
  785. toString(): string;
  786. /**
  787. * Test if equals other selection.
  788. */
  789. equalsSelection(other: ISelection): boolean;
  790. /**
  791. * Test if the two selections are equal.
  792. */
  793. static selectionsEqual(a: ISelection, b: ISelection): boolean;
  794. /**
  795. * Get directions (LTR or RTL).
  796. */
  797. getDirection(): SelectionDirection;
  798. /**
  799. * Create a new selection with a different `positionLineNumber` and `positionColumn`.
  800. */
  801. setEndPosition(endLineNumber: number, endColumn: number): Selection;
  802. /**
  803. * Get the position at `positionLineNumber` and `positionColumn`.
  804. */
  805. getPosition(): Position;
  806. /**
  807. * Get the position at the start of the selection.
  808. */
  809. getSelectionStart(): Position;
  810. /**
  811. * Create a new selection with a different `selectionStartLineNumber` and `selectionStartColumn`.
  812. */
  813. setStartPosition(startLineNumber: number, startColumn: number): Selection;
  814. /**
  815. * Create a `Selection` from one or two positions
  816. */
  817. static fromPositions(start: IPosition, end?: IPosition): Selection;
  818. /**
  819. * Creates a `Selection` from a range, given a direction.
  820. */
  821. static fromRange(range: Range, direction: SelectionDirection): Selection;
  822. /**
  823. * Create a `Selection` from an `ISelection`.
  824. */
  825. static liftSelection(sel: ISelection): Selection;
  826. /**
  827. * `a` equals `b`.
  828. */
  829. static selectionsArrEqual(a: ISelection[], b: ISelection[]): boolean;
  830. /**
  831. * Test if `obj` is an `ISelection`.
  832. */
  833. static isISelection(obj: any): obj is ISelection;
  834. /**
  835. * Create with a direction.
  836. */
  837. static createWithDirection(startLineNumber: number, startColumn: number, endLineNumber: number, endColumn: number, direction: SelectionDirection): Selection;
  838. }
  839. /**
  840. * The direction of a selection.
  841. */
  842. export enum SelectionDirection {
  843. /**
  844. * The selection starts above where it ends.
  845. */
  846. LTR = 0,
  847. /**
  848. * The selection starts below where it ends.
  849. */
  850. RTL = 1
  851. }
  852. export class Token {
  853. readonly offset: number;
  854. readonly type: string;
  855. readonly language: string;
  856. _tokenBrand: void;
  857. constructor(offset: number, type: string, language: string);
  858. toString(): string;
  859. }
  860. }
  861. declare namespace monaco.editor {
  862. export interface IDiffNavigator {
  863. canNavigate(): boolean;
  864. next(): void;
  865. previous(): void;
  866. dispose(): void;
  867. }
  868. /**
  869. * Create a new editor under `domElement`.
  870. * `domElement` should be empty (not contain other dom nodes).
  871. * The editor will read the size of `domElement`.
  872. */
  873. export function create(domElement: HTMLElement, options?: IStandaloneEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneCodeEditor;
  874. /**
  875. * Emitted when an editor is created.
  876. * Creating a diff editor might cause this listener to be invoked with the two editors.
  877. * @event
  878. */
  879. export function onDidCreateEditor(listener: (codeEditor: ICodeEditor) => void): IDisposable;
  880. /**
  881. * Emitted when an diff editor is created.
  882. * @event
  883. */
  884. export function onDidCreateDiffEditor(listener: (diffEditor: IDiffEditor) => void): IDisposable;
  885. /**
  886. * Get all the created editors.
  887. */
  888. export function getEditors(): readonly ICodeEditor[];
  889. /**
  890. * Get all the created diff editors.
  891. */
  892. export function getDiffEditors(): readonly IDiffEditor[];
  893. /**
  894. * Create a new diff editor under `domElement`.
  895. * `domElement` should be empty (not contain other dom nodes).
  896. * The editor will read the size of `domElement`.
  897. */
  898. export function createDiffEditor(domElement: HTMLElement, options?: IStandaloneDiffEditorConstructionOptions, override?: IEditorOverrideServices): IStandaloneDiffEditor;
  899. export interface IDiffNavigatorOptions {
  900. readonly followsCaret?: boolean;
  901. readonly ignoreCharChanges?: boolean;
  902. readonly alwaysRevealFirst?: boolean;
  903. }
  904. export function createDiffNavigator(diffEditor: IStandaloneDiffEditor, opts?: IDiffNavigatorOptions): IDiffNavigator;
  905. /**
  906. * Description of a command contribution
  907. */
  908. export interface ICommandDescriptor {
  909. /**
  910. * An unique identifier of the contributed command.
  911. */
  912. id: string;
  913. /**
  914. * Callback that will be executed when the command is triggered.
  915. */
  916. run: ICommandHandler;
  917. }
  918. /**
  919. * Add a command.
  920. */
  921. export function addCommand(descriptor: ICommandDescriptor): IDisposable;
  922. /**
  923. * Add an action to all editors.
  924. */
  925. export function addEditorAction(descriptor: IActionDescriptor): IDisposable;
  926. /**
  927. * A keybinding rule.
  928. */
  929. export interface IKeybindingRule {
  930. keybinding: number;
  931. command?: string | null;
  932. commandArgs?: any;
  933. when?: string | null;
  934. }
  935. /**
  936. * Add a keybinding rule.
  937. */
  938. export function addKeybindingRule(rule: IKeybindingRule): IDisposable;
  939. /**
  940. * Add keybinding rules.
  941. */
  942. export function addKeybindingRules(rules: IKeybindingRule[]): IDisposable;
  943. /**
  944. * Create a new editor model.
  945. * You can specify the language that should be set for this model or let the language be inferred from the `uri`.
  946. */
  947. export function createModel(value: string, language?: string, uri?: Uri): ITextModel;
  948. /**
  949. * Change the language for a model.
  950. */
  951. export function setModelLanguage(model: ITextModel, mimeTypeOrLanguageId: string): void;
  952. /**
  953. * Set the markers for a model.
  954. */
  955. export function setModelMarkers(model: ITextModel, owner: string, markers: IMarkerData[]): void;
  956. /**
  957. * Remove all markers of an owner.
  958. */
  959. export function removeAllMarkers(owner: string): void;
  960. /**
  961. * Get markers for owner and/or resource
  962. *
  963. * @returns list of markers
  964. */
  965. export function getModelMarkers(filter: {
  966. owner?: string;
  967. resource?: Uri;
  968. take?: number;
  969. }): IMarker[];
  970. /**
  971. * Emitted when markers change for a model.
  972. * @event
  973. */
  974. export function onDidChangeMarkers(listener: (e: readonly Uri[]) => void): IDisposable;
  975. /**
  976. * Get the model that has `uri` if it exists.
  977. */
  978. export function getModel(uri: Uri): ITextModel | null;
  979. /**
  980. * Get all the created models.
  981. */
  982. export function getModels(): ITextModel[];
  983. /**
  984. * Emitted when a model is created.
  985. * @event
  986. */
  987. export function onDidCreateModel(listener: (model: ITextModel) => void): IDisposable;
  988. /**
  989. * Emitted right before a model is disposed.
  990. * @event
  991. */
  992. export function onWillDisposeModel(listener: (model: ITextModel) => void): IDisposable;
  993. /**
  994. * Emitted when a different language is set to a model.
  995. * @event
  996. */
  997. export function onDidChangeModelLanguage(listener: (e: {
  998. readonly model: ITextModel;
  999. readonly oldLanguage: string;
  1000. }) => void): IDisposable;
  1001. /**
  1002. * Create a new web worker that has model syncing capabilities built in.
  1003. * Specify an AMD module to load that will `create` an object that will be proxied.
  1004. */
  1005. export function createWebWorker<T extends object>(opts: IWebWorkerOptions): MonacoWebWorker<T>;
  1006. /**
  1007. * Colorize the contents of `domNode` using attribute `data-lang`.
  1008. */
  1009. export function colorizeElement(domNode: HTMLElement, options: IColorizerElementOptions): Promise<void>;
  1010. /**
  1011. * Colorize `text` using language `languageId`.
  1012. */
  1013. export function colorize(text: string, languageId: string, options: IColorizerOptions): Promise<string>;
  1014. /**
  1015. * Colorize a line in a model.
  1016. */
  1017. export function colorizeModelLine(model: ITextModel, lineNumber: number, tabSize?: number): string;
  1018. /**
  1019. * Tokenize `text` using language `languageId`
  1020. */
  1021. export function tokenize(text: string, languageId: string): Token[][];
  1022. /**
  1023. * Define a new theme or update an existing theme.
  1024. */
  1025. export function defineTheme(themeName: string, themeData: IStandaloneThemeData): void;
  1026. /**
  1027. * Switches to a theme.
  1028. */
  1029. export function setTheme(themeName: string): void;
  1030. /**
  1031. * Clears all cached font measurements and triggers re-measurement.
  1032. */
  1033. export function remeasureFonts(): void;
  1034. /**
  1035. * Register a command.
  1036. */
  1037. export function registerCommand(id: string, handler: (accessor: any, ...args: any[]) => void): IDisposable;
  1038. export interface ILinkOpener {
  1039. open(resource: Uri): boolean | Promise<boolean>;
  1040. }
  1041. /**
  1042. * Registers a handler that is called when a link is opened in any editor. The handler callback should return `true` if the link was handled and `false` otherwise.
  1043. * The handler that was registered last will be called first when a link is opened.
  1044. *
  1045. * Returns a disposable that can unregister the opener again.
  1046. */
  1047. export function registerLinkOpener(opener: ILinkOpener): IDisposable;
  1048. export type BuiltinTheme = 'vs' | 'vs-dark' | 'hc-black' | 'hc-light';
  1049. export interface IStandaloneThemeData {
  1050. base: BuiltinTheme;
  1051. inherit: boolean;
  1052. rules: ITokenThemeRule[];
  1053. encodedTokensColors?: string[];
  1054. colors: IColors;
  1055. }
  1056. export type IColors = {
  1057. [colorId: string]: string;
  1058. };
  1059. export interface ITokenThemeRule {
  1060. token: string;
  1061. foreground?: string;
  1062. background?: string;
  1063. fontStyle?: string;
  1064. }
  1065. /**
  1066. * A web worker that can provide a proxy to an arbitrary file.
  1067. */
  1068. export interface MonacoWebWorker<T> {
  1069. /**
  1070. * Terminate the web worker, thus invalidating the returned proxy.
  1071. */
  1072. dispose(): void;
  1073. /**
  1074. * Get a proxy to the arbitrary loaded code.
  1075. */
  1076. getProxy(): Promise<T>;
  1077. /**
  1078. * Synchronize (send) the models at `resources` to the web worker,
  1079. * making them available in the monaco.worker.getMirrorModels().
  1080. */
  1081. withSyncedResources(resources: Uri[]): Promise<T>;
  1082. }
  1083. export interface IWebWorkerOptions {
  1084. /**
  1085. * The AMD moduleId to load.
  1086. * It should export a function `create` that should return the exported proxy.
  1087. */
  1088. moduleId: string;
  1089. /**
  1090. * The data to send over when calling create on the module.
  1091. */
  1092. createData?: any;
  1093. /**
  1094. * A label to be used to identify the web worker for debugging purposes.
  1095. */
  1096. label?: string;
  1097. /**
  1098. * An object that can be used by the web worker to make calls back to the main thread.
  1099. */
  1100. host?: any;
  1101. /**
  1102. * Keep idle models.
  1103. * Defaults to false, which means that idle models will stop syncing after a while.
  1104. */
  1105. keepIdleModels?: boolean;
  1106. }
  1107. /**
  1108. * Description of an action contribution
  1109. */
  1110. export interface IActionDescriptor {
  1111. /**
  1112. * An unique identifier of the contributed action.
  1113. */
  1114. id: string;
  1115. /**
  1116. * A label of the action that will be presented to the user.
  1117. */
  1118. label: string;
  1119. /**
  1120. * Precondition rule.
  1121. */
  1122. precondition?: string;
  1123. /**
  1124. * An array of keybindings for the action.
  1125. */
  1126. keybindings?: number[];
  1127. /**
  1128. * The keybinding rule (condition on top of precondition).
  1129. */
  1130. keybindingContext?: string;
  1131. /**
  1132. * Control if the action should show up in the context menu and where.
  1133. * The context menu of the editor has these default:
  1134. * navigation - The navigation group comes first in all cases.
  1135. * 1_modification - This group comes next and contains commands that modify your code.
  1136. * 9_cutcopypaste - The last default group with the basic editing commands.
  1137. * You can also create your own group.
  1138. * Defaults to null (don't show in context menu).
  1139. */
  1140. contextMenuGroupId?: string;
  1141. /**
  1142. * Control the order in the context menu group.
  1143. */
  1144. contextMenuOrder?: number;
  1145. /**
  1146. * Method that will be executed when the action is triggered.
  1147. * @param editor The editor instance is passed in as a convenience
  1148. */
  1149. run(editor: ICodeEditor, ...args: any[]): void | Promise<void>;
  1150. }
  1151. /**
  1152. * Options which apply for all editors.
  1153. */
  1154. export interface IGlobalEditorOptions {
  1155. /**
  1156. * The number of spaces a tab is equal to.
  1157. * This setting is overridden based on the file contents when `detectIndentation` is on.
  1158. * Defaults to 4.
  1159. */
  1160. tabSize?: number;
  1161. /**
  1162. * Insert spaces when pressing `Tab`.
  1163. * This setting is overridden based on the file contents when `detectIndentation` is on.
  1164. * Defaults to true.
  1165. */
  1166. insertSpaces?: boolean;
  1167. /**
  1168. * Controls whether `tabSize` and `insertSpaces` will be automatically detected when a file is opened based on the file contents.
  1169. * Defaults to true.
  1170. */
  1171. detectIndentation?: boolean;
  1172. /**
  1173. * Remove trailing auto inserted whitespace.
  1174. * Defaults to true.
  1175. */
  1176. trimAutoWhitespace?: boolean;
  1177. /**
  1178. * Special handling for large files to disable certain memory intensive features.
  1179. * Defaults to true.
  1180. */
  1181. largeFileOptimizations?: boolean;
  1182. /**
  1183. * Controls whether completions should be computed based on words in the document.
  1184. * Defaults to true.
  1185. */
  1186. wordBasedSuggestions?: boolean;
  1187. /**
  1188. * Controls whether word based completions should be included from opened documents of the same language or any language.
  1189. */
  1190. wordBasedSuggestionsOnlySameLanguage?: boolean;
  1191. /**
  1192. * Controls whether the semanticHighlighting is shown for the languages that support it.
  1193. * true: semanticHighlighting is enabled for all themes
  1194. * false: semanticHighlighting is disabled for all themes
  1195. * 'configuredByTheme': semanticHighlighting is controlled by the current color theme's semanticHighlighting setting.
  1196. * Defaults to 'byTheme'.
  1197. */
  1198. 'semanticHighlighting.enabled'?: true | false | 'configuredByTheme';
  1199. /**
  1200. * Keep peek editors open even when double-clicking their content or when hitting `Escape`.
  1201. * Defaults to false.
  1202. */
  1203. stablePeek?: boolean;
  1204. /**
  1205. * Lines above this length will not be tokenized for performance reasons.
  1206. * Defaults to 20000.
  1207. */
  1208. maxTokenizationLineLength?: number;
  1209. /**
  1210. * Theme to be used for rendering.
  1211. * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black', 'hc-light'.
  1212. * You can create custom themes via `monaco.editor.defineTheme`.
  1213. * To switch a theme, use `monaco.editor.setTheme`.
  1214. * **NOTE**: The theme might be overwritten if the OS is in high contrast mode, unless `autoDetectHighContrast` is set to false.
  1215. */
  1216. theme?: string;
  1217. /**
  1218. * If enabled, will automatically change to high contrast theme if the OS is using a high contrast theme.
  1219. * Defaults to true.
  1220. */
  1221. autoDetectHighContrast?: boolean;
  1222. }
  1223. /**
  1224. * The options to create an editor.
  1225. */
  1226. export interface IStandaloneEditorConstructionOptions extends IEditorConstructionOptions, IGlobalEditorOptions {
  1227. /**
  1228. * The initial model associated with this code editor.
  1229. */
  1230. model?: ITextModel | null;
  1231. /**
  1232. * The initial value of the auto created model in the editor.
  1233. * To not automatically create a model, use `model: null`.
  1234. */
  1235. value?: string;
  1236. /**
  1237. * The initial language of the auto created model in the editor.
  1238. * To not automatically create a model, use `model: null`.
  1239. */
  1240. language?: string;
  1241. /**
  1242. * Initial theme to be used for rendering.
  1243. * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black', 'hc-light.
  1244. * You can create custom themes via `monaco.editor.defineTheme`.
  1245. * To switch a theme, use `monaco.editor.setTheme`.
  1246. * **NOTE**: The theme might be overwritten if the OS is in high contrast mode, unless `autoDetectHighContrast` is set to false.
  1247. */
  1248. theme?: string;
  1249. /**
  1250. * If enabled, will automatically change to high contrast theme if the OS is using a high contrast theme.
  1251. * Defaults to true.
  1252. */
  1253. autoDetectHighContrast?: boolean;
  1254. /**
  1255. * An URL to open when Ctrl+H (Windows and Linux) or Cmd+H (OSX) is pressed in
  1256. * the accessibility help dialog in the editor.
  1257. *
  1258. * Defaults to "https://go.microsoft.com/fwlink/?linkid=852450"
  1259. */
  1260. accessibilityHelpUrl?: string;
  1261. /**
  1262. * Container element to use for ARIA messages.
  1263. * Defaults to document.body.
  1264. */
  1265. ariaContainerElement?: HTMLElement;
  1266. }
  1267. /**
  1268. * The options to create a diff editor.
  1269. */
  1270. export interface IStandaloneDiffEditorConstructionOptions extends IDiffEditorConstructionOptions {
  1271. /**
  1272. * Initial theme to be used for rendering.
  1273. * The current out-of-the-box available themes are: 'vs' (default), 'vs-dark', 'hc-black', 'hc-light.
  1274. * You can create custom themes via `monaco.editor.defineTheme`.
  1275. * To switch a theme, use `monaco.editor.setTheme`.
  1276. * **NOTE**: The theme might be overwritten if the OS is in high contrast mode, unless `autoDetectHighContrast` is set to false.
  1277. */
  1278. theme?: string;
  1279. /**
  1280. * If enabled, will automatically change to high contrast theme if the OS is using a high contrast theme.
  1281. * Defaults to true.
  1282. */
  1283. autoDetectHighContrast?: boolean;
  1284. }
  1285. export interface IStandaloneCodeEditor extends ICodeEditor {
  1286. updateOptions(newOptions: IEditorOptions & IGlobalEditorOptions): void;
  1287. addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null;
  1288. createContextKey<T extends ContextKeyValue = ContextKeyValue>(key: string, defaultValue: T): IContextKey<T>;
  1289. addAction(descriptor: IActionDescriptor): IDisposable;
  1290. }
  1291. export interface IStandaloneDiffEditor extends IDiffEditor {
  1292. addCommand(keybinding: number, handler: ICommandHandler, context?: string): string | null;
  1293. createContextKey<T extends ContextKeyValue = ContextKeyValue>(key: string, defaultValue: T): IContextKey<T>;
  1294. addAction(descriptor: IActionDescriptor): IDisposable;
  1295. getOriginalEditor(): IStandaloneCodeEditor;
  1296. getModifiedEditor(): IStandaloneCodeEditor;
  1297. }
  1298. export interface ICommandHandler {
  1299. (...args: any[]): void;
  1300. }
  1301. export interface IContextKey<T extends ContextKeyValue = ContextKeyValue> {
  1302. set(value: T): void;
  1303. reset(): void;
  1304. get(): T | undefined;
  1305. }
  1306. export type ContextKeyValue = null | undefined | boolean | number | string | Array<null | undefined | boolean | number | string> | Record<string, null | undefined | boolean | number | string>;
  1307. export interface IEditorOverrideServices {
  1308. [index: string]: any;
  1309. }
  1310. export interface IMarker {
  1311. owner: string;
  1312. resource: Uri;
  1313. severity: MarkerSeverity;
  1314. code?: string | {
  1315. value: string;
  1316. target: Uri;
  1317. };
  1318. message: string;
  1319. source?: string;
  1320. startLineNumber: number;
  1321. startColumn: number;
  1322. endLineNumber: number;
  1323. endColumn: number;
  1324. modelVersionId?: number;
  1325. relatedInformation?: IRelatedInformation[];
  1326. tags?: MarkerTag[];
  1327. }
  1328. /**
  1329. * A structure defining a problem/warning/etc.
  1330. */
  1331. export interface IMarkerData {
  1332. code?: string | {
  1333. value: string;
  1334. target: Uri;
  1335. };
  1336. severity: MarkerSeverity;
  1337. message: string;
  1338. source?: string;
  1339. startLineNumber: number;
  1340. startColumn: number;
  1341. endLineNumber: number;
  1342. endColumn: number;
  1343. modelVersionId?: number;
  1344. relatedInformation?: IRelatedInformation[];
  1345. tags?: MarkerTag[];
  1346. }
  1347. /**
  1348. *
  1349. */
  1350. export interface IRelatedInformation {
  1351. resource: Uri;
  1352. message: string;
  1353. startLineNumber: number;
  1354. startColumn: number;
  1355. endLineNumber: number;
  1356. endColumn: number;
  1357. }
  1358. export interface IColorizerOptions {
  1359. tabSize?: number;
  1360. }
  1361. export interface IColorizerElementOptions extends IColorizerOptions {
  1362. theme?: string;
  1363. mimeType?: string;
  1364. }
  1365. export enum ScrollbarVisibility {
  1366. Auto = 1,
  1367. Hidden = 2,
  1368. Visible = 3
  1369. }
  1370. export interface ThemeColor {
  1371. id: string;
  1372. }
  1373. /**
  1374. * A single edit operation, that acts as a simple replace.
  1375. * i.e. Replace text at `range` with `text` in model.
  1376. */
  1377. export interface ISingleEditOperation {
  1378. /**
  1379. * The range to replace. This can be empty to emulate a simple insert.
  1380. */
  1381. range: IRange;
  1382. /**
  1383. * The text to replace with. This can be null to emulate a simple delete.
  1384. */
  1385. text: string | null;
  1386. /**
  1387. * This indicates that this operation has "insert" semantics.
  1388. * i.e. forceMoveMarkers = true => if `range` is collapsed, all markers at the position will be moved.
  1389. */
  1390. forceMoveMarkers?: boolean;
  1391. }
  1392. /**
  1393. * Word inside a model.
  1394. */
  1395. export interface IWordAtPosition {
  1396. /**
  1397. * The word.
  1398. */
  1399. readonly word: string;
  1400. /**
  1401. * The column where the word starts.
  1402. */
  1403. readonly startColumn: number;
  1404. /**
  1405. * The column where the word ends.
  1406. */
  1407. readonly endColumn: number;
  1408. }
  1409. /**
  1410. * Vertical Lane in the overview ruler of the editor.
  1411. */
  1412. export enum OverviewRulerLane {
  1413. Left = 1,
  1414. Center = 2,
  1415. Right = 4,
  1416. Full = 7
  1417. }
  1418. /**
  1419. * Position in the minimap to render the decoration.
  1420. */
  1421. export enum MinimapPosition {
  1422. Inline = 1,
  1423. Gutter = 2
  1424. }
  1425. export interface IDecorationOptions {
  1426. /**
  1427. * CSS color to render.
  1428. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
  1429. */
  1430. color: string | ThemeColor | undefined;
  1431. /**
  1432. * CSS color to render.
  1433. * e.g.: rgba(100, 100, 100, 0.5) or a color from the color registry
  1434. */
  1435. darkColor?: string | ThemeColor;
  1436. }
  1437. /**
  1438. * Options for rendering a model decoration in the overview ruler.
  1439. */
  1440. export interface IModelDecorationOverviewRulerOptions extends IDecorationOptions {
  1441. /**
  1442. * The position in the overview ruler.
  1443. */
  1444. position: OverviewRulerLane;
  1445. }
  1446. /**
  1447. * Options for rendering a model decoration in the overview ruler.
  1448. */
  1449. export interface IModelDecorationMinimapOptions extends IDecorationOptions {
  1450. /**
  1451. * The position in the overview ruler.
  1452. */
  1453. position: MinimapPosition;
  1454. }
  1455. /**
  1456. * Options for a model decoration.
  1457. */
  1458. export interface IModelDecorationOptions {
  1459. /**
  1460. * Customize the growing behavior of the decoration when typing at the edges of the decoration.
  1461. * Defaults to TrackedRangeStickiness.AlwaysGrowsWhenTypingAtEdges
  1462. */
  1463. stickiness?: TrackedRangeStickiness;
  1464. /**
  1465. * CSS class name describing the decoration.
  1466. */
  1467. className?: string | null;
  1468. blockClassName?: string | null;
  1469. /**
  1470. * Indicates if this block should be rendered after the last line.
  1471. * In this case, the range must be empty and set to the last line.
  1472. */
  1473. blockIsAfterEnd?: boolean | null;
  1474. blockDoesNotCollapse?: boolean | null;
  1475. blockPadding?: [top: number, right: number, bottom: number, left: number] | null;
  1476. /**
  1477. * Message to be rendered when hovering over the glyph margin decoration.
  1478. */
  1479. glyphMarginHoverMessage?: IMarkdownString | IMarkdownString[] | null;
  1480. /**
  1481. * Array of MarkdownString to render as the decoration message.
  1482. */
  1483. hoverMessage?: IMarkdownString | IMarkdownString[] | null;
  1484. /**
  1485. * Should the decoration expand to encompass a whole line.
  1486. */
  1487. isWholeLine?: boolean;
  1488. /**
  1489. * Always render the decoration (even when the range it encompasses is collapsed).
  1490. */
  1491. showIfCollapsed?: boolean;
  1492. /**
  1493. * Specifies the stack order of a decoration.
  1494. * A decoration with greater stack order is always in front of a decoration with
  1495. * a lower stack order when the decorations are on the same line.
  1496. */
  1497. zIndex?: number;
  1498. /**
  1499. * If set, render this decoration in the overview ruler.
  1500. */
  1501. overviewRuler?: IModelDecorationOverviewRulerOptions | null;
  1502. /**
  1503. * If set, render this decoration in the minimap.
  1504. */
  1505. minimap?: IModelDecorationMinimapOptions | null;
  1506. /**
  1507. * If set, the decoration will be rendered in the glyph margin with this CSS class name.
  1508. */
  1509. glyphMarginClassName?: string | null;
  1510. /**
  1511. * If set, the decoration will be rendered in the lines decorations with this CSS class name.
  1512. */
  1513. linesDecorationsClassName?: string | null;
  1514. /**
  1515. * If set, the decoration will be rendered in the lines decorations with this CSS class name, but only for the first line in case of line wrapping.
  1516. */
  1517. firstLineDecorationClassName?: string | null;
  1518. /**
  1519. * If set, the decoration will be rendered in the margin (covering its full width) with this CSS class name.
  1520. */
  1521. marginClassName?: string | null;
  1522. /**
  1523. * If set, the decoration will be rendered inline with the text with this CSS class name.
  1524. * Please use this only for CSS rules that must impact the text. For example, use `className`
  1525. * to have a background color decoration.
  1526. */
  1527. inlineClassName?: string | null;
  1528. /**
  1529. * If there is an `inlineClassName` which affects letter spacing.
  1530. */
  1531. inlineClassNameAffectsLetterSpacing?: boolean;
  1532. /**
  1533. * If set, the decoration will be rendered before the text with this CSS class name.
  1534. */
  1535. beforeContentClassName?: string | null;
  1536. /**
  1537. * If set, the decoration will be rendered after the text with this CSS class name.
  1538. */
  1539. afterContentClassName?: string | null;
  1540. /**
  1541. * If set, text will be injected in the view after the range.
  1542. */
  1543. after?: InjectedTextOptions | null;
  1544. /**
  1545. * If set, text will be injected in the view before the range.
  1546. */
  1547. before?: InjectedTextOptions | null;
  1548. }
  1549. /**
  1550. * Configures text that is injected into the view without changing the underlying document.
  1551. */
  1552. export interface InjectedTextOptions {
  1553. /**
  1554. * Sets the text to inject. Must be a single line.
  1555. */
  1556. readonly content: string;
  1557. /**
  1558. * If set, the decoration will be rendered inline with the text with this CSS class name.
  1559. */
  1560. readonly inlineClassName?: string | null;
  1561. /**
  1562. * If there is an `inlineClassName` which affects letter spacing.
  1563. */
  1564. readonly inlineClassNameAffectsLetterSpacing?: boolean;
  1565. /**
  1566. * This field allows to attach data to this injected text.
  1567. * The data can be read when injected texts at a given position are queried.
  1568. */
  1569. readonly attachedData?: unknown;
  1570. /**
  1571. * Configures cursor stops around injected text.
  1572. * Defaults to {@link InjectedTextCursorStops.Both}.
  1573. */
  1574. readonly cursorStops?: InjectedTextCursorStops | null;
  1575. }
  1576. export enum InjectedTextCursorStops {
  1577. Both = 0,
  1578. Right = 1,
  1579. Left = 2,
  1580. None = 3
  1581. }
  1582. /**
  1583. * New model decorations.
  1584. */
  1585. export interface IModelDeltaDecoration {
  1586. /**
  1587. * Range that this decoration covers.
  1588. */
  1589. range: IRange;
  1590. /**
  1591. * Options associated with this decoration.
  1592. */
  1593. options: IModelDecorationOptions;
  1594. }
  1595. /**
  1596. * A decoration in the model.
  1597. */
  1598. export interface IModelDecoration {
  1599. /**
  1600. * Identifier for a decoration.
  1601. */
  1602. readonly id: string;
  1603. /**
  1604. * Identifier for a decoration's owner.
  1605. */
  1606. readonly ownerId: number;
  1607. /**
  1608. * Range that this decoration covers.
  1609. */
  1610. readonly range: Range;
  1611. /**
  1612. * Options associated with this decoration.
  1613. */
  1614. readonly options: IModelDecorationOptions;
  1615. }
  1616. /**
  1617. * End of line character preference.
  1618. */
  1619. export enum EndOfLinePreference {
  1620. /**
  1621. * Use the end of line character identified in the text buffer.
  1622. */
  1623. TextDefined = 0,
  1624. /**
  1625. * Use line feed (\n) as the end of line character.
  1626. */
  1627. LF = 1,
  1628. /**
  1629. * Use carriage return and line feed (\r\n) as the end of line character.
  1630. */
  1631. CRLF = 2
  1632. }
  1633. /**
  1634. * The default end of line to use when instantiating models.
  1635. */
  1636. export enum DefaultEndOfLine {
  1637. /**
  1638. * Use line feed (\n) as the end of line character.
  1639. */
  1640. LF = 1,
  1641. /**
  1642. * Use carriage return and line feed (\r\n) as the end of line character.
  1643. */
  1644. CRLF = 2
  1645. }
  1646. /**
  1647. * End of line character preference.
  1648. */
  1649. export enum EndOfLineSequence {
  1650. /**
  1651. * Use line feed (\n) as the end of line character.
  1652. */
  1653. LF = 0,
  1654. /**
  1655. * Use carriage return and line feed (\r\n) as the end of line character.
  1656. */
  1657. CRLF = 1
  1658. }
  1659. /**
  1660. * A single edit operation, that has an identifier.
  1661. */
  1662. export interface IIdentifiedSingleEditOperation extends ISingleEditOperation {
  1663. }
  1664. export interface IValidEditOperation {
  1665. /**
  1666. * The range to replace. This can be empty to emulate a simple insert.
  1667. */
  1668. range: Range;
  1669. /**
  1670. * The text to replace with. This can be empty to emulate a simple delete.
  1671. */
  1672. text: string;
  1673. }
  1674. /**
  1675. * A callback that can compute the cursor state after applying a series of edit operations.
  1676. */
  1677. export interface ICursorStateComputer {
  1678. /**
  1679. * A callback that can compute the resulting cursors state after some edit operations have been executed.
  1680. */
  1681. (inverseEditOperations: IValidEditOperation[]): Selection[] | null;
  1682. }
  1683. export class TextModelResolvedOptions {
  1684. _textModelResolvedOptionsBrand: void;
  1685. readonly tabSize: number;
  1686. readonly indentSize: number;
  1687. readonly insertSpaces: boolean;
  1688. readonly defaultEOL: DefaultEndOfLine;
  1689. readonly trimAutoWhitespace: boolean;
  1690. readonly bracketPairColorizationOptions: BracketPairColorizationOptions;
  1691. get originalIndentSize(): number | 'tabSize';
  1692. }
  1693. export interface BracketPairColorizationOptions {
  1694. enabled: boolean;
  1695. independentColorPoolPerBracketType: boolean;
  1696. }
  1697. export interface ITextModelUpdateOptions {
  1698. tabSize?: number;
  1699. indentSize?: number | 'tabSize';
  1700. insertSpaces?: boolean;
  1701. trimAutoWhitespace?: boolean;
  1702. bracketColorizationOptions?: BracketPairColorizationOptions;
  1703. }
  1704. export class FindMatch {
  1705. _findMatchBrand: void;
  1706. readonly range: Range;
  1707. readonly matches: string[] | null;
  1708. }
  1709. /**
  1710. * Describes the behavior of decorations when typing/editing near their edges.
  1711. * Note: Please do not edit the values, as they very carefully match `DecorationRangeBehavior`
  1712. */
  1713. export enum TrackedRangeStickiness {
  1714. AlwaysGrowsWhenTypingAtEdges = 0,
  1715. NeverGrowsWhenTypingAtEdges = 1,
  1716. GrowsOnlyWhenTypingBefore = 2,
  1717. GrowsOnlyWhenTypingAfter = 3
  1718. }
  1719. /**
  1720. * Text snapshot that works like an iterator.
  1721. * Will try to return chunks of roughly ~64KB size.
  1722. * Will return null when finished.
  1723. */
  1724. export interface ITextSnapshot {
  1725. read(): string | null;
  1726. }
  1727. /**
  1728. * A model.
  1729. */
  1730. export interface ITextModel {
  1731. /**
  1732. * Gets the resource associated with this editor model.
  1733. */
  1734. readonly uri: Uri;
  1735. /**
  1736. * A unique identifier associated with this model.
  1737. */
  1738. readonly id: string;
  1739. /**
  1740. * Get the resolved options for this model.
  1741. */
  1742. getOptions(): TextModelResolvedOptions;
  1743. /**
  1744. * Get the current version id of the model.
  1745. * Anytime a change happens to the model (even undo/redo),
  1746. * the version id is incremented.
  1747. */
  1748. getVersionId(): number;
  1749. /**
  1750. * Get the alternative version id of the model.
  1751. * This alternative version id is not always incremented,
  1752. * it will return the same values in the case of undo-redo.
  1753. */
  1754. getAlternativeVersionId(): number;
  1755. /**
  1756. * Replace the entire text buffer value contained in this model.
  1757. */
  1758. setValue(newValue: string | ITextSnapshot): void;
  1759. /**
  1760. * Get the text stored in this model.
  1761. * @param eol The end of line character preference. Defaults to `EndOfLinePreference.TextDefined`.
  1762. * @param preserverBOM Preserve a BOM character if it was detected when the model was constructed.
  1763. * @return The text.
  1764. */
  1765. getValue(eol?: EndOfLinePreference, preserveBOM?: boolean): string;
  1766. /**
  1767. * Get the text stored in this model.
  1768. * @param preserverBOM Preserve a BOM character if it was detected when the model was constructed.
  1769. * @return The text snapshot (it is safe to consume it asynchronously).
  1770. */
  1771. createSnapshot(preserveBOM?: boolean): ITextSnapshot;
  1772. /**
  1773. * Get the length of the text stored in this model.
  1774. */
  1775. getValueLength(eol?: EndOfLinePreference, preserveBOM?: boolean): number;
  1776. /**
  1777. * Get the text in a certain range.
  1778. * @param range The range describing what text to get.
  1779. * @param eol The end of line character preference. This will only be used for multiline ranges. Defaults to `EndOfLinePreference.TextDefined`.
  1780. * @return The text.
  1781. */
  1782. getValueInRange(range: IRange, eol?: EndOfLinePreference): string;
  1783. /**
  1784. * Get the length of text in a certain range.
  1785. * @param range The range describing what text length to get.
  1786. * @return The text length.
  1787. */
  1788. getValueLengthInRange(range: IRange, eol?: EndOfLinePreference): number;
  1789. /**
  1790. * Get the character count of text in a certain range.
  1791. * @param range The range describing what text length to get.
  1792. */
  1793. getCharacterCountInRange(range: IRange, eol?: EndOfLinePreference): number;
  1794. /**
  1795. * Get the number of lines in the model.
  1796. */
  1797. getLineCount(): number;
  1798. /**
  1799. * Get the text for a certain line.
  1800. */
  1801. getLineContent(lineNumber: number): string;
  1802. /**
  1803. * Get the text length for a certain line.
  1804. */
  1805. getLineLength(lineNumber: number): number;
  1806. /**
  1807. * Get the text for all lines.
  1808. */
  1809. getLinesContent(): string[];
  1810. /**
  1811. * Get the end of line sequence predominantly used in the text buffer.
  1812. * @return EOL char sequence (e.g.: '\n' or '\r\n').
  1813. */
  1814. getEOL(): string;
  1815. /**
  1816. * Get the end of line sequence predominantly used in the text buffer.
  1817. */
  1818. getEndOfLineSequence(): EndOfLineSequence;
  1819. /**
  1820. * Get the minimum legal column for line at `lineNumber`
  1821. */
  1822. getLineMinColumn(lineNumber: number): number;
  1823. /**
  1824. * Get the maximum legal column for line at `lineNumber`
  1825. */
  1826. getLineMaxColumn(lineNumber: number): number;
  1827. /**
  1828. * Returns the column before the first non whitespace character for line at `lineNumber`.
  1829. * Returns 0 if line is empty or contains only whitespace.
  1830. */
  1831. getLineFirstNonWhitespaceColumn(lineNumber: number): number;
  1832. /**
  1833. * Returns the column after the last non whitespace character for line at `lineNumber`.
  1834. * Returns 0 if line is empty or contains only whitespace.
  1835. */
  1836. getLineLastNonWhitespaceColumn(lineNumber: number): number;
  1837. /**
  1838. * Create a valid position.
  1839. */
  1840. validatePosition(position: IPosition): Position;
  1841. /**
  1842. * Advances the given position by the given offset (negative offsets are also accepted)
  1843. * and returns it as a new valid position.
  1844. *
  1845. * If the offset and position are such that their combination goes beyond the beginning or
  1846. * end of the model, throws an exception.
  1847. *
  1848. * If the offset is such that the new position would be in the middle of a multi-byte
  1849. * line terminator, throws an exception.
  1850. */
  1851. modifyPosition(position: IPosition, offset: number): Position;
  1852. /**
  1853. * Create a valid range.
  1854. */
  1855. validateRange(range: IRange): Range;
  1856. /**
  1857. * Converts the position to a zero-based offset.
  1858. *
  1859. * The position will be [adjusted](#TextDocument.validatePosition).
  1860. *
  1861. * @param position A position.
  1862. * @return A valid zero-based offset.
  1863. */
  1864. getOffsetAt(position: IPosition): number;
  1865. /**
  1866. * Converts a zero-based offset to a position.
  1867. *
  1868. * @param offset A zero-based offset.
  1869. * @return A valid [position](#Position).
  1870. */
  1871. getPositionAt(offset: number): Position;
  1872. /**
  1873. * Get a range covering the entire model.
  1874. */
  1875. getFullModelRange(): Range;
  1876. /**
  1877. * Returns if the model was disposed or not.
  1878. */
  1879. isDisposed(): boolean;
  1880. /**
  1881. * Search the model.
  1882. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
  1883. * @param searchOnlyEditableRange Limit the searching to only search inside the editable range of the model.
  1884. * @param isRegex Used to indicate that `searchString` is a regular expression.
  1885. * @param matchCase Force the matching to match lower/upper case exactly.
  1886. * @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
  1887. * @param captureMatches The result will contain the captured groups.
  1888. * @param limitResultCount Limit the number of results
  1889. * @return The ranges where the matches are. It is empty if not matches have been found.
  1890. */
  1891. findMatches(searchString: string, searchOnlyEditableRange: boolean, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean, limitResultCount?: number): FindMatch[];
  1892. /**
  1893. * Search the model.
  1894. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
  1895. * @param searchScope Limit the searching to only search inside these ranges.
  1896. * @param isRegex Used to indicate that `searchString` is a regular expression.
  1897. * @param matchCase Force the matching to match lower/upper case exactly.
  1898. * @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
  1899. * @param captureMatches The result will contain the captured groups.
  1900. * @param limitResultCount Limit the number of results
  1901. * @return The ranges where the matches are. It is empty if no matches have been found.
  1902. */
  1903. findMatches(searchString: string, searchScope: IRange | IRange[], isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean, limitResultCount?: number): FindMatch[];
  1904. /**
  1905. * Search the model for the next match. Loops to the beginning of the model if needed.
  1906. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
  1907. * @param searchStart Start the searching at the specified position.
  1908. * @param isRegex Used to indicate that `searchString` is a regular expression.
  1909. * @param matchCase Force the matching to match lower/upper case exactly.
  1910. * @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
  1911. * @param captureMatches The result will contain the captured groups.
  1912. * @return The range where the next match is. It is null if no next match has been found.
  1913. */
  1914. findNextMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null;
  1915. /**
  1916. * Search the model for the previous match. Loops to the end of the model if needed.
  1917. * @param searchString The string used to search. If it is a regular expression, set `isRegex` to true.
  1918. * @param searchStart Start the searching at the specified position.
  1919. * @param isRegex Used to indicate that `searchString` is a regular expression.
  1920. * @param matchCase Force the matching to match lower/upper case exactly.
  1921. * @param wordSeparators Force the matching to match entire words only. Pass null otherwise.
  1922. * @param captureMatches The result will contain the captured groups.
  1923. * @return The range where the previous match is. It is null if no previous match has been found.
  1924. */
  1925. findPreviousMatch(searchString: string, searchStart: IPosition, isRegex: boolean, matchCase: boolean, wordSeparators: string | null, captureMatches: boolean): FindMatch | null;
  1926. /**
  1927. * Get the language associated with this model.
  1928. */
  1929. getLanguageId(): string;
  1930. /**
  1931. * Get the word under or besides `position`.
  1932. * @param position The position to look for a word.
  1933. * @return The word under or besides `position`. Might be null.
  1934. */
  1935. getWordAtPosition(position: IPosition): IWordAtPosition | null;
  1936. /**
  1937. * Get the word under or besides `position` trimmed to `position`.column
  1938. * @param position The position to look for a word.
  1939. * @return The word under or besides `position`. Will never be null.
  1940. */
  1941. getWordUntilPosition(position: IPosition): IWordAtPosition;
  1942. /**
  1943. * Perform a minimum amount of operations, in order to transform the decorations
  1944. * identified by `oldDecorations` to the decorations described by `newDecorations`
  1945. * and returns the new identifiers associated with the resulting decorations.
  1946. *
  1947. * @param oldDecorations Array containing previous decorations identifiers.
  1948. * @param newDecorations Array describing what decorations should result after the call.
  1949. * @param ownerId Identifies the editor id in which these decorations should appear. If no `ownerId` is provided, the decorations will appear in all editors that attach this model.
  1950. * @return An array containing the new decorations identifiers.
  1951. */
  1952. deltaDecorations(oldDecorations: string[], newDecorations: IModelDeltaDecoration[], ownerId?: number): string[];
  1953. /**
  1954. * Get the options associated with a decoration.
  1955. * @param id The decoration id.
  1956. * @return The decoration options or null if the decoration was not found.
  1957. */
  1958. getDecorationOptions(id: string): IModelDecorationOptions | null;
  1959. /**
  1960. * Get the range associated with a decoration.
  1961. * @param id The decoration id.
  1962. * @return The decoration range or null if the decoration was not found.
  1963. */
  1964. getDecorationRange(id: string): Range | null;
  1965. /**
  1966. * Gets all the decorations for the line `lineNumber` as an array.
  1967. * @param lineNumber The line number
  1968. * @param ownerId If set, it will ignore decorations belonging to other owners.
  1969. * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
  1970. * @return An array with the decorations
  1971. */
  1972. getLineDecorations(lineNumber: number, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[];
  1973. /**
  1974. * Gets all the decorations for the lines between `startLineNumber` and `endLineNumber` as an array.
  1975. * @param startLineNumber The start line number
  1976. * @param endLineNumber The end line number
  1977. * @param ownerId If set, it will ignore decorations belonging to other owners.
  1978. * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
  1979. * @return An array with the decorations
  1980. */
  1981. getLinesDecorations(startLineNumber: number, endLineNumber: number, ownerId?: number, filterOutValidation?: boolean): IModelDecoration[];
  1982. /**
  1983. * Gets all the decorations in a range as an array. Only `startLineNumber` and `endLineNumber` from `range` are used for filtering.
  1984. * So for now it returns all the decorations on the same line as `range`.
  1985. * @param range The range to search in
  1986. * @param ownerId If set, it will ignore decorations belonging to other owners.
  1987. * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
  1988. * @return An array with the decorations
  1989. */
  1990. getDecorationsInRange(range: IRange, ownerId?: number, filterOutValidation?: boolean, onlyMinimapDecorations?: boolean): IModelDecoration[];
  1991. /**
  1992. * Gets all the decorations as an array.
  1993. * @param ownerId If set, it will ignore decorations belonging to other owners.
  1994. * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
  1995. */
  1996. getAllDecorations(ownerId?: number, filterOutValidation?: boolean): IModelDecoration[];
  1997. /**
  1998. * Gets all the decorations that should be rendered in the overview ruler as an array.
  1999. * @param ownerId If set, it will ignore decorations belonging to other owners.
  2000. * @param filterOutValidation If set, it will ignore decorations specific to validation (i.e. warnings, errors).
  2001. */
  2002. getOverviewRulerDecorations(ownerId?: number, filterOutValidation?: boolean): IModelDecoration[];
  2003. /**
  2004. * Gets all the decorations that contain injected text.
  2005. * @param ownerId If set, it will ignore decorations belonging to other owners.
  2006. */
  2007. getInjectedTextDecorations(ownerId?: number): IModelDecoration[];
  2008. /**
  2009. * Normalize a string containing whitespace according to indentation rules (converts to spaces or to tabs).
  2010. */
  2011. normalizeIndentation(str: string): string;
  2012. /**
  2013. * Change the options of this model.
  2014. */
  2015. updateOptions(newOpts: ITextModelUpdateOptions): void;
  2016. /**
  2017. * Detect the indentation options for this model from its content.
  2018. */
  2019. detectIndentation(defaultInsertSpaces: boolean, defaultTabSize: number): void;
  2020. /**
  2021. * Close the current undo-redo element.
  2022. * This offers a way to create an undo/redo stop point.
  2023. */
  2024. pushStackElement(): void;
  2025. /**
  2026. * Open the current undo-redo element.
  2027. * This offers a way to remove the current undo/redo stop point.
  2028. */
  2029. popStackElement(): void;
  2030. /**
  2031. * Push edit operations, basically editing the model. This is the preferred way
  2032. * of editing the model. The edit operations will land on the undo stack.
  2033. * @param beforeCursorState The cursor state before the edit operations. This cursor state will be returned when `undo` or `redo` are invoked.
  2034. * @param editOperations The edit operations.
  2035. * @param cursorStateComputer A callback that can compute the resulting cursors state after the edit operations have been executed.
  2036. * @return The cursor state returned by the `cursorStateComputer`.
  2037. */
  2038. pushEditOperations(beforeCursorState: Selection[] | null, editOperations: IIdentifiedSingleEditOperation[], cursorStateComputer: ICursorStateComputer): Selection[] | null;
  2039. /**
  2040. * Change the end of line sequence. This is the preferred way of
  2041. * changing the eol sequence. This will land on the undo stack.
  2042. */
  2043. pushEOL(eol: EndOfLineSequence): void;
  2044. /**
  2045. * Edit the model without adding the edits to the undo stack.
  2046. * This can have dire consequences on the undo stack! See @pushEditOperations for the preferred way.
  2047. * @param operations The edit operations.
  2048. * @return If desired, the inverse edit operations, that, when applied, will bring the model back to the previous state.
  2049. */
  2050. applyEdits(operations: IIdentifiedSingleEditOperation[]): void;
  2051. applyEdits(operations: IIdentifiedSingleEditOperation[], computeUndoEdits: false): void;
  2052. applyEdits(operations: IIdentifiedSingleEditOperation[], computeUndoEdits: true): IValidEditOperation[];
  2053. /**
  2054. * Change the end of line sequence without recording in the undo stack.
  2055. * This can have dire consequences on the undo stack! See @pushEOL for the preferred way.
  2056. */
  2057. setEOL(eol: EndOfLineSequence): void;
  2058. /**
  2059. * An event emitted when the contents of the model have changed.
  2060. * @event
  2061. */
  2062. onDidChangeContent(listener: (e: IModelContentChangedEvent) => void): IDisposable;
  2063. /**
  2064. * An event emitted when decorations of the model have changed.
  2065. * @event
  2066. */
  2067. readonly onDidChangeDecorations: IEvent<IModelDecorationsChangedEvent>;
  2068. /**
  2069. * An event emitted when the model options have changed.
  2070. * @event
  2071. */
  2072. readonly onDidChangeOptions: IEvent<IModelOptionsChangedEvent>;
  2073. /**
  2074. * An event emitted when the language associated with the model has changed.
  2075. * @event
  2076. */
  2077. readonly onDidChangeLanguage: IEvent<IModelLanguageChangedEvent>;
  2078. /**
  2079. * An event emitted when the language configuration associated with the model has changed.
  2080. * @event
  2081. */
  2082. readonly onDidChangeLanguageConfiguration: IEvent<IModelLanguageConfigurationChangedEvent>;
  2083. /**
  2084. * An event emitted when the model has been attached to the first editor or detached from the last editor.
  2085. * @event
  2086. */
  2087. readonly onDidChangeAttached: IEvent<void>;
  2088. /**
  2089. * An event emitted right before disposing the model.
  2090. * @event
  2091. */
  2092. readonly onWillDispose: IEvent<void>;
  2093. /**
  2094. * Destroy this model.
  2095. */
  2096. dispose(): void;
  2097. /**
  2098. * Returns if this model is attached to an editor or not.
  2099. */
  2100. isAttachedToEditor(): boolean;
  2101. }
  2102. export enum PositionAffinity {
  2103. /**
  2104. * Prefers the left most position.
  2105. */
  2106. Left = 0,
  2107. /**
  2108. * Prefers the right most position.
  2109. */
  2110. Right = 1,
  2111. /**
  2112. * No preference.
  2113. */
  2114. None = 2,
  2115. /**
  2116. * If the given position is on injected text, prefers the position left of it.
  2117. */
  2118. LeftOfInjectedText = 3,
  2119. /**
  2120. * If the given position is on injected text, prefers the position right of it.
  2121. */
  2122. RightOfInjectedText = 4
  2123. }
  2124. /**
  2125. * A change
  2126. */
  2127. export interface IChange {
  2128. readonly originalStartLineNumber: number;
  2129. readonly originalEndLineNumber: number;
  2130. readonly modifiedStartLineNumber: number;
  2131. readonly modifiedEndLineNumber: number;
  2132. }
  2133. /**
  2134. * A character level change.
  2135. */
  2136. export interface ICharChange extends IChange {
  2137. readonly originalStartColumn: number;
  2138. readonly originalEndColumn: number;
  2139. readonly modifiedStartColumn: number;
  2140. readonly modifiedEndColumn: number;
  2141. }
  2142. /**
  2143. * A line change
  2144. */
  2145. export interface ILineChange extends IChange {
  2146. readonly charChanges: ICharChange[] | undefined;
  2147. }
  2148. /**
  2149. * A document diff provider computes the diff between two text models.
  2150. */
  2151. export interface IDocumentDiffProvider {
  2152. /**
  2153. * Computes the diff between the text models `original` and `modified`.
  2154. */
  2155. computeDiff(original: ITextModel, modified: ITextModel, options: IDocumentDiffProviderOptions): Promise<IDocumentDiff>;
  2156. /**
  2157. * Is fired when settings of the diff algorithm change that could alter the result of the diffing computation.
  2158. * Any user of this provider should recompute the diff when this event is fired.
  2159. */
  2160. onDidChange: IEvent<void>;
  2161. }
  2162. /**
  2163. * Options for the diff computation.
  2164. */
  2165. export interface IDocumentDiffProviderOptions {
  2166. /**
  2167. * When set to true, the diff should ignore whitespace changes.i
  2168. */
  2169. ignoreTrimWhitespace: boolean;
  2170. /**
  2171. * A diff computation should throw if it takes longer than this value.
  2172. */
  2173. maxComputationTimeMs: number;
  2174. }
  2175. /**
  2176. * Represents a diff between two text models.
  2177. */
  2178. export interface IDocumentDiff {
  2179. /**
  2180. * If true, both text models are identical (byte-wise).
  2181. */
  2182. readonly identical: boolean;
  2183. /**
  2184. * If true, the diff computation timed out and the diff might not be accurate.
  2185. */
  2186. readonly quitEarly: boolean;
  2187. /**
  2188. * Maps all modified line ranges in the original to the corresponding line ranges in the modified text model.
  2189. */
  2190. readonly changes: LineRangeMapping[];
  2191. }
  2192. /**
  2193. * A range of lines (1-based).
  2194. */
  2195. export class LineRange {
  2196. /**
  2197. * The start line number.
  2198. */
  2199. readonly startLineNumber: number;
  2200. /**
  2201. * The end line number (exclusive).
  2202. */
  2203. readonly endLineNumberExclusive: number;
  2204. constructor(startLineNumber: number, endLineNumberExclusive: number);
  2205. /**
  2206. * Indicates if this line range contains the given line number.
  2207. */
  2208. contains(lineNumber: number): boolean;
  2209. /**
  2210. * Indicates if this line range is empty.
  2211. */
  2212. get isEmpty(): boolean;
  2213. /**
  2214. * Moves this line range by the given offset of line numbers.
  2215. */
  2216. delta(offset: number): LineRange;
  2217. /**
  2218. * The number of lines this line range spans.
  2219. */
  2220. get length(): number;
  2221. /**
  2222. * Creates a line range that combines this and the given line range.
  2223. */
  2224. join(other: LineRange): LineRange;
  2225. toString(): string;
  2226. /**
  2227. * The resulting range is empty if the ranges do not intersect, but touch.
  2228. * If the ranges don't even touch, the result is undefined.
  2229. */
  2230. intersect(other: LineRange): LineRange | undefined;
  2231. overlapOrTouch(other: LineRange): boolean;
  2232. }
  2233. /**
  2234. * Maps a line range in the original text model to a line range in the modified text model.
  2235. */
  2236. export class LineRangeMapping {
  2237. /**
  2238. * The line range in the original text model.
  2239. */
  2240. readonly originalRange: LineRange;
  2241. /**
  2242. * The line range in the modified text model.
  2243. */
  2244. readonly modifiedRange: LineRange;
  2245. /**
  2246. * If inner changes have not been computed, this is set to undefined.
  2247. * Otherwise, it represents the character-level diff in this line range.
  2248. * The original range of each range mapping should be contained in the original line range (same for modified), exceptions are new-lines.
  2249. * Must not be an empty array.
  2250. */
  2251. readonly innerChanges: RangeMapping[] | undefined;
  2252. constructor(originalRange: LineRange, modifiedRange: LineRange, innerChanges: RangeMapping[] | undefined);
  2253. toString(): string;
  2254. }
  2255. /**
  2256. * Maps a range in the original text model to a range in the modified text model.
  2257. */
  2258. export class RangeMapping {
  2259. /**
  2260. * The original range.
  2261. */
  2262. readonly originalRange: Range;
  2263. /**
  2264. * The modified range.
  2265. */
  2266. readonly modifiedRange: Range;
  2267. constructor(originalRange: Range, modifiedRange: Range);
  2268. toString(): string;
  2269. }
  2270. export interface IDimension {
  2271. width: number;
  2272. height: number;
  2273. }
  2274. /**
  2275. * A builder and helper for edit operations for a command.
  2276. */
  2277. export interface IEditOperationBuilder {
  2278. /**
  2279. * Add a new edit operation (a replace operation).
  2280. * @param range The range to replace (delete). May be empty to represent a simple insert.
  2281. * @param text The text to replace with. May be null to represent a simple delete.
  2282. */
  2283. addEditOperation(range: IRange, text: string | null, forceMoveMarkers?: boolean): void;
  2284. /**
  2285. * Add a new edit operation (a replace operation).
  2286. * The inverse edits will be accessible in `ICursorStateComputerData.getInverseEditOperations()`
  2287. * @param range The range to replace (delete). May be empty to represent a simple insert.
  2288. * @param text The text to replace with. May be null to represent a simple delete.
  2289. */
  2290. addTrackedEditOperation(range: IRange, text: string | null, forceMoveMarkers?: boolean): void;
  2291. /**
  2292. * Track `selection` when applying edit operations.
  2293. * A best effort will be made to not grow/expand the selection.
  2294. * An empty selection will clamp to a nearby character.
  2295. * @param selection The selection to track.
  2296. * @param trackPreviousOnEmpty If set, and the selection is empty, indicates whether the selection
  2297. * should clamp to the previous or the next character.
  2298. * @return A unique identifier.
  2299. */
  2300. trackSelection(selection: Selection, trackPreviousOnEmpty?: boolean): string;
  2301. }
  2302. /**
  2303. * A helper for computing cursor state after a command.
  2304. */
  2305. export interface ICursorStateComputerData {
  2306. /**
  2307. * Get the inverse edit operations of the added edit operations.
  2308. */
  2309. getInverseEditOperations(): IValidEditOperation[];
  2310. /**
  2311. * Get a previously tracked selection.
  2312. * @param id The unique identifier returned by `trackSelection`.
  2313. * @return The selection.
  2314. */
  2315. getTrackedSelection(id: string): Selection;
  2316. }
  2317. /**
  2318. * A command that modifies text / cursor state on a model.
  2319. */
  2320. export interface ICommand {
  2321. /**
  2322. * Get the edit operations needed to execute this command.
  2323. * @param model The model the command will execute on.
  2324. * @param builder A helper to collect the needed edit operations and to track selections.
  2325. */
  2326. getEditOperations(model: ITextModel, builder: IEditOperationBuilder): void;
  2327. /**
  2328. * Compute the cursor state after the edit operations were applied.
  2329. * @param model The model the command has executed on.
  2330. * @param helper A helper to get inverse edit operations and to get previously tracked selections.
  2331. * @return The cursor state after the command executed.
  2332. */
  2333. computeCursorState(model: ITextModel, helper: ICursorStateComputerData): Selection;
  2334. }
  2335. /**
  2336. * A model for the diff editor.
  2337. */
  2338. export interface IDiffEditorModel {
  2339. /**
  2340. * Original model.
  2341. */
  2342. original: ITextModel;
  2343. /**
  2344. * Modified model.
  2345. */
  2346. modified: ITextModel;
  2347. }
  2348. /**
  2349. * An event describing that an editor has had its model reset (i.e. `editor.setModel()`).
  2350. */
  2351. export interface IModelChangedEvent {
  2352. /**
  2353. * The `uri` of the previous model or null.
  2354. */
  2355. readonly oldModelUrl: Uri | null;
  2356. /**
  2357. * The `uri` of the new model or null.
  2358. */
  2359. readonly newModelUrl: Uri | null;
  2360. }
  2361. export interface IContentSizeChangedEvent {
  2362. readonly contentWidth: number;
  2363. readonly contentHeight: number;
  2364. readonly contentWidthChanged: boolean;
  2365. readonly contentHeightChanged: boolean;
  2366. }
  2367. export interface INewScrollPosition {
  2368. scrollLeft?: number;
  2369. scrollTop?: number;
  2370. }
  2371. export interface IEditorAction {
  2372. readonly id: string;
  2373. readonly label: string;
  2374. readonly alias: string;
  2375. isSupported(): boolean;
  2376. run(args?: unknown): Promise<void>;
  2377. }
  2378. export type IEditorModel = ITextModel | IDiffEditorModel;
  2379. /**
  2380. * A (serializable) state of the cursors.
  2381. */
  2382. export interface ICursorState {
  2383. inSelectionMode: boolean;
  2384. selectionStart: IPosition;
  2385. position: IPosition;
  2386. }
  2387. /**
  2388. * A (serializable) state of the view.
  2389. */
  2390. export interface IViewState {
  2391. /** written by previous versions */
  2392. scrollTop?: number;
  2393. /** written by previous versions */
  2394. scrollTopWithoutViewZones?: number;
  2395. scrollLeft: number;
  2396. firstPosition: IPosition;
  2397. firstPositionDeltaTop: number;
  2398. }
  2399. /**
  2400. * A (serializable) state of the code editor.
  2401. */
  2402. export interface ICodeEditorViewState {
  2403. cursorState: ICursorState[];
  2404. viewState: IViewState;
  2405. contributionsState: {
  2406. [id: string]: any;
  2407. };
  2408. }
  2409. /**
  2410. * (Serializable) View state for the diff editor.
  2411. */
  2412. export interface IDiffEditorViewState {
  2413. original: ICodeEditorViewState | null;
  2414. modified: ICodeEditorViewState | null;
  2415. }
  2416. /**
  2417. * An editor view state.
  2418. */
  2419. export type IEditorViewState = ICodeEditorViewState | IDiffEditorViewState;
  2420. export enum ScrollType {
  2421. Smooth = 0,
  2422. Immediate = 1
  2423. }
  2424. /**
  2425. * An editor.
  2426. */
  2427. export interface IEditor {
  2428. /**
  2429. * An event emitted when the editor has been disposed.
  2430. * @event
  2431. */
  2432. onDidDispose(listener: () => void): IDisposable;
  2433. /**
  2434. * Dispose the editor.
  2435. */
  2436. dispose(): void;
  2437. /**
  2438. * Get a unique id for this editor instance.
  2439. */
  2440. getId(): string;
  2441. /**
  2442. * Get the editor type. Please see `EditorType`.
  2443. * This is to avoid an instanceof check
  2444. */
  2445. getEditorType(): string;
  2446. /**
  2447. * Update the editor's options after the editor has been created.
  2448. */
  2449. updateOptions(newOptions: IEditorOptions): void;
  2450. /**
  2451. * Instructs the editor to remeasure its container. This method should
  2452. * be called when the container of the editor gets resized.
  2453. *
  2454. * If a dimension is passed in, the passed in value will be used.
  2455. */
  2456. layout(dimension?: IDimension): void;
  2457. /**
  2458. * Brings browser focus to the editor text
  2459. */
  2460. focus(): void;
  2461. /**
  2462. * Returns true if the text inside this editor is focused (i.e. cursor is blinking).
  2463. */
  2464. hasTextFocus(): boolean;
  2465. /**
  2466. * Returns all actions associated with this editor.
  2467. */
  2468. getSupportedActions(): IEditorAction[];
  2469. /**
  2470. * Saves current view state of the editor in a serializable object.
  2471. */
  2472. saveViewState(): IEditorViewState | null;
  2473. /**
  2474. * Restores the view state of the editor from a serializable object generated by `saveViewState`.
  2475. */
  2476. restoreViewState(state: IEditorViewState | null): void;
  2477. /**
  2478. * Given a position, returns a column number that takes tab-widths into account.
  2479. */
  2480. getVisibleColumnFromPosition(position: IPosition): number;
  2481. /**
  2482. * Returns the primary position of the cursor.
  2483. */
  2484. getPosition(): Position | null;
  2485. /**
  2486. * Set the primary position of the cursor. This will remove any secondary cursors.
  2487. * @param position New primary cursor's position
  2488. * @param source Source of the call that caused the position
  2489. */
  2490. setPosition(position: IPosition, source?: string): void;
  2491. /**
  2492. * Scroll vertically as necessary and reveal a line.
  2493. */
  2494. revealLine(lineNumber: number, scrollType?: ScrollType): void;
  2495. /**
  2496. * Scroll vertically as necessary and reveal a line centered vertically.
  2497. */
  2498. revealLineInCenter(lineNumber: number, scrollType?: ScrollType): void;
  2499. /**
  2500. * Scroll vertically as necessary and reveal a line centered vertically only if it lies outside the viewport.
  2501. */
  2502. revealLineInCenterIfOutsideViewport(lineNumber: number, scrollType?: ScrollType): void;
  2503. /**
  2504. * Scroll vertically as necessary and reveal a line close to the top of the viewport,
  2505. * optimized for viewing a code definition.
  2506. */
  2507. revealLineNearTop(lineNumber: number, scrollType?: ScrollType): void;
  2508. /**
  2509. * Scroll vertically or horizontally as necessary and reveal a position.
  2510. */
  2511. revealPosition(position: IPosition, scrollType?: ScrollType): void;
  2512. /**
  2513. * Scroll vertically or horizontally as necessary and reveal a position centered vertically.
  2514. */
  2515. revealPositionInCenter(position: IPosition, scrollType?: ScrollType): void;
  2516. /**
  2517. * Scroll vertically or horizontally as necessary and reveal a position centered vertically only if it lies outside the viewport.
  2518. */
  2519. revealPositionInCenterIfOutsideViewport(position: IPosition, scrollType?: ScrollType): void;
  2520. /**
  2521. * Scroll vertically or horizontally as necessary and reveal a position close to the top of the viewport,
  2522. * optimized for viewing a code definition.
  2523. */
  2524. revealPositionNearTop(position: IPosition, scrollType?: ScrollType): void;
  2525. /**
  2526. * Returns the primary selection of the editor.
  2527. */
  2528. getSelection(): Selection | null;
  2529. /**
  2530. * Returns all the selections of the editor.
  2531. */
  2532. getSelections(): Selection[] | null;
  2533. /**
  2534. * Set the primary selection of the editor. This will remove any secondary cursors.
  2535. * @param selection The new selection
  2536. * @param source Source of the call that caused the selection
  2537. */
  2538. setSelection(selection: IRange, source?: string): void;
  2539. /**
  2540. * Set the primary selection of the editor. This will remove any secondary cursors.
  2541. * @param selection The new selection
  2542. * @param source Source of the call that caused the selection
  2543. */
  2544. setSelection(selection: Range, source?: string): void;
  2545. /**
  2546. * Set the primary selection of the editor. This will remove any secondary cursors.
  2547. * @param selection The new selection
  2548. * @param source Source of the call that caused the selection
  2549. */
  2550. setSelection(selection: ISelection, source?: string): void;
  2551. /**
  2552. * Set the primary selection of the editor. This will remove any secondary cursors.
  2553. * @param selection The new selection
  2554. * @param source Source of the call that caused the selection
  2555. */
  2556. setSelection(selection: Selection, source?: string): void;
  2557. /**
  2558. * Set the selections for all the cursors of the editor.
  2559. * Cursors will be removed or added, as necessary.
  2560. * @param selections The new selection
  2561. * @param source Source of the call that caused the selection
  2562. */
  2563. setSelections(selections: readonly ISelection[], source?: string): void;
  2564. /**
  2565. * Scroll vertically as necessary and reveal lines.
  2566. */
  2567. revealLines(startLineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
  2568. /**
  2569. * Scroll vertically as necessary and reveal lines centered vertically.
  2570. */
  2571. revealLinesInCenter(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
  2572. /**
  2573. * Scroll vertically as necessary and reveal lines centered vertically only if it lies outside the viewport.
  2574. */
  2575. revealLinesInCenterIfOutsideViewport(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
  2576. /**
  2577. * Scroll vertically as necessary and reveal lines close to the top of the viewport,
  2578. * optimized for viewing a code definition.
  2579. */
  2580. revealLinesNearTop(lineNumber: number, endLineNumber: number, scrollType?: ScrollType): void;
  2581. /**
  2582. * Scroll vertically or horizontally as necessary and reveal a range.
  2583. */
  2584. revealRange(range: IRange, scrollType?: ScrollType): void;
  2585. /**
  2586. * Scroll vertically or horizontally as necessary and reveal a range centered vertically.
  2587. */
  2588. revealRangeInCenter(range: IRange, scrollType?: ScrollType): void;
  2589. /**
  2590. * Scroll vertically or horizontally as necessary and reveal a range at the top of the viewport.
  2591. */
  2592. revealRangeAtTop(range: IRange, scrollType?: ScrollType): void;
  2593. /**
  2594. * Scroll vertically or horizontally as necessary and reveal a range centered vertically only if it lies outside the viewport.
  2595. */
  2596. revealRangeInCenterIfOutsideViewport(range: IRange, scrollType?: ScrollType): void;
  2597. /**
  2598. * Scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport,
  2599. * optimized for viewing a code definition.
  2600. */
  2601. revealRangeNearTop(range: IRange, scrollType?: ScrollType): void;
  2602. /**
  2603. * Scroll vertically or horizontally as necessary and reveal a range close to the top of the viewport,
  2604. * optimized for viewing a code definition. Only if it lies outside the viewport.
  2605. */
  2606. revealRangeNearTopIfOutsideViewport(range: IRange, scrollType?: ScrollType): void;
  2607. /**
  2608. * Directly trigger a handler or an editor action.
  2609. * @param source The source of the call.
  2610. * @param handlerId The id of the handler or the id of a contribution.
  2611. * @param payload Extra data to be sent to the handler.
  2612. */
  2613. trigger(source: string | null | undefined, handlerId: string, payload: any): void;
  2614. /**
  2615. * Gets the current model attached to this editor.
  2616. */
  2617. getModel(): IEditorModel | null;
  2618. /**
  2619. * Sets the current model attached to this editor.
  2620. * If the previous model was created by the editor via the value key in the options
  2621. * literal object, it will be destroyed. Otherwise, if the previous model was set
  2622. * via setModel, or the model key in the options literal object, the previous model
  2623. * will not be destroyed.
  2624. * It is safe to call setModel(null) to simply detach the current model from the editor.
  2625. */
  2626. setModel(model: IEditorModel | null): void;
  2627. /**
  2628. * Create a collection of decorations. All decorations added through this collection
  2629. * will get the ownerId of the editor (meaning they will not show up in other editors).
  2630. * These decorations will be automatically cleared when the editor's model changes.
  2631. */
  2632. createDecorationsCollection(decorations?: IModelDeltaDecoration[]): IEditorDecorationsCollection;
  2633. }
  2634. /**
  2635. * A collection of decorations
  2636. */
  2637. export interface IEditorDecorationsCollection {
  2638. /**
  2639. * An event emitted when decorations change in the editor,
  2640. * but the change is not caused by us setting or clearing the collection.
  2641. */
  2642. onDidChange: IEvent<IModelDecorationsChangedEvent>;
  2643. /**
  2644. * Get the decorations count.
  2645. */
  2646. length: number;
  2647. /**
  2648. * Get the range for a decoration.
  2649. */
  2650. getRange(index: number): Range | null;
  2651. /**
  2652. * Get all ranges for decorations.
  2653. */
  2654. getRanges(): Range[];
  2655. /**
  2656. * Determine if a decoration is in this collection.
  2657. */
  2658. has(decoration: IModelDecoration): boolean;
  2659. /**
  2660. * Replace all previous decorations with `newDecorations`.
  2661. */
  2662. set(newDecorations: IModelDeltaDecoration[]): void;
  2663. /**
  2664. * Remove all previous decorations.
  2665. */
  2666. clear(): void;
  2667. }
  2668. /**
  2669. * An editor contribution that gets created every time a new editor gets created and gets disposed when the editor gets disposed.
  2670. */
  2671. export interface IEditorContribution {
  2672. /**
  2673. * Dispose this contribution.
  2674. */
  2675. dispose(): void;
  2676. /**
  2677. * Store view state.
  2678. */
  2679. saveViewState?(): any;
  2680. /**
  2681. * Restore view state.
  2682. */
  2683. restoreViewState?(state: any): void;
  2684. }
  2685. /**
  2686. * The type of the `IEditor`.
  2687. */
  2688. export const EditorType: {
  2689. ICodeEditor: string;
  2690. IDiffEditor: string;
  2691. };
  2692. /**
  2693. * An event describing that the current language associated with a model has changed.
  2694. */
  2695. export interface IModelLanguageChangedEvent {
  2696. /**
  2697. * Previous language
  2698. */
  2699. readonly oldLanguage: string;
  2700. /**
  2701. * New language
  2702. */
  2703. readonly newLanguage: string;
  2704. /**
  2705. * Source of the call that caused the event.
  2706. */
  2707. readonly source: string;
  2708. }
  2709. /**
  2710. * An event describing that the language configuration associated with a model has changed.
  2711. */
  2712. export interface IModelLanguageConfigurationChangedEvent {
  2713. }
  2714. export interface IModelContentChange {
  2715. /**
  2716. * The range that got replaced.
  2717. */
  2718. readonly range: IRange;
  2719. /**
  2720. * The offset of the range that got replaced.
  2721. */
  2722. readonly rangeOffset: number;
  2723. /**
  2724. * The length of the range that got replaced.
  2725. */
  2726. readonly rangeLength: number;
  2727. /**
  2728. * The new text for the range.
  2729. */
  2730. readonly text: string;
  2731. }
  2732. /**
  2733. * An event describing a change in the text of a model.
  2734. */
  2735. export interface IModelContentChangedEvent {
  2736. readonly changes: IModelContentChange[];
  2737. /**
  2738. * The (new) end-of-line character.
  2739. */
  2740. readonly eol: string;
  2741. /**
  2742. * The new version id the model has transitioned to.
  2743. */
  2744. readonly versionId: number;
  2745. /**
  2746. * Flag that indicates that this event was generated while undoing.
  2747. */
  2748. readonly isUndoing: boolean;
  2749. /**
  2750. * Flag that indicates that this event was generated while redoing.
  2751. */
  2752. readonly isRedoing: boolean;
  2753. /**
  2754. * Flag that indicates that all decorations were lost with this edit.
  2755. * The model has been reset to a new value.
  2756. */
  2757. readonly isFlush: boolean;
  2758. /**
  2759. * Flag that indicates that this event describes an eol change.
  2760. */
  2761. readonly isEolChange: boolean;
  2762. }
  2763. /**
  2764. * An event describing that model decorations have changed.
  2765. */
  2766. export interface IModelDecorationsChangedEvent {
  2767. readonly affectsMinimap: boolean;
  2768. readonly affectsOverviewRuler: boolean;
  2769. }
  2770. export interface IModelOptionsChangedEvent {
  2771. readonly tabSize: boolean;
  2772. readonly indentSize: boolean;
  2773. readonly insertSpaces: boolean;
  2774. readonly trimAutoWhitespace: boolean;
  2775. }
  2776. /**
  2777. * Describes the reason the cursor has changed its position.
  2778. */
  2779. export enum CursorChangeReason {
  2780. /**
  2781. * Unknown or not set.
  2782. */
  2783. NotSet = 0,
  2784. /**
  2785. * A `model.setValue()` was called.
  2786. */
  2787. ContentFlush = 1,
  2788. /**
  2789. * The `model` has been changed outside of this cursor and the cursor recovers its position from associated markers.
  2790. */
  2791. RecoverFromMarkers = 2,
  2792. /**
  2793. * There was an explicit user gesture.
  2794. */
  2795. Explicit = 3,
  2796. /**
  2797. * There was a Paste.
  2798. */
  2799. Paste = 4,
  2800. /**
  2801. * There was an Undo.
  2802. */
  2803. Undo = 5,
  2804. /**
  2805. * There was a Redo.
  2806. */
  2807. Redo = 6
  2808. }
  2809. /**
  2810. * An event describing that the cursor position has changed.
  2811. */
  2812. export interface ICursorPositionChangedEvent {
  2813. /**
  2814. * Primary cursor's position.
  2815. */
  2816. readonly position: Position;
  2817. /**
  2818. * Secondary cursors' position.
  2819. */
  2820. readonly secondaryPositions: Position[];
  2821. /**
  2822. * Reason.
  2823. */
  2824. readonly reason: CursorChangeReason;
  2825. /**
  2826. * Source of the call that caused the event.
  2827. */
  2828. readonly source: string;
  2829. }
  2830. /**
  2831. * An event describing that the cursor selection has changed.
  2832. */
  2833. export interface ICursorSelectionChangedEvent {
  2834. /**
  2835. * The primary selection.
  2836. */
  2837. readonly selection: Selection;
  2838. /**
  2839. * The secondary selections.
  2840. */
  2841. readonly secondarySelections: Selection[];
  2842. /**
  2843. * The model version id.
  2844. */
  2845. readonly modelVersionId: number;
  2846. /**
  2847. * The old selections.
  2848. */
  2849. readonly oldSelections: Selection[] | null;
  2850. /**
  2851. * The model version id the that `oldSelections` refer to.
  2852. */
  2853. readonly oldModelVersionId: number;
  2854. /**
  2855. * Source of the call that caused the event.
  2856. */
  2857. readonly source: string;
  2858. /**
  2859. * Reason.
  2860. */
  2861. readonly reason: CursorChangeReason;
  2862. }
  2863. export enum AccessibilitySupport {
  2864. /**
  2865. * This should be the browser case where it is not known if a screen reader is attached or no.
  2866. */
  2867. Unknown = 0,
  2868. Disabled = 1,
  2869. Enabled = 2
  2870. }
  2871. /**
  2872. * Configuration options for auto closing quotes and brackets
  2873. */
  2874. export type EditorAutoClosingStrategy = 'always' | 'languageDefined' | 'beforeWhitespace' | 'never';
  2875. /**
  2876. * Configuration options for auto wrapping quotes and brackets
  2877. */
  2878. export type EditorAutoSurroundStrategy = 'languageDefined' | 'quotes' | 'brackets' | 'never';
  2879. /**
  2880. * Configuration options for typing over closing quotes or brackets
  2881. */
  2882. export type EditorAutoClosingEditStrategy = 'always' | 'auto' | 'never';
  2883. /**
  2884. * Configuration options for auto indentation in the editor
  2885. */
  2886. export enum EditorAutoIndentStrategy {
  2887. None = 0,
  2888. Keep = 1,
  2889. Brackets = 2,
  2890. Advanced = 3,
  2891. Full = 4
  2892. }
  2893. /**
  2894. * Configuration options for the editor.
  2895. */
  2896. export interface IEditorOptions {
  2897. /**
  2898. * This editor is used inside a diff editor.
  2899. */
  2900. inDiffEditor?: boolean;
  2901. /**
  2902. * The aria label for the editor's textarea (when it is focused).
  2903. */
  2904. ariaLabel?: string;
  2905. /**
  2906. * Control whether a screen reader announces inline suggestion content immediately.
  2907. */
  2908. screenReaderAnnounceInlineSuggestion?: boolean;
  2909. /**
  2910. * The `tabindex` property of the editor's textarea
  2911. */
  2912. tabIndex?: number;
  2913. /**
  2914. * Render vertical lines at the specified columns.
  2915. * Defaults to empty array.
  2916. */
  2917. rulers?: (number | IRulerOption)[];
  2918. /**
  2919. * A string containing the word separators used when doing word navigation.
  2920. * Defaults to `~!@#$%^&*()-=+[{]}\\|;:\'",.<>/?
  2921. */
  2922. wordSeparators?: string;
  2923. /**
  2924. * Enable Linux primary clipboard.
  2925. * Defaults to true.
  2926. */
  2927. selectionClipboard?: boolean;
  2928. /**
  2929. * Control the rendering of line numbers.
  2930. * If it is a function, it will be invoked when rendering a line number and the return value will be rendered.
  2931. * Otherwise, if it is a truthy, line numbers will be rendered normally (equivalent of using an identity function).
  2932. * Otherwise, line numbers will not be rendered.
  2933. * Defaults to `on`.
  2934. */
  2935. lineNumbers?: LineNumbersType;
  2936. /**
  2937. * Controls the minimal number of visible leading and trailing lines surrounding the cursor.
  2938. * Defaults to 0.
  2939. */
  2940. cursorSurroundingLines?: number;
  2941. /**
  2942. * Controls when `cursorSurroundingLines` should be enforced
  2943. * Defaults to `default`, `cursorSurroundingLines` is not enforced when cursor position is changed
  2944. * by mouse.
  2945. */
  2946. cursorSurroundingLinesStyle?: 'default' | 'all';
  2947. /**
  2948. * Render last line number when the file ends with a newline.
  2949. * Defaults to 'on' for Windows and macOS and 'dimmed' for Linux.
  2950. */
  2951. renderFinalNewline?: 'on' | 'off' | 'dimmed';
  2952. /**
  2953. * Remove unusual line terminators like LINE SEPARATOR (LS), PARAGRAPH SEPARATOR (PS).
  2954. * Defaults to 'prompt'.
  2955. */
  2956. unusualLineTerminators?: 'auto' | 'off' | 'prompt';
  2957. /**
  2958. * Should the corresponding line be selected when clicking on the line number?
  2959. * Defaults to true.
  2960. */
  2961. selectOnLineNumbers?: boolean;
  2962. /**
  2963. * Control the width of line numbers, by reserving horizontal space for rendering at least an amount of digits.
  2964. * Defaults to 5.
  2965. */
  2966. lineNumbersMinChars?: number;
  2967. /**
  2968. * Enable the rendering of the glyph margin.
  2969. * Defaults to true in vscode and to false in monaco-editor.
  2970. */
  2971. glyphMargin?: boolean;
  2972. /**
  2973. * The width reserved for line decorations (in px).
  2974. * Line decorations are placed between line numbers and the editor content.
  2975. * You can pass in a string in the format floating point followed by "ch". e.g. 1.3ch.
  2976. * Defaults to 10.
  2977. */
  2978. lineDecorationsWidth?: number | string;
  2979. /**
  2980. * When revealing the cursor, a virtual padding (px) is added to the cursor, turning it into a rectangle.
  2981. * This virtual padding ensures that the cursor gets revealed before hitting the edge of the viewport.
  2982. * Defaults to 30 (px).
  2983. */
  2984. revealHorizontalRightPadding?: number;
  2985. /**
  2986. * Render the editor selection with rounded borders.
  2987. * Defaults to true.
  2988. */
  2989. roundedSelection?: boolean;
  2990. /**
  2991. * Class name to be added to the editor.
  2992. */
  2993. extraEditorClassName?: string;
  2994. /**
  2995. * Should the editor be read only. See also `domReadOnly`.
  2996. * Defaults to false.
  2997. */
  2998. readOnly?: boolean;
  2999. /**
  3000. * Should the textarea used for input use the DOM `readonly` attribute.
  3001. * Defaults to false.
  3002. */
  3003. domReadOnly?: boolean;
  3004. /**
  3005. * Enable linked editing.
  3006. * Defaults to false.
  3007. */
  3008. linkedEditing?: boolean;
  3009. /**
  3010. * deprecated, use linkedEditing instead
  3011. */
  3012. renameOnType?: boolean;
  3013. /**
  3014. * Should the editor render validation decorations.
  3015. * Defaults to editable.
  3016. */
  3017. renderValidationDecorations?: 'editable' | 'on' | 'off';
  3018. /**
  3019. * Control the behavior and rendering of the scrollbars.
  3020. */
  3021. scrollbar?: IEditorScrollbarOptions;
  3022. /**
  3023. * Control the behavior of sticky scroll options
  3024. */
  3025. stickyScroll?: IEditorStickyScrollOptions;
  3026. /**
  3027. * Control the behavior and rendering of the minimap.
  3028. */
  3029. minimap?: IEditorMinimapOptions;
  3030. /**
  3031. * Control the behavior of the find widget.
  3032. */
  3033. find?: IEditorFindOptions;
  3034. /**
  3035. * Display overflow widgets as `fixed`.
  3036. * Defaults to `false`.
  3037. */
  3038. fixedOverflowWidgets?: boolean;
  3039. /**
  3040. * The number of vertical lanes the overview ruler should render.
  3041. * Defaults to 3.
  3042. */
  3043. overviewRulerLanes?: number;
  3044. /**
  3045. * Controls if a border should be drawn around the overview ruler.
  3046. * Defaults to `true`.
  3047. */
  3048. overviewRulerBorder?: boolean;
  3049. /**
  3050. * Control the cursor animation style, possible values are 'blink', 'smooth', 'phase', 'expand' and 'solid'.
  3051. * Defaults to 'blink'.
  3052. */
  3053. cursorBlinking?: 'blink' | 'smooth' | 'phase' | 'expand' | 'solid';
  3054. /**
  3055. * Zoom the font in the editor when using the mouse wheel in combination with holding Ctrl.
  3056. * Defaults to false.
  3057. */
  3058. mouseWheelZoom?: boolean;
  3059. /**
  3060. * Control the mouse pointer style, either 'text' or 'default' or 'copy'
  3061. * Defaults to 'text'
  3062. */
  3063. mouseStyle?: 'text' | 'default' | 'copy';
  3064. /**
  3065. * Enable smooth caret animation.
  3066. * Defaults to 'off'.
  3067. */
  3068. cursorSmoothCaretAnimation?: 'off' | 'explicit' | 'on';
  3069. /**
  3070. * Control the cursor style, either 'block' or 'line'.
  3071. * Defaults to 'line'.
  3072. */
  3073. cursorStyle?: 'line' | 'block' | 'underline' | 'line-thin' | 'block-outline' | 'underline-thin';
  3074. /**
  3075. * Control the width of the cursor when cursorStyle is set to 'line'
  3076. */
  3077. cursorWidth?: number;
  3078. /**
  3079. * Enable font ligatures.
  3080. * Defaults to false.
  3081. */
  3082. fontLigatures?: boolean | string;
  3083. /**
  3084. * Enable font variations.
  3085. * Defaults to false.
  3086. */
  3087. fontVariations?: boolean | string;
  3088. /**
  3089. * Disable the use of `transform: translate3d(0px, 0px, 0px)` for the editor margin and lines layers.
  3090. * The usage of `transform: translate3d(0px, 0px, 0px)` acts as a hint for browsers to create an extra layer.
  3091. * Defaults to false.
  3092. */
  3093. disableLayerHinting?: boolean;
  3094. /**
  3095. * Disable the optimizations for monospace fonts.
  3096. * Defaults to false.
  3097. */
  3098. disableMonospaceOptimizations?: boolean;
  3099. /**
  3100. * Should the cursor be hidden in the overview ruler.
  3101. * Defaults to false.
  3102. */
  3103. hideCursorInOverviewRuler?: boolean;
  3104. /**
  3105. * Enable that scrolling can go one screen size after the last line.
  3106. * Defaults to true.
  3107. */
  3108. scrollBeyondLastLine?: boolean;
  3109. /**
  3110. * Enable that scrolling can go beyond the last column by a number of columns.
  3111. * Defaults to 5.
  3112. */
  3113. scrollBeyondLastColumn?: number;
  3114. /**
  3115. * Enable that the editor animates scrolling to a position.
  3116. * Defaults to false.
  3117. */
  3118. smoothScrolling?: boolean;
  3119. /**
  3120. * Enable that the editor will install a ResizeObserver to check if its container dom node size has changed.
  3121. * Defaults to false.
  3122. */
  3123. automaticLayout?: boolean;
  3124. /**
  3125. * Control the wrapping of the editor.
  3126. * When `wordWrap` = "off", the lines will never wrap.
  3127. * When `wordWrap` = "on", the lines will wrap at the viewport width.
  3128. * When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`.
  3129. * When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn).
  3130. * Defaults to "off".
  3131. */
  3132. wordWrap?: 'off' | 'on' | 'wordWrapColumn' | 'bounded';
  3133. /**
  3134. * Override the `wordWrap` setting.
  3135. */
  3136. wordWrapOverride1?: 'off' | 'on' | 'inherit';
  3137. /**
  3138. * Override the `wordWrapOverride1` setting.
  3139. */
  3140. wordWrapOverride2?: 'off' | 'on' | 'inherit';
  3141. /**
  3142. * Control the wrapping of the editor.
  3143. * When `wordWrap` = "off", the lines will never wrap.
  3144. * When `wordWrap` = "on", the lines will wrap at the viewport width.
  3145. * When `wordWrap` = "wordWrapColumn", the lines will wrap at `wordWrapColumn`.
  3146. * When `wordWrap` = "bounded", the lines will wrap at min(viewport width, wordWrapColumn).
  3147. * Defaults to 80.
  3148. */
  3149. wordWrapColumn?: number;
  3150. /**
  3151. * Control indentation of wrapped lines. Can be: 'none', 'same', 'indent' or 'deepIndent'.
  3152. * Defaults to 'same' in vscode and to 'none' in monaco-editor.
  3153. */
  3154. wrappingIndent?: 'none' | 'same' | 'indent' | 'deepIndent';
  3155. /**
  3156. * Controls the wrapping strategy to use.
  3157. * Defaults to 'simple'.
  3158. */
  3159. wrappingStrategy?: 'simple' | 'advanced';
  3160. /**
  3161. * Configure word wrapping characters. A break will be introduced before these characters.
  3162. */
  3163. wordWrapBreakBeforeCharacters?: string;
  3164. /**
  3165. * Configure word wrapping characters. A break will be introduced after these characters.
  3166. */
  3167. wordWrapBreakAfterCharacters?: string;
  3168. /**
  3169. * Sets whether line breaks appear wherever the text would otherwise overflow its content box.
  3170. * When wordBreak = 'normal', Use the default line break rule.
  3171. * When wordBreak = 'keepAll', Word breaks should not be used for Chinese/Japanese/Korean (CJK) text. Non-CJK text behavior is the same as for normal.
  3172. */
  3173. wordBreak?: 'normal' | 'keepAll';
  3174. /**
  3175. * Performance guard: Stop rendering a line after x characters.
  3176. * Defaults to 10000.
  3177. * Use -1 to never stop rendering
  3178. */
  3179. stopRenderingLineAfter?: number;
  3180. /**
  3181. * Configure the editor's hover.
  3182. */
  3183. hover?: IEditorHoverOptions;
  3184. /**
  3185. * Enable detecting links and making them clickable.
  3186. * Defaults to true.
  3187. */
  3188. links?: boolean;
  3189. /**
  3190. * Enable inline color decorators and color picker rendering.
  3191. */
  3192. colorDecorators?: boolean;
  3193. /**
  3194. * Controls the max number of color decorators that can be rendered in an editor at once.
  3195. */
  3196. colorDecoratorsLimit?: number;
  3197. /**
  3198. * Control the behaviour of comments in the editor.
  3199. */
  3200. comments?: IEditorCommentsOptions;
  3201. /**
  3202. * Enable custom contextmenu.
  3203. * Defaults to true.
  3204. */
  3205. contextmenu?: boolean;
  3206. /**
  3207. * A multiplier to be used on the `deltaX` and `deltaY` of mouse wheel scroll events.
  3208. * Defaults to 1.
  3209. */
  3210. mouseWheelScrollSensitivity?: number;
  3211. /**
  3212. * FastScrolling mulitplier speed when pressing `Alt`
  3213. * Defaults to 5.
  3214. */
  3215. fastScrollSensitivity?: number;
  3216. /**
  3217. * Enable that the editor scrolls only the predominant axis. Prevents horizontal drift when scrolling vertically on a trackpad.
  3218. * Defaults to true.
  3219. */
  3220. scrollPredominantAxis?: boolean;
  3221. /**
  3222. * Enable that the selection with the mouse and keys is doing column selection.
  3223. * Defaults to false.
  3224. */
  3225. columnSelection?: boolean;
  3226. /**
  3227. * The modifier to be used to add multiple cursors with the mouse.
  3228. * Defaults to 'alt'
  3229. */
  3230. multiCursorModifier?: 'ctrlCmd' | 'alt';
  3231. /**
  3232. * Merge overlapping selections.
  3233. * Defaults to true
  3234. */
  3235. multiCursorMergeOverlapping?: boolean;
  3236. /**
  3237. * Configure the behaviour when pasting a text with the line count equal to the cursor count.
  3238. * Defaults to 'spread'.
  3239. */
  3240. multiCursorPaste?: 'spread' | 'full';
  3241. /**
  3242. * Controls the max number of text cursors that can be in an active editor at once.
  3243. */
  3244. multiCursorLimit?: number;
  3245. /**
  3246. * Configure the editor's accessibility support.
  3247. * Defaults to 'auto'. It is best to leave this to 'auto'.
  3248. */
  3249. accessibilitySupport?: 'auto' | 'off' | 'on';
  3250. /**
  3251. * Controls the number of lines in the editor that can be read out by a screen reader
  3252. */
  3253. accessibilityPageSize?: number;
  3254. /**
  3255. * Suggest options.
  3256. */
  3257. suggest?: ISuggestOptions;
  3258. inlineSuggest?: IInlineSuggestOptions;
  3259. /**
  3260. * Smart select options.
  3261. */
  3262. smartSelect?: ISmartSelectOptions;
  3263. /**
  3264. *
  3265. */
  3266. gotoLocation?: IGotoLocationOptions;
  3267. /**
  3268. * Enable quick suggestions (shadow suggestions)
  3269. * Defaults to true.
  3270. */
  3271. quickSuggestions?: boolean | IQuickSuggestionsOptions;
  3272. /**
  3273. * Quick suggestions show delay (in ms)
  3274. * Defaults to 10 (ms)
  3275. */
  3276. quickSuggestionsDelay?: number;
  3277. /**
  3278. * Controls the spacing around the editor.
  3279. */
  3280. padding?: IEditorPaddingOptions;
  3281. /**
  3282. * Parameter hint options.
  3283. */
  3284. parameterHints?: IEditorParameterHintOptions;
  3285. /**
  3286. * Options for auto closing brackets.
  3287. * Defaults to language defined behavior.
  3288. */
  3289. autoClosingBrackets?: EditorAutoClosingStrategy;
  3290. /**
  3291. * Options for auto closing quotes.
  3292. * Defaults to language defined behavior.
  3293. */
  3294. autoClosingQuotes?: EditorAutoClosingStrategy;
  3295. /**
  3296. * Options for pressing backspace near quotes or bracket pairs.
  3297. */
  3298. autoClosingDelete?: EditorAutoClosingEditStrategy;
  3299. /**
  3300. * Options for typing over closing quotes or brackets.
  3301. */
  3302. autoClosingOvertype?: EditorAutoClosingEditStrategy;
  3303. /**
  3304. * Options for auto surrounding.
  3305. * Defaults to always allowing auto surrounding.
  3306. */
  3307. autoSurround?: EditorAutoSurroundStrategy;
  3308. /**
  3309. * Controls whether the editor should automatically adjust the indentation when users type, paste, move or indent lines.
  3310. * Defaults to advanced.
  3311. */
  3312. autoIndent?: 'none' | 'keep' | 'brackets' | 'advanced' | 'full';
  3313. /**
  3314. * Emulate selection behaviour of tab characters when using spaces for indentation.
  3315. * This means selection will stick to tab stops.
  3316. */
  3317. stickyTabStops?: boolean;
  3318. /**
  3319. * Enable format on type.
  3320. * Defaults to false.
  3321. */
  3322. formatOnType?: boolean;
  3323. /**
  3324. * Enable format on paste.
  3325. * Defaults to false.
  3326. */
  3327. formatOnPaste?: boolean;
  3328. /**
  3329. * Controls if the editor should allow to move selections via drag and drop.
  3330. * Defaults to false.
  3331. */
  3332. dragAndDrop?: boolean;
  3333. /**
  3334. * Enable the suggestion box to pop-up on trigger characters.
  3335. * Defaults to true.
  3336. */
  3337. suggestOnTriggerCharacters?: boolean;
  3338. /**
  3339. * Accept suggestions on ENTER.
  3340. * Defaults to 'on'.
  3341. */
  3342. acceptSuggestionOnEnter?: 'on' | 'smart' | 'off';
  3343. /**
  3344. * Accept suggestions on provider defined characters.
  3345. * Defaults to true.
  3346. */
  3347. acceptSuggestionOnCommitCharacter?: boolean;
  3348. /**
  3349. * Enable snippet suggestions. Default to 'true'.
  3350. */
  3351. snippetSuggestions?: 'top' | 'bottom' | 'inline' | 'none';
  3352. /**
  3353. * Copying without a selection copies the current line.
  3354. */
  3355. emptySelectionClipboard?: boolean;
  3356. /**
  3357. * Syntax highlighting is copied.
  3358. */
  3359. copyWithSyntaxHighlighting?: boolean;
  3360. /**
  3361. * The history mode for suggestions.
  3362. */
  3363. suggestSelection?: 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix';
  3364. /**
  3365. * The font size for the suggest widget.
  3366. * Defaults to the editor font size.
  3367. */
  3368. suggestFontSize?: number;
  3369. /**
  3370. * The line height for the suggest widget.
  3371. * Defaults to the editor line height.
  3372. */
  3373. suggestLineHeight?: number;
  3374. /**
  3375. * Enable tab completion.
  3376. */
  3377. tabCompletion?: 'on' | 'off' | 'onlySnippets';
  3378. /**
  3379. * Enable selection highlight.
  3380. * Defaults to true.
  3381. */
  3382. selectionHighlight?: boolean;
  3383. /**
  3384. * Enable semantic occurrences highlight.
  3385. * Defaults to true.
  3386. */
  3387. occurrencesHighlight?: boolean;
  3388. /**
  3389. * Show code lens
  3390. * Defaults to true.
  3391. */
  3392. codeLens?: boolean;
  3393. /**
  3394. * Code lens font family. Defaults to editor font family.
  3395. */
  3396. codeLensFontFamily?: string;
  3397. /**
  3398. * Code lens font size. Default to 90% of the editor font size
  3399. */
  3400. codeLensFontSize?: number;
  3401. /**
  3402. * Control the behavior and rendering of the code action lightbulb.
  3403. */
  3404. lightbulb?: IEditorLightbulbOptions;
  3405. /**
  3406. * Timeout for running code actions on save.
  3407. */
  3408. codeActionsOnSaveTimeout?: number;
  3409. /**
  3410. * Enable code folding.
  3411. * Defaults to true.
  3412. */
  3413. folding?: boolean;
  3414. /**
  3415. * Selects the folding strategy. 'auto' uses the strategies contributed for the current document, 'indentation' uses the indentation based folding strategy.
  3416. * Defaults to 'auto'.
  3417. */
  3418. foldingStrategy?: 'auto' | 'indentation';
  3419. /**
  3420. * Enable highlight for folded regions.
  3421. * Defaults to true.
  3422. */
  3423. foldingHighlight?: boolean;
  3424. /**
  3425. * Auto fold imports folding regions.
  3426. * Defaults to true.
  3427. */
  3428. foldingImportsByDefault?: boolean;
  3429. /**
  3430. * Maximum number of foldable regions.
  3431. * Defaults to 5000.
  3432. */
  3433. foldingMaximumRegions?: number;
  3434. /**
  3435. * Controls whether the fold actions in the gutter stay always visible or hide unless the mouse is over the gutter.
  3436. * Defaults to 'mouseover'.
  3437. */
  3438. showFoldingControls?: 'always' | 'never' | 'mouseover';
  3439. /**
  3440. * Controls whether clicking on the empty content after a folded line will unfold the line.
  3441. * Defaults to false.
  3442. */
  3443. unfoldOnClickAfterEndOfLine?: boolean;
  3444. /**
  3445. * Enable highlighting of matching brackets.
  3446. * Defaults to 'always'.
  3447. */
  3448. matchBrackets?: 'never' | 'near' | 'always';
  3449. /**
  3450. * Enable experimental whitespace rendering.
  3451. * Defaults to 'svg'.
  3452. */
  3453. experimentalWhitespaceRendering?: 'svg' | 'font' | 'off';
  3454. /**
  3455. * Enable rendering of whitespace.
  3456. * Defaults to 'selection'.
  3457. */
  3458. renderWhitespace?: 'none' | 'boundary' | 'selection' | 'trailing' | 'all';
  3459. /**
  3460. * Enable rendering of control characters.
  3461. * Defaults to true.
  3462. */
  3463. renderControlCharacters?: boolean;
  3464. /**
  3465. * Enable rendering of current line highlight.
  3466. * Defaults to all.
  3467. */
  3468. renderLineHighlight?: 'none' | 'gutter' | 'line' | 'all';
  3469. /**
  3470. * Control if the current line highlight should be rendered only the editor is focused.
  3471. * Defaults to false.
  3472. */
  3473. renderLineHighlightOnlyWhenFocus?: boolean;
  3474. /**
  3475. * Inserting and deleting whitespace follows tab stops.
  3476. */
  3477. useTabStops?: boolean;
  3478. /**
  3479. * The font family
  3480. */
  3481. fontFamily?: string;
  3482. /**
  3483. * The font weight
  3484. */
  3485. fontWeight?: string;
  3486. /**
  3487. * The font size
  3488. */
  3489. fontSize?: number;
  3490. /**
  3491. * The line height
  3492. */
  3493. lineHeight?: number;
  3494. /**
  3495. * The letter spacing
  3496. */
  3497. letterSpacing?: number;
  3498. /**
  3499. * Controls fading out of unused variables.
  3500. */
  3501. showUnused?: boolean;
  3502. /**
  3503. * Controls whether to focus the inline editor in the peek widget by default.
  3504. * Defaults to false.
  3505. */
  3506. peekWidgetDefaultFocus?: 'tree' | 'editor';
  3507. /**
  3508. * Controls whether the definition link opens element in the peek widget.
  3509. * Defaults to false.
  3510. */
  3511. definitionLinkOpensInPeek?: boolean;
  3512. /**
  3513. * Controls strikethrough deprecated variables.
  3514. */
  3515. showDeprecated?: boolean;
  3516. /**
  3517. * Controls whether suggestions allow matches in the middle of the word instead of only at the beginning
  3518. */
  3519. matchOnWordStartOnly?: boolean;
  3520. /**
  3521. * Control the behavior and rendering of the inline hints.
  3522. */
  3523. inlayHints?: IEditorInlayHintsOptions;
  3524. /**
  3525. * Control if the editor should use shadow DOM.
  3526. */
  3527. useShadowDOM?: boolean;
  3528. /**
  3529. * Controls the behavior of editor guides.
  3530. */
  3531. guides?: IGuidesOptions;
  3532. /**
  3533. * Controls the behavior of the unicode highlight feature
  3534. * (by default, ambiguous and invisible characters are highlighted).
  3535. */
  3536. unicodeHighlight?: IUnicodeHighlightOptions;
  3537. /**
  3538. * Configures bracket pair colorization (disabled by default).
  3539. */
  3540. bracketPairColorization?: IBracketPairColorizationOptions;
  3541. /**
  3542. * Controls dropping into the editor from an external source.
  3543. *
  3544. * When enabled, this shows a preview of the drop location and triggers an `onDropIntoEditor` event.
  3545. */
  3546. dropIntoEditor?: IDropIntoEditorOptions;
  3547. /**
  3548. * Controls whether the editor receives tabs or defers them to the workbench for navigation.
  3549. */
  3550. tabFocusMode?: boolean;
  3551. }
  3552. export interface IDiffEditorBaseOptions {
  3553. /**
  3554. * Allow the user to resize the diff editor split view.
  3555. * Defaults to true.
  3556. */
  3557. enableSplitViewResizing?: boolean;
  3558. /**
  3559. * Render the differences in two side-by-side editors.
  3560. * Defaults to true.
  3561. */
  3562. renderSideBySide?: boolean;
  3563. /**
  3564. * Timeout in milliseconds after which diff computation is cancelled.
  3565. * Defaults to 5000.
  3566. */
  3567. maxComputationTime?: number;
  3568. /**
  3569. * Maximum supported file size in MB.
  3570. * Defaults to 50.
  3571. */
  3572. maxFileSize?: number;
  3573. /**
  3574. * Compute the diff by ignoring leading/trailing whitespace
  3575. * Defaults to true.
  3576. */
  3577. ignoreTrimWhitespace?: boolean;
  3578. /**
  3579. * Render +/- indicators for added/deleted changes.
  3580. * Defaults to true.
  3581. */
  3582. renderIndicators?: boolean;
  3583. /**
  3584. * Shows icons in the glyph margin to revert changes.
  3585. * Default to true.
  3586. */
  3587. renderMarginRevertIcon?: boolean;
  3588. /**
  3589. * Original model should be editable?
  3590. * Defaults to false.
  3591. */
  3592. originalEditable?: boolean;
  3593. /**
  3594. * Should the diff editor enable code lens?
  3595. * Defaults to false.
  3596. */
  3597. diffCodeLens?: boolean;
  3598. /**
  3599. * Is the diff editor should render overview ruler
  3600. * Defaults to true
  3601. */
  3602. renderOverviewRuler?: boolean;
  3603. /**
  3604. * Control the wrapping of the diff editor.
  3605. */
  3606. diffWordWrap?: 'off' | 'on' | 'inherit';
  3607. /**
  3608. * Diff Algorithm
  3609. */
  3610. diffAlgorithm?: 'smart' | 'experimental' | IDocumentDiffProvider;
  3611. }
  3612. /**
  3613. * Configuration options for the diff editor.
  3614. */
  3615. export interface IDiffEditorOptions extends IEditorOptions, IDiffEditorBaseOptions {
  3616. }
  3617. /**
  3618. * An event describing that the configuration of the editor has changed.
  3619. */
  3620. export class ConfigurationChangedEvent {
  3621. hasChanged(id: EditorOption): boolean;
  3622. }
  3623. /**
  3624. * All computed editor options.
  3625. */
  3626. export interface IComputedEditorOptions {
  3627. get<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
  3628. }
  3629. export interface IEditorOption<K extends EditorOption, V> {
  3630. readonly id: K;
  3631. readonly name: string;
  3632. defaultValue: V;
  3633. /**
  3634. * Might modify `value`.
  3635. */
  3636. applyUpdate(value: V | undefined, update: V): ApplyUpdateResult<V>;
  3637. }
  3638. export class ApplyUpdateResult<T> {
  3639. readonly newValue: T;
  3640. readonly didChange: boolean;
  3641. constructor(newValue: T, didChange: boolean);
  3642. }
  3643. /**
  3644. * Configuration options for editor comments
  3645. */
  3646. export interface IEditorCommentsOptions {
  3647. /**
  3648. * Insert a space after the line comment token and inside the block comments tokens.
  3649. * Defaults to true.
  3650. */
  3651. insertSpace?: boolean;
  3652. /**
  3653. * Ignore empty lines when inserting line comments.
  3654. * Defaults to true.
  3655. */
  3656. ignoreEmptyLines?: boolean;
  3657. }
  3658. /**
  3659. * The kind of animation in which the editor's cursor should be rendered.
  3660. */
  3661. export enum TextEditorCursorBlinkingStyle {
  3662. /**
  3663. * Hidden
  3664. */
  3665. Hidden = 0,
  3666. /**
  3667. * Blinking
  3668. */
  3669. Blink = 1,
  3670. /**
  3671. * Blinking with smooth fading
  3672. */
  3673. Smooth = 2,
  3674. /**
  3675. * Blinking with prolonged filled state and smooth fading
  3676. */
  3677. Phase = 3,
  3678. /**
  3679. * Expand collapse animation on the y axis
  3680. */
  3681. Expand = 4,
  3682. /**
  3683. * No-Blinking
  3684. */
  3685. Solid = 5
  3686. }
  3687. /**
  3688. * The style in which the editor's cursor should be rendered.
  3689. */
  3690. export enum TextEditorCursorStyle {
  3691. /**
  3692. * As a vertical line (sitting between two characters).
  3693. */
  3694. Line = 1,
  3695. /**
  3696. * As a block (sitting on top of a character).
  3697. */
  3698. Block = 2,
  3699. /**
  3700. * As a horizontal line (sitting under a character).
  3701. */
  3702. Underline = 3,
  3703. /**
  3704. * As a thin vertical line (sitting between two characters).
  3705. */
  3706. LineThin = 4,
  3707. /**
  3708. * As an outlined block (sitting on top of a character).
  3709. */
  3710. BlockOutline = 5,
  3711. /**
  3712. * As a thin horizontal line (sitting under a character).
  3713. */
  3714. UnderlineThin = 6
  3715. }
  3716. /**
  3717. * Configuration options for editor find widget
  3718. */
  3719. export interface IEditorFindOptions {
  3720. /**
  3721. * Controls whether the cursor should move to find matches while typing.
  3722. */
  3723. cursorMoveOnType?: boolean;
  3724. /**
  3725. * Controls if we seed search string in the Find Widget with editor selection.
  3726. */
  3727. seedSearchStringFromSelection?: 'never' | 'always' | 'selection';
  3728. /**
  3729. * Controls if Find in Selection flag is turned on in the editor.
  3730. */
  3731. autoFindInSelection?: 'never' | 'always' | 'multiline';
  3732. addExtraSpaceOnTop?: boolean;
  3733. /**
  3734. * Controls whether the search result and diff result automatically restarts from the beginning (or the end) when no further matches can be found
  3735. */
  3736. loop?: boolean;
  3737. }
  3738. export type GoToLocationValues = 'peek' | 'gotoAndPeek' | 'goto';
  3739. /**
  3740. * Configuration options for go to location
  3741. */
  3742. export interface IGotoLocationOptions {
  3743. multiple?: GoToLocationValues;
  3744. multipleDefinitions?: GoToLocationValues;
  3745. multipleTypeDefinitions?: GoToLocationValues;
  3746. multipleDeclarations?: GoToLocationValues;
  3747. multipleImplementations?: GoToLocationValues;
  3748. multipleReferences?: GoToLocationValues;
  3749. alternativeDefinitionCommand?: string;
  3750. alternativeTypeDefinitionCommand?: string;
  3751. alternativeDeclarationCommand?: string;
  3752. alternativeImplementationCommand?: string;
  3753. alternativeReferenceCommand?: string;
  3754. }
  3755. /**
  3756. * Configuration options for editor hover
  3757. */
  3758. export interface IEditorHoverOptions {
  3759. /**
  3760. * Enable the hover.
  3761. * Defaults to true.
  3762. */
  3763. enabled?: boolean;
  3764. /**
  3765. * Delay for showing the hover.
  3766. * Defaults to 300.
  3767. */
  3768. delay?: number;
  3769. /**
  3770. * Is the hover sticky such that it can be clicked and its contents selected?
  3771. * Defaults to true.
  3772. */
  3773. sticky?: boolean;
  3774. /**
  3775. * Should the hover be shown above the line if possible?
  3776. * Defaults to false.
  3777. */
  3778. above?: boolean;
  3779. }
  3780. /**
  3781. * A description for the overview ruler position.
  3782. */
  3783. export interface OverviewRulerPosition {
  3784. /**
  3785. * Width of the overview ruler
  3786. */
  3787. readonly width: number;
  3788. /**
  3789. * Height of the overview ruler
  3790. */
  3791. readonly height: number;
  3792. /**
  3793. * Top position for the overview ruler
  3794. */
  3795. readonly top: number;
  3796. /**
  3797. * Right position for the overview ruler
  3798. */
  3799. readonly right: number;
  3800. }
  3801. export enum RenderMinimap {
  3802. None = 0,
  3803. Text = 1,
  3804. Blocks = 2
  3805. }
  3806. /**
  3807. * The internal layout details of the editor.
  3808. */
  3809. export interface EditorLayoutInfo {
  3810. /**
  3811. * Full editor width.
  3812. */
  3813. readonly width: number;
  3814. /**
  3815. * Full editor height.
  3816. */
  3817. readonly height: number;
  3818. /**
  3819. * Left position for the glyph margin.
  3820. */
  3821. readonly glyphMarginLeft: number;
  3822. /**
  3823. * The width of the glyph margin.
  3824. */
  3825. readonly glyphMarginWidth: number;
  3826. /**
  3827. * Left position for the line numbers.
  3828. */
  3829. readonly lineNumbersLeft: number;
  3830. /**
  3831. * The width of the line numbers.
  3832. */
  3833. readonly lineNumbersWidth: number;
  3834. /**
  3835. * Left position for the line decorations.
  3836. */
  3837. readonly decorationsLeft: number;
  3838. /**
  3839. * The width of the line decorations.
  3840. */
  3841. readonly decorationsWidth: number;
  3842. /**
  3843. * Left position for the content (actual text)
  3844. */
  3845. readonly contentLeft: number;
  3846. /**
  3847. * The width of the content (actual text)
  3848. */
  3849. readonly contentWidth: number;
  3850. /**
  3851. * Layout information for the minimap
  3852. */
  3853. readonly minimap: EditorMinimapLayoutInfo;
  3854. /**
  3855. * The number of columns (of typical characters) fitting on a viewport line.
  3856. */
  3857. readonly viewportColumn: number;
  3858. readonly isWordWrapMinified: boolean;
  3859. readonly isViewportWrapping: boolean;
  3860. readonly wrappingColumn: number;
  3861. /**
  3862. * The width of the vertical scrollbar.
  3863. */
  3864. readonly verticalScrollbarWidth: number;
  3865. /**
  3866. * The height of the horizontal scrollbar.
  3867. */
  3868. readonly horizontalScrollbarHeight: number;
  3869. /**
  3870. * The position of the overview ruler.
  3871. */
  3872. readonly overviewRuler: OverviewRulerPosition;
  3873. }
  3874. /**
  3875. * The internal layout details of the editor.
  3876. */
  3877. export interface EditorMinimapLayoutInfo {
  3878. readonly renderMinimap: RenderMinimap;
  3879. readonly minimapLeft: number;
  3880. readonly minimapWidth: number;
  3881. readonly minimapHeightIsEditorHeight: boolean;
  3882. readonly minimapIsSampling: boolean;
  3883. readonly minimapScale: number;
  3884. readonly minimapLineHeight: number;
  3885. readonly minimapCanvasInnerWidth: number;
  3886. readonly minimapCanvasInnerHeight: number;
  3887. readonly minimapCanvasOuterWidth: number;
  3888. readonly minimapCanvasOuterHeight: number;
  3889. }
  3890. /**
  3891. * Configuration options for editor lightbulb
  3892. */
  3893. export interface IEditorLightbulbOptions {
  3894. /**
  3895. * Enable the lightbulb code action.
  3896. * Defaults to true.
  3897. */
  3898. enabled?: boolean;
  3899. }
  3900. export interface IEditorStickyScrollOptions {
  3901. /**
  3902. * Enable the sticky scroll
  3903. */
  3904. enabled?: boolean;
  3905. /**
  3906. * Maximum number of sticky lines to show
  3907. */
  3908. maxLineCount?: number;
  3909. /**
  3910. * Model to choose for sticky scroll by default
  3911. */
  3912. defaultModel?: 'outlineModel' | 'foldingProviderModel' | 'indentationModel';
  3913. }
  3914. /**
  3915. * Configuration options for editor inlayHints
  3916. */
  3917. export interface IEditorInlayHintsOptions {
  3918. /**
  3919. * Enable the inline hints.
  3920. * Defaults to true.
  3921. */
  3922. enabled?: 'on' | 'off' | 'offUnlessPressed' | 'onUnlessPressed';
  3923. /**
  3924. * Font size of inline hints.
  3925. * Default to 90% of the editor font size.
  3926. */
  3927. fontSize?: number;
  3928. /**
  3929. * Font family of inline hints.
  3930. * Defaults to editor font family.
  3931. */
  3932. fontFamily?: string;
  3933. /**
  3934. * Enables the padding around the inlay hint.
  3935. * Defaults to false.
  3936. */
  3937. padding?: boolean;
  3938. }
  3939. /**
  3940. * Configuration options for editor minimap
  3941. */
  3942. export interface IEditorMinimapOptions {
  3943. /**
  3944. * Enable the rendering of the minimap.
  3945. * Defaults to true.
  3946. */
  3947. enabled?: boolean;
  3948. /**
  3949. * Control the rendering of minimap.
  3950. */
  3951. autohide?: boolean;
  3952. /**
  3953. * Control the side of the minimap in editor.
  3954. * Defaults to 'right'.
  3955. */
  3956. side?: 'right' | 'left';
  3957. /**
  3958. * Control the minimap rendering mode.
  3959. * Defaults to 'actual'.
  3960. */
  3961. size?: 'proportional' | 'fill' | 'fit';
  3962. /**
  3963. * Control the rendering of the minimap slider.
  3964. * Defaults to 'mouseover'.
  3965. */
  3966. showSlider?: 'always' | 'mouseover';
  3967. /**
  3968. * Render the actual text on a line (as opposed to color blocks).
  3969. * Defaults to true.
  3970. */
  3971. renderCharacters?: boolean;
  3972. /**
  3973. * Limit the width of the minimap to render at most a certain number of columns.
  3974. * Defaults to 120.
  3975. */
  3976. maxColumn?: number;
  3977. /**
  3978. * Relative size of the font in the minimap. Defaults to 1.
  3979. */
  3980. scale?: number;
  3981. }
  3982. /**
  3983. * Configuration options for editor padding
  3984. */
  3985. export interface IEditorPaddingOptions {
  3986. /**
  3987. * Spacing between top edge of editor and first line.
  3988. */
  3989. top?: number;
  3990. /**
  3991. * Spacing between bottom edge of editor and last line.
  3992. */
  3993. bottom?: number;
  3994. }
  3995. /**
  3996. * Configuration options for parameter hints
  3997. */
  3998. export interface IEditorParameterHintOptions {
  3999. /**
  4000. * Enable parameter hints.
  4001. * Defaults to true.
  4002. */
  4003. enabled?: boolean;
  4004. /**
  4005. * Enable cycling of parameter hints.
  4006. * Defaults to false.
  4007. */
  4008. cycle?: boolean;
  4009. }
  4010. export type QuickSuggestionsValue = 'on' | 'inline' | 'off';
  4011. /**
  4012. * Configuration options for quick suggestions
  4013. */
  4014. export interface IQuickSuggestionsOptions {
  4015. other?: boolean | QuickSuggestionsValue;
  4016. comments?: boolean | QuickSuggestionsValue;
  4017. strings?: boolean | QuickSuggestionsValue;
  4018. }
  4019. export interface InternalQuickSuggestionsOptions {
  4020. readonly other: QuickSuggestionsValue;
  4021. readonly comments: QuickSuggestionsValue;
  4022. readonly strings: QuickSuggestionsValue;
  4023. }
  4024. export type LineNumbersType = 'on' | 'off' | 'relative' | 'interval' | ((lineNumber: number) => string);
  4025. export enum RenderLineNumbersType {
  4026. Off = 0,
  4027. On = 1,
  4028. Relative = 2,
  4029. Interval = 3,
  4030. Custom = 4
  4031. }
  4032. export interface InternalEditorRenderLineNumbersOptions {
  4033. readonly renderType: RenderLineNumbersType;
  4034. readonly renderFn: ((lineNumber: number) => string) | null;
  4035. }
  4036. export interface IRulerOption {
  4037. readonly column: number;
  4038. readonly color: string | null;
  4039. }
  4040. /**
  4041. * Configuration options for editor scrollbars
  4042. */
  4043. export interface IEditorScrollbarOptions {
  4044. /**
  4045. * The size of arrows (if displayed).
  4046. * Defaults to 11.
  4047. * **NOTE**: This option cannot be updated using `updateOptions()`
  4048. */
  4049. arrowSize?: number;
  4050. /**
  4051. * Render vertical scrollbar.
  4052. * Defaults to 'auto'.
  4053. */
  4054. vertical?: 'auto' | 'visible' | 'hidden';
  4055. /**
  4056. * Render horizontal scrollbar.
  4057. * Defaults to 'auto'.
  4058. */
  4059. horizontal?: 'auto' | 'visible' | 'hidden';
  4060. /**
  4061. * Cast horizontal and vertical shadows when the content is scrolled.
  4062. * Defaults to true.
  4063. * **NOTE**: This option cannot be updated using `updateOptions()`
  4064. */
  4065. useShadows?: boolean;
  4066. /**
  4067. * Render arrows at the top and bottom of the vertical scrollbar.
  4068. * Defaults to false.
  4069. * **NOTE**: This option cannot be updated using `updateOptions()`
  4070. */
  4071. verticalHasArrows?: boolean;
  4072. /**
  4073. * Render arrows at the left and right of the horizontal scrollbar.
  4074. * Defaults to false.
  4075. * **NOTE**: This option cannot be updated using `updateOptions()`
  4076. */
  4077. horizontalHasArrows?: boolean;
  4078. /**
  4079. * Listen to mouse wheel events and react to them by scrolling.
  4080. * Defaults to true.
  4081. */
  4082. handleMouseWheel?: boolean;
  4083. /**
  4084. * Always consume mouse wheel events (always call preventDefault() and stopPropagation() on the browser events).
  4085. * Defaults to true.
  4086. * **NOTE**: This option cannot be updated using `updateOptions()`
  4087. */
  4088. alwaysConsumeMouseWheel?: boolean;
  4089. /**
  4090. * Height in pixels for the horizontal scrollbar.
  4091. * Defaults to 10 (px).
  4092. */
  4093. horizontalScrollbarSize?: number;
  4094. /**
  4095. * Width in pixels for the vertical scrollbar.
  4096. * Defaults to 10 (px).
  4097. */
  4098. verticalScrollbarSize?: number;
  4099. /**
  4100. * Width in pixels for the vertical slider.
  4101. * Defaults to `verticalScrollbarSize`.
  4102. * **NOTE**: This option cannot be updated using `updateOptions()`
  4103. */
  4104. verticalSliderSize?: number;
  4105. /**
  4106. * Height in pixels for the horizontal slider.
  4107. * Defaults to `horizontalScrollbarSize`.
  4108. * **NOTE**: This option cannot be updated using `updateOptions()`
  4109. */
  4110. horizontalSliderSize?: number;
  4111. /**
  4112. * Scroll gutter clicks move by page vs jump to position.
  4113. * Defaults to false.
  4114. */
  4115. scrollByPage?: boolean;
  4116. }
  4117. export interface InternalEditorScrollbarOptions {
  4118. readonly arrowSize: number;
  4119. readonly vertical: ScrollbarVisibility;
  4120. readonly horizontal: ScrollbarVisibility;
  4121. readonly useShadows: boolean;
  4122. readonly verticalHasArrows: boolean;
  4123. readonly horizontalHasArrows: boolean;
  4124. readonly handleMouseWheel: boolean;
  4125. readonly alwaysConsumeMouseWheel: boolean;
  4126. readonly horizontalScrollbarSize: number;
  4127. readonly horizontalSliderSize: number;
  4128. readonly verticalScrollbarSize: number;
  4129. readonly verticalSliderSize: number;
  4130. readonly scrollByPage: boolean;
  4131. }
  4132. export type InUntrustedWorkspace = 'inUntrustedWorkspace';
  4133. /**
  4134. * Configuration options for unicode highlighting.
  4135. */
  4136. export interface IUnicodeHighlightOptions {
  4137. /**
  4138. * Controls whether all non-basic ASCII characters are highlighted. Only characters between U+0020 and U+007E, tab, line-feed and carriage-return are considered basic ASCII.
  4139. */
  4140. nonBasicASCII?: boolean | InUntrustedWorkspace;
  4141. /**
  4142. * Controls whether characters that just reserve space or have no width at all are highlighted.
  4143. */
  4144. invisibleCharacters?: boolean;
  4145. /**
  4146. * Controls whether characters are highlighted that can be confused with basic ASCII characters, except those that are common in the current user locale.
  4147. */
  4148. ambiguousCharacters?: boolean;
  4149. /**
  4150. * Controls whether characters in comments should also be subject to unicode highlighting.
  4151. */
  4152. includeComments?: boolean | InUntrustedWorkspace;
  4153. /**
  4154. * Controls whether characters in strings should also be subject to unicode highlighting.
  4155. */
  4156. includeStrings?: boolean | InUntrustedWorkspace;
  4157. /**
  4158. * Defines allowed characters that are not being highlighted.
  4159. */
  4160. allowedCharacters?: Record<string, true>;
  4161. /**
  4162. * Unicode characters that are common in allowed locales are not being highlighted.
  4163. */
  4164. allowedLocales?: Record<string | '_os' | '_vscode', true>;
  4165. }
  4166. export interface IInlineSuggestOptions {
  4167. /**
  4168. * Enable or disable the rendering of automatic inline completions.
  4169. */
  4170. enabled?: boolean;
  4171. /**
  4172. * Configures the mode.
  4173. * Use `prefix` to only show ghost text if the text to replace is a prefix of the suggestion text.
  4174. * Use `subword` to only show ghost text if the replace text is a subword of the suggestion text.
  4175. * Use `subwordSmart` to only show ghost text if the replace text is a subword of the suggestion text, but the subword must start after the cursor position.
  4176. * Defaults to `prefix`.
  4177. */
  4178. mode?: 'prefix' | 'subword' | 'subwordSmart';
  4179. showToolbar?: 'always' | 'onHover';
  4180. suppressSuggestions?: boolean;
  4181. }
  4182. export interface IBracketPairColorizationOptions {
  4183. /**
  4184. * Enable or disable bracket pair colorization.
  4185. */
  4186. enabled?: boolean;
  4187. /**
  4188. * Use independent color pool per bracket type.
  4189. */
  4190. independentColorPoolPerBracketType?: boolean;
  4191. }
  4192. export interface IGuidesOptions {
  4193. /**
  4194. * Enable rendering of bracket pair guides.
  4195. * Defaults to false.
  4196. */
  4197. bracketPairs?: boolean | 'active';
  4198. /**
  4199. * Enable rendering of vertical bracket pair guides.
  4200. * Defaults to 'active'.
  4201. */
  4202. bracketPairsHorizontal?: boolean | 'active';
  4203. /**
  4204. * Enable highlighting of the active bracket pair.
  4205. * Defaults to true.
  4206. */
  4207. highlightActiveBracketPair?: boolean;
  4208. /**
  4209. * Enable rendering of indent guides.
  4210. * Defaults to true.
  4211. */
  4212. indentation?: boolean;
  4213. /**
  4214. * Enable highlighting of the active indent guide.
  4215. * Defaults to true.
  4216. */
  4217. highlightActiveIndentation?: boolean | 'always';
  4218. }
  4219. /**
  4220. * Configuration options for editor suggest widget
  4221. */
  4222. export interface ISuggestOptions {
  4223. /**
  4224. * Overwrite word ends on accept. Default to false.
  4225. */
  4226. insertMode?: 'insert' | 'replace';
  4227. /**
  4228. * Enable graceful matching. Defaults to true.
  4229. */
  4230. filterGraceful?: boolean;
  4231. /**
  4232. * Prevent quick suggestions when a snippet is active. Defaults to true.
  4233. */
  4234. snippetsPreventQuickSuggestions?: boolean;
  4235. /**
  4236. * Favors words that appear close to the cursor.
  4237. */
  4238. localityBonus?: boolean;
  4239. /**
  4240. * Enable using global storage for remembering suggestions.
  4241. */
  4242. shareSuggestSelections?: boolean;
  4243. /**
  4244. * Select suggestions when triggered via quick suggest or trigger characters
  4245. */
  4246. selectionMode?: 'always' | 'never' | 'whenTriggerCharacter' | 'whenQuickSuggestion';
  4247. /**
  4248. * Enable or disable icons in suggestions. Defaults to true.
  4249. */
  4250. showIcons?: boolean;
  4251. /**
  4252. * Enable or disable the suggest status bar.
  4253. */
  4254. showStatusBar?: boolean;
  4255. /**
  4256. * Enable or disable the rendering of the suggestion preview.
  4257. */
  4258. preview?: boolean;
  4259. /**
  4260. * Configures the mode of the preview.
  4261. */
  4262. previewMode?: 'prefix' | 'subword' | 'subwordSmart';
  4263. /**
  4264. * Show details inline with the label. Defaults to true.
  4265. */
  4266. showInlineDetails?: boolean;
  4267. /**
  4268. * Show method-suggestions.
  4269. */
  4270. showMethods?: boolean;
  4271. /**
  4272. * Show function-suggestions.
  4273. */
  4274. showFunctions?: boolean;
  4275. /**
  4276. * Show constructor-suggestions.
  4277. */
  4278. showConstructors?: boolean;
  4279. /**
  4280. * Show deprecated-suggestions.
  4281. */
  4282. showDeprecated?: boolean;
  4283. /**
  4284. * Controls whether suggestions allow matches in the middle of the word instead of only at the beginning
  4285. */
  4286. matchOnWordStartOnly?: boolean;
  4287. /**
  4288. * Show field-suggestions.
  4289. */
  4290. showFields?: boolean;
  4291. /**
  4292. * Show variable-suggestions.
  4293. */
  4294. showVariables?: boolean;
  4295. /**
  4296. * Show class-suggestions.
  4297. */
  4298. showClasses?: boolean;
  4299. /**
  4300. * Show struct-suggestions.
  4301. */
  4302. showStructs?: boolean;
  4303. /**
  4304. * Show interface-suggestions.
  4305. */
  4306. showInterfaces?: boolean;
  4307. /**
  4308. * Show module-suggestions.
  4309. */
  4310. showModules?: boolean;
  4311. /**
  4312. * Show property-suggestions.
  4313. */
  4314. showProperties?: boolean;
  4315. /**
  4316. * Show event-suggestions.
  4317. */
  4318. showEvents?: boolean;
  4319. /**
  4320. * Show operator-suggestions.
  4321. */
  4322. showOperators?: boolean;
  4323. /**
  4324. * Show unit-suggestions.
  4325. */
  4326. showUnits?: boolean;
  4327. /**
  4328. * Show value-suggestions.
  4329. */
  4330. showValues?: boolean;
  4331. /**
  4332. * Show constant-suggestions.
  4333. */
  4334. showConstants?: boolean;
  4335. /**
  4336. * Show enum-suggestions.
  4337. */
  4338. showEnums?: boolean;
  4339. /**
  4340. * Show enumMember-suggestions.
  4341. */
  4342. showEnumMembers?: boolean;
  4343. /**
  4344. * Show keyword-suggestions.
  4345. */
  4346. showKeywords?: boolean;
  4347. /**
  4348. * Show text-suggestions.
  4349. */
  4350. showWords?: boolean;
  4351. /**
  4352. * Show color-suggestions.
  4353. */
  4354. showColors?: boolean;
  4355. /**
  4356. * Show file-suggestions.
  4357. */
  4358. showFiles?: boolean;
  4359. /**
  4360. * Show reference-suggestions.
  4361. */
  4362. showReferences?: boolean;
  4363. /**
  4364. * Show folder-suggestions.
  4365. */
  4366. showFolders?: boolean;
  4367. /**
  4368. * Show typeParameter-suggestions.
  4369. */
  4370. showTypeParameters?: boolean;
  4371. /**
  4372. * Show issue-suggestions.
  4373. */
  4374. showIssues?: boolean;
  4375. /**
  4376. * Show user-suggestions.
  4377. */
  4378. showUsers?: boolean;
  4379. /**
  4380. * Show snippet-suggestions.
  4381. */
  4382. showSnippets?: boolean;
  4383. }
  4384. export interface ISmartSelectOptions {
  4385. selectLeadingAndTrailingWhitespace?: boolean;
  4386. }
  4387. /**
  4388. * Describes how to indent wrapped lines.
  4389. */
  4390. export enum WrappingIndent {
  4391. /**
  4392. * No indentation => wrapped lines begin at column 1.
  4393. */
  4394. None = 0,
  4395. /**
  4396. * Same => wrapped lines get the same indentation as the parent.
  4397. */
  4398. Same = 1,
  4399. /**
  4400. * Indent => wrapped lines get +1 indentation toward the parent.
  4401. */
  4402. Indent = 2,
  4403. /**
  4404. * DeepIndent => wrapped lines get +2 indentation toward the parent.
  4405. */
  4406. DeepIndent = 3
  4407. }
  4408. export interface EditorWrappingInfo {
  4409. readonly isDominatedByLongLines: boolean;
  4410. readonly isWordWrapMinified: boolean;
  4411. readonly isViewportWrapping: boolean;
  4412. readonly wrappingColumn: number;
  4413. }
  4414. /**
  4415. * Configuration options for editor drop into behavior
  4416. */
  4417. export interface IDropIntoEditorOptions {
  4418. /**
  4419. * Enable the dropping into editor.
  4420. * Defaults to true.
  4421. */
  4422. enabled?: boolean;
  4423. }
  4424. export enum EditorOption {
  4425. acceptSuggestionOnCommitCharacter = 0,
  4426. acceptSuggestionOnEnter = 1,
  4427. accessibilitySupport = 2,
  4428. accessibilityPageSize = 3,
  4429. ariaLabel = 4,
  4430. autoClosingBrackets = 5,
  4431. screenReaderAnnounceInlineSuggestion = 6,
  4432. autoClosingDelete = 7,
  4433. autoClosingOvertype = 8,
  4434. autoClosingQuotes = 9,
  4435. autoIndent = 10,
  4436. automaticLayout = 11,
  4437. autoSurround = 12,
  4438. bracketPairColorization = 13,
  4439. guides = 14,
  4440. codeLens = 15,
  4441. codeLensFontFamily = 16,
  4442. codeLensFontSize = 17,
  4443. colorDecorators = 18,
  4444. colorDecoratorsLimit = 19,
  4445. columnSelection = 20,
  4446. comments = 21,
  4447. contextmenu = 22,
  4448. copyWithSyntaxHighlighting = 23,
  4449. cursorBlinking = 24,
  4450. cursorSmoothCaretAnimation = 25,
  4451. cursorStyle = 26,
  4452. cursorSurroundingLines = 27,
  4453. cursorSurroundingLinesStyle = 28,
  4454. cursorWidth = 29,
  4455. disableLayerHinting = 30,
  4456. disableMonospaceOptimizations = 31,
  4457. domReadOnly = 32,
  4458. dragAndDrop = 33,
  4459. dropIntoEditor = 34,
  4460. emptySelectionClipboard = 35,
  4461. experimentalWhitespaceRendering = 36,
  4462. extraEditorClassName = 37,
  4463. fastScrollSensitivity = 38,
  4464. find = 39,
  4465. fixedOverflowWidgets = 40,
  4466. folding = 41,
  4467. foldingStrategy = 42,
  4468. foldingHighlight = 43,
  4469. foldingImportsByDefault = 44,
  4470. foldingMaximumRegions = 45,
  4471. unfoldOnClickAfterEndOfLine = 46,
  4472. fontFamily = 47,
  4473. fontInfo = 48,
  4474. fontLigatures = 49,
  4475. fontSize = 50,
  4476. fontWeight = 51,
  4477. fontVariations = 52,
  4478. formatOnPaste = 53,
  4479. formatOnType = 54,
  4480. glyphMargin = 55,
  4481. gotoLocation = 56,
  4482. hideCursorInOverviewRuler = 57,
  4483. hover = 58,
  4484. inDiffEditor = 59,
  4485. inlineSuggest = 60,
  4486. letterSpacing = 61,
  4487. lightbulb = 62,
  4488. lineDecorationsWidth = 63,
  4489. lineHeight = 64,
  4490. lineNumbers = 65,
  4491. lineNumbersMinChars = 66,
  4492. linkedEditing = 67,
  4493. links = 68,
  4494. matchBrackets = 69,
  4495. minimap = 70,
  4496. mouseStyle = 71,
  4497. mouseWheelScrollSensitivity = 72,
  4498. mouseWheelZoom = 73,
  4499. multiCursorMergeOverlapping = 74,
  4500. multiCursorModifier = 75,
  4501. multiCursorPaste = 76,
  4502. multiCursorLimit = 77,
  4503. occurrencesHighlight = 78,
  4504. overviewRulerBorder = 79,
  4505. overviewRulerLanes = 80,
  4506. padding = 81,
  4507. parameterHints = 82,
  4508. peekWidgetDefaultFocus = 83,
  4509. definitionLinkOpensInPeek = 84,
  4510. quickSuggestions = 85,
  4511. quickSuggestionsDelay = 86,
  4512. readOnly = 87,
  4513. renameOnType = 88,
  4514. renderControlCharacters = 89,
  4515. renderFinalNewline = 90,
  4516. renderLineHighlight = 91,
  4517. renderLineHighlightOnlyWhenFocus = 92,
  4518. renderValidationDecorations = 93,
  4519. renderWhitespace = 94,
  4520. revealHorizontalRightPadding = 95,
  4521. roundedSelection = 96,
  4522. rulers = 97,
  4523. scrollbar = 98,
  4524. scrollBeyondLastColumn = 99,
  4525. scrollBeyondLastLine = 100,
  4526. scrollPredominantAxis = 101,
  4527. selectionClipboard = 102,
  4528. selectionHighlight = 103,
  4529. selectOnLineNumbers = 104,
  4530. showFoldingControls = 105,
  4531. showUnused = 106,
  4532. snippetSuggestions = 107,
  4533. smartSelect = 108,
  4534. smoothScrolling = 109,
  4535. stickyScroll = 110,
  4536. stickyTabStops = 111,
  4537. stopRenderingLineAfter = 112,
  4538. suggest = 113,
  4539. suggestFontSize = 114,
  4540. suggestLineHeight = 115,
  4541. suggestOnTriggerCharacters = 116,
  4542. suggestSelection = 117,
  4543. tabCompletion = 118,
  4544. tabIndex = 119,
  4545. unicodeHighlighting = 120,
  4546. unusualLineTerminators = 121,
  4547. useShadowDOM = 122,
  4548. useTabStops = 123,
  4549. wordBreak = 124,
  4550. wordSeparators = 125,
  4551. wordWrap = 126,
  4552. wordWrapBreakAfterCharacters = 127,
  4553. wordWrapBreakBeforeCharacters = 128,
  4554. wordWrapColumn = 129,
  4555. wordWrapOverride1 = 130,
  4556. wordWrapOverride2 = 131,
  4557. wrappingIndent = 132,
  4558. wrappingStrategy = 133,
  4559. showDeprecated = 134,
  4560. inlayHints = 135,
  4561. editorClassName = 136,
  4562. pixelRatio = 137,
  4563. tabFocusMode = 138,
  4564. layoutInfo = 139,
  4565. wrappingInfo = 140
  4566. }
  4567. export const EditorOptions: {
  4568. acceptSuggestionOnCommitCharacter: IEditorOption<EditorOption.acceptSuggestionOnCommitCharacter, boolean>;
  4569. acceptSuggestionOnEnter: IEditorOption<EditorOption.acceptSuggestionOnEnter, 'on' | 'off' | 'smart'>;
  4570. accessibilitySupport: IEditorOption<EditorOption.accessibilitySupport, AccessibilitySupport>;
  4571. accessibilityPageSize: IEditorOption<EditorOption.accessibilityPageSize, number>;
  4572. ariaLabel: IEditorOption<EditorOption.ariaLabel, string>;
  4573. screenReaderAnnounceInlineSuggestion: IEditorOption<EditorOption.screenReaderAnnounceInlineSuggestion, boolean>;
  4574. autoClosingBrackets: IEditorOption<EditorOption.autoClosingBrackets, 'always' | 'languageDefined' | 'beforeWhitespace' | 'never'>;
  4575. autoClosingDelete: IEditorOption<EditorOption.autoClosingDelete, 'always' | 'never' | 'auto'>;
  4576. autoClosingOvertype: IEditorOption<EditorOption.autoClosingOvertype, 'always' | 'never' | 'auto'>;
  4577. autoClosingQuotes: IEditorOption<EditorOption.autoClosingQuotes, 'always' | 'languageDefined' | 'beforeWhitespace' | 'never'>;
  4578. autoIndent: IEditorOption<EditorOption.autoIndent, EditorAutoIndentStrategy>;
  4579. automaticLayout: IEditorOption<EditorOption.automaticLayout, boolean>;
  4580. autoSurround: IEditorOption<EditorOption.autoSurround, 'languageDefined' | 'never' | 'quotes' | 'brackets'>;
  4581. bracketPairColorization: IEditorOption<EditorOption.bracketPairColorization, Readonly<Required<IBracketPairColorizationOptions>>>;
  4582. bracketPairGuides: IEditorOption<EditorOption.guides, Readonly<Required<IGuidesOptions>>>;
  4583. stickyTabStops: IEditorOption<EditorOption.stickyTabStops, boolean>;
  4584. codeLens: IEditorOption<EditorOption.codeLens, boolean>;
  4585. codeLensFontFamily: IEditorOption<EditorOption.codeLensFontFamily, string>;
  4586. codeLensFontSize: IEditorOption<EditorOption.codeLensFontSize, number>;
  4587. colorDecorators: IEditorOption<EditorOption.colorDecorators, boolean>;
  4588. colorDecoratorsLimit: IEditorOption<EditorOption.colorDecoratorsLimit, number>;
  4589. columnSelection: IEditorOption<EditorOption.columnSelection, boolean>;
  4590. comments: IEditorOption<EditorOption.comments, Readonly<Required<IEditorCommentsOptions>>>;
  4591. contextmenu: IEditorOption<EditorOption.contextmenu, boolean>;
  4592. copyWithSyntaxHighlighting: IEditorOption<EditorOption.copyWithSyntaxHighlighting, boolean>;
  4593. cursorBlinking: IEditorOption<EditorOption.cursorBlinking, TextEditorCursorBlinkingStyle>;
  4594. cursorSmoothCaretAnimation: IEditorOption<EditorOption.cursorSmoothCaretAnimation, 'on' | 'off' | 'explicit'>;
  4595. cursorStyle: IEditorOption<EditorOption.cursorStyle, TextEditorCursorStyle>;
  4596. cursorSurroundingLines: IEditorOption<EditorOption.cursorSurroundingLines, number>;
  4597. cursorSurroundingLinesStyle: IEditorOption<EditorOption.cursorSurroundingLinesStyle, 'default' | 'all'>;
  4598. cursorWidth: IEditorOption<EditorOption.cursorWidth, number>;
  4599. disableLayerHinting: IEditorOption<EditorOption.disableLayerHinting, boolean>;
  4600. disableMonospaceOptimizations: IEditorOption<EditorOption.disableMonospaceOptimizations, boolean>;
  4601. domReadOnly: IEditorOption<EditorOption.domReadOnly, boolean>;
  4602. dragAndDrop: IEditorOption<EditorOption.dragAndDrop, boolean>;
  4603. emptySelectionClipboard: IEditorOption<EditorOption.emptySelectionClipboard, boolean>;
  4604. dropIntoEditor: IEditorOption<EditorOption.dropIntoEditor, Readonly<Required<IDropIntoEditorOptions>>>;
  4605. stickyScroll: IEditorOption<EditorOption.stickyScroll, Readonly<Required<IEditorStickyScrollOptions>>>;
  4606. experimentalWhitespaceRendering: IEditorOption<EditorOption.experimentalWhitespaceRendering, 'off' | 'svg' | 'font'>;
  4607. extraEditorClassName: IEditorOption<EditorOption.extraEditorClassName, string>;
  4608. fastScrollSensitivity: IEditorOption<EditorOption.fastScrollSensitivity, number>;
  4609. find: IEditorOption<EditorOption.find, Readonly<Required<IEditorFindOptions>>>;
  4610. fixedOverflowWidgets: IEditorOption<EditorOption.fixedOverflowWidgets, boolean>;
  4611. folding: IEditorOption<EditorOption.folding, boolean>;
  4612. foldingStrategy: IEditorOption<EditorOption.foldingStrategy, 'auto' | 'indentation'>;
  4613. foldingHighlight: IEditorOption<EditorOption.foldingHighlight, boolean>;
  4614. foldingImportsByDefault: IEditorOption<EditorOption.foldingImportsByDefault, boolean>;
  4615. foldingMaximumRegions: IEditorOption<EditorOption.foldingMaximumRegions, number>;
  4616. unfoldOnClickAfterEndOfLine: IEditorOption<EditorOption.unfoldOnClickAfterEndOfLine, boolean>;
  4617. fontFamily: IEditorOption<EditorOption.fontFamily, string>;
  4618. fontInfo: IEditorOption<EditorOption.fontInfo, FontInfo>;
  4619. fontLigatures2: IEditorOption<EditorOption.fontLigatures, string>;
  4620. fontSize: IEditorOption<EditorOption.fontSize, number>;
  4621. fontWeight: IEditorOption<EditorOption.fontWeight, string>;
  4622. fontVariations: IEditorOption<EditorOption.fontVariations, string>;
  4623. formatOnPaste: IEditorOption<EditorOption.formatOnPaste, boolean>;
  4624. formatOnType: IEditorOption<EditorOption.formatOnType, boolean>;
  4625. glyphMargin: IEditorOption<EditorOption.glyphMargin, boolean>;
  4626. gotoLocation: IEditorOption<EditorOption.gotoLocation, Readonly<Required<IGotoLocationOptions>>>;
  4627. hideCursorInOverviewRuler: IEditorOption<EditorOption.hideCursorInOverviewRuler, boolean>;
  4628. hover: IEditorOption<EditorOption.hover, Readonly<Required<IEditorHoverOptions>>>;
  4629. inDiffEditor: IEditorOption<EditorOption.inDiffEditor, boolean>;
  4630. letterSpacing: IEditorOption<EditorOption.letterSpacing, number>;
  4631. lightbulb: IEditorOption<EditorOption.lightbulb, Readonly<Required<IEditorLightbulbOptions>>>;
  4632. lineDecorationsWidth: IEditorOption<EditorOption.lineDecorationsWidth, number>;
  4633. lineHeight: IEditorOption<EditorOption.lineHeight, number>;
  4634. lineNumbers: IEditorOption<EditorOption.lineNumbers, InternalEditorRenderLineNumbersOptions>;
  4635. lineNumbersMinChars: IEditorOption<EditorOption.lineNumbersMinChars, number>;
  4636. linkedEditing: IEditorOption<EditorOption.linkedEditing, boolean>;
  4637. links: IEditorOption<EditorOption.links, boolean>;
  4638. matchBrackets: IEditorOption<EditorOption.matchBrackets, 'always' | 'never' | 'near'>;
  4639. minimap: IEditorOption<EditorOption.minimap, Readonly<Required<IEditorMinimapOptions>>>;
  4640. mouseStyle: IEditorOption<EditorOption.mouseStyle, 'default' | 'text' | 'copy'>;
  4641. mouseWheelScrollSensitivity: IEditorOption<EditorOption.mouseWheelScrollSensitivity, number>;
  4642. mouseWheelZoom: IEditorOption<EditorOption.mouseWheelZoom, boolean>;
  4643. multiCursorMergeOverlapping: IEditorOption<EditorOption.multiCursorMergeOverlapping, boolean>;
  4644. multiCursorModifier: IEditorOption<EditorOption.multiCursorModifier, 'altKey' | 'metaKey' | 'ctrlKey'>;
  4645. multiCursorPaste: IEditorOption<EditorOption.multiCursorPaste, 'spread' | 'full'>;
  4646. multiCursorLimit: IEditorOption<EditorOption.multiCursorLimit, number>;
  4647. occurrencesHighlight: IEditorOption<EditorOption.occurrencesHighlight, boolean>;
  4648. overviewRulerBorder: IEditorOption<EditorOption.overviewRulerBorder, boolean>;
  4649. overviewRulerLanes: IEditorOption<EditorOption.overviewRulerLanes, number>;
  4650. padding: IEditorOption<EditorOption.padding, Readonly<Required<IEditorPaddingOptions>>>;
  4651. parameterHints: IEditorOption<EditorOption.parameterHints, Readonly<Required<IEditorParameterHintOptions>>>;
  4652. peekWidgetDefaultFocus: IEditorOption<EditorOption.peekWidgetDefaultFocus, 'tree' | 'editor'>;
  4653. definitionLinkOpensInPeek: IEditorOption<EditorOption.definitionLinkOpensInPeek, boolean>;
  4654. quickSuggestions: IEditorOption<EditorOption.quickSuggestions, InternalQuickSuggestionsOptions>;
  4655. quickSuggestionsDelay: IEditorOption<EditorOption.quickSuggestionsDelay, number>;
  4656. readOnly: IEditorOption<EditorOption.readOnly, boolean>;
  4657. renameOnType: IEditorOption<EditorOption.renameOnType, boolean>;
  4658. renderControlCharacters: IEditorOption<EditorOption.renderControlCharacters, boolean>;
  4659. renderFinalNewline: IEditorOption<EditorOption.renderFinalNewline, 'on' | 'off' | 'dimmed'>;
  4660. renderLineHighlight: IEditorOption<EditorOption.renderLineHighlight, 'all' | 'line' | 'none' | 'gutter'>;
  4661. renderLineHighlightOnlyWhenFocus: IEditorOption<EditorOption.renderLineHighlightOnlyWhenFocus, boolean>;
  4662. renderValidationDecorations: IEditorOption<EditorOption.renderValidationDecorations, 'on' | 'off' | 'editable'>;
  4663. renderWhitespace: IEditorOption<EditorOption.renderWhitespace, 'all' | 'none' | 'boundary' | 'selection' | 'trailing'>;
  4664. revealHorizontalRightPadding: IEditorOption<EditorOption.revealHorizontalRightPadding, number>;
  4665. roundedSelection: IEditorOption<EditorOption.roundedSelection, boolean>;
  4666. rulers: IEditorOption<EditorOption.rulers, {}>;
  4667. scrollbar: IEditorOption<EditorOption.scrollbar, InternalEditorScrollbarOptions>;
  4668. scrollBeyondLastColumn: IEditorOption<EditorOption.scrollBeyondLastColumn, number>;
  4669. scrollBeyondLastLine: IEditorOption<EditorOption.scrollBeyondLastLine, boolean>;
  4670. scrollPredominantAxis: IEditorOption<EditorOption.scrollPredominantAxis, boolean>;
  4671. selectionClipboard: IEditorOption<EditorOption.selectionClipboard, boolean>;
  4672. selectionHighlight: IEditorOption<EditorOption.selectionHighlight, boolean>;
  4673. selectOnLineNumbers: IEditorOption<EditorOption.selectOnLineNumbers, boolean>;
  4674. showFoldingControls: IEditorOption<EditorOption.showFoldingControls, 'always' | 'never' | 'mouseover'>;
  4675. showUnused: IEditorOption<EditorOption.showUnused, boolean>;
  4676. showDeprecated: IEditorOption<EditorOption.showDeprecated, boolean>;
  4677. inlayHints: IEditorOption<EditorOption.inlayHints, Readonly<Required<IEditorInlayHintsOptions>>>;
  4678. snippetSuggestions: IEditorOption<EditorOption.snippetSuggestions, 'none' | 'top' | 'bottom' | 'inline'>;
  4679. smartSelect: IEditorOption<EditorOption.smartSelect, Readonly<Required<ISmartSelectOptions>>>;
  4680. smoothScrolling: IEditorOption<EditorOption.smoothScrolling, boolean>;
  4681. stopRenderingLineAfter: IEditorOption<EditorOption.stopRenderingLineAfter, number>;
  4682. suggest: IEditorOption<EditorOption.suggest, Readonly<Required<ISuggestOptions>>>;
  4683. inlineSuggest: IEditorOption<EditorOption.inlineSuggest, Readonly<Required<IInlineSuggestOptions>>>;
  4684. suggestFontSize: IEditorOption<EditorOption.suggestFontSize, number>;
  4685. suggestLineHeight: IEditorOption<EditorOption.suggestLineHeight, number>;
  4686. suggestOnTriggerCharacters: IEditorOption<EditorOption.suggestOnTriggerCharacters, boolean>;
  4687. suggestSelection: IEditorOption<EditorOption.suggestSelection, 'first' | 'recentlyUsed' | 'recentlyUsedByPrefix'>;
  4688. tabCompletion: IEditorOption<EditorOption.tabCompletion, 'on' | 'off' | 'onlySnippets'>;
  4689. tabIndex: IEditorOption<EditorOption.tabIndex, number>;
  4690. unicodeHighlight: IEditorOption<EditorOption.unicodeHighlighting, any>;
  4691. unusualLineTerminators: IEditorOption<EditorOption.unusualLineTerminators, 'auto' | 'off' | 'prompt'>;
  4692. useShadowDOM: IEditorOption<EditorOption.useShadowDOM, boolean>;
  4693. useTabStops: IEditorOption<EditorOption.useTabStops, boolean>;
  4694. wordBreak: IEditorOption<EditorOption.wordBreak, 'normal' | 'keepAll'>;
  4695. wordSeparators: IEditorOption<EditorOption.wordSeparators, string>;
  4696. wordWrap: IEditorOption<EditorOption.wordWrap, 'on' | 'off' | 'wordWrapColumn' | 'bounded'>;
  4697. wordWrapBreakAfterCharacters: IEditorOption<EditorOption.wordWrapBreakAfterCharacters, string>;
  4698. wordWrapBreakBeforeCharacters: IEditorOption<EditorOption.wordWrapBreakBeforeCharacters, string>;
  4699. wordWrapColumn: IEditorOption<EditorOption.wordWrapColumn, number>;
  4700. wordWrapOverride1: IEditorOption<EditorOption.wordWrapOverride1, 'on' | 'off' | 'inherit'>;
  4701. wordWrapOverride2: IEditorOption<EditorOption.wordWrapOverride2, 'on' | 'off' | 'inherit'>;
  4702. editorClassName: IEditorOption<EditorOption.editorClassName, string>;
  4703. pixelRatio: IEditorOption<EditorOption.pixelRatio, number>;
  4704. tabFocusMode: IEditorOption<EditorOption.tabFocusMode, boolean>;
  4705. layoutInfo: IEditorOption<EditorOption.layoutInfo, EditorLayoutInfo>;
  4706. wrappingInfo: IEditorOption<EditorOption.wrappingInfo, EditorWrappingInfo>;
  4707. wrappingIndent: IEditorOption<EditorOption.wrappingIndent, WrappingIndent>;
  4708. wrappingStrategy: IEditorOption<EditorOption.wrappingStrategy, 'simple' | 'advanced'>;
  4709. };
  4710. type EditorOptionsType = typeof EditorOptions;
  4711. type FindEditorOptionsKeyById<T extends EditorOption> = {
  4712. [K in keyof EditorOptionsType]: EditorOptionsType[K]['id'] extends T ? K : never;
  4713. }[keyof EditorOptionsType];
  4714. type ComputedEditorOptionValue<T extends IEditorOption<any, any>> = T extends IEditorOption<any, infer R> ? R : never;
  4715. export type FindComputedEditorOptionValueById<T extends EditorOption> = NonNullable<ComputedEditorOptionValue<EditorOptionsType[FindEditorOptionsKeyById<T>]>>;
  4716. export interface IEditorConstructionOptions extends IEditorOptions {
  4717. /**
  4718. * The initial editor dimension (to avoid measuring the container).
  4719. */
  4720. dimension?: IDimension;
  4721. /**
  4722. * Place overflow widgets inside an external DOM node.
  4723. * Defaults to an internal DOM node.
  4724. */
  4725. overflowWidgetsDomNode?: HTMLElement;
  4726. }
  4727. /**
  4728. * A view zone is a full horizontal rectangle that 'pushes' text down.
  4729. * The editor reserves space for view zones when rendering.
  4730. */
  4731. export interface IViewZone {
  4732. /**
  4733. * The line number after which this zone should appear.
  4734. * Use 0 to place a view zone before the first line number.
  4735. */
  4736. afterLineNumber: number;
  4737. /**
  4738. * The column after which this zone should appear.
  4739. * If not set, the maxLineColumn of `afterLineNumber` will be used.
  4740. * This is relevant for wrapped lines.
  4741. */
  4742. afterColumn?: number;
  4743. /**
  4744. * If the `afterColumn` has multiple view columns, the affinity specifies which one to use. Defaults to `none`.
  4745. */
  4746. afterColumnAffinity?: PositionAffinity;
  4747. /**
  4748. * Suppress mouse down events.
  4749. * If set, the editor will attach a mouse down listener to the view zone and .preventDefault on it.
  4750. * Defaults to false
  4751. */
  4752. suppressMouseDown?: boolean;
  4753. /**
  4754. * The height in lines of the view zone.
  4755. * If specified, `heightInPx` will be used instead of this.
  4756. * If neither `heightInPx` nor `heightInLines` is specified, a default of `heightInLines` = 1 will be chosen.
  4757. */
  4758. heightInLines?: number;
  4759. /**
  4760. * The height in px of the view zone.
  4761. * If this is set, the editor will give preference to it rather than `heightInLines` above.
  4762. * If neither `heightInPx` nor `heightInLines` is specified, a default of `heightInLines` = 1 will be chosen.
  4763. */
  4764. heightInPx?: number;
  4765. /**
  4766. * The minimum width in px of the view zone.
  4767. * If this is set, the editor will ensure that the scroll width is >= than this value.
  4768. */
  4769. minWidthInPx?: number;
  4770. /**
  4771. * The dom node of the view zone
  4772. */
  4773. domNode: HTMLElement;
  4774. /**
  4775. * An optional dom node for the view zone that will be placed in the margin area.
  4776. */
  4777. marginDomNode?: HTMLElement | null;
  4778. /**
  4779. * Callback which gives the relative top of the view zone as it appears (taking scrolling into account).
  4780. */
  4781. onDomNodeTop?: (top: number) => void;
  4782. /**
  4783. * Callback which gives the height in pixels of the view zone.
  4784. */
  4785. onComputedHeight?: (height: number) => void;
  4786. }
  4787. /**
  4788. * An accessor that allows for zones to be added or removed.
  4789. */
  4790. export interface IViewZoneChangeAccessor {
  4791. /**
  4792. * Create a new view zone.
  4793. * @param zone Zone to create
  4794. * @return A unique identifier to the view zone.
  4795. */
  4796. addZone(zone: IViewZone): string;
  4797. /**
  4798. * Remove a zone
  4799. * @param id A unique identifier to the view zone, as returned by the `addZone` call.
  4800. */
  4801. removeZone(id: string): void;
  4802. /**
  4803. * Change a zone's position.
  4804. * The editor will rescan the `afterLineNumber` and `afterColumn` properties of a view zone.
  4805. */
  4806. layoutZone(id: string): void;
  4807. }
  4808. /**
  4809. * A positioning preference for rendering content widgets.
  4810. */
  4811. export enum ContentWidgetPositionPreference {
  4812. /**
  4813. * Place the content widget exactly at a position
  4814. */
  4815. EXACT = 0,
  4816. /**
  4817. * Place the content widget above a position
  4818. */
  4819. ABOVE = 1,
  4820. /**
  4821. * Place the content widget below a position
  4822. */
  4823. BELOW = 2
  4824. }
  4825. /**
  4826. * A position for rendering content widgets.
  4827. */
  4828. export interface IContentWidgetPosition {
  4829. /**
  4830. * Desired position which serves as an anchor for placing the content widget.
  4831. * The widget will be placed above, at, or below the specified position, based on the
  4832. * provided preference. The widget will always touch this position.
  4833. *
  4834. * Given sufficient horizontal space, the widget will be placed to the right of the
  4835. * passed in position. This can be tweaked by providing a `secondaryPosition`.
  4836. *
  4837. * @see preference
  4838. * @see secondaryPosition
  4839. */
  4840. position: IPosition | null;
  4841. /**
  4842. * Optionally, a secondary position can be provided to further define the placing of
  4843. * the content widget. The secondary position must have the same line number as the
  4844. * primary position. If possible, the widget will be placed such that it also touches
  4845. * the secondary position.
  4846. */
  4847. secondaryPosition?: IPosition | null;
  4848. /**
  4849. * Placement preference for position, in order of preference.
  4850. */
  4851. preference: ContentWidgetPositionPreference[];
  4852. /**
  4853. * Placement preference when multiple view positions refer to the same (model) position.
  4854. * This plays a role when injected text is involved.
  4855. */
  4856. positionAffinity?: PositionAffinity;
  4857. }
  4858. /**
  4859. * A content widget renders inline with the text and can be easily placed 'near' an editor position.
  4860. */
  4861. export interface IContentWidget {
  4862. /**
  4863. * Render this content widget in a location where it could overflow the editor's view dom node.
  4864. */
  4865. allowEditorOverflow?: boolean;
  4866. /**
  4867. * Call preventDefault() on mousedown events that target the content widget.
  4868. */
  4869. suppressMouseDown?: boolean;
  4870. /**
  4871. * Get a unique identifier of the content widget.
  4872. */
  4873. getId(): string;
  4874. /**
  4875. * Get the dom node of the content widget.
  4876. */
  4877. getDomNode(): HTMLElement;
  4878. /**
  4879. * Get the placement of the content widget.
  4880. * If null is returned, the content widget will be placed off screen.
  4881. */
  4882. getPosition(): IContentWidgetPosition | null;
  4883. /**
  4884. * Optional function that is invoked before rendering
  4885. * the content widget. If a dimension is returned the editor will
  4886. * attempt to use it.
  4887. */
  4888. beforeRender?(): IDimension | null;
  4889. /**
  4890. * Optional function that is invoked after rendering the content
  4891. * widget. Is being invoked with the selected position preference
  4892. * or `null` if not rendered.
  4893. */
  4894. afterRender?(position: ContentWidgetPositionPreference | null): void;
  4895. }
  4896. /**
  4897. * A positioning preference for rendering overlay widgets.
  4898. */
  4899. export enum OverlayWidgetPositionPreference {
  4900. /**
  4901. * Position the overlay widget in the top right corner
  4902. */
  4903. TOP_RIGHT_CORNER = 0,
  4904. /**
  4905. * Position the overlay widget in the bottom right corner
  4906. */
  4907. BOTTOM_RIGHT_CORNER = 1,
  4908. /**
  4909. * Position the overlay widget in the top center
  4910. */
  4911. TOP_CENTER = 2
  4912. }
  4913. /**
  4914. * A position for rendering overlay widgets.
  4915. */
  4916. export interface IOverlayWidgetPosition {
  4917. /**
  4918. * The position preference for the overlay widget.
  4919. */
  4920. preference: OverlayWidgetPositionPreference | null;
  4921. }
  4922. /**
  4923. * An overlay widgets renders on top of the text.
  4924. */
  4925. export interface IOverlayWidget {
  4926. /**
  4927. * Get a unique identifier of the overlay widget.
  4928. */
  4929. getId(): string;
  4930. /**
  4931. * Get the dom node of the overlay widget.
  4932. */
  4933. getDomNode(): HTMLElement;
  4934. /**
  4935. * Get the placement of the overlay widget.
  4936. * If null is returned, the overlay widget is responsible to place itself.
  4937. */
  4938. getPosition(): IOverlayWidgetPosition | null;
  4939. }
  4940. /**
  4941. * Type of hit element with the mouse in the editor.
  4942. */
  4943. export enum MouseTargetType {
  4944. /**
  4945. * Mouse is on top of an unknown element.
  4946. */
  4947. UNKNOWN = 0,
  4948. /**
  4949. * Mouse is on top of the textarea used for input.
  4950. */
  4951. TEXTAREA = 1,
  4952. /**
  4953. * Mouse is on top of the glyph margin
  4954. */
  4955. GUTTER_GLYPH_MARGIN = 2,
  4956. /**
  4957. * Mouse is on top of the line numbers
  4958. */
  4959. GUTTER_LINE_NUMBERS = 3,
  4960. /**
  4961. * Mouse is on top of the line decorations
  4962. */
  4963. GUTTER_LINE_DECORATIONS = 4,
  4964. /**
  4965. * Mouse is on top of the whitespace left in the gutter by a view zone.
  4966. */
  4967. GUTTER_VIEW_ZONE = 5,
  4968. /**
  4969. * Mouse is on top of text in the content.
  4970. */
  4971. CONTENT_TEXT = 6,
  4972. /**
  4973. * Mouse is on top of empty space in the content (e.g. after line text or below last line)
  4974. */
  4975. CONTENT_EMPTY = 7,
  4976. /**
  4977. * Mouse is on top of a view zone in the content.
  4978. */
  4979. CONTENT_VIEW_ZONE = 8,
  4980. /**
  4981. * Mouse is on top of a content widget.
  4982. */
  4983. CONTENT_WIDGET = 9,
  4984. /**
  4985. * Mouse is on top of the decorations overview ruler.
  4986. */
  4987. OVERVIEW_RULER = 10,
  4988. /**
  4989. * Mouse is on top of a scrollbar.
  4990. */
  4991. SCROLLBAR = 11,
  4992. /**
  4993. * Mouse is on top of an overlay widget.
  4994. */
  4995. OVERLAY_WIDGET = 12,
  4996. /**
  4997. * Mouse is outside of the editor.
  4998. */
  4999. OUTSIDE_EDITOR = 13
  5000. }
  5001. export interface IBaseMouseTarget {
  5002. /**
  5003. * The target element
  5004. */
  5005. readonly element: Element | null;
  5006. /**
  5007. * The 'approximate' editor position
  5008. */
  5009. readonly position: Position | null;
  5010. /**
  5011. * Desired mouse column (e.g. when position.column gets clamped to text length -- clicking after text on a line).
  5012. */
  5013. readonly mouseColumn: number;
  5014. /**
  5015. * The 'approximate' editor range
  5016. */
  5017. readonly range: Range | null;
  5018. }
  5019. export interface IMouseTargetUnknown extends IBaseMouseTarget {
  5020. readonly type: MouseTargetType.UNKNOWN;
  5021. }
  5022. export interface IMouseTargetTextarea extends IBaseMouseTarget {
  5023. readonly type: MouseTargetType.TEXTAREA;
  5024. readonly position: null;
  5025. readonly range: null;
  5026. }
  5027. export interface IMouseTargetMarginData {
  5028. readonly isAfterLines: boolean;
  5029. readonly glyphMarginLeft: number;
  5030. readonly glyphMarginWidth: number;
  5031. readonly lineNumbersWidth: number;
  5032. readonly offsetX: number;
  5033. }
  5034. export interface IMouseTargetMargin extends IBaseMouseTarget {
  5035. readonly type: MouseTargetType.GUTTER_GLYPH_MARGIN | MouseTargetType.GUTTER_LINE_NUMBERS | MouseTargetType.GUTTER_LINE_DECORATIONS;
  5036. readonly position: Position;
  5037. readonly range: Range;
  5038. readonly detail: IMouseTargetMarginData;
  5039. }
  5040. export interface IMouseTargetViewZoneData {
  5041. readonly viewZoneId: string;
  5042. readonly positionBefore: Position | null;
  5043. readonly positionAfter: Position | null;
  5044. readonly position: Position;
  5045. readonly afterLineNumber: number;
  5046. }
  5047. export interface IMouseTargetViewZone extends IBaseMouseTarget {
  5048. readonly type: MouseTargetType.GUTTER_VIEW_ZONE | MouseTargetType.CONTENT_VIEW_ZONE;
  5049. readonly position: Position;
  5050. readonly range: Range;
  5051. readonly detail: IMouseTargetViewZoneData;
  5052. }
  5053. export interface IMouseTargetContentTextData {
  5054. readonly mightBeForeignElement: boolean;
  5055. }
  5056. export interface IMouseTargetContentText extends IBaseMouseTarget {
  5057. readonly type: MouseTargetType.CONTENT_TEXT;
  5058. readonly position: Position;
  5059. readonly range: Range;
  5060. readonly detail: IMouseTargetContentTextData;
  5061. }
  5062. export interface IMouseTargetContentEmptyData {
  5063. readonly isAfterLines: boolean;
  5064. readonly horizontalDistanceToText?: number;
  5065. }
  5066. export interface IMouseTargetContentEmpty extends IBaseMouseTarget {
  5067. readonly type: MouseTargetType.CONTENT_EMPTY;
  5068. readonly position: Position;
  5069. readonly range: Range;
  5070. readonly detail: IMouseTargetContentEmptyData;
  5071. }
  5072. export interface IMouseTargetContentWidget extends IBaseMouseTarget {
  5073. readonly type: MouseTargetType.CONTENT_WIDGET;
  5074. readonly position: null;
  5075. readonly range: null;
  5076. readonly detail: string;
  5077. }
  5078. export interface IMouseTargetOverlayWidget extends IBaseMouseTarget {
  5079. readonly type: MouseTargetType.OVERLAY_WIDGET;
  5080. readonly position: null;
  5081. readonly range: null;
  5082. readonly detail: string;
  5083. }
  5084. export interface IMouseTargetScrollbar extends IBaseMouseTarget {
  5085. readonly type: MouseTargetType.SCROLLBAR;
  5086. readonly position: Position;
  5087. readonly range: Range;
  5088. }
  5089. export interface IMouseTargetOverviewRuler extends IBaseMouseTarget {
  5090. readonly type: MouseTargetType.OVERVIEW_RULER;
  5091. }
  5092. export interface IMouseTargetOutsideEditor extends IBaseMouseTarget {
  5093. readonly type: MouseTargetType.OUTSIDE_EDITOR;
  5094. readonly outsidePosition: 'above' | 'below' | 'left' | 'right';
  5095. readonly outsideDistance: number;
  5096. }
  5097. /**
  5098. * Target hit with the mouse in the editor.
  5099. */
  5100. export type IMouseTarget = (IMouseTargetUnknown | IMouseTargetTextarea | IMouseTargetMargin | IMouseTargetViewZone | IMouseTargetContentText | IMouseTargetContentEmpty | IMouseTargetContentWidget | IMouseTargetOverlayWidget | IMouseTargetScrollbar | IMouseTargetOverviewRuler | IMouseTargetOutsideEditor);
  5101. /**
  5102. * A mouse event originating from the editor.
  5103. */
  5104. export interface IEditorMouseEvent {
  5105. readonly event: IMouseEvent;
  5106. readonly target: IMouseTarget;
  5107. }
  5108. export interface IPartialEditorMouseEvent {
  5109. readonly event: IMouseEvent;
  5110. readonly target: IMouseTarget | null;
  5111. }
  5112. /**
  5113. * A paste event originating from the editor.
  5114. */
  5115. export interface IPasteEvent {
  5116. readonly range: Range;
  5117. readonly languageId: string | null;
  5118. }
  5119. export interface IDiffEditorConstructionOptions extends IDiffEditorOptions {
  5120. /**
  5121. * The initial editor dimension (to avoid measuring the container).
  5122. */
  5123. dimension?: IDimension;
  5124. /**
  5125. * Place overflow widgets inside an external DOM node.
  5126. * Defaults to an internal DOM node.
  5127. */
  5128. overflowWidgetsDomNode?: HTMLElement;
  5129. /**
  5130. * Aria label for original editor.
  5131. */
  5132. originalAriaLabel?: string;
  5133. /**
  5134. * Aria label for modified editor.
  5135. */
  5136. modifiedAriaLabel?: string;
  5137. /**
  5138. * Is the diff editor inside another editor
  5139. * Defaults to false
  5140. */
  5141. isInEmbeddedEditor?: boolean;
  5142. }
  5143. /**
  5144. * A rich code editor.
  5145. */
  5146. export interface ICodeEditor extends IEditor {
  5147. /**
  5148. * An event emitted when the content of the current model has changed.
  5149. * @event
  5150. */
  5151. readonly onDidChangeModelContent: IEvent<IModelContentChangedEvent>;
  5152. /**
  5153. * An event emitted when the language of the current model has changed.
  5154. * @event
  5155. */
  5156. readonly onDidChangeModelLanguage: IEvent<IModelLanguageChangedEvent>;
  5157. /**
  5158. * An event emitted when the language configuration of the current model has changed.
  5159. * @event
  5160. */
  5161. readonly onDidChangeModelLanguageConfiguration: IEvent<IModelLanguageConfigurationChangedEvent>;
  5162. /**
  5163. * An event emitted when the options of the current model has changed.
  5164. * @event
  5165. */
  5166. readonly onDidChangeModelOptions: IEvent<IModelOptionsChangedEvent>;
  5167. /**
  5168. * An event emitted when the configuration of the editor has changed. (e.g. `editor.updateOptions()`)
  5169. * @event
  5170. */
  5171. readonly onDidChangeConfiguration: IEvent<ConfigurationChangedEvent>;
  5172. /**
  5173. * An event emitted when the cursor position has changed.
  5174. * @event
  5175. */
  5176. readonly onDidChangeCursorPosition: IEvent<ICursorPositionChangedEvent>;
  5177. /**
  5178. * An event emitted when the cursor selection has changed.
  5179. * @event
  5180. */
  5181. readonly onDidChangeCursorSelection: IEvent<ICursorSelectionChangedEvent>;
  5182. /**
  5183. * An event emitted when the model of this editor has changed (e.g. `editor.setModel()`).
  5184. * @event
  5185. */
  5186. readonly onDidChangeModel: IEvent<IModelChangedEvent>;
  5187. /**
  5188. * An event emitted when the decorations of the current model have changed.
  5189. * @event
  5190. */
  5191. readonly onDidChangeModelDecorations: IEvent<IModelDecorationsChangedEvent>;
  5192. /**
  5193. * An event emitted when the text inside this editor gained focus (i.e. cursor starts blinking).
  5194. * @event
  5195. */
  5196. readonly onDidFocusEditorText: IEvent<void>;
  5197. /**
  5198. * An event emitted when the text inside this editor lost focus (i.e. cursor stops blinking).
  5199. * @event
  5200. */
  5201. readonly onDidBlurEditorText: IEvent<void>;
  5202. /**
  5203. * An event emitted when the text inside this editor or an editor widget gained focus.
  5204. * @event
  5205. */
  5206. readonly onDidFocusEditorWidget: IEvent<void>;
  5207. /**
  5208. * An event emitted when the text inside this editor or an editor widget lost focus.
  5209. * @event
  5210. */
  5211. readonly onDidBlurEditorWidget: IEvent<void>;
  5212. /**
  5213. * An event emitted after composition has started.
  5214. */
  5215. readonly onDidCompositionStart: IEvent<void>;
  5216. /**
  5217. * An event emitted after composition has ended.
  5218. */
  5219. readonly onDidCompositionEnd: IEvent<void>;
  5220. /**
  5221. * An event emitted when editing failed because the editor is read-only.
  5222. * @event
  5223. */
  5224. readonly onDidAttemptReadOnlyEdit: IEvent<void>;
  5225. /**
  5226. * An event emitted when users paste text in the editor.
  5227. * @event
  5228. */
  5229. readonly onDidPaste: IEvent<IPasteEvent>;
  5230. /**
  5231. * An event emitted on a "mouseup".
  5232. * @event
  5233. */
  5234. readonly onMouseUp: IEvent<IEditorMouseEvent>;
  5235. /**
  5236. * An event emitted on a "mousedown".
  5237. * @event
  5238. */
  5239. readonly onMouseDown: IEvent<IEditorMouseEvent>;
  5240. /**
  5241. * An event emitted on a "contextmenu".
  5242. * @event
  5243. */
  5244. readonly onContextMenu: IEvent<IEditorMouseEvent>;
  5245. /**
  5246. * An event emitted on a "mousemove".
  5247. * @event
  5248. */
  5249. readonly onMouseMove: IEvent<IEditorMouseEvent>;
  5250. /**
  5251. * An event emitted on a "mouseleave".
  5252. * @event
  5253. */
  5254. readonly onMouseLeave: IEvent<IPartialEditorMouseEvent>;
  5255. /**
  5256. * An event emitted on a "keyup".
  5257. * @event
  5258. */
  5259. readonly onKeyUp: IEvent<IKeyboardEvent>;
  5260. /**
  5261. * An event emitted on a "keydown".
  5262. * @event
  5263. */
  5264. readonly onKeyDown: IEvent<IKeyboardEvent>;
  5265. /**
  5266. * An event emitted when the layout of the editor has changed.
  5267. * @event
  5268. */
  5269. readonly onDidLayoutChange: IEvent<EditorLayoutInfo>;
  5270. /**
  5271. * An event emitted when the content width or content height in the editor has changed.
  5272. * @event
  5273. */
  5274. readonly onDidContentSizeChange: IEvent<IContentSizeChangedEvent>;
  5275. /**
  5276. * An event emitted when the scroll in the editor has changed.
  5277. * @event
  5278. */
  5279. readonly onDidScrollChange: IEvent<IScrollEvent>;
  5280. /**
  5281. * An event emitted when hidden areas change in the editor (e.g. due to folding).
  5282. * @event
  5283. */
  5284. readonly onDidChangeHiddenAreas: IEvent<void>;
  5285. /**
  5286. * Saves current view state of the editor in a serializable object.
  5287. */
  5288. saveViewState(): ICodeEditorViewState | null;
  5289. /**
  5290. * Restores the view state of the editor from a serializable object generated by `saveViewState`.
  5291. */
  5292. restoreViewState(state: ICodeEditorViewState | null): void;
  5293. /**
  5294. * Returns true if the text inside this editor or an editor widget has focus.
  5295. */
  5296. hasWidgetFocus(): boolean;
  5297. /**
  5298. * Get a contribution of this editor.
  5299. * @id Unique identifier of the contribution.
  5300. * @return The contribution or null if contribution not found.
  5301. */
  5302. getContribution<T extends IEditorContribution>(id: string): T | null;
  5303. /**
  5304. * Type the getModel() of IEditor.
  5305. */
  5306. getModel(): ITextModel | null;
  5307. /**
  5308. * Sets the current model attached to this editor.
  5309. * If the previous model was created by the editor via the value key in the options
  5310. * literal object, it will be destroyed. Otherwise, if the previous model was set
  5311. * via setModel, or the model key in the options literal object, the previous model
  5312. * will not be destroyed.
  5313. * It is safe to call setModel(null) to simply detach the current model from the editor.
  5314. */
  5315. setModel(model: ITextModel | null): void;
  5316. /**
  5317. * Gets all the editor computed options.
  5318. */
  5319. getOptions(): IComputedEditorOptions;
  5320. /**
  5321. * Gets a specific editor option.
  5322. */
  5323. getOption<T extends EditorOption>(id: T): FindComputedEditorOptionValueById<T>;
  5324. /**
  5325. * Returns the editor's configuration (without any validation or defaults).
  5326. */
  5327. getRawOptions(): IEditorOptions;
  5328. /**
  5329. * Get value of the current model attached to this editor.
  5330. * @see {@link ITextModel.getValue}
  5331. */
  5332. getValue(options?: {
  5333. preserveBOM: boolean;
  5334. lineEnding: string;
  5335. }): string;
  5336. /**
  5337. * Set the value of the current model attached to this editor.
  5338. * @see {@link ITextModel.setValue}
  5339. */
  5340. setValue(newValue: string): void;
  5341. /**
  5342. * Get the width of the editor's content.
  5343. * This is information that is "erased" when computing `scrollWidth = Math.max(contentWidth, width)`
  5344. */
  5345. getContentWidth(): number;
  5346. /**
  5347. * Get the scrollWidth of the editor's viewport.
  5348. */
  5349. getScrollWidth(): number;
  5350. /**
  5351. * Get the scrollLeft of the editor's viewport.
  5352. */
  5353. getScrollLeft(): number;
  5354. /**
  5355. * Get the height of the editor's content.
  5356. * This is information that is "erased" when computing `scrollHeight = Math.max(contentHeight, height)`
  5357. */
  5358. getContentHeight(): number;
  5359. /**
  5360. * Get the scrollHeight of the editor's viewport.
  5361. */
  5362. getScrollHeight(): number;
  5363. /**
  5364. * Get the scrollTop of the editor's viewport.
  5365. */
  5366. getScrollTop(): number;
  5367. /**
  5368. * Change the scrollLeft of the editor's viewport.
  5369. */
  5370. setScrollLeft(newScrollLeft: number, scrollType?: ScrollType): void;
  5371. /**
  5372. * Change the scrollTop of the editor's viewport.
  5373. */
  5374. setScrollTop(newScrollTop: number, scrollType?: ScrollType): void;
  5375. /**
  5376. * Change the scroll position of the editor's viewport.
  5377. */
  5378. setScrollPosition(position: INewScrollPosition, scrollType?: ScrollType): void;
  5379. /**
  5380. * Get an action that is a contribution to this editor.
  5381. * @id Unique identifier of the contribution.
  5382. * @return The action or null if action not found.
  5383. */
  5384. getAction(id: string): IEditorAction | null;
  5385. /**
  5386. * Execute a command on the editor.
  5387. * The edits will land on the undo-redo stack, but no "undo stop" will be pushed.
  5388. * @param source The source of the call.
  5389. * @param command The command to execute
  5390. */
  5391. executeCommand(source: string | null | undefined, command: ICommand): void;
  5392. /**
  5393. * Create an "undo stop" in the undo-redo stack.
  5394. */
  5395. pushUndoStop(): boolean;
  5396. /**
  5397. * Remove the "undo stop" in the undo-redo stack.
  5398. */
  5399. popUndoStop(): boolean;
  5400. /**
  5401. * Execute edits on the editor.
  5402. * The edits will land on the undo-redo stack, but no "undo stop" will be pushed.
  5403. * @param source The source of the call.
  5404. * @param edits The edits to execute.
  5405. * @param endCursorState Cursor state after the edits were applied.
  5406. */
  5407. executeEdits(source: string | null | undefined, edits: IIdentifiedSingleEditOperation[], endCursorState?: ICursorStateComputer | Selection[]): boolean;
  5408. /**
  5409. * Execute multiple (concomitant) commands on the editor.
  5410. * @param source The source of the call.
  5411. * @param command The commands to execute
  5412. */
  5413. executeCommands(source: string | null | undefined, commands: (ICommand | null)[]): void;
  5414. /**
  5415. * Get all the decorations on a line (filtering out decorations from other editors).
  5416. */
  5417. getLineDecorations(lineNumber: number): IModelDecoration[] | null;
  5418. /**
  5419. * Get all the decorations for a range (filtering out decorations from other editors).
  5420. */
  5421. getDecorationsInRange(range: Range): IModelDecoration[] | null;
  5422. /**
  5423. * All decorations added through this call will get the ownerId of this editor.
  5424. * @deprecated Use `createDecorationsCollection`
  5425. * @see createDecorationsCollection
  5426. */
  5427. deltaDecorations(oldDecorations: string[], newDecorations: IModelDeltaDecoration[]): string[];
  5428. /**
  5429. * Remove previously added decorations.
  5430. */
  5431. removeDecorations(decorationIds: string[]): void;
  5432. /**
  5433. * Get the layout info for the editor.
  5434. */
  5435. getLayoutInfo(): EditorLayoutInfo;
  5436. /**
  5437. * Returns the ranges that are currently visible.
  5438. * Does not account for horizontal scrolling.
  5439. */
  5440. getVisibleRanges(): Range[];
  5441. /**
  5442. * Get the vertical position (top offset) for the line's top w.r.t. to the first line.
  5443. */
  5444. getTopForLineNumber(lineNumber: number): number;
  5445. /**
  5446. * Get the vertical position (top offset) for the line's bottom w.r.t. to the first line.
  5447. */
  5448. getBottomForLineNumber(lineNumber: number): number;
  5449. /**
  5450. * Get the vertical position (top offset) for the position w.r.t. to the first line.
  5451. */
  5452. getTopForPosition(lineNumber: number, column: number): number;
  5453. /**
  5454. * Write the screen reader content to be the current selection
  5455. */
  5456. writeScreenReaderContent(reason: string): void;
  5457. /**
  5458. * Returns the editor's container dom node
  5459. */
  5460. getContainerDomNode(): HTMLElement;
  5461. /**
  5462. * Returns the editor's dom node
  5463. */
  5464. getDomNode(): HTMLElement | null;
  5465. /**
  5466. * Add a content widget. Widgets must have unique ids, otherwise they will be overwritten.
  5467. */
  5468. addContentWidget(widget: IContentWidget): void;
  5469. /**
  5470. * Layout/Reposition a content widget. This is a ping to the editor to call widget.getPosition()
  5471. * and update appropriately.
  5472. */
  5473. layoutContentWidget(widget: IContentWidget): void;
  5474. /**
  5475. * Remove a content widget.
  5476. */
  5477. removeContentWidget(widget: IContentWidget): void;
  5478. /**
  5479. * Add an overlay widget. Widgets must have unique ids, otherwise they will be overwritten.
  5480. */
  5481. addOverlayWidget(widget: IOverlayWidget): void;
  5482. /**
  5483. * Layout/Reposition an overlay widget. This is a ping to the editor to call widget.getPosition()
  5484. * and update appropriately.
  5485. */
  5486. layoutOverlayWidget(widget: IOverlayWidget): void;
  5487. /**
  5488. * Remove an overlay widget.
  5489. */
  5490. removeOverlayWidget(widget: IOverlayWidget): void;
  5491. /**
  5492. * Change the view zones. View zones are lost when a new model is attached to the editor.
  5493. */
  5494. changeViewZones(callback: (accessor: IViewZoneChangeAccessor) => void): void;
  5495. /**
  5496. * Get the horizontal position (left offset) for the column w.r.t to the beginning of the line.
  5497. * This method works only if the line `lineNumber` is currently rendered (in the editor's viewport).
  5498. * Use this method with caution.
  5499. */
  5500. getOffsetForColumn(lineNumber: number, column: number): number;
  5501. /**
  5502. * Force an editor render now.
  5503. */
  5504. render(forceRedraw?: boolean): void;
  5505. /**
  5506. * Get the hit test target at coordinates `clientX` and `clientY`.
  5507. * The coordinates are relative to the top-left of the viewport.
  5508. *
  5509. * @returns Hit test target or null if the coordinates fall outside the editor or the editor has no model.
  5510. */
  5511. getTargetAtClientPoint(clientX: number, clientY: number): IMouseTarget | null;
  5512. /**
  5513. * Get the visible position for `position`.
  5514. * The result position takes scrolling into account and is relative to the top left corner of the editor.
  5515. * Explanation 1: the results of this method will change for the same `position` if the user scrolls the editor.
  5516. * Explanation 2: the results of this method will not change if the container of the editor gets repositioned.
  5517. * Warning: the results of this method are inaccurate for positions that are outside the current editor viewport.
  5518. */
  5519. getScrolledVisiblePosition(position: IPosition): {
  5520. top: number;
  5521. left: number;
  5522. height: number;
  5523. } | null;
  5524. /**
  5525. * Apply the same font settings as the editor to `target`.
  5526. */
  5527. applyFontInfo(target: HTMLElement): void;
  5528. setBanner(bannerDomNode: HTMLElement | null, height: number): void;
  5529. }
  5530. /**
  5531. * Information about a line in the diff editor
  5532. */
  5533. export interface IDiffLineInformation {
  5534. readonly equivalentLineNumber: number;
  5535. }
  5536. /**
  5537. * A rich diff editor.
  5538. */
  5539. export interface IDiffEditor extends IEditor {
  5540. /**
  5541. * @see {@link ICodeEditor.getContainerDomNode}
  5542. */
  5543. getContainerDomNode(): HTMLElement;
  5544. /**
  5545. * An event emitted when the diff information computed by this diff editor has been updated.
  5546. * @event
  5547. */
  5548. readonly onDidUpdateDiff: IEvent<void>;
  5549. /**
  5550. * An event emitted when the diff model is changed (i.e. the diff editor shows new content).
  5551. * @event
  5552. */
  5553. readonly onDidChangeModel: IEvent<void>;
  5554. /**
  5555. * Saves current view state of the editor in a serializable object.
  5556. */
  5557. saveViewState(): IDiffEditorViewState | null;
  5558. /**
  5559. * Restores the view state of the editor from a serializable object generated by `saveViewState`.
  5560. */
  5561. restoreViewState(state: IDiffEditorViewState | null): void;
  5562. /**
  5563. * Type the getModel() of IEditor.
  5564. */
  5565. getModel(): IDiffEditorModel | null;
  5566. /**
  5567. * Sets the current model attached to this editor.
  5568. * If the previous model was created by the editor via the value key in the options
  5569. * literal object, it will be destroyed. Otherwise, if the previous model was set
  5570. * via setModel, or the model key in the options literal object, the previous model
  5571. * will not be destroyed.
  5572. * It is safe to call setModel(null) to simply detach the current model from the editor.
  5573. */
  5574. setModel(model: IDiffEditorModel | null): void;
  5575. /**
  5576. * Get the `original` editor.
  5577. */
  5578. getOriginalEditor(): ICodeEditor;
  5579. /**
  5580. * Get the `modified` editor.
  5581. */
  5582. getModifiedEditor(): ICodeEditor;
  5583. /**
  5584. * Get the computed diff information.
  5585. */
  5586. getLineChanges(): ILineChange[] | null;
  5587. /**
  5588. * Get information based on computed diff about a line number from the original model.
  5589. * If the diff computation is not finished or the model is missing, will return null.
  5590. */
  5591. getDiffLineInformationForOriginal(lineNumber: number): IDiffLineInformation | null;
  5592. /**
  5593. * Get information based on computed diff about a line number from the modified model.
  5594. * If the diff computation is not finished or the model is missing, will return null.
  5595. */
  5596. getDiffLineInformationForModified(lineNumber: number): IDiffLineInformation | null;
  5597. /**
  5598. * Update the editor's options after the editor has been created.
  5599. */
  5600. updateOptions(newOptions: IDiffEditorOptions): void;
  5601. }
  5602. export class FontInfo extends BareFontInfo {
  5603. readonly _editorStylingBrand: void;
  5604. readonly version: number;
  5605. readonly isTrusted: boolean;
  5606. readonly isMonospace: boolean;
  5607. readonly typicalHalfwidthCharacterWidth: number;
  5608. readonly typicalFullwidthCharacterWidth: number;
  5609. readonly canUseHalfwidthRightwardsArrow: boolean;
  5610. readonly spaceWidth: number;
  5611. readonly middotWidth: number;
  5612. readonly wsmiddotWidth: number;
  5613. readonly maxDigitWidth: number;
  5614. }
  5615. export class BareFontInfo {
  5616. readonly _bareFontInfoBrand: void;
  5617. readonly pixelRatio: number;
  5618. readonly fontFamily: string;
  5619. readonly fontWeight: string;
  5620. readonly fontSize: number;
  5621. readonly fontFeatureSettings: string;
  5622. readonly fontVariationSettings: string;
  5623. readonly lineHeight: number;
  5624. readonly letterSpacing: number;
  5625. }
  5626. export const EditorZoom: IEditorZoom;
  5627. export interface IEditorZoom {
  5628. onDidChangeZoomLevel: IEvent<number>;
  5629. getZoomLevel(): number;
  5630. setZoomLevel(zoomLevel: number): void;
  5631. }
  5632. //compatibility:
  5633. export type IReadOnlyModel = ITextModel;
  5634. export type IModel = ITextModel;
  5635. }
  5636. declare namespace monaco.languages {
  5637. export interface IRelativePattern {
  5638. /**
  5639. * A base file path to which this pattern will be matched against relatively.
  5640. */
  5641. readonly base: string;
  5642. /**
  5643. * A file glob pattern like `*.{ts,js}` that will be matched on file paths
  5644. * relative to the base path.
  5645. *
  5646. * Example: Given a base of `/home/work/folder` and a file path of `/home/work/folder/index.js`,
  5647. * the file glob pattern will match on `index.js`.
  5648. */
  5649. readonly pattern: string;
  5650. }
  5651. export type LanguageSelector = string | LanguageFilter | ReadonlyArray<string | LanguageFilter>;
  5652. export interface LanguageFilter {
  5653. readonly language?: string;
  5654. readonly scheme?: string;
  5655. readonly pattern?: string | IRelativePattern;
  5656. readonly notebookType?: string;
  5657. /**
  5658. * This provider is implemented in the UI thread.
  5659. */
  5660. readonly hasAccessToAllModels?: boolean;
  5661. readonly exclusive?: boolean;
  5662. }
  5663. /**
  5664. * Register information about a new language.
  5665. */
  5666. export function register(language: ILanguageExtensionPoint): void;
  5667. /**
  5668. * Get the information of all the registered languages.
  5669. */
  5670. export function getLanguages(): ILanguageExtensionPoint[];
  5671. export function getEncodedLanguageId(languageId: string): number;
  5672. /**
  5673. * An event emitted when a language is associated for the first time with a text model.
  5674. * @event
  5675. */
  5676. export function onLanguage(languageId: string, callback: () => void): IDisposable;
  5677. /**
  5678. * An event emitted when a language is associated for the first time with a text model or
  5679. * whena language is encountered during the tokenization of another language.
  5680. * @event
  5681. */
  5682. export function onLanguageEncountered(languageId: string, callback: () => void): IDisposable;
  5683. /**
  5684. * Set the editing configuration for a language.
  5685. */
  5686. export function setLanguageConfiguration(languageId: string, configuration: LanguageConfiguration): IDisposable;
  5687. /**
  5688. * A token.
  5689. */
  5690. export interface IToken {
  5691. startIndex: number;
  5692. scopes: string;
  5693. }
  5694. /**
  5695. * The result of a line tokenization.
  5696. */
  5697. export interface ILineTokens {
  5698. /**
  5699. * The list of tokens on the line.
  5700. */
  5701. tokens: IToken[];
  5702. /**
  5703. * The tokenization end state.
  5704. * A pointer will be held to this and the object should not be modified by the tokenizer after the pointer is returned.
  5705. */
  5706. endState: IState;
  5707. }
  5708. /**
  5709. * The result of a line tokenization.
  5710. */
  5711. export interface IEncodedLineTokens {
  5712. /**
  5713. * The tokens on the line in a binary, encoded format. Each token occupies two array indices. For token i:
  5714. * - at offset 2*i => startIndex
  5715. * - at offset 2*i + 1 => metadata
  5716. * Meta data is in binary format:
  5717. * - -------------------------------------------
  5718. * 3322 2222 2222 1111 1111 1100 0000 0000
  5719. * 1098 7654 3210 9876 5432 1098 7654 3210
  5720. * - -------------------------------------------
  5721. * bbbb bbbb bfff ffff ffFF FFTT LLLL LLLL
  5722. * - -------------------------------------------
  5723. * - L = EncodedLanguageId (8 bits): Use `getEncodedLanguageId` to get the encoded ID of a language.
  5724. * - T = StandardTokenType (2 bits): Other = 0, Comment = 1, String = 2, RegEx = 3.
  5725. * - F = FontStyle (4 bits): None = 0, Italic = 1, Bold = 2, Underline = 4, Strikethrough = 8.
  5726. * - f = foreground ColorId (9 bits)
  5727. * - b = background ColorId (9 bits)
  5728. * - The color value for each colorId is defined in IStandaloneThemeData.customTokenColors:
  5729. * e.g. colorId = 1 is stored in IStandaloneThemeData.customTokenColors[1]. Color id = 0 means no color,
  5730. * id = 1 is for the default foreground color, id = 2 for the default background.
  5731. */
  5732. tokens: Uint32Array;
  5733. /**
  5734. * The tokenization end state.
  5735. * A pointer will be held to this and the object should not be modified by the tokenizer after the pointer is returned.
  5736. */
  5737. endState: IState;
  5738. }
  5739. /**
  5740. * A factory for token providers.
  5741. */
  5742. export interface TokensProviderFactory {
  5743. create(): ProviderResult<TokensProvider | EncodedTokensProvider | IMonarchLanguage>;
  5744. }
  5745. /**
  5746. * A "manual" provider of tokens.
  5747. */
  5748. export interface TokensProvider {
  5749. /**
  5750. * The initial state of a language. Will be the state passed in to tokenize the first line.
  5751. */
  5752. getInitialState(): IState;
  5753. /**
  5754. * Tokenize a line given the state at the beginning of the line.
  5755. */
  5756. tokenize(line: string, state: IState): ILineTokens;
  5757. }
  5758. /**
  5759. * A "manual" provider of tokens, returning tokens in a binary form.
  5760. */
  5761. export interface EncodedTokensProvider {
  5762. /**
  5763. * The initial state of a language. Will be the state passed in to tokenize the first line.
  5764. */
  5765. getInitialState(): IState;
  5766. /**
  5767. * Tokenize a line given the state at the beginning of the line.
  5768. */
  5769. tokenizeEncoded(line: string, state: IState): IEncodedLineTokens;
  5770. /**
  5771. * Tokenize a line given the state at the beginning of the line.
  5772. */
  5773. tokenize?(line: string, state: IState): ILineTokens;
  5774. }
  5775. /**
  5776. * Change the color map that is used for token colors.
  5777. * Supported formats (hex): #RRGGBB, $RRGGBBAA, #RGB, #RGBA
  5778. */
  5779. export function setColorMap(colorMap: string[] | null): void;
  5780. /**
  5781. * Register a tokens provider factory for a language. This tokenizer will be exclusive with a tokenizer
  5782. * set using `setTokensProvider` or one created using `setMonarchTokensProvider`, but will work together
  5783. * with a tokens provider set using `registerDocumentSemanticTokensProvider` or `registerDocumentRangeSemanticTokensProvider`.
  5784. */
  5785. export function registerTokensProviderFactory(languageId: string, factory: TokensProviderFactory): IDisposable;
  5786. /**
  5787. * Set the tokens provider for a language (manual implementation). This tokenizer will be exclusive
  5788. * with a tokenizer created using `setMonarchTokensProvider`, or with `registerTokensProviderFactory`,
  5789. * but will work together with a tokens provider set using `registerDocumentSemanticTokensProvider`
  5790. * or `registerDocumentRangeSemanticTokensProvider`.
  5791. */
  5792. export function setTokensProvider(languageId: string, provider: TokensProvider | EncodedTokensProvider | Thenable<TokensProvider | EncodedTokensProvider>): IDisposable;
  5793. /**
  5794. * Set the tokens provider for a language (monarch implementation). This tokenizer will be exclusive
  5795. * with a tokenizer set using `setTokensProvider`, or with `registerTokensProviderFactory`, but will
  5796. * work together with a tokens provider set using `registerDocumentSemanticTokensProvider` or
  5797. * `registerDocumentRangeSemanticTokensProvider`.
  5798. */
  5799. export function setMonarchTokensProvider(languageId: string, languageDef: IMonarchLanguage | Thenable<IMonarchLanguage>): IDisposable;
  5800. /**
  5801. * Register a reference provider (used by e.g. reference search).
  5802. */
  5803. export function registerReferenceProvider(languageSelector: LanguageSelector, provider: ReferenceProvider): IDisposable;
  5804. /**
  5805. * Register a rename provider (used by e.g. rename symbol).
  5806. */
  5807. export function registerRenameProvider(languageSelector: LanguageSelector, provider: RenameProvider): IDisposable;
  5808. /**
  5809. * Register a signature help provider (used by e.g. parameter hints).
  5810. */
  5811. export function registerSignatureHelpProvider(languageSelector: LanguageSelector, provider: SignatureHelpProvider): IDisposable;
  5812. /**
  5813. * Register a hover provider (used by e.g. editor hover).
  5814. */
  5815. export function registerHoverProvider(languageSelector: LanguageSelector, provider: HoverProvider): IDisposable;
  5816. /**
  5817. * Register a document symbol provider (used by e.g. outline).
  5818. */
  5819. export function registerDocumentSymbolProvider(languageSelector: LanguageSelector, provider: DocumentSymbolProvider): IDisposable;
  5820. /**
  5821. * Register a document highlight provider (used by e.g. highlight occurrences).
  5822. */
  5823. export function registerDocumentHighlightProvider(languageSelector: LanguageSelector, provider: DocumentHighlightProvider): IDisposable;
  5824. /**
  5825. * Register an linked editing range provider.
  5826. */
  5827. export function registerLinkedEditingRangeProvider(languageSelector: LanguageSelector, provider: LinkedEditingRangeProvider): IDisposable;
  5828. /**
  5829. * Register a definition provider (used by e.g. go to definition).
  5830. */
  5831. export function registerDefinitionProvider(languageSelector: LanguageSelector, provider: DefinitionProvider): IDisposable;
  5832. /**
  5833. * Register a implementation provider (used by e.g. go to implementation).
  5834. */
  5835. export function registerImplementationProvider(languageSelector: LanguageSelector, provider: ImplementationProvider): IDisposable;
  5836. /**
  5837. * Register a type definition provider (used by e.g. go to type definition).
  5838. */
  5839. export function registerTypeDefinitionProvider(languageSelector: LanguageSelector, provider: TypeDefinitionProvider): IDisposable;
  5840. /**
  5841. * Register a code lens provider (used by e.g. inline code lenses).
  5842. */
  5843. export function registerCodeLensProvider(languageSelector: LanguageSelector, provider: CodeLensProvider): IDisposable;
  5844. /**
  5845. * Register a code action provider (used by e.g. quick fix).
  5846. */
  5847. export function registerCodeActionProvider(languageSelector: LanguageSelector, provider: CodeActionProvider, metadata?: CodeActionProviderMetadata): IDisposable;
  5848. /**
  5849. * Register a formatter that can handle only entire models.
  5850. */
  5851. export function registerDocumentFormattingEditProvider(languageSelector: LanguageSelector, provider: DocumentFormattingEditProvider): IDisposable;
  5852. /**
  5853. * Register a formatter that can handle a range inside a model.
  5854. */
  5855. export function registerDocumentRangeFormattingEditProvider(languageSelector: LanguageSelector, provider: DocumentRangeFormattingEditProvider): IDisposable;
  5856. /**
  5857. * Register a formatter than can do formatting as the user types.
  5858. */
  5859. export function registerOnTypeFormattingEditProvider(languageSelector: LanguageSelector, provider: OnTypeFormattingEditProvider): IDisposable;
  5860. /**
  5861. * Register a link provider that can find links in text.
  5862. */
  5863. export function registerLinkProvider(languageSelector: LanguageSelector, provider: LinkProvider): IDisposable;
  5864. /**
  5865. * Register a completion item provider (use by e.g. suggestions).
  5866. */
  5867. export function registerCompletionItemProvider(languageSelector: LanguageSelector, provider: CompletionItemProvider): IDisposable;
  5868. /**
  5869. * Register a document color provider (used by Color Picker, Color Decorator).
  5870. */
  5871. export function registerColorProvider(languageSelector: LanguageSelector, provider: DocumentColorProvider): IDisposable;
  5872. /**
  5873. * Register a folding range provider
  5874. */
  5875. export function registerFoldingRangeProvider(languageSelector: LanguageSelector, provider: FoldingRangeProvider): IDisposable;
  5876. /**
  5877. * Register a declaration provider
  5878. */
  5879. export function registerDeclarationProvider(languageSelector: LanguageSelector, provider: DeclarationProvider): IDisposable;
  5880. /**
  5881. * Register a selection range provider
  5882. */
  5883. export function registerSelectionRangeProvider(languageSelector: LanguageSelector, provider: SelectionRangeProvider): IDisposable;
  5884. /**
  5885. * Register a document semantic tokens provider. A semantic tokens provider will complement and enhance a
  5886. * simple top-down tokenizer. Simple top-down tokenizers can be set either via `setMonarchTokensProvider`
  5887. * or `setTokensProvider`.
  5888. *
  5889. * For the best user experience, register both a semantic tokens provider and a top-down tokenizer.
  5890. */
  5891. export function registerDocumentSemanticTokensProvider(languageSelector: LanguageSelector, provider: DocumentSemanticTokensProvider): IDisposable;
  5892. /**
  5893. * Register a document range semantic tokens provider. A semantic tokens provider will complement and enhance a
  5894. * simple top-down tokenizer. Simple top-down tokenizers can be set either via `setMonarchTokensProvider`
  5895. * or `setTokensProvider`.
  5896. *
  5897. * For the best user experience, register both a semantic tokens provider and a top-down tokenizer.
  5898. */
  5899. export function registerDocumentRangeSemanticTokensProvider(languageSelector: LanguageSelector, provider: DocumentRangeSemanticTokensProvider): IDisposable;
  5900. /**
  5901. * Register an inline completions provider.
  5902. */
  5903. export function registerInlineCompletionsProvider(languageSelector: LanguageSelector, provider: InlineCompletionsProvider): IDisposable;
  5904. /**
  5905. * Register an inlay hints provider.
  5906. */
  5907. export function registerInlayHintsProvider(languageSelector: LanguageSelector, provider: InlayHintsProvider): IDisposable;
  5908. /**
  5909. * Contains additional diagnostic information about the context in which
  5910. * a [code action](#CodeActionProvider.provideCodeActions) is run.
  5911. */
  5912. export interface CodeActionContext {
  5913. /**
  5914. * An array of diagnostics.
  5915. */
  5916. readonly markers: editor.IMarkerData[];
  5917. /**
  5918. * Requested kind of actions to return.
  5919. */
  5920. readonly only?: string;
  5921. /**
  5922. * The reason why code actions were requested.
  5923. */
  5924. readonly trigger: CodeActionTriggerType;
  5925. }
  5926. /**
  5927. * The code action interface defines the contract between extensions and
  5928. * the [light bulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
  5929. */
  5930. export interface CodeActionProvider {
  5931. /**
  5932. * Provide commands for the given document and range.
  5933. */
  5934. provideCodeActions(model: editor.ITextModel, range: Range, context: CodeActionContext, token: CancellationToken): ProviderResult<CodeActionList>;
  5935. /**
  5936. * Given a code action fill in the edit. Will only invoked when missing.
  5937. */
  5938. resolveCodeAction?(codeAction: CodeAction, token: CancellationToken): ProviderResult<CodeAction>;
  5939. }
  5940. /**
  5941. * Metadata about the type of code actions that a {@link CodeActionProvider} provides.
  5942. */
  5943. export interface CodeActionProviderMetadata {
  5944. /**
  5945. * List of code action kinds that a {@link CodeActionProvider} may return.
  5946. *
  5947. * This list is used to determine if a given `CodeActionProvider` should be invoked or not.
  5948. * To avoid unnecessary computation, every `CodeActionProvider` should list use `providedCodeActionKinds`. The
  5949. * list of kinds may either be generic, such as `["quickfix", "refactor", "source"]`, or list out every kind provided,
  5950. * such as `["quickfix.removeLine", "source.fixAll" ...]`.
  5951. */
  5952. readonly providedCodeActionKinds?: readonly string[];
  5953. readonly documentation?: ReadonlyArray<{
  5954. readonly kind: string;
  5955. readonly command: Command;
  5956. }>;
  5957. }
  5958. /**
  5959. * Describes how comments for a language work.
  5960. */
  5961. export interface CommentRule {
  5962. /**
  5963. * The line comment token, like `// this is a comment`
  5964. */
  5965. lineComment?: string | null;
  5966. /**
  5967. * The block comment character pair, like `/* block comment *&#47;`
  5968. */
  5969. blockComment?: CharacterPair | null;
  5970. }
  5971. /**
  5972. * The language configuration interface defines the contract between extensions and
  5973. * various editor features, like automatic bracket insertion, automatic indentation etc.
  5974. */
  5975. export interface LanguageConfiguration {
  5976. /**
  5977. * The language's comment settings.
  5978. */
  5979. comments?: CommentRule;
  5980. /**
  5981. * The language's brackets.
  5982. * This configuration implicitly affects pressing Enter around these brackets.
  5983. */
  5984. brackets?: CharacterPair[];
  5985. /**
  5986. * The language's word definition.
  5987. * If the language supports Unicode identifiers (e.g. JavaScript), it is preferable
  5988. * to provide a word definition that uses exclusion of known separators.
  5989. * e.g.: A regex that matches anything except known separators (and dot is allowed to occur in a floating point number):
  5990. * /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
  5991. */
  5992. wordPattern?: RegExp;
  5993. /**
  5994. * The language's indentation settings.
  5995. */
  5996. indentationRules?: IndentationRule;
  5997. /**
  5998. * The language's rules to be evaluated when pressing Enter.
  5999. */
  6000. onEnterRules?: OnEnterRule[];
  6001. /**
  6002. * The language's auto closing pairs. The 'close' character is automatically inserted with the
  6003. * 'open' character is typed. If not set, the configured brackets will be used.
  6004. */
  6005. autoClosingPairs?: IAutoClosingPairConditional[];
  6006. /**
  6007. * The language's surrounding pairs. When the 'open' character is typed on a selection, the
  6008. * selected string is surrounded by the open and close characters. If not set, the autoclosing pairs
  6009. * settings will be used.
  6010. */
  6011. surroundingPairs?: IAutoClosingPair[];
  6012. /**
  6013. * Defines a list of bracket pairs that are colorized depending on their nesting level.
  6014. * If not set, the configured brackets will be used.
  6015. */
  6016. colorizedBracketPairs?: CharacterPair[];
  6017. /**
  6018. * Defines what characters must be after the cursor for bracket or quote autoclosing to occur when using the \'languageDefined\' autoclosing setting.
  6019. *
  6020. * This is typically the set of characters which can not start an expression, such as whitespace, closing brackets, non-unary operators, etc.
  6021. */
  6022. autoCloseBefore?: string;
  6023. /**
  6024. * The language's folding rules.
  6025. */
  6026. folding?: FoldingRules;
  6027. /**
  6028. * **Deprecated** Do not use.
  6029. *
  6030. * @deprecated Will be replaced by a better API soon.
  6031. */
  6032. __electricCharacterSupport?: {
  6033. docComment?: IDocComment;
  6034. };
  6035. }
  6036. /**
  6037. * Describes indentation rules for a language.
  6038. */
  6039. export interface IndentationRule {
  6040. /**
  6041. * If a line matches this pattern, then all the lines after it should be unindented once (until another rule matches).
  6042. */
  6043. decreaseIndentPattern: RegExp;
  6044. /**
  6045. * If a line matches this pattern, then all the lines after it should be indented once (until another rule matches).
  6046. */
  6047. increaseIndentPattern: RegExp;
  6048. /**
  6049. * If a line matches this pattern, then **only the next line** after it should be indented once.
  6050. */
  6051. indentNextLinePattern?: RegExp | null;
  6052. /**
  6053. * If a line matches this pattern, then its indentation should not be changed and it should not be evaluated against the other rules.
  6054. */
  6055. unIndentedLinePattern?: RegExp | null;
  6056. }
  6057. /**
  6058. * Describes language specific folding markers such as '#region' and '#endregion'.
  6059. * The start and end regexes will be tested against the contents of all lines and must be designed efficiently:
  6060. * - the regex should start with '^'
  6061. * - regexp flags (i, g) are ignored
  6062. */
  6063. export interface FoldingMarkers {
  6064. start: RegExp;
  6065. end: RegExp;
  6066. }
  6067. /**
  6068. * Describes folding rules for a language.
  6069. */
  6070. export interface FoldingRules {
  6071. /**
  6072. * Used by the indentation based strategy to decide whether empty lines belong to the previous or the next block.
  6073. * A language adheres to the off-side rule if blocks in that language are expressed by their indentation.
  6074. * See [wikipedia](https://en.wikipedia.org/wiki/Off-side_rule) for more information.
  6075. * If not set, `false` is used and empty lines belong to the previous block.
  6076. */
  6077. offSide?: boolean;
  6078. /**
  6079. * Region markers used by the language.
  6080. */
  6081. markers?: FoldingMarkers;
  6082. }
  6083. /**
  6084. * Describes a rule to be evaluated when pressing Enter.
  6085. */
  6086. export interface OnEnterRule {
  6087. /**
  6088. * This rule will only execute if the text before the cursor matches this regular expression.
  6089. */
  6090. beforeText: RegExp;
  6091. /**
  6092. * This rule will only execute if the text after the cursor matches this regular expression.
  6093. */
  6094. afterText?: RegExp;
  6095. /**
  6096. * This rule will only execute if the text above the this line matches this regular expression.
  6097. */
  6098. previousLineText?: RegExp;
  6099. /**
  6100. * The action to execute.
  6101. */
  6102. action: EnterAction;
  6103. }
  6104. /**
  6105. * Definition of documentation comments (e.g. Javadoc/JSdoc)
  6106. */
  6107. export interface IDocComment {
  6108. /**
  6109. * The string that starts a doc comment (e.g. '/**')
  6110. */
  6111. open: string;
  6112. /**
  6113. * The string that appears on the last line and closes the doc comment (e.g. ' * /').
  6114. */
  6115. close?: string;
  6116. }
  6117. /**
  6118. * A tuple of two characters, like a pair of
  6119. * opening and closing brackets.
  6120. */
  6121. export type CharacterPair = [string, string];
  6122. export interface IAutoClosingPair {
  6123. open: string;
  6124. close: string;
  6125. }
  6126. export interface IAutoClosingPairConditional extends IAutoClosingPair {
  6127. notIn?: string[];
  6128. }
  6129. /**
  6130. * Describes what to do with the indentation when pressing Enter.
  6131. */
  6132. export enum IndentAction {
  6133. /**
  6134. * Insert new line and copy the previous line's indentation.
  6135. */
  6136. None = 0,
  6137. /**
  6138. * Insert new line and indent once (relative to the previous line's indentation).
  6139. */
  6140. Indent = 1,
  6141. /**
  6142. * Insert two new lines:
  6143. * - the first one indented which will hold the cursor
  6144. * - the second one at the same indentation level
  6145. */
  6146. IndentOutdent = 2,
  6147. /**
  6148. * Insert new line and outdent once (relative to the previous line's indentation).
  6149. */
  6150. Outdent = 3
  6151. }
  6152. /**
  6153. * Describes what to do when pressing Enter.
  6154. */
  6155. export interface EnterAction {
  6156. /**
  6157. * Describe what to do with the indentation.
  6158. */
  6159. indentAction: IndentAction;
  6160. /**
  6161. * Describes text to be appended after the new line and after the indentation.
  6162. */
  6163. appendText?: string;
  6164. /**
  6165. * Describes the number of characters to remove from the new line's indentation.
  6166. */
  6167. removeText?: number;
  6168. }
  6169. /**
  6170. * The state of the tokenizer between two lines.
  6171. * It is useful to store flags such as in multiline comment, etc.
  6172. * The model will clone the previous line's state and pass it in to tokenize the next line.
  6173. */
  6174. export interface IState {
  6175. clone(): IState;
  6176. equals(other: IState): boolean;
  6177. }
  6178. /**
  6179. * A provider result represents the values a provider, like the {@link HoverProvider},
  6180. * may return. For once this is the actual result type `T`, like `Hover`, or a thenable that resolves
  6181. * to that type `T`. In addition, `null` and `undefined` can be returned - either directly or from a
  6182. * thenable.
  6183. */
  6184. export type ProviderResult<T> = T | undefined | null | Thenable<T | undefined | null>;
  6185. /**
  6186. * A hover represents additional information for a symbol or word. Hovers are
  6187. * rendered in a tooltip-like widget.
  6188. */
  6189. export interface Hover {
  6190. /**
  6191. * The contents of this hover.
  6192. */
  6193. contents: IMarkdownString[];
  6194. /**
  6195. * The range to which this hover applies. When missing, the
  6196. * editor will use the range at the current position or the
  6197. * current position itself.
  6198. */
  6199. range?: IRange;
  6200. }
  6201. /**
  6202. * The hover provider interface defines the contract between extensions and
  6203. * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
  6204. */
  6205. export interface HoverProvider {
  6206. /**
  6207. * Provide a hover for the given position and document. Multiple hovers at the same
  6208. * position will be merged by the editor. A hover can have a range which defaults
  6209. * to the word range at the position when omitted.
  6210. */
  6211. provideHover(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult<Hover>;
  6212. }
  6213. export enum CompletionItemKind {
  6214. Method = 0,
  6215. Function = 1,
  6216. Constructor = 2,
  6217. Field = 3,
  6218. Variable = 4,
  6219. Class = 5,
  6220. Struct = 6,
  6221. Interface = 7,
  6222. Module = 8,
  6223. Property = 9,
  6224. Event = 10,
  6225. Operator = 11,
  6226. Unit = 12,
  6227. Value = 13,
  6228. Constant = 14,
  6229. Enum = 15,
  6230. EnumMember = 16,
  6231. Keyword = 17,
  6232. Text = 18,
  6233. Color = 19,
  6234. File = 20,
  6235. Reference = 21,
  6236. Customcolor = 22,
  6237. Folder = 23,
  6238. TypeParameter = 24,
  6239. User = 25,
  6240. Issue = 26,
  6241. Snippet = 27
  6242. }
  6243. export interface CompletionItemLabel {
  6244. label: string;
  6245. detail?: string;
  6246. description?: string;
  6247. }
  6248. export enum CompletionItemTag {
  6249. Deprecated = 1
  6250. }
  6251. export enum CompletionItemInsertTextRule {
  6252. None = 0,
  6253. /**
  6254. * Adjust whitespace/indentation of multiline insert texts to
  6255. * match the current line indentation.
  6256. */
  6257. KeepWhitespace = 1,
  6258. /**
  6259. * `insertText` is a snippet.
  6260. */
  6261. InsertAsSnippet = 4
  6262. }
  6263. export interface CompletionItemRanges {
  6264. insert: IRange;
  6265. replace: IRange;
  6266. }
  6267. /**
  6268. * A completion item represents a text snippet that is
  6269. * proposed to complete text that is being typed.
  6270. */
  6271. export interface CompletionItem {
  6272. /**
  6273. * The label of this completion item. By default
  6274. * this is also the text that is inserted when selecting
  6275. * this completion.
  6276. */
  6277. label: string | CompletionItemLabel;
  6278. /**
  6279. * The kind of this completion item. Based on the kind
  6280. * an icon is chosen by the editor.
  6281. */
  6282. kind: CompletionItemKind;
  6283. /**
  6284. * A modifier to the `kind` which affect how the item
  6285. * is rendered, e.g. Deprecated is rendered with a strikeout
  6286. */
  6287. tags?: ReadonlyArray<CompletionItemTag>;
  6288. /**
  6289. * A human-readable string with additional information
  6290. * about this item, like type or symbol information.
  6291. */
  6292. detail?: string;
  6293. /**
  6294. * A human-readable string that represents a doc-comment.
  6295. */
  6296. documentation?: string | IMarkdownString;
  6297. /**
  6298. * A string that should be used when comparing this item
  6299. * with other items. When `falsy` the {@link CompletionItem.label label}
  6300. * is used.
  6301. */
  6302. sortText?: string;
  6303. /**
  6304. * A string that should be used when filtering a set of
  6305. * completion items. When `falsy` the {@link CompletionItem.label label}
  6306. * is used.
  6307. */
  6308. filterText?: string;
  6309. /**
  6310. * Select this item when showing. *Note* that only one completion item can be selected and
  6311. * that the editor decides which item that is. The rule is that the *first* item of those
  6312. * that match best is selected.
  6313. */
  6314. preselect?: boolean;
  6315. /**
  6316. * A string or snippet that should be inserted in a document when selecting
  6317. * this completion.
  6318. */
  6319. insertText: string;
  6320. /**
  6321. * Additional rules (as bitmask) that should be applied when inserting
  6322. * this completion.
  6323. */
  6324. insertTextRules?: CompletionItemInsertTextRule;
  6325. /**
  6326. * A range of text that should be replaced by this completion item.
  6327. *
  6328. * Defaults to a range from the start of the {@link TextDocument.getWordRangeAtPosition current word} to the
  6329. * current position.
  6330. *
  6331. * *Note:* The range must be a {@link Range.isSingleLine single line} and it must
  6332. * {@link Range.contains contain} the position at which completion has been {@link CompletionItemProvider.provideCompletionItems requested}.
  6333. */
  6334. range: IRange | CompletionItemRanges;
  6335. /**
  6336. * An optional set of characters that when pressed while this completion is active will accept it first and
  6337. * then type that character. *Note* that all commit characters should have `length=1` and that superfluous
  6338. * characters will be ignored.
  6339. */
  6340. commitCharacters?: string[];
  6341. /**
  6342. * An optional array of additional text edits that are applied when
  6343. * selecting this completion. Edits must not overlap with the main edit
  6344. * nor with themselves.
  6345. */
  6346. additionalTextEdits?: editor.ISingleEditOperation[];
  6347. /**
  6348. * A command that should be run upon acceptance of this item.
  6349. */
  6350. command?: Command;
  6351. }
  6352. export interface CompletionList {
  6353. suggestions: CompletionItem[];
  6354. incomplete?: boolean;
  6355. dispose?(): void;
  6356. }
  6357. /**
  6358. * How a suggest provider was triggered.
  6359. */
  6360. export enum CompletionTriggerKind {
  6361. Invoke = 0,
  6362. TriggerCharacter = 1,
  6363. TriggerForIncompleteCompletions = 2
  6364. }
  6365. /**
  6366. * Contains additional information about the context in which
  6367. * {@link CompletionItemProvider.provideCompletionItems completion provider} is triggered.
  6368. */
  6369. export interface CompletionContext {
  6370. /**
  6371. * How the completion was triggered.
  6372. */
  6373. triggerKind: CompletionTriggerKind;
  6374. /**
  6375. * Character that triggered the completion item provider.
  6376. *
  6377. * `undefined` if provider was not triggered by a character.
  6378. */
  6379. triggerCharacter?: string;
  6380. }
  6381. /**
  6382. * The completion item provider interface defines the contract between extensions and
  6383. * the [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense).
  6384. *
  6385. * When computing *complete* completion items is expensive, providers can optionally implement
  6386. * the `resolveCompletionItem`-function. In that case it is enough to return completion
  6387. * items with a {@link CompletionItem.label label} from the
  6388. * {@link CompletionItemProvider.provideCompletionItems provideCompletionItems}-function. Subsequently,
  6389. * when a completion item is shown in the UI and gains focus this provider is asked to resolve
  6390. * the item, like adding {@link CompletionItem.documentation doc-comment} or {@link CompletionItem.detail details}.
  6391. */
  6392. export interface CompletionItemProvider {
  6393. triggerCharacters?: string[];
  6394. /**
  6395. * Provide completion items for the given position and document.
  6396. */
  6397. provideCompletionItems(model: editor.ITextModel, position: Position, context: CompletionContext, token: CancellationToken): ProviderResult<CompletionList>;
  6398. /**
  6399. * Given a completion item fill in more data, like {@link CompletionItem.documentation doc-comment}
  6400. * or {@link CompletionItem.detail details}.
  6401. *
  6402. * The editor will only resolve a completion item once.
  6403. */
  6404. resolveCompletionItem?(item: CompletionItem, token: CancellationToken): ProviderResult<CompletionItem>;
  6405. }
  6406. /**
  6407. * How an {@link InlineCompletionsProvider inline completion provider} was triggered.
  6408. */
  6409. export enum InlineCompletionTriggerKind {
  6410. /**
  6411. * Completion was triggered automatically while editing.
  6412. * It is sufficient to return a single completion item in this case.
  6413. */
  6414. Automatic = 0,
  6415. /**
  6416. * Completion was triggered explicitly by a user gesture.
  6417. * Return multiple completion items to enable cycling through them.
  6418. */
  6419. Explicit = 1
  6420. }
  6421. export interface InlineCompletionContext {
  6422. /**
  6423. * How the completion was triggered.
  6424. */
  6425. readonly triggerKind: InlineCompletionTriggerKind;
  6426. readonly selectedSuggestionInfo: SelectedSuggestionInfo | undefined;
  6427. }
  6428. export interface SelectedSuggestionInfo {
  6429. range: IRange;
  6430. text: string;
  6431. isSnippetText: boolean;
  6432. completionKind: CompletionItemKind;
  6433. }
  6434. export interface InlineCompletion {
  6435. /**
  6436. * The text to insert.
  6437. * If the text contains a line break, the range must end at the end of a line.
  6438. * If existing text should be replaced, the existing text must be a prefix of the text to insert.
  6439. *
  6440. * The text can also be a snippet. In that case, a preview with default parameters is shown.
  6441. * When accepting the suggestion, the full snippet is inserted.
  6442. */
  6443. readonly insertText: string | {
  6444. snippet: string;
  6445. };
  6446. /**
  6447. * A text that is used to decide if this inline completion should be shown.
  6448. * An inline completion is shown if the text to replace is a subword of the filter text.
  6449. */
  6450. readonly filterText?: string;
  6451. /**
  6452. * An optional array of additional text edits that are applied when
  6453. * selecting this completion. Edits must not overlap with the main edit
  6454. * nor with themselves.
  6455. */
  6456. readonly additionalTextEdits?: editor.ISingleEditOperation[];
  6457. /**
  6458. * The range to replace.
  6459. * Must begin and end on the same line.
  6460. */
  6461. readonly range?: IRange;
  6462. readonly command?: Command;
  6463. /**
  6464. * If set to `true`, unopened closing brackets are removed and unclosed opening brackets are closed.
  6465. * Defaults to `false`.
  6466. */
  6467. readonly completeBracketPairs?: boolean;
  6468. }
  6469. export interface InlineCompletions<TItem extends InlineCompletion = InlineCompletion> {
  6470. readonly items: readonly TItem[];
  6471. /**
  6472. * A list of commands associated with the inline completions of this list.
  6473. */
  6474. readonly commands?: Command[];
  6475. }
  6476. export interface InlineCompletionsProvider<T extends InlineCompletions = InlineCompletions> {
  6477. provideInlineCompletions(model: editor.ITextModel, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<T>;
  6478. /**
  6479. * Will be called when an item is shown.
  6480. */
  6481. handleItemDidShow?(completions: T, item: T['items'][number]): void;
  6482. /**
  6483. * Will be called when an item is partially accepted.
  6484. */
  6485. handlePartialAccept?(completions: T, item: T['items'][number], acceptedCharacters: number): void;
  6486. /**
  6487. * Will be called when a completions list is no longer in use and can be garbage-collected.
  6488. */
  6489. freeInlineCompletions(completions: T): void;
  6490. }
  6491. export interface CodeAction {
  6492. title: string;
  6493. command?: Command;
  6494. edit?: WorkspaceEdit;
  6495. diagnostics?: editor.IMarkerData[];
  6496. kind?: string;
  6497. isPreferred?: boolean;
  6498. disabled?: string;
  6499. }
  6500. export enum CodeActionTriggerType {
  6501. Invoke = 1,
  6502. Auto = 2
  6503. }
  6504. export interface CodeActionList extends IDisposable {
  6505. readonly actions: ReadonlyArray<CodeAction>;
  6506. }
  6507. /**
  6508. * Represents a parameter of a callable-signature. A parameter can
  6509. * have a label and a doc-comment.
  6510. */
  6511. export interface ParameterInformation {
  6512. /**
  6513. * The label of this signature. Will be shown in
  6514. * the UI.
  6515. */
  6516. label: string | [number, number];
  6517. /**
  6518. * The human-readable doc-comment of this signature. Will be shown
  6519. * in the UI but can be omitted.
  6520. */
  6521. documentation?: string | IMarkdownString;
  6522. }
  6523. /**
  6524. * Represents the signature of something callable. A signature
  6525. * can have a label, like a function-name, a doc-comment, and
  6526. * a set of parameters.
  6527. */
  6528. export interface SignatureInformation {
  6529. /**
  6530. * The label of this signature. Will be shown in
  6531. * the UI.
  6532. */
  6533. label: string;
  6534. /**
  6535. * The human-readable doc-comment of this signature. Will be shown
  6536. * in the UI but can be omitted.
  6537. */
  6538. documentation?: string | IMarkdownString;
  6539. /**
  6540. * The parameters of this signature.
  6541. */
  6542. parameters: ParameterInformation[];
  6543. /**
  6544. * Index of the active parameter.
  6545. *
  6546. * If provided, this is used in place of `SignatureHelp.activeSignature`.
  6547. */
  6548. activeParameter?: number;
  6549. }
  6550. /**
  6551. * Signature help represents the signature of something
  6552. * callable. There can be multiple signatures but only one
  6553. * active and only one active parameter.
  6554. */
  6555. export interface SignatureHelp {
  6556. /**
  6557. * One or more signatures.
  6558. */
  6559. signatures: SignatureInformation[];
  6560. /**
  6561. * The active signature.
  6562. */
  6563. activeSignature: number;
  6564. /**
  6565. * The active parameter of the active signature.
  6566. */
  6567. activeParameter: number;
  6568. }
  6569. export interface SignatureHelpResult extends IDisposable {
  6570. value: SignatureHelp;
  6571. }
  6572. export enum SignatureHelpTriggerKind {
  6573. Invoke = 1,
  6574. TriggerCharacter = 2,
  6575. ContentChange = 3
  6576. }
  6577. export interface SignatureHelpContext {
  6578. readonly triggerKind: SignatureHelpTriggerKind;
  6579. readonly triggerCharacter?: string;
  6580. readonly isRetrigger: boolean;
  6581. readonly activeSignatureHelp?: SignatureHelp;
  6582. }
  6583. /**
  6584. * The signature help provider interface defines the contract between extensions and
  6585. * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature.
  6586. */
  6587. export interface SignatureHelpProvider {
  6588. readonly signatureHelpTriggerCharacters?: ReadonlyArray<string>;
  6589. readonly signatureHelpRetriggerCharacters?: ReadonlyArray<string>;
  6590. /**
  6591. * Provide help for the signature at the given position and document.
  6592. */
  6593. provideSignatureHelp(model: editor.ITextModel, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult<SignatureHelpResult>;
  6594. }
  6595. /**
  6596. * A document highlight kind.
  6597. */
  6598. export enum DocumentHighlightKind {
  6599. /**
  6600. * A textual occurrence.
  6601. */
  6602. Text = 0,
  6603. /**
  6604. * Read-access of a symbol, like reading a variable.
  6605. */
  6606. Read = 1,
  6607. /**
  6608. * Write-access of a symbol, like writing to a variable.
  6609. */
  6610. Write = 2
  6611. }
  6612. /**
  6613. * A document highlight is a range inside a text document which deserves
  6614. * special attention. Usually a document highlight is visualized by changing
  6615. * the background color of its range.
  6616. */
  6617. export interface DocumentHighlight {
  6618. /**
  6619. * The range this highlight applies to.
  6620. */
  6621. range: IRange;
  6622. /**
  6623. * The highlight kind, default is {@link DocumentHighlightKind.Text text}.
  6624. */
  6625. kind?: DocumentHighlightKind;
  6626. }
  6627. /**
  6628. * The document highlight provider interface defines the contract between extensions and
  6629. * the word-highlight-feature.
  6630. */
  6631. export interface DocumentHighlightProvider {
  6632. /**
  6633. * Provide a set of document highlights, like all occurrences of a variable or
  6634. * all exit-points of a function.
  6635. */
  6636. provideDocumentHighlights(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>;
  6637. }
  6638. /**
  6639. * The linked editing range provider interface defines the contract between extensions and
  6640. * the linked editing feature.
  6641. */
  6642. export interface LinkedEditingRangeProvider {
  6643. /**
  6644. * Provide a list of ranges that can be edited together.
  6645. */
  6646. provideLinkedEditingRanges(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>;
  6647. }
  6648. /**
  6649. * Represents a list of ranges that can be edited together along with a word pattern to describe valid contents.
  6650. */
  6651. export interface LinkedEditingRanges {
  6652. /**
  6653. * A list of ranges that can be edited together. The ranges must have
  6654. * identical length and text content. The ranges cannot overlap
  6655. */
  6656. ranges: IRange[];
  6657. /**
  6658. * An optional word pattern that describes valid contents for the given ranges.
  6659. * If no pattern is provided, the language configuration's word pattern will be used.
  6660. */
  6661. wordPattern?: RegExp;
  6662. }
  6663. /**
  6664. * Value-object that contains additional information when
  6665. * requesting references.
  6666. */
  6667. export interface ReferenceContext {
  6668. /**
  6669. * Include the declaration of the current symbol.
  6670. */
  6671. includeDeclaration: boolean;
  6672. }
  6673. /**
  6674. * The reference provider interface defines the contract between extensions and
  6675. * the [find references](https://code.visualstudio.com/docs/editor/editingevolved#_peek)-feature.
  6676. */
  6677. export interface ReferenceProvider {
  6678. /**
  6679. * Provide a set of project-wide references for the given position and document.
  6680. */
  6681. provideReferences(model: editor.ITextModel, position: Position, context: ReferenceContext, token: CancellationToken): ProviderResult<Location[]>;
  6682. }
  6683. /**
  6684. * Represents a location inside a resource, such as a line
  6685. * inside a text file.
  6686. */
  6687. export interface Location {
  6688. /**
  6689. * The resource identifier of this location.
  6690. */
  6691. uri: Uri;
  6692. /**
  6693. * The document range of this locations.
  6694. */
  6695. range: IRange;
  6696. }
  6697. export interface LocationLink {
  6698. /**
  6699. * A range to select where this link originates from.
  6700. */
  6701. originSelectionRange?: IRange;
  6702. /**
  6703. * The target uri this link points to.
  6704. */
  6705. uri: Uri;
  6706. /**
  6707. * The full range this link points to.
  6708. */
  6709. range: IRange;
  6710. /**
  6711. * A range to select this link points to. Must be contained
  6712. * in `LocationLink.range`.
  6713. */
  6714. targetSelectionRange?: IRange;
  6715. }
  6716. export type Definition = Location | Location[] | LocationLink[];
  6717. /**
  6718. * The definition provider interface defines the contract between extensions and
  6719. * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
  6720. * and peek definition features.
  6721. */
  6722. export interface DefinitionProvider {
  6723. /**
  6724. * Provide the definition of the symbol at the given position and document.
  6725. */
  6726. provideDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>;
  6727. }
  6728. /**
  6729. * The definition provider interface defines the contract between extensions and
  6730. * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
  6731. * and peek definition features.
  6732. */
  6733. export interface DeclarationProvider {
  6734. /**
  6735. * Provide the declaration of the symbol at the given position and document.
  6736. */
  6737. provideDeclaration(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>;
  6738. }
  6739. /**
  6740. * The implementation provider interface defines the contract between extensions and
  6741. * the go to implementation feature.
  6742. */
  6743. export interface ImplementationProvider {
  6744. /**
  6745. * Provide the implementation of the symbol at the given position and document.
  6746. */
  6747. provideImplementation(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>;
  6748. }
  6749. /**
  6750. * The type definition provider interface defines the contract between extensions and
  6751. * the go to type definition feature.
  6752. */
  6753. export interface TypeDefinitionProvider {
  6754. /**
  6755. * Provide the type definition of the symbol at the given position and document.
  6756. */
  6757. provideTypeDefinition(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult<Definition | LocationLink[]>;
  6758. }
  6759. /**
  6760. * A symbol kind.
  6761. */
  6762. export enum SymbolKind {
  6763. File = 0,
  6764. Module = 1,
  6765. Namespace = 2,
  6766. Package = 3,
  6767. Class = 4,
  6768. Method = 5,
  6769. Property = 6,
  6770. Field = 7,
  6771. Constructor = 8,
  6772. Enum = 9,
  6773. Interface = 10,
  6774. Function = 11,
  6775. Variable = 12,
  6776. Constant = 13,
  6777. String = 14,
  6778. Number = 15,
  6779. Boolean = 16,
  6780. Array = 17,
  6781. Object = 18,
  6782. Key = 19,
  6783. Null = 20,
  6784. EnumMember = 21,
  6785. Struct = 22,
  6786. Event = 23,
  6787. Operator = 24,
  6788. TypeParameter = 25
  6789. }
  6790. export enum SymbolTag {
  6791. Deprecated = 1
  6792. }
  6793. export interface DocumentSymbol {
  6794. name: string;
  6795. detail: string;
  6796. kind: SymbolKind;
  6797. tags: ReadonlyArray<SymbolTag>;
  6798. containerName?: string;
  6799. range: IRange;
  6800. selectionRange: IRange;
  6801. children?: DocumentSymbol[];
  6802. }
  6803. /**
  6804. * The document symbol provider interface defines the contract between extensions and
  6805. * the [go to symbol](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-symbol)-feature.
  6806. */
  6807. export interface DocumentSymbolProvider {
  6808. displayName?: string;
  6809. /**
  6810. * Provide symbol information for the given document.
  6811. */
  6812. provideDocumentSymbols(model: editor.ITextModel, token: CancellationToken): ProviderResult<DocumentSymbol[]>;
  6813. }
  6814. export interface TextEdit {
  6815. range: IRange;
  6816. text: string;
  6817. eol?: editor.EndOfLineSequence;
  6818. }
  6819. /**
  6820. * Interface used to format a model
  6821. */
  6822. export interface FormattingOptions {
  6823. /**
  6824. * Size of a tab in spaces.
  6825. */
  6826. tabSize: number;
  6827. /**
  6828. * Prefer spaces over tabs.
  6829. */
  6830. insertSpaces: boolean;
  6831. /**
  6832. * The list of multiple ranges to format at once, if the provider supports it.
  6833. */
  6834. ranges?: Range[];
  6835. }
  6836. /**
  6837. * The document formatting provider interface defines the contract between extensions and
  6838. * the formatting-feature.
  6839. */
  6840. export interface DocumentFormattingEditProvider {
  6841. readonly displayName?: string;
  6842. /**
  6843. * Provide formatting edits for a whole document.
  6844. */
  6845. provideDocumentFormattingEdits(model: editor.ITextModel, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
  6846. }
  6847. /**
  6848. * The document formatting provider interface defines the contract between extensions and
  6849. * the formatting-feature.
  6850. */
  6851. export interface DocumentRangeFormattingEditProvider {
  6852. readonly displayName?: string;
  6853. readonly canFormatMultipleRanges: boolean;
  6854. /**
  6855. * Provide formatting edits for a range in a document.
  6856. *
  6857. * The given range is a hint and providers can decide to format a smaller
  6858. * or larger range. Often this is done by adjusting the start and end
  6859. * of the range to full syntax nodes.
  6860. */
  6861. provideDocumentRangeFormattingEdits(model: editor.ITextModel, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
  6862. }
  6863. /**
  6864. * The document formatting provider interface defines the contract between extensions and
  6865. * the formatting-feature.
  6866. */
  6867. export interface OnTypeFormattingEditProvider {
  6868. autoFormatTriggerCharacters: string[];
  6869. /**
  6870. * Provide formatting edits after a character has been typed.
  6871. *
  6872. * The given position and character should hint to the provider
  6873. * what range the position to expand to, like find the matching `{`
  6874. * when `}` has been entered.
  6875. */
  6876. provideOnTypeFormattingEdits(model: editor.ITextModel, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
  6877. }
  6878. /**
  6879. * A link inside the editor.
  6880. */
  6881. export interface ILink {
  6882. range: IRange;
  6883. url?: Uri | string;
  6884. tooltip?: string;
  6885. }
  6886. export interface ILinksList {
  6887. links: ILink[];
  6888. dispose?(): void;
  6889. }
  6890. /**
  6891. * A provider of links.
  6892. */
  6893. export interface LinkProvider {
  6894. provideLinks(model: editor.ITextModel, token: CancellationToken): ProviderResult<ILinksList>;
  6895. resolveLink?: (link: ILink, token: CancellationToken) => ProviderResult<ILink>;
  6896. }
  6897. /**
  6898. * A color in RGBA format.
  6899. */
  6900. export interface IColor {
  6901. /**
  6902. * The red component in the range [0-1].
  6903. */
  6904. readonly red: number;
  6905. /**
  6906. * The green component in the range [0-1].
  6907. */
  6908. readonly green: number;
  6909. /**
  6910. * The blue component in the range [0-1].
  6911. */
  6912. readonly blue: number;
  6913. /**
  6914. * The alpha component in the range [0-1].
  6915. */
  6916. readonly alpha: number;
  6917. }
  6918. /**
  6919. * String representations for a color
  6920. */
  6921. export interface IColorPresentation {
  6922. /**
  6923. * The label of this color presentation. It will be shown on the color
  6924. * picker header. By default this is also the text that is inserted when selecting
  6925. * this color presentation.
  6926. */
  6927. label: string;
  6928. /**
  6929. * An {@link TextEdit edit} which is applied to a document when selecting
  6930. * this presentation for the color.
  6931. */
  6932. textEdit?: TextEdit;
  6933. /**
  6934. * An optional array of additional {@link TextEdit text edits} that are applied when
  6935. * selecting this color presentation.
  6936. */
  6937. additionalTextEdits?: TextEdit[];
  6938. }
  6939. /**
  6940. * A color range is a range in a text model which represents a color.
  6941. */
  6942. export interface IColorInformation {
  6943. /**
  6944. * The range within the model.
  6945. */
  6946. range: IRange;
  6947. /**
  6948. * The color represented in this range.
  6949. */
  6950. color: IColor;
  6951. }
  6952. /**
  6953. * A provider of colors for editor models.
  6954. */
  6955. export interface DocumentColorProvider {
  6956. /**
  6957. * Provides the color ranges for a specific model.
  6958. */
  6959. provideDocumentColors(model: editor.ITextModel, token: CancellationToken): ProviderResult<IColorInformation[]>;
  6960. /**
  6961. * Provide the string representations for a color.
  6962. */
  6963. provideColorPresentations(model: editor.ITextModel, colorInfo: IColorInformation, token: CancellationToken): ProviderResult<IColorPresentation[]>;
  6964. }
  6965. export interface SelectionRange {
  6966. range: IRange;
  6967. }
  6968. export interface SelectionRangeProvider {
  6969. /**
  6970. * Provide ranges that should be selected from the given position.
  6971. */
  6972. provideSelectionRanges(model: editor.ITextModel, positions: Position[], token: CancellationToken): ProviderResult<SelectionRange[][]>;
  6973. }
  6974. export interface FoldingContext {
  6975. }
  6976. /**
  6977. * A provider of folding ranges for editor models.
  6978. */
  6979. export interface FoldingRangeProvider {
  6980. /**
  6981. * An optional event to signal that the folding ranges from this provider have changed.
  6982. */
  6983. onDidChange?: IEvent<this>;
  6984. /**
  6985. * Provides the folding ranges for a specific model.
  6986. */
  6987. provideFoldingRanges(model: editor.ITextModel, context: FoldingContext, token: CancellationToken): ProviderResult<FoldingRange[]>;
  6988. }
  6989. export interface FoldingRange {
  6990. /**
  6991. * The one-based start line of the range to fold. The folded area starts after the line's last character.
  6992. */
  6993. start: number;
  6994. /**
  6995. * The one-based end line of the range to fold. The folded area ends with the line's last character.
  6996. */
  6997. end: number;
  6998. /**
  6999. * Describes the {@link FoldingRangeKind Kind} of the folding range such as {@link FoldingRangeKind.Comment Comment} or
  7000. * {@link FoldingRangeKind.Region Region}. The kind is used to categorize folding ranges and used by commands
  7001. * like 'Fold all comments'. See
  7002. * {@link FoldingRangeKind} for an enumeration of standardized kinds.
  7003. */
  7004. kind?: FoldingRangeKind;
  7005. }
  7006. export class FoldingRangeKind {
  7007. value: string;
  7008. /**
  7009. * Kind for folding range representing a comment. The value of the kind is 'comment'.
  7010. */
  7011. static readonly Comment: FoldingRangeKind;
  7012. /**
  7013. * Kind for folding range representing a import. The value of the kind is 'imports'.
  7014. */
  7015. static readonly Imports: FoldingRangeKind;
  7016. /**
  7017. * Kind for folding range representing regions (for example marked by `#region`, `#endregion`).
  7018. * The value of the kind is 'region'.
  7019. */
  7020. static readonly Region: FoldingRangeKind;
  7021. /**
  7022. * Returns a {@link FoldingRangeKind} for the given value.
  7023. *
  7024. * @param value of the kind.
  7025. */
  7026. static fromValue(value: string): FoldingRangeKind;
  7027. /**
  7028. * Creates a new {@link FoldingRangeKind}.
  7029. *
  7030. * @param value of the kind.
  7031. */
  7032. constructor(value: string);
  7033. }
  7034. export interface WorkspaceEditMetadata {
  7035. needsConfirmation: boolean;
  7036. label: string;
  7037. description?: string;
  7038. }
  7039. export interface WorkspaceFileEditOptions {
  7040. overwrite?: boolean;
  7041. ignoreIfNotExists?: boolean;
  7042. ignoreIfExists?: boolean;
  7043. recursive?: boolean;
  7044. copy?: boolean;
  7045. folder?: boolean;
  7046. skipTrashBin?: boolean;
  7047. maxSize?: number;
  7048. contentsBase64?: string;
  7049. }
  7050. export interface IWorkspaceFileEdit {
  7051. oldResource?: Uri;
  7052. newResource?: Uri;
  7053. options?: WorkspaceFileEditOptions;
  7054. metadata?: WorkspaceEditMetadata;
  7055. }
  7056. export interface IWorkspaceTextEdit {
  7057. resource: Uri;
  7058. textEdit: TextEdit & {
  7059. insertAsSnippet?: boolean;
  7060. };
  7061. versionId: number | undefined;
  7062. metadata?: WorkspaceEditMetadata;
  7063. }
  7064. export interface WorkspaceEdit {
  7065. edits: Array<IWorkspaceTextEdit | IWorkspaceFileEdit>;
  7066. }
  7067. export interface Rejection {
  7068. rejectReason?: string;
  7069. }
  7070. export interface RenameLocation {
  7071. range: IRange;
  7072. text: string;
  7073. }
  7074. export interface RenameProvider {
  7075. provideRenameEdits(model: editor.ITextModel, position: Position, newName: string, token: CancellationToken): ProviderResult<WorkspaceEdit & Rejection>;
  7076. resolveRenameLocation?(model: editor.ITextModel, position: Position, token: CancellationToken): ProviderResult<RenameLocation & Rejection>;
  7077. }
  7078. export interface Command {
  7079. id: string;
  7080. title: string;
  7081. tooltip?: string;
  7082. arguments?: any[];
  7083. }
  7084. export interface CodeLens {
  7085. range: IRange;
  7086. id?: string;
  7087. command?: Command;
  7088. }
  7089. export interface CodeLensList {
  7090. lenses: CodeLens[];
  7091. dispose(): void;
  7092. }
  7093. export interface CodeLensProvider {
  7094. onDidChange?: IEvent<this>;
  7095. provideCodeLenses(model: editor.ITextModel, token: CancellationToken): ProviderResult<CodeLensList>;
  7096. resolveCodeLens?(model: editor.ITextModel, codeLens: CodeLens, token: CancellationToken): ProviderResult<CodeLens>;
  7097. }
  7098. export enum InlayHintKind {
  7099. Type = 1,
  7100. Parameter = 2
  7101. }
  7102. export interface InlayHintLabelPart {
  7103. label: string;
  7104. tooltip?: string | IMarkdownString;
  7105. command?: Command;
  7106. location?: Location;
  7107. }
  7108. export interface InlayHint {
  7109. label: string | InlayHintLabelPart[];
  7110. tooltip?: string | IMarkdownString;
  7111. textEdits?: TextEdit[];
  7112. position: IPosition;
  7113. kind?: InlayHintKind;
  7114. paddingLeft?: boolean;
  7115. paddingRight?: boolean;
  7116. }
  7117. export interface InlayHintList {
  7118. hints: InlayHint[];
  7119. dispose(): void;
  7120. }
  7121. export interface InlayHintsProvider {
  7122. displayName?: string;
  7123. onDidChangeInlayHints?: IEvent<void>;
  7124. provideInlayHints(model: editor.ITextModel, range: Range, token: CancellationToken): ProviderResult<InlayHintList>;
  7125. resolveInlayHint?(hint: InlayHint, token: CancellationToken): ProviderResult<InlayHint>;
  7126. }
  7127. export interface SemanticTokensLegend {
  7128. readonly tokenTypes: string[];
  7129. readonly tokenModifiers: string[];
  7130. }
  7131. export interface SemanticTokens {
  7132. readonly resultId?: string;
  7133. readonly data: Uint32Array;
  7134. }
  7135. export interface SemanticTokensEdit {
  7136. readonly start: number;
  7137. readonly deleteCount: number;
  7138. readonly data?: Uint32Array;
  7139. }
  7140. export interface SemanticTokensEdits {
  7141. readonly resultId?: string;
  7142. readonly edits: SemanticTokensEdit[];
  7143. }
  7144. export interface DocumentSemanticTokensProvider {
  7145. onDidChange?: IEvent<void>;
  7146. getLegend(): SemanticTokensLegend;
  7147. provideDocumentSemanticTokens(model: editor.ITextModel, lastResultId: string | null, token: CancellationToken): ProviderResult<SemanticTokens | SemanticTokensEdits>;
  7148. releaseDocumentSemanticTokens(resultId: string | undefined): void;
  7149. }
  7150. export interface DocumentRangeSemanticTokensProvider {
  7151. getLegend(): SemanticTokensLegend;
  7152. provideDocumentRangeSemanticTokens(model: editor.ITextModel, range: Range, token: CancellationToken): ProviderResult<SemanticTokens>;
  7153. }
  7154. export interface ILanguageExtensionPoint {
  7155. id: string;
  7156. extensions?: string[];
  7157. filenames?: string[];
  7158. filenamePatterns?: string[];
  7159. firstLine?: string;
  7160. aliases?: string[];
  7161. mimetypes?: string[];
  7162. configuration?: Uri;
  7163. }
  7164. /**
  7165. * A Monarch language definition
  7166. */
  7167. export interface IMonarchLanguage {
  7168. /**
  7169. * map from string to ILanguageRule[]
  7170. */
  7171. tokenizer: {
  7172. [name: string]: IMonarchLanguageRule[];
  7173. };
  7174. /**
  7175. * is the language case insensitive?
  7176. */
  7177. ignoreCase?: boolean;
  7178. /**
  7179. * is the language unicode-aware? (i.e., /\u{1D306}/)
  7180. */
  7181. unicode?: boolean;
  7182. /**
  7183. * if no match in the tokenizer assign this token class (default 'source')
  7184. */
  7185. defaultToken?: string;
  7186. /**
  7187. * for example [['{','}','delimiter.curly']]
  7188. */
  7189. brackets?: IMonarchLanguageBracket[];
  7190. /**
  7191. * start symbol in the tokenizer (by default the first entry is used)
  7192. */
  7193. start?: string;
  7194. /**
  7195. * attach this to every token class (by default '.' + name)
  7196. */
  7197. tokenPostfix?: string;
  7198. /**
  7199. * include line feeds (in the form of a \n character) at the end of lines
  7200. * Defaults to false
  7201. */
  7202. includeLF?: boolean;
  7203. /**
  7204. * Other keys that can be referred to by the tokenizer.
  7205. */
  7206. [key: string]: any;
  7207. }
  7208. /**
  7209. * A rule is either a regular expression and an action
  7210. * shorthands: [reg,act] == { regex: reg, action: act}
  7211. * and : [reg,act,nxt] == { regex: reg, action: act{ next: nxt }}
  7212. */
  7213. export type IShortMonarchLanguageRule1 = [string | RegExp, IMonarchLanguageAction];
  7214. export type IShortMonarchLanguageRule2 = [string | RegExp, IMonarchLanguageAction, string];
  7215. export interface IExpandedMonarchLanguageRule {
  7216. /**
  7217. * match tokens
  7218. */
  7219. regex?: string | RegExp;
  7220. /**
  7221. * action to take on match
  7222. */
  7223. action?: IMonarchLanguageAction;
  7224. /**
  7225. * or an include rule. include all rules from the included state
  7226. */
  7227. include?: string;
  7228. }
  7229. export type IMonarchLanguageRule = IShortMonarchLanguageRule1 | IShortMonarchLanguageRule2 | IExpandedMonarchLanguageRule;
  7230. /**
  7231. * An action is either an array of actions...
  7232. * ... or a case statement with guards...
  7233. * ... or a basic action with a token value.
  7234. */
  7235. export type IShortMonarchLanguageAction = string;
  7236. export interface IExpandedMonarchLanguageAction {
  7237. /**
  7238. * array of actions for each parenthesized match group
  7239. */
  7240. group?: IMonarchLanguageAction[];
  7241. /**
  7242. * map from string to ILanguageAction
  7243. */
  7244. cases?: Object;
  7245. /**
  7246. * token class (ie. css class) (or "@brackets" or "@rematch")
  7247. */
  7248. token?: string;
  7249. /**
  7250. * the next state to push, or "@push", "@pop", "@popall"
  7251. */
  7252. next?: string;
  7253. /**
  7254. * switch to this state
  7255. */
  7256. switchTo?: string;
  7257. /**
  7258. * go back n characters in the stream
  7259. */
  7260. goBack?: number;
  7261. /**
  7262. * @open or @close
  7263. */
  7264. bracket?: string;
  7265. /**
  7266. * switch to embedded language (using the mimetype) or get out using "@pop"
  7267. */
  7268. nextEmbedded?: string;
  7269. /**
  7270. * log a message to the browser console window
  7271. */
  7272. log?: string;
  7273. }
  7274. export type IMonarchLanguageAction = IShortMonarchLanguageAction | IExpandedMonarchLanguageAction | (IShortMonarchLanguageAction | IExpandedMonarchLanguageAction)[];
  7275. /**
  7276. * This interface can be shortened as an array, ie. ['{','}','delimiter.curly']
  7277. */
  7278. export interface IMonarchLanguageBracket {
  7279. /**
  7280. * open bracket
  7281. */
  7282. open: string;
  7283. /**
  7284. * closing bracket
  7285. */
  7286. close: string;
  7287. /**
  7288. * token class
  7289. */
  7290. token: string;
  7291. }
  7292. }
  7293. declare namespace monaco.worker {
  7294. export interface IMirrorTextModel {
  7295. readonly version: number;
  7296. }
  7297. export interface IMirrorModel extends IMirrorTextModel {
  7298. readonly uri: Uri;
  7299. readonly version: number;
  7300. getValue(): string;
  7301. }
  7302. export interface IWorkerContext<H = undefined> {
  7303. /**
  7304. * A proxy to the main thread host object.
  7305. */
  7306. host: H;
  7307. /**
  7308. * Get all available mirror models in this worker.
  7309. */
  7310. getMirrorModels(): IMirrorModel[];
  7311. }
  7312. }
  7313. //dtsv=3