Function
lineColAt
(original: string, offset: number)
Source from the content-addressed store, hash-verified
| 153 | // ── Offset → line/col on the ORIGINAL text ──────────────────────────────────── |
| 154 | |
| 155 | function 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 | |
Tested by
no test coverage detected