(unifiedDiff: string)
| 30 | } |
| 31 | |
| 32 | export function parseDiffForDisplay(unifiedDiff: string): ColoredDiffLine[] { |
| 33 | const lines = unifiedDiff.split('\n'); |
| 34 | const result: ColoredDiffLine[] = []; |
| 35 | for (const line of lines) { |
| 36 | if (line.startsWith('@@')) { |
| 37 | result.push({ type: 'hunk', text: line }); |
| 38 | } else if (line.startsWith('+') && !line.startsWith('+++')) { |
| 39 | result.push({ type: 'add', text: line }); |
| 40 | } else if (line.startsWith('-') && !line.startsWith('---')) { |
| 41 | result.push({ type: 'del', text: line }); |
| 42 | } else if (line.startsWith('---') || line.startsWith('+++')) { |
| 43 | continue; |
| 44 | } else { |
| 45 | result.push({ type: 'context', text: line }); |
| 46 | } |
| 47 | } |
| 48 | return result; |
| 49 | } |
no test coverage detected