File tree Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Expand file tree Collapse file tree 2 files changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -103,7 +103,15 @@ public enum FixItApplier {
103103 return edit == remainingEdit
104104 }
105105
106- return remainingEdit. range. overlaps ( edit. range)
106+ // Edits conflict in the following cases:
107+ //
108+ // - Their ranges have a common element.
109+ // - One's range is empty and its lower bound is strictly within the
110+ // other's range. So 0..<2 also conflicts with 1..<1, but not with
111+ // 0..<0 or 2..<2.
112+ //
113+ return edit. endUtf8Offset > remainingEdit. startUtf8Offset
114+ && edit. startUtf8Offset < remainingEdit. endUtf8Offset
107115 }
108116
109117 guard !shouldDropRemainingEdit( ) else {
Original file line number Diff line number Diff line change @@ -232,9 +232,8 @@ class FixItApplierApplyEditsTests: XCTestCase {
232232 . init( range: 0 ..< 5 , replacement: " _ " ) , // Replacement
233233 . init( range: 2 ..< 2 , replacement: " a " ) , // Insertion
234234 ] ,
235- // FIXME: This behavior where these edits are not considered overlapping doesn't feel desirable
236235 outputs: [
237- . init( oneOf: " _x = 1" , " _ a = 1" )
236+ . init( oneOf: " _ = 1" , " vaar x = 1" )
238237 ]
239238 )
240239 }
You can’t perform that action at this time.
0 commit comments