Skip to content

Commit f384851

Browse files
authored
Merge pull request #2332 from ahoppen/subscript-completions
Test that we get subscript completions when completing after `[`
2 parents 79964c8 + 45c3704 commit f384851

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)