Skip to content

Add t hotkey to toggle tree/TOC pane visibility#18

Merged
umputun merged 3 commits intomasterfrom
feat/toggle-tree-pane
Apr 5, 2026
Merged

Add t hotkey to toggle tree/TOC pane visibility#18
umputun merged 3 commits intomasterfrom
feat/toggle-tree-pane

Conversation

@umputun
Copy link
Copy Markdown
Owner

@umputun umputun commented Apr 5, 2026

Summary

  • t key toggles tree/TOC pane visibility, giving diff full terminal width
  • status bar shows icon when pane is hidden
  • pane-switching keys (tab, h) become no-ops while hidden
  • works in multi-file mode (tree pane) and single-file markdown mode (TOC pane)
  • no-op in single-file mode without TOC (already no tree)

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.
Copilot AI review requested due to automatic review settings April 5, 2026 06:43
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 treeHidden state and t hotkey 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.

Comment on lines +313 to +320
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
}
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copilot uses AI. Check for mistakes.
diffContentWidth() was not accounting for treeHidden state,
returning width-5 instead of width-3 when tree was hidden
@umputun umputun merged commit 51a0a2a into master Apr 5, 2026
2 checks passed
@umputun umputun deleted the feat/toggle-tree-pane branch April 5, 2026 06:48
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