Skip to content

Commit 906a89d

Browse files
authored
fix: use truncate_safe for safer string truncation in chat/checkpoint.rs. (#3137)
1 parent ddb293c commit 906a89d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ use serde::{
2828
use tracing::debug;
2929

3030
use crate::cli::ConversationState;
31+
use super::util::truncate_safe;
3132
use crate::cli::chat::conversation::HistoryEntry;
3233
use crate::os::Os;
3334

@@ -370,7 +371,7 @@ pub fn truncate_message(s: &str, max_len: usize) -> String {
370371
return s.to_string();
371372
}
372373

373-
let truncated = &s[..max_len];
374+
let truncated = truncate_safe(s, max_len);
374375
if let Some(pos) = truncated.rfind(' ') {
375376
format!("{}...", &truncated[..pos])
376377
} else {

0 commit comments

Comments
 (0)