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

Function buildWrappedStackCell

src/ui/diff/renderRows.tsx:394–423  ·  view source on GitHub ↗

Build wrapped stack-cell gutter/content lines while keeping continuation gutters blank.

(
  cell: StackLineCell,
  width: number,
  lineNumberDigits: number,
  showLineNumbers: boolean,
  prefixWidth: number,
  theme: AppTheme,
)

Source from the content-addressed store, hash-verified

392
393/** Build wrapped stack-cell gutter/content lines while keeping continuation gutters blank. */
394function buildWrappedStackCell(
395 cell: StackLineCell,
396 width: number,
397 lineNumberDigits: number,
398 showLineNumbers: boolean,
399 prefixWidth: number,
400 theme: AppTheme,
401) {
402 const palette = stackCellPalette(cell.kind, theme);
403 const { gutterWidth, contentWidth } = resolveStackCellGeometry(
404 width,
405 lineNumberDigits,
406 showLineNumbers,
407 prefixWidth,
408 );
409 const firstGutterText = stackGutterText(cell, lineNumberDigits, showLineNumbers).padEnd(
410 gutterWidth,
411 );
412 const wrappedSpans = wrapSpans(cell.spans, contentWidth);
413
414 return {
415 gutterWidth,
416 contentWidth,
417 palette,
418 lines: wrappedSpans.map((spans, index) => ({
419 gutterText: index === 0 ? firstGutterText : " ".repeat(gutterWidth),
420 spans,
421 })),
422 } satisfies WrappedCellLayout;
423}
424
425/** Convert a list of spans to fixed-width plain text while preserving logical clipping. */
426function spansToPlainText(spans: RenderSpan[], width: number, horizontalOffset = 0) {

Callers 4

buildPlainStackCellLinesFunction · 0.85
measureRenderedRowHeightFunction · 0.85
renderRowFunction · 0.85

Calls 4

stackCellPaletteFunction · 0.90
resolveStackCellGeometryFunction · 0.90
stackGutterTextFunction · 0.90
wrapSpansFunction · 0.85

Tested by

no test coverage detected