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

Function renderWrappedSplitCellLine

src/ui/diff/renderRows.tsx:985–1041  ·  view source on GitHub ↗

Render one already-wrapped split cell line with its persistent rail/separator prefix.

(
  line: WrappedCellLine,
  palette: ReturnType<typeof splitCellPalette>,
  contentWidth: number,
  theme: AppTheme,
  keyPrefix: string,
  prefix: {
    text: string;
    fg: string;
    bg: string;
  },
  selected = false,
  selectionColRange?: CopySelectedRowRange,
  paneOffset = 0,
)

Source from the content-addressed store, hash-verified

983
984/** Render one already-wrapped split cell line with its persistent rail/separator prefix. */
985function renderWrappedSplitCellLine(
986 line: WrappedCellLine,
987 palette: ReturnType<typeof splitCellPalette>,
988 contentWidth: number,
989 theme: AppTheme,
990 keyPrefix: string,
991 prefix: {
992 text: string;
993 fg: string;
994 bg: string;
995 },
996 selected = false,
997 selectionColRange?: CopySelectedRowRange,
998 paneOffset = 0,
999) {
1000 const resolvedPalette = selected ? applySelectionPalette(palette, theme) : palette;
1001 const resolvedPrefix = selected ? applySelectionPrefix(prefix, theme) : prefix;
1002
1003 const prefixWidth = prefix.text.length;
1004 const gutterWidth = line.gutterText.length;
1005 const globalContentStart = paneOffset + prefixWidth + gutterWidth;
1006 const localColRange =
1007 selectionColRange && globalContentStart < selectionColRange.endCol
1008 ? {
1009 start: Math.max(0, selectionColRange.startCol - globalContentStart),
1010 end: Math.min(
1011 contentWidth,
1012 Math.max(0, selectionColRange.endCol - globalContentStart + 1),
1013 ),
1014 }
1015 : undefined;
1016
1017 return (
1018 <>
1019 <span key={`${keyPrefix}:prefix`} fg={resolvedPrefix.fg} bg={resolvedPrefix.bg}>
1020 {resolvedPrefix.text}
1021 </span>
1022 <span
1023 key={`${keyPrefix}:gutter`}
1024 fg={resolvedPalette.numberColor}
1025 bg={resolvedPalette.gutterBg}
1026 >
1027 {line.gutterText}
1028 </span>
1029 {renderInlineSpans(
1030 line.spans,
1031 contentWidth,
1032 theme.syntaxColors.default,
1033 resolvedPalette.contentBg,
1034 `${keyPrefix}:content`,
1035 0,
1036 selected ? theme : undefined,
1037 localColRange,
1038 )}
1039 </>
1040 );
1041}
1042

Callers 1

renderRowFunction · 0.85

Calls 3

applySelectionPaletteFunction · 0.85
applySelectionPrefixFunction · 0.85
renderInlineSpansFunction · 0.85

Tested by

no test coverage detected