Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code fragment breaks coloring of subsequent code #3370

Closed
mokiat opened this issue Apr 30, 2024 · 2 comments
Closed

Code fragment breaks coloring of subsequent code #3370

mokiat opened this issue Apr 30, 2024 · 2 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@mokiat
Copy link

mokiat commented Apr 30, 2024

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.22.2 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.15.3
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.88.1
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.41.4
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.

     gopls:	/home/momchil/.go/bin/gopls	(version: v0.15.3 built with go: go1.22.0)
     gotests:	/home/momchil/.go/bin/gotests	(version: v1.6.0 built with go: go1.22.0)
     gomodifytags:	/home/momchil/.go/bin/gomodifytags	(version: v1.16.0 built with go: go1.22.0)
     impl:	/home/momchil/.go/bin/impl	(version: v1.1.0 built with go: go1.22.0)
     goplay:	/home/momchil/.go/bin/goplay	(version: v1.0.0 built with go: go1.22.0)
     dlv:	/home/momchil/.go/bin/dlv	(version: v1.22.1 built with go: go1.22.0)
     staticcheck:	/home/momchil/.go/bin/staticcheck	(version: v0.4.7 built with go: go1.22.0)
    

Share the Go related settings you have added/edited

    "go.gopath": "/home/momchil/.go",
    "go.lintTool": "staticcheck",
    "go.useLanguageServer": true,
    "go.toolsManagement.autoUpdate": true,
    "[go]": {
        "editor.formatOnSave": true,
        "editor.codeActionsOnSave": {
            "source.organizeImports": "explicit"
        },
        "editor.snippetSuggestions": "none"
    },
    "gopls": {
        "ui.completion.usePlaceholders": true,
        "ui.diagnostic.analyses": {
            "staticcheck": true
        }
    },

Describe the bug

The color scheme gets messed up after a specific valid Go code sequence.

Steps to reproduce the behavior:

  1. Open a new Go editor tab in VSCode.
  2. Paste the following snippet:
var (
	vertexData = gblob.LittleEndianBlock(make([]byte, len(geometry.vertices)*int(stride)))
)

if 5 > 10 {

}
  1. Observe that the if has a light blue and not the usual purple.

Screenshots or recordings

go-styling-bug

@gopherbot gopherbot added this to the Untriaged milestone Apr 30, 2024
@hyangah
Copy link
Contributor

hyangah commented May 1, 2024

Please check https://github.com/golang/vscode-go/wiki/faq#syntax-highlighting-doesnt-seem-to-work
and if it is about the default syntax highlighting (not the semantic highlighting), please report the issue to the go-syntax project.

@hyangah hyangah added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label May 1, 2024
@mokiat
Copy link
Author

mokiat commented May 2, 2024

I have checked. Using "gopls": { "ui.semanticTokens": true } the issue cannot be reproduced.

Side note: It still happens when done in a separate tab snippet but I guess the semantic tokens styling is not applied when the code is incomplete or is outside a project and VSCode defaults to go syntax.

I guess I should report this to go-syntax as a follow up.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

3 participants