From 2683ee1a1a69fd23f29e24424305c63970006027 Mon Sep 17 00:00:00 2001 From: Paul <70213368+LostPaul@users.noreply.github.com> Date: Thu, 26 Mar 2026 15:22:04 +0100 Subject: [PATCH] Fix function for getting the folder of a folder note --- src/events/MutationObserver.ts | 4 ++-- src/functions/folderNoteFunctions.ts | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/events/MutationObserver.ts b/src/events/MutationObserver.ts index aadd237..0281823 100644 --- a/src/events/MutationObserver.ts +++ b/src/events/MutationObserver.ts @@ -188,11 +188,11 @@ async function updateFolderNamesInPath( const folderNote = getFolderNote(plugin, folderPath); const viewHeaderTitle = titleContainer.querySelector('.view-header-title'); - if (viewHeaderTitle) { + if (viewHeaderTitle && folderNote) { const filePath = path + (viewHeaderTitle as HTMLElement).innerText.trim() + '.md'; const file = plugin.app.vault.getAbstractFileByPath( filePath); - const folder = getFolderNoteFolder(plugin, file?.path ?? '', file?.name ?? ''); + const folder = getFolderNoteFolder(plugin, folderNote, file?.name ?? ''); if (folder && file && file.path === folderNote?.path && file.parent?.path !== '/') { viewHeaderTitle.parentElement?.classList.add('hide-folder-note-title-in-path'); viewHeaderTitle.classList.add('path-is-folder-note'); diff --git a/src/functions/folderNoteFunctions.ts b/src/functions/folderNoteFunctions.ts index a7d5123..f589edc 100644 --- a/src/functions/folderNoteFunctions.ts +++ b/src/functions/folderNoteFunctions.ts @@ -556,6 +556,13 @@ export function getFolderNoteFolder( filePath = folderNote.path; } const folderName = extractFolderName(plugin.settings.folderNoteName, fileName); + if (!plugin.settings.folderNoteName.includes('{{folder_name}}') && plugin.settings.storageLocation === 'insideFolder') { + if (folderNote instanceof TFile) { + return folderNote.parent; + } + const file = plugin.app.vault.getAbstractFileByPath(filePath); + return file instanceof TFile ? file.parent : null; + } if (!folderName) return null; let folderPath = getFolderPathFromString(filePath); if (plugin.settings.storageLocation === 'parentFolder') {