fix(39047): handle extra spaces after the catch statement (#39306)

This commit is contained in:
Alexander T 2020-06-29 20:10:44 +03:00 committed by GitHub
parent 58ed610ef1
commit ee5c3fa57d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 2 deletions

View File

@ -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 [

View 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 {");
}