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 / sections / file-row / file-row.ts
41 lines · 1.2 KBRaw
1import type { RenderElement } from 'claude-code'
2
3import Limits from '../../../limits'
4import type { Kit } from '../../kit'
5import Layout from '../../layout'
6import { diffStat } from '../diff-stat'
7import type { FileRowModel } from '../file-row-model'
8import { listRow } from '../list-row'
9import { statTextOf } from '../stat-text-of'
10
11/**
12 * One file of the docked list (ReplDiffSidebar FileSummaryRow): the
13 * start-truncated name as a plain Button, its counts at the right.
14 *
15 * Nothing at the right at 0/0 (an untracked or binary file). The label is
16 * padded up to the counts, so the whole row before them presses.
17 *
18 * @param kit the elements, the handlers, the width
19 * @param row the file
20 * @param onPress scrolls the body to the file
21 * @returns the row element
22 */
23export function fileRow(
24 kit: Kit,
25 row: FileRowModel,
26 onPress: () => void,
27): RenderElement {
28 const label = Layout.padEnd(
29 Layout.truncateStart(
30 Layout.sanitizeName(row.displayPath),
31 Math.max(kit.columns - Limits.STAT_CELLS, Limits.PATH_FLOOR),
32 ),
33 kit.columns - statTextOf(row.added, row.removed).length,
34 )
35
36 return listRow(
37 kit,
38 { key: row.key, label, onPress, isDim: true, isAutoFocus: false },
39 diffStat(kit, row.added, row.removed),
40 )
41}