Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 10 additions & 6 deletions src/vs/editor/common/languages/linkComputer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,19 @@ 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 didn't begin with them */

// The following three rules make it that ' or " or ` are allowed inside links
// only if the link is wrapped by some other quote character
case CharCode.SingleQuote:
chClass = (linkBeginChCode === CharCode.SingleQuote ? CharacterClass.ForceTermination : CharacterClass.None);
break;
case CharCode.DoubleQuote:
chClass = (linkBeginChCode === CharCode.DoubleQuote ? CharacterClass.ForceTermination : CharacterClass.None);
break;
case CharCode.BackTick:
chClass = (linkBeginChCode === CharCode.BackTick ? CharacterClass.ForceTermination : CharacterClass.None);
if (linkBeginChCode === chCode) {
chClass = CharacterClass.ForceTermination;
} else if (linkBeginChCode === CharCode.SingleQuote || linkBeginChCode === CharCode.DoubleQuote || linkBeginChCode === CharCode.BackTick) {
chClass = CharacterClass.None;
} else {
chClass = CharacterClass.ForceTermination;
}
break;
case CharCode.Asterisk:
// `*` terminates a link if the link began with `*`
Expand Down
16 changes: 12 additions & 4 deletions src/vs/editor/test/common/modes/linkComputer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,18 @@ suite('Editor Modes - Link Computer', () => {
);
});

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 `,
// Removed because of #156875
// 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 `,
// );
// });

test('issue #156875: Links include quotes ', () => {
assertLink(
`"This file has been converted from https://github.com/jeff-hykin/better-c-syntax/blob/master/autogenerated/c.tmLanguage.json",`,
` https://github.com/jeff-hykin/better-c-syntax/blob/master/autogenerated/c.tmLanguage.json `,
);
});
});