diff --git a/extensions/typescript-language-features/src/test/functionCallSnippet.test.ts b/extensions/typescript-language-features/src/test/functionCallSnippet.test.ts index f8707491b9d..1fc1fa67980 100644 --- a/extensions/typescript-language-features/src/test/functionCallSnippet.test.ts +++ b/extensions/typescript-language-features/src/test/functionCallSnippet.test.ts @@ -107,4 +107,14 @@ suite('typescript function call snippets', () => { ).snippet.value, 'methoda(${1:x})$0'); }); + + test('Should escape snippet syntax in method name', async () => { + assert.strictEqual( + snippetForFunctionCall( + { label: '$abc', }, + [] + ).snippet.value, + '\\$abc()$0'); + }); + }); diff --git a/extensions/typescript-language-features/src/utils/snippetForFunctionCall.ts b/extensions/typescript-language-features/src/utils/snippetForFunctionCall.ts index 7845f4a44c9..7eab1e21ba9 100644 --- a/extensions/typescript-language-features/src/utils/snippetForFunctionCall.ts +++ b/extensions/typescript-language-features/src/utils/snippetForFunctionCall.ts @@ -16,7 +16,8 @@ export function snippetForFunctionCall( } const parameterListParts = getParameterListParts(displayParts); - const snippet = new vscode.SnippetString(`${item.insertText || item.label}(`); + const snippet = new vscode.SnippetString(); + snippet.appendText(`${item.insertText || item.label}(`); appendJoinedPlaceholders(snippet, parameterListParts.parts, ', '); if (parameterListParts.hasOptionalParameters) { snippet.appendTabstop();