( diffLines: DiffLine[], offset: number = 0, maxGroupSize?: number, )
| 285 | * @returns Array of DiffGroup objects representing the changes |
| 286 | */ |
| 287 | export function groupDiffLines( |
| 288 | diffLines: DiffLine[], |
| 289 | offset: number = 0, |
| 290 | maxGroupSize?: number, |
| 291 | ): DiffGroup[] { |
| 292 | const groups: DiffGroup[] = []; |
| 293 | const changedAreas = findChangedAreas(diffLines); |
| 294 | |
| 295 | for (const area of changedAreas) { |
| 296 | if (maxGroupSize === undefined) { |
| 297 | // Mode 1: Flexible group size. |
| 298 | groups.push( |
| 299 | processFlexibleSizeGroup(diffLines, area.start, area.end, offset), |
| 300 | ); |
| 301 | } else { |
| 302 | // Mode 2: Limited group size. |
| 303 | groups.push( |
| 304 | processLimitedSizeGroup( |
| 305 | diffLines, |
| 306 | area.start, |
| 307 | area.end, |
| 308 | maxGroupSize, |
| 309 | offset, |
| 310 | ), |
| 311 | ); |
| 312 | } |
| 313 | } |
| 314 | |
| 315 | return groups; |
| 316 | } |
| 317 | |
| 318 | /** |
| 319 | * Find areas of change in the diff lines. |
no test coverage detected