Add t hotkey to toggle tree/TOC pane visibility#18
Conversation
hide the left pane (file tree or markdown TOC) with t key, giving the diff pane full terminal width. press t again to restore. status bar shows ⊟ icon when hidden. pane-switching keys (tab, h) become no-ops while tree is hidden.
There was a problem hiding this comment.
Pull request overview
Adds a new view toggle (t) to hide/show the left tree/Markdown TOC pane so the diff can use the full terminal width, with UI affordances (status icon + help/docs) and safeguards to make pane-switching keys no-ops while hidden.
Changes:
- Add
treeHiddenstate andthotkey handling to toggle tree/TOC pane visibility. - Update rendering/layout logic (resize, file load, view) and status/help text to reflect the hidden state.
- Add unit tests and update user-facing documentation for the new keybinding.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
ui/model.go |
Implements treeHidden state, t key dispatch, layout updates, and status/help UI changes. |
ui/model_test.go |
Adds coverage for toggling the pane, no-op behaviors while hidden, resize preservation, and status icon. |
README.md |
Documents the t keybinding. |
CLAUDE.md |
Updates internal behavior notes and status icon list to include ⊟ and the tree toggle behavior. |
.claude-plugin/skills/revdiff/references/usage.md |
Updates usage reference table with the t keybinding. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if m.treeHidden { | ||
| m.treeWidth = 0 | ||
| m.focus = paneDiff | ||
| m.viewport.Width = m.width - 2 | ||
| } else { | ||
| m.treeWidth = max(minTreeWidth, m.width*m.treeWidthRatio/10) | ||
| m.viewport.Width = m.width - m.treeWidth - 4 | ||
| } |
There was a problem hiding this comment.
When the tree/TOC pane is hidden you set viewport.Width = m.width - 2 (full-width diff pane), but diff rendering still computes its available content width via diffContentWidth() (in ui/diffview.go) which only special-cases singleFile && mdTOC == nil and otherwise subtracts 4 border columns. With treeHidden=true and treeWidth=0 this yields m.width-5, leaving unused space and preventing the diff from actually using the full terminal width. Consider updating diffContentWidth() to treat treeHidden (and single-file TOC-hidden) as the full-width diff case (borders=2 + cursor bar=1).
diffContentWidth() was not accounting for treeHidden state, returning width-5 instead of width-3 when tree was hidden
Summary
tkey toggles tree/TOC pane visibility, giving diff full terminal width⊟icon when pane is hidden