Skip to content

Commit

Permalink
Fix incorrect line breaks
Browse files Browse the repository at this point in the history
  • Loading branch information
juancampa committed Apr 17, 2024
1 parent 78d95f4 commit 5c13c84
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion crates/epaint/src/text/text_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ fn line_break(paragraph: &Paragraph, job: &LayoutJob, out_rows: &mut Vec<Row>, e
// Start a new row:
row_start_idx = last_kept_index + 1;
row_start_x = paragraph.glyphs[row_start_idx].pos.x;
row_break_candidates = Default::default();
row_break_candidates.forget_candiates_before_idx(row_start_idx);

Check warning on line 299 in crates/epaint/src/text/text_layout.rs

View workflow job for this annotation

GitHub Actions / typos

"candiates" should be "candidates".
} else {
// Found no place to break, so we have to overrun wrap_width.
}
Expand Down Expand Up @@ -943,6 +943,27 @@ impl RowBreakCandidates {
.or(self.any)
}
}

fn forget_candiates_before_idx(&mut self, index: usize) {

Check warning on line 947 in crates/epaint/src/text/text_layout.rs

View workflow job for this annotation

GitHub Actions / typos

"candiates" should be "candidates".
if self.space.map(|s| s < index).unwrap_or_default() {
self.space = None;
}
if self.cjk.map(|s| s < index).unwrap_or_default() {
self.cjk = None;
}
if self.pre_cjk.map(|s| s < index).unwrap_or_default() {
self.pre_cjk = None;
}
if self.dash.map(|s| s < index).unwrap_or_default() {
self.dash = None;
}
if self.punctuation.map(|s| s < index).unwrap_or_default() {
self.punctuation = None;
}
if self.any.map(|s| s < index).unwrap_or_default() {
self.any = None;
}
}
}

#[inline]
Expand Down

0 comments on commit 5c13c84

Please sign in to comment.