mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-14 19:16:17 -06:00
fix(55998): Ability to Place Open Brace On New Line For Try Catch Blocks (#56021)
This commit is contained in:
parent
e6d0f722e0
commit
65f33a2e92
@ -91,7 +91,7 @@ export function getAllRules(): RuleSpec[] {
|
||||
const typeScriptOpenBraceLeftTokenRange = tokenRangeFrom([SyntaxKind.Identifier, SyntaxKind.MultiLineCommentTrivia, SyntaxKind.ClassKeyword, SyntaxKind.ExportKeyword, SyntaxKind.ImportKeyword]);
|
||||
|
||||
// Place a space before open brace in a control flow construct
|
||||
const controlOpenBraceLeftTokenRange = tokenRangeFrom([SyntaxKind.CloseParenToken, SyntaxKind.MultiLineCommentTrivia, SyntaxKind.DoKeyword, SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword, SyntaxKind.ElseKeyword]);
|
||||
const controlOpenBraceLeftTokenRange = tokenRangeFrom([SyntaxKind.CloseParenToken, SyntaxKind.MultiLineCommentTrivia, SyntaxKind.DoKeyword, SyntaxKind.TryKeyword, SyntaxKind.FinallyKeyword, SyntaxKind.ElseKeyword, SyntaxKind.CatchKeyword]);
|
||||
|
||||
// These rules are higher in priority than user-configurable
|
||||
const highPriorityCommonRules = [
|
||||
|
||||
28
tests/cases/fourslash/formatIfTryCatchBlocks.ts
Normal file
28
tests/cases/fourslash/formatIfTryCatchBlocks.ts
Normal file
@ -0,0 +1,28 @@
|
||||
/// <reference path="fourslash.ts"/>
|
||||
|
||||
////try {
|
||||
////}
|
||||
////catch {
|
||||
////}
|
||||
////
|
||||
////try {
|
||||
////}
|
||||
////catch (e) {
|
||||
////}
|
||||
|
||||
format.setOption("PlaceOpenBraceOnNewLineForControlBlocks", true);
|
||||
format.document();
|
||||
verify.currentFileContentIs(
|
||||
`try
|
||||
{
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
}`);
|
||||
Loading…
x
Reference in New Issue
Block a user