diff --git a/extensions/image-preview/src/preview.ts b/extensions/image-preview/src/preview.ts index 90b5fbd4c9607f0892b48078723af4d6968fbc2b..815df001baaf0affd7e3df305be360693ffa347e 100644 --- a/extensions/image-preview/src/preview.ts +++ b/extensions/image-preview/src/preview.ts @@ -28,7 +28,7 @@ export class PreviewManager implements vscode.CustomEditorProvider { ) { } public async openCustomDocument(uri: vscode.Uri) { - return new vscode.CustomDocument(PreviewManager.viewType, uri); + return new vscode.CustomDocument(uri); } public async resolveCustomEditor( diff --git a/extensions/markdown-language-features/src/features/previewManager.ts b/extensions/markdown-language-features/src/features/previewManager.ts index 78b2aa65107aaf1ab5d778fa6879234ece6d8fa2..98c3c9a776acdab8bae1d81594c6f7087b780845 100644 --- a/extensions/markdown-language-features/src/features/previewManager.ts +++ b/extensions/markdown-language-features/src/features/previewManager.ts @@ -151,7 +151,7 @@ export class MarkdownPreviewManager extends Disposable implements vscode.Webview } public async openCustomDocument(uri: vscode.Uri) { - return new vscode.CustomDocument(this.customEditorViewType, uri); + return new vscode.CustomDocument(uri); } public async resolveCustomTextEditor( diff --git a/src/vs/vscode.d.ts b/src/vs/vscode.d.ts index 307737aa174f2472bf2b0cc493f211751dc05acc..ae1d7cb310b0d30cc50d5163ef7816684277ddf6 100644 --- a/src/vs/vscode.d.ts +++ b/src/vs/vscode.d.ts @@ -7006,15 +7006,9 @@ declare module 'vscode' { */ class CustomDocument { /** - * @param viewType The associated uri for this document. * @param uri The associated viewType for this document. */ - constructor(viewType: string, uri: Uri); - - /** - * The associated viewType for this document. - */ - readonly viewType: string; + constructor(uri: Uri); /** * The associated uri for this document. diff --git a/src/vs/workbench/api/common/extHostTypes.ts b/src/vs/workbench/api/common/extHostTypes.ts index fbd06153344f77cebee0f2e8ddd9184194606571..76f40cb3852a9801905d55c05cfc0e918c7772b3 100644 --- a/src/vs/workbench/api/common/extHostTypes.ts +++ b/src/vs/workbench/api/common/extHostTypes.ts @@ -2747,7 +2747,6 @@ export class CustomDocument implements vscode.CustomDocument readonly #edits = new Cache('edits'); - readonly #viewType: string; readonly #uri: vscode.Uri; #editState: EditState = { @@ -2758,15 +2757,12 @@ export class CustomDocument implements vscode.CustomDocument #isDisposed = false; #version = 1; - constructor(viewType: string, uri: vscode.Uri) { - this.#viewType = viewType; + constructor(uri: vscode.Uri) { this.#uri = uri; } //#region Public API - public get viewType(): string { return this.#viewType; } - public get uri(): vscode.Uri { return this.#uri; } public get fileName(): string { return this.uri.fsPath; } diff --git a/src/vs/workbench/api/common/extHostWebview.ts b/src/vs/workbench/api/common/extHostWebview.ts index d5b0d496c021ff25b21267626c56109a18633267..aced97ccc25ebbbaa3093cf6a06e7c35f58911c7 100644 --- a/src/vs/workbench/api/common/extHostWebview.ts +++ b/src/vs/workbench/api/common/extHostWebview.ts @@ -269,16 +269,16 @@ class WebviewDocumentStore { return this._documents.get(this.key(viewType, resource)); } - public add(document: extHostTypes.CustomDocument) { - const key = this.key(document.viewType, document.uri); + public add(viewType: string, document: extHostTypes.CustomDocument) { + const key = this.key(viewType, document.uri); if (this._documents.has(key)) { - throw new Error(`Document already exists for viewType:${document.viewType} resource:${document.uri}`); + throw new Error(`Document already exists for viewType:${viewType} resource:${document.uri}`); } this._documents.set(key, document); } - public delete(document: extHostTypes.CustomDocument) { - const key = this.key(document.viewType, document.uri); + public delete(viewType: string, document: extHostTypes.CustomDocument) { + const key = this.key(viewType, document.uri); this._documents.delete(key); } @@ -414,7 +414,7 @@ export class ExtHostWebviews implements extHostProtocol.ExtHostWebviewsShape { disposables.add(provider.editingDelegate.onDidEdit(e => { const document = e.document; const editId = (document as extHostTypes.CustomDocument)._addEdit(e.edit); - this._proxy.$onDidEdit(document.uri, document.viewType, editId, e.label); + this._proxy.$onDidEdit(document.uri, viewType, editId, e.label); })); } } @@ -516,7 +516,7 @@ export class ExtHostWebviews implements extHostProtocol.ExtHostWebviewsShape { const revivedResource = URI.revive(resource); const document = await entry.provider.openCustomDocument(revivedResource, cancellation); - this._documents.add(document as extHostTypes.CustomDocument); + this._documents.add(viewType, document as extHostTypes.CustomDocument); return { editable: !!entry.provider.editingDelegate, }; @@ -534,7 +534,7 @@ export class ExtHostWebviews implements extHostProtocol.ExtHostWebviewsShape { const revivedResource = URI.revive(resource); const document = this.getCustomDocument(viewType, revivedResource); - this._documents.delete(document); + this._documents.delete(viewType, document); document._dispose(); }