From 286f0150a6d2e819950ca80145945cf61232c166 Mon Sep 17 00:00:00 2001 From: Cyrus Najmabadi Date: Fri, 8 May 2015 10:54:00 -0700 Subject: [PATCH] Prevent infinite loop when classifying. --- src/services/services.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/services/services.ts b/src/services/services.ts index ede6fb8ca7b..bec00b9a66a 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -6039,11 +6039,13 @@ module ts { let end = triviaScanner.getTextPos(); let width = end - start; - if (textSpanIntersectsWith(span, start, width)) { - if (!isTrivia(kind)) { - return; - } + // The moment we get something that isn't trivia, then stop processing. + if (!isTrivia(kind)) { + return; + } + // Only bother with the trivia if it at least intersects the span of interest. + if (textSpanIntersectsWith(span, start, width)) { if (isComment(kind)) { // Simple comment. Just add as is. pushClassification(start, width, ClassificationType.comment);