pseudo-block indentation

This commit is contained in:
SaschaNaz
2015-08-30 15:02:15 +09:00
parent 525aea3cf9
commit 9d867b70e3
2 changed files with 19 additions and 4 deletions
+14
View File
@@ -403,6 +403,20 @@ namespace ts.formatting {
indentation = parentDynamicIndentation.getIndentation();
}
}
else if (node.kind === SyntaxKind.NamedExports || node.kind === SyntaxKind.ImportClause) {
let blockParent = node.kind === SyntaxKind.ImportClause ?
(<ImportClause>node).namedBindings : node;
let children = (<NamedExports | ImportClause>blockParent).getChildren(sourceFile);
// Detect named export/import pseudo-block
if (children[0] && children[0].kind === SyntaxKind.OpenBraceToken &&
children[2] && children[2].kind === SyntaxKind.CloseBraceToken) {
indentation = parentDynamicIndentation.getIndentation();
}
else {
indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta();
}
}
else {
if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) {
indentation = parentDynamicIndentation.getIndentation();
+5 -4
View File
@@ -440,12 +440,11 @@ namespace ts.formatting {
case SyntaxKind.ParenthesizedType:
case SyntaxKind.TaggedTemplateExpression:
case SyntaxKind.AwaitExpression:
case SyntaxKind.NamedExports:
case SyntaxKind.ExportDeclaration:
case SyntaxKind.NamedImports:
case SyntaxKind.ImportDeclaration:
case SyntaxKind.NamedExports:
case SyntaxKind.NamedImports:
case SyntaxKind.ExportSpecifier:
//case SyntaxKind.ImportSpecifier:
case SyntaxKind.ImportSpecifier:
return true;
}
return false;
@@ -470,6 +469,8 @@ namespace ts.formatting {
case SyntaxKind.GetAccessor:
case SyntaxKind.SetAccessor:
return child !== SyntaxKind.Block;
case SyntaxKind.ExportDeclaration:
return child !== SyntaxKind.NamedExports;
default:
return false;
}