(text: string, from: number, to: number, s: string)
| 51 | |
| 52 | /** Replace the range [from,to) with `s`. Returns text + cursor after the inserted text. */ |
| 53 | export function replaceRange(text: string, from: number, to: number, s: string): { text: string; cursor: number } { |
| 54 | const a = Math.max(0, Math.min(from, to)); |
| 55 | const b = Math.min(text.length, Math.max(from, to)); |
| 56 | return { text: text.slice(0, a) + s + text.slice(b), cursor: a + s.length }; |
| 57 | } |
| 58 | |
| 59 | /** |
| 60 | * Ink delivers a terminal paste as a single multi-character burst in ONE useInput |
no outgoing calls
no test coverage detected