Refresh markdown preview on all file changes (#138301)

* Refresh markdown preview on all file changes

* Don't watch `https`, `http`, and `data` uris
This commit is contained in:
Joyce Er
2021-12-06 12:36:22 -08:00
committed by GitHub
parent 08fe3f2247
commit efd055b8ba

View File

@@ -120,6 +120,7 @@ class MarkdownPreview extends Disposable implements WebviewResourceProvider {
private imageInfo: { readonly id: string, readonly width: number, readonly height: number; }[] = [];
private readonly _fileWatchersBySrc = new Map</* src: */ string, vscode.FileSystemWatcher>();
private readonly _unwatchedImageSchemes = new Set(['https', 'http', 'data']);
private readonly _onScrollEmitter = this._register(new vscode.EventEmitter<LastScrollLocation>());
public readonly onScroll = this._onScrollEmitter.event;
@@ -427,7 +428,7 @@ class MarkdownPreview extends Disposable implements WebviewResourceProvider {
const root = vscode.Uri.joinPath(this._resource, '../');
for (const src of srcs) {
const uri = urlToUri(src, root);
if (uri && uri.scheme === 'file' && !this._fileWatchersBySrc.has(src)) {
if (uri && !this._unwatchedImageSchemes.has(uri.scheme) && !this._fileWatchersBySrc.has(src)) {
const watcher = vscode.workspace.createFileSystemWatcher(uri.fsPath);
watcher.onDidChange(() => {
this.refresh(true);