Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 6 additions & 7 deletions lib/selection-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -705,20 +705,19 @@ export class SelectionManager {
// Key insight: we need to EXTEND the selection, not reset it to viewport edge
if (this.selectionEnd) {
const dims = this.wasmTerm.getDimensions();
const viewportY = this.getViewportY();
if (this.autoScrollDirection < 0) {
// Scrolling up - extend selection upward (decrease absoluteRow)
// Set to top of viewport, but only if it extends the selection
const topOfViewport = viewportY;
if (topOfViewport < this.selectionEnd.absoluteRow) {
this.selectionEnd = { col: 0, absoluteRow: topOfViewport };
const topAbsoluteRow = this.viewportRowToAbsolute(0);
if (topAbsoluteRow < this.selectionEnd.absoluteRow) {
this.selectionEnd = { col: 0, absoluteRow: topAbsoluteRow };
}
} else {
// Scrolling down - extend selection downward (increase absoluteRow)
// Set to bottom of viewport, but only if it extends the selection
const bottomOfViewport = viewportY + dims.rows - 1;
if (bottomOfViewport > this.selectionEnd.absoluteRow) {
this.selectionEnd = { col: dims.cols - 1, absoluteRow: bottomOfViewport };
const bottomAbsoluteRow = this.viewportRowToAbsolute(dims.rows - 1);
if (bottomAbsoluteRow > this.selectionEnd.absoluteRow) {
this.selectionEnd = { col: dims.cols - 1, absoluteRow: bottomAbsoluteRow };
}
}
}
Expand Down