File tree Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Expand file tree Collapse file tree 2 files changed +52
-1
lines changed Original file line number Diff line number Diff 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 :
Original file line number Diff line number Diff line change 1+ /// <reference path='fourslash.ts' />
2+
3+ ////
4+ //// var obj = {};
5+ //// obj =
6+ //// {
7+ //// prop: 3
8+ //// };
9+ ////
10+ //// var obj2 = obj ||
11+ //// {
12+ //// prop: 0
13+ //// }
14+ ////
15+
16+ format . document ( ) ;
17+ verify . currentFileContentIs (
18+ `
19+ var obj = {};
20+ obj =
21+ {
22+ prop: 3
23+ };
24+
25+ var obj2 = obj ||
26+ {
27+ prop: 0
28+ }
29+ `
30+ ) ;
31+
32+ format . setOption ( "indentMultiLineObjectLiteralBeginningOnBlankLine" , true ) ;
33+ format . document ( ) ;
34+ verify . currentFileContentIs (
35+ `
36+ var obj = {};
37+ obj =
38+ {
39+ prop: 3
40+ };
41+
42+ var obj2 = obj ||
43+ {
44+ prop: 0
45+ }
46+ `
47+ ) ;
You can’t perform that action at this time.
0 commit comments