From 4dab0387c7b35c5fc128395ee8a470fdc08d9504 Mon Sep 17 00:00:00 2001 From: Alex Carney Date: Sun, 29 Sep 2024 20:01:27 +0100 Subject: [PATCH] code: Compare the string representation of URIs For some reason, the object representation of the same URI is not stable leading to synchronised scrolling breaking after scrolling the preview window. Instead, compare the string representation of the uris which should work around the differences that should not matter. --- code/changes/875.fix.md | 1 + code/src/node/preview.ts | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) create mode 100644 code/changes/875.fix.md diff --git a/code/changes/875.fix.md b/code/changes/875.fix.md new file mode 100644 index 000000000..da08079f2 --- /dev/null +++ b/code/changes/875.fix.md @@ -0,0 +1 @@ +Ensure scrolling is still synchronised, even after scrolling the preview window diff --git a/code/src/node/preview.ts b/code/src/node/preview.ts index 2eb2e8296..4f718ebd1 100644 --- a/code/src/node/preview.ts +++ b/code/src/node/preview.ts @@ -78,7 +78,10 @@ export class PreviewManager { } private scrollView(editor: vscode.TextEditor) { - if (editor.document.uri !== this.currentUri) { + // For some reason, the object representation of the same URI is not stable + // leading this check to fail in cases where it should pass. + // Instead, compare the string representation of the uris. + if (editor.document.uri.toString() !== this.currentUri?.toString()) { return }