Trim before case-mapping the first char in ToUppercaseFirstChar/ToLowercaseFirstChar - #81
Merged
Merged
Conversation
ToUppercaseFirstChar and ToLowercaseFirstChar mapped input[0] and only
then trimmed, so with leading whitespace the whitespace was "case-mapped"
and trimmed away while the first letter was left unchanged
(" hello" -> "hello"). They now collapse and trim first, then map the
first code point. The existing space collapsing is kept and now stated
in the XML summaries.
Fixes #79
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013qSqApi9HSiBjyHaJQYPTP
|
This was referenced Sep 28, 2026
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 #79
What was wrong
ToUppercaseFirstChar/ToLowercaseFirstCharmapped the first code point before trimming. When the input began with whitespace, the whitespace got case-mapped and then trimmed off, so the first letter was never changed:" hello".ToUppercaseFirstChar()returned"hello".Change
CollapseSpaces(input).Trim()first and then map the first code point. This keeps the astral-letter handling from Case-map an astral first letter in ToCamelCase and the first-char helpers #76.Tests
ToUppercaseFirstCharShouldSkipLeadingWhitespace/ToLowercaseFirstCharShouldSkipLeadingWhitespacecover a leading space, a leading tab, and surrounding spaces.FirstCharHelpersShouldCollapseRunsOfSpacespins the space collapsing that is now documented.🤖 Generated with Claude Code
https://claude.ai/code/session_013qSqApi9HSiBjyHaJQYPTP
Generated by Claude Code