MCPcopy Create free account
hub / github.com/modem-dev/hunk / findMaxLineNumberInRows

Function findMaxLineNumberInRows

src/ui/diff/codeColumns.ts:61–81  ·  view source on GitHub ↗
(rows: Iterable<DiffRow>, fallback = 1)

Source from the content-addressed store, hash-verified

59
60/** Find the widest line-number gutter needed for an already-expanded row stream. */
61export 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. */
84export function resolveSplitPaneWidths(width: number) {

Callers 2

buildDiffSectionRowPlanFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected