Skip to content

Commit

Permalink
Handle active file being null
Browse files Browse the repository at this point in the history
  • Loading branch information
jmilldotdev committed Oct 16, 2021
1 parent 45e265d commit 0de2b51
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down

0 comments on commit 0de2b51

Please sign in to comment.