-
Notifications
You must be signed in to change notification settings - Fork 646
Format on save doesn't work anymore #1419
Comments
Can you try
Remember that Workspace Settings will override Global/User Settings. Can you also try on a smaller package separately? |
Hi, tried above setting on 2 different computer (windows and linux) with multiple size projects including very small ones. still no luck. |
Actually, now I notice, other facilities such as automatically arranging imports, go to definition etc don't work either. Here is my global settings file (there is no workspace specific setting) // Place your settings in this file to overwrite the default settings
{
"go.lintTool": "gometalinter",
"git.confirmSync": false,
"extensions.ignoreRecommendations": true,
"workbench.startupEditor": "newUntitledFile",
"git.autofetch": true,
"[go]": {
"editor.formatOnSave": true
}
} |
Release notes say Output on VS CODE only shows that Using MacOS |
Does manual formatting work? |
It does, yes. |
Same here. Running
looking at the output console there is no
NOTE: uninstalled and installed 0.6.69 from VSIX and it's working again |
Ok, then it's the case of formatter taking more time than 750ms. I am currently on vacation. A few things you can do
|
Ok thanks. I'm not convinced it's the 750ms issue though because even a very simple hello world can't be formatted on my computer. Have a nice vacation. |
I'm also having this issue all of a sudden. No formatting or goimports being run. |
@philipithomas had to revert to 0.6.69 like @ramya-rao-a suggested. |
@esinek manual formatting shldnt be affected. I don't recall the keyboard shortcut in Mac for formatting. Can you try the formatting cmd from the cmd pallet or right click on editor and choose "format document" @tapir That does sound suspicious. Can you drop a few console.log() statements in the file "$HOME/.vscode/extensions/lukehoban.go-0.6.70/out/src/goFormat.js" and see if formatting provider is being called?
|
Also missing go.formatOnSave which was fine until I had a variable name collision with some package which gets automatically imported :(
UpdateFixed it changing settings to:
|
here only |
I have the same problem. Neither "go.formatTool": "gofmt" work all of a sudden. Installing 0.6.69 fixed the problem. @ramya-rao-a Keep up the good work! Please don't interrupt your well deserved vacation as there is a workaround. |
This is the same behaviour I am seeing: I too am on vacation so no real rush, just thought a little more info may help. Enjoy the holidays. |
On my environment, formatting on save does not work when problems of linter are too much (exceed the max num of the problems (>100?)). Can I increase the max num of problems like |
Strangely started working on my Linux computer. Did nothing or maybe I've updated the whole VSCode package (that I'm not sure as I did not pay attention to what's in the update) Windows computer is still not working with the latest version of VSCode |
@egorovli The reason for what you are seeing is explained in #613 (comment) @iwaseyusuke The formatting tool does not depend on what the linter does. The format on save feature however is aborted when formatting takes more than 750ms. @tapir Did you use the same codebase on Linux and Windows for comparison? It could be that the formatting tool is slower in Windows when compared to Linux? Also, did you get a chance to follow the steps in #1419 (comment) and get some logging on the time taken by formatting? @nathj07 Adding/removing of imports just from std lib and not from GOPATH seems unrelated to this issue. Does the same happen when you are on the 0.6.69 version of the Go extension? See #1419 (comment) for instructions on reverting to 0.6.69. |
@ramya-rao-a Thanks! Indeed the file failed to format have too many lines. Can we increase the value of timeout (750ms)? |
@ramya-rao-a I have rolled back the extension, that was a simple process thanks for that. It has indeed worked. Thanks for your help. |
@nathj07 Can you log a separate issue for the adding/removing of imports working only for std lib in the latest version with a sample code that I can use to repro? |
@ramya-rao-a done - #1427 the code I added reproduces what I've been seeing. Thanks for the help. |
Here is the requested change and it's result after a save in Go workspace: https://imgur.com/a/N4UfX For people who doesn't want to look to the screenshot |
@tapir Add a Others on 0.6.70 version and not getting the format on save feature, |
Re-instelled the extension and everything works again. Don't know why I didn't try that before... |
@tapir In your case, the issue turned out to be extension activation failure. Meaning, none of the extension features worked But many others here are seeing features line lint/vet work, but not format on save. So there is still an issue here that I cannot repro. @iwaseyusuke Can you consistently repro the format on save feature not working on larger projects, and it works on smaller projects? It will help if any of the others having the format on save issue in 0.6.70 version of the Go extension can follow the instructions in #1419 (comment) and share if indeed the formatting is taking more than 750ms. |
@ramya-rao-a if I manually trigger a format, i see time taken to format printed. |
@kaixianghu Thanks for the extra information about auto-save. Now I can repro!! Can you try disabling the auto-save feature and then seeing if the formatter is being called on manual file save? Others, |
@ramya-rao-a , disabled auto-save feature, manually saving the file does trigger auto-format. |
@ramya-rao-a I haven't enable auto-save and reinstall Go extension resolved my problem. |
@ramya-rao-a Sorry for the delay. Yes, I could reproduce this issue consistently with the large file (over 8000 lines in a single file):
With the file which has about 4000 lines:
Also, when succeeded to format:
Hmmm... it might be better to refactor and split my codes first... |
@iwaseyusuke I can fix the issue of the formatting tool erroring with the max buffer issue. Are the numbers 1925 and 47 the time taken? |
@ramya-rao-a Yes, I just followed your comments and got the outputs of console. |
Ok, so far there are 4 categories I see forming
Anybody seeing anything other than the above 4? |
I had the issue of goreturns taking too long to update, which worked perfectly well before I updated this week. "go.formatTool": "gofmt" works though. |
I have an issue where autosave doesn't format but issuing the "format document" command manually works. I have files.autoSave, as off, it doesn't look like the 750ms issue (the files are short, and doing it manually is very responsive). It is linting, building and vetting on save, just not formatting. I'm running vscode 1.19.3, and go extention 0.6.73 |
[Extension Host] Formatting took too long(1406ms). Format On Save feature could be aborted. |
@mlitvin Do you see similar error like @bofabcd in #1419 (comment) when the formatting on save doesn't work? You will have to open the console via Help -> Toggle Developer Tools -> Console @bofabcd Unfortunately, that is the expected outcome of slow formatters currently |
OK looking at the console I do get the error that it take too long. Sorry. |
Anybody reaching this issue please see #1419 (comment) Closing this issue now, as most of the formatting issues have been addressed. |
I've just noticed that go doesn't automatically format anymore.
I've also noticed that now go.formatOnSave is deprecated hence I'vee switched to editor.formatOnSave: true yet it still doesn't work.
The text was updated successfully, but these errors were encountered: