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

Function maxLineNumberWidth

src/ui/staticDiffPager.ts:227–249  ·  view source on GitHub ↗
(file: DiffFile, rows: DiffRow[])

Source from the content-addressed store, hash-verified

225}
226
227function 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. */
252function fileStatusLabel(file: DiffFile) {

Callers 1

renderStaticFileFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected