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: autocompletion overriding content #42634

Closed
szmcdull opened this issue Nov 13, 2020 · 7 comments
Closed

x/tools/gopls: autocompletion overriding content #42634

szmcdull opened this issue Nov 13, 2020 · 7 comments
Labels

Comments

@szmcdull
Copy link

@szmcdull szmcdull commented Nov 13, 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.3 windows/amd64
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders

    • 1.51.1 e5a624b788d92b8d34d1392e4c4d9789406efe8f x64
  • Check your installed extensions to get the version of the VS Code Go extension

  • Run go env to get the go development environment details

Share the Go related settings you have added/edited

Run Preferences: Open Settings (JSON) command to open your settings.json file.
Share all the settings with the go. or ["go"] or gopls prefixes.

  • "go.useLanguageServer": true,
  • "go.buildTags": "debug",
  • "go.lintTool": "golangci-lint",

Describe the bug

When accepting auto-completion, the suggestion is replaced over the current word (including the part after the cursor).
Other languages such as python or javascript will not replace the part after the cursor.

@hyangah
Copy link
Contributor

@hyangah hyangah commented Nov 13, 2020

@szmcdull What is the gopls version? (gopls -v version from your terminal)

@szmcdull
Copy link
Author

@szmcdull szmcdull commented Nov 14, 2020

@hyangah golang.org/x/tools/gopls@v0.5.3 h1:C8QSrqjqaVzlVoHL1R9yWbROoOApRgI8gN1G+cHlPuw=

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Nov 14, 2020

Can you please provide a small repro case to illustrate the problem?

@szmcdull
Copy link
Author

@szmcdull szmcdull commented Nov 16, 2020

word := 0 // line1
word      // line2

Then set cursor to the start the line 2, then enter "pr", ctrl+space, choose "print" from the candidate list and press ENTER or TAB. Now you can see "word" is disappeared.

@hyangah
Copy link
Contributor

@hyangah hyangah commented Nov 16, 2020

Thanks @szmcdull - I could reproduce the issue even after excluding the extension's snippet by disabling it. Here is the gopls trace - that is suggesting a textEdit for complete word replacement. Transferring to the gopls issue tracker.

[Trace - 09:13:35.400 AM] Received response 'textDocument/completion - (99)' in 11ms.
Result: {"isIncomplete":true,"items":[{"label":"print","kind":3,"detail":"func(args ...Type)","preselect":true,"sortText":"00000","filterText":"print","insertTextFormat":2,"textEdit":{"range":{"start":{"line":16,"character":1},"end":{"line":16,"character":7}},"newText":"print(${1:})"}},{"label":"println","kind":3,"detail":"func(args ...Type)","sortText":"00001","filterText":"println","insertTextFormat":2,"textEdit":{"range":{"start":{"line":16,"character":1},"end":{"line":16,"character":7}},"newText":"println(${1:})"}},{"label":"printer","kind":9,"detail":"\"go/printer\"","sortText":"00002","filterText":"printer","insertTextFormat":2,"textEdit":{"range":{"start":{"line":16,"character":1},"end":{"line":16,"character":7}},"newText":"printer"},"additionalTextEdits":[{"range":{"start":{"line":7,"character":0},"end":{"line":7,"character":0}},"newText":"\nimport \"go/printer\"\n"}]},{"label":"proto","kind":9,"detail":"\"github.com/golang/protobuf/proto\"","sortText":"00003","filterText":"proto","insertTextFormat":2,"textEdit":{"range":{"start":{"line":16,"character":1},"end":{"line":16,"character":7}},"newText":"proto"},"additionalTextEdits":[{"range":{"start":{"line":7,"character":0},"end":{"line":7,"character":0}},"newText":"\nimport \"github.com/golang/protobuf/proto\"\n"}]},{"label":"proto","kind":9,"detail":"\"google.golang.org/grpc/examples/features/proto\"","sortText":"00004","filterText":"proto","insertTextFormat":2,"textEdit":{"range":{"start":{"line":16,"character":1},"end":{"line":16,"character":7}},"newText":"proto"},"additionalTextEdits":[{"range":{"start":{"line":7,"character":0},"end":{"line":7,"character":0}},"newText":"\nimport \"google.golang.org/grpc/examples/features/proto\"\n"}]},{"label":"proto3_proto","kind":9,"detail":"\"github.com/golang/protobuf/proto/proto3_proto\"","sortText":"00005","filterText":"proto3_proto","insertTextFormat":2,"textEdit":{"range":{"start":{"line":16,"character":1},"end":{"line":16,"character":7}},"newText":"proto3_proto"},"additionalTextEdits":[{"range":{"start":{"line":7,"character":0},"end":{"line":7,"character":0}},"newText":"\nimport \"github.com/golang/protobuf/proto/proto3_proto\"\n"}]},{"label":"proxy","kind":9,"detail":"\"golang.org/x/net/proxy\"","sortText":"00006","filterText":"proxy","insertTextFormat":2,"textEdit":{"range":{"start":{"line":16,"character":1},"end":{"line":16,"character":7}},"newText":"proxy"},"additionalTextEdits":[{"range":{"start":{"line":7,"character":0},"end":{"line":7,"character":0}},"newText":"\nimport \"golang.org/x/net/proxy\"\n"}]},{"label":"DefaultUserPrefs","kind":3,"detail":"func() []language.Tag","documentation":"DefaultUserPrefs returns the default user language preferences.\nIt consults the $LC_ALL, $LC_MESSAGES, and $LANG environment\nvariables, in that order.\n","sortText":"00007","filterText":"DefaultUserPrefs","insertTextFormat":2,"textEdit":{"range":{"start":{"line":16,"character":1},"end":{"line":16,"character":7}},"newText":"DefaultUserPrefs()"}}]}

I will transfer this to the gopls repo.

@hyangah hyangah changed the title When accepting auto-completion, the suggestion is replaced over the current word (including the part after the cursor) x/tools/gopls: When accepting auto-completion, the suggestion is replaced over the current word (including the part after the cursor) Nov 16, 2020
@hyangah hyangah transferred this issue from golang/vscode-go Nov 16, 2020
@gopherbot gopherbot added this to the Unreleased milestone Nov 16, 2020
@stamblerre stamblerre changed the title x/tools/gopls: When accepting auto-completion, the suggestion is replaced over the current word (including the part after the cursor) x/tools/gopls: autocompletion overriding content Nov 16, 2020
@muirdm
Copy link

@muirdm muirdm commented Nov 21, 2020

I think this is a dupe of #40871.

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Nov 21, 2020

Duplicate of #40871

@stamblerre stamblerre marked this as a duplicate of #40871 Nov 21, 2020
@stamblerre stamblerre closed this Nov 21, 2020
@stamblerre stamblerre removed this from the gopls/unplanned milestone Nov 22, 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
5 participants
You can’t perform that action at this time.