Skip to content

Commit

Permalink
Allow quotes in links if the link didn't begin with quotes (#153857)
Browse files Browse the repository at this point in the history
Fixes #151631: Allow quotes in links if the link didn't begin with quotes
  • Loading branch information
alexdima committed Jun 30, 2022
1 parent 88ffbc7 commit e777525
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/vs/editor/common/languages/linkComputer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,15 @@ export class LinkComputer {
case CharCode.CloseCurlyBrace:
chClass = (hasOpenCurlyBracket ? CharacterClass.None : CharacterClass.ForceTermination);
break;
/* The following three rules make it that ' or " or ` are allowed inside links if the link began with a different one */
/* The following three rules make it that ' or " or ` are allowed inside links if the link didn't begin with them */
case CharCode.SingleQuote:
chClass = (linkBeginChCode === CharCode.DoubleQuote || linkBeginChCode === CharCode.BackTick) ? CharacterClass.None : CharacterClass.ForceTermination;
chClass = (linkBeginChCode === CharCode.SingleQuote ? CharacterClass.ForceTermination : CharacterClass.None);
break;
case CharCode.DoubleQuote:
chClass = (linkBeginChCode === CharCode.SingleQuote || linkBeginChCode === CharCode.BackTick) ? CharacterClass.None : CharacterClass.ForceTermination;
chClass = (linkBeginChCode === CharCode.DoubleQuote ? CharacterClass.ForceTermination : CharacterClass.None);
break;
case CharCode.BackTick:
chClass = (linkBeginChCode === CharCode.SingleQuote || linkBeginChCode === CharCode.DoubleQuote) ? CharacterClass.None : CharacterClass.ForceTermination;
chClass = (linkBeginChCode === CharCode.BackTick ? CharacterClass.ForceTermination : CharacterClass.None);
break;
case CharCode.Asterisk:
// `*` terminates a link if the link began with `*`
Expand Down
7 changes: 7 additions & 0 deletions src/vs/editor/test/common/modes/linkComputer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,4 +258,11 @@ suite('Editor Modes - Link Computer', () => {
'https://site.web/page.html '
);
});

test('issue #151631: Link parsing stoped where comments include a single quote ', () => {
assertLink(
`aa https://regexper.com/#%2F''%2F aa`,
` https://regexper.com/#%2F''%2F `,
);
});
});

0 comments on commit e777525

Please sign in to comment.