MCPcopy Create free account
hub / github.com/JaredStewart/coderlm / peek_buffer

Function peek_buffer

server/src/ops/buffers.rs:96–117  ·  view source on GitHub ↗
(
    buffers: &DashMap<String, Buffer>,
    name: &str,
    start: usize,
    end: usize,
)

Source from the content-addressed store, hash-verified

94}
95
96pub fn peek_buffer(
97 buffers: &DashMap<String, Buffer>,
98 name: &str,
99 start: usize,
100 end: usize,
101) -> Result<String, String> {
102 let buf = buffers
103 .get(name)
104 .ok_or_else(|| format!("Buffer '{}' not found", name))?;
105
106 let lines: Vec<&str> = buf.content.lines().collect();
107 let total = lines.len();
108 let start = start.min(total);
109 let end = end.min(total);
110
111 Ok(lines[start..end]
112 .iter()
113 .enumerate()
114 .map(|(i, line)| format!("{:>6} | {}", start + i + 1, line))
115 .collect::<Vec<_>>()
116 .join("\n"))
117}
118
119#[derive(Debug, Serialize)]
120pub struct BufferSummary {

Callers

nothing calls this directly

Calls 2

getMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected