refactor(core): simplify truncate_line() by merging identical branches

The function had two branches that both returned line.to_string():
- when !should_truncate
- when line.chars().count() <= max_width

Merged into a single condition. Also updated format! to use
inline variable syntax per clippy suggestion.

Agent: fowler
This commit is contained in:
Dhanji R. Prasanna
2026-01-11 16:18:48 +05:30
parent 74a18794a0
commit 1c3de60bb9

View File

@@ -235,13 +235,11 @@ pub fn truncate_for_display(s: &str, max_len: usize) -> String {
/// Truncate a line for tool output display /// Truncate a line for tool output display
pub fn truncate_line(line: &str, max_width: usize, should_truncate: bool) -> String { pub fn truncate_line(line: &str, max_width: usize, should_truncate: bool) -> String {
if !should_truncate { if !should_truncate || line.chars().count() <= max_width {
line.to_string()
} else if line.chars().count() <= max_width {
line.to_string() line.to_string()
} else { } else {
let truncated: String = line.chars().take(max_width.saturating_sub(3)).collect(); let truncated: String = line.chars().take(max_width.saturating_sub(3)).collect();
format!("{}...", truncated) format!("{truncated}...")
} }
} }