Fix active folder highlight

This commit is contained in:
Lost Paul 2024-01-21 18:12:15 +01:00
parent 45a43c8748
commit b8817a5692
2 changed files with 18 additions and 3 deletions

View file

@ -81,12 +81,25 @@ export async function createFolderNote(plugin: FolderNotesPlugin, folderPath: st
}
file = await plugin.app.vault.create(path, content);
} else {
plugin.app.fileManager.renameFile(existingNote, path);
file = existingNote;
file.path = path;
await plugin.app.fileManager.renameFile(existingNote, path).then(() => {
file = existingNote;
});
}
if (openFile) {
if (plugin.app.workspace.getActiveFile()?.path === path) {
if (plugin.activeFolderDom) {
plugin.activeFolderDom.removeClass('fn-is-active');
plugin.activeFolderDom = null;
}
const folder = getFolder(plugin, file);
if (!folder) { return; }
plugin.activeFolderDom = plugin.getEL(folder.path);
if (plugin.activeFolderDom) plugin.activeFolderDom.addClass('fn-is-active');
}
await leaf.openFile(file);
if (plugin.settings.folderNoteType === '.excalidraw' || extension === '.excalidraw') {
openExcalidrawView(leaf);

View file

@ -199,10 +199,12 @@ export default class FolderNotesPlugin extends Plugin {
this.activeFolderDom.removeClass('fn-is-active');
this.activeFolderDom = null;
}
if (!openFile || !openFile.basename) { return; }
const folder = getFolder(this, openFile);
if (!folder) { return; }
if (extractFolderName(this.settings.folderNoteName, openFile.basename) !== folder.name) { return; }
this.activeFolderDom = this.getEL(folder.path);
if (this.activeFolderDom) this.activeFolderDom.addClass('fn-is-active');
}));