Skip to content

Commit ef8f120

Browse files
committed
feat: add tab conflict
1 parent 722e89b commit ef8f120

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

src/main.ts

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,25 @@ export default class NoteSplitterPlugin extends Plugin {
100100
}
101101

102102
const filePath = normalizePath(`${groupFolderPath}/${fileName}.md`);
103-
await this.app.vault.create(
104-
filePath, line
105-
);
103+
104+
try {
105+
await this.app.vault.create(
106+
filePath, line
107+
);
108+
} catch (err) {
109+
if (err.message.includes("already exists")) {
110+
const newFilePath = `${groupFolderPath}/Tab conflict ${crypto.randomUUID()}.md`;
111+
try {
112+
await this.app.vault.create(
113+
newFilePath, line
114+
);
115+
} catch (err) {
116+
console.error(err);
117+
new Notice(`Error creating file: ${err.message}`);
118+
}
119+
}
120+
throw err;
121+
}
106122
}
107123
new Notice("Split into " + splitLines.length + " note" + (splitLines.length > 1 ? "s" : ""));
108124
},

0 commit comments

Comments
 (0)