mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-10 10:58:20 -05:00
getLineIndentation for others
This commit is contained in:
@@ -66,6 +66,10 @@ module ts.formatting {
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation;
|
||||
}
|
||||
actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options);
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation + options.IndentSize;
|
||||
}
|
||||
|
||||
previous = current;
|
||||
current = current.parent;
|
||||
@@ -122,6 +126,10 @@ module ts.formatting {
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation + indentationDelta;
|
||||
}
|
||||
actualIndentation = getLineIndentationWhenExpressionIsInMultiLine(current, sourceFile, options);
|
||||
if (actualIndentation !== Value.Unknown) {
|
||||
return actualIndentation + indentationDelta;
|
||||
}
|
||||
}
|
||||
|
||||
// increase indentation if parent node wants its content to be indented and parent and child nodes don't start on the same line
|
||||
@@ -279,14 +287,7 @@ module ts.formatting {
|
||||
|
||||
function getActualIndentationForListItem(node: Node, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
let containingList = getContainingList(node, sourceFile);
|
||||
|
||||
if (containingList) {
|
||||
let lineIndentation = getLineIndentationWhenExpressionIsInMultiLine(node, sourceFile, options);
|
||||
if (lineIndentation !== Value.Unknown)
|
||||
return lineIndentation;
|
||||
return getActualIndentationFromList(containingList);
|
||||
}
|
||||
return Value.Unknown;
|
||||
return containingList ? getActualIndentationFromList(containingList) : Value.Unknown;
|
||||
|
||||
function getActualIndentationFromList(list: Node[]): number {
|
||||
let index = indexOf(list, node);
|
||||
@@ -295,8 +296,9 @@ module ts.formatting {
|
||||
}
|
||||
|
||||
function getLineIndentationWhenExpressionIsInMultiLine(node: Node, sourceFile: SourceFile, options: EditorOptions): number {
|
||||
if (node.parent.kind === SyntaxKind.CallExpression ||
|
||||
node.parent.kind === SyntaxKind.NewExpression) {
|
||||
if (node.parent && (
|
||||
node.parent.kind === SyntaxKind.CallExpression ||
|
||||
node.parent.kind === SyntaxKind.NewExpression)) {
|
||||
|
||||
let parentExpression = (<CallExpression | NewExpression>node.parent).expression;
|
||||
let startingExpression = getStartingExpression(<PropertyAccessExpression | CallExpression | ElementAccessExpression>parentExpression);
|
||||
|
||||
Reference in New Issue
Block a user