Skip to content

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

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

fix: don't swallow wheel events in the alt buffer when consumeWheelEvent() returns 0#6118
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.

Fixes #6105 (resubmit of #6104, which was closed when its head repository was removed).

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.

Also re-verified on the current stable release, VS Code 1.128.0 (ships xterm 6.1.0-beta.288), same setup: pixel deltas below the threshold still produce 0 bytes on the pty, line-mode and large deltas pass. The regression is live in the release most users run today.

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.
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.

[Bug] Wheel input is silently dropped in the alt buffer when consumeWheelEvent() rounds to zero lines

1 participant