(ops, filePath, lineOffset)
| 143 | } |
| 144 | |
| 145 | function renderDiffOps(ops, filePath, lineOffset) { |
| 146 | const off = lineOffset || 0; |
| 147 | let addCount = 0, delCount = 0; |
| 148 | ops.forEach(o => { if (o.type === 'add') addCount++; if (o.type === 'del') delCount++; }); |
| 149 | |
| 150 | let rows = ''; |
| 151 | for (const o of ops) { |
| 152 | const cls = o.type === 'del' ? 'diff-del' : o.type === 'add' ? 'diff-add' : 'diff-ctx'; |
| 153 | const sign = o.type === 'del' ? '-' : o.type === 'add' ? '+' : ' '; |
| 154 | const rawLn = o.type === 'del' ? (o.oldLn || '') : (o.newLn || o.oldLn || ''); |
| 155 | const ln = rawLn !== '' ? rawLn + off : ''; |
| 156 | rows += `<tr class="${cls}"><td class="diff-ln">${ln}</td><td class="diff-sign">${sign}</td><td class="diff-code">${esc(o.text)}</td></tr>`; |
| 157 | } |
| 158 | |
| 159 | const shortPath = shortenPath(filePath); |
| 160 | return `<div class="diff-view"> |
| 161 | <div class="diff-header"> |
| 162 | <svg class="diff-file-icon" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/></svg> |
| 163 | <span class="diff-file-path" title="${esc(filePath)}">${esc(shortPath)}</span> |
| 164 | <span class="diff-stats"><span class="ds-add">+${addCount}</span> <span class="ds-del">-${delCount}</span></span> |
| 165 | </div> |
| 166 | <div class="diff-body"><table class="diff-table">${rows}</table></div> |
| 167 | </div>`; |
| 168 | } |
| 169 | |
| 170 | // ---- Step group management ---- |
| 171 | export function closeGroup() { |
no test coverage detected