@xano/xanoscript-monaco-editor 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.vite/manifest.json +49 -49
- package/dist/assets/{editor-Q-H44Xk5.js → editor-CTk4XCQG.js} +1 -1
- package/dist/assets/{fileCommands._save-_f7KuzoK.js → fileCommands._save-BslznhnO.js} +3 -3
- package/dist/assets/{iconv-lite-umd-D8Xc-NRZ.js → iconv-lite-umd-vDmZu3o7.js} +1 -1
- package/dist/assets/{index-kz8GV9yO.js → index-B9LREvGB.js} +1 -1
- package/dist/assets/{index-BQHo-Z-Y.js → index-BMTVGxzX.js} +2 -2
- package/dist/assets/{index-fzRRQ7Qh.js → index-Be1WCD4s.js} +1 -1
- package/dist/assets/{index-DcZHpPDm.js → index-BfLChBOe.js} +1 -1
- package/dist/assets/{index-CQIJkuYI.js → index-BpdMCZU7.js} +1 -1
- package/dist/assets/{index-GR_3sv6M.js → index-Ca2GOtQx.js} +2 -2
- package/dist/assets/{index-CLAWxbMR.js → index-CzmSOBI6.js} +1 -1
- package/dist/assets/{index-CHwATtBn.js → index-DqIUrgd9.js} +3 -3
- package/dist/assets/{index-D9lSNsHR.js → index-GPQU4rv1.js} +3 -3
- package/dist/assets/{main-BtCp5aH0.js → main-CuAxLb8K.js} +1 -1
- package/dist/assets/{main-BnV5RNdt.js → main-kYU-Ynn2.js} +1 -1
- package/dist/assets/{tokenClassificationRegistry-BP6RVP9u.js → tokenClassificationRegistry-BA6yuF5K.js} +2 -2
- package/dist/assets/{views-Hn-QKMUh.js → views-Dck1c7fK.js} +2 -2
- package/dist/assets/workbenchThemeService.service-DlXrxy4t.js +1 -0
- package/dist/index.html +1 -1
- package/dist/logic-assistant-script.js +60 -62
- package/dist/worker.js +92 -94
- package/package.json +3 -2
- package/dist/assets/workbenchThemeService.service-CDwCNsAv.js +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import{fu as qt,fg as jt,cR as y,hS as Q,hT as m,f as O,g as h,m as mt,W as Z,by as Fe,hQ as ue,c1 as vt,bX as L,cd as _,sW as Zt,E as R,h3 as Xt,d as U,dx as me,ez as E,dy as G,a8 as $e,cG as Qt,h5 as qe,hg as ie,q as K,aI as le,hi as fe,mr as je,iY as $,bs as q,U as g,iA as Ze,sX as Jt,sY as ei,a5 as Xe,il as Qe,Z as ti,h as Ve,oW as St,dI as ii,sZ as Je,s_ as yt,s$ as ri,ma as oe,hG as Ct,iG as et,t0 as si,co as C,iz as B,cy as f,ix as oi,D as pe,t1 as ni,mj as j,i8 as S,kg as tt,d8 as V,js as ai,t2 as ve,aK as Se,aL as di,cr as M,ob as it,kE as ci,lm as ye,t3 as hi,x as It,ms as ui,bt as li,eX as fi,eA as Ce,iV as Ie,t4 as pi,sT as gi,m9 as De,iS as Re,cq as Ae,t5 as we,er as Dt,mf as Rt,mb as At,ct as wt,bd as rt,t6 as st,jh as p,cF as Ei,bA as te,ci as mi,kt as We,iR as Ot,sV as vi,dO as _t,qC as Si,cE as bt,jn as J,j9 as yi,qA as Ci,t7 as _e,mh as Ii,n_ as ke,i4 as Tt,V as Di,iJ as Pt,je as Ue,o6 as Lt,sI as xt,cC as Ri,m8 as Ai,a0 as ee,hN as wi,q8 as ot,z as Oi,iK as _i,t8 as bi,mJ as Ti,t9 as x,jg as v,sr as nt,t as Pi,of as Li,O as xi,qa as Mi,X as Ni,Y as Gi,sy as Mt,sx as Oe,ss as Fi,su as Vi,ta as Wi,tb as ki,iy as Ui,tc as Hi,jB as Bi,K as Yi,td as Ki,ks as at,bW as zi,te as $i,tf as dt,hO as re,tg as qi,cW as Nt,ki as ji,th as ct,cS as ge,ti as Zi,bO as Ee,bQ as w,$ as T,tj as Xi,bN as be,tk as Qi,tl as Ji,bV as He,tm as er,tn as tr,to as ir,j as Gt,cM as Ft,oJ as rr,oB as sr,c0 as or,d4 as ht,bY as nr,g0 as ar}from"./index-D9lSNsHR.js";const dr=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));let Te=class extends qt{constructor(e,t,i,r,s,o,n,a,c,u){super(e,t,r,a,o),this.instantiationService=s,this.textResourceConfigurationService=n,this.editorService=c,this.editorGroupService=u,this.groupListener=this._register(new jt),this.viewState=this.getEditorMemento(u,n,i,100)}setEditorVisible(e){this.groupListener.value=this.group.onWillCloseEditor(t=>this.onWillCloseEditor(t)),super.setEditorVisible(e)}onWillCloseEditor(e){const t=e.editor;t===this.input&&this.updateEditorViewState(t)}clearInput(){this.updateEditorViewState(this.input),super.clearInput()}saveState(){this.updateEditorViewState(this.input),super.saveState()}updateEditorViewState(e){if(!e||!this.tracksEditorViewState(e))return;const t=this.toEditorViewStateResource(e);t&&(this.tracksDisposedEditorViewState()||(this.editorViewStateDisposables||(this.editorViewStateDisposables=new Map),this.editorViewStateDisposables.has(e)||this.editorViewStateDisposables.set(e,y.once(e.onWillDispose)(()=>{this.clearEditorViewState(t,this.group),this.editorViewStateDisposables?.delete(e)}))),e.isDisposed()&&!this.tracksDisposedEditorViewState()||!this.shouldRestoreEditorViewState(e)&&!this.group.contains(e)?this.clearEditorViewState(t,this.group):e.isDisposed()||this.saveEditorViewState(t))}shouldRestoreEditorViewState(e,t){return t?.newInGroup?this.textResourceConfigurationService.getValue(Q.getOriginalUri(e,{supportSideBySide:m.PRIMARY}),"workbench.editor.restoreViewState")!==!1:!0}getViewState(){const e=this.input;if(!e||!this.tracksEditorViewState(e))return;const t=this.toEditorViewStateResource(e);if(t)return this.computeEditorViewState(t)}saveEditorViewState(e){const t=this.computeEditorViewState(e);t&&this.viewState.saveEditorState(this.group,e,t)}loadEditorViewState(e,t){if(!e||!this.tracksEditorViewState(e)||!this.shouldRestoreEditorViewState(e,t))return;const i=this.toEditorViewStateResource(e);if(i)return this.viewState.loadEditorState(this.group,i)}moveEditorViewState(e,t,i){return this.viewState.moveEditorState(e,t,i)}clearEditorViewState(e,t){this.viewState.clearEditorState(e,t)}dispose(){if(super.dispose(),this.editorViewStateDisposables){for(const[,e]of this.editorViewStateDisposables)e.dispose();this.editorViewStateDisposables=void 0}}tracksDisposedEditorViewState(){return!1}};Te=O([h(3,mt),h(4,Z),h(5,Fe),h(6,ue),h(7,vt),h(8,L),h(9,_)],Te);var F;ti(dr);function cr(d){const e=d;return typeof e?.primary=="object"&&typeof e.secondary=="object"}var P;let Pe=(P=class extends Te{get minimumPrimaryWidth(){return this.primaryEditorPane?this.primaryEditorPane.minimumWidth:0}get maximumPrimaryWidth(){return this.primaryEditorPane?this.primaryEditorPane.maximumWidth:Number.POSITIVE_INFINITY}get minimumPrimaryHeight(){return this.primaryEditorPane?this.primaryEditorPane.minimumHeight:0}get maximumPrimaryHeight(){return this.primaryEditorPane?this.primaryEditorPane.maximumHeight:Number.POSITIVE_INFINITY}get minimumSecondaryWidth(){return this.secondaryEditorPane?this.secondaryEditorPane.minimumWidth:0}get maximumSecondaryWidth(){return this.secondaryEditorPane?this.secondaryEditorPane.maximumWidth:Number.POSITIVE_INFINITY}get minimumSecondaryHeight(){return this.secondaryEditorPane?this.secondaryEditorPane.minimumHeight:0}get maximumSecondaryHeight(){return this.secondaryEditorPane?this.secondaryEditorPane.maximumHeight:Number.POSITIVE_INFINITY}set minimumWidth(e){}set maximumWidth(e){}set minimumHeight(e){}set maximumHeight(e){}get minimumWidth(){return this.minimumPrimaryWidth+this.minimumSecondaryWidth}get maximumWidth(){return this.maximumPrimaryWidth+this.maximumSecondaryWidth}get minimumHeight(){return this.minimumPrimaryHeight+this.minimumSecondaryHeight}get maximumHeight(){return this.maximumPrimaryHeight+this.maximumSecondaryHeight}constructor(e,t,i,r,s,o,n,a,c){super(F.ID,e,F.VIEW_STATE_PREFERENCE_KEY,t,i,s,n,r,a,c),this.configurationService=o,this.onDidCreateEditors=this._register(new R),this._onDidChangeSizeConstraints=this._register(new Xt),this.onDidChangeSizeConstraints=y.any(this.onDidCreateEditors.event,this._onDidChangeSizeConstraints.event),this._onDidChangeSelection=this._register(new R),this.onDidChangeSelection=this._onDidChangeSelection.event,this.primaryEditorPane=void 0,this.secondaryEditorPane=void 0,this.splitviewDisposables=this._register(new U),this.editorDisposables=this._register(new U),this.dimension=new me(0,0),this.lastFocusedSide=void 0,this.orientation=this.configurationService.getValue(F.SIDE_BY_SIDE_LAYOUT_SETTING)==="vertical"?E.VERTICAL:E.HORIZONTAL,this.registerListeners()}registerListeners(){this._register(this.configurationService.onDidChangeConfiguration(e=>this.onConfigurationUpdated(e)))}onConfigurationUpdated(e){e.affectsConfiguration(F.SIDE_BY_SIDE_LAYOUT_SETTING)&&(this.orientation=this.configurationService.getValue(F.SIDE_BY_SIDE_LAYOUT_SETTING)==="vertical"?E.VERTICAL:E.HORIZONTAL,this.splitview&&this.recreateSplitview())}recreateSplitview(){const e=G(this.getContainer()),t=this.getSplitViewRatio();this.splitview&&(this.splitview.el.remove(),this.splitviewDisposables.clear()),this.createSplitView(e,t),this.layout(this.dimension)}getSplitViewRatio(){let e;if(this.splitview){const t=this.splitview.getViewSize(0),i=this.splitview.getViewSize(1);if(Math.abs(t-i)>1){const r=this.splitview.orientation===E.HORIZONTAL?this.dimension.width:this.dimension.height;e=t/r}}return e}createEditor(e){e.classList.add("side-by-side-editor"),this.secondaryEditorContainer=$e(".side-by-side-editor-container.editor-instance"),this.primaryEditorContainer=$e(".side-by-side-editor-container.editor-instance"),this.createSplitView(e)}createSplitView(e,t){this.splitview=this.splitviewDisposables.add(new Qt(e,{orientation:this.orientation})),this.splitviewDisposables.add(this.splitview.onDidSashReset(()=>this.splitview?.distributeViewSizes())),this.orientation===E.HORIZONTAL?this.splitview.orthogonalEndSash=this._boundarySashes?.bottom:(this.splitview.orthogonalStartSash=this._boundarySashes?.left,this.splitview.orthogonalEndSash=this._boundarySashes?.right);let i=qe.Distribute,r=qe.Distribute;if(t){const n=this.splitview.orientation===E.HORIZONTAL?this.dimension.width:this.dimension.height;i=Math.round(n*t),r=n-i,this.splitview.layout(this.orientation===E.HORIZONTAL?this.dimension.width:this.dimension.height)}const s=G(this.secondaryEditorContainer);this.splitview.addView({element:s,layout:n=>this.layoutPane(this.secondaryEditorPane,n),minimumSize:this.orientation===E.HORIZONTAL?ie.width:ie.height,maximumSize:Number.POSITIVE_INFINITY,onDidChange:y.None},i);const o=G(this.primaryEditorContainer);this.splitview.addView({element:o,layout:n=>this.layoutPane(this.primaryEditorPane,n),minimumSize:this.orientation===E.HORIZONTAL?ie.width:ie.height,maximumSize:Number.POSITIVE_INFINITY,onDidChange:y.None},r),this.updateStyles()}getTitle(){return this.input?this.input.getName():K(3407,"Side by Side Editor")}async setInput(e,t,i,r){const s=this.input;await super.setInput(e,t,i,r),(!s||!e.matches(s))&&(s&&this.disposeEditors(),this.createEditors(e));const{primary:o,secondary:n,viewState:a}=this.loadViewState(e,t,i);if(this.lastFocusedSide=a?.focus,typeof a?.ratio=="number"&&this.splitview){const c=this.splitview.orientation===E.HORIZONTAL?this.dimension.width:this.dimension.height;this.splitview.resizeView(0,Math.round(c*a.ratio))}else this.splitview?.distributeViewSizes();await Promise.all([this.secondaryEditorPane?.setInput(e.secondary,n,i,r),this.primaryEditorPane?.setInput(e.primary,o,i,r)]),typeof t?.target=="number"&&(this.lastFocusedSide=t.target)}loadViewState(e,t,i){const r=cr(t?.viewState)?t?.viewState:this.loadEditorViewState(e,i);let s=Object.create(null),o;return t?.target===m.SECONDARY?o={...t}:s={...t},s.viewState=r?.primary,r?.secondary&&(o?o.viewState=r?.secondary:o={viewState:r.secondary}),{primary:s,secondary:o,viewState:r}}createEditors(e){this.secondaryEditorPane=this.doCreateEditor(e.secondary,G(this.secondaryEditorContainer)),this.primaryEditorPane=this.doCreateEditor(e.primary,G(this.primaryEditorContainer)),this.layout(this.dimension),this._onDidChangeSizeConstraints.input=y.any(y.map(this.secondaryEditorPane.onDidChangeSizeConstraints,()=>{}),y.map(this.primaryEditorPane.onDidChangeSizeConstraints,()=>{})),this.onDidCreateEditors.fire(void 0),this.editorDisposables.add(this.primaryEditorPane.onDidFocus(()=>this.onDidFocusChange(m.PRIMARY))),this.editorDisposables.add(this.secondaryEditorPane.onDidFocus(()=>this.onDidFocusChange(m.SECONDARY)))}doCreateEditor(e,t){const i=le.as(fe.EditorPane).getEditorPane(e);if(!i)throw new Error("No editor pane descriptor for editor found");const r=i.instantiate(this.instantiationService,this.group);return r.create(t),r.setVisible(this.isVisible()),je(r)&&this.editorDisposables.add(r.onDidChangeSelection(s=>this._onDidChangeSelection.fire(s))),this.editorDisposables.add(r),r}onDidFocusChange(e){this.lastFocusedSide=e,this._onDidChangeControl.fire()}getSelection(){const e=this.getLastFocusedEditorPane();if(je(e)){const t=e.getSelection();if(t)return new Be(t,e===this.primaryEditorPane?m.PRIMARY:m.SECONDARY)}}setOptions(e){super.setOptions(e),typeof e?.target=="number"&&(this.lastFocusedSide=e.target),this.getLastFocusedEditorPane()?.setOptions(e)}setEditorVisible(e){this.primaryEditorPane?.setVisible(e),this.secondaryEditorPane?.setVisible(e),super.setEditorVisible(e)}clearInput(){super.clearInput(),this.primaryEditorPane?.clearInput(),this.secondaryEditorPane?.clearInput(),this.disposeEditors()}focus(){super.focus(),this.getLastFocusedEditorPane()?.focus()}getLastFocusedEditorPane(){return this.lastFocusedSide===m.SECONDARY?this.secondaryEditorPane:this.primaryEditorPane}layout(e){this.dimension=e,G(this.splitview).layout(this.orientation===E.HORIZONTAL?e.width:e.height)}setBoundarySashes(e){this._boundarySashes=e,this.splitview&&(this.splitview.orthogonalEndSash=e.bottom)}layoutPane(e,t){e?.layout(this.orientation===E.HORIZONTAL?new me(t,this.dimension.height):new me(this.dimension.width,t))}getControl(){return this.getLastFocusedEditorPane()?.getControl()}getPrimaryEditorPane(){return this.primaryEditorPane}getSecondaryEditorPane(){return this.secondaryEditorPane}tracksEditorViewState(e){return e instanceof $}computeEditorViewState(e){if(!this.input||!q(e,this.toEditorViewStateResource(this.input)))return;const t=this.primaryEditorPane?.getViewState(),i=this.secondaryEditorPane?.getViewState();if(!(!t||!i))return{primary:t,secondary:i,focus:this.lastFocusedSide,ratio:this.getSplitViewRatio()}}toEditorViewStateResource(e){let t,i;if(e instanceof $&&(t=e.primary.resource,i=e.secondary.resource),!(!i||!t))return g.from({scheme:"sideBySide",path:`${Ze(i.toString())}${Ze(t.toString())}`})}updateStyles(){super.updateStyles(),this.primaryEditorContainer&&(this.orientation===E.HORIZONTAL?(this.primaryEditorContainer.style.borderLeftWidth="1px",this.primaryEditorContainer.style.borderLeftStyle="solid",this.primaryEditorContainer.style.borderLeftColor=this.getColor(Jt)??"",this.primaryEditorContainer.style.borderTopWidth="0"):(this.primaryEditorContainer.style.borderTopWidth="1px",this.primaryEditorContainer.style.borderTopStyle="solid",this.primaryEditorContainer.style.borderTopColor=this.getColor(ei)??"",this.primaryEditorContainer.style.borderLeftWidth="0"))}dispose(){this.disposeEditors(),super.dispose()}disposeEditors(){this.editorDisposables.clear(),this.secondaryEditorPane=void 0,this.primaryEditorPane=void 0,this.lastFocusedSide=void 0,this.secondaryEditorContainer&&Xe(this.secondaryEditorContainer),this.primaryEditorContainer&&Xe(this.primaryEditorContainer)}},F=P,P.ID=Zt,P.SIDE_BY_SIDE_LAYOUT_SETTING="workbench.editor.splitInGroupLayout",P.VIEW_STATE_PREFERENCE_KEY="sideBySideEditorViewState",P);Pe=F=O([h(1,mt),h(2,Z),h(3,vt),h(4,Fe),h(5,Ve),h(6,ue),h(7,L),h(8,_)],Pe);class Be{constructor(e,t){this.selection=e,this.side=t}compare(e){return e instanceof Be?this.side!==e.side?Qe.DIFFERENT:this.selection.compare(e.selection):Qe.DIFFERENT}restore(e){const t={...e,target:this.side};return this.selection.restore(t)}}function hr(d,e,t,i){const r=ur(d,e,t,i),s=r.length&&r[0].preserveFocus||!1,o={groupedEditors:[],preserveFocus:s};for(const n of r){const a=pr(n,t);if(!a)continue;const{group:c,editor:u}=a;let l;for(const I of o.groupedEditors)if(I.group.id===c.id){l=I;break}l||(l={group:c,editors:[]},o.groupedEditors.push(l)),u&&l.editors.push(u)}return o}function ur(d,e,t,i){const r=i.lastFocusedList;let s=r instanceof St&&r.getHTMLElement()===ii(),o=fr(d,s,e,t,i);if(!o){const a=t.activeGroup,c=a.activeEditor;o={groupId:a.id,editorIndex:c?a.getIndexOfEditor(c):void 0},s=!1}const n=Vt(o,s,e,t,i);return lr(o,n)}function lr(d,e){if(e.length<=1)return e;const t=e.findIndex(i=>i.groupId===d.groupId&&i.editorIndex===d.editorIndex);if(t!==-1)e.splice(t,1),e.unshift(d);else if(d.editorIndex===void 0)e.unshift(d);else throw new Error("Editor context not found in multi editor context");return e}function fr(d,e,t,i,r){const s=d.filter(o=>Je(o)||g.isUri(o));for(const o of s)if(Je(o))return o;for(const o of s){const n=t.findEditors(o);if(n.length){const a=n[0],c=i.getGroup(a.groupId);return{groupId:a.groupId,editorIndex:c?.getIndexOfEditor(a.editor)}}}if(e){const o=r.lastFocusedList;for(const n of o.getFocusedElements())if(Wt(n))return Le(n,void 0,i)}}function Vt(d,e,t,i,r){if(e){const o=r.lastFocusedList.getSelectedElements().filter(Wt);if(o.length>1)return o.map(n=>Le(n,d.preserveFocus,i));if(o.length===0)return Vt(d,!1,t,i,r)}else{const s=i.getGroup(d.groupId),o=d.editorIndex!==void 0?s?.getEditorByIndex(d.editorIndex):s?.activeEditor;if(s&&o&&s.isSelected(o))return s.selectedEditors.map(n=>Le({editor:n,groupId:s.id},d.preserveFocus,i))}return[d]}function Le(d,e,t){if(yt(d))return{groupId:d.id,editorIndex:void 0,preserveFocus:e};const i=t.getGroup(d.groupId);return{groupId:d.groupId,editorIndex:i?i.getIndexOfEditor(d.editor):-1,preserveFocus:e}}function Wt(d){return yt(d)||ri(d)}function pr(d,e){const t=e.getGroup(d.groupId);if(!t)return;if(d.editorIndex===void 0)return{group:t,editor:void 0};const i=t.getEditorByIndex(d.editorIndex);return{group:t,editor:i}}function ut(d,e,t){const i=d.get(_),r=d.get(Ve),s=gr(e,t,i,r);return s instanceof Promise?s.then(o=>lt(o,e,t,i)):lt(s,e,t,i)}function lt(d,e,t,i){let r;return i.activeGroup!==d&&e.options&&!e.options.inactive&&e.options.preserveFocus&&typeof e.options.activation!="number"&&t!==Ct&&(r=oi.ACTIVATE),[d,r]}function gr(d,e,t,i){let r;const s=oe(d)?d.editor:d,o=d.options;if(e&&typeof e!="number")r=e;else if(typeof e=="number"&&e>=0)r=t.getGroup(e);else if(e===Ct){const n=et(i);let a=t.findGroup({direction:n});(!a||se(a,s))&&(a=t.addGroup(t.activeGroup,n)),r=a}else if(e===si)r=t.createAuxiliaryEditorPart({bounds:o?.auxiliary?.bounds,compact:o?.auxiliary?.compact,alwaysOnTop:o?.auxiliary?.alwaysOnTop}).then(n=>n.activeGroup);else if(!o||typeof o.index!="number"){const n=t.getGroups(C.MOST_RECENTLY_ACTIVE);if(o?.revealIfVisible){for(const a of n)if(Er(a,s)){r=a;break}}if(!r&&(o?.revealIfOpened||i.getValue("workbench.editor.revealIfOpen")||B(s)&&s.hasCapability(f.Singleton))){let a,c;for(const u of n)if(kt(u,s)&&(c||(c=u),!a&&u.isActive(s)&&(a=u)),c&&a)break;r=a||c}}if(!r){let n=t.activeGroup;if(se(n,s)){for(const a of t.getGroups(C.MOST_RECENTLY_ACTIVE))if(!se(a,s)){n=a;break}se(n,s)?r=t.addGroup(n,et(i)):r=n}else r=n}return r}function se(d,e){return!(!d.isLocked||kt(d,e))}function Er(d,e){return d.activeEditor?d.activeEditor.matches(e):!1}function kt(d,e){for(const t of d.editors)if(t.matches(e))return!0;return!1}var X,W;let xe=(W=class extends pe{get count(){return this.mostRecentEditorsMap.size}get editors(){return[...this.mostRecentEditorsMap.values()]}hasEditor(e){return this.editorsPerResourceCounter.get(e.resource)?.has(this.toIdentifier(e))??!1}hasEditors(e){return this.editorsPerResourceCounter.has(e)}toIdentifier(e,t){return typeof e!="string"?this.toIdentifier(e.typeId,e.editorId):t?`${e}/${t}`:e}constructor(e,t,i){super(),this.editorGroupService=t,this.storageService=i,this.keyMap=new Map,this.mostRecentEditorsMap=new ni,this.editorsPerResourceCounter=new j,this._onDidMostRecentlyActiveEditorsChange=this._register(new R),this.onDidMostRecentlyActiveEditorsChange=this._onDidMostRecentlyActiveEditorsChange.event,this.editorGroupsContainer=e??t,this.isScoped=!!e,this.registerListeners(),this.loadState()}registerListeners(){this._register(this.editorGroupsContainer.onDidAddGroup(e=>this.onGroupAdded(e))),this._register(this.editorGroupService.onDidChangeEditorPartOptions(e=>this.onDidChangeEditorPartOptions(e))),this._register(this.storageService.onWillSaveState(()=>this.saveState()))}onGroupAdded(e){const t=e.getEditors(S.MOST_RECENTLY_ACTIVE);for(let i=t.length-1;i>=0;i--)this.addMostRecentEditor(e,t[i],!1,!0);this.editorGroupsContainer.activeGroup===e&&e.activeEditor&&this.addMostRecentEditor(e,e.activeEditor,!0,!1),this.registerGroupListeners(e)}registerGroupListeners(e){const t=new U;t.add(e.onDidModelChange(i=>{switch(i.kind){case tt.GROUP_ACTIVE:{this.editorGroupsContainer.activeGroup===e&&e.activeEditor&&this.addMostRecentEditor(e,e.activeEditor,!0,!1);break}case tt.EDITOR_OPEN:{i.editor&&(this.addMostRecentEditor(e,i.editor,!1,!0),this.ensureOpenedEditorsLimit({groupId:e.id,editor:i.editor},e.id));break}}})),t.add(e.onDidCloseEditor(i=>{this.removeMostRecentEditor(e,i.editor)})),t.add(e.onDidActiveEditorChange(i=>{i.editor&&this.addMostRecentEditor(e,i.editor,this.editorGroupsContainer.activeGroup===e,!1)})),y.once(e.onWillDispose)(()=>V(t))}onDidChangeEditorPartOptions(e){if(!ai(e.newPartOptions.limit,e.oldPartOptions.limit)){const t=this.editorGroupsContainer.activeGroup;let i;t.activeEditor&&(i={editor:t.activeEditor,groupId:t.id}),this.ensureOpenedEditorsLimit(i)}}addMostRecentEditor(e,t,i,r){const s=this.ensureKey(e,t),o=this.mostRecentEditorsMap.first;i||!o?this.mostRecentEditorsMap.set(s,s,o?ve.AsOld:void 0):(this.mostRecentEditorsMap.set(s,s,ve.AsOld),this.mostRecentEditorsMap.set(o,o,ve.AsOld)),r&&this.updateEditorResourcesMap(t,!0),this._onDidMostRecentlyActiveEditorsChange.fire()}updateEditorResourcesMap(e,t){let i,r,s;if(e instanceof $?(i=e.primary.resource,r=e.primary.typeId,s=e.primary.editorId):(i=e.resource,r=e.typeId,s=e.editorId),!i)return;const o=this.toIdentifier(r,s);if(t){let n=this.editorsPerResourceCounter.get(i);n||(n=new Map,this.editorsPerResourceCounter.set(i,n)),n.set(o,(n.get(o)??0)+1)}else{const n=this.editorsPerResourceCounter.get(i);if(n){const a=n.get(o)??0;a>1?n.set(o,a-1):(n.delete(o),n.size===0&&this.editorsPerResourceCounter.delete(i))}}}removeMostRecentEditor(e,t){this.updateEditorResourcesMap(t,!1);const i=this.findKey(e,t);if(i){this.mostRecentEditorsMap.delete(i);const r=this.keyMap.get(e.id);r&&r.delete(i.editor)&&r.size===0&&this.keyMap.delete(e.id),this._onDidMostRecentlyActiveEditorsChange.fire()}}findKey(e,t){const i=this.keyMap.get(e.id);if(i)return i.get(t)}ensureKey(e,t){let i=this.keyMap.get(e.id);i||(i=new Map,this.keyMap.set(e.id,i));let r=i.get(t);return r||(r={groupId:e.id,editor:t},i.set(t,r)),r}async ensureOpenedEditorsLimit(e,t){if(!this.editorGroupService.partOptions.limit?.enabled||typeof this.editorGroupService.partOptions.limit.value!="number"||this.editorGroupService.partOptions.limit.value<=0)return;const i=this.editorGroupService.partOptions.limit.value;if(this.editorGroupService.partOptions.limit?.perEditorGroup)if(typeof t=="number"){const r=this.editorGroupsContainer.getGroup(t);r&&await this.doEnsureOpenedEditorsLimit(i,r.getEditors(S.MOST_RECENTLY_ACTIVE).map(s=>({editor:s,groupId:t})),e)}else for(const r of this.editorGroupsContainer.groups)await this.ensureOpenedEditorsLimit(e,r.id);else await this.doEnsureOpenedEditorsLimit(i,[...this.mostRecentEditorsMap.values()],e)}async doEnsureOpenedEditorsLimit(e,t,i){let r;if(this.editorGroupService.partOptions.limit?.excludeDirty?r=t.filter(({editor:a})=>!(a.isDirty()&&!a.isSaving()||a.hasCapability(f.Scratchpad))):r=t,e>=r.length)return;const s=r.reverse().filter(({editor:a,groupId:c})=>!(a.isDirty()&&!a.isSaving()||a.hasCapability(f.Scratchpad)||i&&a===i.editor&&c===i.groupId||this.editorGroupsContainer.getGroup(c)?.isSticky(a)));let o=r.length-e;const n=new Map;for(const{groupId:a,editor:c}of s){let u=n.get(a);if(u||(u=[],n.set(a,u)),u.push(c),o--,o===0)break}for(const[a,c]of n){const u=this.editorGroupsContainer.getGroup(a);u&&await u.closeEditors(c,{preserveFocus:!0})}}saveState(){this.isScoped||(this.mostRecentEditorsMap.isEmpty()?this.storageService.remove(X.STORAGE_KEY,Se.WORKSPACE):this.storageService.store(X.STORAGE_KEY,JSON.stringify(this.serialize()),Se.WORKSPACE,di.MACHINE))}serialize(){const e=le.as(fe.EditorFactory),t=[...this.mostRecentEditorsMap.values()],i=new Map;return{entries:M(t.map(({editor:r,groupId:s})=>{const o=this.editorGroupsContainer.getGroup(s);if(!o)return;let n=i.get(o);n||(n=o.getEditors(S.SEQUENTIAL).filter(c=>e.getEditorSerializer(c)?.canSerialize(c)),i.set(o,n));const a=n.indexOf(r);if(a!==-1)return{groupId:s,index:a}}))}}async loadState(){(this.editorGroupsContainer===this.editorGroupService.mainPart||this.editorGroupsContainer===this.editorGroupService)&&await this.editorGroupService.whenReady;let e=!1;if(!this.isScoped){const t=this.storageService.get(X.STORAGE_KEY,Se.WORKSPACE);t&&(e=!0,this.deserialize(JSON.parse(t)))}if(!e){const t=this.editorGroupsContainer.getGroups(C.MOST_RECENTLY_ACTIVE);for(let i=t.length-1;i>=0;i--){const r=t[i],s=r.getEditors(S.MOST_RECENTLY_ACTIVE);for(let o=s.length-1;o>=0;o--)this.addMostRecentEditor(r,s[o],!0,!0)}}for(const t of this.editorGroupsContainer.groups)this.registerGroupListeners(t)}deserialize(e){const t=[];for(const{groupId:i,index:r}of e.entries){const s=this.editorGroupsContainer.getGroup(i);if(!s)continue;const o=s.getEditorByIndex(r);if(!o)continue;const n=this.ensureKey(s,o);t.push([n,n]),this.updateEditorResourcesMap(o,!0)}this.mostRecentEditorsMap.fromJSON(t)}},X=W,W.STORAGE_KEY="editors.mru",W);xe=X=O([h(1,_),h(2,Fe)],xe);var Me;let ft=Me=class extends pe{constructor(e,t,i,r,s,o,n,a,c,u,l){super(),this.editorGroupService=t,this.instantiationService=i,this.fileService=r,this.configurationService=s,this.contextService=o,this.uriIdentityService=n,this.editorResolverService=a,this.workspaceTrustRequestService=c,this.hostService=u,this.textEditorService=l,this._onDidActiveEditorChange=this._register(new R),this.onDidActiveEditorChange=this._onDidActiveEditorChange.event,this._onDidVisibleEditorsChange=this._register(new R),this.onDidVisibleEditorsChange=this._onDidVisibleEditorsChange.event,this._onDidEditorsChange=this._register(new R),this.onDidEditorsChange=this._onDidEditorsChange.event,this._onWillOpenEditor=this._register(new R),this.onWillOpenEditor=this._onWillOpenEditor.event,this._onDidCloseEditor=this._register(new R),this.onDidCloseEditor=this._onDidCloseEditor.event,this._onDidOpenEditorFail=this._register(new R),this.onDidOpenEditorFail=this._onDidOpenEditorFail.event,this._onDidMostRecentlyActiveEditorsChange=this._register(new R),this.onDidMostRecentlyActiveEditorsChange=this._onDidMostRecentlyActiveEditorsChange.event,this.lastActiveEditor=void 0,this.activeOutOfWorkspaceWatchers=new j,this.closeOnFileDelete=!1,this.editorGroupsContainer=e??t,this.editorsObserver=this._register(this.instantiationService.createInstance(xe,this.editorGroupsContainer)),this.onConfigurationUpdated(),this.registerListeners()}createScoped(e,t){return t.add(new Me(e,this.editorGroupService,this.instantiationService,this.fileService,this.configurationService,this.contextService,this.uriIdentityService,this.editorResolverService,this.workspaceTrustRequestService,this.hostService,this.textEditorService))}registerListeners(){this.editorGroupsContainer===this.editorGroupService.mainPart||this.editorGroupsContainer===this.editorGroupService?this.editorGroupService.whenReady.then(()=>this.onEditorGroupsReady()):this.onEditorGroupsReady(),this._register(this.editorGroupsContainer.onDidChangeActiveGroup(e=>this.handleActiveEditorChange(e))),this._register(this.editorGroupsContainer.onDidAddGroup(e=>this.registerGroupListeners(e))),this._register(this.editorsObserver.onDidMostRecentlyActiveEditorsChange(()=>this._onDidMostRecentlyActiveEditorsChange.fire())),this._register(this.onDidVisibleEditorsChange(()=>this.handleVisibleEditorsChange())),this._register(this.fileService.onDidRunOperation(e=>this.onDidRunFileOperation(e))),this._register(this.fileService.onDidFilesChange(e=>this.onDidFilesChange(e))),this._register(this.configurationService.onDidChangeConfiguration(e=>this.onConfigurationUpdated(e)))}onEditorGroupsReady(){for(const e of this.editorGroupsContainer.groups)this.registerGroupListeners(e);this.activeEditor&&(this.doHandleActiveEditorChangeEvent(),this._onDidVisibleEditorsChange.fire())}handleActiveEditorChange(e){e===this.editorGroupsContainer.activeGroup&&(!this.lastActiveEditor&&!e.activeEditor||this.doHandleActiveEditorChangeEvent())}doHandleActiveEditorChangeEvent(){const e=this.editorGroupsContainer.activeGroup;this.lastActiveEditor=e.activeEditor??void 0,this._onDidActiveEditorChange.fire()}registerGroupListeners(e){const t=new U;t.add(e.onDidModelChange(i=>{this._onDidEditorsChange.fire({groupId:e.id,event:i})})),t.add(e.onDidActiveEditorChange(()=>{this.handleActiveEditorChange(e),this._onDidVisibleEditorsChange.fire()})),t.add(e.onWillOpenEditor(i=>{this._onWillOpenEditor.fire(i)})),t.add(e.onDidCloseEditor(i=>{this._onDidCloseEditor.fire(i)})),t.add(e.onDidOpenEditorFail(i=>{this._onDidOpenEditorFail.fire({editor:i,groupId:e.id})})),y.once(e.onWillDispose)(()=>{V(t)})}handleVisibleEditorsChange(){const e=new it;for(const t of this.visibleEditors){const i=ci(M([Q.getCanonicalUri(t,{supportSideBySide:m.PRIMARY}),Q.getCanonicalUri(t,{supportSideBySide:m.SECONDARY})]),r=>r.toString());for(const r of i)this.fileService.hasProvider(r)&&!this.contextService.isInsideWorkspace(r)&&e.add(r)}for(const t of this.activeOutOfWorkspaceWatchers.keys())e.has(t)||(V(this.activeOutOfWorkspaceWatchers.get(t)),this.activeOutOfWorkspaceWatchers.delete(t));for(const t of e.keys())if(!this.activeOutOfWorkspaceWatchers.get(t)){const i=this.fileService.watch(t);this.activeOutOfWorkspaceWatchers.set(t,i)}}async onDidRunFileOperation(e){e.isOperation(ye.MOVE)&&this.handleMovedFile(e.resource,e.target.resource),(e.isOperation(ye.DELETE)||e.isOperation(ye.MOVE))&&this.handleDeletedFile(e.resource,!1,e.target?e.target.resource:void 0)}onDidFilesChange(e){e.gotDeleted()&&this.handleDeletedFile(e,!0)}async handleMovedFile(e,t){for(const i of this.editorGroupsContainer.groups){const r=[];for(const s of i.editors){const o=s.resource;if(!o||!this.uriIdentityService.extUri.isEqualOrParent(o,e))continue;let n;if(this.uriIdentityService.extUri.isEqual(e,o))n=t;else{const u=hi(o.path,e.path,this.uriIdentityService.extUri.ignorePathCasing(o));n=It(t,o.path.substr(u+e.path.length+1))}const a=await s.rename(i.id,n);if(!a)return;const c={preserveFocus:!0,pinned:i.isPinned(s),sticky:i.isSticky(s),index:i.getIndexOfEditor(s),inactive:!i.isActive(s)};B(a.editor)?r.push({editor:s,replacement:a.editor,options:{...a.options,...c}}):r.push({editor:s,replacement:{...a.editor,options:{...a.editor.options,...c}}})}r.length&&this.replaceEditors(r,i)}}onConfigurationUpdated(e){if(e&&!e.affectsConfiguration("workbench.editor.closeOnFileDelete"))return;const t=this.configurationService.getValue();typeof t.workbench?.editor?.closeOnFileDelete=="boolean"?this.closeOnFileDelete=t.workbench.editor.closeOnFileDelete:this.closeOnFileDelete=!1}handleDeletedFile(e,t,i){for(const r of this.getAllNonDirtyEditors({includeUntitled:!1,supportSideBySide:!0}))(async()=>{const s=r.resource;if(s&&(this.closeOnFileDelete||!t)){if(i&&this.uriIdentityService.extUri.isEqualOrParent(s,i))return;let o=!1;if(e instanceof ui?o=e.contains(s,li.DELETED):o=this.uriIdentityService.extUri.isEqualOrParent(s,e),!o)return;let n=!1;t&&this.fileService.hasProvider(s)&&(await fi(100),n=await this.fileService.exists(s)),!n&&!r.isDisposed()&&r.dispose()}})()}getAllNonDirtyEditors(e){const t=[];function i(r){r.hasCapability(f.Untitled)&&!e.includeUntitled||r.isDirty()||t.push(r)}for(const r of this.editors)e.supportSideBySide&&r instanceof $?(i(r.primary),i(r.secondary)):i(r);return t}get activeEditorPane(){return this.editorGroupsContainer.activeGroup?.activeEditorPane}get activeTextEditorControl(){const e=this.activeEditorPane;if(e){const t=e.getControl();if(Ce(t)||Ie(t))return t;if(pi(t)&&Ce(t.activeCodeEditor))return t.activeCodeEditor}}get activeTextEditorLanguageId(){let e;const t=this.activeTextEditorControl;return Ie(t)?e=t.getModifiedEditor():e=t,e?.getModel()?.getLanguageId()}get count(){return this.editorsObserver.count}get editors(){return this.getEditors(S.SEQUENTIAL).map(({editor:e})=>e)}getEditors(e,t){switch(e){case S.MOST_RECENTLY_ACTIVE:return t?.excludeSticky?this.editorsObserver.editors.filter(({groupId:i,editor:r})=>!this.editorGroupsContainer.getGroup(i)?.isSticky(r)):this.editorsObserver.editors;case S.SEQUENTIAL:{const i=[];for(const r of this.editorGroupsContainer.getGroups(C.GRID_APPEARANCE))i.push(...r.getEditors(S.SEQUENTIAL,t).map(s=>({editor:s,groupId:r.id})));return i}}}get activeEditor(){const e=this.editorGroupsContainer.activeGroup;return e?e.activeEditor??void 0:void 0}get visibleEditorPanes(){return M(this.editorGroupsContainer.groups.map(e=>e.activeEditorPane))}get visibleTextEditorControls(){return this.doGetVisibleTextEditorControls(this.visibleEditorPanes)}doGetVisibleTextEditorControls(e){const t=[];for(const i of e){const r=[];i instanceof Pe?(r.push(i.getPrimaryEditorPane()?.getControl()),r.push(i.getSecondaryEditorPane()?.getControl())):r.push(i.getControl());for(const s of r)(Ce(s)||Ie(s))&&t.push(s)}return t}getVisibleTextEditorControls(e){return this.doGetVisibleTextEditorControls(M(this.editorGroupsContainer.getGroups(e===S.SEQUENTIAL?C.GRID_APPEARANCE:C.MOST_RECENTLY_ACTIVE).map(t=>t.activeEditorPane)))}get visibleEditors(){return M(this.editorGroupsContainer.groups.map(e=>e.activeEditor))}async openEditor(e,t,i){let r,s=B(e)?t:e.options,o;if(gi(t)&&(i=t),!B(e)){const n=await this.editorResolverService.resolveEditor(e,i);if(n===De.ABORT)return;Re(n)&&(r=n.editor,s=n.options,o=n.group)}if(r||(r=B(e)?e:await this.textEditorService.resolveTextEditor(e)),!o){let n;const a=this.instantiationService.invokeFunction(ut,{editor:r,options:s},i);a instanceof Promise?[o,n]=await a:[o,n]=a,n&&(s={...s,activation:n})}return o.openEditor(r,s)}async openEditors(e,t,i){if(i?.validateTrust&&!await this.handleWorkspaceTrust(e))return[];const r=new Map;for(const o of e){let n,a;if(!oe(o)){const u=await this.editorResolverService.resolveEditor(o,t);if(u===De.ABORT)continue;Re(u)&&(n=u,a=u.group)}if(n||(n=oe(o)?o:{editor:await this.textEditorService.resolveTextEditor(o),options:o.options}),!a){const u=this.instantiationService.invokeFunction(ut,n,t);u instanceof Promise?[a]=await u:[a]=u}let c=r.get(a);c||(c=[],r.set(a,c)),c.push(n)}const s=[];for(const[o,n]of r)s.push(o.openEditors(n));return M(await Ae.settled(s))}async handleWorkspaceTrust(e){const{resources:t,diffMode:i,mergeMode:r}=this.extractEditorResources(e);switch(await this.workspaceTrustRequestService.requestOpenFilesTrust(t)){case we.Open:return!0;case we.OpenInNewWindow:return await this.hostService.openWindow(t.map(o=>({fileUri:o})),{forceNewWindow:!0,diffMode:i,mergeMode:r}),!1;case we.Cancel:return!1}}extractEditorResources(e){const t=new it;let i=!1,r=!1;for(const s of e)if(oe(s)){const o=Q.getOriginalUri(s.editor,{supportSideBySide:m.BOTH});g.isUri(o)?t.add(o):o&&(o.primary&&t.add(o.primary),o.secondary&&t.add(o.secondary),i=s.editor instanceof Dt)}else Rt(s)&&(g.isUri(s.input1)&&t.add(s.input1.resource),g.isUri(s.input2)&&t.add(s.input2.resource),g.isUri(s.base)&&t.add(s.base.resource),g.isUri(s.result)&&t.add(s.result.resource),r=!0),At(s)?(g.isUri(s.original.resource)&&t.add(s.original.resource),g.isUri(s.modified.resource)&&t.add(s.modified.resource),i=!0):wt(s)&&t.add(s.resource);return{resources:Array.from(t.keys()),diffMode:i,mergeMode:r}}isOpened(e){return this.editorsObserver.hasEditor({resource:this.uriIdentityService.asCanonicalUri(e.resource),typeId:e.typeId,editorId:e.editorId})}isVisible(e){for(const t of this.editorGroupsContainer.groups)if(t.activeEditor?.matches(e))return!0;return!1}async closeEditor({editor:e,groupId:t},i){await this.editorGroupsContainer.getGroup(t)?.closeEditor(e,i)}async closeEditors(e,t){const i=new Map;for(const{editor:r,groupId:s}of e){const o=this.editorGroupsContainer.getGroup(s);if(!o)continue;let n=i.get(o);n||(n=[],i.set(o,n)),n.push(r)}for(const[r,s]of i)await r.closeEditors(s,t)}findEditors(e,t,i){const r=g.isUri(e)?e:e.resource,s=g.isUri(e)?void 0:e.typeId;if(t?.supportSideBySide!==m.ANY&&t?.supportSideBySide!==m.SECONDARY&&!this.editorsObserver.hasEditors(r))return g.isUri(e)||rt(i)?[]:void 0;if(rt(i)){const o=[];for(const n of this.editorGroupsContainer.getGroups(t?.order===S.SEQUENTIAL?C.GRID_APPEARANCE:C.MOST_RECENTLY_ACTIVE)){const a=[];if(g.isUri(e))a.push(...this.findEditors(e,t,n));else{const c=this.findEditors(e,t,n);c&&a.push(c)}o.push(...a.map(c=>({editor:c,groupId:n.id})))}return o}else{const o=typeof i=="number"?this.editorGroupsContainer.getGroup(i):i;if(g.isUri(e))return o?o.findEditors(r,t):[];{if(!o)return;const n=o.findEditors(r,t);for(const a of n)if(a.typeId===s)return a;return}}}async replaceEditors(e,t){const i=typeof t=="number"?this.editorGroupsContainer.getGroup(t):t,r=[];for(const s of e){let o;if(!B(s.replacement)){const n=await this.editorResolverService.resolveEditor(s.replacement,i);if(n===De.ABORT)continue;Re(n)&&(o={editor:s.editor,replacement:n.editor,options:n.options,forceReplaceDirty:s.forceReplaceDirty})}o||(o={editor:s.editor,replacement:st(s)?s.replacement:await this.textEditorService.resolveTextEditor(s.replacement),options:st(s)?s.options:s.replacement.options,forceReplaceDirty:s.forceReplaceDirty}),r.push(o)}return i?.replaceEditors(r)}async save(e,t){Array.isArray(e)||(e=[e]);const i=this.getUniqueEditors(e),r=[],s=[];if(t?.saveAs)s.push(...i);else for(const{groupId:n,editor:a}of i)a.hasCapability(f.Untitled)?s.push({groupId:n,editor:a}):r.push({groupId:n,editor:a});const o=await Ae.settled(r.map(({groupId:n,editor:a})=>(t?.reason===p.EXPLICIT&&this.editorGroupsContainer.getGroup(n)?.pinEditor(a),a.save(n,t))));for(const{groupId:n,editor:a}of s){if(a.isDisposed())continue;const u={pinned:!0,viewState:(await this.openEditor(a,n))?.getViewState()},l=t?.saveAs?await a.saveAs(n,t):await a.save(n,t);if(o.push(l),!l)break;if(!a.matches(l)){const I=a.hasCapability(f.Untitled)?this.editorGroupsContainer.groups.map(H=>H.id):[n];for(const H of I)l instanceof Ei?await this.replaceEditors([{editor:a,replacement:l,options:u}],H):await this.replaceEditors([{editor:a,replacement:{...l,options:u}}],H)}}return{success:o.every(n=>!!n),editors:M(o)}}saveAll(e){return this.save(this.getAllModifiedEditors(e),e)}async revert(e,t){Array.isArray(e)||(e=[e]);const i=this.getUniqueEditors(e);return await Ae.settled(i.map(async({groupId:r,editor:s})=>(this.editorGroupsContainer.getGroup(r)?.pinEditor(s),s.revert(r,t)))),!i.some(({editor:r})=>r.isDirty())}async revertAll(e){return this.revert(this.getAllModifiedEditors(e),e)}getAllModifiedEditors(e){const t=[];for(const i of this.editorGroupsContainer.getGroups(C.MOST_RECENTLY_ACTIVE))for(const r of i.getEditors(S.MOST_RECENTLY_ACTIVE))r.isModified()&&((typeof e?.includeUntitled=="boolean"||!e?.includeUntitled?.includeScratchpad)&&r.hasCapability(f.Scratchpad)||!e?.includeUntitled&&r.hasCapability(f.Untitled)||e?.excludeSticky&&i.isSticky(r)||t.push({groupId:i.id,editor:r}));return t}getUniqueEditors(e){const t=[];for(const{editor:i,groupId:r}of e)t.some(s=>s.editor.matches(i))||t.push({editor:i,groupId:r});return t}dispose(){super.dispose(),this.activeOutOfWorkspaceWatchers.forEach(e=>V(e)),this.activeOutOfWorkspaceWatchers.clear()}};ft=Me=O([h(1,_),h(2,Z),h(3,te),h(4,Ve),h(5,mi),h(6,We),h(7,Ot),h(8,vi),h(9,_t),h(10,Si)],ft);var ne,k;let ae=(k=class extends bt{get typeId(){return ne.ID}get editorId(){return J.id}constructor(e,t,i,r,s,o,n,a,c,u,l){super(e.resource,void 0,r,t,i,s,a,u,l),this.model=e,this.environmentService=o,this.pathService=n,this.textModelService=c,this.modelResolve=void 0,this.modelDisposables=this._register(new U),this.cachedUntitledTextEditorModelReference=void 0,this.registerModelListeners(e),this._register(this.textFileService.untitled.onDidCreate(I=>this.onDidCreateUntitledModel(I)))}registerModelListeners(e){this.modelDisposables.clear(),this.modelDisposables.add(e.onDidChangeDirty(()=>this._onDidChangeDirty.fire())),this.modelDisposables.add(e.onDidChangeName(()=>this._onDidChangeLabel.fire())),this.modelDisposables.add(e.onDidRevert(()=>this.dispose()))}onDidCreateUntitledModel(e){q(e.resource,this.model.resource)&&e!==this.model&&(this.model=e,this.registerModelListeners(e))}getName(){return this.model.name}getDescription(e=yi.MEDIUM){if(!this.model.hasAssociatedFilePath){const t=this.resource.path;return t!==this.getName()?t:void 0}return super.getDescription(e)}getTitle(e){if(!this.model.hasAssociatedFilePath){const t=this.getName(),i=this.getDescription();return i&&i!==t?`${t} • ${i}`:t}return super.getTitle(e)}isDirty(){return this.model.isDirty()}getEncoding(){return this.model.getEncoding()}setEncoding(e,t){return this.model.setEncoding(e)}get hasLanguageSetExplicitly(){return this.model.hasLanguageSetExplicitly}get hasAssociatedFilePath(){return this.model.hasAssociatedFilePath}setLanguageId(e,t){this.model.setLanguageId(e,t)}getLanguageId(){return this.model.getLanguageId()}async resolve(){return this.modelResolve||(this.modelResolve=(async()=>{this.cachedUntitledTextEditorModelReference=await this.textModelService.createModelReference(this.resource)})()),await this.modelResolve,this.isDisposed()&&this.disposeModelReference(),this.model}toUntyped(e){const t={resource:this.model.hasAssociatedFilePath?Ci(this.model.resource,this.environmentService.remoteAuthority,this.pathService.defaultUriScheme):this.resource,forceUntitled:!0,options:{override:this.editorId}};return typeof e?.preserveViewState=="number"&&(t.encoding=this.getEncoding(),t.languageId=this.getLanguageId(),t.contents=this.model.isModified()?this.model.textEditorModel?.getValue():void 0,t.options.viewState=_e(this,e.preserveViewState,this.editorService),typeof t.contents=="string"&&!this.model.hasAssociatedFilePath&&!e.preserveResource&&(t.resource=void 0)),t}matches(e){return this===e?!0:e instanceof ne?q(e.resource,this.resource):Ii(e)?super.matches(e):!1}dispose(){this.modelResolve=void 0,this.disposeModelReference(),super.dispose()}disposeModelReference(){V(this.cachedUntitledTextEditorModelReference),this.cachedUntitledTextEditorModelReference=void 0}},ne=k,k.ID="workbench.editors.untitledEditorInput",k);ae=ne=O([h(1,ke),h(2,Tt),h(3,L),h(4,te),h(5,Di),h(6,Pt),h(7,Ue),h(8,Lt),h(9,ue),h(10,xt)],ae);var Y;class mr extends Error{constructor(e,t){super(e),this.name="FileEditorInputLeakError",this.stack=t}}var A;let pt=(A=class extends pe{constructor(e,t,i,r,s){super(),this.untitledTextEditorService=e,this.instantiationService=t,this.uriIdentityService=i,this.fileService=r,this.editorResolverService=s,this.editorInputCache=new j,this.fileEditorFactory=le.as(fe.EditorFactory).getFileEditorFactory(),this.mapLeakToCounter=new Map,this.registerDefaultEditor()}registerDefaultEditor(){this._register(this.editorResolverService.registerEditor("*",{id:J.id,label:J.displayName,detail:J.providerDisplayName,priority:Ri.builtin},{},{createEditorInput:e=>({editor:this.createTextEditor(e)}),createUntitledEditorInput:e=>({editor:this.createTextEditor(e)}),createDiffEditorInput:e=>({editor:this.createTextEditor(e)})}))}async resolveTextEditor(e){return this.createTextEditor(e)}createTextEditor(e){if(Rt(e))return this.createTextEditor(e.result);if(At(e)){const r=this.createTextEditor(e.original),s=this.createTextEditor(e.modified);return this.instantiationService.createInstance(Dt,e.label,e.description,r,s,void 0)}if(Ai(e)){const r=this.createTextEditor(e.primary),s=this.createTextEditor(e.secondary);return this.instantiationService.createInstance($,e.label,e.description,s,r)}const t=e;if(t.forceUntitled||!t.resource||t.resource.scheme===ee.untitled){const r={languageId:t.languageId,initialValue:t.contents,encoding:t.encoding};let s;return t.resource?.scheme===ee.untitled?s=this.untitledTextEditorService.create({untitledResource:t.resource,...r}):s=this.untitledTextEditorService.create({associatedResource:t.resource,...r}),this.createOrGetCached(s.resource,()=>this.instantiationService.createInstance(ae,s))}const i=e;if(i.resource instanceof g){const r=i.label||wi(i.resource),s=i.resource,o=this.uriIdentityService.asCanonicalUri(s);return this.createOrGetCached(o,()=>i.forceFile||this.fileService.hasProvider(o)?this.fileEditorFactory.createFileEditor(o,s,i.label,i.description,i.encoding,i.languageId,i.contents,this.instantiationService):this.instantiationService.createInstance(ot,o,i.label,i.description,i.languageId,i.contents),n=>{n instanceof ae||(n instanceof ot?(r&&n.setName(r),i.description&&n.setDescription(i.description),i.languageId&&n.setPreferredLanguageId(i.languageId),typeof i.contents=="string"&&n.setPreferredContents(i.contents)):(n.setPreferredResource(s),i.label&&n.setPreferredName(i.label),i.description&&n.setPreferredDescription(i.description),i.encoding&&n.setPreferredEncoding(i.encoding),i.languageId&&n.setPreferredLanguageId(i.languageId),typeof i.contents=="string"&&n.setPreferredContents(i.contents)))})}throw new Error(`ITextEditorService: Unable to create texteditor from ${JSON.stringify(e)}`)}createOrGetCached(e,t,i){let r=this.editorInputCache.get(e);if(r)return i?.(r),r;r=t(),this.editorInputCache.set(e,r);const s=this.trackLeaks(r);return y.once(r.onWillDispose)(()=>{this.editorInputCache.delete(e),s&&this.untrackLeaks(s)}),r}trackLeaks(e){if(Y.LEAK_REPORTED||this.editorInputCache.size<Y.LEAK_TRACKING_THRESHOLD)return;const t=`${e.resource.scheme}#${e.typeId||"<no typeId>"}#${e.editorId||"<no editorId>"}
|
|
1
|
+
import{fu as jt,fg as qt,cR as y,hS as Q,hT as m,f as O,g as h,m as mt,W as Z,by as Fe,hQ as ue,c1 as vt,bX as L,cc as _,sW as Zt,E as R,h3 as Xt,d as U,dx as me,ez as E,dy as G,ai as $e,cG as Qt,h5 as je,hg as ie,s as K,aP as le,hi as fe,mr as qe,iY as $,bs as j,U as g,iA as Ze,sX as Jt,sY as ei,a5 as Xe,il as Qe,Z as ti,h as Ve,oW as St,dI as ii,sZ as Je,s_ as yt,s$ as ri,ma as oe,hG as Ct,iG as et,t0 as si,co as C,iz as B,cD as f,ix as oi,D as pe,t1 as ni,mj as q,i8 as S,kg as tt,d8 as V,js as ai,t2 as ve,aJ as Se,aK as di,cr as M,ob as it,kE as ci,lm as ye,t3 as hi,x as It,ms as ui,bt as li,eW as fi,eA as Ce,iV as Ie,t4 as pi,sT as gi,m9 as De,iS as Re,cq as Ae,t5 as we,er as Dt,mf as Rt,mb as At,ct as wt,bd as rt,t6 as st,jh as p,cC as Ei,bA as te,ci as mi,kt as We,iR as Ot,sV as vi,dO as _t,qC as Si,cy as bt,jn as J,j9 as yi,qA as Ci,t7 as _e,mh as Ii,n_ as ke,i4 as Tt,V as Di,iJ as Pt,je as Ue,o6 as Lt,sI as xt,cF as Ri,m8 as Ai,a0 as ee,hN as wi,q8 as ot,z as Oi,iK as _i,t8 as bi,mI as Ti,t9 as x,jg as v,sr as nt,t as Pi,of as Li,O as xi,qa as Mi,X as Ni,Y as Gi,sy as Mt,sx as Oe,ss as Fi,su as Vi,ta as Wi,tb as ki,iy as Ui,tc as Hi,jB as Bi,K as Yi,td as Ki,ks as at,bW as zi,te as $i,tf as dt,hO as re,tg as ji,cW as Nt,ki as qi,th as ct,cS as ge,ti as Zi,bN as Ee,bQ as w,$ as T,tj as Xi,bP as be,tk as Qi,tl as Ji,bV as He,tm as er,tn as tr,to as ir,j as Gt,cM as Ft,oJ as rr,oB as sr,c0 as or,d4 as ht,bY as nr,g0 as ar}from"./index-GPQU4rv1.js";const dr=Object.freeze(Object.defineProperty({__proto__:null},Symbol.toStringTag,{value:"Module"}));let Te=class extends jt{constructor(e,t,i,r,s,o,n,a,c,u){super(e,t,r,a,o),this.instantiationService=s,this.textResourceConfigurationService=n,this.editorService=c,this.editorGroupService=u,this.groupListener=this._register(new qt),this.viewState=this.getEditorMemento(u,n,i,100)}setEditorVisible(e){this.groupListener.value=this.group.onWillCloseEditor(t=>this.onWillCloseEditor(t)),super.setEditorVisible(e)}onWillCloseEditor(e){const t=e.editor;t===this.input&&this.updateEditorViewState(t)}clearInput(){this.updateEditorViewState(this.input),super.clearInput()}saveState(){this.updateEditorViewState(this.input),super.saveState()}updateEditorViewState(e){if(!e||!this.tracksEditorViewState(e))return;const t=this.toEditorViewStateResource(e);t&&(this.tracksDisposedEditorViewState()||(this.editorViewStateDisposables||(this.editorViewStateDisposables=new Map),this.editorViewStateDisposables.has(e)||this.editorViewStateDisposables.set(e,y.once(e.onWillDispose)(()=>{this.clearEditorViewState(t,this.group),this.editorViewStateDisposables?.delete(e)}))),e.isDisposed()&&!this.tracksDisposedEditorViewState()||!this.shouldRestoreEditorViewState(e)&&!this.group.contains(e)?this.clearEditorViewState(t,this.group):e.isDisposed()||this.saveEditorViewState(t))}shouldRestoreEditorViewState(e,t){return t?.newInGroup?this.textResourceConfigurationService.getValue(Q.getOriginalUri(e,{supportSideBySide:m.PRIMARY}),"workbench.editor.restoreViewState")!==!1:!0}getViewState(){const e=this.input;if(!e||!this.tracksEditorViewState(e))return;const t=this.toEditorViewStateResource(e);if(t)return this.computeEditorViewState(t)}saveEditorViewState(e){const t=this.computeEditorViewState(e);t&&this.viewState.saveEditorState(this.group,e,t)}loadEditorViewState(e,t){if(!e||!this.tracksEditorViewState(e)||!this.shouldRestoreEditorViewState(e,t))return;const i=this.toEditorViewStateResource(e);if(i)return this.viewState.loadEditorState(this.group,i)}moveEditorViewState(e,t,i){return this.viewState.moveEditorState(e,t,i)}clearEditorViewState(e,t){this.viewState.clearEditorState(e,t)}dispose(){if(super.dispose(),this.editorViewStateDisposables){for(const[,e]of this.editorViewStateDisposables)e.dispose();this.editorViewStateDisposables=void 0}}tracksDisposedEditorViewState(){return!1}};Te=O([h(3,mt),h(4,Z),h(5,Fe),h(6,ue),h(7,vt),h(8,L),h(9,_)],Te);var F;ti(dr);function cr(d){const e=d;return typeof e?.primary=="object"&&typeof e.secondary=="object"}var P;let Pe=(P=class extends Te{get minimumPrimaryWidth(){return this.primaryEditorPane?this.primaryEditorPane.minimumWidth:0}get maximumPrimaryWidth(){return this.primaryEditorPane?this.primaryEditorPane.maximumWidth:Number.POSITIVE_INFINITY}get minimumPrimaryHeight(){return this.primaryEditorPane?this.primaryEditorPane.minimumHeight:0}get maximumPrimaryHeight(){return this.primaryEditorPane?this.primaryEditorPane.maximumHeight:Number.POSITIVE_INFINITY}get minimumSecondaryWidth(){return this.secondaryEditorPane?this.secondaryEditorPane.minimumWidth:0}get maximumSecondaryWidth(){return this.secondaryEditorPane?this.secondaryEditorPane.maximumWidth:Number.POSITIVE_INFINITY}get minimumSecondaryHeight(){return this.secondaryEditorPane?this.secondaryEditorPane.minimumHeight:0}get maximumSecondaryHeight(){return this.secondaryEditorPane?this.secondaryEditorPane.maximumHeight:Number.POSITIVE_INFINITY}set minimumWidth(e){}set maximumWidth(e){}set minimumHeight(e){}set maximumHeight(e){}get minimumWidth(){return this.minimumPrimaryWidth+this.minimumSecondaryWidth}get maximumWidth(){return this.maximumPrimaryWidth+this.maximumSecondaryWidth}get minimumHeight(){return this.minimumPrimaryHeight+this.minimumSecondaryHeight}get maximumHeight(){return this.maximumPrimaryHeight+this.maximumSecondaryHeight}constructor(e,t,i,r,s,o,n,a,c){super(F.ID,e,F.VIEW_STATE_PREFERENCE_KEY,t,i,s,n,r,a,c),this.configurationService=o,this.onDidCreateEditors=this._register(new R),this._onDidChangeSizeConstraints=this._register(new Xt),this.onDidChangeSizeConstraints=y.any(this.onDidCreateEditors.event,this._onDidChangeSizeConstraints.event),this._onDidChangeSelection=this._register(new R),this.onDidChangeSelection=this._onDidChangeSelection.event,this.primaryEditorPane=void 0,this.secondaryEditorPane=void 0,this.splitviewDisposables=this._register(new U),this.editorDisposables=this._register(new U),this.dimension=new me(0,0),this.lastFocusedSide=void 0,this.orientation=this.configurationService.getValue(F.SIDE_BY_SIDE_LAYOUT_SETTING)==="vertical"?E.VERTICAL:E.HORIZONTAL,this.registerListeners()}registerListeners(){this._register(this.configurationService.onDidChangeConfiguration(e=>this.onConfigurationUpdated(e)))}onConfigurationUpdated(e){e.affectsConfiguration(F.SIDE_BY_SIDE_LAYOUT_SETTING)&&(this.orientation=this.configurationService.getValue(F.SIDE_BY_SIDE_LAYOUT_SETTING)==="vertical"?E.VERTICAL:E.HORIZONTAL,this.splitview&&this.recreateSplitview())}recreateSplitview(){const e=G(this.getContainer()),t=this.getSplitViewRatio();this.splitview&&(this.splitview.el.remove(),this.splitviewDisposables.clear()),this.createSplitView(e,t),this.layout(this.dimension)}getSplitViewRatio(){let e;if(this.splitview){const t=this.splitview.getViewSize(0),i=this.splitview.getViewSize(1);if(Math.abs(t-i)>1){const r=this.splitview.orientation===E.HORIZONTAL?this.dimension.width:this.dimension.height;e=t/r}}return e}createEditor(e){e.classList.add("side-by-side-editor"),this.secondaryEditorContainer=$e(".side-by-side-editor-container.editor-instance"),this.primaryEditorContainer=$e(".side-by-side-editor-container.editor-instance"),this.createSplitView(e)}createSplitView(e,t){this.splitview=this.splitviewDisposables.add(new Qt(e,{orientation:this.orientation})),this.splitviewDisposables.add(this.splitview.onDidSashReset(()=>this.splitview?.distributeViewSizes())),this.orientation===E.HORIZONTAL?this.splitview.orthogonalEndSash=this._boundarySashes?.bottom:(this.splitview.orthogonalStartSash=this._boundarySashes?.left,this.splitview.orthogonalEndSash=this._boundarySashes?.right);let i=je.Distribute,r=je.Distribute;if(t){const n=this.splitview.orientation===E.HORIZONTAL?this.dimension.width:this.dimension.height;i=Math.round(n*t),r=n-i,this.splitview.layout(this.orientation===E.HORIZONTAL?this.dimension.width:this.dimension.height)}const s=G(this.secondaryEditorContainer);this.splitview.addView({element:s,layout:n=>this.layoutPane(this.secondaryEditorPane,n),minimumSize:this.orientation===E.HORIZONTAL?ie.width:ie.height,maximumSize:Number.POSITIVE_INFINITY,onDidChange:y.None},i);const o=G(this.primaryEditorContainer);this.splitview.addView({element:o,layout:n=>this.layoutPane(this.primaryEditorPane,n),minimumSize:this.orientation===E.HORIZONTAL?ie.width:ie.height,maximumSize:Number.POSITIVE_INFINITY,onDidChange:y.None},r),this.updateStyles()}getTitle(){return this.input?this.input.getName():K(3407,"Side by Side Editor")}async setInput(e,t,i,r){const s=this.input;await super.setInput(e,t,i,r),(!s||!e.matches(s))&&(s&&this.disposeEditors(),this.createEditors(e));const{primary:o,secondary:n,viewState:a}=this.loadViewState(e,t,i);if(this.lastFocusedSide=a?.focus,typeof a?.ratio=="number"&&this.splitview){const c=this.splitview.orientation===E.HORIZONTAL?this.dimension.width:this.dimension.height;this.splitview.resizeView(0,Math.round(c*a.ratio))}else this.splitview?.distributeViewSizes();await Promise.all([this.secondaryEditorPane?.setInput(e.secondary,n,i,r),this.primaryEditorPane?.setInput(e.primary,o,i,r)]),typeof t?.target=="number"&&(this.lastFocusedSide=t.target)}loadViewState(e,t,i){const r=cr(t?.viewState)?t?.viewState:this.loadEditorViewState(e,i);let s=Object.create(null),o;return t?.target===m.SECONDARY?o={...t}:s={...t},s.viewState=r?.primary,r?.secondary&&(o?o.viewState=r?.secondary:o={viewState:r.secondary}),{primary:s,secondary:o,viewState:r}}createEditors(e){this.secondaryEditorPane=this.doCreateEditor(e.secondary,G(this.secondaryEditorContainer)),this.primaryEditorPane=this.doCreateEditor(e.primary,G(this.primaryEditorContainer)),this.layout(this.dimension),this._onDidChangeSizeConstraints.input=y.any(y.map(this.secondaryEditorPane.onDidChangeSizeConstraints,()=>{}),y.map(this.primaryEditorPane.onDidChangeSizeConstraints,()=>{})),this.onDidCreateEditors.fire(void 0),this.editorDisposables.add(this.primaryEditorPane.onDidFocus(()=>this.onDidFocusChange(m.PRIMARY))),this.editorDisposables.add(this.secondaryEditorPane.onDidFocus(()=>this.onDidFocusChange(m.SECONDARY)))}doCreateEditor(e,t){const i=le.as(fe.EditorPane).getEditorPane(e);if(!i)throw new Error("No editor pane descriptor for editor found");const r=i.instantiate(this.instantiationService,this.group);return r.create(t),r.setVisible(this.isVisible()),qe(r)&&this.editorDisposables.add(r.onDidChangeSelection(s=>this._onDidChangeSelection.fire(s))),this.editorDisposables.add(r),r}onDidFocusChange(e){this.lastFocusedSide=e,this._onDidChangeControl.fire()}getSelection(){const e=this.getLastFocusedEditorPane();if(qe(e)){const t=e.getSelection();if(t)return new Be(t,e===this.primaryEditorPane?m.PRIMARY:m.SECONDARY)}}setOptions(e){super.setOptions(e),typeof e?.target=="number"&&(this.lastFocusedSide=e.target),this.getLastFocusedEditorPane()?.setOptions(e)}setEditorVisible(e){this.primaryEditorPane?.setVisible(e),this.secondaryEditorPane?.setVisible(e),super.setEditorVisible(e)}clearInput(){super.clearInput(),this.primaryEditorPane?.clearInput(),this.secondaryEditorPane?.clearInput(),this.disposeEditors()}focus(){super.focus(),this.getLastFocusedEditorPane()?.focus()}getLastFocusedEditorPane(){return this.lastFocusedSide===m.SECONDARY?this.secondaryEditorPane:this.primaryEditorPane}layout(e){this.dimension=e,G(this.splitview).layout(this.orientation===E.HORIZONTAL?e.width:e.height)}setBoundarySashes(e){this._boundarySashes=e,this.splitview&&(this.splitview.orthogonalEndSash=e.bottom)}layoutPane(e,t){e?.layout(this.orientation===E.HORIZONTAL?new me(t,this.dimension.height):new me(this.dimension.width,t))}getControl(){return this.getLastFocusedEditorPane()?.getControl()}getPrimaryEditorPane(){return this.primaryEditorPane}getSecondaryEditorPane(){return this.secondaryEditorPane}tracksEditorViewState(e){return e instanceof $}computeEditorViewState(e){if(!this.input||!j(e,this.toEditorViewStateResource(this.input)))return;const t=this.primaryEditorPane?.getViewState(),i=this.secondaryEditorPane?.getViewState();if(!(!t||!i))return{primary:t,secondary:i,focus:this.lastFocusedSide,ratio:this.getSplitViewRatio()}}toEditorViewStateResource(e){let t,i;if(e instanceof $&&(t=e.primary.resource,i=e.secondary.resource),!(!i||!t))return g.from({scheme:"sideBySide",path:`${Ze(i.toString())}${Ze(t.toString())}`})}updateStyles(){super.updateStyles(),this.primaryEditorContainer&&(this.orientation===E.HORIZONTAL?(this.primaryEditorContainer.style.borderLeftWidth="1px",this.primaryEditorContainer.style.borderLeftStyle="solid",this.primaryEditorContainer.style.borderLeftColor=this.getColor(Jt)??"",this.primaryEditorContainer.style.borderTopWidth="0"):(this.primaryEditorContainer.style.borderTopWidth="1px",this.primaryEditorContainer.style.borderTopStyle="solid",this.primaryEditorContainer.style.borderTopColor=this.getColor(ei)??"",this.primaryEditorContainer.style.borderLeftWidth="0"))}dispose(){this.disposeEditors(),super.dispose()}disposeEditors(){this.editorDisposables.clear(),this.secondaryEditorPane=void 0,this.primaryEditorPane=void 0,this.lastFocusedSide=void 0,this.secondaryEditorContainer&&Xe(this.secondaryEditorContainer),this.primaryEditorContainer&&Xe(this.primaryEditorContainer)}},F=P,P.ID=Zt,P.SIDE_BY_SIDE_LAYOUT_SETTING="workbench.editor.splitInGroupLayout",P.VIEW_STATE_PREFERENCE_KEY="sideBySideEditorViewState",P);Pe=F=O([h(1,mt),h(2,Z),h(3,vt),h(4,Fe),h(5,Ve),h(6,ue),h(7,L),h(8,_)],Pe);class Be{constructor(e,t){this.selection=e,this.side=t}compare(e){return e instanceof Be?this.side!==e.side?Qe.DIFFERENT:this.selection.compare(e.selection):Qe.DIFFERENT}restore(e){const t={...e,target:this.side};return this.selection.restore(t)}}function hr(d,e,t,i){const r=ur(d,e,t,i),s=r.length&&r[0].preserveFocus||!1,o={groupedEditors:[],preserveFocus:s};for(const n of r){const a=pr(n,t);if(!a)continue;const{group:c,editor:u}=a;let l;for(const I of o.groupedEditors)if(I.group.id===c.id){l=I;break}l||(l={group:c,editors:[]},o.groupedEditors.push(l)),u&&l.editors.push(u)}return o}function ur(d,e,t,i){const r=i.lastFocusedList;let s=r instanceof St&&r.getHTMLElement()===ii(),o=fr(d,s,e,t,i);if(!o){const a=t.activeGroup,c=a.activeEditor;o={groupId:a.id,editorIndex:c?a.getIndexOfEditor(c):void 0},s=!1}const n=Vt(o,s,e,t,i);return lr(o,n)}function lr(d,e){if(e.length<=1)return e;const t=e.findIndex(i=>i.groupId===d.groupId&&i.editorIndex===d.editorIndex);if(t!==-1)e.splice(t,1),e.unshift(d);else if(d.editorIndex===void 0)e.unshift(d);else throw new Error("Editor context not found in multi editor context");return e}function fr(d,e,t,i,r){const s=d.filter(o=>Je(o)||g.isUri(o));for(const o of s)if(Je(o))return o;for(const o of s){const n=t.findEditors(o);if(n.length){const a=n[0],c=i.getGroup(a.groupId);return{groupId:a.groupId,editorIndex:c?.getIndexOfEditor(a.editor)}}}if(e){const o=r.lastFocusedList;for(const n of o.getFocusedElements())if(Wt(n))return Le(n,void 0,i)}}function Vt(d,e,t,i,r){if(e){const o=r.lastFocusedList.getSelectedElements().filter(Wt);if(o.length>1)return o.map(n=>Le(n,d.preserveFocus,i));if(o.length===0)return Vt(d,!1,t,i,r)}else{const s=i.getGroup(d.groupId),o=d.editorIndex!==void 0?s?.getEditorByIndex(d.editorIndex):s?.activeEditor;if(s&&o&&s.isSelected(o))return s.selectedEditors.map(n=>Le({editor:n,groupId:s.id},d.preserveFocus,i))}return[d]}function Le(d,e,t){if(yt(d))return{groupId:d.id,editorIndex:void 0,preserveFocus:e};const i=t.getGroup(d.groupId);return{groupId:d.groupId,editorIndex:i?i.getIndexOfEditor(d.editor):-1,preserveFocus:e}}function Wt(d){return yt(d)||ri(d)}function pr(d,e){const t=e.getGroup(d.groupId);if(!t)return;if(d.editorIndex===void 0)return{group:t,editor:void 0};const i=t.getEditorByIndex(d.editorIndex);return{group:t,editor:i}}function ut(d,e,t){const i=d.get(_),r=d.get(Ve),s=gr(e,t,i,r);return s instanceof Promise?s.then(o=>lt(o,e,t,i)):lt(s,e,t,i)}function lt(d,e,t,i){let r;return i.activeGroup!==d&&e.options&&!e.options.inactive&&e.options.preserveFocus&&typeof e.options.activation!="number"&&t!==Ct&&(r=oi.ACTIVATE),[d,r]}function gr(d,e,t,i){let r;const s=oe(d)?d.editor:d,o=d.options;if(e&&typeof e!="number")r=e;else if(typeof e=="number"&&e>=0)r=t.getGroup(e);else if(e===Ct){const n=et(i);let a=t.findGroup({direction:n});(!a||se(a,s))&&(a=t.addGroup(t.activeGroup,n)),r=a}else if(e===si)r=t.createAuxiliaryEditorPart({bounds:o?.auxiliary?.bounds,compact:o?.auxiliary?.compact,alwaysOnTop:o?.auxiliary?.alwaysOnTop}).then(n=>n.activeGroup);else if(!o||typeof o.index!="number"){const n=t.getGroups(C.MOST_RECENTLY_ACTIVE);if(o?.revealIfVisible){for(const a of n)if(Er(a,s)){r=a;break}}if(!r&&(o?.revealIfOpened||i.getValue("workbench.editor.revealIfOpen")||B(s)&&s.hasCapability(f.Singleton))){let a,c;for(const u of n)if(kt(u,s)&&(c||(c=u),!a&&u.isActive(s)&&(a=u)),c&&a)break;r=a||c}}if(!r){let n=t.activeGroup;if(se(n,s)){for(const a of t.getGroups(C.MOST_RECENTLY_ACTIVE))if(!se(a,s)){n=a;break}se(n,s)?r=t.addGroup(n,et(i)):r=n}else r=n}return r}function se(d,e){return!(!d.isLocked||kt(d,e))}function Er(d,e){return d.activeEditor?d.activeEditor.matches(e):!1}function kt(d,e){for(const t of d.editors)if(t.matches(e))return!0;return!1}var X,W;let xe=(W=class extends pe{get count(){return this.mostRecentEditorsMap.size}get editors(){return[...this.mostRecentEditorsMap.values()]}hasEditor(e){return this.editorsPerResourceCounter.get(e.resource)?.has(this.toIdentifier(e))??!1}hasEditors(e){return this.editorsPerResourceCounter.has(e)}toIdentifier(e,t){return typeof e!="string"?this.toIdentifier(e.typeId,e.editorId):t?`${e}/${t}`:e}constructor(e,t,i){super(),this.editorGroupService=t,this.storageService=i,this.keyMap=new Map,this.mostRecentEditorsMap=new ni,this.editorsPerResourceCounter=new q,this._onDidMostRecentlyActiveEditorsChange=this._register(new R),this.onDidMostRecentlyActiveEditorsChange=this._onDidMostRecentlyActiveEditorsChange.event,this.editorGroupsContainer=e??t,this.isScoped=!!e,this.registerListeners(),this.loadState()}registerListeners(){this._register(this.editorGroupsContainer.onDidAddGroup(e=>this.onGroupAdded(e))),this._register(this.editorGroupService.onDidChangeEditorPartOptions(e=>this.onDidChangeEditorPartOptions(e))),this._register(this.storageService.onWillSaveState(()=>this.saveState()))}onGroupAdded(e){const t=e.getEditors(S.MOST_RECENTLY_ACTIVE);for(let i=t.length-1;i>=0;i--)this.addMostRecentEditor(e,t[i],!1,!0);this.editorGroupsContainer.activeGroup===e&&e.activeEditor&&this.addMostRecentEditor(e,e.activeEditor,!0,!1),this.registerGroupListeners(e)}registerGroupListeners(e){const t=new U;t.add(e.onDidModelChange(i=>{switch(i.kind){case tt.GROUP_ACTIVE:{this.editorGroupsContainer.activeGroup===e&&e.activeEditor&&this.addMostRecentEditor(e,e.activeEditor,!0,!1);break}case tt.EDITOR_OPEN:{i.editor&&(this.addMostRecentEditor(e,i.editor,!1,!0),this.ensureOpenedEditorsLimit({groupId:e.id,editor:i.editor},e.id));break}}})),t.add(e.onDidCloseEditor(i=>{this.removeMostRecentEditor(e,i.editor)})),t.add(e.onDidActiveEditorChange(i=>{i.editor&&this.addMostRecentEditor(e,i.editor,this.editorGroupsContainer.activeGroup===e,!1)})),y.once(e.onWillDispose)(()=>V(t))}onDidChangeEditorPartOptions(e){if(!ai(e.newPartOptions.limit,e.oldPartOptions.limit)){const t=this.editorGroupsContainer.activeGroup;let i;t.activeEditor&&(i={editor:t.activeEditor,groupId:t.id}),this.ensureOpenedEditorsLimit(i)}}addMostRecentEditor(e,t,i,r){const s=this.ensureKey(e,t),o=this.mostRecentEditorsMap.first;i||!o?this.mostRecentEditorsMap.set(s,s,o?ve.AsOld:void 0):(this.mostRecentEditorsMap.set(s,s,ve.AsOld),this.mostRecentEditorsMap.set(o,o,ve.AsOld)),r&&this.updateEditorResourcesMap(t,!0),this._onDidMostRecentlyActiveEditorsChange.fire()}updateEditorResourcesMap(e,t){let i,r,s;if(e instanceof $?(i=e.primary.resource,r=e.primary.typeId,s=e.primary.editorId):(i=e.resource,r=e.typeId,s=e.editorId),!i)return;const o=this.toIdentifier(r,s);if(t){let n=this.editorsPerResourceCounter.get(i);n||(n=new Map,this.editorsPerResourceCounter.set(i,n)),n.set(o,(n.get(o)??0)+1)}else{const n=this.editorsPerResourceCounter.get(i);if(n){const a=n.get(o)??0;a>1?n.set(o,a-1):(n.delete(o),n.size===0&&this.editorsPerResourceCounter.delete(i))}}}removeMostRecentEditor(e,t){this.updateEditorResourcesMap(t,!1);const i=this.findKey(e,t);if(i){this.mostRecentEditorsMap.delete(i);const r=this.keyMap.get(e.id);r&&r.delete(i.editor)&&r.size===0&&this.keyMap.delete(e.id),this._onDidMostRecentlyActiveEditorsChange.fire()}}findKey(e,t){const i=this.keyMap.get(e.id);if(i)return i.get(t)}ensureKey(e,t){let i=this.keyMap.get(e.id);i||(i=new Map,this.keyMap.set(e.id,i));let r=i.get(t);return r||(r={groupId:e.id,editor:t},i.set(t,r)),r}async ensureOpenedEditorsLimit(e,t){if(!this.editorGroupService.partOptions.limit?.enabled||typeof this.editorGroupService.partOptions.limit.value!="number"||this.editorGroupService.partOptions.limit.value<=0)return;const i=this.editorGroupService.partOptions.limit.value;if(this.editorGroupService.partOptions.limit?.perEditorGroup)if(typeof t=="number"){const r=this.editorGroupsContainer.getGroup(t);r&&await this.doEnsureOpenedEditorsLimit(i,r.getEditors(S.MOST_RECENTLY_ACTIVE).map(s=>({editor:s,groupId:t})),e)}else for(const r of this.editorGroupsContainer.groups)await this.ensureOpenedEditorsLimit(e,r.id);else await this.doEnsureOpenedEditorsLimit(i,[...this.mostRecentEditorsMap.values()],e)}async doEnsureOpenedEditorsLimit(e,t,i){let r;if(this.editorGroupService.partOptions.limit?.excludeDirty?r=t.filter(({editor:a})=>!(a.isDirty()&&!a.isSaving()||a.hasCapability(f.Scratchpad))):r=t,e>=r.length)return;const s=r.reverse().filter(({editor:a,groupId:c})=>!(a.isDirty()&&!a.isSaving()||a.hasCapability(f.Scratchpad)||i&&a===i.editor&&c===i.groupId||this.editorGroupsContainer.getGroup(c)?.isSticky(a)));let o=r.length-e;const n=new Map;for(const{groupId:a,editor:c}of s){let u=n.get(a);if(u||(u=[],n.set(a,u)),u.push(c),o--,o===0)break}for(const[a,c]of n){const u=this.editorGroupsContainer.getGroup(a);u&&await u.closeEditors(c,{preserveFocus:!0})}}saveState(){this.isScoped||(this.mostRecentEditorsMap.isEmpty()?this.storageService.remove(X.STORAGE_KEY,Se.WORKSPACE):this.storageService.store(X.STORAGE_KEY,JSON.stringify(this.serialize()),Se.WORKSPACE,di.MACHINE))}serialize(){const e=le.as(fe.EditorFactory),t=[...this.mostRecentEditorsMap.values()],i=new Map;return{entries:M(t.map(({editor:r,groupId:s})=>{const o=this.editorGroupsContainer.getGroup(s);if(!o)return;let n=i.get(o);n||(n=o.getEditors(S.SEQUENTIAL).filter(c=>e.getEditorSerializer(c)?.canSerialize(c)),i.set(o,n));const a=n.indexOf(r);if(a!==-1)return{groupId:s,index:a}}))}}async loadState(){(this.editorGroupsContainer===this.editorGroupService.mainPart||this.editorGroupsContainer===this.editorGroupService)&&await this.editorGroupService.whenReady;let e=!1;if(!this.isScoped){const t=this.storageService.get(X.STORAGE_KEY,Se.WORKSPACE);t&&(e=!0,this.deserialize(JSON.parse(t)))}if(!e){const t=this.editorGroupsContainer.getGroups(C.MOST_RECENTLY_ACTIVE);for(let i=t.length-1;i>=0;i--){const r=t[i],s=r.getEditors(S.MOST_RECENTLY_ACTIVE);for(let o=s.length-1;o>=0;o--)this.addMostRecentEditor(r,s[o],!0,!0)}}for(const t of this.editorGroupsContainer.groups)this.registerGroupListeners(t)}deserialize(e){const t=[];for(const{groupId:i,index:r}of e.entries){const s=this.editorGroupsContainer.getGroup(i);if(!s)continue;const o=s.getEditorByIndex(r);if(!o)continue;const n=this.ensureKey(s,o);t.push([n,n]),this.updateEditorResourcesMap(o,!0)}this.mostRecentEditorsMap.fromJSON(t)}},X=W,W.STORAGE_KEY="editors.mru",W);xe=X=O([h(1,_),h(2,Fe)],xe);var Me;let ft=Me=class extends pe{constructor(e,t,i,r,s,o,n,a,c,u,l){super(),this.editorGroupService=t,this.instantiationService=i,this.fileService=r,this.configurationService=s,this.contextService=o,this.uriIdentityService=n,this.editorResolverService=a,this.workspaceTrustRequestService=c,this.hostService=u,this.textEditorService=l,this._onDidActiveEditorChange=this._register(new R),this.onDidActiveEditorChange=this._onDidActiveEditorChange.event,this._onDidVisibleEditorsChange=this._register(new R),this.onDidVisibleEditorsChange=this._onDidVisibleEditorsChange.event,this._onDidEditorsChange=this._register(new R),this.onDidEditorsChange=this._onDidEditorsChange.event,this._onWillOpenEditor=this._register(new R),this.onWillOpenEditor=this._onWillOpenEditor.event,this._onDidCloseEditor=this._register(new R),this.onDidCloseEditor=this._onDidCloseEditor.event,this._onDidOpenEditorFail=this._register(new R),this.onDidOpenEditorFail=this._onDidOpenEditorFail.event,this._onDidMostRecentlyActiveEditorsChange=this._register(new R),this.onDidMostRecentlyActiveEditorsChange=this._onDidMostRecentlyActiveEditorsChange.event,this.lastActiveEditor=void 0,this.activeOutOfWorkspaceWatchers=new q,this.closeOnFileDelete=!1,this.editorGroupsContainer=e??t,this.editorsObserver=this._register(this.instantiationService.createInstance(xe,this.editorGroupsContainer)),this.onConfigurationUpdated(),this.registerListeners()}createScoped(e,t){return t.add(new Me(e,this.editorGroupService,this.instantiationService,this.fileService,this.configurationService,this.contextService,this.uriIdentityService,this.editorResolverService,this.workspaceTrustRequestService,this.hostService,this.textEditorService))}registerListeners(){this.editorGroupsContainer===this.editorGroupService.mainPart||this.editorGroupsContainer===this.editorGroupService?this.editorGroupService.whenReady.then(()=>this.onEditorGroupsReady()):this.onEditorGroupsReady(),this._register(this.editorGroupsContainer.onDidChangeActiveGroup(e=>this.handleActiveEditorChange(e))),this._register(this.editorGroupsContainer.onDidAddGroup(e=>this.registerGroupListeners(e))),this._register(this.editorsObserver.onDidMostRecentlyActiveEditorsChange(()=>this._onDidMostRecentlyActiveEditorsChange.fire())),this._register(this.onDidVisibleEditorsChange(()=>this.handleVisibleEditorsChange())),this._register(this.fileService.onDidRunOperation(e=>this.onDidRunFileOperation(e))),this._register(this.fileService.onDidFilesChange(e=>this.onDidFilesChange(e))),this._register(this.configurationService.onDidChangeConfiguration(e=>this.onConfigurationUpdated(e)))}onEditorGroupsReady(){for(const e of this.editorGroupsContainer.groups)this.registerGroupListeners(e);this.activeEditor&&(this.doHandleActiveEditorChangeEvent(),this._onDidVisibleEditorsChange.fire())}handleActiveEditorChange(e){e===this.editorGroupsContainer.activeGroup&&(!this.lastActiveEditor&&!e.activeEditor||this.doHandleActiveEditorChangeEvent())}doHandleActiveEditorChangeEvent(){const e=this.editorGroupsContainer.activeGroup;this.lastActiveEditor=e.activeEditor??void 0,this._onDidActiveEditorChange.fire()}registerGroupListeners(e){const t=new U;t.add(e.onDidModelChange(i=>{this._onDidEditorsChange.fire({groupId:e.id,event:i})})),t.add(e.onDidActiveEditorChange(()=>{this.handleActiveEditorChange(e),this._onDidVisibleEditorsChange.fire()})),t.add(e.onWillOpenEditor(i=>{this._onWillOpenEditor.fire(i)})),t.add(e.onDidCloseEditor(i=>{this._onDidCloseEditor.fire(i)})),t.add(e.onDidOpenEditorFail(i=>{this._onDidOpenEditorFail.fire({editor:i,groupId:e.id})})),y.once(e.onWillDispose)(()=>{V(t)})}handleVisibleEditorsChange(){const e=new it;for(const t of this.visibleEditors){const i=ci(M([Q.getCanonicalUri(t,{supportSideBySide:m.PRIMARY}),Q.getCanonicalUri(t,{supportSideBySide:m.SECONDARY})]),r=>r.toString());for(const r of i)this.fileService.hasProvider(r)&&!this.contextService.isInsideWorkspace(r)&&e.add(r)}for(const t of this.activeOutOfWorkspaceWatchers.keys())e.has(t)||(V(this.activeOutOfWorkspaceWatchers.get(t)),this.activeOutOfWorkspaceWatchers.delete(t));for(const t of e.keys())if(!this.activeOutOfWorkspaceWatchers.get(t)){const i=this.fileService.watch(t);this.activeOutOfWorkspaceWatchers.set(t,i)}}async onDidRunFileOperation(e){e.isOperation(ye.MOVE)&&this.handleMovedFile(e.resource,e.target.resource),(e.isOperation(ye.DELETE)||e.isOperation(ye.MOVE))&&this.handleDeletedFile(e.resource,!1,e.target?e.target.resource:void 0)}onDidFilesChange(e){e.gotDeleted()&&this.handleDeletedFile(e,!0)}async handleMovedFile(e,t){for(const i of this.editorGroupsContainer.groups){const r=[];for(const s of i.editors){const o=s.resource;if(!o||!this.uriIdentityService.extUri.isEqualOrParent(o,e))continue;let n;if(this.uriIdentityService.extUri.isEqual(e,o))n=t;else{const u=hi(o.path,e.path,this.uriIdentityService.extUri.ignorePathCasing(o));n=It(t,o.path.substr(u+e.path.length+1))}const a=await s.rename(i.id,n);if(!a)return;const c={preserveFocus:!0,pinned:i.isPinned(s),sticky:i.isSticky(s),index:i.getIndexOfEditor(s),inactive:!i.isActive(s)};B(a.editor)?r.push({editor:s,replacement:a.editor,options:{...a.options,...c}}):r.push({editor:s,replacement:{...a.editor,options:{...a.editor.options,...c}}})}r.length&&this.replaceEditors(r,i)}}onConfigurationUpdated(e){if(e&&!e.affectsConfiguration("workbench.editor.closeOnFileDelete"))return;const t=this.configurationService.getValue();typeof t.workbench?.editor?.closeOnFileDelete=="boolean"?this.closeOnFileDelete=t.workbench.editor.closeOnFileDelete:this.closeOnFileDelete=!1}handleDeletedFile(e,t,i){for(const r of this.getAllNonDirtyEditors({includeUntitled:!1,supportSideBySide:!0}))(async()=>{const s=r.resource;if(s&&(this.closeOnFileDelete||!t)){if(i&&this.uriIdentityService.extUri.isEqualOrParent(s,i))return;let o=!1;if(e instanceof ui?o=e.contains(s,li.DELETED):o=this.uriIdentityService.extUri.isEqualOrParent(s,e),!o)return;let n=!1;t&&this.fileService.hasProvider(s)&&(await fi(100),n=await this.fileService.exists(s)),!n&&!r.isDisposed()&&r.dispose()}})()}getAllNonDirtyEditors(e){const t=[];function i(r){r.hasCapability(f.Untitled)&&!e.includeUntitled||r.isDirty()||t.push(r)}for(const r of this.editors)e.supportSideBySide&&r instanceof $?(i(r.primary),i(r.secondary)):i(r);return t}get activeEditorPane(){return this.editorGroupsContainer.activeGroup?.activeEditorPane}get activeTextEditorControl(){const e=this.activeEditorPane;if(e){const t=e.getControl();if(Ce(t)||Ie(t))return t;if(pi(t)&&Ce(t.activeCodeEditor))return t.activeCodeEditor}}get activeTextEditorLanguageId(){let e;const t=this.activeTextEditorControl;return Ie(t)?e=t.getModifiedEditor():e=t,e?.getModel()?.getLanguageId()}get count(){return this.editorsObserver.count}get editors(){return this.getEditors(S.SEQUENTIAL).map(({editor:e})=>e)}getEditors(e,t){switch(e){case S.MOST_RECENTLY_ACTIVE:return t?.excludeSticky?this.editorsObserver.editors.filter(({groupId:i,editor:r})=>!this.editorGroupsContainer.getGroup(i)?.isSticky(r)):this.editorsObserver.editors;case S.SEQUENTIAL:{const i=[];for(const r of this.editorGroupsContainer.getGroups(C.GRID_APPEARANCE))i.push(...r.getEditors(S.SEQUENTIAL,t).map(s=>({editor:s,groupId:r.id})));return i}}}get activeEditor(){const e=this.editorGroupsContainer.activeGroup;return e?e.activeEditor??void 0:void 0}get visibleEditorPanes(){return M(this.editorGroupsContainer.groups.map(e=>e.activeEditorPane))}get visibleTextEditorControls(){return this.doGetVisibleTextEditorControls(this.visibleEditorPanes)}doGetVisibleTextEditorControls(e){const t=[];for(const i of e){const r=[];i instanceof Pe?(r.push(i.getPrimaryEditorPane()?.getControl()),r.push(i.getSecondaryEditorPane()?.getControl())):r.push(i.getControl());for(const s of r)(Ce(s)||Ie(s))&&t.push(s)}return t}getVisibleTextEditorControls(e){return this.doGetVisibleTextEditorControls(M(this.editorGroupsContainer.getGroups(e===S.SEQUENTIAL?C.GRID_APPEARANCE:C.MOST_RECENTLY_ACTIVE).map(t=>t.activeEditorPane)))}get visibleEditors(){return M(this.editorGroupsContainer.groups.map(e=>e.activeEditor))}async openEditor(e,t,i){let r,s=B(e)?t:e.options,o;if(gi(t)&&(i=t),!B(e)){const n=await this.editorResolverService.resolveEditor(e,i);if(n===De.ABORT)return;Re(n)&&(r=n.editor,s=n.options,o=n.group)}if(r||(r=B(e)?e:await this.textEditorService.resolveTextEditor(e)),!o){let n;const a=this.instantiationService.invokeFunction(ut,{editor:r,options:s},i);a instanceof Promise?[o,n]=await a:[o,n]=a,n&&(s={...s,activation:n})}return o.openEditor(r,s)}async openEditors(e,t,i){if(i?.validateTrust&&!await this.handleWorkspaceTrust(e))return[];const r=new Map;for(const o of e){let n,a;if(!oe(o)){const u=await this.editorResolverService.resolveEditor(o,t);if(u===De.ABORT)continue;Re(u)&&(n=u,a=u.group)}if(n||(n=oe(o)?o:{editor:await this.textEditorService.resolveTextEditor(o),options:o.options}),!a){const u=this.instantiationService.invokeFunction(ut,n,t);u instanceof Promise?[a]=await u:[a]=u}let c=r.get(a);c||(c=[],r.set(a,c)),c.push(n)}const s=[];for(const[o,n]of r)s.push(o.openEditors(n));return M(await Ae.settled(s))}async handleWorkspaceTrust(e){const{resources:t,diffMode:i,mergeMode:r}=this.extractEditorResources(e);switch(await this.workspaceTrustRequestService.requestOpenFilesTrust(t)){case we.Open:return!0;case we.OpenInNewWindow:return await this.hostService.openWindow(t.map(o=>({fileUri:o})),{forceNewWindow:!0,diffMode:i,mergeMode:r}),!1;case we.Cancel:return!1}}extractEditorResources(e){const t=new it;let i=!1,r=!1;for(const s of e)if(oe(s)){const o=Q.getOriginalUri(s.editor,{supportSideBySide:m.BOTH});g.isUri(o)?t.add(o):o&&(o.primary&&t.add(o.primary),o.secondary&&t.add(o.secondary),i=s.editor instanceof Dt)}else Rt(s)&&(g.isUri(s.input1)&&t.add(s.input1.resource),g.isUri(s.input2)&&t.add(s.input2.resource),g.isUri(s.base)&&t.add(s.base.resource),g.isUri(s.result)&&t.add(s.result.resource),r=!0),At(s)?(g.isUri(s.original.resource)&&t.add(s.original.resource),g.isUri(s.modified.resource)&&t.add(s.modified.resource),i=!0):wt(s)&&t.add(s.resource);return{resources:Array.from(t.keys()),diffMode:i,mergeMode:r}}isOpened(e){return this.editorsObserver.hasEditor({resource:this.uriIdentityService.asCanonicalUri(e.resource),typeId:e.typeId,editorId:e.editorId})}isVisible(e){for(const t of this.editorGroupsContainer.groups)if(t.activeEditor?.matches(e))return!0;return!1}async closeEditor({editor:e,groupId:t},i){await this.editorGroupsContainer.getGroup(t)?.closeEditor(e,i)}async closeEditors(e,t){const i=new Map;for(const{editor:r,groupId:s}of e){const o=this.editorGroupsContainer.getGroup(s);if(!o)continue;let n=i.get(o);n||(n=[],i.set(o,n)),n.push(r)}for(const[r,s]of i)await r.closeEditors(s,t)}findEditors(e,t,i){const r=g.isUri(e)?e:e.resource,s=g.isUri(e)?void 0:e.typeId;if(t?.supportSideBySide!==m.ANY&&t?.supportSideBySide!==m.SECONDARY&&!this.editorsObserver.hasEditors(r))return g.isUri(e)||rt(i)?[]:void 0;if(rt(i)){const o=[];for(const n of this.editorGroupsContainer.getGroups(t?.order===S.SEQUENTIAL?C.GRID_APPEARANCE:C.MOST_RECENTLY_ACTIVE)){const a=[];if(g.isUri(e))a.push(...this.findEditors(e,t,n));else{const c=this.findEditors(e,t,n);c&&a.push(c)}o.push(...a.map(c=>({editor:c,groupId:n.id})))}return o}else{const o=typeof i=="number"?this.editorGroupsContainer.getGroup(i):i;if(g.isUri(e))return o?o.findEditors(r,t):[];{if(!o)return;const n=o.findEditors(r,t);for(const a of n)if(a.typeId===s)return a;return}}}async replaceEditors(e,t){const i=typeof t=="number"?this.editorGroupsContainer.getGroup(t):t,r=[];for(const s of e){let o;if(!B(s.replacement)){const n=await this.editorResolverService.resolveEditor(s.replacement,i);if(n===De.ABORT)continue;Re(n)&&(o={editor:s.editor,replacement:n.editor,options:n.options,forceReplaceDirty:s.forceReplaceDirty})}o||(o={editor:s.editor,replacement:st(s)?s.replacement:await this.textEditorService.resolveTextEditor(s.replacement),options:st(s)?s.options:s.replacement.options,forceReplaceDirty:s.forceReplaceDirty}),r.push(o)}return i?.replaceEditors(r)}async save(e,t){Array.isArray(e)||(e=[e]);const i=this.getUniqueEditors(e),r=[],s=[];if(t?.saveAs)s.push(...i);else for(const{groupId:n,editor:a}of i)a.hasCapability(f.Untitled)?s.push({groupId:n,editor:a}):r.push({groupId:n,editor:a});const o=await Ae.settled(r.map(({groupId:n,editor:a})=>(t?.reason===p.EXPLICIT&&this.editorGroupsContainer.getGroup(n)?.pinEditor(a),a.save(n,t))));for(const{groupId:n,editor:a}of s){if(a.isDisposed())continue;const u={pinned:!0,viewState:(await this.openEditor(a,n))?.getViewState()},l=t?.saveAs?await a.saveAs(n,t):await a.save(n,t);if(o.push(l),!l)break;if(!a.matches(l)){const I=a.hasCapability(f.Untitled)?this.editorGroupsContainer.groups.map(H=>H.id):[n];for(const H of I)l instanceof Ei?await this.replaceEditors([{editor:a,replacement:l,options:u}],H):await this.replaceEditors([{editor:a,replacement:{...l,options:u}}],H)}}return{success:o.every(n=>!!n),editors:M(o)}}saveAll(e){return this.save(this.getAllModifiedEditors(e),e)}async revert(e,t){Array.isArray(e)||(e=[e]);const i=this.getUniqueEditors(e);return await Ae.settled(i.map(async({groupId:r,editor:s})=>(this.editorGroupsContainer.getGroup(r)?.pinEditor(s),s.revert(r,t)))),!i.some(({editor:r})=>r.isDirty())}async revertAll(e){return this.revert(this.getAllModifiedEditors(e),e)}getAllModifiedEditors(e){const t=[];for(const i of this.editorGroupsContainer.getGroups(C.MOST_RECENTLY_ACTIVE))for(const r of i.getEditors(S.MOST_RECENTLY_ACTIVE))r.isModified()&&((typeof e?.includeUntitled=="boolean"||!e?.includeUntitled?.includeScratchpad)&&r.hasCapability(f.Scratchpad)||!e?.includeUntitled&&r.hasCapability(f.Untitled)||e?.excludeSticky&&i.isSticky(r)||t.push({groupId:i.id,editor:r}));return t}getUniqueEditors(e){const t=[];for(const{editor:i,groupId:r}of e)t.some(s=>s.editor.matches(i))||t.push({editor:i,groupId:r});return t}dispose(){super.dispose(),this.activeOutOfWorkspaceWatchers.forEach(e=>V(e)),this.activeOutOfWorkspaceWatchers.clear()}};ft=Me=O([h(1,_),h(2,Z),h(3,te),h(4,Ve),h(5,mi),h(6,We),h(7,Ot),h(8,vi),h(9,_t),h(10,Si)],ft);var ne,k;let ae=(k=class extends bt{get typeId(){return ne.ID}get editorId(){return J.id}constructor(e,t,i,r,s,o,n,a,c,u,l){super(e.resource,void 0,r,t,i,s,a,u,l),this.model=e,this.environmentService=o,this.pathService=n,this.textModelService=c,this.modelResolve=void 0,this.modelDisposables=this._register(new U),this.cachedUntitledTextEditorModelReference=void 0,this.registerModelListeners(e),this._register(this.textFileService.untitled.onDidCreate(I=>this.onDidCreateUntitledModel(I)))}registerModelListeners(e){this.modelDisposables.clear(),this.modelDisposables.add(e.onDidChangeDirty(()=>this._onDidChangeDirty.fire())),this.modelDisposables.add(e.onDidChangeName(()=>this._onDidChangeLabel.fire())),this.modelDisposables.add(e.onDidRevert(()=>this.dispose()))}onDidCreateUntitledModel(e){j(e.resource,this.model.resource)&&e!==this.model&&(this.model=e,this.registerModelListeners(e))}getName(){return this.model.name}getDescription(e=yi.MEDIUM){if(!this.model.hasAssociatedFilePath){const t=this.resource.path;return t!==this.getName()?t:void 0}return super.getDescription(e)}getTitle(e){if(!this.model.hasAssociatedFilePath){const t=this.getName(),i=this.getDescription();return i&&i!==t?`${t} • ${i}`:t}return super.getTitle(e)}isDirty(){return this.model.isDirty()}getEncoding(){return this.model.getEncoding()}setEncoding(e,t){return this.model.setEncoding(e)}get hasLanguageSetExplicitly(){return this.model.hasLanguageSetExplicitly}get hasAssociatedFilePath(){return this.model.hasAssociatedFilePath}setLanguageId(e,t){this.model.setLanguageId(e,t)}getLanguageId(){return this.model.getLanguageId()}async resolve(){return this.modelResolve||(this.modelResolve=(async()=>{this.cachedUntitledTextEditorModelReference=await this.textModelService.createModelReference(this.resource)})()),await this.modelResolve,this.isDisposed()&&this.disposeModelReference(),this.model}toUntyped(e){const t={resource:this.model.hasAssociatedFilePath?Ci(this.model.resource,this.environmentService.remoteAuthority,this.pathService.defaultUriScheme):this.resource,forceUntitled:!0,options:{override:this.editorId}};return typeof e?.preserveViewState=="number"&&(t.encoding=this.getEncoding(),t.languageId=this.getLanguageId(),t.contents=this.model.isModified()?this.model.textEditorModel?.getValue():void 0,t.options.viewState=_e(this,e.preserveViewState,this.editorService),typeof t.contents=="string"&&!this.model.hasAssociatedFilePath&&!e.preserveResource&&(t.resource=void 0)),t}matches(e){return this===e?!0:e instanceof ne?j(e.resource,this.resource):Ii(e)?super.matches(e):!1}dispose(){this.modelResolve=void 0,this.disposeModelReference(),super.dispose()}disposeModelReference(){V(this.cachedUntitledTextEditorModelReference),this.cachedUntitledTextEditorModelReference=void 0}},ne=k,k.ID="workbench.editors.untitledEditorInput",k);ae=ne=O([h(1,ke),h(2,Tt),h(3,L),h(4,te),h(5,Di),h(6,Pt),h(7,Ue),h(8,Lt),h(9,ue),h(10,xt)],ae);var Y;class mr extends Error{constructor(e,t){super(e),this.name="FileEditorInputLeakError",this.stack=t}}var A;let pt=(A=class extends pe{constructor(e,t,i,r,s){super(),this.untitledTextEditorService=e,this.instantiationService=t,this.uriIdentityService=i,this.fileService=r,this.editorResolverService=s,this.editorInputCache=new q,this.fileEditorFactory=le.as(fe.EditorFactory).getFileEditorFactory(),this.mapLeakToCounter=new Map,this.registerDefaultEditor()}registerDefaultEditor(){this._register(this.editorResolverService.registerEditor("*",{id:J.id,label:J.displayName,detail:J.providerDisplayName,priority:Ri.builtin},{},{createEditorInput:e=>({editor:this.createTextEditor(e)}),createUntitledEditorInput:e=>({editor:this.createTextEditor(e)}),createDiffEditorInput:e=>({editor:this.createTextEditor(e)})}))}async resolveTextEditor(e){return this.createTextEditor(e)}createTextEditor(e){if(Rt(e))return this.createTextEditor(e.result);if(At(e)){const r=this.createTextEditor(e.original),s=this.createTextEditor(e.modified);return this.instantiationService.createInstance(Dt,e.label,e.description,r,s,void 0)}if(Ai(e)){const r=this.createTextEditor(e.primary),s=this.createTextEditor(e.secondary);return this.instantiationService.createInstance($,e.label,e.description,s,r)}const t=e;if(t.forceUntitled||!t.resource||t.resource.scheme===ee.untitled){const r={languageId:t.languageId,initialValue:t.contents,encoding:t.encoding};let s;return t.resource?.scheme===ee.untitled?s=this.untitledTextEditorService.create({untitledResource:t.resource,...r}):s=this.untitledTextEditorService.create({associatedResource:t.resource,...r}),this.createOrGetCached(s.resource,()=>this.instantiationService.createInstance(ae,s))}const i=e;if(i.resource instanceof g){const r=i.label||wi(i.resource),s=i.resource,o=this.uriIdentityService.asCanonicalUri(s);return this.createOrGetCached(o,()=>i.forceFile||this.fileService.hasProvider(o)?this.fileEditorFactory.createFileEditor(o,s,i.label,i.description,i.encoding,i.languageId,i.contents,this.instantiationService):this.instantiationService.createInstance(ot,o,i.label,i.description,i.languageId,i.contents),n=>{n instanceof ae||(n instanceof ot?(r&&n.setName(r),i.description&&n.setDescription(i.description),i.languageId&&n.setPreferredLanguageId(i.languageId),typeof i.contents=="string"&&n.setPreferredContents(i.contents)):(n.setPreferredResource(s),i.label&&n.setPreferredName(i.label),i.description&&n.setPreferredDescription(i.description),i.encoding&&n.setPreferredEncoding(i.encoding),i.languageId&&n.setPreferredLanguageId(i.languageId),typeof i.contents=="string"&&n.setPreferredContents(i.contents)))})}throw new Error(`ITextEditorService: Unable to create texteditor from ${JSON.stringify(e)}`)}createOrGetCached(e,t,i){let r=this.editorInputCache.get(e);if(r)return i?.(r),r;r=t(),this.editorInputCache.set(e,r);const s=this.trackLeaks(r);return y.once(r.onWillDispose)(()=>{this.editorInputCache.delete(e),s&&this.untrackLeaks(s)}),r}trackLeaks(e){if(Y.LEAK_REPORTED||this.editorInputCache.size<Y.LEAK_TRACKING_THRESHOLD)return;const t=`${e.resource.scheme}#${e.typeId||"<no typeId>"}#${e.editorId||"<no editorId>"}
|
|
2
2
|
${new Error().stack?.split(`
|
|
3
3
|
`).slice(2).join(`
|
|
4
|
-
`)??""}`,i=(this.mapLeakToCounter.get(t)??0)+1;if(this.mapLeakToCounter.set(t,i),this.editorInputCache.size>Y.LEAK_REPORTING_THRESHOLD){Y.LEAK_REPORTED=!0;const[r,s]=Array.from(this.mapLeakToCounter.entries()).reduce(([n,a],[c,u])=>u>a?[c,u]:[n,a]),o=`Potential text editor input LEAK detected, having ${this.editorInputCache.size} text editor inputs already. Most frequent owner (${s})`;Oi(new mr(o,r))}return t}untrackLeaks(e){const t=(this.mapLeakToCounter.get(e)??1)-1;this.mapLeakToCounter.set(e,t),t===0&&this.mapLeakToCounter.delete(e)}},Y=A,A.LEAK_TRACKING_THRESHOLD=256,A.LEAK_REPORTING_THRESHOLD=2*A.LEAK_TRACKING_THRESHOLD,A.LEAK_REPORTED=!1,A);pt=Y=O([h(0,_i),h(1,Z),h(2,We),h(3,te),h(4,Ot)],pt);let Ne=class extends bi{constructor(e,t,i){super(),this.resource=e,this.name=t,this.fileService=i,this.mime=Ti.binary}getName(){return this.name}getSize(){return this.size}getMime(){return this.mime}getETag(){return this.etag}async resolve(){if(this.fileService.hasProvider(this.resource)){const e=await this.fileService.stat(this.resource);this.etag=e.etag,typeof e.size=="number"&&(this.size=e.size)}return super.resolve()}};Ne=O([h(2,te)],Ne);var z;let de=(z=class extends pe{constructor(e,t,i,r,s,o,n,a){super(),this.filesConfigurationService=e,this.hostService=t,this.editorService=i,this.editorGroupService=r,this.workingCopyService=s,this.logService=o,this.markerService=n,this.uriIdentityService=a,this.scheduledAutoSavesAfterDelay=new Map,this.lastActiveEditor=void 0,this.lastActiveGroupId=void 0,this.lastActiveEditorControlDisposable=this._register(new U),this.waitingOnConditionAutoSaveWorkingCopies=new j(c=>this.uriIdentityService.extUri.getComparisonKey(c)),this.waitingOnConditionAutoSaveEditors=new j(c=>this.uriIdentityService.extUri.getComparisonKey(c));for(const c of this.workingCopyService.dirtyWorkingCopies)this.onDidRegister(c);this.registerListeners()}registerListeners(){this._register(this.hostService.onDidChangeFocus(e=>this.onWindowFocusChange(e))),this._register(this.hostService.onDidChangeActiveWindow(()=>this.onActiveWindowChange())),this._register(this.editorService.onDidActiveEditorChange(()=>this.onDidActiveEditorChange())),this._register(this.filesConfigurationService.onDidChangeAutoSaveConfiguration(()=>this.onDidChangeAutoSaveConfiguration())),this._register(this.workingCopyService.onDidRegister(e=>this.onDidRegister(e))),this._register(this.workingCopyService.onDidUnregister(e=>this.onDidUnregister(e))),this._register(this.workingCopyService.onDidChangeDirty(e=>this.onDidChangeDirty(e))),this._register(this.workingCopyService.onDidChangeContent(e=>this.onDidChangeContent(e))),this._register(this.markerService.onMarkerChanged(e=>this.onConditionChanged(e,x.ERRORS))),this._register(this.filesConfigurationService.onDidChangeAutoSaveDisabled(e=>this.onConditionChanged([e],x.DISABLED)))}onConditionChanged(e,t){for(const i of e){const r=this.waitingOnConditionAutoSaveWorkingCopies.get(i);if(r?.condition===t)r.workingCopy.isDirty()&&this.filesConfigurationService.getAutoSaveMode(r.workingCopy.resource,r.reason).mode!==v.OFF&&(this.discardAutoSave(r.workingCopy),this.logService.trace("[editor auto save] running auto save from condition change event",r.workingCopy.resource.toString(),r.workingCopy.typeId),r.workingCopy.save({reason:r.reason}));else{const s=this.waitingOnConditionAutoSaveEditors.get(i);s?.condition===t&&!s.editor.editor.isDisposed()&&s.editor.editor.isDirty()&&this.filesConfigurationService.getAutoSaveMode(s.editor.editor,s.reason).mode!==v.OFF&&(this.waitingOnConditionAutoSaveEditors.delete(i),this.logService.trace(`[editor auto save] running auto save from condition change event with reason ${s.reason}`),this.editorService.save(s.editor,{reason:s.reason}))}}}onWindowFocusChange(e){e||this.maybeTriggerAutoSave(p.WINDOW_CHANGE)}onActiveWindowChange(){this.maybeTriggerAutoSave(p.WINDOW_CHANGE)}onDidActiveEditorChange(){this.lastActiveEditor&&typeof this.lastActiveGroupId=="number"&&this.maybeTriggerAutoSave(p.FOCUS_CHANGE,{groupId:this.lastActiveGroupId,editor:this.lastActiveEditor});const e=this.editorGroupService.activeGroup,t=this.lastActiveEditor=e.activeEditor??void 0;this.lastActiveGroupId=e.id,this.lastActiveEditorControlDisposable.clear();const i=this.editorService.activeEditorPane;t&&i&&this.lastActiveEditorControlDisposable.add(i.onDidBlur(()=>{this.maybeTriggerAutoSave(p.FOCUS_CHANGE,{groupId:e.id,editor:t})}))}maybeTriggerAutoSave(e,t){if(t){if(!t.editor.isDirty()||t.editor.isReadonly()||t.editor.hasCapability(f.Untitled))return;const i=this.filesConfigurationService.getAutoSaveMode(t.editor,e);i.mode!==v.OFF?(e===p.WINDOW_CHANGE&&(i.mode===v.ON_FOCUS_CHANGE||i.mode===v.ON_WINDOW_CHANGE)||e===p.FOCUS_CHANGE&&i.mode===v.ON_FOCUS_CHANGE)&&(this.logService.trace(`[editor auto save] triggering auto save with reason ${e}`),this.editorService.save(t,{reason:e})):t.editor.resource&&(i.reason===x.ERRORS||i.reason===x.DISABLED)&&this.waitingOnConditionAutoSaveEditors.set(t.editor.resource,{editor:t,reason:e,condition:i.reason})}else this.saveAllDirtyAutoSaveables(e)}onDidChangeAutoSaveConfiguration(){let e;switch(this.filesConfigurationService.getAutoSaveMode(void 0).mode){case v.ON_FOCUS_CHANGE:e=p.FOCUS_CHANGE;break;case v.ON_WINDOW_CHANGE:e=p.WINDOW_CHANGE;break;case v.AFTER_SHORT_DELAY:case v.AFTER_LONG_DELAY:e=p.AUTO;break}e&&this.saveAllDirtyAutoSaveables(e)}saveAllDirtyAutoSaveables(e){for(const t of this.workingCopyService.dirtyWorkingCopies){if(t.capabilities&nt.Untitled)continue;const i=this.filesConfigurationService.getAutoSaveMode(t.resource,e);i.mode!==v.OFF?t.save({reason:e}):(i.reason===x.ERRORS||i.reason===x.DISABLED)&&this.waitingOnConditionAutoSaveWorkingCopies.set(t.resource,{workingCopy:t,reason:e,condition:i.reason})}}onDidRegister(e){e.isDirty()&&this.scheduleAutoSave(e)}onDidUnregister(e){this.discardAutoSave(e)}onDidChangeDirty(e){e.isDirty()?this.scheduleAutoSave(e):this.discardAutoSave(e)}onDidChangeContent(e){e.isDirty()&&this.scheduleAutoSave(e)}scheduleAutoSave(e){if(e.capabilities&nt.Untitled)return;const t=this.filesConfigurationService.getAutoSaveConfiguration(e.resource).autoSaveDelay;if(typeof t!="number")return;this.discardAutoSave(e),this.logService.trace(`[editor auto save] scheduling auto save after ${t}ms`,e.resource.toString(),e.typeId);const i=setTimeout(()=>{if(this.discardAutoSave(e),e.isDirty()){const r=p.AUTO,s=this.filesConfigurationService.getAutoSaveMode(e.resource,r);s.mode!==v.OFF?(this.logService.trace("[editor auto save] running auto save",e.resource.toString(),e.typeId),e.save({reason:r})):(s.reason===x.ERRORS||s.reason===x.DISABLED)&&this.waitingOnConditionAutoSaveWorkingCopies.set(e.resource,{workingCopy:e,reason:r,condition:s.reason})}},t);this.scheduledAutoSavesAfterDelay.set(e,Pi(()=>{this.logService.trace("[editor auto save] clearing pending auto save",e.resource.toString(),e.typeId),clearTimeout(i)}))}discardAutoSave(e){V(this.scheduledAutoSavesAfterDelay.get(e)),this.scheduledAutoSavesAfterDelay.delete(e),this.waitingOnConditionAutoSaveWorkingCopies.delete(e.resource),this.waitingOnConditionAutoSaveEditors.delete(e.resource)}},z.ID="workbench.contrib.editorAutoSave",z);de=O([h(0,Ue),h(1,_t),h(2,L),h(3,_),h(4,Li),h(5,xi),h(6,Mi),h(7,We)],de);Ni(de.ID,de,Gi.BlockRestore);var Ge,N;(function(d){d[d.None=0]="None",d[d.Text=1]="Text",d[d.Binary=2]="Binary"})(N||(N={}));let ce=Ge=class extends bt{get typeId(){return Mt}get editorId(){return J.id}get capabilities(){let e=f.CanSplitInGroup;return this.model?this.model.isReadonly()&&(e|=f.Readonly):this.fileService.hasProvider(this.resource)?this.filesConfigurationService.isReadonly(this.resource)&&(e|=f.Readonly):e|=f.Untitled,e&f.Readonly||(e|=f.CanDropIntoEditor),e}constructor(e,t,i,r,s,o,n,a,c,u,l,I,H,Bt,Yt,Kt,zt){super(e,t,Bt,c,l,I,H,Kt,zt),this.instantiationService=a,this.textModelService=u,this.pathService=Yt,this.forceOpenAs=N.None,this.model=void 0,this.cachedTextFileModelReference=void 0,this.modelListeners=this._register(new U),this.model=this.textFileService.files.get(e),i&&this.setPreferredName(i),r&&this.setPreferredDescription(r),s&&this.setPreferredEncoding(s),o&&this.setPreferredLanguageId(o),typeof n=="string"&&this.setPreferredContents(n),this._register(this.textFileService.files.onDidCreate($t=>this.onDidCreateTextFileModel($t))),this.model&&this.registerModelListeners(this.model)}onDidCreateTextFileModel(e){q(e.resource,this.resource)&&(this.model=e,this.registerModelListeners(e))}registerModelListeners(e){this.modelListeners.clear(),this.modelListeners.add(e.onDidChangeDirty(()=>this._onDidChangeDirty.fire())),this.modelListeners.add(e.onDidChangeReadonly(()=>this._onDidChangeCapabilities.fire())),this.modelListeners.add(e.onDidSaveError(()=>this._onDidChangeDirty.fire())),this.modelListeners.add(y.once(e.onWillDispose)(()=>{this.modelListeners.clear(),this.model=void 0}))}getName(){return this.preferredName||super.getName()}setPreferredName(e){this.allowLabelOverride()&&this.preferredName!==e&&(this.preferredName=e,this._onDidChangeLabel.fire())}allowLabelOverride(){return this.resource.scheme!==this.pathService.defaultUriScheme&&this.resource.scheme!==ee.vscodeUserData&&this.resource.scheme!==ee.file&&this.resource.scheme!==ee.vscodeRemote}getPreferredName(){return this.preferredName}isReadonly(){return this.model?this.model.isReadonly():this.filesConfigurationService.isReadonly(this.resource)}getDescription(e){return this.preferredDescription||super.getDescription(e)}setPreferredDescription(e){this.allowLabelOverride()&&this.preferredDescription!==e&&(this.preferredDescription=e,this._onDidChangeLabel.fire())}getPreferredDescription(){return this.preferredDescription}getTitle(e){let t=super.getTitle(e);const i=this.getPreferredTitle();return i&&(t=`${i} (${t})`),t}getPreferredTitle(){if(this.preferredName&&this.preferredDescription)return`${this.preferredName} ${this.preferredDescription}`;if(this.preferredName||this.preferredDescription)return this.preferredName??this.preferredDescription}getEncoding(){return this.model?this.model.getEncoding():this.preferredEncoding}getPreferredEncoding(){return this.preferredEncoding}async setEncoding(e,t){return this.setPreferredEncoding(e),this.model?.setEncoding(e,t)}setPreferredEncoding(e){this.preferredEncoding=e,this.setForceOpenAsText()}getLanguageId(){return this.model?this.model.getLanguageId():this.preferredLanguageId}getPreferredLanguageId(){return this.preferredLanguageId}setLanguageId(e,t){this.setPreferredLanguageId(e),this.model?.setLanguageId(e,t)}setPreferredLanguageId(e){this.preferredLanguageId=e,this.setForceOpenAsText()}setPreferredContents(e){this.preferredContents=e,this.setForceOpenAsText()}setForceOpenAsText(){this.forceOpenAs=N.Text}setForceOpenAsBinary(){this.forceOpenAs=N.Binary}isDirty(){return!!this.model?.isDirty()}isSaving(){return this.model?.hasState(Oe.SAVED)||this.model?.hasState(Oe.CONFLICT)||this.model?.hasState(Oe.ERROR)?!1:this.filesConfigurationService.hasShortAutoSaveDelay(this)?!0:super.isSaving()}prefersEditorPane(e){return this.forceOpenAs===N.Binary?e.find(t=>t.typeId===Fi):e.find(t=>t.typeId===Vi)}resolve(e){return this.forceOpenAs===N.Binary?this.doResolveAsBinary():this.doResolveAsText(e)}async doResolveAsText(e){try{const t=this.preferredContents;this.preferredContents=void 0,await this.textFileService.files.resolve(this.resource,{languageId:this.preferredLanguageId,encoding:this.preferredEncoding,contents:typeof t=="string"?ki(t):void 0,reload:{async:!0},allowBinary:this.forceOpenAs===N.Text,reason:Wi.EDITOR,limits:this.ensureLimits(e)}),this.cachedTextFileModelReference||(this.cachedTextFileModelReference=await this.textModelService.createModelReference(this.resource));const i=this.cachedTextFileModelReference.object;return this.isDisposed()&&this.disposeModelReference(),i}catch(t){if(t.textFileOperationResult===Ui.FILE_IS_BINARY)return this.doResolveAsBinary();throw t}}async doResolveAsBinary(){const e=this.instantiationService.createInstance(Ne,this.preferredResource,this.getName());return await e.resolve(),e}isResolved(){return!!this.model}async rename(e,t){return{editor:{resource:t,encoding:this.getEncoding(),options:{viewState:_e(this,e,this.editorService)}}}}toUntyped(e){const t={resource:this.preferredResource,forceFile:!0,options:{override:this.editorId}};return typeof e?.preserveViewState=="number"&&(t.encoding=this.getEncoding(),t.languageId=this.getLanguageId(),t.contents=(()=>{const i=this.textFileService.files.get(this.resource);if(i?.isDirty()&&!i.textEditorModel.isTooLargeForHeapOperation())return i.textEditorModel.getValue()})(),t.options={...t.options,viewState:_e(this,e.preserveViewState,this.editorService)}),t}matches(e){return this===e?!0:e instanceof Ge?q(e.resource,this.resource):wt(e)?super.matches(e):!1}dispose(){this.model=void 0,this.disposeModelReference(),super.dispose()}disposeModelReference(){V(this.cachedTextFileModelReference),this.cachedTextFileModelReference=void 0}};ce=Ge=O([h(7,Z),h(8,ke),h(9,Lt),h(10,Tt),h(11,te),h(12,Ue),h(13,L),h(14,Pt),h(15,ue),h(16,xt)],ce);le.as(fe.EditorFactory).registerFileEditorFactory({typeId:Mt,createFileEditor:(d,e,t,i,r,s,o,n)=>n.createInstance(ce,d,e,t,i,r,s,o),isFileEditor:d=>d instanceof ce});class vr{constructor(e){this.root=new he;for(const[t,i]of e)for(const r of i)this.root.add(t,r)}toString(){return this.root.toString()}getAttributes(e,t){const i=e.lastIndexOf(".");return i<1?{dirname:t,basename:e,extname:""}:{dirname:t,basename:e.substring(0,i),extname:e.substring(i+1)}}nest(e,t){const i=new he;for(const o of e){const n=this.getAttributes(o,t),a=this.root.get(o,n);for(const c of a)i.add(c,o)}const r=(o,n=new Set)=>{if(n.has(o))return[];n.add(o);const a=this.getAttributes(o,t),c=i.get(o,a);return c.length===0?[o]:c.length===1&&c[0]===o?[o]:c.flatMap(u=>r(u,n))},s=new Map;for(const o of e){let n=r(o);n.length===0&&(n=[o]);for(const a of n){let c=s.get(a);c||s.set(a,c=new Set),o!==a&&c.add(o)}}return s}}class he{constructor(){this.value=new Ye,this.map=new Map}add(e,t){if(e==="")this.value.add(e,t);else if(e[0]==="*")this.value.add(e,t);else{const i=e[0],r=e.slice(1);let s=this.map.get(i);s||this.map.set(i,s=new he),s.add(r,t)}}get(e,t){const i=[];i.push(...this.value.get(e,t));const r=e[0],s=e.slice(1),o=this.map.get(r);return o&&i.push(...o.get(s,t)),i}toString(e=""){const t=[];return this.value.hasItems&&t.push(`* =>
|
|
4
|
+
`)??""}`,i=(this.mapLeakToCounter.get(t)??0)+1;if(this.mapLeakToCounter.set(t,i),this.editorInputCache.size>Y.LEAK_REPORTING_THRESHOLD){Y.LEAK_REPORTED=!0;const[r,s]=Array.from(this.mapLeakToCounter.entries()).reduce(([n,a],[c,u])=>u>a?[c,u]:[n,a]),o=`Potential text editor input LEAK detected, having ${this.editorInputCache.size} text editor inputs already. Most frequent owner (${s})`;Oi(new mr(o,r))}return t}untrackLeaks(e){const t=(this.mapLeakToCounter.get(e)??1)-1;this.mapLeakToCounter.set(e,t),t===0&&this.mapLeakToCounter.delete(e)}},Y=A,A.LEAK_TRACKING_THRESHOLD=256,A.LEAK_REPORTING_THRESHOLD=2*A.LEAK_TRACKING_THRESHOLD,A.LEAK_REPORTED=!1,A);pt=Y=O([h(0,_i),h(1,Z),h(2,We),h(3,te),h(4,Ot)],pt);let Ne=class extends bi{constructor(e,t,i){super(),this.resource=e,this.name=t,this.fileService=i,this.mime=Ti.binary}getName(){return this.name}getSize(){return this.size}getMime(){return this.mime}getETag(){return this.etag}async resolve(){if(this.fileService.hasProvider(this.resource)){const e=await this.fileService.stat(this.resource);this.etag=e.etag,typeof e.size=="number"&&(this.size=e.size)}return super.resolve()}};Ne=O([h(2,te)],Ne);var z;let de=(z=class extends pe{constructor(e,t,i,r,s,o,n,a){super(),this.filesConfigurationService=e,this.hostService=t,this.editorService=i,this.editorGroupService=r,this.workingCopyService=s,this.logService=o,this.markerService=n,this.uriIdentityService=a,this.scheduledAutoSavesAfterDelay=new Map,this.lastActiveEditor=void 0,this.lastActiveGroupId=void 0,this.lastActiveEditorControlDisposable=this._register(new U),this.waitingOnConditionAutoSaveWorkingCopies=new q(c=>this.uriIdentityService.extUri.getComparisonKey(c)),this.waitingOnConditionAutoSaveEditors=new q(c=>this.uriIdentityService.extUri.getComparisonKey(c));for(const c of this.workingCopyService.dirtyWorkingCopies)this.onDidRegister(c);this.registerListeners()}registerListeners(){this._register(this.hostService.onDidChangeFocus(e=>this.onWindowFocusChange(e))),this._register(this.hostService.onDidChangeActiveWindow(()=>this.onActiveWindowChange())),this._register(this.editorService.onDidActiveEditorChange(()=>this.onDidActiveEditorChange())),this._register(this.filesConfigurationService.onDidChangeAutoSaveConfiguration(()=>this.onDidChangeAutoSaveConfiguration())),this._register(this.workingCopyService.onDidRegister(e=>this.onDidRegister(e))),this._register(this.workingCopyService.onDidUnregister(e=>this.onDidUnregister(e))),this._register(this.workingCopyService.onDidChangeDirty(e=>this.onDidChangeDirty(e))),this._register(this.workingCopyService.onDidChangeContent(e=>this.onDidChangeContent(e))),this._register(this.markerService.onMarkerChanged(e=>this.onConditionChanged(e,x.ERRORS))),this._register(this.filesConfigurationService.onDidChangeAutoSaveDisabled(e=>this.onConditionChanged([e],x.DISABLED)))}onConditionChanged(e,t){for(const i of e){const r=this.waitingOnConditionAutoSaveWorkingCopies.get(i);if(r?.condition===t)r.workingCopy.isDirty()&&this.filesConfigurationService.getAutoSaveMode(r.workingCopy.resource,r.reason).mode!==v.OFF&&(this.discardAutoSave(r.workingCopy),this.logService.trace("[editor auto save] running auto save from condition change event",r.workingCopy.resource.toString(),r.workingCopy.typeId),r.workingCopy.save({reason:r.reason}));else{const s=this.waitingOnConditionAutoSaveEditors.get(i);s?.condition===t&&!s.editor.editor.isDisposed()&&s.editor.editor.isDirty()&&this.filesConfigurationService.getAutoSaveMode(s.editor.editor,s.reason).mode!==v.OFF&&(this.waitingOnConditionAutoSaveEditors.delete(i),this.logService.trace(`[editor auto save] running auto save from condition change event with reason ${s.reason}`),this.editorService.save(s.editor,{reason:s.reason}))}}}onWindowFocusChange(e){e||this.maybeTriggerAutoSave(p.WINDOW_CHANGE)}onActiveWindowChange(){this.maybeTriggerAutoSave(p.WINDOW_CHANGE)}onDidActiveEditorChange(){this.lastActiveEditor&&typeof this.lastActiveGroupId=="number"&&this.maybeTriggerAutoSave(p.FOCUS_CHANGE,{groupId:this.lastActiveGroupId,editor:this.lastActiveEditor});const e=this.editorGroupService.activeGroup,t=this.lastActiveEditor=e.activeEditor??void 0;this.lastActiveGroupId=e.id,this.lastActiveEditorControlDisposable.clear();const i=this.editorService.activeEditorPane;t&&i&&this.lastActiveEditorControlDisposable.add(i.onDidBlur(()=>{this.maybeTriggerAutoSave(p.FOCUS_CHANGE,{groupId:e.id,editor:t})}))}maybeTriggerAutoSave(e,t){if(t){if(!t.editor.isDirty()||t.editor.isReadonly()||t.editor.hasCapability(f.Untitled))return;const i=this.filesConfigurationService.getAutoSaveMode(t.editor,e);i.mode!==v.OFF?(e===p.WINDOW_CHANGE&&(i.mode===v.ON_FOCUS_CHANGE||i.mode===v.ON_WINDOW_CHANGE)||e===p.FOCUS_CHANGE&&i.mode===v.ON_FOCUS_CHANGE)&&(this.logService.trace(`[editor auto save] triggering auto save with reason ${e}`),this.editorService.save(t,{reason:e})):t.editor.resource&&(i.reason===x.ERRORS||i.reason===x.DISABLED)&&this.waitingOnConditionAutoSaveEditors.set(t.editor.resource,{editor:t,reason:e,condition:i.reason})}else this.saveAllDirtyAutoSaveables(e)}onDidChangeAutoSaveConfiguration(){let e;switch(this.filesConfigurationService.getAutoSaveMode(void 0).mode){case v.ON_FOCUS_CHANGE:e=p.FOCUS_CHANGE;break;case v.ON_WINDOW_CHANGE:e=p.WINDOW_CHANGE;break;case v.AFTER_SHORT_DELAY:case v.AFTER_LONG_DELAY:e=p.AUTO;break}e&&this.saveAllDirtyAutoSaveables(e)}saveAllDirtyAutoSaveables(e){for(const t of this.workingCopyService.dirtyWorkingCopies){if(t.capabilities&nt.Untitled)continue;const i=this.filesConfigurationService.getAutoSaveMode(t.resource,e);i.mode!==v.OFF?t.save({reason:e}):(i.reason===x.ERRORS||i.reason===x.DISABLED)&&this.waitingOnConditionAutoSaveWorkingCopies.set(t.resource,{workingCopy:t,reason:e,condition:i.reason})}}onDidRegister(e){e.isDirty()&&this.scheduleAutoSave(e)}onDidUnregister(e){this.discardAutoSave(e)}onDidChangeDirty(e){e.isDirty()?this.scheduleAutoSave(e):this.discardAutoSave(e)}onDidChangeContent(e){e.isDirty()&&this.scheduleAutoSave(e)}scheduleAutoSave(e){if(e.capabilities&nt.Untitled)return;const t=this.filesConfigurationService.getAutoSaveConfiguration(e.resource).autoSaveDelay;if(typeof t!="number")return;this.discardAutoSave(e),this.logService.trace(`[editor auto save] scheduling auto save after ${t}ms`,e.resource.toString(),e.typeId);const i=setTimeout(()=>{if(this.discardAutoSave(e),e.isDirty()){const r=p.AUTO,s=this.filesConfigurationService.getAutoSaveMode(e.resource,r);s.mode!==v.OFF?(this.logService.trace("[editor auto save] running auto save",e.resource.toString(),e.typeId),e.save({reason:r})):(s.reason===x.ERRORS||s.reason===x.DISABLED)&&this.waitingOnConditionAutoSaveWorkingCopies.set(e.resource,{workingCopy:e,reason:r,condition:s.reason})}},t);this.scheduledAutoSavesAfterDelay.set(e,Pi(()=>{this.logService.trace("[editor auto save] clearing pending auto save",e.resource.toString(),e.typeId),clearTimeout(i)}))}discardAutoSave(e){V(this.scheduledAutoSavesAfterDelay.get(e)),this.scheduledAutoSavesAfterDelay.delete(e),this.waitingOnConditionAutoSaveWorkingCopies.delete(e.resource),this.waitingOnConditionAutoSaveEditors.delete(e.resource)}},z.ID="workbench.contrib.editorAutoSave",z);de=O([h(0,Ue),h(1,_t),h(2,L),h(3,_),h(4,Li),h(5,xi),h(6,Mi),h(7,We)],de);Ni(de.ID,de,Gi.BlockRestore);var Ge,N;(function(d){d[d.None=0]="None",d[d.Text=1]="Text",d[d.Binary=2]="Binary"})(N||(N={}));let ce=Ge=class extends bt{get typeId(){return Mt}get editorId(){return J.id}get capabilities(){let e=f.CanSplitInGroup;return this.model?this.model.isReadonly()&&(e|=f.Readonly):this.fileService.hasProvider(this.resource)?this.filesConfigurationService.isReadonly(this.resource)&&(e|=f.Readonly):e|=f.Untitled,e&f.Readonly||(e|=f.CanDropIntoEditor),e}constructor(e,t,i,r,s,o,n,a,c,u,l,I,H,Bt,Yt,Kt,zt){super(e,t,Bt,c,l,I,H,Kt,zt),this.instantiationService=a,this.textModelService=u,this.pathService=Yt,this.forceOpenAs=N.None,this.model=void 0,this.cachedTextFileModelReference=void 0,this.modelListeners=this._register(new U),this.model=this.textFileService.files.get(e),i&&this.setPreferredName(i),r&&this.setPreferredDescription(r),s&&this.setPreferredEncoding(s),o&&this.setPreferredLanguageId(o),typeof n=="string"&&this.setPreferredContents(n),this._register(this.textFileService.files.onDidCreate($t=>this.onDidCreateTextFileModel($t))),this.model&&this.registerModelListeners(this.model)}onDidCreateTextFileModel(e){j(e.resource,this.resource)&&(this.model=e,this.registerModelListeners(e))}registerModelListeners(e){this.modelListeners.clear(),this.modelListeners.add(e.onDidChangeDirty(()=>this._onDidChangeDirty.fire())),this.modelListeners.add(e.onDidChangeReadonly(()=>this._onDidChangeCapabilities.fire())),this.modelListeners.add(e.onDidSaveError(()=>this._onDidChangeDirty.fire())),this.modelListeners.add(y.once(e.onWillDispose)(()=>{this.modelListeners.clear(),this.model=void 0}))}getName(){return this.preferredName||super.getName()}setPreferredName(e){this.allowLabelOverride()&&this.preferredName!==e&&(this.preferredName=e,this._onDidChangeLabel.fire())}allowLabelOverride(){return this.resource.scheme!==this.pathService.defaultUriScheme&&this.resource.scheme!==ee.vscodeUserData&&this.resource.scheme!==ee.file&&this.resource.scheme!==ee.vscodeRemote}getPreferredName(){return this.preferredName}isReadonly(){return this.model?this.model.isReadonly():this.filesConfigurationService.isReadonly(this.resource)}getDescription(e){return this.preferredDescription||super.getDescription(e)}setPreferredDescription(e){this.allowLabelOverride()&&this.preferredDescription!==e&&(this.preferredDescription=e,this._onDidChangeLabel.fire())}getPreferredDescription(){return this.preferredDescription}getTitle(e){let t=super.getTitle(e);const i=this.getPreferredTitle();return i&&(t=`${i} (${t})`),t}getPreferredTitle(){if(this.preferredName&&this.preferredDescription)return`${this.preferredName} ${this.preferredDescription}`;if(this.preferredName||this.preferredDescription)return this.preferredName??this.preferredDescription}getEncoding(){return this.model?this.model.getEncoding():this.preferredEncoding}getPreferredEncoding(){return this.preferredEncoding}async setEncoding(e,t){return this.setPreferredEncoding(e),this.model?.setEncoding(e,t)}setPreferredEncoding(e){this.preferredEncoding=e,this.setForceOpenAsText()}getLanguageId(){return this.model?this.model.getLanguageId():this.preferredLanguageId}getPreferredLanguageId(){return this.preferredLanguageId}setLanguageId(e,t){this.setPreferredLanguageId(e),this.model?.setLanguageId(e,t)}setPreferredLanguageId(e){this.preferredLanguageId=e,this.setForceOpenAsText()}setPreferredContents(e){this.preferredContents=e,this.setForceOpenAsText()}setForceOpenAsText(){this.forceOpenAs=N.Text}setForceOpenAsBinary(){this.forceOpenAs=N.Binary}isDirty(){return!!this.model?.isDirty()}isSaving(){return this.model?.hasState(Oe.SAVED)||this.model?.hasState(Oe.CONFLICT)||this.model?.hasState(Oe.ERROR)?!1:this.filesConfigurationService.hasShortAutoSaveDelay(this)?!0:super.isSaving()}prefersEditorPane(e){return this.forceOpenAs===N.Binary?e.find(t=>t.typeId===Fi):e.find(t=>t.typeId===Vi)}resolve(e){return this.forceOpenAs===N.Binary?this.doResolveAsBinary():this.doResolveAsText(e)}async doResolveAsText(e){try{const t=this.preferredContents;this.preferredContents=void 0,await this.textFileService.files.resolve(this.resource,{languageId:this.preferredLanguageId,encoding:this.preferredEncoding,contents:typeof t=="string"?ki(t):void 0,reload:{async:!0},allowBinary:this.forceOpenAs===N.Text,reason:Wi.EDITOR,limits:this.ensureLimits(e)}),this.cachedTextFileModelReference||(this.cachedTextFileModelReference=await this.textModelService.createModelReference(this.resource));const i=this.cachedTextFileModelReference.object;return this.isDisposed()&&this.disposeModelReference(),i}catch(t){if(t.textFileOperationResult===Ui.FILE_IS_BINARY)return this.doResolveAsBinary();throw t}}async doResolveAsBinary(){const e=this.instantiationService.createInstance(Ne,this.preferredResource,this.getName());return await e.resolve(),e}isResolved(){return!!this.model}async rename(e,t){return{editor:{resource:t,encoding:this.getEncoding(),options:{viewState:_e(this,e,this.editorService)}}}}toUntyped(e){const t={resource:this.preferredResource,forceFile:!0,options:{override:this.editorId}};return typeof e?.preserveViewState=="number"&&(t.encoding=this.getEncoding(),t.languageId=this.getLanguageId(),t.contents=(()=>{const i=this.textFileService.files.get(this.resource);if(i?.isDirty()&&!i.textEditorModel.isTooLargeForHeapOperation())return i.textEditorModel.getValue()})(),t.options={...t.options,viewState:_e(this,e.preserveViewState,this.editorService)}),t}matches(e){return this===e?!0:e instanceof Ge?j(e.resource,this.resource):wt(e)?super.matches(e):!1}dispose(){this.model=void 0,this.disposeModelReference(),super.dispose()}disposeModelReference(){V(this.cachedTextFileModelReference),this.cachedTextFileModelReference=void 0}};ce=Ge=O([h(7,Z),h(8,ke),h(9,Lt),h(10,Tt),h(11,te),h(12,Ue),h(13,L),h(14,Pt),h(15,ue),h(16,xt)],ce);le.as(fe.EditorFactory).registerFileEditorFactory({typeId:Mt,createFileEditor:(d,e,t,i,r,s,o,n)=>n.createInstance(ce,d,e,t,i,r,s,o),isFileEditor:d=>d instanceof ce});class vr{constructor(e){this.root=new he;for(const[t,i]of e)for(const r of i)this.root.add(t,r)}toString(){return this.root.toString()}getAttributes(e,t){const i=e.lastIndexOf(".");return i<1?{dirname:t,basename:e,extname:""}:{dirname:t,basename:e.substring(0,i),extname:e.substring(i+1)}}nest(e,t){const i=new he;for(const o of e){const n=this.getAttributes(o,t),a=this.root.get(o,n);for(const c of a)i.add(c,o)}const r=(o,n=new Set)=>{if(n.has(o))return[];n.add(o);const a=this.getAttributes(o,t),c=i.get(o,a);return c.length===0?[o]:c.length===1&&c[0]===o?[o]:c.flatMap(u=>r(u,n))},s=new Map;for(const o of e){let n=r(o);n.length===0&&(n=[o]);for(const a of n){let c=s.get(a);c||s.set(a,c=new Set),o!==a&&c.add(o)}}return s}}class he{constructor(){this.value=new Ye,this.map=new Map}add(e,t){if(e==="")this.value.add(e,t);else if(e[0]==="*")this.value.add(e,t);else{const i=e[0],r=e.slice(1);let s=this.map.get(i);s||this.map.set(i,s=new he),s.add(r,t)}}get(e,t){const i=[];i.push(...this.value.get(e,t));const r=e[0],s=e.slice(1),o=this.map.get(r);return o&&i.push(...o.get(s,t)),i}toString(e=""){const t=[];return this.value.hasItems&&t.push(`* =>
|
|
5
5
|
`+this.value.toString(e+" ")),t.map(i=>e+i).join(`
|
|
6
6
|
`)}}class Ye{constructor(){this.star=[],this.epsilon=[],this.map=new Map,this.hasItems=!1}add(e,t){if(this.hasItems=!0,e==="*")this.star.push(new Et(t));else if(e==="")this.epsilon.push(new Et(t));else{const i=e[e.length-1],r=e.slice(0,e.length-1);if(i==="*")throw Error("Unexpected star in SufTrie key: "+e);{let s=this.map.get(i);s||this.map.set(i,s=new Ye),s.add(r,t)}}}get(e,t){const i=[];e===""&&i.push(...this.epsilon.map(n=>n.substitute(t))),this.star.length&&i.push(...this.star.map(n=>n.substitute(t,e)));const r=e[e.length-1],s=e.slice(0,e.length-1),o=this.map.get(r);return o&&i.push(...o.get(s,t)),i}toString(e=""){const t=[];return this.star.length&&t.push("* => "+this.star.join("; ")),this.epsilon.length&&t.push("ε => "+this.epsilon.join("; ")),t.map(i=>e+i).join(`
|
|
7
|
-
`)}}var D;(function(d){d.capture="capture",d.basename="basename",d.dirname="dirname",d.extname="extname"})(D||(D={}));const gt=/\$[({](capture|basename|dirname|extname)[)}]/g;class Et{constructor(e){this.tokens=[],gt.lastIndex=0;let t,i=0;for(;t=gt.exec(e);){const r=e.slice(i,t.index);this.tokens.push(r);const s=t[1];switch(s){case D.basename:case D.dirname:case D.extname:case D.capture:this.tokens.push({capture:s});break;default:throw Error("unknown substitution type: "+s)}i=t.index+t[0].length}if(i!==e.length){const r=e.slice(i,e.length);this.tokens.push(r)}}substitute(e,t){return this.tokens.map(i=>{if(typeof i=="string")return i;switch(i.capture){case D.basename:return e.basename;case D.dirname:return e.dirname;case D.extname:return e.extname;case D.capture:return t||""}}).join("")}}class b{constructor(e,t,i,r,s,o,n,a,c,u=Bi(e),l,I=!1){this.resource=e,this.fileService=t,this.configService=i,this.filesConfigService=r,this._parent=s,this._isDirectory=o,this._isSymbolicLink=n,this._readonly=a,this._locked=c,this._name=u,this._mtime=l,this._unknown=I,this.error=void 0,this._isExcluded=!1,this.markedAsFindResult=!1,this._isDirectoryResolved=!1}get isExcluded(){return this._isExcluded?!0:this._parent?this._parent.isExcluded:!1}set isExcluded(e){this._isExcluded=e}hasChildren(e){return this.hasNests?this.nestedChildren?.some(t=>e(t))??!1:this.isDirectory}get hasNests(){return!!this.nestedChildren?.length}get isDirectoryResolved(){return this._isDirectoryResolved}get isSymbolicLink(){return!!this._isSymbolicLink}get isDirectory(){return!!this._isDirectory}get isReadonly(){return this.filesConfigService.isReadonly(this.resource,{resource:this.resource,name:this.name,readonly:this._readonly,locked:this._locked})}get mtime(){return this._mtime}get name(){return this._name}get isUnknown(){return this._unknown}get parent(){return this._parent}get root(){return this._parent?this._parent.root:this}get children(){return new Map}updateName(e){this._parent?.removeChild(this),this._name=e,this._parent?.addChild(this)}getId(){let e=this.root.resource.toString()+"::"+this.resource.toString();return this.isMarkedAsFiltered()&&(e+="::findFilterResult"),e}toString(){return`ExplorerItem: ${this.name}`}get isRoot(){return this===this.root}static create(e,t,i,r,s,o){const n=new b(r.resource,e,t,i,s,r.isDirectory,r.isSymbolicLink,r.readonly,r.locked,r.name,r.mtime,!r.isFile&&!r.isDirectory);if(n.isDirectory&&(n._isDirectoryResolved=!!r.children||!!o&&o.some(a=>Yi(a,n.resource)),r.children))for(let a=0,c=r.children.length;a<c;a++){const u=b.create(e,t,i,r.children[a],n,o);n.addChild(u)}return n}static mergeLocalWithDisk(e,t){if(e.resource.toString()!==t.resource.toString())return;const i=e.isDirectory||t.isDirectory;if(!(i&&t._isDirectoryResolved&&!e._isDirectoryResolved)&&(t.resource=e.resource,t.isRoot||t.updateName(e.name),t._isDirectory=e.isDirectory,t._mtime=e.mtime,t._isDirectoryResolved=e._isDirectoryResolved,t._isSymbolicLink=e.isSymbolicLink,t.error=e.error,i&&e._isDirectoryResolved)){const r=new j;t.children.forEach(s=>{r.set(s.resource,s)}),t.children.clear(),e.children.forEach(s=>{const o=r.get(s.resource);o?(b.mergeLocalWithDisk(s,o),t.addChild(o),r.delete(s.resource)):t.addChild(s)}),r.forEach(s=>{s instanceof Sr&&t.addChild(s)})}}addChild(e){e._parent=this,e.updateResource(!1),this.children.set(this.getPlatformAwareName(e.name),e)}getChild(e){return this.children.get(this.getPlatformAwareName(e))}fetchChildren(e){const t=this.configService.getValue({resource:this.root.resource}).explorer.fileNesting;return t.enabled&&this.nestedChildren?this.nestedChildren:(async()=>{if(!this._isDirectoryResolved){const r=e===Ki.Modified;this.error=void 0;try{const s=await this.fileService.resolve(this.resource,{resolveSingleChildDescendants:!0,resolveMetadata:r}),o=b.create(this.fileService,this.configService,this.filesConfigService,s,this);b.mergeLocalWithDisk(o,this)}catch(s){throw this.error=s,s}this._isDirectoryResolved=!0}const i=[];if(t.enabled){const r=[],s=[];for(const n of this.children.entries())n[1].nestedParent=void 0,n[1].isDirectory?s.push(n):r.push(n);const o=this.fileNester.nest(r.map(([n])=>n),this.getPlatformAwareName(this.name));for(const[n,a]of r){const c=o.get(n);if(c!==void 0){a.nestedChildren=[];for(const u of c.keys()){const l=G(this.children.get(u));a.nestedChildren.push(l),l.nestedParent=a}i.push(a)}else a.nestedChildren=void 0}for(const[n,a]of s.values())i.push(a)}else this.children.forEach(r=>{i.push(r)});return i})()}get fileNester(){if(!this.root._fileNester){const e=this.configService.getValue({resource:this.root.resource}).explorer.fileNesting,t=Object.entries(e.patterns).filter(i=>typeof i[0]=="string"&&typeof i[1]=="string"&&i[0]&&i[1]).map(([i,r])=>[this.getPlatformAwareName(i.trim()),r.split(",").map(s=>this.getPlatformAwareName(s.trim().replace(/\u200b/g,"").trim())).filter(s=>s!=="")]);this.root._fileNester=new vr(t)}return this.root._fileNester}removeChild(e){this.nestedChildren=void 0,this.children.delete(this.getPlatformAwareName(e.name))}forgetChildren(){this.children.clear(),this.nestedChildren=void 0,this._isDirectoryResolved=!1,this._fileNester=void 0}getPlatformAwareName(e){return this.fileService.hasCapability(this.resource,at.PathCaseSensitive)?e:e.toLowerCase()}move(e){this.nestedParent?.removeChild(this),this._parent?.removeChild(this),e.removeChild(this),e.addChild(this),this.updateResource(!0)}updateResource(e){this._parent&&(this.resource=It(this._parent.resource,this.name)),e&&this.isDirectory&&this.children.forEach(t=>{t.updateResource(!0)})}rename(e){this.updateName(e.name),this._mtime=e.mtime,this.updateResource(!0)}find(e){const t=!this.fileService.hasCapability(e,at.PathCaseSensitive);return e&&this.resource.scheme===e.scheme&&zi(this.resource.authority,e.authority)&&(t?$i(e.path,this.resource.path):e.path.startsWith(this.resource.path))?this.findByPath(dt(e.path,re.sep),this.resource.path.length,t):null}findByPath(e,t,i){if(qi(dt(this.resource.path,re.sep),e,i))return this;if(this.isDirectory){for(;t<e.length&&e[t]===re.sep;)t++;let r=e.indexOf(re.sep,t);r===-1&&(r=e.length);const s=e.substring(t,r),o=this.children.get(this.getPlatformAwareName(s));if(o)return o.findByPath(e,r,i)}return null}isMarkedAsFiltered(){return this.markedAsFindResult}markItemAndParentsAsFiltered(){this.markedAsFindResult=!0,this.parent?.markItemAndParentsAsFiltered()}unmarkItemAndChildren(){this.markedAsFindResult=!1,this.children.forEach(e=>e.unmarkItemAndChildren())}}b.__decorator=O([Hi],b.prototype,"children",null);class Sr extends b{constructor(e,t,i,r,s){super(g.file(""),e,t,i,r,s),this._isDirectoryResolved=!0}}function Ut(d){const e=d.get(Nt).lastFocusedList,t=e?.getHTMLElement();if(t&&ji(t)&&e instanceof St){const i=M(e.getSelectedElements().filter(n=>n instanceof ct)),r=e.getFocusedElements(),s=r.length?r[0]:void 0;let o;return s instanceof ct&&(o=s),i.some(n=>n===o)?i:o?[o]:void 0}}async function Ke(d,e){const t=d.get(_),i=d.get(rr),r=d.get(ke);let s=Ut(d);if(!s){const n=t.activeGroup;n.activeEditor&&(s=[],n.activeEditor instanceof $&&!e?.saveAs&&!(n.activeEditor.primary.hasCapability(f.Untitled)||n.activeEditor.secondary.hasCapability(f.Untitled))&&n.activeEditor.secondary.isModified()?(s.push({groupId:n.id,editor:n.activeEditor.primary}),s.push({groupId:n.id,editor:n.activeEditor.secondary})):s.push({groupId:n.id,editor:n.activeEditor}))}if(!s||s.length===0)return;await ze(d,s,e);const o=i.getFocusedCodeEditor();if(o instanceof sr&&!o.isSimpleWidget){const n=o.getModel()?.uri;n&&!s.some(({editor:a})=>q(Q.getCanonicalUri(a,{supportSideBySide:m.PRIMARY}),n))&&(r.files.get(n)?.isReadonly()||await r.save(n,e))}}function Ht(d,e,t){const i=[];for(const r of e)for(const s of r.getEditors(S.MOST_RECENTLY_ACTIVE))s.isDirty()&&i.push({groupId:r.id,editor:s});return ze(d,i,t)}async function ze(d,e,t){const i=d.get(L),r=d.get(Gt),s=d.get(Z);try{await i.save(e,t)}catch(o){if(!or(o)){const n=[ht({id:"workbench.action.files.saveEditors",label:K(7410,"Retry"),run:()=>s.invokeFunction(c=>ze(c,e,t))})],a=e.filter(({editor:c})=>!c.hasCapability(f.Untitled));a.length>0&&n.push(ht({id:"workbench.action.files.revertEditors",label:a.length>1?K(7411,"Revert All"):K(7412,"Revert"),run:()=>i.revert(a)})),r.notify({id:e.map(({editor:c})=>ar(c.resource?.toString())).join(),severity:nr.Error,message:K(7413,"Failed to save '{0}': {1}",e.map(({editor:c})=>c.getName()).join(", "),Ft(o,!1)),actions:{primary:n}})}}}ge.registerCommandAndKeybindingRule({when:void 0,weight:Ee.WorkbenchContrib,primary:w.CtrlCmd|T.KeyS,id:Zi,handler:d=>Ke(d,{reason:p.EXPLICIT,force:!0})});ge.registerCommandAndKeybindingRule({when:void 0,weight:Ee.WorkbenchContrib,primary:be(w.CtrlCmd|T.KeyK,T.KeyS),win:{primary:be(w.CtrlCmd|T.KeyK,w.CtrlCmd|w.Shift|T.KeyS)},id:Xi,handler:d=>Ke(d,{reason:p.EXPLICIT,force:!0,skipSaveParticipants:!0})});ge.registerCommandAndKeybindingRule({id:Qi,weight:Ee.WorkbenchContrib,when:void 0,primary:w.CtrlCmd|w.Shift|T.KeyS,handler:d=>Ke(d,{reason:p.EXPLICIT,saveAs:!0})});ge.registerCommandAndKeybindingRule({when:void 0,weight:Ee.WorkbenchContrib,primary:void 0,mac:{primary:w.CtrlCmd|w.Alt|T.KeyS},win:{primary:be(w.CtrlCmd|T.KeyK,T.KeyS)},id:Ji,handler:d=>Ht(d,d.get(_).getGroups(C.MOST_RECENTLY_ACTIVE),{reason:p.EXPLICIT})});He.registerCommand({id:er,handler:(d,e,t)=>{const i=d.get(_),r=hr([t],d.get(L),i,d.get(Nt));let s;return r.groupedEditors.length?s=r.groupedEditors.map(({group:o})=>o):s=i.getGroups(C.MOST_RECENTLY_ACTIVE),Ht(d,s,{reason:p.EXPLICIT})}});He.registerCommand({id:tr,handler:async d=>(await d.get(L).saveAll({includeUntitled:!1,reason:p.EXPLICIT})).success});He.registerCommand({id:ir,handler:async d=>{const e=d.get(_),t=d.get(L);let i=Ut(d);if(!i){const r=e.activeGroup;r.activeEditor&&(i=[{groupId:r.id,editor:r.activeEditor}])}if(!(!i||i.length===0))try{await t.revert(i.filter(({editor:r})=>!r.hasCapability(f.Untitled)),{force:!0})}catch(r){d.get(Gt).error(K(7414,"Failed to revert '{0}': {1}",i.map(({editor:o})=>o.getName()).join(", "),Ft(r,!1)))}}});export{Te as A,Ne as B,ft as E,ce as F,Pe as S,pt as T,ae as U,ut as f,hr as r};
|
|
7
|
+
`)}}var D;(function(d){d.capture="capture",d.basename="basename",d.dirname="dirname",d.extname="extname"})(D||(D={}));const gt=/\$[({](capture|basename|dirname|extname)[)}]/g;class Et{constructor(e){this.tokens=[],gt.lastIndex=0;let t,i=0;for(;t=gt.exec(e);){const r=e.slice(i,t.index);this.tokens.push(r);const s=t[1];switch(s){case D.basename:case D.dirname:case D.extname:case D.capture:this.tokens.push({capture:s});break;default:throw Error("unknown substitution type: "+s)}i=t.index+t[0].length}if(i!==e.length){const r=e.slice(i,e.length);this.tokens.push(r)}}substitute(e,t){return this.tokens.map(i=>{if(typeof i=="string")return i;switch(i.capture){case D.basename:return e.basename;case D.dirname:return e.dirname;case D.extname:return e.extname;case D.capture:return t||""}}).join("")}}class b{constructor(e,t,i,r,s,o,n,a,c,u=Bi(e),l,I=!1){this.resource=e,this.fileService=t,this.configService=i,this.filesConfigService=r,this._parent=s,this._isDirectory=o,this._isSymbolicLink=n,this._readonly=a,this._locked=c,this._name=u,this._mtime=l,this._unknown=I,this.error=void 0,this._isExcluded=!1,this.markedAsFindResult=!1,this._isDirectoryResolved=!1}get isExcluded(){return this._isExcluded?!0:this._parent?this._parent.isExcluded:!1}set isExcluded(e){this._isExcluded=e}hasChildren(e){return this.hasNests?this.nestedChildren?.some(t=>e(t))??!1:this.isDirectory}get hasNests(){return!!this.nestedChildren?.length}get isDirectoryResolved(){return this._isDirectoryResolved}get isSymbolicLink(){return!!this._isSymbolicLink}get isDirectory(){return!!this._isDirectory}get isReadonly(){return this.filesConfigService.isReadonly(this.resource,{resource:this.resource,name:this.name,readonly:this._readonly,locked:this._locked})}get mtime(){return this._mtime}get name(){return this._name}get isUnknown(){return this._unknown}get parent(){return this._parent}get root(){return this._parent?this._parent.root:this}get children(){return new Map}updateName(e){this._parent?.removeChild(this),this._name=e,this._parent?.addChild(this)}getId(){let e=this.root.resource.toString()+"::"+this.resource.toString();return this.isMarkedAsFiltered()&&(e+="::findFilterResult"),e}toString(){return`ExplorerItem: ${this.name}`}get isRoot(){return this===this.root}static create(e,t,i,r,s,o){const n=new b(r.resource,e,t,i,s,r.isDirectory,r.isSymbolicLink,r.readonly,r.locked,r.name,r.mtime,!r.isFile&&!r.isDirectory);if(n.isDirectory&&(n._isDirectoryResolved=!!r.children||!!o&&o.some(a=>Yi(a,n.resource)),r.children))for(let a=0,c=r.children.length;a<c;a++){const u=b.create(e,t,i,r.children[a],n,o);n.addChild(u)}return n}static mergeLocalWithDisk(e,t){if(e.resource.toString()!==t.resource.toString())return;const i=e.isDirectory||t.isDirectory;if(!(i&&t._isDirectoryResolved&&!e._isDirectoryResolved)&&(t.resource=e.resource,t.isRoot||t.updateName(e.name),t._isDirectory=e.isDirectory,t._mtime=e.mtime,t._isDirectoryResolved=e._isDirectoryResolved,t._isSymbolicLink=e.isSymbolicLink,t.error=e.error,i&&e._isDirectoryResolved)){const r=new q;t.children.forEach(s=>{r.set(s.resource,s)}),t.children.clear(),e.children.forEach(s=>{const o=r.get(s.resource);o?(b.mergeLocalWithDisk(s,o),t.addChild(o),r.delete(s.resource)):t.addChild(s)}),r.forEach(s=>{s instanceof Sr&&t.addChild(s)})}}addChild(e){e._parent=this,e.updateResource(!1),this.children.set(this.getPlatformAwareName(e.name),e)}getChild(e){return this.children.get(this.getPlatformAwareName(e))}fetchChildren(e){const t=this.configService.getValue({resource:this.root.resource}).explorer.fileNesting;return t.enabled&&this.nestedChildren?this.nestedChildren:(async()=>{if(!this._isDirectoryResolved){const r=e===Ki.Modified;this.error=void 0;try{const s=await this.fileService.resolve(this.resource,{resolveSingleChildDescendants:!0,resolveMetadata:r}),o=b.create(this.fileService,this.configService,this.filesConfigService,s,this);b.mergeLocalWithDisk(o,this)}catch(s){throw this.error=s,s}this._isDirectoryResolved=!0}const i=[];if(t.enabled){const r=[],s=[];for(const n of this.children.entries())n[1].nestedParent=void 0,n[1].isDirectory?s.push(n):r.push(n);const o=this.fileNester.nest(r.map(([n])=>n),this.getPlatformAwareName(this.name));for(const[n,a]of r){const c=o.get(n);if(c!==void 0){a.nestedChildren=[];for(const u of c.keys()){const l=G(this.children.get(u));a.nestedChildren.push(l),l.nestedParent=a}i.push(a)}else a.nestedChildren=void 0}for(const[n,a]of s.values())i.push(a)}else this.children.forEach(r=>{i.push(r)});return i})()}get fileNester(){if(!this.root._fileNester){const e=this.configService.getValue({resource:this.root.resource}).explorer.fileNesting,t=Object.entries(e.patterns).filter(i=>typeof i[0]=="string"&&typeof i[1]=="string"&&i[0]&&i[1]).map(([i,r])=>[this.getPlatformAwareName(i.trim()),r.split(",").map(s=>this.getPlatformAwareName(s.trim().replace(/\u200b/g,"").trim())).filter(s=>s!=="")]);this.root._fileNester=new vr(t)}return this.root._fileNester}removeChild(e){this.nestedChildren=void 0,this.children.delete(this.getPlatformAwareName(e.name))}forgetChildren(){this.children.clear(),this.nestedChildren=void 0,this._isDirectoryResolved=!1,this._fileNester=void 0}getPlatformAwareName(e){return this.fileService.hasCapability(this.resource,at.PathCaseSensitive)?e:e.toLowerCase()}move(e){this.nestedParent?.removeChild(this),this._parent?.removeChild(this),e.removeChild(this),e.addChild(this),this.updateResource(!0)}updateResource(e){this._parent&&(this.resource=It(this._parent.resource,this.name)),e&&this.isDirectory&&this.children.forEach(t=>{t.updateResource(!0)})}rename(e){this.updateName(e.name),this._mtime=e.mtime,this.updateResource(!0)}find(e){const t=!this.fileService.hasCapability(e,at.PathCaseSensitive);return e&&this.resource.scheme===e.scheme&&zi(this.resource.authority,e.authority)&&(t?$i(e.path,this.resource.path):e.path.startsWith(this.resource.path))?this.findByPath(dt(e.path,re.sep),this.resource.path.length,t):null}findByPath(e,t,i){if(ji(dt(this.resource.path,re.sep),e,i))return this;if(this.isDirectory){for(;t<e.length&&e[t]===re.sep;)t++;let r=e.indexOf(re.sep,t);r===-1&&(r=e.length);const s=e.substring(t,r),o=this.children.get(this.getPlatformAwareName(s));if(o)return o.findByPath(e,r,i)}return null}isMarkedAsFiltered(){return this.markedAsFindResult}markItemAndParentsAsFiltered(){this.markedAsFindResult=!0,this.parent?.markItemAndParentsAsFiltered()}unmarkItemAndChildren(){this.markedAsFindResult=!1,this.children.forEach(e=>e.unmarkItemAndChildren())}}b.__decorator=O([Hi],b.prototype,"children",null);class Sr extends b{constructor(e,t,i,r,s){super(g.file(""),e,t,i,r,s),this._isDirectoryResolved=!0}}function Ut(d){const e=d.get(Nt).lastFocusedList,t=e?.getHTMLElement();if(t&&qi(t)&&e instanceof St){const i=M(e.getSelectedElements().filter(n=>n instanceof ct)),r=e.getFocusedElements(),s=r.length?r[0]:void 0;let o;return s instanceof ct&&(o=s),i.some(n=>n===o)?i:o?[o]:void 0}}async function Ke(d,e){const t=d.get(_),i=d.get(rr),r=d.get(ke);let s=Ut(d);if(!s){const n=t.activeGroup;n.activeEditor&&(s=[],n.activeEditor instanceof $&&!e?.saveAs&&!(n.activeEditor.primary.hasCapability(f.Untitled)||n.activeEditor.secondary.hasCapability(f.Untitled))&&n.activeEditor.secondary.isModified()?(s.push({groupId:n.id,editor:n.activeEditor.primary}),s.push({groupId:n.id,editor:n.activeEditor.secondary})):s.push({groupId:n.id,editor:n.activeEditor}))}if(!s||s.length===0)return;await ze(d,s,e);const o=i.getFocusedCodeEditor();if(o instanceof sr&&!o.isSimpleWidget){const n=o.getModel()?.uri;n&&!s.some(({editor:a})=>j(Q.getCanonicalUri(a,{supportSideBySide:m.PRIMARY}),n))&&(r.files.get(n)?.isReadonly()||await r.save(n,e))}}function Ht(d,e,t){const i=[];for(const r of e)for(const s of r.getEditors(S.MOST_RECENTLY_ACTIVE))s.isDirty()&&i.push({groupId:r.id,editor:s});return ze(d,i,t)}async function ze(d,e,t){const i=d.get(L),r=d.get(Gt),s=d.get(Z);try{await i.save(e,t)}catch(o){if(!or(o)){const n=[ht({id:"workbench.action.files.saveEditors",label:K(7410,"Retry"),run:()=>s.invokeFunction(c=>ze(c,e,t))})],a=e.filter(({editor:c})=>!c.hasCapability(f.Untitled));a.length>0&&n.push(ht({id:"workbench.action.files.revertEditors",label:a.length>1?K(7411,"Revert All"):K(7412,"Revert"),run:()=>i.revert(a)})),r.notify({id:e.map(({editor:c})=>ar(c.resource?.toString())).join(),severity:nr.Error,message:K(7413,"Failed to save '{0}': {1}",e.map(({editor:c})=>c.getName()).join(", "),Ft(o,!1)),actions:{primary:n}})}}}ge.registerCommandAndKeybindingRule({when:void 0,weight:Ee.WorkbenchContrib,primary:w.CtrlCmd|T.KeyS,id:Zi,handler:d=>Ke(d,{reason:p.EXPLICIT,force:!0})});ge.registerCommandAndKeybindingRule({when:void 0,weight:Ee.WorkbenchContrib,primary:be(w.CtrlCmd|T.KeyK,T.KeyS),win:{primary:be(w.CtrlCmd|T.KeyK,w.CtrlCmd|w.Shift|T.KeyS)},id:Xi,handler:d=>Ke(d,{reason:p.EXPLICIT,force:!0,skipSaveParticipants:!0})});ge.registerCommandAndKeybindingRule({id:Qi,weight:Ee.WorkbenchContrib,when:void 0,primary:w.CtrlCmd|w.Shift|T.KeyS,handler:d=>Ke(d,{reason:p.EXPLICIT,saveAs:!0})});ge.registerCommandAndKeybindingRule({when:void 0,weight:Ee.WorkbenchContrib,primary:void 0,mac:{primary:w.CtrlCmd|w.Alt|T.KeyS},win:{primary:be(w.CtrlCmd|T.KeyK,T.KeyS)},id:Ji,handler:d=>Ht(d,d.get(_).getGroups(C.MOST_RECENTLY_ACTIVE),{reason:p.EXPLICIT})});He.registerCommand({id:er,handler:(d,e,t)=>{const i=d.get(_),r=hr([t],d.get(L),i,d.get(Nt));let s;return r.groupedEditors.length?s=r.groupedEditors.map(({group:o})=>o):s=i.getGroups(C.MOST_RECENTLY_ACTIVE),Ht(d,s,{reason:p.EXPLICIT})}});He.registerCommand({id:tr,handler:async d=>(await d.get(L).saveAll({includeUntitled:!1,reason:p.EXPLICIT})).success});He.registerCommand({id:ir,handler:async d=>{const e=d.get(_),t=d.get(L);let i=Ut(d);if(!i){const r=e.activeGroup;r.activeEditor&&(i=[{groupId:r.id,editor:r.activeEditor}])}if(!(!i||i.length===0))try{await t.revert(i.filter(({editor:r})=>!r.hasCapability(f.Untitled)),{force:!0})}catch(r){d.get(Gt).error(K(7414,"Failed to revert '{0}': {1}",i.map(({editor:o})=>o.getName()).join(", "),Ft(r,!1)))}}});export{Te as A,Ne as B,ft as E,ce as F,Pe as S,pt as T,ae as U,ut as f,hr as r};
|