Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Line just diapered on [Ctrl + S] #368

Closed
seemsindie opened this issue Jun 21, 2016 · 9 comments
Closed

Line just diapered on [Ctrl + S] #368

seemsindie opened this issue Jun 21, 2016 · 9 comments

Comments

@seemsindie
Copy link

Ok, i don't know if this is about this package, but it happened just after i installed it.
So i found the package, and installed dependencies, and restarted the editor(not full, the button restart now). And when i click Ctrl + S the line goes away, but it's perfectly correct line....
I am going to post gif of this, because i don't believe what is happening to me :)

http://imgur.com/ZahFSS2

@adlangx
Copy link

adlangx commented Jun 22, 2016

I just installed the package as well and I can't seem to change a go file. No matter what I do the lines get undone immediately. Strange.

@adlangx
Copy link

adlangx commented Jun 22, 2016

OK, I figured out my issue. I think its the gofmt tool combining with a VSCode auto save setting
I get the same if I add a few carriage returns and pause before typing code.
I have the following in my user settings.json

"files.autoSave": "afterDelay",
"files.autoSaveDelay": 2500,

1000ms or 1500ms was too fast.

@seemsindie
Copy link
Author

@adlangx That doesn't work for me, still getting deleted... :(

@lukehoban
Copy link
Member

Yes - this is because of the change to turn Format on Save on by default per #253.

It is true that Format on Save and Auto Save interact rather poorly. Since Auto Save is off by default in VS Code, and many Go users expect Format on Save to be on by default based on experience in other Go editors, we decided that was the best set of defaults. There's some discussion of that in issue, and we added this to the README documentation:

Note: Users may want to consider turning Auto Save on in Visual Studio Code ("files.autoSave": "afterDelay") when using this extension. Many of the Go tools work only on saved files, and error reporting will be more interactive with Auto Save turned on. If you do turn Auto Save on, you may also want to turn format-on-save off ("go.formatOnSave": "false"), so that it is not triggered while typing.

You can turn off Auto Save by removing the "files.autosave" setting from your settings, or setting it to "offf".

@seemsindie
Copy link
Author

seemsindie commented Jun 28, 2016

Neither of these two solutions works, my line is still getting deleted :)
I tried adding afterDelay and set it to 2500ms, and turning it off, nothing works.

EDIT: It's seems like trivial bug, but it really makes VSCode unusable and not that productive, i have to turn on some other editor to save the file...

@ramya-rao-a
Copy link
Contributor

@seemsindie Do you still have this issue? Can you give an example of a line of code that gets deleted for you? Is it packages that have been imported but not used yet? Or blank lines?

@joelsinbarba
Copy link

joelsinbarba commented Mar 29, 2017

Had this issue today, it seems like the formatting tool automatically deletes all the lines where you import packages that are not being used, it's a bit annoying when you are addicted to save changes on every line, but you should not import packages without using it in Go anyways.

@ramya-rao-a
Copy link
Contributor

@joelsinbarba You can change the formatting tool being used to gofmt. Just add this line to your user settings:

"go.formatTool": "gofmt"

gofmt does not remove unused imports where as goimports and goreturns do

@mojinfu
Copy link

mojinfu commented Sep 27, 2017

If you don't want vs code to change your code.
Just change user settings like that:
"go.formatTool": "gofuck"

@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 24, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants