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

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

Open
khughitt opened this issue Mar 5, 2020 · 2 comments
Open

Comments

@khughitt
Copy link

khughitt commented Mar 5, 2020

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:

  • Arch Linux 5.5.7 64-bit
  • termite v15
  • vim-scroll-barnacle (commit b27f2d5)

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
Copy link
Owner

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

  • Subscribe to the nvim_buf_lines_event using channels. From the docs it looks like this could be used to detect scrolling events in a buffer-specific manner. This would then allow for a proper response to the mousewheel event in scrollbar floating window. A side bonus would be also using this as the scroll detection mechanism in the main text window, so that movement keys not longer need to be patched. Disclaimer, I don't know how to use channels so I don't know if my reading of the docs is correct.
  • Somehow disable scrolling in the floating window. This would not allow the main window to respond to bar wheel events, it would just get rid of the graphical glitching.

Suggestions welcome

@khughitt
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants