Skip to content

:GoErrCheck overwrites my file if it finds syntax error #2661

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

Closed
winkee01 opened this issue Jan 18, 2020 · 3 comments · Fixed by #2667
Closed

:GoErrCheck overwrites my file if it finds syntax error #2661

winkee01 opened this issue Jan 18, 2020 · 3 comments · Fixed by #2667

Comments

@winkee01
Copy link

What did you do? (required: The issue will be closed when not provided)

If the source file has a syntax error, :GoErrorCheck will rewrite my file(buffer) with a default template. I can only ctrl + o to get back to my original file.

What did you expect to happen?

nothing should happen to my file, except it display the corresponding error info on the bottom.

What happened instead?

my file is overwritten, everything is gone.

err01

err02

Configuration (MUST fill this out):

default

vim-go version:

latest

vimrc you used to reproduce (use a minimal vimrc with other plugins disabled; do not link to a 2,000 line vimrc):

vimrc

Vim version (first three lines from :version):

8.2

Go version (go version):

go version go1.13.3 darwin/amd64

Go environment

go env Output:

gopls version

gopls version Output:golang.org/x/tools/gopls 0.2.2 golang.org/x/tools/[email protected] h1:ujGisyytgY1VGcmd66wIJ9+wVAfmodXj6daHM43HRXk=

bhcleek added a commit to bhcleek/vim-go that referenced this issue Jan 18, 2020
@bhcleek
Copy link
Collaborator

bhcleek commented Jan 18, 2020

You should be able to reload the file; nothing is actually lost.

@winkee01
Copy link
Author

Yes, I can get back by ctrol-o. But it loads a new file to take up my current window, isn't it weird? It can show error info on the bottom, but nothing should happen to my window, right?

@bhcleek
Copy link
Collaborator

bhcleek commented Jan 19, 2020

Yes, what you've reported is indeed a bug due to the handling of errcheck's return code. There's an open PR that fixes the behavior you reported.

You can also execute :e # get back to the buffer. Until ##2667 is merged, I'd advise you to run :GoBuild before :GoErrCheck to make sure there aren't any syntax errors that affect the package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants