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: didChange cannot handle multiple incremental changes #32114

Closed
myitcv opened this issue May 17, 2019 · 2 comments
Closed

x/tools/cmd/gopls: didChange cannot handle multiple incremental changes #32114

myitcv opened this issue May 17, 2019 · 2 comments

Comments

@myitcv
Copy link
Member

@myitcv myitcv commented May 17, 2019

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

$ go version
go version go1.12.5 linux/amd64
$ go list -m golang.org/x/tools
golang.org/x/tools v0.0.0-20190517162734-1da8801a9502

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="https://proxy.golang.org/"
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-build590315354=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Starting with the following file:

package blah

// Line 3
// Line 4
// Line 5
// Line 6
// Line 7

Then performing an edit such that the deltas are:

&protocol.DidChangeTextDocumentParams{
    TextDocument: protocol.VersionedTextDocumentIdentifier{
        Version:                1,
        TextDocumentIdentifier: protocol.TextDocumentIdentifier{URI:"file:///home/myitcv/gostuff/src/github.com/myitcv/govim/blah/blah.go"},
    },
    ContentChanges: {
        {
            Range: &protocol.Range{
                Start: protocol.Position{Line:6, Character:0},
                End:   protocol.Position{Line:7, Character:0},
            },
            RangeLength: 0,
            Text:        "// Line \n",
        },
        {
            Range: &protocol.Range{
                Start: protocol.Position{Line:7, Character:0},
                End:   protocol.Position{Line:7, Character:0},
            },
            RangeLength: 0,
            Text:        "7\n",
        },
    },
}

What did you expect to see?

No panic.

What did you see instead?

panic: runtime error: slice bounds out of range

goroutine 19 [running]:
golang.org/x/tools/internal/lsp.(*Server).applyChanges(0xc0001664d0, 0x8f54e0, 0xc0000a6010, 0xc000224030, 0x0, 0x0, 0xc0002de028, 0x16)
      /home/myitcv/gostuff/src/golang.org/x/tools/internal/lsp/text_synchronization.go:92 +0x99f
golang.org/x/tools/internal/lsp.(*Server).didChange(0xc0001664d0, 0x8f54e0, 0xc0000a6010, 0xc000224030, 0x0, 0xc0002de000)
      /home/myitcv/gostuff/src/golang.org/x/tools/internal/lsp/text_synchronization.go:31 +0x25b
golang.org/x/tools/internal/lsp.(*Server).DidChange(0xc0001664d0, 0x8f54e0, 0xc0000a6010, 0xc000224030, 0xc000224030, 0x0)
      /home/myitcv/gostuff/src/golang.org/x/tools/internal/lsp/server.go:140 +0x49
golang.org/x/tools/internal/lsp/protocol.serverHandler.func1(0x8f54e0, 0xc0000a6010, 0xc000166540, 0xc000249de0)
      /home/myitcv/gostuff/src/golang.org/x/tools/internal/lsp/protocol/tsserver.go:114 +0x3134
golang.org/x/tools/internal/jsonrpc2.(*Conn).Run.func1(0xc0000acae0, 0xc000166540)
      /home/myitcv/gostuff/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:276 +0xda
created by golang.org/x/tools/internal/jsonrpc2.(*Conn).Run
      /home/myitcv/gostuff/src/golang.org/x/tools/internal/jsonrpc2/jsonrpc2.go:270 +0xba

It appears that in this loop the content of the column mapper is not updated.


cc @stamblerre @ianthehat

@gopherbot gopherbot added this to the Unreleased milestone May 17, 2019
@gopherbot
Copy link

@gopherbot gopherbot commented May 20, 2019

Change https://golang.org/cl/178157 mentions this issue: internal/lsp: update column mapper with content on incremental changes

@stamblerre
Copy link
Contributor

@stamblerre stamblerre commented May 20, 2019

Thanks for finding the bug in your report!

@golang golang locked and limited conversation to collaborators May 19, 2020
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.