Skip to content

Commit afdd47c

Browse files
author
Andy
authored
Simplify rules for isControlFlowEndingStatement (microsoft#25693)
1 parent 8ef146e commit afdd47c

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

src/services/formatting/smartIndenter.ts

+2-9
Original file line numberDiff line numberDiff line change
@@ -579,17 +579,10 @@ namespace ts.formatting {
579579
function isControlFlowEndingStatement(kind: SyntaxKind, parent: TextRangeWithKind): boolean {
580580
switch (kind) {
581581
case SyntaxKind.ReturnStatement:
582-
case SyntaxKind.ThrowStatement: {
583-
if (parent.kind !== SyntaxKind.Block) {
584-
return true;
585-
}
586-
const grandParent = (parent as Node).parent;
587-
// In a function, we may want to write inner functions after this.
588-
return !(grandParent && grandParent.kind === SyntaxKind.FunctionExpression || grandParent.kind === SyntaxKind.FunctionDeclaration);
589-
}
582+
case SyntaxKind.ThrowStatement:
590583
case SyntaxKind.ContinueStatement:
591584
case SyntaxKind.BreakStatement:
592-
return true;
585+
return parent.kind !== SyntaxKind.Block;
593586
default:
594587
return false;
595588
}
+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/// <reference path='fourslash.ts'/>
2+
3+
//// function foo() {
4+
//// if (true) {
5+
//// {| "indentation": 8|}
6+
//// return;
7+
//// {| "indentation": 8|}
8+
//// }
9+
//// }
10+
11+
for (const marker of test.markers()) {
12+
verify.indentationAtPositionIs(marker.fileName, marker.position, marker.data.indentation);
13+
}

0 commit comments

Comments
 (0)