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 / dialog-pane / dialog-window-of / dialog-window-of.ts
23 lines · 715 BRaw
1import Limits from '../../../limits'
2import type PaneState from '../../../pane-state'
3
4/**
5 * The first of the MAX_VISIBLE_FILES rows the dialog lists (DiffFileList's
6 * window): centred on the selected file, the first when none is, clamped.
7 *
8 * @param model the pane's state: the selection
9 * @param paths the listed files' paths, in order
10 * @returns the first listed row's index
11 */
12export const dialogWindowOf = (
13 model: Pick<PaneState.PaneModel, 'selectedPath'>,
14 paths: readonly string[],
15): number =>
16 Math.max(
17 0,
18 Math.min(
19 paths.length - Limits.MAX_VISIBLE_FILES,
20 Math.max(0, paths.indexOf(model.selectedPath ?? '')) -
21 Math.floor(Limits.MAX_VISIBLE_FILES / 2),
22 ),
23 )