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 / list-scrolled-by.ts
29 lines · 728 BRaw
1import Limits from '../../limits'
2import type PaneState from '../../pane-state'
3import Plan from './plan'
4
5/**
6 * The docked pane's place with the list window moved by so many files,
7 * clamped to the list (ReplDiffSidebar's scrollSummary).
8 *
9 * @param model the pane's state
10 * @param delta the files to move by, negative toward the top
11 * @returns the place
12 */
13export function listScrolledBy(
14 model: PaneState.PaneModel,
15 delta: number,
16): PaneState.PaneModel['place'] {
17 const last = Math.max(
18 0,
19 Plan.dockPlanOf(model).rows.length - Limits.MAX_SUMMARY_ROWS,
20 )
21
22 return {
23 ...model.place,
24 listStart: Math.max(
25 0,
26 Math.min(last, Math.min(model.place.listStart, last) + delta),
27 ),
28 }
29}