Skip to content

Keep no-break spaces inside words in NominalWordWrap [patch] - #164

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/150-no-break-spaces
Oct 13, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/150-no-break-spaces

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #150

What changed

BuildAtoms split each segment with Split((char[]?)null, RemoveEmptyEntries), which breaks on every char.IsWhiteSpace character. 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. The NominalWordWrap doc 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 unchanged

Both 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

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
@sonarqubecloud

Copy link
Copy Markdown

@matt-edmondson
matt-edmondson merged commit 40292ec into main Oct 13, 2026
14 checks passed
@matt-edmondson
matt-edmondson deleted the fix/150-no-break-spaces branch October 13, 2026 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NominalWordWrap breaks lines at no-break spaces and rewrites them as plain spaces: "Total: 100 kg" wraps to "Total: 100" / "kg"

2 participants