File tree 1 file changed +11
-5
lines changed
1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -913,6 +913,11 @@ namespace ts {
913
913
}
914
914
915
915
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
916
921
let remainingLessThanTokens = 0 ;
917
922
while ( token ) {
918
923
switch ( token . kind ) {
@@ -927,11 +932,13 @@ namespace ts {
927
932
break ;
928
933
929
934
case SyntaxKind . GreaterThanGreaterThanGreaterThanToken :
930
- remainingLessThanTokens ++ ;
931
- // falls through
935
+ remainingLessThanTokens = + 3 ;
936
+ break ;
937
+
932
938
case SyntaxKind . GreaterThanGreaterThanToken :
933
- remainingLessThanTokens ++ ;
934
- // falls through
939
+ remainingLessThanTokens = + 2 ;
940
+ break ;
941
+
935
942
case SyntaxKind . GreaterThanToken :
936
943
remainingLessThanTokens ++ ;
937
944
break ;
@@ -991,7 +998,6 @@ namespace ts {
991
998
return false ;
992
999
}
993
1000
994
-
995
1001
/**
996
1002
* Returns true if the cursor at position in sourceFile is within a comment.
997
1003
*
You can’t perform that action at this time.
0 commit comments