Fix hover hint underline alignment and wrapped URL matching - #1884
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
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 hover underline for URL hints could render shifted to the right of the actual URL. The regex hover path used oniguruma byte offsets directly as cell columns, so any multi-byte character left of the match on the row (box-drawing prefixes, CJK, emoji) dragged the underline right by one cell per extra UTF-8 byte. The same code searched a single visual row at a time, so soft-wrapped URLs matched truncated or not at all.
Matching now runs over the logical (unwrapped) line under the pointer, extracted together with a byte-to-cell map: every byte of the extracted text records its source cell, and match offsets resolve through the map, so bounds cannot drift regardless of encoding. Wide-char spacers are skipped, blank cells read as spaces, zero-width marks are emitted with their base character, and a match ending on a wide character extends over its spacer so the underline covers the full glyph. Wrapped URLs now resolve whole from any of their rows, and clicking opens the full URL.
Performance work on the probe path, since it runs on mouse movement:
Covered by new unit tests over a mock grid: exact cell bounds on plain ASCII, multi-byte prefixes, wide-char prefixes, soft-wrapped URLs from either row, a URL deep inside a huge wrapped line, and tail post-processing rules. Also adds a librio test pinning url_at alignment for the same scenario.