Load picker: vi-style navigation (j/k) — UX + makes the picker demoable in casts #24
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Add vi-style navigation keys (
j/k, and ideallyg/G) to the load picker (Modal::LoadPicker, list sub-mode), alongside the existing arrow keys.Motivation
Two reasons, one UX and one concrete:
UX. vi-style
j/knavigation is a near-universal, low-cost convenience in TUI list pickers; many users reach for it reflexively.It makes the load picker demoable in the documentation casts. The website records asciinema demos with autocast, whose key set is limited to single characters, ASCII control codes (
^X), and waits — it cannot send arrow keys, PageUp/PageDown, Home/End, or function keys (those are multi-byte escape sequences; an attempt to fakeESC [ Bfails because autocast's per-key delay makes the terminal read a loneEsc). The load picker currently navigates only withUp/Down, so a cast cannot move the selection. This blocks a proper projects demo on the website (the parameterless project commands —save as/new/load— are exactly the ones that read poorly as static text and most need a moving picture). Withj/k(plain characters), autocast can drive the picker and we can record a realsave as → new → loadround-trip that switches projects.Proposal
In
src/app.rs,handle_load_picker_key, theLoadPickerSubMode::Listmatch (around the existingKeyCode::Up/KeyCode::Downarms):KeyCode::Char('j')→ move selection down (same asKeyCode::Down).KeyCode::Char('k')→ move selection up (same asKeyCode::Up).KeyCode::Char('g')→ jump to first entry;KeyCode::Char('G')→ jump to last entry.Keep all existing keys (
Up/Down/Enter/Esc, andb/Bfor the path-entry sub-mode). Noteb/Bis already bound, so vi's horizontalh/lare not needed for this vertical list.Implementation notes
src/app.rs(searchload_picker/LoadPicker). Add unit tests thatj/kmove the selection and respect the bounds (no wrap past first/last), mirroring the arrow-key tests; addg/Gtests if implemented.Related / out of scope
PageUp/PageDown, same autocast limitation) — that would be a separate enhancement (e.g. vi-styleCtrl-d/Ctrl-uorj/kscroll keys for the output pane) if we want to demo scrolling later. autocast itself cannot be taught arrow keys; the fix is always app-side typeable keys.Implemented in commit
638b4c9onmain(purely additive to the ADR-0015 load picker; no ADR needed).Added vi-style keys to the load picker's list sub-mode:
j/kmirror Down/Up (bounds-respecting, no wrap),g/Gjump to first/last. Existing keys (↑↓/Enter/Esc/b) unchanged; the footer hint is left as-is (new keys unadvertised, per request).This makes the picker drivable by
autocast(which can only send typeable characters, not arrow keys), unblocking a realsave as → new → loadprojects demo on the website.Tests:
load_picker_jk_navigates_like_arrows,load_picker_g_jumps_to_first_and_last(test-first). Closing as done.