MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / headWindowOf

Method headWindowOf

src/mcp/tools.ts:6277–6289  ·  view source on GitHub ↗
(
        r: ExploreLineRange, room: number, minLines = 0,
      )

Source from the content-addressed store, hash-verified

6275 * else has been emitted and the alternative is an empty section.
6276 */
6277 const headWindowOf = (
6278 r: ExploreLineRange, room: number, minLines = 0,
6279 ): ExploreLineRange | null => {
6280 let end = r.start - 1;
6281 let chars = 0;
6282 for (let ln = r.start; ln <= r.end; ln++) {
6283 const cost = lineCost(ln);
6284 if (chars + cost > room && end - r.start + 1 >= minLines) break;
6285 chars += cost;
6286 end = ln;
6287 }
6288 return end >= r.start ? { start: r.start, end } : null;
6289 };
6290 /** Widest window around `line` inside [lo, hi] that fits `room`. */
6291 const centeredWindowOf = (
6292 line: number, lo: number, hi: number, room: number,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected