Skip to content

feat: (optional) arrow-key pane focus and hide gesture - #348

Closed
N4M3Z wants to merge 2 commits into
agavra:mainfrom
N4M3Z:feat-arrow-pane-focus
Closed

feat: (optional) arrow-key pane focus and hide gesture#348
N4M3Z wants to merge 2 commits into
agavra:mainfrom
N4M3Z:feat-arrow-pane-focus

Conversation

@N4M3Z

@N4M3Z N4M3Z commented May 21, 2026

Copy link
Copy Markdown
Contributor

Stacked on top of #370 (opt-in folder expansion). Adds slide-focus-between-panes and the optional second-press hide gesture, all gated by the same arrow_tree_navigation flag (default off).

Note

This depends on #370 being merged first. Default behaviour is unchanged for vim users -- h / l stay as horizontal scroll.

  • Diff: h at scroll_x == 0 slides focus to the file list (revealing it if hidden) when arrow_tree_navigation = true. Otherwise plain horizontal scroll.
  • File list: l at max_scroll_x on a file slides focus to the diff when arrow_tree_navigation = true. Tree-nav behaviours on folders come from feat: (optional) arrow folder expansion in the file tree #370.
  • Sticky-prefix rendering and scroll_x = 0 reset on leaving the file list are unconditional.
  • right_arrow_hides_file_list = true enables a press-release-press collapse: the slide arms it, a Right Release sets the gate, a fresh Right Press in the diff collapses the file list. Held keys never satisfy the gate. Requires kitty REPORT_EVENT_TYPES to be useful.
  • ADR: docs/decisions/FEAT-0012 Arrow Navigation.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, h in the diff at scroll_x = 0 slides focus to the file list (and reveals it if hidden)
  • Manual: with the same config, l on a file in the file list slides focus to the diff
  • Manual: sticky prefix (status badge, checkbox, indent) stays visible while filenames scroll horizontally
  • Manual: file list scroll_x resets to 0 after focus moves away
  • Manual: with right_arrow_hides_file_list = true, deliberate release+press of l in the diff collapses the file list; held l does not

@N4M3Z
N4M3Z force-pushed the feat-arrow-pane-focus branch from 81bb926 to 5f8c632 Compare May 21, 2026 22:13
@agavra

agavra commented May 21, 2026

Copy link
Copy Markdown
Owner

hmm, I don't think I like this to be honest. tried it out locally and I prefer just using the leader for swapping focus ;h and ;l is quite simple

@N4M3Z
N4M3Z force-pushed the feat-arrow-pane-focus branch from 5f8c632 to db7d2a2 Compare May 21, 2026 22:46
@N4M3Z

N4M3Z commented May 21, 2026

Copy link
Copy Markdown
Contributor Author

Yeah, tab works too for that and it might just be sufficient. I was trying to capture what gitui does, where on right arrow press the pane "slides" out of the way, you review your file. Leave this open for a bit, I'll try to play with the UX. I might end up just extracting the part where right arrow in the file explorer allows you to quickly auto expand folders and this makes it more easy to navigate to the files you want.

@N4M3Z
N4M3Z force-pushed the feat-arrow-pane-focus branch 4 times, most recently from bdca239 to 92d1788 Compare May 23, 2026 17:07
@N4M3Z
N4M3Z force-pushed the feat-arrow-pane-focus branch 3 times, most recently from 84d2a94 to 12100d4 Compare May 23, 2026 21:46
@N4M3Z N4M3Z changed the title feat: arrow-key tree navigation in the file list feat: opt-in arrow-key pane focus and hide gesture May 23, 2026
@N4M3Z N4M3Z changed the title feat: opt-in arrow-key pane focus and hide gesture feat: (optional]arrow-key pane focus and hide gesture May 24, 2026
@N4M3Z N4M3Z changed the title feat: (optional]arrow-key pane focus and hide gesture feat: (optional) arrow-key pane focus and hide gesture May 24, 2026
N4M3Z added 2 commits May 24, 2026 13: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
Builds on FEAT-0014's `arrow_tree_navigation` flag (default off). When
the flag is on, `h` / `l` slide focus between the file list and the
diff at the horizontal scroll boundary, mirroring the gitui mental
model. The default is unchanged: `h` / `l` stay as plain horizontal
scroll, matching vim's character navigation.

- diff: `h` at `scroll_x == 0` slides focus to the file list
  (revealing it if hidden) when the flag is on; otherwise scrolls.
- file list: `l` at `max_scroll_x` on a file slides focus to the diff
  when the flag is on; otherwise scrolls. Folders fall through to the
  tree-nav rules from FEAT-0014.

ADR: docs/decisions/FEAT-0012 Arrow Navigation.md
@N4M3Z
N4M3Z force-pushed the feat-arrow-pane-focus branch from 12100d4 to f71d81c Compare May 24, 2026 11:43
@N4M3Z

N4M3Z commented May 24, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of two narrower changes:

The remaining slide-focus-between-panes behavior lives on in my fork at N4M3Z#3 for personal use; happy to re-propose upstream as a smaller PR if there's appetite once #370 lands.

@N4M3Z N4M3Z closed this May 24, 2026
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