fix(lsp): match wikilink anchors against raw heading text
`[[Page#Heading text]]` parsed the anchor as the literal string after `#`, but the index stored each heading's anchor as `slugify(title)`. The two never compared equal, so every TOC-style anchor link (`[[#1. Topologia atual]]`, etc.) was reported as a broken anchor and goto-definition couldn't jump to the right heading either. Slugify the request before comparing — `slugify` is idempotent on valid-slug input, so the same code path now accepts both `[[Page#some-heading]]` (slug form) and `[[Page#Some Heading]]` (raw text). Applied to diagnostics, navigation, and hover preview so all three agree on what "an anchor matches a heading" means. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -212,7 +212,8 @@ pub fn classify_link(
|
||||
}
|
||||
|
||||
fn anchor_resolves_on(page: &crate::index::IndexedPage, anchor: &str) -> bool {
|
||||
page.headings.iter().any(|h| h.anchor == anchor) || page.tags.iter().any(|t| t.name == anchor)
|
||||
page.find_heading_by_anchor(anchor).is_some()
|
||||
|| page.tags.iter().any(|t| t.name == anchor)
|
||||
}
|
||||
|
||||
/// Same classification as [`classify_link`] but driven from the cached
|
||||
|
||||
Reference in New Issue
Block a user