Skip to content

Commit

Permalink
Fix on linkComputer.ts to address single quote parse issue
Browse files Browse the repository at this point in the history
  • Loading branch information
kalebers committed Dec 31, 2024
1 parent 6d6cfdc commit af6af85
Showing 1 changed file with 9 additions and 3 deletions.
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

0 comments on commit af6af85

Please sign in to comment.