Skip to content

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.

TypeScript
830 B
Raw Blame
import Limits from '../../../../limits'
import type PaneState from '../../../../pane-state'
import type { DockPlan, ListWindow } from '../../types'

/**
 * The docked list's MAX_SUMMARY_ROWS-row window starting at the file the
 * person scrolled it to, clamped so a shrinking list pulls it back.
 *
 * @param model where the person put the list window
 * @param plan the docked pane's rows
 * @returns the window
 */
export function listWindowOf(
  model: Pick<PaneState.PaneModel, 'place'>,
  plan: Pick<DockPlan, 'rows'>,
): ListWindow {
  const first = Math.max(
    0,
    Math.min(model.place.listStart, plan.rows.length - Limits.MAX_SUMMARY_ROWS),
  )

  const shown = plan.rows.slice(first, first + Limits.MAX_SUMMARY_ROWS)

  return {
    shown,
    above: first,
    below: plan.rows.length - first - shown.length,
  }
}