Fix bug with auto create of folder notes and multiple folder note types

This commit is contained in:
Lost Paul 2023-10-21 21:41:09 +02:00
parent d41710ac50
commit 46ec0b14e2
2 changed files with 7 additions and 2 deletions

View file

@ -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;

View file

@ -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';