Repository navigation
Conversation
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.
Summary
Adds opt-in free-form input to
Prompt.Select<T>, so a pick list can also accept a value that is not in the list. Fixes #336.Behavior
Resolution order on Enter is unchanged except for the new fallback:
CreateCustomItemset and non-empty typed text, the callback produces the result.Details:
CreateCustomItemdefaults tonull; when it is not set, every existing outcome, error message, and single-item auto-selection is preserved.appand create it even whenappleis the only match; pressing ↓ still selectsapple. The same policy drives rendering, so the highlighted row and the Enter result cannot disagree.Itemsis accepted only when the callback is set. Without a callback it still throwsArgumentException.nullreturn is rejected withValidation_Invalid.TextSelectorlike any other item.TypeConverteruse, so the feature is Native AOT safe.MultiSelectis unchanged: the publicPaginator.TryGetSelectedItemsignature is retained and the new overload is internal.API
SelectOptions<T>.CreateCustomItem(Func<string, T>?)SelectOptionsExtensions.WithCreateCustomItem(...)Tests
18 new tests:
PaginatorTests: auto-select on/off, exact match, explicit highlight, empty list.FormInteractionTests: creation, exact-match and highlight precedence, partial match without a false highlight, empty filter, emptyItemswith/without callback, factory exception,nullreturn, no-callback regression, customTextSelector.FluentExtensionsTests: option assignment and null-argument validation.Sharprompt.Tests(484) andSharprompt.SourceGenerator.Tests(210) pass in Release;dotnet formatreports no changes.