Skip to content

Commit b932f78

Browse files
committed
Update one more test
1 parent 03431b8 commit b932f78

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

Tests/SourceKitLSPTests/OnTypeFormattingTests.swift

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,13 @@ final class OnTypeFormattingTests: XCTestCase {
5454
let testClient = try await TestSourceKitLSPClient()
5555
let uri = DocumentURI(for: .swift)
5656

57-
let positions = testClient.openDocument(
58-
"""
57+
let source = """
5958
func foo() {
6059
1️⃣if let SomeReallyLongVar = 2️⃣ 3️⃣Some.More.Stuff(), let a = 4️⃣ 5️⃣myfunc() 6️⃣{
6160
}
6261
}
63-
""",
64-
uri: uri
65-
)
62+
"""
63+
let positions = testClient.openDocument(source, uri: uri)
6664

6765
let response = try await testClient.send(
6866
DocumentOnTypeFormattingRequest(
@@ -74,13 +72,18 @@ final class OnTypeFormattingTests: XCTestCase {
7472
)
7573

7674
let edits = try XCTUnwrap(response)
75+
let (_, unmarkedSource) = extractMarkers(source)
76+
let formattedSource = unmarkedSource.applying(edits)
77+
7778
XCTAssertEqual(
78-
edits,
79-
[
80-
TextEdit(range: Range(positions["1️⃣"]), newText: " "),
81-
TextEdit(range: positions["2️⃣"]..<positions["3️⃣"], newText: ""),
82-
TextEdit(range: positions["4️⃣"]..<positions["5️⃣"], newText: ""),
83-
]
79+
formattedSource,
80+
"""
81+
func foo() {
82+
if let SomeReallyLongVar = Some.More.Stuff(), let a = myfunc() {
83+
}
84+
}
85+
86+
"""
8487
)
8588
}
8689

0 commit comments

Comments
 (0)