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

Function diffDifferentWidth

src/ink/screen.ts:1378–1463  ·  view source on GitHub ↗

* Fallback: diff two screens with different widths (resize). * Separate indices for prev and next cells arrays.

(
  prev: Screen,
  next: Screen,
  startX: number,
  endX: number,
  startY: number,
  endY: number,
  cb: DiffCallback,
)

Source from the content-addressed store, hash-verified

1376 * Separate indices for prev and next cells arrays.
1377 */
1378function diffDifferentWidth(
1379 prev: Screen,
1380 next: Screen,
1381 startX: number,
1382 endX: number,
1383 startY: number,
1384 endY: number,
1385 cb: DiffCallback,
1386): boolean {
1387 const prevWidth = prev.width
1388 const nextWidth = next.width
1389 const prevCells = prev.cells
1390 const nextCells = next.cells
1391
1392 const prevCell: Cell = {
1393 char: ' ',
1394 styleId: 0,
1395 width: CellWidth.Narrow,
1396 hyperlink: undefined,
1397 }
1398 const nextCell: Cell = {
1399 char: ' ',
1400 styleId: 0,
1401 width: CellWidth.Narrow,
1402 hyperlink: undefined,
1403 }
1404
1405 const prevStride = prevWidth << 1
1406 const nextStride = nextWidth << 1
1407 let prevRowCI = (startY * prevWidth + startX) << 1
1408 let nextRowCI = (startY * nextWidth + startX) << 1
1409
1410 for (let y = startY; y < endY; y++) {
1411 const prevIn = y < prev.height
1412 const nextIn = y < next.height
1413 const prevEndX = prevIn ? Math.min(endX, prevWidth) : startX
1414 const nextEndX = nextIn ? Math.min(endX, nextWidth) : startX
1415 const bothEndX = Math.min(prevEndX, nextEndX)
1416
1417 let prevCI = prevRowCI
1418 let nextCI = nextRowCI
1419
1420 for (let x = startX; x < bothEndX; x++) {
1421 if (
1422 prevCells[prevCI] === nextCells[nextCI] &&
1423 prevCells[prevCI + 1] === nextCells[nextCI + 1]
1424 ) {
1425 prevCI += 2
1426 nextCI += 2
1427 continue
1428 }
1429 cellAtCI(prev, prevCI, prevCell)
1430 cellAtCI(next, nextCI, nextCell)
1431 prevCI += 2
1432 nextCI += 2
1433 if (cb(x, y, prevCell, nextCell)) return true
1434 }
1435

Callers 1

diffEachFunction · 0.85

Calls 1

cellAtCIFunction · 0.85

Tested by

no test coverage detected