mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-06 01:39:28 -06:00
fix(39047): handle extra spaces after the catch statement (#39306)
This commit is contained in:
parent
58ed610ef1
commit
ee5c3fa57d
@ -348,8 +348,8 @@ namespace ts.formatting {
|
||||
anyToken,
|
||||
[isNonJsxSameLineTokenContext, isNonJsxElementOrFragmentContext, isNotForContext],
|
||||
RuleAction.InsertSpace),
|
||||
// This low-pri rule takes care of "try {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter.
|
||||
rule("SpaceAfterTryFinally", [SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword], SyntaxKind.OpenBraceToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace),
|
||||
// This low-pri rule takes care of "try {", "catch {" and "finally {" in case the rule SpaceBeforeOpenBraceInControl didn't execute on FormatOnEnter.
|
||||
rule("SpaceAfterTryCatchFinally", [SyntaxKind.TryKeyword, SyntaxKind.CatchKeyword, SyntaxKind.FinallyKeyword], SyntaxKind.OpenBraceToken, [isNonJsxSameLineTokenContext], RuleAction.InsertSpace),
|
||||
];
|
||||
|
||||
return [
|
||||
|
||||
16
tests/cases/fourslash/formatCatch.ts
Normal file
16
tests/cases/fourslash/formatCatch.ts
Normal file
@ -0,0 +1,16 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////try {
|
||||
////} /*0*/catch {
|
||||
////}
|
||||
////
|
||||
////try {
|
||||
////} /*1*/catch{
|
||||
////}
|
||||
|
||||
format.document();
|
||||
|
||||
for (const marker of test.markers()) {
|
||||
goTo.marker(marker);
|
||||
verify.currentLineContentIs("} catch {");
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user