MCPcopy Create free account
hub / github.com/Zoo-Code-Org/Zoo-Code / computeIncludedRanges

Function computeIncludedRanges

src/integrations/misc/indentation-reader.ts:252–275  ·  view source on GitHub ↗

* Convert a contiguous array of LineRecords into merged ranges for output.

(lines: LineRecord[])

Source from the content-addressed store, hash-verified

250 * Convert a contiguous array of LineRecords into merged ranges for output.
251 */
252function computeIncludedRanges(lines: LineRecord[]): Array<[number, number]> {
253 if (lines.length === 0) return []
254
255 const ranges: Array<[number, number]> = []
256 let rangeStart = lines[0].lineNumber
257 let rangeEnd = lines[0].lineNumber
258
259 for (let i = 1; i < lines.length; i++) {
260 const lineNum = lines[i].lineNumber
261 if (lineNum === rangeEnd + 1) {
262 // Contiguous
263 rangeEnd = lineNum
264 } else {
265 // Gap - save current range and start new one
266 ranges.push([rangeStart, rangeEnd])
267 rangeStart = lineNum
268 rangeEnd = lineNum
269 }
270 }
271 // Don't forget the last range
272 ranges.push([rangeStart, rangeEnd])
273
274 return ranges
275}
276
277// ─── Main Export ──────────────────────────────────────────────────────────────
278

Callers 1

readWithIndentationFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected