Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Add option to collapse all folders before revealing the active file in the file explorer #26

Open
karutt opened this issue Sep 18, 2024 · 1 comment

Comments

@karutt
Copy link

karutt commented Sep 18, 2024

Summary

I would like to propose adding an option to collapse all folders in the file explorer before revealing the active file. This feature allows users to focus only on the folder containing the current file, which greatly improves the user experience, especially when working with a large number of open folders.

Proposed Solution

Adding the following line of code to trigger the collapse-all action before revealing the active file:

    private async reveal() {
        // --- add ---
        (this.app as any).commands.executeCommandById("obsidian-collapse-all-plugin:collapse-file-explorer");
        // -----------
        (this.app as any).commands.executeCommandById("file-explorer:reveal-active-file");
        await this.wait_active_leaf_change();
        this.app.workspace.setActiveLeaf(this.current_open_file_leaf, { focus: true });
    }

This would collapse all the folders in the file explorer before revealing the currently active file, allowing users to easily focus on the file they are working on.

Benefits
This feature helps users who often open multiple folders and files to reduce the need for excessive scrolling and manual folder management. It creates a cleaner and more efficient workflow by automatically organizing the file explorer.

Additional Thoughts
It would be great if there was also a toggle option in the plugin's settings to turn this feature on or off, depending on the user's preference. This would provide flexibility for users who may not want to collapse folders every time they open a file.

Thank you for considering this suggestion!

@karutt
Copy link
Author

karutt commented Sep 26, 2024

I just realized that the command obsidian-collapse-all-plugin:collapse-file-explorer utilizes functionality from another plugin called obsidian-collapse-all. This plugin must be installed and enabled for the command to work as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant