(rows: Iterable<DiffRow>, fallback = 1)
| 59 | |
| 60 | /** Find the widest line-number gutter needed for an already-expanded row stream. */ |
| 61 | export function findMaxLineNumberInRows(rows: Iterable<DiffRow>, fallback = 1) { |
| 62 | let highest = fallback; |
| 63 | |
| 64 | for (const row of rows) { |
| 65 | if (row.type === "collapsed") { |
| 66 | highest = Math.max(highest, row.oldRange[1], row.newRange[1]); |
| 67 | continue; |
| 68 | } |
| 69 | |
| 70 | if (row.type === "split-line") { |
| 71 | highest = Math.max(highest, row.left.lineNumber ?? 0, row.right.lineNumber ?? 0); |
| 72 | continue; |
| 73 | } |
| 74 | |
| 75 | if (row.type === "stack-line") { |
| 76 | highest = Math.max(highest, row.cell.oldLineNumber ?? 0, row.cell.newLineNumber ?? 0); |
| 77 | } |
| 78 | } |
| 79 | |
| 80 | return Math.max(highest, 1); |
| 81 | } |
| 82 | |
| 83 | /** Split-view panes reserve one rail column on the left and one separator column in the middle. */ |
| 84 | export function resolveSplitPaneWidths(width: number) { |
no outgoing calls
no test coverage detected