fix(TextPrompt): prevent ArgumentOutOfRangeException for non-ASCII default values - #2177
Closed
Moha-sami wants to merge 1 commit into
Closed
fix(TextPrompt): prevent ArgumentOutOfRangeException for non-ASCII default values#2177Moha-sami wants to merge 1 commit into
Moha-sami wants to merge 1 commit into
Conversation
Author
|
@microsoft-github-policy-service agree |
Contributor
|
Thanks for opening this pull request. Before I can review it, the pull request template needs to be fully filled out so I have all the necessary context. I’m going to close this for now, but feel free to update the template and reopen the PR once everything is completed as expected. Thanks! |
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 #2152
Changes
Problem
When using
TextPromptwithEditableDefaultValue(true)containing non-ASCII or Unicode characters (e.g."日本語"or"ä"),AnsiConsoleExtensions.Input.cspassed(ConsoleKey)chtoConsoleKeyInfo, which throwsArgumentOutOfRangeExceptionin .NET whenConsoleKey > 255.Solution
AnsiConsoleExtensions.Input.csto check(int)ch <= 255 ? (ConsoleKey)ch : (ConsoleKey)0, preventing out-of-range exceptions while maintaining full Unicode string processing.Should_Not_Throw_When_Editable_Default_Value_Contains_Non_Ascii_CharactersinTextPromptTests.cs.