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: corrupting file when saving in visual studio code #49465

Open
ThisEndUp opened this issue Nov 8, 2021 · 4 comments
Open

x/tools/gopls: corrupting file when saving in visual studio code #49465

ThisEndUp opened this issue Nov 8, 2021 · 4 comments

Comments

@ThisEndUp
Copy link

@ThisEndUp ThisEndUp commented Nov 8, 2021

This seems to have occurred several years ago (#3027). Obviously fixed and closed, but has come back!

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

$ go version
go version go1.17.3 windows/amd64
gopls is 0.29.0 (as far as I can tell)

visual studio code
Version: 1.62.0 (system setup)
Commit: b3318bc0524af3d74034b8bb8a64df0ccf35549a
Date: 2021-11-03T15:23:01.379Z
Electron: 13.5.1
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19042


Does this issue reproduce with the latest release?

yes, but it failed on previous go (1.17.2) as well and previous vs code, too. I updated both to see if the problem would go away.

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

go env Output
$ go env
set GO111MODULE=
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Richard\AppData\Local\go-build
set GOENV=C:\Users\Richard\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Richard\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Richard\go
set GOPRIVATE=
set GOPROXY=https://proxy.golang.org,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.17.3
set GCCGO=gccgo
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=C:\Local\Dropbox\GoWork\code\learning\go.mod
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\msys64\tmp\go-build1397263953=/tmp/go-build -gno-record-gcc-switches

What did you do?

Made small alteration in go program and used ^S to save. File corrupted -- characters deleted.

Specifically,

  1. Start with program at https://play.golang.org/p/Wqdjy_sIayB
  2. comment out vb := container.NewVBox(list)
  3. add line vb := container.New(layout.NewVBoxLayout(),list)
  4. save result ^S

What did you expect to see?

Just the alterations in the file

// vb := container.NewVBox(list)
vb := container.New(layout.NewVBoxLayout(),list)

(plus "fyne.io/fyne/v2/layout" added to the include section)

What did you see instead?

letters disappeared; see diffs

list --> lit in first line

32,33c32
<       // vb := container.NewVBox(lit)
<       vb := container.New(layout.NewVBoxLayout(),list)
---
>       vb := container.NewVBox(list)

myWindow --> mWindow or yWindow -- see diffs below:

58,59c57,58
<               mWindow.Canvas().Size().Height*(float32(len(data))),
< ))
---
>               myWindow.Canvas().Size().Height*(float32(len(data))),
>       ))
61c60
<       yWindow.ShowAndRun()
---
>       myWindow.ShowAndRun()
@gopherbot gopherbot added this to the Unreleased milestone Nov 8, 2021
@hyangah
Copy link
Contributor

@hyangah hyangah commented Nov 10, 2021

Thanks for the report @ThisEndUp
Sorry that I cannot reproduce the issue from my environment so we need more information about your environment.

  • Follow the instruction here to collect gopls trace, and share the trace captured while you run the repro case.
  • Run gopls -v version command from the integrated terminal and share the output.
  • What is your End Of Line choice? (LF vs CRLF --- see the bottom of the VS Code window)

Loading

@ThisEndUp
Copy link
Author

@ThisEndUp ThisEndUp commented Nov 11, 2021

Thanks for replying. I am attaching a file with the requested data. I had to make a few attempts to reproduce the failure, but since the trace and info were running while I did these, I hope the errant behavior will show up, Let me know if you'd like more information.

Go.Issue.49465.file01.txt

One more thing: looking at the VS Code Extensions | Runtime Status, I see that there is an uncaught error:
Uncaught Errors (1)
write after end

Loading

@findleyr
Copy link
Contributor

@findleyr findleyr commented Nov 19, 2021

I finally got to looking at this a bit. It looks like there may be some edit fighting going on -- could you share your VS Code settings.json. Also, do you have any other extensions that operate on Go code?

Thanks.

Loading

@ThisEndUp
Copy link
Author

@ThisEndUp ThisEndUp commented Nov 24, 2021

Thanks for replying. I won't have access to the computer that was displaying the problem for some months. If you need more from me, I'll have to see if the problem crops up on one of the other computers I'm using, but in the interest of making progress on my project, I've temporarily reverted to a slightly older version of gopls and will wait for a new one to appear before updating again.

Loading

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
4 participants