From 2690d792c15996b85f06799c451b399eef390d28 Mon Sep 17 00:00:00 2001 From: Andrew Casey Date: Tue, 20 Jun 2017 15:32:32 -0700 Subject: [PATCH] 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. --- src/services/utilities.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/services/utilities.ts b/src/services/utilities.ts index c5483251c61..d74e829cf45 100644 --- a/src/services/utilities.ts +++ b/src/services/utilities.ts @@ -649,7 +649,8 @@ namespace ts { const start = allowPositionInLeadingTrivia ? child.getFullStart() : child.getStart(sourceFile, includeJsDocComment); if (start > position) { - continue; + // If this child begins after position, then all subsequent children will as well. + break; } const end = child.getEnd();