Skip to content

feat: add ui.startFoldersOpenDepth config option#123

Merged
dlvhdr merged 2 commits into
dlvhdr:mainfrom
nasxisbest:feat/start-folders-open-depth
Apr 20, 2026
Merged

feat: add ui.startFoldersOpenDepth config option#123
dlvhdr merged 2 commits into
dlvhdr:mainfrom
nasxisbest:feat/start-folders-open-depth

Conversation

@nasxisbest
Copy link
Copy Markdown
Contributor

@nasxisbest nasxisbest commented Apr 10, 2026

Summary

Adds ui.startFoldersOpenDepth config option to control how many levels deep folders are expanded when diffnav starts.

  • -1 (default): all folders open, same as current behavior
  • 0: all folders collapsed
  • 1: first level open, everything deeper is collapsed
  • N: N levels open

AI disclosure: Written with Claude Code. I reviewed all changes and understand the code. The closeDirsBelow function recursively walks children-first, then closes any directory node whose depth exceeds maxOpenDepth. Children-first traversal is needed because the charm bubbles tree hides a closed node's children from iteration via lipgloss Offset.

How Did You Test this Change?

  • Unit tests for depth 0 (all collapsed) and depth 1 (first level open, deeper closed)
  • go test ./... passes
  • go build ./... clean

Images/Videos

Allow users to control how many levels of folders are expanded on
start in the file tree sidebar. Defaults to -1 (all open, preserving
current behavior). Set to 0 for all collapsed, or any positive
integer for that many levels of depth.
@dlvhdr
Copy link
Copy Markdown
Owner

dlvhdr commented Apr 20, 2026

Hey @nasxisbest, thanks for the contribution :)
I understand why this can be useful but can you further explain what's your case for this?

Comment thread pkg/ui/panes/filetree/filetree.go
Comment thread pkg/ui/panes/filetree/filetree.go Outdated
@nasxisbest
Copy link
Copy Markdown
Contributor Author

Yea, there's some project with different folder architectures. Monorepos, src / test folders, etc. etc.
This option allows them to tailor the diffnav to their use case better.

E.g. for monorepos - you could set the ui.startFoldersOpenDepth to 1 to only see the high-level project folders and see the diff for the whole folder.

@nasxisbest nasxisbest force-pushed the feat/start-folders-open-depth branch from 06c491e to 7f0440b Compare April 20, 2026 19:54
@nasxisbest
Copy link
Copy Markdown
Contributor Author

nasxisbest commented Apr 20, 2026

Implemented the suggestions, thank you for the review!

@nasxisbest
Copy link
Copy Markdown
Contributor Author

Working on CI fixes.

@dlvhdr dlvhdr changed the title feat: Add ui.startFoldersOpenDepth config option feat: add ui.startFoldersOpenDepth config option Apr 20, 2026
@dlvhdr dlvhdr merged commit 214ed73 into dlvhdr:main Apr 20, 2026
3 checks passed
@nasxisbest
Copy link
Copy Markdown
Contributor Author

nasxisbest commented Apr 20, 2026

On a second thought, I do think it would be cool to have shortcuts for how deep the folders are opened. hhahaha

@dlvhdr
Copy link
Copy Markdown
Owner

dlvhdr commented Apr 20, 2026

thank you :)

@nasxisbest
Copy link
Copy Markdown
Contributor Author

Thank you too!

@nasxisbest
Copy link
Copy Markdown
Contributor Author

I'll file a follow up PR if I find the shortcuts useful.

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

Successfully merging this pull request may close these issues.

2 participants