Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/src/vs
diff options
context:
space:
mode:
authorMatt Bierner <matb@microsoft.com>2022-07-27 22:02:01 +0300
committerGitHub <noreply@github.com>2022-07-27 22:02:01 +0300
commit4aa9759988b08626cf8a34ceaa9519c9af3e8676 (patch)
tree95fcb37ddc63d313bc3704f42e013eb59762f860 /src/vs
parent00bb9bdefcfef4cb0ec92399e52dedee4b223ff7 (diff)
Fix webview providerId not being restored on reload (#156492)
Fixes #156491
Diffstat (limited to 'src/vs')
-rw-r--r--src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts16
-rw-r--r--src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts4
-rw-r--r--src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInput.ts22
-rw-r--r--src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.ts4
-rw-r--r--src/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService.ts12
5 files changed, 39 insertions, 19 deletions
diff --git a/src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts b/src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts
index 116c74df092..a514a41b857 100644
--- a/src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts
+++ b/src/vs/workbench/contrib/customEditor/browser/customEditorInput.ts
@@ -24,6 +24,12 @@ import { IWebviewService, IOverlayWebview } from 'vs/workbench/contrib/webview/b
import { IWebviewWorkbenchService, LazilyResolvedWebviewEditorInput } from 'vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService';
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
+export interface CustomEditorInputInitInfo {
+ readonly resource: URI;
+ readonly viewType: string;
+ readonly id: string;
+}
+
export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
static create(
@@ -45,7 +51,7 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
contentOptions: {},
extension: undefined,
});
- const input = instantiationService.createInstance(CustomEditorInput, resource, viewType, id, webview, { untitledDocumentData: untitledDocumentData, oldResource: options?.oldResource });
+ const input = instantiationService.createInstance(CustomEditorInput, { resource, viewType, id }, webview, { untitledDocumentData: untitledDocumentData, oldResource: options?.oldResource });
if (typeof group !== 'undefined') {
input.updateGroup(group);
}
@@ -68,9 +74,7 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
private _modelRef?: IReference<ICustomEditorModel>;
constructor(
- resource: URI,
- viewType: string,
- id: string,
+ init: CustomEditorInputInitInfo,
webview: IOverlayWebview,
options: { startsDirty?: boolean; backupId?: string; untitledDocumentData?: VSBuffer; readonly oldResource?: URI },
@IWebviewWorkbenchService webviewWorkbenchService: IWebviewWorkbenchService,
@@ -81,8 +85,8 @@ export class CustomEditorInput extends LazilyResolvedWebviewEditorInput {
@IUndoRedoService private readonly undoRedoService: IUndoRedoService,
@IFileService private readonly fileService: IFileService
) {
- super(id, viewType, '', webview, webviewWorkbenchService);
- this._editorResource = resource;
+ super({ id: init.id, providedId: init.viewType, viewType: init.viewType, name: '' }, webview, webviewWorkbenchService);
+ this._editorResource = init.resource;
this.oldResource = options.oldResource;
this._defaultDirtyState = options.startsDirty;
this._backupId = options.backupId;
diff --git a/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts b/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts
index 9bc10254662..4277c67ab6a 100644
--- a/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts
+++ b/src/vs/workbench/contrib/customEditor/browser/customEditorInputFactory.ts
@@ -100,7 +100,7 @@ export class CustomEditorInputSerializer extends WebviewEditorInputSerializer {
}
const webview = reviveWebview(this._webviewService, data);
- const customInput = this._instantiationService.createInstance(CustomEditorInput, data.editorResource, data.viewType, data.id, webview, { startsDirty: data.dirty, backupId: data.backupId });
+ const customInput = this._instantiationService.createInstance(CustomEditorInput, { resource: data.editorResource, viewType: data.viewType, id: data.id }, webview, { startsDirty: data.dirty, backupId: data.backupId });
if (typeof data.group === 'number') {
customInput.updateGroup(data.group);
}
@@ -196,7 +196,7 @@ export class ComplexCustomWorkingCopyEditorHandler extends Disposable implements
extension,
});
- const editor = this._instantiationService.createInstance(CustomEditorInput, URI.revive(backupData.editorResource), backupData.viewType, id, webview, { backupId: backupData.backupId });
+ const editor = this._instantiationService.createInstance(CustomEditorInput, { resource: URI.revive(backupData.editorResource), viewType: backupData.viewType, id }, webview, { backupId: backupData.backupId });
editor.updateGroup(0);
return editor;
}
diff --git a/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInput.ts b/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInput.ts
index 63e3f1cc124..5a4ac6b904c 100644
--- a/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInput.ts
+++ b/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInput.ts
@@ -10,6 +10,13 @@ import { EditorInput } from 'vs/workbench/common/editor/editorInput';
import { IOverlayWebview } from 'vs/workbench/contrib/webview/browser/webview';
import { WebviewIconManager, WebviewIcons } from 'vs/workbench/contrib/webviewPanel/browser/webviewIconManager';
+export interface WebviewInputInitInfo {
+ readonly id: string;
+ readonly viewType: string;
+ readonly providedId: string | undefined;
+ readonly name: string;
+}
+
export class WebviewInput extends EditorInput {
public static typeId = 'workbench.editors.webviewInput';
@@ -41,15 +48,22 @@ export class WebviewInput extends EditorInput {
});
}
+ public readonly id: string;
+ public readonly viewType: string;
+ public readonly providedId: string | undefined;
+
constructor(
- public readonly id: string,
- public readonly viewType: string,
- name: string,
+ init: WebviewInputInitInfo,
webview: IOverlayWebview,
private readonly _iconManager: WebviewIconManager,
) {
super();
- this._name = name;
+
+ this.id = init.id;
+ this.viewType = init.viewType;
+ this.providedId = init.providedId;
+
+ this._name = init.name;
this._webview = webview;
}
diff --git a/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.ts b/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.ts
index ec4f4c9ef91..483a6b37bc9 100644
--- a/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.ts
+++ b/src/vs/workbench/contrib/webviewPanel/browser/webviewEditorInputSerializer.ts
@@ -23,6 +23,7 @@ export interface SerializedWebview {
readonly id: string;
readonly origin: string | undefined;
readonly viewType: string;
+ readonly providedId: string | undefined;
readonly title: string;
readonly options: SerializedWebviewOptions;
readonly extensionLocation: UriComponents | undefined;
@@ -36,6 +37,7 @@ export interface DeserializedWebview {
readonly id: string;
readonly origin: string | undefined;
readonly viewType: string;
+ readonly providedId: string | undefined;
readonly title: string;
readonly webviewOptions: WebviewOptions;
readonly contentOptions: WebviewContentOptions;
@@ -78,6 +80,7 @@ export class WebviewEditorInputSerializer implements IEditorSerializer {
return this._webviewWorkbenchService.reviveWebview({
webviewInitInfo: {
id: data.id,
+ providedId: data.providedId,
origin: data.origin,
options: data.webviewOptions,
contentOptions: data.contentOptions,
@@ -107,6 +110,7 @@ export class WebviewEditorInputSerializer implements IEditorSerializer {
id: input.id,
origin: input.webview.origin,
viewType: input.viewType,
+ providedId: input.providedId,
title: input.getName(),
options: { ...input.webview.options, ...input.webview.contentOptions },
extensionLocation: input.extension ? input.extension.location : undefined,
diff --git a/src/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService.ts b/src/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService.ts
index 9c8629d7e5f..00232b050e9 100644
--- a/src/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService.ts
+++ b/src/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService.ts
@@ -20,7 +20,7 @@ import { WebviewInitInfo } from 'vs/workbench/contrib/webview/browser/webviewEle
import { WebviewIconManager, WebviewIcons } from 'vs/workbench/contrib/webviewPanel/browser/webviewIconManager';
import { IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { ACTIVE_GROUP_TYPE, IEditorService, SIDE_GROUP_TYPE } from 'vs/workbench/services/editor/common/editorService';
-import { WebviewInput } from './webviewEditorInput';
+import { WebviewInput, WebviewInputInitInfo } from './webviewEditorInput';
export const IWebviewWorkbenchService = createDecorator<IWebviewWorkbenchService>('webviewEditorService');
@@ -94,13 +94,11 @@ export class LazilyResolvedWebviewEditorInput extends WebviewInput {
constructor(
- id: string,
- viewType: string,
- name: string,
+ init: WebviewInputInitInfo,
webview: IOverlayWebview,
@IWebviewWorkbenchService private readonly _webviewWorkbenchService: IWebviewWorkbenchService,
) {
- super(id, viewType, name, webview, _webviewWorkbenchService.iconManager);
+ super(init, webview, _webviewWorkbenchService.iconManager);
}
override dispose() {
@@ -244,7 +242,7 @@ export class WebviewEditorService extends Disposable implements IWebviewWorkbenc
showOptions: ICreateWebViewShowOptions,
): WebviewInput {
const webview = this._webviewService.createWebviewOverlay(webviewInitInfo);
- const webviewInput = this._instantiationService.createInstance(WebviewInput, webviewInitInfo.id, viewType, title, webview, this.iconManager);
+ const webviewInput = this._instantiationService.createInstance(WebviewInput, { id: webviewInitInfo.id, viewType, name: title, providedId: webviewInitInfo.providedId }, webview, this.iconManager);
this._editorService.openEditor(webviewInput, {
pinned: true,
preserveFocus: showOptions.preserveFocus,
@@ -295,7 +293,7 @@ export class WebviewEditorService extends Disposable implements IWebviewWorkbenc
const webview = this._webviewService.createWebviewOverlay(options.webviewInitInfo);
webview.state = options.state;
- const webviewInput = this._instantiationService.createInstance(LazilyResolvedWebviewEditorInput, options.webviewInitInfo.id, options.viewType, options.title, webview);
+ const webviewInput = this._instantiationService.createInstance(LazilyResolvedWebviewEditorInput, { id: options.webviewInitInfo.id, viewType: options.viewType, providedId: options.webviewInitInfo.providedId, name: options.title }, webview);
webviewInput.iconPath = options.iconPath;
if (typeof options.group === 'number') {