Skip to content

Comments

Fix detecting partially visible URLs#19878

Open
carlos-zamora wants to merge 5 commits intomainfrom
dev/cazamor/bugfix/url-detection
Open

Fix detecting partially visible URLs#19878
carlos-zamora wants to merge 5 commits intomainfrom
dev/cazamor/bugfix/url-detection

Conversation

@carlos-zamora
Copy link
Member

@carlos-zamora carlos-zamora commented Feb 18, 2026

Summary of the Pull Request

Fixes a bug where a partially visible URL would not be detected. This is fixed by expanding the search space by 1 viewport height in both directions.

The _patternIntervalTree now operates in the absolute-buffer space as opposed to the viewport-relative space. It's a bit of an annoying change, but the alternative would be to keep track of the offset used by the method above, which I find more annoying, personally. As a part of this change, I made it a bit more clear when something is viewport-relative vs buffer-absolute.

Regarding mark mode hyperlink navigation, now that everything is in the absolute-buffer space, I'm able to fix some of the issues in #13854. I removed _selectionIsTargetingUrl and fixed/validated navigating to hyperlinks that are partially visible.

Validation Steps Performed

Detects URL that is...
✅ fully visible
✅ partially cropped off the top
✅ partially cropped off the bottom

✅ Above scenarios work with mark mode hyperlink navigation

✅Tests added

Closes #18177
Closes #13854

@carlos-zamora

This comment was marked as resolved.

@carlos-zamora

This comment was marked as resolved.

@lhecker lhecker self-requested a review February 18, 2026 23:01
@lhecker
Copy link
Member

lhecker commented Feb 18, 2026

Ah whoops, I thought I had already reviewed it last week and just re-approved it. Dejavu?

Copy link
Member

@lhecker lhecker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Some ideas.

Comment on lines +529 to +530
const auto beg = std::max<til::CoordType>(0, bufferPos.y - viewportHeight);
const auto end = std::min(bufferSize.BottomInclusive(), bufferPos.y + viewportHeight);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should move the min/max into UTextFromTextBuffer itself so that all callers are protected. Then, we can simplify the code here by dropping the min/max.

BTW why doesn't this function use the cached _patternIntervalTree?

Comment on lines +1202 to +1206
// GH#18177: Scan extra rows beyond the viewport so that URLs
// wrapping across the viewport boundary are matched in full
const auto bufferSize = _activeBuffer().GetSize();
const auto beg = std::max<til::CoordType>(0, visStart - viewportHeight);
const auto end = std::min(bufferSize.BottomInclusive(), visEnd + viewportHeight);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we trim the results? For instance, we could pass both a start/end range for search, as well as a start/end range for filtering the search to _getPatterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ctrl+clicking URLs partially out of viewport not working as expected Mark mode hyperlink navigation sometimes skips over entries

2 participants