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

Method centeredWindowOf

src/mcp/tools.ts:6313–6324  ·  view source on GitHub ↗
(
        line: number, lo: number, hi: number, room: number,
      )

Source from the content-addressed store, hash-verified

6311 };
6312 /** Widest window around `line` inside [lo, hi] that fits `room`. */
6313 const centeredWindowOf = (
6314 line: number, lo: number, hi: number, room: number,
6315 ): ExploreLineRange | null => {
6316 if (line < lo || line > hi) return null;
6317 let start = line, end = line, chars = lineCost(line);
6318 for (let grown = true; grown;) {
6319 grown = false;
6320 if (end + 1 <= hi && chars + lineCost(end + 1) <= room) { end += 1; chars += lineCost(end); grown = true; }
6321 if (start - 1 >= lo && chars + lineCost(start - 1) <= room) { start -= 1; chars += lineCost(start); grown = true; }
6322 }
6323 return { start, end };
6324 };
6325 /**
6326 * Reduce rendered parts to fit `ceiling`, never to nothing. Whole parts are
6327 * kept while they fit; the first part that overruns is cut to a leading

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected