summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/layout/grid.rs2
-rw-r--r--src/layout/par.rs10
-rw-r--r--src/layout/stack.rs3
-rw-r--r--tests/ref/layout/grid-5.pngbin0 -> 1427 bytes
-rw-r--r--tests/typ/layout/grid-5.typ11
5 files changed, 19 insertions, 7 deletions
diff --git a/src/layout/grid.rs b/src/layout/grid.rs
index 35706498..91cc0014 100644
--- a/src/layout/grid.rs
+++ b/src/layout/grid.rs
@@ -179,8 +179,6 @@ impl<'a> GridLayouter<'a> {
// Sum of fractions of all fractional tracks.
let mut fr = Fractional::zero();
-
-
// Resolve the size of all linear columns and compute the sum of all
// fractional tracks.
for (&col, rcol) in self.cols.iter().zip(&mut self.rcols) {
diff --git a/src/layout/par.rs b/src/layout/par.rs
index dc2ce0ef..18a701cd 100644
--- a/src/layout/par.rs
+++ b/src/layout/par.rs
@@ -218,21 +218,25 @@ impl<'a> ParLayouter<'a> {
stack.constraints.max.y.set_min(stack.size.h + line.size.h);
stack.finish_region(ctx);
}
+
// If the line does not fit horizontally or we have a mandatory
// line break (i.e. due to "\n"), we push the line into the
// stack.
if mandatory || !stack.regions.current.w.fits(line.size.w) {
- stack.push(line);
start = end;
last = None;
+ stack.push(line);
stack.constraints.min.y = Some(stack.size.h);
// If there is a trailing line break at the end of the
// paragraph, we want to force an empty line.
if mandatory && end == self.bidi.text.len() {
- stack.push(LineLayout::new(ctx, &self, end .. end));
- stack.constraints.min.y = Some(stack.size.h);
+ let line = LineLayout::new(ctx, &self, end .. end);
+ if stack.regions.current.h.fits(line.size.h) {
+ stack.push(line);
+ stack.constraints.min.y = Some(stack.size.h);
+ }
}
} else {
// Otherwise, the line fits both horizontally and vertically
diff --git a/src/layout/stack.rs b/src/layout/stack.rs
index 4afe9c64..4b148ad8 100644
--- a/src/layout/stack.rs
+++ b/src/layout/stack.rs
@@ -173,8 +173,7 @@ impl<'a> StackLayouter<'a> {
let expand = self.expand;
let used = self.used.to_size(self.block);
- // Determine the stack's size dependening on whether the region is
- // fixed.
+ // Determine the stack's size dependening on whether the region expands.
let size = Size::new(
if expand.x {
self.constraints.exact.x = Some(self.full.w);
diff --git a/tests/ref/layout/grid-5.png b/tests/ref/layout/grid-5.png
new file mode 100644
index 00000000..a43408f8
--- /dev/null
+++ b/tests/ref/layout/grid-5.png
Binary files differ
diff --git a/tests/typ/layout/grid-5.typ b/tests/typ/layout/grid-5.typ
new file mode 100644
index 00000000..cd1c8dc9
--- /dev/null
+++ b/tests/typ/layout/grid-5.typ
@@ -0,0 +1,11 @@
+
+---
+// Test that trailing linebreak doesn't overflow the region.
+#page(height: 2cm)
+#grid[
+ Hello \
+ Hello \
+ Hello \
+
+ World
+]