Emamul Andalib
e9816b98bb
terminal: Fix fast scrolling during mouse mode ( #45600 )
...
Closes #18930
### Summary
- Fix fast Macbook trackpad/mouse scrolling in terminal applications
with mouse mode enabled
### The Problem
Scrolling with a trackpad in tmux, neovim, or any terminal app that
enables mouse mode was too fast. A gentle swipe would send me through
hundreds of lines, making these apps practically unusable in Zed's
terminal.
### Root Cause
When the terminal is in mouse mode, we send escape sequences to report
scroll events to the application. The bug was in `scroll_report()`:
https://github.com/zed-industries/zed/blob/3f8f7da2595116744439794fafacea6f570775db/crates/terminal/src/terminal.rs#L1983-L1988
That `max(scroll_lines, 1)` meant we'd send **at least 1 scroll event
even when `scroll_lines` was 0**.
https://github.com/zed-industries/zed/blob/3f8f7da2595116744439794fafacea6f570775db/crates/terminal/src/mappings/mouse.rs#L96
On macOS, trackpad gestures fire many small pixel deltas due to scroll
acceleration. Each tiny movement triggered a scroll event, even though
we hadn't accumulated enough pixels for a full line yet. This is a known
issue alacritty/alacritty#2869 - macOS sends fractional line deltas
(like 0.1) instead of whole lines.
### The Fix
Don't send mouse reports when no full line has accumulated
This aligns with Alacritty's approach - accumulate partial scroll
amounts and only report when complete lines are ready.
https://github.com/alacritty/alacritty/blob/6ee6e53ee3457c24137f117237b0ff1d84f6f836/alacritty/src/input/mod.rs#L700-L730
### Testing
Tested trackpad scrolling in:
- tmux (pane navigation, scrollback)
- neovim (buffer scrolling)
- opencode (TUI navigation)
All scroll smoothly now.
### Demo
The demo shows the behavior of the scrolling. I can go fast or I can go
slow
https://github.com/user-attachments/assets/14bfc2f4-f286-4341-bf55-4ced894d63f9
Release Notes:
- Fixed trackpad scrolling being too fast in terminal applications with
mouse mode enabled (tmux, neovim, opencode, etc.)
2026-01-19 14:18:53 +01:00
..
2026-01-16 16:05:43 +00:00
2025-12-29 11:01:19 -03:00
2026-01-14 13:49:51 -05:00
2026-01-15 15:21:57 +00:00
2026-01-16 18:18:39 -05:00
2026-01-16 16:05:43 +00:00
2026-01-15 21:28:33 +00:00
2026-01-16 16:05:43 +00:00
2026-01-16 16:05:43 +00:00
2026-01-15 13:06:45 -05:00
2026-01-08 10:59:03 +00:00
2026-01-14 07:19:13 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2026-01-14 07:19:13 +00:00
2026-01-15 21:28:33 +00:00
2026-01-07 12:48:24 -08:00
2026-01-07 12:48:24 -08:00
2025-11-11 12:55:19 +00:00
2026-01-15 15:21:57 +00:00
2025-10-17 18:58:14 +00:00
2025-12-17 12:54:57 +01:00
2026-01-06 09:42:00 -03:00
2026-01-17 19:29:19 +00:00
2026-01-07 12:48:24 -08:00
2026-01-07 12:48:24 -08:00
2025-12-16 01:22:41 +00:00
2026-01-15 13:06:45 -05:00
2025-11-06 09:16:45 +00:00
2025-11-10 23:00:55 -07:00
2026-01-15 13:06:45 -05:00
2026-01-16 02:16:34 +00:00
2026-01-16 02:16:34 +00:00
2026-01-16 20:18:53 +02:00
2026-01-15 17:48:15 +00:00
2025-10-17 18:58:14 +00:00
2026-01-14 07:19:13 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2026-01-14 07:19:13 +00:00
2026-01-07 12:48:24 -08:00
2026-01-15 13:22:03 +01:00
2026-01-14 14:44:13 +00:00
2026-01-14 14:44:13 +00:00
2026-01-14 07:19:13 +00:00
2026-01-07 12:48:24 -08:00
2026-01-14 07:19:13 +00:00
2025-12-08 19:57:02 +01:00
2025-10-17 18:58:14 +00:00
2026-01-14 07:19:13 +00:00
2026-01-07 12:48:24 -08:00
2026-01-15 17:48:15 +00:00
2025-12-18 12:47:34 +00:00
2025-10-17 18:58:14 +00:00
2026-01-16 15:20:48 -08:00
2026-01-15 17:48:15 +00:00
2025-12-18 21:59:05 -05:00
2026-01-18 20:25:23 -08:00
2026-01-18 20:25:23 -08:00
2026-01-16 02:16:34 +00:00
2026-01-06 17:20:25 -05:00
2026-01-15 18:10:21 +00:00
2026-01-16 23:56:51 +00:00
2026-01-07 07:24:46 +00:00
2026-01-15 21:28:33 +00:00
2025-12-18 17:26:20 +01:00
2025-10-17 18:58:14 +00:00
2026-01-17 19:29:19 +00:00
2025-12-17 16:25:07 -08:00
2025-12-08 21:49:26 +01:00
2026-01-17 19:29:19 +00:00
2026-01-07 12:48:24 -08:00
2026-01-14 13:49:51 -05:00
2025-10-17 18:58:14 +00:00
2026-01-07 12:48:24 -08:00
2025-10-17 18:58:14 +00:00
2026-01-15 15:21:57 +00:00
2025-10-20 10:30:06 +00:00
2025-12-26 18:47:53 +00:00
2025-12-08 19:50:20 +01:00
2026-01-14 07:19:13 +00:00
2026-01-05 16:15:21 +00:00
2026-01-17 19:29:19 +00:00
2025-12-17 16:51:16 +00:00
2025-12-17 20:12:40 -06:00
2026-01-17 02:57:06 +00:00
2026-01-14 07:19:13 +00:00
2026-01-07 12:48:24 -08:00
2025-10-17 18:58:14 +00:00
2025-12-09 09:29:40 -08:00
2025-10-17 18:58:14 +00:00
2026-01-15 21:28:33 +00:00
2026-01-14 11:49:38 +02:00
2026-01-07 12:48:24 -08:00
2026-01-07 12:48:24 -08:00
2025-11-19 22:00:58 +00:00
2026-01-16 14:33:28 +00:00
2026-01-15 15:21:57 +00:00
2026-01-17 19:29:19 +00:00
2026-01-17 19:29:19 +00:00
2026-01-15 21:28:33 +00:00
2026-01-16 17:09:08 -05:00
2025-10-17 18:58:14 +00:00
2026-01-07 12:48:24 -08:00
2026-01-18 23:13:25 +00:00
2026-01-19 09:50:48 +00:00
2025-10-22 19:52:38 +00:00
2025-10-17 18:58:14 +00:00
2026-01-16 14:20:23 +00:00
2025-10-17 18:58:14 +00:00
2026-01-14 07:19:13 +00:00
2026-01-13 22:38:28 -07:00
2026-01-14 21:42:00 +00:00
2025-10-17 18:58:14 +00:00
2025-12-30 07:49:01 -03:00
2026-01-15 21:28:33 +00:00
2026-01-14 07:19:13 +00:00
2025-12-18 09:49:32 +00:00
2026-01-17 19:29:19 +00:00
2026-01-06 08:14:34 +00:00
2025-10-17 18:58:14 +00:00
2025-12-17 16:53:42 +00:00
2026-01-07 12:48:24 -08:00
2025-11-11 16:10:47 +01:00
2025-12-17 16:51:16 +00:00
2026-01-16 17:09:08 -05:00
2025-11-24 13:24:26 -05:00
2026-01-14 08:06:55 -03:00
2026-01-13 16:39:41 +00:00
2025-10-17 18:58:14 +00:00
2025-12-10 12:10:43 -08:00
2025-12-30 13:29:44 -03:00
2026-01-07 12:48:24 -08:00
2026-01-17 19:29:19 +00:00
2026-01-09 20:22:29 +01:00
2026-01-16 17:01:09 +01:00
2026-01-14 07:19:13 +00:00
2026-01-07 12:48:24 -08:00
2026-01-14 14:41:22 -05:00
2026-01-16 15:20:48 -08:00
2025-12-15 13:30:13 +00:00
2025-11-27 13:46:43 +00:00
2026-01-16 15:20:48 -08:00
2026-01-16 20:18:53 +02:00
2026-01-14 07:19:13 +00:00
2025-12-09 09:29:40 -08:00
2025-11-03 19:25:15 +00:00
2025-12-31 20:02:45 -05:00
2025-12-29 20:21:59 +00:00
2026-01-15 21:28:33 +00:00
2026-01-15 18:39:06 +00:00
2025-12-16 10:48:14 -05:00
2026-01-15 17:48:15 +00:00
2026-01-14 07:19:13 +00:00
2026-01-15 18:10:21 +00:00
2026-01-16 15:20:48 -08:00
2025-10-27 10:13:26 -04:00
2025-11-21 08:28:17 -07:00
2025-11-07 22:27:14 +00:00
2026-01-15 18:10:21 +00:00
2025-10-17 18:58:14 +00:00
2026-01-11 15:08:34 +02:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2026-01-14 07:19:13 +00:00
2025-11-03 19:25:15 +00:00
2026-01-16 18:05:56 +01:00
2026-01-04 23:28:18 +00:00
2026-01-04 23:28:18 +00:00
2025-12-27 23:29:36 +00:00
2025-11-24 13:34:04 +01:00
2025-12-16 08:26:29 +00:00
2025-12-04 15:37:32 -05:00
2025-12-09 09:08:59 +01:00
2025-11-07 11:36:05 +00:00
2025-11-24 13:34:04 +01:00
2026-01-19 14:18:53 +01:00
2026-01-15 18:10:21 +00:00
2026-01-19 09:08:45 +01:00
2026-01-15 18:10:21 +00:00
2025-10-17 18:58:14 +00:00
2026-01-15 18:10:21 +00:00
2025-12-01 20:52:57 -07:00
2025-10-17 18:58:14 +00:00
2026-01-15 13:06:45 -05:00
2026-01-07 12:48:24 -08:00
2026-01-15 13:55:20 +00:00
2026-01-07 10:52:51 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2026-01-15 15:21:57 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2026-01-16 15:23:57 +00:00
2025-11-07 22:27:14 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-10-17 18:58:14 +00:00
2025-12-17 11:53:48 -07:00
2026-01-19 12:34:22 +00:00
2026-01-17 19:29:19 +00:00
2026-01-07 12:48:24 -08:00
2025-12-08 16:38:34 +01:00
2026-01-16 15:20:48 -08:00
2026-01-13 13:39:07 +00:00
2025-12-13 11:06:30 -05:00
2026-01-16 02:16:34 +00:00
2025-12-06 17:56:49 +00:00
2025-11-07 22:27:14 +00:00
2026-01-17 19:29:19 +00:00
2025-12-05 17:23:06 +00:00