Skip to content

Can't toggle comments #4036

Description

@gmarsano

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.

    • go version go1.26.3 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.

    • golang.org/x/tools/gopls v0.22.0, built with go: go1.26.3
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.

    • 1.121.0 (f6cfa2ea2403534de03f069bdf160d06451ed282) x64
  • Check your installed extensions to get the version of the VS Code Go extension

    • golang.go@0.52.2
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

    Go: Locate Configured Go Tools output
     # Tools Configuration
    
     ## Environment
    
     GOBIN: undefined
     toolsGopath:
     gopath: /home/gmarsano/go
     GOROOT: /usr/local/go
     PATH: /home/gmarsano/.config/composer/vendor/bin:/home/gmarsano/.local/bin:/home/gmarsano/.nvm/versions/node/v24.11.1/bin:/home/gmarsano/.config/composer/vendor/bin:/home/gmarsano/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin:/home/gmarsano/go/bin:/usr/local/go/bin:/home/gmarsano/go/bin
    
     ## Tools
    
     	go:      /usr/local/go/bin/go: go version go1.26.3 linux/amd64
     	gotests: /home/gmarsano/go/bin/gotests (version: v1.6.0 built with go: go1.26.3)
     	impl:    /home/gmarsano/go/bin/impl    (version: v1.4.0 built with go: go1.26.3)
     	goplay:  /home/gmarsano/go/bin/goplay  (version: v1.0.0 built with go: go1.26.3)
     	dlv:     /home/gmarsano/go/bin/dlv     (version: v1.26.3 built with go: go1.26.3)
     	gopls:   /home/gmarsano/go/bin/gopls   (version: v0.22.0 built with go: go1.26.3)
    

Share the Go related settings you have added/edited

"gopls": {
  "ui.semanticTokens": true
},
"[go]": {
  "editor.defaultFormatter": "golang.go"
},
"go.toolsManagement.autoUpdate": true

Describe the bug

editor.action.commentLine does not work on .go files. Whether triggered via keyboard shortcut or the Command Palette, the command is dispatched (confirmed with Developer: Toggle Keyboard Shortcuts Troubleshooting) but has no effect — lines are neither commented nor uncommented.

The issue appears to be exclusive to Go files managed by the vscode-go extension. The same command works correctly on other file types (e.g. JavaScript, Python).

Expected behavior: The current line (or selected lines) should be toggled between commented and uncommented using //.

Steps to reproduce the behavior:

  1. Open any .go file in VS Code.
  2. Place the cursor on a line with code (or select multiple lines).
  3. Trigger editor.action.commentLine via its keyboard shortcut or via the Command Palette (Toggle Line Comment).
  4. Observe that nothing happens — no comment is added or removed.

To confirm the command is reaching VS Code: enable Developer: Toggle Keyboard Shortcuts Troubleshooting, trigger the shortcut, and check the Output panel. The command appears in the log but produces no visible result.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions