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

Adopt formatOnSave changes #540

Closed
jrieken opened this issue Oct 18, 2016 · 16 comments
Closed

Adopt formatOnSave changes #540

jrieken opened this issue Oct 18, 2016 · 16 comments

Comments

@jrieken
Copy link
Member

jrieken commented Oct 18, 2016

Since VS Code now has the editor.formatOnSave-setting and the onWillSaveTextDocument-event, this code should be revisited. I'd recommend to remove it and to rely on the built-in formatOnSave feature or to use the new event. Both will prevent unnecessary fs-operations and reduce the risk for endless write-event-write loops.

See https://code.visualstudio.com/updates#_format-on-save, microsoft/vscode#12449, and microsoft/vscode#239 for more details

@jrieken jrieken changed the title Adopte formatOnSave changes Adopt formatOnSave changes Oct 18, 2016
@ksmithut
Copy link

Can that editor.formatOnSave be applied on a per-language basis? I would love that setting for go, but not for javascript

@ramya-rao-a
Copy link
Contributor

@jrieken In VS Code 1.6 only formatters implementing DocumentRangeFormattingEditProvider get to use the editor.formatOnSave. The Go extension formatter implements DocumentFormattingEditProvider which I see that we are working on for VS Code 1.7

Can you confirm?

@jrieken
Copy link
Member Author

jrieken commented Oct 24, 2016

Yeah - I have fixed a bug for the Oct release that makes sure we honour Document and DocumentRange formatters.

@ramya-rao-a
Copy link
Contributor

great, will wait for the next release then

@thnt
Copy link

thnt commented Nov 10, 2016

I think you should keep go.formatOnSave until microsoft/vscode#13547 has been resolved

@dbudworth
Copy link

agreed on it needing to be a language specific thing.
All go editors format on save as it's expected by the community that you have ran your code through "go fmt"

that is not expected by folks in other languages in general. If I formatted javascript on save, i'd have a lot of really annoyed co-workers.

As it stands, I basically can't use vscode as my go editor as I'm so used to format-on-save that I don't even think of formatting.

And, being a child of the DOS era, I habitually save as I move around looking at files. So having javascript code that I have no intention of changing get reformatted as a side effect of 25 year old muscle memory is kind of a non-starter.

@ramya-rao-a
Copy link
Contributor

Current State: The adoption of editor.formatOnSave was reverted in 0.6.49

@jrieken
Copy link
Member Author

jrieken commented Nov 22, 2016

why?

@ramya-rao-a
Copy link
Contributor

@jrieken editor.formatOnSave saves all files on save. There has been feedback from the community that they prefer formatting just go files on save rather than all files.
Since editor.formatOnSave doesn't add any benefits over go.formatOnSave for the users at the moment, this has been reverted.
If and when we have a way to apply editor settings at file type level, this will be revisited.

@ramya-rao-a
Copy link
Contributor

Now that editor.formatOnSave can be configured per language, we should re-visit this.

Things to do

@ramya-rao-a
Copy link
Contributor

@wader has started looking into this in #1069

@ishanray
Copy link

editor.formatOnSave makes gofmt take almost a second to finish.

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Nov 25, 2017

@ishanray how much time does it take otherwise?

@ishanray
Copy link

@ramya-rao-a Otherwise it takes very less. Almost unnoticeable. I can look into it further if required.

@ramya-rao-a
Copy link
Contributor

That's ok. We cannot rely on the editor.formatOnSave until we figure out the blocking issues with goreturns as described in #540 (comment)

@ramya-rao-a
Copy link
Contributor

The latest update to the Go extension (0.6.70) has adopted the editor.formatOnSave setting

@vscodebot vscodebot bot locked and limited conversation to collaborators Feb 2, 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