diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 3773412bace..d8ca7f03d96 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -403,16 +403,13 @@ namespace ts.formatting { indentation = parentDynamicIndentation.getIndentation(); } } - else if (SmartIndenter.isIndentationPrevented(node)) { + else if (SmartIndenter.isIndentationPrevented(node) || + SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { + indentation = parentDynamicIndentation.getIndentation(); } else { - if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) { - indentation = parentDynamicIndentation.getIndentation(); - } - else { - indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); - } + indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(); } } diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index a95d756f356..86ee0f5f363 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -482,7 +482,7 @@ namespace ts.formatting { switch (node.kind) { case SyntaxKind.NamedExports: return true; - // Allow indentation only when namedBindings is NamespaceImport. + // NamedImports has its own braces as Block does case SyntaxKind.ImportClause: return (node).namedBindings.kind === SyntaxKind.NamedImports; }