Skip to content

Commit dfc97db

Browse files
committed
Don't add extra indentation for objects inside function parameters
1 parent fbdbb14 commit dfc97db

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/services/formatting/smartIndenter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,6 @@ namespace ts.formatting {
482482
case SyntaxKind.ArrayLiteralExpression:
483483
case SyntaxKind.Block:
484484
case SyntaxKind.ModuleBlock:
485-
case SyntaxKind.ObjectLiteralExpression:
486485
case SyntaxKind.TypeLiteral:
487486
case SyntaxKind.MappedType:
488487
case SyntaxKind.TupleType:
@@ -524,6 +523,8 @@ namespace ts.formatting {
524523
return rangeIsOnOneLine(sourceFile, child!);
525524
}
526525
return true;
526+
case SyntaxKind.CallExpression:
527+
return childKind !== SyntaxKind.ObjectLiteralExpression
527528
case SyntaxKind.DoStatement:
528529
case SyntaxKind.WhileStatement:
529530
case SyntaxKind.ForInStatement:

tests/cases/fourslash/consistenceOnIndentionsOfObjectsInAListAfterFormatting.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ format.document();
88
goTo.marker("1");
99
verify.currentLineContentIs("}, {");
1010
goTo.marker("2");
11-
verify.currentLineContentIs(" });");
11+
verify.currentLineContentIs("});");
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
////
4+
//// someRandomFunction({
5+
//// prop1: 1,
6+
//// prop2: 2
7+
//// }, {
8+
//// prop3: 3,
9+
//// prop4: 4
10+
//// }, {
11+
//// prop5: 5,
12+
//// prop6: 6
13+
//// });
14+
15+
format.document();
16+
verify.currentFileContentIs(`
17+
someRandomFunction({
18+
prop1: 1,
19+
prop2: 2
20+
}, {
21+
prop3: 3,
22+
prop4: 4
23+
}, {
24+
prop5: 5,
25+
prop6: 6
26+
});`);

0 commit comments

Comments
 (0)