x/tools/gopls: "only" refactor codeAction requests returns null #49263
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
Is your feature request related to a problem? Please describe.
vscode is my main editor for golang, but one area where it is sorely lacking is the refactoring support.
One example of an improvement I'd love to have is for the golang extension to respond to the
Refactor...
command in the editor.The command I'm talking about is the one that gets triggered by the following actions:
ctrl+shift+p
, typing "Refactor...", hitting enterctrl+shift+r
For most languages, triggering this command opens a context menu with different refactoring options like Extract method, Extract variable, etc.
For example:
But the golang extension doesn't respond to this command... It always says
No refactorings available...
Personally, I use this command all the time in other languages - it saves many keystrokes moving around bits of code.
Describe the solution you'd like
gopls does actually have refactorings available, it just doesn't respond to
Refactor...
What I'd like to see is a context menu with all applicable refactorings upon issuing the
Refactor...
command.I'm not very familiar with the anatomy of LSP and vscode extensions, so I couldn't say if this is a deficiency of the golang extension or of gopls. I would suspect both.
Describe alternatives you've considered
The next best alternative is to use the command palette (and/or keybindings) to manually search for the refactoring operation you want to run.
But this is unwieldy and much less useful since refactoring is context-dependent and the commands often fail - it would help if the editor was able to tell you what refactorings it knows are possible on the code you selected.
The text was updated successfully, but these errors were encountered: