Don't require pressing Return when selecting a gem#9646
Open
eval wants to merge 1 commit into
Open
Conversation
When `bundle info`/`show`/`open` show a numbered menu for an ambiguous gem name, accept the choice on a single keypress instead of requiring Enter: - With <10 options every digit (including 0/exit) selects immediately. - With >=10 options a digit waits only while it's a prefix of a larger valid option (e.g. 1 when 10/11 exist); Enter then resolves the prefix to what's typed so far. Backspace edits; invalid digits are ignored.
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.
I opened this discussion a few weeks ago but it didn't get a response yet - so following up with a concrete implementation to make the proposal easier to evaluate. Happy to adjust the approach based on feedback.
What was the end-user or developer problem that led to this PR?
When using commands
info,show,openwith an ambiguous search-term (e.g.bundle show rspec), a menu with numbered candidates is shown. Selecting one always required confirming with Return, which adds friction to what is usually a single-digit choice.What is your fix for the problem, implemented in this PR?
The menu now accepts a selection on a single keypress, so no extra Return is needed in the common case:
selecting 1 while 10 exists). Backspace edits the entry, digits that can't lead to any valid option are ignored.
Terminal control keys behave conventionally:
The single-keypress path is only used when both stdin and stdout are a TTY and io/console is available. Otherwise (piped input, non-interactive shells, CI) it falls back to the existing line-based prompt, so scripted usage and existing specs are unaffected.
The discussion raised whether this should be opt-in via configuration. I've kept it on by default, since the non-TTY fallback means scripts and CI are unaffected and the change to interactive use is minimal. I'm happy to gate it behind a config setting if maintainers prefer.
Make sure the following tasks are checked