Skip to content

Commit

Permalink
fix: no active editor won't break plugin now, set a minimum time for …
Browse files Browse the repository at this point in the history
…plugin run the second time

fix #29
  • Loading branch information
JYC333 committed Dec 26, 2023
1 parent 1ec6243 commit c11e44a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/main.ts
Expand Up @@ -249,7 +249,13 @@ export default class AttachmentNameFormatting extends Plugin {
}
this.renaming = true;
timeInterval = new Date();
const editor = this.app.workspace.activeEditor.editor;

let editor;
try {
editor = this.app.workspace.activeEditor.editor;
} catch {
console.log("No active editor.");
}

await this.getVaultAttachmentFolderPath();

Expand Down Expand Up @@ -561,7 +567,7 @@ export default class AttachmentNameFormatting extends Plugin {
} else {
console.log("No attachments found...");
}
this.renaming = false;
setTimeout(() => (this.renaming = false), 3000);
}

/*
Expand Down

0 comments on commit c11e44a

Please sign in to comment.