@@ -68,7 +68,7 @@ public enum FixItApplier {
6868 source. replaceSubrange ( startIndex..< endIndex, with: edit. replacement)
6969
7070 edits = edits. compactMap { remainingEdit -> SourceEdit ? in
71- if remainingEdit. replacementRange . overlaps ( edit. replacementRange ) {
71+ if remainingEdit. range . overlaps ( edit. range ) {
7272 // The edit overlaps with the previous edit. We can't apply both
7373 // without conflicts. Apply the one that's listed first and drop the
7474 // later edit.
@@ -78,12 +78,10 @@ public enum FixItApplier {
7878 // If the remaining edit starts after or at the end of the edit that we just applied,
7979 // shift it by the current edit's difference in length.
8080 if edit. endUtf8Offset <= remainingEdit. startUtf8Offset {
81- let startPosition = AbsolutePosition (
82- utf8Offset: remainingEdit. startUtf8Offset - edit. replacementRange. count + edit. replacementLength. utf8Length
83- )
84- let endPosition = AbsolutePosition (
85- utf8Offset: remainingEdit. endUtf8Offset - edit. replacementRange. count + edit. replacementLength. utf8Length
86- )
81+ let shift = edit. replacementLength. utf8Length - edit. range. count
82+ let startPosition = AbsolutePosition ( utf8Offset: remainingEdit. startUtf8Offset + shift)
83+ let endPosition = AbsolutePosition ( utf8Offset: remainingEdit. endUtf8Offset + shift)
84+
8785 return SourceEdit ( range: startPosition..< endPosition, replacement: remainingEdit. replacement)
8886 }
8987
@@ -103,8 +101,4 @@ private extension SourceEdit {
103101 var endUtf8Offset : Int {
104102 return range. upperBound. utf8Offset
105103 }
106-
107- var replacementRange : Range < Int > {
108- return startUtf8Offset..< endUtf8Offset
109- }
110104}
0 commit comments