@@ -159,11 +159,11 @@ final class CodeLensTests: XCTestCase {
159159 CodeLens (
160160 range: positions [ " 3️⃣ " ] ..< positions [ " 4️⃣ " ] ,
161161 command: Command (
162- title: " Play \" MyApp/Test.swift:7 \" " ,
162+ title: " Play \" MyApp/Test.swift:7:1 \" " ,
163163 command: " swift.play " ,
164164 arguments: [
165165 TextDocumentPlayground (
166- id: " MyApp/Test.swift:7 " ,
166+ id: " MyApp/Test.swift:7:1 " ,
167167 label: nil ,
168168 range: positions [ " 3️⃣ " ] ..< positions [ " 4️⃣ " ] ,
169169 ) . encodeToLSPAny ( )
@@ -177,7 +177,7 @@ final class CodeLensTests: XCTestCase {
177177 command: " swift.play " ,
178178 arguments: [
179179 TextDocumentPlayground (
180- id: " MyApp/Test.swift:11 " ,
180+ id: " MyApp/Test.swift:11:1 " ,
181181 label: " named " ,
182182 range: positions [ " 5️⃣ " ] ..< positions [ " 6️⃣ " ] ,
183183 ) . encodeToLSPAny ( )
@@ -188,6 +188,76 @@ final class CodeLensTests: XCTestCase {
188188 )
189189 }
190190
191+ func testMultiplePlaygroundCodeLensOnLine( ) async throws {
192+ var codeLensCapabilities = TextDocumentClientCapabilities . CodeLens ( )
193+ codeLensCapabilities. supportedCommands = [
194+ SupportedCodeLensCommand . play: " swift.play " ,
195+ ]
196+ let capabilities = ClientCapabilities ( textDocument: TextDocumentClientCapabilities ( codeLens: codeLensCapabilities) )
197+ let toolchainRegistry = ToolchainRegistry ( toolchains: [ toolchainWithSwiftPlay] )
198+
199+ let project = try await SwiftPMTestProject (
200+ files: [
201+ " Sources/MyApp/Test.swift " : """
202+ import Playgrounds
203+ 1️⃣#Playground { print( " Hello Playground! " ) }2️⃣; 3️⃣#Playground { print( " Hello Again! " ) }4️⃣
204+ """
205+ ] ,
206+ manifest: """
207+ // swift-tools-version: 5.7
208+
209+ import PackageDescription
210+
211+ let package = Package(
212+ name: " MyApp " ,
213+ targets: [.executableTarget(name: " MyApp " )]
214+ )
215+ """ ,
216+ capabilities: capabilities,
217+ toolchainRegistry: toolchainRegistry
218+ )
219+
220+ let ( uri, positions) = try project. openDocument ( " Test.swift " )
221+
222+ let response = try await project. testClient. send (
223+ CodeLensRequest ( textDocument: TextDocumentIdentifier ( uri) )
224+ )
225+
226+ XCTAssertEqual (
227+ response,
228+ [
229+ CodeLens (
230+ range: positions [ " 1️⃣ " ] ..< positions [ " 2️⃣ " ] ,
231+ command: Command (
232+ title: " Play \" MyApp/Test.swift:2:1 \" " ,
233+ command: " swift.play " ,
234+ arguments: [
235+ TextDocumentPlayground (
236+ id: " MyApp/Test.swift:2:1 " ,
237+ label: nil ,
238+ range: positions [ " 1️⃣ " ] ..< positions [ " 2️⃣ " ] ,
239+ ) . encodeToLSPAny ( )
240+ ]
241+ )
242+ ) ,
243+ CodeLens (
244+ range: positions [ " 3️⃣ " ] ..< positions [ " 4️⃣ " ] ,
245+ command: Command (
246+ title: " Play \" MyApp/Test.swift:2:46 \" " ,
247+ command: " swift.play " ,
248+ arguments: [
249+ TextDocumentPlayground (
250+ id: " MyApp/Test.swift:2:46 " ,
251+ label: nil ,
252+ range: positions [ " 3️⃣ " ] ..< positions [ " 4️⃣ " ] ,
253+ ) . encodeToLSPAny ( )
254+ ]
255+ )
256+ ) ,
257+ ]
258+ )
259+ }
260+
191261 func testCodeLensRequestSwiftPlayMissing( ) async throws {
192262 var codeLensCapabilities = TextDocumentClientCapabilities . CodeLens ( )
193263 codeLensCapabilities. supportedCommands = [
0 commit comments