mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
pseudo-block indentation
This commit is contained in:
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user