Skip to content

Commit 04d4db5

Browse files
committed
Fixes #32923
1 parent ccf41ef commit 04d4db5

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

src/services/formatting/smartIndenter.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -539,10 +539,14 @@ namespace ts.formatting {
539539
return true;
540540
case SyntaxKind.VariableDeclaration:
541541
case SyntaxKind.PropertyAssignment:
542+
case SyntaxKind.BinaryExpression:
542543
if (!settings.indentMultiLineObjectLiteralBeginningOnBlankLine && sourceFile && childKind === SyntaxKind.ObjectLiteralExpression) { // TODO: GH#18217
543544
return rangeIsOnOneLine(sourceFile, child!);
544545
}
545-
return true;
546+
if (parent.kind !== SyntaxKind.BinaryExpression) {
547+
return true;
548+
}
549+
break;
546550
case SyntaxKind.DoStatement:
547551
case SyntaxKind.WhileStatement:
548552
case SyntaxKind.ForInStatement:
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
////
4+
//// var clear = {};
5+
//// clear =
6+
//// {
7+
//// outerKey:
8+
//// {
9+
//// innerKey: 1,
10+
//// innerKey2:
11+
//// 2
12+
//// }
13+
//// };
14+
////
15+
16+
format.document();
17+
verify.currentFileContentIs(
18+
`
19+
var clear = {};
20+
clear =
21+
{
22+
outerKey:
23+
{
24+
innerKey: 1,
25+
innerKey2:
26+
2
27+
}
28+
};
29+
`
30+
);
31+
32+
format.setOption("indentMultiLineObjectLiteralBeginningOnBlankLine", true);
33+
format.document();
34+
verify.currentFileContentIs(
35+
`
36+
var clear = {};
37+
clear =
38+
{
39+
outerKey:
40+
{
41+
innerKey: 1,
42+
innerKey2:
43+
2
44+
}
45+
};
46+
`
47+
);

0 commit comments

Comments
 (0)