| 52 | const starts = [0]; |
| 53 | for (let index = 0; index < text.length; index++) if (text.charCodeAt(index) === 10) starts.push(index + 1); |
| 54 | const position = (offset: number) => { |
| 55 | let low = 0, high = starts.length; |
| 56 | while (low + 1 < high) { |
| 57 | const middle = (low + high) >>> 1; |
| 58 | if (starts[middle] <= offset) low = middle; else high = middle; |
| 59 | } |
| 60 | return { line: source.startLine + low, column: offset - starts[low] + (low === 0 ? source.startColumn : 1) }; |
| 61 | }; |
| 62 | const make = (start: number, end: number, index: number): ExplanationEvidence => { |
| 63 | const content = prefix(text.slice(start, end), end - start); |
| 64 | // slice(start, end) may itself end halfway through a pair; inspect the |