mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-24 04:09:28 +00:00
Fix bug where return type containing function type could be merged with normal parameters
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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');
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user