Skip to content

Refresh markdown preview when tab switch #166932

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 1 commit into
base: main
Choose a base branch
from

Conversation

pingren
Copy link
Contributor

@pingren pingren commented Nov 22, 2022

Fixes #165188

CleanShot 2022-11-22 at 13 47 48

@mjbvz mjbvz added this to the December 2022 milestone Nov 29, 2022
// this will avoid the stale content when the preview is reactivated
// https://github.com/microsoft/vscode/issues/165188
if (!e.webviewPanel.active) {
this.refresh();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not a fan of this approach as it results in extra rendering of the markdown

What about storing the current markdown inside the webview using setState?

Copy link
Contributor Author

@pingren pingren Dec 6, 2022

Choose a reason for hiding this comment

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

storing the current markdown inside the webview using setState

I tried but didn't figure out how to do it. The nearest thing I camp up is updating current webiview HTML(which does not avoid extra rendering of the markdown I guess):

const document = await vscode.workspace.openTextDocument(this._resource);
const content = await this._contentProvider.renderDocument(document, this, this._previewConfigurations, undefined, undefined, undefined, this._disposeCts.token);
this._webviewPanel.webview.html = content.html;

Could you please elaborate?

@mjbvz mjbvz modified the milestones: January 2023, On Deck Jan 24, 2023
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.

Markdown preview text is missing after tabs are switched
2 participants