Skip to content

Commit 45c3704

Browse files
committed
Test that we get subscript completions when completing after [
Noticed that we don’t have any test for this when investigating #798.
1 parent 79964c8 commit 45c3704

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Tests/SourceKitLSPTests/SwiftCompletionTests.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,6 +1443,23 @@ final class SwiftCompletionTests: XCTestCase {
14431443
)
14441444
XCTAssert(completions.items.contains(where: { $0.label.contains("myFancyFunction") }))
14451445
}
1446+
1447+
func testSubscriptCompletions() async throws {
1448+
let testClient = try await TestSourceKitLSPClient()
1449+
let uri = DocumentURI(for: .swift)
1450+
let positions = testClient.openDocument(
1451+
"""
1452+
func foo(x: [Int: Int]) {
1453+
x[1️⃣
1454+
}
1455+
""",
1456+
uri: uri
1457+
)
1458+
let completions = try await testClient.send(
1459+
CompletionRequest(textDocument: TextDocumentIdentifier(uri), position: positions["1️⃣"])
1460+
)
1461+
assertContains(completions.items.map(\.label), "[key: Int, default: Int]")
1462+
}
14461463
}
14471464

14481465
private func countFs(_ response: CompletionList) -> Int {

0 commit comments

Comments
 (0)