Worktrunk is a CLI for Git worktree management, designed for parallel AI agent workflows
Improve string handling in `display` and `git` modules
Maximilian Roosb752fadcfcd1
diff --git a/src/display.rs b/src/display.rsindex d1eb17729..c52ca4bbe 100644--- a/src/display.rs+++ b/src/display.rs@@ -162,7 +162,7 @@ pub fn shorten_path(path: &Path, prefix: &Path) -> String {/// Truncate text at word boundary with ellipsis, respecting terminal widthpub fn truncate_at_word_boundary(text: &str, max_width: usize) -> String {- use unicode_width::UnicodeWidthStr;+ use unicode_width::{UnicodeWidthChar, UnicodeWidthStr};if text.width() <= max_width {return text.to_string();@@ -175,7 +175,7 @@ pub fn truncate_at_word_boundary(text: &str, max_width: usize) -> String {let mut last_idx = 0;for (idx, ch) in text.char_indices() {- let char_width = UnicodeWidthStr::width(ch.to_string().as_str());+ let char_width = ch.width().unwrap_or(0);if current_width + char_width > target_width {break;}diff --git a/src/git.rs b/src/git.rsindex 2fb3f3367..8af0ea714 100644--- a/src/git.rs+++ b/src/git.rs@@ -203,7 +203,7 @@ impl Repository {pub fn changed_files(&self, base: &str, head: &str) -> Result<Vec<String>, GitError> {let range = format!("{}..{}", base, head);let stdout = run_git_command(&["diff", "--name-only", &range], Some(&self.path))?;- Ok(stdout.lines().map(|s| s.to_string()).collect())+ Ok(stdout.lines().map(str::to_owned).collect())}/// Get commit timestamp in seconds since epoch.@@ -334,7 +334,7 @@ impl Repository {/// Get commit subjects (first line of commit message) from a range.pub fn commit_subjects(&self, range: &str) -> Result<Vec<String>, GitError> {let output = run_git_command(&["log", "--format=%s", range], Some(&self.path))?;- Ok(output.lines().map(|s| s.to_string()).collect())+ Ok(output.lines().map(str::to_owned).collect())}/// Check if there are staged changes.