Skip to content

[Refactor] When extracting a function, comments were left out #3583

@vector090

Description

@vector090

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
  • Run go version to get version of Go from the VS Code integrated terminal.
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
  • Check your installed extensions to get the version of the VS Code Go extension
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

go version go1.23.1 windows/amd64

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

Describe the bug

When extracting a function, comments were left out, i.e. they didn't go into the new function.

Steps to reproduce the behavior:

Selected code,
right click,
"Refactor",
"Extract Function",

Screenshots or recordings

If applicable, add screenshots or recordings to help explain your problem.
image

image

image

issue: the comments were stripped and left there
image

the new function missed all the comments
image

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions