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
| 1 | import type { UiScrollInput } from 'claude-code' |
| 2 | |
| 3 | import Limits from '../../limits' |
| 4 | import type PaneState from '../../pane-state' |
| 5 | import Plan from './plan' |
| 6 | |
| 7 | /** |
| 8 | * The docked pane's place after one of the person's scrolls of the body: |
| 9 | * a wheel tick or arrow three rows, a page key the window, Home/End an end. |
| 10 | * |
| 11 | * Told apart by the rows the move asks for against the pane's body and |
| 12 | * tree, as the engine sizes each; clamped to the body's extent. |
| 13 | * |
| 14 | * @param model the pane's state |
| 15 | * @param scroll the move: its signed rows, the body's rows, the tree's rows |
| 16 | * @returns the place |
| 17 | */ |
| 18 | export function bodyScrolledBy( |
| 19 | model: PaneState.PaneModel, |
| 20 | scroll: Pick<UiScrollInput, 'by' | 'bodyRows' | 'contentRows'>, |
| 21 | ): PaneState.PaneModel['place'] { |
| 22 | const { visibleRows, maxTop } = Plan.bodyLayoutOf( |
| 23 | model, |
| 24 | Plan.dockPlanOf(model), |
| 25 | ) |
| 26 | |
| 27 | const size = Math.abs(scroll.by) |
| 28 | |
| 29 | const isEnd = |
| 30 | size >= scroll.contentRows && scroll.contentRows > scroll.bodyRows |
| 31 | |
| 32 | const isPage = !isEnd && size >= scroll.bodyRows |
| 33 | |
| 34 | const step = isEnd |
| 35 | ? maxTop |
| 36 | : isPage |
| 37 | ? Math.max(1, visibleRows) |
| 38 | : size * Limits.WHEEL_ROWS |
| 39 | |
| 40 | return { |
| 41 | ...model.place, |
| 42 | top: Math.max( |
| 43 | 0, |
| 44 | Math.min(maxTop, model.place.top + Math.sign(scroll.by) * step), |
| 45 | ), |
| 46 | } |
| 47 | } |