Extract text from one screen row. When the next row is a soft-wrap * continuation (screen.softWrap[row+1]>0), clamp to that content-end * column and skip the trailing trim so the word-separator space survives * the join. See Screen.softWrap for why the clamp is necessary.
( screen: Screen, row: number, colStart: number, colEnd: number, )
| 714 | * column and skip the trailing trim so the word-separator space survives |
| 715 | * the join. See Screen.softWrap for why the clamp is necessary. */ |
| 716 | function extractRowText( |
| 717 | screen: Screen, |
| 718 | row: number, |
| 719 | colStart: number, |
| 720 | colEnd: number, |
| 721 | ): string { |
| 722 | const noSelect = screen.noSelect |
| 723 | const rowOff = row * screen.width |
| 724 | const contentEnd = row + 1 < screen.height ? screen.softWrap[row + 1]! : 0 |
| 725 | const lastCol = contentEnd > 0 ? Math.min(colEnd, contentEnd - 1) : colEnd |
| 726 | let line = '' |
| 727 | for (let col = colStart; col <= lastCol; col++) { |
| 728 | // Skip cells marked noSelect (gutters, line numbers, diff sigils). |
| 729 | // Check before cellAt to avoid the decode cost for excluded cells. |
| 730 | if (noSelect[rowOff + col] === 1) continue |
| 731 | const cell = cellAt(screen, col, row) |
| 732 | if (!cell) continue |
| 733 | // Skip spacer tails (second half of wide chars) — the head already |
| 734 | // contains the full grapheme. SpacerHead is a blank at line-end. |
| 735 | if ( |
| 736 | cell.width === CellWidth.SpacerTail || |
| 737 | cell.width === CellWidth.SpacerHead |
| 738 | ) { |
| 739 | continue |
| 740 | } |
| 741 | line += cell.char |
| 742 | } |
| 743 | return contentEnd > 0 ? line : line.replace(/\s+$/, '') |
| 744 | } |
| 745 | |
| 746 | /** Accumulator for selected text that merges soft-wrapped rows back |
| 747 | * into logical lines. push(text, sw) appends a newline before text |
no test coverage detected