Skip to content

[SR-11195] swift-format should allow a trailing array literal without wrapping earlier arguments #356

Open
@benlangmuir

Description

@benlangmuir
Previous ID SR-11195
Radar None
Original Reporter @benlangmuir
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s swift-format
Labels Improvement
Assignee None
Priority Medium

md5: 176b0e1a10655367bcdecb8bcb8a133d

Issue Description:

swift-format makes the following change:

-    XCTAssertEqual(ranges, [
-      FoldingRange(startLine: 0, endLine: 1, kind: .comment),
-      FoldingRange(startLine: 3, endLine: 12, kind: .comment),
-      FoldingRange(startLine: 14, endLine: 26, kind: nil),
-      FoldingRange(startLine: 17, endLine: 18, kind: .comment),
-      FoldingRange(startLine: 22, endLine: 24, kind: nil),
-      FoldingRange(startLine: 29, endLine: 31, kind: .comment),
-      FoldingRange(startLine: 33, endLine: 35, kind: .comment),
-    ])
+    XCTAssertEqual(
+      ranges,
+      [
+        FoldingRange(startLine: 0, endLine: 1, kind: .comment),
+        FoldingRange(startLine: 3, endLine: 12, kind: .comment),
+        FoldingRange(startLine: 14, endLine: 26, kind: nil),
+        FoldingRange(startLine: 17, endLine: 18, kind: .comment),
+        FoldingRange(startLine: 22, endLine: 24, kind: nil),
+        FoldingRange(startLine: 29, endLine: 31, kind: .comment),
+        FoldingRange(startLine: 33, endLine: 35, kind: .comment),
+      ])
   }

I think the original code is preferable, as it visually feels similar to the way a trailing closure would be handled. It also makes it look more like the single-argument case after https://bugs.swift.org/browse/SR-11106 is fixed.

This could be treated as a narrow exception that only applies to the last argument.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions