Fix `leading_space` sometimes being ignored during paragraph splitting (#7031)

Fixes a regression introduced in https://github.com/emilk/egui/pull/5411
(possibly
d74bee536f)
that breaks `leading_space` handling.
I think this is what the condition should be but I haven't touched this
code in a while.
This commit is contained in:
Hubert Głuchowski 2025-05-08 15:47:13 +02:00 committed by GitHub
parent 7872b5b363
commit e9609ac94e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 10 additions and 10 deletions

View File

@ -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,