diff options
| author | Laurenz <laurmaedje@gmail.com> | 2024-09-17 17:54:15 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-09-17 15:54:15 +0000 |
| commit | 92ec56601831b9c454dbeaf28dba84e2769c7726 (patch) | |
| tree | 45f52431a78b69b74dc7fefe3cbe251c518efc69 /crates | |
| parent | ab8295c07dd1883f9c19d3e075e7a4971fec0de0 (diff) | |
Fix tags at the start of paragraphs (#4978)
Co-authored-by: Martin Haug <mhaug@live.de>
Diffstat (limited to 'crates')
| -rw-r--r-- | crates/typst/src/layout/inline/prepare.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/typst/src/layout/inline/prepare.rs b/crates/typst/src/layout/inline/prepare.rs index 9e73af66..3ac155b5 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<Item = &(Range, Item<'a>)> { - 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 }) |
