File size: 588 Bytes
7f0ec95
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
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
    )
  })