( row: PlannedReviewRow, options: PlannedRowTextOptions, )
| 705 | * into the span text itself, this dedupe should be revisited. |
| 706 | */ |
| 707 | export 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 |
no test coverage detected