Skip to content

Commit dc186d7

Browse files
authored
Merge pull request #40 from ra1028/v0.7.2
v0.7.2
2 parents d717448 + d0bba3e commit dc186d7

20 files changed

Lines changed: 44 additions & 30 deletions

DifferenceKit.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |spec|
22
spec.name = 'DifferenceKit'
3-
spec.version = '0.7.1'
3+
spec.version = '0.7.2'
44
spec.author = { 'ra1028' => 'r.fe51028.r@gmail.com' }
55
spec.homepage = 'https://github.com/ra1028/DifferenceKit'
66
spec.documentation_url = 'https://ra1028.github.io/DifferenceKit'

Sources/Algorithm.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
269269
// If the element target section is recorded as insertion, record its element path as deletion.
270270
if let targetElementPath = sourceElementTraces[sourceElementPath].reference,
271271
case .some = sectionResult.metadata.targetReferences[targetElementPath.section] {
272-
let sourceElement = contiguousSourceSections[sourceElementPath]
273-
firstStageElements.append(sourceElement)
272+
let targetElement = contiguousTargetSections[targetElementPath]
273+
firstStageElements.append(targetElement)
274274
continue
275275
}
276276

@@ -322,10 +322,10 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
322322
sourceElementTraces[sourceElementPath].isTracked = true
323323

324324
let sourceElement = contiguousSourceSections[sourceElementPath]
325-
thirdStageElements.append(sourceElement)
325+
thirdStageElements.append(targetElement)
326326

327327
if !targetElement.isContentEqual(to: sourceElement) {
328-
elementUpdated.append(targetElementPath)
328+
elementUpdated.append(sourceElementPath)
329329
}
330330

331331
if sourceElementPath.section != sourceSectionIndex || sourceElementPath.element != untrackedSourceIndex {
@@ -345,17 +345,19 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
345345
// - Includes:
346346
// - section deletes
347347
// - element deletes
348-
if !sectionResult.deleted.isEmpty || !elementDeleted.isEmpty {
348+
// - element updates
349+
if !sectionResult.deleted.isEmpty || !elementDeleted.isEmpty || !elementUpdated.isEmpty {
349350
changesets.append(
350351
Changeset(
351352
data: Collection(firstStageSections),
352353
sectionDeleted: sectionResult.deleted,
353-
elementDeleted: elementDeleted
354+
elementDeleted: elementDeleted,
355+
elementUpdated: elementUpdated
354356
)
355357
)
356358
}
357359

358-
// The 2st stage changeset.
360+
// The 2nd stage changeset.
359361
// - Includes:
360362
// - section inserts
361363
// - section moves
@@ -369,7 +371,7 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
369371
)
370372
}
371373

372-
// The 3st stage changeset.
374+
// The 3rd stage changeset.
373375
// - Includes:
374376
// - element inserts
375377
// - element moves
@@ -383,16 +385,14 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
383385
)
384386
}
385387

386-
// The 3st stage changeset.
388+
// The 4th stage changeset.
387389
// - Includes:
388390
// - section updates
389-
// - element updates
390-
if !sectionResult.updated.isEmpty || !elementUpdated.isEmpty {
391+
if !sectionResult.updated.isEmpty {
391392
changesets.append(
392393
Changeset(
393394
data: target,
394-
sectionUpdated: sectionResult.updated,
395-
elementUpdated: elementUpdated
395+
sectionUpdated: sectionResult.updated
396396
)
397397
)
398398
}

Sources/AnyDifferentiable.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public struct AnyDifferentiable: Differentiable {
6262

6363
extension AnyDifferentiable: CustomDebugStringConvertible {
6464
public var debugDescription: String {
65-
return "AnyDifferentiable(\(String(reflecting: base))"
65+
return "AnyDifferentiable(\(String(reflecting: base)))"
6666
}
6767
}
6868

Sources/Extensions/AppKitExtension.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ public extension NSTableView {
6464
setData(data)
6565
return reloadData()
6666
}
67+
6768
beginUpdates()
6869
setData(changeset.data)
6970

@@ -82,6 +83,7 @@ public extension NSTableView {
8283
for (source, target) in changeset.elementMoved {
8384
moveRow(at: source.element, to: target.element)
8485
}
86+
8587
endUpdates()
8688
}
8789
}

Sources/Extensions/UIKitExtension.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public extension UITableView {
6868
return reloadData()
6969
}
7070

71+
let contentOffset = self.contentOffset
72+
7173
for changeset in stagedChangeset {
7274
if let interrupt = interrupt, interrupt(changeset), let data = stagedChangeset.last?.data {
7375
setData(data)
@@ -110,6 +112,10 @@ public extension UITableView {
110112
}
111113
}
112114
}
115+
116+
if contentSize.height > bounds.size.height {
117+
setContentOffset(contentOffset, animated: false)
118+
}
113119
}
114120

115121
private func _performBatchUpdates(_ updates: () -> Void) {
@@ -146,6 +152,8 @@ public extension UICollectionView {
146152
return reloadData()
147153
}
148154

155+
let contentOffset = self.contentOffset
156+
149157
for changeset in stagedChangeset {
150158
if let interrupt = interrupt, interrupt(changeset), let data = stagedChangeset.last?.data {
151159
setData(data)
@@ -188,6 +196,10 @@ public extension UICollectionView {
188196
}
189197
})
190198
}
199+
200+
if contentSize.height > bounds.size.height {
201+
setContentOffset(contentOffset, animated: false)
202+
}
191203
}
192204
}
193205
#endif

docs/Extensions.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ <h4>Declaration</h4>
179179
</section>
180180
</section>
181181
<section id="footer">
182-
<p>&copy; 2018 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-10-04)</p>
182+
<p>&copy; 2018 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-10-09)</p>
183183
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
184184
</section>
185185
</article>

docs/Extensions/Optional.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ <h4>Return Value</h4>
153153
</section>
154154
</section>
155155
<section id="footer">
156-
<p>&copy; 2018 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-10-04)</p>
156+
<p>&copy; 2018 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-10-09)</p>
157157
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
158158
</section>
159159
</article>

docs/Extensions/UICollectionView.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ <h4>Parameters</h4>
181181
</section>
182182
</section>
183183
<section id="footer">
184-
<p>&copy; 2018 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-10-04)</p>
184+
<p>&copy; 2018 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-10-09)</p>
185185
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
186186
</section>
187187
</article>

docs/Extensions/UITableView.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ <h4>Parameters</h4>
355355
</section>
356356
</section>
357357
<section id="footer">
358-
<p>&copy; 2018 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-10-04)</p>
358+
<p>&copy; 2018 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-10-09)</p>
359359
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
360360
</section>
361361
</article>

docs/Protocols.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ <h4>Declaration</h4>
185185
</section>
186186
</section>
187187
<section id="footer">
188-
<p>&copy; 2018 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-10-04)</p>
188+
<p>&copy; 2018 <a class="link" href="https://github.com/ra1028" target="_blank" rel="external">Ryo Aoyama</a>. All rights reserved. (Last updated: 2018-10-09)</p>
189189
<p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.9.3</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
190190
</section>
191191
</article>

0 commit comments

Comments
 (0)