findPrecedingToken handles EOF child more gracefully

This commit is contained in:
Arthur Ozga 2017-08-15 11:26:47 -07:00
parent 472ad9d313
commit f3e0cbbd52
2 changed files with 2 additions and 2 deletions

View file

@ -113,7 +113,7 @@ namespace ts {
}
pos = textPos;
if (token === SyntaxKind.EndOfFileToken) {
return pos;
break;
}
}
return pos;

View file

@ -753,7 +753,7 @@ namespace ts {
const start = child.getStart(sourceFile, includeJsDoc);
const lookInPreviousChild =
(start >= position) || // cursor in the leading trivia
nodeHasTokens(child) ||
!nodeHasTokens(child) ||
(child.kind === SyntaxKind.JsxText && start === child.end); // whitespace only JsxText
if (lookInPreviousChild) {