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/cmd/gopls: completions do not work for unpersisted imports #31338

Closed
myitcv opened this issue Apr 8, 2019 · 1 comment
Closed

x/tools/cmd/gopls: completions do not work for unpersisted imports #31338

myitcv opened this issue Apr 8, 2019 · 1 comment

Comments

@myitcv
Copy link
Member

@myitcv myitcv commented Apr 8, 2019

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

$ go version
go version go1.12.2 linux/amd64
$ go list -m golang.org/x/tools
golang.org/x/tools v0.0.0-20190406165526-0d5674b3111a

Does this issue reproduce with the latest release?

Yes

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

go env Output
$ go env
GOARCH="amd64"
GOBIN="/home/myitcv/gostuff/src/github.com/myitcv/govim/cmd/govim/.bin"
GOCACHE="/home/myitcv/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPROXY=""
GORACE=""
GOROOT="/home/myitcv/gos"
GOTMPDIR=""
GOTOOLDIR="/home/myitcv/gos/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/myitcv/gostuff/src/github.com/myitcv/govim/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 -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build127648482=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Considering the following govim testscript in which I attempt a completion in a file that does not currently have the relevant import (of "fmt") persisted to disk:

vim ex 'e main.go'
vim ex 'call setline(3, \"import \\\"fmt\\\"\")'
vim ex 'call setline(6, \"\\tfmt.Pr\")'
vim ex 'call cursor(6,1)'
vim ex 'call feedkeys(\"A\\<C-X>\\<C-O>\\<C-N>\\<C-N>\\<C-N>\\<ESC>\", \"x\")'
vim ex 'w'
cmp main.go main.go.golden

-- go.mod --
module mod.com

-- main.go --
package main

// import

func main() {
	// fmt.Pr
}

-- main.go.golden --
package main

import "fmt"

func main() {
	fmt.Println
}

As with all govim buffers, every initial buffer read is sent to gopls as a DidOpen notification; every subsequent change is sent as a DidChange.

What did you expect to see?

The completion to succeed and hence the test to pass.

What did you see instead?

> cmp main.go main.go.golden
[diff -main.go +main.go.golden]
 package main

 import "fmt"

 func main() {
-       fmt.Pr
+       fmt.Println
 }
-

FAIL: testdata/complete_import_not_on_disk.txt:10: main.go and main.go.golden differ

cc @stamblerre @ianthehat

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.