fix(lsp): resolve links from anywhere in the link, including the title
goto-definition (and references/hover) reported "No locations found" when the cursor was on the *description* of a piped link — `[[target|Title]]` or `[desc](url)` — and only worked over the target/location part. find_in_inlines descended into the link's description and returned its inner Text node, so the nav handlers saw a Text (not a WikiLink/ ExternalLink) and bailed. A link is an atomic unit for navigation: stop descending into descriptions so a hit anywhere in the link returns the link node itself. Adds a navigation regression test for cursor-on-title. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -106,14 +106,11 @@ fn find_in_inlines(inlines: &[InlineNode], line: u32, col: u32) -> Option<&Inlin
|
||||
InlineNode::Superscript(s) => find_in_inlines(&s.children, line, col),
|
||||
InlineNode::Subscript(s) => find_in_inlines(&s.children, line, col),
|
||||
InlineNode::Color(c) => find_in_inlines(&c.children, line, col),
|
||||
InlineNode::WikiLink(w) => w
|
||||
.description
|
||||
.as_ref()
|
||||
.and_then(|d| find_in_inlines(d, line, col)),
|
||||
InlineNode::ExternalLink(e) => e
|
||||
.description
|
||||
.as_ref()
|
||||
.and_then(|d| find_in_inlines(d, line, col)),
|
||||
// Links are an atomic unit for navigation: a cursor anywhere in
|
||||
// `[[target|description]]` (or `[desc](url)`) should resolve the
|
||||
// link itself. Don't descend into the description — returning its
|
||||
// inner Text node leaves goto-definition/references/hover with
|
||||
// nothing to act on ("No locations found" when on the title).
|
||||
_ => None,
|
||||
};
|
||||
return Some(deeper.unwrap_or(n));
|
||||
|
||||
Reference in New Issue
Block a user