Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix on linkComputer.ts file on regex and logic in order to address single quote inside link issue while parsing #237126

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/vs/editor/common/languages/linkComputer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ function getClassifier(): CharacterClassifier<CharacterClass> {
_classifier = new CharacterClassifier<CharacterClass>(CharacterClass.None);

// allow-any-unicode-next-line
const FORCE_TERMINATION_CHARACTERS = ' \t<>\'\"、。。、,.:;‘〈「『〔([{「」}])〕』」〉’`~…';
const FORCE_TERMINATION_CHARACTERS = '\t<>\'\"、。。、,.:;‘〈「『〔([{「」}])〕』」〉’`~…\'';
for (let i = 0; i < FORCE_TERMINATION_CHARACTERS.length; i++) {
_classifier.set(FORCE_TERMINATION_CHARACTERS.charCodeAt(i), CharacterClass.ForceTermination);
}
Expand Down Expand Up @@ -259,14 +259,20 @@ export class LinkComputer {
chClass = (hasOpenCurlyBracket ? CharacterClass.None : CharacterClass.ForceTermination);
break;

// The following three rules make it that ' or " or ` are allowed inside links
// The following rules allow `'`, `"`, or `` ` `` inside links
// only if the link is wrapped by some other quote character
case CharCode.SingleQuote:
case CharCode.DoubleQuote:
case CharCode.BackTick:
if (linkBeginChCode === chCode) {
// If the link started with this character, terminate the link
chClass = CharacterClass.ForceTermination;
} else if (linkBeginChCode === CharCode.SingleQuote || linkBeginChCode === CharCode.DoubleQuote || linkBeginChCode === CharCode.BackTick) {
} else if (
linkBeginChCode === CharCode.SingleQuote ||
linkBeginChCode === CharCode.DoubleQuote ||
linkBeginChCode === CharCode.BackTick
) {
// Allow internal quotes if link began with a different quote
chClass = CharacterClass.None;
} else {
chClass = CharacterClass.ForceTermination;
Expand Down