From 084f4f3240669b3a86cb17c38f3c492d043859f5 Mon Sep 17 00:00:00 2001 From: bflatastic Date: Thu, 29 Oct 2026 20:36:07 +0700 Subject: [PATCH] Text: a line ending at the paragraph's start can't underflow --- crates/text/src/layout/flow.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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,