Skip to content

x/tools/gopls: FoldingRange: no fold option for functions (there is a comment at the end of the line) #73735

@pantsmann

Description

@pantsmann

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.
    • go1.24.2 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.18.1
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.100.0
      19e0f9e681ecb8e5c09d8784acaa601316ca4571
      x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.46.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
    • Too much dawling! Too much!

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

There is a fold option arrow in the gutter next to functions except when there is a comment at the end of the function line e.g.
func FuncName() { // comment

I'd expect code folding to work with or without the comment.

Steps to reproduce the behavior:

  1. pick a function, any function, don't show the audience.
  2. hover over the gutter, notice the up or down arrow.
  3. show the audience that clicking the arrow hides and unhides the function content.
  4. add a comment after the opening curly brace. Show the audience there is nothing up your sleeves.
  5. hover over the gutter again. Amazing, the folding arrow has disappeared! No magic words necessary!
  6. does anyone else get bored writing all this down in a bug report? Shame on you, the info is helpful. ;)

Not sure when this started happening. Wasn't paying too much attention. Sleight of hand, man!

Screenshots or recordings

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

Metadata

Metadata

Assignees

Labels

ToolsThis label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.help wanted

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions