@@ -310,6 +310,12 @@ module ts.SignatureHelp {
310
310
// args without commas. We want to find what index we're at. So we count
311
311
// forward until we hit ourselves, only incrementing the index if it isn't a
312
312
// comma.
313
+ //
314
+ // Note: the subtlety around trailing commas (in getArgumentCount) does not apply
315
+ // here. That's because we're only walking forward until we hit the node we're
316
+ // on. In that case, even if we're after the trailing comma, we'll still see
317
+ // that trailing comma in the list, and we'll have generated the appropriate
318
+ // arg index.
313
319
var argumentIndex = 0 ;
314
320
var listChildren = argumentsList . getChildren ( ) ;
315
321
for ( var i = 0 , n = listChildren . length ; i < n ; i ++ ) {
@@ -332,6 +338,11 @@ module ts.SignatureHelp {
332
338
// is a small subtlety. If you have "Foo(a,)", then the child list will just have
333
339
// 'a' '<comma>'. So, in the case where the last child is a comma, we increase the
334
340
// arg count by one to compensate.
341
+ //
342
+ // Note: this subtlety only applies to the last comma. If you had "Foo(a,," then
343
+ // we'll have: 'a' '<comma>' '<missing>'
344
+ // That will give us 2 non-commas. We then add one for the last comma, givin us an
345
+ // arg count of 3.
335
346
var listChildren = argumentsList . getChildren ( ) ;
336
347
337
348
var argumentCount = countWhere ( listChildren , arg => arg . kind !== SyntaxKind . CommaToken ) ;
0 commit comments