diff --git a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift index 1023d886f..76592a48d 100644 --- a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift +++ b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift @@ -3911,6 +3911,7 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor { before(clause.poundKeyword, tokens: .break(.contextual, size: 0)) } before(postfixIfExpr.config.poundEndif, tokens: .break(.contextual, size: 0)) + after(postfixIfExpr.config.poundEndif, tokens: .break(.same, size: 0)) return insertContextualBreaks(base, isTopLevel: false) } else if let callingExpr = expr.asProtocol(CallingExprSyntaxProtocol.self) { diff --git a/Tests/SwiftFormatTests/PrettyPrint/IfConfigTests.swift b/Tests/SwiftFormatTests/PrettyPrint/IfConfigTests.swift index 4f8026ab4..5a6113529 100644 --- a/Tests/SwiftFormatTests/PrettyPrint/IfConfigTests.swift +++ b/Tests/SwiftFormatTests/PrettyPrint/IfConfigTests.swift @@ -516,4 +516,19 @@ final class IfConfigTests: PrettyPrintTestCase { assertPrettyPrintEqual(input: input, expected: expected, linelength: 45) } + + func testPostfixPoundIfInParameterList() { + let input = + """ + print( + 32 + #if true + .foo + #endif + , 22 + ) + + """ + assertPrettyPrintEqual(input: input, expected: input, linelength: 45) + } }