diff --git a/src/services/formatting/smartIndenter.ts b/src/services/formatting/smartIndenter.ts index c6ed975a1a516..7f41a2701b8c3 100644 --- a/src/services/formatting/smartIndenter.ts +++ b/src/services/formatting/smartIndenter.ts @@ -729,6 +729,11 @@ export namespace SmartIndenter { return false; } break; + case SyntaxKind.TryStatement: + if (childKind === SyntaxKind.Block) { + return false; + } + break; } // No explicit rule for given nodes so the result will follow the default value argument return indentByDefault; diff --git a/tests/cases/fourslash/formatTryFinally.ts b/tests/cases/fourslash/formatTryFinally.ts new file mode 100644 index 0000000000000..d81cd45e79366 --- /dev/null +++ b/tests/cases/fourslash/formatTryFinally.ts @@ -0,0 +1,15 @@ +/// + +////if (true) try { +//// // ... +////} finally { +//// // ... +////} + +format.document(); +verify.currentFileContentIs( +`if (true) try { + // ... +} finally { + // ... +}`);