MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / hopCompare

Function hopCompare

src/ui-server/api/steps.ts:1737–1743  ·  view source on GitHub ↗

Source order of two hops: a hop written inside the other's call runs first; else by position; another file sorts after.

(a: HopSite | undefined, b: HopSite | undefined)

Source from the content-addressed store, hash-verified

1735
1736/** Source order of two hops: a hop written inside the other's call runs first; else by position; another file sorts after. */
1737function hopCompare(a: HopSite | undefined, b: HopSite | undefined): number {
1738 if (!a || !b) return a ? -1 : b ? 1 : 0;
1739 if (a.file !== b.file) return a.file.localeCompare(b.file);
1740 if (hopInside(a, b)) return -1;
1741 if (hopInside(b, a)) return 1;
1742 return a.line - b.line || a.column - b.column;
1743}
1744
1745/** `x` starts strictly after `y` starts and before `y` ends. */
1746function hopInside(x: HopSite, y: HopSite): boolean {

Callers 1

buildStepsFunction · 0.85

Calls 1

hopInsideFunction · 0.85

Tested by

no test coverage detected