Skip to content

Commit 03d4d0d

Browse files
committed
refactor: remove redundant edge case check in truncate_description
Remove the unnecessary if-check that was doing nothing. char_indices().next() always returns index 0 for the first character, so this code was just reassigning truncate_at = 0 without any effect. All tests pass without this code, confirming it was redundant.
1 parent 4065436 commit 03d4d0d

File tree

1 file changed

+0
-6
lines changed

1 file changed

+0
-6
lines changed

crates/chat-cli/src/cli/chat/cli/prompts.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,12 +257,6 @@ fn truncate_description(text: &str, max_length: usize) -> String {
257257
truncate_at = idx;
258258
}
259259

260-
// If we found a valid boundary, use it; otherwise use the last character start
261-
if truncate_at == 0 && !text.is_empty() {
262-
// Edge case: even the first character is too long
263-
truncate_at = text.char_indices().next().map(|(i, _)| i).unwrap_or(0);
264-
}
265-
266260
let truncated = &text[..truncate_at];
267261
format!("{}...", truncated.trim_end())
268262
}

0 commit comments

Comments
 (0)