Skip to content

Commit 73947f8

Browse files
committed
Add comments and make some nit changes based on PR feedback
1 parent e1a89e7 commit 73947f8

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/services/utilities.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -913,6 +913,11 @@ namespace ts {
913913
}
914914

915915
export function isPossiblyTypeArgumentPosition(token: Node, sourceFile: SourceFile) {
916+
// This function determines if the node could be type argument position
917+
// Since during editing, when type argument list is not complete,
918+
// the tree could be of any shape depending on the tokens parsed before current node,
919+
// scanning of the previous identifier followed by "<" before current node would give us better result
920+
// Note that we also balance out the already provided type arguments, arrays, object literals while doing so
916921
let remainingLessThanTokens = 0;
917922
while (token) {
918923
switch (token.kind) {
@@ -927,11 +932,13 @@ namespace ts {
927932
break;
928933

929934
case SyntaxKind.GreaterThanGreaterThanGreaterThanToken:
930-
remainingLessThanTokens++;
931-
// falls through
935+
remainingLessThanTokens = + 3;
936+
break;
937+
932938
case SyntaxKind.GreaterThanGreaterThanToken:
933-
remainingLessThanTokens++;
934-
// falls through
939+
remainingLessThanTokens = + 2;
940+
break;
941+
935942
case SyntaxKind.GreaterThanToken:
936943
remainingLessThanTokens++;
937944
break;
@@ -991,7 +998,6 @@ namespace ts {
991998
return false;
992999
}
9931000

994-
9951001
/**
9961002
* Returns true if the cursor at position in sourceFile is within a comment.
9971003
*

0 commit comments

Comments
 (0)