MCPcopy Index your code
hub / github.com/codeaashu/claude-code / diffEach

Function diffEach

src/ink/screen.ts:1156–1206  ·  view source on GitHub ↗
(
  prev: Screen,
  next: Screen,
  cb: DiffCallback,
)

Source from the content-addressed store, hash-verified

1154 * Returns true if the callback ever returned true (early exit signal).
1155 */
1156export function diffEach(
1157 prev: Screen,
1158 next: Screen,
1159 cb: DiffCallback,
1160): boolean {
1161 const prevWidth = prev.width
1162 const nextWidth = next.width
1163 const prevHeight = prev.height
1164 const nextHeight = next.height
1165
1166 let region: Rectangle
1167 if (prevWidth === 0 && prevHeight === 0) {
1168 region = { x: 0, y: 0, width: nextWidth, height: nextHeight }
1169 } else if (next.damage) {
1170 region = next.damage
1171 if (prev.damage) {
1172 region = unionRect(region, prev.damage)
1173 }
1174 } else if (prev.damage) {
1175 region = prev.damage
1176 } else {
1177 region = { x: 0, y: 0, width: 0, height: 0 }
1178 }
1179
1180 if (prevHeight > nextHeight) {
1181 region = unionRect(region, {
1182 x: 0,
1183 y: nextHeight,
1184 width: prevWidth,
1185 height: prevHeight - nextHeight,
1186 })
1187 }
1188 if (prevWidth > nextWidth) {
1189 region = unionRect(region, {
1190 x: nextWidth,
1191 y: 0,
1192 width: prevWidth - nextWidth,
1193 height: prevHeight,
1194 })
1195 }
1196
1197 const maxHeight = Math.max(prevHeight, nextHeight)
1198 const maxWidth = Math.max(prevWidth, nextWidth)
1199 const endY = Math.min(region.y + region.height, maxHeight)
1200 const endX = Math.min(region.x + region.width, maxWidth)
1201
1202 if (prevWidth === nextWidth) {
1203 return diffSameWidth(prev, next, region.x, endX, region.y, endY, cb)
1204 }
1205 return diffDifferentWidth(prev, next, region.x, endX, region.y, endY, cb)
1206}
1207
1208/**
1209 * Scan for the next cell that differs between two Int32Arrays.

Callers 2

renderMethod · 0.85
diffFunction · 0.85

Calls 4

unionRectFunction · 0.85
diffSameWidthFunction · 0.85
diffDifferentWidthFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected