Skip to content

Hover popup: bare URLs styled as links but not registered as clickable #497

Description

@JDonaghy

Symptom

The LSP editor hover popup renders many URL strings in link colour (theme.md_link) but they don't respond to clicks. Discovered during #488 smoke testing.

Concrete example

Hovering Rust's Vec (rust-analyzer doc) produced a popup with 143 lines of content. Debug output at draw time showed:

popup.lines = 143
popup.links = 13            ← only 13 registered as clickable
scroll_top  = 38
max_visible_rows = 20       ← so visible window = lines 38-57

The 13 registered links lived on lines 48, 76, 104, 106, 106, 127, 127, 135, 135, 142, 142, 142, 142. With scroll_top=38, max_visible=20, only link[0] (line 48) falls in the visible window. The other 12 are out of view.

Meanwhile, looking at the visible content (lines 38-57), there are many URLs rendered in link colour — e.g. (https://doc.rust-lang.org/stable/alloc/macros/macro.vec.html), (https://doc.rust-lang.org/stable/alloc/vec/struct.Vec.html#capacity-and-reallocation), etc. None of these correspond to entries in popup.links → no hit rect → click does nothing.

Root cause (suspected)

editor_hover_to_quadraui_rich_text (src/render.rs:1045) populates popup.links from eh.links. That field comes from the markdown parsing pipeline. The markdown parser appears to handle [text](url) syntax (creating links where the visible "text" is registered) but does NOT auto-link bare URL text — even though the same URL might be styled in link colour via MdStyle::LinkUrl / MdStyle::Link.

Look at src/core/markdown/ for the link extraction logic. Likely missing: an auto-link pass that scans rendered lines for https?://[^\s)]+ patterns and registers each as a link if not already covered.

Fix sketches

Option A — auto-link bare URLs at adapter time

In editor_hover_to_quadraui_rich_text (or upstream in markdown rendering), scan each eh.rendered.lines[i] for URL patterns and append a RichTextLink for each match that doesn't already overlap an entry in eh.links. Pros: contained to render layer, doesn't change markdown parser. Cons: regex maintenance, false positives for URLs inside backticks or code spans.

Option B — fix the markdown parser to emit auto-links

Update the markdown parser to recognize bare URLs (CommonMark §6.5) and emit them as links during parsing. Pros: correct by construction, also benefits any other consumer of the parser. Cons: bigger change, needs to honour CommonMark autolink edge cases.

Option C — handled at the LSP layer

rust-analyzer markdown output for Vec does NOT wrap bare URLs in autolink syntax (it uses [url](url) for some, bare text for others). Could pre-process the LSP markdown server-side... no, this is rust-analyzer's content, we can't change it.

Recommended: Option A. Smaller, faster to ship, fixes the user-visible problem.

Related

Repro

  1. cargo run --bin vimcode -- some_rust_file.rs
  2. Hover any symbol with rich rust-analyzer docs containing bare URLs (e.g. Vec, HashMap)
  3. Scroll the popup with arrow keys / mouse wheel
  4. Try to click any URL rendered in link colour
  5. Most do nothing. The [text](url)-style links (where text != url) work. The bare-URL ones don't.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinguiUI/rendering

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions