Skip to content

Conversation

@sreya
Copy link
Contributor

@sreya sreya commented Nov 17, 2025

No description provided.

When users scroll back in terminal history and select text, the selection
was incorrectly reading from the current screen buffer instead of the
scrollback buffer, causing copied text to be wrong.

Root cause: SelectionManager.getSelection() always called getLine() which
reads screen buffer, ignoring the viewport scroll position (viewportY).

Solution: Make getSelection() viewport-aware by checking viewportY and
using getScrollbackLine() for rows in scrollback vs getLine() for rows
in the screen buffer. This follows the same pattern used by the terminal's
link detection code.

Changes:
- lib/selection-manager.ts: Updated getSelection() to handle viewport offset
- lib/terminal.test.ts: Added 4 comprehensive test cases covering:
  - Selection entirely in scrollback
  - Selection spanning scrollback and screen
  - Selection when not scrolled (regression test)
  - Selection at top of scrollback history

All tests pass. Fixes copy/paste from scrollback history.
@sreya sreya merged commit 17a4957 into main Nov 17, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant