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

Method centeredWindowOf

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

Source from the content-addressed store, hash-verified

6289 };
6290 /** Widest window around `line` inside [lo, hi] that fits `room`. */
6291 const centeredWindowOf = (
6292 line: number, lo: number, hi: number, room: number,
6293 ): ExploreLineRange | null => {
6294 if (line < lo || line > hi) return null;
6295 let start = line, end = line, chars = lineCost(line);
6296 for (let grown = true; grown;) {
6297 grown = false;
6298 if (end + 1 <= hi && chars + lineCost(end + 1) <= room) { end += 1; chars += lineCost(end); grown = true; }
6299 if (start - 1 >= lo && chars + lineCost(start - 1) <= room) { start -= 1; chars += lineCost(start); grown = true; }
6300 }
6301 return { start, end };
6302 };
6303 /**
6304 * Reduce rendered parts to fit `ceiling`, never to nothing. Whole parts are
6305 * 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