Skip to content

Commit

Permalink
fix: crash when logging window titles with non-English characters (#947)
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger authored Jan 28, 2025
1 parent d574060 commit aff6511
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/wm/src/models/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<String>())
} else {
title
};
Expand Down

0 comments on commit aff6511

Please sign in to comment.