MCPcopy Create free account
hub / github.com/aws/amazon-q-developer-cli / truncate_message

Function truncate_message

crates/chat-cli/src/cli/chat/checkpoint.rs:369–380  ·  view source on GitHub ↗

Truncate message for display

(s: &str, max_len: usize)

Source from the content-addressed store, hash-verified

367
368/// Truncate message for display
369pub fn truncate_message(s: &str, max_len: usize) -> String {
370 if s.len() <= max_len {
371 return s.to_string();
372 }
373
374 let truncated = truncate_safe(s, max_len);
375 if let Some(pos) = truncated.rfind(' ') {
376 format!("{}...", &truncated[..pos])
377 } else {
378 format!("{}...", truncated)
379 }
380}
381
382pub const CHECKPOINT_MESSAGE_MAX_LENGTH: usize = 60;
383

Callers 1

handle_responseMethod · 0.85

Calls 3

to_stringMethod · 0.80
truncate_safeFunction · 0.50
lenMethod · 0.45

Tested by

no test coverage detected