| 225 | } |
| 226 | |
| 227 | function maxLineNumberWidth(file: DiffFile, rows: DiffRow[]) { |
| 228 | let max = 1; |
| 229 | for (const row of rows) { |
| 230 | if (row.type === "stack-line") { |
| 231 | max = Math.max( |
| 232 | max, |
| 233 | row.cell.oldLineNumber ? String(row.cell.oldLineNumber).length : 1, |
| 234 | row.cell.newLineNumber ? String(row.cell.newLineNumber).length : 1, |
| 235 | ); |
| 236 | continue; |
| 237 | } |
| 238 | |
| 239 | if (row.type === "split-line") { |
| 240 | max = Math.max( |
| 241 | max, |
| 242 | row.left.lineNumber ? String(row.left.lineNumber).length : 1, |
| 243 | row.right.lineNumber ? String(row.right.lineNumber).length : 1, |
| 244 | ); |
| 245 | } |
| 246 | } |
| 247 | |
| 248 | return Math.max(max, String(file.metadata.additionLines.length).length); |
| 249 | } |
| 250 | |
| 251 | /** Describe the file-level change without exposing raw patch transport headers. */ |
| 252 | function fileStatusLabel(file: DiffFile) { |