diff --git a/Sources/Rules/OrganizeDeclarations.swift b/Sources/Rules/OrganizeDeclarations.swift index f9fd123dc..f37e590b7 100644 --- a/Sources/Rules/OrganizeDeclarations.swift +++ b/Sources/Rules/OrganizeDeclarations.swift @@ -524,8 +524,7 @@ extension Formatter { Array(Set([ // The user's specific category separator template $0.markCommentBody(from: options.categoryMarkComment, with: options.organizationMode), - // Other common variants that we would want to replace with the correct variant - $0.markCommentBody(from: "%c", with: options.organizationMode), + // Always look for MARKs even if the user is using a different template $0.markCommentBody(from: "MARK: %c", with: options.organizationMode), ])) }.compactMap { $0 } diff --git a/Tests/Rules/OrganizeDeclarationsTests.swift b/Tests/Rules/OrganizeDeclarationsTests.swift index 8a337568a..53a963eaf 100644 --- a/Tests/Rules/OrganizeDeclarationsTests.swift +++ b/Tests/Rules/OrganizeDeclarationsTests.swift @@ -1568,9 +1568,9 @@ class OrganizeDeclarationsTests: XCTestCase { init() {} - // Public + // mark: Public - // - Public + // mark - Public public func bar() {} @@ -3593,4 +3593,17 @@ class OrganizeDeclarationsTests: XCTestCase { testFormatting(for: input, output, rule: .organizeDeclarations, exclude: [.blankLinesAtStartOfScope]) } + + func testPreservesUnrelatedComments() { + let input = """ + enum Test { + /// Test Properties + static let foo = "foo" + static let bar = "bar" + static let baaz = "baaz" + } + """ + + testFormatting(for: input, rule: .organizeDeclarations) + } }