Skip to content

Commit

Permalink
Fix webview deserialization
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Mar 12, 2019
1 parent 1e6206f commit 5570695
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ interface SerializedWebview {
readonly extensionLocation: string | UriComponents | undefined;
readonly state: any;
readonly iconPath: SerializedIconPath | undefined;
readonly group?: number;
}

export class WebviewEditorInputFactory implements IEditorInputFactory {
Expand Down Expand Up @@ -53,6 +54,7 @@ export class WebviewEditorInputFactory implements IEditorInputFactory {
extensionLocation: input.extensionLocation,
state: input.state,
iconPath: input.iconPath ? { light: input.iconPath.light, dark: input.iconPath.dark, } : undefined,
group: input.group
};

try {
Expand All @@ -69,7 +71,7 @@ export class WebviewEditorInputFactory implements IEditorInputFactory {
const data: SerializedWebview = JSON.parse(serializedEditorInput);
const extensionLocation = reviveUri(data.extensionLocation);
const iconPath = reviveIconPath(data.iconPath);
return this._webviewService.reviveWebview(data.viewType, data.id, data.title, iconPath, data.state, data.options, extensionLocation);
return this._webviewService.reviveWebview(data.viewType, data.id, data.title, iconPath, data.state, data.options, extensionLocation, data.group);
}
}
function reviveIconPath(data: SerializedIconPath | undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export interface IWebviewEditorService {
state: any,
options: WebviewInputOptions,
extensionLocation: URI | undefined,
group: number | undefined
): WebviewEditorInput;

revealWebview(
Expand Down Expand Up @@ -134,7 +135,8 @@ export class WebviewEditorService implements IWebviewEditorService {
iconPath: { light: URI, dark: URI } | undefined,
state: any,
options: WebviewInputOptions,
extensionLocation: URI
extensionLocation: URI,
group: number | undefined,
): WebviewEditorInput {
const webviewInput = this._instantiationService.createInstance(RevivedWebviewEditorInput, viewType, id, title, options, state, {}, extensionLocation, async (webview: WebviewEditorInput): Promise<void> => {
const didRevive = await this.tryRevive(webview);
Expand All @@ -149,6 +151,9 @@ export class WebviewEditorService implements IWebviewEditorService {
return promise;
});
webviewInput.iconPath = iconPath;
if (typeof group === 'number') {
webviewInput.updateGroup(group);
}
return webviewInput;
}

Expand Down

0 comments on commit 5570695

Please sign in to comment.