diff --git a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift index 5d0f003f3..1023d886f 100644 --- a/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift +++ b/Sources/SwiftFormat/PrettyPrint/TokenStreamCreator.swift @@ -1802,6 +1802,11 @@ fileprivate final class TokenStreamCreator: SyntaxVisitor { override func visit(_ node: OriginallyDefinedInAttributeArgumentsSyntax) -> SyntaxVisitorContinueKind { after(node.colon.lastToken(viewMode: .sourceAccurate), tokens: .break(.same, size: 1)) after(node.comma.lastToken(viewMode: .sourceAccurate), tokens: .break(.same, size: 1)) + return .visitChildren + } + + override func visit(_ node: DocumentationAttributeArgumentSyntax) -> SyntaxVisitorContinueKind { + after(node.colon, tokens: .break(.same, size: 1)) return .visitChildren } diff --git a/Tests/SwiftFormatTests/PrettyPrint/AttributeTests.swift b/Tests/SwiftFormatTests/PrettyPrint/AttributeTests.swift index 1289dad96..3031fc31b 100644 --- a/Tests/SwiftFormatTests/PrettyPrint/AttributeTests.swift +++ b/Tests/SwiftFormatTests/PrettyPrint/AttributeTests.swift @@ -43,6 +43,23 @@ final class AttributeTests: PrettyPrintTestCase { assertPrettyPrintEqual(input: input, expected: expected, linelength: 60) } + func testAttributeParamSpacingInDocVisibility() { + let input = + """ + @_documentation( visibility :private ) + func f() {} + """ + + let expected = + """ + @_documentation(visibility: private) + func f() {} + + """ + + assertPrettyPrintEqual(input: input, expected: expected, linelength: 60) + } + func testAttributeBinPackedWrapping() { let input = """