diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 868683bb6af..8a713dc032c 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -387,9 +387,7 @@ namespace ts.formatting { let indentation = inheritedIndentation; if (indentation === Constants.Unknown) { - if (SmartIndenter.shouldInheritParentIndentation(parent, node) || - SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - + if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { indentation = parentDynamicIndentation.getIndentation(); } else { @@ -590,6 +588,10 @@ namespace ts.formatting { return inheritedIndentation; } + if (SmartIndenter.shouldInheritParentIndentation(parent, child)) { + parentDynamicIndentation = getDynamicIndentation(parent, parentStartLine, indentation, 0); + } + if (isToken(child)) { // if child node is a token, it does not impact indentation, proceed it using parent indentation scope rules let tokenInfo = formattingScanner.readTokenInfo(child);