Repository navigation
GH-99: expand and collapse folders in the tree - #100
Merged
Merged
Conversation
The folder pane draws the listing as a tree. A folder with subfolders leads with + (folded) or - (expanded) in the imap-notes shape, and the cursor is the bold row rather than a "> " glyph, so the marker is never displaced. Folders are folded by default; the expanded set is stored per account in state.toml, names only, and only an explicit expand or collapse writes it. enter expands a collapsed folder before it opens anything: the first press reveals the subfolders, the next loads the folder as before. right expands, left folds, and both are scoped to the folder pane. The folders overlay and the move picker stay flat, so a folded folder is still reachable. A parent is the nearest ancestor the listing actually contains, so a server that omits an intermediate container gets no invented row; a folder with no listed ancestor is a root. Two presentation changes ride with the issue on this branch: the footer joins its command keys with two spaces, matching imap-notes (44 cells for the five-hint set, inside the 54-cell floor at 60 columns); and the panels are separated by a two-column layout gap, so folders/messages and messages/reader have the same four blank cells. The gap is subtracted from the pane widths, keeping the frame exact.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The folder pane draws the listing as a tree. Folders with subfolders show a
+whenfolded and
-when expanded, in the shape imap-notes uses: the marker leads the row andthe cursor is the bold row, so the selection never displaces the marker. Folded is the
default, and which folders are open is remembered per account.
Owner rulings applied:
enterexpands a collapsed folder first; the nextenterloads it, exactly as before.rightexpands without opening,leftfolds. Both are folder-pane actions only.>cursor glyph.Folder tree
tui/foldertree.goderives the visible rows on demand from the listing and an expansionset keyed by mailbox name, so there is no cached second tree to go stale. Every cursor,
scroll, clamp and render path indexes the visible rows instead of
m.folders.listedParentwalks the whole path and uses the nearest ancestor the listing contains.A server that lists
Work/Projects/2025withoutWork/Projectsgets the grandchild undera listed
Workand no synthetic row; a folder with no listed ancestor renders as a root.Indent is tree depth, not delimiter count.
The folders overlay (
\) and the move picker (m) stay flat, so a folded folder is stillreachable; both convert between their flat index and the tree cursor when they open a
folder.
enteron a folder with children expands it;enteron an expanded folder or a leafopens it.
rightcalls the same expansion without opening,leftfolds.zremainsthread-collapse only and is still inert in the folder pane.
Persistence
config.StategainsExpanded map[string][]string— account name to the folders whosesubfolders were shown. It is written
0600through the existing temp-file-and-rename, isstill names only, and is written only by an explicit expand or collapse: revealing a path
for a remembered or opened folder happens in memory and does not create or modify the
file. A fresh state file therefore opens the tree folded.
Two presentation changes in the same delivery
(
tui/view.go:135). The five-hint default is 44 cells against the 54-cell floor at 60columns. The visual-range footer at 105 columns now drops its last hint whole rather
than fitting everything; nothing is truncated mid-hint.
PanelGap = 2columns between panels, so folders/messages and messages/reader have thesame four blank cells (one of padding on each side plus the gap). The gap is subtracted
from the pane widths in
ComputeLayoutWithand drawn as a real blank block, so thevisible columns and gaps still sum to the content width and the frame stays exact. At
120 columns: folders 28, messages 40, reader 42.
Verification
Behaviour is pinned by
tui/foldertree_test.go: folded by default,enterexpands thenopens,
right/leftfold and expand, arrows inert outside the pane, no invented parent,a persisted expand survives a reload, a remembered
Work/2024/Q1reopens with its pathshown and writes nothing, and the tree keeps the frame exact at 60x20, 105x59 and 140x40.
TestFolderTreeSelectionIsBoldNotAGlyphforces a TrueColor profile because lipgloss packsbold and colour into one SGR sequence.
Notes
leftandrightare folder-pane actions;leftin the reader does not mean "back".Flagged rather than changed, since
escowns that meaning today.open / expandandcollapse thread / folderrows, which matters because the overlay is already at itstested height.
Closes #99