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

When unfocusing webview with retainContextWhenHidden true, webview still get reconstructed #44681

Closed
octref opened this issue Feb 27, 2018 · 0 comments
Assignees
Labels
webview Webview issues

Comments

@octref
Copy link
Contributor

octref commented Feb 27, 2018

Testing #44466

I would assume the webview's html content is preserved when it's unfocused. So if I switch away from webview 1 and come back to it, I should see the counter continue going up (instead of starting again from 0).
This does not seem to be the case.

kapture 2018-02-27 at 15 40 57

import * as vscode from 'vscode';
import * as path from 'path';
import * as fs from 'fs';

export function activate(context: vscode.ExtensionContext) {
  const htmlPath = path.resolve(context.extensionPath, 'media/index.html');

  vscode.commands.registerCommand('extension.sayHello', () => {
    const wv = vscode.window.createWebview(vscode.Uri.parse(`foo:${new Date().toTimeString()}`), vscode.ViewColumn.One, {
      enableScripts: true,
      retainContextWhenHidden: true
    });
    wv.html = fs.readFileSync(htmlPath, 'utf-8');
    wv.title = 'hello'
  });
}

index.html

<p id='counter' style='font-size: 100px; font-family: "Comic Sans MS";'></p>

<script>
  const counter = document.getElementById('counter')

  let count = 0
  setInterval(() => {    
3
    counter.textContent = '' + count++;
  }, 100);
</script>
@octref octref added the webview Webview issues label Feb 27, 2018
@mjbvz mjbvz closed this as completed in 103d106 Feb 28, 2018
@vscodebot vscodebot bot locked and limited conversation to collaborators Apr 14, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
webview Webview issues
Projects
None yet
Development

No branches or pull requests

2 participants