mirror of
https://github.com/typst/typst
synced 2025-05-18 11:05:28 +08:00
Fix compiler panic for float with no vertical alignment (#2437)
This commit is contained in:
parent
3ed6462ee0
commit
cf9ca6cb59
@ -95,7 +95,10 @@ impl Layout for PlaceElem {
|
|||||||
let float = self.float(styles);
|
let float = self.float(styles);
|
||||||
let alignment = self.alignment(styles);
|
let alignment = self.alignment(styles);
|
||||||
|
|
||||||
if float && alignment.map_or(false, |align| align.y() == Some(VAlign::Horizon)) {
|
if float
|
||||||
|
&& alignment
|
||||||
|
.map_or(false, |align| matches!(align.y(), None | Some(VAlign::Horizon)))
|
||||||
|
{
|
||||||
bail!(self.span(), "floating placement must be `auto`, `top`, or `bottom`");
|
bail!(self.span(), "floating placement must be `auto`, `top`, or `bottom`");
|
||||||
} else if !float && alignment.is_auto() {
|
} else if !float && alignment.is_auto() {
|
||||||
return Err("automatic positioning is only available for floating placement")
|
return Err("automatic positioning is only available for floating placement")
|
||||||
|
@ -17,3 +17,15 @@
|
|||||||
---
|
---
|
||||||
// Error: 2-45 floating placement must be `auto`, `top`, or `bottom`
|
// Error: 2-45 floating placement must be `auto`, `top`, or `bottom`
|
||||||
#place(center + horizon, float: true)[Hello]
|
#place(center + horizon, float: true)[Hello]
|
||||||
|
|
||||||
|
---
|
||||||
|
// Error: 2-36 floating placement must be `auto`, `top`, or `bottom`
|
||||||
|
#place(horizon, float: true)[Hello]
|
||||||
|
|
||||||
|
---
|
||||||
|
// Error: 2-27 floating placement must be `auto`, `top`, or `bottom`
|
||||||
|
#place(float: true)[Hello]
|
||||||
|
|
||||||
|
---
|
||||||
|
// Error: 2-34 floating placement must be `auto`, `top`, or `bottom`
|
||||||
|
#place(right, float: true)[Hello]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user