diff --git a/SPDiffable.podspec b/SPDiffable.podspec index 3e52b68..4af0c23 100644 --- a/SPDiffable.podspec +++ b/SPDiffable.podspec @@ -1,7 +1,7 @@ Pod::Spec.new do |s| s.name = 'SPDiffable' - s.version = '4.0.6' + s.version = '4.0.7' s.summary = 'Extension of Diffable API which allow not duplicate code and use less models. Included example for SideBar.' s.homepage = 'https://github.com/ivanvorobei/SPDiffable' s.source = { :git => 'https://github.com/ivanvorobei/SPDiffable.git', :tag => s.version } diff --git a/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource.swift b/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource.swift index 2d54ad8..bb7db20 100644 --- a/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource.swift +++ b/Sources/SPDiffable/Collection/DataSource/SPDiffableCollectionDataSource.swift @@ -239,6 +239,12 @@ open class SPDiffableCollectionDataSource: NSObject, SPDiffableDataSourceInterfa let previousSection = sections[previousSectionIndex] guard let _ = snapshot.sectionIdentifiers.first(where: { $0.id == section.id }) else { continue } guard let _ = snapshot.sectionIdentifiers.first(where: { $0.id == previousSection.id }) else { continue } + + // If try move section to same index as original. + // This line allow skip it action. + // Can happen crash for collection if doing it. + if (previousSectionIndex + 1) == sectionIndex { continue } + snapshot.moveSection(section, afterSection: previousSection) }