Skip to content

Commit e777525

Browse files
authored
Allow quotes in links if the link didn't begin with quotes (microsoft#153857)
Fixes microsoft#151631: Allow quotes in links if the link didn't begin with quotes
1 parent 88ffbc7 commit e777525

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/vs/editor/common/languages/linkComputer.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,15 +258,15 @@ export class LinkComputer {
258258
case CharCode.CloseCurlyBrace:
259259
chClass = (hasOpenCurlyBracket ? CharacterClass.None : CharacterClass.ForceTermination);
260260
break;
261-
/* The following three rules make it that ' or " or ` are allowed inside links if the link began with a different one */
261+
/* The following three rules make it that ' or " or ` are allowed inside links if the link didn't begin with them */
262262
case CharCode.SingleQuote:
263-
chClass = (linkBeginChCode === CharCode.DoubleQuote || linkBeginChCode === CharCode.BackTick) ? CharacterClass.None : CharacterClass.ForceTermination;
263+
chClass = (linkBeginChCode === CharCode.SingleQuote ? CharacterClass.ForceTermination : CharacterClass.None);
264264
break;
265265
case CharCode.DoubleQuote:
266-
chClass = (linkBeginChCode === CharCode.SingleQuote || linkBeginChCode === CharCode.BackTick) ? CharacterClass.None : CharacterClass.ForceTermination;
266+
chClass = (linkBeginChCode === CharCode.DoubleQuote ? CharacterClass.ForceTermination : CharacterClass.None);
267267
break;
268268
case CharCode.BackTick:
269-
chClass = (linkBeginChCode === CharCode.SingleQuote || linkBeginChCode === CharCode.DoubleQuote) ? CharacterClass.None : CharacterClass.ForceTermination;
269+
chClass = (linkBeginChCode === CharCode.BackTick ? CharacterClass.ForceTermination : CharacterClass.None);
270270
break;
271271
case CharCode.Asterisk:
272272
// `*` terminates a link if the link began with `*`

src/vs/editor/test/common/modes/linkComputer.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,4 +258,11 @@ suite('Editor Modes - Link Computer', () => {
258258
'https://site.web/page.html '
259259
);
260260
});
261+
262+
test('issue #151631: Link parsing stoped where comments include a single quote ', () => {
263+
assertLink(
264+
`aa https://regexper.com/#%2F''%2F aa`,
265+
` https://regexper.com/#%2F''%2F `,
266+
);
267+
});
261268
});

0 commit comments

Comments
 (0)