Skip to content

Commit d0d83d4

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 eb8981c commit d0d83d4

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
@@ -262,12 +262,6 @@ fn truncate_description(text: &str, max_length: usize) -> String {
262262
truncate_at = idx;
263263
}
264264

265-
// If we found a valid boundary, use it; otherwise use the last character start
266-
if truncate_at == 0 && !text.is_empty() {
267-
// Edge case: even the first character is too long
268-
truncate_at = text.char_indices().next().map(|(i, _)| i).unwrap_or(0);
269-
}
270-
271265
let truncated = &text[..truncate_at];
272266
format!("{}...", truncated.trim_end())
273267
}

0 commit comments

Comments
 (0)