Don't create an unnecessary text span in isInStringOrRegularExpressionOrTemplateLiteral (#52697)

This commit is contained in:
Daniel Rosenwasser 2023-02-09 15:37:22 -08:00 committed by GitHub
parent bd905d4936
commit 7fb6c99c19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -36,7 +36,6 @@ import {
createPackageJsonImportFilter,
createPrinter,
createSortedArray,
createTextRangeFromSpan,
createTextSpanFromBounds,
createTextSpanFromNode,
createTextSpanFromRange,
@ -3697,7 +3696,7 @@ function getCompletionData(
// 2. at the end position of an unterminated token.
// 3. at the end of a regular expression (due to trailing flags like '/foo/g').
return (isRegularExpressionLiteral(contextToken) || isStringTextContainingNode(contextToken)) && (
rangeContainsPositionExclusive(createTextRangeFromSpan(createTextSpanFromNode(contextToken)), position) ||
rangeContainsPositionExclusive(contextToken, position) ||
position === contextToken.end && (!!contextToken.isUnterminated || isRegularExpressionLiteral(contextToken)));
}