(params: {
cursorPosition: number
lineStarts: number[]
cursorIsChar: boolean
direction: 'up' | 'down'
desiredIndex: number
})
| 35 | } |
| 36 | |
| 37 | export function calculateNewCursorPosition(params: { |
| 38 | cursorPosition: number |
| 39 | lineStarts: number[] |
| 40 | cursorIsChar: boolean |
| 41 | direction: 'up' | 'down' |
| 42 | desiredIndex: number |
| 43 | }): number { |
| 44 | const { direction } = params |
| 45 | if (direction === 'up') { |
| 46 | return cursorUp(params) |
| 47 | } |
| 48 | if (direction === 'down') { |
| 49 | return cursorDown(params) |
| 50 | } |
| 51 | direction satisfies never |
| 52 | throw new Error(`Invalid direction: ${direction}`) |
| 53 | } |
no test coverage detected