Fix crash when the length of a line is greater than 1024 chars (#11536)
Close #11518 Release Notes: - N/A
This commit is contained in:
@@ -4495,20 +4495,26 @@ fn layout_line(
|
||||
) -> Result<ShapedLine> {
|
||||
let mut line = snapshot.line(row);
|
||||
|
||||
if line.len() > MAX_LINE_LEN {
|
||||
let mut len = MAX_LINE_LEN;
|
||||
while !line.is_char_boundary(len) {
|
||||
len -= 1;
|
||||
}
|
||||
let len = {
|
||||
let line_len = line.len();
|
||||
if line_len > MAX_LINE_LEN {
|
||||
let mut len = MAX_LINE_LEN;
|
||||
while !line.is_char_boundary(len) {
|
||||
len -= 1;
|
||||
}
|
||||
|
||||
line.truncate(len);
|
||||
}
|
||||
line.truncate(len);
|
||||
len
|
||||
} else {
|
||||
line_len
|
||||
}
|
||||
};
|
||||
|
||||
cx.text_system().shape_line(
|
||||
line.into(),
|
||||
style.text.font_size.to_pixels(cx.rem_size()),
|
||||
&[TextRun {
|
||||
len: snapshot.line_len(row) as usize,
|
||||
len,
|
||||
font: style.text.font(),
|
||||
color: Hsla::default(),
|
||||
background_color: None,
|
||||
|
||||
Reference in New Issue
Block a user