mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-30 01:04:49 -05:00
Ensure findPrecedingToken recurses into JSDoc children when needed (#53487)
This commit is contained in:
@@ -1739,7 +1739,14 @@ export function findPrecedingToken(position: number, sourceFile: SourceFileLike,
|
||||
if (lookInPreviousChild) {
|
||||
// actual start of the node is past the position - previous token should be at the end of previous child
|
||||
const candidate = findRightmostChildNodeWithTokens(children, /*exclusiveStartPosition*/ i, sourceFile, n.kind);
|
||||
return candidate && findRightmostToken(candidate, sourceFile);
|
||||
if (candidate) {
|
||||
// Ensure we recurse into JSDoc nodes with children.
|
||||
if (!excludeJsdoc && isJSDocCommentContainingNode(candidate) && candidate.getChildren(sourceFile).length) {
|
||||
return find(candidate);
|
||||
}
|
||||
return findRightmostToken(candidate, sourceFile);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
else {
|
||||
// candidate should be in this node
|
||||
|
||||
Reference in New Issue
Block a user