Don't parse wikilink references inside inline code / code blocks (#269)#464
Open
quantamShade0337 wants to merge 2 commits into
Open
Don't parse wikilink references inside inline code / code blocks (#269)#464quantamShade0337 wants to merge 2 commits into
quantamShade0337 wants to merge 2 commits into
Conversation
…Feel-ix-343#269) References were only dropped when fully contained in a single code span (.includes); a [[ ... ]] spanning two inline-code spans slipped through. Filter now drops any reference whose range overlaps a code span/block (new Rangeable::overlaps). Adds a regression test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR improves reference parsing by excluding matches that intersect code blocks/spans, preventing false-positive references created from bracket markers inside inline code.
Changes:
- Added
Rangeable::overlapsto detect intersecting ranges. - Switched reference filtering from “fully included in code block” to “overlaps with code block”.
- Added a regression test ensuring
[[/]]inside inline code doesn’t produce a reference.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+604
to
+613
| fn overlaps(&self, other: &impl Rangeable) -> bool { | ||
| fn before(left: Position, right: Position) -> bool { | ||
| left.line < right.line || (left.line == right.line && left.character < right.character) | ||
| } | ||
|
|
||
| let self_range = self.range(); | ||
| let other_range = other.range(); | ||
|
|
||
| before(self_range.start, other_range.end) && before(other_range.start, self_range.end) | ||
| } |
Comment on lines
+1819
to
+1842
| fn test_settings() -> Settings { | ||
| Settings { | ||
| dailynote: "%Y-%m-%d".into(), | ||
| new_file_folder_path: "".into(), | ||
| daily_notes_folder: "".into(), | ||
| heading_completions: true, | ||
| title_headings: true, | ||
| unresolved_diagnostics: true, | ||
| semantic_tokens: true, | ||
| tags_in_codeblocks: false, | ||
| references_in_codeblocks: false, | ||
| include_md_extension_md_link: false, | ||
| include_md_extension_wikilink: false, | ||
| hover: true, | ||
| case_matching: Case::Smart, | ||
| inlay_hints: true, | ||
| block_transclusion: true, | ||
| block_transclusion_length: EmbeddedBlockTransclusionLength::Full, | ||
| link_filenames_only: false, | ||
| excluded_folders: vec![], | ||
| heading_slug: false, | ||
| callout_completions: true, | ||
| } | ||
| } |
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.
Closes #269.
[[/]]appearing inside an inline code span were parsed as a wikilink reference and flagged "unresolved" — e.g.:Root cause
With
references_in_codeblocks: false, references were dropped only when fully contained in a single code span (code_blocks.iter().any(|cb| cb.includes(it))). Here the reference range spans from one inline-code span (`[[`) to another (`]]`), so it isn't contained in any single span and slipped through.Fix
Added
Rangeable::overlapsand changed the filter to drop any reference whose range overlaps a code span/block. Real[[wikilinks]]outside code are unaffected.Test
Added
wikilink_markers_in_inline_code_are_not_references(the exact issue text → only the real outside[[Note]]parses).cargo testpasses locally./claim #269