Skip to content
This repository was archived by the owner on Sep 1, 2024. It is now read-only.

Commit 7faf232

Browse files
committed
fix: no active editor won't break plugin now, set a minimum time for plugin run the second time
fix #29
1 parent 1ec6243 commit 7faf232

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

CHANGELOG.md

+9
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
## [2.1.7](https://github.com/JYC333/obsidian-file-structure-format/compare/2.1.6...2.1.7) (2023-12-26)
2+
3+
4+
### Bug Fixes
5+
6+
* no active editor won't break plugin now, set a minimum time for plugin run the second time ([c11e44a](https://github.com/JYC333/obsidian-file-structure-format/commit/c11e44ab14d3f5ab0eac50f568322e5f1bf86b3e)), closes [#29](https://github.com/JYC333/obsidian-file-structure-format/issues/29)
7+
8+
9+
110
## [2.1.5](https://github.com/JYC333/obsidian-file-structure-format/compare/2.1.4...2.1.5) (2023-12-07)
211

312

manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "obsidian-attachment-name-formatting",
33
"name": "Attachment Name Formatting",
4-
"version": "2.1.5",
4+
"version": "2.1.7",
55
"minAppVersion": "0.12.0",
66
"description": "Obsidian plugin for formatting attachments name (filename attachmentType indexNumber.xxx)",
77
"author": "JYC333",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "obsidian-attachment-name-formattion",
3-
"version": "2.1.5",
3+
"version": "2.1.7",
44
"description": "Obsidian plugin for formatting attachments name (filename attachmentType indexNumber.xxx)",
55
"main": "main.js",
66
"scripts": {

src/main.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,13 @@ export default class AttachmentNameFormatting extends Plugin {
249249
}
250250
this.renaming = true;
251251
timeInterval = new Date();
252-
const editor = this.app.workspace.activeEditor.editor;
252+
253+
let editor;
254+
try {
255+
editor = this.app.workspace.activeEditor.editor;
256+
} catch {
257+
console.log("No active editor.");
258+
}
253259

254260
await this.getVaultAttachmentFolderPath();
255261

@@ -561,7 +567,7 @@ export default class AttachmentNameFormatting extends Plugin {
561567
} else {
562568
console.log("No attachments found...");
563569
}
564-
this.renaming = false;
570+
setTimeout(() => (this.renaming = false), 3000);
565571
}
566572

567573
/*

versions.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,6 @@
2727
"2.1.2": "0.12.0",
2828
"2.1.3": "0.12.0",
2929
"2.1.4": "0.12.0",
30-
"2.1.5": "0.12.0"
30+
"2.1.5": "0.12.0",
31+
"2.1.7": "0.12.0"
3132
}

0 commit comments

Comments
 (0)