x/tools/gopls: "Extract Function" code action provides invalid suggestions #48963
Labels
FrozenDueToAge
gopls
Issues related to the Go language server, gopls.
help wanted
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Tools
This label describes issues relating to any tools in the x/tools repository.
Milestone
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.Share the Go related settings you have added/edited
Describe the bug
When using the
Extract Function
code action on the curly-bracket-wrapped body of an anonymous function, it produces invalid code, likely due to selecting the wrong source range from the document to be extracted. I suspect the code action logic is selecting the start/end lines of the selection, disregarding the start/end columns, which are important in this case.Steps to reproduce the behavior:
repro.go
file, and paste the following code:handler()
, including the curly brackets (as indicated in the screenshot):Extract Function
code actionThe text was updated successfully, but these errors were encountered: