* Find the visual line index that contains the given logical position.
(
visualLines: Array<{ logicalLine: number; startCol: number; length: number }>,
line: number,
col: number,
)
| 1826 | * Find the visual line index that contains the given logical position. |
| 1827 | */ |
| 1828 | private findVisualLineAt( |
| 1829 | visualLines: Array<{ logicalLine: number; startCol: number; length: number }>, |
| 1830 | line: number, |
| 1831 | col: number, |
| 1832 | ): number { |
| 1833 | for (let i = 0; i < visualLines.length; i++) { |
| 1834 | const vl = visualLines[i]; |
| 1835 | if (!vl || vl.logicalLine !== line) continue; |
| 1836 | const offset = col - vl.startCol; |
| 1837 | // Cursor is in this segment if it's within range. For the last |
| 1838 | // segment of a logical line, cursor can be at length (end position) |
| 1839 | const isLastSegmentOfLine = i === visualLines.length - 1 || visualLines[i + 1]?.logicalLine !== vl.logicalLine; |
| 1840 | if (offset >= 0 && (offset < vl.length || (isLastSegmentOfLine && offset === vl.length))) { |
| 1841 | return i; |
| 1842 | } |
| 1843 | } |
| 1844 | return visualLines.length - 1; |
| 1845 | } |
| 1846 | |
| 1847 | /** |
| 1848 | * Find the visual line index for the current cursor position. |
no outgoing calls
no test coverage detected