(text: string, cursor: number)
| 17 | |
| 18 | /** Index after jumping one word RIGHT from `cursor` (skip whitespace, then word). */ |
| 19 | export function wordRight(text: string, cursor: number): number { |
| 20 | const n = text.length; |
| 21 | let i = Math.max(0, Math.min(cursor, n)); |
| 22 | while (i < n && isWS(text[i]!)) i++; |
| 23 | while (i < n && !isWS(text[i]!)) i++; |
| 24 | return i; |
| 25 | } |
| 26 | |
| 27 | /** Delete the word immediately left of the cursor (Ctrl+W). Returns new text+cursor. */ |
| 28 | export function deleteWordLeft(text: string, cursor: number): { text: string; cursor: number } { |
no test coverage detected