MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / truncate_text

Function truncate_text

crates/opencode-tui/src/components/sidebar.rs:611–624  ·  view source on GitHub ↗
(text: &str, max_chars: usize)

Source from the content-addressed store, hash-verified

609}
610
611fn truncate_text(text: &str, max_chars: usize) -> String {
612 if max_chars == 0 {
613 return String::new();
614 }
615 if text.chars().count() <= max_chars {
616 return text.to_string();
617 }
618 let mut out = String::with_capacity(max_chars + 1);
619 for ch in text.chars().take(max_chars.saturating_sub(1)) {
620 out.push(ch);
621 }
622 out.push('…');
623 out
624}
625
626fn split_path_segments(path: &str) -> (String, String) {
627 if path.is_empty() {

Callers

nothing calls this directly

Calls 2

newFunction · 0.85
countMethod · 0.80

Tested by

no test coverage detected