@@ -33,6 +33,7 @@ public struct Configuration: Codable, Equatable {
33
33
case indentConditionalCompilationBlocks
34
34
case lineBreakAroundMultilineExpressionChainComponents
35
35
case fileScopedDeclarationPrivacy
36
+ case indentSwitchCaseLabels
36
37
case rules
37
38
}
38
39
@@ -120,6 +121,27 @@ public struct Configuration: Codable, Equatable {
120
121
/// declarations whose effective access level is private to the containing file.
121
122
public var fileScopedDeclarationPrivacy = FileScopedDeclarationPrivacyConfiguration ( )
122
123
124
+ /// Determines if `case` statements should be indented compared to the containing `switch` block.
125
+ ///
126
+ /// When `false`, the correct form is:
127
+ /// ```swift
128
+ /// switch someValue {
129
+ /// case someCase:
130
+ /// someStatement
131
+ /// ...
132
+ /// }
133
+ /// ```
134
+ ///
135
+ /// When `true`, the correct form is:
136
+ /// ```swift
137
+ /// switch someValue {
138
+ /// case someCase:
139
+ /// someStatement
140
+ /// ...
141
+ /// }
142
+ ///```
143
+ public var indentSwitchCaseLabels = false
144
+
123
145
/// Constructs a Configuration with all default values.
124
146
public init ( ) {
125
147
self . version = highestSupportedConfigurationVersion
@@ -176,6 +198,8 @@ public struct Configuration: Codable, Equatable {
176
198
try container. decodeIfPresent (
177
199
FileScopedDeclarationPrivacyConfiguration . self, forKey: . fileScopedDeclarationPrivacy)
178
200
?? FileScopedDeclarationPrivacyConfiguration ( )
201
+ self . indentSwitchCaseLabels
202
+ = try container. decodeIfPresent ( Bool . self, forKey: . indentSwitchCaseLabels) ?? false
179
203
180
204
// If the `rules` key is not present at all, default it to the built-in set
181
205
// so that the behavior is the same as if the configuration had been
@@ -203,6 +227,7 @@ public struct Configuration: Codable, Equatable {
203
227
lineBreakAroundMultilineExpressionChainComponents,
204
228
forKey: . lineBreakAroundMultilineExpressionChainComponents)
205
229
try container. encode ( fileScopedDeclarationPrivacy, forKey: . fileScopedDeclarationPrivacy)
230
+ try container. encode ( indentSwitchCaseLabels, forKey: . indentSwitchCaseLabels)
206
231
try container. encode ( rules, forKey: . rules)
207
232
}
208
233
0 commit comments