Skip to content

Fix detecting partially visible URLs#19878

Merged
carlos-zamora merged 7 commits intomainfrom
dev/cazamor/bugfix/url-detection
Feb 27, 2026
Merged

Fix detecting partially visible URLs#19878
carlos-zamora merged 7 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 +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.

Copy link
Member Author

Choose a reason for hiding this comment

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

Eh. _patternIntervalTree can definitely be improved to include/expose the buffer range it's looking at and that would make some of the other parts of the code a bit cleaner. That said, I think that's a separate refactor outside of this PR and I don't think we necessarily need that right now.

@github-actions
Copy link

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors and Warnings Count
❌ forbidden-pattern 2
⚠️ ignored-expect-variant 1

See ❌ Event descriptions for more information.

These words are not needed and should be removed lto Tlgg

Forbidden patterns 🙅 (1)

In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves.

These forbidden patterns matched content:

Should be for, for, to or to

\b(?:for to|to for)\b
✏️ Contributor please read this

By default the command suggestion will generate a file named based on your commit. That's generally ok as long as you add the file to your commit. Someone can reorganize it later.

If the listed items are:

  • ... misspelled, then please correct them instead of using the command.
  • ... names, please add them to .github/actions/spelling/allow/names.txt.
  • ... APIs, you can add them to a file in .github/actions/spelling/allow/.
  • ... just things you're using, please add them to an appropriate file in .github/actions/spelling/expect/.
  • ... tokens you only need in one place and shouldn't generally be used, you can add an item in an appropriate file in .github/actions/spelling/patterns/.

See the README.md in each directory for more information.

🔬 You can test your commits without appending to a PR by creating a new branch with that extra change and pushing it to your fork. The check-spelling action will run in response to your push -- it doesn't require an open pull request. By using such a branch, you can limit the number of typos your peers see you make. 😉

If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

@carlos-zamora carlos-zamora enabled auto-merge (squash) February 26, 2026 23:56
const auto visibleViewport = _GetVisibleViewport();
if (visibleViewport.IsInBounds(bufferPos))
// Check cached interval tree (covers visible viewport +/- viewport height)
if (const auto results = _patternIntervalTree.findOverlapping({ bufferPos.x + 1, bufferPos.y }, bufferPos); !results.empty())
Copy link
Member

Choose a reason for hiding this comment

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

why x+1?

@carlos-zamora carlos-zamora merged commit 3918332 into main Feb 27, 2026
18 of 20 checks passed
@carlos-zamora carlos-zamora deleted the dev/cazamor/bugfix/url-detection branch February 27, 2026 19:13
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

3 participants