(text: string, columns: number)
| 37 | } |
| 38 | |
| 39 | function estimateTextRows(text: string, columns: number): number | undefined { |
| 40 | if (!text) return undefined; |
| 41 | const wrapWidth = Math.max(1, columns); |
| 42 | let rows = 0; |
| 43 | let start = 0; |
| 44 | while (start <= text.length) { |
| 45 | const end = text.indexOf('\n', start); |
| 46 | const lineLength = (end === -1 ? text.length : end) - start; |
| 47 | rows += Math.max(1, Math.ceil(lineLength / wrapWidth)); |
| 48 | if (end === -1) break; |
| 49 | start = end + 1; |
| 50 | } |
| 51 | return rows; |
| 52 | } |
| 53 | export type StickyPrompt = { |
| 54 | text: string; |
| 55 | scrollTo: () => void; |
no test coverage detected