zed-industries / zed

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
https://zed.dev
Other
50.66k stars 3.14k forks source link

Scroll speed in tmux in terminal emulator is way too fast #18930

Open fasterthanlime opened 1 month ago

fasterthanlime commented 1 month ago

Check for existing issues

Describe the bug / provide steps to reproduce it

When using the mouse wheel / trackpad to scroll up and down in the terminal in a tmux session with mouse mode enabled, scroll speed is way too fast, compared to a terminal emulator like WezTerm.

Environment

Zed: v0.156.0 (Zed Preview) OS: macOS 15.0.1 Memory: 8 GiB Architecture: aarch64

If applicable, add mockups / screenshots to help explain present your vision of the feature

Compare and contrast — same tmux session, from WezTerm (reasonable scroll speed) then Zed (way too fast):

https://github.com/user-attachments/assets/81a47933-1692-4007-801d-f7ec4d9454bd

If applicable, attach your Zed.log file to this issue.

Zed.log


WeetHet commented 1 month ago

Does this happen in alacritty too? Zed uses alacritty as an underlying terminal library, so it might be an issue with its implementation or with our usage

Edit: I've tested this and the bug is not present in alacritty

fasterthanlime commented 1 month ago

Alacritty seems to behave okay here:

https://github.com/user-attachments/assets/2eb6a214-e650-4f9b-af8c-c3dc1ead351c

notpeter commented 1 month ago

I have enabled Alternate Scroll Mode with "terminal": { "alternate_scroll": "on" } in my settings and can't reproduce what you're seeing where it jumps 5 rows at a time.

https://github.com/user-attachments/assets/6aaf5140-59a4-4ce1-9823-7026e75a5888

I've tested with:

In System Preferences->Pointer Control I have the Scroll Speed set to 5/8 for the Trackpad Options and 3/8 for the mouse options, but those does not appear to impact the behavior of Zed.

Steps I used to reproduce: run tmux, then for i in {1..10000}; do echo $i; done Enter the scroll buffer with ctrl-b [ and scroll away. (q to quit scroll mode)

WeetHet commented 1 month ago

I've turned Alternate Scroll mode on and it does not seem to solve this problem, so it must be something else. I've looked into what events we are sending to alacritty, and so far was able to determine that for a scroll up we are sending sgr_mouse_report(..., 64, false) once, which indeed corresponds to scrolling up by one line, and is seemingly the same as alacritty

Also, this is not a tmux-specific bug, as zellij has the same problem when scrolling