Skip to content
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

reveal does not reveal webview #48707

Closed
octref opened this issue Apr 25, 2018 · 0 comments
Closed

reveal does not reveal webview #48707

octref opened this issue Apr 25, 2018 · 0 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Milestone

Comments

@octref
Copy link
Contributor

octref commented Apr 25, 2018

Testing #48453

import * as vscode from 'vscode';

const cats = {
    'Coding Cat': 'https://media.giphy.com/media/JIX9t2j0ZTN9S/giphy.gif',
    'Compiling Cat':'https://media.giphy.com/media/mlvseq9yvZhba/giphy.gif'
};

export function activate(context: vscode.ExtensionContext) {
    let panel: vscode.WebviewPanel;
    context.subscriptions.push(vscode.commands.registerCommand('catCoding.start', () => {
        panel = vscode.window.createWebviewPanel('catCoding', "Cat Coding", vscode.ViewColumn.One, {});

        let iteration = 0;
        const updateWebview = () => {
            const cat = iteration++ % 2 ? 'Compiling Cat' : 'Coding Cat'
            panel.title = cat;
            panel.webview.html = getWebviewContent(cat);
        }

        updateWebview();
        const interval = setInterval(updateWebview, 1000);

        panel.onDidDispose(() => {
            // When the panel is closed, cancel any future updates to the webview content
            clearInterval(interval);
        }, null, context.subscriptions)
    }));

    context.subscriptions.push(vscode.commands.registerCommand('catCoding.test', () => {
        panel.reveal();
    }));
}

function getWebviewContent(cat: keyof typeof cats) {
    return `<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Cat Coding</title>
</head>
<body>
    <img src="${cats[cat]}" width="300" />
</body>
</html>`;
}

webview

@mjbvz mjbvz added the bug Issue identified by VS Code Team member as probable bug label Apr 25, 2018
@mjbvz mjbvz added this to the April 2018 milestone Apr 25, 2018
@mjbvz mjbvz closed this as completed in 6091135 Apr 25, 2018
@dbaeumer dbaeumer added the verified Verification succeeded label Apr 27, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Jun 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

3 participants