diff --git a/Sources/Rules.swift b/Sources/Rules.swift index 5d196387..ecd4e8ee 100644 --- a/Sources/Rules.swift +++ b/Sources/Rules.swift @@ -1418,9 +1418,6 @@ public struct _FormatRules { formatter.removeToken(at: closingBraceIndex - 1) } } - guard !formatter.isStartOfClosure(at: i) else { - return - } if formatter.options.allmanBraces { // Implement Allman-style braces, where opening brace appears on the next line switch formatter.last(.nonSpace, before: i) ?? .space("") { diff --git a/Tests/RulesTests.swift b/Tests/RulesTests.swift index cd01b2e5..e68443b5 100644 --- a/Tests/RulesTests.swift +++ b/Tests/RulesTests.swift @@ -2420,7 +2420,8 @@ class RulesTests: XCTestCase { """ let options = FormatOptions(wrapArguments: .disabled, closingParenOnSameLine: true) - testFormatting(for: input, rule: FormatRules.indent, options: options) + testFormatting(for: input, rule: FormatRules.indent, options: options, + exclude: ["braces"]) } func testSingleIndentTrailingClosureBodyOfShortMethod() { @@ -2514,7 +2515,8 @@ class RulesTests: XCTestCase { } """ let options = FormatOptions(xcodeIndentation: true) - testFormatting(for: input, output, rule: FormatRules.indent, options: options) + testFormatting(for: input, output, rule: FormatRules.indent, options: options, + exclude: ["braces"]) } func testWrappedMultilineStringOnNewLineWithXcodeIndentation() { @@ -3414,31 +3416,6 @@ class RulesTests: XCTestCase { testFormatting(for: input, rule: FormatRules.braces) } - func testKnRBracesIgnoresClosure() { - let input = """ - let foo = - { bar in - print(bar) - } - """ - testFormatting(for: input, rule: FormatRules.braces) - } - - func testUnbalancedClosingClosureBraceCorrected() { - let input = """ - let foo = - { bar in - print(bar) } - """ - let output = """ - let foo = - { bar in - print(bar) - } - """ - testFormatting(for: input, output, rule: FormatRules.braces) - } - func testAllmanComputedPropertyBracesConverted() { let input = """ var foo: Int @@ -8105,7 +8082,7 @@ class RulesTests: XCTestCase { true } """ - let options = FormatOptions(maxWidth: 20) + let options = FormatOptions(allmanBraces: true, maxWidth: 20) testFormatting(for: input, [output, output2], rules: [FormatRules.wrap], options: options) } @@ -8124,7 +8101,7 @@ class RulesTests: XCTestCase { bar } """ - let options = FormatOptions(maxWidth: 20) + let options = FormatOptions(allmanBraces: true, maxWidth: 20) testFormatting(for: input, [output, output2], rules: [FormatRules.wrap], options: options) } @@ -8743,8 +8720,7 @@ class RulesTests: XCTestCase { var mathFunction: (Int, Int, String) - -> Int = - { _, _, _ in + -> Int = { _, _, _ in 0 } """ diff --git a/Tests/XCTestManifests.swift b/Tests/XCTestManifests.swift index 6a9bb06b..8b3a9f9b 100644 --- a/Tests/XCTestManifests.swift +++ b/Tests/XCTestManifests.swift @@ -813,7 +813,6 @@ extension RulesTests { ("testKnRBracesAfterMultilineComment", testKnRBracesAfterMultilineComment), ("testKnRBracesAfterMultilineComment2", testKnRBracesAfterMultilineComment2), ("testKnRBracesAreConverted", testKnRBracesAreConverted), - ("testKnRBracesIgnoresClosure", testKnRBracesIgnoresClosure), ("testKnRClosingBraceWrapped", testKnRClosingBraceWrapped), ("testKnRExtraSpaceNotAddedBeforeBrace", testKnRExtraSpaceNotAddedBeforeBrace), ("testKnRInlineBracesNotWrapped", testKnRInlineBracesNotWrapped), @@ -1721,7 +1720,6 @@ extension RulesTests { ("testTypeAttributeStaysWrapped", testTypeAttributeStaysWrapped), ("testTypedClosureArgumentNotUnwrapped", testTypedClosureArgumentNotUnwrapped), ("testTypedMultipleClosureArgumentNotUnwrapped", testTypedMultipleClosureArgumentNotUnwrapped), - ("testUnbalancedClosingClosureBraceCorrected", testUnbalancedClosingClosureBraceCorrected), ("testUnhoistCaseLet", testUnhoistCaseLet), ("testUnhoistCaseVar", testUnhoistCaseVar), ("testUnhoistCatchLet", testUnhoistCatchLet),