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

x/tools/gopls: organizeImports code action failing with latest LSP stubs #55080

Closed
findleyr opened this issue Sep 14, 2022 · 1 comment
Closed
Assignees
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

With https://go.dev/cl/424214 (updating LSP stubs), I'm experiencing failures of the organizeImports code action in gopls.

In coc.nvim, this is the error I get:

2022-09-14T19:07:28.276 ERROR (pid:1768922) [attach] - Request error: runCommand [ 'editor.action.organizeImport' ] Error: Action "Organize Imports" is disabled: undefined
    at WD.applyCodeAction (/home/rfindley/.vim/plugged/coc.nvim/build/index.js:281:5323)
    at WD.organizeImport (/home/rfindley/.vim/plugged/coc.nvim/build/index.js:281:3455)
    at async /home/rfindley/.vim/plugged/coc.nvim/build/index.js:281:2688
    at async cte.fireCommand (/home/rfindley/.vim/plugged/coc.nvim/build/index.js:277:28532)
    at async UD.runCommand (/home/rfindley/.vim/plugged/coc.nvim/build/index.js:281:16245)
    at async Cx.cocAction (/home/rfindley/.vim/plugged/coc.nvim/build/index.js:301:17532)
    at async HM.<anonymous> (/home/rfindley/.vim/plugged/coc.nvim/build/index.js:301:19628)

I noticed this due to the build breakage in https://go.dev/cl/424075 (I am somewhat ashamed to say I didn't build before mailing...).
Looking at the logs, here is the new response:

[Trace - 19:07:28.269 PM] Received response 'textDocument/codeAction - (2)' in 4ms.
Result: [{"title":"Organize Imports","kind":"source.organizeImports","disabled":{"Reason":""},"edit":{"documentChanges":[{"textDocument":{"version":1,"uri":"file:///home/rfindley/src/tools/internal/gocommand/invoke_test.go"},"edits":[{"range":{"start":{"line":7,"character":8},"end":{"line":8,"character":5}},"newText":""},{"range":{"start":{"line":8,"character":6},"end":{"line":8,"character":9}},"newText":""}]}]}}]

Compare with the old response:

[Trace - 19:18:03.688 PM] Received response 'textDocument/codeAction - (2)' in 3ms.
Result: [{"title":"Organize Imports","kind":"source.organizeImports","edit":{"documentChanges":[{"textDocument":{"version":1,"uri":"file:///home/rfindley/src/tools/internal/gocommand/invoke_test.go"},"edits":[{"range":{"start":{"line":7,"character":8},"end":{"line":8,"character":5}},"newText":""},{"range":{"start":{"line":8,"character":6},"end":{"line":8,"character":9}},"newText":""}]}]}}]

Note that the "disabled" key is now set. Presumably our testing frameworks ignore this, hence why tests continue to pass.

We should fix our fake editor to honor "disabled", and fix the JSON serialization.

CC @pjweinb @hyangah @dle8 @adonovan (for awareness)

@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Sep 14, 2022
@gopherbot gopherbot added this to the Unreleased milestone Sep 14, 2022
@findleyr findleyr modified the milestones: Unreleased, gopls/v0.10.0 Sep 15, 2022
@gopherbot
Copy link

Change https://go.dev/cl/431216 mentions this issue: gopls/tsprotocol: make Disabled in CodeAction optional

@golang golang locked and limited conversation to collaborators Sep 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants