Skip to content

Fix: Linkify markdown links with no space before [ when link text contains spaces#319073

Open
tamuratak wants to merge 1 commit into
microsoft:mainfrom
tamuratak:linkify_and_space_b
Open

Fix: Linkify markdown links with no space before [ when link text contains spaces#319073
tamuratak wants to merge 1 commit into
microsoft:mainfrom
tamuratak:linkify_and_space_b

Conversation

@tamuratak
Copy link
Copy Markdown
Contributor

Close #318866

Fix: Linkify markdown links with no space before [ when link text contains spaces

When a markdown link is immediately preceded by text (e.g. abc[src/main.ts 17](src/main.ts#L17)), the Linkifier's whitespace-based tokenization splits the input such that the [ never lands at the start of a token, preventing the state machine from entering PotentialLink mode. This fix detects an unclosed [ within accumulated Word state tokens, splits the text at the bracket, linkifies the prefix as a normal word, and transitions the remainder into PotentialLink state.

Created with GitHub Copilot + MiMO-V2.5-Pro

CC: @vijayupadya @justschen

Copilot AI review requested due to automatic review settings May 29, 2026 23:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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.

Adds handling in the stateful linkifier for markdown links that are immediately preceded by text without an intervening space (e.g. abc[file.ts](file.ts)), so the preceding text is emitted as its own part and the link is still detected.

Changes:

  • When accumulating a Word and whitespace is encountered, detect an unclosed [ inside the accumulated text and split the buffer into a preceding text portion plus a PotentialLink starting at [.
  • Add tests covering both single-token and incrementally-streamed inputs with markdown links preceded by text.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
extensions/copilot/src/extension/linkify/common/linkifier.ts Splits accumulated word at [ to start a PotentialLink state when the bracket is unclosed.
extensions/copilot/src/extension/linkify/test/node/linkifier.spec.ts Adds tests for markdown links preceded by text, in both single and split-token scenarios.

@tamuratak tamuratak requested a review from Copilot May 29, 2026 23:27
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.

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.

([src/main.ts 17](src/main.ts#17)) is not properly linkified in Chat view

3 participants