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

Function maxFileCodeLineWidth

src/ui/diff/codeColumns.ts:22–43  ·  view source on GitHub ↗
(file: DiffFile)

Source from the content-addressed store, hash-verified

20
21/** Track the widest rendered code line for one file. */
22export 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. */
46export function findMaxLineNumber(file: DiffFile) {

Callers 2

AppFunction · 0.90

Calls 1

Tested by

no test coverage detected