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 / record / width-bucket-of / width-bucket-of.ts
21 lines · 692 BRaw
1import Limits from '../../limits'
2import { WIDTH_BUCKETS } from '../width-buckets'
3
4/**
5 * The bucket a terminal width falls in, the built-in panel's own buckets.
6 *
7 * @param columns the terminal's width, or null when no render told it yet
8 * @returns one of WIDTH_BUCKETS
9 */
10export function widthBucketOf(
11 columns: number | null,
12): (typeof WIDTH_BUCKETS)[number] {
13 const [narrow, medium, wide, widest] = WIDTH_BUCKETS
14 const width = columns ?? 0
15
16 const isNarrow = width < Limits.OPEN_MIN_COLUMNS
17 const isMedium = width < Limits.AUTO_OPEN_MIN_COLUMNS
18 const isWide = width < Limits.WIDEST_BUCKET_COLUMNS
19
20 return isNarrow ? narrow : isMedium ? medium : isWide ? wide : widest
21}