mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-04 21:53:42 -06:00
fix: nodeWillIndentChild judge for BinaryExpression with JsxElement child (#44695)
This commit is contained in:
parent
88d8d1ccee
commit
7139f37201
@ -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;
|
||||
}
|
||||
|
||||
@ -0,0 +1,36 @@
|
||||
/// <reference path="fourslash.ts" />
|
||||
|
||||
//@Filename: file.tsx
|
||||
//// function TestWidget() {
|
||||
//// const test = true;
|
||||
//// return (
|
||||
//// <div>
|
||||
//// {test &&
|
||||
//// <div>
|
||||
//// /*1*/ <div>some text</div>/*2*/
|
||||
//// <div>some text</div>
|
||||
//// <div>some text</div>
|
||||
//// </div>
|
||||
//// }
|
||||
//// <div>some text</div>
|
||||
//// </div>
|
||||
//// );
|
||||
//// }
|
||||
|
||||
format.selection("1", "2");
|
||||
verify.currentFileContentIs(
|
||||
`function TestWidget() {
|
||||
const test = true;
|
||||
return (
|
||||
<div>
|
||||
{test &&
|
||||
<div>
|
||||
<div>some text</div>
|
||||
<div>some text</div>
|
||||
<div>some text</div>
|
||||
</div>
|
||||
}
|
||||
<div>some text</div>
|
||||
</div>
|
||||
);
|
||||
}`)
|
||||
Loading…
x
Reference in New Issue
Block a user