Repository navigation
Keep no-break spaces inside words in NominalWordWrap [patch] - #164
Merged
Merged
Conversation
BuildAtoms split words on every char.IsWhiteSpace character, which includes U+00A0, U+2007 and U+202F. The wrapper therefore broke lines exactly where the author forbade a break, and rewrote those characters as plain spaces even when nothing wrapped. Split only on whitespace that allows a break. Fixes #150 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011XTgJFveY9S4CJX3Bzeyej
|
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 #150
What changed
BuildAtomssplit each segment withSplit((char[]?)null, RemoveEmptyEntries), which breaks on everychar.IsWhiteSpacecharacter. That set includes the no-break spaces U+00A0, U+2007 and U+202F. As a result the wrapper broke lines exactly where the author had forbidden a break, and it rewrote those characters as U+0020 even when nothing wrapped.A small tokenizer,
SplitAtBreakingWhiteSpace, now splits only on whitespace that allows a break. No-break spaces stay inside their word and are emitted unchanged. TheNominalWordWrapdoc comment now says so.Tests
NominalWordWrapDoesNotBreakAtANoBreakSpace:"Total: 100 kg"at 10 chars gives["Total:", "100 kg"]NominalWordWrapKeepsNoBreakSpacesUnchanged: all three characters come through a non-wrapping call unchangedBoth fail on
main(the first returns"Total: 100", the second returns U+0020) and pass with the fix. The full suite passes: 195/195 on net10.0.🤖 Generated with Claude Code
https://claude.ai/code/session_011XTgJFveY9S4CJX3Bzeyej
Generated by Claude Code