mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 13:45:34 -05:00
Fix formatter's processChildNodes (#48921)
processChildNodes needs to skip processing when the node array is outside the target range, just like processChildNode already does for a single node. Fixes #48006
This commit is contained in:
committed by
GitHub
parent
63a941dc2a
commit
e73d755668
@@ -778,6 +778,13 @@ namespace ts.formatting {
|
||||
|
||||
let listDynamicIndentation = parentDynamicIndentation;
|
||||
let startLine = parentStartLine;
|
||||
// node range is outside the target range - do not dive inside
|
||||
if (!rangeOverlapsWithStartEnd(originalRange, nodes.pos, nodes.end)) {
|
||||
if (nodes.end < originalRange.pos) {
|
||||
formattingScanner.skipToEndOf(nodes);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (listStartToken !== SyntaxKind.Unknown) {
|
||||
// introduce a new indentation scope for lists (including list start and end tokens)
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace ts.formatting {
|
||||
readEOFTokenRange(): TextRangeWithKind;
|
||||
getCurrentLeadingTrivia(): TextRangeWithKind[] | undefined;
|
||||
lastTrailingTriviaWasNewLine(): boolean;
|
||||
skipToEndOf(node: Node): void;
|
||||
skipToEndOf(node: Node | NodeArray<Node>): void;
|
||||
skipToStartOf(node: Node): void;
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ namespace ts.formatting {
|
||||
return tokenInfo;
|
||||
}
|
||||
|
||||
function skipToEndOf(node: Node): void {
|
||||
function skipToEndOf(node: Node | NodeArray<Node>): void {
|
||||
scanner.setTextPos(node.end);
|
||||
savedPos = scanner.getStartPos();
|
||||
lastScanAction = undefined;
|
||||
|
||||
Reference in New Issue
Block a user