indent expressions

This commit is contained in:
SaschaNaz 2015-09-30 02:59:10 +09:00
parent 077e0bd9b5
commit 06bf74a029
4 changed files with 39 additions and 2 deletions

View File

@ -405,6 +405,7 @@ namespace ts.formatting {
function nodeContentIsAlwaysIndented(kind: SyntaxKind): boolean {
switch (kind) {
case SyntaxKind.ExpressionStatement:
case SyntaxKind.ClassDeclaration:
case SyntaxKind.ClassExpression:
case SyntaxKind.InterfaceDeclaration:

View File

@ -128,7 +128,8 @@ namespace ts {
return isCompletedNode((<IfStatement>n).thenStatement, sourceFile);
case SyntaxKind.ExpressionStatement:
return isCompletedNode((<ExpressionStatement>n).expression, sourceFile);
return isCompletedNode((<ExpressionStatement>n).expression, sourceFile) ||
hasChildOfKind(n, SyntaxKind.SemicolonToken);
case SyntaxKind.ArrayLiteralExpression:
case SyntaxKind.ArrayBindingPattern:

View File

@ -0,0 +1,35 @@
/// <reference path="fourslash.ts"/>
////let t: number;
////t
/////*nextlineWithEqual*/=2+2;
////t=
/////*nextlineWithoutEqual*/2
/////*nextline2*/+2;
////t
/////*addition*/+= 22
/////*nextlineSemicolon*/;
////t
////=t
/////*chained*/=t+ 4;
format.document();
goTo.marker("nextlineWithEqual");
verify.indentationIs(4);
verify.currentLineContentIs(" = 2 + 2;");
goTo.marker("nextlineWithoutEqual");
verify.indentationIs(4);
verify.currentLineContentIs(" 2");
goTo.marker("nextline2");
verify.indentationIs(4);
verify.currentLineContentIs(" + 2;");
goTo.marker("addition");
verify.indentationIs(4);
verify.currentLineContentIs(" += 22");
goTo.marker("nextlineSemicolon");
verify.indentationIs(4);
verify.currentLineContentIs(" ;");
goTo.marker("chained");
verify.indentationIs(4);
verify.currentLineContentIs(" = t + 4;");

View File

@ -155,7 +155,7 @@ verify.currentLineContentIs(" else");
goTo.marker("61");
verify.currentLineContentIs(" x += 2");
goTo.marker("62");
verify.currentLineContentIs(" ;");
verify.currentLineContentIs(" ;");
goTo.marker("63");
verify.currentLineContentIs("do do do do");
goTo.marker("64");