@xano/xanoscript-monaco-editor 0.1.0 → 0.1.2
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/README.md +77 -126
- package/dist/.vite/manifest.json +54 -54
- package/dist/assets/{editor-BivTGeL1.js → editor-4HUBGwOu.js} +1 -1
- package/dist/assets/{extensionHost.worker-bYZXB0kM.js → extensionHost.worker-BEj8h9xB.js} +7 -7
- package/dist/assets/{files.contribution._fileEditorFactory-vS4ZLYi1.js → files.contribution._fileEditorFactory-YNF_vxMj.js} +1 -1
- package/dist/assets/{iconv-lite-umd-DQaTktu2.js → iconv-lite-umd-BCZHOywd.js} +2 -7
- package/dist/assets/{iconv-lite-umd-DYWd8cEa.js → iconv-lite-umd-BGIeO9cR.js} +2 -7
- package/dist/assets/{index-CrbRjSB_.js → index-9GTRLRSC.js} +1 -1
- package/dist/assets/{index-BGwiFEyd.js → index-B48SQPT2.js} +1 -1
- package/dist/assets/{index-VRHnXpb2.js → index-B7W-kS7G.js} +1 -1
- package/dist/assets/{index-51WpeTZl.js → index-CBODr4QR.js} +3 -3
- package/dist/assets/{index-C3pnKX8a.js → index-Cw1WVxjJ.js} +1 -1
- package/dist/assets/{index-BwfWF2CI.js → index-DSexFukl.js} +47 -47
- package/dist/assets/{index-C25FTAfE.js → index-DV2XmbY1.js} +1 -1
- package/dist/assets/{index-B132pG6E.js → index-DoXiLhIy.js} +2 -2
- package/dist/assets/{index-DgK2LcnW.js → index-r-mEMSNw.js} +2 -2
- package/dist/assets/{index-yPQeQvu7.js → index-sQEJqDvC.js} +1 -1
- package/dist/assets/main--VvQJcub.js +4 -0
- package/dist/assets/main-DUUA0eUQ.js +4 -0
- package/dist/assets/main-DWv94O3B.js +1 -0
- package/dist/assets/main-Du3mMy1c.js +1 -0
- package/dist/assets/{tokenClassificationRegistry-DcBtqg2t.js → tokenClassificationRegistry-CZyxOMX0.js} +1 -1
- package/dist/assets/{views-hUfpm9tT.js → views-Bu3Oa5Y-.js} +3 -3
- package/dist/assets/{views-C4cPu3oQ.css → views-qXWInm-E.css} +1 -1
- package/dist/assets/workbenchThemeService.service-CXlQNmVU.js +1 -0
- package/dist/assets/{worker-BIMDXoFp.js → worker-BiA-ZZ0u.js} +2 -2
- package/dist/index.html +1 -1
- package/dist/logic-assistant-script.js +22301 -16325
- package/dist/logic-assistant-script.js.map +4 -4
- package/dist/worker.js +20541 -14435
- package/dist/worker.js.map +4 -4
- package/package.json +3 -1
- package/dist/assets/main-D6ceXGB_.js +0 -4
- package/dist/assets/main-DNugpDp4.js +0 -4
- package/dist/assets/main-FP17jmvp.js +0 -1
- package/dist/assets/main-b5eBH2vx.js +0 -1
- package/dist/assets/workbenchThemeService.service-qBFVnuYD.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{cc as F,h as ge,jn as k,hA as Se,tG as re,tH as Te,co as A,jM as R,cz as g,jw as _e,D as P,tI as be,jC as b,E as y,jO as E,d as J,hI as se,cR as X,d8 as _,il as Me,tJ as x,jr as Z,aJ as W,aK as we,aH as ee,k1 as te,cr as O,f as U,g as u,bx as ke,lQ as oe,hD as Le,jk as N,jl as G,ik as V,tK as Fe,x as Pe,jL as Ue,bs as xe,eQ as We,ev as H,lN as K,tL as Ne,o6 as Ve,tD as He,jj as B,jq as Y,cq as q,tM as z,U as l,em as Ce,jx as ye,jp as Ae,ct as Ke,bc as ne,tN as ae,tO as p,cF as Be,W as Oe,bz as De,ch as Ye,ip as ie,k5 as Re,tF as qe,dN as Ie,oC as ze,cC as je,jo as j,ji as $e,a0 as de,n_ as ce,jA as Qe,o2 as ue,z as Je,oD as Xe,tP as C,tQ as f,t5 as he,t as Ze,oy as et,bW as tt,lU as it,O as rt,o8 as st,X as ot,Y as nt,th as at,t7 as le}from"./index-BwfWF2CI.js";function fe(h,e,t){const i=h.get(F),r=h.get(ge),s=dt(e,t,i,r);return s instanceof Promise?s.then(n=>pe(n,e,t,i)):pe(s,e,t,i)}function pe(h,e,t,i){let r;return i.activeGroup!==h&&e.options&&!e.options.inactive&&e.options.preserveFocus&&typeof e.options.activation!="number"&&t!==Se&&(r=_e.ACTIVATE),[h,r]}function dt(h,e,t,i){let r;const s=k(h)?h.editor:h,n=h.options;if(e&&typeof e!="number")r=e;else if(typeof e=="number"&&e>=0)r=t.getGroup(e);else if(e===Se){const o=re(i);let a=t.findGroup({direction:o});(!a||w(a,s))&&(a=t.addGroup(t.activeGroup,o)),r=a}else if(e===Te)r=t.createAuxiliaryEditorPart({bounds:n?.auxiliary?.bounds,compact:n?.auxiliary?.compact,alwaysOnTop:n?.auxiliary?.alwaysOnTop}).then(o=>o.activeGroup);else if(!n||typeof n.index!="number"){const o=t.getGroups(A.MOST_RECENTLY_ACTIVE);if(n?.revealIfVisible){for(const a of o)if(ct(a,s)){r=a;break}}if(!r&&(n?.revealIfOpened||i.getValue("workbench.editor.revealIfOpen")||R(s)&&s.hasCapability(g.Singleton))){let a,d;for(const c of o)if(me(c,s)&&(d||(d=c),!a&&c.isActive(s)&&(a=c)),d&&a)break;r=a||d}}if(!r){let o=t.activeGroup;if(w(o,s)){for(const a of t.getGroups(A.MOST_RECENTLY_ACTIVE))if(!w(a,s)){o=a;break}w(o,s)?r=t.addGroup(o,re(i)):r=o}else r=o}return r}function w(h,e){return!(!h.isLocked||me(h,e))}function ct(h,e){return h.activeEditor?h.activeEditor.matches(e):!1}function me(h,e){for(const t of h.editors)if(t.matches(e))return!0;return!1}var T,D;let $=(D=class extends P{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 be,this.editorsPerResourceCounter=new b,this._onDidMostRecentlyActiveEditorsChange=this._register(new y),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(E.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 J;t.add(e.onDidModelChange(i=>{switch(i.kind){case se.GROUP_ACTIVE:{this.editorGroupsContainer.activeGroup===e&&e.activeEditor&&this.addMostRecentEditor(e,e.activeEditor,!0,!1);break}case se.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)})),X.once(e.onWillDispose)(()=>_(t))}onDidChangeEditorPartOptions(e){if(!Me(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),n=this.mostRecentEditorsMap.first;i||!n?this.mostRecentEditorsMap.set(s,s,n?x.AsOld:void 0):(this.mostRecentEditorsMap.set(s,s,x.AsOld),this.mostRecentEditorsMap.set(n,n,x.AsOld)),r&&this.updateEditorResourcesMap(t,!0),this._onDidMostRecentlyActiveEditorsChange.fire()}updateEditorResourcesMap(e,t){let i,r,s;if(e instanceof Z?(i=e.primary.resource,r=e.primary.typeId,s=e.primary.editorId):(i=e.resource,r=e.typeId,s=e.editorId),!i)return;const n=this.toIdentifier(r,s);if(t){let o=this.editorsPerResourceCounter.get(i);o||(o=new Map,this.editorsPerResourceCounter.set(i,o)),o.set(n,(o.get(n)??0)+1)}else{const o=this.editorsPerResourceCounter.get(i);if(o){const a=o.get(n)??0;a>1?o.set(n,a-1):(o.delete(n),o.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(E.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(g.Scratchpad))):r=t,e>=r.length)return;const s=r.reverse().filter(({editor:a,groupId:d})=>!(a.isDirty()&&!a.isSaving()||a.hasCapability(g.Scratchpad)||i&&a===i.editor&&d===i.groupId||this.editorGroupsContainer.getGroup(d)?.isSticky(a)));let n=r.length-e;const o=new Map;for(const{groupId:a,editor:d}of s){let c=o.get(a);if(c||(c=[],o.set(a,c)),c.push(d),n--,n===0)break}for(const[a,d]of o){const c=this.editorGroupsContainer.getGroup(a);c&&await c.closeEditors(d,{preserveFocus:!0})}}saveState(){this.isScoped||(this.mostRecentEditorsMap.isEmpty()?this.storageService.remove(T.STORAGE_KEY,W.WORKSPACE):this.storageService.store(T.STORAGE_KEY,JSON.stringify(this.serialize()),W.WORKSPACE,we.MACHINE))}serialize(){const e=ee.as(te.EditorFactory),t=[...this.mostRecentEditorsMap.values()],i=new Map;return{entries:O(t.map(({editor:r,groupId:s})=>{const n=this.editorGroupsContainer.getGroup(s);if(!n)return;let o=i.get(n);o||(o=n.getEditors(E.SEQUENTIAL).filter(d=>e.getEditorSerializer(d)?.canSerialize(d)),i.set(n,o));const a=o.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(T.STORAGE_KEY,W.WORKSPACE);t&&(e=!0,this.deserialize(JSON.parse(t)))}if(!e){const t=this.editorGroupsContainer.getGroups(A.MOST_RECENTLY_ACTIVE);for(let i=t.length-1;i>=0;i--){const r=t[i],s=r.getEditors(E.MOST_RECENTLY_ACTIVE);for(let n=s.length-1;n>=0;n--)this.addMostRecentEditor(r,s[n],!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 n=s.getEditorByIndex(r);if(!n)continue;const o=this.ensureKey(s,n);t.push([o,o]),this.updateEditorResourcesMap(n,!0)}this.mostRecentEditorsMap.fromJSON(t)}},T=D,D.STORAGE_KEY="editors.mru",D);$=T=U([u(1,F),u(2,ke)],$);var Q;let Ee=Q=class extends P{constructor(e,t,i,r,s,n,o,a,d,c,S){super(),this.editorGroupService=t,this.instantiationService=i,this.fileService=r,this.configurationService=s,this.contextService=n,this.uriIdentityService=o,this.editorResolverService=a,this.workspaceTrustRequestService=d,this.hostService=c,this.textEditorService=S,this._onDidActiveEditorChange=this._register(new y),this.onDidActiveEditorChange=this._onDidActiveEditorChange.event,this._onDidVisibleEditorsChange=this._register(new y),this.onDidVisibleEditorsChange=this._onDidVisibleEditorsChange.event,this._onDidEditorsChange=this._register(new y),this.onDidEditorsChange=this._onDidEditorsChange.event,this._onWillOpenEditor=this._register(new y),this.onWillOpenEditor=this._onWillOpenEditor.event,this._onDidCloseEditor=this._register(new y),this.onDidCloseEditor=this._onDidCloseEditor.event,this._onDidOpenEditorFail=this._register(new y),this.onDidOpenEditorFail=this._onDidOpenEditorFail.event,this._onDidMostRecentlyActiveEditorsChange=this._register(new y),this.onDidMostRecentlyActiveEditorsChange=this._onDidMostRecentlyActiveEditorsChange.event,this.lastActiveEditor=void 0,this.activeOutOfWorkspaceWatchers=new b,this.closeOnFileDelete=!1,this.editorGroupsContainer=e??t,this.editorsObserver=this._register(this.instantiationService.createInstance($,this.editorGroupsContainer)),this.onConfigurationUpdated(),this.registerListeners()}createScoped(e,t){return t.add(new Q(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 J;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})})),X.once(e.onWillDispose)(()=>{_(t)})}handleVisibleEditorsChange(){const e=new oe;for(const t of this.visibleEditors){const i=Le(O([N.getCanonicalUri(t,{supportSideBySide:G.PRIMARY}),N.getCanonicalUri(t,{supportSideBySide:G.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)||(_(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(V.MOVE)&&this.handleMovedFile(e.resource,e.target.resource),(e.isOperation(V.DELETE)||e.isOperation(V.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 n=s.resource;if(!n||!this.uriIdentityService.extUri.isEqualOrParent(n,e))continue;let o;if(this.uriIdentityService.extUri.isEqual(e,n))o=t;else{const c=Fe(n.path,e.path,this.uriIdentityService.extUri.ignorePathCasing(n));o=Pe(t,n.path.substr(c+e.path.length+1))}const a=await s.rename(i.id,o);if(!a)return;const d={preserveFocus:!0,pinned:i.isPinned(s),sticky:i.isSticky(s),index:i.getIndexOfEditor(s),inactive:!i.isActive(s)};R(a.editor)?r.push({editor:s,replacement:a.editor,options:{...a.options,...d}}):r.push({editor:s,replacement:{...a.editor,options:{...a.editor.options,...d}}})}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 n=!1;if(e instanceof Ue?n=e.contains(s,xe.DELETED):n=this.uriIdentityService.extUri.isEqualOrParent(s,e),!n)return;let o=!1;t&&this.fileService.hasProvider(s)&&(await We(100),o=await this.fileService.exists(s)),!o&&!r.isDisposed()&&r.dispose()}})()}getAllNonDirtyEditors(e){const t=[];function i(r){r.hasCapability(g.Untitled)&&!e.includeUntitled||r.isDirty()||t.push(r)}for(const r of this.editors)e.supportSideBySide&&r instanceof Z?(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(H(t)||K(t))return t;if(Ne(t)&&H(t.activeCodeEditor))return t.activeCodeEditor}}get activeTextEditorLanguageId(){let e;const t=this.activeTextEditorControl;return K(t)?e=t.getModifiedEditor():e=t,e?.getModel()?.getLanguageId()}get count(){return this.editorsObserver.count}get editors(){return this.getEditors(E.SEQUENTIAL).map(({editor:e})=>e)}getEditors(e,t){switch(e){case E.MOST_RECENTLY_ACTIVE:return t?.excludeSticky?this.editorsObserver.editors.filter(({groupId:i,editor:r})=>!this.editorGroupsContainer.getGroup(i)?.isSticky(r)):this.editorsObserver.editors;case E.SEQUENTIAL:{const i=[];for(const r of this.editorGroupsContainer.getGroups(A.GRID_APPEARANCE))i.push(...r.getEditors(E.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 O(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 Ve?(r.push(i.getPrimaryEditorPane()?.getControl()),r.push(i.getSecondaryEditorPane()?.getControl())):r.push(i.getControl());for(const s of r)(H(s)||K(s))&&t.push(s)}return t}getVisibleTextEditorControls(e){return this.doGetVisibleTextEditorControls(O(this.editorGroupsContainer.getGroups(e===E.SEQUENTIAL?A.GRID_APPEARANCE:A.MOST_RECENTLY_ACTIVE).map(t=>t.activeEditorPane)))}get visibleEditors(){return O(this.editorGroupsContainer.groups.map(e=>e.activeEditor))}async openEditor(e,t,i){let r,s=R(e)?t:e.options,n;if(He(t)&&(i=t),!R(e)){const o=await this.editorResolverService.resolveEditor(e,i);if(o===B.ABORT)return;Y(o)&&(r=o.editor,s=o.options,n=o.group)}if(r||(r=R(e)?e:await this.textEditorService.resolveTextEditor(e)),!n){let o;const a=this.instantiationService.invokeFunction(fe,{editor:r,options:s},i);a instanceof Promise?[n,o]=await a:[n,o]=a,o&&(s={...s,activation:o})}return n.openEditor(r,s)}async openEditors(e,t,i){if(i?.validateTrust&&!await this.handleWorkspaceTrust(e))return[];const r=new Map;for(const n of e){let o,a;if(!k(n)){const c=await this.editorResolverService.resolveEditor(n,t);if(c===B.ABORT)continue;Y(c)&&(o=c,a=c.group)}if(o||(o=k(n)?n:{editor:await this.textEditorService.resolveTextEditor(n),options:n.options}),!a){const c=this.instantiationService.invokeFunction(fe,o,t);c instanceof Promise?[a]=await c:[a]=c}let d=r.get(a);d||(d=[],r.set(a,d)),d.push(o)}const s=[];for(const[n,o]of r)s.push(n.openEditors(o));return O(await q.settled(s))}async handleWorkspaceTrust(e){const{resources:t,diffMode:i,mergeMode:r}=this.extractEditorResources(e);switch(await this.workspaceTrustRequestService.requestOpenFilesTrust(t)){case z.Open:return!0;case z.OpenInNewWindow:return await this.hostService.openWindow(t.map(n=>({fileUri:n})),{forceNewWindow:!0,diffMode:i,mergeMode:r}),!1;case z.Cancel:return!1}}extractEditorResources(e){const t=new oe;let i=!1,r=!1;for(const s of e)if(k(s)){const n=N.getOriginalUri(s.editor,{supportSideBySide:G.BOTH});l.isUri(n)?t.add(n):n&&(n.primary&&t.add(n.primary),n.secondary&&t.add(n.secondary),i=s.editor instanceof Ce)}else ye(s)&&(l.isUri(s.input1)&&t.add(s.input1.resource),l.isUri(s.input2)&&t.add(s.input2.resource),l.isUri(s.base)&&t.add(s.base.resource),l.isUri(s.result)&&t.add(s.result.resource),r=!0),Ae(s)?(l.isUri(s.original.resource)&&t.add(s.original.resource),l.isUri(s.modified.resource)&&t.add(s.modified.resource),i=!0):Ke(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 n=this.editorGroupsContainer.getGroup(s);if(!n)continue;let o=i.get(n);o||(o=[],i.set(n,o)),o.push(r)}for(const[r,s]of i)await r.closeEditors(s,t)}findEditors(e,t,i){const r=l.isUri(e)?e:e.resource,s=l.isUri(e)?void 0:e.typeId;if(t?.supportSideBySide!==G.ANY&&t?.supportSideBySide!==G.SECONDARY&&!this.editorsObserver.hasEditors(r))return l.isUri(e)||ne(i)?[]:void 0;if(ne(i)){const n=[];for(const o of this.editorGroupsContainer.getGroups(A.MOST_RECENTLY_ACTIVE)){const a=[];if(l.isUri(e))a.push(...this.findEditors(e,t,o));else{const d=this.findEditors(e,t,o);d&&a.push(d)}n.push(...a.map(d=>({editor:d,groupId:o.id})))}return n}else{const n=typeof i=="number"?this.editorGroupsContainer.getGroup(i):i;if(l.isUri(e))return n?n.findEditors(r,t):[];{if(!n)return;const o=n.findEditors(r,t);for(const a of o)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 n;if(!R(s.replacement)){const o=await this.editorResolverService.resolveEditor(s.replacement,i);if(o===B.ABORT)continue;Y(o)&&(n={editor:s.editor,replacement:o.editor,options:o.options,forceReplaceDirty:s.forceReplaceDirty})}n||(n={editor:s.editor,replacement:ae(s)?s.replacement:await this.textEditorService.resolveTextEditor(s.replacement),options:ae(s)?s.options:s.replacement.options,forceReplaceDirty:s.forceReplaceDirty}),r.push(n)}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:o,editor:a}of i)a.hasCapability(g.Untitled)?s.push({groupId:o,editor:a}):r.push({groupId:o,editor:a});const n=await q.settled(r.map(({groupId:o,editor:a})=>(t?.reason===p.EXPLICIT&&this.editorGroupsContainer.getGroup(o)?.pinEditor(a),a.save(o,t))));for(const{groupId:o,editor:a}of s){if(a.isDisposed())continue;const c={pinned:!0,viewState:(await this.openEditor(a,o))?.getViewState()},S=t?.saveAs?await a.saveAs(o,t):await a.save(o,t);if(n.push(S),!S)break;if(!a.matches(S)){const Ge=a.hasCapability(g.Untitled)?this.editorGroupsContainer.groups.map(M=>M.id):[o];for(const M of Ge)S instanceof Be?await this.replaceEditors([{editor:a,replacement:S,options:c}],M):await this.replaceEditors([{editor:a,replacement:{...S,options:c}}],M)}}return{success:n.every(o=>!!o),editors:O(n)}}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 q.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(A.MOST_RECENTLY_ACTIVE))for(const r of i.getEditors(E.MOST_RECENTLY_ACTIVE))r.isModified()&&((typeof e?.includeUntitled=="boolean"||!e?.includeUntitled?.includeScratchpad)&&r.hasCapability(g.Scratchpad)||!e?.includeUntitled&&r.hasCapability(g.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=>_(e)),this.activeOutOfWorkspaceWatchers.clear()}};Ee=Q=U([u(1,F),u(2,Oe),u(3,De),u(4,ge),u(5,Ye),u(6,ie),u(7,Re),u(8,qe),u(9,Ie),u(10,ze)],Ee);var I;class ut extends Error{constructor(e,t){super(e),this.name="FileEditorInputLeakError",this.stack=t}}var v;let ve=(v=class extends P{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 b,this.fileEditorFactory=ee.as(te.EditorFactory).getFileEditorFactory(),this.mapLeakToCounter=new Map,this.registerDefaultEditor()}registerDefaultEditor(){this._register(this.editorResolverService.registerEditor("*",{id:j.id,label:j.displayName,detail:j.providerDisplayName,priority:je.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(ye(e))return this.createTextEditor(e.result);if(Ae(e)){const r=this.createTextEditor(e.original),s=this.createTextEditor(e.modified);return this.instantiationService.createInstance(Ce,e.label,e.description,r,s,void 0)}if($e(e)){const r=this.createTextEditor(e.primary),s=this.createTextEditor(e.secondary);return this.instantiationService.createInstance(Z,e.label,e.description,s,r)}const t=e;if(t.forceUntitled||!t.resource||t.resource.scheme===de.untitled){const r={languageId:t.languageId,initialValue:t.contents,encoding:t.encoding};let s;return t.resource?.scheme===de.untitled?s=this.untitledTextEditorService.create({untitledResource:t.resource,...r}):s=this.untitledTextEditorService.create({associatedResource:t.resource,...r}),this.createOrGetCached(s.resource,()=>this.instantiationService.createInstance(ce,s))}const i=e;if(i.resource instanceof l){const r=i.label||Qe(i.resource),s=i.resource,n=this.uriIdentityService.asCanonicalUri(s);return this.createOrGetCached(n,()=>i.forceFile||this.fileService.hasProvider(n)?this.fileEditorFactory.createFileEditor(n,s,i.label,i.description,i.encoding,i.languageId,i.contents,this.instantiationService):this.instantiationService.createInstance(ue,n,i.label,i.description,i.languageId,i.contents),o=>{o instanceof ce||(o instanceof ue?(r&&o.setName(r),i.description&&o.setDescription(i.description),i.languageId&&o.setPreferredLanguageId(i.languageId),typeof i.contents=="string"&&o.setPreferredContents(i.contents)):(o.setPreferredResource(s),i.label&&o.setPreferredName(i.label),i.description&&o.setPreferredDescription(i.description),i.encoding&&o.setPreferredEncoding(i.encoding),i.languageId&&o.setPreferredLanguageId(i.languageId),typeof i.contents=="string"&&o.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 X.once(r.onWillDispose)(()=>{this.editorInputCache.delete(e),s&&this.untrackLeaks(s)}),r}trackLeaks(e){if(I.LEAK_REPORTED||this.editorInputCache.size<I.LEAK_TRACKING_THRESHOLD)return;const t=`${e.resource.scheme}#${e.typeId||"<no typeId>"}#${e.editorId||"<no editorId>"}
|
|
1
|
+
import{cc as F,h as ge,jn as k,hA as Se,tG as re,tH as Te,co as A,jM as R,cz as g,jw as _e,D as P,tI as be,jC as b,E as y,jO as E,d as J,hI as se,cR as X,d8 as _,il as Me,tJ as x,jr as Z,aJ as W,aK as we,aH as ee,k1 as te,cr as O,f as U,g as u,bx as ke,lQ as oe,hD as Le,jk as N,jl as G,ik as V,tK as Fe,x as Pe,jL as Ue,bs as xe,eQ as We,ev as H,lN as K,tL as Ne,o6 as Ve,tD as He,jj as B,jq as Y,cq as q,tM as z,U as l,em as Ce,jx as ye,jp as Ae,ct as Ke,bc as ne,tN as ae,tO as p,cF as Be,W as Oe,bz as De,ch as Ye,ip as ie,k5 as Re,tF as qe,dN as Ie,oC as ze,cC as je,jo as j,ji as $e,a0 as de,n_ as ce,jA as Qe,o2 as ue,z as Je,oD as Xe,tP as C,tQ as f,t5 as he,t as Ze,oy as et,bW as tt,lU as it,O as rt,o8 as st,X as ot,Y as nt,th as at,t7 as le}from"./index-DSexFukl.js";function fe(h,e,t){const i=h.get(F),r=h.get(ge),s=dt(e,t,i,r);return s instanceof Promise?s.then(n=>pe(n,e,t,i)):pe(s,e,t,i)}function pe(h,e,t,i){let r;return i.activeGroup!==h&&e.options&&!e.options.inactive&&e.options.preserveFocus&&typeof e.options.activation!="number"&&t!==Se&&(r=_e.ACTIVATE),[h,r]}function dt(h,e,t,i){let r;const s=k(h)?h.editor:h,n=h.options;if(e&&typeof e!="number")r=e;else if(typeof e=="number"&&e>=0)r=t.getGroup(e);else if(e===Se){const o=re(i);let a=t.findGroup({direction:o});(!a||w(a,s))&&(a=t.addGroup(t.activeGroup,o)),r=a}else if(e===Te)r=t.createAuxiliaryEditorPart({bounds:n?.auxiliary?.bounds,compact:n?.auxiliary?.compact,alwaysOnTop:n?.auxiliary?.alwaysOnTop}).then(o=>o.activeGroup);else if(!n||typeof n.index!="number"){const o=t.getGroups(A.MOST_RECENTLY_ACTIVE);if(n?.revealIfVisible){for(const a of o)if(ct(a,s)){r=a;break}}if(!r&&(n?.revealIfOpened||i.getValue("workbench.editor.revealIfOpen")||R(s)&&s.hasCapability(g.Singleton))){let a,d;for(const c of o)if(me(c,s)&&(d||(d=c),!a&&c.isActive(s)&&(a=c)),d&&a)break;r=a||d}}if(!r){let o=t.activeGroup;if(w(o,s)){for(const a of t.getGroups(A.MOST_RECENTLY_ACTIVE))if(!w(a,s)){o=a;break}w(o,s)?r=t.addGroup(o,re(i)):r=o}else r=o}return r}function w(h,e){return!(!h.isLocked||me(h,e))}function ct(h,e){return h.activeEditor?h.activeEditor.matches(e):!1}function me(h,e){for(const t of h.editors)if(t.matches(e))return!0;return!1}var T,D;let $=(D=class extends P{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 be,this.editorsPerResourceCounter=new b,this._onDidMostRecentlyActiveEditorsChange=this._register(new y),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(E.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 J;t.add(e.onDidModelChange(i=>{switch(i.kind){case se.GROUP_ACTIVE:{this.editorGroupsContainer.activeGroup===e&&e.activeEditor&&this.addMostRecentEditor(e,e.activeEditor,!0,!1);break}case se.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)})),X.once(e.onWillDispose)(()=>_(t))}onDidChangeEditorPartOptions(e){if(!Me(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),n=this.mostRecentEditorsMap.first;i||!n?this.mostRecentEditorsMap.set(s,s,n?x.AsOld:void 0):(this.mostRecentEditorsMap.set(s,s,x.AsOld),this.mostRecentEditorsMap.set(n,n,x.AsOld)),r&&this.updateEditorResourcesMap(t,!0),this._onDidMostRecentlyActiveEditorsChange.fire()}updateEditorResourcesMap(e,t){let i,r,s;if(e instanceof Z?(i=e.primary.resource,r=e.primary.typeId,s=e.primary.editorId):(i=e.resource,r=e.typeId,s=e.editorId),!i)return;const n=this.toIdentifier(r,s);if(t){let o=this.editorsPerResourceCounter.get(i);o||(o=new Map,this.editorsPerResourceCounter.set(i,o)),o.set(n,(o.get(n)??0)+1)}else{const o=this.editorsPerResourceCounter.get(i);if(o){const a=o.get(n)??0;a>1?o.set(n,a-1):(o.delete(n),o.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(E.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(g.Scratchpad))):r=t,e>=r.length)return;const s=r.reverse().filter(({editor:a,groupId:d})=>!(a.isDirty()&&!a.isSaving()||a.hasCapability(g.Scratchpad)||i&&a===i.editor&&d===i.groupId||this.editorGroupsContainer.getGroup(d)?.isSticky(a)));let n=r.length-e;const o=new Map;for(const{groupId:a,editor:d}of s){let c=o.get(a);if(c||(c=[],o.set(a,c)),c.push(d),n--,n===0)break}for(const[a,d]of o){const c=this.editorGroupsContainer.getGroup(a);c&&await c.closeEditors(d,{preserveFocus:!0})}}saveState(){this.isScoped||(this.mostRecentEditorsMap.isEmpty()?this.storageService.remove(T.STORAGE_KEY,W.WORKSPACE):this.storageService.store(T.STORAGE_KEY,JSON.stringify(this.serialize()),W.WORKSPACE,we.MACHINE))}serialize(){const e=ee.as(te.EditorFactory),t=[...this.mostRecentEditorsMap.values()],i=new Map;return{entries:O(t.map(({editor:r,groupId:s})=>{const n=this.editorGroupsContainer.getGroup(s);if(!n)return;let o=i.get(n);o||(o=n.getEditors(E.SEQUENTIAL).filter(d=>e.getEditorSerializer(d)?.canSerialize(d)),i.set(n,o));const a=o.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(T.STORAGE_KEY,W.WORKSPACE);t&&(e=!0,this.deserialize(JSON.parse(t)))}if(!e){const t=this.editorGroupsContainer.getGroups(A.MOST_RECENTLY_ACTIVE);for(let i=t.length-1;i>=0;i--){const r=t[i],s=r.getEditors(E.MOST_RECENTLY_ACTIVE);for(let n=s.length-1;n>=0;n--)this.addMostRecentEditor(r,s[n],!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 n=s.getEditorByIndex(r);if(!n)continue;const o=this.ensureKey(s,n);t.push([o,o]),this.updateEditorResourcesMap(n,!0)}this.mostRecentEditorsMap.fromJSON(t)}},T=D,D.STORAGE_KEY="editors.mru",D);$=T=U([u(1,F),u(2,ke)],$);var Q;let Ee=Q=class extends P{constructor(e,t,i,r,s,n,o,a,d,c,S){super(),this.editorGroupService=t,this.instantiationService=i,this.fileService=r,this.configurationService=s,this.contextService=n,this.uriIdentityService=o,this.editorResolverService=a,this.workspaceTrustRequestService=d,this.hostService=c,this.textEditorService=S,this._onDidActiveEditorChange=this._register(new y),this.onDidActiveEditorChange=this._onDidActiveEditorChange.event,this._onDidVisibleEditorsChange=this._register(new y),this.onDidVisibleEditorsChange=this._onDidVisibleEditorsChange.event,this._onDidEditorsChange=this._register(new y),this.onDidEditorsChange=this._onDidEditorsChange.event,this._onWillOpenEditor=this._register(new y),this.onWillOpenEditor=this._onWillOpenEditor.event,this._onDidCloseEditor=this._register(new y),this.onDidCloseEditor=this._onDidCloseEditor.event,this._onDidOpenEditorFail=this._register(new y),this.onDidOpenEditorFail=this._onDidOpenEditorFail.event,this._onDidMostRecentlyActiveEditorsChange=this._register(new y),this.onDidMostRecentlyActiveEditorsChange=this._onDidMostRecentlyActiveEditorsChange.event,this.lastActiveEditor=void 0,this.activeOutOfWorkspaceWatchers=new b,this.closeOnFileDelete=!1,this.editorGroupsContainer=e??t,this.editorsObserver=this._register(this.instantiationService.createInstance($,this.editorGroupsContainer)),this.onConfigurationUpdated(),this.registerListeners()}createScoped(e,t){return t.add(new Q(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 J;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})})),X.once(e.onWillDispose)(()=>{_(t)})}handleVisibleEditorsChange(){const e=new oe;for(const t of this.visibleEditors){const i=Le(O([N.getCanonicalUri(t,{supportSideBySide:G.PRIMARY}),N.getCanonicalUri(t,{supportSideBySide:G.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)||(_(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(V.MOVE)&&this.handleMovedFile(e.resource,e.target.resource),(e.isOperation(V.DELETE)||e.isOperation(V.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 n=s.resource;if(!n||!this.uriIdentityService.extUri.isEqualOrParent(n,e))continue;let o;if(this.uriIdentityService.extUri.isEqual(e,n))o=t;else{const c=Fe(n.path,e.path,this.uriIdentityService.extUri.ignorePathCasing(n));o=Pe(t,n.path.substr(c+e.path.length+1))}const a=await s.rename(i.id,o);if(!a)return;const d={preserveFocus:!0,pinned:i.isPinned(s),sticky:i.isSticky(s),index:i.getIndexOfEditor(s),inactive:!i.isActive(s)};R(a.editor)?r.push({editor:s,replacement:a.editor,options:{...a.options,...d}}):r.push({editor:s,replacement:{...a.editor,options:{...a.editor.options,...d}}})}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 n=!1;if(e instanceof Ue?n=e.contains(s,xe.DELETED):n=this.uriIdentityService.extUri.isEqualOrParent(s,e),!n)return;let o=!1;t&&this.fileService.hasProvider(s)&&(await We(100),o=await this.fileService.exists(s)),!o&&!r.isDisposed()&&r.dispose()}})()}getAllNonDirtyEditors(e){const t=[];function i(r){r.hasCapability(g.Untitled)&&!e.includeUntitled||r.isDirty()||t.push(r)}for(const r of this.editors)e.supportSideBySide&&r instanceof Z?(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(H(t)||K(t))return t;if(Ne(t)&&H(t.activeCodeEditor))return t.activeCodeEditor}}get activeTextEditorLanguageId(){let e;const t=this.activeTextEditorControl;return K(t)?e=t.getModifiedEditor():e=t,e?.getModel()?.getLanguageId()}get count(){return this.editorsObserver.count}get editors(){return this.getEditors(E.SEQUENTIAL).map(({editor:e})=>e)}getEditors(e,t){switch(e){case E.MOST_RECENTLY_ACTIVE:return t?.excludeSticky?this.editorsObserver.editors.filter(({groupId:i,editor:r})=>!this.editorGroupsContainer.getGroup(i)?.isSticky(r)):this.editorsObserver.editors;case E.SEQUENTIAL:{const i=[];for(const r of this.editorGroupsContainer.getGroups(A.GRID_APPEARANCE))i.push(...r.getEditors(E.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 O(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 Ve?(r.push(i.getPrimaryEditorPane()?.getControl()),r.push(i.getSecondaryEditorPane()?.getControl())):r.push(i.getControl());for(const s of r)(H(s)||K(s))&&t.push(s)}return t}getVisibleTextEditorControls(e){return this.doGetVisibleTextEditorControls(O(this.editorGroupsContainer.getGroups(e===E.SEQUENTIAL?A.GRID_APPEARANCE:A.MOST_RECENTLY_ACTIVE).map(t=>t.activeEditorPane)))}get visibleEditors(){return O(this.editorGroupsContainer.groups.map(e=>e.activeEditor))}async openEditor(e,t,i){let r,s=R(e)?t:e.options,n;if(He(t)&&(i=t),!R(e)){const o=await this.editorResolverService.resolveEditor(e,i);if(o===B.ABORT)return;Y(o)&&(r=o.editor,s=o.options,n=o.group)}if(r||(r=R(e)?e:await this.textEditorService.resolveTextEditor(e)),!n){let o;const a=this.instantiationService.invokeFunction(fe,{editor:r,options:s},i);a instanceof Promise?[n,o]=await a:[n,o]=a,o&&(s={...s,activation:o})}return n.openEditor(r,s)}async openEditors(e,t,i){if(i?.validateTrust&&!await this.handleWorkspaceTrust(e))return[];const r=new Map;for(const n of e){let o,a;if(!k(n)){const c=await this.editorResolverService.resolveEditor(n,t);if(c===B.ABORT)continue;Y(c)&&(o=c,a=c.group)}if(o||(o=k(n)?n:{editor:await this.textEditorService.resolveTextEditor(n),options:n.options}),!a){const c=this.instantiationService.invokeFunction(fe,o,t);c instanceof Promise?[a]=await c:[a]=c}let d=r.get(a);d||(d=[],r.set(a,d)),d.push(o)}const s=[];for(const[n,o]of r)s.push(n.openEditors(o));return O(await q.settled(s))}async handleWorkspaceTrust(e){const{resources:t,diffMode:i,mergeMode:r}=this.extractEditorResources(e);switch(await this.workspaceTrustRequestService.requestOpenFilesTrust(t)){case z.Open:return!0;case z.OpenInNewWindow:return await this.hostService.openWindow(t.map(n=>({fileUri:n})),{forceNewWindow:!0,diffMode:i,mergeMode:r}),!1;case z.Cancel:return!1}}extractEditorResources(e){const t=new oe;let i=!1,r=!1;for(const s of e)if(k(s)){const n=N.getOriginalUri(s.editor,{supportSideBySide:G.BOTH});l.isUri(n)?t.add(n):n&&(n.primary&&t.add(n.primary),n.secondary&&t.add(n.secondary),i=s.editor instanceof Ce)}else ye(s)&&(l.isUri(s.input1)&&t.add(s.input1.resource),l.isUri(s.input2)&&t.add(s.input2.resource),l.isUri(s.base)&&t.add(s.base.resource),l.isUri(s.result)&&t.add(s.result.resource),r=!0),Ae(s)?(l.isUri(s.original.resource)&&t.add(s.original.resource),l.isUri(s.modified.resource)&&t.add(s.modified.resource),i=!0):Ke(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 n=this.editorGroupsContainer.getGroup(s);if(!n)continue;let o=i.get(n);o||(o=[],i.set(n,o)),o.push(r)}for(const[r,s]of i)await r.closeEditors(s,t)}findEditors(e,t,i){const r=l.isUri(e)?e:e.resource,s=l.isUri(e)?void 0:e.typeId;if(t?.supportSideBySide!==G.ANY&&t?.supportSideBySide!==G.SECONDARY&&!this.editorsObserver.hasEditors(r))return l.isUri(e)||ne(i)?[]:void 0;if(ne(i)){const n=[];for(const o of this.editorGroupsContainer.getGroups(A.MOST_RECENTLY_ACTIVE)){const a=[];if(l.isUri(e))a.push(...this.findEditors(e,t,o));else{const d=this.findEditors(e,t,o);d&&a.push(d)}n.push(...a.map(d=>({editor:d,groupId:o.id})))}return n}else{const n=typeof i=="number"?this.editorGroupsContainer.getGroup(i):i;if(l.isUri(e))return n?n.findEditors(r,t):[];{if(!n)return;const o=n.findEditors(r,t);for(const a of o)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 n;if(!R(s.replacement)){const o=await this.editorResolverService.resolveEditor(s.replacement,i);if(o===B.ABORT)continue;Y(o)&&(n={editor:s.editor,replacement:o.editor,options:o.options,forceReplaceDirty:s.forceReplaceDirty})}n||(n={editor:s.editor,replacement:ae(s)?s.replacement:await this.textEditorService.resolveTextEditor(s.replacement),options:ae(s)?s.options:s.replacement.options,forceReplaceDirty:s.forceReplaceDirty}),r.push(n)}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:o,editor:a}of i)a.hasCapability(g.Untitled)?s.push({groupId:o,editor:a}):r.push({groupId:o,editor:a});const n=await q.settled(r.map(({groupId:o,editor:a})=>(t?.reason===p.EXPLICIT&&this.editorGroupsContainer.getGroup(o)?.pinEditor(a),a.save(o,t))));for(const{groupId:o,editor:a}of s){if(a.isDisposed())continue;const c={pinned:!0,viewState:(await this.openEditor(a,o))?.getViewState()},S=t?.saveAs?await a.saveAs(o,t):await a.save(o,t);if(n.push(S),!S)break;if(!a.matches(S)){const Ge=a.hasCapability(g.Untitled)?this.editorGroupsContainer.groups.map(M=>M.id):[o];for(const M of Ge)S instanceof Be?await this.replaceEditors([{editor:a,replacement:S,options:c}],M):await this.replaceEditors([{editor:a,replacement:{...S,options:c}}],M)}}return{success:n.every(o=>!!o),editors:O(n)}}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 q.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(A.MOST_RECENTLY_ACTIVE))for(const r of i.getEditors(E.MOST_RECENTLY_ACTIVE))r.isModified()&&((typeof e?.includeUntitled=="boolean"||!e?.includeUntitled?.includeScratchpad)&&r.hasCapability(g.Scratchpad)||!e?.includeUntitled&&r.hasCapability(g.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=>_(e)),this.activeOutOfWorkspaceWatchers.clear()}};Ee=Q=U([u(1,F),u(2,Oe),u(3,De),u(4,ge),u(5,Ye),u(6,ie),u(7,Re),u(8,qe),u(9,Ie),u(10,ze)],Ee);var I;class ut extends Error{constructor(e,t){super(e),this.name="FileEditorInputLeakError",this.stack=t}}var v;let ve=(v=class extends P{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 b,this.fileEditorFactory=ee.as(te.EditorFactory).getFileEditorFactory(),this.mapLeakToCounter=new Map,this.registerDefaultEditor()}registerDefaultEditor(){this._register(this.editorResolverService.registerEditor("*",{id:j.id,label:j.displayName,detail:j.providerDisplayName,priority:je.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(ye(e))return this.createTextEditor(e.result);if(Ae(e)){const r=this.createTextEditor(e.original),s=this.createTextEditor(e.modified);return this.instantiationService.createInstance(Ce,e.label,e.description,r,s,void 0)}if($e(e)){const r=this.createTextEditor(e.primary),s=this.createTextEditor(e.secondary);return this.instantiationService.createInstance(Z,e.label,e.description,s,r)}const t=e;if(t.forceUntitled||!t.resource||t.resource.scheme===de.untitled){const r={languageId:t.languageId,initialValue:t.contents,encoding:t.encoding};let s;return t.resource?.scheme===de.untitled?s=this.untitledTextEditorService.create({untitledResource:t.resource,...r}):s=this.untitledTextEditorService.create({associatedResource:t.resource,...r}),this.createOrGetCached(s.resource,()=>this.instantiationService.createInstance(ce,s))}const i=e;if(i.resource instanceof l){const r=i.label||Qe(i.resource),s=i.resource,n=this.uriIdentityService.asCanonicalUri(s);return this.createOrGetCached(n,()=>i.forceFile||this.fileService.hasProvider(n)?this.fileEditorFactory.createFileEditor(n,s,i.label,i.description,i.encoding,i.languageId,i.contents,this.instantiationService):this.instantiationService.createInstance(ue,n,i.label,i.description,i.languageId,i.contents),o=>{o instanceof ce||(o instanceof ue?(r&&o.setName(r),i.description&&o.setDescription(i.description),i.languageId&&o.setPreferredLanguageId(i.languageId),typeof i.contents=="string"&&o.setPreferredContents(i.contents)):(o.setPreferredResource(s),i.label&&o.setPreferredName(i.label),i.description&&o.setPreferredDescription(i.description),i.encoding&&o.setPreferredEncoding(i.encoding),i.languageId&&o.setPreferredLanguageId(i.languageId),typeof i.contents=="string"&&o.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 X.once(r.onWillDispose)(()=>{this.editorInputCache.delete(e),s&&this.untrackLeaks(s)}),r}trackLeaks(e){if(I.LEAK_REPORTED||this.editorInputCache.size<I.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
4
|
`)??""}`,i=(this.mapLeakToCounter.get(t)??0)+1;if(this.mapLeakToCounter.set(t,i),this.editorInputCache.size>I.LEAK_REPORTING_THRESHOLD){I.LEAK_REPORTED=!0;const[r,s]=Array.from(this.mapLeakToCounter.entries()).reduce(([o,a],[d,c])=>c>a?[d,c]:[o,a]),n=`Potential text editor input LEAK detected, having ${this.editorInputCache.size} text editor inputs already. Most frequent owner (${s})`;Je(new ut(n,r))}return t}untrackLeaks(e){const t=(this.mapLeakToCounter.get(e)??1)-1;this.mapLeakToCounter.set(e,t),t===0&&this.mapLeakToCounter.delete(e)}},I=v,v.LEAK_TRACKING_THRESHOLD=256,v.LEAK_REPORTING_THRESHOLD=2*v.LEAK_TRACKING_THRESHOLD,v.LEAK_REPORTED=!1,v);ve=I=U([u(0,Xe),u(1,Oe),u(2,ie),u(3,De),u(4,Re)],ve);var m;let L=(m=class extends P{constructor(e,t,i,r,s,n,o,a){super(),this.filesConfigurationService=e,this.hostService=t,this.editorService=i,this.editorGroupService=r,this.workingCopyService=s,this.logService=n,this.markerService=o,this.uriIdentityService=a,this.scheduledAutoSavesAfterDelay=new Map,this.lastActiveEditor=void 0,this.lastActiveGroupId=void 0,this.lastActiveEditorControlDisposable=this._register(new J),this.waitingOnConditionAutoSaveWorkingCopies=new b(d=>this.uriIdentityService.extUri.getComparisonKey(d)),this.waitingOnConditionAutoSaveEditors=new b(d=>this.uriIdentityService.extUri.getComparisonKey(d));for(const d of this.workingCopyService.dirtyWorkingCopies)this.onDidRegister(d);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,C.ERRORS))),this._register(this.filesConfigurationService.onDidChangeAutoSaveDisabled(e=>this.onConditionChanged([e],C.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!==f.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!==f.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(g.Untitled))return;const i=this.filesConfigurationService.getAutoSaveMode(t.editor,e);i.mode!==f.OFF?(e===p.WINDOW_CHANGE&&(i.mode===f.ON_FOCUS_CHANGE||i.mode===f.ON_WINDOW_CHANGE)||e===p.FOCUS_CHANGE&&i.mode===f.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===C.ERRORS||i.reason===C.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 f.ON_FOCUS_CHANGE:e=p.FOCUS_CHANGE;break;case f.ON_WINDOW_CHANGE:e=p.WINDOW_CHANGE;break;case f.AFTER_SHORT_DELAY:case f.AFTER_LONG_DELAY:e=p.AUTO;break}e&&this.saveAllDirtyAutoSaveables(e)}saveAllDirtyAutoSaveables(e){for(const t of this.workingCopyService.dirtyWorkingCopies){if(t.capabilities&he.Untitled)continue;const i=this.filesConfigurationService.getAutoSaveMode(t.resource,e);i.mode!==f.OFF?t.save({reason:e}):(i.reason===C.ERRORS||i.reason===C.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&he.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!==f.OFF?(this.logService.trace("[editor auto save] running auto save",e.resource.toString(),e.typeId),e.save({reason:r})):(s.reason===C.ERRORS||s.reason===C.DISABLED)&&this.waitingOnConditionAutoSaveWorkingCopies.set(e.resource,{workingCopy:e,reason:r,condition:s.reason})}},t);this.scheduledAutoSavesAfterDelay.set(e,Ze(()=>{this.logService.trace("[editor auto save] clearing pending auto save",e.resource.toString(),e.typeId),clearTimeout(i)}))}discardAutoSave(e){_(this.scheduledAutoSavesAfterDelay.get(e)),this.scheduledAutoSavesAfterDelay.delete(e),this.waitingOnConditionAutoSaveWorkingCopies.delete(e.resource),this.waitingOnConditionAutoSaveEditors.delete(e.resource)}},m.ID="workbench.contrib.editorAutoSave",m);L=U([u(0,et),u(1,Ie),u(2,tt),u(3,F),u(4,it),u(5,rt),u(6,st),u(7,ie)],L);ot(L.ID,L,nt.BlockRestore);ee.as(te.EditorFactory).registerFileEditorFactory({typeId:at,createFileEditor:(h,e,t,i,r,s,n,o)=>o.createInstance(le,h,e,t,i,r,s,n),isFileEditor:h=>h instanceof le});export{Ee as E,ve as T,fe as f};
|