ray-x / lsp_signature.nvim

LSP signature hint as you type
Apache License 2.0
2.01k stars 56 forks source link

ignore signature results for other buffers #233

Closed Gelio closed 1 year ago

Gelio commented 1 year ago

Language servers can be slow to respond to the textDocument/signatureHelp request. During that time, the user could have moved to another buffer. The signature would be shown for the current buffer even though it was meant for some other buffer.

In this reproduction, I modify some code to make tsserver busy, quickly ask for signatureHelp and then quickly open Telescope:

https://user-images.githubusercontent.com/889383/202849435-e4ec105f-3b2f-4573-b0cd-a56decb43947.mp4

Let's only show the signature if it is for the current buffer.

The same Telescope bug reproduction with the fix from this PR (it no longer causes an error because the signature is ignored):

https://user-images.githubusercontent.com/889383/202849512-c1595d6d-9c55-4f2f-8b76-bef5781bc9d7.mp4

This bugfix is cherry-picked from the Neovim core signature_help LSP handler.

Gelio commented 1 year ago

Thanks for merging the PR!

Yeah, the delay may also be from there, but in my case, it is definitely tsserver choking on the size of the project. I have the same delays for diagnostics, hover information, autocomplete, etc :sweat_smile: