| 6280 | .sort((a, b) => a - b); |
| 6281 | /** Source-ordered fill of whole parts, the overrunning one cut to a head window. */ |
| 6282 | const fill = (room: number): { emit: ExploreLineRange[]; used: number } => { |
| 6283 | const emit: ExploreLineRange[] = []; |
| 6284 | let used = 0; |
| 6285 | for (const p of parts) { |
| 6286 | const join = emit.length > 0 ? GAP_MARKER.length : 0; |
| 6287 | if (used + join + p.text.length <= room) { |
| 6288 | emit.push(p.range); |
| 6289 | used += join + p.text.length; |
| 6290 | continue; |
| 6291 | } |
| 6292 | const first = emit.length === 0; |
| 6293 | const win = headWindowOf( |
| 6294 | p.range, Math.max(0, room - used - join), first ? MIN_WINDOW_LINES : 0); |
| 6295 | if (win && (first || win.end - win.start + 1 >= MIN_WINDOW_LINES)) { |
| 6296 | emit.push(win); |
| 6297 | used += join + renderSpan(win).length; |
| 6298 | } |
| 6299 | break; |
| 6300 | } |
| 6301 | return { emit, used }; |
| 6302 | }; |
| 6303 | let { emit, used } = fill(ceiling); |
| 6304 | const reached = () => (emit.length ? emit[emit.length - 1]!.end : 0); |
| 6305 | if (focus.some((l) => l > reached())) { |