Skip to content

Commit 997aadb

Browse files
committed
Merge pull request microsoft#1437 from Microsoft/formatting_conditionals
conditionals are now introduce indentation scope
2 parents 638518c + d69ba56 commit 997aadb

2 files changed

Lines changed: 45 additions & 0 deletions

File tree

src/services/smartIndenter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ module ts.formatting {
342342
case SyntaxKind.VariableDeclaration:
343343
case SyntaxKind.ExportAssignment:
344344
case SyntaxKind.ReturnStatement:
345+
case SyntaxKind.ConditionalExpression:
345346
return true;
346347
}
347348
return false;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/// <reference path='fourslash.ts' />
2+
3+
4+
////var v =
5+
/////*0*/a === b
6+
/////*1*/? c
7+
/////*2*/: d;
8+
9+
////var v = a === b
10+
/////*3*/? c
11+
/////*4*/: d;
12+
13+
////var x =
14+
/////*5*/a
15+
/////*6*/? function(){
16+
/////*7*/var z = 1
17+
/////*8*/}
18+
/////*9*/: function(){
19+
/////*10*/var z = 2
20+
/////*11*/}
21+
22+
23+
24+
25+
function verifyLine(marker: string, content: string) {
26+
goTo.marker(marker);
27+
verify.currentLineContentIs(content);
28+
}
29+
30+
format.document();
31+
verifyLine("0", " a === b");
32+
verifyLine("1", " ? c");
33+
verifyLine("2", " : d;");
34+
35+
verifyLine("3", " ? c");
36+
verifyLine("4", " : d;");
37+
38+
verifyLine("5", " a");
39+
verifyLine("6", " ? function() {");
40+
verifyLine("7", " var z = 1");
41+
verifyLine("8", " }");
42+
verifyLine("9", " : function() {");
43+
verifyLine("10", " var z = 2");
44+
verifyLine("11", " }");

0 commit comments

Comments
 (0)