Skip to content

[issues/310] Fix navigation for links wrapped in backticks, quotes, and angle brackets#314

Merged
couimet merged 4 commits intomainfrom
issues/310
Feb 7, 2026
Merged

[issues/310] Fix navigation for links wrapped in backticks, quotes, and angle brackets#314
couimet merged 4 commits intomainfrom
issues/310

Conversation

@couimet
Copy link
Owner

@couimet couimet commented Feb 7, 2026

Summary

Links wrapped in common text wrapper characters (backticks, single quotes, double quotes, angle brackets) failed navigation because the wrapper character was captured as part of the file path. The link detection regex used \S (non-whitespace) for path matching, which matches all of these characters. This PR replaces \S with a PATH_CHAR class that excludes wrapper characters from path matching, fixing navigation across all wrapping scenarios users encounter in markdown, prose, and AI scratchpads.

Changes

  • Introduced PATH_CHAR constant [^\s\x60\x27\x22<>] that excludes backtick, single quote, double quote, and angle brackets from path character matching
  • Replaced \S with PATH_CHAR in both single-char and multi-char hash delimiter path patterns
  • Parentheses and brackets are intentionally NOT excluded — they appear in real directory/file names
  • Added 19 new tests covering all wrapper types: backtick (9), single quote (2), double quote (2), angle bracket (2), parentheses/brackets NOT excluded (2), mixed scenarios (2)
  • Added CHANGELOG entry under [Unreleased] Fixed

Design Decision

The excluded characters (`, ', ", <, >) are:

  • Invalid on Windows (", <, >) or cause shell issues (`, ')
  • Never/practically never in real file paths
  • The same tradeoff as the existing URL character exclusion

Parentheses () and brackets [] are intentionally kept as valid path characters because they appear in real directory names (e.g., "My Documents (backup)", "[archived]").

Test Plan

  • All 1407 existing tests pass (no regressions)
  • 19 new tests for wrapper character handling
  • Tests cover: full wrapping, one-sided wrapping, triple backticks, inline prose, multiple links, column ranges, multi-char hash delimiters, mixed wrapper types in one line
  • Tests document intentional behavior for parentheses/brackets

Documentation

  • CHANGELOG.md: Entry added under [Unreleased] Fixed
  • README.md: Not needed (bug fix, no new feature/command/setting)

Related

Summary by CodeRabbit

Bug Fixes

  • Fixed navigation for RangeLinks wrapped in backticks, single/double quotes, or angle brackets. Wrapper characters are no longer incorrectly captured as part of the path.

Tests

  • Added comprehensive test coverage for wrapped link detection across various wrapper character scenarios.

Links wrapped in backticks, quotes, or angle brackets failed navigation because the
wrapper character was captured as part of the path. The detection regex used \S
(non-whitespace) which matches all of these, resulting in paths like "`file.ts" or
"'file.ts" that can't be resolved.

Replaces \S with a PATH_CHAR class [^\s\x60\x27\x22<>] that excludes common wrapper
characters (backtick, single quote, double quote, angle brackets) from path matching.
These are never/practically never in real file paths and are the same tradeoff as the
existing URL character exclusion.

Parentheses and brackets are intentionally NOT excluded — they appear in real paths.
Verifies the PATH_CHAR fix from the previous commit works correctly across
all wrapper characters (backtick, single quote, double quote, angle brackets)
and all wrapping scenarios users encounter in markdown, prose, and scratchpads.

Also documents that parentheses and brackets are intentionally NOT excluded
since they appear in real directory/file names.
… fix

Documents the broader fix covering all wrapper characters (backtick, single quote,
double quote, angle brackets) under the [Unreleased] Fixed section.
@coderabbitai
Copy link

coderabbitai bot commented Feb 7, 2026

Walkthrough

This PR fixes navigation failures when RangeLinks are wrapped in markdown delimiter characters (backticks, quotes, angle brackets). It introduces a new PATH_CHAR pattern that explicitly excludes wrapper characters from path matching, replacing the previous non-whitespace pattern, and adds comprehensive test coverage for various wrapping scenarios.

Changes

Cohort / File(s) Summary
Path Pattern Logic
packages/rangelink-core-ts/src/utils/buildLinkPattern.ts
Introduced PATH_CHAR pattern to define valid path characters, explicitly excluding backticks, quotes, and angle brackets. Replaced \S pattern matching with PATH_CHAR in single- and multi-char hash path construction to prevent wrapper characters from being captured as part of the path.
Test Suite
packages/rangelink-core-ts/src/__tests__/utils/buildLinkPattern.test.ts
Added comprehensive "wrapper character handling" test suite covering backticks, single/double quotes, angle brackets, and mixed wrappers. Tests include edge cases: triple backticks, multi-char delimiters, wrapped columns, asymmetrical wrapper pairs, and parentheses/brackets in paths, across single and multi-line contexts.
Documentation
packages/rangelink-vscode-extension/CHANGELOG.md
Documented fix for wrapped link navigation: RangeLinks wrapped in backticks, quotes, or angle brackets now resolve correctly by excluding wrapper characters from path matching.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 A rabbit hops through wrapped-up links,
Where backticks once broke navigation's chain.
Now PATH_CHAR dances, stripped of tricks,
Wrapper characters fall away like rain.
Links resolve true—no more ` in sight! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly references issue #310 and accurately summarizes the main change: fixing navigation for links wrapped in backticks, quotes, and angle brackets.
Linked Issues check ✅ Passed The PR successfully implements the coding requirement from #310: introducing PATH_CHAR pattern to exclude wrapper characters (backticks, quotes, angle brackets) from path matching, with comprehensive test coverage.
Out of Scope Changes check ✅ Passed All changes are directly related to fixing issue #310: modifications to buildLinkPattern.ts implement the fix, tests in buildLinkPattern.test.ts verify the functionality, and CHANGELOG.md documents the change.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issues/310

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@couimet couimet merged commit 4cad8a0 into main Feb 7, 2026
2 checks passed
@couimet couimet deleted the issues/310 branch February 7, 2026 01:17
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.

Navigation fails when RangeLink link is wrapped in markdown backticks

1 participant