Fix bug for completing function name parameters if function name contained special snippet syntax

pull/65581/head^2
Matt Bierner 2018-12-20 13:04:01 -08:00
parent 75071898dc
commit 494e5e8509
2 changed files with 12 additions and 1 deletions

View File

@ -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');
});
});

View File

@ -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();