Skip to content

Commit 0de2b51

Browse files
committed
Handle active file being null
1 parent 45e265d commit 0de2b51

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

main.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,12 @@ export default class WikipediaPlugin extends Plugin {
166166
}
167167

168168
async getWikipediaTextForActiveFile(editor: Editor) {
169-
const searchTerm = await this.app.workspace.getActiveFile().basename;
170-
if (searchTerm) {
171-
await this.pasteIntoEditor(editor, searchTerm);
169+
const activeFile = await this.app.workspace.getActiveFile();
170+
if (activeFile) {
171+
const searchTerm = activeFile.basename;
172+
if (searchTerm) {
173+
await this.pasteIntoEditor(editor, searchTerm);
174+
}
172175
}
173176
}
174177

0 commit comments

Comments
 (0)