Skip to content

feat: (optional) arrow folder expansion in the file tree - #370

Open
N4M3Z wants to merge 1 commit into
agavra:mainfrom
N4M3Z:feat-arrow-folder-expansion
Open

feat: (optional) arrow folder expansion in the file tree#370
N4M3Z wants to merge 1 commit into
agavra:mainfrom
N4M3Z:feat-arrow-folder-expansion

Conversation

@N4M3Z

@N4M3Z N4M3Z commented May 23, 2026

Copy link
Copy Markdown
Contributor

The default for h / l is unchanged: they stay as horizontal scroll, matching vim's character navigation. Users who want gitui-style tree nav opt in via config.

  • New config arrow_tree_navigation (default false). When set to true, h / l in the file list fall through to gitui-style tree nav at the horizontal scroll boundary: l expands a collapsed folder, descends into an expanded one, or jumps to the next folder below on a file; h collapses an expanded folder, otherwise ascends to the parent (and at the top level jumps to the previous folder above).
  • With the flag on, moving the file-list cursor (j / k, arrows, or the tree-nav keys above) to a file also scrolls the diff to that file's header without changing focus. Folders are a no-op so arrowing past collapsed entries leaves the diff alone. Matches gitui / lazygit preview behavior. Enter still commits the selection and shifts focus.
  • Horizontal scroll keeps the sticky prefix (indent, expand icon, checkbox, status badge) anchored at the left edge; only the filename portion slides. Scroll caps at "at least one column visible" so a name never disappears entirely. Leaving the file list resets scroll_x to 0.
  • Enter / Space still toggle folders directly, regardless of the flag.
  • ADR: docs/decisions/FEAT-0014 Folder Expansion.md

Test plan

  • cargo fmt && cargo clippy -- -D warnings clean
  • Manual: default config keeps h/l as plain horizontal scroll
  • Manual: with arrow_tree_navigation = true, l on a folder expands; second l descends; l on a file jumps to the next folder
  • Manual: with arrow_tree_navigation = true, h on an expanded folder collapses; on a file jumps to the containing folder; at top level jumps to the previous folder
  • Manual: with arrow_tree_navigation = true, arrowing the file-list cursor across files scrolls the diff to the new file's header; arrowing over folders does not move the diff; focus stays on the file list
  • Manual: with arrow_tree_navigation = false, arrowing the file-list cursor leaves the diff viewport alone (Enter still required to jump)
  • Manual: horizontal scroll on a long filename keeps the checkbox and status badge visible at the left edge; only the name slides
  • Manual: switching focus away from the file list and back returns long names to their starting position

@N4M3Z

N4M3Z commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

Last larger feature I have in the pipeline, I'll send something cosmetic and that's gonna be it for a while. We should split app.rs into several modules so that we can also split off tests by concern, I might get to it in a couple week

@agavra

agavra commented May 23, 2026

Copy link
Copy Markdown
Owner

Thanks @N4M3Z let's split this into different PRs. I like the mouse down change but I don't want to repurpose h and l for something other than scrolling, this is primarily meant to "feel" like vim, not gitui

also I'll break up app.rs soon, that's on my todo list - i totally agree we need that

@N4M3Z

N4M3Z commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

Sure, I'll split it, but please give the folder expansion a shot, it makes it super quick to navigate the folder tree.

@N4M3Z
N4M3Z force-pushed the feat-arrow-folder-expansion branch 2 times, most recently from 4f607c3 to 75a69f9 Compare May 23, 2026 18:55
@N4M3Z N4M3Z changed the title feat: gitui-style folder expansion and click-to-focus feat: gitui-style folder expansion in the file list May 23, 2026
@N4M3Z
N4M3Z force-pushed the feat-arrow-folder-expansion branch from 75a69f9 to 6de6702 Compare May 23, 2026 21:33
@N4M3Z N4M3Z changed the title feat: gitui-style folder expansion in the file list feat: opt-in gitui-style folder expansion in the file list May 23, 2026
@N4M3Z
N4M3Z force-pushed the feat-arrow-folder-expansion branch from 6de6702 to 036070c Compare May 23, 2026 21:40
@N4M3Z N4M3Z changed the title feat: opt-in gitui-style folder expansion in the file list feat: (optional) arrow folder expansion in the file tree May 23, 2026
@N4M3Z

N4M3Z commented May 23, 2026

Copy link
Copy Markdown
Contributor Author

Minimized the feature set, made the behaviour optional

@N4M3Z
N4M3Z force-pushed the feat-arrow-folder-expansion branch 3 times, most recently from 75ff4f8 to c53fce8 Compare May 24, 2026 11:26
When `arrow_tree_navigation = true`, `h` / `l` in the file list fall
through to gitui-style tree nav at the horizontal scroll boundary:

- `l` on a collapsed folder expands it; on an expanded folder descends
  to the first child; on a file jumps to the next folder below.
- `h` on an expanded folder collapses it; otherwise ascends to the
  parent. At the top level it jumps to the previous folder above.

Default is `false` so `h` / `l` stay as plain horizontal scroll,
matching vim's character navigation. Folders are still expandable with
`Enter` / `Space` regardless of the flag.

With the flag on, moving the file-list cursor (`j` / `k`, arrows, or
the tree-nav keys above) to a file also scrolls the diff to that
file's header without changing focus. Folders are a no-op so arrowing
past collapsed entries leaves the diff viewport alone. Enter still
commits the selection and shifts focus.

Horizontal scroll keeps the sticky prefix (indent, expand icon,
checkbox, status badge) anchored at the left edge; only the filename
portion slides. Scroll caps at "at least one column visible" so a
name never disappears entirely. Leaving the file list resets
`scroll_x` to 0.

New `App::file_list_select_parent` / `_select_next_folder` /
`_select_prev_folder` walk the visible tree to the relevant entry.
`App::auto_jump_to_selected_file_if_enabled` syncs the diff to the
file-list cursor when the flag is on.

ADR: docs/decisions/FEAT-0014 Folder Expansion.md
@N4M3Z
N4M3Z force-pushed the feat-arrow-folder-expansion branch from c53fce8 to 235222b Compare May 26, 2026 23:47
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