fix(lsp): codeActions not found if multiple clients are active #749
+1
−1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #744, which was thought to be caused by "copilot.vim", but actually happens anytime
rust-analyzer
does not haveid: 1
. We thought that this case was already handled (see: #744 (comment)), but it turns out that it wasn't.According to the lua manual:
What happens is that the
result
table returned byis sparse with respect to the LSPs that return a codeAction table. So consider
rust-analyzer
hasid: 2
, and the LSP withid: 1
does not return a codeAction table (presumably because the lsp is not made for rust files). Thenipairs
will stop at index 1 and return nil, since it stops at the first absent index.This PR fixes the bug by indexing only the codeActions provided by
rust-analyzer
.@mrcjkb, when you tested out with null-ls, I believe you simply got lucky and
rust-analyzer
happened to be the lsp withid: 1
.