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: first change check is broken #40531

Closed
tennashi opened this issue Aug 2, 2020 · 2 comments
Closed

x/tools/gopls: first change check is broken #40531

tennashi opened this issue Aug 2, 2020 · 2 comments
Labels
FrozenDueToAge gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@tennashi
Copy link

tennashi commented Aug 2, 2020

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

$ go version
go version go1.14.4 linux/amd64

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
tennashi@pon-home ~/c/s/g/g/t/gopls (master)> go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/tennashi/.cache/go-build"
GOENV="/home/tennashi/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/tennashi/code"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/home/tennashi/.asdf/installs/golang/1.14.4/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/home/tennashi/.asdf/installs/golang/1.14.4/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/home/tennashi/code/src/github.com/golang/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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build167933104=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I edited the file to match this regular expression.

What did you expect to see?

This notification is sent to the LSP client (I use vim-lsp) only on the first edit.

What did you see instead?

It was never sent.

The following patch should fix it.

diff --git a/internal/lsp/text_synchronization.go b/internal/lsp/text_synchronization.go
index 7fc4161a..d516775f 100644
--- a/internal/lsp/text_synchronization.go
+++ b/internal/lsp/text_synchronization.go
@@ -151,7 +151,9 @@ func (s *Server) didChange(ctx context.Context, params *protocol.DidChangeTextDo
                }); err != nil {
                        return err
                }
+               s.changedFiles[uri] = struct{}{}
        }
+
        return nil
 }

@@ -347,7 +349,7 @@ func (s *Server) wasFirstChange(uri span.URI) bool {
                s.changedFiles = make(map[span.URI]struct{})
        }
        _, ok := s.changedFiles[uri]
-       return ok
+       return !ok
 }

 func (s *Server) changedText(ctx context.Context, uri span.URI, changes []protocol.TextDocumentContentChangeEvent) ([]byte, error) {
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Aug 2, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 2, 2020
@stamblerre
Copy link
Contributor

Thanks for catching this! Please feel free to send your patch as a contribution.

@stamblerre stamblerre modified the milestones: Unreleased, gopls/v.0.4.5 Aug 4, 2020
@stamblerre stamblerre changed the title x/tools/gopls: The check for being the first change is not working well x/tools/gopls: first change check is broken Aug 4, 2020
@gopherbot
Copy link

Change https://golang.org/cl/247118 mentions this issue: internal/lsp: fix the first change check

@golang golang locked and limited conversation to collaborators Aug 6, 2021
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. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

3 participants