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 { DetailModel } from '../detail-model' |
| 2 | import { SAFE_PATHSPEC_PATTERN } from './safe-pathspec-pattern' |
| 3 | |
| 4 | /** |
| 5 | * The dim italic lines drawn instead of hunks (DiffDetailView's wording), |
| 6 | * or null when the hunks draw. |
| 7 | * |
| 8 | * Untracked (the backend's note, its pasteable command only for a name of |
| 9 | * letters, digits and `._/@+-`), binary, loading, unreadable, large, or |
| 10 | * empty. |
| 11 | * |
| 12 | * @param detail the selected file |
| 13 | * @returns the lines, or null |
| 14 | */ |
| 15 | export function placeholderOf(detail: DetailModel): readonly string[] | null { |
| 16 | if (detail.isUntracked) { |
| 17 | return detail.words.untrackedNoteOf( |
| 18 | detail.path, |
| 19 | SAFE_PATHSPEC_PATTERN.test(detail.path), |
| 20 | ) |
| 21 | } |
| 22 | |
| 23 | if (detail.isBinary) { |
| 24 | return ['Binary file - cannot display diff'] |
| 25 | } |
| 26 | |
| 27 | if (detail.bodyState === 'idle' || detail.bodyState === 'loading') { |
| 28 | return ['Loading diff…'] |
| 29 | } |
| 30 | |
| 31 | if (detail.bodyState === 'failed' || !detail.body) { |
| 32 | return ['Diff unavailable'] |
| 33 | } |
| 34 | |
| 35 | const { isLarge, hunks } = detail.body |
| 36 | const isEmpty = hunks.length === 0 |
| 37 | const note = isLarge |
| 38 | ? 'Large file - diff exceeds 1 MB limit' |
| 39 | : isEmpty |
| 40 | ? 'No diff content' |
| 41 | : null |
| 42 | |
| 43 | return note ? [note] : null |
| 44 | } |