FuelLabs / sway

🌴 Empowering everyone to build reliable and efficient smart contracts.
https://docs.fuel.network/docs/sway/
Apache License 2.0
62.78k stars 5.35k forks source link

`forc fmt` doesn't format when using VS code on macOS #6425

Open partylikeits1983 opened 4 weeks ago

partylikeits1983 commented 4 weeks ago

Related Component

forc-fmt

Problem

When editing a sway file in VS code, saving it, then running forc fmt I get the error:

error: Formatting skipped due to error.
error: The below file is open in an editor and contains unsaved changes.

Even when the file is 100% been saved I still get this error. The only way to fix this error is via reboot.

Steps

1) Open a sway file. 2) edit it in VS code 3) save it. 4) run forc fmt

Possible Solution(s)

Edit this: https://github.com/FuelLabs/sway/blob/a82e954c17751e1664b26b0d98b131c404ac86df/forc-plugins/forc-fmt/src/main.rs#L113

Or add a argument such as --force to override this: https://github.com/FuelLabs/sway/blob/a82e954c17751e1664b26b0d98b131c404ac86df/forc-plugins/forc-fmt/src/main.rs#L152

Notes

No response

Installed components

latest - Update available (9 updates)
fuelup - Up to date
partylikeits1983 commented 4 weeks ago

The issue goes away when you run cargo clean

sdankel commented 3 weeks ago

latest - Update available (9 updates)

This means you should run fuelup update.

I wasn't able to repro the issue. Could you share the output of forc-fmt --version and forc-lsp --version ?