Skip to content

Commit

Permalink
Fix incorrect behavior with LayoutJob::max_rows
Browse files Browse the repository at this point in the history
  • Loading branch information
afishhh committed Dec 5, 2024
1 parent 40f237d commit 17a5f1f
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions crates/epaint/src/text/fonts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,17 @@ impl GalleyCache {
// This will prevent us from invalidating cache entries unnecessarily
if left_max_rows != usize::MAX {
left_max_rows -= galley.rows.len();
// Ignore extra trailing row, see merging counterpart below for more details.
if end < job.text.len() && !galley.elided {
left_max_rows += 1;
}
}

let elided = galley.elided;
galleys.push(galley);
if elided {
break;
}

current = end;
}
Expand Down Expand Up @@ -896,10 +905,9 @@ impl GalleyCache {

merged_galley.num_vertices += galley.num_vertices;
merged_galley.num_indices += galley.num_indices;
if galley.elided {
merged_galley.elided = true;
break;
}
// Note that if `galley.elided` is true this will be the last `Galley` in
// the vector and the loop will end.
merged_galley.elided |= galley.elided;
}

if merged_galley.job.round_output_size_to_nearest_ui_point {
Expand Down

0 comments on commit 17a5f1f

Please sign in to comment.