Skip to content

Commit 2c75d54

Browse files
committed
FixItApplier: Non-empty insertions can conflict with other edits
1 parent 3a2b93a commit 2c75d54

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Sources/SwiftIDEUtils/FixItApplier.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,9 @@ public enum FixItApplier {
106106
return false
107107
}
108108

109-
return remainingEdit.range.overlaps(edit.range)
109+
// Anything else that is not disjoint bound-wise will conflict.
110+
return edit.endUtf8Offset > remainingEdit.startUtf8Offset
111+
&& edit.startUtf8Offset < remainingEdit.endUtf8Offset
110112
}
111113

112114
guard !shouldDropRemainingEdit() else {

Tests/SwiftIDEUtilsTest/FixItApplierTests.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,9 +200,8 @@ class FixItApplierApplyEditsTests: XCTestCase {
200200
.init(range: 0..<5, replacement: "_"), // Replacement
201201
.init(range: 2..<2, replacement: "a"), // Insertion
202202
],
203-
// FIXME: This behavior where these edits are not considered overlapping doesn't feel desirable
204203
outputs: [
205-
.either(["_x = 1", "_ a= 1"])
204+
.either(["_ = 1", "vaar x = 1"])
206205
]
207206
)
208207
}

0 commit comments

Comments
 (0)