fix: ignore wiki-links overlapping inline code (fixes #269) - #478
Open
SoulSniper-V2 wants to merge 1 commit into
Open
fix: ignore wiki-links overlapping inline code (fixes #269)#478SoulSniper-V2 wants to merge 1 commit into
SoulSniper-V2 wants to merge 1 commit into
Conversation
When references_in_codeblocks is disabled, filter references that overlap any inline or fenced code block instead of requiring full containment. This prevents false unresolved wiki-links when `[[` and `]]` appear in separate inline-code spans, as reported in Feel-ix-343#269.
There was a problem hiding this comment.
Pull request overview
Fixes incorrect wiki-link diagnostics by excluding references that overlap inline/fenced code spans when references_in_codeblocks is disabled, addressing the [[ … ]]-split-across-inline-code-spans repro from #269.
Changes:
- Add
Rangeable::overlapsto detect partial range intersection. - Change reference filtering to drop references that overlap any parsed code block when
references_in_codeblocks = false. - Add regression tests covering split-marker and adjacency edge cases.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+1814
to
+1825
| use tower_lsp::lsp_types::{ClientCapabilities, Position, Range}; | ||
|
|
||
| use crate::config::Settings; | ||
| use crate::vault::{HeadingLevel, MyRange, ReferenceData}; | ||
| use crate::vault::{MDLinkReferenceDefinition, Refname}; | ||
|
|
||
| use super::Reference::*; | ||
| use super::{MDFile, MDFootnote, MDHeading, MDIndexedBlock, MDTag, Reference, Referenceable}; | ||
|
|
||
| fn default_settings() -> Settings { | ||
| Settings::new(Path::new("."), &ClientCapabilities::default()).unwrap() | ||
| } |
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.
Fixes #269
/claim #269
Summary
Wiki-link detection used
codeblock.includes(reference), which only drops references fully contained in a code span. The#269repro puts`[[`and`]]`in separate inline-code spans, so the regex still matches[[…]]across the gap and diagnostics mark it unresolved.This PR filters references that overlap any inline or fenced code block when
references_in_codeblocksis false.Changes
Rangeable::overlapsfor partial range intersectionreference_overlaps_codeblockhelper used by reference filteringProof
Before (conceptual):
* DO NOT use the square bracket[[and]]markers→ false unresolved wiki-link` and `After: no references parsed from that line (default settings)
Still works:
This is a [[link]]→ one reference`example`[[note]]→noteremains a referencereferences_in_codeblocks = true, the spanning match is preserved (existing opt-in)Validation
cargo test wiki_link(local toolchain install was incomplete; CI should run full suite)vault_tests:wiki_link_markers_in_separate_inline_code_spans_are_not_referenceswiki_link_inside_inline_code_is_not_a_referencewiki_link_adjacent_to_inline_code_is_still_a_referencewiki_link_spanning_inline_code_is_kept_when_references_in_codeblocks_enabledMade with Cursor