diff --git a/crates/typst/src/layout/inline/prepare.rs b/crates/typst/src/layout/inline/prepare.rs index 9e73af660..3ac155b5e 100644 --- a/crates/typst/src/layout/inline/prepare.rs +++ b/crates/typst/src/layout/inline/prepare.rs @@ -58,7 +58,13 @@ impl<'a> Preparation<'a> { /// Iterate over the items that intersect the given `sliced` range. pub fn slice(&self, sliced: Range) -> impl Iterator)> { - let start = self.indices.get(sliced.start).copied().unwrap_or(0); + // Usually, we don't want empty-range items at the start of the line + // (because they will be part of the previous line), but for the first + // line, we need to keep them. + let start = match sliced.start { + 0 => 0, + n => self.indices.get(n).copied().unwrap_or(0), + }; self.items[start..].iter().take_while(move |(range, _)| { range.start < sliced.end || range.end <= sliced.end }) diff --git a/tests/suite/model/par.typ b/tests/suite/model/par.typ index 7a5a37f53..f62c0dca7 100644 --- a/tests/suite/model/par.typ +++ b/tests/suite/model/par.typ @@ -101,3 +101,8 @@ Lorem ipsum dolor #metadata(none) nonumy eirmod tempor. --- issue-4938-par-bad-ratio --- #set par(justify: true) #box($k in NN_0$) + +--- issue-4770-par-tag-at-start --- +#h(0pt) #box[] + +#context test(query().len(), 1)