lewis6991 / satellite.nvim

Decorate scrollbar for Neovim
MIT License
542 stars 20 forks source link

Visual selecting with the mouse breaks in some buffers at random with Satellite #24

Closed amaanq closed 1 year ago

amaanq commented 1 year ago

Describe the bug Using the mouse to visually highlight lines doesn't work with this plugin

To Reproduce

  1. Open a project with a few buffers
  2. Use mouse to visually higlight some lines
  3. A lot of times it doesn't work

Expected behavior Mouse should highlight

Additional context I loaded the plugin on events User PackerDefered and BufEnter, both have this bug

lewis6991 commented 1 year ago

If you are using 0.8.0 then this is a known issue which has been fixed in 0.9.0 and will be backported to 0.8.1.

See https://github.com/neovim/neovim/pull/20645 and https://github.com/neovim/neovim/pull/20665.

In the future, please provide more information in issues. This is an experimental plugin, and I will close low-effort bug reports.

amaanq commented 1 year ago

Sorry about that, but I am on 0.9.0, any more information I can provide?

lewis6991 commented 1 year ago
nmrtv commented 1 year ago

Actually, there is a bug here: https://github.com/lewis6991/satellite.nvim/blob/024920b94611684840731ea79f5a9c6a687683e8/lua/satellite/mouse.lua#L269 For windows that don't have scrollbars (either the content is too short or current_only option is set, and you're clicking on an inactive split), props is nil and all left clicks are blocked.

I don't know the internals here, but changing the code like this makes the problem disappear for me.

                local props = view.get_props(mouse_winid)
                -- Add 1 cell horizontal left-padding for grabbing the scrollbar. Don't
                -- add right-padding as this would extend past the window and will
                -- interfere with dragging the vertical separator to resize the window.
                if
                    not props
                    or (
                        mouse_row < props.row
                        or mouse_row >= props.row + props.height
                        or mouse_col < props.col
                        or mouse_col > props.col + props.width
                    )
                then
                    -- The click was not on a scrollbar.
                    fn.feedkeys(string.sub(input_string, str_idx), "ni")
                    return
                end