Skip to content

Commit a31ef92

Browse files
committed
FixItApplier: Non-empty insertions can conflict with other edits
1 parent c8d5641 commit a31ef92

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
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: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -206,10 +206,9 @@ class FixItApplierApplyEditsTests: XCTestCase {
206206
.init(range: 0..<5, replacement: "_"), // Replacement
207207
.init(range: 2..<2, replacement: "a"), // Insertion
208208
],
209-
// FIXME: This behavior where these edits are not considered overlapping doesn't feel desirable
210209
outputs: [
211-
.init("_x = 1"),
212-
.init("_ a= 1"),
210+
.init("_ = 1"),
211+
.init("vaar x = 1"),
213212
]
214213
)
215214
}

0 commit comments

Comments
 (0)