sslivkoff / vim-scroll-barnacle

a scrollbar for vim in the terminal
Apache License 2.0
14 stars 0 forks source link

Using mousewheel over the the scrollbar region causes bar to jump #1

Open khughitt opened 4 years ago

khughitt commented 4 years ago

Greetings!

First off, thank you for creating this great plugin, and for taking the time to document and share it! Already it is much better than any of the previous solutions I've attempted to use in the past.

I'm testing it out now with my current config, and have come across a few small problems that I will report as issues.

One issue I noticed is that the mousewheel works as expected, and the scrollbar updates properly, when the cursor is over the main body of neovim, but not when the mouse is held over the narrow scrollbar region. Attempting to use the mousewheel above the scrollbar causes the bar itself to jump around dramatically, while the document itself is unchanged.

I realize that there are some issues with Neovim's mouse support that may be related to this, but I figured it would still be good to keep track of.

One final thought -- you might consider sharing the plugin on r/neovim, if you haven't already. I'm sure others would find it useful and you might get some good feedback there as well.

Cheers, Keith

System info:

Neovim version:

NVIM v0.5.0-296-gfa9b057d3
Build type: RelWithDebInfo
LuaJIT 2.0.5
Compilation: /usr/bin/cc -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fdiagnostics-color=auto -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/keith/.cache/yay/neovim-git/src/neovim-git/build/config -I/home/keith/.cache/yay/neovim-git/src/neovim-git/src -I/usr/include -I/home/keith/.cache/yay/neovim-git/src/neovim-git/build/src/nvim/auto -I/home/keith/.cache/yay/neovim-git/src/neovim-git/build/include
Compiled by keith@titan

Features: +acl +iconv +tui
sslivkoff commented 4 years ago

Thanks for all the feedback, it is very helpful

Vim allows the scrollwheel to scroll inactive windows without activating them. The scrollbar floating window is an always-inactive floating window, and so it gets scrolled by the wheel. The plugin currently attempts to prevent this by patching <ScrollWheelUp> to run SBRedrawScrollbar() after scrolling, but as you can see it is not detected reliably.

The main problem is that I don't know of a straightforward way to detect the particular window where the mouse is when a scrollevent occurs, or to detect the window that the scrollwheel event occurs in. Remaping <ScrollWheelUp> or responding to autocmd events will not change the values returned by nvim_get_current_[win|buf|etc] functions.

I'm a bit busy right now but I will look into it when I have more time. A couple possible paths forward

Suggestions welcome

khughitt commented 4 years ago

No problem! Unfortunately I don't know enough about Neovim's internal plugin API to really offer help here.. It's not the most urgent issue though, so I can live without mousewheel support for now and we can just keep the issue open to keep track of it. If I ever get around to learning how to write plugins, perhaps I can come back to this and take a stab then.