From 31076724a35c420d22ecbd03a6add1334f330e6c Mon Sep 17 00:00:00 2001 From: Sofia Rodriguez Date: Mon, 4 Nov 2024 12:26:14 +0000 Subject: [PATCH] Remove `nil` default values from primary content section. The enconder for primary content section now checks for nil values inside the collection, when before it weas checking for empty arrays, causing issues when calculating the index for the replace patcher. rdar://139195428 --- .../Model/Rendering/Variants/VariantCollection+Coding.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/SwiftDocC/Model/Rendering/Variants/VariantCollection+Coding.swift b/Sources/SwiftDocC/Model/Rendering/Variants/VariantCollection+Coding.swift index 482e3594aa..aaa5d0c2c6 100644 --- a/Sources/SwiftDocC/Model/Rendering/Variants/VariantCollection+Coding.swift +++ b/Sources/SwiftDocC/Model/Rendering/Variants/VariantCollection+Coding.swift @@ -108,6 +108,10 @@ extension KeyedEncodingContainer { try encodeIfNotEmpty(variantCollectionValues.compactMap(\.defaultValue), forKey: key) for (index, variantCollection) in variantCollectionValues.enumerated() { + // Filter `nil` default values. + guard variantCollection.defaultValue != nil else { + continue + } variantCollection.addVariantsToEncoder( encoder,