Fix panic for empty breakable block equations (#5116)

This commit is contained in:
Eric Biedert 2024-10-07 10:13:09 +02:00 committed by GitHub
parent 60f9f66950
commit 20ce48dc36
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View File

@ -379,6 +379,12 @@ fn layout_equation_block(
equation_builder.size.y = height; equation_builder.size.y = height;
} }
// Ensure that there is at least one frame, even for empty equations.
if equation_builders.is_empty() {
equation_builders
.push(MathRunFrameBuilder { frames: vec![], size: Size::zero() });
}
equation_builders equation_builders
} else { } else {
vec![full_equation_builder] vec![full_equation_builder]

View File

@ -147,11 +147,15 @@ $ a + b $
Shouldn't overflow: Shouldn't overflow:
$ a + b $ $ a + b $
--- issue-5113-pagebreaking-empty ---
// Test empty breakable equations.
#show math.equation: set block(breakable: true)
#math.equation(block: true, [])
--- issue-1948-math-text-break --- --- issue-1948-math-text-break ---
// Test text with linebreaks in math. // Test text with linebreaks in math.
$ x := "a\nb\nc\nd\ne" $ $ x := "a\nb\nc\nd\ne" $
--- issue-4829-math-pagebreaking-wrong-number --- --- issue-4829-math-pagebreaking-wrong-number ---
// Test numbering of empty regions of broken equations. // Test numbering of empty regions of broken equations.
#set page(height: 5em) #set page(height: 5em)