MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / slice_lines

Method slice_lines

crates/opencode-session/src/prompt.rs:682–695  ·  view source on GitHub ↗
(text: &str, start: usize, end: Option<usize>)

Source from the content-addressed store, hash-verified

680 }
681
682 fn slice_lines(text: &str, start: usize, end: Option<usize>) -> String {
683 let lines: Vec<&str> = text.lines().collect();
684 if lines.is_empty() {
685 return String::new();
686 }
687
688 let start_idx = start.saturating_sub(1).min(lines.len());
689 let end_idx = end.unwrap_or(lines.len()).min(lines.len());
690 if start_idx >= end_idx {
691 return String::new();
692 }
693
694 lines[start_idx..end_idx].join("\n")
695 }
696
697 async fn read_directory_preview(path: &Path) -> String {
698 let mut entries = match tokio::fs::read_dir(path).await {

Callers

nothing calls this directly

Calls 2

newFunction · 0.85
is_emptyMethod · 0.80

Tested by

no test coverage detected