(file: DiffFile)
| 20 | |
| 21 | /** Track the widest rendered code line for one file. */ |
| 22 | export function maxFileCodeLineWidth(file: DiffFile) { |
| 23 | const cachedWidth = maxFileCodeLineWidthCache.get(file.metadata); |
| 24 | if (cachedWidth !== undefined) { |
| 25 | return cachedWidth; |
| 26 | } |
| 27 | |
| 28 | const deletionLines = file.metadata.deletionLines ?? []; |
| 29 | const additionLines = file.metadata.additionLines ?? []; |
| 30 | |
| 31 | let maxWidth = 0; |
| 32 | |
| 33 | for (const line of deletionLines) { |
| 34 | maxWidth = Math.max(maxWidth, measureRenderedCodeLineWidth(line)); |
| 35 | } |
| 36 | |
| 37 | for (const line of additionLines) { |
| 38 | maxWidth = Math.max(maxWidth, measureRenderedCodeLineWidth(line)); |
| 39 | } |
| 40 | |
| 41 | maxFileCodeLineWidthCache.set(file.metadata, maxWidth); |
| 42 | return maxWidth; |
| 43 | } |
| 44 | |
| 45 | /** Find the widest line-number gutter needed for one file. */ |
| 46 | export function findMaxLineNumber(file: DiffFile) { |
no test coverage detected