-
Notifications
You must be signed in to change notification settings - Fork 62
Bugfix OSC Hyperlinks when broken mid-text by wrap() #193
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
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
You wouldn't think until you get into it, that OSC hyperlink is so much more work for a word-wrapping algorithm that it first appears. The previous change just treated the boundaries as unbreakable but it still (incorrectly) broke an OSC hyperlink if the text contained spaces and a margin is reached. The most naive approach simply says "nothing ever breaks in a hyperlink", but that means any "long" hyperlink is entirely unbreakable and cannot be wrapped by a word margin. But to break it is also very complicated, We must identify and preserve any exting 'id' parameter, or define and generate new unique ones, to allow wrapping them, by closing and re-emitting (and generating!) a new hyperlink of matching id at the next line. We also have to be careful of the word-wrapping rules within, to do the best to match sensible break_on_long_words, break_on_hyphen, etc.
You would think just generating our own id's, starting with id=1 is fine, but I guess there is a rare case that the stream already contains mixed with-and-without ids, and starting with id=1 would be the most obvious default. To prevent conflict, we use padded hexadecimal of random generated values, the famous "git short" length, something like 4 billion-in-1
wrap()wrap()
wrap()
Merging this PR will not alter performance
Performance Changes
Comparing |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #193 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 13 13
Lines 668 716 +48
Branches 164 175 +11
=========================================
+ Hits 668 716 +48 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jquast
added a commit
that referenced
this pull request
Jan 26, 2026
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.
The previous change #191 treated the OSC hyperlink edges as unbreakable, but it still incorrectly broke an OSC hyperlink sequence in half if the hyperlink text also contained spaces.
The most naive approach simply says "nothing ever breaks in a hyperlink", but that means any "long" hyperlink is entirely unbreakable and cannot be wrapped by a word margin, bleeding off the screen or other ill-effect.
To break OSC is complicated. It is necessary to identify and preserve any existing 'id' parameter, or define and generate new unique ones, and to allow wrapping them by closing and re-emitting a new hyperlink sequence of the remaining text, of matching id, at the next line.