diff --git a/extensions/markdown-language-features/src/features/preview.ts b/extensions/markdown-language-features/src/features/preview.ts index 0ee7deafff289e981a03663b80ec6d98b9ce70c6..00224e1364d74c96b5a6e8322434fbc90a99ba52 100644 --- a/extensions/markdown-language-features/src/features/preview.ts +++ b/extensions/markdown-language-features/src/features/preview.ts @@ -288,12 +288,15 @@ export class MarkdownPreview extends Disposable { const editor = vscode.window.activeTextEditor; // Reposition scroll preview, position scroll to the top if active text editor // doesn't corresponds with preview - if (editor && editor.document.uri.fsPath === resource.fsPath) { - this.line = getVisibleLine(editor); - } else { - this.line = 0; + if (editor) { + if (editor.document.uri.fsPath === resource.fsPath) { + this.line = getVisibleLine(editor); + } else { + this.line = 0; + } } + // If we have changed resources, cancel any pending updates const isResourceChange = resource.fsPath !== this._resource.fsPath; if (isResourceChange) {