({
previousViewportHeight,
terminalRows = 0,
coldStartCount = COLD_START_COUNT,
}: {
previousViewportHeight: number
terminalRows?: number
coldStartCount?: number
})
| 118 | } |
| 119 | |
| 120 | export function resolveVirtualScrollColdStartCount({ |
| 121 | previousViewportHeight, |
| 122 | terminalRows = 0, |
| 123 | coldStartCount = COLD_START_COUNT, |
| 124 | }: { |
| 125 | previousViewportHeight: number |
| 126 | terminalRows?: number |
| 127 | coldStartCount?: number |
| 128 | }): number { |
| 129 | if (previousViewportHeight > 0) { |
| 130 | return Math.min( |
| 131 | coldStartCount, |
| 132 | Math.max(12, Math.ceil(previousViewportHeight) + 6), |
| 133 | ) |
| 134 | } |
| 135 | |
| 136 | if (terminalRows > 0) { |
| 137 | // Long-history transcript entry is dominated by the first viewportH=0 |
| 138 | // mount. Before ScrollBox lays out, Ink already knows the real terminal |
| 139 | // height; using it here avoids over-mounting the historical 30-row tail |
| 140 | // for giant rendered file/code blocks the user cannot see on frame 0. |
| 141 | return Math.min(coldStartCount, Math.max(12, Math.ceil(terminalRows))) |
| 142 | } |
| 143 | |
| 144 | return coldStartCount |
| 145 | } |
| 146 | |
| 147 | export function computeVirtualScrollColdStartRange({ |
| 148 | itemKeys, |
no test coverage detected