Skip to content

Commit 0f7f978

Browse files
author
Armando Aguirre
committed
Fixed test regression, removed nodeContentIsAlwaysIndented
1 parent 1146c69 commit 0f7f978

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

src/services/formatting/smartIndenter.ts

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -482,8 +482,10 @@ namespace ts.formatting {
482482
return findFirstNonWhitespaceCharacterAndColumn(startPos, endPos, sourceFile, options).column;
483483
}
484484

485-
function nodeContentIsAlwaysIndented(kind: SyntaxKind): boolean {
486-
switch (kind) {
485+
export function nodeWillIndentChild(settings: FormatCodeSettings | undefined, parent: TextRangeWithKind, child: TextRangeWithKind | undefined, sourceFile: SourceFileLike | undefined, indentByDefault: boolean): boolean {
486+
const childKind = child ? child.kind : SyntaxKind.Unknown;
487+
488+
switch (parent.kind) {
487489
case SyntaxKind.ExpressionStatement:
488490
case SyntaxKind.ClassDeclaration:
489491
case SyntaxKind.ClassExpression:
@@ -529,20 +531,12 @@ namespace ts.formatting {
529531
case SyntaxKind.ImportSpecifier:
530532
case SyntaxKind.PropertyDeclaration:
531533
return true;
532-
}
533-
return false;
534-
}
535-
536-
export function nodeWillIndentChild(settings: FormatCodeSettings | undefined, parent: TextRangeWithKind, child: TextRangeWithKind | undefined, sourceFile: SourceFileLike | undefined, indentByDefault: boolean): boolean {
537-
const childKind = child ? child.kind : SyntaxKind.Unknown;
538-
539-
switch (parent.kind) {
540534
case SyntaxKind.VariableDeclaration:
541535
case SyntaxKind.PropertyAssignment:
542536
if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === SyntaxKind.ObjectLiteralExpression) {
543537
return rangeIsOnOneLine(sourceFile, child);
544538
}
545-
break;
539+
return true;
546540
case SyntaxKind.DoStatement:
547541
case SyntaxKind.WhileStatement:
548542
case SyntaxKind.ForInStatement:
@@ -595,7 +589,7 @@ namespace ts.formatting {
595589
* @param isNextChild If true, we are judging indent of a hypothetical child *after* this one, not the current child.
596590
*/
597591
export function shouldIndentChildNode(settings: FormatCodeSettings | undefined, parent: TextRangeWithKind, child?: Node, sourceFile?: SourceFileLike, isNextChild = false): boolean {
598-
return (nodeContentIsAlwaysIndented(parent.kind) || nodeWillIndentChild(settings, parent, child, sourceFile, /*indentByDefault*/ false))
592+
return nodeWillIndentChild(settings, parent, child, sourceFile, /*indentByDefault*/ false)
599593
&& !(isNextChild && child && isControlFlowEndingStatement(child.kind, parent));
600594
}
601595

0 commit comments

Comments
 (0)