Make bare URLs in LSP hover popups clickable - #2316
Open
sinelaw wants to merge 2 commits into
Open
Conversation
sinelaw
force-pushed
the
claude/peaceful-goodall-14usmf
branch
3 times, most recently
from
June 23, 2026 14:06
2f75f1a to
5cc6ed7
Compare
LSP servers such as pyrefly embed plain http/https URLs in their hover documentation. CommonMark does not autolink bare URLs, so parse_markdown left them as inert text and they could not be clicked, even though the popup click plumbing (link_at_position -> open::that) already handled markdown [text](url) links. Add markdown::linkify_bare_urls, a post-processing pass over the parsed hover lines that splits spans at bare URLs and tags the URL segment with the existing link_url metadata and link styling (underlined cyan). Spans that already carry a link_url (real markdown links) are left untouched, so nothing is double-processed. Apply it once in the hover popup builder, covering both the markdown and plain-text branches; the existing mouse layer then makes the URLs clickable for free. Closes #603.
Adversarial UTF-8 cases: CJK prose adjacent to the URL, a non-ASCII character terminating the URL, and ZWJ-emoji/combining marks in the surrounding text. Guards against byte-index slicing on non-char boundaries.
sinelaw
force-pushed
the
claude/peaceful-goodall-14usmf
branch
from
July 17, 2026 11:54
5cc6ed7 to
acd363b
Compare
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.
Summary
Closes #603.
Some LSP servers (e.g. pyrefly) embed plain
http/httpsURLs in their hover documentation. CommonMark — and thereforeparse_markdown— does not autolink bare URLs, so they rendered as inert text and could not be clicked. (Markdown[text](url)and<url>links were already clickable: the popup click plumbingPopup::link_at_position→open::thathas been in place.)This PR closes that gap by detecting bare URLs in the parsed hover content and reusing the existing link infrastructure.
What changed
view/markdown.rs— newlinkify_bare_urls(&mut [StyledLine])pass. It splits each span at any barehttp/httpsURL, tagging the URL segment with the existinglink_urlmetadata and the link style (underlined cyan). Spans that already carry alink_url(real markdown links) are left untouched, so nothing is double‑processed. URL boundaries follow RFC‑3986 chars and trailing sentence punctuation (. , ; : ! ? ) ] } " ') is excluded.app/lsp_requests.rs— apply the pass once when building the hover popup, covering both the markdown and the plain‑text branch. The existing mouse layer then makes the URLs clickable for free; no changes to the click handlers were needed.docs/internal/hover-bare-url-links-design.md— short design note.Testing
markdown.rs): bare URL → link span; leading/trailing prose preserved; trailing punctuation trimmed; parenthesized URL; multiple URLs per line;http/httpswithout://ignored; markdown links untouched; and a component test provingPopup::link_at_positionresolves a bare URL to a clickable link.tests/e2e/lsp.rs, with a newFakeLspServer::spawn_with_url_hover): hover a symbol whose LSP hover contains a bare URL, render, and assert the URL renders with the link style (cyan + underline) — observable rendered output, no real browser launch.All new tests pass; existing markdown (40) and hover e2e (25) suites remain green. Validated manually by running the new e2e test in a tmux session.
Generated by Claude Code