Fix trailing mandatory breaks being swallowed (#2502)

This commit is contained in:
tingerrr 2023-10-27 00:17:47 +02:00 committed by GitHub
parent b80382b216
commit 1603e2df26
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1206,15 +1206,20 @@ impl Iterator for Breakpoints<'_> {
// Fix for: https://github.com/unicode-org/icu4x/issues/4146
if let Some(c) = self.p.bidi.text[..self.end].chars().next_back() {
if self.end == self.p.bidi.text.len() {
self.mandatory = true;
break;
}
self.mandatory = match lb.get(c) {
LineBreak::Glue | LineBreak::WordJoiner | LineBreak::ZWJ => continue,
LineBreak::MandatoryBreak
| LineBreak::CarriageReturn
| LineBreak::LineFeed
| LineBreak::NextLine => true,
_ => self.end == self.p.bidi.text.len(),
_ => false,
};
};
}
break;
}