@@ -220,6 +220,35 @@ final class LocalSwiftTests: XCTestCase {
220
220
XCTAssertNotEqual ( after, selfDot)
221
221
}
222
222
223
+ func testCompletionPosition( ) {
224
+ let url = URL ( fileURLWithPath: " /a.swift " )
225
+ sk. allowUnexpectedNotification = true
226
+
227
+ sk. send ( DidOpenTextDocument ( textDocument: TextDocumentItem (
228
+ url: url,
229
+ language: . swift,
230
+ version: 12 ,
231
+ text: " foo " ) ) )
232
+
233
+ for col in 0 ... 3 {
234
+ let inOrAfterFoo = try ! sk. sendSync ( CompletionRequest (
235
+ textDocument: TextDocumentIdentifier ( url) ,
236
+ position: Position ( line: 0 , utf16index: col) ) )
237
+ XCTAssertFalse ( inOrAfterFoo. isIncomplete)
238
+ XCTAssertFalse ( inOrAfterFoo. items. isEmpty)
239
+ }
240
+
241
+ let outOfRange1 = try ! sk. sendSync ( CompletionRequest (
242
+ textDocument: TextDocumentIdentifier ( url) ,
243
+ position: Position ( line: 0 , utf16index: 4 ) ) )
244
+ XCTAssertTrue ( outOfRange1. isIncomplete)
245
+
246
+ let outOfRange2 = try ! sk. sendSync ( CompletionRequest (
247
+ textDocument: TextDocumentIdentifier ( url) ,
248
+ position: Position ( line: 1 , utf16index: 0 ) ) )
249
+ XCTAssertTrue ( outOfRange2. isIncomplete)
250
+ }
251
+
223
252
func testXMLToMarkdownDeclaration( ) {
224
253
XCTAssertEqual ( try ! xmlDocumentationToMarkdown ( """
225
254
<Declaration>func foo(_ bar: <Type usr= " fake " >Baz</Type>)</Declaration>
0 commit comments