Repository navigation
Keep a hard-broken hyphen on the line with the rest of its word [patch] - #183
Open
matt-edmondson wants to merge 2 commits into
Open
matt-edmondson wants to merge 2 commits into
matt-edmondson wants to merge 2 commits into
Conversation
When a chunk like "self-" was exactly one character too wide, the hard break left only its trailing hyphen on the new line, and the next chunk of the word then broke before itself, so "self-explanatory" at width 4 wrapped to "self" / "-" / "expl" / ... A line left holding only that hyphen run now takes the next chunk of the same word and hard-breaks from there: "self" / "-exp" / "lana" / "tory". Breaks at spaces and soft hyphens, and the width-1 output, are unchanged. Fixes #182 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5jAJ5C3wivQLYNkMm
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017vfJW5jAJ5C3wivQLYNkMm
|
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 #182
What changed
NominalWordWrapkeeps a visible hyphen on the end of its chunk ("self-"). When that chunk was exactly one character too wide, the hard break left only the hyphen on the new line. The next chunk of the word could break before itself, so the line stayed holding nothing but-.After a hard break leaves a remainder made only of hyphens, the next atom is joined to that line if it continues the same word (
GlueSpace == false), then hard-broken from there as usual. Breaks at spaces and soft hyphens don't change.self-explanatory, 4self/-/expl/anat/oryself/-exp/lana/toryabcde-fghij, 5abcde/-/fghijabcde/-fghi/jwell-known e-mail, 4well/-/know/n e-/mailwell/-kno/wn/e-/mailx-ray, 1x/-/r/a/yThe hard-break loop moved into a
HardBreakhelper soNominalWordWrapIteratorstays under the CA1502 complexity limit.Tests
NominalWordWrapNeverLeavesALineOfOnlyHyphens(3 cases) checks the exact lines, that no line is only hyphens, and that no line is wider than the width. NewNominalWordWrapAtWidthOneKeepsTheHyphenOnItsOwnLinepins the width-1 behaviour.NominalWordWrapPrefersHyphenBoundaryOverHardBreakand the NominalWordWrap breaks after a word-initial hyphen, splitting "-5" and "--force" across lines #156/NominalWordWrap breaks between the two hyphens of a "--" dash: "late--too" wraps to "late-" / "-too" #159 cases. The library builds clean for every target framework.Generated by Claude Code