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

Function renderCodeOnlyPlannedRowText

src/ui/diff/renderRows.tsx:707–820  ·  view source on GitHub ↗
(
  row: PlannedReviewRow,
  options: PlannedRowTextOptions,
)

Source from the content-addressed store, hash-verified

705 * into the span text itself, this dedupe should be revisited.
706 */
707export function renderCodeOnlyPlannedRowText(
708 row: PlannedReviewRow,
709 options: PlannedRowTextOptions,
710) {
711 const { width, lineNumberDigits, showLineNumbers, wrapLines, codeHorizontalOffset, theme, side } =
712 options;
713
714 if (width <= 0 || row.kind !== "diff-row") {
715 return [];
716 }
717
718 const preparedRow = row.row;
719 if (preparedRow.type === "hunk-header" || preparedRow.type === "collapsed") {
720 return [];
721 }
722
723 if (preparedRow.type === "stack-line") {
724 if (!wrapLines) {
725 return [cellCodeText(preparedRow.cell.spans, codeHorizontalOffset)].filter(Boolean);
726 }
727
728 return buildWrappedStackCell(
729 preparedRow.cell,
730 width,
731 lineNumberDigits,
732 showLineNumbers,
733 marker().length,
734 theme,
735 )
736 .lines.map((line) => spansText(line.spans))
737 .filter(Boolean);
738 }
739
740 if (preparedRow.type !== "split-line") {
741 return [];
742 }
743
744 if (!wrapLines) {
745 const leftText =
746 preparedRow.left.kind === "empty"
747 ? ""
748 : cellCodeText(preparedRow.left.spans, codeHorizontalOffset);
749 const rightText =
750 preparedRow.right.kind === "empty"
751 ? ""
752 : cellCodeText(preparedRow.right.spans, codeHorizontalOffset);
753
754 if (side === "left") {
755 return [leftText].filter(Boolean);
756 }
757 if (side === "right") {
758 return [rightText].filter(Boolean);
759 }
760
761 if (leftText && rightText && leftText === rightText) {
762 return [leftText];
763 }
764

Callers 2

expandSelectionPointFunction · 0.90
pierre.test.tsFile · 0.90

Calls 5

resolveSplitPaneWidthsFunction · 0.90
cellCodeTextFunction · 0.85
buildWrappedStackCellFunction · 0.85
spansTextFunction · 0.85
buildWrappedSplitCellFunction · 0.85

Tested by

no test coverage detected