diff --git a/src/vs/workbench/contrib/webview/browser/webviewCommands.ts b/src/vs/workbench/contrib/webview/browser/webviewCommands.ts index d1566c6c49a..9f949d73926 100644 --- a/src/vs/workbench/contrib/webview/browser/webviewCommands.ts +++ b/src/vs/workbench/contrib/webview/browser/webviewCommands.ts @@ -12,7 +12,7 @@ import { InputFocusedContextKey } from 'vs/platform/contextkey/common/contextkey import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { KeybindingWeight } from 'vs/platform/keybinding/common/keybindingsRegistry'; import { KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_FOCUSED, KEYBINDING_CONTEXT_WEBVIEW_FIND_WIDGET_VISIBLE, Webview } from 'vs/workbench/contrib/webview/browser/webview'; -import { WebviewEditor } from 'vs/workbench/contrib/webview/browser/webviewEditor'; +import { WebviewInput } from 'vs/workbench/contrib/webview/browser/webviewEditorInput'; import { IEditorService } from 'vs/workbench/services/editor/common/editorService'; export class ShowWebViewEditorFindWidgetAction extends Action2 { @@ -134,9 +134,9 @@ export class ReloadWebviewAction extends Action { } public async run(): Promise { - for (const editorPane of this._editorService.visibleEditorPanes) { - if ((editorPane as WebviewEditor).isWebviewEditor) { - (editorPane as WebviewEditor).webview?.reload(); + for (const editor of this._editorService.visibleEditors) { + if (editor instanceof WebviewInput) { + editor.webview.reload(); } } } @@ -144,6 +144,6 @@ export class ReloadWebviewAction extends Action { export function getActiveWebviewEditor(accessor: ServicesAccessor): Webview | undefined { const editorService = accessor.get(IEditorService); - const activeEditorPane = editorService.activeEditorPane as WebviewEditor | undefined; - return activeEditorPane?.isWebviewEditor ? activeEditorPane.webview : undefined; + const activeEditor = editorService.activeEditor; + return activeEditor instanceof WebviewInput ? activeEditor.webview : undefined; } diff --git a/src/vs/workbench/contrib/webview/browser/webviewEditor.ts b/src/vs/workbench/contrib/webview/browser/webviewEditor.ts index b442aad86ae..8edbb9f2934 100644 --- a/src/vs/workbench/contrib/webview/browser/webviewEditor.ts +++ b/src/vs/workbench/contrib/webview/browser/webviewEditor.ts @@ -45,8 +45,8 @@ export class WebviewEditor extends BaseEditor { super(WebviewEditor.ID, telemetryService, themeService, storageService); } - public get isWebviewEditor() { - return true; + private get webview(): WebviewOverlay | undefined { + return this.input instanceof WebviewInput ? this.input.webview : undefined; } protected createEditor(parent: HTMLElement): void { @@ -84,10 +84,6 @@ export class WebviewEditor extends BaseEditor { this.webview?.focus(); } - public get webview(): WebviewOverlay | undefined { - return this.input instanceof WebviewInput ? this.input.webview : undefined; - } - protected setEditorVisible(visible: boolean, group: IEditorGroup | undefined): void { if (this.input instanceof WebviewInput && this.webview) { if (visible) { @@ -120,6 +116,7 @@ export class WebviewEditor extends BaseEditor { await super.setInput(input, options, token); await input.resolve(); + if (token.isCancellationRequested) { return; }