Skip to content

Commit 05c2a3e

Browse files
Add explanatory comments.
1 parent 63ba645 commit 05c2a3e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

src/services/signatureHelp.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,12 @@ module ts.SignatureHelp {
310310
// args without commas. We want to find what index we're at. So we count
311311
// forward until we hit ourselves, only incrementing the index if it isn't a
312312
// 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.
313319
var argumentIndex = 0;
314320
var listChildren = argumentsList.getChildren();
315321
for (var i = 0, n = listChildren.length; i < n; i++) {
@@ -332,6 +338,11 @@ module ts.SignatureHelp {
332338
// is a small subtlety. If you have "Foo(a,)", then the child list will just have
333339
// 'a' '<comma>'. So, in the case where the last child is a comma, we increase the
334340
// 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.
335346
var listChildren = argumentsList.getChildren();
336347

337348
var argumentCount = countWhere(listChildren, arg => arg.kind !== SyntaxKind.CommaToken);

0 commit comments

Comments
 (0)