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.

Comment From: gopherbot

Change https://go.dev/cl/673395 mentions this issue: gopls/internal/test: add folding ranges test cases

Comment From: xieyuschen

Added some test cases in CL673395, regardless having comment or not, gopls always reports correct folding range. However, I saw the language server response is abnormal when there is a comment after {. It's probably not a gopls(server side) issue.

[Trace - 12:53:00.824 PM] Sending request 'textDocument/foldingRange - (4)'.
Params: {"textDocument":{"uri":"file:///Users/yuchen.xie/workspace/playground/a.go"}}

[Trace - 12:53:01.133 PM] Received response 'textDocument/foldingRange - (4)' in 309ms.
Result: null
````

The response is null, I'm not sure what happened at the client side. It's possible that client ignores it due to client treats it "invalid".

/* * Represents a folding range. To be valid, start and end line must be bigger * than zero and smaller than the number of lines in the document. Clients * are free to ignore invalid ranges. / export interface FoldingRange { ```