Skip to content

Commit a8d25c8

Browse files
Prevent infinite loop when classifying.
1 parent c233073 commit a8d25c8

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/services/services.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5902,11 +5902,13 @@ module ts {
59025902
let end = triviaScanner.getTextPos();
59035903
let width = end - start;
59045904

5905-
if (textSpanIntersectsWith(span, start, width)) {
5906-
if (!isTrivia(kind)) {
5907-
return;
5908-
}
5905+
// The moment we get something that isn't trivia, then stop processing.
5906+
if (!isTrivia(kind)) {
5907+
return;
5908+
}
59095909

5910+
// Only bother with the trivia if it at least intersects the span of interest.
5911+
if (textSpanIntersectsWith(span, start, width)) {
59105912
if (isComment(kind)) {
59115913
// Simple comment. Just add as is.
59125914
result.push({

0 commit comments

Comments
 (0)