fix: currency symbols stick to adjacent numbers during line breaking#105
Open
ImpulseB23 wants to merge 2 commits intochenglou:mainfrom
Open
fix: currency symbols stick to adjacent numbers during line breaking#105ImpulseB23 wants to merge 2 commits intochenglou:mainfrom
ImpulseB23 wants to merge 2 commits intochenglou:mainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
Fixes incorrect line-break opportunities introduced by Intl.Segmenter splitting currency symbols away from adjacent text, bringing Pretext wrapping behavior in line with browser layout.
Changes:
- Add a Unicode currency-symbol (
\p{Sc}) detector inanalysis.ts. - Treat currency symbols as both left-sticky and forward-sticky merge candidates so
$500/500€are kept as single segments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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 #98
Currency symbols (
$,£,€,¥, etc.) were getting segmented separately from adjacent text byIntl.Segmenter, leaving a breakable gap. So pretext could wrap between$and500, or between500and€, which browsers don't do.Added a
\p{Sc}(Unicode currency symbol category) check to both the forward-sticky and left-sticky merge passes inanalysis.ts. This covers prefix ($500) and postfix (500€) currencies, matching browser behavior.Before:
$500-> segments["$", "500"](breakable)500€-> segments["500", "€"](breakable)After:
$500-> segments["$500"]500€-> segments["500€"]Tested in Chromium on Windows across
$,£,€,¥,₹at various widths. All match browser line counts. 81/81 existing tests pass.