diff --git a/extensions/markdown-language-features/src/features/previewManager.ts b/extensions/markdown-language-features/src/features/previewManager.ts index d18850b0f22..bffab3ac74b 100644 --- a/extensions/markdown-language-features/src/features/previewManager.ts +++ b/extensions/markdown-language-features/src/features/previewManager.ts @@ -147,13 +147,13 @@ export class MarkdownPreviewManager implements vscode.WebviewPanelSerializer { } }); - preview.onDidChangeViewState(({ active }) => { + preview.onDidChangeViewState(({ webviewPanel }) => { disposeAll(this.previews.filter(otherPreview => preview !== otherPreview && preview!.matches(otherPreview))); vscode.commands.executeCommand('setContext', MarkdownPreviewManager.markdownPreviewActiveContextKey, - active); + webviewPanel.visible); - this.activePreview = active ? preview : undefined; + this.activePreview = webviewPanel.visible ? preview : undefined; }); return preview; diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index 878b329df2d..2b0030d68c5 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -691,6 +691,11 @@ declare module 'vscode' { */ readonly viewColumn?: ViewColumn; + /** + * Is the panel current visible? + */ + readonly visible: boolean; + /** * Fired when the panel's view state changes. */ @@ -724,9 +729,14 @@ declare module 'vscode' { dispose(): any; } + /** + * Event fired when a webview panel's view state changes. + */ export interface WebviewPanelOnDidChangeViewStateEvent { - readonly viewColumn: ViewColumn; - readonly active: boolean; + /** + * Webview panel who's view state changed. + */ + readonly webviewPanel: WebviewPanel; } /** diff --git a/src/vs/workbench/api/node/extHostWebview.ts b/src/vs/workbench/api/node/extHostWebview.ts index f8bbc3f7961..0f9be6d7c77 100644 --- a/src/vs/workbench/api/node/extHostWebview.ts +++ b/src/vs/workbench/api/node/extHostWebview.ts @@ -97,7 +97,7 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel { private readonly _proxy: MainThreadWebviewsShape; private _isDisposed: boolean = false; private _viewColumn: vscode.ViewColumn; - private _active: boolean; + private _visible: boolean; public readonly onDisposeEmitter = new Emitter(); public readonly onDidDispose: Event = this.onDisposeEmitter.event; @@ -155,9 +155,9 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel { return this._viewColumn; } - get active(): boolean { + get visible(): boolean { this.assertNotDisposed(); - return this._active; + return this._visible; } set viewColumn(value: vscode.ViewColumn) { @@ -167,7 +167,7 @@ export class ExtHostWebviewPanel implements vscode.WebviewPanel { set active(value: boolean) { this.assertNotDisposed(); - this._active = value; + this._visible = value; } public postMessage(message: any): Thenable { @@ -247,7 +247,7 @@ export class ExtHostWebviews implements ExtHostWebviewsShape { if (panel.active !== active || panel.viewColumn !== viewColumn) { panel.active = active; panel.viewColumn = viewColumn; - panel.onDidChangeViewStateEmitter.fire({ active, viewColumn }); + panel.onDidChangeViewStateEmitter.fire({ webviewPanel: panel }); } } }