New Plugin: Automatically reveal active file

When I open a file in obsidian, I want to see where it is in my folder structure as that gives me quite a bit of context. So I can go to the command palette and reveal the active file. But I am used to applications such as VS Code doing this for me. So I wrote a really small plugin to automatically reveal the active file. My hope is that eventually, this plugin becomes deprecated and the functionality implemented directly in Obsidian as a setting.

The plugin is called “Automatically Reveal Active File” and can be found in the Third-party plugins tab in the Obsidian settings.

6 Likes

This is awesome, just feels like a natural feature in Obsidian :+1:

Small bug though: I keep some files in the right sidebar (calendar, daily note, my running notes catchall) so that I can collapse my “manage today and tasks” view as required, with the main workspace area free for what I’m working on. Selecting one of those files in the sidebar doesn’t reveal it as the active file in the navigator, I’m assuming you’re excluding sidebar content?

1 Like

Hmm that would depend on what Obsidian qualifies as opening a file in the current workspace. The plugin hooks into a file open event to then trigger the reveal active file command. I’m fairly new to Obsidian and so I haven’t done much in terms of the sidebar. Could you send me a screenshot of what your side bar looks like and how you are opening the files in the sidebar?

Created by literally just dragging the file into the sidebar, in the same way you can drag them around the workspace. Looks like this:

I’m thinking it’s likely that the trigger is not firing from the Obsidian side rather than your plugin.

By the way, noticed something else: if a file is in a collapsed folder in the navigator, or it’s outside the current scrolled view position, it isn’t “shown” (it’s selected, but it’s not moved into view). Meaning maybe there’s a need to expand the folder(s) to where the file is, and to change the scroll position of the navigator window to bring it into view. Again this could be something that sits on the Obsidian side of the API.

1 Like

Thanks for the screenshot. I was able to reproduce what you are seeing. I will look into if there is a way to get the file open event to trigger for files open in the sidebar.

Regarding the issue with the navigator not scrolling into view or opening a collapsed folder. This all happens in the “Reveal active file in navigator” command. I suspect that the same issue would happen by issuing the command from the command palette.

My navigator does open collapsed folders and scrolls but it doesn’t always scroll 100% accurately. Might be a good bug report.

Thanks for looking into a fix :slight_smile: And noted on the navigator scrolling, although it works for me? No problems with it scrolling and revealing the correct file, either via the header menu or via the command palette.

I’ll go have a look if there’s a bug on it in any case.

FYI, seems that there are a few issues with having notes in the sidebars Hotkeys should apply to sidebar notes when they are focused

A very useful little plug-in. I was wondering if another similar one could be made, perhaps just as a modification of this one, to do the same for the ToC pane.

I use the ToC a lot, but with long notes it is difficult to see whereabouts one is in the tree structure.