You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NominalWordWrap merges lines separated by U+2028, U+2029, NEL or form feed into one line ("Line one" LS "Line two" → "Line one Line two") #184
NominalWordWrap treats only \r\n, \r and \n as forced line breaks. Unicode has other characters that also mean "end this line here":
U+2028 LINE SEPARATOR
U+2029 PARAGRAPH SEPARATOR
U+0085 NEXT LINE (NEL)
U+000C FORM FEED
Each of these is a mandatory break (class BK or NL) in UAX #14. The wrapper turns each one into an ordinary space instead. Lines the input deliberately separated get run together.
SplitAtBreakingWhiteSpace then sees char.IsWhiteSpace(ch), which is true for all four characters. It treats each one as a word separator, and the separator is rendered as a single space.
Reproduction
The source was compiled directly from main and run on net10.0. Each call uses text.NominalWordWrap(80f, 1f):
Input
Output
"Line one\nLine two"
["Line one", "Line two"] (correct)
`"Line one" + '
' + "Line two"`
["Line one Line two"]
`"Para one" + '
' + "Para two"`
["Para one Para two"]
"Line one" + '\u0085' + "Line two"
["Line one Line two"]
"Page one" + '\f' + "Page two"
["Page one Page two"]
`"a" + '
' + '
' + "b"`
["a b"]: the blank line is lost too, though "a\n\nb" keeps it
Why it matters
U+2028 and U+2029 are common in real text:
JavaScript and JSON payloads carry them.
Word and rich-text editors produce them when you paste with Shift+Enter or as a paragraph mark.
NEL turns up in text converted from EBCDIC and other mainframe sources.
A caller that wraps such text for a console or an ImGui label gets the paragraphs merged into one run-on line. Nothing tells them anything went wrong. The function already handles NBSP, figure space, narrow NBSP, soft hyphens and surrogate pairs carefully, so this is a gap in the same Unicode handling, not a new feature.
Suggested fix
In NominalWordWrapIterator, split segments on every mandatory break, not only on \n. For example, after the existing Unix normalisation, split on '\n', ' ', ' ', '\u0085', '\f', and probably '\v' as well. Each separator then produces a line boundary, and consecutive ones produce blank lines, just as \n\n does today.
SplitAtBreakingWhiteSpace can stay as it is, because these characters will no longer reach it.
NormalizeLineEndings and DetermineLineEndings are documented in terms of CR/LF styles, so leaving them unchanged is reasonable. This issue is only about the wrapper.
Acceptance criteria
NominalWordWrap yields "Line one" and "Line two" as separate lines when they are separated by U+2028, U+2029, U+0085 or U+000C, at any width that fits each line.
Two consecutive separators yield an empty line between, matching "\n\n".
Data-row tests for each separator sit alongside the existing line-ending tests in Extensions.Test/StringExtensionsTests.cs.
changed the title [-]NominalWordWrap joins lines split by U+2028, U+2029 or NEL into one: "Line one Line two" at width 80 gives "Line one Line two"[/-][+]NominalWordWrap merges lines separated by U+2028, U+2029, NEL or form feed into one line ("Line one" LS "Line two" → "Line one Line two")[/+]on Nov 2, 2026
Priority: Medium. Separate lines are merged with no error, so the output is silently wrong. The affected characters are less common than \n, though, and the fix is small and local.
Area / suggested assignment:Extensions/StringExtensions.cs, specifically the NominalWordWrapIterator segment split. Whoever is already working on the NominalWordWrap series should take it.
Next step: The issue's suggested fix is sound. After the Unix normalisation, split segments on \n, U+2028, U+2029, U+0085 and \f, and decide whether to include \v. Then add data-row tests for each separator and for the double-separator blank-line case in Extensions.Test/StringExtensionsTests.cs.
Activity
[-]NominalWordWrap joins lines split by U+2028, U+2029 or NEL into one: "Line one Line two" at width 80 gives "Line one Line two"[/-][+]NominalWordWrap merges lines separated by U+2028, U+2029, NEL or form feed into one line ("Line one" LS "Line two" → "Line one Line two")[/+]matt-edmondson commentedon Nov 2, 2026
Triage
\n, though, and the fix is small and local.Extensions/StringExtensions.cs, specifically theNominalWordWrapIteratorsegment split. Whoever is already working on theNominalWordWrapseries should take it.NominalWordWrapbugs, but they cover different behaviour.NominalWordWrap, so the fix should be sequenced after them or rebased onto them to avoid conflicts. Coder PR #381 makes the same U+0085/U+2028/U+2029 change for comment lines and is a useful reference.\n, U+2028, U+2029, U+0085 and\f, and decide whether to include\v. Then add data-row tests for each separator and for the double-separator blank-line case inExtensions.Test/StringExtensionsTests.cs.Generated by Claude Code