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

Use mouse position for diagnostic and fold preview #80

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

PgBiel
Copy link

@PgBiel PgBiel commented Feb 8, 2025

Fixes #73

Now diagnostic and fold preview show information from under the mouse on hover, not under the cursor.

I haven't changed the other providers (which also have this bug) since they depend on the cursor to get information (i.e. <cword>). Those could require a larger refactor.

More generally, all providers seem to only work with the current window, whereas, in a window split, the current window might not be the window the mouse is hovering on, returning wrong information. Fixing this would be best done in a separate PR as the changes would be quite large.

So, for this PR, I try to bring the most value for the smallest changes. Let me know if any further changes are needed.

@lewis6991
Copy link
Owner

I assume the cursor position is still used if the key mapping is used instead?

@PgBiel
Copy link
Author

PgBiel commented Feb 8, 2025

Is that information passed to opts? Because if so, execute would work but I'd have to change enabled a bit (shouldn't be too difficult).

@PgBiel
Copy link
Author

PgBiel commented Feb 8, 2025

I assume the cursor position is still used if the key mapping is used instead?

Okay! I managed to implement this by using opts for enabled. Tested the keybind and the mouse versions and they both seem to report information for the correct positions, for both diagnostic and fold preview providers. 👍

@PgBiel
Copy link
Author

PgBiel commented Feb 8, 2025

I also managed to fix this from the PR description:

More generally, all providers seem to only work with the current window, whereas, in a window split, the current window might not be the window the mouse is hovering on, returning wrong information. Fixing this would be best done in a separate PR as the changes would be quite large.

Actually, by using the bufnr provided through opts it works fine with window splits... so I just had to change fold preview to use bufnr through a buf_call, much simpler than I thought. Yay!

Fixing the other providers could require some additional work due to <cword>, however, so that's best kept to a separate PR.

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

Successfully merging this pull request may close these issues.

when used as mouse_provider, Diagnostics provider shows diagnostics from cursor position not mouse position
2 participants