Make sure markdown preview is updated if on disk file is updated

Fixes #111685
This commit is contained in:
Matt Bierner 2020-12-09 14:04:59 -08:00
parent 6ad6905f98
commit 79557ebbd2

View file

@ -156,6 +156,16 @@ class MarkdownPreview extends Disposable implements WebviewResourceProvider {
}
}));
const watcher = this._register(vscode.workspace.createFileSystemWatcher(resource.fsPath));
this._register(watcher.onDidChange(uri => {
if (this.isPreviewOf(uri)) {
// Only use the file system event when VS Code does not already know about the file
if (!vscode.workspace.textDocuments.some(doc => doc.uri.toString() !== uri.toString())) {
this.refresh();
}
}
}));
this._register(this._webviewPanel.webview.onDidReceiveMessage((e: CacheImageSizesMessage | RevealLineMessage | DidClickMessage | ClickLinkMessage | ShowPreviewSecuritySelectorMessage | PreviewStyleLoadErrorMessage) => {
if (e.source !== this._resource.toString()) {
return;