kosayoda / nvim-lightbulb

VSCode 💡 for neovim's built-in LSP.
MIT License
801 stars 30 forks source link

Use buffer the request came from instead of current buffer #16

Closed ii14 closed 3 years ago

ii14 commented 3 years ago

When you're currently on a line with available code action and then open a new window from that line (eg. :help), the sign can be placed on another buffer, because _update* functions always use the current buffer. This PR fixes this bug by passing the buffer handle to the handler function when the codeAction request is made.

kosayoda commented 3 years ago

Thank you for the PR. I can't seem to reproduce the issue you mentioned. Can you give me an example workflow where the lightbulb shows up where it's not supposed to? Not to say that it's not a good idea to get the buffer only at the start, I'll review and merge as soon as possible.

ii14 commented 3 years ago

https://asciinema.org/a/G0yDogA9xOdQAkr5iXZoOzRLe

ii14 commented 3 years ago

Maybe that's because I call it very often, on CursorMoved event.

au CursorMoved * lua require 'nvim-lightbulb'.update_lightbulb()
kosayoda commented 3 years ago

Maybe that's because I call it very often, on CursorMoved event.

That makes a lot of sense, thank you for the improvement!