File tree 2 files changed +14
-7
lines changed
2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -86,6 +86,11 @@ class DiffTests: XCTestCase {
86
86
}
87
87
}
88
88
89
+ func testSingleElementArray( ) {
90
+ let changes = " a " . diff ( to: " a " )
91
+ XCTAssertEqual ( changes. elements. count, 0 )
92
+ }
93
+
89
94
func duplicateTraces( from: String , to: String ) -> Bool {
90
95
let traces = from. characters. diffTraces ( to: to. characters)
91
96
let tracesSet = Set ( traces)
Original file line number Diff line number Diff line change @@ -294,13 +294,15 @@ public extension Collection where Iterator.Element: Equatable {
294
294
var item = traces. last!
295
295
array. append ( item)
296
296
297
- for trace in traces. reversed ( ) {
298
- if trace. to. x == item. from. x && trace. to. y == item. from. y {
299
- array. insert ( trace, at: 0 )
300
- item = trace
301
-
302
- if trace. from == Point ( x: 0 , y: 0 ) {
303
- break
297
+ if item. from != Point ( x: 0 , y: 0 ) {
298
+ for trace in traces. reversed ( ) {
299
+ if trace. to. x == item. from. x && trace. to. y == item. from. y {
300
+ array. insert ( trace, at: 0 )
301
+ item = trace
302
+
303
+ if trace. from == Point ( x: 0 , y: 0 ) {
304
+ break
305
+ }
304
306
}
305
307
}
306
308
}
You can’t perform that action at this time.
0 commit comments