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

Method headWindowOf

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

Source from the content-addressed store, hash-verified

6219 * else has been emitted and the alternative is an empty section.
6220 */
6221 const headWindowOf = (
6222 r: ExploreLineRange, room: number, minLines = 0,
6223 ): ExploreLineRange | null => {
6224 let end = r.start - 1;
6225 let chars = 0;
6226 for (let ln = r.start; ln <= r.end; ln++) {
6227 const cost = lineCost(ln);
6228 if (chars + cost > room && end - r.start + 1 >= minLines) break;
6229 chars += cost;
6230 end = ln;
6231 }
6232 return end >= r.start ? { start: r.start, end } : null;
6233 };
6234 /** Widest window around `line` inside [lo, hi] that fits `room`. */
6235 const centeredWindowOf = (
6236 line: number, lo: number, hi: number, room: number,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected