Skip to content

Commit 2c3be44

Browse files
authored
fix(60887): Incorrect Formatting on if (a) try {} finally {} (#60898)
1 parent 8ae98d0 commit 2c3be44

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

src/services/formatting/smartIndenter.ts

+5
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,11 @@ export namespace SmartIndenter {
729729
return false;
730730
}
731731
break;
732+
case SyntaxKind.TryStatement:
733+
if (childKind === SyntaxKind.Block) {
734+
return false;
735+
}
736+
break;
732737
}
733738
// No explicit rule for given nodes so the result will follow the default value argument
734739
return indentByDefault;
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// <reference path="fourslash.ts"/>
2+
3+
////if (true) try {
4+
//// // ...
5+
////} finally {
6+
//// // ...
7+
////}
8+
9+
format.document();
10+
verify.currentFileContentIs(
11+
`if (true) try {
12+
// ...
13+
} finally {
14+
// ...
15+
}`);

0 commit comments

Comments
 (0)