2 Commits

Author SHA1 Message Date
4fb98a4b2c Merge pull request #3 from wesleyel/copilot/fix-rendering-issue-formula
Some checks failed
CI / Test All Platforms (push) Has been cancelled
CI / Backward Compatibility (Xcode 16.4) (push) Has been cancelled
Format / swift-format (push) Has been cancelled
Add `array` environment support for piecewise formulas
2026-04-07 20:36:26 +08:00
70066e8043 Handle invalid inter-element spaces to prevent crashes in debug builds 2026-04-07 20:35:20 +08:00

View File

@@ -1846,7 +1846,11 @@ extension Math {
let spaceArray = getInterElementSpaces()[Int(leftIndex)]
let spaceTypeObj = spaceArray[Int(rightIndex)]
let spaceType = spaceTypeObj
assert(spaceType != .invalid, "Invalid space between \(left) and \(right)")
// Keep malformed LaTeX from crashing debug builds. Propagating NaN lets callers
// detect the failed layout and surface it as a validation issue instead.
if spaceType == .invalid {
return .nan
}
let spaceMultipler = self.getSpacingInMu(spaceType)
if spaceMultipler > 0 {