Skip to content

fix: allow parentheses in terminal link paths#304992

Open
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/terminal-links-parens-in-paths
Open

fix: allow parentheses in terminal link paths#304992
yogeshwaran-c wants to merge 1 commit intomicrosoft:mainfrom
yogeshwaran-c:fix/terminal-links-parens-in-paths

Conversation

@yogeshwaran-c
Copy link
Contributor

What kind of change does this PR introduce?

Bug fix

What is the current behavior?

File paths containing parentheses like ./src/(hello)/[world]/file.tsx (common in Next.js route groups) are not properly recognized as clickable links in the terminal. The path gets split at ( and ) characters because they are excluded from the ExcludedPathCharactersClause regex.

For example, echo "./src/(hello)/[world]/file.tsx" in the terminal produces segmented links instead of one clickable path:

./src/(hello)/[world]/file.tsx
------ ----- - ----- ---------

Closes #212109

What is the new behavior?

Parentheses () are now allowed in the middle of terminal link paths. They remain excluded from start positions via ExcludedStartPathCharactersClause, preventing false positives.

The suffix-based link detection (which handles patterns like file(339,12)) is unaffected since it uses its own dedicated regex that works backwards from detected suffixes.

Additional context

The fix removes () from ExcludedPathCharactersClause and WinExcludedPathCharactersClause (2 lines changed). The ExcludedStartPathCharactersClause variants still exclude ()[] from the first character of a path.

Code pointer from @Tyriar: #212109 (comment)

File paths containing parentheses like `./src/(hello)/[world]/file.tsx`
(common in Next.js route groups) are not recognized as clickable links
in the terminal because `()` characters are excluded from the path
character regex.

Remove `()` from ExcludedPathCharactersClause and
WinExcludedPathCharactersClause so parentheses are allowed in the
middle of paths. They remain excluded from start positions via the
ExcludedStartPathCharactersClause variants, preventing false positives
from parenthesized expressions at the start of potential links.

The suffix-based link detection (which handles patterns like
`file(339,12)`) is unaffected since it uses its own regex that works
backwards from the suffix.

Closes microsoft#212109
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.

Parentheses () and square brackets [] in file names can break terminal links (eg. next.js dynamic file paths)

2 participants