Terminate URL detection at CJK full-width ! and ?#314618
Open
yogeshwaran-c wants to merge 1 commit into
Open
Conversation
The link computer's FORCE_TERMINATION_CHARACTERS already includes CJK sentence-enders such as the full-width period (。) and comma (,), but omitted the full-width exclamation mark (!, U+FF01) and question mark (?, U+FF1F). When a URL was followed by either of these in CJK text, the punctuation was incorrectly absorbed into the detected link. Fixes microsoft#303101
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adjusts VS Code’s link detection (used by both the editor link computer and terminal URL link detection) so that CJK full-width exclamation (!, U+FF01) and question (?, U+FF1F) characters forcibly terminate a detected URL, preventing trailing punctuation from being incorrectly included in the clickable link.
Changes:
- Add
!and?toFORCE_TERMINATION_CHARACTERSin the link computer classifier. - Add editor unit tests to verify URLs terminate before
!/?in CJK text. - Add terminal URL detector unit test cases mirroring the reported reproduction.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/vs/workbench/contrib/terminalContrib/links/test/browser/terminalUriLinkDetector.test.ts | Adds terminal link detection test cases ensuring !/? are excluded from detected URLs. |
| src/vs/editor/test/common/modes/linkComputer.test.ts | Adds editor link computer tests validating URL termination at full-width ! and ?. |
| src/vs/editor/common/languages/linkComputer.ts | Extends the force-termination character set to include full-width ! and ?. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In CJK contexts, when a URL was followed by a full-width exclamation mark (
!, U+FF01) or full-width question mark (?, U+FF1F), the punctuation was incorrectly absorbed into the detected link, producing a broken URL.The link computer's
FORCE_TERMINATION_CHARACTERSalready includes the full-width period (。), comma (,), and other CJK sentence-enders, but omitted these two. Adding them as force-termination characters fixes the issue while preserving existing CJK URL behavior (e.g. Wikipedia URLs that legitimately contain【】,《》,"").Fixes #303101
Test plan
linkComputer.test.tscovering!and?after URLs in CJK textterminalUriLinkDetector.test.tsmirroring the issue's exact reproduction (https://github.com/lobehub/lobehub/pull/13120!)