( lineIds: number[], oldStepIds: number[] = [], oldStepCode: string = "", newStepCode: string = "" )
| 65 | } |
| 66 | |
| 67 | function getStepIds( |
| 68 | lineIds: number[], |
| 69 | oldStepIds: number[] = [], |
| 70 | oldStepCode: string = "", |
| 71 | newStepCode: string = "" |
| 72 | ): number[] { |
| 73 | const changes = getChanges(oldStepCode, newStepCode); |
| 74 | |
| 75 | const newStepIds = oldStepIds.slice(0); |
| 76 | changes.forEach(({ op, count, index }) => { |
| 77 | if (op === "-") { |
| 78 | newStepIds.splice(index, count); |
| 79 | } else { |
| 80 | const afterId = newStepIds[index - 1]; |
| 81 | const newIds = generateIds(lineIds, afterId, count); |
| 82 | newStepIds.splice(index, 0, ...newIds); |
| 83 | } |
| 84 | }); |
| 85 | return newStepIds; |
| 86 | } |
| 87 | |
| 88 | export function linesDiff(codeList: string[]) { |
| 89 | const steps: number[][] = []; |
no test coverage detected