Handle feedback from #32359
This commit is contained in:
parent
59d5585814
commit
1d78218053
2 changed files with 7 additions and 8 deletions
|
@ -490,7 +490,7 @@ namespace ts.formatting {
|
|||
else if (SmartIndenter.childStartsOnTheSameLineWithElseInIfStatement(parent, node, startLine, sourceFile)) {
|
||||
return { indentation: parentDynamicIndentation.getIndentation(), delta };
|
||||
}
|
||||
else if (SmartIndenter.childStartsInlineWithPreviousObject(parent, node, startLine, sourceFile)) {
|
||||
else if (SmartIndenter.argumentStartsOnSameLineAsPreviousArgument(parent, node, startLine, sourceFile)) {
|
||||
return { indentation: parentDynamicIndentation.getIndentation(), delta };
|
||||
}
|
||||
else {
|
||||
|
|
|
@ -322,16 +322,15 @@ namespace ts.formatting {
|
|||
return false;
|
||||
}
|
||||
|
||||
export function childStartsInlineWithPreviousObject(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean {
|
||||
if (parent.kind === SyntaxKind.CallExpression) {
|
||||
const parentCallExpression = <CallExpression>parent;
|
||||
const currentNode = find(parentCallExpression.arguments, arg => arg.pos === child.pos);
|
||||
if (!currentNode) return false; // Shouldn't happen
|
||||
export function argumentStartsOnSameLineAsPreviousArgument(parent: Node, child: TextRangeWithKind, childStartLine: number, sourceFile: SourceFileLike): boolean {
|
||||
if (isCallOrNewExpression(parent)) {
|
||||
if (!parent.arguments) return false;
|
||||
|
||||
const currentIndex = parentCallExpression.arguments.indexOf(currentNode);
|
||||
const currentNode = Debug.assertDefined(find(parent.arguments, arg => arg.pos === child.pos));
|
||||
const currentIndex = parent.arguments.indexOf(currentNode);
|
||||
if (currentIndex === 0) return false; // Can't look at previous node if first
|
||||
|
||||
const previousNode = parentCallExpression.arguments[currentIndex - 1];
|
||||
const previousNode = parent.arguments[currentIndex - 1];
|
||||
const lineOfPreviousNode = getLineAndCharacterOfPosition(sourceFile, previousNode.getEnd()).line;
|
||||
|
||||
if (childStartLine === lineOfPreviousNode) {
|
||||
|
|
Loading…
Reference in a new issue