summaryrefslogtreecommitdiff
path: root/crates/typst-layout/src/grid/lines.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/typst-layout/src/grid/lines.rs')
-rw-r--r--crates/typst-layout/src/grid/lines.rs29
1 files changed, 16 insertions, 13 deletions
diff --git a/crates/typst-layout/src/grid/lines.rs b/crates/typst-layout/src/grid/lines.rs
index 7549673f..d5da7e26 100644
--- a/crates/typst-layout/src/grid/lines.rs
+++ b/crates/typst-layout/src/grid/lines.rs
@@ -391,10 +391,12 @@ pub fn vline_stroke_at_row(
///
/// This function assumes columns are sorted by increasing `x`, and rows are
/// sorted by increasing `y`.
+#[allow(clippy::too_many_arguments)]
pub fn hline_stroke_at_column(
grid: &CellGrid,
rows: &[RowPiece],
local_top_y: Option<usize>,
+ header_end_above: Option<usize>,
in_last_region: bool,
y: usize,
x: usize,
@@ -499,17 +501,15 @@ pub fn hline_stroke_at_column(
// Top border stroke and header stroke are generally prioritized, unless
// they don't have explicit hline overrides and one or more user-provided
// hlines would appear at the same position, which then are prioritized.
- let top_stroke_comes_from_header = grid
- .header
- .as_ref()
- .and_then(Repeatable::as_repeated)
- .zip(local_top_y)
- .is_some_and(|(header, local_top_y)| {
- // Ensure the row above us is a repeated header.
- // FIXME: Make this check more robust when headers at arbitrary
- // positions are added.
- local_top_y < header.end && y > header.end
- });
+ let top_stroke_comes_from_header = header_end_above.zip(local_top_y).is_some_and(
+ |(last_repeated_header_end, local_top_y)| {
+ // Check if the last repeated header row is above this line.
+ //
+ // Note that `y == last_repeated_header_end` is impossible for a
+ // strictly repeated header (not in its original position).
+ local_top_y < last_repeated_header_end && y > last_repeated_header_end
+ },
+ );
// Prioritize the footer's top stroke as well where applicable.
let bottom_stroke_comes_from_footer = grid
@@ -637,7 +637,7 @@ mod test {
},
vec![],
vec![],
- None,
+ vec![],
None,
entries,
)
@@ -1175,7 +1175,7 @@ mod test {
},
vec![],
vec![],
- None,
+ vec![],
None,
entries,
)
@@ -1268,6 +1268,7 @@ mod test {
grid,
&rows,
y.checked_sub(1),
+ None,
true,
y,
x,
@@ -1461,6 +1462,7 @@ mod test {
grid,
&rows,
y.checked_sub(1),
+ None,
true,
y,
x,
@@ -1506,6 +1508,7 @@ mod test {
grid,
&rows,
if y == 4 { Some(2) } else { y.checked_sub(1) },
+ None,
true,
y,
x,