(diff: LineObject[], startLine: number)
| 421 | }); |
| 422 | } |
| 423 | export function numberDiffLines(diff: LineObject[], startLine: number): DiffLine[] { |
| 424 | let i = startLine; |
| 425 | const result: DiffLine[] = []; |
| 426 | const queue = [...diff]; |
| 427 | while (queue.length > 0) { |
| 428 | const current = queue.shift()!; |
| 429 | const { |
| 430 | code, |
| 431 | type, |
| 432 | originalCode, |
| 433 | wordDiff, |
| 434 | matchedLine |
| 435 | } = current; |
| 436 | const line = { |
| 437 | code, |
| 438 | type, |
| 439 | i, |
| 440 | originalCode, |
| 441 | wordDiff, |
| 442 | matchedLine |
| 443 | }; |
| 444 | |
| 445 | // Update counters based on change type |
| 446 | switch (type) { |
| 447 | case 'nochange': |
| 448 | i++; |
| 449 | result.push(line); |
| 450 | break; |
| 451 | case 'add': |
| 452 | i++; |
| 453 | result.push(line); |
| 454 | break; |
| 455 | case 'remove': |
| 456 | { |
| 457 | result.push(line); |
| 458 | let numRemoved = 0; |
| 459 | while (queue[0]?.type === 'remove') { |
| 460 | i++; |
| 461 | const current = queue.shift()!; |
| 462 | const { |
| 463 | code, |
| 464 | type, |
| 465 | originalCode, |
| 466 | wordDiff, |
| 467 | matchedLine |
| 468 | } = current; |
| 469 | const line = { |
| 470 | code, |
| 471 | type, |
| 472 | i, |
| 473 | originalCode, |
| 474 | wordDiff, |
| 475 | matchedLine |
| 476 | }; |
| 477 | result.push(line); |
| 478 | numRemoved++; |
| 479 | } |
| 480 | i -= numRemoved; |
no test coverage detected