From 0de2b516cf4a8754586cdc95c09451e90bc7ffd6 Mon Sep 17 00:00:00 2001 From: Jonathan Miller Date: Sat, 16 Oct 2021 09:34:49 -0400 Subject: [PATCH] Handle active file being null --- main.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/main.ts b/main.ts index d029891..dc7603d 100644 --- a/main.ts +++ b/main.ts @@ -166,9 +166,12 @@ export default class WikipediaPlugin extends Plugin { } async getWikipediaTextForActiveFile(editor: Editor) { - const searchTerm = await this.app.workspace.getActiveFile().basename; - if (searchTerm) { - await this.pasteIntoEditor(editor, searchTerm); + const activeFile = await this.app.workspace.getActiveFile(); + if (activeFile) { + const searchTerm = activeFile.basename; + if (searchTerm) { + await this.pasteIntoEditor(editor, searchTerm); + } } }