MCPcopy Index your code
hub / github.com/continuedev/continue / findChangedAreas

Function findChangedAreas

core/nextEdit/diff/diff.ts:321–343  ·  view source on GitHub ↗

* Find areas of change in the diff lines.

(
  diffLines: DiffLine[],
)

Source from the content-addressed store, hash-verified

319 * Find areas of change in the diff lines.
320 */
321function findChangedAreas(
322 diffLines: DiffLine[],
323): { start: number; end: number }[] {
324 const changedAreas: { start: number; end: number }[] = [];
325 let changedAreaStart = -1;
326
327 for (let i = 0; i < diffLines.length; i++) {
328 if (diffLines[i].type !== "same" && changedAreaStart === -1) {
329 changedAreaStart = i;
330 } else if (diffLines[i].type === "same" && changedAreaStart !== -1) {
331 // We've found the end of a changed area.
332 changedAreas.push({ start: changedAreaStart, end: i - 1 });
333 changedAreaStart = -1;
334 }
335 }
336
337 // Handle the last changed area if it extends to the end.
338 if (changedAreaStart !== -1) {
339 changedAreas.push({ start: changedAreaStart, end: diffLines.length - 1 });
340 }
341
342 return changedAreas;
343}
344
345/**
346 * Count the number of lines in the old content (excluding "new" lines).

Callers 1

groupDiffLinesFunction · 0.85

Calls 1

pushMethod · 0.65

Tested by

no test coverage detected