Merge pull request #118 from pop-os/checked_sub

Use checked_sub to fix panic on window resize.
This commit is contained in:
Jeremy Soller 2023-03-31 06:43:30 -06:00 committed by GitHub
commit f2445987fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -243,14 +243,16 @@ impl<'b> Iterator for LayoutRunIter<'b> {
return None;
}
self.remaining_len -= 1;
return Some(LayoutRun {
line_i: self.line_i,
text: line.text(),
rtl: shape.rtl,
glyphs: &layout_line.glyphs,
line_y: self.line_y,
line_w: layout_line.w,
return self.remaining_len.checked_sub(1).map(|num| {
self.remaining_len = num;
LayoutRun {
line_i: self.line_i,
text: line.text(),
rtl: shape.rtl,
glyphs: &layout_line.glyphs,
line_y: self.line_y,
line_w: layout_line.w,
}
});
}
self.line_i += 1;