Repository navigation
fix(colors): number keys and hidden separators in Edit Colors - #686
Open
eric-engberg wants to merge 2 commits into
Open
eric-engberg wants to merge 2 commits into
eric-engberg wants to merge 2 commits into
Conversation
ink-select-input selects the item at a digit key's position, the same as Enter on it. Edit Colors ignored digits in its own key handler, but its list still passed them to onSelect, and choosing the Back entry there called onBack. So on a line with two colorable widgets, pressing 3 left the screen; with eight, 9 did. Edit Colors now handles Enter on Back itself and gives the list no onSelect, so digits do nothing, as the handler already intended. Enter on a widget still does nothing, and Enter on Back and ESC still go back.
With separators shown in Edit Colors, highlighting one and pressing s again hid it but left the highlight pointing at it. The list redrew with the marker on the first item, but every key that acts on the highlighted item looked up the hidden separator and found nothing: b, d, r and left/right did nothing, a color entered after a, h or g was dropped, and the "Current foreground" line went blank. When hiding separators takes away the highlighted one, the highlight now moves to the first widget, where the list already draws the marker. Showing separators, or hiding them while a widget is highlighted, keeps the highlight where it was.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Two key fixes in Edit Colors:
← Back(or ESC) goes back.s) while one is highlighted moves the highlight to the first widget, so the color keys and the "Current foreground" line work again.Why
Number keys. The widget list is an
ink-select-inputlist, which selects the item at a digit's position, the same as Enter on it. Edit Colors already skips digits in its own key handler ("Ignore number keys to prevent SelectInput numerical navigation"), but the list still passed them toonSelect, and selecting← BackcalledonBack. With four widgets on a line,5drops you back to "Select Line to Edit Colors"; with two,3does.Hidden separator. In plain mode,
sshows separators so they can be colored. Show them, ↓ onto2: Separator: |, presssagain: the list redraws with ▶ on1: Model, but the highlight still points at the hidden separator. The "Current foreground" line goes blank,b,d,rand ←/→ do nothing, and a color entered aftera,horgis dropped, until you move the highlight with ↑/↓.How
onSelect; Edit Colors handles Enter in its own key handler and goes back when← Backis highlighted. Enter on a widget still does nothing (colors cycle with ←/→), and ESC still leaves background mode first, then the screen. No other menu changes.shandler checks whether hiding takes away the highlighted separator and, if so, highlights the first widget, the item the list already draws ▶ on. Showing separators, or hiding them with a widget highlighted, keeps the highlight where it was.Demo
The TUI's sample data. First, Edit Colors on a line with four widgets: press
5(the Back entry's position), then ↓.Powerline: before
Powerline: after
Plain: before
Plain: after
Then a plain line with a separator:
sto show separators, ↓ onto it,sto hide them, thenband →. Plain only: Powerline mode has no separator widgets, andsdoes nothing there.Plain: before
Plain: after
Testing
ColorMenu.test.tsx, each waiting for every key's visible effect:3, then ↓: expects the highlight on2: Versionand noonBack, then ↓ and Enter on← BackcallonBackonce. Failed onmain(onBackcalled once by the3).s, ↓,s: expects ▶ on1: Modeland the "Current foreground" line, thenbmakes Model bold. Failed onmain(the line was blank andbchanged nothing).bun test: 2784 pass, 0 fail.bun run lintpasses.ColorMenu.test.tsxunder Node 26.10.0 (Vitest): 3 pass (1 existing and 2 new);mainpasses its 1.main,3leaves for "Select Line to Edit Colors", and after hiding the separator "Current foreground" is missing andb/→ change nothing. On this branch3keeps the screen, the hidden separator hands the highlight to Model (Current foreground (8/17): Cyan),band → apply (White [BOLD]), and Enter on← Backstill leaves.