Use areUrisEqual helper for better uri checks

This commit is contained in:
Matt Bierner
2026-03-27 00:42:39 -07:00
parent 3b3b067a1d
commit bd5b480c23

View File

@@ -129,8 +129,9 @@ class MarkdownPreview extends Disposable implements WebviewResourceProvider {
const watcher = this._register(vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(resource, '*')));
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())) {
// Only use the file system event when VS Code does not already know about the file.
// This is needed to avoid duplicate refreshes
if (!vscode.workspace.textDocuments.some(doc => areUrisEqual(doc.uri, uri))) {
this.refresh();
}
}