MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / normalizeRanges

Function normalizeRanges

src/cm/colorView.ts:167–187  ·  view source on GitHub ↗
(ranges: readonly DocRange[])

Source from the content-addressed store, hash-verified

165}
166
167function normalizeRanges(ranges: readonly DocRange[]): DocRange[] {
168 if (!ranges.length) return [];
169 const sorted = [...ranges]
170 .map(({ from, to }) => {
171 const rangeFrom = Math.max(0, from);
172 return { from: rangeFrom, to: Math.max(rangeFrom, to) };
173 })
174 .sort((a, b) => a.from - b.from || a.to - b.to);
175 const merged: DocRange[] = [];
176
177 for (const range of sorted) {
178 const last = merged[merged.length - 1];
179 if (last && range.from <= last.to) {
180 last.to = Math.max(last.to, range.to);
181 continue;
182 }
183 merged.push(range);
184 }
185
186 return merged;
187}
188
189function mapRanges(
190 ranges: readonly DocRange[],

Callers 7

mapRangesFunction · 0.85
intersectRangesFunction · 0.85
subtractRangesFunction · 0.85
constructorMethod · 0.85
scheduleVisibleRangesMethod · 0.85
scheduleDecorationsMethod · 0.85
flushDecorationsMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected