From aff65113cf631237e08343a4a9e2800dee5b8056 Mon Sep 17 00:00:00 2001 From: Lars Berger Date: Tue, 28 Jan 2025 17:38:42 +0000 Subject: [PATCH] fix: crash when logging window titles with non-English characters (#947) --- packages/wm/src/models/container.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/wm/src/models/container.rs b/packages/wm/src/models/container.rs index 7c097d19..0cfe74c6 100644 --- a/packages/wm/src/models/container.rs +++ b/packages/wm/src/models/container.rs @@ -220,9 +220,10 @@ impl std::fmt::Display for WindowContainer { let class = native.class_name().unwrap_or_default(); let process = native.process_name().unwrap_or_default(); - // Truncate title if longer than 20 chars. + // Truncate title if longer than 20 chars. Need to use `chars()` + // instead of byte slices to handle invalid byte indices. let title = if title.len() > 20 { - format!("{}...", &title[..17]) + format!("{}...", &title.chars().take(17).collect::()) } else { title };