-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Open
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.
Milestone
Description
Go version
go version go1.25.0 windows/amd64
Output of go env
in your module/workspace:
set AR=ar
set CC=gcc
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_ENABLED=0
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set CXX=g++
set GCCGO=gccgo
set GO111MODULE=
set GOAMD64=v1
set GOARCH=amd64
set GOAUTH=netrc
set GOBIN=
set GOCACHE=C:\Users\xxx\AppData\Local\go-build
set GOCACHEPROG=
set GODEBUG=
set GOENV=C:\Users\xxx\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFIPS140=off
set GOFLAGS=
set GOGCCFLAGS=-m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\xxx\AppData\Local\Temp\go-build1152973792=/tmp/go-build -gno-record-gcc-switches
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMOD=C:\Users\xxx\xxx\go.mod
set GOMODCACHE=C:\Users\xxx\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\xxx\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Users\xxx\go\pkg\mod\golang.org\t[email protected]
set GOSUMDB=sum.golang.org
set GOTELEMETRY=local
set GOTELEMETRYDIR=C:\Users\xxx\AppData\Roaming\go\telemetry
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\xxx\go\pkg\mod\golang.org\t[email protected]\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.25.0
set GOWORK=
set PKG_CONFIG=pkg-config
What did you do?
test.go
package main
func test() string {
return `
aaaaa`
}
gopls version
> golang.org/x/tools/gopls v0.19.1
gopls semtok test.go
What did you see happen?
/*⇒7,keyword,[]*/package /*⇒4,namespace,[]*/main
/*⇒4,keyword,[]*/func /*⇒4,function,[definition signature]*/test() /*⇒6,type,[defaultLibrary string]*/string {
/*⇒6,keyword,[]*/return /*⇒1,string,[]*/`
/*⇒0,string,[]*/
/*⇒0,string,[]*/
/*⇒0,string,[]*/
/*⇒2,string,[]*/aaaaa`
}
The last line aaaaa
is only marked up to two characters.
epos
in
https://github.com/golang/tools/blob/c2e79795ae0d753340da9a7b0060f44314f455e5/gopls/internal/golang/semtok.go#L813
already contains the wrong position.
Replacing it with epos := tv.fset.Position(end)
returns the same invalid position.
What did you expect to see?
/*⇒7,keyword,[]*/package /*⇒4,namespace,[]*/main
/*⇒4,keyword,[]*/func /*⇒4,function,[definition signature]*/test() /*⇒6,type,[defaultLibrary string]*/string {
/*⇒6,keyword,[]*/return /*⇒1,string,[]*/`
/*⇒0,string,[]*/
/*⇒0,string,[]*/
/*⇒0,string,[]*/
/*⇒6,string,[]*/aaaaa`
}
The last line aaaaa
is marked completely (5 characters + 1 for the tick).
Metadata
Metadata
Assignees
Labels
BugReportIssues describing a possible bug in the Go implementation.Issues describing a possible bug in the Go implementation.ToolsThis label describes issues relating to any tools in the x/tools repository.This label describes issues relating to any tools in the x/tools repository.goplsIssues related to the Go language server, gopls.Issues related to the Go language server, gopls.