diff --git a/src/services/services.ts b/src/services/services.ts index 98a7fe0499f..58c5ecf079f 100644 --- a/src/services/services.ts +++ b/src/services/services.ts @@ -5902,11 +5902,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. result.push({