Change:
Does this issue occur when all extensions are disabled?: Yes VS Code Version: 1.61.2 OS Version: macOS Big Sur Steps to Reproduce: a new markdown file. ! But according to it isn't necessary to escape spaces when the text is enclosed in :
Removing help wanted since this is a bit more complicated than anticipated
Thanks!

Discussion:
const linkPattern = /([((![[^]]*?](s*)([^s()]+?)s*)]|(?:]|[^]])*])(s*)(([^s()]|([^s()]*?))+)s*(".*?")?)/g; /** <ins> * Matches `[text](<link>)` */ const linkPatternAngle = /([((![[^]]*?](s*)([^s()]+?)s*)]|(?:]|[^]])*])(s*<)(([^<>]|([^s()]*?))+)>s*(".*?")?)/g; /** </ins> * Matches `[text][ref]` or `[shorthand]` */ const referenceLinkPattern = /(^|[^]])(?:(?:([((?:]|[^]])+)][s*?)([^s]]*?)]|[s*?([^s]]*?)])(?![:(]))/gm;

private *getInlineLinks(document: SkinnyTextDocument, noLinkRanges: NoLinkRanges): Iterable<MdLink> { const text = document.getText(); <ins> for (const match of text.matchAll(linkPatternAngle)) { const matchImageData = match[4] && extractDocumentLink(document, match[3].length + 1, match[4], match.index); if (matchImageData && !noLinkRanges.contains(matchImageData.source.hrefRange)) { yield matchImageData; } const matchLinkData = extractDocumentLink(document, match[1].length, match[5], match.index); if (matchLinkData && !noLinkRanges.contains(matchLinkData.source.hrefRange)) { yield matchLinkData; } } </ins> for (const match of text.matchAll(linkPattern)) { const matchImageData = match[4] && extractDocumentLink(document, match[3].length + 1, match[4], match.index); if (matchImageData && !noLinkRanges.contains(matchImageData.source.hrefRange)) { yield matchImageData; } <ins> if (match[5] !== undefined && match[5].startsWith('<')) { continue; } </ins> const matchLinkData = extractDocumentLink(document, match[1].length, match[5], match.index); if (matchLinkData && !noLinkRanges.contains(matchLinkData.source.hrefRange)) { yield matchLinkData;

return provider.provideDocumentLinks(doc, noopToken); } <ins> function assertLinksEqual(actualLinks: readonly vscode.DocumentLink[], expectedRanges: readonly vscode.Range[]) { assert.strictEqual(actualLinks.length, expectedRanges.length); for (let i = 0; i < actualLinks.length; ++i) { assertRangeEqual(actualLinks[i].range, expectedRanges[i], `Range ${i} to be equal`); } } </ins> suite('markdown.DocumentLinkProvider', () => { test('Should not return anything for empty document', async () => { const links = await getLinksForFile('');

test('Should detect basic http links', async () => { const links = await getLinksForFile('a [b](https://example.com) c'); <del> assert.strictEqual(links.length, 1); const [link] = links; assertRangeEqual(link.range, new vscode.Range(0, 6, 0, 25)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 6, 0, 25) ]); </ins> }); test('Should detect basic workspace links', async () => { { const links = await getLinksForFile('a [b](./file) c'); <del> assert.strictEqual(links.length, 1); const [link] = links; assertRangeEqual(link.range, new vscode.Range(0, 6, 0, 12)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 6, 0, 12) ]); </ins> } { const links = await getLinksForFile('a [b](file.png) c'); <del> assert.strictEqual(links.length, 1); const [link] = links; assertRangeEqual(link.range, new vscode.Range(0, 6, 0, 14)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 6, 0, 14) ]); </ins> } }); test('Should detect links with title', async () => { const links = await getLinksForFile('a [b](https://example.com "abc") c'); <del> assert.strictEqual(links.length, 1); const [link] = links; assertRangeEqual(link.range, new vscode.Range(0, 6, 0, 25)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 6, 0, 25) ]); </ins> }); test('Should handle links with escaped characters in name (#35245)', async () => { const links = await getLinksForFile('a [b]](./file)'); <del> assert.strictEqual(links.length, 1); const [link] = links; assertRangeEqual(link.range, new vscode.Range(0, 8, 0, 14)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 8, 0, 14) ]); </ins> }); test('Should handle links with balanced parens', async () => { { const links = await getLinksForFile('a [b](https://example.com/a()c) c'); <del> assert.strictEqual(links.length, 1); const [link] = links; assertRangeEqual(link.range, new vscode.Range(0, 6, 0, 30)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 6, 0, 30) ]); </ins> } { const links = await getLinksForFile('a [b](https://example.com/a(b)c) c'); <del> assert.strictEqual(links.length, 1); const [link] = links; assertRangeEqual(link.range, new vscode.Range(0, 6, 0, 31)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 6, 0, 31) ]); </ins> } { // #49011 const links = await getLinksForFile('[A link](http://ThisUrlhasParens/A_link(in_parens))'); <del> assert.strictEqual(links.length, 1); const [link] = links; assertRangeEqual(link.range, new vscode.Range(0, 9, 0, 50)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 9, 0, 50) ]); </ins> } }); test('Should handle two links without space', async () => { const links = await getLinksForFile('a ([test](test)[test2](test2)) c'); <del> assert.strictEqual(links.length, 2); const [link1, link2] = links; assertRangeEqual(link1.range, new vscode.Range(0, 10, 0, 14)); assertRangeEqual(link2.range, new vscode.Range(0, 23, 0, 28)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 10, 0, 14), new vscode.Range(0, 23, 0, 28) ]); </ins> }); test('should handle hyperlinked images (#49238)', async () => { { const links = await getLinksForFile('[![alt text](image.jpg)](https://example.com)'); <del> assert.strictEqual(links.length, 2); const [link1, link2] = links; assertRangeEqual(link1.range, new vscode.Range(0, 13, 0, 22)); assertRangeEqual(link2.range, new vscode.Range(0, 25, 0, 44)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 13, 0, 22), new vscode.Range(0, 25, 0, 44) ]); </ins> } { const links = await getLinksForFile('[![a]( whitespace.jpg )]( https://whitespace.com )'); <del> assert.strictEqual(links.length, 2); const [link1, link2] = links; assertRangeEqual(link1.range, new vscode.Range(0, 7, 0, 21)); assertRangeEqual(link2.range, new vscode.Range(0, 26, 0, 48)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 7, 0, 21), new vscode.Range(0, 26, 0, 48) ]); </ins> } { const links = await getLinksForFile('[![a](img1.jpg)](file1.txt) text [![a](img2.jpg)](file2.txt)'); <del> assert.strictEqual(links.length, 4); const [link1, link2, link3, link4] = links; assertRangeEqual(link1.range, new vscode.Range(0, 6, 0, 14)); assertRangeEqual(link2.range, new vscode.Range(0, 17, 0, 26)); assertRangeEqual(link3.range, new vscode.Range(0, 39, 0, 47)); assertRangeEqual(link4.range, new vscode.Range(0, 50, 0, 59)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 6, 0, 14), new vscode.Range(0, 17, 0, 26), new vscode.Range(0, 39, 0, 47), new vscode.Range(0, 50, 0, 59), ]); </ins> } });

'[a]: <b c>', '[b]: <cd>', )); <del> assert.strictEqual(links.length, 2); const [link1, link2] = links; assertRangeEqual(link1.range, new vscode.Range(0, 6, 0, 9)); assertRangeEqual(link2.range, new vscode.Range(1, 6, 1, 8)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 6, 0, 9), new vscode.Range(1, 6, 1, 8), ]); </ins> }); test('Should only find one link for reference sources [a]: source (#141285)', async () => {

`[good]`, `[good]: http://example.com`, )); <del> assert.strictEqual(links.length, 1); assertRangeEqual(links[0].range, new vscode.Range(2, 8, 2, 26)); // Should only find the definition </del> <ins> assertLinksEqual(links, [ new vscode.Range(2, 8, 2, 26) // Should only find the definition ]); </ins> }); test('Should not consider links in code fenced with backticks', async () => {

test('Should find autolinks', async () => { const links = await getLinksForFile('pre <http://example.com> post'); <del> assert.strictEqual(links.length, 1); const link = links[0]; assertRangeEqual(link.range, new vscode.Range(0, 5, 0, 23)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 5, 0, 23) ]); </ins> }); test('Should not detect links inside html comment blocks', async () => {

``, `[x]: http://example.com` )); <del> assert.strictEqual(links.length, 1); assertRangeEqual(links[0].range, new vscode.Range(7, 5, 7, 23)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(7, 5, 7, 23) ]); </ins> }); test('Should still find links on line with checkbox', async () => {

``, `[x]: http://example.com` )); <del> assert.strictEqual(links.length, 4); assertRangeEqual(links[0].range, new vscode.Range(0, 7, 0, 8)); assertRangeEqual(links[1].range, new vscode.Range(1, 7, 1, 8)); assertRangeEqual(links[2].range, new vscode.Range(2, 6, 2, 7)); assertRangeEqual(links[3].range, new vscode.Range(4, 5, 4, 23)); </del> <ins> assertLinksEqual(links, [ new vscode.Range(0, 7, 0, 8), new vscode.Range(1, 7, 1, 8), new vscode.Range(2, 6, 2, 7), new vscode.Range(4, 5, 4, 23), ]); }); test('Should find link only within angle brackets.', async () => { const links = await getLinksForFile(joinLines( `[link](<path>)` )); assertLinksEqual(links, [new vscode.Range(0, 8, 0, 12)]); }); test('Should find link within angle brackets even with link title.', async () => { const links = await getLinksForFile(joinLines( `[link](<path> "test title")` )); assertLinksEqual(links, [new vscode.Range(0, 8, 0, 12)]); }); test('Should find link within angle brackets even with surrounding spaces.', async () => { const links = await getLinksForFile(joinLines( `[link]( <path> )` )); assertLinksEqual(links, [new vscode.Range(0, 9, 0, 13)]); }); test('Should find link within angle brackets for image hyperlinks.', async () => { const links = await getLinksForFile(joinLines( `![link](<path>)` )); assertLinksEqual(links, [new vscode.Range(0, 9, 0, 13)]); }); test('Should find link with spaces in angle brackets for image hyperlinks with titles.', async () => { const links = await getLinksForFile(joinLines( `![link](< path > "test")` )); assertLinksEqual(links, [new vscode.Range(0, 9, 0, 15)]); }); test('Should not find link due to incorrect angle bracket notation or usage.', async () => { const links = await getLinksForFile(joinLines( `[link](<path )`, `[link](<> path>)`, `[link](> path)`, )); assert.strictEqual(links.length, 0); }); test('Should find link within angle brackets even with space inside link.', async () => { const links = await getLinksForFile(joinLines( `[link](<pa th>)` )); assertLinksEqual(links, [new vscode.Range(0, 8, 0, 13)]); </ins> }); });