From 9febc52387b64551c2723dbbc02a27414aebd9ab Mon Sep 17 00:00:00 2001 From: Jason Lee Date: Tue, 23 Sep 2025 09:47:32 +0800 Subject: [PATCH] kbd: Fix byte slice crash. (#1275) --- crates/ui/src/kbd.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/crates/ui/src/kbd.rs b/crates/ui/src/kbd.rs index e79e0b31..3f49550f 100644 --- a/crates/ui/src/kbd.rs +++ b/crates/ui/src/kbd.rs @@ -165,8 +165,13 @@ impl Kbd { if key_str.len() == 1 { keys.push_str(&key_str.to_uppercase()); } else { - if let Some(first_char) = key_str.chars().next() { - keys.push_str(&format!("{}{}", first_char.to_uppercase(), &key_str[1..])); + let mut chars = key_str.chars(); + if let Some(first_char) = chars.next() { + keys.push_str(&format!( + "{}{}", + first_char.to_uppercase(), + chars.collect::() + )); } else { keys.push_str(&key_str); }