Skip to content

fix: send correct number of sequences for wheel scroll in alt buffer#5803

Closed
dolonet wants to merge 1 commit intoxtermjs:masterfrom
dolonet:fix/5194-alternate-scroll-line-count
Closed

fix: send correct number of sequences for wheel scroll in alt buffer#5803
dolonet wants to merge 1 commit intoxtermjs:masterfrom
dolonet:fix/5194-alternate-scroll-line-count

Conversation

@dolonet
Copy link
Copy Markdown

@dolonet dolonet commented Apr 12, 2026

Fixes #5194

Problem

When the terminal is in the alt buffer (no scrollback — vim, less, man, etc.), mouse wheel events are converted to up/down arrow key sequences. Previously only a single sequence was sent per wheel event, regardless of how many lines the wheel reported scrolling. This made scrolling in alternate-screen apps feel sluggish — one notch of the wheel moved exactly one line instead of the expected three.

The same code path that handles touch scroll (_handleTouchScrollAsKeys) already sends one sequence per line correctly. The wheel path was inconsistent with it.

Fix

Loop lines times when sending the sequence, matching the existing touch scroll logic:

// before
this._coreService.triggerDataEvent(sequence, true);

// after
for (let i = 0; i < lines; i++) {
  this._coreService.triggerDataEvent(sequence, true);
}

lines is already computed by _consumeWheelEvent just above — no new state needed.

Testing

Manually verified with less and man: one scroll click now moves the expected number of lines. The touch scroll path is unchanged.

When the terminal is in the alt buffer (no scrollback), mouse wheel
events are converted to up/down arrow key sequences. Previously only
a single sequence was sent per wheel event regardless of how many
lines were scrolled, making apps like less and man scroll much more
slowly than expected.

The touch scroll path (_handleTouchScrollAsKeys) already sends one
sequence per line. Align the wheel path with the same behaviour.
@dolonet dolonet closed this by deleting the head repository Apr 13, 2026
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.

implement alternateScroll settings

1 participant