MCPcopy Create free account
hub / github.com/codeaashu/claude-code / findAdjacentPairs

Function findAdjacentPairs

src/native-ts/color-diff/index.ts:576–602  ·  view source on GitHub ↗
(markers: Marker[])

Source from the content-addressed store, hash-verified

574}
575
576function findAdjacentPairs(markers: Marker[]): [number, number][] {
577 const pairs: [number, number][] = []
578 let i = 0
579 while (i < markers.length) {
580 if (markers[i] === '-') {
581 const delStart = i
582 let delEnd = i
583 while (delEnd < markers.length && markers[delEnd] === '-') delEnd++
584 let addEnd = delEnd
585 while (addEnd < markers.length && markers[addEnd] === '+') addEnd++
586 const delCount = delEnd - delStart
587 const addCount = addEnd - delEnd
588 if (delCount > 0 && addCount > 0) {
589 const n = Math.min(delCount, addCount)
590 for (let k = 0; k < n; k++) {
591 pairs.push([delStart + k, delEnd + k])
592 }
593 i = addEnd
594 } else {
595 i = delEnd
596 }
597 } else {
598 i++
599 }
600 }
601 return pairs
602}
603
604function wordDiffStrings(oldStr: string, newStr: string): [Range[], Range[]] {
605 const oldTokens = tokenize(oldStr)

Callers 1

renderMethod · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected