From c3aa75a48a36b582150fa89173882b2ecf4534ba Mon Sep 17 00:00:00 2001 From: Lee <18611401994@163.com> Date: Wed, 13 May 2020 15:20:04 +0800 Subject: [PATCH 1/2] Fix NSCollectionView sections update bug in AppKit extension. --- Sources/Extensions/AppKitExtension.swift | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Sources/Extensions/AppKitExtension.swift b/Sources/Extensions/AppKitExtension.swift index 6b30b76..da4fd84 100644 --- a/Sources/Extensions/AppKitExtension.swift +++ b/Sources/Extensions/AppKitExtension.swift @@ -123,6 +123,22 @@ public extension NSCollectionView { animator().performBatchUpdates({ setData(changeset.data) + if !changeset.sectionDeleted.isEmpty { + deleteSections(IndexSet(changeset.sectionDeleted)) + } + + if !changeset.sectionInserted.isEmpty { + insertSections(IndexSet(changeset.sectionInserted)) + } + + if !changeset.sectionUpdated.isEmpty { + reloadSections(IndexSet(changeset.sectionUpdated)) + } + + for (source, target) in changeset.sectionMoved { + moveSection(source, toSection: target) + } + if !changeset.elementDeleted.isEmpty { deleteItems(at: Set(changeset.elementDeleted.map { IndexPath(item: $0.element, section: $0.section) })) } From a0571e72817bf873d7ad25cb391e4d683708e139 Mon Sep 17 00:00:00 2001 From: Lee <18611401994@163.com> Date: Wed, 10 Jun 2020 14:09:06 +0800 Subject: [PATCH 2/2] Adjust grammar --- Sources/Extensions/AppKitExtension.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/Extensions/AppKitExtension.swift b/Sources/Extensions/AppKitExtension.swift index da4fd84..eacc04c 100644 --- a/Sources/Extensions/AppKitExtension.swift +++ b/Sources/Extensions/AppKitExtension.swift @@ -138,7 +138,7 @@ public extension NSCollectionView { for (source, target) in changeset.sectionMoved { moveSection(source, toSection: target) } - + if !changeset.elementDeleted.isEmpty { deleteItems(at: Set(changeset.elementDeleted.map { IndexPath(item: $0.element, section: $0.section) })) }