* Insert text at cursor position and return the new text and cursor position.
( text: string, cursorPosition: number, textToInsert: string, )
| 67 | * Insert text at cursor position and return the new text and cursor position. |
| 68 | */ |
| 69 | function insertTextAtCursor( |
| 70 | text: string, |
| 71 | cursorPosition: number, |
| 72 | textToInsert: string, |
| 73 | ): { newText: string; newCursor: number } { |
| 74 | const before = text.slice(0, cursorPosition) |
| 75 | const after = text.slice(cursorPosition) |
| 76 | return { |
| 77 | newText: before + textToInsert + after, |
| 78 | newCursor: before.length + textToInsert.length, |
| 79 | } |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * Creates a paste handler for text-only inputs (feedback, ask-user, etc.). |
no outgoing calls
no test coverage detected