Change:
Type: <bBug</b( it into a markdown file Bug The inserted markdown link is not valid because of the mismatched parens In cases like this, we can either escape the with or wrap the entire url in : VS Code version: Code - Insiders 1.81.0-insider (Universal) (, 2023-07-25T08:15:40.243Z) OS version: Darwin x64 22.5.0 Modes: <details<summarySystem Info</summary </details<!-- generated by issue reporter --
! looks correct in that it displays with but the rightmost parenthesis is still highlighted red. Is this the desired behavior
Can you please open a new issue for that? I think bracket pair colorization isn't working properly in this case (the markdown grammar seems to get it right)

Discussion:
if (pasteAsMarkdownLink) { snippet.appendText('['); snippet.appendPlaceholder(escapeBrackets(title) || 'Title', placeholderValue); <del> snippet.appendText(isExternalLink ? `](${uriString})` : `](${escapeMarkdownLinkPath(mdPath)})`); </del> <ins> snippet.appendText(`](${escapeMarkdownLinkPath(isExternalLink ? uriString : mdPath, isExternalLink)})`); </ins> } else { <del> snippet.appendText(isExternalLink ? uriString : escapeMarkdownLinkPath(mdPath)); </del> <ins> snippet.appendText((escapeMarkdownLinkPath(isExternalLink ? uriString : mdPath, isExternalLink))); </ins> } return snippet; }

const placeholderText = escapeBrackets(title) || options?.placeholderText || 'Alt text'; const placeholderIndex = typeof options?.placeholderStartIndex !== 'undefined' ? options?.placeholderStartIndex + i : (placeholderValue === 0 ? undefined : placeholderValue); snippet.appendPlaceholder(placeholderText, placeholderIndex); <del> snippet.appendText(`](${escapeMarkdownLinkPath(mdPath)})`); </del> <ins> snippet.appendText(`](${escapeMarkdownLinkPath(mdPath, isExternalLink)})`); </ins> } else { <del> snippet.appendText(escapeMarkdownLinkPath(mdPath)); </del> <ins> snippet.appendText(escapeMarkdownLinkPath(mdPath, isExternalLink)); </ins> } } } else {

return encodeURI(attr).replaceAll('"', '&quot;'); } <del> function escapeMarkdownLinkPath(mdPath: string): string { </del> <ins> function escapeMarkdownLinkPath(mdPath: string, isExternalLink: boolean): string { </ins> if (needsBracketLink(mdPath)) { return '<' + mdPath.replaceAll('<', '<').replaceAll('>', '>') + '>'; } <del> return encodeURI(mdPath); </del> <ins> return isExternalLink ? mdPath : encodeURI(mdPath); </ins> } function escapeBrackets(value: string): string {

}); suite('appendToLinkSnippet', () => { <ins> test('Should create auto link when pasted link has an mismatched parentheses', () => { const uriString = 'https://www.mic(rosoft.com'; const snippet = appendToLinkSnippet(new vscode.SnippetString(''), false, 'https:/www.microsoft.com', '', uriString, 0, true); assert.strictEqual(snippet?.value, '<https://www.mic(rosoft.com>'); }); test('Should create snippet with < > when pasted link has an mismatched parentheses', () => { const uriString = 'https://www.mic(rosoft.com'; const snippet = appendToLinkSnippet(new vscode.SnippetString(''), true, 'https:/www.microsoft.com', 'abc', uriString, 0, true); assert.strictEqual(snippet?.value, '[${0:abc}](<https://www.mic(rosoft.com>)'); }); </ins> test('Should not create Markdown link snippet when pasteAsMarkdownLink is false', () => { const uriString = 'https://www.microsoft.com'; const snippet = appendToLinkSnippet(new vscode.SnippetString(''), false, 'https:/www.microsoft.com', '', uriString, 0, true);