(text: string, cursor: number)
| 38 | |
| 39 | /** Backspace one char left of cursor. */ |
| 40 | export function backspace(text: string, cursor: number): { text: string; cursor: number } { |
| 41 | if (cursor <= 0) return { text, cursor: 0 }; |
| 42 | return { text: text.slice(0, cursor - 1) + text.slice(cursor), cursor: cursor - 1 }; |
| 43 | } |
| 44 | |
| 45 | /** Delete the half-open range [from,to) (order-independent). Returns text + cursor at range start. */ |
| 46 | export function deleteRange(text: string, from: number, to: number): { text: string; cursor: number } { |
no outgoing calls
no test coverage detected