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 / tests / fixtures / code-blocks-of / are-contiguous.ts
19 lines · 588 BRaw
1import type { ParsedHunk } from './parsed-hunk.js'
2
3/**
4 * Whether each hunk starts where the one before it ended, on both sides:
5 * the sub-hunks of one hunk split leave no line out and repeat none.
6 *
7 * @param parts the hunks in order
8 * @returns true when they abut
9 */
10export const areContiguous = (parts: readonly ParsedHunk[]): boolean =>
11 parts.slice(1).every((part, at) => {
12 const before = parts[at]
13
14 return (
15 before !== undefined &&
16 part.oldStart === before.oldStart + before.oldLines &&
17 part.newStart === before.newStart + before.newLines
18 )
19 })