szn

Bug 63 — SGR mouse wheel release events misreported — wheel info lost on release

63. SGR mouse wheel release events misreported — wheel info lost on release

File: src/tty/tty_key.zig:241–256 Severity: LOW Status: ✅ FIXED — Moved wheel_up/wheel_down checks before release check in parseSgrMouse.

const wheel_up = (btn & 0xC3) == 0x40;
const wheel_down = (btn & 0xC3) == 0x41;

const button: MouseButton = if (release)
    .release
else if (wheel_up)
    .scroll_up
else if (wheel_down)
    .scroll_down
else switch (btn_type) {

When a wheel event has the release bit set (button + 0x20), wheel_up detection fails: (0x40 | 0x20) & 0xC3 = 0x60 & 0xC3 = 0x40. Wait — actually 0x60 & 0xC3 = 0x40: the release bit 0x20 is masked out by & 0xC3. So wheel + release still correctly reports as scroll_up/scroll_down. But release is checked FIRST, so wheel-release events would report .release instead. In the SGR protocol, wheel events always have M final byte (press) and m final byte (release) — meaning release tracking for wheel is already handled by the release parameter. The current code maps wheel+m to .scroll_up/.scroll_down correctly (since release is false for m? No — looking at line 137: parseSgrMouse(seq, byte == 'm') where 'm' means release=true). So wheel with 'm' final byte has release=true, hits the first if, returns .release. The wheel direction information is lost. Minor because most terminals only send press events for wheels.