Add MultiSelect option to toggle option under cursor when submitting empty prompt#331
Open
sirbrillig wants to merge 3 commits intomikaelmello:mainfrom
Open
Add MultiSelect option to toggle option under cursor when submitting empty prompt#331sirbrillig wants to merge 3 commits intomikaelmello:mainfrom
sirbrillig wants to merge 3 commits intomikaelmello:mainfrom
Conversation
30553a1 to
e75d1c1
Compare
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?
This PR adds a new option to the
MultiSelectprompt calledselect_on_empty_submit. If set, and no options are selected when the user submits the prompt, the option currently under the cursor will be selected instead of nothing.This feature gives
MultiSelectthe ability to act as eitherSelectorMultiSelect, depending on the user's preference. If they only want to pick one option, they don't have to first select it and then submit the prompt; both can be done at the same time.Note
Naming is hard. If anyone has a better idea for the name of this option, let me know!
Why?
In an app I'm developing, I often ask the user to select from a list of items. Some of those prompts (like "Select an item to edit") only ever work for one item, but others can support multiple items (like "Select items to delete").
For example, in one prompt, whichever items are selected will have a star applied. Most of the time the user will only want to select one of those options, so using a
Selectmakes sense. That way when the user presses Enter, the item under the cursor has a star applied.But sometimes the user will want to select multiple options, so I'm forced to use
MultiSelect. Now, when the user presses Enter, no items are starred. Instead, the user must press Space, and then Enter.Because the user has two different types of prompts, and both use the same list of options, it's confusing to remember which input pattern they need to use for the situation.
By providing
select_on_empty_submit,MultiSelectcan support both input patterns. The user can either press Enter immediately to select one item, or they can press Space to check several items before pressing Enter. I feel this more natually simulates UI list patterns where multi-select is optional.