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 / pane-state / selection-of / selection-of.ts
16 lines · 595 BRaw
1import type Git from '../../git'
2
3/**
4 * The file whose body the pane shows: the one the person picked while it is
5 * still listed, else the first listed one, else none.
6 *
7 * @param listed the rows on screen, in order (session rows, then the
8 * pre-session rows while that section is open)
9 * @param selectedPath the person's pick, or null
10 * @returns the selected row, or null for an empty list
11 */
12export const selectionOf = (
13 listed: readonly Git.FileStat[],
14 selectedPath: string | null,
15): Git.FileStat | null =>
16 listed.find(file => file.path === selectedPath) ?? listed[0] ?? null