(value: string)
| 407 | }>; |
| 408 | |
| 409 | function buildInputLineRanges(value: string): InputLineRanges { |
| 410 | const starts: number[] = []; |
| 411 | const ends: number[] = []; |
| 412 | let lineStart = 0; |
| 413 | for (let i = 0; i < value.length; i++) { |
| 414 | if (value.charCodeAt(i) === 0x0a) { |
| 415 | starts.push(lineStart); |
| 416 | ends.push(i); |
| 417 | lineStart = i + 1; |
| 418 | } |
| 419 | } |
| 420 | starts.push(lineStart); |
| 421 | ends.push(value.length); |
| 422 | return Object.freeze({ starts: Object.freeze(starts), ends: Object.freeze(ends) }); |
| 423 | } |
| 424 | |
| 425 | function findLineIndexAtCursor(lines: InputLineRanges, cursor: number): number { |
| 426 | const c = Math.max(0, cursor); |
no test coverage detected