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: formatting introducing bad edits #40800

Closed
Aukstkalnis opened this issue Aug 14, 2020 · 7 comments
Closed

x/tools/gopls: formatting introducing bad edits #40800

Aukstkalnis opened this issue Aug 14, 2020 · 7 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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Milestone

Comments

@Aukstkalnis
Copy link

Please answer these questions before submitting your issue. Thanks!

What version of Go, VS Code & VS Code Go extension are you using?

  • Run go version to get version of Go
    • 1.5
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders
    - 1.48.0 db40434f562994116e5b21c24015a2e40b2504e6
    x64
  • Check your installed extensions to get the version of the VS Code Go extension
    - 0.16.1
  • Run go env to get the go development environment details
    set GO111MODULE=auto
    set GOARCH=386
    set GOHOSTARCH=386
    set GOHOSTOS=windows
    set GOMODCACHE=D:\Projects\Go_Projects\GoPath\pkg\mod
    set GONOPROXY=gitlab.com/Aukstkalnis/go-teltonika/*
    set GONOSUMDB=gitlab.com/Aukstkalnis/go-teltonika/*
    set GOOS=windows
    set GOPATH=D:\Projects\Go_Projects\GoPath
    set GOPROXY=https://proxy.golang.org,direct
    set GOROOT=C:\go
    set GOSUMDB=sum.golang.org
    set GOTOOLDIR=C:\go\pkg\tool\windows_386
    set GCCGO=gccgo
    set GO386=sse2
    set AR=ar
    set CC=gcc
    set CXX=g++
    set CGO_ENABLED=1
    set CGO_CFLAGS=-g -O2
    set CGO_CXXFLAGS=-g -O2
    set CGO_FFLAGS=-g -O2
    set CGO_LDFLAGS=-g -O2
    set PKG_CONFIG=pkg-config
    set GOGCCFLAGS=-m32 -mthreads -fmessage-length=0 -fdebug-prefix-map=D:\Temp\go-build110131278=/tmp/go-build -gno-record-gcc-switches

Share the Go related settings you have added/edited

"go.docsTool": "guru",
"go.vetOnSave": "off",
"go.formatTool": "gofmt",
"go.autocompleteUnimportedPackages": true,
"go.buildOnSave": "off",
"go.useLanguageServer": true,

Describe the bug

When I save file, some unexpected text is added.

Steps to reproduce the behavior:

I don't know. This sometimes happens in normal code, and today happened in testing file.

Screenshots or recordings

rebase-example

@hyangah
Copy link
Contributor

hyangah commented Aug 14, 2020

@Aukstkalnis Wow, it's bad. It looks like the language server is in bad state. Can you turn on the language server debug tracing and share the trace? Here is the instruction.

The gopls team may need the full trace to inspect how the server ended up in the bad state.

/cc @stamblerre

@stamblerre stamblerre transferred this issue from golang/vscode-go Aug 14, 2020
@stamblerre stamblerre changed the title BUG: Saving file adds unknown text x/tools/gopls: formatting introducing bad edits Aug 14, 2020
@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 14, 2020
@gopherbot gopherbot added this to the Unreleased milestone Aug 14, 2020
@stamblerre stamblerre modified the milestones: Unreleased, gopls/v.0.4.5 Aug 14, 2020
@stamblerre
Copy link
Contributor

Thanks for the report - transferred this to the gopls issue tracker. The logs will be critical to investigating this issue, but you can also please provide your gopls version. If it is not v0.4.4, please update by opening the Command Palette (Ctrl + Shift + P) -> Go: Install/Updated Tools and selecting gopls.

@stamblerre stamblerre added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Aug 15, 2020
@Aukstkalnis
Copy link
Author

I am using v0.4.4. I made some log while editing the code by removing that pasted text after saving and saving again, and adding some text and saving again. Hope it will help. For me it is easy to to reproduce this problem. So if you need to test something just name it :)

gopls_log.zip

@heschi
Copy link
Contributor

heschi commented Aug 19, 2020

I suspect the issue is related to line endings somehow. gopls is sending a giant edit for organize imports.

Result: [{"title":"Organize Imports",
"kind":"source.organizeImports",
"edit":{"documentChanges":[{"textDocument":{"version":138,
"uri":"file:///D:/Projects/Go_Projects/go-teltonika/avl/tcp_packet_test.go"},
"edits":[{"range":{"start":{"line":0,
"character":11},
"end":{"line":0,
"character":12}},
"newText":""},
{"range":{"start":{"line":1,
"character":0},
"end":{"line":1,
"character":1}},
"newText":""},
{"range":{"start":{"line":2,
"character":8},
"end":{"line":2,
"character":9}},
"newText":""},
{"range":{"start":{"line":3,
"character":6},
"end":{"line":3,
"character":7}},
"newText":""},
{"range":{"start":{"line":4,
"character":10},
"end":{"line":4,
"character":11}},
"newText":""},
{"range":{"start":{"line":5,
"character":10},
"end":{"line":5,
"character":11}},
"newText":""},
{"range":{"start":{"line":6,
"character":1},
"end":{"line":6,
"character":2}},
"newText":""},
{"range":{"start":{"line":7,
"character":0},
"end":{"line":7,
"character":1}},
"newText":""},
{"range":{"start":{"line":8,
"character":2},
"end":{"line":8,
"character":3}},
"newText":""},
{"range":{"start":{"line":9,
"character":34},
"end":{"line":9,
"character":35}},
"newText":""},
{"range":{"start":{"line":10,
"character":23},
"end":{"line":10,
"character":24}},
"newText":""},
{"range":{"start":{"line":11,
"character":18},
"end":{"line":11,
"character":19}},
"newText":""},
{"range":{"start":{"line":12,
"character":11},
"end":{"line":12,
"character":12}},
"newText":""},
{"range":{"start":{"line":13,
"character":3},
"end":{"line":13,
"character":4}},
"newText":""},
{"range":{"start":{"line":14,
"character":291},
"end":{"line":14,
"character":292}},
"newText":""},
{"range":{"start":{"line":15,
"character":293},
"end":{"line":15,
"character":294}},
"newText":""},
{"range":{"start":{"line":16,
"character":4},
"end":{"line":16,
"character":5}},
"newText":""},
{"range":{"start":{"line":17,
"character":291},
"end":{"line":17,
"character":292}},
"newText":""},
{"range":{"start":{"line":18,
"character":293},
"end":{"line":18,
"character":294}},
"newText":""},
{"range":{"start":{"line":19,
"character":4},
"end":{"line":19,
"character":5}},
"newText":""},
{"range":{"start":{"line":20,
"character":2},
"end":{"line":20,
"character":3}},
"newText":""},
{"range":{"start":{"line":21,
"character":10},
"end":{"line":21,
"character":11}},
"newText":""},
{"range":{"start":{"line":22,
"character":18},
"end":{"line":22,
"character":19}},
"newText":""},
{"range":{"start":{"line":23,
"character":29},
"end":{"line":23,
"character":30}},
"newText":""},
{"range":{"start":{"line":24,
"character":34},
"end":{"line":24,
"character":35}},
"newText":""},
{"range":{"start":{"line":25,
"character":17},
"end":{"line":25,
"character":18}},
"newText":""},
{"range":{"start":{"line":26,
"character":56},
"end":{"line":26,
"character":57}},
"newText":""},
{"range":{"start":{"line":27,
"character":11},
"end":{"line":27,
"character":12}},
"newText":""},
{"range":{"start":{"line":28,
"character":3},
"end":{"line":28,
"character":4}},
"newText":""},
{"range":{"start":{"line":29,
"character":27},
"end":{"line":29,
"character":28}},
"newText":""},
{"range":{"start":{"line":30,
"character":94},
"end":{"line":30,
"character":95}},
"newText":""},
{"range":{"start":{"line":31,
"character":11},
"end":{"line":31,
"character":12}},
"newText":""},
{"range":{"start":{"line":32,
"character":3},
"end":{"line":32,
"character":4}},
"newText":""},
{"range":{"start":{"line":33,
"character":41},
"end":{"line":33,
"character":42}},
"newText":""},
{"range":{"start":{"line":34,
"character":93},
"end":{"line":34,
"character":94}},
"newText":""},
{"range":{"start":{"line":35,
"character":11},
"end":{"line":35,
"character":12}},
"newText":""},
{"range":{"start":{"line":36,
"character":3},
"end":{"line":36,
"character":4}},
"newText":""},
{"range":{"start":{"line":37,
"character":44},
"end":{"line":37,
"character":45}},
"newText":""},
{"range":{"start":{"line":38,
"character":119},
"end":{"line":38,
"character":120}},
"newText":""},
{"range":{"start":{"line":39,
"character":11},
"end":{"line":39,
"character":12}},
"newText":""},
{"range":{"start":{"line":40,
"character":3},
"end":{"line":40,
"character":4}},
"newText":""},
{"range":{"start":{"line":41,
"character":39},
"end":{"line":41,
"character":40}},
"newText":""},
{"range":{"start":{"line":42,
"character":46},
"end":{"line":42,
"character":47}},
"newText":""},
{"range":{"start":{"line":43,
"character":121},
"end":{"line":43,
"character":122}},
"newText":""},
{"range":{"start":{"line":44,
"character":22},
"end":{"line":44,
"character":23}},
"newText":""},
{"range":{"start":{"line":45,
"character":4},
"end":{"line":45,
"character":5}},
"newText":""},
{"range":{"start":{"line":46,
"character":3},
"end":{"line":46,
"character":4}},
"newText":""},
{"range":{"start":{"line":47,
"character":25},
"end":{"line":47,
"character":26}},
"newText":""},
{"range":{"start":{"line":48,
"character":83},
"end":{"line":48,
"character":84}},
"newText":""},
{"range":{"start":{"line":49,
"character":11},
"end":{"line":49,
"character":12}},
"newText":""},
{"range":{"start":{"line":50,
"character":3},
"end":{"line":50,
"character":4}},
"newText":""},
{"range":{"start":{"line":51,
"character":2},
"end":{"line":51,
"character":3}},
"newText":""},
{"range":{"start":{"line":52,
"character":1},
"end":{"line":52,
"character":2}},
"newText":""},
{"range":{"start":{"line":53,
"character":0},
"end":{"line":53,
"character":1}},
"newText":""},
{"range":{"start":{"line":54,
"character":34},
"end":{"line":54,
"character":35}},
"newText":""},
{"range":{"start":{"line":55,
"character":21},
"end":{"line":55,
"character":22}},
"newText":""},
{"range":{"start":{"line":56,
"character":23},
"end":{"line":56,
"character":24}},
"newText":""},
{"range":{"start":{"line":57,
"character":21},
"end":{"line":57,
"character":22}},
"newText":""},
{"range":{"start":{"line":58,
"character":23},
"end":{"line":58,
"character":24}},
"newText":""},
{"range":{"start":{"line":59,
"character":26},
"end":{"line":59,
"character":27}},
"newText":""},
{"range":{"start":{"line":60,
"character":17},
"end":{"line":60,
"character":17}},
"newText":"TCP(dataNew)\n\tif err != nil {\n\t\tt.Error(err)\n\t}\n}*/"}]}]}}]

Note that there's one edit per line, plausibly at the end, removing one character from each. We've had problems like this in the past, but I thought we'd fixed them.

@heschi
Copy link
Contributor

heschi commented Aug 19, 2020

@Aukstkalnis can you check that you don't have any extensions installed that might be changing the file in ways that conflict with gopls?

@heschi
Copy link
Contributor

heschi commented Aug 19, 2020

Never mind, this is probably a dupe of #40355, the fix for which has not yet been released. You can wait for the next release, or use the master version of gopls.

@stamblerre
Copy link
Contributor

Duplicate of #40355

@stamblerre stamblerre marked this as a duplicate of #40355 Aug 26, 2020
@golang golang locked and limited conversation to collaborators Aug 26, 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. WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants