File tree Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Expand file tree Collapse file tree 1 file changed +14
-11
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments