mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Make markdown preview revive wait on content populated
This commit is contained in:
parent
d0f7d2e8da
commit
afc08ae477
|
@ -29,14 +29,14 @@ export class MarkdownPreview {
|
|||
private forceUpdate = false;
|
||||
private isScrolling = false;
|
||||
|
||||
public static revive(
|
||||
public static async revive(
|
||||
webview: vscode.Webview,
|
||||
state: any,
|
||||
contentProvider: MarkdownContentProvider,
|
||||
previewConfigurations: MarkdownPreviewConfigurationManager,
|
||||
logger: Logger,
|
||||
topmostLineMonitor: MarkdownFileTopmostLineMonitor
|
||||
): MarkdownPreview {
|
||||
): Promise<MarkdownPreview> {
|
||||
const resource = vscode.Uri.parse(state.resource);
|
||||
const locked = state.locked;
|
||||
const line = state.line;
|
||||
|
@ -53,6 +53,7 @@ export class MarkdownPreview {
|
|||
if (!isNaN(line)) {
|
||||
preview.line = line;
|
||||
}
|
||||
await preview.doUpdate();
|
||||
return preview;
|
||||
}
|
||||
|
||||
|
@ -299,13 +300,11 @@ export class MarkdownPreview {
|
|||
this.forceUpdate = false;
|
||||
|
||||
this.currentVersion = { resource, version: document.version };
|
||||
this.contentProvider.provideTextDocumentContent(document, this.previewConfigurations, this.line)
|
||||
.then(content => {
|
||||
if (this._resource === resource) {
|
||||
this.webview.title = MarkdownPreview.getPreviewTitle(this._resource, this.locked);
|
||||
this.webview.html = content;
|
||||
}
|
||||
});
|
||||
const content = await this.contentProvider.provideTextDocumentContent(document, this.previewConfigurations, this.line);
|
||||
if (this._resource === resource) {
|
||||
this.webview.title = MarkdownPreview.getPreviewTitle(this._resource, this.locked);
|
||||
this.webview.html = content;
|
||||
}
|
||||
}
|
||||
|
||||
private static getLocalResourceRoots(
|
||||
|
|
|
@ -92,7 +92,7 @@ export class MarkdownPreviewManager implements vscode.WebviewSerializer {
|
|||
webview: vscode.Webview,
|
||||
state: any
|
||||
): Promise<boolean> {
|
||||
const preview = MarkdownPreview.revive(
|
||||
const preview = await MarkdownPreview.revive(
|
||||
webview,
|
||||
state,
|
||||
this.contentProvider,
|
||||
|
@ -101,7 +101,6 @@ export class MarkdownPreviewManager implements vscode.WebviewSerializer {
|
|||
this.topmostLineMonitor);
|
||||
|
||||
this.registerPreview(preview);
|
||||
preview.refresh();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue