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

Method centeredWindowOf

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

Source from the content-addressed store, hash-verified

6233 };
6234 /** Widest window around `line` inside [lo, hi] that fits `room`. */
6235 const centeredWindowOf = (
6236 line: number, lo: number, hi: number, room: number,
6237 ): ExploreLineRange | null => {
6238 if (line < lo || line > hi) return null;
6239 let start = line, end = line, chars = lineCost(line);
6240 for (let grown = true; grown;) {
6241 grown = false;
6242 if (end + 1 <= hi && chars + lineCost(end + 1) <= room) { end += 1; chars += lineCost(end); grown = true; }
6243 if (start - 1 >= lo && chars + lineCost(start - 1) <= room) { start -= 1; chars += lineCost(start); grown = true; }
6244 }
6245 return { start, end };
6246 };
6247 /**
6248 * Reduce rendered parts to fit `ceiling`, never to nothing. Whole parts are
6249 * 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