Case insensitive user text input comparison#1960
Open
akinsmosu wants to merge 8 commits intospectreconsole:mainfrom
Open
Case insensitive user text input comparison#1960akinsmosu wants to merge 8 commits intospectreconsole:mainfrom
akinsmosu wants to merge 8 commits intospectreconsole:mainfrom
Conversation
Author
@microsoft-github-policy-service agree |
patriksvensson
requested changes
Nov 14, 2025
Contributor
patriksvensson
left a comment
There was a problem hiding this comment.
Great first PR, but there are some changes I would like to see before I merge this 👍
src/Tests/Spectre.Console.Tests/Unit/Prompts/TextPromptTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Patrik Svensson <patriksvensson@users.noreply.github.com>
Co-authored-by: Patrik Svensson <patriksvensson@users.noreply.github.com>
Co-authored-by: Patrik Svensson <patriksvensson@users.noreply.github.com>
Co-authored-by: Patrik Svensson <patriksvensson@users.noreply.github.com>
Author
|
Thanks for the feedback! All suggestions applied. |
patriksvensson
approved these changes
Nov 14, 2025
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.
fixes #1906
Changes
Summary
This PR makes
TextPrompt<string>case-insensitive when matching user input against defined choices. Previously, inputs such as"yes"would fail to match"Yes".What this change does
When the
TextPrompt's generic is a string and the user did not explicitly provide a comparer, it automatically configures_comparertoStringComparer.OrdinalIgnoreCase.Adds a theory-based test to verify case-insensitive matching.
All existing behavior remains unchanged for non-string
TextPrompt<T>usage.Implementation Notes
Added a
typeof(T) == typeof(string)check inTextPrompt<T>to detect string-based prompts._compareris set toStringComparison.OrdinalIgnoreCaseonly if the user does not supply a comparer.