Repository navigation
Conversation
parseText recorded each link's begin/end as offsets into the raw marked-up string, but recheckTextBoxes feeds those to pango, whose layout text is the markup-stripped output. So any styling markup before a link, including the link's own <u><span> wrapper, shifted its clickable region off the glyphs. Count displayed bytes when recording begin/end, and make the region loop half-open now that end is an exclusive offset.
This was referenced Nov 11, 2026
vaxerski
reviewed
Nov 13, 2026
| // markup assembled here. counting displayed bytes keeps the region on the link's glyphs instead of | ||
| // drifting by the length of the styling tags in front of it. valid markup only: a broken fragment | ||
| // would already have failed the whole-string parse in setPangoText. | ||
| static size_t displayedLength(std::string_view s) { |
Member
There was a problem hiding this comment.
this is a hellish function that needs tests
Contributor
Author
There was a problem hiding this comment.
added a test for it in 5d6db54. it checks every case against pango's own stripped text, and that caught a real bug: pango takes a raw > inside a quoted attribute value, and this ended the tag there. fixed that too.
pango takes a raw '>' inside a quoted attribute value, so ending the tag at the first one miscounted everything after such a span. the new test checks each case against pango's own stripped text, plus the unbalanced fragments parseText feeds it.
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.
parseTextrecords each link'sbegin/endas byte offsets into the raw marked-up string it assembles, butrecheckTextBoxeslater feeds those offsets to pango (pango_layout_index_to_pos), whose layout text is the markup-stripped output ofpango_parse_markup. So any markup sitting before a link, including the<u><span foreground=...>wrapper the parser adds to every link, shifted the region off the actual glyphs. With more than one link the second one drifts the most.Count displayed bytes (tags skipped, entities resolved) when recording
begin/endso they index into the same text pango lays out. The region loop is now half-open sinceendbecame an exclusive offset.Added two regression tests that strip
parsedTextwith pango and assert the link's[begin, end)slice equals its displayed text. Before the change they resolve tolink! Hi link2!andw; after, tolink/link2/LINK. Full suite 92/92.Fixes #127.