Skip to content

Close webview when extension host restart #225979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BABA983
Copy link
Contributor

@BABA983 BABA983 commented Aug 19, 2024

Close #70656

Not all webviews require an extension to live in the background.

Instead of all the panels being closed when disposed, introduce a new option in WebviewPanelOptions that can close webview editor when the extension host restart.

panel = vscode.window.createWebviewPanel(
    'catCoding',
    'Cat Coding with auto close',
    vscode.ViewColumn.One,
    {
	    autoCloseWhenDispose: true
    } 
);

demo

@BABA983 BABA983 requested review from jrieken and mjbvz as code owners August 19, 2024 15:01
public override dispose(): void {
for (const webview of this._webviewInputs) {
if (typeof webview.group === 'number' && webview.webview.options.autoCloseWhenDispose) {
this._editorService.closeEditor({ editor: webview, groupId: webview.group });
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

webview.dispose() will do the same. But maybe we can do it explicitly here to make it more readable.

@BABA983 BABA983 force-pushed the feature/close-webview-when-extension-host-restart branch from 0b0d70b to 9bd97e7 Compare August 19, 2024 15:58
@BABA983
Copy link
Contributor Author

BABA983 commented Sep 3, 2024

@mjbvz Would you might take some time to look at this PR? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

WebView doesn't close on extension (but not window) reload
2 participants