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 / detail / runs-of / runs-of.ts
23 lines · 485 BRaw
1import type Types from '../types'
2
3/**
4 * Rows grouped into runs of one kind, in order.
5 *
6 * @param rows the laid-out rows
7 * @returns the runs
8 */
9export function runsOf(rows: readonly Types.Row[]): Types.Run[] {
10 const runs: Types.Run[] = []
11 let start = 0
12
13 rows.forEach((row, at) => {
14 const isRunEnd = rows[at + 1]?.kind !== row.kind
15
16 if (isRunEnd) {
17 runs.push({ kind: row.kind, rows: rows.slice(start, at + 1) })
18 start = at + 1
19 }
20 })
21
22 return runs
23}