MCPcopy
hub / github.com/garrytan/gstack / lineColAt

Function lineColAt

lib/redact-engine.ts:155–167  ·  view source on GitHub ↗
(original: string, offset: number)

Source from the content-addressed store, hash-verified

153// ── Offset → line/col on the ORIGINAL text ────────────────────────────────────
154
155function lineColAt(original: string, offset: number): { line: number; col: number } {
156 let line = 1;
157 let col = 1;
158 for (let i = 0; i < offset && i < original.length; i++) {
159 if (original[i] === "\n") {
160 line += 1;
161 col = 1;
162 } else {
163 col += 1;
164 }
165 }
166 return { line, col };
167}
168
169// ── Safe preview masking ──────────────────────────────────────────────────────
170

Callers 1

scanFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected