diff --git a/src/services/smartIndenter.ts b/src/services/smartIndenter.ts index cafd92a7551..758c06226a4 100644 --- a/src/services/smartIndenter.ts +++ b/src/services/smartIndenter.ts @@ -342,6 +342,7 @@ module ts.formatting { case SyntaxKind.VariableDeclaration: case SyntaxKind.ExportAssignment: case SyntaxKind.ReturnStatement: + case SyntaxKind.ConditionalExpression: return true; } return false; diff --git a/tests/cases/fourslash/formattingConditionals.ts b/tests/cases/fourslash/formattingConditionals.ts new file mode 100644 index 00000000000..65029134b87 --- /dev/null +++ b/tests/cases/fourslash/formattingConditionals.ts @@ -0,0 +1,23 @@ +/// + + +////var v = +/////*0*/a === b +/////*1*/? c +/////*2*/: d; + +////var v = a === b +/////*3*/? c +/////*4*/: d; + +function verifyLine(marker: string, content: string) { + goTo.marker(marker); + verify.currentLineContentIs(content); +} + +format.document(); +verifyLine("0", " a === b"); +verifyLine("1", " ? c"); +verifyLine("2", " : d;"); +verifyLine("3", " ? c"); +verifyLine("4", " : d;");