spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / diff / hooks / views / body / plan / segments / list-window-of.ts
29 lines · 830 BRaw
1import Limits from '../../../../limits'
2import type PaneState from '../../../../pane-state'
3import type { DockPlan, ListWindow } from '../../types'
4
5/**
6 * The docked list's MAX_SUMMARY_ROWS-row window starting at the file the
7 * person scrolled it to, clamped so a shrinking list pulls it back.
8 *
9 * @param model where the person put the list window
10 * @param plan the docked pane's rows
11 * @returns the window
12 */
13export function listWindowOf(
14 model: Pick<PaneState.PaneModel, 'place'>,
15 plan: Pick<DockPlan, 'rows'>,
16): ListWindow {
17 const first = Math.max(
18 0,
19 Math.min(model.place.listStart, plan.rows.length - Limits.MAX_SUMMARY_ROWS),
20 )
21
22 const shown = plan.rows.slice(first, first + Limits.MAX_SUMMARY_ROWS)
23
24 return {
25 shown,
26 above: first,
27 below: plan.rows.length - first - shown.length,
28 }
29}