mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Make sure we set html on markdown preview when it is not visible
Fixes #138630 If the webview does not exist, we need to update the html on it instead of posting a message to it. This makes sure the correct content is shown when the webview is created again This also removes a previous workaround for this issue that I no longer believe is required
This commit is contained in:
parent
eaf352e6d1
commit
bd36b7d6a3
|
@ -179,31 +179,6 @@ class MarkdownPreview extends Disposable implements WebviewResourceProvider {
|
|||
}
|
||||
}));
|
||||
|
||||
this._register(this._webviewPanel.onDidChangeViewState(async () => {
|
||||
if (this._disposed) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._webviewPanel.active) {
|
||||
let document: vscode.TextDocument;
|
||||
try {
|
||||
document = await vscode.workspace.openTextDocument(this._resource);
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
if (this._disposed) {
|
||||
return;
|
||||
}
|
||||
|
||||
const content = await this._contentProvider.provideTextDocumentContent(document, this, this._previewConfigurations, this.line, this.state);
|
||||
if (!this._webviewPanel.active && !this._disposed) {
|
||||
// Update the html so we can show it properly when restoring it
|
||||
this._webviewPanel.webview.html = content.html;
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
this._register(this._webviewPanel.webview.onDidReceiveMessage((e: CacheImageSizesMessage | RevealLineMessage | DidClickMessage | ClickLinkMessage | ShowPreviewSecuritySelectorMessage | PreviewStyleLoadErrorMessage) => {
|
||||
if (e.source !== this._resource.toString()) {
|
||||
return;
|
||||
|
@ -343,7 +318,7 @@ class MarkdownPreview extends Disposable implements WebviewResourceProvider {
|
|||
return;
|
||||
}
|
||||
|
||||
const shouldReloadPage = forceUpdate || !this.currentVersion || this.currentVersion.resource.toString() !== pendingVersion.resource.toString();
|
||||
const shouldReloadPage = forceUpdate || !this.currentVersion || this.currentVersion.resource.toString() !== pendingVersion.resource.toString() || !this._webviewPanel.visible;
|
||||
this.currentVersion = pendingVersion;
|
||||
|
||||
const content = await (shouldReloadPage
|
||||
|
|
Loading…
Reference in a new issue