fables-tales / rubyfmt

Ruby Autoformatter!
MIT License
1.07k stars 50 forks source link

Support user-multilined binary operator chains #402

Closed reese closed 1 year ago

reese commented 1 year ago

Resolves #359

This adds support for user-multilined binary operators. This adds quite a bit of complexity to the format_binary implementation, but I think it's reasonable to make it work the way users would expect. That said, by "the way users would expect," I'm assuming that most folks would assume the operators would all indent on the same level, even when mixing operators (see the fixtures for examples).

That said, there's a totally reasonable argument for not doing it this way, since it somewhat obscures operator precedence, but IMO if a user wants to be explicit, they should probably use parens (and not write it this way in the first place 🤷). Either way, very open to alternatives, because the current implementation is a bit under-specified for particularly complex binaries.