From 46ec0b14e2afdac718ab114da1f4b0a362b6a449 Mon Sep 17 00:00:00 2001 From: Lost Paul <70213368+LostPaul@users.noreply.github.com> Date: Sat, 21 Oct 2023 21:41:09 +0200 Subject: [PATCH] Fix bug with auto create of folder notes and multiple folder note types --- src/Commands.ts | 7 ++++++- src/functions/folderNoteFunctions.ts | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Commands.ts b/src/Commands.ts index 9f4306f..1dc2915 100644 --- a/src/Commands.ts +++ b/src/Commands.ts @@ -220,10 +220,15 @@ export class Commands { if (this.plugin.app.vault.getAbstractFileByPath(newPath)) { return new Notice('Folder already exists'); } + const automaticallyCreateFolderNote = this.plugin.settings.autoCreate; + this.plugin.settings.autoCreate = false; + this.plugin.saveSettings(); await this.plugin.app.vault.createFolder(newPath); const newFolder = this.plugin.app.vault.getAbstractFileByPath(newPath); if (!(newFolder instanceof TFolder)) return; - createFolderNote(this.plugin, newFolder.path, true, undefined, false, file); + await createFolderNote(this.plugin, newFolder.path, true, '.' + file.extension, false, file); + this.plugin.settings.autoCreate = automaticallyCreateFolderNote; + this.plugin.saveSettings(); }); }); if (this.plugin.getFolderPathFromString(file.path) === '') return; diff --git a/src/functions/folderNoteFunctions.ts b/src/functions/folderNoteFunctions.ts index e923412..b02f9b8 100644 --- a/src/functions/folderNoteFunctions.ts +++ b/src/functions/folderNoteFunctions.ts @@ -11,7 +11,7 @@ export async function createFolderNote(plugin: FolderNotesPlugin, folderPath: st const leaf = plugin.app.workspace.getLeaf(false); const folderName = plugin.getFolderNameFromPathString(folderPath); const fileName = plugin.settings.folderNoteName.replace('{{folder_name}}', folderName); - let folderNoteType = extension || plugin.settings.folderNoteType; + let folderNoteType = extension ?? plugin.settings.folderNoteType; if (folderNoteType === '.excalidraw') { folderNoteType = '.md'; extension = '.excalidraw';