Skip to content

fix: ignore wiki-links overlapping inline code (fixes #269) - #478

Open
SoulSniper-V2 wants to merge 1 commit into
Feel-ix-343:mainfrom
SoulSniper-V2:fix/issue-269-wikilink-inline-code
Open

fix: ignore wiki-links overlapping inline code (fixes #269)#478
SoulSniper-V2 wants to merge 1 commit into
Feel-ix-343:mainfrom
SoulSniper-V2:fix/issue-269-wikilink-inline-code

Conversation

@SoulSniper-V2

Copy link
Copy Markdown

Fixes #269

/claim #269

Summary

Wiki-link detection used codeblock.includes(reference), which only drops references fully contained in a code span. The #269 repro 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_codeblocks is false.

Changes

  • Add Rangeable::overlaps for partial range intersection
  • Add reference_overlaps_codeblock helper used by reference filtering
  • Add regression tests copied from the issue repro and adjacent edge cases

Proof

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]]note remains a reference
  • With references_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)
  • Targeted tests added in vault_tests:
    • wiki_link_markers_in_separate_inline_code_spans_are_not_references
    • wiki_link_inside_inline_code_is_not_a_reference
    • wiki_link_adjacent_to_inline_code_is_still_a_reference
    • wiki_link_spanning_inline_code_is_kept_when_references_in_codeblocks_enabled

Made with Cursor

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.
Copilot AI review requested due to automatic review settings June 26, 2026 11:02

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

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::overlaps to 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 thread src/vault/mod.rs
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()
}
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