Fix bug where return type containing function type could be merged with normal parameters

This commit is contained in:
Matt Bierner
2018-11-20 16:52:53 -08:00
parent 86d7fd923a
commit 1755715a13
2 changed files with 12 additions and 0 deletions

View File

@@ -666,6 +666,9 @@ export function snippetForFunctionCall(
++parenCount;
} else if (part.text === ')') {
--parenCount;
if (parenCount <= 0) {
break;
}
} else if (part.text === '...' && parenCount === 1) {
// Found rest parmeter. Do not fill in any further arguments
hasOptionalParameters = true;

View File

@@ -80,4 +80,13 @@ suite('typescript function call snippets', () => {
).value,
'foo(${1:a}, ${2:b})$0');
});
test('Should skip over return type', async () => {
assert.strictEqual(
snippetForFunctionCall(
{ label: 'foo' },
[{ "text": "function", "kind": "keyword" }, { "text": " ", "kind": "space" }, { "text": "foo", "kind": "functionName" }, { "text": "(", "kind": "punctuation" }, { "text": "a", "kind": "parameterName" }, { "text": ":", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "number", "kind": "keyword" }, { "text": ")", "kind": "punctuation" }, { "text": ":", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "{", "kind": "punctuation" }, { "text": "\n", "kind": "lineBreak" }, { "text": " ", "kind": "space" }, { "text": "f", "kind": "propertyName" }, { "text": ":", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "(", "kind": "punctuation" }, { "text": "b", "kind": "parameterName" }, { "text": ":", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "number", "kind": "keyword" }, { "text": ")", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "=>", "kind": "punctuation" }, { "text": " ", "kind": "space" }, { "text": "number", "kind": "keyword" }, { "text": ";", "kind": "punctuation" }, { "text": "\n", "kind": "lineBreak" }, { "text": "}", "kind": "punctuation" }]
).value,
'foo(${1:a})$0');
});
});