Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vim/Neovim/tmux scroll way too fast with trackpads #6184

Closed
reissbaker opened this issue May 25, 2020 · 11 comments · Fixed by #6843
Closed

Vim/Neovim/tmux scroll way too fast with trackpads #6184

reissbaker opened this issue May 25, 2020 · 11 comments · Fixed by #6843
Assignees
Labels
Area-Input Related to input processing (key presses, mouse, etc.) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-3 A description (P3) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Milestone

Comments

@reissbaker
Copy link

reissbaker commented May 25, 2020

Environment

Platform ServicePack Version      VersionString
-------- ----------- -------      -------------
 Win32NT             10.0.18362.0 Microsoft Windows NT 10.0.18362.0

Windows Terminal version 1.0.1401.0.

I'm curious whether or not this is trackpad-related, so FWIW I'm using a Surface Book and scrolling with the trackpad.

EDIT: I tried with a normal mouse plugged into the USB port instead of the trackpad, and it's definitely trackpad-related: regular mouse wheels work just fine.

Steps to reproduce

tmux set up with:

set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'select-pane -t=; copy-mode -e; send-keys -M'"	
bind -n WheelDownPane select-pane -t= \; send-keys -M

And/or Neovim (or just plain old Vim) with:

set mouse=a

Expected behavior

The above snippets make vim, nvim, and tmux able to be scrolled with the mouse/trackpad on macOS and Linux. They also work in WSL... If I use Xming to run an X server, and use urxvt as my terminal emulator. So, I'd expect that they'd also work for Windows Terminal.

They work in all of the above either alone (e.g. Vim/Neovim not nested inside tmux), or nested (e.g. running Neovim inside tmux).

Actual behavior

For some reason with the Windows Terminal, when I scroll in vim/nvim/tmux (with the editors either nested in tmux or un-nested) they all go absolutely nuts and scroll at like 10x speed, which is kind of unusable. FWIW I'm using a Surface Book and scrolling with my trackpad, if that makes a difference? It looks like it's just sending way more scroll events to the terminal than it should be.

Windows Terminal is otherwise dope and I'd love to be able to replace my janky Xming + urxvt setup for coding on Windows.

Here's a video I captured of the behavior in tmux — I tried to scroll a very small amount, and instead it scrolled 78 rows:

ezgif com-video-to-gif

@ghost ghost added Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels May 25, 2020
@reissbaker
Copy link
Author

FWIW, I dug up a mouse I had lying around and tried scrolling with the mouse wheel. It worked perfectly, so I'm guessing this is an issue with trackpad support for scrolling in the Windows Terminal?

@reissbaker reissbaker changed the title Vim/Neovim/tmux scroll way too fast Vim/Neovim/tmux scroll way too fast with trackpads May 25, 2020
@zadjii-msft
Copy link
Member

This seems just like the earlier issue we had where trackpads would scroll the Terminal buffer entirely too fast. I bet we're using the lines to scroll value from the system for scrolling the buffer, but not the VT mouse events we generate.

@zadjii-msft zadjii-msft added Area-Input Related to input processing (key presses, mouse, etc.) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Product-Terminal The new Windows Terminal. labels May 26, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label May 26, 2020
@zadjii-msft zadjii-msft added the Priority-3 A description (P3) label May 26, 2020
@zadjii-msft zadjii-msft added this to the Terminal v2.0 milestone May 26, 2020
@reissbaker
Copy link
Author

Makes sense. Thanks for the quick response! Looking forward to seeing this one close so I can switch over to using the Terminal.

@zadjii-msft zadjii-msft removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label May 27, 2020
@reissbaker
Copy link
Author

FWIW, this is somewhat worse with WSL2, since WSL2 broke (secure) X server communication from the Linux guest to the Windows host, and so it's unsafe to run Linux-based GUI terminals now.

I switched back to wsltty, but even that has some awkward scrolling bugs when used with trackpads (the beginning of the swipe up is treated as an up arrow, which cycles history in most shells). AFAICT there aren't any terminals on Windows anymore that work with WSL and trackpads.

@DHowett DHowett self-assigned this Jul 8, 2020
@DHowett
Copy link
Member

DHowett commented Jul 8, 2020

Alright, I’m taking this on. Gonna move delta accumulation into the shared mouse input code so both conhost and terminal benefit from it.

DHowett added a commit that referenced this issue Jul 8, 2020
By storing up the accumulated delta in the mouse input handler, we can
enlighten both conhost and terminal about wheel events that are less
than one line in size. Previously, we had a workaround in conhost that
clamped small scroll deltas to a whole line, which made trackpad
scrolling unimaginably fast. Terminal didn't make this mistake, but it
also didn't handle delta accumulation . . . which resulted in the same
behavior.

MouseInput will now wait until it's received WHEEL_DELTA (well-known
constant, value 120) worth of scrolling delta before it dispatches a
single scroll event.

Future considerations may include sending multiple wheel button events
for every *multiple* of WHEEL_DELTA, but that would be a slightly larger
refactoring that I'm not yet ready to undertake.

There's a chance that we should be dividing WHEEL_DELTA by the system's
"number of lines to scroll at once" setting, because on trackpads
conhost now scrolls a little _slow_. I think the only way to determine
whether this is palatable is to just ship it.

Fixes #6184.
@ghost ghost added the In-PR This issue has a related PR label Jul 8, 2020
@ghost ghost closed this as completed in #6843 Jul 9, 2020
@ghost ghost removed the In-PR This issue has a related PR label Jul 9, 2020
ghost pushed a commit that referenced this issue Jul 9, 2020
By storing up the accumulated delta in the mouse input handler, we can
enlighten both conhost and terminal about wheel events that are less
than one line in size. Previously, we had a workaround in conhost that
clamped small scroll deltas to a whole line, which made trackpad
scrolling unimaginably fast. Terminal didn't make this mistake, but it
also didn't handle delta accumulation . . . which resulted in the same
behavior.

MouseInput will now wait until it's received WHEEL_DELTA (well-known
constant, value 120) worth of scrolling delta before it dispatches a
single scroll event.

Future considerations may include sending multiple wheel button events
for every *multiple* of WHEEL_DELTA, but that would be a slightly larger
refactoring that I'm not yet ready to undertake.

There's a chance that we should be dividing WHEEL_DELTA by the system's
"number of lines to scroll at once" setting, because on trackpads
conhost now scrolls a little _slow_. I think the only way to determine
whether this is palatable is to just ship it.

Fixes #6184.
@ghost ghost added the Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release. label Jul 9, 2020
@DHowett
Copy link
Member

DHowett commented Jul 9, 2020

@reissbaker thanks for spurring us into action. 😄

DHowett added a commit that referenced this issue Jul 17, 2020
By storing up the accumulated delta in the mouse input handler, we can
enlighten both conhost and terminal about wheel events that are less
than one line in size. Previously, we had a workaround in conhost that
clamped small scroll deltas to a whole line, which made trackpad
scrolling unimaginably fast. Terminal didn't make this mistake, but it
also didn't handle delta accumulation . . . which resulted in the same
behavior.

MouseInput will now wait until it's received WHEEL_DELTA (well-known
constant, value 120) worth of scrolling delta before it dispatches a
single scroll event.

Future considerations may include sending multiple wheel button events
for every *multiple* of WHEEL_DELTA, but that would be a slightly larger
refactoring that I'm not yet ready to undertake.

There's a chance that we should be dividing WHEEL_DELTA by the system's
"number of lines to scroll at once" setting, because on trackpads
conhost now scrolls a little _slow_. I think the only way to determine
whether this is palatable is to just ship it.

Fixes #6184.

(cherry picked from commit fc08329)
@ghost
Copy link

ghost commented Jul 21, 2020

🎉This issue was addressed in #6843, which has now been successfully released as Windows Terminal v1.1.2021.0.:tada:

Handy links:

1 similar comment
@ghost
Copy link

ghost commented Jul 22, 2020

🎉This issue was addressed in #6843, which has now been successfully released as Windows Terminal v1.1.2021.0.:tada:

Handy links:

@ghost
Copy link

ghost commented Jul 22, 2020

🎉This issue was addressed in #6843, which has now been successfully released as Windows Terminal Preview v1.2.2022.0.:tada:

Handy links:

@reissbaker
Copy link
Author

reissbaker commented Aug 3, 2020

Yesssss thank you! 😁

Edit: tried out the Preview build, works perfectly!

@DHowett
Copy link
Member

DHowett commented Aug 3, 2020

Happy to hear it. Thanks for letting us know!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Input Related to input processing (key presses, mouse, etc.) Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Help Wanted We encourage anyone to jump in on these. Issue-Bug It either shouldn't be doing this or needs an investigation. Priority-3 A description (P3) Product-Terminal The new Windows Terminal. Resolution-Fix-Committed Fix is checked in, but it might be 3-4 weeks until a release.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants