What's wrong
ChunkWord (Extensions/StringExtensions.cs:347-389) splits a word after a visible hyphen. It adds the chunk "well-" and resets hyphenBefore = false (:375-380). If the next character is a soft hyphen (U+00AD), then current is empty and chunks.Count > 0, so the branch at :365-369 sets hyphenBefore = true for the following chunk. When NominalWordWrapIterator later breaks before that chunk, it appends '-' to the upper line (:284-287). That line already ends with the visible hyphen, so the output is "well--".
The XML doc (:221-226) says a soft hyphen "renders as a hyphen only when a break lands there". A break right after an existing visible hyphen needs no extra hyphen; adding one produces visibly wrong text and makes the line overhang the requested width.
Failure scenario
"well-known".NominalWordWrap(5, 1)
- Expected:
["well-", "known"]
- Actual:
["well--", "known"]. The first line is 6 characters, which exceeds maxCharsPerLine = 5.
Text run through automatic soft-hyphenation commonly has a U+00AD inserted next to existing hyphens, so this input is realistic.
How verified
Built the library for net10.0 and ran a console program that prints each line of "well-known".NominalWordWrap(5, 1):
Suggested fix / acceptance criteria
- In
ChunkWord, when a soft hyphen immediately follows a visible hyphen (the previous chunk ends in '-' and current is empty), do not set hyphenBefore. The visible-hyphen break already covers that position.
- Alternatively, skip the
line.Append('-') in the iterator when the line already ends with '-'.
- Add a test asserting that
"well-known".NominalWordWrap(5, 1) yields ["well-", "known"].
What's wrong
ChunkWord(Extensions/StringExtensions.cs:347-389) splits a word after a visible hyphen. It adds the chunk"well-"and resetshyphenBefore = false(:375-380). If the next character is a soft hyphen (U+00AD), thencurrentis empty andchunks.Count > 0, so the branch at:365-369setshyphenBefore = truefor the following chunk. WhenNominalWordWrapIteratorlater breaks before that chunk, it appends'-'to the upper line (:284-287). That line already ends with the visible hyphen, so the output is"well--".The XML doc (
:221-226) says a soft hyphen "renders as a hyphen only when a break lands there". A break right after an existing visible hyphen needs no extra hyphen; adding one produces visibly wrong text and makes the line overhang the requested width.Failure scenario
["well-", "known"]["well--", "known"]. The first line is 6 characters, which exceedsmaxCharsPerLine = 5.Text run through automatic soft-hyphenation commonly has a U+00AD inserted next to existing hyphens, so this input is realistic.
How verified
Built the library for net10.0 and ran a console program that prints each line of
"well-known".NominalWordWrap(5, 1):Suggested fix / acceptance criteria
ChunkWord, when a soft hyphen immediately follows a visible hyphen (the previous chunk ends in'-'andcurrentis empty), do not sethyphenBefore. The visible-hyphen break already covers that position.line.Append('-')in the iterator when the line already ends with'-'."well-known".NominalWordWrap(5, 1)yields["well-", "known"].