File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
Sources/SourceKitLSP/Swift Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change @@ -162,6 +162,13 @@ fileprivate final class FoldingRangeFinder: SyntaxAnyVisitor {
162
162
)
163
163
}
164
164
165
+ override func visit( _ node: SwitchCaseSyntax ) -> SyntaxVisitorContinueKind {
166
+ return self . addFoldingRange (
167
+ start: node. label. endPositionBeforeTrailingTrivia. utf8Offset,
168
+ end: node. statements. endPosition. utf8Offset
169
+ )
170
+ }
171
+
165
172
__consuming func finalize( ) -> Set < FoldingRange > {
166
173
return self . ranges
167
174
}
Original file line number Diff line number Diff line change @@ -283,4 +283,24 @@ final class FoldingRangeTests: XCTestCase {
283
283
]
284
284
)
285
285
}
286
+
287
+ func testFoldSwitchCase( ) async throws {
288
+ try await assertFoldingRanges (
289
+ markedSource: """
290
+ switch foo {1️⃣
291
+ case 1:2️⃣
292
+ break 3️⃣
293
+ default:4️⃣
294
+ let x = 1
295
+ print(5️⃣x6️⃣)7️⃣
296
+ 8️⃣}
297
+ """ ,
298
+ expectedRanges: [
299
+ FoldingRangeSpec ( from: " 1️⃣ " , to: " 8️⃣ " ) ,
300
+ FoldingRangeSpec ( from: " 2️⃣ " , to: " 3️⃣ " ) ,
301
+ FoldingRangeSpec ( from: " 4️⃣ " , to: " 7️⃣ " ) ,
302
+ FoldingRangeSpec ( from: " 5️⃣ " , to: " 6️⃣ " ) ,
303
+ ]
304
+ )
305
+ }
286
306
}
You can’t perform that action at this time.
0 commit comments