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: import autocomplete appends suggestion instead of replacing #42748

Open
RomanKornev opened this issue Nov 20, 2020 · 1 comment
Open

Comments

@RomanKornev
Copy link

@RomanKornev RomanKornev commented Nov 20, 2020

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • go version go1.15.2 darwin/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    • Version: 1.51.1
  • Check your installed extensions to get the version of the VS Code Go extension
    • 0.18.1
  • Run go env to get the go development environment details
    • GO111MODULE=""
      GOARCH="amd64"
      GOBIN=""
      GOCACHE="/Users/df/Library/Caches/go-build"
      GOENV="/Users/df/Library/Application Support/go/env"
      GOEXE=""
      GOFLAGS=""
      GOHOSTARCH="amd64"
      GOHOSTOS="darwin"
      GOINSECURE=""
      GOMODCACHE="/Users/df/go/pkg/mod"
      GONOPROXY=""
      GONOSUMDB=""
      GOOS="darwin"
      GOPATH="/Users/df/go"
      GOPRIVATE=""
      GOPROXY="https://proxy.golang.org,direct"
      GOROOT="/usr/local/Cellar/go/1.15.2/libexec"
      GOSUMDB="sum.golang.org"
      GOTMPDIR=""
      GOTOOLDIR="/usr/local/Cellar/go/1.15.2/libexec/pkg/tool/darwin_amd64"
      GCCGO="gccgo"
      AR="ar"
      CC="clang"
      CXX="clang++"
      CGO_ENABLED="1"
      GOMOD=""
      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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/gd/ck6ncspn19115_7mxytyzw840000gp/T/go-build892077481=/tmp/go-build -gno-record-gcc-switches -fno-common"

Share the Go related settings you have added/edited

"go.useLanguageServer": true,

Describe the bug

Autocompleting import mat produces import mat"math/"

Steps to reproduce the behavior:

  1. Type import mat
  2. Enter or Tab
  3. See import mat"math/" instead of import "math"

Screenshots or recordings

image

@hyangah
Copy link
Contributor

@hyangah hyangah commented Nov 20, 2020

@RomanKornev thanks for the report.
@stamblerre I could reproduce with the gopls built on the master (post v0.5.3)
I think it's related to the fact that the original import statement is missing "" so invalid.


[Trace - 10:12:46.016 AM] Sending notification 'textDocument/didChange'.
Params: {"textDocument":{"uri":"file:///Users/hakim/hello/a.go","version":10},"contentChanges":[{"range":{"start":{"line":2,"character":8},"end":{"line":2,"character":8}},"rangeLength":0,"text":"a"}]}


[Trace - 10:12:46.017 AM] Sending request 'textDocument/completion - (27)'.
Params: {"textDocument":{"uri":"file:///Users/hakim/hello/a.go"},"position":{"line":2,"character":9},"context":{"triggerKind":3}}

...
[Trace - 10:12:46.120 AM] Received response 'textDocument/completion - (27)' in 103ms.
Result: {"isIncomplete":true,"items":[{"label":"\"math\"","kind":9,"detail":"\"math\"","preselect":true,"sortText":"00000","filterText":"\"math\"","insertTextFormat":2,"textEdit":{"range":{"start":{"line":2,"character":9},"end":{"line":2,"character":9}},"newText":"\"math\""}},{"label":"\"math/\"","kind":9,"detail":"\"math/\"","sortText":"00001","filterText":"\"math/\"","insertTextFormat":2,"textEdit":{"range":{"start":{"line":2,"character":9},"end":{"line":2,"character":9}},"newText":"\"math/\""}}]}

@hyangah hyangah changed the title Language server: Import autocomplete appends suggestion instead of replacing x/tools/gopls: Import autocomplete appends suggestion instead of replacing Nov 20, 2020
@hyangah hyangah transferred this issue from golang/vscode-go Nov 20, 2020
@gopherbot gopherbot added this to the Unreleased milestone Nov 20, 2020
@stamblerre stamblerre added the NeedsFix label Nov 20, 2020
@stamblerre stamblerre changed the title x/tools/gopls: Import autocomplete appends suggestion instead of replacing x/tools/gopls: import autocomplete appends suggestion instead of replacing Nov 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

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