Correctly set webview active state on restore

Fixes #145648
This commit is contained in:
Matt Bierner
2022-04-05 16:03:13 -07:00
parent a4ff080324
commit 32acfdde2a
5 changed files with 26 additions and 17 deletions

View File

@@ -32,7 +32,7 @@ class ExtHostWebviewPanel extends Disposable implements vscode.WebviewPanel {
#iconPath?: IconPath;
#viewColumn: vscode.ViewColumn | undefined = undefined;
#visible: boolean = true;
#active: boolean = true;
#active: boolean;
#isDisposed: boolean = false;
readonly #onDidDispose = this._register(new Emitter<void>());
@@ -44,20 +44,24 @@ class ExtHostWebviewPanel extends Disposable implements vscode.WebviewPanel {
constructor(
handle: extHostProtocol.WebviewHandle,
proxy: extHostProtocol.MainThreadWebviewPanelsShape,
viewType: string,
title: string,
viewColumn: vscode.ViewColumn | undefined,
panelOptions: vscode.WebviewPanelOptions,
webview: ExtHostWebview
webview: ExtHostWebview,
params: {
viewType: string;
title: string;
viewColumn: vscode.ViewColumn | undefined;
panelOptions: vscode.WebviewPanelOptions;
active: boolean;
}
) {
super();
this.#handle = handle;
this.#proxy = proxy;
this.#viewType = viewType;
this.#options = panelOptions;
this.#viewColumn = viewColumn;
this.#title = title;
this.#webview = webview;
this.#viewType = params.viewType;
this.#options = params.panelOptions;
this.#viewColumn = params.viewColumn;
this.#title = params.title;
this.#active = params.active;
}
public override dispose() {
@@ -209,7 +213,7 @@ export class ExtHostWebviewPanels implements extHostProtocol.ExtHostWebviewPanel
}, webviewShowOptions);
const webview = this.webviews.createNewWebview(handle, options, extension);
const panel = this.createNewWebviewPanel(handle, viewType, title, viewColumn, options, webview);
const panel = this.createNewWebviewPanel(handle, viewType, title, viewColumn, options, webview, true);
return panel;
}
@@ -283,6 +287,7 @@ export class ExtHostWebviewPanels implements extHostProtocol.ExtHostWebviewPanel
state: any;
webviewOptions: extHostProtocol.IWebviewContentOptions;
panelOptions: extHostProtocol.IWebviewPanelOptions;
active: boolean;
},
position: EditorGroupColumn
): Promise<void> {
@@ -293,12 +298,12 @@ export class ExtHostWebviewPanels implements extHostProtocol.ExtHostWebviewPanel
const { serializer, extension } = entry;
const webview = this.webviews.createNewWebview(webviewHandle, initData.webviewOptions, extension);
const revivedPanel = this.createNewWebviewPanel(webviewHandle, viewType, initData.title, position, initData.panelOptions, webview);
const revivedPanel = this.createNewWebviewPanel(webviewHandle, viewType, initData.title, position, initData.panelOptions, webview, initData.active);
await serializer.deserializeWebviewPanel(revivedPanel, initData.state);
}
public createNewWebviewPanel(webviewHandle: string, viewType: string, title: string, position: vscode.ViewColumn, options: extHostProtocol.IWebviewPanelOptions, webview: ExtHostWebview) {
const panel = new ExtHostWebviewPanel(webviewHandle, this._proxy, viewType, title, position, options, webview);
public createNewWebviewPanel(webviewHandle: string, viewType: string, title: string, position: vscode.ViewColumn, options: extHostProtocol.IWebviewPanelOptions, webview: ExtHostWebview, active: boolean) {
const panel = new ExtHostWebviewPanel(webviewHandle, this._proxy, webview, { viewType, title, viewColumn: position, panelOptions: options, active });
this._webviewPanels.set(webviewHandle, panel);
return panel;
}