-
Notifications
You must be signed in to change notification settings - Fork 770
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
Syntax highlighting and Intellisense broken in VS Code 1.86+ when a string with "]" is cast to []byte #3158
Comments
I am not naively able to reproduce this. It would be very suprising if this code broke gopls' intellisense, since gopls is built on top of compiler tools which definitely handle these inputs. Do you have any other extensions installed that may interact with Go code? |
@anirudhgiri Can you please try semantic token based syntax highlighting and if it works better for you?
|
Apologies for the late response. @findleyr I just reproduced it on a different machine running VSCode 1.86.1 with no other extensions installed except vscode-go (please refer to the screenshot below, note that line 6 is highlighted properly while line 8 is not). Are you sure you're using a version of VSCode that is 1.86.0 or above? @hyangah Yes, adding the provided field to my |
@anirudhgiri indeed, I just installed VS Code 1.86.1 and reproduced, without even installing the Go extension. This is a VS Code bug. I've filed it as microsoft/vscode#205306. VS Code 1.86 switched to a new Go syntax engine, apparently. |
I'm going to leave this open for visibility. For now, the workaround is to use |
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
orcode-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.GOBIN: undefined
toolsGopath:
gopath: /home/anirudh-g/go
GOROOT: /snap/go/10489
PATH: /snap/go/10489/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
go: /snap/go/current/bin/go: go version go1.21.6 linux/amd64
gopls: /home/anirudh-g/go/bin/gopls (version: v0.14.2 built with go: go1.21.4)
gotests: not installed
gomodifytags: not installed
impl: not installed
goplay: not installed
dlv: /home/anirudh-g/go/bin/dlv (version: v1.21.0 built with go: go1.21.0)
staticcheck: /home/anirudh-g/go/bin/staticcheck (version: v0.4.5 built with go: go1.21.0)
go env
Workspace Folder (playground): /home/anirudh-g/Documents/programming/golang/playground
GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/home/anirudh-g/.cache/go-build'
GOENV='/home/anirudh-g/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/anirudh-g/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/anirudh-g/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/snap/go/10489'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/snap/go/10489/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.21.6'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOMOD='/home/anirudh-g/Documents/programming/golang/playground/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build2453955022=/tmp/go-build -gno-record-gcc-switches'
Share the Go related settings you have added/edited
Describe the bug
If a string that contains the
]
character is converted to a[]byte
, both syntax highlighting and intellisense stop working from that line onwards. All subsequent lines of code have incorrect syntax highlighting, and intellisense does not work on those lines of code. This only happens on VSCode version 1.86.0Steps to reproduce the behavior:
var myByteArray []byte = []byte("]")
somewhere in the middleScreenshots or recordings
Syntax highlighting on VSCode version 1.86.0:

Expected Syntax highlighting:

The text was updated successfully, but these errors were encountered: