Don't add extra indentation for objects inside function parameters

This commit is contained in:
Orta Therox 2019-07-11 14:26:03 -04:00
parent fbdbb141a2
commit dfc97db323
3 changed files with 29 additions and 2 deletions

View file

@ -482,7 +482,6 @@ namespace ts.formatting {
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.Block:
case SyntaxKind.ModuleBlock:
case SyntaxKind.ObjectLiteralExpression:
case SyntaxKind.TypeLiteral:
case SyntaxKind.MappedType:
case SyntaxKind.TupleType:
@ -524,6 +523,8 @@ namespace ts.formatting {
return rangeIsOnOneLine(sourceFile, child!);
}
return true;
case SyntaxKind.CallExpression:
return childKind !== SyntaxKind.ObjectLiteralExpression
case SyntaxKind.DoStatement:
case SyntaxKind.WhileStatement:
case SyntaxKind.ForInStatement:

View file

@ -8,4 +8,4 @@ format.document();
goTo.marker("1");
verify.currentLineContentIs("}, {");
goTo.marker("2");
verify.currentLineContentIs(" });");
verify.currentLineContentIs("});");

View file

@ -0,0 +1,26 @@
/// <reference path="fourslash.ts"/>
////
//// someRandomFunction({
//// prop1: 1,
//// prop2: 2
//// }, {
//// prop3: 3,
//// prop4: 4
//// }, {
//// prop5: 5,
//// prop6: 6
//// });
format.document();
verify.currentFileContentIs(`
someRandomFunction({
prop1: 1,
prop2: 2
}, {
prop3: 3,
prop4: 4
}, {
prop5: 5,
prop6: 6
});`);