| 6336 | .sort((a, b) => a - b); |
| 6337 | /** Source-ordered fill of whole parts, the overrunning one cut to a head window. */ |
| 6338 | const fill = (room: number): { emit: ExploreLineRange[]; used: number } => { |
| 6339 | const emit: ExploreLineRange[] = []; |
| 6340 | let used = 0; |
| 6341 | for (const p of parts) { |
| 6342 | const join = emit.length > 0 ? GAP_MARKER.length : 0; |
| 6343 | if (used + join + p.text.length <= room) { |
| 6344 | emit.push(p.range); |
| 6345 | used += join + p.text.length; |
| 6346 | continue; |
| 6347 | } |
| 6348 | const first = emit.length === 0; |
| 6349 | const win = headWindowOf( |
| 6350 | p.range, Math.max(0, room - used - join), first ? MIN_WINDOW_LINES : 0); |
| 6351 | if (win && (first || win.end - win.start + 1 >= MIN_WINDOW_LINES)) { |
| 6352 | emit.push(win); |
| 6353 | used += join + renderSpan(win).length; |
| 6354 | } |
| 6355 | break; |
| 6356 | } |
| 6357 | return { emit, used }; |
| 6358 | }; |
| 6359 | let { emit, used } = fill(ceiling); |
| 6360 | const reached = () => (emit.length ? emit[emit.length - 1]!.end : 0); |
| 6361 | if (focus.some((l) => l > reached())) { |