terminal: Fix mouse scroll report count for negative scroll lines#49931
Merged
MrSubidubi merged 1 commit intozed-industries:mainfrom Feb 24, 2026
Merged
Conversation
MrSubidubi
approved these changes
Feb 24, 2026
Member
MrSubidubi
left a comment
There was a problem hiding this comment.
Nice find, nice write-up, nice follow-up, nice test-coverage. Very nice PR, thank you!
Contributor
Author
|
Thank you for the great feedback and you're welcome 😊 |
Anthony-Eid
pushed a commit
to bobbymannino/zed
that referenced
this pull request
Feb 25, 2026
…d-industries#49931) Follow-up to zed-industries#45600. ## Summary Fix mouse scroll reports sending only one event when scrolling down in terminal apps with mouse mode (tmux, neovim, etc.), regardless of how many lines were scrolled. ## The Problem After zed-industries#45600, trackpad scrolling speed was fixed. But when scrolling **down** (negative `scroll_lines`), the terminal was still sending only **one** scroll report per gesture, no matter how many lines the user scrolled. Scrolling up worked correctly. ## Root Cause In `scroll_report()` we had: https://github.com/zed-industries/zed/blob/a8043dcff8f28a0443d7ec238e7f020689ebe1ff/crates/terminal/src/mappings/mouse.rs#L96 `scroll_lines` can be negative (scroll down) or positive (scroll up). For negative values: | scroll_lines | max(scroll_lines, 1) | Reports sent | Verdict | |--------------|---------------------|--------------|------| | 3 (up) | 3 | 3 |Right | -3 (down) | 1 | 1 |WRONG| So we always sent exactly 1 report when scrolling down, losing the scroll magnitude. Use `scroll_lines.unsigned_abs()` instead of `max(scroll_lines, 1)`. This matches how `alt_scroll()` in the same file already handles `scroll_lines`. Now both directions send the correct number of reports. https://github.com/zed-industries/zed/blob/a8043dcff8f28a0443d7ec238e7f020689ebe1ff/crates/terminal/src/mappings/mouse.rs#L102 ## Testing - Added unit tests: `scroll_report_repeats_for_negative_scroll_lines` and `scroll_report_repeats_for_positive_scroll_lines` - Manually tested scrolling in tmux and neovim with mouse mode --- Release Notes: - Fixed mouse scroll in terminal apps (tmux, neovim, etc.) only sending one scroll event when scrolling down, regardless of scroll amount
Caio-Ze
pushed a commit
to Caio-Ze/postprod-ide
that referenced
this pull request
Mar 1, 2026
…d-industries#49931) Follow-up to zed-industries#45600. ## Summary Fix mouse scroll reports sending only one event when scrolling down in terminal apps with mouse mode (tmux, neovim, etc.), regardless of how many lines were scrolled. ## The Problem After zed-industries#45600, trackpad scrolling speed was fixed. But when scrolling **down** (negative `scroll_lines`), the terminal was still sending only **one** scroll report per gesture, no matter how many lines the user scrolled. Scrolling up worked correctly. ## Root Cause In `scroll_report()` we had: https://github.com/zed-industries/zed/blob/a8043dcff8f28a0443d7ec238e7f020689ebe1ff/crates/terminal/src/mappings/mouse.rs#L96 `scroll_lines` can be negative (scroll down) or positive (scroll up). For negative values: | scroll_lines | max(scroll_lines, 1) | Reports sent | Verdict | |--------------|---------------------|--------------|------| | 3 (up) | 3 | 3 |Right | -3 (down) | 1 | 1 |WRONG| So we always sent exactly 1 report when scrolling down, losing the scroll magnitude. Use `scroll_lines.unsigned_abs()` instead of `max(scroll_lines, 1)`. This matches how `alt_scroll()` in the same file already handles `scroll_lines`. Now both directions send the correct number of reports. https://github.com/zed-industries/zed/blob/a8043dcff8f28a0443d7ec238e7f020689ebe1ff/crates/terminal/src/mappings/mouse.rs#L102 ## Testing - Added unit tests: `scroll_report_repeats_for_negative_scroll_lines` and `scroll_report_repeats_for_positive_scroll_lines` - Manually tested scrolling in tmux and neovim with mouse mode --- Release Notes: - Fixed mouse scroll in terminal apps (tmux, neovim, etc.) only sending one scroll event when scrolling down, regardless of scroll amount
tahayvr
pushed a commit
to tahayvr/zed
that referenced
this pull request
Mar 4, 2026
…d-industries#49931) Follow-up to zed-industries#45600. ## Summary Fix mouse scroll reports sending only one event when scrolling down in terminal apps with mouse mode (tmux, neovim, etc.), regardless of how many lines were scrolled. ## The Problem After zed-industries#45600, trackpad scrolling speed was fixed. But when scrolling **down** (negative `scroll_lines`), the terminal was still sending only **one** scroll report per gesture, no matter how many lines the user scrolled. Scrolling up worked correctly. ## Root Cause In `scroll_report()` we had: https://github.com/zed-industries/zed/blob/a8043dcff8f28a0443d7ec238e7f020689ebe1ff/crates/terminal/src/mappings/mouse.rs#L96 `scroll_lines` can be negative (scroll down) or positive (scroll up). For negative values: | scroll_lines | max(scroll_lines, 1) | Reports sent | Verdict | |--------------|---------------------|--------------|------| | 3 (up) | 3 | 3 |Right | -3 (down) | 1 | 1 |WRONG| So we always sent exactly 1 report when scrolling down, losing the scroll magnitude. Use `scroll_lines.unsigned_abs()` instead of `max(scroll_lines, 1)`. This matches how `alt_scroll()` in the same file already handles `scroll_lines`. Now both directions send the correct number of reports. https://github.com/zed-industries/zed/blob/a8043dcff8f28a0443d7ec238e7f020689ebe1ff/crates/terminal/src/mappings/mouse.rs#L102 ## Testing - Added unit tests: `scroll_report_repeats_for_negative_scroll_lines` and `scroll_report_repeats_for_positive_scroll_lines` - Manually tested scrolling in tmux and neovim with mouse mode --- Release Notes: - Fixed mouse scroll in terminal apps (tmux, neovim, etc.) only sending one scroll event when scrolling down, regardless of scroll amount
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #45600.
Summary
Fix mouse scroll reports sending only one event when scrolling down in terminal apps with mouse mode (tmux, neovim, etc.), regardless of how many lines were scrolled.
The Problem
After #45600, trackpad scrolling speed was fixed. But when scrolling down (negative
scroll_lines), the terminal was still sending only one scroll report per gesture, no matter how many lines the user scrolled. Scrolling up worked correctly.Root Cause
In
scroll_report()we had:zed/crates/terminal/src/mappings/mouse.rs
Line 96 in a8043dc
scroll_linescan be negative (scroll down) or positive (scroll up). For negative values:So we always sent exactly 1 report when scrolling down, losing the scroll magnitude.
Use
scroll_lines.unsigned_abs()instead ofmax(scroll_lines, 1). This matches howalt_scroll()in the same file already handlesscroll_lines. Now both directions send the correct number of reports.zed/crates/terminal/src/mappings/mouse.rs
Line 102 in a8043dc
Testing
scroll_report_repeats_for_negative_scroll_linesandscroll_report_repeats_for_positive_scroll_linesRelease Notes: