mirror of
https://github.com/lostpaul/obsidian-folder-notes.git
synced 2026-07-22 07:40:24 +00:00
Fix active folder highlight
This commit is contained in:
parent
45a43c8748
commit
b8817a5692
2 changed files with 18 additions and 3 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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');
|
||||
}));
|
||||
|
|
|
|||
Loading…
Reference in a new issue