diff --git a/src/services/formatting/formatting.ts b/src/services/formatting/formatting.ts index 4fa3b71a3a200..c8ea5da926f2e 100644 --- a/src/services/formatting/formatting.ts +++ b/src/services/formatting/formatting.ts @@ -461,6 +461,10 @@ namespace ts.formatting { else { indentation = parentDynamicIndentation.getIndentation() + parentDynamicIndentation.getDelta(node); } + if (node.kind === SyntaxKind.OpenParenToken) { + // if an open paren is on a different line from the call expression, indent the arguments one level deeper + delta = options.indentSize; + } } return { diff --git a/tests/cases/fourslash/formattingOnChainedCallbacks.ts b/tests/cases/fourslash/formattingOnChainedCallbacks.ts index b8dbc55d8b6cb..ee173f005c366 100644 --- a/tests/cases/fourslash/formattingOnChainedCallbacks.ts +++ b/tests/cases/fourslash/formattingOnChainedCallbacks.ts @@ -20,6 +20,14 @@ //// /*n2*/ //// .then(); +////Promise +//// .then( +//// /*cbNoComma*/cb +//// /*endNoComma*/) +//// .then( +//// /*cbComma*/cb, +//// /*endComma*/) +//// .then(); goTo.marker('1'); edit.insertLine(''); @@ -49,4 +57,15 @@ verify.currentLineContentIs(' });'); goTo.marker('n1'); verify.indentationIs(8); goTo.marker('n2'); -verify.indentationIs(4); \ No newline at end of file +verify.indentationIs(4); + +format.document(); + +goTo.marker('cbNoComma'); +verify.currentLineContentIs(' cb'); +goTo.marker('cbComma'); +verify.currentLineContentIs(' cb,'); +goTo.marker('endNoComma'); +verify.currentLineContentIs(' )'); +goTo.marker('endComma'); +// verify.currentLineContentIs(' )');