# HG changeset patch # User Ludovic Chabant # Date 1644872406 28800 # Node ID b1cb0474bb18e2d1c1f65d7968f9a6740cd9af37 # Parent 114d7e6d26339873daa6051e29525411d883cda8 Fix possible crash when an opened file isn't a markdown file diff -r 114d7e6d2633 -r b1cb0474bb18 src/main.ts --- a/src/main.ts Mon Feb 14 12:35:45 2022 -0800 +++ b/src/main.ts Mon Feb 14 13:00:06 2022 -0800 @@ -168,13 +168,16 @@ // and there is now an empty pane. if (openedFile) { var activeView = this.app.workspace.getActiveViewOfType(MarkdownView); - this.registerOnUnloadFile(activeView); + if (activeView) { + this.registerOnUnloadFile(activeView); - if (!this._suppressNextFileOpen) { - this.restoreFileState(openedFile, activeView); - } else { - this._suppressNextFileOpen = false; + if (!this._suppressNextFileOpen) { + this.restoreFileState(openedFile, activeView); + } } + // else: the file isn't handled by a markdown editor. + + this._suppressNextFileOpen = false; } }