From fd9528257e44d72e3af9f23046cd677198dbaeca Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Wed, 25 Sep 2019 14:48:01 -0700 Subject: [PATCH] Make sure we use consistent unique ids for custom editors --- src/vs/workbench/api/browser/mainThreadWebview.ts | 2 +- .../contrib/customEditor/browser/customEditorInputFactory.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/api/browser/mainThreadWebview.ts b/src/vs/workbench/api/browser/mainThreadWebview.ts index 2b6d4c71199..8b4e16a1fb8 100644 --- a/src/vs/workbench/api/browser/mainThreadWebview.ts +++ b/src/vs/workbench/api/browser/mainThreadWebview.ts @@ -250,7 +250,7 @@ export class MainThreadWebviews extends Disposable implements MainThreadWebviews return webviewEditorInput.getTypeId() !== WebviewInput.typeId && webviewEditorInput.viewType === viewType; }, resolveWebview: async (webview) => { - const handle = generateUuid(); + const handle = webview.id; this._webviewEditorInputs.add(handle, webview); this.hookupWebviewEventDelegate(handle, webview); diff --git a/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts b/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts index bcb570dbacb..6f038e2db50 100644 --- a/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts +++ b/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts @@ -40,12 +40,13 @@ export class CustomEditoInputFactory extends WebviewEditorInputFactory { serializedEditorInput: string ): CustomFileEditorInput { const data = this.fromJson(serializedEditorInput); - const webviewInput = this.webviewService.reviveWebview(generateUuid(), data.viewType, data.title, data.iconPath, data.state, data.options, data.extensionLocation ? { + const id = data.id || generateUuid(); + const webviewInput = this.webviewService.reviveWebview(id, data.viewType, data.title, data.iconPath, data.state, data.options, data.extensionLocation ? { location: data.extensionLocation, id: data.extensionId } : undefined, data.group); - const customInput = this._instantiationService.createInstance(CustomFileEditorInput, URI.from((data as any).editorResource), data.viewType, generateUuid(), new UnownedDisposable(webviewInput.webview)); + const customInput = this._instantiationService.createInstance(CustomFileEditorInput, URI.from((data as any).editorResource), data.viewType, id, new UnownedDisposable(webviewInput.webview)); if (typeof data.group === 'number') { customInput.updateGroup(data.group); } -- GitLab