fix(tui): clamp copied selection bounds

Clamp copied selection columns to the screen width before scanning rendered cells.
This commit is contained in:
Brooklyn Nicholson 2026-04-25 15:32:45 -05:00
parent b1c18e5a41
commit 31d7f1951a
2 changed files with 12 additions and 2 deletions

View file

@ -969,8 +969,8 @@ export function getSelectedText(s: SelectionState, screen: Screen): string {
}
for (let row = start.row; row <= end.row; row++) {
const rowStart = row === start.row ? start.col : 0
const rowEnd = row === end.row ? end.col : screen.width - 1
const rowStart = Math.max(0, row === start.row ? start.col : 0)
const rowEnd = Math.min(row === end.row ? end.col : screen.width - 1, screen.width - 1)
const bounds = selectionContentBounds(screen, row, rowStart, rowEnd)
joinRows(lines, bounds ? extractRowText(screen, row, bounds.first, bounds.last) : '', sw[row]! > 0)