clean up onDidChangeActiveTextEditor

Also fixes potential bug if line === 0
This commit is contained in:
Matt Bierner
2021-11-02 14:02:36 -07:00
parent d42476c575
commit 359cd4330d

View File

@@ -78,11 +78,10 @@ export class MarkdownPreviewManager extends Disposable implements vscode.Webview
this._register(vscode.window.registerCustomEditorProvider(this.customEditorViewType, this));
this._register(vscode.window.onDidChangeActiveTextEditor(textEditor => {
// When at a markdown file, apply existing scroll settings
if (textEditor && textEditor.document && isMarkdownFile(textEditor.document)) {
if (textEditor?.document && isMarkdownFile(textEditor.document)) {
const line = this._topmostLineMonitor.getPreviousStaticEditorLineByUri(textEditor.document.uri);
if (line) {
if (typeof line === 'number') {
scrollEditorToLine(line, textEditor);
}
}