MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / onePass

Function onePass

src/util/unifyRanges.ts:12–28  ·  view source on GitHub ↗
(ranges: Range[])

Source from the content-addressed store, hash-verified

10}
11
12function onePass(ranges: Range[]): [Range[], boolean] {
13 const result: Range[] = [];
14 let madeChanges = false;
15 ranges.forEach((range) => {
16 const index = result.findIndex((r) => r.intersection(range) != null);
17 // Update existing intersecting range
18 if (index > -1) {
19 result[index] = result[index].union(range);
20 madeChanges = true;
21 }
22 // Add new range
23 else {
24 result.push(range);
25 }
26 });
27 return [result, madeChanges];
28}

Callers 1

unifyRangesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected