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: zero-effect deltas returned in response to textDocument/formatting #31119

Closed
myitcv opened this issue Mar 28, 2019 · 1 comment
Labels
Documentation FrozenDueToAge gopls Issues related to the Go language server, gopls.
Milestone

Comments

@myitcv
Copy link
Member

myitcv commented Mar 28, 2019

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

$ go version
go version go1.12.1 linux/amd64
$ go list -m golang.org/x/tools
golang.org/x/tools v0.0.0-20190328030505-8f05a32dce9f

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/.bin"
GOCACHE="/home/myitcv/.cache/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/myitcv/gostuff"
GOPROXY=""
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-build709084862=/tmp/go-build -gno-record-gcc-switches"

What did you do?

Call textDocument/formatting to format the following:

package govim

const ( x = 5
)

What did you expect to see?

A []TextEdit result that only contains non-zero-effect deltas.

What did you see instead?

A []TextEdit result that contained one zero-effect delta:

[]protocol.TextEdit{
    {
        Range: protocol.Range{
            Start: protocol.Position{Line:2, Character:0},
            End:   protocol.Position{Line:3, Character:0},
        },
        NewText: "",
    },
    {
        Range: protocol.Range{
            Start: protocol.Position{Line:3, Character:0},
            End:   protocol.Position{Line:4, Character:0},
        },
        NewText: "",
    },
    {
        Range: protocol.Range{
            Start: protocol.Position{Line:4, Character:0},
            End:   protocol.Position{Line:4, Character:0},
        },
        NewText: "const (\n",
    },
    {
        Range: protocol.Range{
            Start: protocol.Position{Line:4, Character:0},
            End:   protocol.Position{Line:4, Character:0},
        },
        NewText: "\tx = 5\n",
    },
    {
        Range: protocol.Range{
            Start: protocol.Position{Line:4, Character:0},
            End:   protocol.Position{Line:4, Character:0},
        },
        NewText: ")\n",
    },
    {
        Range: protocol.Range{
            Start: protocol.Position{Line:4, Character:0},
            End:   protocol.Position{Line:4, Character:0},
        },
        NewText: "",
    },
}

The last TextEdit implies zero delta.

cc @stamblerre

@myitcv myitcv added the gopls Issues related to the Go language server, gopls. label Mar 28, 2019
@gopherbot gopherbot added this to the Unreleased milestone Mar 28, 2019
@myitcv
Copy link
Member Author

myitcv commented Mar 28, 2019

This is my mistake. The last TextEdit is a blank line at the end of the file.

@myitcv myitcv closed this as completed Mar 28, 2019
@golang golang locked and limited conversation to collaborators Mar 27, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge gopls Issues related to the Go language server, gopls.
Projects
None yet
Development

No branches or pull requests

2 participants