Skip to content

Keep hyphen runs and word-initial hyphens together in NominalWordWrap [patch] - #162

Merged
matt-edmondson merged 1 commit into
mainfrom
fix/156-159-hyphen-runs
Oct 9, 2026
Merged

matt-edmondson merged 1 commit into
mainfrom
fix/156-159-hyphen-runs

Conversation

@matt-edmondson

Copy link
Copy Markdown
Contributor

Fixes #156
Fixes #159

What changes

ChunkWord ended a chunk after every visible hyphen. Both triage comments say to fix these two issues together, so this PR changes one rule. A visible hyphen is now a break opportunity only when both of these hold:

Input Width Before After
It was late--too late to call 12 It was late- / -too late to / call It was / late--too / late to call
ab -5 4 ab - / 5 ab / -5
Use the --force flag 10 Use the -- / force flag Use the / --force / flag

well-known and foo-bar-baz still break after their hyphens. The soft-hyphen behaviour from #135 and #151 is unchanged, and its existing tests still pass.

A hyphen can now stay inside an unbroken chunk, so one guard was added for that case. When a soft hyphen follows a leading --, a break there no longer adds a third hyphen.

Tests

  • New tests cover the repros from both issues, a break after the last hyphen of a run, -5-6 (a hyphen after a leading one is still a break), and the soft-hyphen guard.
  • With the fix reverted, the two repro tests fail. With the fix, the full suite passes (181 tests). The Release build passes on every target framework.

🤖 Generated with Claude Code

https://claude.ai/code/session_01P2fpLkFHYU6nd3JVKufVtK


Generated by Claude Code

…WordWrap

ChunkWord ended a chunk after every visible hyphen, so "--" could be split
across lines ("late-" / "-too") and a word-initial hyphen could be left
dangling ("ab -" / "5", "Use the --" / "force"). A visible hyphen is now a
break opportunity only when it ends its run of hyphens and another character
comes before it in the word.

Fixes #156
Fixes #159

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01P2fpLkFHYU6nd3JVKufVtK
@sonarqubecloud

sonarqubecloud Bot commented Oct 9, 2026

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants