Skip to content

Commit

Permalink
Add RowBreakCandidates::has_good_candidate
Browse files Browse the repository at this point in the history
  • Loading branch information
awaken1ng committed Mar 21, 2022
1 parent 1881cec commit bb21718
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion epaint/src/text/text_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,9 @@ fn line_break(
}

if potential_row_width > job.wrap.max_width {
if first_row_indentation > 0.0 && !row_break_candidates.has_word_boundary() {
if first_row_indentation > 0.0
&& !row_break_candidates.has_good_candidate(job.wrap.break_anywhere)
{
// Allow the first row to be completely empty, because we know there will be more space on the next row:
// TODO: this records the height of this first row as zero, though that is probably fine since first_row_indentation usually comes with a first_row_min_height.
out_rows.push(Row {
Expand Down Expand Up @@ -749,6 +751,14 @@ impl RowBreakCandidates {
self.space.is_some() || self.logogram.is_some()
}

fn has_good_candidate(&self, break_anywhere: bool) -> bool {
if break_anywhere {
self.any.is_some()
} else {
self.has_word_boundary()
}
}

fn get(&self, break_anywhere: bool) -> Option<usize> {
if break_anywhere {
self.any
Expand Down

0 comments on commit bb21718

Please sign in to comment.