(text: string, cursor: number, s: string)
| 32 | |
| 33 | /** Insert `s` at `cursor`. Returns new text and the cursor after the inserted text. */ |
| 34 | export function insertAt(text: string, cursor: number, s: string): { text: string; cursor: number } { |
| 35 | const c = Math.max(0, Math.min(cursor, text.length)); |
| 36 | return { text: text.slice(0, c) + s + text.slice(c), cursor: c + s.length }; |
| 37 | } |
| 38 | |
| 39 | /** Backspace one char left of cursor. */ |
| 40 | export function backspace(text: string, cursor: number): { text: string; cursor: number } { |
no outgoing calls
no test coverage detected