(text: string, cursor: number)
| 9 | |
| 10 | /** Index after jumping one word LEFT from `cursor` (skip whitespace, then word). */ |
| 11 | export function wordLeft(text: string, cursor: number): number { |
| 12 | let i = Math.max(0, Math.min(cursor, text.length)); |
| 13 | while (i > 0 && isWS(text[i - 1]!)) i--; |
| 14 | while (i > 0 && !isWS(text[i - 1]!)) i--; |
| 15 | return i; |
| 16 | } |
| 17 | |
| 18 | /** Index after jumping one word RIGHT from `cursor` (skip whitespace, then word). */ |
| 19 | export function wordRight(text: string, cursor: number): number { |
no test coverage detected