summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/typst-library/src/layout/par.rs4
-rw-r--r--tests/ref/visualize/shape-rect.pngbin9691 -> 247247 bytes
-rw-r--r--tests/typ/visualize/shape-rect.typ8
3 files changed, 11 insertions, 1 deletions
diff --git a/crates/typst-library/src/layout/par.rs b/crates/typst-library/src/layout/par.rs
index 6d1b653f..271d9467 100644
--- a/crates/typst-library/src/layout/par.rs
+++ b/crates/typst-library/src/layout/par.rs
@@ -1344,7 +1344,9 @@ fn finalize(
let width = if !region.x.is_finite()
|| (!expand && lines.iter().all(|line| line.fr().is_zero()))
{
- p.hang + lines.iter().map(|line| line.width).max().unwrap_or_default()
+ region
+ .x
+ .min(p.hang + lines.iter().map(|line| line.width).max().unwrap_or_default())
} else {
region.x
};
diff --git a/tests/ref/visualize/shape-rect.png b/tests/ref/visualize/shape-rect.png
index 17675400..48d40447 100644
--- a/tests/ref/visualize/shape-rect.png
+++ b/tests/ref/visualize/shape-rect.png
Binary files differ
diff --git a/tests/typ/visualize/shape-rect.typ b/tests/typ/visualize/shape-rect.typ
index 951d5bea..17dd0f92 100644
--- a/tests/typ/visualize/shape-rect.typ
+++ b/tests/typ/visualize/shape-rect.typ
@@ -53,3 +53,11 @@
---
// Error: 15-21 expected length, color, dictionary, stroke, none, or auto, found array
#rect(stroke: (1, 2))
+
+---
+#set page(width: 17.8cm)
+#lorem(100)
+#rect(lorem(100))
+#set par(justify: true)
+#lorem(100)
+#rect(lorem(100))