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: unused completions after "." ".." or "........" #37358

Closed
netjune opened this issue Feb 21, 2020 · 9 comments
Closed

x/tools/gopls: unused completions after "." ".." or "........" #37358

netjune opened this issue Feb 21, 2020 · 9 comments
Labels
Milestone

Comments

@netjune
Copy link

@netjune netjune commented Feb 21, 2020

example code:

package "main"

main () {
    .|
}

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

1.13.5

Does this issue reproduce with the latest release?

Yes

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

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/jun/Library/Caches/go-build"
GOENV="/Users/jun/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/jun/Projects/go"
GOPRIVATE=""
GOPROXY="https://goproxy.io,direct"
GOROOT="/usr/local/Cellar/go/1.13.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.13.5/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/jun/Projects/go/src/golang.org/x/tools/gopls/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 -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/yl/0xyrgw396fj89vd1n2vk649c0000gn/T/go-build115939707=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

What did you expect to see?

What did you see instead?

@gopherbot gopherbot added the gopls label Feb 21, 2020
@stamblerre stamblerre changed the title gopls: unused completions after "." ".." or "........" x/tools/gopls: unused completions after "." ".." or "........" Feb 21, 2020
@gopherbot gopherbot added this to the Unreleased milestone Feb 21, 2020
@gopherbot gopherbot added the Tools label Feb 21, 2020
@golang golang deleted a comment from gopherbot Feb 21, 2020
@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented Feb 21, 2020

/cc @muirdm

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v1.0.0 Feb 21, 2020
@muirdm
Copy link

@muirdm muirdm commented Feb 21, 2020

I can guess what the issue is about, but it would still be helpful to answer the issue template questions.

"." alone is a syntax error so gopls falls back to lexical completions. This case is more noticeable than others since "." triggers completions in most editors. However, for example, triggering completions after a lone "(" results in the same thing:

package "main"
main () {
    (
}
@netjune
Copy link
Author

@netjune netjune commented Feb 22, 2020

I can guess what the issue is about, but it would still be helpful to answer the issue template questions.

Sorry for my poor English. It happens mainly in the following case:

pkt := append(pkt, buf[:cnt]...|)

Cursor is at '|'.

"." alone is a syntax error so gopls falls back to lexical completions. This case is more noticeable than others since "." triggers completions in most editors. However, for example, triggering completions after a lone "(" results in the same thing:

package "main"
main () {
    (
}

This doesn't popups completion menu here(emacs+lsp-mode).

@netjune
Copy link
Author

@netjune netjune commented Feb 22, 2020

Another related issue:

package "main"
main () {
}

aaaaaa|

Cursor is at "|". There are many completion items. And they don't have prefix "aaaaaa".

@muirdm
Copy link

@muirdm muirdm commented Feb 22, 2020

This doesn't popups completion menu here(emacs+lsp-mode).

Run (company-manual-begin) to trigger a completion. "." is a character that triggers completions automatically.

Cursor is at "|". There are many completion items. And they don't have prefix "aaaaaa".

That is a separate issue and is actually fixed on master. Completions at the file level scope are special (only keywords are allowed).

@netjune
Copy link
Author

@netjune netjune commented Feb 22, 2020

This doesn't popups completion menu here(emacs+lsp-mode).

Run (company-manual-begin) to trigger a completion. "." is a character that triggers completions automatically.

Yes.

Cursor is at "|". There are many completion items. And they don't have prefix "aaaaaa".

That is a separate issue and is actually fixed on master. Completions at the file level scope are special (only keywords are allowed).

Thanks.

@muirdm
Copy link

@muirdm muirdm commented Feb 23, 2020

It happens mainly in the following case:
pkt := append(pkt, buf[:cnt]...|)

My first reaction is that this is an editor bug. Editors should not trigger completion after multiple ".", only after a single one. That being said, VSCode seems to also pop up completions automatically after "...", so perhaps it is worth suppressing completions when the cursor is directly after the "...". @stamblerre what do you think?

@zikaeroh
Copy link
Contributor

@zikaeroh zikaeroh commented Feb 23, 2020

I don't think it's unusual for the editor to do completions like that, given you declare that it should send completions so after a . (with no other qualifier).

If I were typing . or .., a completion of ... would be handy in specific contexts, and there are probably other languages out there which would want similar things. An immediate example that's not exactly a . would be in C++ where you may declare to the client the intent to complete after : in order to get completions for namespaces after ::. Not triggering for repeats would prevent that sort of completion.

I'd personally suppress after ....

@gopherbot
Copy link

@gopherbot gopherbot commented Mar 6, 2020

Change https://golang.org/cl/222200 mentions this issue: internal/lsp/source: suppress completions in ellipsis

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.