Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.7.2 #40

Merged
merged 4 commits into from
Oct 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DifferenceKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |spec|
spec.name = 'DifferenceKit'
spec.version = '0.7.1'
spec.version = '0.7.2'
spec.author = { 'ra1028' => 'r.fe51028.r@gmail.com' }
spec.homepage = 'https://github.com/ra1028/DifferenceKit'
spec.documentation_url = 'https://ra1028.github.io/DifferenceKit'
Expand Down
26 changes: 13 additions & 13 deletions Sources/Algorithm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
// If the element target section is recorded as insertion, record its element path as deletion.
if let targetElementPath = sourceElementTraces[sourceElementPath].reference,
case .some = sectionResult.metadata.targetReferences[targetElementPath.section] {
let sourceElement = contiguousSourceSections[sourceElementPath]
firstStageElements.append(sourceElement)
let targetElement = contiguousTargetSections[targetElementPath]
firstStageElements.append(targetElement)
continue
}

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

let sourceElement = contiguousSourceSections[sourceElementPath]
thirdStageElements.append(sourceElement)
thirdStageElements.append(targetElement)

if !targetElement.isContentEqual(to: sourceElement) {
elementUpdated.append(targetElementPath)
elementUpdated.append(sourceElementPath)
}

if sourceElementPath.section != sourceSectionIndex || sourceElementPath.element != untrackedSourceIndex {
Expand All @@ -345,17 +345,19 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
// - Includes:
// - section deletes
// - element deletes
if !sectionResult.deleted.isEmpty || !elementDeleted.isEmpty {
// - element updates
if !sectionResult.deleted.isEmpty || !elementDeleted.isEmpty || !elementUpdated.isEmpty {
changesets.append(
Changeset(
data: Collection(firstStageSections),
sectionDeleted: sectionResult.deleted,
elementDeleted: elementDeleted
elementDeleted: elementDeleted,
elementUpdated: elementUpdated
)
)
}

// The 2st stage changeset.
// The 2nd stage changeset.
// - Includes:
// - section inserts
// - section moves
Expand All @@ -369,7 +371,7 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
)
}

// The 3st stage changeset.
// The 3rd stage changeset.
// - Includes:
// - element inserts
// - element moves
Expand All @@ -383,16 +385,14 @@ public extension StagedChangeset where Collection: RangeReplaceableCollection, C
)
}

// The 3st stage changeset.
// The 4th stage changeset.
// - Includes:
// - section updates
// - element updates
if !sectionResult.updated.isEmpty || !elementUpdated.isEmpty {
if !sectionResult.updated.isEmpty {
changesets.append(
Changeset(
data: target,
sectionUpdated: sectionResult.updated,
elementUpdated: elementUpdated
sectionUpdated: sectionResult.updated
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/AnyDifferentiable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public struct AnyDifferentiable: Differentiable {

extension AnyDifferentiable: CustomDebugStringConvertible {
public var debugDescription: String {
return "AnyDifferentiable(\(String(reflecting: base))"
return "AnyDifferentiable(\(String(reflecting: base)))"
}
}

Expand Down
2 changes: 2 additions & 0 deletions Sources/Extensions/AppKitExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ public extension NSTableView {
setData(data)
return reloadData()
}

beginUpdates()
setData(changeset.data)

Expand All @@ -82,6 +83,7 @@ public extension NSTableView {
for (source, target) in changeset.elementMoved {
moveRow(at: source.element, to: target.element)
}

endUpdates()
}
}
Expand Down
12 changes: 12 additions & 0 deletions Sources/Extensions/UIKitExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ public extension UITableView {
return reloadData()
}

let contentOffset = self.contentOffset

for changeset in stagedChangeset {
if let interrupt = interrupt, interrupt(changeset), let data = stagedChangeset.last?.data {
setData(data)
Expand Down Expand Up @@ -110,6 +112,10 @@ public extension UITableView {
}
}
}

if contentSize.height > bounds.size.height {
setContentOffset(contentOffset, animated: false)
}
}

private func _performBatchUpdates(_ updates: () -> Void) {
Expand Down Expand Up @@ -146,6 +152,8 @@ public extension UICollectionView {
return reloadData()
}

let contentOffset = self.contentOffset

for changeset in stagedChangeset {
if let interrupt = interrupt, interrupt(changeset), let data = stagedChangeset.last?.data {
setData(data)
Expand Down Expand Up @@ -188,6 +196,10 @@ public extension UICollectionView {
}
})
}

if contentSize.height > bounds.size.height {
setContentOffset(contentOffset, animated: false)
}
}
}
#endif
2 changes: 1 addition & 1 deletion docs/Extensions.html
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/Optional.html
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ <h4>Return Value</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/UICollectionView.html
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ <h4>Parameters</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Extensions/UITableView.html
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ <h4>Parameters</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols.html
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols/ContentEquatable.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ <h4>Return Value</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols/Differentiable.html
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Protocols/DifferentiableSection.html
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ <h4>Parameters</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs.html
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/AnyDifferentiable.html
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/ArraySection.html
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/Changeset.html
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/ElementPath.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/Structs/StagedChangeset.html
Original file line number Diff line number Diff line change
Expand Up @@ -709,7 +709,7 @@ <h4>Declaration</h4>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ <h2 id='license' class='heading'>License</h2>
</section>
</section>
<section id="footer">
<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>
<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>
<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>
</section>
</article>
Expand Down