mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
indent expressions
This commit is contained in:
parent
077e0bd9b5
commit
06bf74a029
@ -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:
|
||||
|
||||
@ -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:
|
||||
|
||||
35
tests/cases/fourslash/formatVariableAssignments.ts
Normal file
35
tests/cases/fourslash/formatVariableAssignments.ts
Normal 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;");
|
||||
@ -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");
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user