From e9609ac94e6f3d23314f3577974b4bd6d8ededf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hubert=20G=C5=82uchowski?= Date: Thu, 8 May 2025 15:47:13 +0200 Subject: [PATCH] Fix `leading_space` sometimes being ignored during paragraph splitting (#7031) Fixes a regression introduced in https://github.com/emilk/egui/pull/5411 (possibly https://github.com/emilk/egui/pull/5411/commits/d74bee536f7c57d83014b759b18a0ddef8725552) that breaks `leading_space` handling. I think this is what the condition should be but I haven't touched this code in a while. --- crates/epaint/src/text/fonts.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index bca9212d..e6551421 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -913,7 +913,7 @@ impl GalleyCache { "Bad new section range: {new_range:?}" ); paragraph_job.sections.push(LayoutSection { - leading_space: if start <= new_range.start { + leading_space: if start <= section_range.start { *leading_space } else { 0.0 @@ -1080,15 +1080,7 @@ mod tests { ..Default::default() }; job.append( - "1st paragraph has some leading space.\n", - 16.0, - TextFormat { - font_id: FontId::new(14.0, FontFamily::Proportional), - ..Default::default() - }, - ); - job.append( - "2nd paragraph has underline and strikthrough, and has some non-ASCII characters:\n ÅÄÖ.", + "1st paragraph has underline and strikethrough, and has some non-ASCII characters:\n ÅÄÖ.", 0.0, TextFormat { font_id: FontId::new(15.0, FontFamily::Monospace), @@ -1097,6 +1089,14 @@ mod tests { ..Default::default() }, ); + job.append( + "2nd paragraph has some leading space.\n", + 16.0, + TextFormat { + font_id: FontId::new(14.0, FontFamily::Proportional), + ..Default::default() + }, + ); job.append( "3rd paragraph is kind of boring, but has italics.\nAnd a newline", 0.0,