Skip to content

VectorCraft: An open-source, vector art tool written by scratch in pure Rust

Text: a line ending at the paragraph's start can't underflow

bflatastic084f4f324066
diff --git a/crates/text/src/layout/flow.rs b/crates/text/src/layout/flow.rs
index 1680d3acb..03c2eb3c4 100644
--- a/crates/text/src/layout/flow.rs
+++ b/crates/text/src/layout/flow.rs
@@ -543,7 +543,7 @@ fn prepare_line_geometry(cx: &Ctx<'_>, t: &TextObject, paragraph: &ParagraphData
// Justification adds nothing to the list marker's glyphs.
let mut held = held;
held.extend(index..paragraph.marker.min(body));
- let last_of_para = position.end >= n || sg.get(position.end - 1).is_some_and(|g| g.ch == '\u{2028}');
+ let last_of_para = position.end >= n || position.end.checked_sub(1).and_then(|i| sg.get(i)).is_some_and(|g| g.ch == '\u{2028}');
LineGeometry {
position,
index,