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: autocomplete not working as expected #32654

Closed
gencer opened this issue Jun 17, 2019 · 9 comments
Closed

x/tools/gopls: autocomplete not working as expected #32654

gencer opened this issue Jun 17, 2019 · 9 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@gencer
Copy link

gencer commented Jun 17, 2019

What version of Go are you using (go version)?

$ go version
go version go1.12.6 windows/amd64

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

Windows 10 1903 x64 uses Ryzen 3 processor.

go env Output
$ go env
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\gence\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Go\
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-LD:\Go\/src/mingw-4.7.2-64 -lchilkatExt-9.5.0 -lws2_32 -lstdc++
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\gence\AppData\Local\Temp\go-build166751930=/tmp/go-build -gno-record-gcc-switches

What did you do?

Trying to see members of an object or class. See below GIF animations.

What did you expect to see?

I would like to see members of FileInfo or cli.

What did you see instead?

Sometimes I get intellisense work but mostly it behaves like that variable/object doesn't exists at all. So, no auto-complete.

Autocomplete issue:

2

  • As you can see req barely completes. Above works below not. Most of my code is like this.

Also few samples:

2

and...

1

Here is logfile: logfile.log

Logfile is big, i couldn't paste here. (max. allowed size exceeded).

This logfile is belongs to info. (info balya.FileInfo) sample above GIF. I should see FileInfo's members however, even info variable is not auto-completed.

For now, I installed from a commit that committed on May 24, 2019. Which works perfectly.

@gopherbot gopherbot added this to the Unreleased milestone Jun 17, 2019
@gopherbot gopherbot added the gopls Issues related to the Go language server, gopls. label Jun 17, 2019
@stamblerre
Copy link
Contributor

So interestingly enough, there are no errors in your log. There is only one case where the textDocument/completion request returns no results. If you type out "info" can you jump to definition on it?

@gencer
Copy link
Author

gencer commented Jun 17, 2019

I can't. I illustrated 2 things in below. One is info.Authorization. (Authorization as string is in struct). And other one is invokeHookSync. As you can see i can ctrl+click on invokeHookSync however, when I type, no such method exists. If i manually enter that, i can't go to that definition.

I also captured logs during this GIF recording. I've attached both below. Let me know if you need anything else.

2

logfile.log

@muirdm
Copy link

muirdm commented Jun 18, 2019

I see various errors like FromUTF16Column: chr goes beyond the line, which usually means file contents have gotten out of sync between your editor and gopls. If things get out of sync then everything breaks.

An easy way to check if this is happening:

  1. Add "-debug localhost:8080" to gopls cil flags (or change port to whatever you want).
  2. Restart gopls either by killing the process or by reloading in your editor
  3. Wait for issues to start happening in a file
  4. Open your browser to localhost:8080 and navigate the gopls cache links to find the file in question
  5. Compare the contents displayed in the browser with what is in your editor

If they don't match, then things have gotten out of sync. If they do match, I am out of ideas.

@SirAlvarex
Copy link

SirAlvarex commented Jun 18, 2019

I'm having the exact same issue as this user. For me it happens from the very beginning, so I was able to capture the log at a minimal size.

Log File:
gopls.log

If I run gopls for awhile, I sometimes am able to see this error pop up:

[Error - 3:14:44 PM] send textDocument/codeAction#49 line is beyond end of file

Sadly, the Cache does look to be exactly correct. It updates with every keystroke to the correct contents.

Go INFO:

go version go1.12.4 windows/amd64

set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\kygordon.NORTHAMERICA\AppData\Local\go-build
set GOEXE=.exe
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\Public\Development\go
set GOPROXY=
set GORACE=
set GOROOT=C:\Go
set GOTMPDIR=
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=C:\Users\KYGORD~1.NOR\AppData\Local\Temp\go-build225681462=/tmp/go-build -gno-record-gcc-switches

Is there any other info I can provide to help debug this issue?

EDIT: Okay the problem just went away when I enabled GO111MODULES=on . Originally I had to disable the modules because of gopls taking up over 4GB of memory on an older version. I'll operate with the modules being enabled for awhile and see if the issue props up again. But issues with modules disabled could be a consistent setting between myself and the original poster.

@stamblerre
Copy link
Contributor

@gencer: Are you still seeing this issue on the latest version of gopls (go get -u golang.org/x/tools/gopls@master)? I just fixed an issue relating to race conditions, so I wonder if this could be related.

@gencer
Copy link
Author

gencer commented Jun 28, 2019

when using without GO111MODULES=on and with dep, autocomplete still broken. When I convert project to go.mod and enable go modules, all works.

@stamblerre
Copy link
Contributor

stamblerre commented Jun 28, 2019

Can you share the full logs that you see in $GOPATH mode? It's possible that gopls is playing badly with dep.

@gencer
Copy link
Author

gencer commented Jun 30, 2019

@stamblerre, sorry for late reply. See, I am trying to reproduce same behavior on my project since 2 days that uses dep, but it seems it just works.

I am constantly watching and will record both GIF and a log for this when i face with same issue. But it seems fixed here.

Dunno why i got wrong behavior in the first place. Perhaps, something was different at that time but as i said, it just works at the moment.

Thank you so much for your help & fast fixes for both of my issues!

@stamblerre
Copy link
Contributor

Glad that this has been resolved! Thanks for your patience.

@golang golang locked and limited conversation to collaborators Jun 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls.
Projects
None yet
Development

No branches or pull requests

5 participants