From 494e5e85096ae080a19225abc65f7abaee35bdef Mon Sep 17 00:00:00 2001 From: Matt Bierner Date: Thu, 20 Dec 2018 13:04:01 -0800 Subject: [PATCH] Fix bug for completing function name parameters if function name contained special snippet syntax --- .../src/test/functionCallSnippet.test.ts | 10 ++++++++++ .../src/utils/snippetForFunctionCall.ts | 3 ++- 2 files changed, 12 insertions(+), 1 deletion(-) 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();