[Bug] /explorer: "go up a directory" is bound to Backspace, a key mainstream terminals never actually send
Description
The tree-mode branch of /explorer's key handler checks only key.backspace, while the search-mode branch of the exact same handler forty lines above it correctly checks key.backspace || key.delete. Ink parses the physical Backspace key (the \x7f byte sent by macOS Terminal, iTerm2, and effectively every Linux terminal) as key.delete, not key.backspace (which Ink reserves for a literal \b / Ctrl+H). So on mainstream terminals, pressing the actual Backspace key in tree mode never satisfies the key.backspace-only check.
Parent: #907
Steps to Reproduce
- Run
/explorer. - Move onto a directory entry and press Enter to expand into it.
- Press the physical Backspace key, intending to go back up a level.
Expected Behavior
Backspace collapses the current directory / moves the selection up a level, the same way it does in every terminal emulator's own file-browser convention.
Actual Behavior
Nothing happens at all. Confirmed by comparing the rendered screen immediately before and immediately after the Backspace keypress they are byte-for-byte identical. The feature is both unreachable on mainstream terminals and undiscoverable, since the tree-mode help line doesn't advertise a "go up" shortcut either.
Recording
Root Cause
source/components/file-explorer/index.tsx:
- Search mode (line 316):
if (key.backspace || key.delete) { ... }, correct. - Tree mode (line 357):
} else if (key.backspace) { ... handleGoUp(); }, missing|| key.delete.
Every other keyboard surface in the codebase checks both (settings-tabs.tsx, model-database.tsx, filterable-select-list.tsx, user-input.tsx, wizards/steps/model-selection-list.tsx).
Suggested Fix
Add || key.delete to the tree-mode branch, matching the search-mode branch immediately above it and every other keyboard handler in the codebase.
Additional Context
- [x] I have searched existing issues to ensure this is not a duplicate
- [x] I can reproduce this issue consistently
- [x] This issue occurs on the latest
main
Hi @akramcodez, I've gone through the issue could you assign this to me ?
Picking this up - a fix will follow shortly.
Thanks for assigning this, @akramcodez!
@will-lamerton's 40020735 fixed the key itself: tree mode now accepts key.delete, so the physical Backspace reaches handleGoUp. The handler behind it still didn't match the expected behaviour though, so the repro steps here still did nothing:
- it collapsed the parent of the highlighted node, so Backspace on a directory you'd just opened was a no-op at the top level, and hid that directory when nested
- it never moved the selection, which stayed on an unrelated row after a collapse
- it split paths on
/, but the tree builds them withpath.join, so on Windows it never found a parent at all - the help line didn't mention it
I've opened a PR that makes Backspace collapse an open directory and otherwise move up to the parent row, lists it in the help line, and adds a test that drives the real component.