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

@ -55,6 +55,16 @@ describe('selection whitespace handling', () => {
expect(getSelectedText(selection, screen)).toBe(' x')
})
it('clamps copied selection bounds to screen width', () => {
const { screen } = screenWithText()
const selection = createSelectionState()
startSelection(selection, 0, 1)
updateSelection(selection, 99, 1)
expect(getSelectedText(selection, screen)).toBe('hi')
})
it('does not paint selection background on leading/trailing empty cells or empty rows', () => {
const { screen, styles } = screenWithText()
const selection = createSelectionState()