Skip to content

Commit 6d46beb

Browse files
author
Andy Hanson
committed
Undo smartIndenter change (no longer related)
1 parent 0e5eae3 commit 6d46beb

1 file changed

Lines changed: 19 additions & 8 deletions

File tree

src/services/formatting/smartIndenter.ts

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -565,15 +565,26 @@ namespace ts.formatting {
565565
function isControlFlowEndingStatement(kind: SyntaxKind, parent: TextRangeWithKind): boolean {
566566
switch (kind) {
567567
case SyntaxKind.ReturnStatement:
568-
case SyntaxKind.ThrowStatement: {
569-
const parentKind = parent.kind as StatementOnly["parent"]["kind"];
570-
if (parentKind !== SyntaxKind.Block) {
571-
return true;
568+
case SyntaxKind.ThrowStatement:
569+
switch (parent.kind) {
570+
case SyntaxKind.Block:
571+
const grandParent = (parent as Node).parent;
572+
switch (grandParent && grandParent.kind) {
573+
case SyntaxKind.FunctionDeclaration:
574+
case SyntaxKind.FunctionExpression:
575+
// We may want to write inner functions after this.
576+
return false;
577+
default:
578+
return true;
579+
}
580+
case SyntaxKind.CaseClause:
581+
case SyntaxKind.DefaultClause:
582+
case SyntaxKind.SourceFile:
583+
case SyntaxKind.ModuleBlock:
584+
return true;
585+
default:
586+
throw Debug.fail();
572587
}
573-
const grandParent = (parent as Node).parent;
574-
// In a function, we may want to write inner functions after this.
575-
return !(grandParent && grandParent.kind === SyntaxKind.FunctionExpression || grandParent.kind === SyntaxKind.FunctionDeclaration);
576-
}
577588
case SyntaxKind.ContinueStatement:
578589
case SyntaxKind.BreakStatement:
579590
return true;

0 commit comments

Comments
 (0)