Skip to content

Horizontal mouse wheel events treated as vertical scrolling #4848

Description

@jason5122

Checklist

  • I have read through the manual page (man fzf)
  • I have searched through the existing issues
  • For bug reports, I have checked if the bug is reproducible in the latest version of fzf

Output of fzf --version

0.73.1 (Homebrew)

OS

  • Linux
  • macOS
  • Windows
  • Etc.

Shell

  • bash
  • zsh
  • fish

Problem / Steps to reproduce

Note

No AI was used! I noticed you closed contributions due to an influx of low-effort PRs, so I put in the time to keep the code minimal and fully understand the changes. I love your work, please keep going!

One day, I encountered jittering when scrolling up/down on my macOS trackpad in fzf. I realized it was because the horizontal scroll component is factored in, so if you scroll 45° up and right or 45° down and left, the scroll counteracts itself! I propose that horizontal mouse wheel events should not count as vertical scrolling.

Reproducing

  1. Use a terminal that supports horizontal scrolling (e.g., Ghostty, Alacritty, Kitty, etc.).
  2. Scroll horizontally in fzf.
  3. Scrolling left should scroll upwards. Scrolling right should scroll downwards.

The Fix

I believe the issue has to do with lines 908-915 of light.go. The logic for SGR mouse wheel events is as follows. Is this intended?

SGR Mouse Event Formula Scroll
64 (up) 64 & 1 => 0 +1 (up)
65 (down) 65 & 1 => 1 -1 (down)
66 (left) 66 & 1 => 0 +1 (up)
67 (right) 67 & 1 => 1 -1 (down)

I made a branch with the following changes:

SGR Mouse Event Formula Scroll
64 64 & 3 => 0 +1
65 65 & 3 => 1 -1
66 66 & 3 => 2 0 (ignored)
67 67 & 3 => 3 0 (ignored)

I just made horizontal scrolling a no-op. In the future, we can support proper horizontal scrolling (#4824).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions