Mercurial > obsidian-remember-file-state
changeset 7:b1cb0474bb18
Fix possible crash when an opened file isn't a markdown file
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Mon, 14 Feb 2022 13:00:06 -0800 |
parents | 114d7e6d2633 |
children | ec6c48a07b03 |
files | src/main.ts |
diffstat | 1 files changed, 8 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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; } }