@@ -68,7 +68,7 @@ public enum FixItApplier {
68
68
source. replaceSubrange ( startIndex..< endIndex, with: edit. replacement)
69
69
70
70
edits = edits. compactMap { remainingEdit -> SourceEdit ? in
71
- if remainingEdit. replacementRange . overlaps ( edit. replacementRange ) {
71
+ if remainingEdit. range . overlaps ( edit. range ) {
72
72
// The edit overlaps with the previous edit. We can't apply both
73
73
// without conflicts. Apply the one that's listed first and drop the
74
74
// later edit.
@@ -78,12 +78,10 @@ public enum FixItApplier {
78
78
// If the remaining edit starts after or at the end of the edit that we just applied,
79
79
// shift it by the current edit's difference in length.
80
80
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
+
87
85
return SourceEdit ( range: startPosition..< endPosition, replacement: remainingEdit. replacement)
88
86
}
89
87
@@ -103,8 +101,4 @@ private extension SourceEdit {
103
101
var endUtf8Offset : Int {
104
102
return range. upperBound. utf8Offset
105
103
}
106
-
107
- var replacementRange : Range < Int > {
108
- return startUtf8Offset..< endUtf8Offset
109
- }
110
104
}
0 commit comments