fix: nodeWillIndentChild judge for BinaryExpression with JsxElement child (#44695)

This commit is contained in:
Jm
2021-08-13 05:01:52 +08:00
committed by GitHub
parent 88d8d1ccee
commit 7139f37201
2 changed files with 41 additions and 0 deletions

View File

@@ -606,6 +606,11 @@ namespace ts.formatting {
if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === SyntaxKind.ObjectLiteralExpression) { // TODO: GH#18217
return rangeIsOnOneLine(sourceFile, child!);
}
if (parent.kind === SyntaxKind.BinaryExpression && sourceFile && child && childKind === SyntaxKind.JsxElement) {
const parentStartLine = sourceFile.getLineAndCharacterOfPosition(skipTrivia(sourceFile.text, parent.pos)).line;
const childStartLine = sourceFile.getLineAndCharacterOfPosition(skipTrivia(sourceFile.text, child.pos)).line;
return parentStartLine !== childStartLine;
}
if (parent.kind !== SyntaxKind.BinaryExpression) {
return true;
}