Skip to content

Commit 2690d79

Browse files
committed
Short-circuit getTokenAtPositionWorker
The children of a given node are sorted by start position so, if one of them starts after a given position, all subsequent children all start after that position.
1 parent 9cd04e0 commit 2690d79

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/services/utilities.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,8 @@ namespace ts {
649649

650650
const start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment);
651651
if (start > position) {
652-
continue;
652+
// If this child begins after position, then all subsequent children will as well.
653+
break;
653654
}
654655

655656
const end = child.getEnd();

0 commit comments

Comments
 (0)