mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 10:38:59 +01:00
@@ -275,6 +275,7 @@ export class MainThreadWebviewPanels extends Disposable implements extHostProtoc
|
||||
state,
|
||||
panelOptions: webviewInput.webview.options,
|
||||
webviewOptions: webviewInput.webview.contentOptions,
|
||||
active: webviewInput === this._editorService.activeEditor,
|
||||
}, editorGroupToColumn(this._editorGroupService, webviewInput.group || 0));
|
||||
} catch (error) {
|
||||
onUnexpectedError(error);
|
||||
|
||||
@@ -866,6 +866,7 @@ export interface ExtHostWebviewPanelsShape {
|
||||
state: any;
|
||||
webviewOptions: IWebviewContentOptions;
|
||||
panelOptions: IWebviewPanelOptions;
|
||||
active: boolean;
|
||||
},
|
||||
position: EditorGroupColumn,
|
||||
): Promise<void>;
|
||||
|
||||
@@ -267,7 +267,7 @@ export class ExtHostCustomEditors implements extHostProtocol.ExtHostCustomEditor
|
||||
const viewColumn = typeConverters.ViewColumn.to(position);
|
||||
|
||||
const webview = this._extHostWebview.createNewWebview(handle, initData.webviewOptions, entry.extension);
|
||||
const panel = this._extHostWebviewPanels.createNewWebviewPanel(handle, viewType, initData.title, viewColumn, initData.panelOptions, webview);
|
||||
const panel = this._extHostWebviewPanels.createNewWebviewPanel(handle, viewType, initData.title, viewColumn, initData.panelOptions, webview, true);
|
||||
|
||||
const revivedResource = URI.revive(resource);
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,8 @@ suite('ExtHostWebview', () => {
|
||||
title: 'title',
|
||||
state: {},
|
||||
panelOptions: {},
|
||||
webviewOptions: {}
|
||||
webviewOptions: {},
|
||||
active: true,
|
||||
}, 0 as EditorGroupColumn);
|
||||
assert.strictEqual(lastInvokedDeserializer, serializerA);
|
||||
|
||||
@@ -71,7 +72,8 @@ suite('ExtHostWebview', () => {
|
||||
title: 'title',
|
||||
state: {},
|
||||
panelOptions: {},
|
||||
webviewOptions: {}
|
||||
webviewOptions: {},
|
||||
active: true,
|
||||
}, 0 as EditorGroupColumn);
|
||||
assert.strictEqual(lastInvokedDeserializer, serializerB);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user