Skip to content

Don't parse wikilink references inside inline code / code blocks (#269)#464

Open
quantamShade0337 wants to merge 2 commits into
Feel-ix-343:mainfrom
quantamShade0337:fix/269-references-in-inline-code
Open

Don't parse wikilink references inside inline code / code blocks (#269)#464
quantamShade0337 wants to merge 2 commits into
Feel-ix-343:mainfrom
quantamShade0337:fix/269-references-in-inline-code

Conversation

@quantamShade0337

Copy link
Copy Markdown

Closes #269.

[[ / ]] appearing inside an inline code span were parsed as a wikilink reference and flagged "unresolved" — e.g.:

* DO NOT use the square bracket `[[` and `]]` markers

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::overlaps and 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 test passes locally.

/claim #269

…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>
Copilot AI review requested due to automatic review settings June 4, 2026 03:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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::overlaps to 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 thread src/vault/mod.rs
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 thread src/vault/mod.rs
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,
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unresolved reference when using [[ and ]]

2 participants