From 3500e5d5bcac180a7d702c8a1ffb592f60d28167 Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Wed, 12 Nov 2025 18:19:43 +0800 Subject: [PATCH] label: Fix Label highlight may crash of `not a char boundary`. (#1574) --- crates/story/src/label_story.rs | 4 +++- crates/ui/src/label.rs | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/crates/story/src/label_story.rs b/crates/story/src/label_story.rs index f673202d..cf261286 100644 --- a/crates/story/src/label_story.rs +++ b/crates/story/src/label_story.rs @@ -113,7 +113,9 @@ impl Render for LabelStory { v_flex() .gap_y_4() .child(Label::new("This is a label").highlights(ht.clone())) - .child(Label::new("这是一个标签").highlights(ht.clone())), + // This case for test match CJK with ASCII, it was has a crash bug before. + // Try to input "AA" to see the highlights effect. + .child(Label::new("AAA中文BB").highlights(ht.clone())), ), ) .child( diff --git a/crates/ui/src/label.rs b/crates/ui/src/label.rs index b8b61d7d..e43cc59e 100644 --- a/crates/ui/src/label.rs +++ b/crates/ui/src/label.rs @@ -181,7 +181,7 @@ impl Label { )); } - Some(highlights) + Some(gpui::combine_highlights(vec![], highlights).collect()) } }