Skip to content

fix: don't swallow wheel events in the alt buffer when consumeWheelEvent() returns 0 - #6104

Closed
Xukun-Liu wants to merge 1 commit into
xtermjs:masterfrom
Xukun-Liu:fix/alt-buffer-wheel-swallow
Closed

Xukun-Liu wants to merge 1 commit into
xtermjs:masterfrom
Xukun-Liu:fix/alt-buffer-wheel-swallow

Conversation

@Xukun-Liu

Copy link
Copy Markdown

Summary

Since 5.6.0-beta.119 the alt-buffer wheel handler gates on consumeWheelEvent() returning a non-zero amount, and drops the event when it rounds to zero. That kills the wheel for full-screen TUI apps on trackpads, smooth wheels and low-sensitivity scroll settings: any single pixel delta below roughly one cell height gets dampened, floored to 0, and never reaches the app. It also swallows shift+wheel entirely.

The sequence this path sends is always exactly one ESC[A/ESC[B, the return value is only used as a boolean, and the comment above the code already states the behavior is "simply send a single up or down sequence". So the gate is leftover from the old line-scrolling implementation and has nothing to gain here.

This keeps the consumeWheelEvent() call so the partial-scroll accumulator stays in sync, but only deltaY === 0 skips sending.

Verification

Byte-level A/B between VS Code 1.104 (xterm 5.6.0-beta.118) and 1.105 (5.6.0-beta.119): raw-mode pty listener in the alt screen, instrumented bundle logging consumeWheelEvent() input and result per event.

probe 1.104 (beta.118) 1.105 (beta.119)
pixel deltaY=20 ESC[B sent returns 0, nothing sent
pixel deltaY=100 ESC[B sent returns 6, ESC[B sent
line deltaY=3 ESC[B sent returns 3, ESC[B sent
line deltaY=100 ESC[B sent returns 100, ESC[B sent
CDP pixel deltaY=20 ESC[B sent returns 0, nothing sent
CDP pixel deltaY=100 ESC[B sent returns 6, ESC[B sent

1.104 sent one ESC[B for every probe, 1.105 dropped all pixel probes under 50px (0 bytes on the pty) while line-mode and large deltas passed. Renderer dims were healthy in both runs, so the failures are the dampening path, not a sizing race.

Tests: 4 new unit cases (small pixel delta, negative delta, zero delta, app-handles-wheel-itself). Full unit suite passes (2342 tests), lint clean.

…returns 0

Wheel events in the alternate screen (no scrollback) are converted into a
single up/down sequence so full-screen TUI apps can scroll. Since
5.6.0-beta.119 this path is gated on consumeWheelEvent() returning a
non-zero amount, which silently drops the event when the pixel delta
dampens and floors to zero lines (|deltaY| < ~50px on typical setups),
when shift is held, or when renderer dims are not ready yet.

The magnitude is never used by this path - the sequence sent is always
exactly one ESC[A/ESC[B - so the gate is purely destructive and
contradicts the comment above it. Keep the call to sync the partial
scroll accumulator for the wheel-scroll option, but don't gate on it.

Byte-level A/B evidence (VS Code 1.104 beta.118 vs 1.105 beta.119,
instrumented bundle + raw-mode pty listener in the alt screen):
1.104 sends one ESC[B for every probe; 1.105 swallows all pixel probes
below ~50px while line-mode and large deltas pass.
@Xukun-Liu

Copy link
Copy Markdown
Author

Added byte-level verification on the current release as well, VS Code 1.128.0 (ships xterm 6.1.0-beta.288). Same setup: raw-mode pty listener in the alt screen, instrumented runtime, injected wheel events. Event log and probe timestamps aligned:

probe when bytes on pty
DOM pixel deltaY=20 09:11:31.618Z none (dropped)
DOM pixel deltaY=100 09:11:32.825Z ESC[B
DOM line deltaY=3 09:11:34.043Z ESC[B
DOM line deltaY=100 09:11:35.249Z ESC[B
CDP pixel deltaY=20 09:11:36.460Z none (dropped)
CDP pixel deltaY=100 09:11:37.688Z ESC[B

So the bug is present in the release everyone uses today, not just the old beta. Trackpads, smooth wheels and low-sensitivity mice (small pixel deltas, or shift+wheel) still get zero bytes. The reason most users never notice is that fast-scrolling mice send deltas above the ~50px threshold and the wheel "works".

Full history of this issue: 5.6.0-beta.118 (no gate, all six probes passed) -> 5.6.0-beta.119 (gate added, small pixel deltas dropped) -> 6.1.0-beta.288 (gate still there, same behavior).

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