sway
sway copied to clipboard
Chained methods & fields that should be multiline need logic to handle vertical formatting
fuelcoin.really_long_field.other_really_long_field.foo().bar().baz().quux();
should be:
fuelcoin
.really_long_field
.other_really_long_field
.foo()
.bar()
.baz()
.quux();
To elaborate further, this applies only to swayfmt. Logic needs to be added to handle the formatting of Sway code so that chained methods & fields that exceed a certain length (IIRC it's 60 but we are using the rustfmt standard which you can find here) are formatted as multiline chains.
rustfmt has a file dedicated to handling formatting of chains, here.
hey @eureka-cpu, is the issue still open, i'd like to try to solve this issue :))
hey @eureka-cpu, is the issue still open, i'd like to try to solve this issue :))
Please, feel free!
Take a look at how we handle import statements for some general direction
Hey @eureka-cpu, sorry for such a late response but i'm not able to find the issue? Could you please help me out?
Hi @AliJafriETH, I would start by adding a few tests to swayfmt/src/formatter/mod.rs. Then check swayfmt/src/utils/language/expr/mod.rs, you should find everything you need there. Hopefully this clarifies where, but if you still need help feel free to reach out.
Hey @eureka-cpu, thank you so much for the help, I'll update you with the progress :))
Thanks 💯