fables-tales / rubyfmt

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

Don't double-indent multiline expressions in binary operations #462

Closed reese closed 7 months ago

reese commented 7 months ago

Now that binary expressions are modeled as breakables, they (correctly) add an indentation level when they split to multiple lines. However, we usually don't actually start that indentation until after the initial LHS expression, so we need to account for this and dedent the LHS to prevent double-indenting.

Before:

{
  a: Foo
      .calculate_stuff / # Too deep!
    2
}

After:

{
  a: Foo
    .calculate_stuff / # Lookin' good
    2
}