claude-code / mods /diff /tests /fixtures /code-blocks-of /are-contiguous.ts
SaylorTwift's picture
SaylorTwift HF Staff
Add files using upload-large-folder tool
7f0ec95 verified
Raw History Blame Contribute Delete
588 Bytes
import type { ParsedHunk } from './parsed-hunk.js'
/**
* Whether each hunk starts where the one before it ended, on both sides:
* the sub-hunks of one hunk split leave no line out and repeat none.
*
* @param parts the hunks in order
* @returns true when they abut
*/
export const areContiguous = (parts: readonly ParsedHunk[]): boolean =>
parts.slice(1).every((part, at) => {
const before = parts[at]
return (
before !== undefined &&
part.oldStart === before.oldStart + before.oldLines &&
part.newStart === before.newStart + before.newLines
)
})