From 0fc9e7e313412e1a77c260a0823a03e4609360a2 Mon Sep 17 00:00:00 2001 From: SaschaNaz Date: Sun, 6 Sep 2015 16:02:38 +0900 Subject: [PATCH] simplified code flow --- src/services/formatting/formatting.ts | 11 ++++------- src/services/formatting/smartIndenter.ts | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) 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; }