Fix line truncate crash on Windows (#17271)

Closes #17267

We should update the `len` of `runs` when truncating. cc @huacnlee 

Release Notes:

- N/A
This commit is contained in:
张小白
2024-11-20 16:47:55 -08:00
committed by GitHub
parent 33e84da657
commit 49ed932c1f
2 changed files with 174 additions and 27 deletions
+2 -2
View File
@@ -263,7 +263,7 @@ impl TextLayout {
.line_height
.to_pixels(font_size.into(), cx.rem_size());
let runs = if let Some(runs) = runs {
let mut runs = if let Some(runs) = runs {
runs
} else {
vec![text_style.to_run(text.len())]
@@ -306,7 +306,7 @@ impl TextLayout {
let mut line_wrapper = cx.text_system().line_wrapper(text_style.font(), font_size);
let text = if let Some(truncate_width) = truncate_width {
line_wrapper.truncate_line(text.clone(), truncate_width, ellipsis)
line_wrapper.truncate_line(text.clone(), truncate_width, ellipsis, &mut runs)
} else {
text.clone()
};