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

x/tools/gopls: variable autocomplete is not working correctly on broken code #48964

Open
abhimanyu003 opened this issue Oct 11, 2021 · 1 comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.

Comments

@abhimanyu003
Copy link

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.17 darwin/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
Build info
----------
golang.org/x/tools/gopls v0.7.2
    golang.org/x/tools/gopls@v0.7.2 h1:kRKKdvA8GOzra8rhSFDClOR7hV/x8v0J0Vm4C/gWq8s=
    github.com/BurntSushi/toml@v0.4.1 h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=
    github.com/google/go-cmp@v0.5.6 h1:BKbKCqvP6I+rmFHt06ZmyQtvB8xAkWdhFyr0ZUNZcxQ=
    github.com/sergi/go-diff@v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
    golang.org/x/mod@v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
    golang.org/x/sync@v0.0.0-20210220032951-036812b2e83c h1:5KslGYwFpkhGh+Q16bwMP3cOontH8FOep7tGV86Y7SQ=
    golang.org/x/sys@v0.0.0-20210809222454-d867a43fc93e h1:WUoyKPm6nCo1BnNUvPGnFG3T5DUVem42yDJZZ4CNxMA=
    golang.org/x/tools@v0.1.6-0.20210908190839-cf92b39a962c h1:C0nyHiBU2m0cR6hDiUORWqQIt3h37wsp1255QBSSXqY=
    golang.org/x/xerrors@v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=
    honnef.co/go/tools@v0.2.0 h1:ws8AfbgTX3oIczLPNPCu5166oBg9ST2vNs0rcht+mDE=
    mvdan.cc/gofumpt@v0.1.1 h1:bi/1aS/5W00E2ny5q65w9SnKpWEF/UIOqDYBILpo9rA=
    mvdan.cc/xurls/v2@v2.3.0 h1:59Olnbt67UKpxF1EwVBopJvkSUBmgtb468E4GVWIZ1I=
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
1.61.0
ee8c7def80afc00dd6e593ef12f37756d8f504ea
x64
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.28.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
go env
Workspace Folder (code): /Users/abhi1589/go/src/code
	GO111MODULE=""
	GOARCH="amd64"
	GOBIN=""
	GOCACHE="/Users/abhi1589/Library/Caches/go-build"
	GOENV="/Users/abhi1589/Library/Application Support/go/env"
	GOEXE=""
	GOEXPERIMENT=""
	GOFLAGS=""
	GOHOSTARCH="amd64"
	GOHOSTOS="darwin"
	GOINSECURE=""
	GOMODCACHE="/Users/abhi1589/go/pkg/mod"
	GONOPROXY="github.rackspace.com"
	GONOSUMDB="github.rackspace.com"
	GOOS="darwin"
	GOPATH="/Users/abhi1589/go"
	GOPRIVATE="github.rackspace.com"
	GOPROXY="https://proxy.golang.org,direct"
	GOROOT="/usr/local/Cellar/go/1.17/libexec"
	GOSUMDB="sum.golang.org"
	GOTMPDIR=""
	GOTOOLDIR="/usr/local/Cellar/go/1.17/libexec/pkg/tool/darwin_amd64"
	GOVCS=""
	GOVERSION="go1.17"
	GCCGO="gccgo"
	AR="ar"
	CC="clang"
	CXX="clang++"
	CGO_ENABLED="1"
	GOMOD="/Users/abhi1589/go/src/code/go.mod"
	CGO_CFLAGS="-g -O2"
	CGO_CPPFLAGS=""
	CGO_CXXFLAGS="-g -O2"
	CGO_FFLAGS="-g -O2"
	CGO_LDFLAGS="-g -O2"
	PKG_CONFIG="pkg-config"
	GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/wy/s6djdr5x6zx6vw7h5g3r8k6m0000gp/T/go-build3142353325=/tmp/go-build -gno-record-gcc-switches -fno-common"

Describe the bug

Auto variable auto-complete is not working as expected

Expected: cMap
Got: cmcMap

Code Used.

package main

func main() {
	test("abcabcbb")
}

func test(s string) int {
	b := []byte(s)
	var last int
	var cMap map[int]int
	for _, v : = range b {
		cmcMap // <------------------- This is where problem is
	return 0
}

Steps to reproduce the behavior:

  1. Copy the above code
  2. Try to update the line with <------------------- This is where the problem is comment

Screenshots or recordings

Recording.2021-10-12.02-41-31.from.Snipclip.mp4
@stamblerre
Copy link
Contributor

Thanks for the repro case! I don't know if it's likely that we'll address this soon since there are multiple issues going on here, but we can certainly look into it at some point.

@stamblerre stamblerre transferred this issue from golang/vscode-go Oct 14, 2021
@stamblerre stamblerre changed the title Variable autocomplete is not working correctly on broken code. x/tools/gopls: variable autocomplete is not working correctly on broken code Oct 14, 2021
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Oct 14, 2021
@gopherbot gopherbot added this to the Unreleased milestone Oct 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants